summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp20
-rw-r--r--korganizer/koeditordetails.cpp2
-rw-r--r--korganizer/koeditorgeneral.cpp9
-rw-r--r--korganizer/koeditorgeneralevent.cpp5
-rw-r--r--korganizer/koeditorgeneraltodo.cpp2
-rw-r--r--korganizer/koeventeditor.cpp6
-rw-r--r--korganizer/koincidenceeditor.cpp2
-rw-r--r--korganizer/kotodoeditor.cpp4
8 files changed, 40 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index c0f3be7..fd026fa 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3472 +1,3486 @@
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#include "categoryeditdialog.h" 119#include "categoryeditdialog.h"
120 120
121#include "calendarview.h" 121#include "calendarview.h"
122#ifndef DESKTOP_VERSION 122#ifndef DESKTOP_VERSION
123#include <qtopia/alarmserver.h> 123#include <qtopia/alarmserver.h>
124#endif 124#endif
125#ifndef _WIN32_ 125#ifndef _WIN32_
126#include <stdlib.h> 126#include <stdlib.h>
127#include <stdio.h> 127#include <stdio.h>
128#include <unistd.h> 128#include <unistd.h>
129#else 129#else
130#include <qprocess.h> 130#include <qprocess.h>
131#endif 131#endif
132 132
133#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
134#include <kabc/stdaddressbook.h> 134#include <kabc/stdaddressbook.h>
135#endif 135#endif
136using namespace KOrg; 136using namespace KOrg;
137using namespace KCal; 137using namespace KCal;
138extern int globalFlagBlockAgenda; 138extern int globalFlagBlockAgenda;
139extern int globalFlagBlockStartup; 139extern int globalFlagBlockStartup;
140 140
141 141
142MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 142MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
143 143
144{ 144{
145 mAlarms = alarms; 145 mAlarms = alarms;
146 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 146 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
147 QString mText = "<table width=\"100%\">\n"; 147 QString mText = "<table width=\"100%\">\n";
148 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 148 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
149#ifdef DESKTOP_VERSION 149#ifdef DESKTOP_VERSION
150 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 150 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
151#else 151#else
152 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 152 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
153#endif 153#endif
154 // mText += "<img src=\""; 154 // mText += "<img src=\"";
155 // mText += ipath; 155 // mText += ipath;
156 // mText += "\">"; 156 // mText += "\">";
157 //mEventDate = QDate::currentDate(); 157 //mEventDate = QDate::currentDate();
158#ifdef DESKTOP_VERSION 158#ifdef DESKTOP_VERSION
159 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 159 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
160#else 160#else
161 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 161 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
162#endif 162#endif
163 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 163 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
164 164
165 Incidence * inc = getNextInc( start ); 165 Incidence * inc = getNextInc( start );
166 int time = 0; 166 int time = 0;
167 //mText += "<table>"; 167 //mText += "<table>";
168 while ( inc ) { 168 while ( inc ) {
169 QDateTime dt ; 169 QDateTime dt ;
170 QString tempText = "<a "; 170 QString tempText = "<a ";
171 bool ok; 171 bool ok;
172 dt = inc->getNextOccurence( start, &ok ); 172 dt = inc->getNextOccurence( start, &ok );
173 if ( !ok ) continue; 173 if ( !ok ) continue;
174 if ( inc->typeID() == eventID ) { 174 if ( inc->typeID() == eventID ) {
175 tempText += "href=\"event:"; 175 tempText += "href=\"event:";
176 } else if ( inc->typeID() == todoID ) { 176 } else if ( inc->typeID() == todoID ) {
177 tempText += "href=\"todo:"; 177 tempText += "href=\"todo:";
178 } 178 }
179 tempText += inc->uid() + "\">"; 179 tempText += inc->uid() + "\">";
180 if ( inc->typeID() == todoID ) 180 if ( inc->typeID() == todoID )
181 tempText += i18n("Todo: "); 181 tempText += i18n("Todo: ");
182 if ( inc->summary().length() > 0 ) 182 if ( inc->summary().length() > 0 )
183 tempText += inc->summary(); 183 tempText += inc->summary();
184 else 184 else
185 tempText += i18n("-no summary-"); 185 tempText += i18n("-no summary-");
186 QString timestr; 186 QString timestr;
187 if (!inc->doesFloat()) 187 if (!inc->doesFloat())
188 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 188 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
189 else 189 else
190 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 190 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
191 if ( dt.date() < QDate::currentDate() && time == 0 ) { 191 if ( dt.date() < QDate::currentDate() && time == 0 ) {
192 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 192 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
193 mText += "<table>"; 193 mText += "<table>";
194 time = 1; 194 time = 1;
195 } 195 }
196 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 196 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
197 if ( time > 0 ) 197 if ( time > 0 )
198 mText +="</table>"; 198 mText +="</table>";
199 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 199 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
200 mText += "<table>"; 200 mText += "<table>";
201 time = 2; 201 time = 2;
202 202
203 } 203 }
204 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 204 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
205 if ( time > 0 ) 205 if ( time > 0 )
206 mText +="</table>"; 206 mText +="</table>";
207 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 207 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
208 mText += "<table>"; 208 mText += "<table>";
209 time = 3; 209 time = 3;
210 } 210 }
211 mText +="<tr><td><b>"; 211 mText +="<tr><td><b>";
212 mText += timestr; 212 mText += timestr;
213 mText += "</b></td><td>"; 213 mText += "</b></td><td>";
214 mText += tempText; 214 mText += tempText;
215 mText += "</td></tr>\n"; 215 mText += "</td></tr>\n";
216 inc = getNextInc( start ); 216 inc = getNextInc( start );
217 } 217 }
218 mText +="</table>"; 218 mText +="</table>";
219 setText( mText ); 219 setText( mText );
220} 220}
221 221
222MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 222MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
223{ 223{
224 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 224 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
225} 225}
226Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 226Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
227{ 227{
228 QDateTime dt ; 228 QDateTime dt ;
229 Incidence * retInc; 229 Incidence * retInc;
230 Incidence * inc = mAlarms.first(); 230 Incidence * inc = mAlarms.first();
231 if ( inc == 0 ) 231 if ( inc == 0 )
232 return 0; 232 return 0;
233 bool ok; 233 bool ok;
234 dt = inc->getNextOccurence( start, &ok ); 234 dt = inc->getNextOccurence( start, &ok );
235 if ( ! ok ) return 0; 235 if ( ! ok ) return 0;
236 QDateTime dtn ; 236 QDateTime dtn ;
237 retInc = inc; 237 retInc = inc;
238 inc = mAlarms.next(); 238 inc = mAlarms.next();
239 while ( inc ) { 239 while ( inc ) {
240 dtn = inc->getNextOccurence( start, &ok ); 240 dtn = inc->getNextOccurence( start, &ok );
241 if ( ! ok ) return 0; 241 if ( ! ok ) return 0;
242 if ( dtn < dt ) { 242 if ( dtn < dt ) {
243 dt = dtn; 243 dt = dtn;
244 retInc = inc; 244 retInc = inc;
245 } 245 }
246 inc = mAlarms.next(); 246 inc = mAlarms.next();
247 } 247 }
248 mAlarms.remove( retInc ); 248 mAlarms.remove( retInc );
249 return retInc; 249 return retInc;
250 250
251} 251}
252void MissedAlarmTextBrowser::setSource(const QString & n) 252void MissedAlarmTextBrowser::setSource(const QString & n)
253{ 253{
254 if (n.startsWith("event:")) { 254 if (n.startsWith("event:")) {
255#ifdef DESKTOP_VERSION 255#ifdef DESKTOP_VERSION
256 emit showIncidence(n.mid(8)); 256 emit showIncidence(n.mid(8));
257#else 257#else
258 emit showIncidence(n.mid(6)); 258 emit showIncidence(n.mid(6));
259#endif 259#endif
260 return; 260 return;
261 } else if (n.startsWith("todo:")) { 261 } else if (n.startsWith("todo:")) {
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 emit showIncidence(n.mid(7)); 263 emit showIncidence(n.mid(7));
264#else 264#else
265 emit showIncidence(n.mid(5)); 265 emit showIncidence(n.mid(5));
266#endif 266#endif
267 return; 267 return;
268 } 268 }
269} 269}
270 270
271 271
272class KOBeamPrefs : public QDialog 272class KOBeamPrefs : public QDialog
273{ 273{
274 public: 274 public:
275 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 275 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
276 QDialog( parent, name, true ) 276 QDialog( parent, name, true )
277 { 277 {
278 setCaption( i18n("Beam Options") ); 278 setCaption( i18n("Beam Options") );
279 QVBoxLayout* lay = new QVBoxLayout( this ); 279 QVBoxLayout* lay = new QVBoxLayout( this );
280 lay->setSpacing( 3 ); 280 lay->setSpacing( 3 );
281 lay->setMargin( 3 ); 281 lay->setMargin( 3 );
282 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 282 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
283 lay->addWidget( format ); 283 lay->addWidget( format );
284 format->setExclusive ( true ) ; 284 format->setExclusive ( true ) ;
285 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 285 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
286 lay->addWidget( time ); time->setExclusive ( true ) ; 286 lay->addWidget( time ); time->setExclusive ( true ) ;
287 vcal = new QRadioButton(" vCalendar ", format ); 287 vcal = new QRadioButton(" vCalendar ", format );
288 ical = new QRadioButton(" iCalendar ", format ); 288 ical = new QRadioButton(" iCalendar ", format );
289 vcal->setChecked( true ); 289 vcal->setChecked( true );
290 tz = new QRadioButton(i18n(" With timezone "), time ); 290 tz = new QRadioButton(i18n(" With timezone "), time );
291 local = new QRadioButton(i18n(" Local time "), time ); 291 local = new QRadioButton(i18n(" Local time "), time );
292 tz->setChecked( true ); 292 tz->setChecked( true );
293 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 293 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
294 lay->addWidget( ok ); 294 lay->addWidget( ok );
295 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 295 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
296 lay->addWidget( cancel ); 296 lay->addWidget( cancel );
297 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 297 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
298 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 298 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
299 resize( 200, 200 ); 299 resize( 200, 200 );
300 } 300 }
301 301
302 bool beamVcal() { return vcal->isChecked(); } 302 bool beamVcal() { return vcal->isChecked(); }
303 bool beamLocal() { return local->isChecked(); } 303 bool beamLocal() { return local->isChecked(); }
304private: 304private:
305 QRadioButton* vcal, *ical, *local, *tz; 305 QRadioButton* vcal, *ical, *local, *tz;
306}; 306};
307class KOCatPrefs : public QDialog 307class KOCatPrefs : public QDialog
308{ 308{
309 public: 309 public:
310 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 310 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
311 QDialog( parent, name, true ) 311 QDialog( parent, name, true )
312 { 312 {
313 setCaption( i18n("Manage new Categories") ); 313 setCaption( i18n("Manage new Categories") );
314 QVBoxLayout* lay = new QVBoxLayout( this ); 314 QVBoxLayout* lay = new QVBoxLayout( this );
315 lay->setSpacing( 3 ); 315 lay->setSpacing( 3 );
316 lay->setMargin( 3 ); 316 lay->setMargin( 3 );
317 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 317 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
318 lay->addWidget( lab ); 318 lay->addWidget( lab );
319 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 319 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
320 lay->addWidget( format ); 320 lay->addWidget( format );
321 format->setExclusive ( true ) ; 321 format->setExclusive ( true ) ;
322 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 322 addCatBut = new QRadioButton(i18n("Add to category list"), format );
323 new QRadioButton(i18n("Remove from Events/Todos"), format ); 323 new QRadioButton(i18n("Remove from Events/Todos"), format );
324 addCatBut->setChecked( true ); 324 addCatBut->setChecked( true );
325 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 325 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
326 lay->addWidget( ok ); 326 lay->addWidget( ok );
327 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 327 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
328 lay->addWidget( cancel ); 328 lay->addWidget( cancel );
329 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 329 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
330 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 330 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
331 resize( 200, 200 ); 331 resize( 200, 200 );
332 } 332 }
333 333
334 bool addCat() { return addCatBut->isChecked(); } 334 bool addCat() { return addCatBut->isChecked(); }
335private: 335private:
336 QRadioButton* addCatBut; 336 QRadioButton* addCatBut;
337}; 337};
338 338
339 339
340 340
341CalendarView::CalendarView( CalendarResources *calendar, 341CalendarView::CalendarView( CalendarResources *calendar,
342 QWidget *parent, const char *name ) 342 QWidget *parent, const char *name )
343 : CalendarViewBase( parent, name ), 343 : CalendarViewBase( parent, name ),
344 mCalendar( calendar ), 344 mCalendar( calendar ),
345 mResourceManager( calendar->resourceManager() ) 345 mResourceManager( calendar->resourceManager() )
346{ 346{
347 347
348 mEventEditor = 0; 348 mEventEditor = 0;
349 mTodoEditor = 0; 349 mTodoEditor = 0;
350 350
351 init(); 351 init();
352} 352}
353 353
354CalendarView::CalendarView( Calendar *calendar, 354CalendarView::CalendarView( Calendar *calendar,
355 QWidget *parent, const char *name ) 355 QWidget *parent, const char *name )
356 : CalendarViewBase( parent, name ), 356 : CalendarViewBase( parent, name ),
357 mCalendar( calendar ), 357 mCalendar( calendar ),
358 mResourceManager( 0 ) 358 mResourceManager( 0 )
359{ 359{
360 360
361 mEventEditor = 0; 361 mEventEditor = 0;
362 mTodoEditor = 0; 362 mTodoEditor = 0;
363 init(); 363 init();
364} 364}
365 365
366void CalendarView::init() 366void CalendarView::init()
367{ 367{
368 mNextAlarmDateTime = QDateTime::currentDateTime(); 368 mNextAlarmDateTime = QDateTime::currentDateTime();
369 setFocusPolicy ( NoFocus ); 369 setFocusPolicy ( NoFocus );
370 mViewerCallerIsSearchDialog = false; 370 mViewerCallerIsSearchDialog = false;
371 mBlockShowDates = false; 371 mBlockShowDates = false;
372 372
373 mDatePickerMode = 0; 373 mDatePickerMode = 0;
374 mCurrentSyncDevice = ""; 374 mCurrentSyncDevice = "";
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#ifdef DESKTOP_VERSION 449#ifdef DESKTOP_VERSION
450 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); 450 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
451 topLayout->addWidget( mDateScrollBar ); 451 topLayout->addWidget( mDateScrollBar );
452 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 452 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
453 if ( QApplication::desktop()->width() < 800 ) 453 if ( QApplication::desktop()->width() < 800 )
454 mDateScrollBar->hide(); 454 mDateScrollBar->hide();
455#endif 455#endif
456 //mainBoxLayout->addWidget (mLeftFrame); 456 //mainBoxLayout->addWidget (mLeftFrame);
457 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 457 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
458 "CalendarView::DateNavigator" ); 458 "CalendarView::DateNavigator" );
459#if 0 459#if 0
460 // FIXME 460 // FIXME
461 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 461 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
462 "CalendarView::DateNavigator", QDate::currentDate()); 462 "CalendarView::DateNavigator", QDate::currentDate());
463#endif 463#endif
464 // mDateNavigator->blockSignals( true ); 464 // mDateNavigator->blockSignals( true );
465 //leftFrameLayout->addWidget( mDateNavigator ); 465 //leftFrameLayout->addWidget( mDateNavigator );
466 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 466 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
467 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 467 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
468 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 468 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
469 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 469 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
470 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 471 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 474 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
475 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 475 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
478 478
479 mTodoList->setNavigator( mNavigator ); 479 mTodoList->setNavigator( mNavigator );
480#if 0 480#if 0
481 if ( QApplication::desktop()->width() < 480 ) { 481 if ( QApplication::desktop()->width() < 480 ) {
482 leftFrameLayout->addWidget(mFilterView); 482 leftFrameLayout->addWidget(mFilterView);
483 leftFrameLayout->addWidget(mTodoList, 2 ); 483 leftFrameLayout->addWidget(mTodoList, 2 );
484 484
485 } else { 485 } else {
486 leftFrameLayout->addWidget(mTodoList,2 ); 486 leftFrameLayout->addWidget(mTodoList,2 );
487 leftFrameLayout->addWidget(mFilterView ); 487 leftFrameLayout->addWidget(mFilterView );
488 } 488 }
489#endif 489#endif
490 mFilterView->hide(); 490 mFilterView->hide();
491 mCalEditView->hide(); 491 mCalEditView->hide();
492 QWidget *rightBox = new QWidget( mMainFrame ); 492 QWidget *rightBox = new QWidget( mMainFrame );
493 //mainBoxLayout->addWidget ( rightBox, 10 ); 493 //mainBoxLayout->addWidget ( rightBox, 10 );
494 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 494 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
495 mRightFrame = new QWidgetStack( rightBox ); 495 mRightFrame = new QWidgetStack( rightBox );
496 rightLayout->addWidget( mRightFrame, 10 ); 496 rightLayout->addWidget( mRightFrame, 10 );
497 497
498 //mLeftFrame = (QWidget *)leftFrame; 498 //mLeftFrame = (QWidget *)leftFrame;
499 if ( KOPrefs::instance()->mVerticalScreen ) { 499 if ( KOPrefs::instance()->mVerticalScreen ) {
500 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 500 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
501 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 501 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
502 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 503 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
504 } else { 504 } else {
505 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 505 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
506 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 506 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
507 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
508 } 508 }
509 if ( !KOPrefs::instance()->mShowDateNavigator) 509 if ( !KOPrefs::instance()->mShowDateNavigator)
510 mDateNavigator->hide(); 510 mDateNavigator->hide();
511 //qDebug("Calendarview Size %d %d ", width(), height()); 511 //qDebug("Calendarview Size %d %d ", width(), height());
512#endif 512#endif
513 513
514 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 514 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
515 SLOT( showDates( const KCal::DateList & ) ) ); 515 SLOT( showDates( const KCal::DateList & ) ) );
516 516
517 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 517 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
518 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 518 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
519 519
520 520
521 521
522 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 522 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
523 mViewManager, SLOT( showMonth( const QDate & ) ) ); 523 mViewManager, SLOT( showMonth( const QDate & ) ) );
524 524
525 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 525 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
526 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 526 mNavigator, SLOT( selectWeek( const QDate & ) ) );
527 527
528 connect( mDateNavigator, SIGNAL( goPrevYear() ), 528 connect( mDateNavigator, SIGNAL( goPrevYear() ),
529 mNavigator, SLOT( selectPreviousYear() ) ); 529 mNavigator, SLOT( selectPreviousYear() ) );
530 connect( mDateNavigator, SIGNAL( goNextYear() ), 530 connect( mDateNavigator, SIGNAL( goNextYear() ),
531 mNavigator, SLOT( selectNextYear() ) ); 531 mNavigator, SLOT( selectNextYear() ) );
532 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 532 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
533 mNavigator, SLOT( selectPreviousMonth() ) ); 533 mNavigator, SLOT( selectPreviousMonth() ) );
534 connect( mDateNavigator, SIGNAL( goNextMonth() ), 534 connect( mDateNavigator, SIGNAL( goNextMonth() ),
535 mNavigator, SLOT( selectNextMonth() ) ); 535 mNavigator, SLOT( selectNextMonth() ) );
536 536
537 connect( mDateNavigator, SIGNAL( goPrevious() ), 537 connect( mDateNavigator, SIGNAL( goPrevious() ),
538 mNavigator, SLOT( selectPrevious() ) ); 538 mNavigator, SLOT( selectPrevious() ) );
539 connect( mDateNavigator, SIGNAL( goNext() ), 539 connect( mDateNavigator, SIGNAL( goNext() ),
540 mNavigator, SLOT( selectNext() ) ); 540 mNavigator, SLOT( selectNext() ) );
541 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 541 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
542 mNavigator, SLOT( slotMonthSelect( int ) ) ); 542 mNavigator, SLOT( slotMonthSelect( int ) ) );
543 543
544 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 544 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
545 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 545 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
546#if 0 546#if 0
547 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 547 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
548 SLOT( incidenceAdded( Incidence *) ) ); 548 SLOT( incidenceAdded( Incidence *) ) );
549#endif 549#endif
550 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 550 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
551 551
552 connect( this, SIGNAL( configChanged() ), 552 connect( this, SIGNAL( configChanged() ),
553 mDateNavigator, SLOT( updateConfig() ) ); 553 mDateNavigator, SLOT( updateConfig() ) );
554 554
555 connect( mTodoList, SIGNAL( newTodoSignal() ), 555 connect( mTodoList, SIGNAL( newTodoSignal() ),
556 SLOT( newTodo() ) ); 556 SLOT( newTodo() ) );
557 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 557 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
558 SLOT( newSubTodo( Todo * ) ) ); 558 SLOT( newSubTodo( Todo * ) ) );
559 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 559 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
560 SLOT( editTodo( Todo * ) ) ); 560 SLOT( editTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
562 SLOT( showTodo( Todo *) ) ); 562 SLOT( showTodo( Todo *) ) );
563 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 563 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
564 SLOT( deleteTodo( Todo *) ) ); 564 SLOT( deleteTodo( Todo *) ) );
565 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 565 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
566 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 566 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
567 SLOT( purgeCompleted() ) ); 567 SLOT( purgeCompleted() ) );
568 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 568 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
569 SIGNAL( todoModified( Todo *, int ) ) ); 569 SIGNAL( todoModified( Todo *, int ) ) );
570 570
571 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 571 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
572 this, SLOT ( cloneIncidence( Incidence * ) ) ); 572 this, SLOT ( cloneIncidence( Incidence * ) ) );
573 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
574 this, SLOT (cancelIncidence( Incidence * ) ) ); 574 this, SLOT (cancelIncidence( Incidence * ) ) );
575 575
576 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 576 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
577 this, SLOT ( moveIncidence( Incidence * ) ) ); 577 this, SLOT ( moveIncidence( Incidence * ) ) );
578 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
579 this, SLOT ( beamIncidence( Incidence * ) ) ); 579 this, SLOT ( beamIncidence( Incidence * ) ) );
580 580
581 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 581 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
582 this, SLOT ( todo_unsub( Todo * ) ) ); 582 this, SLOT ( todo_unsub( Todo * ) ) );
583 583
584 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 584 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
585 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 585 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
586 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 586 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
587 SLOT( updateTodo( Todo *, int ) ) ); 587 SLOT( updateTodo( Todo *, int ) ) );
588 connect( this, SIGNAL( todoModified( Todo *, int )), this, 588 connect( this, SIGNAL( todoModified( Todo *, int )), this,
589 SLOT( changeTodoDisplay( Todo *, int ) ) ); 589 SLOT( changeTodoDisplay( Todo *, int ) ) );
590 590
591 591
592 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 592 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
593 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 593 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
594 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 594 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
595 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 595 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
596 596
597 597
598 598
599 599
600 600
601 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 601 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
602 SLOT(checkClipboard())); 602 SLOT(checkClipboard()));
603 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 603 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
604 SLOT( processTodoListSelection( Incidence * ) ) ); 604 SLOT( processTodoListSelection( Incidence * ) ) );
605 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 605 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
606 606
607 // kdDebug() << "CalendarView::CalendarView() done" << endl; 607 // kdDebug() << "CalendarView::CalendarView() done" << endl;
608 608
609 mDateFrame = new QVBox(0,0,WType_Popup); 609 mDateFrame = new QVBox(0,0,WType_Popup);
610 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 610 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
611 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 611 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
612 mDateFrame->setLineWidth(3); 612 mDateFrame->setLineWidth(3);
613 mDateFrame->hide(); 613 mDateFrame->hide();
614 mDateFrame->setCaption( i18n( "Pick a date to display")); 614 mDateFrame->setCaption( i18n( "Pick a date to display"));
615 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 615 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
616 616
617 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 617 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
618 618
619 mEventEditor = mDialogManager->getEventEditor(); 619 mEventEditor = mDialogManager->getEventEditor();
620 mTodoEditor = mDialogManager->getTodoEditor(); 620 mTodoEditor = mDialogManager->getTodoEditor();
621 621
622 mFlagEditDescription = false; 622 mFlagEditDescription = false;
623 623
624 mSuspendTimer = new QTimer( this ); 624 mSuspendTimer = new QTimer( this );
625 mAlarmTimer = new QTimer( this ); 625 mAlarmTimer = new QTimer( this );
626 mRecheckAlarmTimer = new QTimer( this ); 626 mRecheckAlarmTimer = new QTimer( this );
627 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 627 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
628 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 628 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
629 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 629 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
630 mAlarmDialog = new AlarmDialog( this ); 630 mAlarmDialog = new AlarmDialog( this );
631 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 631 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
632 mAlarmDialog->setServerNotification( false ); 632 mAlarmDialog->setServerNotification( false );
633 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 633 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
634 634
635 635
636#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
637//US listen for arriving address resultsets 637//US listen for arriving address resultsets
638 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 638 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
639 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 639 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
640#endif 640#endif
641 mDateNavigator->setCalendar( mCalendar ); 641 mDateNavigator->setCalendar( mCalendar );
642} 642}
643 643
644 644
645CalendarView::~CalendarView() 645CalendarView::~CalendarView()
646{ 646{
647 // kdDebug() << "~CalendarView()" << endl; 647 // kdDebug() << "~CalendarView()" << endl;
648 //qDebug("CalendarView::~CalendarView() "); 648 //qDebug("CalendarView::~CalendarView() ");
649 delete mDialogManager; 649 delete mDialogManager;
650 delete mViewManager; 650 delete mViewManager;
651 delete mStorage; 651 delete mStorage;
652 delete mDateFrame ; 652 delete mDateFrame ;
653 delete mEventViewerDialog; 653 delete mEventViewerDialog;
654 //kdDebug() << "~CalendarView() done" << endl; 654 //kdDebug() << "~CalendarView() done" << endl;
655} 655}
656void CalendarView::setScrollBarStep(int val ) 656void CalendarView::setScrollBarStep(int val )
657{ 657{
658#ifdef DESKTOP_VERSION 658#ifdef DESKTOP_VERSION
659 mDateScrollBar->setLineStep ( val ); 659 mDateScrollBar->setLineStep ( val );
660#endif 660#endif
661} 661}
662void CalendarView::scrollBarValue(int val ) 662void CalendarView::scrollBarValue(int val )
663{ 663{
664#ifdef DESKTOP_VERSION 664#ifdef DESKTOP_VERSION
665 if ( QApplication::desktop()->width() < 800 ) return; 665 if ( QApplication::desktop()->width() < 800 ) return;
666 static bool block = false; 666 static bool block = false;
667 if ( block ) return; 667 if ( block ) return;
668 block = true; 668 block = true;
669 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 669 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
670 //qDebug("VAL %d ",val ); 670 //qDebug("VAL %d ",val );
671 int count = mNavigator->selectedDates().count(); 671 int count = mNavigator->selectedDates().count();
672 int year = mNavigator->selectedDates().first().year(); 672 int year = mNavigator->selectedDates().first().year();
673 int day = mNavigator->selectedDates().first().dayOfYear(); 673 int day = mNavigator->selectedDates().first().dayOfYear();
674 if ( val == day -1 ) { 674 if ( val == day -1 ) {
675 block = false; 675 block = false;
676 return; 676 return;
677 } 677 }
678 QDate d ( year,1,1 ); 678 QDate d ( year,1,1 );
679 mNavigator->selectDates( d.addDays( val ), count ); 679 mNavigator->selectDates( d.addDays( val ), count );
680 block = false; 680 block = false;
681#endif 681#endif
682 682
683} 683}
684 684
685void CalendarView::checkAlarms() 685void CalendarView::checkAlarms()
686{ 686{
687
688 QString message;
689 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
690 KopiCalendarFile * cal = calendars.first();
691 while ( cal ) {
692 if ( cal->mErrorOnLoad ) {
693 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
694 }
695 cal = calendars.next();
696 }
697 if ( !message.isEmpty() ) {
698 message = KGlobal::formatMessage( i18n("The loading of one or more calendar failed:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
699 KMessageBox::error(this,message);
700 }
687 KConfig *config = KOGlobals::config(); 701 KConfig *config = KOGlobals::config();
688 config->setGroup( "AppRun" ); 702 config->setGroup( "AppRun" );
689 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 703 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
690 int daysto = dt.daysTo( QDate::currentDate() ); 704 int daysto = dt.daysTo( QDate::currentDate() );
691 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 705 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
692 dt = dt.addDays( days ); 706 dt = dt.addDays( days );
693 int secto = dt.secsTo( QDateTime::currentDateTime() ); 707 int secto = dt.secsTo( QDateTime::currentDateTime() );
694 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 708 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
695 //qDebug("KO: Reading program stop %d ", secs); 709 //qDebug("KO: Reading program stop %d ", secs);
696 //secs -= ( 3600 * 24*3 ); // debug only 710 //secs -= ( 3600 * 24*3 ); // debug only
697 QDateTime latest = dt.addSecs ( secs ); 711 QDateTime latest = dt.addSecs ( secs );
698 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 712 qDebug("KO: Last termination on %s ", latest.toString().latin1());
699 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 713 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
700 QPtrList<Incidence> el = mCalendar->rawIncidences(); 714 QPtrList<Incidence> el = mCalendar->rawIncidences();
701 QPtrList<Incidence> al; 715 QPtrList<Incidence> al;
702 Incidence* inL = el.first(); 716 Incidence* inL = el.first();
703 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 717 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
704 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 718 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
705 while ( inL ) { 719 while ( inL ) {
706 bool ok = false; 720 bool ok = false;
707 int offset = 0; 721 int offset = 0;
708 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 722 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
709 if ( ok ) { 723 if ( ok ) {
710 //qDebug("OK %s",next.toString().latin1()); 724 //qDebug("OK %s",next.toString().latin1());
711 if ( next < cur ) { 725 if ( next < cur ) {
712 al.append( inL ); 726 al.append( inL );
713 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 727 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
714 } 728 }
715 } 729 }
716 inL = el.next(); 730 inL = el.next();
717 } 731 }
718 if ( al.count() ) { 732 if ( al.count() ) {
719 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 733 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
720 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 734 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
721 QVBoxLayout* lay = new QVBoxLayout( dia ); 735 QVBoxLayout* lay = new QVBoxLayout( dia );
722 lay->setSpacing( 0 ); 736 lay->setSpacing( 0 );
723 lay->setMargin( 0 ); 737 lay->setMargin( 0 );
724 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 738 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
725 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 739 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
726 lay->addWidget( matb ); 740 lay->addWidget( matb );
727 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 741 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
728 int wid = 210; 742 int wid = 210;
729 int x = QApplication::desktop()->width() - wid - 7; 743 int x = QApplication::desktop()->width() - wid - 7;
730 int y = QApplication::desktop()->height() - wid - 70; 744 int y = QApplication::desktop()->height() - wid - 70;
731 dia->setGeometry ( x,y,wid,wid); 745 dia->setGeometry ( x,y,wid,wid);
732 } else { 746 } else {
733 int si = 220; 747 int si = 220;
734 if ( QApplication::desktop()->width() > 470 ) 748 if ( QApplication::desktop()->width() > 470 )
735 si = 400; 749 si = 400;
736 dia->resize(si,si/2); 750 dia->resize(si,si/2);
737 } 751 }
738 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 752 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
739 dia->show(); 753 dia->show();
740 754
741 } 755 }
742} 756}
743void CalendarView::showDay( QDate d ) 757void CalendarView::showDay( QDate d )
744{ 758{
745 dateNavigator()->blockSignals( true ); 759 dateNavigator()->blockSignals( true );
746 dateNavigator()->selectDate( d ); 760 dateNavigator()->selectDate( d );
747 dateNavigator()->blockSignals( false ); 761 dateNavigator()->blockSignals( false );
748 mViewManager->showDayView(); 762 mViewManager->showDayView();
749 //dateNavigator()->selectDate( d ); 763 //dateNavigator()->selectDate( d );
750} 764}
751void CalendarView::timerAlarm() 765void CalendarView::timerAlarm()
752{ 766{
753 //qDebug("CalendarView::timerAlarm() "); 767 //qDebug("CalendarView::timerAlarm() ");
754 computeAlarm(mAlarmNotification ); 768 computeAlarm(mAlarmNotification );
755} 769}
756 770
757void CalendarView::suspendAlarm() 771void CalendarView::suspendAlarm()
758{ 772{
759 //qDebug(" CalendarView::suspendAlarm() "); 773 //qDebug(" CalendarView::suspendAlarm() ");
760 computeAlarm(mSuspendAlarmNotification ); 774 computeAlarm(mSuspendAlarmNotification );
761 775
762} 776}
763 777
764void CalendarView::startAlarm( QString mess , QString filename) 778void CalendarView::startAlarm( QString mess , QString filename)
765{ 779{
766 780
767 topLevelWidget()->showNormal(); 781 topLevelWidget()->showNormal();
768 topLevelWidget()->setActiveWindow(); 782 topLevelWidget()->setActiveWindow();
769 topLevelWidget()->raise(); 783 topLevelWidget()->raise();
770 784
771 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 785 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
772 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 786 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
773 787
774} 788}
775 789
776void CalendarView::checkNextTimerAlarm() 790void CalendarView::checkNextTimerAlarm()
777{ 791{
778 mCalendar->checkAlarmForIncidence( 0, true ); 792 mCalendar->checkAlarmForIncidence( 0, true );
779} 793}
780 794
781void CalendarView::computeAlarm( QString msg ) 795void CalendarView::computeAlarm( QString msg )
782{ 796{
783 797
784 QString mess = msg; 798 QString mess = msg;
785 QString mAlarmMessage = mess.mid( 9 ); 799 QString mAlarmMessage = mess.mid( 9 );
786 QString filename = MainWindow::resourcePath(); 800 QString filename = MainWindow::resourcePath();
787 filename += "koalarm.wav"; 801 filename += "koalarm.wav";
788 QString tempfilename; 802 QString tempfilename;
789 if ( mess.left( 13 ) == "suspend_alarm") { 803 if ( mess.left( 13 ) == "suspend_alarm") {
790 bool error = false; 804 bool error = false;
791 int len = mess.mid( 13 ).find("+++"); 805 int len = mess.mid( 13 ).find("+++");
792 if ( len < 2 ) 806 if ( len < 2 )
793 error = true; 807 error = true;
794 else { 808 else {
795 tempfilename = mess.mid( 13, len ); 809 tempfilename = mess.mid( 13, len );
796 if ( !QFile::exists( tempfilename ) ) 810 if ( !QFile::exists( tempfilename ) )
797 error = true; 811 error = true;
798 } 812 }
799 if ( ! error ) { 813 if ( ! error ) {
800 filename = tempfilename; 814 filename = tempfilename;
801 } 815 }
802 mAlarmMessage = mess.mid( 13+len+3 ); 816 mAlarmMessage = mess.mid( 13+len+3 );
803 //qDebug("suspend file %s ",tempfilename.latin1() ); 817 //qDebug("suspend file %s ",tempfilename.latin1() );
804 startAlarm( mAlarmMessage, filename); 818 startAlarm( mAlarmMessage, filename);
805 return; 819 return;
806 } 820 }
807 if ( mess.left( 11 ) == "timer_alarm") { 821 if ( mess.left( 11 ) == "timer_alarm") {
808 //mTimerTime = 0; 822 //mTimerTime = 0;
809 startAlarm( mess.mid( 11 ), filename ); 823 startAlarm( mess.mid( 11 ), filename );
810 return; 824 return;
811 } 825 }
812 if ( mess.left( 10 ) == "proc_alarm") { 826 if ( mess.left( 10 ) == "proc_alarm") {
813 bool error = false; 827 bool error = false;
814 int len = mess.mid( 10 ).find("+++"); 828 int len = mess.mid( 10 ).find("+++");
815 if ( len < 2 ) 829 if ( len < 2 )
816 error = true; 830 error = true;
817 else { 831 else {
818 tempfilename = mess.mid( 10, len ); 832 tempfilename = mess.mid( 10, len );
819 if ( !QFile::exists( tempfilename ) ) 833 if ( !QFile::exists( tempfilename ) )
820 error = true; 834 error = true;
821 } 835 }
822 if ( error ) { 836 if ( error ) {
823 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 837 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
824 mAlarmMessage += mess.mid( 10+len+3+9 ); 838 mAlarmMessage += mess.mid( 10+len+3+9 );
825 } else { 839 } else {
826 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 840 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
827 //qDebug("-----system command %s ",tempfilename.latin1() ); 841 //qDebug("-----system command %s ",tempfilename.latin1() );
828#ifndef _WIN32_ 842#ifndef _WIN32_
829 if ( vfork () == 0 ) { 843 if ( vfork () == 0 ) {
830 execl ( tempfilename.latin1(), 0 ); 844 execl ( tempfilename.latin1(), 0 );
831 return; 845 return;
832 } 846 }
833#else 847#else
834 QProcess* p = new QProcess(); 848 QProcess* p = new QProcess();
835 p->addArgument( tempfilename.latin1() ); 849 p->addArgument( tempfilename.latin1() );
836 p->start(); 850 p->start();
837 return; 851 return;
838#endif 852#endif
839 853
840 return; 854 return;
841 } 855 }
842 856
843 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 857 //qDebug("+++++++system command %s ",tempfilename.latin1() );
844 } 858 }
845 if ( mess.left( 11 ) == "audio_alarm") { 859 if ( mess.left( 11 ) == "audio_alarm") {
846 bool error = false; 860 bool error = false;
847 int len = mess.mid( 11 ).find("+++"); 861 int len = mess.mid( 11 ).find("+++");
848 if ( len < 2 ) 862 if ( len < 2 )
849 error = true; 863 error = true;
850 else { 864 else {
851 tempfilename = mess.mid( 11, len ); 865 tempfilename = mess.mid( 11, len );
852 if ( !QFile::exists( tempfilename ) ) 866 if ( !QFile::exists( tempfilename ) )
853 error = true; 867 error = true;
854 } 868 }
855 if ( ! error ) { 869 if ( ! error ) {
856 filename = tempfilename; 870 filename = tempfilename;
857 } 871 }
858 mAlarmMessage = mess.mid( 11+len+3+9 ); 872 mAlarmMessage = mess.mid( 11+len+3+9 );
859 //qDebug("audio file command %s ",tempfilename.latin1() ); 873 //qDebug("audio file command %s ",tempfilename.latin1() );
860 } 874 }
861 if ( mess.left( 9 ) == "cal_alarm") { 875 if ( mess.left( 9 ) == "cal_alarm") {
862 mAlarmMessage = mess.mid( 9 ) ; 876 mAlarmMessage = mess.mid( 9 ) ;
863 } 877 }
864 878
865 startAlarm( mAlarmMessage, filename ); 879 startAlarm( mAlarmMessage, filename );
866 880
867 881
868} 882}
869 883
870void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 884void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
871{ 885{
872 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 886 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
873 887
874 mSuspendAlarmNotification = noti; 888 mSuspendAlarmNotification = noti;
875 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 889 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
876 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 890 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
877 mSuspendTimer->start( ms , true ); 891 mSuspendTimer->start( ms , true );
878 892
879} 893}
880 894
881void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 895void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
882{ 896{
883 mNextAlarmDateTime = qdt; 897 mNextAlarmDateTime = qdt;
884 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 898 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
885 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 899 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
886#ifndef DESKTOP_VERSION 900#ifndef DESKTOP_VERSION
887 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 901 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
888#endif 902#endif
889 return; 903 return;
890 } 904 }
891 int maxSec; 905 int maxSec;
892 //maxSec = 5; //testing only 906 //maxSec = 5; //testing only
893 maxSec = 86400+3600; // one day+1hour 907 maxSec = 86400+3600; // one day+1hour
894 mAlarmNotification = noti; 908 mAlarmNotification = noti;
895 int sec = QDateTime::currentDateTime().secsTo( qdt ); 909 int sec = QDateTime::currentDateTime().secsTo( qdt );
896 if ( sec > maxSec ) { 910 if ( sec > maxSec ) {
897 mRecheckAlarmTimer->start( maxSec * 1000 ); 911 mRecheckAlarmTimer->start( maxSec * 1000 );
898 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 912 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
899 return; 913 return;
900 } else { 914 } else {
901 mRecheckAlarmTimer->stop(); 915 mRecheckAlarmTimer->stop();
902 } 916 }
903 //qDebug("Alarm timer started with secs: %d ", sec); 917 //qDebug("Alarm timer started with secs: %d ", sec);
904 mAlarmTimer->start( sec *1000 , true ); 918 mAlarmTimer->start( sec *1000 , true );
905 919
906} 920}
907// called by mRecheckAlarmTimer to get next alarm 921// called by mRecheckAlarmTimer to get next alarm
908// we need this, because a QTimer has only a max range of 25 days 922// we need this, because a QTimer has only a max range of 25 days
909void CalendarView::recheckTimerAlarm() 923void CalendarView::recheckTimerAlarm()
910{ 924{
911 mAlarmTimer->stop(); 925 mAlarmTimer->stop();
912 mRecheckAlarmTimer->stop(); 926 mRecheckAlarmTimer->stop();
913 mCalendar->checkAlarmForIncidence( 0, true ); 927 mCalendar->checkAlarmForIncidence( 0, true );
914} 928}
915void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 929void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
916{ 930{
917 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 931 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
918 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 932 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
919#ifndef DESKTOP_VERSION 933#ifndef DESKTOP_VERSION
920 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 934 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
921#endif 935#endif
922 return; 936 return;
923 } 937 }
924 mAlarmTimer->stop(); 938 mAlarmTimer->stop();
925} 939}
926void CalendarView::selectWeekNum ( int num ) 940void CalendarView::selectWeekNum ( int num )
927{ 941{
928 dateNavigator()->blockSignals( true ); 942 dateNavigator()->blockSignals( true );
929 dateNavigator()->selectWeek( num ); 943 dateNavigator()->selectWeek( num );
930 dateNavigator()->blockSignals( false ); 944 dateNavigator()->blockSignals( false );
931 mViewManager->showWeekView(); 945 mViewManager->showWeekView();
932} 946}
933KOViewManager *CalendarView::viewManager() 947KOViewManager *CalendarView::viewManager()
934{ 948{
935 return mViewManager; 949 return mViewManager;
936} 950}
937 951
938KODialogManager *CalendarView::dialogManager() 952KODialogManager *CalendarView::dialogManager()
939{ 953{
940 return mDialogManager; 954 return mDialogManager;
941} 955}
942 956
943QDate CalendarView::startDate() 957QDate CalendarView::startDate()
944{ 958{
945 DateList dates = mNavigator->selectedDates(); 959 DateList dates = mNavigator->selectedDates();
946 960
947 return dates.first(); 961 return dates.first();
948} 962}
949 963
950QDate CalendarView::endDate() 964QDate CalendarView::endDate()
951{ 965{
952 DateList dates = mNavigator->selectedDates(); 966 DateList dates = mNavigator->selectedDates();
953 967
954 return dates.last(); 968 return dates.last();
955} 969}
956 970
957 971
958void CalendarView::createPrinter() 972void CalendarView::createPrinter()
959{ 973{
960#ifndef KORG_NOPRINTER 974#ifndef KORG_NOPRINTER
961 if (!mCalPrinter) { 975 if (!mCalPrinter) {
962 mCalPrinter = new CalPrinter(this, mCalendar); 976 mCalPrinter = new CalPrinter(this, mCalendar);
963 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 977 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
964 } 978 }
965#endif 979#endif
966} 980}
967 981
968 982
969//KOPrefs::instance()->mWriteBackFile 983//KOPrefs::instance()->mWriteBackFile
970//KOPrefs::instance()->mWriteBackExistingOnly 984//KOPrefs::instance()->mWriteBackExistingOnly
971 985
972// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 986// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
973// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 987// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
974// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 988// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
975// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 989// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
976// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 990// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
977// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 991// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
978 992
979int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 993int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
980{ 994{
981 995
982 // 0 equal 996 // 0 equal
983 // 1 take local 997 // 1 take local
984 // 2 take remote 998 // 2 take remote
985 // 3 cancel 999 // 3 cancel
986 QDateTime lastSync = mLastCalendarSync; 1000 QDateTime lastSync = mLastCalendarSync;
987 QDateTime localMod = local->lastModified(); 1001 QDateTime localMod = local->lastModified();
988 QDateTime remoteMod = remote->lastModified(); 1002 QDateTime remoteMod = remote->lastModified();
989 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1003 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
990 bool remCh, locCh; 1004 bool remCh, locCh;
991 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1005 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
992 //if ( remCh ) 1006 //if ( remCh )
993 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1007 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
994 locCh = ( localMod > mLastCalendarSync ); 1008 locCh = ( localMod > mLastCalendarSync );
995 if ( !remCh && ! locCh ) { 1009 if ( !remCh && ! locCh ) {
996 //qDebug("both not changed "); 1010 //qDebug("both not changed ");
997 lastSync = localMod.addDays(1); 1011 lastSync = localMod.addDays(1);
998 if ( mode <= SYNC_PREF_ASK ) 1012 if ( mode <= SYNC_PREF_ASK )
999 return 0; 1013 return 0;
1000 } else { 1014 } else {
1001 if ( locCh ) { 1015 if ( locCh ) {
1002 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1016 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1003 lastSync = localMod.addDays( -1 ); 1017 lastSync = localMod.addDays( -1 );
1004 if ( !remCh ) 1018 if ( !remCh )
1005 remoteMod = ( lastSync.addDays( -1 ) ); 1019 remoteMod = ( lastSync.addDays( -1 ) );
1006 } else { 1020 } else {
1007 //qDebug(" not loc changed "); 1021 //qDebug(" not loc changed ");
1008 lastSync = localMod.addDays( 1 ); 1022 lastSync = localMod.addDays( 1 );
1009 if ( remCh ) 1023 if ( remCh )
1010 remoteMod =( lastSync.addDays( 1 ) ); 1024 remoteMod =( lastSync.addDays( 1 ) );
1011 1025
1012 } 1026 }
1013 } 1027 }
1014 full = true; 1028 full = true;
1015 if ( mode < SYNC_PREF_ASK ) 1029 if ( mode < SYNC_PREF_ASK )
1016 mode = SYNC_PREF_ASK; 1030 mode = SYNC_PREF_ASK;
1017 } else { 1031 } else {
1018 if ( localMod == remoteMod ) 1032 if ( localMod == remoteMod )
1019 // if ( local->revision() == remote->revision() ) 1033 // if ( local->revision() == remote->revision() )
1020 return 0; 1034 return 0;
1021 1035
1022 } 1036 }
1023 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1037 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1024 1038
1025 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1039 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1026 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1040 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1027 //full = true; //debug only 1041 //full = true; //debug only
1028 if ( full ) { 1042 if ( full ) {
1029 bool equ = false; 1043 bool equ = false;
1030 if ( local->typeID() == eventID ) { 1044 if ( local->typeID() == eventID ) {
1031 equ = (*((Event*) local) == *((Event*) remote)); 1045 equ = (*((Event*) local) == *((Event*) remote));
1032 } 1046 }
1033 else if ( local->typeID() == todoID ) 1047 else if ( local->typeID() == todoID )
1034 equ = (*((Todo*) local) == (*(Todo*) remote)); 1048 equ = (*((Todo*) local) == (*(Todo*) remote));
1035 else if ( local->typeID() == journalID ) 1049 else if ( local->typeID() == journalID )
1036 equ = (*((Journal*) local) == *((Journal*) remote)); 1050 equ = (*((Journal*) local) == *((Journal*) remote));
1037 if ( equ ) { 1051 if ( equ ) {
1038 //qDebug("equal "); 1052 //qDebug("equal ");
1039 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1040 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1054 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1041 } 1055 }
1042 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1056 if ( mode < SYNC_PREF_FORCE_LOCAL )
1043 return 0; 1057 return 0;
1044 1058
1045 }//else //debug only 1059 }//else //debug only
1046 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1060 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1047 } 1061 }
1048 int result; 1062 int result;
1049 bool localIsNew; 1063 bool localIsNew;
1050 //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() ); 1064 //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() );
1051 1065
1052 1066
1053 // ************************************************ 1067 // ************************************************
1054 // ************************************************ 1068 // ************************************************
1055 // ************************************************ 1069 // ************************************************
1056 // We may have that lastSync > remoteMod AND lastSync > localMod 1070 // We may have that lastSync > remoteMod AND lastSync > localMod
1057 // BUT remoteMod != localMod 1071 // BUT remoteMod != localMod
1058 1072
1059 1073
1060 if ( full && mode < SYNC_PREF_NEWEST ) 1074 if ( full && mode < SYNC_PREF_NEWEST )
1061 mode = SYNC_PREF_ASK; 1075 mode = SYNC_PREF_ASK;
1062 1076
1063 switch( mode ) { 1077 switch( mode ) {
1064 case SYNC_PREF_LOCAL: 1078 case SYNC_PREF_LOCAL:
1065 if ( lastSync > remoteMod ) 1079 if ( lastSync > remoteMod )
1066 return 1; 1080 return 1;
1067 if ( lastSync > localMod ) 1081 if ( lastSync > localMod )
1068 return 2; 1082 return 2;
1069 return 1; 1083 return 1;
1070 break; 1084 break;
1071 case SYNC_PREF_REMOTE: 1085 case SYNC_PREF_REMOTE:
1072 if ( lastSync > localMod ) 1086 if ( lastSync > localMod )
1073 return 2; 1087 return 2;
1074 if ( lastSync > remoteMod ) 1088 if ( lastSync > remoteMod )
1075 return 1; 1089 return 1;
1076 return 2; 1090 return 2;
1077 break; 1091 break;
1078 case SYNC_PREF_NEWEST: 1092 case SYNC_PREF_NEWEST:
1079 if ( localMod >= remoteMod ) 1093 if ( localMod >= remoteMod )
1080 return 1; 1094 return 1;
1081 else 1095 else
1082 return 2; 1096 return 2;
1083 break; 1097 break;
1084 case SYNC_PREF_ASK: 1098 case SYNC_PREF_ASK:
1085 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1099 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1086 if ( lastSync > remoteMod && lastSync > localMod) 1100 if ( lastSync > remoteMod && lastSync > localMod)
1087 return 0; 1101 return 0;
1088 if ( lastSync > remoteMod ) 1102 if ( lastSync > remoteMod )
1089 return 1; 1103 return 1;
1090 if ( lastSync > localMod ) 1104 if ( lastSync > localMod )
1091 return 2; 1105 return 2;
1092 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1106 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1093 localIsNew = localMod >= remoteMod; 1107 localIsNew = localMod >= remoteMod;
1094 if ( localIsNew ) 1108 if ( localIsNew )
1095 getEventViewerDialog()->setColorMode( 1 ); 1109 getEventViewerDialog()->setColorMode( 1 );
1096 else 1110 else
1097 getEventViewerDialog()->setColorMode( 2 ); 1111 getEventViewerDialog()->setColorMode( 2 );
1098 getEventViewerDialog()->setIncidence(local); 1112 getEventViewerDialog()->setIncidence(local);
1099 if ( localIsNew ) 1113 if ( localIsNew )
1100 getEventViewerDialog()->setColorMode( 2 ); 1114 getEventViewerDialog()->setColorMode( 2 );
1101 else 1115 else
1102 getEventViewerDialog()->setColorMode( 1 ); 1116 getEventViewerDialog()->setColorMode( 1 );
1103 getEventViewerDialog()->addIncidence(remote); 1117 getEventViewerDialog()->addIncidence(remote);
1104 getEventViewerDialog()->setColorMode( 0 ); 1118 getEventViewerDialog()->setColorMode( 0 );
1105 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1119 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1106 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1120 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1107 getEventViewerDialog()->showMe(); 1121 getEventViewerDialog()->showMe();
1108 result = getEventViewerDialog()->executeS( localIsNew ); 1122 result = getEventViewerDialog()->executeS( localIsNew );
1109 return result; 1123 return result;
1110 1124
1111 break; 1125 break;
1112 case SYNC_PREF_FORCE_LOCAL: 1126 case SYNC_PREF_FORCE_LOCAL:
1113 return 1; 1127 return 1;
1114 break; 1128 break;
1115 case SYNC_PREF_FORCE_REMOTE: 1129 case SYNC_PREF_FORCE_REMOTE:
1116 return 2; 1130 return 2;
1117 break; 1131 break;
1118 1132
1119 default: 1133 default:
1120 // SYNC_PREF_TAKE_BOTH not implemented 1134 // SYNC_PREF_TAKE_BOTH not implemented
1121 break; 1135 break;
1122 } 1136 }
1123 return 0; 1137 return 0;
1124} 1138}
1125Event* CalendarView::getLastSyncEvent() 1139Event* CalendarView::getLastSyncEvent()
1126{ 1140{
1127 Event* lse; 1141 Event* lse;
1128 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1142 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1129 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1143 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1130 if (!lse) { 1144 if (!lse) {
1131 lse = new Event(); 1145 lse = new Event();
1132 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1146 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1133 QString sum = ""; 1147 QString sum = "";
1134 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1148 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1135 sum = "E: "; 1149 sum = "E: ";
1136 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1150 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1137 lse->setDtStart( mLastCalendarSync ); 1151 lse->setDtStart( mLastCalendarSync );
1138 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1152 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1139 lse->setCategories( i18n("SyncEvent") ); 1153 lse->setCategories( i18n("SyncEvent") );
1140 lse->setReadOnly( true ); 1154 lse->setReadOnly( true );
1141 mCalendar->addEvent( lse ); 1155 mCalendar->addEvent( lse );
1142 } 1156 }
1143 1157
1144 return lse; 1158 return lse;
1145 1159
1146} 1160}
1147 1161
1148// we check, if the to delete event has a id for a profile 1162// we check, if the to delete event has a id for a profile
1149// if yes, we set this id in the profile to delete 1163// if yes, we set this id in the profile to delete
1150void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1164void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1151{ 1165{
1152 if ( lastSync.count() == 0 ) { 1166 if ( lastSync.count() == 0 ) {
1153 //qDebug(" lastSync.count() == 0"); 1167 //qDebug(" lastSync.count() == 0");
1154 return; 1168 return;
1155 } 1169 }
1156 if ( toDelete->typeID() == journalID ) 1170 if ( toDelete->typeID() == journalID )
1157 return; 1171 return;
1158 1172
1159 Event* eve = lastSync.first(); 1173 Event* eve = lastSync.first();
1160 1174
1161 while ( eve ) { 1175 while ( eve ) {
1162 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1176 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1163 if ( !id.isEmpty() ) { 1177 if ( !id.isEmpty() ) {
1164 QString des = eve->description(); 1178 QString des = eve->description();
1165 QString pref = "e"; 1179 QString pref = "e";
1166 if ( toDelete->typeID() == todoID ) 1180 if ( toDelete->typeID() == todoID )
1167 pref = "t"; 1181 pref = "t";
1168 des += pref+ id + ","; 1182 des += pref+ id + ",";
1169 eve->setReadOnly( false ); 1183 eve->setReadOnly( false );
1170 eve->setDescription( des ); 1184 eve->setDescription( des );
1171 //qDebug("setdes %s ", des.latin1()); 1185 //qDebug("setdes %s ", des.latin1());
1172 eve->setReadOnly( true ); 1186 eve->setReadOnly( true );
1173 } 1187 }
1174 eve = lastSync.next(); 1188 eve = lastSync.next();
1175 } 1189 }
1176 1190
1177} 1191}
1178void CalendarView::checkExternalId( Incidence * inc ) 1192void CalendarView::checkExternalId( Incidence * inc )
1179{ 1193{
1180 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1194 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1181 checkExternSyncEvent( lastSync, inc ); 1195 checkExternSyncEvent( lastSync, inc );
1182 1196
1183} 1197}
1184bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1198bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1185{ 1199{
1186 bool syncOK = true; 1200 bool syncOK = true;
1187 int addedEvent = 0; 1201 int addedEvent = 0;
1188 int addedEventR = 0; 1202 int addedEventR = 0;
1189 int deletedEventR = 0; 1203 int deletedEventR = 0;
1190 int deletedEventL = 0; 1204 int deletedEventL = 0;
1191 int changedLocal = 0; 1205 int changedLocal = 0;
1192 int changedRemote = 0; 1206 int changedRemote = 0;
1193 int filteredIN = 0; 1207 int filteredIN = 0;
1194 int filteredOUT = 0; 1208 int filteredOUT = 0;
1195 //QPtrList<Event> el = local->rawEvents(); 1209 //QPtrList<Event> el = local->rawEvents();
1196 Event* eventR; 1210 Event* eventR;
1197 QString uid; 1211 QString uid;
1198 int take; 1212 int take;
1199 Event* eventL; 1213 Event* eventL;
1200 Event* eventRSync; 1214 Event* eventRSync;
1201 Event* eventLSync; 1215 Event* eventLSync;
1202 clearAllViews(); 1216 clearAllViews();
1203 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1217 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1204 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1218 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1205 bool fullDateRange = false; 1219 bool fullDateRange = false;
1206 local->resetTempSyncStat(); 1220 local->resetTempSyncStat();
1207 mLastCalendarSync = QDateTime::currentDateTime(); 1221 mLastCalendarSync = QDateTime::currentDateTime();
1208 if ( mSyncManager->syncWithDesktop() ) { 1222 if ( mSyncManager->syncWithDesktop() ) {
1209 remote->resetPilotStat(1); 1223 remote->resetPilotStat(1);
1210 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1224 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1211 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1225 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1212 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1226 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1213 } else { 1227 } else {
1214 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1228 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1215 } 1229 }
1216 } 1230 }
1217 QDateTime modifiedCalendar = mLastCalendarSync; 1231 QDateTime modifiedCalendar = mLastCalendarSync;
1218 eventLSync = getLastSyncEvent(); 1232 eventLSync = getLastSyncEvent();
1219 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1233 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1220 if ( eventR ) { 1234 if ( eventR ) {
1221 eventRSync = (Event*) eventR->clone(); 1235 eventRSync = (Event*) eventR->clone();
1222 remote->deleteEvent(eventR ); 1236 remote->deleteEvent(eventR );
1223 1237
1224 } else { 1238 } else {
1225 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1239 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1226 eventRSync = (Event*)eventLSync->clone(); 1240 eventRSync = (Event*)eventLSync->clone();
1227 } else { 1241 } else {
1228 fullDateRange = true; 1242 fullDateRange = true;
1229 eventRSync = new Event(); 1243 eventRSync = new Event();
1230 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1244 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1231 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1245 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1232 eventRSync->setDtStart( mLastCalendarSync ); 1246 eventRSync->setDtStart( mLastCalendarSync );
1233 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1247 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1234 eventRSync->setCategories( i18n("SyncEvent") ); 1248 eventRSync->setCategories( i18n("SyncEvent") );
1235 } 1249 }
1236 } 1250 }
1237 if ( eventLSync->dtStart() == mLastCalendarSync ) 1251 if ( eventLSync->dtStart() == mLastCalendarSync )
1238 fullDateRange = true; 1252 fullDateRange = true;
1239 1253
1240 if ( ! fullDateRange ) { 1254 if ( ! fullDateRange ) {
1241 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1255 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1242 1256
1243 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1257 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1244 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1258 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1245 fullDateRange = true; 1259 fullDateRange = true;
1246 } 1260 }
1247 } 1261 }
1248 if ( mSyncManager->syncWithDesktop() ) { 1262 if ( mSyncManager->syncWithDesktop() ) {
1249 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1263 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1250 } 1264 }
1251 if ( fullDateRange ) 1265 if ( fullDateRange )
1252 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1266 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1253 else 1267 else
1254 mLastCalendarSync = eventLSync->dtStart(); 1268 mLastCalendarSync = eventLSync->dtStart();
1255 // for resyncing if own file has changed 1269 // for resyncing if own file has changed
1256 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1270 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1257 mLastCalendarSync = loadedFileVersion; 1271 mLastCalendarSync = loadedFileVersion;
1258 //qDebug("setting mLastCalendarSync "); 1272 //qDebug("setting mLastCalendarSync ");
1259 } 1273 }
1260 //qDebug("*************************** "); 1274 //qDebug("*************************** ");
1261 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1275 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1262 QPtrList<Incidence> er = remote->rawIncidences(); 1276 QPtrList<Incidence> er = remote->rawIncidences();
1263 Incidence* inR = er.first(); 1277 Incidence* inR = er.first();
1264 Incidence* inL; 1278 Incidence* inL;
1265 QProgressBar bar( er.count(),0 ); 1279 QProgressBar bar( er.count(),0 );
1266 bar.setCaption (i18n("Syncing - close to abort!") ); 1280 bar.setCaption (i18n("Syncing - close to abort!") );
1267 1281
1268 // ************** setting up filter ************* 1282 // ************** setting up filter *************
1269 CalFilter *filterIN = 0; 1283 CalFilter *filterIN = 0;
1270 CalFilter *filterOUT = 0; 1284 CalFilter *filterOUT = 0;
1271 CalFilter *filter = mFilters.first(); 1285 CalFilter *filter = mFilters.first();
1272 while(filter) { 1286 while(filter) {
1273 if ( filter->name() == mSyncManager->mFilterInCal ) 1287 if ( filter->name() == mSyncManager->mFilterInCal )
1274 filterIN = filter; 1288 filterIN = filter;
1275 if ( filter->name() == mSyncManager->mFilterOutCal ) 1289 if ( filter->name() == mSyncManager->mFilterOutCal )
1276 filterOUT = filter; 1290 filterOUT = filter;
1277 filter = mFilters.next(); 1291 filter = mFilters.next();
1278 } 1292 }
1279 int w = 300; 1293 int w = 300;
1280 if ( QApplication::desktop()->width() < 320 ) 1294 if ( QApplication::desktop()->width() < 320 )
1281 w = 220; 1295 w = 220;
1282 int h = bar.sizeHint().height() ; 1296 int h = bar.sizeHint().height() ;
1283 int dw = QApplication::desktop()->width(); 1297 int dw = QApplication::desktop()->width();
1284 int dh = QApplication::desktop()->height(); 1298 int dh = QApplication::desktop()->height();
1285 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1299 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1286 bar.show(); 1300 bar.show();
1287 int modulo = (er.count()/10)+1; 1301 int modulo = (er.count()/10)+1;
1288 int incCounter = 0; 1302 int incCounter = 0;
1289 while ( inR ) { 1303 while ( inR ) {
1290 if ( ! bar.isVisible() ) 1304 if ( ! bar.isVisible() )
1291 return false; 1305 return false;
1292 if ( incCounter % modulo == 0 ) 1306 if ( incCounter % modulo == 0 )
1293 bar.setProgress( incCounter ); 1307 bar.setProgress( incCounter );
1294 ++incCounter; 1308 ++incCounter;
1295 uid = inR->uid(); 1309 uid = inR->uid();
1296 bool skipIncidence = false; 1310 bool skipIncidence = false;
1297 if ( uid.left(15) == QString("last-syncEvent-") ) 1311 if ( uid.left(15) == QString("last-syncEvent-") )
1298 skipIncidence = true; 1312 skipIncidence = true;
1299 QString idS; 1313 QString idS;
1300 qApp->processEvents(); 1314 qApp->processEvents();
1301 if ( !skipIncidence ) { 1315 if ( !skipIncidence ) {
1302 inL = local->incidence( uid ); 1316 inL = local->incidence( uid );
1303 if ( inL ) { // maybe conflict - same uid in both calendars 1317 if ( inL ) { // maybe conflict - same uid in both calendars
1304 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1318 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1305 //qDebug("take %d %s ", take, inL->summary().latin1()); 1319 //qDebug("take %d %s ", take, inL->summary().latin1());
1306 if ( take == 3 ) 1320 if ( take == 3 )
1307 return false; 1321 return false;
1308 if ( take == 1 ) {// take local ********************** 1322 if ( take == 1 ) {// take local **********************
1309 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1323 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1310 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1324 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1311 else 1325 else
1312 idS = inR->IDStr(); 1326 idS = inR->IDStr();
1313 remote->deleteIncidence( inR ); 1327 remote->deleteIncidence( inR );
1314 inR = inL->clone(); 1328 inR = inL->clone();
1315 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1329 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1316 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1330 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1317 inR->setIDStr( idS ); 1331 inR->setIDStr( idS );
1318 remote->addIncidence( inR ); 1332 remote->addIncidence( inR );
1319 if ( mSyncManager->syncWithDesktop() ) 1333 if ( mSyncManager->syncWithDesktop() )
1320 inR->setPilotId( 2 ); 1334 inR->setPilotId( 2 );
1321 ++changedRemote; 1335 ++changedRemote;
1322 } else {// take remote ********************** 1336 } else {// take remote **********************
1323 idS = inL->IDStr(); 1337 idS = inL->IDStr();
1324 int pid = inL->pilotId(); 1338 int pid = inL->pilotId();
1325 local->deleteIncidence( inL ); 1339 local->deleteIncidence( inL );
1326 inL = inR->clone(); 1340 inL = inR->clone();
1327 if ( mSyncManager->syncWithDesktop() ) 1341 if ( mSyncManager->syncWithDesktop() )
1328 inL->setPilotId( pid ); 1342 inL->setPilotId( pid );
1329 inL->setIDStr( idS ); 1343 inL->setIDStr( idS );
1330 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1331 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1345 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1332 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1346 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1333 } 1347 }
1334 local->addIncidence( inL ); 1348 local->addIncidence( inL );
1335 ++changedLocal; 1349 ++changedLocal;
1336 } 1350 }
1337 } 1351 }
1338 } else { // no conflict ********** add or delete remote 1352 } else { // no conflict ********** add or delete remote
1339 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1353 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1340 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1341 QString des = eventLSync->description(); 1355 QString des = eventLSync->description();
1342 QString pref = "e"; 1356 QString pref = "e";
1343 if ( inR->typeID() == todoID ) 1357 if ( inR->typeID() == todoID )
1344 pref = "t"; 1358 pref = "t";
1345 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1359 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1346 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1360 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1347 //remote->deleteIncidence( inR ); 1361 //remote->deleteIncidence( inR );
1348 ++deletedEventR; 1362 ++deletedEventR;
1349 } else { 1363 } else {
1350 inR->setLastModified( modifiedCalendar ); 1364 inR->setLastModified( modifiedCalendar );
1351 inL = inR->clone(); 1365 inL = inR->clone();
1352 inL->setIDStr( ":" ); 1366 inL->setIDStr( ":" );
1353 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1367 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1354 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1368 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1355 local->addIncidence( inL ); 1369 local->addIncidence( inL );
1356 ++addedEvent; 1370 ++addedEvent;
1357 1371
1358 } 1372 }
1359 } else { 1373 } else {
1360 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1374 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1361 inR->setLastModified( modifiedCalendar ); 1375 inR->setLastModified( modifiedCalendar );
1362 inL = inR->clone(); 1376 inL = inR->clone();
1363 inL->setIDStr( ":" ); 1377 inL->setIDStr( ":" );
1364 local->addIncidence( inL ); 1378 local->addIncidence( inL );
1365 ++addedEvent; 1379 ++addedEvent;
1366 1380
1367 } else { 1381 } else {
1368 checkExternSyncEvent(eventRSyncSharp, inR); 1382 checkExternSyncEvent(eventRSyncSharp, inR);
1369 remote->deleteIncidence( inR ); 1383 remote->deleteIncidence( inR );
1370 ++deletedEventR; 1384 ++deletedEventR;
1371 } 1385 }
1372 } 1386 }
1373 } else { 1387 } else {
1374 ++filteredIN; 1388 ++filteredIN;
1375 } 1389 }
1376 } 1390 }
1377 } 1391 }
1378 inR = er.next(); 1392 inR = er.next();
1379 } 1393 }
1380 QPtrList<Incidence> el = local->rawIncidences(); 1394 QPtrList<Incidence> el = local->rawIncidences();
1381 inL = el.first(); 1395 inL = el.first();
1382 modulo = (el.count()/10)+1; 1396 modulo = (el.count()/10)+1;
1383 bar.setCaption (i18n("Add / remove events") ); 1397 bar.setCaption (i18n("Add / remove events") );
1384 bar.setTotalSteps ( el.count() ) ; 1398 bar.setTotalSteps ( el.count() ) ;
1385 bar.show(); 1399 bar.show();
1386 incCounter = 0; 1400 incCounter = 0;
1387 1401
1388 while ( inL ) { 1402 while ( inL ) {
1389 1403
1390 qApp->processEvents(); 1404 qApp->processEvents();
1391 if ( ! bar.isVisible() ) 1405 if ( ! bar.isVisible() )
1392 return false; 1406 return false;
1393 if ( incCounter % modulo == 0 ) 1407 if ( incCounter % modulo == 0 )
1394 bar.setProgress( incCounter ); 1408 bar.setProgress( incCounter );
1395 ++incCounter; 1409 ++incCounter;
1396 uid = inL->uid(); 1410 uid = inL->uid();
1397 bool skipIncidence = false; 1411 bool skipIncidence = false;
1398 if ( uid.left(15) == QString("last-syncEvent-") ) 1412 if ( uid.left(15) == QString("last-syncEvent-") )
1399 skipIncidence = true; 1413 skipIncidence = true;
1400 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1414 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1401 skipIncidence = true; 1415 skipIncidence = true;
1402 if ( !skipIncidence ) { 1416 if ( !skipIncidence ) {
1403 inR = remote->incidence( uid ); 1417 inR = remote->incidence( uid );
1404 if ( ! inR ) { 1418 if ( ! inR ) {
1405 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1419 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1406 // no conflict ********** add or delete local 1420 // no conflict ********** add or delete local
1407 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1421 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1408 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1422 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1409 checkExternSyncEvent(eventLSyncSharp, inL); 1423 checkExternSyncEvent(eventLSyncSharp, inL);
1410 local->deleteIncidence( inL ); 1424 local->deleteIncidence( inL );
1411 ++deletedEventL; 1425 ++deletedEventL;
1412 } else { 1426 } else {
1413 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1427 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1414 inL->removeID(mCurrentSyncDevice ); 1428 inL->removeID(mCurrentSyncDevice );
1415 ++addedEventR; 1429 ++addedEventR;
1416 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1430 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1417 inL->setLastModified( modifiedCalendar ); 1431 inL->setLastModified( modifiedCalendar );
1418 inR = inL->clone(); 1432 inR = inL->clone();
1419 inR->setIDStr( ":" ); 1433 inR->setIDStr( ":" );
1420 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1434 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1421 remote->addIncidence( inR ); 1435 remote->addIncidence( inR );
1422 } 1436 }
1423 } 1437 }
1424 } else { 1438 } else {
1425 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1439 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1426 checkExternSyncEvent(eventLSyncSharp, inL); 1440 checkExternSyncEvent(eventLSyncSharp, inL);
1427 local->deleteIncidence( inL ); 1441 local->deleteIncidence( inL );
1428 ++deletedEventL; 1442 ++deletedEventL;
1429 } else { 1443 } else {
1430 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1444 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1431 ++addedEventR; 1445 ++addedEventR;
1432 inL->setLastModified( modifiedCalendar ); 1446 inL->setLastModified( modifiedCalendar );
1433 inR = inL->clone(); 1447 inR = inL->clone();
1434 inR->setIDStr( ":" ); 1448 inR->setIDStr( ":" );
1435 remote->addIncidence( inR ); 1449 remote->addIncidence( inR );
1436 } 1450 }
1437 } 1451 }
1438 } 1452 }
1439 } else { 1453 } else {
1440 ++filteredOUT; 1454 ++filteredOUT;
1441 } 1455 }
1442 } 1456 }
1443 } 1457 }
1444 inL = el.next(); 1458 inL = el.next();
1445 } 1459 }
1446 int delFut = 0; 1460 int delFut = 0;
1447 int remRem = 0; 1461 int remRem = 0;
1448 if ( mSyncManager->mWriteBackInFuture ) { 1462 if ( mSyncManager->mWriteBackInFuture ) {
1449 er = remote->rawIncidences(); 1463 er = remote->rawIncidences();
1450 remRem = er.count(); 1464 remRem = er.count();
1451 inR = er.first(); 1465 inR = er.first();
1452 QDateTime dt; 1466 QDateTime dt;
1453 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1467 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1454 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1468 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1455 while ( inR ) { 1469 while ( inR ) {
1456 if ( inR->typeID() == todoID ) { 1470 if ( inR->typeID() == todoID ) {
1457 Todo * t = (Todo*)inR; 1471 Todo * t = (Todo*)inR;
1458 if ( t->hasDueDate() ) 1472 if ( t->hasDueDate() )
1459 dt = t->dtDue(); 1473 dt = t->dtDue();
1460 else 1474 else
1461 dt = cur.addSecs( 62 ); 1475 dt = cur.addSecs( 62 );
1462 } 1476 }
1463 else if (inR->typeID() == eventID ) { 1477 else if (inR->typeID() == eventID ) {
1464 bool ok; 1478 bool ok;
1465 dt = inR->getNextOccurence( cur, &ok ); 1479 dt = inR->getNextOccurence( cur, &ok );
1466 if ( !ok ) 1480 if ( !ok )
1467 dt = cur.addSecs( -62 ); 1481 dt = cur.addSecs( -62 );
1468 } 1482 }
1469 else 1483 else
1470 dt = inR->dtStart(); 1484 dt = inR->dtStart();
1471 if ( dt < cur || dt > end ) { 1485 if ( dt < cur || dt > end ) {
1472 remote->deleteIncidence( inR ); 1486 remote->deleteIncidence( inR );
1473 ++delFut; 1487 ++delFut;
1474 } 1488 }
1475 inR = er.next(); 1489 inR = er.next();
1476 } 1490 }
1477 } 1491 }
1478 bar.hide(); 1492 bar.hide();
1479 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1493 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1480 eventLSync->setReadOnly( false ); 1494 eventLSync->setReadOnly( false );
1481 eventLSync->setDtStart( mLastCalendarSync ); 1495 eventLSync->setDtStart( mLastCalendarSync );
1482 eventRSync->setDtStart( mLastCalendarSync ); 1496 eventRSync->setDtStart( mLastCalendarSync );
1483 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1497 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1484 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1498 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1485 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1499 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1486 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1500 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1487 eventLSync->setReadOnly( true ); 1501 eventLSync->setReadOnly( true );
1488 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1502 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1489 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1503 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1490 remote->addEvent( eventRSync ); 1504 remote->addEvent( eventRSync );
1491 else 1505 else
1492 delete eventRSync; 1506 delete eventRSync;
1493 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1507 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1494 QString mes; 1508 QString mes;
1495 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 ); 1509 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 );
1496 QString delmess; 1510 QString delmess;
1497 if ( delFut ) { 1511 if ( delFut ) {
1498 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); 1512 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);
1499 mes += delmess; 1513 mes += delmess;
1500 } 1514 }
1501 mes = i18n("Local calendar changed!\n") +mes; 1515 mes = i18n("Local calendar changed!\n") +mes;
1502 mCalendar->checkAlarmForIncidence( 0, true ); 1516 mCalendar->checkAlarmForIncidence( 0, true );
1503 qDebug( mes ); 1517 qDebug( mes );
1504 if ( mSyncManager->mShowSyncSummary ) { 1518 if ( mSyncManager->mShowSyncSummary ) {
1505 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1519 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1506 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1520 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1507 qDebug("KO: WB cancelled "); 1521 qDebug("KO: WB cancelled ");
1508 mSyncManager->mWriteBackFile = false; 1522 mSyncManager->mWriteBackFile = false;
1509 return syncOK; 1523 return syncOK;
1510 } 1524 }
1511 } 1525 }
1512 return syncOK; 1526 return syncOK;
1513} 1527}
1514 1528
1515void CalendarView::setSyncDevice( QString s ) 1529void CalendarView::setSyncDevice( QString s )
1516{ 1530{
1517 mCurrentSyncDevice= s; 1531 mCurrentSyncDevice= s;
1518} 1532}
1519void CalendarView::setSyncName( QString s ) 1533void CalendarView::setSyncName( QString s )
1520{ 1534{
1521 mCurrentSyncName= s; 1535 mCurrentSyncName= s;
1522} 1536}
1523bool CalendarView::syncCalendar(QString filename, int mode) 1537bool CalendarView::syncCalendar(QString filename, int mode)
1524{ 1538{
1525 //qDebug("syncCalendar %s ", filename.latin1()); 1539 //qDebug("syncCalendar %s ", filename.latin1());
1526 mGlobalSyncMode = SYNC_MODE_NORMAL; 1540 mGlobalSyncMode = SYNC_MODE_NORMAL;
1527 CalendarLocal* calendar = new CalendarLocal(); 1541 CalendarLocal* calendar = new CalendarLocal();
1528 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1542 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1529 FileStorage* storage = new FileStorage( calendar ); 1543 FileStorage* storage = new FileStorage( calendar );
1530 bool syncOK = false; 1544 bool syncOK = false;
1531 storage->setFileName( filename ); 1545 storage->setFileName( filename );
1532 // qDebug("loading ... "); 1546 // qDebug("loading ... ");
1533 if ( storage->load() ) { 1547 if ( storage->load() ) {
1534 getEventViewerDialog()->setSyncMode( true ); 1548 getEventViewerDialog()->setSyncMode( true );
1535 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1549 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1536 getEventViewerDialog()->setSyncMode( false ); 1550 getEventViewerDialog()->setSyncMode( false );
1537 if ( syncOK ) { 1551 if ( syncOK ) {
1538 if ( mSyncManager->mWriteBackFile ) 1552 if ( mSyncManager->mWriteBackFile )
1539 { 1553 {
1540 storage->setSaveFormat( new ICalFormat() ); 1554 storage->setSaveFormat( new ICalFormat() );
1541 storage->save(); 1555 storage->save();
1542 } 1556 }
1543 } 1557 }
1544 setModified( true ); 1558 setModified( true );
1545 } 1559 }
1546 delete storage; 1560 delete storage;
1547 delete calendar; 1561 delete calendar;
1548 if ( syncOK ) 1562 if ( syncOK )
1549 updateView(); 1563 updateView();
1550 return syncOK; 1564 return syncOK;
1551} 1565}
1552 1566
1553void CalendarView::syncExternal( int mode ) 1567void CalendarView::syncExternal( int mode )
1554{ 1568{
1555 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1569 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1556 1570
1557 qApp->processEvents(); 1571 qApp->processEvents();
1558 CalendarLocal* calendar = new CalendarLocal(); 1572 CalendarLocal* calendar = new CalendarLocal();
1559 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1573 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1560 bool syncOK = false; 1574 bool syncOK = false;
1561 bool loadSuccess = false; 1575 bool loadSuccess = false;
1562 PhoneFormat* phoneFormat = 0; 1576 PhoneFormat* phoneFormat = 0;
1563 emit tempDisableBR(true); 1577 emit tempDisableBR(true);
1564#ifndef DESKTOP_VERSION 1578#ifndef DESKTOP_VERSION
1565 SharpFormat* sharpFormat = 0; 1579 SharpFormat* sharpFormat = 0;
1566 if ( mode == 0 ) { // sharp 1580 if ( mode == 0 ) { // sharp
1567 sharpFormat = new SharpFormat () ; 1581 sharpFormat = new SharpFormat () ;
1568 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1582 loadSuccess = sharpFormat->load( calendar, mCalendar );
1569 1583
1570 } else 1584 } else
1571#endif 1585#endif
1572 if ( mode == 1 ) { // phone 1586 if ( mode == 1 ) { // phone
1573 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1587 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1574 mSyncManager->mPhoneDevice, 1588 mSyncManager->mPhoneDevice,
1575 mSyncManager->mPhoneConnection, 1589 mSyncManager->mPhoneConnection,
1576 mSyncManager->mPhoneModel); 1590 mSyncManager->mPhoneModel);
1577 loadSuccess = phoneFormat->load( calendar,mCalendar); 1591 loadSuccess = phoneFormat->load( calendar,mCalendar);
1578 1592
1579 } else { 1593 } else {
1580 emit tempDisableBR(false); 1594 emit tempDisableBR(false);
1581 return; 1595 return;
1582 } 1596 }
1583 if ( loadSuccess ) { 1597 if ( loadSuccess ) {
1584 getEventViewerDialog()->setSyncMode( true ); 1598 getEventViewerDialog()->setSyncMode( true );
1585 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1599 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1586 getEventViewerDialog()->setSyncMode( false ); 1600 getEventViewerDialog()->setSyncMode( false );
1587 qApp->processEvents(); 1601 qApp->processEvents();
1588 if ( syncOK ) { 1602 if ( syncOK ) {
1589 if ( mSyncManager->mWriteBackFile ) 1603 if ( mSyncManager->mWriteBackFile )
1590 { 1604 {
1591 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1605 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1592 Incidence* inc = iL.first(); 1606 Incidence* inc = iL.first();
1593 if ( phoneFormat ) { 1607 if ( phoneFormat ) {
1594 while ( inc ) { 1608 while ( inc ) {
1595 inc->removeID(mCurrentSyncDevice); 1609 inc->removeID(mCurrentSyncDevice);
1596 inc = iL.next(); 1610 inc = iL.next();
1597 } 1611 }
1598 } 1612 }
1599#ifndef DESKTOP_VERSION 1613#ifndef DESKTOP_VERSION
1600 if ( sharpFormat ) 1614 if ( sharpFormat )
1601 sharpFormat->save(calendar); 1615 sharpFormat->save(calendar);
1602#endif 1616#endif
1603 if ( phoneFormat ) 1617 if ( phoneFormat )
1604 phoneFormat->save(calendar); 1618 phoneFormat->save(calendar);
1605 iL = calendar->rawIncidences(); 1619 iL = calendar->rawIncidences();
1606 inc = iL.first(); 1620 inc = iL.first();
1607 Incidence* loc; 1621 Incidence* loc;
1608 while ( inc ) { 1622 while ( inc ) {
1609 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1623 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1610 loc = mCalendar->incidence(inc->uid() ); 1624 loc = mCalendar->incidence(inc->uid() );
1611 if ( loc ) { 1625 if ( loc ) {
1612 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1626 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1613 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1627 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1614 } 1628 }
1615 } 1629 }
1616 inc = iL.next(); 1630 inc = iL.next();
1617 } 1631 }
1618 Incidence* lse = getLastSyncEvent(); 1632 Incidence* lse = getLastSyncEvent();
1619 if ( lse ) { 1633 if ( lse ) {
1620 lse->setReadOnly( false ); 1634 lse->setReadOnly( false );
1621 lse->setDescription( "" ); 1635 lse->setDescription( "" );
1622 lse->setReadOnly( true ); 1636 lse->setReadOnly( true );
1623 } 1637 }
1624 } 1638 }
1625 } else { 1639 } else {
1626 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1640 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1627 } 1641 }
1628 setModified( true ); 1642 setModified( true );
1629 } else { 1643 } else {
1630 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1644 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1631 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1645 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1632 question, i18n("Ok")) ; 1646 question, i18n("Ok")) ;
1633 1647
1634 } 1648 }
1635 delete calendar; 1649 delete calendar;
1636 updateView(); 1650 updateView();
1637 emit tempDisableBR(false); 1651 emit tempDisableBR(false);
1638 return ;//syncOK; 1652 return ;//syncOK;
1639 1653
1640} 1654}
1641 1655
1642bool CalendarView::importBday() 1656bool CalendarView::importBday()
1643{ 1657{
1644#ifndef KORG_NOKABC 1658#ifndef KORG_NOKABC
1645 1659
1646#ifdef DESKTOP_VERSION 1660#ifdef DESKTOP_VERSION
1647 int curCal = mCalendar->defaultCalendar(); 1661 int curCal = mCalendar->defaultCalendar();
1648 int bd = mCalEditView->getBirtdayID(); 1662 int bd = mCalEditView->getBirtdayID();
1649 if ( bd == 0 ) 1663 if ( bd == 0 )
1650 return false; 1664 return false;
1651 mCalendar->setDefaultCalendar( bd ); 1665 mCalendar->setDefaultCalendar( bd );
1652 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1666 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1653 KABC::AddressBook::Iterator it; 1667 KABC::AddressBook::Iterator it;
1654 int count = 0; 1668 int count = 0;
1655 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1669 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1656 ++count; 1670 ++count;
1657 } 1671 }
1658 QProgressBar bar(count,0 ); 1672 QProgressBar bar(count,0 );
1659 int w = 300; 1673 int w = 300;
1660 if ( QApplication::desktop()->width() < 320 ) 1674 if ( QApplication::desktop()->width() < 320 )
1661 w = 220; 1675 w = 220;
1662 int h = bar.sizeHint().height() ; 1676 int h = bar.sizeHint().height() ;
1663 int dw = QApplication::desktop()->width(); 1677 int dw = QApplication::desktop()->width();
1664 int dh = QApplication::desktop()->height(); 1678 int dh = QApplication::desktop()->height();
1665 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1679 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1666 bar.show(); 1680 bar.show();
1667 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1681 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1668 qApp->processEvents(); 1682 qApp->processEvents();
1669 count = 0; 1683 count = 0;
1670 int addCount = 0; 1684 int addCount = 0;
1671 KCal::Attendee* a = 0; 1685 KCal::Attendee* a = 0;
1672 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1686 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1673 if ( ! bar.isVisible() ) 1687 if ( ! bar.isVisible() )
1674 return false; 1688 return false;
1675 bar.setProgress( count++ ); 1689 bar.setProgress( count++ );
1676 qApp->processEvents(); 1690 qApp->processEvents();
1677 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1691 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1678 if ( (*it).birthday().date().isValid() ){ 1692 if ( (*it).birthday().date().isValid() ){
1679 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1693 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1680 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1694 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1681 ++addCount; 1695 ++addCount;
1682 } 1696 }
1683 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1697 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1684 if ( anni.isValid() ){ 1698 if ( anni.isValid() ){
1685 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1699 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1686 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1700 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1687 ++addCount; 1701 ++addCount;
1688 } 1702 }
1689 } 1703 }
1690 mCalendar->setDefaultCalendar( curCal ); 1704 mCalendar->setDefaultCalendar( curCal );
1691 updateView(); 1705 updateView();
1692 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1706 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1693#else //DESKTOP_VERSION 1707#else //DESKTOP_VERSION
1694 1708
1695 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1709 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1696 // the result should now arrive through method insertBirthdays 1710 // the result should now arrive through method insertBirthdays
1697 1711
1698#endif //DESKTOP_VERSION 1712#endif //DESKTOP_VERSION
1699 1713
1700#endif //KORG_NOKABC 1714#endif //KORG_NOKABC
1701 1715
1702 1716
1703 return true; 1717 return true;
1704} 1718}
1705 1719
1706// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1720// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1707void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1721void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1708 const QStringList& anniversaryList, const QStringList& realNameList, 1722 const QStringList& anniversaryList, const QStringList& realNameList,
1709 const QStringList& emailList, const QStringList& assembledNameList, 1723 const QStringList& emailList, const QStringList& assembledNameList,
1710 const QStringList& uidList) 1724 const QStringList& uidList)
1711{ 1725{
1712 1726
1713 //qDebug("KO::CalendarView::insertBirthdays"); 1727 //qDebug("KO::CalendarView::insertBirthdays");
1714 if (uid == this->name()) 1728 if (uid == this->name())
1715 { 1729 {
1716 int curCal = mCalendar->defaultCalendar(); 1730 int curCal = mCalendar->defaultCalendar();
1717 int bd = mCalEditView->getBirtdayID(); 1731 int bd = mCalEditView->getBirtdayID();
1718 if ( bd == 0 ) 1732 if ( bd == 0 )
1719 return; 1733 return;
1720 mCalendar->setDefaultCalendar( bd ); 1734 mCalendar->setDefaultCalendar( bd );
1721 1735
1722 1736
1723 int count = birthdayList.count(); 1737 int count = birthdayList.count();
1724 int addCount = 0; 1738 int addCount = 0;
1725 KCal::Attendee* a = 0; 1739 KCal::Attendee* a = 0;
1726 1740
1727 //qDebug("CalView 1 %i", count); 1741 //qDebug("CalView 1 %i", count);
1728 1742
1729 QProgressBar bar(count,0 ); 1743 QProgressBar bar(count,0 );
1730 int w = 300; 1744 int w = 300;
1731 if ( QApplication::desktop()->width() < 320 ) 1745 if ( QApplication::desktop()->width() < 320 )
1732 w = 220; 1746 w = 220;
1733 int h = bar.sizeHint().height() ; 1747 int h = bar.sizeHint().height() ;
1734 int dw = QApplication::desktop()->width(); 1748 int dw = QApplication::desktop()->width();
1735 int dh = QApplication::desktop()->height(); 1749 int dh = QApplication::desktop()->height();
1736 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1750 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1737 bar.show(); 1751 bar.show();
1738 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1752 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1739 qApp->processEvents(); 1753 qApp->processEvents();
1740 1754
1741 QDate birthday; 1755 QDate birthday;
1742 QDate anniversary; 1756 QDate anniversary;
1743 QString realName; 1757 QString realName;
1744 QString email; 1758 QString email;
1745 QString assembledName; 1759 QString assembledName;
1746 QString uid; 1760 QString uid;
1747 bool ok = true; 1761 bool ok = true;
1748 for ( int i = 0; i < count; i++) 1762 for ( int i = 0; i < count; i++)
1749 { 1763 {
1750 if ( ! bar.isVisible() ) 1764 if ( ! bar.isVisible() )
1751 return; 1765 return;
1752 bar.setProgress( i ); 1766 bar.setProgress( i );
1753 qApp->processEvents(); 1767 qApp->processEvents();
1754 1768
1755 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1769 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1756 if (!ok) { 1770 if (!ok) {
1757 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1771 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1758 } 1772 }
1759 1773
1760 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1774 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1761 if (!ok) { 1775 if (!ok) {
1762 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1776 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1763 } 1777 }
1764 realName = realNameList[i]; 1778 realName = realNameList[i];
1765 email = emailList[i]; 1779 email = emailList[i];
1766 assembledName = assembledNameList[i]; 1780 assembledName = assembledNameList[i];
1767 uid = uidList[i]; 1781 uid = uidList[i];
1768 //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() ); 1782 //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() );
1769 1783
1770 if ( birthday.isValid() ){ 1784 if ( birthday.isValid() ){
1771 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1785 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1772 KCal::Attendee::ReqParticipant,uid) ; 1786 KCal::Attendee::ReqParticipant,uid) ;
1773 if ( addAnniversary( birthday, assembledName, a, true ) ) 1787 if ( addAnniversary( birthday, assembledName, a, true ) )
1774 ++addCount; 1788 ++addCount;
1775 } 1789 }
1776 1790
1777 if ( anniversary.isValid() ){ 1791 if ( anniversary.isValid() ){
1778 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1792 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1779 KCal::Attendee::ReqParticipant,uid) ; 1793 KCal::Attendee::ReqParticipant,uid) ;
1780 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1794 if ( addAnniversary( anniversary, assembledName, a, false ) )
1781 ++addCount; 1795 ++addCount;
1782 } 1796 }
1783 } 1797 }
1784 1798
1785 mCalendar->setDefaultCalendar( curCal ); 1799 mCalendar->setDefaultCalendar( curCal );
1786 updateView(); 1800 updateView();
1787 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1801 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1788 1802
1789 } 1803 }
1790 1804
1791} 1805}
1792 1806
1793 1807
1794 1808
1795bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1809bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1796{ 1810{
1797 //qDebug("addAnni "); 1811 //qDebug("addAnni ");
1798 Event * ev = new Event(); 1812 Event * ev = new Event();
1799 ev->setOrganizer(KOPrefs::instance()->email()); 1813 ev->setOrganizer(KOPrefs::instance()->email());
1800 if ( a ) { 1814 if ( a ) {
1801 ev->addAttendee( a ); 1815 ev->addAttendee( a );
1802 } 1816 }
1803 QString kind; 1817 QString kind;
1804 if ( birthday ) { 1818 if ( birthday ) {
1805 kind = i18n( "Birthday" ); 1819 kind = i18n( "Birthday" );
1806 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1820 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1807 } 1821 }
1808 else { 1822 else {
1809 kind = i18n( "Anniversary" ); 1823 kind = i18n( "Anniversary" );
1810 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1824 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1811 } 1825 }
1812 ev->setCategories( kind ); 1826 ev->setCategories( kind );
1813 ev->setDtStart( QDateTime(date) ); 1827 ev->setDtStart( QDateTime(date) );
1814 ev->setDtEnd( QDateTime(date) ); 1828 ev->setDtEnd( QDateTime(date) );
1815 ev->setFloats( true ); 1829 ev->setFloats( true );
1816 Recurrence * rec = ev->recurrence(); 1830 Recurrence * rec = ev->recurrence();
1817 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1831 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1818 rec->addYearlyNum( date.month() ); 1832 rec->addYearlyNum( date.month() );
1819 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1833 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1820 delete ev; 1834 delete ev;
1821 return false; 1835 return false;
1822 } 1836 }
1823 return true; 1837 return true;
1824 1838
1825} 1839}
1826bool CalendarView::importQtopia( const QString &categories, 1840bool CalendarView::importQtopia( const QString &categories,
1827 const QString &datebook, 1841 const QString &datebook,
1828 const QString &todolist ) 1842 const QString &todolist )
1829{ 1843{
1830 1844
1831 QtopiaFormat qtopiaFormat; 1845 QtopiaFormat qtopiaFormat;
1832 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1846 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1833 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1847 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1834 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1848 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1835 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1849 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1836 1850
1837 updateView(); 1851 updateView();
1838 return true; 1852 return true;
1839 1853
1840#if 0 1854#if 0
1841 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1855 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1842 mCurrentSyncDevice = "qtopia-XML"; 1856 mCurrentSyncDevice = "qtopia-XML";
1843 if ( mSyncManager->mAskForPreferences ) 1857 if ( mSyncManager->mAskForPreferences )
1844 edit_sync_options(); 1858 edit_sync_options();
1845 qApp->processEvents(); 1859 qApp->processEvents();
1846 CalendarLocal* calendar = new CalendarLocal(); 1860 CalendarLocal* calendar = new CalendarLocal();
1847 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1861 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1848 bool syncOK = false; 1862 bool syncOK = false;
1849 QtopiaFormat qtopiaFormat; 1863 QtopiaFormat qtopiaFormat;
1850 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1864 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1851 bool loadOk = true; 1865 bool loadOk = true;
1852 if ( !categories.isEmpty() ) 1866 if ( !categories.isEmpty() )
1853 loadOk = qtopiaFormat.load( calendar, categories ); 1867 loadOk = qtopiaFormat.load( calendar, categories );
1854 if ( loadOk && !datebook.isEmpty() ) 1868 if ( loadOk && !datebook.isEmpty() )
1855 loadOk = qtopiaFormat.load( calendar, datebook ); 1869 loadOk = qtopiaFormat.load( calendar, datebook );
1856 if ( loadOk && !todolist.isEmpty() ) 1870 if ( loadOk && !todolist.isEmpty() )
1857 loadOk = qtopiaFormat.load( calendar, todolist ); 1871 loadOk = qtopiaFormat.load( calendar, todolist );
1858 1872
1859 if ( loadOk ) { 1873 if ( loadOk ) {
1860 getEventViewerDialog()->setSyncMode( true ); 1874 getEventViewerDialog()->setSyncMode( true );
1861 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1875 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1862 getEventViewerDialog()->setSyncMode( false ); 1876 getEventViewerDialog()->setSyncMode( false );
1863 qApp->processEvents(); 1877 qApp->processEvents();
1864 if ( syncOK ) { 1878 if ( syncOK ) {
1865 if ( mSyncManager->mWriteBackFile ) 1879 if ( mSyncManager->mWriteBackFile )
1866 { 1880 {
1867 // write back XML file 1881 // write back XML file
1868 1882
1869 } 1883 }
1870 setModified( true ); 1884 setModified( true );
1871 } 1885 }
1872 } else { 1886 } else {
1873 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1887 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1874 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1888 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1875 question, i18n("Ok")) ; 1889 question, i18n("Ok")) ;
1876 } 1890 }
1877 delete calendar; 1891 delete calendar;
1878 updateView(); 1892 updateView();
1879 return syncOK; 1893 return syncOK;
1880 1894
1881 1895
1882#endif 1896#endif
1883 1897
1884} 1898}
1885 1899
1886void CalendarView::setSyncEventsReadOnly() 1900void CalendarView::setSyncEventsReadOnly()
1887{ 1901{
1888 mCalendar->setSyncEventsReadOnly(); 1902 mCalendar->setSyncEventsReadOnly();
1889} 1903}
1890 1904
1891bool CalendarView::loadCalendars() 1905bool CalendarView::loadCalendars()
1892{ 1906{
1893 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1907 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1894 KopiCalendarFile * cal = calendars.first(); 1908 KopiCalendarFile * cal = calendars.first();
1895 mCalendar->setDefaultCalendar( 1 ); 1909 mCalendar->setDefaultCalendar( 1 );
1896 openCalendar( MainWindow::defaultFileName(), false ); 1910 openCalendar( MainWindow::defaultFileName(), false );
1897 cal = calendars.next(); 1911 cal = calendars.next();
1898 while ( cal ) { 1912 while ( cal ) {
1899 addCalendar( cal ); 1913 addCalendar( cal );
1900 cal = calendars.next(); 1914 cal = calendars.next();
1901 } 1915 }
1902 restoreCalendarSettings(); 1916 restoreCalendarSettings();
1903 return true; 1917 return true;
1904} 1918}
1905bool CalendarView::restoreCalendarSettings() 1919bool CalendarView::restoreCalendarSettings()
1906{ 1920{
1907 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1921 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1908 KopiCalendarFile * cal = calendars.first(); 1922 KopiCalendarFile * cal = calendars.first();
1909 while ( cal ) { 1923 while ( cal ) {
1910 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1924 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1911 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1925 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1912 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1926 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1913 if ( cal->isStandard ) 1927 if ( cal->isStandard )
1914 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1928 mCalendar->setDefaultCalendar( cal->mCalNumber );
1915 cal = calendars.next(); 1929 cal = calendars.next();
1916 } 1930 }
1917 setSyncEventsReadOnly(); 1931 setSyncEventsReadOnly();
1918 mCalendar->reInitAlarmSettings(); 1932 mCalendar->reInitAlarmSettings();
1919 updateUnmanagedViews(); 1933 updateUnmanagedViews();
1920 updateView(); 1934 updateView();
1921 return true; 1935 return true;
1922} 1936}
1923void CalendarView::addCalendarId( int id ) 1937void CalendarView::addCalendarId( int id )
1924{ 1938{
1925 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1939 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1926 addCalendar( cal ); 1940 if ( cal )
1941 addCalendar( cal );
1927} 1942}
1928bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1943bool CalendarView::addCalendar( KopiCalendarFile * cal )
1929{ 1944{
1930 cal->mErrorOnLoad = false; 1945 cal->mErrorOnLoad = false;
1931 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1946 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1932 cal->mLoadDt = QDateTime::currentDateTime(); 1947 cal->mLoadDt = QDateTime::currentDateTime();
1933 return true; 1948 return true;
1934 } 1949 }
1935 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1950 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
1936 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1937 cal->mErrorOnLoad = true; 1951 cal->mErrorOnLoad = true;
1938 return false; 1952 return false;
1939} 1953}
1940bool CalendarView::openCalendar(QString filename, bool merge) 1954bool CalendarView::openCalendar(QString filename, bool merge)
1941{ 1955{
1942 1956
1943 if (filename.isEmpty()) { 1957 if (filename.isEmpty()) {
1944 return false; 1958 return false;
1945 } 1959 }
1946 1960
1947 if (!QFile::exists(filename)) { 1961 if (!QFile::exists(filename)) {
1948 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1962 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1949 return false; 1963 return false;
1950 } 1964 }
1951 1965
1952 globalFlagBlockAgenda = 1; 1966 globalFlagBlockAgenda = 1;
1953 clearAllViews(); 1967 clearAllViews();
1954 if (!merge) { 1968 if (!merge) {
1955 mViewManager->setDocumentId( filename ); 1969 mViewManager->setDocumentId( filename );
1956 mCalendar->close(); 1970 mCalendar->close();
1957 } 1971 }
1958 mStorage->setFileName( filename ); 1972 mStorage->setFileName( filename );
1959 1973
1960 if ( mStorage->load() ) { 1974 if ( mStorage->load() ) {
1961 if ( merge ) ;//setModified( true ); 1975 if ( merge ) ;//setModified( true );
1962 else { 1976 else {
1963 //setModified( true ); 1977 //setModified( true );
1964 mViewManager->setDocumentId( filename ); 1978 mViewManager->setDocumentId( filename );
1965 mDialogManager->setDocumentId( filename ); 1979 mDialogManager->setDocumentId( filename );
1966 mTodoList->setDocumentId( filename ); 1980 mTodoList->setDocumentId( filename );
1967 } 1981 }
1968 globalFlagBlockAgenda = 2; 1982 globalFlagBlockAgenda = 2;
1969 // if ( getLastSyncEvent() ) 1983 // if ( getLastSyncEvent() )
1970 // getLastSyncEvent()->setReadOnly( true ); 1984 // getLastSyncEvent()->setReadOnly( true );
1971 mCalendar->reInitAlarmSettings(); 1985 mCalendar->reInitAlarmSettings();
1972 setSyncEventsReadOnly(); 1986 setSyncEventsReadOnly();
1973 updateUnmanagedViews(); 1987 updateUnmanagedViews();
1974 updateView(); 1988 updateView();
1975 if ( filename != MainWindow::defaultFileName() ) { 1989 if ( filename != MainWindow::defaultFileName() ) {
1976 saveCalendar( MainWindow::defaultFileName() ); 1990 saveCalendar( MainWindow::defaultFileName() );
1977 } else { 1991 } else {
1978 QFileInfo finf ( MainWindow::defaultFileName()); 1992 QFileInfo finf ( MainWindow::defaultFileName());
1979 if ( finf.exists() ) { 1993 if ( finf.exists() ) {
1980 setLoadedFileVersion( finf.lastModified () ); 1994 setLoadedFileVersion( finf.lastModified () );
1981 } 1995 }
1982 } 1996 }
1983 return true; 1997 return true;
1984 } else { 1998 } else {
1985 // while failing to load, the calendar object could 1999 // while failing to load, the calendar object could
1986 // have become partially populated. Clear it out. 2000 // have become partially populated. Clear it out.
1987 if ( !merge ) { 2001 if ( !merge ) {
1988 mCalendar->close(); 2002 mCalendar->close();
1989 mViewManager->setDocumentId( filename ); 2003 mViewManager->setDocumentId( filename );
1990 mDialogManager->setDocumentId( filename ); 2004 mDialogManager->setDocumentId( filename );
1991 mTodoList->setDocumentId( filename ); 2005 mTodoList->setDocumentId( filename );
1992 } 2006 }
1993 2007
1994 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2008 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1995 2009
1996 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2010 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1997 globalFlagBlockAgenda = 2; 2011 globalFlagBlockAgenda = 2;
1998 mCalendar->reInitAlarmSettings(); 2012 mCalendar->reInitAlarmSettings();
1999 setSyncEventsReadOnly(); 2013 setSyncEventsReadOnly();
2000 updateUnmanagedViews(); 2014 updateUnmanagedViews();
2001 updateView(); 2015 updateView();
2002 } 2016 }
2003 return false; 2017 return false;
2004} 2018}
2005void CalendarView::showOpenError() 2019void CalendarView::showOpenError()
2006{ 2020{
2007 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2021 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2008} 2022}
2009void CalendarView::setLoadedFileVersion(QDateTime dt) 2023void CalendarView::setLoadedFileVersion(QDateTime dt)
2010{ 2024{
2011 loadedFileVersion = dt; 2025 loadedFileVersion = dt;
2012} 2026}
2013bool CalendarView::checkFileChanged(QString fn) 2027bool CalendarView::checkFileChanged(QString fn)
2014{ 2028{
2015 QFileInfo finf ( fn ); 2029 QFileInfo finf ( fn );
2016 if ( !finf.exists() ) 2030 if ( !finf.exists() )
2017 return true; 2031 return true;
2018 QDateTime dt = finf.lastModified (); 2032 QDateTime dt = finf.lastModified ();
2019 if ( dt <= loadedFileVersion ) 2033 if ( dt <= loadedFileVersion )
2020 return false; 2034 return false;
2021 return true; 2035 return true;
2022 2036
2023} 2037}
2024void CalendarView::watchSavedFile() 2038void CalendarView::watchSavedFile()
2025{ 2039{
2026 QFileInfo finf ( MainWindow::defaultFileName()); 2040 QFileInfo finf ( MainWindow::defaultFileName());
2027 if ( !finf.exists() ) 2041 if ( !finf.exists() )
2028 return; 2042 return;
2029 QDateTime dt = finf.lastModified (); 2043 QDateTime dt = finf.lastModified ();
2030 if ( dt < loadedFileVersion ) { 2044 if ( dt < loadedFileVersion ) {
2031 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2045 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2032 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2046 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2033 return; 2047 return;
2034 } 2048 }
2035 loadedFileVersion = dt; 2049 loadedFileVersion = dt;
2036} 2050}
2037bool CalendarView::checkAllFileVersions() 2051bool CalendarView::checkAllFileVersions()
2038{ 2052{
2039 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2053 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2040 KopiCalendarFile * cal = calendars.first(); 2054 KopiCalendarFile * cal = calendars.first();
2041 mCalendar->setDefaultCalendar( 1 ); 2055 mCalendar->setDefaultCalendar( 1 );
2042 mCalendar->setDefaultCalendarEnabledOnly(); 2056 mCalendar->setDefaultCalendarEnabledOnly();
2043 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2057 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2044 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2058 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2045 restoreCalendarSettings(); 2059 restoreCalendarSettings();
2046 return false; 2060 return false;
2047 } 2061 }
2048 } 2062 }
2049 cal = calendars.next(); 2063 cal = calendars.next();
2050 QDateTime storeTemp = loadedFileVersion; 2064 QDateTime storeTemp = loadedFileVersion;
2051 while ( cal ) { 2065 while ( cal ) {
2052 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2066 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2053 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2067 mCalendar->setDefaultCalendar( cal->mCalNumber );
2054 mCalendar->setDefaultCalendarEnabledOnly(); 2068 mCalendar->setDefaultCalendarEnabledOnly();
2055 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2069 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2056 if ( !checkFileVersion(cal->mFileName )) { 2070 if ( !checkFileVersion(cal->mFileName )) {
2057 loadedFileVersion = storeTemp; 2071 loadedFileVersion = storeTemp;
2058 restoreCalendarSettings(); 2072 restoreCalendarSettings();
2059 return false; 2073 return false;
2060 } 2074 }
2061 } 2075 }
2062 cal = calendars.next(); 2076 cal = calendars.next();
2063 } 2077 }
2064 loadedFileVersion = storeTemp; 2078 loadedFileVersion = storeTemp;
2065 return true; 2079 return true;
2066} 2080}
2067bool CalendarView::checkFileVersion(QString fn) 2081bool CalendarView::checkFileVersion(QString fn)
2068{ 2082{
2069 QFileInfo finf ( fn ); 2083 QFileInfo finf ( fn );
2070 if ( !finf.exists() ) 2084 if ( !finf.exists() )
2071 return true; 2085 return true;
2072 QDateTime dt = finf.lastModified (); 2086 QDateTime dt = finf.lastModified ();
2073 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2087 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2074 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2088 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2075 if ( dt <= loadedFileVersion ) 2089 if ( dt <= loadedFileVersion )
2076 return true; 2090 return true;
2077 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2091 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2078 i18n("KO/Pi Warning"),i18n("Overwrite"), 2092 i18n("KO/Pi Warning"),i18n("Overwrite"),
2079 i18n("Sync+save")); 2093 i18n("Sync+save"));
2080 2094
2081 if ( km == KMessageBox::Cancel ) 2095 if ( km == KMessageBox::Cancel )
2082 return false; 2096 return false;
2083 if ( km == KMessageBox::Yes ) 2097 if ( km == KMessageBox::Yes )
2084 return true; 2098 return true;
2085 2099
2086 setSyncDevice("deleteaftersync" ); 2100 setSyncDevice("deleteaftersync" );
2087 mSyncManager->mAskForPreferences = true; 2101 mSyncManager->mAskForPreferences = true;
2088 mSyncManager->mSyncAlgoPrefs = 3; 2102 mSyncManager->mSyncAlgoPrefs = 3;
2089 mSyncManager->mWriteBackFile = false; 2103 mSyncManager->mWriteBackFile = false;
2090 mSyncManager->mWriteBackExistingOnly = false; 2104 mSyncManager->mWriteBackExistingOnly = false;
2091 mSyncManager->mShowSyncSummary = false; 2105 mSyncManager->mShowSyncSummary = false;
2092 syncCalendar( fn, 3 ); 2106 syncCalendar( fn, 3 );
2093 Event * e = getLastSyncEvent(); 2107 Event * e = getLastSyncEvent();
2094 if ( e ) 2108 if ( e )
2095 mCalendar->deleteEvent( e ); 2109 mCalendar->deleteEvent( e );
2096 return true; 2110 return true;
2097} 2111}
2098bool CalendarView::saveCalendars() 2112bool CalendarView::saveCalendars()
2099{ 2113{
2100 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2114 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2101 KopiCalendarFile * cal = calendars.first(); 2115 KopiCalendarFile * cal = calendars.first();
2102 mCalendar->setDefaultCalendar( 1 ); 2116 mCalendar->setDefaultCalendar( 1 );
2103 mCalendar->setDefaultCalendarEnabledOnly(); 2117 mCalendar->setDefaultCalendarEnabledOnly();
2104 saveCalendar( MainWindow::defaultFileName() ); 2118 saveCalendar( MainWindow::defaultFileName() );
2105 cal = calendars.next(); 2119 cal = calendars.next();
2106 while ( cal ) { 2120 while ( cal ) {
2107 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2121 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2108 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2122 mCalendar->setDefaultCalendar( cal->mCalNumber );
2109 mCalendar->setDefaultCalendarEnabledOnly(); 2123 mCalendar->setDefaultCalendarEnabledOnly();
2110 if ( saveCalendar( cal->mFileName ) ) 2124 if ( saveCalendar( cal->mFileName ) )
2111 cal->mLoadDt = QDateTime::currentDateTime(); 2125 cal->mLoadDt = QDateTime::currentDateTime();
2112 } 2126 }
2113 cal = calendars.next(); 2127 cal = calendars.next();
2114 } 2128 }
2115 restoreCalendarSettings(); 2129 restoreCalendarSettings();
2116 return true; 2130 return true;
2117} 2131}
2118bool CalendarView::saveCalendar( QString filename ) 2132bool CalendarView::saveCalendar( QString filename )
2119{ 2133{
2120 2134
2121 // Store back all unsaved data into calendar object 2135 // Store back all unsaved data into calendar object
2122 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2136 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2123 if ( mViewManager->currentView() ) 2137 if ( mViewManager->currentView() )
2124 mViewManager->currentView()->flushView(); 2138 mViewManager->currentView()->flushView();
2125 2139
2126 2140
2127 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2141 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2128 mStorage->setSaveFormat( new ICalFormat() ); 2142 mStorage->setSaveFormat( new ICalFormat() );
2129 mStorage->setFileName( filename ); 2143 mStorage->setFileName( filename );
2130 bool success; 2144 bool success;
2131 success = mStorage->save(); 2145 success = mStorage->save();
2132 if ( !success ) { 2146 if ( !success ) {
2133 return false; 2147 return false;
2134 } 2148 }
2135 if ( filename == MainWindow::defaultFileName() ) { 2149 if ( filename == MainWindow::defaultFileName() ) {
2136 setLoadedFileVersion( lfv ); 2150 setLoadedFileVersion( lfv );
2137 watchSavedFile(); 2151 watchSavedFile();
2138 } 2152 }
2139 return true; 2153 return true;
2140} 2154}
2141 2155
2142void CalendarView::closeCalendar() 2156void CalendarView::closeCalendar()
2143{ 2157{
2144 2158
2145 // child windows no longer valid 2159 // child windows no longer valid
2146 clearAllViews(); 2160 clearAllViews();
2147 emit closingDown(); 2161 emit closingDown();
2148 2162
2149 mCalendar->close(); 2163 mCalendar->close();
2150 setModified(false); 2164 setModified(false);
2151 updateView(); 2165 updateView();
2152} 2166}
2153 2167
2154void CalendarView::archiveCalendar() 2168void CalendarView::archiveCalendar()
2155{ 2169{
2156 mDialogManager->showArchiveDialog(); 2170 mDialogManager->showArchiveDialog();
2157} 2171}
2158 2172
2159 2173
2160void CalendarView::readSettings() 2174void CalendarView::readSettings()
2161{ 2175{
2162 2176
2163 2177
2164 // mViewManager->showAgendaView(); 2178 // mViewManager->showAgendaView();
2165 QString str; 2179 QString str;
2166 //qDebug("CalendarView::readSettings() "); 2180 //qDebug("CalendarView::readSettings() ");
2167 // read settings from the KConfig, supplying reasonable 2181 // read settings from the KConfig, supplying reasonable
2168 // defaults where none are to be found 2182 // defaults where none are to be found
2169 KConfig *config = KOGlobals::config(); 2183 KConfig *config = KOGlobals::config();
2170#ifndef KORG_NOSPLITTER 2184#ifndef KORG_NOSPLITTER
2171 config->setGroup("KOrganizer Geometry"); 2185 config->setGroup("KOrganizer Geometry");
2172 2186
2173 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2187 QValueList<int> sizes = config->readIntListEntry("Separator1");
2174 if (sizes.count() != 2) { 2188 if (sizes.count() != 2) {
2175 sizes << mDateNavigator->minimumSizeHint().width(); 2189 sizes << mDateNavigator->minimumSizeHint().width();
2176 sizes << 300; 2190 sizes << 300;
2177 } 2191 }
2178 mPanner->setSizes(sizes); 2192 mPanner->setSizes(sizes);
2179 2193
2180 sizes = config->readIntListEntry("Separator2"); 2194 sizes = config->readIntListEntry("Separator2");
2181 if ( ( mResourceView && sizes.count() == 4 ) || 2195 if ( ( mResourceView && sizes.count() == 4 ) ||
2182 ( !mResourceView && sizes.count() == 3 ) ) { 2196 ( !mResourceView && sizes.count() == 3 ) ) {
2183 mLeftSplitter->setSizes(sizes); 2197 mLeftSplitter->setSizes(sizes);
2184 } 2198 }
2185#endif 2199#endif
2186 globalFlagBlockAgenda = 1; 2200 globalFlagBlockAgenda = 1;
2187 mViewManager->showAgendaView(); 2201 mViewManager->showAgendaView();
2188 //mViewManager->readSettings( config ); 2202 //mViewManager->readSettings( config );
2189 mTodoList->restoreLayout(config,QString("Todo Layout")); 2203 mTodoList->restoreLayout(config,QString("Todo Layout"));
2190 readFilterSettings(config); 2204 readFilterSettings(config);
2191 2205
2192#ifdef DESKTOP_VERSION 2206#ifdef DESKTOP_VERSION
2193 config->setGroup("WidgetLayout"); 2207 config->setGroup("WidgetLayout");
2194 QStringList list; 2208 QStringList list;
2195 list = config->readListEntry("MainLayout"); 2209 list = config->readListEntry("MainLayout");
2196 int x,y,w,h; 2210 int x,y,w,h;
2197 if ( ! list.isEmpty() ) { 2211 if ( ! list.isEmpty() ) {
2198 x = list[0].toInt(); 2212 x = list[0].toInt();
2199 y = list[1].toInt(); 2213 y = list[1].toInt();
2200 w = list[2].toInt(); 2214 w = list[2].toInt();
2201 h = list[3].toInt(); 2215 h = list[3].toInt();
2202 KApplication::testCoords( &x,&y,&w,&h ); 2216 KApplication::testCoords( &x,&y,&w,&h );
2203 topLevelWidget()->setGeometry(x,y,w,h); 2217 topLevelWidget()->setGeometry(x,y,w,h);
2204 2218
2205 } else { 2219 } else {
2206 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2220 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2207 } 2221 }
2208 list = config->readListEntry("EditEventLayout"); 2222 list = config->readListEntry("EditEventLayout");
2209 if ( ! list.isEmpty() ) { 2223 if ( ! list.isEmpty() ) {
2210 x = list[0].toInt(); 2224 x = list[0].toInt();
2211 y = list[1].toInt(); 2225 y = list[1].toInt();
2212 w = list[2].toInt(); 2226 w = list[2].toInt();
2213 h = list[3].toInt(); 2227 h = list[3].toInt();
2214 KApplication::testCoords( &x,&y,&w,&h ); 2228 KApplication::testCoords( &x,&y,&w,&h );
2215 mEventEditor->setGeometry(x,y,w,h); 2229 mEventEditor->setGeometry(x,y,w,h);
2216 2230
2217 } 2231 }
2218 list = config->readListEntry("EditTodoLayout"); 2232 list = config->readListEntry("EditTodoLayout");
2219 if ( ! list.isEmpty() ) { 2233 if ( ! list.isEmpty() ) {
2220 x = list[0].toInt(); 2234 x = list[0].toInt();
2221 y = list[1].toInt(); 2235 y = list[1].toInt();
2222 w = list[2].toInt(); 2236 w = list[2].toInt();
2223 h = list[3].toInt(); 2237 h = list[3].toInt();
2224 KApplication::testCoords( &x,&y,&w,&h ); 2238 KApplication::testCoords( &x,&y,&w,&h );
2225 mTodoEditor->setGeometry(x,y,w,h); 2239 mTodoEditor->setGeometry(x,y,w,h);
2226 2240
2227 } 2241 }
2228 list = config->readListEntry("ViewerLayout"); 2242 list = config->readListEntry("ViewerLayout");
2229 if ( ! list.isEmpty() ) { 2243 if ( ! list.isEmpty() ) {
2230 x = list[0].toInt(); 2244 x = list[0].toInt();
2231 y = list[1].toInt(); 2245 y = list[1].toInt();
2232 w = list[2].toInt(); 2246 w = list[2].toInt();
2233 h = list[3].toInt(); 2247 h = list[3].toInt();
2234 KApplication::testCoords( &x,&y,&w,&h ); 2248 KApplication::testCoords( &x,&y,&w,&h );
2235 getEventViewerDialog()->setGeometry(x,y,w,h); 2249 getEventViewerDialog()->setGeometry(x,y,w,h);
2236 } 2250 }
2237#endif 2251#endif
2238 config->setGroup( "Views" ); 2252 config->setGroup( "Views" );
2239 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2253 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2240 2254
2241 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2255 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2242 2256
2243 int resetval = 0; 2257 int resetval = 0;
2244 int maxVal = 0; 2258 int maxVal = 0;
2245 if (sizes.count() != 3) { 2259 if (sizes.count() != 3) {
2246 if ( KOPrefs::instance()->mVerticalScreen ) { 2260 if ( KOPrefs::instance()->mVerticalScreen ) {
2247 resetval = mDateNavigator->sizeHint().width()+2; 2261 resetval = mDateNavigator->sizeHint().width()+2;
2248 } else { 2262 } else {
2249 resetval = mDateNavigator->sizeHint().height()+2; 2263 resetval = mDateNavigator->sizeHint().height()+2;
2250 } 2264 }
2251 } 2265 }
2252 if ( resetval ) { 2266 if ( resetval ) {
2253 sizes.clear(); 2267 sizes.clear();
2254 if ( KOPrefs::instance()->mVerticalScreen ) { 2268 if ( KOPrefs::instance()->mVerticalScreen ) {
2255 maxVal = QApplication::desktop()->width() -10; 2269 maxVal = QApplication::desktop()->width() -10;
2256 } else { 2270 } else {
2257 maxVal = QApplication::desktop()->height()-10; 2271 maxVal = QApplication::desktop()->height()-10;
2258 } 2272 }
2259 sizes << resetval; 2273 sizes << resetval;
2260 if ( maxVal < resetval + resetval) 2274 if ( maxVal < resetval + resetval)
2261 resetval = maxVal - resetval; 2275 resetval = maxVal - resetval;
2262 sizes << resetval; 2276 sizes << resetval;
2263 sizes << 100; 2277 sizes << 100;
2264 } 2278 }
2265 mLeftFrame->setSizes(sizes); 2279 mLeftFrame->setSizes(sizes);
2266 sizes = config->readIntListEntry("Main Splitter Frame"); 2280 sizes = config->readIntListEntry("Main Splitter Frame");
2267 resetval = 0; 2281 resetval = 0;
2268 maxVal = 0; 2282 maxVal = 0;
2269 if (sizes.count() != 2) { 2283 if (sizes.count() != 2) {
2270 if ( !KOPrefs::instance()->mVerticalScreen ) { 2284 if ( !KOPrefs::instance()->mVerticalScreen ) {
2271 resetval = mDateNavigator->sizeHint().width()+2; 2285 resetval = mDateNavigator->sizeHint().width()+2;
2272 } else { 2286 } else {
2273 resetval = mDateNavigator->sizeHint().height()+2; 2287 resetval = mDateNavigator->sizeHint().height()+2;
2274 } 2288 }
2275 } 2289 }
2276 if ( resetval ) { 2290 if ( resetval ) {
2277 sizes.clear(); 2291 sizes.clear();
2278 if ( !KOPrefs::instance()->mVerticalScreen ) { 2292 if ( !KOPrefs::instance()->mVerticalScreen ) {
2279 maxVal = QApplication::desktop()->width() -10; 2293 maxVal = QApplication::desktop()->width() -10;
2280 } else { 2294 } else {
2281 maxVal = QApplication::desktop()->height()-10; 2295 maxVal = QApplication::desktop()->height()-10;
2282 } 2296 }
2283 sizes << resetval; 2297 sizes << resetval;
2284 if ( maxVal < resetval + resetval) 2298 if ( maxVal < resetval + resetval)
2285 resetval = maxVal - resetval; 2299 resetval = maxVal - resetval;
2286 sizes << resetval; 2300 sizes << resetval;
2287 } 2301 }
2288 mMainFrame->setSizes(sizes); 2302 mMainFrame->setSizes(sizes);
2289 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2303 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2290 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2304 else if ( dateCount == 7 ) mNavigator->selectWeek();
2291 else mNavigator->selectDates( dateCount ); 2305 else mNavigator->selectDates( dateCount );
2292 // mViewManager->readSettings( config ); 2306 // mViewManager->readSettings( config );
2293 updateConfig(); 2307 updateConfig();
2294 globalFlagBlockAgenda = 2; 2308 globalFlagBlockAgenda = 2;
2295 mViewManager->readSettings( config ); 2309 mViewManager->readSettings( config );
2296 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2310 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2297} 2311}
2298 2312
2299 2313
2300void CalendarView::writeSettings() 2314void CalendarView::writeSettings()
2301{ 2315{
2302 // kdDebug() << "CalendarView::writeSettings" << endl; 2316 // kdDebug() << "CalendarView::writeSettings" << endl;
2303 2317
2304 KConfig *config = KOGlobals::config(); 2318 KConfig *config = KOGlobals::config();
2305 2319
2306 mViewManager->writeSettings( config ); 2320 mViewManager->writeSettings( config );
2307 mTodoList->saveLayout(config,QString("Todo Layout")); 2321 mTodoList->saveLayout(config,QString("Todo Layout"));
2308 mDialogManager->writeSettings( config ); 2322 mDialogManager->writeSettings( config );
2309 //KOPrefs::instance()->usrWriteConfig(); 2323 //KOPrefs::instance()->usrWriteConfig();
2310 KOPrefs::instance()->writeConfig(); 2324 KOPrefs::instance()->writeConfig();
2311 2325
2312 writeFilterSettings(config); 2326 writeFilterSettings(config);
2313 config->setGroup( "AppRun" ); 2327 config->setGroup( "AppRun" );
2314 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2328 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2315 int days = dt.daysTo( QDate::currentDate() ); 2329 int days = dt.daysTo( QDate::currentDate() );
2316 dt = dt.addDays( days ); 2330 dt = dt.addDays( days );
2317 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2331 int secs = dt.secsTo( QDateTime::currentDateTime() );
2318 config->writeEntry( "LatestProgramStopDays", days ); 2332 config->writeEntry( "LatestProgramStopDays", days );
2319 config->writeEntry( "LatestProgramStopSecs", secs ); 2333 config->writeEntry( "LatestProgramStopSecs", secs );
2320 //qDebug("KO: Writing stop time: %d ", secs); 2334 //qDebug("KO: Writing stop time: %d ", secs);
2321 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2335 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2322 //QDateTime latest = dt.addSecs ( secs ); 2336 //QDateTime latest = dt.addSecs ( secs );
2323 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2337 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2324 config->setGroup( "Views" ); 2338 config->setGroup( "Views" );
2325 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2339 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2326 2340
2327#if 0 2341#if 0
2328 qDebug("********************* "); 2342 qDebug("********************* ");
2329 qDebug("Testcode secsto "); 2343 qDebug("Testcode secsto ");
2330 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2344 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2331 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2345 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2332 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2346 int secsto = dt_nodaylight.secsTo( dt_daylight );
2333 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2347 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2334 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2348 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2335 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2349 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2336 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2350 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2337 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2351 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2338 qDebug("********************* testcode end"); 2352 qDebug("********************* testcode end");
2339 2353
2340#endif 2354#endif
2341 2355
2342 QValueList<int> listINT = mLeftFrame->sizes(); 2356 QValueList<int> listINT = mLeftFrame->sizes();
2343 config->writeEntry("Left Splitter Frame",listINT); 2357 config->writeEntry("Left Splitter Frame",listINT);
2344 QValueList<int> listINT2 = mMainFrame->sizes(); 2358 QValueList<int> listINT2 = mMainFrame->sizes();
2345 config->writeEntry("Main Splitter Frame",listINT2); 2359 config->writeEntry("Main Splitter Frame",listINT2);
2346#ifdef DESKTOP_VERSION 2360#ifdef DESKTOP_VERSION
2347 config->setGroup("WidgetLayout"); 2361 config->setGroup("WidgetLayout");
2348 QStringList list ;//= config->readListEntry("MainLayout"); 2362 QStringList list ;//= config->readListEntry("MainLayout");
2349 int x,y,w,h; 2363 int x,y,w,h;
2350 QWidget* wid; 2364 QWidget* wid;
2351 wid = topLevelWidget(); 2365 wid = topLevelWidget();
2352 x = wid->geometry().x(); 2366 x = wid->geometry().x();
2353 y = wid->geometry().y(); 2367 y = wid->geometry().y();
2354 w = wid->width(); 2368 w = wid->width();
2355 h = wid->height(); 2369 h = wid->height();
2356 list.clear(); 2370 list.clear();
2357 list << QString::number( x ); 2371 list << QString::number( x );
2358 list << QString::number( y ); 2372 list << QString::number( y );
2359 list << QString::number( w ); 2373 list << QString::number( w );
2360 list << QString::number( h ); 2374 list << QString::number( h );
2361 config->writeEntry("MainLayout",list ); 2375 config->writeEntry("MainLayout",list );
2362 2376
2363 wid = mEventEditor; 2377 wid = mEventEditor;
2364 x = wid->geometry().x(); 2378 x = wid->geometry().x();
2365 y = wid->geometry().y(); 2379 y = wid->geometry().y();
2366 w = wid->width(); 2380 w = wid->width();
2367 h = wid->height(); 2381 h = wid->height();
2368 list.clear(); 2382 list.clear();
2369 list << QString::number( x ); 2383 list << QString::number( x );
2370 list << QString::number( y ); 2384 list << QString::number( y );
2371 list << QString::number( w ); 2385 list << QString::number( w );
2372 list << QString::number( h ); 2386 list << QString::number( h );
2373 config->writeEntry("EditEventLayout",list ); 2387 config->writeEntry("EditEventLayout",list );
2374 2388
2375 wid = mTodoEditor; 2389 wid = mTodoEditor;
2376 x = wid->geometry().x(); 2390 x = wid->geometry().x();
2377 y = wid->geometry().y(); 2391 y = wid->geometry().y();
2378 w = wid->width(); 2392 w = wid->width();
2379 h = wid->height(); 2393 h = wid->height();
2380 list.clear(); 2394 list.clear();
2381 list << QString::number( x ); 2395 list << QString::number( x );
2382 list << QString::number( y ); 2396 list << QString::number( y );
2383 list << QString::number( w ); 2397 list << QString::number( w );
2384 list << QString::number( h ); 2398 list << QString::number( h );
2385 config->writeEntry("EditTodoLayout",list ); 2399 config->writeEntry("EditTodoLayout",list );
2386 wid = getEventViewerDialog(); 2400 wid = getEventViewerDialog();
2387 x = wid->geometry().x(); 2401 x = wid->geometry().x();
2388 y = wid->geometry().y(); 2402 y = wid->geometry().y();
2389 w = wid->width(); 2403 w = wid->width();
2390 h = wid->height(); 2404 h = wid->height();
2391 list.clear(); 2405 list.clear();
2392 list << QString::number( x ); 2406 list << QString::number( x );
2393 list << QString::number( y ); 2407 list << QString::number( y );
2394 list << QString::number( w ); 2408 list << QString::number( w );
2395 list << QString::number( h ); 2409 list << QString::number( h );
2396 config->writeEntry("ViewerLayout",list ); 2410 config->writeEntry("ViewerLayout",list );
2397 wid = mDialogManager->getSearchDialog(); 2411 wid = mDialogManager->getSearchDialog();
2398 if ( wid ) { 2412 if ( wid ) {
2399 x = wid->geometry().x(); 2413 x = wid->geometry().x();
2400 y = wid->geometry().y(); 2414 y = wid->geometry().y();
2401 w = wid->width(); 2415 w = wid->width();
2402 h = wid->height(); 2416 h = wid->height();
2403 list.clear(); 2417 list.clear();
2404 list << QString::number( x ); 2418 list << QString::number( x );
2405 list << QString::number( y ); 2419 list << QString::number( y );
2406 list << QString::number( w ); 2420 list << QString::number( w );
2407 list << QString::number( h ); 2421 list << QString::number( h );
2408 config->writeEntry("SearchLayout",list ); 2422 config->writeEntry("SearchLayout",list );
2409 } 2423 }
2410#endif 2424#endif
2411 2425
2412 2426
2413 config->sync(); 2427 config->sync();
2414} 2428}
2415 2429
2416void CalendarView::readFilterSettings(KConfig *config) 2430void CalendarView::readFilterSettings(KConfig *config)
2417{ 2431{
2418 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2432 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2419 2433
2420 mFilters.clear(); 2434 mFilters.clear();
2421 2435
2422 config->setGroup("General"); 2436 config->setGroup("General");
2423 QStringList filterList = config->readListEntry("CalendarFilters"); 2437 QStringList filterList = config->readListEntry("CalendarFilters");
2424 2438
2425 QStringList::ConstIterator it = filterList.begin(); 2439 QStringList::ConstIterator it = filterList.begin();
2426 QStringList::ConstIterator end = filterList.end(); 2440 QStringList::ConstIterator end = filterList.end();
2427 while(it != end) { 2441 while(it != end) {
2428 // kdDebug() << " filter: " << (*it) << endl; 2442 // kdDebug() << " filter: " << (*it) << endl;
2429 2443
2430 CalFilter *filter; 2444 CalFilter *filter;
2431 filter = new CalFilter(*it); 2445 filter = new CalFilter(*it);
2432 config->setGroup("Filter_" + (*it).utf8()); 2446 config->setGroup("Filter_" + (*it).utf8());
2433 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2447 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2434 filter->setCriteria(config->readNumEntry("Criteria",0)); 2448 filter->setCriteria(config->readNumEntry("Criteria",0));
2435 filter->setCategoryList(config->readListEntry("CategoryList")); 2449 filter->setCategoryList(config->readListEntry("CategoryList"));
2436 mFilters.append(filter); 2450 mFilters.append(filter);
2437 2451
2438 ++it; 2452 ++it;
2439 } 2453 }
2440 2454
2441 if (mFilters.count() == 0) { 2455 if (mFilters.count() == 0) {
2442 CalFilter *filter = new CalFilter(i18n("Default")); 2456 CalFilter *filter = new CalFilter(i18n("Default"));
2443 mFilters.append(filter); 2457 mFilters.append(filter);
2444 } 2458 }
2445 mFilterView->updateFilters(); 2459 mFilterView->updateFilters();
2446 config->setGroup("FilterView"); 2460 config->setGroup("FilterView");
2447 2461
2448 mFilterView->blockSignals(true); 2462 mFilterView->blockSignals(true);
2449 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2463 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2450 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2464 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2451 mFilterView->blockSignals(false); 2465 mFilterView->blockSignals(false);
2452 // We do it manually to avoid it being done twice by the above calls 2466 // We do it manually to avoid it being done twice by the above calls
2453 updateFilter(); 2467 updateFilter();
2454} 2468}
2455 2469
2456void CalendarView::writeFilterSettings(KConfig *config) 2470void CalendarView::writeFilterSettings(KConfig *config)
2457{ 2471{
2458 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2472 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2459 2473
2460 QStringList filterList; 2474 QStringList filterList;
2461 2475
2462 CalFilter *filter = mFilters.first(); 2476 CalFilter *filter = mFilters.first();
2463 while(filter) { 2477 while(filter) {
2464 // kdDebug() << " fn: " << filter->name() << endl; 2478 // kdDebug() << " fn: " << filter->name() << endl;
2465 filterList << filter->name(); 2479 filterList << filter->name();
2466 config->setGroup("Filter_" + filter->name().utf8()); 2480 config->setGroup("Filter_" + filter->name().utf8());
2467 config->writeEntry("Criteria",filter->criteria()); 2481 config->writeEntry("Criteria",filter->criteria());
2468 config->writeEntry("CategoryList",filter->categoryList()); 2482 config->writeEntry("CategoryList",filter->categoryList());
2469 filter = mFilters.next(); 2483 filter = mFilters.next();
2470 } 2484 }
2471 config->setGroup("General"); 2485 config->setGroup("General");
2472 config->writeEntry("CalendarFilters",filterList); 2486 config->writeEntry("CalendarFilters",filterList);
2473 2487
2474 config->setGroup("FilterView"); 2488 config->setGroup("FilterView");
2475 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2489 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2476 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2490 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2477} 2491}
2478 2492
2479 2493
2480void CalendarView::goToday() 2494void CalendarView::goToday()
2481{ 2495{
2482 if ( mViewManager->currentView()->isMonthView() ) 2496 if ( mViewManager->currentView()->isMonthView() )
2483 mNavigator->selectTodayMonth(); 2497 mNavigator->selectTodayMonth();
2484 else 2498 else
2485 mNavigator->selectToday(); 2499 mNavigator->selectToday();
2486} 2500}
2487 2501
2488void CalendarView::goNext() 2502void CalendarView::goNext()
2489{ 2503{
2490 mNavigator->selectNext(); 2504 mNavigator->selectNext();
2491} 2505}
2492 2506
2493void CalendarView::goPrevious() 2507void CalendarView::goPrevious()
2494{ 2508{
2495 mNavigator->selectPrevious(); 2509 mNavigator->selectPrevious();
2496} 2510}
2497void CalendarView::goNextMonth() 2511void CalendarView::goNextMonth()
2498{ 2512{
2499 mNavigator->selectNextMonth(); 2513 mNavigator->selectNextMonth();
2500} 2514}
2501 2515
2502void CalendarView::goPreviousMonth() 2516void CalendarView::goPreviousMonth()
2503{ 2517{
2504 mNavigator->selectPreviousMonth(); 2518 mNavigator->selectPreviousMonth();
2505} 2519}
2506 2520
2507void CalendarView::updateConfig() 2521void CalendarView::updateConfig()
2508{ 2522{
2509 if ( KOPrefs::instance()->mUseAppColors ) 2523 if ( KOPrefs::instance()->mUseAppColors )
2510 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2524 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2511 emit configChanged(); 2525 emit configChanged();
2512 mTodoList->updateConfig(); 2526 mTodoList->updateConfig();
2513 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2527 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2514 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2528 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2515 // To make the "fill window" configurations work 2529 // To make the "fill window" configurations work
2516 //mViewManager->raiseCurrentView(); 2530 //mViewManager->raiseCurrentView();
2517} 2531}
2518 2532
2519 2533
2520void CalendarView::eventChanged(Event *event) 2534void CalendarView::eventChanged(Event *event)
2521{ 2535{
2522 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2536 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2523 //updateUnmanagedViews(); 2537 //updateUnmanagedViews();
2524} 2538}
2525 2539
2526void CalendarView::eventAdded(Event *event) 2540void CalendarView::eventAdded(Event *event)
2527{ 2541{
2528 changeEventDisplay(event,KOGlobals::EVENTADDED); 2542 changeEventDisplay(event,KOGlobals::EVENTADDED);
2529} 2543}
2530 2544
2531void CalendarView::eventToBeDeleted(Event *) 2545void CalendarView::eventToBeDeleted(Event *)
2532{ 2546{
2533 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2547 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2534} 2548}
2535 2549
2536void CalendarView::eventDeleted() 2550void CalendarView::eventDeleted()
2537{ 2551{
2538 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2552 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2539} 2553}
2540void CalendarView::changeTodoDisplay(Todo *which, int action) 2554void CalendarView::changeTodoDisplay(Todo *which, int action)
2541{ 2555{
2542 changeIncidenceDisplay((Incidence *)which, action); 2556 changeIncidenceDisplay((Incidence *)which, action);
2543 mDateNavigator->updateView(); //LR 2557 mDateNavigator->updateView(); //LR
2544 //mDialogManager->updateSearchDialog(); 2558 //mDialogManager->updateSearchDialog();
2545 2559
2546 if (which) { 2560 if (which) {
2547 mViewManager->updateWNview(); 2561 mViewManager->updateWNview();
2548 //mTodoList->updateView(); 2562 //mTodoList->updateView();
2549 } 2563 }
2550 2564
2551} 2565}
2552 2566
2553void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2567void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2554{ 2568{
2555 updateUnmanagedViews(); 2569 updateUnmanagedViews();
2556 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2570 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2557 if ( action == KOGlobals::EVENTDELETED ) { //delete 2571 if ( action == KOGlobals::EVENTDELETED ) { //delete
2558 mCalendar->checkAlarmForIncidence( 0, true ); 2572 mCalendar->checkAlarmForIncidence( 0, true );
2559 if ( mEventViewerDialog ) 2573 if ( mEventViewerDialog )
2560 mEventViewerDialog->hide(); 2574 mEventViewerDialog->hide();
2561 } 2575 }
2562 else 2576 else
2563 mCalendar->checkAlarmForIncidence( which , false ); 2577 mCalendar->checkAlarmForIncidence( which , false );
2564} 2578}
2565 2579
2566// most of the changeEventDisplays() right now just call the view's 2580// most of the changeEventDisplays() right now just call the view's
2567// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2581// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2568void CalendarView::changeEventDisplay(Event *which, int action) 2582void CalendarView::changeEventDisplay(Event *which, int action)
2569{ 2583{
2570 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2584 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2571 changeIncidenceDisplay((Incidence *)which, action); 2585 changeIncidenceDisplay((Incidence *)which, action);
2572 mDateNavigator->updateView(); 2586 mDateNavigator->updateView();
2573 //mDialogManager->updateSearchDialog(); 2587 //mDialogManager->updateSearchDialog();
2574 2588
2575 if (which) { 2589 if (which) {
2576 // If there is an event view visible update the display 2590 // If there is an event view visible update the display
2577 mViewManager->currentView()->changeEventDisplay(which,action); 2591 mViewManager->currentView()->changeEventDisplay(which,action);
2578 // TODO: check, if update needed 2592 // TODO: check, if update needed
2579 // if (which->getTodoStatus()) { 2593 // if (which->getTodoStatus()) {
2580 mTodoList->updateView(); 2594 mTodoList->updateView();
2581 // } 2595 // }
2582 } else { 2596 } else {
2583 mViewManager->currentView()->updateView(); 2597 mViewManager->currentView()->updateView();
2584 } 2598 }
2585} 2599}
2586 2600
2587 2601
2588void CalendarView::updateTodoViews() 2602void CalendarView::updateTodoViews()
2589{ 2603{
2590 mTodoList->updateView(); 2604 mTodoList->updateView();
2591 mViewManager->currentView()->updateView(); 2605 mViewManager->currentView()->updateView();
2592 2606
2593} 2607}
2594 2608
2595 2609
2596void CalendarView::updateView(const QDate &start, const QDate &end) 2610void CalendarView::updateView(const QDate &start, const QDate &end)
2597{ 2611{
2598#ifdef DESKTOP_VERSION 2612#ifdef DESKTOP_VERSION
2599 mDateScrollBar->blockSignals( true ); 2613 mDateScrollBar->blockSignals( true );
2600 mDateScrollBar->setValue( start.dayOfYear()-1); 2614 mDateScrollBar->setValue( start.dayOfYear()-1);
2601 mDateScrollBar->blockSignals( false ); 2615 mDateScrollBar->blockSignals( false );
2602#endif 2616#endif
2603 mTodoList->updateView(); 2617 mTodoList->updateView();
2604 mViewManager->updateView(start, end); 2618 mViewManager->updateView(start, end);
2605 //mDateNavigator->updateView(); 2619 //mDateNavigator->updateView();
2606} 2620}
2607 2621
2608void CalendarView::clearAllViews() 2622void CalendarView::clearAllViews()
2609{ 2623{
2610 mTodoList->clearList(); 2624 mTodoList->clearList();
2611 mViewManager->clearAllViews(); 2625 mViewManager->clearAllViews();
2612 SearchDialog * sd = mDialogManager->getSearchDialog(); 2626 SearchDialog * sd = mDialogManager->getSearchDialog();
2613 if ( sd ) { 2627 if ( sd ) {
2614 KOListView* kol = sd->listview(); 2628 KOListView* kol = sd->listview();
2615 if ( kol ) 2629 if ( kol )
2616 kol->clearList(); 2630 kol->clearList();
2617 } 2631 }
2618} 2632}
2619void CalendarView::updateView() 2633void CalendarView::updateView()
2620{ 2634{
2621 DateList tmpList = mNavigator->selectedDates(); 2635 DateList tmpList = mNavigator->selectedDates();
2622 2636
2623 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2637 if ( KOPrefs::instance()->mHideNonStartedTodos )
2624 mTodoList->updateView(); 2638 mTodoList->updateView();
2625 // We assume that the navigator only selects consecutive days. 2639 // We assume that the navigator only selects consecutive days.
2626 updateView( tmpList.first(), tmpList.last() ); 2640 updateView( tmpList.first(), tmpList.last() );
2627} 2641}
2628 2642
2629void CalendarView::updateUnmanagedViews() 2643void CalendarView::updateUnmanagedViews()
2630{ 2644{
2631 mDateNavigator->updateDayMatrix(); 2645 mDateNavigator->updateDayMatrix();
2632} 2646}
2633 2647
2634int CalendarView::msgItemDelete(const QString name) 2648int CalendarView::msgItemDelete(const QString name)
2635{ 2649{
2636 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2650 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2637 i18n("This item will be\npermanently deleted."), 2651 i18n("This item will be\npermanently deleted."),
2638 i18n("KO/Pi Confirmation"),i18n("Delete")); 2652 i18n("KO/Pi Confirmation"),i18n("Delete"));
2639} 2653}
2640 2654
2641 2655
2642void CalendarView::edit_cut() 2656void CalendarView::edit_cut()
2643{ 2657{
2644 Event *anEvent=0; 2658 Event *anEvent=0;
2645 2659
2646 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2660 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2647 2661
2648 if (mViewManager->currentView()->isEventView()) { 2662 if (mViewManager->currentView()->isEventView()) {
2649 if ( incidence && incidence->typeID() == eventID ) { 2663 if ( incidence && incidence->typeID() == eventID ) {
2650 anEvent = static_cast<Event *>(incidence); 2664 anEvent = static_cast<Event *>(incidence);
2651 } 2665 }
2652 } 2666 }
2653 2667
2654 if (!anEvent) { 2668 if (!anEvent) {
2655 KNotifyClient::beep(); 2669 KNotifyClient::beep();
2656 return; 2670 return;
2657 } 2671 }
2658 DndFactory factory( mCalendar ); 2672 DndFactory factory( mCalendar );
2659 factory.cutIncidence(anEvent); 2673 factory.cutIncidence(anEvent);
2660 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2674 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2661} 2675}
2662 2676
2663void CalendarView::edit_copy() 2677void CalendarView::edit_copy()
2664{ 2678{
2665 Event *anEvent=0; 2679 Event *anEvent=0;
2666 2680
2667 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2681 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2668 2682
2669 if (mViewManager->currentView()->isEventView()) { 2683 if (mViewManager->currentView()->isEventView()) {
2670 if ( incidence && incidence->typeID() == eventID ) { 2684 if ( incidence && incidence->typeID() == eventID ) {
2671 anEvent = static_cast<Event *>(incidence); 2685 anEvent = static_cast<Event *>(incidence);
2672 } 2686 }
2673 } 2687 }
2674 2688
2675 if (!anEvent) { 2689 if (!anEvent) {
2676 KNotifyClient::beep(); 2690 KNotifyClient::beep();
2677 return; 2691 return;
2678 } 2692 }
2679 DndFactory factory( mCalendar ); 2693 DndFactory factory( mCalendar );
2680 factory.copyIncidence(anEvent); 2694 factory.copyIncidence(anEvent);
2681} 2695}
2682 2696
2683void CalendarView::edit_paste() 2697void CalendarView::edit_paste()
2684{ 2698{
2685 QDate date = mNavigator->selectedDates().first(); 2699 QDate date = mNavigator->selectedDates().first();
2686 2700
2687 DndFactory factory( mCalendar ); 2701 DndFactory factory( mCalendar );
2688 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2702 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2689 2703
2690 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2704 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2691} 2705}
2692void CalendarView::edit_global_options() 2706void CalendarView::edit_global_options()
2693{ 2707{
2694 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2708 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2695 emit save(); 2709 emit save();
2696 emit saveStopTimer(); 2710 emit saveStopTimer();
2697 mDialogManager->showGlobalOptionsDialog(); 2711 mDialogManager->showGlobalOptionsDialog();
2698 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2712 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2699 emit saveStopTimer(); 2713 emit saveStopTimer();
2700 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2714 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2701 i18n("Timezone settings"),i18n("Reload"))) { 2715 i18n("Timezone settings"),i18n("Reload"))) {
2702 qDebug("KO: TZ reload cancelled "); 2716 qDebug("KO: TZ reload cancelled ");
2703 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2717 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2704 return; 2718 return;
2705 } 2719 }
2706 qDebug("KO: Timezone change "); 2720 qDebug("KO: Timezone change ");
2707 loadCalendars(); 2721 loadCalendars();
2708 setModified(true); 2722 setModified(true);
2709 } 2723 }
2710 else 2724 else
2711 qDebug("KO: No tz change "); 2725 qDebug("KO: No tz change ");
2712} 2726}
2713void CalendarView::edit_options() 2727void CalendarView::edit_options()
2714{ 2728{
2715 mDialogManager->showOptionsDialog(); 2729 mDialogManager->showOptionsDialog();
2716} 2730}
2717 2731
2718 2732
2719void CalendarView::slotSelectPickerDate( QDate d) 2733void CalendarView::slotSelectPickerDate( QDate d)
2720{ 2734{
2721 mDateFrame->hide(); 2735 mDateFrame->hide();
2722 if ( mDatePickerMode == 1 ) { 2736 if ( mDatePickerMode == 1 ) {
2723 mNavigator->slotDaySelect( d ); 2737 mNavigator->slotDaySelect( d );
2724 } else if ( mDatePickerMode == 2 ) { 2738 } else if ( mDatePickerMode == 2 ) {
2725 if ( mMoveIncidence->typeID() == todoID ) { 2739 if ( mMoveIncidence->typeID() == todoID ) {
2726 Todo * to = (Todo *) mMoveIncidence; 2740 Todo * to = (Todo *) mMoveIncidence;
2727 QTime tim; 2741 QTime tim;
2728 int len = 0; 2742 int len = 0;
2729 if ( to->hasStartDate() && to->hasDueDate() ) 2743 if ( to->hasStartDate() && to->hasDueDate() )
2730 len = to->dtStart().secsTo( to->dtDue()); 2744 len = to->dtStart().secsTo( to->dtDue());
2731 if ( to->hasDueDate() ) 2745 if ( to->hasDueDate() )
2732 tim = to->dtDue().time(); 2746 tim = to->dtDue().time();
2733 else { 2747 else {
2734 tim = QTime ( 0,0,0 ); 2748 tim = QTime ( 0,0,0 );
2735 to->setFloats( true ); 2749 to->setFloats( true );
2736 to->setHasDueDate( true ); 2750 to->setHasDueDate( true );
2737 } 2751 }
2738 QDateTime dt ( d,tim ); 2752 QDateTime dt ( d,tim );
2739 to->setDtDue( dt ); 2753 to->setDtDue( dt );
2740 2754
2741 if ( to->hasStartDate() ) { 2755 if ( to->hasStartDate() ) {
2742 if ( len>0 ) 2756 if ( len>0 )
2743 to->setDtStart(to->dtDue().addSecs( -len )); 2757 to->setDtStart(to->dtDue().addSecs( -len ));
2744 else 2758 else
2745 if (to->dtStart() > to->dtDue() ) 2759 if (to->dtStart() > to->dtDue() )
2746 to->setDtStart(to->dtDue().addDays( -3 )); 2760 to->setDtStart(to->dtDue().addDays( -3 ));
2747 } 2761 }
2748 2762
2749 todoChanged( to ); 2763 todoChanged( to );
2750 } else { 2764 } else {
2751 if ( mMoveIncidence->doesRecur() ) { 2765 if ( mMoveIncidence->doesRecur() ) {
2752#if 0 2766#if 0
2753 // PENDING implement this 2767 // PENDING implement this
2754 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2768 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2755 mCalendar()->addIncidence( newInc ); 2769 mCalendar()->addIncidence( newInc );
2756 if ( mMoveIncidence->typeID() == todoID ) 2770 if ( mMoveIncidence->typeID() == todoID )
2757 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2771 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2758 else 2772 else
2759 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2773 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2760 mMoveIncidence = newInc; 2774 mMoveIncidence = newInc;
2761 2775
2762#endif 2776#endif
2763 } 2777 }
2764 QTime tim = mMoveIncidence->dtStart().time(); 2778 QTime tim = mMoveIncidence->dtStart().time();
2765 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2779 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2766 QDateTime dt ( d,tim ); 2780 QDateTime dt ( d,tim );
2767 mMoveIncidence->setDtStart( dt ); 2781 mMoveIncidence->setDtStart( dt );
2768 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2782 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2769 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2783 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2770 } 2784 }
2771 2785
2772 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2786 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2773 } 2787 }
2774} 2788}
2775 2789
2776void CalendarView::removeCategories() 2790void CalendarView::removeCategories()
2777{ 2791{
2778 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2792 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2779 QStringList catList = KOPrefs::instance()->mCustomCategories; 2793 QStringList catList = KOPrefs::instance()->mCustomCategories;
2780 QStringList catIncList; 2794 QStringList catIncList;
2781 QStringList newCatList; 2795 QStringList newCatList;
2782 Incidence* inc = incList.first(); 2796 Incidence* inc = incList.first();
2783 int i; 2797 int i;
2784 int count = 0; 2798 int count = 0;
2785 while ( inc ) { 2799 while ( inc ) {
2786 newCatList.clear(); 2800 newCatList.clear();
2787 catIncList = inc->categories() ; 2801 catIncList = inc->categories() ;
2788 for( i = 0; i< catIncList.count(); ++i ) { 2802 for( i = 0; i< catIncList.count(); ++i ) {
2789 if ( catList.contains (catIncList[i])) 2803 if ( catList.contains (catIncList[i]))
2790 newCatList.append( catIncList[i] ); 2804 newCatList.append( catIncList[i] );
2791 } 2805 }
2792 newCatList.sort(); 2806 newCatList.sort();
2793 inc->setCategories( newCatList.join(",") ); 2807 inc->setCategories( newCatList.join(",") );
2794 inc = incList.next(); 2808 inc = incList.next();
2795 } 2809 }
2796} 2810}
2797 2811
2798int CalendarView::addCategories() 2812int CalendarView::addCategories()
2799{ 2813{
2800 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2814 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2801 QStringList catList = KOPrefs::instance()->mCustomCategories; 2815 QStringList catList = KOPrefs::instance()->mCustomCategories;
2802 QStringList catIncList; 2816 QStringList catIncList;
2803 Incidence* inc = incList.first(); 2817 Incidence* inc = incList.first();
2804 int i; 2818 int i;
2805 int count = 0; 2819 int count = 0;
2806 while ( inc ) { 2820 while ( inc ) {
2807 catIncList = inc->categories() ; 2821 catIncList = inc->categories() ;
2808 for( i = 0; i< catIncList.count(); ++i ) { 2822 for( i = 0; i< catIncList.count(); ++i ) {
2809 if ( !catList.contains (catIncList[i])) { 2823 if ( !catList.contains (catIncList[i])) {
2810 catList.append( catIncList[i] ); 2824 catList.append( catIncList[i] );
2811 //qDebug("add cat %s ", catIncList[i].latin1()); 2825 //qDebug("add cat %s ", catIncList[i].latin1());
2812 ++count; 2826 ++count;
2813 } 2827 }
2814 } 2828 }
2815 inc = incList.next(); 2829 inc = incList.next();
2816 } 2830 }
2817 catList.sort(); 2831 catList.sort();
2818 KOPrefs::instance()->mCustomCategories = catList; 2832 KOPrefs::instance()->mCustomCategories = catList;
2819 return count; 2833 return count;
2820} 2834}
2821 2835
2822void CalendarView::editCategories() 2836void CalendarView::editCategories()
2823{ 2837{
2824 qDebug("CalendarView::editCategories() "); 2838 qDebug("CalendarView::editCategories() ");
2825 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 2839 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
2826 ced.exec(); 2840 ced.exec();
2827} 2841}
2828void CalendarView::manageCategories() 2842void CalendarView::manageCategories()
2829{ 2843{
2830 KOCatPrefs* cp = new KOCatPrefs(); 2844 KOCatPrefs* cp = new KOCatPrefs();
2831 cp->show(); 2845 cp->show();
2832 int w =cp->sizeHint().width() ; 2846 int w =cp->sizeHint().width() ;
2833 int h = cp->sizeHint().height() ; 2847 int h = cp->sizeHint().height() ;
2834 int dw = QApplication::desktop()->width(); 2848 int dw = QApplication::desktop()->width();
2835 int dh = QApplication::desktop()->height(); 2849 int dh = QApplication::desktop()->height();
2836 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2850 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2837 if ( !cp->exec() ) { 2851 if ( !cp->exec() ) {
2838 delete cp; 2852 delete cp;
2839 return; 2853 return;
2840 } 2854 }
2841 int count = 0; 2855 int count = 0;
2842 if ( cp->addCat() ) { 2856 if ( cp->addCat() ) {
2843 count = addCategories(); 2857 count = addCategories();
2844 if ( count ) { 2858 if ( count ) {
2845 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2859 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2846 writeSettings(); 2860 writeSettings();
2847 } else 2861 } else
2848 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2862 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2849 } else { 2863 } else {
2850 removeCategories(); 2864 removeCategories();
2851 updateView(); 2865 updateView();
2852 } 2866 }
2853 delete cp; 2867 delete cp;
2854} 2868}
2855 2869
2856void CalendarView::beamIncidence(Incidence * Inc) 2870void CalendarView::beamIncidence(Incidence * Inc)
2857{ 2871{
2858 QPtrList<Incidence> delSel ; 2872 QPtrList<Incidence> delSel ;
2859 delSel.append(Inc); 2873 delSel.append(Inc);
2860 beamIncidenceList( delSel ); 2874 beamIncidenceList( delSel );
2861} 2875}
2862void CalendarView::beamCalendar() 2876void CalendarView::beamCalendar()
2863{ 2877{
2864 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2878 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2865 //qDebug("beamCalendar() "); 2879 //qDebug("beamCalendar() ");
2866 beamIncidenceList( delSel ); 2880 beamIncidenceList( delSel );
2867} 2881}
2868void CalendarView::beamFilteredCalendar() 2882void CalendarView::beamFilteredCalendar()
2869{ 2883{
2870 QPtrList<Incidence> delSel = mCalendar->incidences(); 2884 QPtrList<Incidence> delSel = mCalendar->incidences();
2871 //qDebug("beamFilteredCalendar() "); 2885 //qDebug("beamFilteredCalendar() ");
2872 beamIncidenceList( delSel ); 2886 beamIncidenceList( delSel );
2873} 2887}
2874void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2888void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2875{ 2889{
2876 2890
2877 KOBeamPrefs beamDialog; 2891 KOBeamPrefs beamDialog;
2878 if ( beamDialog.exec () == QDialog::Rejected ) 2892 if ( beamDialog.exec () == QDialog::Rejected )
2879 return; 2893 return;
2880#ifdef DESKTOP_VERSION 2894#ifdef DESKTOP_VERSION
2881 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2895 QString fn = locateLocal( "tmp", "kopibeamfile" );
2882#else 2896#else
2883 QString fn = "/tmp/kopibeamfile"; 2897 QString fn = "/tmp/kopibeamfile";
2884#endif 2898#endif
2885 QString mes; 2899 QString mes;
2886 bool createbup = true; 2900 bool createbup = true;
2887 if ( createbup ) { 2901 if ( createbup ) {
2888 QString description = "\n"; 2902 QString description = "\n";
2889 CalendarLocal* cal = new CalendarLocal(); 2903 CalendarLocal* cal = new CalendarLocal();
2890 if ( beamDialog.beamLocal() ) 2904 if ( beamDialog.beamLocal() )
2891 cal->setLocalTime(); 2905 cal->setLocalTime();
2892 else 2906 else
2893 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2907 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2894 Incidence *incidence = delSel.first(); 2908 Incidence *incidence = delSel.first();
2895 bool addText = false; 2909 bool addText = false;
2896 if ( delSel.count() < 10 ) 2910 if ( delSel.count() < 10 )
2897 addText = true; 2911 addText = true;
2898 else { 2912 else {
2899 description.sprintf(i18n(" %d items?"),delSel.count() ); 2913 description.sprintf(i18n(" %d items?"),delSel.count() );
2900 } 2914 }
2901 while ( incidence ) { 2915 while ( incidence ) {
2902 Incidence *in = incidence->clone(); 2916 Incidence *in = incidence->clone();
2903 if ( ! in->summary().isEmpty() ) { 2917 if ( ! in->summary().isEmpty() ) {
2904 in->setDescription(""); 2918 in->setDescription("");
2905 } else { 2919 } else {
2906 in->setSummary( in->description().left(20)); 2920 in->setSummary( in->description().left(20));
2907 in->setDescription(""); 2921 in->setDescription("");
2908 } 2922 }
2909 if ( addText ) 2923 if ( addText )
2910 description += in->summary() + "\n"; 2924 description += in->summary() + "\n";
2911 cal->addIncidence( in ); 2925 cal->addIncidence( in );
2912 incidence = delSel.next(); 2926 incidence = delSel.next();
2913 } 2927 }
2914 if ( beamDialog.beamVcal() ) { 2928 if ( beamDialog.beamVcal() ) {
2915 fn += ".vcs"; 2929 fn += ".vcs";
2916 FileStorage storage( cal, fn, new VCalFormat ); 2930 FileStorage storage( cal, fn, new VCalFormat );
2917 storage.save(); 2931 storage.save();
2918 } else { 2932 } else {
2919 fn += ".ics"; 2933 fn += ".ics";
2920 FileStorage storage( cal, fn, new ICalFormat( ) ); 2934 FileStorage storage( cal, fn, new ICalFormat( ) );
2921 storage.save(); 2935 storage.save();
2922 } 2936 }
2923 delete cal; 2937 delete cal;
2924 mes = i18n("KO/Pi: Ready for beaming"); 2938 mes = i18n("KO/Pi: Ready for beaming");
2925 topLevelWidget()->setCaption(mes); 2939 topLevelWidget()->setCaption(mes);
2926 KApplication::convert2latin1( fn ); 2940 KApplication::convert2latin1( fn );
2927#ifndef DESKTOP_VERSION 2941#ifndef DESKTOP_VERSION
2928 Ir *ir = new Ir( this ); 2942 Ir *ir = new Ir( this );
2929 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2943 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2930 ir->send( fn, description, "text/x-vCalendar" ); 2944 ir->send( fn, description, "text/x-vCalendar" );
2931#endif 2945#endif
2932 } 2946 }
2933} 2947}
2934void CalendarView::beamDone( Ir *ir ) 2948void CalendarView::beamDone( Ir *ir )
2935{ 2949{
2936#ifndef DESKTOP_VERSION 2950#ifndef DESKTOP_VERSION
2937 delete ir; 2951 delete ir;
2938#endif 2952#endif
2939 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2953 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2940 topLevelWidget()->raise(); 2954 topLevelWidget()->raise();
2941} 2955}
2942 2956
2943void CalendarView::moveIncidence(Incidence * inc ) 2957void CalendarView::moveIncidence(Incidence * inc )
2944{ 2958{
2945 if ( !inc ) return; 2959 if ( !inc ) return;
2946 showDatePickerPopup(); 2960 showDatePickerPopup();
2947 mDatePickerMode = 2; 2961 mDatePickerMode = 2;
2948 mMoveIncidence = inc ; 2962 mMoveIncidence = inc ;
2949 QDate da; 2963 QDate da;
2950 if ( mMoveIncidence->typeID() == todoID ) { 2964 if ( mMoveIncidence->typeID() == todoID ) {
2951 Todo * to = (Todo *) mMoveIncidence; 2965 Todo * to = (Todo *) mMoveIncidence;
2952 if ( to->hasDueDate() ) 2966 if ( to->hasDueDate() )
2953 da = to->dtDue().date(); 2967 da = to->dtDue().date();
2954 else 2968 else
2955 da = QDate::currentDate(); 2969 da = QDate::currentDate();
2956 } else { 2970 } else {
2957 da = mMoveIncidence->dtStart().date(); 2971 da = mMoveIncidence->dtStart().date();
2958 } 2972 }
2959 //PENDING set date for recurring incidence to date of recurrence 2973 //PENDING set date for recurring incidence to date of recurrence
2960 //mMoveIncidenceOldDate; 2974 //mMoveIncidenceOldDate;
2961 mDatePicker->setDate( da ); 2975 mDatePicker->setDate( da );
2962} 2976}
2963void CalendarView::showDatePickerPopup() 2977void CalendarView::showDatePickerPopup()
2964{ 2978{
2965 if ( mDateFrame->isVisible() ) 2979 if ( mDateFrame->isVisible() )
2966 mDateFrame->hide(); 2980 mDateFrame->hide();
2967 else { 2981 else {
2968 int offX = 0, offY = 0; 2982 int offX = 0, offY = 0;
2969#ifdef DESKTOP_VERSION 2983#ifdef DESKTOP_VERSION
2970 int w =mDatePicker->sizeHint().width() ; 2984 int w =mDatePicker->sizeHint().width() ;
2971 int h = mDatePicker->sizeHint().height() ; 2985 int h = mDatePicker->sizeHint().height() ;
2972 int dw = topLevelWidget()->width(); 2986 int dw = topLevelWidget()->width();
2973 int dh = topLevelWidget()->height(); 2987 int dh = topLevelWidget()->height();
2974 offX = topLevelWidget()->x(); 2988 offX = topLevelWidget()->x();
2975 offY = topLevelWidget()->y(); 2989 offY = topLevelWidget()->y();
2976#else 2990#else
2977 int w =mDatePicker->sizeHint().width() ; 2991 int w =mDatePicker->sizeHint().width() ;
2978 int h = mDatePicker->sizeHint().height() ; 2992 int h = mDatePicker->sizeHint().height() ;
2979 int dw = QApplication::desktop()->width(); 2993 int dw = QApplication::desktop()->width();
2980 int dh = QApplication::desktop()->height(); 2994 int dh = QApplication::desktop()->height();
2981#endif 2995#endif
2982 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2996 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2983 mDateFrame->show(); 2997 mDateFrame->show();
2984 } 2998 }
2985} 2999}
2986void CalendarView::showDatePicker( ) 3000void CalendarView::showDatePicker( )
2987{ 3001{
2988 showDatePickerPopup(); 3002 showDatePickerPopup();
2989 mDatePickerMode = 1; 3003 mDatePickerMode = 1;
2990 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3004 mDatePicker->setDate( mNavigator->selectedDates().first() );
2991} 3005}
2992 3006
2993void CalendarView::showEventEditor() 3007void CalendarView::showEventEditor()
2994{ 3008{
2995#ifdef DESKTOP_VERSION 3009#ifdef DESKTOP_VERSION
2996 int x,y,w,h; 3010 int x,y,w,h;
2997 x = mEventEditor->geometry().x(); 3011 x = mEventEditor->geometry().x();
2998 y = mEventEditor->geometry().y(); 3012 y = mEventEditor->geometry().y();
2999 w = mEventEditor->width(); 3013 w = mEventEditor->width();
3000 h = mEventEditor->height(); 3014 h = mEventEditor->height();
3001 mEventEditor->show(); 3015 mEventEditor->show();
3002 mEventEditor->setGeometry(x,y,w,h); 3016 mEventEditor->setGeometry(x,y,w,h);
3003#else 3017#else
3004 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3018 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3005 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3019 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3006 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3020 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3007 qApp->processEvents(); 3021 qApp->processEvents();
3008 delete mEventEditor; 3022 delete mEventEditor;
3009 mEventEditor = mDialogManager->getEventEditor(); 3023 mEventEditor = mDialogManager->getEventEditor();
3010 topLevelWidget()->setCaption( i18n("") ); 3024 topLevelWidget()->setCaption( i18n("") );
3011 } 3025 }
3012 mEventEditor->showMaximized(); 3026 mEventEditor->showMaximized();
3013#endif 3027#endif
3014} 3028}
3015void CalendarView::showTodoEditor() 3029void CalendarView::showTodoEditor()
3016{ 3030{
3017#ifdef DESKTOP_VERSION 3031#ifdef DESKTOP_VERSION
3018 int x,y,w,h; 3032 int x,y,w,h;
3019 x = mTodoEditor->geometry().x(); 3033 x = mTodoEditor->geometry().x();
3020 y = mTodoEditor->geometry().y(); 3034 y = mTodoEditor->geometry().y();
3021 w = mTodoEditor->width(); 3035 w = mTodoEditor->width();
3022 h = mTodoEditor->height(); 3036 h = mTodoEditor->height();
3023 mTodoEditor->show(); 3037 mTodoEditor->show();
3024 mTodoEditor->setGeometry(x,y,w,h); 3038 mTodoEditor->setGeometry(x,y,w,h);
3025#else 3039#else
3026 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3040 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3027 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3041 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3028 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3042 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3029 qApp->processEvents(); 3043 qApp->processEvents();
3030 delete mTodoEditor; 3044 delete mTodoEditor;
3031 mTodoEditor = mDialogManager->getTodoEditor(); 3045 mTodoEditor = mDialogManager->getTodoEditor();
3032 topLevelWidget()->setCaption( i18n("") ); 3046 topLevelWidget()->setCaption( i18n("") );
3033 } 3047 }
3034 mTodoEditor->showMaximized(); 3048 mTodoEditor->showMaximized();
3035#endif 3049#endif
3036} 3050}
3037 3051
3038void CalendarView::cloneIncidence() 3052void CalendarView::cloneIncidence()
3039{ 3053{
3040 Incidence *incidence = currentSelection(); 3054 Incidence *incidence = currentSelection();
3041 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3055 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3042 if ( incidence ) { 3056 if ( incidence ) {
3043 cloneIncidence(incidence); 3057 cloneIncidence(incidence);
3044 } 3058 }
3045} 3059}
3046void CalendarView::moveIncidence() 3060void CalendarView::moveIncidence()
3047{ 3061{
3048 Incidence *incidence = currentSelection(); 3062 Incidence *incidence = currentSelection();
3049 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3063 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3050 if ( incidence ) { 3064 if ( incidence ) {
3051 moveIncidence(incidence); 3065 moveIncidence(incidence);
3052 } 3066 }
3053} 3067}
3054void CalendarView::beamIncidence() 3068void CalendarView::beamIncidence()
3055{ 3069{
3056 Incidence *incidence = currentSelection(); 3070 Incidence *incidence = currentSelection();
3057 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3071 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3058 if ( incidence ) { 3072 if ( incidence ) {
3059 beamIncidence(incidence); 3073 beamIncidence(incidence);
3060 } 3074 }
3061} 3075}
3062void CalendarView::toggleCancelIncidence() 3076void CalendarView::toggleCancelIncidence()
3063{ 3077{
3064 Incidence *incidence = currentSelection(); 3078 Incidence *incidence = currentSelection();
3065 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3079 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3066 if ( incidence ) { 3080 if ( incidence ) {
3067 cancelIncidence(incidence); 3081 cancelIncidence(incidence);
3068 } 3082 }
3069} 3083}
3070 3084
3071 3085
3072void CalendarView::cancelIncidence(Incidence * inc ) 3086void CalendarView::cancelIncidence(Incidence * inc )
3073{ 3087{
3074 inc->setCancelled( ! inc->cancelled() ); 3088 inc->setCancelled( ! inc->cancelled() );
3075 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3089 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3076 updateView(); 3090 updateView();
3077} 3091}
3078void CalendarView::cloneIncidence(Incidence * orgInc ) 3092void CalendarView::cloneIncidence(Incidence * orgInc )
3079{ 3093{
3080 Incidence * newInc = orgInc->clone(); 3094 Incidence * newInc = orgInc->clone();
3081 newInc->recreate(); 3095 newInc->recreate();
3082 3096
3083 if ( newInc->typeID() == todoID ) { 3097 if ( newInc->typeID() == todoID ) {
3084 Todo* t = (Todo*) newInc; 3098 Todo* t = (Todo*) newInc;
3085 bool cloneSub = false; 3099 bool cloneSub = false;
3086 if ( orgInc->relations().count() ) { 3100 if ( orgInc->relations().count() ) {
3087 int result = KMessageBox::warningYesNoCancel(this, 3101 int result = KMessageBox::warningYesNoCancel(this,
3088 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 ) ), 3102 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 ) ),
3089 i18n("Todo has subtodos"), 3103 i18n("Todo has subtodos"),
3090 i18n("Yes"), 3104 i18n("Yes"),
3091 i18n("No")); 3105 i18n("No"));
3092 3106
3093 if ( result == KMessageBox::Cancel ) { 3107 if ( result == KMessageBox::Cancel ) {
3094 delete t; 3108 delete t;
3095 return; 3109 return;
3096 } 3110 }
3097 if (result == KMessageBox::Yes) cloneSub = true; 3111 if (result == KMessageBox::Yes) cloneSub = true;
3098 } 3112 }
3099 showTodoEditor(); 3113 showTodoEditor();
3100 mTodoEditor->editTodo( t ); 3114 mTodoEditor->editTodo( t );
3101 if ( mTodoEditor->exec() ) { 3115 if ( mTodoEditor->exec() ) {
3102 if ( cloneSub ) { 3116 if ( cloneSub ) {
3103 orgInc->cloneRelations( t ); 3117 orgInc->cloneRelations( t );
3104 mCalendar->addIncidenceBranch( t ); 3118 mCalendar->addIncidenceBranch( t );
3105 updateView(); 3119 updateView();
3106 3120
3107 } else { 3121 } else {
3108 mCalendar->addTodo( t ); 3122 mCalendar->addTodo( t );
3109 updateView(); 3123 updateView();
3110 } 3124 }
3111 } else { 3125 } else {
3112 delete t; 3126 delete t;
3113 } 3127 }
3114 } 3128 }
3115 else { 3129 else {
3116 Event* e = (Event*) newInc; 3130 Event* e = (Event*) newInc;
3117 showEventEditor(); 3131 showEventEditor();
3118 mEventEditor->editEvent( e ); 3132 mEventEditor->editEvent( e );
3119 if ( mEventEditor->exec() ) { 3133 if ( mEventEditor->exec() ) {
3120 mCalendar->addEvent( e ); 3134 mCalendar->addEvent( e );
3121 updateView(); 3135 updateView();
3122 } else { 3136 } else {
3123 delete e; 3137 delete e;
3124 } 3138 }
3125 } 3139 }
3126 setActiveWindow(); 3140 setActiveWindow();
3127} 3141}
3128 3142
3129void CalendarView::newEvent() 3143void CalendarView::newEvent()
3130{ 3144{
3131 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3145 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3132 KOAgendaView *aView = mViewManager->agendaView(); 3146 KOAgendaView *aView = mViewManager->agendaView();
3133 if (aView) { 3147 if (aView) {
3134 if (aView->selectionStart().isValid()) { 3148 if (aView->selectionStart().isValid()) {
3135 if (aView->selectedIsAllDay()) { 3149 if (aView->selectedIsAllDay()) {
3136 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3150 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3137 } else { 3151 } else {
3138 newEvent(aView->selectionStart(),aView->selectionEnd()); 3152 newEvent(aView->selectionStart(),aView->selectionEnd());
3139 } 3153 }
3140 return; 3154 return;
3141 } 3155 }
3142 } 3156 }
3143 3157
3144 QDate date = mNavigator->selectedDates().first(); 3158 QDate date = mNavigator->selectedDates().first();
3145 QDateTime current = QDateTime::currentDateTime(); 3159 QDateTime current = QDateTime::currentDateTime();
3146 if ( date <= current.date() ) { 3160 if ( date <= current.date() ) {
3147 int hour = current.time().hour() +1; 3161 int hour = current.time().hour() +1;
3148 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3162 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3149 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3163 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3150 } else 3164 } else
3151 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3165 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3152 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3166 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3153 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3167 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3154} 3168}
3155 3169
3156void CalendarView::newEvent(QDateTime fh) 3170void CalendarView::newEvent(QDateTime fh)
3157{ 3171{
3158 newEvent(fh, 3172 newEvent(fh,
3159 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3173 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3160} 3174}
3161 3175
3162void CalendarView::newEvent(QDate dt) 3176void CalendarView::newEvent(QDate dt)
3163{ 3177{
3164 newEvent(QDateTime(dt, QTime(0,0,0)), 3178 newEvent(QDateTime(dt, QTime(0,0,0)),
3165 QDateTime(dt, QTime(0,0,0)), true); 3179 QDateTime(dt, QTime(0,0,0)), true);
3166} 3180}
3167void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3181void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3168{ 3182{
3169 newEvent(fromHint, toHint, false); 3183 newEvent(fromHint, toHint, false);
3170} 3184}
3171void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3185void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3172{ 3186{
3173 3187
3174 showEventEditor(); 3188 showEventEditor();
3175 mEventEditor->newEvent(fromHint,toHint,allDay); 3189 mEventEditor->newEvent(fromHint,toHint,allDay);
3176 if ( mFilterView->filtersEnabled() ) { 3190 if ( mFilterView->filtersEnabled() ) {
3177 CalFilter *filter = mFilterView->selectedFilter(); 3191 CalFilter *filter = mFilterView->selectedFilter();
3178 if (filter && filter->showCategories()) { 3192 if (filter && filter->showCategories()) {
3179 mEventEditor->setCategories(filter->categoryList().join(",") ); 3193 mEventEditor->setCategories(filter->categoryList().join(",") );
3180 } 3194 }
3181 if ( filter ) 3195 if ( filter )
3182 mEventEditor->setSecrecy( filter->getSecrecy() ); 3196 mEventEditor->setSecrecy( filter->getSecrecy() );
3183 } 3197 }
3184 mEventEditor->exec(); 3198 mEventEditor->exec();
3185 setActiveWindow(); 3199 setActiveWindow();
3186} 3200}
3187void CalendarView::todoAdded(Todo * t) 3201void CalendarView::todoAdded(Todo * t)
3188{ 3202{
3189 3203
3190 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3204 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3191 updateTodoViews(); 3205 updateTodoViews();
3192} 3206}
3193void CalendarView::todoChanged(Todo * t) 3207void CalendarView::todoChanged(Todo * t)
3194{ 3208{
3195 emit todoModified( t, 4 ); 3209 emit todoModified( t, 4 );
3196 // updateTodoViews(); 3210 // updateTodoViews();
3197} 3211}
3198void CalendarView::todoToBeDeleted(Todo *) 3212void CalendarView::todoToBeDeleted(Todo *)
3199{ 3213{
3200 //qDebug("todoToBeDeleted(Todo *) "); 3214 //qDebug("todoToBeDeleted(Todo *) ");
3201 updateTodoViews(); 3215 updateTodoViews();
3202} 3216}
3203void CalendarView::todoDeleted() 3217void CalendarView::todoDeleted()
3204{ 3218{
3205 //qDebug(" todoDeleted()"); 3219 //qDebug(" todoDeleted()");
3206 updateTodoViews(); 3220 updateTodoViews();
3207} 3221}
3208 3222
3209 3223
3210void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3224void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3211{ 3225{
3212 showTodoEditor(); 3226 showTodoEditor();
3213 mTodoEditor->newTodo(dt,0,allday); 3227 mTodoEditor->newTodo(dt,0,allday);
3214 if ( mFilterView->filtersEnabled() ) { 3228 if ( mFilterView->filtersEnabled() ) {
3215 CalFilter *filter = mFilterView->selectedFilter(); 3229 CalFilter *filter = mFilterView->selectedFilter();
3216 if (filter && filter->showCategories()) { 3230 if (filter && filter->showCategories()) {
3217 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3231 mTodoEditor->setCategories(filter->categoryList().join(",") );
3218 } 3232 }
3219 if ( filter ) 3233 if ( filter )
3220 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3234 mTodoEditor->setSecrecy( filter->getSecrecy() );
3221 } 3235 }
3222 mTodoEditor->exec(); 3236 mTodoEditor->exec();
3223 setActiveWindow(); 3237 setActiveWindow();
3224} 3238}
3225 3239
3226void CalendarView::newTodo() 3240void CalendarView::newTodo()
3227{ 3241{
3228 newTodoDateTime( QDateTime(),true ); 3242 newTodoDateTime( QDateTime(),true );
3229} 3243}
3230 3244
3231void CalendarView::newSubTodo() 3245void CalendarView::newSubTodo()
3232{ 3246{
3233 Todo *todo = selectedTodo(); 3247 Todo *todo = selectedTodo();
3234 if ( todo ) newSubTodo( todo ); 3248 if ( todo ) newSubTodo( todo );
3235} 3249}
3236 3250
3237void CalendarView::newSubTodo(Todo *parentEvent) 3251void CalendarView::newSubTodo(Todo *parentEvent)
3238{ 3252{
3239 3253
3240 showTodoEditor(); 3254 showTodoEditor();
3241 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3255 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3242 mTodoEditor->exec(); 3256 mTodoEditor->exec();
3243 setActiveWindow(); 3257 setActiveWindow();
3244} 3258}
3245 3259
3246void CalendarView::newFloatingEvent() 3260void CalendarView::newFloatingEvent()
3247{ 3261{
3248 DateList tmpList = mNavigator->selectedDates(); 3262 DateList tmpList = mNavigator->selectedDates();
3249 QDate date = tmpList.first(); 3263 QDate date = tmpList.first();
3250 3264
3251 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3265 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3252 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3266 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3253} 3267}
3254 3268
3255 3269
3256void CalendarView::editEvent( Event *event ) 3270void CalendarView::editEvent( Event *event )
3257{ 3271{
3258 3272
3259 if ( !event ) return; 3273 if ( !event ) return;
3260 if ( event->isReadOnly() ) { 3274 if ( event->isReadOnly() ) {
3261 showEvent( event ); 3275 showEvent( event );
3262 return; 3276 return;
3263 } 3277 }
3264 showEventEditor(); 3278 showEventEditor();
3265 mEventEditor->editEvent( event , mFlagEditDescription); 3279 mEventEditor->editEvent( event , mFlagEditDescription);
3266 mEventEditor->exec(); 3280 mEventEditor->exec();
3267 setActiveWindow(); 3281 setActiveWindow();
3268 3282
3269} 3283}
3270void CalendarView::editJournal( Journal *jour ) 3284void CalendarView::editJournal( Journal *jour )
3271{ 3285{
3272 if ( !jour ) return; 3286 if ( !jour ) return;
3273 mDialogManager->hideSearchDialog(); 3287 mDialogManager->hideSearchDialog();
3274 mViewManager->showJournalView(); 3288 mViewManager->showJournalView();
3275 mNavigator->slotDaySelect( jour->dtStart().date() ); 3289 mNavigator->slotDaySelect( jour->dtStart().date() );
3276} 3290}
3277void CalendarView::editTodo( Todo *todo ) 3291void CalendarView::editTodo( Todo *todo )
3278{ 3292{
3279 if ( !todo ) return; 3293 if ( !todo ) return;
3280 3294
3281 if ( todo->isReadOnly() ) { 3295 if ( todo->isReadOnly() ) {
3282 showTodo( todo ); 3296 showTodo( todo );
3283 return; 3297 return;
3284 } 3298 }
3285 showTodoEditor(); 3299 showTodoEditor();
3286 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3300 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3287 mTodoEditor->exec(); 3301 mTodoEditor->exec();
3288 setActiveWindow(); 3302 setActiveWindow();
3289 3303
3290} 3304}
3291 3305
3292KOEventViewerDialog* CalendarView::getEventViewerDialog() 3306KOEventViewerDialog* CalendarView::getEventViewerDialog()
3293{ 3307{
3294 if ( !mEventViewerDialog ) { 3308 if ( !mEventViewerDialog ) {
3295 mEventViewerDialog = new KOEventViewerDialog(0); 3309 mEventViewerDialog = new KOEventViewerDialog(0);
3296 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3310 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3297 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3311 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3298 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3312 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3299 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3313 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3300 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3314 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3301 viewManager(), SLOT( showAgendaView( bool ) ) ); 3315 viewManager(), SLOT( showAgendaView( bool ) ) );
3302 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3316 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3303 this, SLOT( slotViewerClosed() ) ); 3317 this, SLOT( slotViewerClosed() ) );
3304 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3318 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3305 this, SLOT( todoChanged(Todo *) ) ); 3319 this, SLOT( todoChanged(Todo *) ) );
3306 mEventViewerDialog->resize( 640, 480 ); 3320 mEventViewerDialog->resize( 640, 480 );
3307 3321
3308 } 3322 }
3309 return mEventViewerDialog; 3323 return mEventViewerDialog;
3310} 3324}
3311void CalendarView::showEvent(Event *event) 3325void CalendarView::showEvent(Event *event)
3312{ 3326{
3313 getEventViewerDialog()->setEvent(event); 3327 getEventViewerDialog()->setEvent(event);
3314 getEventViewerDialog()->showMe(); 3328 getEventViewerDialog()->showMe();
3315} 3329}
3316 3330
3317void CalendarView::showTodo(Todo *event) 3331void CalendarView::showTodo(Todo *event)
3318{ 3332{
3319 getEventViewerDialog()->setTodo(event); 3333 getEventViewerDialog()->setTodo(event);
3320 getEventViewerDialog()->showMe(); 3334 getEventViewerDialog()->showMe();
3321} 3335}
3322void CalendarView::showJournal( Journal *jour ) 3336void CalendarView::showJournal( Journal *jour )
3323{ 3337{
3324 getEventViewerDialog()->setJournal(jour); 3338 getEventViewerDialog()->setJournal(jour);
3325 getEventViewerDialog()->showMe(); 3339 getEventViewerDialog()->showMe();
3326 3340
3327} 3341}
3328// void CalendarView::todoModified (Todo *event, int changed) 3342// void CalendarView::todoModified (Todo *event, int changed)
3329// { 3343// {
3330// // if (mDialogList.find (event) != mDialogList.end ()) { 3344// // if (mDialogList.find (event) != mDialogList.end ()) {
3331// // kdDebug() << "Todo modified and open" << endl; 3345// // kdDebug() << "Todo modified and open" << endl;
3332// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3346// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3333// // temp->modified (changed); 3347// // temp->modified (changed);
3334 3348
3335// // } 3349// // }
3336 3350
3337// mViewManager->updateView(); 3351// mViewManager->updateView();
3338// } 3352// }
3339 3353
3340void CalendarView::appointment_show() 3354void CalendarView::appointment_show()
3341{ 3355{
3342 Event *anEvent = 0; 3356 Event *anEvent = 0;
3343 3357
3344 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3358 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3345 3359
3346 if (mViewManager->currentView()->isEventView()) { 3360 if (mViewManager->currentView()->isEventView()) {
3347 if ( incidence && incidence->typeID() == eventID ) { 3361 if ( incidence && incidence->typeID() == eventID ) {
3348 anEvent = static_cast<Event *>(incidence); 3362 anEvent = static_cast<Event *>(incidence);
3349 } 3363 }
3350 } 3364 }
3351 3365
3352 if (!anEvent) { 3366 if (!anEvent) {
3353 KNotifyClient::beep(); 3367 KNotifyClient::beep();
3354 return; 3368 return;
3355 } 3369 }
3356 3370
3357 showEvent(anEvent); 3371 showEvent(anEvent);
3358} 3372}
3359 3373
3360void CalendarView::appointment_edit() 3374void CalendarView::appointment_edit()
3361{ 3375{
3362 Event *anEvent = 0; 3376 Event *anEvent = 0;
3363 3377
3364 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3378 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3365 3379
3366 if (mViewManager->currentView()->isEventView()) { 3380 if (mViewManager->currentView()->isEventView()) {
3367 if ( incidence && incidence->typeID() == eventID ) { 3381 if ( incidence && incidence->typeID() == eventID ) {
3368 anEvent = static_cast<Event *>(incidence); 3382 anEvent = static_cast<Event *>(incidence);
3369 } 3383 }
3370 } 3384 }
3371 3385
3372 if (!anEvent) { 3386 if (!anEvent) {
3373 KNotifyClient::beep(); 3387 KNotifyClient::beep();
3374 return; 3388 return;
3375 } 3389 }
3376 3390
3377 editEvent(anEvent); 3391 editEvent(anEvent);
3378} 3392}
3379 3393
3380void CalendarView::appointment_delete() 3394void CalendarView::appointment_delete()
3381{ 3395{
3382 Event *anEvent = 0; 3396 Event *anEvent = 0;
3383 3397
3384 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3398 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3385 3399
3386 if (mViewManager->currentView()->isEventView()) { 3400 if (mViewManager->currentView()->isEventView()) {
3387 if ( incidence && incidence->typeID() == eventID ) { 3401 if ( incidence && incidence->typeID() == eventID ) {
3388 anEvent = static_cast<Event *>(incidence); 3402 anEvent = static_cast<Event *>(incidence);
3389 } 3403 }
3390 } 3404 }
3391 3405
3392 if (!anEvent) { 3406 if (!anEvent) {
3393 KNotifyClient::beep(); 3407 KNotifyClient::beep();
3394 return; 3408 return;
3395 } 3409 }
3396 3410
3397 deleteEvent(anEvent); 3411 deleteEvent(anEvent);
3398} 3412}
3399 3413
3400void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3414void CalendarView::todo_resub( Todo * parent, Todo * sub )
3401{ 3415{
3402 if (!sub) return; 3416 if (!sub) return;
3403 if ( sub->relatedTo() == parent ) 3417 if ( sub->relatedTo() == parent )
3404 return; 3418 return;
3405 sub->setRelatedTo(parent); 3419 sub->setRelatedTo(parent);
3406 sub->updated(); 3420 sub->updated();
3407 setModified(true); 3421 setModified(true);
3408 updateView(); 3422 updateView();
3409} 3423}
3410void CalendarView::todo_unsub(Todo *anTodo ) 3424void CalendarView::todo_unsub(Todo *anTodo )
3411{ 3425{
3412 todo_resub( 0, anTodo ); 3426 todo_resub( 0, anTodo );
3413} 3427}
3414 3428
3415void CalendarView::deleteTodo(Todo *todo) 3429void CalendarView::deleteTodo(Todo *todo)
3416{ 3430{
3417 if (!todo) { 3431 if (!todo) {
3418 KNotifyClient::beep(); 3432 KNotifyClient::beep();
3419 return; 3433 return;
3420 } 3434 }
3421 if (KOPrefs::instance()->mConfirm) { 3435 if (KOPrefs::instance()->mConfirm) {
3422 QString text = todo->summary().left(20); 3436 QString text = todo->summary().left(20);
3423 if (!todo->relations().isEmpty()) { 3437 if (!todo->relations().isEmpty()) {
3424 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3438 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3425 3439
3426 } 3440 }
3427 switch (msgItemDelete(text)) { 3441 switch (msgItemDelete(text)) {
3428 case KMessageBox::Continue: // OK 3442 case KMessageBox::Continue: // OK
3429 bool deleteT = false; 3443 bool deleteT = false;
3430 if (!todo->relations().isEmpty()) { 3444 if (!todo->relations().isEmpty()) {
3431 deleteT = removeCompletedSubTodos( todo ); 3445 deleteT = removeCompletedSubTodos( todo );
3432 } 3446 }
3433 // deleteT == true: todo already deleted in removeCompletedSubTodos 3447 // deleteT == true: todo already deleted in removeCompletedSubTodos
3434 if ( !deleteT ) { 3448 if ( !deleteT ) {
3435 checkExternalId( todo ); 3449 checkExternalId( todo );
3436 calendar()->deleteTodo(todo); 3450 calendar()->deleteTodo(todo);
3437 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3451 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3438 updateView(); 3452 updateView();
3439 } 3453 }
3440 break; 3454 break;
3441 } // switch 3455 } // switch
3442 } else { 3456 } else {
3443 checkExternalId( todo ); 3457 checkExternalId( todo );
3444 mCalendar->deleteTodo(todo); 3458 mCalendar->deleteTodo(todo);
3445 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3459 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3446 updateView(); 3460 updateView();
3447 } 3461 }
3448 3462
3449 emit updateSearchDialog(); 3463 emit updateSearchDialog();
3450} 3464}
3451void CalendarView::deleteJournal(Journal *jour) 3465void CalendarView::deleteJournal(Journal *jour)
3452{ 3466{
3453 if (!jour) { 3467 if (!jour) {
3454 KNotifyClient::beep(); 3468 KNotifyClient::beep();
3455 return; 3469 return;
3456 } 3470 }
3457 if (KOPrefs::instance()->mConfirm) { 3471 if (KOPrefs::instance()->mConfirm) {
3458 switch (msgItemDelete( jour->description().left(20))) { 3472 switch (msgItemDelete( jour->description().left(20))) {
3459 case KMessageBox::Continue: // OK 3473 case KMessageBox::Continue: // OK
3460 calendar()->deleteJournal(jour); 3474 calendar()->deleteJournal(jour);
3461 updateView(); 3475 updateView();
3462 break; 3476 break;
3463 } // switch 3477 } // switch
3464 } else { 3478 } else {
3465 calendar()->deleteJournal(jour);; 3479 calendar()->deleteJournal(jour);;
3466 updateView(); 3480 updateView();
3467 } 3481 }
3468 emit updateSearchDialog(); 3482 emit updateSearchDialog();
3469} 3483}
3470 3484
3471void CalendarView::deleteEvent(Event *anEvent) 3485void CalendarView::deleteEvent(Event *anEvent)
3472{ 3486{
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
index 7354940..479bd8b 100644
--- a/korganizer/koeditordetails.cpp
+++ b/korganizer/koeditordetails.cpp
@@ -1,480 +1,482 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in thse hope that it will be useful, 10 This program is distributed in thse hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapp.h> 32#include <qapp.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kdialog.h>
36#include <kiconloader.h> 37#include <kiconloader.h>
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38#include <kmessagebox.h> 39#include <kmessagebox.h>
39#ifndef KORG_NOKABC 40#ifndef KORG_NOKABC
40 41
41#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
42#include <kabc/addresseedialog.h> 43#include <kabc/addresseedialog.h>
43#else //DESKTOP_VERSION 44#else //DESKTOP_VERSION
44#include <externalapphandler.h> 45#include <externalapphandler.h>
45#endif //DESKTOP_VERSION 46#endif //DESKTOP_VERSION
46 47
47#endif 48#endif
48 49
49#include <libkcal/incidence.h> 50#include <libkcal/incidence.h>
50 51
51#include "koprefs.h" 52#include "koprefs.h"
52 53
53#include "koeditordetails.h" 54#include "koeditordetails.h"
54 55
55template <> 56template <>
56CustomListViewItem<class Attendee *>::~CustomListViewItem() 57CustomListViewItem<class Attendee *>::~CustomListViewItem()
57{ 58{
58 delete mData; 59 delete mData;
59} 60}
60 61
61template <> 62template <>
62void CustomListViewItem<class Attendee *>::updateItem() 63void CustomListViewItem<class Attendee *>::updateItem()
63{ 64{
64 setText(0,mData->name()); 65 setText(0,mData->name());
65 setText(1,mData->email()); 66 setText(1,mData->email());
66 setText(2,mData->roleStr()); 67 setText(2,mData->roleStr());
67 setText(3,mData->statusStr()); 68 setText(3,mData->statusStr());
68 if (mData->RSVP() && !mData->email().isEmpty()) { 69 if (mData->RSVP() && !mData->email().isEmpty()) {
69 setPixmap(4,SmallIcon("mailappt")); 70 setPixmap(4,SmallIcon("mailappt"));
70 setSortKey(4,"j"); 71 setSortKey(4,"j");
71 } 72 }
72 else { 73 else {
73 setPixmap(4,SmallIcon("nomailappt")); 74 setPixmap(4,SmallIcon("nomailappt"));
74 setSortKey(4,"n"); 75 setSortKey(4,"n");
75 } 76 }
76} 77}
77 78
78 79
79KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) 80KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name)
80 : QWidget( parent, name), mDisableItemUpdate( false ) 81 : QWidget( parent, name), mDisableItemUpdate( false )
81{ 82{
82 QGridLayout *topLayout = new QGridLayout(this); 83 QGridLayout *topLayout = new QGridLayout(this);
83 topLayout->setSpacing(spacing); 84 topLayout->setSpacing(spacing);
85 topLayout->setMargin(KDialog::marginHint()-2);
84 86
85 QString organizer = KOPrefs::instance()->email(); 87 QString organizer = KOPrefs::instance()->email();
86 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); 88 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this);
87 89
88 mListView = new KListView(this,"mListView"); 90 mListView = new KListView(this,"mListView");
89 mListView->addColumn(i18n("Name"),180); 91 mListView->addColumn(i18n("Name"),180);
90 mListView->addColumn(i18n("Email"),180); 92 mListView->addColumn(i18n("Email"),180);
91 mListView->addColumn(i18n("Role"),60); 93 mListView->addColumn(i18n("Role"),60);
92 mListView->addColumn(i18n("Status"),100); 94 mListView->addColumn(i18n("Status"),100);
93 mListView->addColumn(i18n("RSVP"),35); 95 mListView->addColumn(i18n("RSVP"),35);
94 if ( QApplication::desktop()->width() <= 320 || QApplication::desktop()->height() <= 240) { 96 if ( QApplication::desktop()->width() <= 320 || QApplication::desktop()->height() <= 240) {
95 int hei = 80; 97 int hei = 80;
96 if ( QApplication::desktop()->height() <= 240 ) 98 if ( QApplication::desktop()->height() <= 240 )
97 hei = 60; 99 hei = 60;
98 mListView->setFixedHeight(hei); 100 mListView->setFixedHeight(hei);
99 } 101 }
100 mListView->setAllColumnsShowFocus (true ); 102 mListView->setAllColumnsShowFocus (true );
101 //mListView->setSingleClick( true ); 103 //mListView->setSingleClick( true );
102 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), 104 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)),
103 SLOT(updateAttendeeInput())); 105 SLOT(updateAttendeeInput()));
104 106
105 connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), 107 connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )),
106 SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); 108 SLOT(itemClicked(QListViewItem * ,const QPoint& , int )));
107 109
108 mRsvpButton = new QCheckBox(this); 110 mRsvpButton = new QCheckBox(this);
109 mRsvpButton->setText(i18n("Request response")); 111 mRsvpButton->setText(i18n("Request response"));
110 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); 112 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this);
111 QLabel *attendeeLabel = new QLabel(this); 113 QLabel *attendeeLabel = new QLabel(this);
112 attendeeLabel->setText(i18n("Name:")); 114 attendeeLabel->setText(i18n("Name:"));
113 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); 115 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() );
114 mNameEdit = new QLineEdit(this); 116 mNameEdit = new QLineEdit(this);
115 connect(mNameEdit,SIGNAL(textChanged(const QString &)), 117 connect(mNameEdit,SIGNAL(textChanged(const QString &)),
116 SLOT(updateAttendeeItem())); 118 SLOT(updateAttendeeItem()));
117 119
118 mUidEdit = new QLineEdit(0); 120 mUidEdit = new QLineEdit(0);
119 mUidEdit->setText(""); 121 mUidEdit->setText("");
120 122
121 QLabel *emailLabel = new QLabel(this); 123 QLabel *emailLabel = new QLabel(this);
122 emailLabel->setText(i18n("Email:")); 124 emailLabel->setText(i18n("Email:"));
123 mEmailEdit = new QLineEdit(this); 125 mEmailEdit = new QLineEdit(this);
124 connect(mEmailEdit,SIGNAL(textChanged(const QString &)), 126 connect(mEmailEdit,SIGNAL(textChanged(const QString &)),
125 SLOT(updateAttendeeItem())); 127 SLOT(updateAttendeeItem()));
126 128
127 QLabel *attendeeRoleLabel = new QLabel(this); 129 QLabel *attendeeRoleLabel = new QLabel(this);
128 attendeeRoleLabel->setText(i18n("Role:")); 130 attendeeRoleLabel->setText(i18n("Role:"));
129 mRoleCombo = new QComboBox(false,this); 131 mRoleCombo = new QComboBox(false,this);
130 mRoleCombo->insertStringList(Attendee::roleList()); 132 mRoleCombo->insertStringList(Attendee::roleList());
131 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 133 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
132 134
133 QLabel *statusLabel = new QLabel(this); 135 QLabel *statusLabel = new QLabel(this);
134 statusLabel->setText( i18n("Status:") ); 136 statusLabel->setText( i18n("Status:") );
135 137
136 mStatusCombo = new QComboBox(false,this); 138 mStatusCombo = new QComboBox(false,this);
137 mStatusCombo->insertStringList(Attendee::statusList()); 139 mStatusCombo->insertStringList(Attendee::statusList());
138 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 140 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
139 141
140 142
141 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); 143 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem()));
142 QWidget *buttonBox = new QWidget(this); 144 QWidget *buttonBox = new QWidget(this);
143 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); 145 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox);
144 146
145 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); 147 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox);
146 buttonLayout->addWidget(newButton); 148 buttonLayout->addWidget(newButton);
147 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); 149 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee()));
148 150
149 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); 151 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox);
150 buttonLayout->addWidget(mRemoveButton); 152 buttonLayout->addWidget(mRemoveButton);
151 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); 153 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee()));
152 154
153 // buttonLayout->addWidget(mAddressBookButton); 155 // buttonLayout->addWidget(mAddressBookButton);
154 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); 156 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook()));
155 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); 157 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () );
156 if ( QApplication::desktop()->height() <= 240 ) { 158 if ( QApplication::desktop()->height() <= 240 ) {
157 mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); 159 mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) );
158 mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); 160 mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) );
159 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 161 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
160 topLayout->addMultiCellWidget(mListView,1,1,0,5); 162 topLayout->addMultiCellWidget(mListView,1,1,0,5);
161 topLayout->addWidget(attendeeLabel,3,0); 163 topLayout->addWidget(attendeeLabel,3,0);
162 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 164 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
163 topLayout->addWidget(emailLabel,4,0); 165 topLayout->addWidget(emailLabel,4,0);
164 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 166 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
165 topLayout->addWidget(attendeeRoleLabel,5,0); 167 topLayout->addWidget(attendeeRoleLabel,5,0);
166 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 168 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
167 topLayout->addWidget(statusLabel,5,3); 169 topLayout->addWidget(statusLabel,5,3);
168 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 170 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
169 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5); 171 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5);
170 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 172 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
171 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 173 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
172 topLayout->setRowStretch(1,5); 174 topLayout->setRowStretch(1,5);
173 topLayout->setColStretch(0,0); 175 topLayout->setColStretch(0,0);
174 } else { 176 } else {
175 if (qApp->desktop()->width() < 640 ) { 177 if (qApp->desktop()->width() < 640 ) {
176 if ( qApp->desktop()->width() < 300 ) 178 if ( qApp->desktop()->width() < 300 )
177 topLayout->setSpacing(1); 179 topLayout->setSpacing(1);
178 ;//mListView->setFixedHeight(80); 180 ;//mListView->setFixedHeight(80);
179 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); 181 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3);
180 topLayout->addMultiCellWidget(mListView,1,1,0,3); 182 topLayout->addMultiCellWidget(mListView,1,1,0,3);
181 topLayout->addWidget(attendeeLabel,3,0); 183 topLayout->addWidget(attendeeLabel,3,0);
182 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); 184 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2);
183 topLayout->addWidget(emailLabel,4,0); 185 topLayout->addWidget(emailLabel,4,0);
184 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); 186 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2);
185 topLayout->addWidget(attendeeRoleLabel,5,0); 187 topLayout->addWidget(attendeeRoleLabel,5,0);
186 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); 188 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3);
187 topLayout->addWidget(statusLabel,6,0); 189 topLayout->addWidget(statusLabel,6,0);
188 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); 190 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3);
189 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); 191 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3);
190 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 192 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
191 topLayout->addMultiCellWidget(buttonBox,3,4,3,3); 193 topLayout->addMultiCellWidget(buttonBox,3,4,3,3);
192 topLayout->setRowStretch(1,2); 194 topLayout->setRowStretch(1,2);
193 topLayout->setColStretch(0,0); 195 topLayout->setColStretch(0,0);
194 topLayout->setColStretch(1,2); 196 topLayout->setColStretch(1,2);
195 topLayout->setColStretch(2,1); 197 topLayout->setColStretch(2,1);
196 topLayout->setColStretch(3,1); 198 topLayout->setColStretch(3,1);
197 } else { 199 } else {
198 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 200 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
199 topLayout->addMultiCellWidget(mListView,1,1,0,5); 201 topLayout->addMultiCellWidget(mListView,1,1,0,5);
200 topLayout->addWidget(attendeeLabel,3,0); 202 topLayout->addWidget(attendeeLabel,3,0);
201 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 203 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
202 topLayout->addWidget(emailLabel,4,0); 204 topLayout->addWidget(emailLabel,4,0);
203 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 205 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
204 topLayout->addWidget(attendeeRoleLabel,5,0); 206 topLayout->addWidget(attendeeRoleLabel,5,0);
205 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 207 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
206 topLayout->addWidget(statusLabel,5,3); 208 topLayout->addWidget(statusLabel,5,3);
207 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 209 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
208 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); 210 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5);
209 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 211 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
210 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 212 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
211 topLayout->setRowStretch(1,5); 213 topLayout->setRowStretch(1,5);
212 topLayout->setColStretch(0,0); 214 topLayout->setColStretch(0,0);
213 } 215 }
214 } 216 }
215// #if 0 217// #if 0
216// topLayout->setColStretch(2,1); 218// topLayout->setColStretch(2,1);
217// topLayout->addWidget(statusLabel,3,3); 219// topLayout->addWidget(statusLabel,3,3);
218// topLayout->addWidget(mStatusCombo,3,4); 220// topLayout->addWidget(mStatusCombo,3,4);
219// #else 221// #else
220// topLayout->addWidget(statusLabel,4,3); 222// topLayout->addWidget(statusLabel,4,3);
221// // topLayout->addWidget(mStatusCombo,4,3); 223// // topLayout->addWidget(mStatusCombo,4,3);
222// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); 224// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5);
223 225
224// #endif 226// #endif
225// // topLayout->setRowStretch(5,1); 227// // topLayout->setRowStretch(5,1);
226// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); 228// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1);
227// topLayout->addMultiCellWidget(buttonBox,2,3,5,5); 229// topLayout->addMultiCellWidget(buttonBox,2,3,5,5);
228// topLayout->setRowStretch(1,5); 230// topLayout->setRowStretch(1,5);
229// topLayout->setColStretch(0,0); 231// topLayout->setColStretch(0,0);
230 232
231#ifdef KORG_NOKABC 233#ifdef KORG_NOKABC
232 mAddressBookButton->hide(); 234 mAddressBookButton->hide();
233#endif 235#endif
234 236
235 updateAttendeeInput(); 237 updateAttendeeInput();
236#ifndef DESKTOP_VERSION 238#ifndef DESKTOP_VERSION
237//US listen for arriving address resultsets 239//US listen for arriving address resultsets
238 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 240 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
239 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 241 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
240#endif 242#endif
241 243
242} 244}
243 245
244KOEditorDetails::~KOEditorDetails() 246KOEditorDetails::~KOEditorDetails()
245{ 247{
246} 248}
247 249
248void KOEditorDetails::removeAttendee() 250void KOEditorDetails::removeAttendee()
249{ 251{
250 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); 252 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem();
251 if (!aItem) return; 253 if (!aItem) return;
252 254
253 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), 255 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(),
254 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), 256 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(),
255 aItem->data()->uid()); 257 aItem->data()->uid());
256 mdelAttendees.append(delA); 258 mdelAttendees.append(delA);
257 259
258 delete aItem; 260 delete aItem;
259 261
260 updateAttendeeInput(); 262 updateAttendeeInput();
261} 263}
262 264
263 265
264void KOEditorDetails::openAddressBook() 266void KOEditorDetails::openAddressBook()
265{ 267{
266#ifndef KORG_NOKABC 268#ifndef KORG_NOKABC
267 269
268#ifdef DESKTOP_VERSION 270#ifdef DESKTOP_VERSION
269 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 271 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
270 uint i=0; 272 uint i=0;
271 for (i=0; i < list.count(); i++) { 273 for (i=0; i < list.count(); i++) {
272 insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); 274 insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) );
273 } 275 }
274#else 276#else
275 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 277 bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
276 // the result should now arrive through method insertAttendees 278 // the result should now arrive through method insertAttendees
277#endif 279#endif
278 280
279 281
280#if 0 282#if 0
281 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); 283 KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
282 if (!a.isEmpty()) { 284 if (!a.isEmpty()) {
283 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); 285 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) );
284 } 286 }
285#endif 287#endif
286#endif 288#endif
287} 289}
288 290
289 291
290void KOEditorDetails::addNewAttendee() 292void KOEditorDetails::addNewAttendee()
291{ 293{
292#if 0 294#if 0
293 // this is cool. If they didn't enter an email address, 295 // this is cool. If they didn't enter an email address,
294 // try to look it up in the address book and fill it in for them. 296 // try to look it up in the address book and fill it in for them.
295 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { 297 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) {
296 KabAPI addrBook; 298 KabAPI addrBook;
297 QString name; 299 QString name;
298 std::list<AddressBook::Entry> entries; 300 std::list<AddressBook::Entry> entries;
299 name = mNameEdit->text(); 301 name = mNameEdit->text();
300 if (addrBook.init() == AddressBook::NoError) { 302 if (addrBook.init() == AddressBook::NoError) {
301 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { 303 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) {
302 kdDebug() << "positive match" << endl; 304 kdDebug() << "positive match" << endl;
303 // take first email address 305 // take first email address
304 if (!entries.front().emails.isEmpty() && 306 if (!entries.front().emails.isEmpty() &&
305 entries.front().emails.first().length()>0) 307 entries.front().emails.first().length()>0)
306 mEmailEdit->setText(entries.front().emails.first()); 308 mEmailEdit->setText(entries.front().emails.first());
307 } 309 }
308 } 310 }
309 } 311 }
310#endif 312#endif
311 313
312 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); 314 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)"));
313 insertAttendee(a); 315 insertAttendee(a);
314} 316}
315 317
316//the map includes name/email pairs, that comes from Ka/Pi 318//the map includes name/email pairs, that comes from Ka/Pi
317void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 319void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
318{ 320{
319 if (uid == this->name()) 321 if (uid == this->name())
320 { 322 {
321 for ( int i = 0; i < nameList.count(); i++) 323 for ( int i = 0; i < nameList.count(); i++)
322 { 324 {
323 QString _name = nameList[i]; 325 QString _name = nameList[i];
324 QString _email = emailList[i]; 326 QString _email = emailList[i];
325 QString _uid = uidList[i]; 327 QString _uid = uidList[i];
326 328
327 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); 329 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid);
328 insertAttendee(a); 330 insertAttendee(a);
329 } 331 }
330 } 332 }
331 333
332} 334}
333 335
334void KOEditorDetails::insertAttendee(Attendee *a) 336void KOEditorDetails::insertAttendee(Attendee *a)
335{ 337{
336 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); 338 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild();
337 while (first) { 339 while (first) {
338 if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) 340 if ( first->data()->name() == a->name() && first->data()->email() == a->email() )
339 return; 341 return;
340 first = (AttendeeListItem*) first->nextSibling(); 342 first = (AttendeeListItem*) first->nextSibling();
341 } 343 }
342 344
343 AttendeeListItem *item = new AttendeeListItem(a,mListView); 345 AttendeeListItem *item = new AttendeeListItem(a,mListView);
344 mListView->setSelected( item, true ); 346 mListView->setSelected( item, true );
345} 347}
346 348
347void KOEditorDetails::setDefaults() 349void KOEditorDetails::setDefaults()
348{ 350{
349 mRsvpButton->setChecked(true); 351 mRsvpButton->setChecked(true);
350 mListView->clear(); 352 mListView->clear();
351 mdelAttendees.clear(); 353 mdelAttendees.clear();
352 clearAttendeeInput(); 354 clearAttendeeInput();
353 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); 355 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email()));
354 356
355 mNameEdit->setText(""); 357 mNameEdit->setText("");
356 mUidEdit->setText(""); 358 mUidEdit->setText("");
357 mEmailEdit->setText(""); 359 mEmailEdit->setText("");
358 mRoleCombo->setCurrentItem( 0 ); 360 mRoleCombo->setCurrentItem( 0 );
359 mStatusCombo->setCurrentItem( 0 ); 361 mStatusCombo->setCurrentItem( 0 );
360 362
361} 363}
362 364
363void KOEditorDetails::readEvent(Incidence *event) 365void KOEditorDetails::readEvent(Incidence *event)
364{ 366{
365 setDefaults(); 367 setDefaults();
366 //mListView->clear(); 368 //mListView->clear();
367 //mdelAttendees.clear(); 369 //mdelAttendees.clear();
368 QPtrList<Attendee> tmpAList = event->attendees(); 370 QPtrList<Attendee> tmpAList = event->attendees();
369 Attendee *a; 371 Attendee *a;
370 for (a = tmpAList.first(); a; a = tmpAList.next()) 372 for (a = tmpAList.first(); a; a = tmpAList.next())
371 insertAttendee(new Attendee(*a)); 373 insertAttendee(new Attendee(*a));
372 374
373 mListView->setSelected( mListView->firstChild(), true ); 375 mListView->setSelected( mListView->firstChild(), true );
374 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); 376 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer()));
375} 377}
376 378
377void KOEditorDetails::writeEvent(Incidence *event) 379void KOEditorDetails::writeEvent(Incidence *event)
378{ 380{
379 event->clearAttendees(); 381 event->clearAttendees();
380 QListViewItem *item; 382 QListViewItem *item;
381 AttendeeListItem *a; 383 AttendeeListItem *a;
382 for (item = mListView->firstChild(); item; 384 for (item = mListView->firstChild(); item;
383 item = item->nextSibling()) { 385 item = item->nextSibling()) {
384 a = (AttendeeListItem *)item; 386 a = (AttendeeListItem *)item;
385 event->addAttendee(new Attendee(*(a->data()))); 387 event->addAttendee(new Attendee(*(a->data())));
386 } 388 }
387 event->setOrganizer(KOPrefs::instance()->email()); 389 event->setOrganizer(KOPrefs::instance()->email());
388} 390}
389 391
390void KOEditorDetails::cancelAttendeeEvent(Incidence *event) 392void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
391{ 393{
392 event->clearAttendees(); 394 event->clearAttendees();
393 Attendee * att; 395 Attendee * att;
394 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { 396 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
395 event->addAttendee(new Attendee(*att)); 397 event->addAttendee(new Attendee(*att));
396 } 398 }
397 mdelAttendees.clear(); 399 mdelAttendees.clear();
398} 400}
399 401
400bool KOEditorDetails::validateInput() 402bool KOEditorDetails::validateInput()
401{ 403{
402 return true; 404 return true;
403} 405}
404 406
405void KOEditorDetails::updateAttendeeInput() 407void KOEditorDetails::updateAttendeeInput()
406{ 408{
407 QListViewItem *item = mListView->selectedItem(); 409 QListViewItem *item = mListView->selectedItem();
408 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 410 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
409 if (aItem) { 411 if (aItem) {
410 fillAttendeeInput( aItem ); 412 fillAttendeeInput( aItem );
411 } else { 413 } else {
412 clearAttendeeInput(); 414 clearAttendeeInput();
413 } 415 }
414} 416}
415 417
416void KOEditorDetails::clearAttendeeInput() 418void KOEditorDetails::clearAttendeeInput()
417{ 419{
418 mNameEdit->setText(""); 420 mNameEdit->setText("");
419 mUidEdit->setText(""); 421 mUidEdit->setText("");
420 mEmailEdit->setText(""); 422 mEmailEdit->setText("");
421 mRoleCombo->setCurrentItem(0); 423 mRoleCombo->setCurrentItem(0);
422 mStatusCombo->setCurrentItem(0); 424 mStatusCombo->setCurrentItem(0);
423 mRsvpButton->setChecked(true); 425 mRsvpButton->setChecked(true);
424 setEnabledAttendeeInput( false ); 426 setEnabledAttendeeInput( false );
425} 427}
426 428
427void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) 429void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
428{ 430{
429 Attendee *a = aItem->data(); 431 Attendee *a = aItem->data();
430 mDisableItemUpdate = true; 432 mDisableItemUpdate = true;
431 mNameEdit->setText(a->name()); 433 mNameEdit->setText(a->name());
432 mUidEdit->setText(a->uid()); 434 mUidEdit->setText(a->uid());
433 mEmailEdit->setText(a->email()); 435 mEmailEdit->setText(a->email());
434 mRoleCombo->setCurrentItem(a->role()); 436 mRoleCombo->setCurrentItem(a->role());
435 mStatusCombo->setCurrentItem(a->status()); 437 mStatusCombo->setCurrentItem(a->status());
436 mRsvpButton->setChecked(a->RSVP()); 438 mRsvpButton->setChecked(a->RSVP());
437 439
438 mDisableItemUpdate = false; 440 mDisableItemUpdate = false;
439 441
440 setEnabledAttendeeInput( true ); 442 setEnabledAttendeeInput( true );
441} 443}
442 444
443void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) 445void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
444{ 446{
445 mNameEdit->setEnabled( enabled ); 447 mNameEdit->setEnabled( enabled );
446 mEmailEdit->setEnabled( enabled ); 448 mEmailEdit->setEnabled( enabled );
447 mRoleCombo->setEnabled( enabled ); 449 mRoleCombo->setEnabled( enabled );
448 mStatusCombo->setEnabled( enabled ); 450 mStatusCombo->setEnabled( enabled );
449 mRsvpButton->setEnabled( enabled ); 451 mRsvpButton->setEnabled( enabled );
450 452
451 mRemoveButton->setEnabled( enabled ); 453 mRemoveButton->setEnabled( enabled );
452} 454}
453 455
454void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) 456void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c )
455{ 457{
456 if ( item && c == 4 ) { 458 if ( item && c == 4 ) {
457 mRsvpButton->setChecked( !mRsvpButton->isChecked() ); 459 mRsvpButton->setChecked( !mRsvpButton->isChecked() );
458 updateAttendeeItem(); 460 updateAttendeeItem();
459 } 461 }
460} 462}
461void KOEditorDetails::updateAttendeeItem() 463void KOEditorDetails::updateAttendeeItem()
462{ 464{
463 if (mDisableItemUpdate) return; 465 if (mDisableItemUpdate) return;
464 466
465 QListViewItem *item = mListView->selectedItem(); 467 QListViewItem *item = mListView->selectedItem();
466 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 468 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
467 if ( !aItem ) return; 469 if ( !aItem ) return;
468 470
469 Attendee *a = aItem->data(); 471 Attendee *a = aItem->data();
470 472
471 a->setName( mNameEdit->text() ); 473 a->setName( mNameEdit->text() );
472 a->setUid( mUidEdit->text() ); 474 a->setUid( mUidEdit->text() );
473 a->setEmail( mEmailEdit->text() ); 475 a->setEmail( mEmailEdit->text() );
474 if ( mEmailEdit->text().isEmpty() ) 476 if ( mEmailEdit->text().isEmpty() )
475 mRsvpButton->setChecked( false ); 477 mRsvpButton->setChecked( false );
476 a->setRSVP( mRsvpButton->isChecked() ); 478 a->setRSVP( mRsvpButton->isChecked() );
477 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); 479 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
478 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); 480 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
479 aItem->updateItem(); 481 aItem->updateItem();
480} 482}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index e07bc53..29e68b3 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,569 +1,572 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qregexp.h> 34#include <qregexp.h>
35 35
36 36
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kdialog.h>
38#include <kdebug.h> 39#include <kdebug.h>
39#include <klocale.h> 40#include <klocale.h>
40#include <kiconloader.h> 41#include <kiconloader.h>
41#include <kmessagebox.h> 42#include <kmessagebox.h>
42#include <kfiledialog.h> 43#include <kfiledialog.h>
43#include <kstandarddirs.h> 44#include <kstandarddirs.h>
44 45
45#include <libkcal/todo.h> 46#include <libkcal/todo.h>
46#include <libkcal/event.h> 47#include <libkcal/event.h>
47#include <libkdepim/categoryselectdialog.h> 48#include <libkdepim/categoryselectdialog.h>
48#include <libkdepim/kdateedit.h> 49#include <libkdepim/kdateedit.h>
49 50
50#include "koprefs.h" 51#include "koprefs.h"
51#include "koglobals.h" 52#include "koglobals.h"
52 53
53#include "koeditorgeneral.h" 54#include "koeditorgeneral.h"
54#include "kolocationbox.h" 55#include "kolocationbox.h"
55#ifndef DESKTOP_VERSION 56#ifndef DESKTOP_VERSION
56#include <qpe/qpeapplication.h> 57#include <qpe/qpeapplication.h>
57#else 58#else
58#include <qapplication.h> 59#include <qapplication.h>
59#endif 60#endif
60 61
61KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 62KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
62 QObject( parent, name) 63 QObject( parent, name)
63{ 64{
64 mNextFocus = 0; 65 mNextFocus = 0;
65} 66}
66 67
67KOEditorGeneral::~KOEditorGeneral() 68KOEditorGeneral::~KOEditorGeneral()
68{ 69{
69} 70}
70 71
71void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 72void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
72{ 73{
73 QGridLayout *headerLayout = new QGridLayout(topLayout); 74 QGridLayout *headerLayout = new QGridLayout(topLayout);
74 75
75#if 0 76#if 0
76 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 77 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
77 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 78 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
78#endif 79#endif
79 80 // 1 on pda
81 // 11 on desktop
82 headerLayout->setSpacing( (KDialog::spacingHint()-3)*2+1 );
80 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 83 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
81 headerLayout->addWidget(summaryLabel,1,0); 84 headerLayout->addWidget(summaryLabel,1,0);
82 85
83 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 86 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
84 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 87 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
85 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 88 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
86 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 89 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
87 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 90 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
88 if ( QApplication::desktop()->width() > 320 ) 91 if ( QApplication::desktop()->width() > 320 )
89 mSummaryEdit->setMaximumHeight( hei +6 ); 92 mSummaryEdit->setMaximumHeight( hei +6 );
90 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 93 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
91 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 94 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
92 // mSummaryEdit = new QLineEdit(parent); 95 // mSummaryEdit = new QLineEdit(parent);
93 headerLayout->addWidget(mSummaryEdit,1,1); 96 headerLayout->addWidget(mSummaryEdit,1,1);
94 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 97 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
95 98
96 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 99 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
97 if ( QApplication::desktop()->height() < 320 ) 100 if ( QApplication::desktop()->height() < 320 )
98 headerLayout->addWidget(locationLabel,1,2); 101 headerLayout->addWidget(locationLabel,1,2);
99 else 102 else
100 headerLayout->addWidget(locationLabel,2,0); 103 headerLayout->addWidget(locationLabel,2,0);
101 104
102 mLocationEdit = new KOLocationBox(TRUE,parent,10); 105 mLocationEdit = new KOLocationBox(TRUE,parent,10);
103 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 106 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
104 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 ) 107 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->height() > 240 )
105 mLocationEdit->setMaximumHeight( hei + 6); 108 mLocationEdit->setMaximumHeight( hei + 6);
106 109
107 // mLocationEdit = new QLineEdit(parent); 110 // mLocationEdit = new QLineEdit(parent);
108 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 111 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
109 if ( QApplication::desktop()->height() < 320 ) { 112 if ( QApplication::desktop()->height() < 320 ) {
110 headerLayout->addWidget(mLocationEdit,1,3); 113 headerLayout->addWidget(mLocationEdit,1,3);
111 headerLayout->setColStretch( 1, 10); 114 headerLayout->setColStretch( 1, 10);
112 headerLayout->setColStretch( 3, 10); 115 headerLayout->setColStretch( 3, 10);
113 } 116 }
114 else { 117 else {
115 headerLayout->addWidget(mLocationEdit,2,1); 118 headerLayout->addWidget(mLocationEdit,2,1);
116 headerLayout->setColStretch( 1, 10); 119 headerLayout->setColStretch( 1, 10);
117 } 120 }
118} 121}
119void KOEditorGeneral::setFocusOn( int i ) 122void KOEditorGeneral::setFocusOn( int i )
120{ 123{
121 mNextFocus = i; 124 mNextFocus = i;
122 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 125 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
123} 126}
124void KOEditorGeneral::slotSetFocusOn() 127void KOEditorGeneral::slotSetFocusOn()
125{ 128{
126 mNextFocus; 129 mNextFocus;
127 if ( mNextFocus == 1 ) { 130 if ( mNextFocus == 1 ) {
128 mDescriptionEdit->setFocus(); 131 mDescriptionEdit->setFocus();
129 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 132 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
130 } 133 }
131 if ( mNextFocus == 2 ) { 134 if ( mNextFocus == 2 ) {
132 mSummaryEdit->setFocus(); 135 mSummaryEdit->setFocus();
133 } 136 }
134} 137}
135void KOEditorGeneral::editCategories() 138void KOEditorGeneral::editCategories()
136{ 139{
137 // qDebug("KOEditorGeneral::editCategories() "); 140 // qDebug("KOEditorGeneral::editCategories() ");
138 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 141 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
139 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 142 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
140 //KOGlobals::fitDialogToScreen( csd ); 143 //KOGlobals::fitDialogToScreen( csd );
141 csd->setColorEnabled(); 144 csd->setColorEnabled();
142 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 145 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
143 csd->exec(); 146 csd->exec();
144 delete csd; 147 delete csd;
145} 148}
146 149
147void KOEditorGeneral::showCatPopup() 150void KOEditorGeneral::showCatPopup()
148{ 151{
149 mCatPopup->clear(); 152 mCatPopup->clear();
150 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text()); 153 QStringList checkedCategories = QStringList::split (",", mCategoriesLabel->text());
151 int index = 0; 154 int index = 0;
152 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 155 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
153 it != KOPrefs::instance()->mCustomCategories.end (); 156 it != KOPrefs::instance()->mCustomCategories.end ();
154 ++it) { 157 ++it) {
155 mCatPopup->insertItem (*it, index ); 158 mCatPopup->insertItem (*it, index );
156 //mCategory[index] = *it; 159 //mCategory[index] = *it;
157 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true); 160 if (checkedCategories.find (*it) != checkedCategories.end ()) mCatPopup->setItemChecked (index, true);
158 ++index; 161 ++index;
159 } 162 }
160} 163}
161void KOEditorGeneral::selectedCatPopup( int index ) 164void KOEditorGeneral::selectedCatPopup( int index )
162{ 165{
163 QStringList categories = QStringList::split (",", mCategoriesLabel->text()); 166 QStringList categories = QStringList::split (",", mCategoriesLabel->text());
164 QString colcat = categories.first(); 167 QString colcat = categories.first();
165 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ()) 168 if (categories.find (KOPrefs::instance()->mCustomCategories[index]) != categories.end ())
166 categories.remove (KOPrefs::instance()->mCustomCategories[index]); 169 categories.remove (KOPrefs::instance()->mCustomCategories[index]);
167 else 170 else
168 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]); 171 categories.insert (categories.end(), KOPrefs::instance()->mCustomCategories[index]);
169 categories.sort (); 172 categories.sort ();
170 if ( !colcat.isEmpty() ) { 173 if ( !colcat.isEmpty() ) {
171 if ( categories.find ( colcat ) != categories.end () ) { 174 if ( categories.find ( colcat ) != categories.end () ) {
172 categories.remove( colcat ); 175 categories.remove( colcat );
173 categories.prepend( colcat ); 176 categories.prepend( colcat );
174 } 177 }
175 } 178 }
176 setCategories( categories.join(",") ); 179 setCategories( categories.join(",") );
177} 180}
178 181
179void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 182void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
180{ 183{
181 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 184 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
182 mCatPopup = new QPopupMenu ( parent ); 185 mCatPopup = new QPopupMenu ( parent );
183 mCatPopup->setCheckable (true); 186 mCatPopup->setCheckable (true);
184 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup())); 187 connect(mCatPopup,SIGNAL(aboutToShow () ), this ,SLOT(showCatPopup()));
185 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int ))); 188 connect(mCatPopup,SIGNAL( activated ( int ) ), this ,SLOT(selectedCatPopup( int )));
186 mCategoriesButton = new QPushButton(parent); 189 mCategoriesButton = new QPushButton(parent);
187 mCategoriesButton->setText(i18n("Categories...")); 190 mCategoriesButton->setText(i18n("Categories..."));
188 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 191 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
189 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 192 //connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
190 categoriesLayout->addWidget(mCategoriesButton); 193 categoriesLayout->addWidget(mCategoriesButton);
191 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent); 194 mCategoriesLabel = new QPushButton(parent);//new QLabel(parent);
192 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 195 mCategoriesLabel->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) );
193 mCategoriesLabel->setPopup( mCatPopup ); 196 mCategoriesLabel->setPopup( mCatPopup );
194 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 197 //mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
195 categoriesLayout->addWidget(mCategoriesLabel,1); 198 categoriesLayout->addWidget(mCategoriesLabel,1);
196} 199}
197 200
198void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 201void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
199{ 202{
200 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 203 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
201 204
202 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 205 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
203 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 206 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
204 secrecyLayout->addWidget(mCancelBox); 207 secrecyLayout->addWidget(mCancelBox);
205 secrecyLayout->addWidget(secrecyLabel); 208 secrecyLayout->addWidget(secrecyLabel);
206 209
207 mSecrecyCombo = new QComboBox(parent); 210 mSecrecyCombo = new QComboBox(parent);
208 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 211 mSecrecyCombo->insertStringList(Incidence::secrecyList());
209 secrecyLayout->addWidget(mSecrecyCombo); 212 secrecyLayout->addWidget(mSecrecyCombo);
210} 213}
211 214
212void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 215void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
213{ 216{
214 mDescriptionEdit = new KTextEdit(parent); 217 mDescriptionEdit = new KTextEdit(parent);
215 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 218 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
216 mDescriptionEdit->append(""); 219 mDescriptionEdit->append("");
217 mDescriptionEdit->setReadOnly(false); 220 mDescriptionEdit->setReadOnly(false);
218 mDescriptionEdit->setOverwriteMode(false); 221 mDescriptionEdit->setOverwriteMode(false);
219 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 222 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
220 topLayout->addWidget(mDescriptionEdit); 223 topLayout->addWidget(mDescriptionEdit);
221#ifndef DESKTOP_VERSION 224#ifndef DESKTOP_VERSION
222 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 225 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
223#endif 226#endif
224 227
225} 228}
226 229
227void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 230void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
228{ 231{
229 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 232 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
230 233
231 //mAlarmBell = new QLabel(parent); 234 //mAlarmBell = new QLabel(parent);
232 //mAlarmBell->setPixmap(SmallIcon("bell")); 235 //mAlarmBell->setPixmap(SmallIcon("bell"));
233 //alarmLayout->addWidget(mAlarmBell); 236 //alarmLayout->addWidget(mAlarmBell);
234 if ( QApplication::desktop()->width() < 320 ) 237 if ( QApplication::desktop()->width() < 320 )
235 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 238 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
236 else 239 else
237 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 240 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
238 241
239 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 242 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
240 alarmLayout->addWidget(mAlarmButton); 243 alarmLayout->addWidget(mAlarmButton);
241 244
242 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 245 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
243 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 246 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
244 alarmLayout->addWidget(mAlarmTimeEdit); 247 alarmLayout->addWidget(mAlarmTimeEdit);
245 mAlarmIncrCombo = new QComboBox(false, parent); 248 mAlarmIncrCombo = new QComboBox(false, parent);
246 if ( QApplication::desktop()->width() < 320 ) { 249 if ( QApplication::desktop()->width() < 320 ) {
247 mAlarmIncrCombo->insertItem(i18n("min")); 250 mAlarmIncrCombo->insertItem(i18n("min"));
248 mAlarmIncrCombo->insertItem(i18n("hou")); 251 mAlarmIncrCombo->insertItem(i18n("hou"));
249 mAlarmIncrCombo->insertItem(i18n("day")); 252 mAlarmIncrCombo->insertItem(i18n("day"));
250 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 253 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
251 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 254 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
252 } else { 255 } else {
253 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 256 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
254 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 257 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
255 mAlarmIncrCombo->insertItem(i18n("day(s)")); 258 mAlarmIncrCombo->insertItem(i18n("day(s)"));
256 } 259 }
257 260
258 // mAlarmIncrCombo->setMinimumHeight(20); 261 // mAlarmIncrCombo->setMinimumHeight(20);
259 alarmLayout->addWidget(mAlarmIncrCombo); 262 alarmLayout->addWidget(mAlarmIncrCombo);
260 mAlarmSoundButton = new QPushButton(parent); 263 mAlarmSoundButton = new QPushButton(parent);
261 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 264 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
262 mAlarmSoundButton->setToggleButton(true); 265 mAlarmSoundButton->setToggleButton(true);
263 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 266 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
264 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 267 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
265 alarmLayout->addWidget(mAlarmSoundButton); 268 alarmLayout->addWidget(mAlarmSoundButton);
266 269
267 mAlarmProgramButton = new QPushButton(parent); 270 mAlarmProgramButton = new QPushButton(parent);
268 mAlarmProgramButton->setPixmap(SmallIcon("run")); 271 mAlarmProgramButton->setPixmap(SmallIcon("run"));
269 mAlarmProgramButton->setToggleButton(true); 272 mAlarmProgramButton->setToggleButton(true);
270 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 273 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
271 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 274 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
272 alarmLayout->addWidget(mAlarmProgramButton); 275 alarmLayout->addWidget(mAlarmProgramButton);
273 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 276 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
274 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 277 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
275 // if ( KOPrefs::instance()->mCompactDialogs ) { 278 // if ( KOPrefs::instance()->mCompactDialogs ) {
276 // mAlarmSoundButton->hide(); 279 // mAlarmSoundButton->hide();
277 // mAlarmProgramButton->hide(); 280 // mAlarmProgramButton->hide();
278 // } 281 // }
279} 282}
280 283
281void KOEditorGeneral::pickAlarmSound() 284void KOEditorGeneral::pickAlarmSound()
282{ 285{
283 286
284 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 287 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
285 288
286 bool oldState = mAlarmSoundButton->isOn(); 289 bool oldState = mAlarmSoundButton->isOn();
287 290
288 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 291 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
289 i18n("*.wav|Wav Files"), 0)); 292 i18n("*.wav|Wav Files"), 0));
290 if (!fileName.isEmpty()) { 293 if (!fileName.isEmpty()) {
291 mAlarmSound = fileName; 294 mAlarmSound = fileName;
292 QToolTip::remove(mAlarmSoundButton); 295 QToolTip::remove(mAlarmSoundButton);
293 QString dispStr = i18n("Playing '%1'").arg(fileName); 296 QString dispStr = i18n("Playing '%1'").arg(fileName);
294 QToolTip::add(mAlarmSoundButton, dispStr); 297 QToolTip::add(mAlarmSoundButton, dispStr);
295 mAlarmProgramButton->setOn(false); 298 mAlarmProgramButton->setOn(false);
296 mAlarmSoundButton->setOn(true); 299 mAlarmSoundButton->setOn(true);
297 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 300 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
298 } else { 301 } else {
299 mAlarmProgramButton->setOn(oldState); 302 mAlarmProgramButton->setOn(oldState);
300 mAlarmSoundButton->setOn(!oldState); 303 mAlarmSoundButton->setOn(!oldState);
301 304
302 305
303 } 306 }
304 307
305 if (mAlarmProgramButton->isOn()) 308 if (mAlarmProgramButton->isOn())
306 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 309 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
307 if ( mAlarmSoundButton->isOn()) 310 if ( mAlarmSoundButton->isOn())
308 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 311 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
309 312
310} 313}
311 314
312void KOEditorGeneral::pickAlarmProgram() 315void KOEditorGeneral::pickAlarmProgram()
313{ 316{
314 bool oldState = mAlarmProgramButton->isOn(); 317 bool oldState = mAlarmProgramButton->isOn();
315 318
316 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 319 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
317 if (!fileName.isEmpty()) { 320 if (!fileName.isEmpty()) {
318 mAlarmProgram = fileName; 321 mAlarmProgram = fileName;
319 QToolTip::remove(mAlarmProgramButton); 322 QToolTip::remove(mAlarmProgramButton);
320 QString dispStr = i18n("Running '%1'").arg(fileName); 323 QString dispStr = i18n("Running '%1'").arg(fileName);
321 QToolTip::add(mAlarmProgramButton, dispStr); 324 QToolTip::add(mAlarmProgramButton, dispStr);
322 mAlarmSoundButton->setOn(false); 325 mAlarmSoundButton->setOn(false);
323 mAlarmProgramButton->setOn(true); 326 mAlarmProgramButton->setOn(true);
324 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 327 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
325 } else { 328 } else {
326 mAlarmProgramButton->setOn(!oldState); 329 mAlarmProgramButton->setOn(!oldState);
327 mAlarmSoundButton->setOn(oldState); 330 mAlarmSoundButton->setOn(oldState);
328 } 331 }
329 332
330 if (mAlarmProgramButton->isOn()) 333 if (mAlarmProgramButton->isOn())
331 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 334 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
332 if ( mAlarmSoundButton->isOn()) 335 if ( mAlarmSoundButton->isOn())
333 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 336 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
334 337
335} 338}
336 339
337 340
338QString KOEditorGeneral::getFittingPath( const QString s ) 341QString KOEditorGeneral::getFittingPath( const QString s )
339{ 342{
340 int maxlen = 50; 343 int maxlen = 50;
341 if ( QApplication::desktop()->width() < 640 ) { 344 if ( QApplication::desktop()->width() < 640 ) {
342 if ( QApplication::desktop()->width() < 320 ) 345 if ( QApplication::desktop()->width() < 320 )
343 maxlen = 22; 346 maxlen = 22;
344 else 347 else
345 maxlen = 35; 348 maxlen = 35;
346 } 349 }
347 if ( s.length() > maxlen ) { 350 if ( s.length() > maxlen ) {
348 return "..."+s.right(maxlen -3); 351 return "..."+s.right(maxlen -3);
349 } 352 }
350 return s; 353 return s;
351} 354}
352 355
353void KOEditorGeneral::enableAlarmEdit(bool enable) 356void KOEditorGeneral::enableAlarmEdit(bool enable)
354{ 357{
355 if ( enable ) { 358 if ( enable ) {
356 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 359 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
357 mAlarmSoundButton->setOn( true ); 360 mAlarmSoundButton->setOn( true );
358 if ( mAlarmSound.isEmpty() ) 361 if ( mAlarmSound.isEmpty() )
359 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
360 else { 363 else {
361 if ( ! QFile::exists( mAlarmSound ) ) 364 if ( ! QFile::exists( mAlarmSound ) )
362 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 365 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
363 } 366 }
364 } 367 }
365 } 368 }
366 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 369 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
367 mAlarmTimeEdit->setEnabled(enable); 370 mAlarmTimeEdit->setEnabled(enable);
368 mAlarmSoundButton->setEnabled(enable); 371 mAlarmSoundButton->setEnabled(enable);
369 mAlarmProgramButton->setEnabled(enable); 372 mAlarmProgramButton->setEnabled(enable);
370 mAlarmIncrCombo->setEnabled(enable); 373 mAlarmIncrCombo->setEnabled(enable);
371} 374}
372 375
373void KOEditorGeneral::disableAlarmEdit(bool disable) 376void KOEditorGeneral::disableAlarmEdit(bool disable)
374{ 377{
375 enableAlarmEdit( !disable ); 378 enableAlarmEdit( !disable );
376} 379}
377 380
378void KOEditorGeneral::enableAlarm( bool enable ) 381void KOEditorGeneral::enableAlarm( bool enable )
379{ 382{
380 enableAlarmEdit( enable ); 383 enableAlarmEdit( enable );
381} 384}
382 385
383void KOEditorGeneral::alarmDisable(bool disable) 386void KOEditorGeneral::alarmDisable(bool disable)
384{ 387{
385 if (!disable) { 388 if (!disable) {
386 //mAlarmBell->setEnabled(true); 389 //mAlarmBell->setEnabled(true);
387 mAlarmButton->setEnabled(true); 390 mAlarmButton->setEnabled(true);
388 } else { 391 } else {
389 //mAlarmBell->setEnabled(false); 392 //mAlarmBell->setEnabled(false);
390 mAlarmButton->setEnabled(false); 393 mAlarmButton->setEnabled(false);
391 mAlarmButton->setChecked(false); 394 mAlarmButton->setChecked(false);
392 mAlarmTimeEdit->setEnabled(false); 395 mAlarmTimeEdit->setEnabled(false);
393 mAlarmSoundButton->setEnabled(false); 396 mAlarmSoundButton->setEnabled(false);
394 mAlarmProgramButton->setEnabled(false); 397 mAlarmProgramButton->setEnabled(false);
395 mAlarmIncrCombo->setEnabled(false); 398 mAlarmIncrCombo->setEnabled(false);
396 } 399 }
397} 400}
398 401
399void KOEditorGeneral::setCategories(const QString &str) 402void KOEditorGeneral::setCategories(const QString &str)
400{ 403{
401 QString tt = str; 404 QString tt = str;
402 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>"); 405 QToolTip::add( mCategoriesLabel, i18n("<b>Click here to edit categories: </b>") +"<em>"+tt.replace( QRegExp(","),", ")+"</em>");
403 mCategoriesLabel->setText(str); 406 mCategoriesLabel->setText(str);
404} 407}
405 408
406void KOEditorGeneral::setDefaults(bool allDay) 409void KOEditorGeneral::setDefaults(bool allDay)
407{ 410{
408#if 0 411#if 0
409 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 412 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
410#endif 413#endif
411 414
412 mAlarmMessage = i18n("Edit new item"); 415 mAlarmMessage = i18n("Edit new item");
413 enableAlarmEdit( !allDay ); 416 enableAlarmEdit( !allDay );
414 417
415 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 418 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
416 int alarmTime; 419 int alarmTime;
417 int a[] = { 1,5,10,15,30,60,180, 1440 }; 420 int a[] = { 1,5,10,15,30,60,180, 1440 };
418 int index = KOPrefs::instance()->mAlarmTime; 421 int index = KOPrefs::instance()->mAlarmTime;
419 if (index < 0 || index > 7) { 422 if (index < 0 || index > 7) {
420 alarmTime = 15; 423 alarmTime = 15;
421 } else { 424 } else {
422 alarmTime = a[index]; 425 alarmTime = a[index];
423 } 426 }
424 mAlarmButton ->setChecked( false ); 427 mAlarmButton ->setChecked( false );
425 mAlarmTimeEdit->setValue(alarmTime); 428 mAlarmTimeEdit->setValue(alarmTime);
426 mAlarmIncrCombo->setCurrentItem(0); 429 mAlarmIncrCombo->setCurrentItem(0);
427 enableAlarmEdit( false ); 430 enableAlarmEdit( false );
428 //alarmDisable (false); 431 //alarmDisable (false);
429 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 432 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
430 mCancelBox->setChecked( false ); 433 mCancelBox->setChecked( false );
431 mSummaryEdit->setEditText(""); 434 mSummaryEdit->setEditText("");
432 mLocationEdit->setEditText(""); 435 mLocationEdit->setEditText("");
433 mDescriptionEdit->setText(""); 436 mDescriptionEdit->setText("");
434 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 437 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
435 setCategories(""); 438 setCategories("");
436} 439}
437void KOEditorGeneral::setSecrecy( int num ) 440void KOEditorGeneral::setSecrecy( int num )
438{ 441{
439 mSecrecyCombo->setCurrentItem(num); 442 mSecrecyCombo->setCurrentItem(num);
440} 443}
441void KOEditorGeneral::readIncidence(Incidence *event) 444void KOEditorGeneral::readIncidence(Incidence *event)
442{ 445{
443 446
444 mAlarmMessage = event->summary(); 447 mAlarmMessage = event->summary();
445 if ( ! event->location().isEmpty() ) 448 if ( ! event->location().isEmpty() )
446 mAlarmMessage += " ("+event->location()+")"; 449 mAlarmMessage += " ("+event->location()+")";
447 mAlarmIncrCombo->setCurrentItem(0); 450 mAlarmIncrCombo->setCurrentItem(0);
448 mSummaryEdit->setEditText(event->summary()); 451 mSummaryEdit->setEditText(event->summary());
449 mLocationEdit->setEditText(event->location()); 452 mLocationEdit->setEditText(event->location());
450 mDescriptionEdit->setText(event->description()); 453 mDescriptionEdit->setText(event->description());
451 454
452#if 0 455#if 0
453 // organizer information 456 // organizer information
454 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 457 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
455#endif 458#endif
456 459
457 enableAlarmEdit( event->isAlarmEnabled() ); 460 enableAlarmEdit( event->isAlarmEnabled() );
458 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 461 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
459 if(!event->isAlarmEnabled()) { 462 if(!event->isAlarmEnabled()) {
460 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 463 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
461 int alarmTime; 464 int alarmTime;
462 int a[] = { 1,5,10,15,30,60,180, 1440 }; 465 int a[] = { 1,5,10,15,30,60,180, 1440 };
463 int index = KOPrefs::instance()->mAlarmTime; 466 int index = KOPrefs::instance()->mAlarmTime;
464 if (index < 0 || index > 7) { 467 if (index < 0 || index > 7) {
465 alarmTime = 15; 468 alarmTime = 15;
466 } else { 469 } else {
467 alarmTime = a[index]; 470 alarmTime = a[index];
468 } 471 }
469 mAlarmTimeEdit->setValue(alarmTime); 472 mAlarmTimeEdit->setValue(alarmTime);
470 } 473 }
471 mAlarmButton->setChecked( event->isAlarmEnabled() ); 474 mAlarmButton->setChecked( event->isAlarmEnabled() );
472 mSecrecyCombo->setCurrentItem(event->secrecy()); 475 mSecrecyCombo->setCurrentItem(event->secrecy());
473 mCancelBox->setChecked( event->cancelled() ); 476 mCancelBox->setChecked( event->cancelled() );
474 mAlarmProgramButton->setOn(false); 477 mAlarmProgramButton->setOn(false);
475 mAlarmSoundButton->setOn(false); 478 mAlarmSoundButton->setOn(false);
476 479
477 // set up alarm stuff 480 // set up alarm stuff
478 QPtrList<Alarm> alarms = event->alarms(); 481 QPtrList<Alarm> alarms = event->alarms();
479 Alarm* alarm; 482 Alarm* alarm;
480 mAlarmIncrCombo->setCurrentItem(0); 483 mAlarmIncrCombo->setCurrentItem(0);
481 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 484 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
482 int offset; 485 int offset;
483 if ( alarm->hasTime() ) { 486 if ( alarm->hasTime() ) {
484 QDateTime t = alarm->time(); 487 QDateTime t = alarm->time();
485 offset = event->dtStart().secsTo( t ); 488 offset = event->dtStart().secsTo( t );
486 } else { 489 } else {
487 offset = alarm->startOffset().asSeconds(); 490 offset = alarm->startOffset().asSeconds();
488 } 491 }
489 if ( offset != 0 ) { 492 if ( offset != 0 ) {
490 offset = offset / -60; // make minutes 493 offset = offset / -60; // make minutes
491 if (offset % 60 == 0) { // divides evenly into hours? 494 if (offset % 60 == 0) { // divides evenly into hours?
492 offset = offset / 60; 495 offset = offset / 60;
493 mAlarmIncrCombo->setCurrentItem(1); 496 mAlarmIncrCombo->setCurrentItem(1);
494 if (offset % 24 == 0) { // divides evenly into days? 497 if (offset % 24 == 0) { // divides evenly into days?
495 offset = offset / 24; 498 offset = offset / 24;
496 mAlarmIncrCombo->setCurrentItem(2); 499 mAlarmIncrCombo->setCurrentItem(2);
497 } 500 }
498 } 501 }
499 } 502 }
500 mAlarmTimeEdit->setValue( offset ); 503 mAlarmTimeEdit->setValue( offset );
501 if (alarm->type() == Alarm::Procedure) { 504 if (alarm->type() == Alarm::Procedure) {
502 505
503 mAlarmProgram = alarm->programFile(); 506 mAlarmProgram = alarm->programFile();
504 mAlarmProgramButton->setOn(true); 507 mAlarmProgramButton->setOn(true);
505 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 508 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
506 QToolTip::add(mAlarmProgramButton, dispStr); 509 QToolTip::add(mAlarmProgramButton, dispStr);
507 } 510 }
508 else if (alarm->type() == Alarm::Audio) { 511 else if (alarm->type() == Alarm::Audio) {
509 mAlarmSound = alarm->audioFile(); 512 mAlarmSound = alarm->audioFile();
510 if ( ! QFile::exists( mAlarmSound ) ) 513 if ( ! QFile::exists( mAlarmSound ) )
511 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 514 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
512 mAlarmSoundButton->setOn(true); 515 mAlarmSoundButton->setOn(true);
513 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 516 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
514 QToolTip::add(mAlarmSoundButton, dispStr); 517 QToolTip::add(mAlarmSoundButton, dispStr);
515 } 518 }
516 mAlarmButton->setChecked(alarm->enabled()); 519 mAlarmButton->setChecked(alarm->enabled());
517 enableAlarmEdit( alarm->enabled() ); 520 enableAlarmEdit( alarm->enabled() );
518 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 521 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
519 // TODO: Deal with multiple alarms 522 // TODO: Deal with multiple alarms
520 break; // For now, stop after the first alarm 523 break; // For now, stop after the first alarm
521 } 524 }
522 525
523 setCategories(event->categoriesStr()); 526 setCategories(event->categoriesStr());
524} 527}
525 528
526void KOEditorGeneral::writeIncidence(Incidence *event) 529void KOEditorGeneral::writeIncidence(Incidence *event)
527{ 530{
528 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 531 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
529 mLocationEdit->save(KOLocationBox::LOCATION); 532 mLocationEdit->save(KOLocationBox::LOCATION);
530 event->setSummary(mSummaryEdit->currentText()); 533 event->setSummary(mSummaryEdit->currentText());
531 event->setLocation(mLocationEdit->currentText()); 534 event->setLocation(mLocationEdit->currentText());
532 event->setDescription(mDescriptionEdit->text()); 535 event->setDescription(mDescriptionEdit->text());
533 event->setCategories(mCategoriesLabel->text()); 536 event->setCategories(mCategoriesLabel->text());
534 event->setSecrecy(mSecrecyCombo->currentItem()); 537 event->setSecrecy(mSecrecyCombo->currentItem());
535 event->setCancelled(mCancelBox->isChecked() );; 538 event->setCancelled(mCancelBox->isChecked() );;
536 // alarm stuff 539 // alarm stuff
537 if (mAlarmButton->isChecked()) { 540 if (mAlarmButton->isChecked()) {
538 if (event->alarms().count() == 0) 541 if (event->alarms().count() == 0)
539 event->newAlarm(); 542 event->newAlarm();
540 QPtrList<Alarm> alarms = event->alarms(); 543 QPtrList<Alarm> alarms = event->alarms();
541 Alarm *alarm; 544 Alarm *alarm;
542 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 545 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
543 alarm->setEnabled(true); 546 alarm->setEnabled(true);
544 int j = mAlarmTimeEdit->value()* -60; 547 int j = mAlarmTimeEdit->value()* -60;
545 if (mAlarmIncrCombo->currentItem() == 1) 548 if (mAlarmIncrCombo->currentItem() == 1)
546 j = j * 60; 549 j = j * 60;
547 else if (mAlarmIncrCombo->currentItem() == 2) 550 else if (mAlarmIncrCombo->currentItem() == 2)
548 j = j * (60 * 24); 551 j = j * (60 * 24);
549 alarm->setStartOffset( j ); 552 alarm->setStartOffset( j );
550 553
551 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 554 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
552 alarm->setProcedureAlarm(mAlarmProgram); 555 alarm->setProcedureAlarm(mAlarmProgram);
553 } 556 }
554 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 557 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
555 alarm->setAudioAlarm(mAlarmSound); 558 alarm->setAudioAlarm(mAlarmSound);
556 else 559 else
557 alarm->setType(Alarm::Invalid); 560 alarm->setType(Alarm::Invalid);
558 //alarm->setAudioAlarm("default"); 561 //alarm->setAudioAlarm("default");
559 // TODO: Deal with multiple alarms 562 // TODO: Deal with multiple alarms
560 break; // For now, stop after the first alarm 563 break; // For now, stop after the first alarm
561 } 564 }
562 } else { 565 } else {
563 Alarm* alarm = event->alarms().first(); 566 Alarm* alarm = event->alarms().first();
564 if ( alarm ) { 567 if ( alarm ) {
565 alarm->setEnabled(false); 568 alarm->setEnabled(false);
566 alarm->setType(Alarm::Invalid); 569 alarm->setType(Alarm::Invalid);
567 } 570 }
568 } 571 }
569} 572}
diff --git a/korganizer/koeditorgeneralevent.cpp b/korganizer/koeditorgeneralevent.cpp
index 3dd7f5c..2c6ed9f 100644
--- a/korganizer/koeditorgeneralevent.cpp
+++ b/korganizer/koeditorgeneralevent.cpp
@@ -1,443 +1,444 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qvgroupbox.h> 28#include <qvgroupbox.h>
29#include <qwidgetstack.h> 29#include <qwidgetstack.h>
30#include <qdatetime.h> 30#include <qdatetime.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kdialog.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kiconloader.h> 36#include <kiconloader.h>
36#include <kmessagebox.h> 37#include <kmessagebox.h>
37#include <kfiledialog.h> 38#include <kfiledialog.h>
38#include <kstandarddirs.h> 39#include <kstandarddirs.h>
39 40
40#include <libkcal/event.h> 41#include <libkcal/event.h>
41 42
42#include <libkdepim/kdateedit.h> 43#include <libkdepim/kdateedit.h>
43 44
44#include "koprefs.h" 45#include "koprefs.h"
45 46
46#include "koeditorgeneralevent.h" 47#include "koeditorgeneralevent.h"
47#include "kolocationbox.h" 48#include "kolocationbox.h"
48 49
49KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent, 50KOEditorGeneralEvent::KOEditorGeneralEvent(QObject* parent,
50 const char* name) : 51 const char* name) :
51 KOEditorGeneral( parent, name) 52 KOEditorGeneral( parent, name)
52{ 53{
53 mTemplate = false; 54 mTemplate = false;
54 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 55 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
55 SLOT(setDuration())); 56 SLOT(setDuration()));
56 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 57 connect(this,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
57 SLOT(emitDateTimeStr())); 58 SLOT(emitDateTimeStr()));
58} 59}
59 60
60KOEditorGeneralEvent::~KOEditorGeneralEvent() 61KOEditorGeneralEvent::~KOEditorGeneralEvent()
61{ 62{
62} 63}
63 64
64void KOEditorGeneralEvent::finishSetup() 65void KOEditorGeneralEvent::finishSetup()
65{ 66{
66 67
67 //disabled 68 //disabled
68// QWidget::setTabOrder( mSummaryEdit, mLocationEdit ); 69// QWidget::setTabOrder( mSummaryEdit, mLocationEdit );
69// QWidget::setTabOrder( mLocationEdit, mStartDateEdit ); 70// QWidget::setTabOrder( mLocationEdit, mStartDateEdit );
70// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit ); 71// QWidget::setTabOrder( mStartDateEdit, mStartTimeEdit );
71// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit ); 72// QWidget::setTabOrder( mStartTimeEdit, mEndDateEdit );
72// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit ); 73// QWidget::setTabOrder( mEndDateEdit, mEndTimeEdit );
73// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton ); 74// QWidget::setTabOrder( mEndTimeEdit, mNoTimeButton );
74// QWidget::setTabOrder( mNoTimeButton, mAlarmButton ); 75// QWidget::setTabOrder( mNoTimeButton, mAlarmButton );
75// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit ); 76// QWidget::setTabOrder( mAlarmButton, mAlarmTimeEdit );
76// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton ); 77// QWidget::setTabOrder( mFreeTimeCombo, mCategoriesButton );
77// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo ); 78// QWidget::setTabOrder( mCategoriesButton, mSecrecyCombo );
78// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit ); 79// QWidget::setTabOrder( mSecrecyCombo, mDescriptionEdit );
79 80
80 81
81 82
82 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 83 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
83 mSummaryEdit->setFocus(); 84 mSummaryEdit->setFocus();
84} 85}
85 86
86void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout) 87void KOEditorGeneralEvent::initTime(QWidget *parent,QBoxLayout *topLayout)
87{ 88{
88 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 89 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
89 90
90 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 91 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
91 i18n("Date && Time"),parent); 92 i18n("Date && Time"),parent);
92 timeLayout->addWidget(timeGroupBox); 93 timeLayout->addWidget(timeGroupBox);
93 94
94 timeGroupBox->layout()->setSpacing( 0 ); 95 timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() );
95 timeGroupBox->layout()->setMargin( 5 ); 96 timeGroupBox->layout()->setMargin( KDialog::marginHint() );
96 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 97 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
97 98
98 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3); 99 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,2,3);
99 layoutTimeBox->setSpacing(topLayout->spacing()); 100 layoutTimeBox->setSpacing(topLayout->spacing());
100 101
101 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame); 102 mStartDateLabel = new QLabel(i18n("Start:"),timeBoxFrame);
102 layoutTimeBox->addWidget(mStartDateLabel,0,0); 103 layoutTimeBox->addWidget(mStartDateLabel,0,0);
103 104
104 mStartDateEdit = new KDateEdit(timeBoxFrame); 105 mStartDateEdit = new KDateEdit(timeBoxFrame);
105 layoutTimeBox->addWidget(mStartDateEdit,0,1); 106 layoutTimeBox->addWidget(mStartDateEdit,0,1);
106 107
107 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 108 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
108 layoutTimeBox->addWidget(mStartTimeEdit,0,2); 109 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
109 110
110 111
111 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame); 112 mEndDateLabel = new QLabel(i18n("End:"),timeBoxFrame);
112 layoutTimeBox->addWidget(mEndDateLabel,1,0); 113 layoutTimeBox->addWidget(mEndDateLabel,1,0);
113 114
114 mEndDateEdit = new KDateEdit(timeBoxFrame); 115 mEndDateEdit = new KDateEdit(timeBoxFrame);
115 layoutTimeBox->addWidget(mEndDateEdit,1,1); 116 layoutTimeBox->addWidget(mEndDateEdit,1,1);
116 117
117 mEndTimeEdit = new KOTimeEdit(timeBoxFrame); 118 mEndTimeEdit = new KOTimeEdit(timeBoxFrame);
118 layoutTimeBox->addWidget(mEndTimeEdit,1,2); 119 layoutTimeBox->addWidget(mEndTimeEdit,1,2);
119 QWidget* duration = new QWidget( timeBoxFrame ); 120 QWidget* duration = new QWidget( timeBoxFrame );
120 QHBoxLayout *flagsBox = new QHBoxLayout( duration ); 121 QHBoxLayout *flagsBox = new QHBoxLayout( duration );
121 mNoTimeButton = new QCheckBox(i18n("All day event"),duration); 122 mNoTimeButton = new QCheckBox(i18n("All day event"),duration);
122 flagsBox->addWidget(mNoTimeButton); 123 flagsBox->addWidget(mNoTimeButton);
123 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool))); 124 connect(mNoTimeButton, SIGNAL(toggled(bool)),SLOT(dontAssociateTime(bool)));
124 mDurationLabel = new QLabel( duration ); 125 mDurationLabel = new QLabel( duration );
125 // if ( KOPrefs::instance()->mCompactDialogs ) { 126 // if ( KOPrefs::instance()->mCompactDialogs ) {
126 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 ); 127 //layoutTimeBox->addMultiCellWidget( mDurationLabel, 3, 3, 0, 3 );
127 //} else { 128 //} else {
128 flagsBox->addWidget( mDurationLabel ); 129 flagsBox->addWidget( mDurationLabel );
129 //} 130 //}
130 flagsBox->setStretchFactor(mDurationLabel, 10 ); 131 flagsBox->setStretchFactor(mDurationLabel, 10 );
131 mDurationLabel->setAlignment( AlignRight | AlignVCenter); 132 mDurationLabel->setAlignment( AlignRight | AlignVCenter);
132 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 ); 133 layoutTimeBox->addMultiCellWidget( duration, 2, 2, 0, 3 );
133 134
134 // time widgets are checked if they contain a valid time 135 // time widgets are checked if they contain a valid time
135 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)), 136 connect(mStartTimeEdit, SIGNAL(timeChanged(QTime)),
136 this, SLOT(startTimeChanged(QTime))); 137 this, SLOT(startTimeChanged(QTime)));
137 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)), 138 connect(mEndTimeEdit, SIGNAL(timeChanged(QTime)),
138 this, SLOT(endTimeChanged(QTime))); 139 this, SLOT(endTimeChanged(QTime)));
139 140
140 // date widgets are checked if they contain a valid date 141 // date widgets are checked if they contain a valid date
141 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), 142 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
142 this, SLOT(startDateChanged(QDate))); 143 this, SLOT(startDateChanged(QDate)));
143 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)), 144 connect(mEndDateEdit, SIGNAL(dateChanged(QDate)),
144 this, SLOT(endDateChanged(QDate))); 145 this, SLOT(endDateChanged(QDate)));
145 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime))); 146 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(sTimeChanged(QTime)));
146 connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime))); 147 connect(mEndDateEdit,SIGNAL(setTimeTo(QTime)),this,SLOT(eTimeChanged(QTime)));
147} 148}
148 149
149void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout) 150void KOEditorGeneralEvent::initClass(QWidget *parent,QBoxLayout *topLayout)
150{ 151{
151 QBoxLayout *classLayout = new QHBoxLayout(topLayout); 152 QBoxLayout *classLayout = new QHBoxLayout(topLayout);
152 153
153 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent); 154 QLabel *freeTimeLabel = new QLabel(i18n("Show time as:"),parent);
154 classLayout->addWidget(freeTimeLabel); 155 classLayout->addWidget(freeTimeLabel);
155 156
156 mFreeTimeCombo = new QComboBox(false, parent); 157 mFreeTimeCombo = new QComboBox(false, parent);
157 mFreeTimeCombo->insertItem(i18n("Busy")); 158 mFreeTimeCombo->insertItem(i18n("Busy"));
158 mFreeTimeCombo->insertItem(i18n("Free")); 159 mFreeTimeCombo->insertItem(i18n("Free"));
159 classLayout->addWidget(mFreeTimeCombo); 160 classLayout->addWidget(mFreeTimeCombo);
160} 161}
161 162
162void KOEditorGeneralEvent::timeStuffDisable(bool disable) 163void KOEditorGeneralEvent::timeStuffDisable(bool disable)
163{ 164{
164 mStartTimeEdit->setEnabled( !disable ); 165 mStartTimeEdit->setEnabled( !disable );
165 mEndTimeEdit->setEnabled( !disable ); 166 mEndTimeEdit->setEnabled( !disable );
166 167
167 setDuration(); 168 setDuration();
168 emitDateTimeStr(); 169 emitDateTimeStr();
169} 170}
170 171
171void KOEditorGeneralEvent::dontAssociateTime(bool noTime) 172void KOEditorGeneralEvent::dontAssociateTime(bool noTime)
172{ 173{
173 timeStuffDisable(noTime); 174 timeStuffDisable(noTime);
174 //if(alarmButton->isChecked()) alarmStuffDisable(noTime); 175 //if(alarmButton->isChecked()) alarmStuffDisable(noTime);
175 allDayChanged(noTime); 176 allDayChanged(noTime);
176} 177}
177 178
178void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end) 179void KOEditorGeneralEvent::setDateTimes(QDateTime start, QDateTime end)
179{ 180{
180// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl; 181// kdDebug() << "KOEditorGeneralEvent::setDateTimes(): Start DateTime: " << start.toString() << endl;
181 if ( !mTemplate ) 182 if ( !mTemplate )
182 mStartDateEdit->setDate(start.date()); 183 mStartDateEdit->setDate(start.date());
183 // KTimeEdit seems to emit some signals when setTime() is called. 184 // KTimeEdit seems to emit some signals when setTime() is called.
184 mStartTimeEdit->blockSignals( true ); 185 mStartTimeEdit->blockSignals( true );
185 mStartTimeEdit->setTime(start.time()); 186 mStartTimeEdit->setTime(start.time());
186 mStartTimeEdit->blockSignals( false ); 187 mStartTimeEdit->blockSignals( false );
187 if ( !mTemplate ) 188 if ( !mTemplate )
188 mEndDateEdit->setDate(end.date()); 189 mEndDateEdit->setDate(end.date());
189 mEndTimeEdit->setTime(end.time()); 190 mEndTimeEdit->setTime(end.time());
190 191
191 mCurrStartDateTime = start; 192 mCurrStartDateTime = start;
192 mCurrEndDateTime = end; 193 mCurrEndDateTime = end;
193 194
194 setDuration(); 195 setDuration();
195 emitDateTimeStr(); 196 emitDateTimeStr();
196} 197}
197 198
198void KOEditorGeneralEvent::sTimeChanged(QTime ti) 199void KOEditorGeneralEvent::sTimeChanged(QTime ti)
199{ 200{
200 mStartTimeEdit->setTime( ti ); 201 mStartTimeEdit->setTime( ti );
201 startTimeChanged ( ti); 202 startTimeChanged ( ti);
202} 203}
203void KOEditorGeneralEvent::eTimeChanged(QTime ti ) 204void KOEditorGeneralEvent::eTimeChanged(QTime ti )
204{ 205{
205 mEndTimeEdit->setTime( ti ); 206 mEndTimeEdit->setTime( ti );
206 endTimeChanged( ti ); 207 endTimeChanged( ti );
207} 208}
208void KOEditorGeneralEvent::startTimeChanged(QTime newtime) 209void KOEditorGeneralEvent::startTimeChanged(QTime newtime)
209{ 210{
210 211
211 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime); 212 int secsep = mCurrStartDateTime.secsTo(mCurrEndDateTime);
212 213
213 mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) ); 214 mCurrStartDateTime = QDateTime( mStartDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0) );
214 // adjust end time so that the event has the same duration as before. 215 // adjust end time so that the event has the same duration as before.
215 if( secsep > 0 ) 216 if( secsep > 0 )
216 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep); 217 mCurrEndDateTime = mCurrStartDateTime.addSecs(secsep);
217 mEndTimeEdit->setTime(mCurrEndDateTime.time()); 218 mEndTimeEdit->setTime(mCurrEndDateTime.time());
218 mEndDateEdit->setDate(mCurrEndDateTime.date()); 219 mEndDateEdit->setDate(mCurrEndDateTime.date());
219 220
220 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 221 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
221} 222}
222 223
223void KOEditorGeneralEvent::endTimeChanged(QTime newtime) 224void KOEditorGeneralEvent::endTimeChanged(QTime newtime)
224{ 225{
225 226
226 mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0)); 227 mCurrEndDateTime = QDateTime ( mEndDateEdit->date(), QTime(newtime.hour(),newtime.minute(),0));
227 228
228 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 229 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
229} 230}
230 231
231void KOEditorGeneralEvent::startDateChanged(QDate newdate) 232void KOEditorGeneralEvent::startDateChanged(QDate newdate)
232{ 233{
233 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime); 234 int daysep = mCurrStartDateTime.daysTo(mCurrEndDateTime);
234 235
235 mCurrStartDateTime.setDate(newdate); 236 mCurrStartDateTime.setDate(newdate);
236 237
237 // adjust end date so that the event has the same duration as before 238 // adjust end date so that the event has the same duration as before
238 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep)); 239 mCurrEndDateTime.setDate(mCurrStartDateTime.date().addDays(daysep));
239 mEndDateEdit->setDate(mCurrEndDateTime.date()); 240 mEndDateEdit->setDate(mCurrEndDateTime.date());
240 qDebug("KOEditorGeneralEvent::startDateChanged "); 241 qDebug("KOEditorGeneralEvent::startDateChanged ");
241 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 242 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
242} 243}
243 244
244void KOEditorGeneralEvent::endDateChanged(QDate newdate) 245void KOEditorGeneralEvent::endDateChanged(QDate newdate)
245{ 246{
246 QDateTime newdt(newdate, mCurrEndDateTime.time()); 247 QDateTime newdt(newdate, mCurrEndDateTime.time());
247 248
248 if(newdt < mCurrStartDateTime) { 249 if(newdt < mCurrStartDateTime) {
249 // oops, we can't let that happen. 250 // oops, we can't let that happen.
250 newdt = mCurrStartDateTime; 251 newdt = mCurrStartDateTime;
251 mEndDateEdit->setDate(newdt.date()); 252 mEndDateEdit->setDate(newdt.date());
252 mEndTimeEdit->setTime(newdt.time()); 253 mEndTimeEdit->setTime(newdt.time());
253 } 254 }
254 mCurrEndDateTime = newdt; 255 mCurrEndDateTime = newdt;
255 256
256 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime); 257 emit dateTimesChanged(mCurrStartDateTime,mCurrEndDateTime);
257} 258}
258 259
259void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay) 260void KOEditorGeneralEvent::setDefaults(QDateTime from,QDateTime to,bool allDay)
260{ 261{
261 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 262 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
262 mLocationEdit->load(KOLocationBox::LOCATION); 263 mLocationEdit->load(KOLocationBox::LOCATION);
263 KOEditorGeneral::setDefaults(allDay); 264 KOEditorGeneral::setDefaults(allDay);
264 265
265 mNoTimeButton->setChecked(allDay); 266 mNoTimeButton->setChecked(allDay);
266 timeStuffDisable(allDay); 267 timeStuffDisable(allDay);
267 mFreeTimeCombo->setCurrentItem( 0 ); 268 mFreeTimeCombo->setCurrentItem( 0 );
268 setDateTimes(from,to); 269 setDateTimes(from,to);
269} 270}
270 271
271void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl ) 272void KOEditorGeneralEvent::readEvent( Event *event, bool tmpl )
272{ 273{
273 QString tmpStr; 274 QString tmpStr;
274 275
275 mTemplate = tmpl; 276 mTemplate = tmpl;
276 // the rest is for the events only 277 // the rest is for the events only
277 mNoTimeButton->setChecked(event->doesFloat()); 278 mNoTimeButton->setChecked(event->doesFloat());
278 timeStuffDisable(event->doesFloat()); 279 timeStuffDisable(event->doesFloat());
279 280
280 setDateTimes(event->dtStart(),event->dtEnd()); 281 setDateTimes(event->dtStart(),event->dtEnd());
281 282
282 mTemplate = false; 283 mTemplate = false;
283 switch( event->transparency() ) { 284 switch( event->transparency() ) {
284 case Event::Transparent: 285 case Event::Transparent:
285 mFreeTimeCombo->setCurrentItem(1); 286 mFreeTimeCombo->setCurrentItem(1);
286 break; 287 break;
287 case Event::Opaque: 288 case Event::Opaque:
288 mFreeTimeCombo->setCurrentItem(0); 289 mFreeTimeCombo->setCurrentItem(0);
289 break; 290 break;
290 } 291 }
291 292
292 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT); 293 mSummaryEdit->load(KOLocationBox::SUMMARYEVENT);
293 mLocationEdit->load(KOLocationBox::LOCATION); 294 mLocationEdit->load(KOLocationBox::LOCATION);
294 readIncidence(event); 295 readIncidence(event);
295} 296}
296 297
297void KOEditorGeneralEvent::writeEvent(Event *event) 298void KOEditorGeneralEvent::writeEvent(Event *event)
298{ 299{
299// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl; 300// kdDebug() << "KOEditorGeneralEvent::writeEvent()" << endl;
300 301
301 writeIncidence(event); 302 writeIncidence(event);
302 303
303 QDate tmpDate; 304 QDate tmpDate;
304 QTime tmpTime; 305 QTime tmpTime;
305 QDateTime tmpDT; 306 QDateTime tmpDT;
306 307
307 // temp. until something better happens. 308 // temp. until something better happens.
308 QString tmpStr; 309 QString tmpStr;
309 310
310 if (mNoTimeButton->isChecked()) { 311 if (mNoTimeButton->isChecked()) {
311 event->setFloats(true); 312 event->setFloats(true);
312 // need to change this. 313 // need to change this.
313 tmpDate = mStartDateEdit->date(); 314 tmpDate = mStartDateEdit->date();
314 tmpTime.setHMS(0,0,0); 315 tmpTime.setHMS(0,0,0);
315 tmpDT.setDate(tmpDate); 316 tmpDT.setDate(tmpDate);
316 tmpDT.setTime(tmpTime); 317 tmpDT.setTime(tmpTime);
317 event->setDtStart(tmpDT); 318 event->setDtStart(tmpDT);
318 319
319 tmpDate = mEndDateEdit->date(); 320 tmpDate = mEndDateEdit->date();
320 tmpTime.setHMS(0,0,0); 321 tmpTime.setHMS(0,0,0);
321 tmpDT.setDate(tmpDate); 322 tmpDT.setDate(tmpDate);
322 tmpDT.setTime(tmpTime); 323 tmpDT.setTime(tmpTime);
323 event->setDtEnd(tmpDT); 324 event->setDtEnd(tmpDT);
324 } else { 325 } else {
325 event->setFloats(false); 326 event->setFloats(false);
326 327
327 // set date/time end 328 // set date/time end
328 tmpDate = mEndDateEdit->date(); 329 tmpDate = mEndDateEdit->date();
329 tmpTime = mEndTimeEdit->getTime(); 330 tmpTime = mEndTimeEdit->getTime();
330 tmpDT.setDate(tmpDate); 331 tmpDT.setDate(tmpDate);
331 tmpDT.setTime(tmpTime); 332 tmpDT.setTime(tmpTime);
332 event->setDtEnd(tmpDT); 333 event->setDtEnd(tmpDT);
333 334
334 // set date/time start 335 // set date/time start
335 tmpDate = mStartDateEdit->date(); 336 tmpDate = mStartDateEdit->date();
336 tmpTime = mStartTimeEdit->getTime(); 337 tmpTime = mStartTimeEdit->getTime();
337 tmpDT.setDate(tmpDate); 338 tmpDT.setDate(tmpDate);
338 tmpDT.setTime(tmpTime); 339 tmpDT.setTime(tmpTime);
339 event->setDtStart(tmpDT); 340 event->setDtStart(tmpDT);
340 } // check for float 341 } // check for float
341 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT); 342 mSummaryEdit->save(KOLocationBox::SUMMARYEVENT);
342 343
343 event->setTransparency(mFreeTimeCombo->currentItem() > 0 344 event->setTransparency(mFreeTimeCombo->currentItem() > 0
344 ? KCal::Event::Transparent 345 ? KCal::Event::Transparent
345 : KCal::Event::Opaque); 346 : KCal::Event::Opaque);
346 347
347// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl; 348// kdDebug() << "KOEditorGeneralEvent::writeEvent() done" << endl;
348} 349}
349 350
350void KOEditorGeneralEvent::setDuration() 351void KOEditorGeneralEvent::setDuration()
351{ 352{
352 QString tmpStr = "", catStr; 353 QString tmpStr = "", catStr;
353 int hourdiff, minutediff; 354 int hourdiff, minutediff;
354 // end<date is an accepted temporary state while typing, but don't show 355 // end<date is an accepted temporary state while typing, but don't show
355 // any duration if this happens 356 // any duration if this happens
356 if(mCurrEndDateTime >= mCurrStartDateTime) { 357 if(mCurrEndDateTime >= mCurrStartDateTime) {
357 358
358 if (mNoTimeButton->isChecked()) { 359 if (mNoTimeButton->isChecked()) {
359 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1; 360 int daydiff = mCurrStartDateTime.date().daysTo(mCurrEndDateTime.date()) + 1;
360 tmpStr = i18n("Duration: "); 361 tmpStr = i18n("Duration: ");
361 tmpStr.append(i18n("1 Day","%n Days",daydiff)); 362 tmpStr.append(i18n("1 Day","%n Days",daydiff));
362 } else { 363 } else {
363 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime ); 364 int secto = mCurrStartDateTime.secsTo( mCurrEndDateTime );
364 hourdiff = secto / 3600; 365 hourdiff = secto / 3600;
365 minutediff = (secto/60 ) % 60; 366 minutediff = (secto/60 ) % 60;
366 if (hourdiff || minutediff){ 367 if (hourdiff || minutediff){
367 tmpStr = i18n("Duration: "); 368 tmpStr = i18n("Duration: ");
368 if (hourdiff){ 369 if (hourdiff){
369 catStr = i18n("1 h","%n h",hourdiff); 370 catStr = i18n("1 h","%n h",hourdiff);
370 tmpStr.append(catStr); 371 tmpStr.append(catStr);
371 } 372 }
372 if (hourdiff && minutediff){ 373 if (hourdiff && minutediff){
373 tmpStr += i18n(", "); 374 tmpStr += i18n(", ");
374 } 375 }
375 if (minutediff){ 376 if (minutediff){
376 catStr = i18n("1 min","%n min",minutediff); 377 catStr = i18n("1 min","%n min",minutediff);
377 tmpStr += catStr; 378 tmpStr += catStr;
378 } 379 }
379 } else tmpStr = ""; 380 } else tmpStr = "";
380 } 381 }
381 } 382 }
382 mDurationLabel->setText(tmpStr); 383 mDurationLabel->setText(tmpStr);
383} 384}
384 385
385void KOEditorGeneralEvent::emitDateTimeStr() 386void KOEditorGeneralEvent::emitDateTimeStr()
386{ 387{
387 KLocale *l = KGlobal::locale(); 388 KLocale *l = KGlobal::locale();
388 QString startString = ""; 389 QString startString = "";
389 if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) { 390 if ( mCurrStartDateTime.date() < mCurrEndDateTime.date() ) {
390 if ( mNoTimeButton->isChecked() ) { 391 if ( mNoTimeButton->isChecked() ) {
391 startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() ); 392 startString = i18n("From: ") + l->formatDate(mCurrStartDateTime.date() );
392 startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date()); 393 startString += "\n"+i18n("To: ")+ l->formatDate(mCurrEndDateTime.date());
393 394
394 } else { 395 } else {
395 startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false); 396 startString = i18n("From: ") +l->formatDateTime(mCurrStartDateTime, false);
396 startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false); 397 startString += "\n"+i18n("To: ")+l->formatDateTime(mCurrEndDateTime, false);
397 } 398 }
398 } else { 399 } else {
399 if ( mNoTimeButton->isChecked() ) { 400 if ( mNoTimeButton->isChecked() ) {
400 startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() ); 401 startString = i18n("On: ") + l->formatDate(mCurrStartDateTime.date() );
401 } else { 402 } else {
402 startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+ 403 startString = i18n("From: ") + KGlobal::locale()->formatTime(mCurrStartDateTime.time())+
403 "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time()); 404 "-"+KGlobal::locale()->formatTime(mCurrEndDateTime.time());
404 startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true); 405 startString += i18n(" on ")+KGlobal::locale()->formatDate( mCurrStartDateTime.date(), true);
405 } 406 }
406 } 407 }
407 startString +="\n"+mDurationLabel->text(); 408 startString +="\n"+mDurationLabel->text();
408 emit dateTimeStrChanged(startString); 409 emit dateTimeStrChanged(startString);
409} 410}
410 411
411bool KOEditorGeneralEvent::validateInput() 412bool KOEditorGeneralEvent::validateInput()
412{ 413{
413 414
414 if (!mStartDateEdit->inputIsValid()) { 415 if (!mStartDateEdit->inputIsValid()) {
415 KMessageBox::sorry( 0, 416 KMessageBox::sorry( 0,
416 i18n("Please specify a valid start date,\nfor example '%1'.") 417 i18n("Please specify a valid start date,\nfor example '%1'.")
417 .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); 418 .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) );
418 return false; 419 return false;
419 } 420 }
420 421
421 if (!mEndDateEdit->inputIsValid()) { 422 if (!mEndDateEdit->inputIsValid()) {
422 KMessageBox::sorry( 0, 423 KMessageBox::sorry( 0,
423 i18n("Please specify a valid end date,\nfor example '%1'.") 424 i18n("Please specify a valid end date,\nfor example '%1'.")
424 .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) ); 425 .arg( KGlobal::locale()->formatDate( QDate::currentDate(), true ) ) );
425 return false; 426 return false;
426 } 427 }
427 428
428 QDateTime startDt,endDt; 429 QDateTime startDt,endDt;
429 startDt.setDate(mStartDateEdit->date()); 430 startDt.setDate(mStartDateEdit->date());
430 endDt.setDate(mEndDateEdit->date()); 431 endDt.setDate(mEndDateEdit->date());
431 if (!mNoTimeButton->isChecked()) { 432 if (!mNoTimeButton->isChecked()) {
432 startDt.setTime(mStartTimeEdit->getTime()); 433 startDt.setTime(mStartTimeEdit->getTime());
433 endDt.setTime(mEndTimeEdit->getTime()); 434 endDt.setTime(mEndTimeEdit->getTime());
434 } 435 }
435 436
436 if (startDt > endDt) { 437 if (startDt > endDt) {
437 KMessageBox::sorry(0,i18n("The event ends before it starts.\n" 438 KMessageBox::sorry(0,i18n("The event ends before it starts.\n"
438 "Please correct dates and times.")); 439 "Please correct dates and times."));
439 return false; 440 return false;
440 } 441 }
441 442
442 return KOEditorGeneral::validateInput(); 443 return KOEditorGeneral::validateInput();
443} 444}
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp
index 0a734ee..965cf47 100644
--- a/korganizer/koeditorgeneraltodo.cpp
+++ b/korganizer/koeditorgeneraltodo.cpp
@@ -1,508 +1,508 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kglobal.h> 34#include <kglobal.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kmessagebox.h> 37#include <kmessagebox.h>
38#include <kdebug.h> 38#include <kdebug.h>
39#include <krestrictedline.h> 39#include <krestrictedline.h>
40#include <kstandarddirs.h> 40#include <kstandarddirs.h>
41#include <kfiledialog.h> 41#include <kfiledialog.h>
42#include <kdialog.h> 42#include <kdialog.h>
43 43
44#include <libkcal/todo.h> 44#include <libkcal/todo.h>
45 45
46#include <libkdepim/kdateedit.h> 46#include <libkdepim/kdateedit.h>
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49#include "ktimeedit.h" 49#include "ktimeedit.h"
50 50
51#include "koeditorgeneraltodo.h" 51#include "koeditorgeneraltodo.h"
52#include "kolocationbox.h" 52#include "kolocationbox.h"
53 53
54KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, 54KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent,
55 const char* name) 55 const char* name)
56 : KOEditorGeneral( parent, name) 56 : KOEditorGeneral( parent, name)
57{ 57{
58} 58}
59 59
60KOEditorGeneralTodo::~KOEditorGeneralTodo() 60KOEditorGeneralTodo::~KOEditorGeneralTodo()
61{ 61{
62} 62}
63 63
64void KOEditorGeneralTodo::finishSetup() 64void KOEditorGeneralTodo::finishSetup()
65{ 65{
66 66
67// QWidget::setTabOrder(mSummaryEdit, mLocationEdit); 67// QWidget::setTabOrder(mSummaryEdit, mLocationEdit);
68// QWidget::setTabOrder(mLocationEdit, mDueCheck); 68// QWidget::setTabOrder(mLocationEdit, mDueCheck);
69// QWidget::setTabOrder(mDueCheck, mDueDateEdit); 69// QWidget::setTabOrder(mDueCheck, mDueDateEdit);
70// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); 70// QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit);
71// QWidget::setTabOrder(mDueTimeEdit, mStartCheck); 71// QWidget::setTabOrder(mDueTimeEdit, mStartCheck);
72// QWidget::setTabOrder(mStartCheck, mStartDateEdit); 72// QWidget::setTabOrder(mStartCheck, mStartDateEdit);
73// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); 73// QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit);
74// QWidget::setTabOrder(mStartTimeEdit, mTimeButton); 74// QWidget::setTabOrder(mStartTimeEdit, mTimeButton);
75// QWidget::setTabOrder(mTimeButton, mCompletedCombo); 75// QWidget::setTabOrder(mTimeButton, mCompletedCombo);
76// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); 76// QWidget::setTabOrder(mCompletedCombo, mPriorityCombo);
77// QWidget::setTabOrder(mPriorityCombo, mAlarmButton); 77// QWidget::setTabOrder(mPriorityCombo, mAlarmButton);
78// QWidget::setTabOrder(mAlarmButton, mCategoriesButton); 78// QWidget::setTabOrder(mAlarmButton, mCategoriesButton);
79// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); 79// QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo);
80// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); 80// QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit);
81 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 81 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
82 mSummaryEdit->setFocus(); 82 mSummaryEdit->setFocus();
83} 83}
84 84
85void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) 85void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout)
86{ 86{
87 QBoxLayout *timeLayout = new QVBoxLayout(topLayout); 87 QBoxLayout *timeLayout = new QVBoxLayout(topLayout);
88 88
89 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, 89 QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal,
90 i18n("Date && Time"),parent); 90 i18n("Date && Time"),parent);
91 timeLayout->addWidget(timeGroupBox); 91 timeLayout->addWidget(timeGroupBox);
92 timeGroupBox->layout()->setSpacing( KDialog::spacingHintSmall() ); 92 timeGroupBox->layout()->setSpacing( KDialog::spacingHint()-2 );
93 timeGroupBox->layout()->setMargin( KDialog::marginHint() ); 93 timeGroupBox->layout()->setMargin( KDialog::marginHint() );
94 QFrame *timeBoxFrame = new QFrame(timeGroupBox); 94 QFrame *timeBoxFrame = new QFrame(timeGroupBox);
95 95
96 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); 96 QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3);
97 layoutTimeBox->setSpacing(KDialog::spacingHintSmall()); 97 layoutTimeBox->setSpacing(KDialog::spacingHintSmall());
98 layoutTimeBox->setColStretch( 1, 1 ); 98 layoutTimeBox->setColStretch( 1, 1 );
99 99
100 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); 100 mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame);
101 layoutTimeBox->addWidget(mDueCheck,1,0); 101 layoutTimeBox->addWidget(mDueCheck,1,0);
102 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); 102 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool)));
103 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); 103 connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm()));
104 104
105 105
106 mDueDateEdit = new KDateEdit(timeBoxFrame); 106 mDueDateEdit = new KDateEdit(timeBoxFrame);
107 layoutTimeBox->addWidget(mDueDateEdit,1,1); 107 layoutTimeBox->addWidget(mDueDateEdit,1,1);
108 108
109 mDueTimeEdit = new KOTimeEdit(timeBoxFrame); 109 mDueTimeEdit = new KOTimeEdit(timeBoxFrame);
110 layoutTimeBox->addWidget(mDueTimeEdit,1,2); 110 layoutTimeBox->addWidget(mDueTimeEdit,1,2);
111 111
112 112
113 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); 113 mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame);
114 layoutTimeBox->addWidget(mStartCheck,0,0); 114 layoutTimeBox->addWidget(mStartCheck,0,0);
115 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); 115 connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool)));
116 116
117 mStartDateEdit = new KDateEdit(timeBoxFrame); 117 mStartDateEdit = new KDateEdit(timeBoxFrame);
118 layoutTimeBox->addWidget(mStartDateEdit,0,1); 118 layoutTimeBox->addWidget(mStartDateEdit,0,1);
119 119
120 mStartTimeEdit = new KOTimeEdit(timeBoxFrame); 120 mStartTimeEdit = new KOTimeEdit(timeBoxFrame);
121 layoutTimeBox->addWidget(mStartTimeEdit,0,2); 121 layoutTimeBox->addWidget(mStartTimeEdit,0,2);
122 122
123 123
124 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); 124 mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame);
125 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); 125 layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1);
126 126
127 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); 127 connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool)));
128 connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime))); 128 connect(mDueDateEdit,SIGNAL(setTimeTo(QTime)),mDueTimeEdit,SLOT(setTime(QTime)));
129 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime))); 129 connect(mStartDateEdit,SIGNAL(setTimeTo(QTime)),mStartTimeEdit,SLOT(setTime(QTime)));
130 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)), 130 connect(mStartDateEdit, SIGNAL(dateChanged(QDate)),
131 this, SLOT(startDateChanged(QDate))); 131 this, SLOT(startDateChanged(QDate)));
132 // some more layouting 132 // some more layouting
133 //layoutTimeBox->setColStretch(3,1); 133 //layoutTimeBox->setColStretch(3,1);
134} 134}
135 135
136 136
137void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) 137void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout)
138{ 138{
139 mCompletedCombo = new QComboBox(parent); 139 mCompletedCombo = new QComboBox(parent);
140 // xgettext:no-c-format 140 // xgettext:no-c-format
141 mCompletedCombo->insertItem(i18n(" 0 %")); 141 mCompletedCombo->insertItem(i18n(" 0 %"));
142 // xgettext:no-c-format 142 // xgettext:no-c-format
143 mCompletedCombo->insertItem(i18n(" 20 %")); 143 mCompletedCombo->insertItem(i18n(" 20 %"));
144 // xgettext:no-c-format 144 // xgettext:no-c-format
145 mCompletedCombo->insertItem(i18n(" 40 %")); 145 mCompletedCombo->insertItem(i18n(" 40 %"));
146 // xgettext:no-c-format 146 // xgettext:no-c-format
147 mCompletedCombo->insertItem(i18n(" 60 %")); 147 mCompletedCombo->insertItem(i18n(" 60 %"));
148 // xgettext:no-c-format 148 // xgettext:no-c-format
149 mCompletedCombo->insertItem(i18n(" 80 %")); 149 mCompletedCombo->insertItem(i18n(" 80 %"));
150 // xgettext:no-c-format 150 // xgettext:no-c-format
151 mCompletedCombo->insertItem(i18n("100 %")); 151 mCompletedCombo->insertItem(i18n("100 %"));
152 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); 152 connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int)));
153 topLayout->addWidget(mCompletedCombo); 153 topLayout->addWidget(mCompletedCombo);
154 154
155 mCompletedLabel = new QLabel(i18n("completed"),parent); 155 mCompletedLabel = new QLabel(i18n("completed"),parent);
156 topLayout->addWidget(mCompletedLabel); 156 topLayout->addWidget(mCompletedLabel);
157 157
158 mCompleteDateEdit = new KDateEdit(parent); 158 mCompleteDateEdit = new KDateEdit(parent);
159 topLayout->addWidget(mCompleteDateEdit ); 159 topLayout->addWidget(mCompleteDateEdit );
160 160
161 mCompleteTimeEdit = new KOTimeEdit(parent); 161 mCompleteTimeEdit = new KOTimeEdit(parent);
162 topLayout->addWidget( mCompleteTimeEdit); 162 topLayout->addWidget( mCompleteTimeEdit);
163 163
164 mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); 164 mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) );
165 mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); 165 mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) );
166 connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime))); 166 connect(mCompleteDateEdit,SIGNAL(setTimeTo(QTime)),mCompleteTimeEdit,SLOT(setTime(QTime)));
167 167
168 if ( QApplication::desktop()->width() <= 480 ) { 168 if ( QApplication::desktop()->width() <= 480 ) {
169 if ( QApplication::desktop()->width() < 320 ) 169 if ( QApplication::desktop()->width() < 320 )
170 mCompleteDateEdit->setMaximumWidth( 85 ); 170 mCompleteDateEdit->setMaximumWidth( 85 );
171 else 171 else
172 mCompleteDateEdit->setMaximumWidth( 140 ); 172 mCompleteDateEdit->setMaximumWidth( 140 );
173 topLayout->setSpacing( 0 ); 173 topLayout->setSpacing( 0 );
174 } 174 }
175} 175}
176 176
177void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) 177void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout)
178{ 178{
179 179
180 QHBox* h = new QHBox ( parent ); 180 QHBox* h = new QHBox ( parent );
181 topLayout->addWidget( h ); 181 topLayout->addWidget( h );
182 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); 182 QLabel *priorityLabel = new QLabel(i18n("Priority:"), h);
183 // topLayout->addWidget(priorityLabel); 183 // topLayout->addWidget(priorityLabel);
184 mPriorityCombo = new QComboBox( h ); 184 mPriorityCombo = new QComboBox( h );
185 mPriorityCombo->insertItem(i18n("1 (high)")); 185 mPriorityCombo->insertItem(i18n("1 (high)"));
186 mPriorityCombo->insertItem(i18n("2")); 186 mPriorityCombo->insertItem(i18n("2"));
187 mPriorityCombo->insertItem(i18n("3")); 187 mPriorityCombo->insertItem(i18n("3"));
188 mPriorityCombo->insertItem(i18n("4")); 188 mPriorityCombo->insertItem(i18n("4"));
189 mPriorityCombo->insertItem(i18n("5 (low)")); 189 mPriorityCombo->insertItem(i18n("5 (low)"));
190 //topLayout->addWidget(mPriorityCombo); 190 //topLayout->addWidget(mPriorityCombo);
191} 191}
192 192
193void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) 193void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout)
194{ 194{
195 QBoxLayout *statusLayout = new QHBoxLayout(topLayout); 195 QBoxLayout *statusLayout = new QHBoxLayout(topLayout);
196 196
197 initCompletion( parent, statusLayout ); 197 initCompletion( parent, statusLayout );
198 198
199 statusLayout->addStretch( 1 ); 199 statusLayout->addStretch( 1 );
200 200
201 initPriority( parent, statusLayout ); 201 initPriority( parent, statusLayout );
202} 202}
203 203
204void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) 204void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay)
205{ 205{
206 206
207 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 207 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
208 mLocationEdit->load(KOLocationBox::LOCATION); 208 mLocationEdit->load(KOLocationBox::LOCATION);
209 KOEditorGeneral::setDefaults(allDay); 209 KOEditorGeneral::setDefaults(allDay);
210 210
211 mTimeButton->setChecked( !allDay ); 211 mTimeButton->setChecked( !allDay );
212 if(mTimeButton->isChecked()) { 212 if(mTimeButton->isChecked()) {
213 mTimeButton->setEnabled(true); 213 mTimeButton->setEnabled(true);
214 } 214 }
215 else { 215 else {
216 mTimeButton->setEnabled(false); 216 mTimeButton->setEnabled(false);
217 } 217 }
218 218
219 enableTimeEdits( !allDay ); 219 enableTimeEdits( !allDay );
220 if ( due.isValid() ) { 220 if ( due.isValid() ) {
221 mDueCheck->setChecked(true); 221 mDueCheck->setChecked(true);
222 enableDueEdit(true); 222 enableDueEdit(true);
223 alarmDisable(false); 223 alarmDisable(false);
224 } else { 224 } else {
225 mDueCheck->setChecked(false); 225 mDueCheck->setChecked(false);
226 enableDueEdit(false); 226 enableDueEdit(false);
227 due = QDateTime::currentDateTime().addDays(7); 227 due = QDateTime::currentDateTime().addDays(7);
228 alarmDisable(true); 228 alarmDisable(true);
229 } 229 }
230 230
231 231
232 mStartCheck->setChecked(false); 232 mStartCheck->setChecked(false);
233 enableStartEdit(false); 233 enableStartEdit(false);
234 234
235 mDueDateEdit->setDate(due.date()); 235 mDueDateEdit->setDate(due.date());
236 mDueTimeEdit->setTime(due.time()); 236 mDueTimeEdit->setTime(due.time());
237 due = due.addDays(-7); 237 due = due.addDays(-7);
238 mStartDateEdit->setDate(due.date()); 238 mStartDateEdit->setDate(due.date());
239 mStartTimeEdit->setTime(due.time()); 239 mStartTimeEdit->setTime(due.time());
240 240
241 mPriorityCombo->setCurrentItem(2); 241 mPriorityCombo->setCurrentItem(2);
242 mCompletedLabel->setText(i18n(" completed"));; 242 mCompletedLabel->setText(i18n(" completed"));;
243 mCompletedCombo->setCurrentItem(0); 243 mCompletedCombo->setCurrentItem(0);
244 mCompleteDateEdit->hide(); 244 mCompleteDateEdit->hide();
245 mCompleteTimeEdit->hide(); 245 mCompleteTimeEdit->hide();
246} 246}
247 247
248void KOEditorGeneralTodo::readTodo(Todo *todo) 248void KOEditorGeneralTodo::readTodo(Todo *todo)
249{ 249{
250 250
251 mSummaryEdit->load(KOLocationBox::SUMMARYTODO); 251 mSummaryEdit->load(KOLocationBox::SUMMARYTODO);
252 mLocationEdit->load(KOLocationBox::LOCATION); 252 mLocationEdit->load(KOLocationBox::LOCATION);
253 KOEditorGeneral::readIncidence(todo); 253 KOEditorGeneral::readIncidence(todo);
254 254
255 QDateTime dueDT; 255 QDateTime dueDT;
256 256
257 if (todo->hasDueDate()) { 257 if (todo->hasDueDate()) {
258 enableAlarmEdit(true); 258 enableAlarmEdit(true);
259 dueDT = todo->dtDue(); 259 dueDT = todo->dtDue();
260 mDueDateEdit->setDate(todo->dtDue().date()); 260 mDueDateEdit->setDate(todo->dtDue().date());
261 mDueTimeEdit->setTime(todo->dtDue().time()); 261 mDueTimeEdit->setTime(todo->dtDue().time());
262 mDueCheck->setChecked(true); 262 mDueCheck->setChecked(true);
263 } else { 263 } else {
264 alarmDisable(true); 264 alarmDisable(true);
265 mDueDateEdit->setEnabled(false); 265 mDueDateEdit->setEnabled(false);
266 mDueTimeEdit->setEnabled(false); 266 mDueTimeEdit->setEnabled(false);
267 mDueDateEdit->setDate(QDate::currentDate()); 267 mDueDateEdit->setDate(QDate::currentDate());
268 mDueTimeEdit->setTime(QTime::currentTime()); 268 mDueTimeEdit->setTime(QTime::currentTime());
269 mDueCheck->setChecked(false); 269 mDueCheck->setChecked(false);
270 } 270 }
271 271
272 if (todo->hasStartDate()) { 272 if (todo->hasStartDate()) {
273 mStartDateEdit->setDate(todo->dtStart().date()); 273 mStartDateEdit->setDate(todo->dtStart().date());
274 mStartTimeEdit->setTime(todo->dtStart().time()); 274 mStartTimeEdit->setTime(todo->dtStart().time());
275 mStartCheck->setChecked(true); 275 mStartCheck->setChecked(true);
276 } else { 276 } else {
277 mStartDateEdit->setEnabled(false); 277 mStartDateEdit->setEnabled(false);
278 mStartTimeEdit->setEnabled(false); 278 mStartTimeEdit->setEnabled(false);
279 mStartDateEdit->setDate(QDate::currentDate()); 279 mStartDateEdit->setDate(QDate::currentDate());
280 mStartTimeEdit->setTime(QTime::currentTime()); 280 mStartTimeEdit->setTime(QTime::currentTime());
281 mStartCheck->setChecked(false); 281 mStartCheck->setChecked(false);
282 } 282 }
283 283
284 mTimeButton->setChecked( !todo->doesFloat() ); 284 mTimeButton->setChecked( !todo->doesFloat() );
285 285
286 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 286 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
287 if (todo->isCompleted() && todo->hasCompletedDate()) { 287 if (todo->isCompleted() && todo->hasCompletedDate()) {
288 mCompleted = todo->completed(); 288 mCompleted = todo->completed();
289 } 289 }
290 setCompletedDate(); 290 setCompletedDate();
291 291
292 mPriorityCombo->setCurrentItem(todo->priority()-1); 292 mPriorityCombo->setCurrentItem(todo->priority()-1);
293} 293}
294 294
295void KOEditorGeneralTodo::writeTodo(Todo *todo) 295void KOEditorGeneralTodo::writeTodo(Todo *todo)
296{ 296{
297 KOEditorGeneral::writeIncidence(todo); 297 KOEditorGeneral::writeIncidence(todo);
298 298
299 // temp. until something better happens. 299 // temp. until something better happens.
300 QString tmpStr; 300 QString tmpStr;
301 301
302 todo->setHasDueDate(mDueCheck->isChecked()); 302 todo->setHasDueDate(mDueCheck->isChecked());
303 todo->setHasStartDate(mStartCheck->isChecked()); 303 todo->setHasStartDate(mStartCheck->isChecked());
304 304
305 QDate tmpDate; 305 QDate tmpDate;
306 QTime tmpTime; 306 QTime tmpTime;
307 QDateTime tmpDT; 307 QDateTime tmpDT;
308 if ( mTimeButton->isChecked() ) { 308 if ( mTimeButton->isChecked() ) {
309 todo->setFloats(false); 309 todo->setFloats(false);
310 310
311 // set due date/time 311 // set due date/time
312 tmpDate = mDueDateEdit->date(); 312 tmpDate = mDueDateEdit->date();
313 tmpTime = mDueTimeEdit->getTime(); 313 tmpTime = mDueTimeEdit->getTime();
314 tmpDT.setDate(tmpDate); 314 tmpDT.setDate(tmpDate);
315 tmpDT.setTime(tmpTime); 315 tmpDT.setTime(tmpTime);
316 todo->setDtDue(tmpDT); 316 todo->setDtDue(tmpDT);
317 317
318 // set start date/time 318 // set start date/time
319 tmpDate = mStartDateEdit->date(); 319 tmpDate = mStartDateEdit->date();
320 tmpTime = mStartTimeEdit->getTime(); 320 tmpTime = mStartTimeEdit->getTime();
321 tmpDT.setDate(tmpDate); 321 tmpDT.setDate(tmpDate);
322 tmpDT.setTime(tmpTime); 322 tmpDT.setTime(tmpTime);
323 todo->setDtStart(tmpDT); 323 todo->setDtStart(tmpDT);
324 } else { 324 } else {
325 todo->setFloats(true); 325 todo->setFloats(true);
326 326
327 // need to change this. 327 // need to change this.
328 tmpDate = mDueDateEdit->date(); 328 tmpDate = mDueDateEdit->date();
329 tmpTime.setHMS(0,0,0); 329 tmpTime.setHMS(0,0,0);
330 tmpDT.setDate(tmpDate); 330 tmpDT.setDate(tmpDate);
331 tmpDT.setTime(tmpTime); 331 tmpDT.setTime(tmpTime);
332 todo->setDtDue(tmpDT); 332 todo->setDtDue(tmpDT);
333 333
334 tmpDate = mStartDateEdit->date(); 334 tmpDate = mStartDateEdit->date();
335 tmpTime.setHMS(0,0,0); 335 tmpTime.setHMS(0,0,0);
336 tmpDT.setDate(tmpDate); 336 tmpDT.setDate(tmpDate);
337 tmpDT.setTime(tmpTime); 337 tmpDT.setTime(tmpTime);
338 todo->setDtStart(tmpDT); 338 todo->setDtStart(tmpDT);
339 } 339 }
340 todo->setPriority(mPriorityCombo->currentItem()+1); 340 todo->setPriority(mPriorityCombo->currentItem()+1);
341 341
342 // set completion state 342 // set completion state
343 if ( mCompletedCombo->currentItem() == 5 ) { 343 if ( mCompletedCombo->currentItem() == 5 ) {
344 QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); 344 QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() );
345 if ( comp.isValid () ) { 345 if ( comp.isValid () ) {
346 todo->setPercentComplete(100); 346 todo->setPercentComplete(100);
347 todo->setCompleted(comp); 347 todo->setCompleted(comp);
348 } else { 348 } else {
349 todo->setPercentComplete( 100 ); 349 todo->setPercentComplete( 100 );
350 if ( mCompleted.isValid() ) 350 if ( mCompleted.isValid() )
351 todo->setCompleted(mCompleted); 351 todo->setCompleted(mCompleted);
352 } 352 }
353 } else { 353 } else {
354 todo->setPercentComplete(mCompletedCombo->currentItem() * 20); 354 todo->setPercentComplete(mCompletedCombo->currentItem() * 20);
355 } 355 }
356 356
357 mSummaryEdit->save(KOLocationBox::SUMMARYTODO); 357 mSummaryEdit->save(KOLocationBox::SUMMARYTODO);
358} 358}
359 359
360void KOEditorGeneralTodo::enableDueEdit(bool enable) 360void KOEditorGeneralTodo::enableDueEdit(bool enable)
361{ 361{
362 mDueDateEdit->setEnabled( enable ); 362 mDueDateEdit->setEnabled( enable );
363 363
364 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 364 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
365 mTimeButton->setEnabled(true); 365 mTimeButton->setEnabled(true);
366 } 366 }
367 else { 367 else {
368 mTimeButton->setEnabled(false); 368 mTimeButton->setEnabled(false);
369 mTimeButton->setChecked(false); 369 mTimeButton->setChecked(false);
370 } 370 }
371 371
372 if (enable) { 372 if (enable) {
373 mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); 373 mDueTimeEdit->setEnabled( mTimeButton->isChecked() );
374 } else { 374 } else {
375 mDueTimeEdit->setEnabled( false ); 375 mDueTimeEdit->setEnabled( false );
376 } 376 }
377 emit datesChecked(); 377 emit datesChecked();
378} 378}
379 379
380void KOEditorGeneralTodo::enableStartEdit( bool enable ) 380void KOEditorGeneralTodo::enableStartEdit( bool enable )
381{ 381{
382 mStartDateEdit->setEnabled( enable ); 382 mStartDateEdit->setEnabled( enable );
383 383
384 if(mDueCheck->isChecked() || mStartCheck->isChecked()) { 384 if(mDueCheck->isChecked() || mStartCheck->isChecked()) {
385 mTimeButton->setEnabled(true); 385 mTimeButton->setEnabled(true);
386 } 386 }
387 else { 387 else {
388 mTimeButton->setEnabled(false); 388 mTimeButton->setEnabled(false);
389 mTimeButton->setChecked(false); 389 mTimeButton->setChecked(false);
390 } 390 }
391 391
392 if (enable) { 392 if (enable) {
393 mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); 393 mStartTimeEdit->setEnabled( mTimeButton->isChecked() );
394 } else { 394 } else {
395 mStartTimeEdit->setEnabled( false ); 395 mStartTimeEdit->setEnabled( false );
396 } 396 }
397 emit datesChecked(); 397 emit datesChecked();
398} 398}
399void KOEditorGeneralTodo::startDateChanged(QDate newdate) 399void KOEditorGeneralTodo::startDateChanged(QDate newdate)
400{ 400{
401 if ( mDueCheck->isChecked() ) 401 if ( mDueCheck->isChecked() )
402 emit dateTimesChanged(newdate,mDueDateEdit->date()); 402 emit dateTimesChanged(newdate,mDueDateEdit->date());
403} 403}
404void KOEditorGeneralTodo::enableTimeEdits(bool enable) 404void KOEditorGeneralTodo::enableTimeEdits(bool enable)
405{ 405{
406 if(mStartCheck->isChecked()) { 406 if(mStartCheck->isChecked()) {
407 mStartTimeEdit->setEnabled( enable ); 407 mStartTimeEdit->setEnabled( enable );
408 } 408 }
409 if(mDueCheck->isChecked()) { 409 if(mDueCheck->isChecked()) {
410 mDueTimeEdit->setEnabled( enable ); 410 mDueTimeEdit->setEnabled( enable );
411 } 411 }
412} 412}
413 413
414void KOEditorGeneralTodo::showAlarm() 414void KOEditorGeneralTodo::showAlarm()
415{ 415{
416 if ( mDueCheck->isChecked() ) { 416 if ( mDueCheck->isChecked() ) {
417 alarmDisable(false); 417 alarmDisable(false);
418 } 418 }
419 else { 419 else {
420 alarmDisable(true); 420 alarmDisable(true);
421 } 421 }
422} 422}
423 423
424bool KOEditorGeneralTodo::validateInput() 424bool KOEditorGeneralTodo::validateInput()
425{ 425{
426 if (mDueCheck->isChecked()) { 426 if (mDueCheck->isChecked()) {
427 if (!mDueDateEdit->inputIsValid()) { 427 if (!mDueDateEdit->inputIsValid()) {
428 KMessageBox::sorry(0,i18n("Please specify a valid due date.")); 428 KMessageBox::sorry(0,i18n("Please specify a valid due date."));
429 return false; 429 return false;
430 } 430 }
431 } 431 }
432 432
433 if (mStartCheck->isChecked()) { 433 if (mStartCheck->isChecked()) {
434 if (!mStartDateEdit->inputIsValid()) { 434 if (!mStartDateEdit->inputIsValid()) {
435 KMessageBox::sorry(0,i18n("Please specify a valid start date.")); 435 KMessageBox::sorry(0,i18n("Please specify a valid start date."));
436 return false; 436 return false;
437 } 437 }
438 } 438 }
439 439
440 if (mStartCheck->isChecked() && mDueCheck->isChecked()) { 440 if (mStartCheck->isChecked() && mDueCheck->isChecked()) {
441 QDateTime startDate; 441 QDateTime startDate;
442 QDateTime dueDate; 442 QDateTime dueDate;
443 startDate.setDate(mStartDateEdit->date()); 443 startDate.setDate(mStartDateEdit->date());
444 dueDate.setDate(mDueDateEdit->date()); 444 dueDate.setDate(mDueDateEdit->date());
445 if (mTimeButton->isChecked()) { 445 if (mTimeButton->isChecked()) {
446 startDate.setTime(mStartTimeEdit->getTime()); 446 startDate.setTime(mStartTimeEdit->getTime());
447 dueDate.setTime(mDueTimeEdit->getTime()); 447 dueDate.setTime(mDueTimeEdit->getTime());
448 } 448 }
449 if (startDate > dueDate) { 449 if (startDate > dueDate) {
450 KMessageBox::sorry(0, 450 KMessageBox::sorry(0,
451 i18n("The start date cannot be after the due date.")); 451 i18n("The start date cannot be after the due date."));
452 return false; 452 return false;
453 } 453 }
454 } 454 }
455 455
456 return KOEditorGeneral::validateInput(); 456 return KOEditorGeneral::validateInput();
457} 457}
458 458
459void KOEditorGeneralTodo::completedChanged(int index) 459void KOEditorGeneralTodo::completedChanged(int index)
460{ 460{
461 if (index == 5) { 461 if (index == 5) {
462 //get rid of milli sec 462 //get rid of milli sec
463 mCompleted = QDateTime::currentDateTime(); 463 mCompleted = QDateTime::currentDateTime();
464 } 464 }
465 setCompletedDate(); 465 setCompletedDate();
466} 466}
467 467
468void KOEditorGeneralTodo::setCompletedDate() 468void KOEditorGeneralTodo::setCompletedDate()
469{ 469{
470 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { 470 if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) {
471 if ( QApplication::desktop()->width() < 480 ) { 471 if ( QApplication::desktop()->width() < 480 ) {
472 mCompletedLabel->setText(i18n(" on")); 472 mCompletedLabel->setText(i18n(" on"));
473 } 473 }
474 else 474 else
475 mCompletedLabel->setText(i18n(" completed on ")); 475 mCompletedLabel->setText(i18n(" completed on "));
476 mCompleteDateEdit->show(); 476 mCompleteDateEdit->show();
477 mCompleteTimeEdit->show(); 477 mCompleteTimeEdit->show();
478 mCompleteTimeEdit->setTime( mCompleted.time() ); 478 mCompleteTimeEdit->setTime( mCompleted.time() );
479 mCompleteDateEdit->setDate( mCompleted.date() ); 479 mCompleteDateEdit->setDate( mCompleted.date() );
480 } else { 480 } else {
481 mCompletedLabel->setText(i18n(" completed")); 481 mCompletedLabel->setText(i18n(" completed"));
482 mCompleteDateEdit->hide(); 482 mCompleteDateEdit->hide();
483 mCompleteTimeEdit->hide(); 483 mCompleteTimeEdit->hide();
484 } 484 }
485} 485}
486 486
487void KOEditorGeneralTodo::modified (Todo* todo, int modification) 487void KOEditorGeneralTodo::modified (Todo* todo, int modification)
488{ 488{
489 switch (modification) { 489 switch (modification) {
490 case KOGlobals::PRIORITY_MODIFIED: 490 case KOGlobals::PRIORITY_MODIFIED:
491 mPriorityCombo->setCurrentItem(todo->priority()-1); 491 mPriorityCombo->setCurrentItem(todo->priority()-1);
492 break; 492 break;
493 case KOGlobals::COMPLETION_MODIFIED: 493 case KOGlobals::COMPLETION_MODIFIED:
494 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); 494 mCompletedCombo->setCurrentItem(todo->percentComplete() / 20);
495 if (todo->isCompleted() && todo->hasCompletedDate()) { 495 if (todo->isCompleted() && todo->hasCompletedDate()) {
496 mCompleted = todo->completed(); 496 mCompleted = todo->completed();
497 } 497 }
498 setCompletedDate(); 498 setCompletedDate();
499 break; 499 break;
500 case KOGlobals::CATEGORY_MODIFIED: 500 case KOGlobals::CATEGORY_MODIFIED:
501 setCategories (todo->categoriesStr ()); 501 setCategories (todo->categoriesStr ());
502 break; 502 break;
503 case KOGlobals::UNKNOWN_MODIFIED: // fall through 503 case KOGlobals::UNKNOWN_MODIFIED: // fall through
504 default: 504 default:
505 readTodo( todo ); 505 readTodo( todo );
506 break; 506 break;
507 } 507 }
508} 508}
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp
index 75dae34..9ede543 100644
--- a/korganizer/koeventeditor.cpp
+++ b/korganizer/koeventeditor.cpp
@@ -1,378 +1,384 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qhbox.h> 27#include <qhbox.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <libkcal/calendarresources.h> 39#include <libkcal/calendarresources.h>
40#include <libkcal/resourcecalendar.h> 40#include <libkcal/resourcecalendar.h>
41#include <kresources/resourceselectdialog.h> 41#include <kresources/resourceselectdialog.h>
42 42
43#include <libkdepim/categoryselectdialog.h> 43#include <libkdepim/categoryselectdialog.h>
44#include <libkcal/calendarlocal.h> 44#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koeventeditor.h" 49#include "koeventeditor.h"
50extern int globalFlagBlockAgenda; 50extern int globalFlagBlockAgenda;
51 51
52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : 52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) :
53 KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) 53 KOIncidenceEditor( i18n("Edit Event"), calendar, parent )
54{ 54{
55 mEvent = 0; 55 mEvent = 0;
56 init(); 56 init();
57 if ( QApplication::desktop()->height() <= 240 ) 57 if ( QApplication::desktop()->height() <= 240 )
58 hideButtons(); 58 hideButtons();
59} 59}
60 60
61KOEventEditor::~KOEventEditor() 61KOEventEditor::~KOEventEditor()
62{ 62{
63 //emit dialogClose( mEvent ); 63 //emit dialogClose( mEvent );
64} 64}
65 65
66void KOEventEditor::init() 66void KOEventEditor::init()
67{ 67{
68 68
69 setupGeneral(); 69 setupGeneral();
70 setupAttendeesTab(); 70 setupAttendeesTab();
71 setupRecurrence(); 71 setupRecurrence();
72 72
73 // Propagate date time settings to recurrence tab 73 // Propagate date time settings to recurrence tab
74 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 74 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
75 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); 75 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
76 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), 76 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)),
77 mRecurrence,SLOT(setDateTimeStr(const QString &))); 77 mRecurrence,SLOT(setDateTimeStr(const QString &)));
78 78
79 // Category dialog 79 // Category dialog
80 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 80 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
81 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), 81 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)),
82 // mGeneral,SLOT(setCategories(const QString &))); 82 // mGeneral,SLOT(setCategories(const QString &)));
83 83
84 84
85} 85}
86 86
87void KOEventEditor::reload() 87void KOEventEditor::reload()
88{ 88{
89 if ( mEvent ) readEvent( mEvent ); 89 if ( mEvent ) readEvent( mEvent );
90} 90}
91 91
92void KOEventEditor::setSecrecy( int sec ) 92void KOEventEditor::setSecrecy( int sec )
93{ 93{
94 mGeneral->setSecrecy( sec ); 94 mGeneral->setSecrecy( sec );
95} 95}
96void KOEventEditor::setCategories( QString s ) 96void KOEventEditor::setCategories( QString s )
97{ 97{
98 mGeneral->setCategories(s); 98 mGeneral->setCategories(s);
99 99
100} 100}
101void KOEventEditor::setupGeneral() 101void KOEventEditor::setupGeneral()
102{ 102{
103 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); 103 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" );
104 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 104 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
105 105
106 if( KOPrefs::instance()->mCompactDialogs ) { 106 if( KOPrefs::instance()->mCompactDialogs ) {
107 QFrame *topFrame = addPage(i18n("General")); 107 QFrame *topFrame = addPage(i18n("General"));
108 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 108 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
109 topLayout->setSpacing(spacingHint()-1); 109 topLayout->setSpacing(spacingHint()-1);
110 topLayout->setMargin(marginHint()-1); 110 topLayout->setMargin(marginHint()-1);
111 topLayout->addStretch ( 1 );
111 mGeneral->initHeader(topFrame,topLayout); 112 mGeneral->initHeader(topFrame,topLayout);
113 topLayout->addStretch ( 1 );
112 mGeneral->initTime(topFrame,topLayout); 114 mGeneral->initTime(topFrame,topLayout);
115 topLayout->addStretch ( 1 );
113// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 116// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
114 mGeneral->initAlarm(topFrame,topLayout); 117 mGeneral->initAlarm(topFrame,topLayout);
118 topLayout->addStretch ( 1 );
115 mGeneral->enableAlarm( false ); 119 mGeneral->enableAlarm( false );
116 120
117 QBoxLayout *buttonLayout; 121 QBoxLayout *buttonLayout;
118 if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 ) 122 if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 )
119 buttonLayout = new QVBoxLayout( topLayout ); 123 buttonLayout = new QVBoxLayout( topLayout );
120 else 124 else
121 buttonLayout = new QHBoxLayout( topLayout ); 125 buttonLayout = new QHBoxLayout( topLayout );
122 QHBox* buttonWidget = new QHBox (topFrame); 126 QHBox* buttonWidget = new QHBox (topFrame);
123 QIconSet icon; 127 QIconSet icon;
124 if ( QApplication::desktop()->width() < 321 ) 128 if ( QApplication::desktop()->width() < 321 )
125 icon = SmallIcon("fileexport16"); 129 icon = SmallIcon("fileexport16");
126 else 130 else
127 icon = SmallIcon("fileexport"); 131 icon = SmallIcon("fileexport");
128 QPushButton * loadTemplate = new QPushButton( buttonWidget); 132 QPushButton * loadTemplate = new QPushButton( buttonWidget);
129 QPushButton * saveTemplate = new QPushButton( buttonWidget); 133 QPushButton * saveTemplate = new QPushButton( buttonWidget);
130 saveTemplate->setIconSet (icon ) ; 134 saveTemplate->setIconSet (icon ) ;
131 int size = saveTemplate->sizeHint().height(); 135 int size = saveTemplate->sizeHint().height();
132 saveTemplate->setFixedSize( size, size ); 136 saveTemplate->setFixedSize( size, size );
133 if ( QApplication::desktop()->width() < 321 ) 137 if ( QApplication::desktop()->width() < 321 )
134 icon = SmallIcon("fileimport16"); 138 icon = SmallIcon("fileimport16");
135 else 139 else
136 icon = SmallIcon("fileimport"); 140 icon = SmallIcon("fileimport");
137 loadTemplate->setIconSet (icon ) ; 141 loadTemplate->setIconSet (icon ) ;
138 loadTemplate->setFixedSize( size, size ); 142 loadTemplate->setFixedSize( size, size );
139 buttonLayout->addWidget( buttonWidget ); 143 buttonLayout->addWidget( buttonWidget );
140 mGeneral->initCategories( topFrame, buttonLayout ); 144 mGeneral->initCategories( topFrame, buttonLayout );
141 145
142 topLayout->addStretch( 1 ); 146 topLayout->addStretch( 1 );
143 147
144 QFrame *topFrame2 = addPage(i18n("Details")); 148 QFrame *topFrame2 = addPage(i18n("Details"));
145 149
146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 150 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
151 topLayout2->setSpacing(spacingHint()-1);
152 topLayout2->setMargin(marginHint()-1);
147 topLayout2->setSpacing(spacingHint()); 153 topLayout2->setSpacing(spacingHint());
148 154
149 mGeneral->initClass(topFrame2,topLayout2); 155 mGeneral->initClass(topFrame2,topLayout2);
150 mGeneral->initSecrecy( topFrame2, topLayout2 ); 156 mGeneral->initSecrecy( topFrame2, topLayout2 );
151 mGeneral->initDescription(topFrame2,topLayout2); 157 mGeneral->initDescription(topFrame2,topLayout2);
152 158
153 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 159 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
154 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 160 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
155 } else { 161 } else {
156 QFrame *topFrame = addPage(i18n("General")); 162 QFrame *topFrame = addPage(i18n("General"));
157 163
158 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 164 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
159 topLayout->setSpacing(spacingHint()); 165 topLayout->setSpacing(spacingHint());
160 166
161 mGeneral->initHeader(topFrame,topLayout); 167 mGeneral->initHeader(topFrame,topLayout);
162 mGeneral->initTime(topFrame,topLayout); 168 mGeneral->initTime(topFrame,topLayout);
163 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 169 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
164 mGeneral->initAlarm(topFrame,alarmLineLayout); 170 mGeneral->initAlarm(topFrame,alarmLineLayout);
165 mGeneral->initClass(topFrame,alarmLineLayout); 171 mGeneral->initClass(topFrame,alarmLineLayout);
166 mGeneral->initDescription(topFrame,topLayout); 172 mGeneral->initDescription(topFrame,topLayout);
167 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
168 mGeneral->initCategories( topFrame, detailsLayout ); 174 mGeneral->initCategories( topFrame, detailsLayout );
169 mGeneral->initSecrecy( topFrame, detailsLayout ); 175 mGeneral->initSecrecy( topFrame, detailsLayout );
170 } 176 }
171 177
172 mGeneral->finishSetup(); 178 mGeneral->finishSetup();
173 179
174} 180}
175 181
176void KOEventEditor::setupRecurrence() 182void KOEventEditor::setupRecurrence()
177{ 183{
178 QFrame *topFrame = addPage( i18n("Recurrence") ); 184 QFrame *topFrame = addPage( i18n("Recurrence") );
179 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 185 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
180 186
181 mRecurrence = new KOEditorRecurrence( topFrame ); 187 mRecurrence = new KOEditorRecurrence( topFrame );
182 topLayout->addWidget( mRecurrence ); 188 topLayout->addWidget( mRecurrence );
183} 189}
184 190
185void KOEventEditor::editEvent(Event *event, bool showDescription) 191void KOEventEditor::editEvent(Event *event, bool showDescription)
186{ 192{
187 // init(); 193 // init();
188 194
189 mEvent = event; 195 mEvent = event;
190 readEvent(mEvent); 196 readEvent(mEvent);
191 if ( showDescription ) { 197 if ( showDescription ) {
192 showPage( 1 ); 198 showPage( 1 );
193 mGeneral->setFocusOn( 1 ); 199 mGeneral->setFocusOn( 1 );
194 } else { 200 } else {
195 showPage( 0 ); 201 showPage( 0 );
196 mGeneral->setFocusOn( 2 ); 202 mGeneral->setFocusOn( 2 );
197 } 203 }
198} 204}
199 205
200void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) 206void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay )
201{ 207{
202 // init(); 208 // init();
203 209
204 mEvent = 0; 210 mEvent = 0;
205 setDefaults(from,to,allDay); 211 setDefaults(from,to,allDay);
206} 212}
207 213
208void KOEventEditor::loadDefaults() 214void KOEventEditor::loadDefaults()
209{ 215{
210 int fmt = KOPrefs::instance()->mStartTime; 216 int fmt = KOPrefs::instance()->mStartTime;
211 217
212 QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); 218 QDateTime from(QDate::currentDate(), QTime(fmt,0,0));
213 QDateTime to(QDate::currentDate(), 219 QDateTime to(QDate::currentDate(),
214 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); 220 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0));
215 221
216 setDefaults(from,to,false); 222 setDefaults(from,to,false);
217} 223}
218 224
219bool KOEventEditor::processInput( bool emitTime ) 225bool KOEventEditor::processInput( bool emitTime )
220{ 226{
221 if (!validateInput()) return false; 227 if (!validateInput()) return false;
222 228
223 Event *event = 0; 229 Event *event = 0;
224 230
225 if (mEvent) event = mEvent; 231 if (mEvent) event = mEvent;
226 else { 232 else {
227 event = new Event; 233 event = new Event;
228 event->setOrganizer(KOPrefs::instance()->email()); 234 event->setOrganizer(KOPrefs::instance()->email());
229 } 235 }
230 236
231 writeEvent(event); 237 writeEvent(event);
232 if ( emitTime ) { 238 if ( emitTime ) {
233 globalFlagBlockAgenda = 1; 239 globalFlagBlockAgenda = 1;
234 emit showAgendaView( false ); 240 emit showAgendaView( false );
235 emit jumpToTime( event->dtStart().date() ); 241 emit jumpToTime( event->dtStart().date() );
236 globalFlagBlockAgenda = 2; 242 globalFlagBlockAgenda = 2;
237 243
238 } 244 }
239 if (mEvent) { 245 if (mEvent) {
240 event->setRevision(event->revision()+1); 246 event->setRevision(event->revision()+1);
241 emit eventChanged(event); 247 emit eventChanged(event);
242 } else { 248 } else {
243 mCalendar->addEvent(event); 249 mCalendar->addEvent(event);
244 mEvent = event; 250 mEvent = event;
245 emit eventAdded(event); 251 emit eventAdded(event);
246 } 252 }
247 253
248 return true; 254 return true;
249} 255}
250 256
251void KOEventEditor::deleteEvent() 257void KOEventEditor::deleteEvent()
252{ 258{
253 kdDebug() << "Delete event" << endl; 259 kdDebug() << "Delete event" << endl;
254 260
255 if (mEvent) { 261 if (mEvent) {
256 if (KOPrefs::instance()->mConfirm) { 262 if (KOPrefs::instance()->mConfirm) {
257 switch (msgItemDelete()) { 263 switch (msgItemDelete()) {
258 case KMessageBox::Continue: // OK 264 case KMessageBox::Continue: // OK
259 emit eventToBeDeleted(mEvent); 265 emit eventToBeDeleted(mEvent);
260 emit dialogClose(mEvent); 266 emit dialogClose(mEvent);
261 mCalendar->deleteEvent(mEvent); 267 mCalendar->deleteEvent(mEvent);
262 emit eventDeleted(); 268 emit eventDeleted();
263 reject(); 269 reject();
264 break; 270 break;
265 } 271 }
266 } 272 }
267 else { 273 else {
268 emit eventToBeDeleted(mEvent); 274 emit eventToBeDeleted(mEvent);
269 emit dialogClose(mEvent); 275 emit dialogClose(mEvent);
270 mCalendar->deleteEvent(mEvent); 276 mCalendar->deleteEvent(mEvent);
271 emit eventDeleted(); 277 emit eventDeleted();
272 reject(); 278 reject();
273 } 279 }
274 } else { 280 } else {
275 reject(); 281 reject();
276 } 282 }
277} 283}
278 284
279void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) 285void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay)
280{ 286{
281 mGeneral->setDefaults(from,to,allDay); 287 mGeneral->setDefaults(from,to,allDay);
282 mDetails->setDefaults(); 288 mDetails->setDefaults();
283 mRecurrence->setDefaults(from,to); 289 mRecurrence->setDefaults(from,to);
284 showPage( 0 ); 290 showPage( 0 );
285 mGeneral->setFocusOn( 2 ); 291 mGeneral->setFocusOn( 2 );
286} 292}
287 293
288void KOEventEditor::readEvent( Event *event, bool tmpl ) 294void KOEventEditor::readEvent( Event *event, bool tmpl )
289{ 295{
290 mGeneral->readEvent( event, tmpl ); 296 mGeneral->readEvent( event, tmpl );
291 mDetails->readEvent( event ); 297 mDetails->readEvent( event );
292 mRecurrence->readEvent( event ); 298 mRecurrence->readEvent( event );
293 299
294 // categories 300 // categories
295 //mCategoryDialog->setSelected( event->categories() ); 301 //mCategoryDialog->setSelected( event->categories() );
296} 302}
297 303
298void KOEventEditor::writeEvent(Event *event) 304void KOEventEditor::writeEvent(Event *event)
299{ 305{
300 mGeneral->writeEvent( event ); 306 mGeneral->writeEvent( event );
301 mDetails->writeEvent( event ); 307 mDetails->writeEvent( event );
302 308
303 if ( event->organizer() == KOPrefs::instance()->email() ) { 309 if ( event->organizer() == KOPrefs::instance()->email() ) {
304 Event *ev = new Event( *event ); 310 Event *ev = new Event( *event );
305 ev->registerObserver(0); 311 ev->registerObserver(0);
306 mDetails->cancelAttendeeEvent( ev ); 312 mDetails->cancelAttendeeEvent( ev );
307 if ( ev->attendeeCount() > 0 ) { 313 if ( ev->attendeeCount() > 0 ) {
308 emit deleteAttendee( ev ); 314 emit deleteAttendee( ev );
309 } 315 }
310 delete(ev); 316 delete(ev);
311 } 317 }
312 318
313 mRecurrence->writeEvent(event); 319 mRecurrence->writeEvent(event);
314} 320}
315 321
316bool KOEventEditor::validateInput() 322bool KOEventEditor::validateInput()
317{ 323{
318 if (!mGeneral->validateInput()) return false; 324 if (!mGeneral->validateInput()) return false;
319 if (!mDetails->validateInput()) return false; 325 if (!mDetails->validateInput()) return false;
320 if (!mRecurrence->validateInput()) return false; 326 if (!mRecurrence->validateInput()) return false;
321 return true; 327 return true;
322} 328}
323 329
324int KOEventEditor::msgItemDelete() 330int KOEventEditor::msgItemDelete()
325{ 331{
326 return KMessageBox::warningContinueCancel(this, 332 return KMessageBox::warningContinueCancel(this,
327 i18n("This item will be permanently deleted."), 333 i18n("This item will be permanently deleted."),
328 i18n("KOrganizer Confirmation"),i18n("Delete")); 334 i18n("KOrganizer Confirmation"),i18n("Delete"));
329} 335}
330 336
331void KOEventEditor::slotLoadTemplate() 337void KOEventEditor::slotLoadTemplate()
332{ 338{
333 339
334 QString fileName =locateLocal( "templates", "events" ); 340 QString fileName =locateLocal( "templates", "events" );
335 QDir t_dir; 341 QDir t_dir;
336 if ( !t_dir.exists(fileName) ) 342 if ( !t_dir.exists(fileName) )
337 t_dir.mkdir ( fileName ); 343 t_dir.mkdir ( fileName );
338 fileName += "/event"; 344 fileName += "/event";
339 fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); 345 fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this );
340 if ( fileName.length() == 0 ) 346 if ( fileName.length() == 0 )
341 return; 347 return;
342 CalendarLocal cal; 348 CalendarLocal cal;
343 ICalFormat format; 349 ICalFormat format;
344 if ( !format.load( &cal, fileName ) ) { 350 if ( !format.load( &cal, fileName ) ) {
345 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 351 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
346 .arg( fileName ) ); 352 .arg( fileName ) );
347 return ; 353 return ;
348 } 354 }
349 QPtrList<Event> events = cal.events(); 355 QPtrList<Event> events = cal.events();
350 Event* event = events.first(); 356 Event* event = events.first();
351 if ( !event ) { 357 if ( !event ) {
352 KMessageBox::error( this, 358 KMessageBox::error( this,
353 i18n("Template does not contain\na valid Event.")); 359 i18n("Template does not contain\na valid Event."));
354 } else { 360 } else {
355 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; 361 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
356 readEvent( event, true ); 362 readEvent( event, true );
357 } 363 }
358} 364}
359 365
360 366
361void KOEventEditor::slotSaveTemplate() 367void KOEventEditor::slotSaveTemplate()
362{ 368{
363 QString fileName =locateLocal( "templates", "events" ); 369 QString fileName =locateLocal( "templates", "events" );
364 QDir t_dir; 370 QDir t_dir;
365 if ( !t_dir.exists(fileName) ) 371 if ( !t_dir.exists(fileName) )
366 t_dir.mkdir ( fileName ); 372 t_dir.mkdir ( fileName );
367 fileName += "/event"; 373 fileName += "/event";
368 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); 374 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this );
369 if ( fileName.length() > 0 ) 375 if ( fileName.length() > 0 )
370 saveTemplate( fileName ); 376 saveTemplate( fileName );
371} 377}
372 378
373void KOEventEditor::saveTemplate( const QString &templateName ) 379void KOEventEditor::saveTemplate( const QString &templateName )
374{ 380{
375 Event *event = new Event; 381 Event *event = new Event;
376 writeEvent( event ); 382 writeEvent( event );
377 saveAsTemplate( event, templateName ); 383 saveAsTemplate( event, templateName );
378} 384}
diff --git a/korganizer/koincidenceeditor.cpp b/korganizer/koincidenceeditor.cpp
index 9813a80..9bc0302 100644
--- a/korganizer/koincidenceeditor.cpp
+++ b/korganizer/koincidenceeditor.cpp
@@ -1,185 +1,185 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qdatetime.h> 29#include <qdatetime.h>
30#include <qdir.h> 30#include <qdir.h>
31 31
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36#include <kfiledialog.h> 36#include <kfiledialog.h>
37 37
38#include <libkdepim/categoryselectdialog.h> 38#include <libkdepim/categoryselectdialog.h>
39#include <libkdepim/kinputdialog.h> 39#include <libkdepim/kinputdialog.h>
40 40
41#include <libkcal/calendarlocal.h> 41#include <libkcal/calendarlocal.h>
42#include <libkcal/icalformat.h> 42#include <libkcal/icalformat.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45 45
46#include "koincidenceeditor.h" 46#include "koincidenceeditor.h"
47 47
48KOIncidenceEditor::KOIncidenceEditor( const QString &caption, 48KOIncidenceEditor::KOIncidenceEditor( const QString &caption,
49 Calendar *calendar, QWidget *parent ) : 49 Calendar *calendar, QWidget *parent ) :
50 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok, 50 KDialogBase( Tabbed, caption, Ok | Apply | Cancel |/* Default | */User1, Ok,
51 parent, caption, true, false ), 51 parent, caption, true, false ),
52 mSaveTemplateDialog( 0 ) 52 mSaveTemplateDialog( 0 )
53{ 53{
54 mCalendar = calendar; 54 mCalendar = calendar;
55 55
56 setButtonText( Default, i18n("Template...") ); 56 setButtonText( Default, i18n("Template...") );
57 57
58 QString saveTemplateText; 58 QString saveTemplateText;
59 // if ( KOPrefs::instance()->mCompactDialogs ) { 59 // if ( KOPrefs::instance()->mCompactDialogs ) {
60// showButton( User1, false ); 60// showButton( User1, false );
61// showButton( Apply, false ); 61// showButton( Apply, false );
62// } else { 62// } else {
63 showButton( Apply, false ); 63 showButton( Apply, false );
64 saveTemplateText = i18n("Ok+Agenda"); 64 saveTemplateText = i18n("Ok+Agenda");
65 // } 65 // }
66 setButtonText( User1, saveTemplateText ); 66 setButtonText( User1, saveTemplateText );
67 67
68 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this ); 68 //mCategoryDialog = new KPIM::CategorySelectDialog( KOPrefs::instance(), this );
69 // KOGlobals::fitDialogToScreen( mCategoryDialog ); 69 // KOGlobals::fitDialogToScreen( mCategoryDialog );
70 70
71 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories())); 71 //connect(mCategoryDialog,SIGNAL(editCategories()),SIGNAL(editCategories()));
72 72
73 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) ); 73 //connect( this, SIGNAL( defaultClicked() ), SLOT( slotLoadTemplate() ) );
74 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) ); 74 // connect( this, SIGNAL( user1Clicked() ), SLOT( slotSaveTemplate() ) );
75 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) ); 75 connect( this, SIGNAL( user1Clicked() ), SLOT( slotShowIncidence() ) );
76} 76}
77 77
78KOIncidenceEditor::~KOIncidenceEditor() 78KOIncidenceEditor::~KOIncidenceEditor()
79{ 79{
80 //delete mCategoryDialog; 80 //delete mCategoryDialog;
81} 81}
82 82
83void KOIncidenceEditor::setupAttendeesTab() 83void KOIncidenceEditor::setupAttendeesTab()
84{ 84{
85 QFrame *topFrame = addPage(i18n("Attendees")); 85 QFrame *topFrame = addPage(i18n("Attendees"));
86 86
87 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 87 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
88 88
89 mDetails = new KOEditorDetails(spacingHint(),topFrame); 89 mDetails = new KOEditorDetails(spacingHint()-2,topFrame);
90 topLayout->addWidget(mDetails); 90 topLayout->addWidget(mDetails);
91} 91}
92 92
93 93
94void KOIncidenceEditor::slotApply() 94void KOIncidenceEditor::slotApply()
95{ 95{
96 processInput( false ); 96 processInput( false );
97} 97}
98void KOIncidenceEditor::accept() 98void KOIncidenceEditor::accept()
99{ 99{
100 slotOk(); 100 slotOk();
101} 101}
102void KOIncidenceEditor::slotOk() 102void KOIncidenceEditor::slotOk()
103{ 103{
104 if ( processInput( false ) ) QDialog::accept(); 104 if ( processInput( false ) ) QDialog::accept();
105} 105}
106 106
107void KOIncidenceEditor::updateCategoryConfig() 107void KOIncidenceEditor::updateCategoryConfig()
108{ 108{
109 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! "); 109 qDebug("KOIncidenceEditor::updateCategoryConfig() is dead! ");
110 //mCategoryDialog->updateCategoryConfig(); 110 //mCategoryDialog->updateCategoryConfig();
111} 111}
112 112
113void KOIncidenceEditor::slotCancel() 113void KOIncidenceEditor::slotCancel()
114{ 114{
115 reject(); 115 reject();
116} 116}
117 117
118void KOIncidenceEditor::slotLoadTemplate() 118void KOIncidenceEditor::slotLoadTemplate()
119{ 119{
120 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl; 120 kdDebug() << "KOIncidenceEditor::loadTemplate()" << endl;
121} 121}
122void KOIncidenceEditor::slotShowIncidence() 122void KOIncidenceEditor::slotShowIncidence()
123{ 123{
124 124
125 if ( processInput(true ) ) { 125 if ( processInput(true ) ) {
126 accept(); 126 accept();
127 } 127 }
128} 128}
129 129
130void KOIncidenceEditor::slotSaveTemplate() 130void KOIncidenceEditor::slotSaveTemplate()
131{ 131{
132 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl; 132 kdDebug() << "KOIncidenceEditor::saveTemplate()" << endl;
133} 133}
134 134
135void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type ) 135void KOIncidenceEditor::createSaveTemplateDialog( SaveTemplateDialog::IncidenceType type )
136{ 136{
137 if ( !mSaveTemplateDialog ) { 137 if ( !mSaveTemplateDialog ) {
138 mSaveTemplateDialog = new SaveTemplateDialog( type, this ); 138 mSaveTemplateDialog = new SaveTemplateDialog( type, this );
139 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ), 139 connect( mSaveTemplateDialog, SIGNAL( templateSelected( const QString & ) ),
140 SLOT( saveTemplate( const QString & ) ) ); 140 SLOT( saveTemplate( const QString & ) ) );
141 } 141 }
142 mSaveTemplateDialog->show(); 142 mSaveTemplateDialog->show();
143 mSaveTemplateDialog->raise(); 143 mSaveTemplateDialog->raise();
144} 144}
145 145
146void KOIncidenceEditor::saveAsTemplate( Incidence *incidence, 146void KOIncidenceEditor::saveAsTemplate( Incidence *incidence,
147 const QString &templateName ) 147 const QString &templateName )
148{ 148{
149 CalendarLocal cal; 149 CalendarLocal cal;
150 cal.addIncidence( incidence ); 150 cal.addIncidence( incidence );
151 ICalFormat format; 151 ICalFormat format;
152 format.save( &cal, templateName ); 152 format.save( &cal, templateName );
153} 153}
154 154
155QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type, 155QString KOIncidenceEditor::loadTemplate( Calendar *cal, const QString &type,
156 const QStringList &templates ) 156 const QStringList &templates )
157{ 157{
158 // bool ok = false; 158 // bool ok = false;
159// QString templateName = KInputDialog::getItem( i18n("Load Template"), 159// QString templateName = KInputDialog::getItem( i18n("Load Template"),
160// i18n("Select a template to load:"), templates, 0, &ok ); 160// i18n("Select a template to load:"), templates, 0, &ok );
161// if ( !ok || templateName.isEmpty() ) return QString::null; 161// if ( !ok || templateName.isEmpty() ) return QString::null;
162 162
163// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" + 163// QString fileName = locateLocal( "data", "korganizer/templates/" + type + "/" +
164// templateName ); 164// templateName );
165// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this ); 165// fn =KFileDialog:: getOpenFileName( fn, "Import filename(*.ics/*.vcs)", this );
166 166
167 // QString fileName;// =locateLocal( "templates", incidence->type() ); 167 // QString fileName;// =locateLocal( "templates", incidence->type() );
168// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this ); 168// fileName=KFileDialog:: getOpenFileName( fileName, "Load "+incidence()->type(), this );
169// if ( fileNamelength() == 0) 169// if ( fileNamelength() == 0)
170// return QString::null; 170// return QString::null;
171// if ( fileName.isEmpty() ) { 171// if ( fileName.isEmpty() ) {
172// KMessageBox::error( this, i18n("Unable to find template '%1'.") 172// KMessageBox::error( this, i18n("Unable to find template '%1'.")
173// .arg( fileName ) ); 173// .arg( fileName ) );
174// return QString::null; 174// return QString::null;
175// } else { 175// } else {
176// ICalFormat format; 176// ICalFormat format;
177// if ( !format.load( cal, fileName ) ) { 177// if ( !format.load( cal, fileName ) ) {
178// KMessageBox::error( this, i18n("Error loading template file '%1'.") 178// KMessageBox::error( this, i18n("Error loading template file '%1'.")
179// .arg( fileName ) ); 179// .arg( fileName ) );
180// return QString::null; 180// return QString::null;
181// } 181// }
182// } 182// }
183 183
184 return ""; 184 return "";
185} 185}
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 8b90ae5..555c1b1 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,448 +1,452 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1997, 1998 Preston Brown 3 Copyright (c) 1997, 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qframe.h> 26#include <qframe.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qhbox.h> 29#include <qhbox.h>
30#include <qdir.h> 30#include <qdir.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapplication.h> 32#include <qapplication.h>
33#include <qtabwidget.h> 33#include <qtabwidget.h>
34 34
35#include <kiconloader.h> 35#include <kiconloader.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kstandarddirs.h> 38#include <kstandarddirs.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41#include <libkdepim/categoryselectdialog.h> 41#include <libkdepim/categoryselectdialog.h>
42#include <libkcal/calendarlocal.h> 42#include <libkcal/calendarlocal.h>
43#include <libkcal/calendarresources.h> 43#include <libkcal/calendarresources.h>
44#include <libkcal/resourcecalendar.h> 44#include <libkcal/resourcecalendar.h>
45#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
46#include <kresources/resourceselectdialog.h> 46#include <kresources/resourceselectdialog.h>
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
49#include "koprefs.h" 49#include "koprefs.h"
50#include "kolocationbox.h" 50#include "kolocationbox.h"
51 51
52#include "kotodoeditor.h" 52#include "kotodoeditor.h"
53extern int globalFlagBlockAgenda; 53extern int globalFlagBlockAgenda;
54 54
55KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 55KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) :
56 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) 56 KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent )
57{ 57{
58 mTodo = 0; 58 mTodo = 0;
59 mRelatedTodo = 0; 59 mRelatedTodo = 0;
60 findButton(User1)->hide(); 60 findButton(User1)->hide();
61 init(); 61 init();
62 if ( QApplication::desktop()->height() <= 240 ) 62 if ( QApplication::desktop()->height() <= 240 )
63 hideButtons(); 63 hideButtons();
64} 64}
65 65
66KOTodoEditor::~KOTodoEditor() 66KOTodoEditor::~KOTodoEditor()
67{ 67{
68 emit dialogClose( mTodo ); 68 emit dialogClose( mTodo );
69} 69}
70 70
71void KOTodoEditor::init() 71void KOTodoEditor::init()
72{ 72{
73 setupGeneral(); 73 setupGeneral();
74 setupAttendeesTab(); 74 setupAttendeesTab();
75 setupRecurrence(); 75 setupRecurrence();
76 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); 76 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
77 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); 77 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") );
78 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 78 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
79 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime))); 79 mRecurrence,SLOT(setDefaultsDates(QDateTime,QDateTime)));
80} 80}
81void KOTodoEditor::setupRecurrence() 81void KOTodoEditor::setupRecurrence()
82{ 82{
83 QFrame *topFrame = addPage( i18n("Recurrence") ); 83 QFrame *topFrame = addPage( i18n("Recurrence") );
84 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 84 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
85 85
86 mRecurrence = new KOEditorRecurrence( topFrame ); 86 mRecurrence = new KOEditorRecurrence( topFrame );
87 topLayout->addWidget( mRecurrence ); 87 topLayout->addWidget( mRecurrence );
88} 88}
89 89
90void KOTodoEditor::setCategories( QString s ) 90void KOTodoEditor::setCategories( QString s )
91{ 91{
92 mGeneral->setCategories(s); 92 mGeneral->setCategories(s);
93} 93}
94void KOTodoEditor::setSecrecy( int sec ) 94void KOTodoEditor::setSecrecy( int sec )
95{ 95{
96 mGeneral->setSecrecy( sec ); 96 mGeneral->setSecrecy( sec );
97} 97}
98void KOTodoEditor::reload() 98void KOTodoEditor::reload()
99{ 99{
100 if ( mTodo ) readTodo( mTodo ); 100 if ( mTodo ) readTodo( mTodo );
101} 101}
102 102
103void KOTodoEditor::setupGeneral() 103void KOTodoEditor::setupGeneral()
104{ 104{
105 mGeneral = new KOEditorGeneralTodo(this); 105 mGeneral = new KOEditorGeneralTodo(this);
106 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 106 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
107 107
108 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 108 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
109 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 109 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
110 // mGeneral,SLOT(setCategories(const QString &))); 110 // mGeneral,SLOT(setCategories(const QString &)));
111 111
112 if (KOPrefs::instance()->mCompactDialogs) { 112 if (KOPrefs::instance()->mCompactDialogs) {
113 QFrame *topFrame = addPage(i18n("General")); 113 QFrame *topFrame = addPage(i18n("General"));
114 114
115 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 115 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
116 if ( QApplication::desktop()->width() < 480 ) { 116 if ( QApplication::desktop()->width() < 480 ) {
117 topLayout->setMargin(marginHintSmall()); 117 topLayout->setMargin(marginHintSmall());
118 topLayout->setSpacing(spacingHintSmall()); 118 topLayout->setSpacing(spacingHintSmall());
119 } else { 119 } else {
120 topLayout->setMargin(marginHint()); 120 topLayout->setMargin(marginHint());
121 topLayout->setSpacing(spacingHint()); 121 topLayout->setSpacing(spacingHint());
122 } 122 }
123 topLayout->addStretch( 1 );
123 mGeneral->initHeader(topFrame,topLayout); 124 mGeneral->initHeader(topFrame,topLayout);
125 topLayout->addStretch( 1 );
124 mGeneral->initTime(topFrame,topLayout); 126 mGeneral->initTime(topFrame,topLayout);
127 topLayout->addStretch( 1 );
125 mGeneral->initAlarm(topFrame,topLayout); 128 mGeneral->initAlarm(topFrame,topLayout);
129 topLayout->addStretch( 1 );
126 mGeneral->enableAlarm( false ); 130 mGeneral->enableAlarm( false );
127 131
128 132
129 QBoxLayout *priorityLayout; 133 QBoxLayout *priorityLayout;
130 if ( QApplication::desktop()->width() < 500 ) 134 if ( QApplication::desktop()->width() < 500 )
131 priorityLayout = new QVBoxLayout( topLayout ); 135 priorityLayout = new QVBoxLayout( topLayout );
132 else 136 else
133 priorityLayout = new QHBoxLayout( topLayout ); 137 priorityLayout = new QHBoxLayout( topLayout );
134 QWidget* prioWidget = new QWidget (topFrame); 138 QWidget* prioWidget = new QWidget (topFrame);
135 priorityLayout->addWidget( prioWidget ); 139 priorityLayout->addWidget( prioWidget );
136 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 140 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
137 141
138 142
139 QIconSet icon; 143 QIconSet icon;
140 if ( QApplication::desktop()->width() < 321 ) 144 if ( QApplication::desktop()->width() < 321 )
141 icon = SmallIcon("fileimport16"); 145 icon = SmallIcon("fileimport16");
142 else 146 else
143 icon = SmallIcon("fileimport"); 147 icon = SmallIcon("fileimport");
144 QPushButton * loadTemplate = new QPushButton( prioWidget); 148 QPushButton * loadTemplate = new QPushButton( prioWidget);
145 loadTemplate->setIconSet (icon ) ; 149 loadTemplate->setIconSet (icon ) ;
146 int size = loadTemplate->sizeHint().height(); 150 int size = loadTemplate->sizeHint().height();
147 loadTemplate->setFixedSize( size, size ); 151 loadTemplate->setFixedSize( size, size );
148 if ( QApplication::desktop()->width() < 321 ) 152 if ( QApplication::desktop()->width() < 321 )
149 icon = SmallIcon("fileexport16"); 153 icon = SmallIcon("fileexport16");
150 else 154 else
151 icon = SmallIcon("fileexport"); 155 icon = SmallIcon("fileexport");
152 QPushButton * saveTemplate = new QPushButton( prioWidget); 156 QPushButton * saveTemplate = new QPushButton( prioWidget);
153 saveTemplate->setIconSet (icon ) ; 157 saveTemplate->setIconSet (icon ) ;
154 saveTemplate->setFixedSize( size, size ); 158 saveTemplate->setFixedSize( size, size );
155 159
156 priorityLayout2->addWidget(loadTemplate); 160 priorityLayout2->addWidget(loadTemplate);
157 priorityLayout2->addWidget(saveTemplate); 161 priorityLayout2->addWidget(saveTemplate);
158 mGeneral->initPriority(prioWidget,priorityLayout2); 162 mGeneral->initPriority(prioWidget,priorityLayout2);
159 mGeneral->initCategories( topFrame, priorityLayout ); 163 mGeneral->initCategories( topFrame, priorityLayout );
160 topLayout->addStretch(1); 164 topLayout->addStretch(1);
161 165
162 QFrame *topFrame2 = addPage(i18n("Details")); 166 QFrame *topFrame2 = addPage(i18n("Details"));
163 167
164 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 168 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
165 topLayout2->setMargin(marginHint()); 169 topLayout2->setMargin(marginHint());
166 topLayout2->setSpacing(spacingHint()); 170 topLayout2->setSpacing(spacingHint());
167 171
168 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 172 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
169 mGeneral->initCompletion(topFrame2,completionLayout); 173 mGeneral->initCompletion(topFrame2,completionLayout);
170 174
171 175
172 mGeneral->initSecrecy( topFrame2, topLayout2 ); 176 mGeneral->initSecrecy( topFrame2, topLayout2 );
173 mGeneral->initDescription(topFrame2,topLayout2); 177 mGeneral->initDescription(topFrame2,topLayout2);
174 178
175 // QHBox * hb = new QHBox ( topFrame2 ); 179 // QHBox * hb = new QHBox ( topFrame2 );
176 // topLayout2->addWidget(hb); 180 // topLayout2->addWidget(hb);
177 // hb->setSpacing( 3 ); 181 // hb->setSpacing( 3 );
178 182
179 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 183 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
180 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 184 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
181 185
182 } else { 186 } else {
183 QFrame *topFrame = addPage(i18n("General")); 187 QFrame *topFrame = addPage(i18n("General"));
184 188
185 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 189 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
186 topLayout->setSpacing(spacingHint()); 190 topLayout->setSpacing(spacingHint());
187 191
188 mGeneral->initHeader(topFrame,topLayout); 192 mGeneral->initHeader(topFrame,topLayout);
189 mGeneral->initTime(topFrame,topLayout); 193 mGeneral->initTime(topFrame,topLayout);
190 mGeneral->initStatus(topFrame,topLayout); 194 mGeneral->initStatus(topFrame,topLayout);
191 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 195 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
192 mGeneral->initAlarm(topFrame,alarmLineLayout); 196 mGeneral->initAlarm(topFrame,alarmLineLayout);
193 mGeneral->initDescription(topFrame,topLayout); 197 mGeneral->initDescription(topFrame,topLayout);
194 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 198 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
195 mGeneral->initCategories( topFrame, detailsLayout ); 199 mGeneral->initCategories( topFrame, detailsLayout );
196 mGeneral->initSecrecy( topFrame, detailsLayout ); 200 mGeneral->initSecrecy( topFrame, detailsLayout );
197 } 201 }
198 mGeneral->finishSetup(); 202 mGeneral->finishSetup();
199 203
200} 204}
201 205
202void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 206void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
203{ 207{
204 //init(); 208 //init();
205 209
206 mTodo = todo; 210 mTodo = todo;
207 readTodo(mTodo); 211 readTodo(mTodo);
208 if ( editDescription ) { 212 if ( editDescription ) {
209 showPage( 1 ); 213 showPage( 1 );
210 mGeneral->setFocusOn( 1 ); 214 mGeneral->setFocusOn( 1 );
211 } else { 215 } else {
212 showPage( 0 ); 216 showPage( 0 );
213 mGeneral->setFocusOn( 2 ); 217 mGeneral->setFocusOn( 2 );
214 } 218 }
215 checkRecurrence(); 219 checkRecurrence();
216} 220}
217 221
218void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 222void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
219{ 223{
220 //init(); 224 //init();
221 225
222 mTodo = 0; 226 mTodo = 0;
223 setDefaults(due,relatedTodo,allDay); 227 setDefaults(due,relatedTodo,allDay);
224} 228}
225 229
226void KOTodoEditor::loadDefaults() 230void KOTodoEditor::loadDefaults()
227{ 231{
228 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 232 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
229} 233}
230 234
231bool KOTodoEditor::processInput( bool emitTime ) 235bool KOTodoEditor::processInput( bool emitTime )
232{ 236{
233 if (!validateInput()) return false; 237 if (!validateInput()) return false;
234 238
235 Todo *todo = 0; 239 Todo *todo = 0;
236 240
237 if (mTodo) todo = mTodo; 241 if (mTodo) todo = mTodo;
238 else { 242 else {
239 todo = new Todo; 243 todo = new Todo;
240 todo->setOrganizer(KOPrefs::instance()->email()); 244 todo->setOrganizer(KOPrefs::instance()->email());
241 } 245 }
242 246
243 writeTodo(todo); 247 writeTodo(todo);
244 if ( emitTime ) { 248 if ( emitTime ) {
245 globalFlagBlockAgenda = 1; 249 globalFlagBlockAgenda = 1;
246 emit showAgendaView( false ); 250 emit showAgendaView( false );
247 if ( todo->hasDueDate() ) 251 if ( todo->hasDueDate() )
248 emit jumpToTime( todo->dtDue().date() ); 252 emit jumpToTime( todo->dtDue().date() );
249 globalFlagBlockAgenda = 2; 253 globalFlagBlockAgenda = 2;
250 } 254 }
251 if (mTodo) { 255 if (mTodo) {
252 todo->setRevision(todo->revision()+1); 256 todo->setRevision(todo->revision()+1);
253 emit todoChanged(todo); 257 emit todoChanged(todo);
254 } else { 258 } else {
255 mCalendar->addTodo(todo); 259 mCalendar->addTodo(todo);
256 mTodo = todo; 260 mTodo = todo;
257 emit todoAdded(todo); 261 emit todoAdded(todo);
258 } 262 }
259 263
260 return true; 264 return true;
261} 265}
262 266
263void KOTodoEditor::deleteTodo() 267void KOTodoEditor::deleteTodo()
264{ 268{
265 if (mTodo) { 269 if (mTodo) {
266 if (KOPrefs::instance()->mConfirm) { 270 if (KOPrefs::instance()->mConfirm) {
267 switch (msgItemDelete()) { 271 switch (msgItemDelete()) {
268 case KMessageBox::Continue: // OK 272 case KMessageBox::Continue: // OK
269 emit todoToBeDeleted(mTodo); 273 emit todoToBeDeleted(mTodo);
270 emit dialogClose(mTodo); 274 emit dialogClose(mTodo);
271 mCalendar->deleteTodo(mTodo); 275 mCalendar->deleteTodo(mTodo);
272 emit todoDeleted(); 276 emit todoDeleted();
273 reject(); 277 reject();
274 break; 278 break;
275 } 279 }
276 } 280 }
277 else { 281 else {
278 emit todoToBeDeleted(mTodo); 282 emit todoToBeDeleted(mTodo);
279 emit dialogClose(mTodo); 283 emit dialogClose(mTodo);
280 mCalendar->deleteTodo(mTodo); 284 mCalendar->deleteTodo(mTodo);
281 emit todoDeleted(); 285 emit todoDeleted();
282 reject(); 286 reject();
283 } 287 }
284 } else { 288 } else {
285 reject(); 289 reject();
286 } 290 }
287} 291}
288 292
289void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 293void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
290{ 294{
291 mRelatedTodo = relatedEvent; 295 mRelatedTodo = relatedEvent;
292 296
293 mGeneral->setDefaults(due,allDay); 297 mGeneral->setDefaults(due,allDay);
294 mDetails->setDefaults(); 298 mDetails->setDefaults();
295 showPage( 0 ); 299 showPage( 0 );
296 if ( mRelatedTodo ) { 300 if ( mRelatedTodo ) {
297 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 301 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
298 mGeneral->setSecrecy (mRelatedTodo->secrecy ()); 302 mGeneral->setSecrecy (mRelatedTodo->secrecy ());
299 if ( mRelatedTodo->priority() < 3 ) 303 if ( mRelatedTodo->priority() < 3 )
300 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); 304 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
301 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); 305 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
302 int len = mRelatedTodo->summary().length(); 306 int len = mRelatedTodo->summary().length();
303 mGeneral->mSummaryEdit->lineEdit()->setFocus(); 307 mGeneral->mSummaryEdit->lineEdit()->setFocus();
304 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); 308 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
305 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); 309 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
306 310
307 } else 311 } else
308 mGeneral->setFocusOn( 2 ); 312 mGeneral->setFocusOn( 2 );
309 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 313 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
310 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); 314 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
311} 315}
312void KOTodoEditor::checkRecurrence() 316void KOTodoEditor::checkRecurrence()
313{ 317{
314 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 318 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
315 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); 319 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true );
316 320
317 if ( mTodo ) 321 if ( mTodo )
318 mRecurrence->readEvent( mTodo ); 322 mRecurrence->readEvent( mTodo );
319 else { 323 else {
320 bool time = mGeneral->mTimeButton->isChecked(); 324 bool time = mGeneral->mTimeButton->isChecked();
321 QDateTime from,to; 325 QDateTime from,to;
322 if ( time ) { 326 if ( time ) {
323 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; 327 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
324 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; 328 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
325 } else { 329 } else {
326 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; 330 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
327 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; 331 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
328 } 332 }
329 if ( to < from ) 333 if ( to < from )
330 to = from; 334 to = from;
331 mRecurrence->setDefaults(from,to); 335 mRecurrence->setDefaults(from,to);
332 } 336 }
333 } else { 337 } else {
334 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 338 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
335 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 )); 339 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ));
336 } 340 }
337} 341}
338void KOTodoEditor::readTodo(Todo *todo) 342void KOTodoEditor::readTodo(Todo *todo)
339{ 343{
340 mGeneral->readTodo(todo); 344 mGeneral->readTodo(todo);
341 mDetails->readEvent(todo); 345 mDetails->readEvent(todo);
342 mRelatedTodo = 0;//todo->relatedTo(); 346 mRelatedTodo = 0;//todo->relatedTo();
343 // categories 347 // categories
344 // mCategoryDialog->setSelected(todo->categories()); 348 // mCategoryDialog->setSelected(todo->categories());
345 349
346 // We should handle read-only events here. 350 // We should handle read-only events here.
347} 351}
348 352
349void KOTodoEditor::writeTodo(Todo *event) 353void KOTodoEditor::writeTodo(Todo *event)
350{ 354{
351 bool maybeComputeRecurrenceTime = false; 355 bool maybeComputeRecurrenceTime = false;
352 if( event->hasRecurrenceID() && event->percentComplete() < 100) 356 if( event->hasRecurrenceID() && event->percentComplete() < 100)
353 maybeComputeRecurrenceTime = true; 357 maybeComputeRecurrenceTime = true;
354 event->setHasRecurrenceID( false ); 358 event->setHasRecurrenceID( false );
355 mGeneral->writeTodo(event); 359 mGeneral->writeTodo(event);
356 mDetails->writeEvent(event); 360 mDetails->writeEvent(event);
357 361
358 // set related event, i.e. parent to-do in this case. 362 // set related event, i.e. parent to-do in this case.
359 if (mRelatedTodo) { 363 if (mRelatedTodo) {
360 event->setRelatedTo(mRelatedTodo); 364 event->setRelatedTo(mRelatedTodo);
361 } 365 }
362 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 366 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
363 mRecurrence->writeEvent(event); 367 mRecurrence->writeEvent(event);
364 if ( event->doesRecur() ) { 368 if ( event->doesRecur() ) {
365 int addSec = -1 ; 369 int addSec = -1 ;
366 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) 370 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
367 addSec = 1; 371 addSec = 1;
368 event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); 372 event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
369 event->setRecurDates(); 373 event->setRecurDates();
370 } else { 374 } else {
371 event->setHasRecurrenceID( false ); 375 event->setHasRecurrenceID( false );
372 } 376 }
373 } else { 377 } else {
374 event->setHasRecurrenceID( false ); 378 event->setHasRecurrenceID( false );
375 event->recurrence()->unsetRecurs(); 379 event->recurrence()->unsetRecurs();
376 } 380 }
377} 381}
378 382
379bool KOTodoEditor::validateInput() 383bool KOTodoEditor::validateInput()
380{ 384{
381 if (!mGeneral->validateInput()) return false; 385 if (!mGeneral->validateInput()) return false;
382 if (!mDetails->validateInput()) return false; 386 if (!mDetails->validateInput()) return false;
383 return true; 387 return true;
384} 388}
385 389
386int KOTodoEditor::msgItemDelete() 390int KOTodoEditor::msgItemDelete()
387{ 391{
388 return KMessageBox::warningContinueCancel(this, 392 return KMessageBox::warningContinueCancel(this,
389 i18n("This item will be permanently deleted."), 393 i18n("This item will be permanently deleted."),
390 i18n("KOrganizer Confirmation"),i18n("Delete")); 394 i18n("KOrganizer Confirmation"),i18n("Delete"));
391} 395}
392 396
393void KOTodoEditor::modified (int modification) 397void KOTodoEditor::modified (int modification)
394{ 398{
395 if (modification == KOGlobals::CATEGORY_MODIFIED || 399 if (modification == KOGlobals::CATEGORY_MODIFIED ||
396 KOGlobals::UNKNOWN_MODIFIED == modification ) 400 KOGlobals::UNKNOWN_MODIFIED == modification )
397 // mCategoryDialog->setSelected (mTodo->categories ()); 401 // mCategoryDialog->setSelected (mTodo->categories ());
398 mGeneral->modified (mTodo, modification); 402 mGeneral->modified (mTodo, modification);
399 403
400} 404}
401 405
402void KOTodoEditor::slotLoadTemplate() 406void KOTodoEditor::slotLoadTemplate()
403{ 407{
404 408
405 QString fileName =locateLocal( "templates", "todos" ); 409 QString fileName =locateLocal( "templates", "todos" );
406 QDir t_dir; 410 QDir t_dir;
407 if ( !t_dir.exists(fileName) ) 411 if ( !t_dir.exists(fileName) )
408 t_dir.mkdir ( fileName ); 412 t_dir.mkdir ( fileName );
409 fileName += "/todo"; 413 fileName += "/todo";
410 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 414 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
411 if ( fileName.length() == 0 ) 415 if ( fileName.length() == 0 )
412 return; 416 return;
413 CalendarLocal cal; 417 CalendarLocal cal;
414 ICalFormat format; 418 ICalFormat format;
415 if ( !format.load( &cal, fileName ) ) { 419 if ( !format.load( &cal, fileName ) ) {
416 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 420 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
417 .arg( fileName ) ); 421 .arg( fileName ) );
418 return ; 422 return ;
419 } 423 }
420 QPtrList<Todo> todos = cal.todos(); 424 QPtrList<Todo> todos = cal.todos();
421 Todo * todo = todos.first(); 425 Todo * todo = todos.first();
422 if ( !todo ) { 426 if ( !todo ) {
423 KMessageBox::error( this, 427 KMessageBox::error( this,
424 i18n("Template does not\ncontain a valid Todo.")); 428 i18n("Template does not\ncontain a valid Todo."));
425 } else { 429 } else {
426 readTodo( todo ); 430 readTodo( todo );
427 } 431 }
428 432
429} 433}
430 434
431void KOTodoEditor::slotSaveTemplate() 435void KOTodoEditor::slotSaveTemplate()
432{ 436{
433 QString fileName =locateLocal( "templates", "todos" ); 437 QString fileName =locateLocal( "templates", "todos" );
434 QDir t_dir; 438 QDir t_dir;
435 if ( !t_dir.exists(fileName) ) 439 if ( !t_dir.exists(fileName) )
436 t_dir.mkdir ( fileName ); 440 t_dir.mkdir ( fileName );
437 fileName += "/todo"; 441 fileName += "/todo";
438 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 442 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
439 if ( fileName.length() > 0 ) 443 if ( fileName.length() > 0 )
440 saveTemplate( fileName ); 444 saveTemplate( fileName );
441} 445}
442 446
443void KOTodoEditor::saveTemplate( const QString &templateName ) 447void KOTodoEditor::saveTemplate( const QString &templateName )
444{ 448{
445 Todo *todo = new Todo; 449 Todo *todo = new Todo;
446 writeTodo( todo ); 450 writeTodo( todo );
447 saveAsTemplate( todo, templateName ); 451 saveAsTemplate( todo, templateName );
448} 452}