summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp2
-rw-r--r--microkde/kfiledialog.cpp11
-rw-r--r--microkde/kfiledialog.h2
-rw-r--r--microkde/kio/kfile/kurlrequester.cpp7
-rw-r--r--microkde/kio/kfile/kurlrequester.h2
6 files changed, 30 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 4b82aa8..8f5de4d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3696 +1,3703 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->typeID() == eventID ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->typeID() == todoID ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->typeID() == todoID ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 mTodoList->setNavigator( mNavigator ); 462 mTodoList->setNavigator( mNavigator );
463#if 0 463#if 0
464 if ( QApplication::desktop()->width() < 480 ) { 464 if ( QApplication::desktop()->width() < 480 ) {
465 leftFrameLayout->addWidget(mFilterView); 465 leftFrameLayout->addWidget(mFilterView);
466 leftFrameLayout->addWidget(mTodoList, 2 ); 466 leftFrameLayout->addWidget(mTodoList, 2 );
467 467
468 } else { 468 } else {
469 leftFrameLayout->addWidget(mTodoList,2 ); 469 leftFrameLayout->addWidget(mTodoList,2 );
470 leftFrameLayout->addWidget(mFilterView ); 470 leftFrameLayout->addWidget(mFilterView );
471 } 471 }
472#endif 472#endif
473 mFilterView->hide(); 473 mFilterView->hide();
474 mCalEditView->hide(); 474 mCalEditView->hide();
475 QWidget *rightBox = new QWidget( mMainFrame ); 475 QWidget *rightBox = new QWidget( mMainFrame );
476 //mainBoxLayout->addWidget ( rightBox, 10 ); 476 //mainBoxLayout->addWidget ( rightBox, 10 );
477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
478 mRightFrame = new QWidgetStack( rightBox ); 478 mRightFrame = new QWidgetStack( rightBox );
479 rightLayout->addWidget( mRightFrame, 10 ); 479 rightLayout->addWidget( mRightFrame, 10 );
480 480
481 //mLeftFrame = (QWidget *)leftFrame; 481 //mLeftFrame = (QWidget *)leftFrame;
482 if ( KOPrefs::instance()->mVerticalScreen ) { 482 if ( KOPrefs::instance()->mVerticalScreen ) {
483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
487 } else { 487 } else {
488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
491 } 491 }
492 if ( !KOPrefs::instance()->mShowDateNavigator) 492 if ( !KOPrefs::instance()->mShowDateNavigator)
493 mDateNavigator->hide(); 493 mDateNavigator->hide();
494 //qDebug("Calendarview Size %d %d ", width(), height()); 494 //qDebug("Calendarview Size %d %d ", width(), height());
495#endif 495#endif
496 496
497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
498 SLOT( showDates( const KCal::DateList & ) ) ); 498 SLOT( showDates( const KCal::DateList & ) ) );
499 499
500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
502 502
503 503
504 504
505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
506 mViewManager, SLOT( showMonth( const QDate & ) ) ); 506 mViewManager, SLOT( showMonth( const QDate & ) ) );
507 507
508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
509 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 509 mNavigator, SLOT( selectWeek( const QDate & ) ) );
510 510
511 connect( mDateNavigator, SIGNAL( goPrevYear() ), 511 connect( mDateNavigator, SIGNAL( goPrevYear() ),
512 mNavigator, SLOT( selectPreviousYear() ) ); 512 mNavigator, SLOT( selectPreviousYear() ) );
513 connect( mDateNavigator, SIGNAL( goNextYear() ), 513 connect( mDateNavigator, SIGNAL( goNextYear() ),
514 mNavigator, SLOT( selectNextYear() ) ); 514 mNavigator, SLOT( selectNextYear() ) );
515 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 515 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
516 mNavigator, SLOT( selectPreviousMonth() ) ); 516 mNavigator, SLOT( selectPreviousMonth() ) );
517 connect( mDateNavigator, SIGNAL( goNextMonth() ), 517 connect( mDateNavigator, SIGNAL( goNextMonth() ),
518 mNavigator, SLOT( selectNextMonth() ) ); 518 mNavigator, SLOT( selectNextMonth() ) );
519 519
520 connect( mDateNavigator, SIGNAL( goPrevious() ), 520 connect( mDateNavigator, SIGNAL( goPrevious() ),
521 mNavigator, SLOT( selectPrevious() ) ); 521 mNavigator, SLOT( selectPrevious() ) );
522 connect( mDateNavigator, SIGNAL( goNext() ), 522 connect( mDateNavigator, SIGNAL( goNext() ),
523 mNavigator, SLOT( selectNext() ) ); 523 mNavigator, SLOT( selectNext() ) );
524 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 524 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
525 mNavigator, SLOT( slotMonthSelect( int ) ) ); 525 mNavigator, SLOT( slotMonthSelect( int ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 527 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
528 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 528 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
529#if 0 529#if 0
530 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 530 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
531 SLOT( incidenceAdded( Incidence *) ) ); 531 SLOT( incidenceAdded( Incidence *) ) );
532#endif 532#endif
533 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 533 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
534 534
535 connect( this, SIGNAL( configChanged() ), 535 connect( this, SIGNAL( configChanged() ),
536 mDateNavigator, SLOT( updateConfig() ) ); 536 mDateNavigator, SLOT( updateConfig() ) );
537 537
538 connect( mTodoList, SIGNAL( newTodoSignal() ), 538 connect( mTodoList, SIGNAL( newTodoSignal() ),
539 SLOT( newTodo() ) ); 539 SLOT( newTodo() ) );
540 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 540 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
541 SLOT( newSubTodo( Todo * ) ) ); 541 SLOT( newSubTodo( Todo * ) ) );
542 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 542 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
543 SLOT( editTodo( Todo * ) ) ); 543 SLOT( editTodo( Todo * ) ) );
544 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 544 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
545 SLOT( showTodo( Todo *) ) ); 545 SLOT( showTodo( Todo *) ) );
546 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 546 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
547 SLOT( deleteTodo( Todo *) ) ); 547 SLOT( deleteTodo( Todo *) ) );
548 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 548 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
549 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 549 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
550 SLOT( purgeCompleted() ) ); 550 SLOT( purgeCompleted() ) );
551 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 551 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
552 SIGNAL( todoModified( Todo *, int ) ) ); 552 SIGNAL( todoModified( Todo *, int ) ) );
553 553
554 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 554 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
555 this, SLOT ( cloneIncidence( Incidence * ) ) ); 555 this, SLOT ( cloneIncidence( Incidence * ) ) );
556 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 556 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
557 this, SLOT (cancelIncidence( Incidence * ) ) ); 557 this, SLOT (cancelIncidence( Incidence * ) ) );
558 558
559 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 559 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
560 this, SLOT ( moveIncidence( Incidence * ) ) ); 560 this, SLOT ( moveIncidence( Incidence * ) ) );
561 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 561 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
562 this, SLOT ( beamIncidence( Incidence * ) ) ); 562 this, SLOT ( beamIncidence( Incidence * ) ) );
563 563
564 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 564 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
565 this, SLOT ( todo_unsub( Todo * ) ) ); 565 this, SLOT ( todo_unsub( Todo * ) ) );
566 566
567 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 567 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
568 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 568 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
569 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 569 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
570 SLOT( updateTodo( Todo *, int ) ) ); 570 SLOT( updateTodo( Todo *, int ) ) );
571 connect( this, SIGNAL( todoModified( Todo *, int )), this, 571 connect( this, SIGNAL( todoModified( Todo *, int )), this,
572 SLOT( changeTodoDisplay( Todo *, int ) ) ); 572 SLOT( changeTodoDisplay( Todo *, int ) ) );
573 573
574 574
575 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 575 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
576 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 576 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
577 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 577 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
578 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 578 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
579 579
580 580
581 581
582 582
583 583
584 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 584 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
585 SLOT(checkClipboard())); 585 SLOT(checkClipboard()));
586 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 586 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
587 SLOT( processTodoListSelection( Incidence * ) ) ); 587 SLOT( processTodoListSelection( Incidence * ) ) );
588 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 588 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
589 589
590 // kdDebug() << "CalendarView::CalendarView() done" << endl; 590 // kdDebug() << "CalendarView::CalendarView() done" << endl;
591 591
592 mDateFrame = new QVBox(0,0,WType_Popup); 592 mDateFrame = new QVBox(0,0,WType_Popup);
593 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 593 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
594 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 594 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
595 mDateFrame->setLineWidth(3); 595 mDateFrame->setLineWidth(3);
596 mDateFrame->hide(); 596 mDateFrame->hide();
597 mDateFrame->setCaption( i18n( "Pick a date to display")); 597 mDateFrame->setCaption( i18n( "Pick a date to display"));
598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
599 599
600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
601 601
602 mEventEditor = mDialogManager->getEventEditor(); 602 mEventEditor = mDialogManager->getEventEditor();
603 mTodoEditor = mDialogManager->getTodoEditor(); 603 mTodoEditor = mDialogManager->getTodoEditor();
604 604
605 mFlagEditDescription = false; 605 mFlagEditDescription = false;
606 606
607 mSuspendTimer = new QTimer( this ); 607 mSuspendTimer = new QTimer( this );
608 mAlarmTimer = new QTimer( this ); 608 mAlarmTimer = new QTimer( this );
609 mRecheckAlarmTimer = new QTimer( this ); 609 mRecheckAlarmTimer = new QTimer( this );
610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
613 mAlarmDialog = new AlarmDialog( this ); 613 mAlarmDialog = new AlarmDialog( this );
614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
615 mAlarmDialog->setServerNotification( false ); 615 mAlarmDialog->setServerNotification( false );
616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
617 617
618 618
619#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
620//US listen for arriving address resultsets 620//US listen for arriving address resultsets
621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
623#endif 623#endif
624 mDateNavigator->setCalendar( mCalendar ); 624 mDateNavigator->setCalendar( mCalendar );
625} 625}
626 626
627 627
628CalendarView::~CalendarView() 628CalendarView::~CalendarView()
629{ 629{
630 // kdDebug() << "~CalendarView()" << endl; 630 // kdDebug() << "~CalendarView()" << endl;
631 //qDebug("CalendarView::~CalendarView() "); 631 //qDebug("CalendarView::~CalendarView() ");
632 delete mDialogManager; 632 delete mDialogManager;
633 delete mViewManager; 633 delete mViewManager;
634 delete mStorage; 634 delete mStorage;
635 delete mDateFrame ; 635 delete mDateFrame ;
636 delete beamDialog; 636 delete beamDialog;
637 delete mEventViewerDialog; 637 delete mEventViewerDialog;
638 //kdDebug() << "~CalendarView() done" << endl; 638 //kdDebug() << "~CalendarView() done" << endl;
639} 639}
640void CalendarView::checkAlarms() 640void CalendarView::checkAlarms()
641{ 641{
642 KConfig *config = KOGlobals::config(); 642 KConfig *config = KOGlobals::config();
643 config->setGroup( "AppRun" ); 643 config->setGroup( "AppRun" );
644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
645 int secto = dt.secsTo( QDateTime::currentDateTime() ); 645 int secto = dt.secsTo( QDateTime::currentDateTime() );
646 int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; 646 int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30;
647 qDebug("KO: Reading program stop %d ", secs);
647 //secs -= ( 3600 * 24*3 ); // debug only 648 //secs -= ( 3600 * 24*3 ); // debug only
648 QDateTime latest = dt.addSecs ( secs ); 649 QDateTime latest = dt.addSecs ( secs );
649 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 650 qDebug("KO: Last termination on %s ", latest.toString().latin1());
651 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
650 QPtrList<Incidence> el = mCalendar->rawIncidences(); 652 QPtrList<Incidence> el = mCalendar->rawIncidences();
651 QPtrList<Incidence> al; 653 QPtrList<Incidence> al;
652 Incidence* inL = el.first(); 654 Incidence* inL = el.first();
653 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 655 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
654 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 656 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
655 while ( inL ) { 657 while ( inL ) {
656 bool ok = false; 658 bool ok = false;
657 int offset = 0; 659 int offset = 0;
658 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 660 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
659 if ( ok ) { 661 if ( ok ) {
660 //qDebug("OK %s",next.toString().latin1()); 662 //qDebug("OK %s",next.toString().latin1());
661 if ( next < cur ) { 663 if ( next < cur ) {
662 al.append( inL ); 664 al.append( inL );
663 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 665 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
664 } 666 }
665 } 667 }
666 inL = el.next(); 668 inL = el.next();
667 } 669 }
668 if ( al.count() ) { 670 if ( al.count() ) {
669 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 671 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
670 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 672 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
671 QVBoxLayout* lay = new QVBoxLayout( dia ); 673 QVBoxLayout* lay = new QVBoxLayout( dia );
672 lay->setSpacing( 0 ); 674 lay->setSpacing( 0 );
673 lay->setMargin( 0 ); 675 lay->setMargin( 0 );
674 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 676 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
675 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 677 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
676 lay->addWidget( matb ); 678 lay->addWidget( matb );
677 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 679 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
678 int wid = 210; 680 int wid = 210;
679 int x = QApplication::desktop()->width() - wid - 7; 681 int x = QApplication::desktop()->width() - wid - 7;
680 int y = QApplication::desktop()->height() - wid - 70; 682 int y = QApplication::desktop()->height() - wid - 70;
681 dia->setGeometry ( x,y,wid,wid); 683 dia->setGeometry ( x,y,wid,wid);
682 } else { 684 } else {
683 int si = 220; 685 int si = 220;
684 if ( QApplication::desktop()->width() > 470 ) 686 if ( QApplication::desktop()->width() > 470 )
685 si = 400; 687 si = 400;
686 dia->resize(si,si/2); 688 dia->resize(si,si/2);
687 } 689 }
688 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 690 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
689 dia->show(); 691 dia->show();
690 692
691 } 693 }
692} 694}
693void CalendarView::showDay( QDate d ) 695void CalendarView::showDay( QDate d )
694{ 696{
695 dateNavigator()->blockSignals( true ); 697 dateNavigator()->blockSignals( true );
696 dateNavigator()->selectDate( d ); 698 dateNavigator()->selectDate( d );
697 dateNavigator()->blockSignals( false ); 699 dateNavigator()->blockSignals( false );
698 mViewManager->showDayView(); 700 mViewManager->showDayView();
699 //dateNavigator()->selectDate( d ); 701 //dateNavigator()->selectDate( d );
700} 702}
701void CalendarView::timerAlarm() 703void CalendarView::timerAlarm()
702{ 704{
703 //qDebug("CalendarView::timerAlarm() "); 705 //qDebug("CalendarView::timerAlarm() ");
704 computeAlarm(mAlarmNotification ); 706 computeAlarm(mAlarmNotification );
705} 707}
706 708
707void CalendarView::suspendAlarm() 709void CalendarView::suspendAlarm()
708{ 710{
709 //qDebug(" CalendarView::suspendAlarm() "); 711 //qDebug(" CalendarView::suspendAlarm() ");
710 computeAlarm(mSuspendAlarmNotification ); 712 computeAlarm(mSuspendAlarmNotification );
711 713
712} 714}
713 715
714void CalendarView::startAlarm( QString mess , QString filename) 716void CalendarView::startAlarm( QString mess , QString filename)
715{ 717{
716 718
717 topLevelWidget()->showNormal(); 719 topLevelWidget()->showNormal();
718 topLevelWidget()->setActiveWindow(); 720 topLevelWidget()->setActiveWindow();
719 topLevelWidget()->raise(); 721 topLevelWidget()->raise();
720 722
721 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 723 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
722 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 724 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
723 725
724} 726}
725 727
726void CalendarView::checkNextTimerAlarm() 728void CalendarView::checkNextTimerAlarm()
727{ 729{
728 mCalendar->checkAlarmForIncidence( 0, true ); 730 mCalendar->checkAlarmForIncidence( 0, true );
729} 731}
730 732
731void CalendarView::computeAlarm( QString msg ) 733void CalendarView::computeAlarm( QString msg )
732{ 734{
733 735
734 QString mess = msg; 736 QString mess = msg;
735 QString mAlarmMessage = mess.mid( 9 ); 737 QString mAlarmMessage = mess.mid( 9 );
736 QString filename = MainWindow::resourcePath(); 738 QString filename = MainWindow::resourcePath();
737 filename += "koalarm.wav"; 739 filename += "koalarm.wav";
738 QString tempfilename; 740 QString tempfilename;
739 if ( mess.left( 13 ) == "suspend_alarm") { 741 if ( mess.left( 13 ) == "suspend_alarm") {
740 bool error = false; 742 bool error = false;
741 int len = mess.mid( 13 ).find("+++"); 743 int len = mess.mid( 13 ).find("+++");
742 if ( len < 2 ) 744 if ( len < 2 )
743 error = true; 745 error = true;
744 else { 746 else {
745 tempfilename = mess.mid( 13, len ); 747 tempfilename = mess.mid( 13, len );
746 if ( !QFile::exists( tempfilename ) ) 748 if ( !QFile::exists( tempfilename ) )
747 error = true; 749 error = true;
748 } 750 }
749 if ( ! error ) { 751 if ( ! error ) {
750 filename = tempfilename; 752 filename = tempfilename;
751 } 753 }
752 mAlarmMessage = mess.mid( 13+len+3 ); 754 mAlarmMessage = mess.mid( 13+len+3 );
753 //qDebug("suspend file %s ",tempfilename.latin1() ); 755 //qDebug("suspend file %s ",tempfilename.latin1() );
754 startAlarm( mAlarmMessage, filename); 756 startAlarm( mAlarmMessage, filename);
755 return; 757 return;
756 } 758 }
757 if ( mess.left( 11 ) == "timer_alarm") { 759 if ( mess.left( 11 ) == "timer_alarm") {
758 //mTimerTime = 0; 760 //mTimerTime = 0;
759 startAlarm( mess.mid( 11 ), filename ); 761 startAlarm( mess.mid( 11 ), filename );
760 return; 762 return;
761 } 763 }
762 if ( mess.left( 10 ) == "proc_alarm") { 764 if ( mess.left( 10 ) == "proc_alarm") {
763 bool error = false; 765 bool error = false;
764 int len = mess.mid( 10 ).find("+++"); 766 int len = mess.mid( 10 ).find("+++");
765 if ( len < 2 ) 767 if ( len < 2 )
766 error = true; 768 error = true;
767 else { 769 else {
768 tempfilename = mess.mid( 10, len ); 770 tempfilename = mess.mid( 10, len );
769 if ( !QFile::exists( tempfilename ) ) 771 if ( !QFile::exists( tempfilename ) )
770 error = true; 772 error = true;
771 } 773 }
772 if ( error ) { 774 if ( error ) {
773 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 775 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
774 mAlarmMessage += mess.mid( 10+len+3+9 ); 776 mAlarmMessage += mess.mid( 10+len+3+9 );
775 } else { 777 } else {
776 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 778 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
777 //qDebug("-----system command %s ",tempfilename.latin1() ); 779 //qDebug("-----system command %s ",tempfilename.latin1() );
778#ifndef _WIN32_ 780#ifndef _WIN32_
779 if ( vfork () == 0 ) { 781 if ( vfork () == 0 ) {
780 execl ( tempfilename.latin1(), 0 ); 782 execl ( tempfilename.latin1(), 0 );
781 return; 783 return;
782 } 784 }
783#else 785#else
784 QProcess* p = new QProcess(); 786 QProcess* p = new QProcess();
785 p->addArgument( tempfilename.latin1() ); 787 p->addArgument( tempfilename.latin1() );
786 p->start(); 788 p->start();
787 return; 789 return;
788#endif 790#endif
789 791
790 return; 792 return;
791 } 793 }
792 794
793 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 795 //qDebug("+++++++system command %s ",tempfilename.latin1() );
794 } 796 }
795 if ( mess.left( 11 ) == "audio_alarm") { 797 if ( mess.left( 11 ) == "audio_alarm") {
796 bool error = false; 798 bool error = false;
797 int len = mess.mid( 11 ).find("+++"); 799 int len = mess.mid( 11 ).find("+++");
798 if ( len < 2 ) 800 if ( len < 2 )
799 error = true; 801 error = true;
800 else { 802 else {
801 tempfilename = mess.mid( 11, len ); 803 tempfilename = mess.mid( 11, len );
802 if ( !QFile::exists( tempfilename ) ) 804 if ( !QFile::exists( tempfilename ) )
803 error = true; 805 error = true;
804 } 806 }
805 if ( ! error ) { 807 if ( ! error ) {
806 filename = tempfilename; 808 filename = tempfilename;
807 } 809 }
808 mAlarmMessage = mess.mid( 11+len+3+9 ); 810 mAlarmMessage = mess.mid( 11+len+3+9 );
809 //qDebug("audio file command %s ",tempfilename.latin1() ); 811 //qDebug("audio file command %s ",tempfilename.latin1() );
810 } 812 }
811 if ( mess.left( 9 ) == "cal_alarm") { 813 if ( mess.left( 9 ) == "cal_alarm") {
812 mAlarmMessage = mess.mid( 9 ) ; 814 mAlarmMessage = mess.mid( 9 ) ;
813 } 815 }
814 816
815 startAlarm( mAlarmMessage, filename ); 817 startAlarm( mAlarmMessage, filename );
816 818
817 819
818} 820}
819 821
820void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 822void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
821{ 823{
822 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 824 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
823 825
824 mSuspendAlarmNotification = noti; 826 mSuspendAlarmNotification = noti;
825 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 827 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
826 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 828 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
827 mSuspendTimer->start( ms , true ); 829 mSuspendTimer->start( ms , true );
828 830
829} 831}
830 832
831void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 833void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
832{ 834{
833 mNextAlarmDateTime = qdt; 835 mNextAlarmDateTime = qdt;
834 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 836 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
835 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 837 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
836#ifndef DESKTOP_VERSION 838#ifndef DESKTOP_VERSION
837 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 839 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
838#endif 840#endif
839 return; 841 return;
840 } 842 }
841 int maxSec; 843 int maxSec;
842 //maxSec = 5; //testing only 844 //maxSec = 5; //testing only
843 maxSec = 86400+3600; // one day+1hour 845 maxSec = 86400+3600; // one day+1hour
844 mAlarmNotification = noti; 846 mAlarmNotification = noti;
845 int sec = QDateTime::currentDateTime().secsTo( qdt ); 847 int sec = QDateTime::currentDateTime().secsTo( qdt );
846 if ( sec > maxSec ) { 848 if ( sec > maxSec ) {
847 mRecheckAlarmTimer->start( maxSec * 1000 ); 849 mRecheckAlarmTimer->start( maxSec * 1000 );
848 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 850 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
849 return; 851 return;
850 } else { 852 } else {
851 mRecheckAlarmTimer->stop(); 853 mRecheckAlarmTimer->stop();
852 } 854 }
853 //qDebug("Alarm timer started with secs: %d ", sec); 855 //qDebug("Alarm timer started with secs: %d ", sec);
854 mAlarmTimer->start( sec *1000 , true ); 856 mAlarmTimer->start( sec *1000 , true );
855 857
856} 858}
857// called by mRecheckAlarmTimer to get next alarm 859// called by mRecheckAlarmTimer to get next alarm
858// we need this, because a QTimer has only a max range of 25 days 860// we need this, because a QTimer has only a max range of 25 days
859void CalendarView::recheckTimerAlarm() 861void CalendarView::recheckTimerAlarm()
860{ 862{
861 mAlarmTimer->stop(); 863 mAlarmTimer->stop();
862 mRecheckAlarmTimer->stop(); 864 mRecheckAlarmTimer->stop();
863 mCalendar->checkAlarmForIncidence( 0, true ); 865 mCalendar->checkAlarmForIncidence( 0, true );
864} 866}
865void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 867void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
866{ 868{
867 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 869 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
868 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 870 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
869#ifndef DESKTOP_VERSION 871#ifndef DESKTOP_VERSION
870 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 872 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
871#endif 873#endif
872 return; 874 return;
873 } 875 }
874 mAlarmTimer->stop(); 876 mAlarmTimer->stop();
875} 877}
876void CalendarView::selectWeekNum ( int num ) 878void CalendarView::selectWeekNum ( int num )
877{ 879{
878 dateNavigator()->blockSignals( true ); 880 dateNavigator()->blockSignals( true );
879 dateNavigator()->selectWeek( num ); 881 dateNavigator()->selectWeek( num );
880 dateNavigator()->blockSignals( false ); 882 dateNavigator()->blockSignals( false );
881 mViewManager->showWeekView(); 883 mViewManager->showWeekView();
882} 884}
883KOViewManager *CalendarView::viewManager() 885KOViewManager *CalendarView::viewManager()
884{ 886{
885 return mViewManager; 887 return mViewManager;
886} 888}
887 889
888KODialogManager *CalendarView::dialogManager() 890KODialogManager *CalendarView::dialogManager()
889{ 891{
890 return mDialogManager; 892 return mDialogManager;
891} 893}
892 894
893QDate CalendarView::startDate() 895QDate CalendarView::startDate()
894{ 896{
895 DateList dates = mNavigator->selectedDates(); 897 DateList dates = mNavigator->selectedDates();
896 898
897 return dates.first(); 899 return dates.first();
898} 900}
899 901
900QDate CalendarView::endDate() 902QDate CalendarView::endDate()
901{ 903{
902 DateList dates = mNavigator->selectedDates(); 904 DateList dates = mNavigator->selectedDates();
903 905
904 return dates.last(); 906 return dates.last();
905} 907}
906 908
907 909
908void CalendarView::createPrinter() 910void CalendarView::createPrinter()
909{ 911{
910#ifndef KORG_NOPRINTER 912#ifndef KORG_NOPRINTER
911 if (!mCalPrinter) { 913 if (!mCalPrinter) {
912 mCalPrinter = new CalPrinter(this, mCalendar); 914 mCalPrinter = new CalPrinter(this, mCalendar);
913 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 915 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
914 } 916 }
915#endif 917#endif
916} 918}
917 919
918 920
919//KOPrefs::instance()->mWriteBackFile 921//KOPrefs::instance()->mWriteBackFile
920//KOPrefs::instance()->mWriteBackExistingOnly 922//KOPrefs::instance()->mWriteBackExistingOnly
921 923
922// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 924// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
923// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 925// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
924// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 926// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
925// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 927// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
926// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 928// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
927// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 929// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
928 930
929int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 931int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
930{ 932{
931 933
932 // 0 equal 934 // 0 equal
933 // 1 take local 935 // 1 take local
934 // 2 take remote 936 // 2 take remote
935 // 3 cancel 937 // 3 cancel
936 QDateTime lastSync = mLastCalendarSync; 938 QDateTime lastSync = mLastCalendarSync;
937 QDateTime localMod = local->lastModified(); 939 QDateTime localMod = local->lastModified();
938 QDateTime remoteMod = remote->lastModified(); 940 QDateTime remoteMod = remote->lastModified();
939 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 941 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
940 bool remCh, locCh; 942 bool remCh, locCh;
941 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 943 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
942 //if ( remCh ) 944 //if ( remCh )
943 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 945 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
944 locCh = ( localMod > mLastCalendarSync ); 946 locCh = ( localMod > mLastCalendarSync );
945 if ( !remCh && ! locCh ) { 947 if ( !remCh && ! locCh ) {
946 //qDebug("both not changed "); 948 //qDebug("both not changed ");
947 lastSync = localMod.addDays(1); 949 lastSync = localMod.addDays(1);
948 if ( mode <= SYNC_PREF_ASK ) 950 if ( mode <= SYNC_PREF_ASK )
949 return 0; 951 return 0;
950 } else { 952 } else {
951 if ( locCh ) { 953 if ( locCh ) {
952 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 954 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
953 lastSync = localMod.addDays( -1 ); 955 lastSync = localMod.addDays( -1 );
954 if ( !remCh ) 956 if ( !remCh )
955 remoteMod = ( lastSync.addDays( -1 ) ); 957 remoteMod = ( lastSync.addDays( -1 ) );
956 } else { 958 } else {
957 //qDebug(" not loc changed "); 959 //qDebug(" not loc changed ");
958 lastSync = localMod.addDays( 1 ); 960 lastSync = localMod.addDays( 1 );
959 if ( remCh ) 961 if ( remCh )
960 remoteMod =( lastSync.addDays( 1 ) ); 962 remoteMod =( lastSync.addDays( 1 ) );
961 963
962 } 964 }
963 } 965 }
964 full = true; 966 full = true;
965 if ( mode < SYNC_PREF_ASK ) 967 if ( mode < SYNC_PREF_ASK )
966 mode = SYNC_PREF_ASK; 968 mode = SYNC_PREF_ASK;
967 } else { 969 } else {
968 if ( localMod == remoteMod ) 970 if ( localMod == remoteMod )
969 // if ( local->revision() == remote->revision() ) 971 // if ( local->revision() == remote->revision() )
970 return 0; 972 return 0;
971 973
972 } 974 }
973 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 975 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
974 976
975 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 977 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
976 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 978 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
977 //full = true; //debug only 979 //full = true; //debug only
978 if ( full ) { 980 if ( full ) {
979 bool equ = false; 981 bool equ = false;
980 if ( local->typeID() == eventID ) { 982 if ( local->typeID() == eventID ) {
981 equ = (*((Event*) local) == *((Event*) remote)); 983 equ = (*((Event*) local) == *((Event*) remote));
982 } 984 }
983 else if ( local->typeID() == todoID ) 985 else if ( local->typeID() == todoID )
984 equ = (*((Todo*) local) == (*(Todo*) remote)); 986 equ = (*((Todo*) local) == (*(Todo*) remote));
985 else if ( local->typeID() == journalID ) 987 else if ( local->typeID() == journalID )
986 equ = (*((Journal*) local) == *((Journal*) remote)); 988 equ = (*((Journal*) local) == *((Journal*) remote));
987 if ( equ ) { 989 if ( equ ) {
988 //qDebug("equal "); 990 //qDebug("equal ");
989 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
990 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 992 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
991 } 993 }
992 if ( mode < SYNC_PREF_FORCE_LOCAL ) 994 if ( mode < SYNC_PREF_FORCE_LOCAL )
993 return 0; 995 return 0;
994 996
995 }//else //debug only 997 }//else //debug only
996 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 998 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
997 } 999 }
998 int result; 1000 int result;
999 bool localIsNew; 1001 bool localIsNew;
1000 //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() ); 1002 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1001 1003
1002 1004
1003 // ************************************************ 1005 // ************************************************
1004 // ************************************************ 1006 // ************************************************
1005 // ************************************************ 1007 // ************************************************
1006 // We may have that lastSync > remoteMod AND lastSync > localMod 1008 // We may have that lastSync > remoteMod AND lastSync > localMod
1007 // BUT remoteMod != localMod 1009 // BUT remoteMod != localMod
1008 1010
1009 1011
1010 if ( full && mode < SYNC_PREF_NEWEST ) 1012 if ( full && mode < SYNC_PREF_NEWEST )
1011 mode = SYNC_PREF_ASK; 1013 mode = SYNC_PREF_ASK;
1012 1014
1013 switch( mode ) { 1015 switch( mode ) {
1014 case SYNC_PREF_LOCAL: 1016 case SYNC_PREF_LOCAL:
1015 if ( lastSync > remoteMod ) 1017 if ( lastSync > remoteMod )
1016 return 1; 1018 return 1;
1017 if ( lastSync > localMod ) 1019 if ( lastSync > localMod )
1018 return 2; 1020 return 2;
1019 return 1; 1021 return 1;
1020 break; 1022 break;
1021 case SYNC_PREF_REMOTE: 1023 case SYNC_PREF_REMOTE:
1022 if ( lastSync > localMod ) 1024 if ( lastSync > localMod )
1023 return 2; 1025 return 2;
1024 if ( lastSync > remoteMod ) 1026 if ( lastSync > remoteMod )
1025 return 1; 1027 return 1;
1026 return 2; 1028 return 2;
1027 break; 1029 break;
1028 case SYNC_PREF_NEWEST: 1030 case SYNC_PREF_NEWEST:
1029 if ( localMod >= remoteMod ) 1031 if ( localMod >= remoteMod )
1030 return 1; 1032 return 1;
1031 else 1033 else
1032 return 2; 1034 return 2;
1033 break; 1035 break;
1034 case SYNC_PREF_ASK: 1036 case SYNC_PREF_ASK:
1035 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1036 if ( lastSync > remoteMod && lastSync > localMod) 1038 if ( lastSync > remoteMod && lastSync > localMod)
1037 return 0; 1039 return 0;
1038 if ( lastSync > remoteMod ) 1040 if ( lastSync > remoteMod )
1039 return 1; 1041 return 1;
1040 if ( lastSync > localMod ) 1042 if ( lastSync > localMod )
1041 return 2; 1043 return 2;
1042 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1044 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1043 localIsNew = localMod >= remoteMod; 1045 localIsNew = localMod >= remoteMod;
1044 if ( localIsNew ) 1046 if ( localIsNew )
1045 getEventViewerDialog()->setColorMode( 1 ); 1047 getEventViewerDialog()->setColorMode( 1 );
1046 else 1048 else
1047 getEventViewerDialog()->setColorMode( 2 ); 1049 getEventViewerDialog()->setColorMode( 2 );
1048 getEventViewerDialog()->setIncidence(local); 1050 getEventViewerDialog()->setIncidence(local);
1049 if ( localIsNew ) 1051 if ( localIsNew )
1050 getEventViewerDialog()->setColorMode( 2 ); 1052 getEventViewerDialog()->setColorMode( 2 );
1051 else 1053 else
1052 getEventViewerDialog()->setColorMode( 1 ); 1054 getEventViewerDialog()->setColorMode( 1 );
1053 getEventViewerDialog()->addIncidence(remote); 1055 getEventViewerDialog()->addIncidence(remote);
1054 getEventViewerDialog()->setColorMode( 0 ); 1056 getEventViewerDialog()->setColorMode( 0 );
1055 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1057 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1056 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1058 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1057 getEventViewerDialog()->showMe(); 1059 getEventViewerDialog()->showMe();
1058 result = getEventViewerDialog()->executeS( localIsNew ); 1060 result = getEventViewerDialog()->executeS( localIsNew );
1059 return result; 1061 return result;
1060 1062
1061 break; 1063 break;
1062 case SYNC_PREF_FORCE_LOCAL: 1064 case SYNC_PREF_FORCE_LOCAL:
1063 return 1; 1065 return 1;
1064 break; 1066 break;
1065 case SYNC_PREF_FORCE_REMOTE: 1067 case SYNC_PREF_FORCE_REMOTE:
1066 return 2; 1068 return 2;
1067 break; 1069 break;
1068 1070
1069 default: 1071 default:
1070 // SYNC_PREF_TAKE_BOTH not implemented 1072 // SYNC_PREF_TAKE_BOTH not implemented
1071 break; 1073 break;
1072 } 1074 }
1073 return 0; 1075 return 0;
1074} 1076}
1075Event* CalendarView::getLastSyncEvent() 1077Event* CalendarView::getLastSyncEvent()
1076{ 1078{
1077 Event* lse; 1079 Event* lse;
1078 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1080 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1079 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1081 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1080 if (!lse) { 1082 if (!lse) {
1081 lse = new Event(); 1083 lse = new Event();
1082 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1084 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1083 QString sum = ""; 1085 QString sum = "";
1084 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1086 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1085 sum = "E: "; 1087 sum = "E: ";
1086 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1088 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1087 lse->setDtStart( mLastCalendarSync ); 1089 lse->setDtStart( mLastCalendarSync );
1088 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1090 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1089 lse->setCategories( i18n("SyncEvent") ); 1091 lse->setCategories( i18n("SyncEvent") );
1090 lse->setReadOnly( true ); 1092 lse->setReadOnly( true );
1091 mCalendar->addEvent( lse ); 1093 mCalendar->addEvent( lse );
1092 } 1094 }
1093 1095
1094 return lse; 1096 return lse;
1095 1097
1096} 1098}
1097 1099
1098// we check, if the to delete event has a id for a profile 1100// we check, if the to delete event has a id for a profile
1099// if yes, we set this id in the profile to delete 1101// if yes, we set this id in the profile to delete
1100void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1102void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1101{ 1103{
1102 if ( lastSync.count() == 0 ) { 1104 if ( lastSync.count() == 0 ) {
1103 //qDebug(" lastSync.count() == 0"); 1105 //qDebug(" lastSync.count() == 0");
1104 return; 1106 return;
1105 } 1107 }
1106 if ( toDelete->typeID() == journalID ) 1108 if ( toDelete->typeID() == journalID )
1107 return; 1109 return;
1108 1110
1109 Event* eve = lastSync.first(); 1111 Event* eve = lastSync.first();
1110 1112
1111 while ( eve ) { 1113 while ( eve ) {
1112 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1114 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1113 if ( !id.isEmpty() ) { 1115 if ( !id.isEmpty() ) {
1114 QString des = eve->description(); 1116 QString des = eve->description();
1115 QString pref = "e"; 1117 QString pref = "e";
1116 if ( toDelete->typeID() == todoID ) 1118 if ( toDelete->typeID() == todoID )
1117 pref = "t"; 1119 pref = "t";
1118 des += pref+ id + ","; 1120 des += pref+ id + ",";
1119 eve->setReadOnly( false ); 1121 eve->setReadOnly( false );
1120 eve->setDescription( des ); 1122 eve->setDescription( des );
1121 //qDebug("setdes %s ", des.latin1()); 1123 //qDebug("setdes %s ", des.latin1());
1122 eve->setReadOnly( true ); 1124 eve->setReadOnly( true );
1123 } 1125 }
1124 eve = lastSync.next(); 1126 eve = lastSync.next();
1125 } 1127 }
1126 1128
1127} 1129}
1128void CalendarView::checkExternalId( Incidence * inc ) 1130void CalendarView::checkExternalId( Incidence * inc )
1129{ 1131{
1130 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1132 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1131 checkExternSyncEvent( lastSync, inc ); 1133 checkExternSyncEvent( lastSync, inc );
1132 1134
1133} 1135}
1134bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1136bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1135{ 1137{
1136 bool syncOK = true; 1138 bool syncOK = true;
1137 int addedEvent = 0; 1139 int addedEvent = 0;
1138 int addedEventR = 0; 1140 int addedEventR = 0;
1139 int deletedEventR = 0; 1141 int deletedEventR = 0;
1140 int deletedEventL = 0; 1142 int deletedEventL = 0;
1141 int changedLocal = 0; 1143 int changedLocal = 0;
1142 int changedRemote = 0; 1144 int changedRemote = 0;
1143 int filteredIN = 0; 1145 int filteredIN = 0;
1144 int filteredOUT = 0; 1146 int filteredOUT = 0;
1145 //QPtrList<Event> el = local->rawEvents(); 1147 //QPtrList<Event> el = local->rawEvents();
1146 Event* eventR; 1148 Event* eventR;
1147 QString uid; 1149 QString uid;
1148 int take; 1150 int take;
1149 Event* eventL; 1151 Event* eventL;
1150 Event* eventRSync; 1152 Event* eventRSync;
1151 Event* eventLSync; 1153 Event* eventLSync;
1152 clearAllViews(); 1154 clearAllViews();
1153 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1155 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1154 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1156 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1155 bool fullDateRange = false; 1157 bool fullDateRange = false;
1156 local->resetTempSyncStat(); 1158 local->resetTempSyncStat();
1157 mLastCalendarSync = QDateTime::currentDateTime(); 1159 mLastCalendarSync = QDateTime::currentDateTime();
1158 if ( mSyncManager->syncWithDesktop() ) { 1160 if ( mSyncManager->syncWithDesktop() ) {
1159 remote->resetPilotStat(1); 1161 remote->resetPilotStat(1);
1160 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1162 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1161 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1163 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1162 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1164 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1163 } else { 1165 } else {
1164 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1166 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1165 } 1167 }
1166 } 1168 }
1167 QDateTime modifiedCalendar = mLastCalendarSync; 1169 QDateTime modifiedCalendar = mLastCalendarSync;
1168 eventLSync = getLastSyncEvent(); 1170 eventLSync = getLastSyncEvent();
1169 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1171 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1170 if ( eventR ) { 1172 if ( eventR ) {
1171 eventRSync = (Event*) eventR->clone(); 1173 eventRSync = (Event*) eventR->clone();
1172 remote->deleteEvent(eventR ); 1174 remote->deleteEvent(eventR );
1173 1175
1174 } else { 1176 } else {
1175 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1177 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1176 eventRSync = (Event*)eventLSync->clone(); 1178 eventRSync = (Event*)eventLSync->clone();
1177 } else { 1179 } else {
1178 fullDateRange = true; 1180 fullDateRange = true;
1179 eventRSync = new Event(); 1181 eventRSync = new Event();
1180 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1182 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1181 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1183 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1182 eventRSync->setDtStart( mLastCalendarSync ); 1184 eventRSync->setDtStart( mLastCalendarSync );
1183 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1185 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1184 eventRSync->setCategories( i18n("SyncEvent") ); 1186 eventRSync->setCategories( i18n("SyncEvent") );
1185 } 1187 }
1186 } 1188 }
1187 if ( eventLSync->dtStart() == mLastCalendarSync ) 1189 if ( eventLSync->dtStart() == mLastCalendarSync )
1188 fullDateRange = true; 1190 fullDateRange = true;
1189 1191
1190 if ( ! fullDateRange ) { 1192 if ( ! fullDateRange ) {
1191 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1193 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1192 1194
1193 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1195 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1194 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1196 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1195 fullDateRange = true; 1197 fullDateRange = true;
1196 } 1198 }
1197 } 1199 }
1198 if ( mSyncManager->syncWithDesktop() ) { 1200 if ( mSyncManager->syncWithDesktop() ) {
1199 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1201 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1200 } 1202 }
1201 if ( fullDateRange ) 1203 if ( fullDateRange )
1202 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1204 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1203 else 1205 else
1204 mLastCalendarSync = eventLSync->dtStart(); 1206 mLastCalendarSync = eventLSync->dtStart();
1205 // for resyncing if own file has changed 1207 // for resyncing if own file has changed
1206 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1208 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1207 mLastCalendarSync = loadedFileVersion; 1209 mLastCalendarSync = loadedFileVersion;
1208 //qDebug("setting mLastCalendarSync "); 1210 //qDebug("setting mLastCalendarSync ");
1209 } 1211 }
1210 //qDebug("*************************** "); 1212 //qDebug("*************************** ");
1211 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1213 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1212 QPtrList<Incidence> er = remote->rawIncidences(); 1214 QPtrList<Incidence> er = remote->rawIncidences();
1213 Incidence* inR = er.first(); 1215 Incidence* inR = er.first();
1214 Incidence* inL; 1216 Incidence* inL;
1215 QProgressBar bar( er.count(),0 ); 1217 QProgressBar bar( er.count(),0 );
1216 bar.setCaption (i18n("Syncing - close to abort!") ); 1218 bar.setCaption (i18n("Syncing - close to abort!") );
1217 1219
1218 // ************** setting up filter ************* 1220 // ************** setting up filter *************
1219 CalFilter *filterIN = 0; 1221 CalFilter *filterIN = 0;
1220 CalFilter *filterOUT = 0; 1222 CalFilter *filterOUT = 0;
1221 CalFilter *filter = mFilters.first(); 1223 CalFilter *filter = mFilters.first();
1222 while(filter) { 1224 while(filter) {
1223 if ( filter->name() == mSyncManager->mFilterInCal ) 1225 if ( filter->name() == mSyncManager->mFilterInCal )
1224 filterIN = filter; 1226 filterIN = filter;
1225 if ( filter->name() == mSyncManager->mFilterOutCal ) 1227 if ( filter->name() == mSyncManager->mFilterOutCal )
1226 filterOUT = filter; 1228 filterOUT = filter;
1227 filter = mFilters.next(); 1229 filter = mFilters.next();
1228 } 1230 }
1229 int w = 300; 1231 int w = 300;
1230 if ( QApplication::desktop()->width() < 320 ) 1232 if ( QApplication::desktop()->width() < 320 )
1231 w = 220; 1233 w = 220;
1232 int h = bar.sizeHint().height() ; 1234 int h = bar.sizeHint().height() ;
1233 int dw = QApplication::desktop()->width(); 1235 int dw = QApplication::desktop()->width();
1234 int dh = QApplication::desktop()->height(); 1236 int dh = QApplication::desktop()->height();
1235 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1237 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1236 bar.show(); 1238 bar.show();
1237 int modulo = (er.count()/10)+1; 1239 int modulo = (er.count()/10)+1;
1238 int incCounter = 0; 1240 int incCounter = 0;
1239 while ( inR ) { 1241 while ( inR ) {
1240 if ( ! bar.isVisible() ) 1242 if ( ! bar.isVisible() )
1241 return false; 1243 return false;
1242 if ( incCounter % modulo == 0 ) 1244 if ( incCounter % modulo == 0 )
1243 bar.setProgress( incCounter ); 1245 bar.setProgress( incCounter );
1244 ++incCounter; 1246 ++incCounter;
1245 uid = inR->uid(); 1247 uid = inR->uid();
1246 bool skipIncidence = false; 1248 bool skipIncidence = false;
1247 if ( uid.left(15) == QString("last-syncEvent-") ) 1249 if ( uid.left(15) == QString("last-syncEvent-") )
1248 skipIncidence = true; 1250 skipIncidence = true;
1249 QString idS; 1251 QString idS;
1250 qApp->processEvents(); 1252 qApp->processEvents();
1251 if ( !skipIncidence ) { 1253 if ( !skipIncidence ) {
1252 inL = local->incidence( uid ); 1254 inL = local->incidence( uid );
1253 if ( inL ) { // maybe conflict - same uid in both calendars 1255 if ( inL ) { // maybe conflict - same uid in both calendars
1254 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1256 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1255 //qDebug("take %d %s ", take, inL->summary().latin1()); 1257 //qDebug("take %d %s ", take, inL->summary().latin1());
1256 if ( take == 3 ) 1258 if ( take == 3 )
1257 return false; 1259 return false;
1258 if ( take == 1 ) {// take local ********************** 1260 if ( take == 1 ) {// take local **********************
1259 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1261 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1260 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1262 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1261 else 1263 else
1262 idS = inR->IDStr(); 1264 idS = inR->IDStr();
1263 remote->deleteIncidence( inR ); 1265 remote->deleteIncidence( inR );
1264 inR = inL->clone(); 1266 inR = inL->clone();
1265 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1267 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1266 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1268 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1267 inR->setIDStr( idS ); 1269 inR->setIDStr( idS );
1268 remote->addIncidence( inR ); 1270 remote->addIncidence( inR );
1269 if ( mSyncManager->syncWithDesktop() ) 1271 if ( mSyncManager->syncWithDesktop() )
1270 inR->setPilotId( 2 ); 1272 inR->setPilotId( 2 );
1271 ++changedRemote; 1273 ++changedRemote;
1272 } else {// take remote ********************** 1274 } else {// take remote **********************
1273 idS = inL->IDStr(); 1275 idS = inL->IDStr();
1274 int pid = inL->pilotId(); 1276 int pid = inL->pilotId();
1275 local->deleteIncidence( inL ); 1277 local->deleteIncidence( inL );
1276 inL = inR->clone(); 1278 inL = inR->clone();
1277 if ( mSyncManager->syncWithDesktop() ) 1279 if ( mSyncManager->syncWithDesktop() )
1278 inL->setPilotId( pid ); 1280 inL->setPilotId( pid );
1279 inL->setIDStr( idS ); 1281 inL->setIDStr( idS );
1280 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1282 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1281 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1283 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1282 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1284 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1283 } 1285 }
1284 local->addIncidence( inL ); 1286 local->addIncidence( inL );
1285 ++changedLocal; 1287 ++changedLocal;
1286 } 1288 }
1287 } 1289 }
1288 } else { // no conflict ********** add or delete remote 1290 } else { // no conflict ********** add or delete remote
1289 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1291 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1290 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1291 QString des = eventLSync->description(); 1293 QString des = eventLSync->description();
1292 QString pref = "e"; 1294 QString pref = "e";
1293 if ( inR->typeID() == todoID ) 1295 if ( inR->typeID() == todoID )
1294 pref = "t"; 1296 pref = "t";
1295 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1297 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1296 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1298 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1297 //remote->deleteIncidence( inR ); 1299 //remote->deleteIncidence( inR );
1298 ++deletedEventR; 1300 ++deletedEventR;
1299 } else { 1301 } else {
1300 inR->setLastModified( modifiedCalendar ); 1302 inR->setLastModified( modifiedCalendar );
1301 inL = inR->clone(); 1303 inL = inR->clone();
1302 inL->setIDStr( ":" ); 1304 inL->setIDStr( ":" );
1303 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1305 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1304 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1306 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1305 local->addIncidence( inL ); 1307 local->addIncidence( inL );
1306 ++addedEvent; 1308 ++addedEvent;
1307 1309
1308 } 1310 }
1309 } else { 1311 } else {
1310 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1312 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1311 inR->setLastModified( modifiedCalendar ); 1313 inR->setLastModified( modifiedCalendar );
1312 inL = inR->clone(); 1314 inL = inR->clone();
1313 inL->setIDStr( ":" ); 1315 inL->setIDStr( ":" );
1314 local->addIncidence( inL ); 1316 local->addIncidence( inL );
1315 ++addedEvent; 1317 ++addedEvent;
1316 1318
1317 } else { 1319 } else {
1318 checkExternSyncEvent(eventRSyncSharp, inR); 1320 checkExternSyncEvent(eventRSyncSharp, inR);
1319 remote->deleteIncidence( inR ); 1321 remote->deleteIncidence( inR );
1320 ++deletedEventR; 1322 ++deletedEventR;
1321 } 1323 }
1322 } 1324 }
1323 } else { 1325 } else {
1324 ++filteredIN; 1326 ++filteredIN;
1325 } 1327 }
1326 } 1328 }
1327 } 1329 }
1328 inR = er.next(); 1330 inR = er.next();
1329 } 1331 }
1330 QPtrList<Incidence> el = local->rawIncidences(); 1332 QPtrList<Incidence> el = local->rawIncidences();
1331 inL = el.first(); 1333 inL = el.first();
1332 modulo = (el.count()/10)+1; 1334 modulo = (el.count()/10)+1;
1333 bar.setCaption (i18n("Add / remove events") ); 1335 bar.setCaption (i18n("Add / remove events") );
1334 bar.setTotalSteps ( el.count() ) ; 1336 bar.setTotalSteps ( el.count() ) ;
1335 bar.show(); 1337 bar.show();
1336 incCounter = 0; 1338 incCounter = 0;
1337 1339
1338 while ( inL ) { 1340 while ( inL ) {
1339 1341
1340 qApp->processEvents(); 1342 qApp->processEvents();
1341 if ( ! bar.isVisible() ) 1343 if ( ! bar.isVisible() )
1342 return false; 1344 return false;
1343 if ( incCounter % modulo == 0 ) 1345 if ( incCounter % modulo == 0 )
1344 bar.setProgress( incCounter ); 1346 bar.setProgress( incCounter );
1345 ++incCounter; 1347 ++incCounter;
1346 uid = inL->uid(); 1348 uid = inL->uid();
1347 bool skipIncidence = false; 1349 bool skipIncidence = false;
1348 if ( uid.left(15) == QString("last-syncEvent-") ) 1350 if ( uid.left(15) == QString("last-syncEvent-") )
1349 skipIncidence = true; 1351 skipIncidence = true;
1350 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1352 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1351 skipIncidence = true; 1353 skipIncidence = true;
1352 if ( !skipIncidence ) { 1354 if ( !skipIncidence ) {
1353 inR = remote->incidence( uid ); 1355 inR = remote->incidence( uid );
1354 if ( ! inR ) { 1356 if ( ! inR ) {
1355 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1357 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1356 // no conflict ********** add or delete local 1358 // no conflict ********** add or delete local
1357 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1359 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1358 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1360 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1359 checkExternSyncEvent(eventLSyncSharp, inL); 1361 checkExternSyncEvent(eventLSyncSharp, inL);
1360 local->deleteIncidence( inL ); 1362 local->deleteIncidence( inL );
1361 ++deletedEventL; 1363 ++deletedEventL;
1362 } else { 1364 } else {
1363 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1365 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1364 inL->removeID(mCurrentSyncDevice ); 1366 inL->removeID(mCurrentSyncDevice );
1365 ++addedEventR; 1367 ++addedEventR;
1366 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1368 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1367 inL->setLastModified( modifiedCalendar ); 1369 inL->setLastModified( modifiedCalendar );
1368 inR = inL->clone(); 1370 inR = inL->clone();
1369 inR->setIDStr( ":" ); 1371 inR->setIDStr( ":" );
1370 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1372 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1371 remote->addIncidence( inR ); 1373 remote->addIncidence( inR );
1372 } 1374 }
1373 } 1375 }
1374 } else { 1376 } else {
1375 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1377 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1376 checkExternSyncEvent(eventLSyncSharp, inL); 1378 checkExternSyncEvent(eventLSyncSharp, inL);
1377 local->deleteIncidence( inL ); 1379 local->deleteIncidence( inL );
1378 ++deletedEventL; 1380 ++deletedEventL;
1379 } else { 1381 } else {
1380 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1382 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1381 ++addedEventR; 1383 ++addedEventR;
1382 inL->setLastModified( modifiedCalendar ); 1384 inL->setLastModified( modifiedCalendar );
1383 inR = inL->clone(); 1385 inR = inL->clone();
1384 inR->setIDStr( ":" ); 1386 inR->setIDStr( ":" );
1385 remote->addIncidence( inR ); 1387 remote->addIncidence( inR );
1386 } 1388 }
1387 } 1389 }
1388 } 1390 }
1389 } else { 1391 } else {
1390 ++filteredOUT; 1392 ++filteredOUT;
1391 } 1393 }
1392 } 1394 }
1393 } 1395 }
1394 inL = el.next(); 1396 inL = el.next();
1395 } 1397 }
1396 int delFut = 0; 1398 int delFut = 0;
1397 int remRem = 0; 1399 int remRem = 0;
1398 if ( mSyncManager->mWriteBackInFuture ) { 1400 if ( mSyncManager->mWriteBackInFuture ) {
1399 er = remote->rawIncidences(); 1401 er = remote->rawIncidences();
1400 remRem = er.count(); 1402 remRem = er.count();
1401 inR = er.first(); 1403 inR = er.first();
1402 QDateTime dt; 1404 QDateTime dt;
1403 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1405 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1404 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1406 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1405 while ( inR ) { 1407 while ( inR ) {
1406 if ( inR->typeID() == todoID ) { 1408 if ( inR->typeID() == todoID ) {
1407 Todo * t = (Todo*)inR; 1409 Todo * t = (Todo*)inR;
1408 if ( t->hasDueDate() ) 1410 if ( t->hasDueDate() )
1409 dt = t->dtDue(); 1411 dt = t->dtDue();
1410 else 1412 else
1411 dt = cur.addSecs( 62 ); 1413 dt = cur.addSecs( 62 );
1412 } 1414 }
1413 else if (inR->typeID() == eventID ) { 1415 else if (inR->typeID() == eventID ) {
1414 bool ok; 1416 bool ok;
1415 dt = inR->getNextOccurence( cur, &ok ); 1417 dt = inR->getNextOccurence( cur, &ok );
1416 if ( !ok ) 1418 if ( !ok )
1417 dt = cur.addSecs( -62 ); 1419 dt = cur.addSecs( -62 );
1418 } 1420 }
1419 else 1421 else
1420 dt = inR->dtStart(); 1422 dt = inR->dtStart();
1421 if ( dt < cur || dt > end ) { 1423 if ( dt < cur || dt > end ) {
1422 remote->deleteIncidence( inR ); 1424 remote->deleteIncidence( inR );
1423 ++delFut; 1425 ++delFut;
1424 } 1426 }
1425 inR = er.next(); 1427 inR = er.next();
1426 } 1428 }
1427 } 1429 }
1428 bar.hide(); 1430 bar.hide();
1429 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1431 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1430 eventLSync->setReadOnly( false ); 1432 eventLSync->setReadOnly( false );
1431 eventLSync->setDtStart( mLastCalendarSync ); 1433 eventLSync->setDtStart( mLastCalendarSync );
1432 eventRSync->setDtStart( mLastCalendarSync ); 1434 eventRSync->setDtStart( mLastCalendarSync );
1433 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1435 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1434 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1436 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1435 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1437 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1436 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1438 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1437 eventLSync->setReadOnly( true ); 1439 eventLSync->setReadOnly( true );
1438 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1440 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1439 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1441 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1440 remote->addEvent( eventRSync ); 1442 remote->addEvent( eventRSync );
1441 else 1443 else
1442 delete eventRSync; 1444 delete eventRSync;
1443 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1445 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1444 QString mes; 1446 QString mes;
1445 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 ); 1447 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1446 QString delmess; 1448 QString delmess;
1447 if ( delFut ) { 1449 if ( delFut ) {
1448 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); 1450 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1449 mes += delmess; 1451 mes += delmess;
1450 } 1452 }
1451 mes = i18n("Local calendar changed!\n") +mes; 1453 mes = i18n("Local calendar changed!\n") +mes;
1452 mCalendar->checkAlarmForIncidence( 0, true ); 1454 mCalendar->checkAlarmForIncidence( 0, true );
1453 qDebug( mes ); 1455 qDebug( mes );
1454 if ( mSyncManager->mShowSyncSummary ) { 1456 if ( mSyncManager->mShowSyncSummary ) {
1455 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1457 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1456 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1458 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1457 qDebug("KO: WB cancelled "); 1459 qDebug("KO: WB cancelled ");
1458 mSyncManager->mWriteBackFile = false; 1460 mSyncManager->mWriteBackFile = false;
1459 return syncOK; 1461 return syncOK;
1460 } 1462 }
1461 } 1463 }
1462 return syncOK; 1464 return syncOK;
1463} 1465}
1464 1466
1465void CalendarView::setSyncDevice( QString s ) 1467void CalendarView::setSyncDevice( QString s )
1466{ 1468{
1467 mCurrentSyncDevice= s; 1469 mCurrentSyncDevice= s;
1468} 1470}
1469void CalendarView::setSyncName( QString s ) 1471void CalendarView::setSyncName( QString s )
1470{ 1472{
1471 mCurrentSyncName= s; 1473 mCurrentSyncName= s;
1472} 1474}
1473bool CalendarView::syncCalendar(QString filename, int mode) 1475bool CalendarView::syncCalendar(QString filename, int mode)
1474{ 1476{
1475 //qDebug("syncCalendar %s ", filename.latin1()); 1477 //qDebug("syncCalendar %s ", filename.latin1());
1476 mGlobalSyncMode = SYNC_MODE_NORMAL; 1478 mGlobalSyncMode = SYNC_MODE_NORMAL;
1477 CalendarLocal* calendar = new CalendarLocal(); 1479 CalendarLocal* calendar = new CalendarLocal();
1478 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1480 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1479 FileStorage* storage = new FileStorage( calendar ); 1481 FileStorage* storage = new FileStorage( calendar );
1480 bool syncOK = false; 1482 bool syncOK = false;
1481 storage->setFileName( filename ); 1483 storage->setFileName( filename );
1482 // qDebug("loading ... "); 1484 // qDebug("loading ... ");
1483 if ( storage->load() ) { 1485 if ( storage->load() ) {
1484 getEventViewerDialog()->setSyncMode( true ); 1486 getEventViewerDialog()->setSyncMode( true );
1485 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1487 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1486 getEventViewerDialog()->setSyncMode( false ); 1488 getEventViewerDialog()->setSyncMode( false );
1487 if ( syncOK ) { 1489 if ( syncOK ) {
1488 if ( mSyncManager->mWriteBackFile ) 1490 if ( mSyncManager->mWriteBackFile )
1489 { 1491 {
1490 storage->setSaveFormat( new ICalFormat() ); 1492 storage->setSaveFormat( new ICalFormat() );
1491 storage->save(); 1493 storage->save();
1492 } 1494 }
1493 } 1495 }
1494 setModified( true ); 1496 setModified( true );
1495 } 1497 }
1496 delete storage; 1498 delete storage;
1497 delete calendar; 1499 delete calendar;
1498 if ( syncOK ) 1500 if ( syncOK )
1499 updateView(); 1501 updateView();
1500 return syncOK; 1502 return syncOK;
1501} 1503}
1502 1504
1503void CalendarView::syncExternal( int mode ) 1505void CalendarView::syncExternal( int mode )
1504{ 1506{
1505 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1507 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1506 1508
1507 qApp->processEvents(); 1509 qApp->processEvents();
1508 CalendarLocal* calendar = new CalendarLocal(); 1510 CalendarLocal* calendar = new CalendarLocal();
1509 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1511 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1510 bool syncOK = false; 1512 bool syncOK = false;
1511 bool loadSuccess = false; 1513 bool loadSuccess = false;
1512 PhoneFormat* phoneFormat = 0; 1514 PhoneFormat* phoneFormat = 0;
1513 emit tempDisableBR(true); 1515 emit tempDisableBR(true);
1514#ifndef DESKTOP_VERSION 1516#ifndef DESKTOP_VERSION
1515 SharpFormat* sharpFormat = 0; 1517 SharpFormat* sharpFormat = 0;
1516 if ( mode == 0 ) { // sharp 1518 if ( mode == 0 ) { // sharp
1517 sharpFormat = new SharpFormat () ; 1519 sharpFormat = new SharpFormat () ;
1518 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1520 loadSuccess = sharpFormat->load( calendar, mCalendar );
1519 1521
1520 } else 1522 } else
1521#endif 1523#endif
1522 if ( mode == 1 ) { // phone 1524 if ( mode == 1 ) { // phone
1523 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1525 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1524 mSyncManager->mPhoneDevice, 1526 mSyncManager->mPhoneDevice,
1525 mSyncManager->mPhoneConnection, 1527 mSyncManager->mPhoneConnection,
1526 mSyncManager->mPhoneModel); 1528 mSyncManager->mPhoneModel);
1527 loadSuccess = phoneFormat->load( calendar,mCalendar); 1529 loadSuccess = phoneFormat->load( calendar,mCalendar);
1528 1530
1529 } else { 1531 } else {
1530 emit tempDisableBR(false); 1532 emit tempDisableBR(false);
1531 return; 1533 return;
1532 } 1534 }
1533 if ( loadSuccess ) { 1535 if ( loadSuccess ) {
1534 getEventViewerDialog()->setSyncMode( true ); 1536 getEventViewerDialog()->setSyncMode( true );
1535 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1537 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1536 getEventViewerDialog()->setSyncMode( false ); 1538 getEventViewerDialog()->setSyncMode( false );
1537 qApp->processEvents(); 1539 qApp->processEvents();
1538 if ( syncOK ) { 1540 if ( syncOK ) {
1539 if ( mSyncManager->mWriteBackFile ) 1541 if ( mSyncManager->mWriteBackFile )
1540 { 1542 {
1541 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1543 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1542 Incidence* inc = iL.first(); 1544 Incidence* inc = iL.first();
1543 if ( phoneFormat ) { 1545 if ( phoneFormat ) {
1544 while ( inc ) { 1546 while ( inc ) {
1545 inc->removeID(mCurrentSyncDevice); 1547 inc->removeID(mCurrentSyncDevice);
1546 inc = iL.next(); 1548 inc = iL.next();
1547 } 1549 }
1548 } 1550 }
1549#ifndef DESKTOP_VERSION 1551#ifndef DESKTOP_VERSION
1550 if ( sharpFormat ) 1552 if ( sharpFormat )
1551 sharpFormat->save(calendar); 1553 sharpFormat->save(calendar);
1552#endif 1554#endif
1553 if ( phoneFormat ) 1555 if ( phoneFormat )
1554 phoneFormat->save(calendar); 1556 phoneFormat->save(calendar);
1555 iL = calendar->rawIncidences(); 1557 iL = calendar->rawIncidences();
1556 inc = iL.first(); 1558 inc = iL.first();
1557 Incidence* loc; 1559 Incidence* loc;
1558 while ( inc ) { 1560 while ( inc ) {
1559 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1561 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1560 loc = mCalendar->incidence(inc->uid() ); 1562 loc = mCalendar->incidence(inc->uid() );
1561 if ( loc ) { 1563 if ( loc ) {
1562 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1564 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1563 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1565 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1564 } 1566 }
1565 } 1567 }
1566 inc = iL.next(); 1568 inc = iL.next();
1567 } 1569 }
1568 Incidence* lse = getLastSyncEvent(); 1570 Incidence* lse = getLastSyncEvent();
1569 if ( lse ) { 1571 if ( lse ) {
1570 lse->setReadOnly( false ); 1572 lse->setReadOnly( false );
1571 lse->setDescription( "" ); 1573 lse->setDescription( "" );
1572 lse->setReadOnly( true ); 1574 lse->setReadOnly( true );
1573 } 1575 }
1574 } 1576 }
1575 } else { 1577 } else {
1576 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1578 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1577 } 1579 }
1578 setModified( true ); 1580 setModified( true );
1579 } else { 1581 } else {
1580 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1582 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1581 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1583 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1582 question, i18n("Ok")) ; 1584 question, i18n("Ok")) ;
1583 1585
1584 } 1586 }
1585 delete calendar; 1587 delete calendar;
1586 updateView(); 1588 updateView();
1587 emit tempDisableBR(false); 1589 emit tempDisableBR(false);
1588 return ;//syncOK; 1590 return ;//syncOK;
1589 1591
1590} 1592}
1591 1593
1592bool CalendarView::importBday() 1594bool CalendarView::importBday()
1593{ 1595{
1594#ifndef KORG_NOKABC 1596#ifndef KORG_NOKABC
1595 1597
1596#ifdef DESKTOP_VERSION 1598#ifdef DESKTOP_VERSION
1597 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1599 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1598 KABC::AddressBook::Iterator it; 1600 KABC::AddressBook::Iterator it;
1599 int count = 0; 1601 int count = 0;
1600 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1602 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1601 ++count; 1603 ++count;
1602 } 1604 }
1603 QProgressBar bar(count,0 ); 1605 QProgressBar bar(count,0 );
1604 int w = 300; 1606 int w = 300;
1605 if ( QApplication::desktop()->width() < 320 ) 1607 if ( QApplication::desktop()->width() < 320 )
1606 w = 220; 1608 w = 220;
1607 int h = bar.sizeHint().height() ; 1609 int h = bar.sizeHint().height() ;
1608 int dw = QApplication::desktop()->width(); 1610 int dw = QApplication::desktop()->width();
1609 int dh = QApplication::desktop()->height(); 1611 int dh = QApplication::desktop()->height();
1610 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1612 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1611 bar.show(); 1613 bar.show();
1612 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1614 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1613 qApp->processEvents(); 1615 qApp->processEvents();
1614 count = 0; 1616 count = 0;
1615 int addCount = 0; 1617 int addCount = 0;
1616 KCal::Attendee* a = 0; 1618 KCal::Attendee* a = 0;
1617 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1619 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1618 if ( ! bar.isVisible() ) 1620 if ( ! bar.isVisible() )
1619 return false; 1621 return false;
1620 bar.setProgress( count++ ); 1622 bar.setProgress( count++ );
1621 qApp->processEvents(); 1623 qApp->processEvents();
1622 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1624 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1623 if ( (*it).birthday().date().isValid() ){ 1625 if ( (*it).birthday().date().isValid() ){
1624 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1626 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1625 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1627 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1626 ++addCount; 1628 ++addCount;
1627 } 1629 }
1628 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1630 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1629 if ( anni.isValid() ){ 1631 if ( anni.isValid() ){
1630 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1632 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1631 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1633 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1632 ++addCount; 1634 ++addCount;
1633 } 1635 }
1634 } 1636 }
1635 updateView(); 1637 updateView();
1636 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1638 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1637#else //DESKTOP_VERSION 1639#else //DESKTOP_VERSION
1638 1640
1639 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1641 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1640 // the result should now arrive through method insertBirthdays 1642 // the result should now arrive through method insertBirthdays
1641 1643
1642#endif //DESKTOP_VERSION 1644#endif //DESKTOP_VERSION
1643 1645
1644#endif //KORG_NOKABC 1646#endif //KORG_NOKABC
1645 1647
1646 1648
1647 return true; 1649 return true;
1648} 1650}
1649 1651
1650// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1652// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1651void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1653void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1652 const QStringList& anniversaryList, const QStringList& realNameList, 1654 const QStringList& anniversaryList, const QStringList& realNameList,
1653 const QStringList& emailList, const QStringList& assembledNameList, 1655 const QStringList& emailList, const QStringList& assembledNameList,
1654 const QStringList& uidList) 1656 const QStringList& uidList)
1655{ 1657{
1656 //qDebug("KO::CalendarView::insertBirthdays"); 1658 //qDebug("KO::CalendarView::insertBirthdays");
1657 if (uid == this->name()) 1659 if (uid == this->name())
1658 { 1660 {
1659 int count = birthdayList.count(); 1661 int count = birthdayList.count();
1660 int addCount = 0; 1662 int addCount = 0;
1661 KCal::Attendee* a = 0; 1663 KCal::Attendee* a = 0;
1662 1664
1663 //qDebug("CalView 1 %i", count); 1665 //qDebug("CalView 1 %i", count);
1664 1666
1665 QProgressBar bar(count,0 ); 1667 QProgressBar bar(count,0 );
1666 int w = 300; 1668 int w = 300;
1667 if ( QApplication::desktop()->width() < 320 ) 1669 if ( QApplication::desktop()->width() < 320 )
1668 w = 220; 1670 w = 220;
1669 int h = bar.sizeHint().height() ; 1671 int h = bar.sizeHint().height() ;
1670 int dw = QApplication::desktop()->width(); 1672 int dw = QApplication::desktop()->width();
1671 int dh = QApplication::desktop()->height(); 1673 int dh = QApplication::desktop()->height();
1672 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1674 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1673 bar.show(); 1675 bar.show();
1674 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1676 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1675 qApp->processEvents(); 1677 qApp->processEvents();
1676 1678
1677 QDate birthday; 1679 QDate birthday;
1678 QDate anniversary; 1680 QDate anniversary;
1679 QString realName; 1681 QString realName;
1680 QString email; 1682 QString email;
1681 QString assembledName; 1683 QString assembledName;
1682 QString uid; 1684 QString uid;
1683 bool ok = true; 1685 bool ok = true;
1684 for ( int i = 0; i < count; i++) 1686 for ( int i = 0; i < count; i++)
1685 { 1687 {
1686 if ( ! bar.isVisible() ) 1688 if ( ! bar.isVisible() )
1687 return; 1689 return;
1688 bar.setProgress( i ); 1690 bar.setProgress( i );
1689 qApp->processEvents(); 1691 qApp->processEvents();
1690 1692
1691 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1693 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1692 if (!ok) { 1694 if (!ok) {
1693 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1695 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1694 } 1696 }
1695 1697
1696 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1698 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1697 if (!ok) { 1699 if (!ok) {
1698 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1700 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1699 } 1701 }
1700 realName = realNameList[i]; 1702 realName = realNameList[i];
1701 email = emailList[i]; 1703 email = emailList[i];
1702 assembledName = assembledNameList[i]; 1704 assembledName = assembledNameList[i];
1703 uid = uidList[i]; 1705 uid = uidList[i];
1704 //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() ); 1706 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1705 1707
1706 if ( birthday.isValid() ){ 1708 if ( birthday.isValid() ){
1707 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1709 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1708 KCal::Attendee::ReqParticipant,uid) ; 1710 KCal::Attendee::ReqParticipant,uid) ;
1709 if ( addAnniversary( birthday, assembledName, a, true ) ) 1711 if ( addAnniversary( birthday, assembledName, a, true ) )
1710 ++addCount; 1712 ++addCount;
1711 } 1713 }
1712 1714
1713 if ( anniversary.isValid() ){ 1715 if ( anniversary.isValid() ){
1714 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1716 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1715 KCal::Attendee::ReqParticipant,uid) ; 1717 KCal::Attendee::ReqParticipant,uid) ;
1716 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1718 if ( addAnniversary( anniversary, assembledName, a, false ) )
1717 ++addCount; 1719 ++addCount;
1718 } 1720 }
1719 } 1721 }
1720 1722
1721 updateView(); 1723 updateView();
1722 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1724 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1723 1725
1724 } 1726 }
1725 1727
1726} 1728}
1727 1729
1728 1730
1729 1731
1730bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1732bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1731{ 1733{
1732 //qDebug("addAnni "); 1734 //qDebug("addAnni ");
1733 Event * ev = new Event(); 1735 Event * ev = new Event();
1734 ev->setOrganizer(KOPrefs::instance()->email()); 1736 ev->setOrganizer(KOPrefs::instance()->email());
1735 if ( a ) { 1737 if ( a ) {
1736 ev->addAttendee( a ); 1738 ev->addAttendee( a );
1737 } 1739 }
1738 QString kind; 1740 QString kind;
1739 if ( birthday ) { 1741 if ( birthday ) {
1740 kind = i18n( "Birthday" ); 1742 kind = i18n( "Birthday" );
1741 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1743 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1742 } 1744 }
1743 else { 1745 else {
1744 kind = i18n( "Anniversary" ); 1746 kind = i18n( "Anniversary" );
1745 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1747 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1746 } 1748 }
1747 ev->setCategories( kind ); 1749 ev->setCategories( kind );
1748 ev->setDtStart( QDateTime(date) ); 1750 ev->setDtStart( QDateTime(date) );
1749 ev->setDtEnd( QDateTime(date) ); 1751 ev->setDtEnd( QDateTime(date) );
1750 ev->setFloats( true ); 1752 ev->setFloats( true );
1751 Recurrence * rec = ev->recurrence(); 1753 Recurrence * rec = ev->recurrence();
1752 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1754 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1753 rec->addYearlyNum( date.month() ); 1755 rec->addYearlyNum( date.month() );
1754 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1756 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1755 delete ev; 1757 delete ev;
1756 return false; 1758 return false;
1757 } 1759 }
1758 return true; 1760 return true;
1759 1761
1760} 1762}
1761bool CalendarView::importQtopia( const QString &categories, 1763bool CalendarView::importQtopia( const QString &categories,
1762 const QString &datebook, 1764 const QString &datebook,
1763 const QString &todolist ) 1765 const QString &todolist )
1764{ 1766{
1765 1767
1766 QtopiaFormat qtopiaFormat; 1768 QtopiaFormat qtopiaFormat;
1767 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1769 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1768 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1770 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1769 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1771 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1770 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1772 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1771 1773
1772 updateView(); 1774 updateView();
1773 return true; 1775 return true;
1774 1776
1775#if 0 1777#if 0
1776 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1778 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1777 mCurrentSyncDevice = "qtopia-XML"; 1779 mCurrentSyncDevice = "qtopia-XML";
1778 if ( mSyncManager->mAskForPreferences ) 1780 if ( mSyncManager->mAskForPreferences )
1779 edit_sync_options(); 1781 edit_sync_options();
1780 qApp->processEvents(); 1782 qApp->processEvents();
1781 CalendarLocal* calendar = new CalendarLocal(); 1783 CalendarLocal* calendar = new CalendarLocal();
1782 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1784 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1783 bool syncOK = false; 1785 bool syncOK = false;
1784 QtopiaFormat qtopiaFormat; 1786 QtopiaFormat qtopiaFormat;
1785 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1787 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1786 bool loadOk = true; 1788 bool loadOk = true;
1787 if ( !categories.isEmpty() ) 1789 if ( !categories.isEmpty() )
1788 loadOk = qtopiaFormat.load( calendar, categories ); 1790 loadOk = qtopiaFormat.load( calendar, categories );
1789 if ( loadOk && !datebook.isEmpty() ) 1791 if ( loadOk && !datebook.isEmpty() )
1790 loadOk = qtopiaFormat.load( calendar, datebook ); 1792 loadOk = qtopiaFormat.load( calendar, datebook );
1791 if ( loadOk && !todolist.isEmpty() ) 1793 if ( loadOk && !todolist.isEmpty() )
1792 loadOk = qtopiaFormat.load( calendar, todolist ); 1794 loadOk = qtopiaFormat.load( calendar, todolist );
1793 1795
1794 if ( loadOk ) { 1796 if ( loadOk ) {
1795 getEventViewerDialog()->setSyncMode( true ); 1797 getEventViewerDialog()->setSyncMode( true );
1796 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1798 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1797 getEventViewerDialog()->setSyncMode( false ); 1799 getEventViewerDialog()->setSyncMode( false );
1798 qApp->processEvents(); 1800 qApp->processEvents();
1799 if ( syncOK ) { 1801 if ( syncOK ) {
1800 if ( mSyncManager->mWriteBackFile ) 1802 if ( mSyncManager->mWriteBackFile )
1801 { 1803 {
1802 // write back XML file 1804 // write back XML file
1803 1805
1804 } 1806 }
1805 setModified( true ); 1807 setModified( true );
1806 } 1808 }
1807 } else { 1809 } else {
1808 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1810 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1809 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1811 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1810 question, i18n("Ok")) ; 1812 question, i18n("Ok")) ;
1811 } 1813 }
1812 delete calendar; 1814 delete calendar;
1813 updateView(); 1815 updateView();
1814 return syncOK; 1816 return syncOK;
1815 1817
1816 1818
1817#endif 1819#endif
1818 1820
1819} 1821}
1820 1822
1821void CalendarView::setSyncEventsReadOnly() 1823void CalendarView::setSyncEventsReadOnly()
1822{ 1824{
1823 Event * ev; 1825 Event * ev;
1824 QPtrList<Event> eL = mCalendar->rawEvents(); 1826 QPtrList<Event> eL = mCalendar->rawEvents();
1825 ev = eL.first(); 1827 ev = eL.first();
1826 while ( ev ) { 1828 while ( ev ) {
1827 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1829 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1828 ev->setReadOnly( true ); 1830 ev->setReadOnly( true );
1829 ev = eL.next(); 1831 ev = eL.next();
1830 } 1832 }
1831} 1833}
1832bool CalendarView::openCalendar(QString filename, bool merge) 1834bool CalendarView::openCalendar(QString filename, bool merge)
1833{ 1835{
1834 1836
1835 if (filename.isEmpty()) { 1837 if (filename.isEmpty()) {
1836 return false; 1838 return false;
1837 } 1839 }
1838 1840
1839 if (!QFile::exists(filename)) { 1841 if (!QFile::exists(filename)) {
1840 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1842 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1841 return false; 1843 return false;
1842 } 1844 }
1843 1845
1844 globalFlagBlockAgenda = 1; 1846 globalFlagBlockAgenda = 1;
1845 clearAllViews(); 1847 clearAllViews();
1846 if (!merge) { 1848 if (!merge) {
1847 mViewManager->setDocumentId( filename ); 1849 mViewManager->setDocumentId( filename );
1848 mCalendar->close(); 1850 mCalendar->close();
1849 } 1851 }
1850 mStorage->setFileName( filename ); 1852 mStorage->setFileName( filename );
1851 1853
1852 if ( mStorage->load() ) { 1854 if ( mStorage->load() ) {
1853 if ( merge ) ;//setModified( true ); 1855 if ( merge ) ;//setModified( true );
1854 else { 1856 else {
1855 //setModified( true ); 1857 //setModified( true );
1856 mViewManager->setDocumentId( filename ); 1858 mViewManager->setDocumentId( filename );
1857 mDialogManager->setDocumentId( filename ); 1859 mDialogManager->setDocumentId( filename );
1858 mTodoList->setDocumentId( filename ); 1860 mTodoList->setDocumentId( filename );
1859 } 1861 }
1860 globalFlagBlockAgenda = 2; 1862 globalFlagBlockAgenda = 2;
1861 // if ( getLastSyncEvent() ) 1863 // if ( getLastSyncEvent() )
1862 // getLastSyncEvent()->setReadOnly( true ); 1864 // getLastSyncEvent()->setReadOnly( true );
1863 mCalendar->reInitAlarmSettings(); 1865 mCalendar->reInitAlarmSettings();
1864 setSyncEventsReadOnly(); 1866 setSyncEventsReadOnly();
1865 updateUnmanagedViews(); 1867 updateUnmanagedViews();
1866 updateView(); 1868 updateView();
1867 if ( filename != MainWindow::defaultFileName() ) { 1869 if ( filename != MainWindow::defaultFileName() ) {
1868 saveCalendar( MainWindow::defaultFileName() ); 1870 saveCalendar( MainWindow::defaultFileName() );
1869 } else { 1871 } else {
1870 QFileInfo finf ( MainWindow::defaultFileName()); 1872 QFileInfo finf ( MainWindow::defaultFileName());
1871 if ( finf.exists() ) { 1873 if ( finf.exists() ) {
1872 setLoadedFileVersion( finf.lastModified () ); 1874 setLoadedFileVersion( finf.lastModified () );
1873 } 1875 }
1874 } 1876 }
1875 return true; 1877 return true;
1876 } else { 1878 } else {
1877 // while failing to load, the calendar object could 1879 // while failing to load, the calendar object could
1878 // have become partially populated. Clear it out. 1880 // have become partially populated. Clear it out.
1879 if ( !merge ) { 1881 if ( !merge ) {
1880 mCalendar->close(); 1882 mCalendar->close();
1881 mViewManager->setDocumentId( filename ); 1883 mViewManager->setDocumentId( filename );
1882 mDialogManager->setDocumentId( filename ); 1884 mDialogManager->setDocumentId( filename );
1883 mTodoList->setDocumentId( filename ); 1885 mTodoList->setDocumentId( filename );
1884 } 1886 }
1885 1887
1886 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1888 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1887 1889
1888 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1890 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1889 globalFlagBlockAgenda = 2; 1891 globalFlagBlockAgenda = 2;
1890 mCalendar->reInitAlarmSettings(); 1892 mCalendar->reInitAlarmSettings();
1891 setSyncEventsReadOnly(); 1893 setSyncEventsReadOnly();
1892 updateUnmanagedViews(); 1894 updateUnmanagedViews();
1893 updateView(); 1895 updateView();
1894 } 1896 }
1895 return false; 1897 return false;
1896} 1898}
1897void CalendarView::showOpenError() 1899void CalendarView::showOpenError()
1898{ 1900{
1899 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1901 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1900} 1902}
1901void CalendarView::setLoadedFileVersion(QDateTime dt) 1903void CalendarView::setLoadedFileVersion(QDateTime dt)
1902{ 1904{
1903 loadedFileVersion = dt; 1905 loadedFileVersion = dt;
1904} 1906}
1905bool CalendarView::checkFileChanged(QString fn) 1907bool CalendarView::checkFileChanged(QString fn)
1906{ 1908{
1907 QFileInfo finf ( fn ); 1909 QFileInfo finf ( fn );
1908 if ( !finf.exists() ) 1910 if ( !finf.exists() )
1909 return true; 1911 return true;
1910 QDateTime dt = finf.lastModified (); 1912 QDateTime dt = finf.lastModified ();
1911 if ( dt <= loadedFileVersion ) 1913 if ( dt <= loadedFileVersion )
1912 return false; 1914 return false;
1913 return true; 1915 return true;
1914 1916
1915} 1917}
1916void CalendarView::watchSavedFile() 1918void CalendarView::watchSavedFile()
1917{ 1919{
1918 QFileInfo finf ( MainWindow::defaultFileName()); 1920 QFileInfo finf ( MainWindow::defaultFileName());
1919 if ( !finf.exists() ) 1921 if ( !finf.exists() )
1920 return; 1922 return;
1921 QDateTime dt = finf.lastModified (); 1923 QDateTime dt = finf.lastModified ();
1922 if ( dt < loadedFileVersion ) { 1924 if ( dt < loadedFileVersion ) {
1923 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1925 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1924 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1926 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1925 return; 1927 return;
1926 } 1928 }
1927 loadedFileVersion = dt; 1929 loadedFileVersion = dt;
1928} 1930}
1929 1931
1930bool CalendarView::checkFileVersion(QString fn) 1932bool CalendarView::checkFileVersion(QString fn)
1931{ 1933{
1932 QFileInfo finf ( fn ); 1934 QFileInfo finf ( fn );
1933 if ( !finf.exists() ) 1935 if ( !finf.exists() )
1934 return true; 1936 return true;
1935 QDateTime dt = finf.lastModified (); 1937 QDateTime dt = finf.lastModified ();
1936 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1938 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1937 //qDebug("file on disk version %s",dt.toString().latin1()); 1939 //qDebug("file on disk version %s",dt.toString().latin1());
1938 if ( dt <= loadedFileVersion ) 1940 if ( dt <= loadedFileVersion )
1939 return true; 1941 return true;
1940 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1942 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1941 i18n("KO/Pi Warning"),i18n("Overwrite"), 1943 i18n("KO/Pi Warning"),i18n("Overwrite"),
1942 i18n("Sync+save")); 1944 i18n("Sync+save"));
1943 1945
1944 if ( km == KMessageBox::Cancel ) 1946 if ( km == KMessageBox::Cancel )
1945 return false; 1947 return false;
1946 if ( km == KMessageBox::Yes ) 1948 if ( km == KMessageBox::Yes )
1947 return true; 1949 return true;
1948 1950
1949 setSyncDevice("deleteaftersync" ); 1951 setSyncDevice("deleteaftersync" );
1950 mSyncManager->mAskForPreferences = true; 1952 mSyncManager->mAskForPreferences = true;
1951 mSyncManager->mSyncAlgoPrefs = 3; 1953 mSyncManager->mSyncAlgoPrefs = 3;
1952 mSyncManager->mWriteBackFile = false; 1954 mSyncManager->mWriteBackFile = false;
1953 mSyncManager->mWriteBackExistingOnly = false; 1955 mSyncManager->mWriteBackExistingOnly = false;
1954 mSyncManager->mShowSyncSummary = false; 1956 mSyncManager->mShowSyncSummary = false;
1955 syncCalendar( fn, 3 ); 1957 syncCalendar( fn, 3 );
1956 Event * e = getLastSyncEvent(); 1958 Event * e = getLastSyncEvent();
1957 if ( e ) 1959 if ( e )
1958 deleteEvent ( e ); 1960 deleteEvent ( e );
1959 updateView(); 1961 updateView();
1960 return true; 1962 return true;
1961} 1963}
1962 1964
1963bool CalendarView::saveCalendar( QString filename ) 1965bool CalendarView::saveCalendar( QString filename )
1964{ 1966{
1965 1967
1966 // Store back all unsaved data into calendar object 1968 // Store back all unsaved data into calendar object
1967 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1969 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1968 if ( mViewManager->currentView() ) 1970 if ( mViewManager->currentView() )
1969 mViewManager->currentView()->flushView(); 1971 mViewManager->currentView()->flushView();
1970 1972
1971 1973
1972 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1974 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1973 mStorage->setSaveFormat( new ICalFormat() ); 1975 mStorage->setSaveFormat( new ICalFormat() );
1974 mStorage->setFileName( filename ); 1976 mStorage->setFileName( filename );
1975 bool success; 1977 bool success;
1976 success = mStorage->save(); 1978 success = mStorage->save();
1977 if ( !success ) { 1979 if ( !success ) {
1978 return false; 1980 return false;
1979 } 1981 }
1980 if ( filename == MainWindow::defaultFileName() ) { 1982 if ( filename == MainWindow::defaultFileName() ) {
1981 setLoadedFileVersion( lfv ); 1983 setLoadedFileVersion( lfv );
1982 watchSavedFile(); 1984 watchSavedFile();
1983 } 1985 }
1984 return true; 1986 return true;
1985} 1987}
1986 1988
1987void CalendarView::closeCalendar() 1989void CalendarView::closeCalendar()
1988{ 1990{
1989 1991
1990 // child windows no longer valid 1992 // child windows no longer valid
1991 clearAllViews(); 1993 clearAllViews();
1992 emit closingDown(); 1994 emit closingDown();
1993 1995
1994 mCalendar->close(); 1996 mCalendar->close();
1995 setModified(false); 1997 setModified(false);
1996 updateView(); 1998 updateView();
1997} 1999}
1998 2000
1999void CalendarView::archiveCalendar() 2001void CalendarView::archiveCalendar()
2000{ 2002{
2001 mDialogManager->showArchiveDialog(); 2003 mDialogManager->showArchiveDialog();
2002} 2004}
2003 2005
2004 2006
2005void CalendarView::readSettings() 2007void CalendarView::readSettings()
2006{ 2008{
2007 2009
2008 2010
2009 // mViewManager->showAgendaView(); 2011 // mViewManager->showAgendaView();
2010 QString str; 2012 QString str;
2011 //qDebug("CalendarView::readSettings() "); 2013 //qDebug("CalendarView::readSettings() ");
2012 // read settings from the KConfig, supplying reasonable 2014 // read settings from the KConfig, supplying reasonable
2013 // defaults where none are to be found 2015 // defaults where none are to be found
2014 KConfig *config = KOGlobals::config(); 2016 KConfig *config = KOGlobals::config();
2015#ifndef KORG_NOSPLITTER 2017#ifndef KORG_NOSPLITTER
2016 config->setGroup("KOrganizer Geometry"); 2018 config->setGroup("KOrganizer Geometry");
2017 2019
2018 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2020 QValueList<int> sizes = config->readIntListEntry("Separator1");
2019 if (sizes.count() != 2) { 2021 if (sizes.count() != 2) {
2020 sizes << mDateNavigator->minimumSizeHint().width(); 2022 sizes << mDateNavigator->minimumSizeHint().width();
2021 sizes << 300; 2023 sizes << 300;
2022 } 2024 }
2023 mPanner->setSizes(sizes); 2025 mPanner->setSizes(sizes);
2024 2026
2025 sizes = config->readIntListEntry("Separator2"); 2027 sizes = config->readIntListEntry("Separator2");
2026 if ( ( mResourceView && sizes.count() == 4 ) || 2028 if ( ( mResourceView && sizes.count() == 4 ) ||
2027 ( !mResourceView && sizes.count() == 3 ) ) { 2029 ( !mResourceView && sizes.count() == 3 ) ) {
2028 mLeftSplitter->setSizes(sizes); 2030 mLeftSplitter->setSizes(sizes);
2029 } 2031 }
2030#endif 2032#endif
2031 globalFlagBlockAgenda = 1; 2033 globalFlagBlockAgenda = 1;
2032 mViewManager->showAgendaView(); 2034 mViewManager->showAgendaView();
2033 //mViewManager->readSettings( config ); 2035 //mViewManager->readSettings( config );
2034 mTodoList->restoreLayout(config,QString("Todo Layout")); 2036 mTodoList->restoreLayout(config,QString("Todo Layout"));
2035 readFilterSettings(config); 2037 readFilterSettings(config);
2036 2038
2037#ifdef DESKTOP_VERSION 2039#ifdef DESKTOP_VERSION
2038 config->setGroup("WidgetLayout"); 2040 config->setGroup("WidgetLayout");
2039 QStringList list; 2041 QStringList list;
2040 list = config->readListEntry("MainLayout"); 2042 list = config->readListEntry("MainLayout");
2041 int x,y,w,h; 2043 int x,y,w,h;
2042 if ( ! list.isEmpty() ) { 2044 if ( ! list.isEmpty() ) {
2043 x = list[0].toInt(); 2045 x = list[0].toInt();
2044 y = list[1].toInt(); 2046 y = list[1].toInt();
2045 w = list[2].toInt(); 2047 w = list[2].toInt();
2046 h = list[3].toInt(); 2048 h = list[3].toInt();
2047 KApplication::testCoords( &x,&y,&w,&h ); 2049 KApplication::testCoords( &x,&y,&w,&h );
2048 topLevelWidget()->setGeometry(x,y,w,h); 2050 topLevelWidget()->setGeometry(x,y,w,h);
2049 2051
2050 } else { 2052 } else {
2051 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2053 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2052 } 2054 }
2053 list = config->readListEntry("EditEventLayout"); 2055 list = config->readListEntry("EditEventLayout");
2054 if ( ! list.isEmpty() ) { 2056 if ( ! list.isEmpty() ) {
2055 x = list[0].toInt(); 2057 x = list[0].toInt();
2056 y = list[1].toInt(); 2058 y = list[1].toInt();
2057 w = list[2].toInt(); 2059 w = list[2].toInt();
2058 h = list[3].toInt(); 2060 h = list[3].toInt();
2059 KApplication::testCoords( &x,&y,&w,&h ); 2061 KApplication::testCoords( &x,&y,&w,&h );
2060 mEventEditor->setGeometry(x,y,w,h); 2062 mEventEditor->setGeometry(x,y,w,h);
2061 2063
2062 } 2064 }
2063 list = config->readListEntry("EditTodoLayout"); 2065 list = config->readListEntry("EditTodoLayout");
2064 if ( ! list.isEmpty() ) { 2066 if ( ! list.isEmpty() ) {
2065 x = list[0].toInt(); 2067 x = list[0].toInt();
2066 y = list[1].toInt(); 2068 y = list[1].toInt();
2067 w = list[2].toInt(); 2069 w = list[2].toInt();
2068 h = list[3].toInt(); 2070 h = list[3].toInt();
2069 KApplication::testCoords( &x,&y,&w,&h ); 2071 KApplication::testCoords( &x,&y,&w,&h );
2070 mTodoEditor->setGeometry(x,y,w,h); 2072 mTodoEditor->setGeometry(x,y,w,h);
2071 2073
2072 } 2074 }
2073 list = config->readListEntry("ViewerLayout"); 2075 list = config->readListEntry("ViewerLayout");
2074 if ( ! list.isEmpty() ) { 2076 if ( ! list.isEmpty() ) {
2075 x = list[0].toInt(); 2077 x = list[0].toInt();
2076 y = list[1].toInt(); 2078 y = list[1].toInt();
2077 w = list[2].toInt(); 2079 w = list[2].toInt();
2078 h = list[3].toInt(); 2080 h = list[3].toInt();
2079 KApplication::testCoords( &x,&y,&w,&h ); 2081 KApplication::testCoords( &x,&y,&w,&h );
2080 getEventViewerDialog()->setGeometry(x,y,w,h); 2082 getEventViewerDialog()->setGeometry(x,y,w,h);
2081 } 2083 }
2082#endif 2084#endif
2083 config->setGroup( "Views" ); 2085 config->setGroup( "Views" );
2084 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2086 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2085 2087
2086 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2088 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2087 2089
2088 int resetval = 0; 2090 int resetval = 0;
2089 int maxVal = 0; 2091 int maxVal = 0;
2090 if (sizes.count() != 3) { 2092 if (sizes.count() != 3) {
2091 if ( KOPrefs::instance()->mVerticalScreen ) { 2093 if ( KOPrefs::instance()->mVerticalScreen ) {
2092 resetval = mDateNavigator->sizeHint().width()+2; 2094 resetval = mDateNavigator->sizeHint().width()+2;
2093 } else { 2095 } else {
2094 resetval = mDateNavigator->sizeHint().height()+2; 2096 resetval = mDateNavigator->sizeHint().height()+2;
2095 } 2097 }
2096 } 2098 }
2097 if ( resetval ) { 2099 if ( resetval ) {
2098 sizes.clear(); 2100 sizes.clear();
2099 if ( KOPrefs::instance()->mVerticalScreen ) { 2101 if ( KOPrefs::instance()->mVerticalScreen ) {
2100 maxVal = QApplication::desktop()->width() -10; 2102 maxVal = QApplication::desktop()->width() -10;
2101 } else { 2103 } else {
2102 maxVal = QApplication::desktop()->height()-10; 2104 maxVal = QApplication::desktop()->height()-10;
2103 } 2105 }
2104 sizes << resetval; 2106 sizes << resetval;
2105 if ( maxVal < resetval + resetval) 2107 if ( maxVal < resetval + resetval)
2106 resetval = maxVal - resetval; 2108 resetval = maxVal - resetval;
2107 sizes << resetval; 2109 sizes << resetval;
2108 sizes << 100; 2110 sizes << 100;
2109 } 2111 }
2110 mLeftFrame->setSizes(sizes); 2112 mLeftFrame->setSizes(sizes);
2111 sizes = config->readIntListEntry("Main Splitter Frame"); 2113 sizes = config->readIntListEntry("Main Splitter Frame");
2112 resetval = 0; 2114 resetval = 0;
2113 maxVal = 0; 2115 maxVal = 0;
2114 if (sizes.count() != 2) { 2116 if (sizes.count() != 2) {
2115 if ( !KOPrefs::instance()->mVerticalScreen ) { 2117 if ( !KOPrefs::instance()->mVerticalScreen ) {
2116 resetval = mDateNavigator->sizeHint().width()+2; 2118 resetval = mDateNavigator->sizeHint().width()+2;
2117 } else { 2119 } else {
2118 resetval = mDateNavigator->sizeHint().height()+2; 2120 resetval = mDateNavigator->sizeHint().height()+2;
2119 } 2121 }
2120 } 2122 }
2121 if ( resetval ) { 2123 if ( resetval ) {
2122 sizes.clear(); 2124 sizes.clear();
2123 if ( !KOPrefs::instance()->mVerticalScreen ) { 2125 if ( !KOPrefs::instance()->mVerticalScreen ) {
2124 maxVal = QApplication::desktop()->width() -10; 2126 maxVal = QApplication::desktop()->width() -10;
2125 } else { 2127 } else {
2126 maxVal = QApplication::desktop()->height()-10; 2128 maxVal = QApplication::desktop()->height()-10;
2127 } 2129 }
2128 sizes << resetval; 2130 sizes << resetval;
2129 if ( maxVal < resetval + resetval) 2131 if ( maxVal < resetval + resetval)
2130 resetval = maxVal - resetval; 2132 resetval = maxVal - resetval;
2131 sizes << resetval; 2133 sizes << resetval;
2132 } 2134 }
2133 mMainFrame->setSizes(sizes); 2135 mMainFrame->setSizes(sizes);
2134 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2136 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2135 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2137 else if ( dateCount == 7 ) mNavigator->selectWeek();
2136 else mNavigator->selectDates( dateCount ); 2138 else mNavigator->selectDates( dateCount );
2137 // mViewManager->readSettings( config ); 2139 // mViewManager->readSettings( config );
2138 updateConfig(); 2140 updateConfig();
2139 globalFlagBlockAgenda = 2; 2141 globalFlagBlockAgenda = 2;
2140 mViewManager->readSettings( config ); 2142 mViewManager->readSettings( config );
2141 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2143 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2142} 2144}
2143 2145
2144 2146
2145void CalendarView::writeSettings() 2147void CalendarView::writeSettings()
2146{ 2148{
2147 // kdDebug() << "CalendarView::writeSettings" << endl; 2149 // kdDebug() << "CalendarView::writeSettings" << endl;
2148 2150
2149 KConfig *config = KOGlobals::config(); 2151 KConfig *config = KOGlobals::config();
2150 2152
2151 mViewManager->writeSettings( config ); 2153 mViewManager->writeSettings( config );
2152 mTodoList->saveLayout(config,QString("Todo Layout")); 2154 mTodoList->saveLayout(config,QString("Todo Layout"));
2153 mDialogManager->writeSettings( config ); 2155 mDialogManager->writeSettings( config );
2154 //KOPrefs::instance()->usrWriteConfig(); 2156 //KOPrefs::instance()->usrWriteConfig();
2155 KOPrefs::instance()->writeConfig(); 2157 KOPrefs::instance()->writeConfig();
2156 2158
2157 writeFilterSettings(config); 2159 writeFilterSettings(config);
2158 config->setGroup( "AppRun" ); 2160 config->setGroup( "AppRun" );
2159 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2161 QDateTime dt ( QDate (2005,3,1), QTime( 0,0,0 ) );
2160 config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); 2162 int secs = dt.secsTo( QDateTime::currentDateTime() );
2163 config->writeEntry( "LatestProgramStop", secs );
2164 qDebug("KO: Writing stop time: %d ", secs);
2165 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2166 QDateTime latest = dt.addSecs ( secs );
2167 qDebug("KO: Test termination on %s ", latest.toString().latin1());
2161 config->setGroup( "Views" ); 2168 config->setGroup( "Views" );
2162 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2169 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2163 2170
2164 QValueList<int> listINT = mLeftFrame->sizes(); 2171 QValueList<int> listINT = mLeftFrame->sizes();
2165 config->writeEntry("Left Splitter Frame",listINT); 2172 config->writeEntry("Left Splitter Frame",listINT);
2166 QValueList<int> listINT2 = mMainFrame->sizes(); 2173 QValueList<int> listINT2 = mMainFrame->sizes();
2167 config->writeEntry("Main Splitter Frame",listINT2); 2174 config->writeEntry("Main Splitter Frame",listINT2);
2168#ifdef DESKTOP_VERSION 2175#ifdef DESKTOP_VERSION
2169 config->setGroup("WidgetLayout"); 2176 config->setGroup("WidgetLayout");
2170 QStringList list ;//= config->readListEntry("MainLayout"); 2177 QStringList list ;//= config->readListEntry("MainLayout");
2171 int x,y,w,h; 2178 int x,y,w,h;
2172 QWidget* wid; 2179 QWidget* wid;
2173 wid = topLevelWidget(); 2180 wid = topLevelWidget();
2174 x = wid->geometry().x(); 2181 x = wid->geometry().x();
2175 y = wid->geometry().y(); 2182 y = wid->geometry().y();
2176 w = wid->width(); 2183 w = wid->width();
2177 h = wid->height(); 2184 h = wid->height();
2178 list.clear(); 2185 list.clear();
2179 list << QString::number( x ); 2186 list << QString::number( x );
2180 list << QString::number( y ); 2187 list << QString::number( y );
2181 list << QString::number( w ); 2188 list << QString::number( w );
2182 list << QString::number( h ); 2189 list << QString::number( h );
2183 config->writeEntry("MainLayout",list ); 2190 config->writeEntry("MainLayout",list );
2184 2191
2185 wid = mEventEditor; 2192 wid = mEventEditor;
2186 x = wid->geometry().x(); 2193 x = wid->geometry().x();
2187 y = wid->geometry().y(); 2194 y = wid->geometry().y();
2188 w = wid->width(); 2195 w = wid->width();
2189 h = wid->height(); 2196 h = wid->height();
2190 list.clear(); 2197 list.clear();
2191 list << QString::number( x ); 2198 list << QString::number( x );
2192 list << QString::number( y ); 2199 list << QString::number( y );
2193 list << QString::number( w ); 2200 list << QString::number( w );
2194 list << QString::number( h ); 2201 list << QString::number( h );
2195 config->writeEntry("EditEventLayout",list ); 2202 config->writeEntry("EditEventLayout",list );
2196 2203
2197 wid = mTodoEditor; 2204 wid = mTodoEditor;
2198 x = wid->geometry().x(); 2205 x = wid->geometry().x();
2199 y = wid->geometry().y(); 2206 y = wid->geometry().y();
2200 w = wid->width(); 2207 w = wid->width();
2201 h = wid->height(); 2208 h = wid->height();
2202 list.clear(); 2209 list.clear();
2203 list << QString::number( x ); 2210 list << QString::number( x );
2204 list << QString::number( y ); 2211 list << QString::number( y );
2205 list << QString::number( w ); 2212 list << QString::number( w );
2206 list << QString::number( h ); 2213 list << QString::number( h );
2207 config->writeEntry("EditTodoLayout",list ); 2214 config->writeEntry("EditTodoLayout",list );
2208 wid = getEventViewerDialog(); 2215 wid = getEventViewerDialog();
2209 x = wid->geometry().x(); 2216 x = wid->geometry().x();
2210 y = wid->geometry().y(); 2217 y = wid->geometry().y();
2211 w = wid->width(); 2218 w = wid->width();
2212 h = wid->height(); 2219 h = wid->height();
2213 list.clear(); 2220 list.clear();
2214 list << QString::number( x ); 2221 list << QString::number( x );
2215 list << QString::number( y ); 2222 list << QString::number( y );
2216 list << QString::number( w ); 2223 list << QString::number( w );
2217 list << QString::number( h ); 2224 list << QString::number( h );
2218 config->writeEntry("ViewerLayout",list ); 2225 config->writeEntry("ViewerLayout",list );
2219 wid = mDialogManager->getSearchDialog(); 2226 wid = mDialogManager->getSearchDialog();
2220 if ( wid ) { 2227 if ( wid ) {
2221 x = wid->geometry().x(); 2228 x = wid->geometry().x();
2222 y = wid->geometry().y(); 2229 y = wid->geometry().y();
2223 w = wid->width(); 2230 w = wid->width();
2224 h = wid->height(); 2231 h = wid->height();
2225 list.clear(); 2232 list.clear();
2226 list << QString::number( x ); 2233 list << QString::number( x );
2227 list << QString::number( y ); 2234 list << QString::number( y );
2228 list << QString::number( w ); 2235 list << QString::number( w );
2229 list << QString::number( h ); 2236 list << QString::number( h );
2230 config->writeEntry("SearchLayout",list ); 2237 config->writeEntry("SearchLayout",list );
2231 } 2238 }
2232#endif 2239#endif
2233 2240
2234 2241
2235 config->sync(); 2242 config->sync();
2236} 2243}
2237 2244
2238void CalendarView::readFilterSettings(KConfig *config) 2245void CalendarView::readFilterSettings(KConfig *config)
2239{ 2246{
2240 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2247 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2241 2248
2242 mFilters.clear(); 2249 mFilters.clear();
2243 2250
2244 config->setGroup("General"); 2251 config->setGroup("General");
2245 QStringList filterList = config->readListEntry("CalendarFilters"); 2252 QStringList filterList = config->readListEntry("CalendarFilters");
2246 2253
2247 QStringList::ConstIterator it = filterList.begin(); 2254 QStringList::ConstIterator it = filterList.begin();
2248 QStringList::ConstIterator end = filterList.end(); 2255 QStringList::ConstIterator end = filterList.end();
2249 while(it != end) { 2256 while(it != end) {
2250 // kdDebug() << " filter: " << (*it) << endl; 2257 // kdDebug() << " filter: " << (*it) << endl;
2251 2258
2252 CalFilter *filter; 2259 CalFilter *filter;
2253 filter = new CalFilter(*it); 2260 filter = new CalFilter(*it);
2254 config->setGroup("Filter_" + (*it).utf8()); 2261 config->setGroup("Filter_" + (*it).utf8());
2255 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2262 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2256 filter->setCriteria(config->readNumEntry("Criteria",0)); 2263 filter->setCriteria(config->readNumEntry("Criteria",0));
2257 filter->setCategoryList(config->readListEntry("CategoryList")); 2264 filter->setCategoryList(config->readListEntry("CategoryList"));
2258 mFilters.append(filter); 2265 mFilters.append(filter);
2259 2266
2260 ++it; 2267 ++it;
2261 } 2268 }
2262 2269
2263 if (mFilters.count() == 0) { 2270 if (mFilters.count() == 0) {
2264 CalFilter *filter = new CalFilter(i18n("Default")); 2271 CalFilter *filter = new CalFilter(i18n("Default"));
2265 mFilters.append(filter); 2272 mFilters.append(filter);
2266 } 2273 }
2267 mFilterView->updateFilters(); 2274 mFilterView->updateFilters();
2268 config->setGroup("FilterView"); 2275 config->setGroup("FilterView");
2269 2276
2270 mFilterView->blockSignals(true); 2277 mFilterView->blockSignals(true);
2271 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2278 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2272 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2279 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2273 mFilterView->blockSignals(false); 2280 mFilterView->blockSignals(false);
2274 // We do it manually to avoid it being done twice by the above calls 2281 // We do it manually to avoid it being done twice by the above calls
2275 updateFilter(); 2282 updateFilter();
2276} 2283}
2277 2284
2278void CalendarView::writeFilterSettings(KConfig *config) 2285void CalendarView::writeFilterSettings(KConfig *config)
2279{ 2286{
2280 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2287 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2281 2288
2282 QStringList filterList; 2289 QStringList filterList;
2283 2290
2284 CalFilter *filter = mFilters.first(); 2291 CalFilter *filter = mFilters.first();
2285 while(filter) { 2292 while(filter) {
2286 // kdDebug() << " fn: " << filter->name() << endl; 2293 // kdDebug() << " fn: " << filter->name() << endl;
2287 filterList << filter->name(); 2294 filterList << filter->name();
2288 config->setGroup("Filter_" + filter->name().utf8()); 2295 config->setGroup("Filter_" + filter->name().utf8());
2289 config->writeEntry("Criteria",filter->criteria()); 2296 config->writeEntry("Criteria",filter->criteria());
2290 config->writeEntry("CategoryList",filter->categoryList()); 2297 config->writeEntry("CategoryList",filter->categoryList());
2291 filter = mFilters.next(); 2298 filter = mFilters.next();
2292 } 2299 }
2293 config->setGroup("General"); 2300 config->setGroup("General");
2294 config->writeEntry("CalendarFilters",filterList); 2301 config->writeEntry("CalendarFilters",filterList);
2295 2302
2296 config->setGroup("FilterView"); 2303 config->setGroup("FilterView");
2297 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2304 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2298 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2305 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2299} 2306}
2300 2307
2301 2308
2302void CalendarView::goToday() 2309void CalendarView::goToday()
2303{ 2310{
2304 if ( mViewManager->currentView()->isMonthView() ) 2311 if ( mViewManager->currentView()->isMonthView() )
2305 mNavigator->selectTodayMonth(); 2312 mNavigator->selectTodayMonth();
2306 else 2313 else
2307 mNavigator->selectToday(); 2314 mNavigator->selectToday();
2308} 2315}
2309 2316
2310void CalendarView::goNext() 2317void CalendarView::goNext()
2311{ 2318{
2312 mNavigator->selectNext(); 2319 mNavigator->selectNext();
2313} 2320}
2314 2321
2315void CalendarView::goPrevious() 2322void CalendarView::goPrevious()
2316{ 2323{
2317 mNavigator->selectPrevious(); 2324 mNavigator->selectPrevious();
2318} 2325}
2319void CalendarView::goNextMonth() 2326void CalendarView::goNextMonth()
2320{ 2327{
2321 mNavigator->selectNextMonth(); 2328 mNavigator->selectNextMonth();
2322} 2329}
2323 2330
2324void CalendarView::goPreviousMonth() 2331void CalendarView::goPreviousMonth()
2325{ 2332{
2326 mNavigator->selectPreviousMonth(); 2333 mNavigator->selectPreviousMonth();
2327} 2334}
2328void CalendarView::writeLocale() 2335void CalendarView::writeLocale()
2329{ 2336{
2330 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2337 //KPimGlobalPrefs::instance()->setGlobalConfig();
2331#if 0 2338#if 0
2332 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2339 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2333 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2340 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2334 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2341 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2335 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2342 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2336 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2343 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2337 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2344 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2338 dummy = KOPrefs::instance()->mUserDateFormatShort; 2345 dummy = KOPrefs::instance()->mUserDateFormatShort;
2339 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2346 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2340 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2347 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2341 KOPrefs::instance()->mDaylightsavingStart, 2348 KOPrefs::instance()->mDaylightsavingStart,
2342 KOPrefs::instance()->mDaylightsavingEnd ); 2349 KOPrefs::instance()->mDaylightsavingEnd );
2343 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2350 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2344#endif 2351#endif
2345} 2352}
2346void CalendarView::updateConfig() 2353void CalendarView::updateConfig()
2347{ 2354{
2348 writeLocale(); 2355 writeLocale();
2349 if ( KOPrefs::instance()->mUseAppColors ) 2356 if ( KOPrefs::instance()->mUseAppColors )
2350 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2357 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2351 emit configChanged(); 2358 emit configChanged();
2352 mTodoList->updateConfig(); 2359 mTodoList->updateConfig();
2353 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2360 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2354 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2361 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2355 // To make the "fill window" configurations work 2362 // To make the "fill window" configurations work
2356 //mViewManager->raiseCurrentView(); 2363 //mViewManager->raiseCurrentView();
2357} 2364}
2358 2365
2359 2366
2360void CalendarView::eventChanged(Event *event) 2367void CalendarView::eventChanged(Event *event)
2361{ 2368{
2362 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2369 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2363 //updateUnmanagedViews(); 2370 //updateUnmanagedViews();
2364} 2371}
2365 2372
2366void CalendarView::eventAdded(Event *event) 2373void CalendarView::eventAdded(Event *event)
2367{ 2374{
2368 changeEventDisplay(event,KOGlobals::EVENTADDED); 2375 changeEventDisplay(event,KOGlobals::EVENTADDED);
2369} 2376}
2370 2377
2371void CalendarView::eventToBeDeleted(Event *) 2378void CalendarView::eventToBeDeleted(Event *)
2372{ 2379{
2373 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2380 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2374} 2381}
2375 2382
2376void CalendarView::eventDeleted() 2383void CalendarView::eventDeleted()
2377{ 2384{
2378 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2385 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2379} 2386}
2380void CalendarView::changeTodoDisplay(Todo *which, int action) 2387void CalendarView::changeTodoDisplay(Todo *which, int action)
2381{ 2388{
2382 changeIncidenceDisplay((Incidence *)which, action); 2389 changeIncidenceDisplay((Incidence *)which, action);
2383 mDateNavigator->updateView(); //LR 2390 mDateNavigator->updateView(); //LR
2384 //mDialogManager->updateSearchDialog(); 2391 //mDialogManager->updateSearchDialog();
2385 2392
2386 if (which) { 2393 if (which) {
2387 mViewManager->updateWNview(); 2394 mViewManager->updateWNview();
2388 //mTodoList->updateView(); 2395 //mTodoList->updateView();
2389 } 2396 }
2390 2397
2391} 2398}
2392 2399
2393void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2400void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2394{ 2401{
2395 updateUnmanagedViews(); 2402 updateUnmanagedViews();
2396 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2403 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2397 if ( action == KOGlobals::EVENTDELETED ) { //delete 2404 if ( action == KOGlobals::EVENTDELETED ) { //delete
2398 mCalendar->checkAlarmForIncidence( 0, true ); 2405 mCalendar->checkAlarmForIncidence( 0, true );
2399 if ( mEventViewerDialog ) 2406 if ( mEventViewerDialog )
2400 mEventViewerDialog->hide(); 2407 mEventViewerDialog->hide();
2401 } 2408 }
2402 else 2409 else
2403 mCalendar->checkAlarmForIncidence( which , false ); 2410 mCalendar->checkAlarmForIncidence( which , false );
2404} 2411}
2405 2412
2406// most of the changeEventDisplays() right now just call the view's 2413// most of the changeEventDisplays() right now just call the view's
2407// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2414// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2408void CalendarView::changeEventDisplay(Event *which, int action) 2415void CalendarView::changeEventDisplay(Event *which, int action)
2409{ 2416{
2410 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2417 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2411 changeIncidenceDisplay((Incidence *)which, action); 2418 changeIncidenceDisplay((Incidence *)which, action);
2412 mDateNavigator->updateView(); 2419 mDateNavigator->updateView();
2413 //mDialogManager->updateSearchDialog(); 2420 //mDialogManager->updateSearchDialog();
2414 2421
2415 if (which) { 2422 if (which) {
2416 // If there is an event view visible update the display 2423 // If there is an event view visible update the display
2417 mViewManager->currentView()->changeEventDisplay(which,action); 2424 mViewManager->currentView()->changeEventDisplay(which,action);
2418 // TODO: check, if update needed 2425 // TODO: check, if update needed
2419 // if (which->getTodoStatus()) { 2426 // if (which->getTodoStatus()) {
2420 mTodoList->updateView(); 2427 mTodoList->updateView();
2421 // } 2428 // }
2422 } else { 2429 } else {
2423 mViewManager->currentView()->updateView(); 2430 mViewManager->currentView()->updateView();
2424 } 2431 }
2425} 2432}
2426 2433
2427 2434
2428void CalendarView::updateTodoViews() 2435void CalendarView::updateTodoViews()
2429{ 2436{
2430 mTodoList->updateView(); 2437 mTodoList->updateView();
2431 mViewManager->currentView()->updateView(); 2438 mViewManager->currentView()->updateView();
2432 2439
2433} 2440}
2434 2441
2435 2442
2436void CalendarView::updateView(const QDate &start, const QDate &end) 2443void CalendarView::updateView(const QDate &start, const QDate &end)
2437{ 2444{
2438 mTodoList->updateView(); 2445 mTodoList->updateView();
2439 mViewManager->updateView(start, end); 2446 mViewManager->updateView(start, end);
2440 //mDateNavigator->updateView(); 2447 //mDateNavigator->updateView();
2441} 2448}
2442 2449
2443void CalendarView::clearAllViews() 2450void CalendarView::clearAllViews()
2444{ 2451{
2445 mTodoList->clearList(); 2452 mTodoList->clearList();
2446 mViewManager->clearAllViews(); 2453 mViewManager->clearAllViews();
2447 SearchDialog * sd = mDialogManager->getSearchDialog(); 2454 SearchDialog * sd = mDialogManager->getSearchDialog();
2448 if ( sd ) { 2455 if ( sd ) {
2449 KOListView* kol = sd->listview(); 2456 KOListView* kol = sd->listview();
2450 if ( kol ) 2457 if ( kol )
2451 kol->clearList(); 2458 kol->clearList();
2452 } 2459 }
2453} 2460}
2454void CalendarView::updateView() 2461void CalendarView::updateView()
2455{ 2462{
2456 DateList tmpList = mNavigator->selectedDates(); 2463 DateList tmpList = mNavigator->selectedDates();
2457 2464
2458 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2465 if ( KOPrefs::instance()->mHideNonStartedTodos )
2459 mTodoList->updateView(); 2466 mTodoList->updateView();
2460 // We assume that the navigator only selects consecutive days. 2467 // We assume that the navigator only selects consecutive days.
2461 updateView( tmpList.first(), tmpList.last() ); 2468 updateView( tmpList.first(), tmpList.last() );
2462} 2469}
2463 2470
2464void CalendarView::updateUnmanagedViews() 2471void CalendarView::updateUnmanagedViews()
2465{ 2472{
2466 mDateNavigator->updateDayMatrix(); 2473 mDateNavigator->updateDayMatrix();
2467} 2474}
2468 2475
2469int CalendarView::msgItemDelete(const QString name) 2476int CalendarView::msgItemDelete(const QString name)
2470{ 2477{
2471 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2478 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2472 i18n("This item will be\npermanently deleted."), 2479 i18n("This item will be\npermanently deleted."),
2473 i18n("KO/Pi Confirmation"),i18n("Delete")); 2480 i18n("KO/Pi Confirmation"),i18n("Delete"));
2474} 2481}
2475 2482
2476 2483
2477void CalendarView::edit_cut() 2484void CalendarView::edit_cut()
2478{ 2485{
2479 Event *anEvent=0; 2486 Event *anEvent=0;
2480 2487
2481 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2488 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2482 2489
2483 if (mViewManager->currentView()->isEventView()) { 2490 if (mViewManager->currentView()->isEventView()) {
2484 if ( incidence && incidence->typeID() == eventID ) { 2491 if ( incidence && incidence->typeID() == eventID ) {
2485 anEvent = static_cast<Event *>(incidence); 2492 anEvent = static_cast<Event *>(incidence);
2486 } 2493 }
2487 } 2494 }
2488 2495
2489 if (!anEvent) { 2496 if (!anEvent) {
2490 KNotifyClient::beep(); 2497 KNotifyClient::beep();
2491 return; 2498 return;
2492 } 2499 }
2493 DndFactory factory( mCalendar ); 2500 DndFactory factory( mCalendar );
2494 factory.cutIncidence(anEvent); 2501 factory.cutIncidence(anEvent);
2495 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2502 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2496} 2503}
2497 2504
2498void CalendarView::edit_copy() 2505void CalendarView::edit_copy()
2499{ 2506{
2500 Event *anEvent=0; 2507 Event *anEvent=0;
2501 2508
2502 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2503 2510
2504 if (mViewManager->currentView()->isEventView()) { 2511 if (mViewManager->currentView()->isEventView()) {
2505 if ( incidence && incidence->typeID() == eventID ) { 2512 if ( incidence && incidence->typeID() == eventID ) {
2506 anEvent = static_cast<Event *>(incidence); 2513 anEvent = static_cast<Event *>(incidence);
2507 } 2514 }
2508 } 2515 }
2509 2516
2510 if (!anEvent) { 2517 if (!anEvent) {
2511 KNotifyClient::beep(); 2518 KNotifyClient::beep();
2512 return; 2519 return;
2513 } 2520 }
2514 DndFactory factory( mCalendar ); 2521 DndFactory factory( mCalendar );
2515 factory.copyIncidence(anEvent); 2522 factory.copyIncidence(anEvent);
2516} 2523}
2517 2524
2518void CalendarView::edit_paste() 2525void CalendarView::edit_paste()
2519{ 2526{
2520 QDate date = mNavigator->selectedDates().first(); 2527 QDate date = mNavigator->selectedDates().first();
2521 2528
2522 DndFactory factory( mCalendar ); 2529 DndFactory factory( mCalendar );
2523 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2530 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2524 2531
2525 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2532 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2526} 2533}
2527void CalendarView::edit_global_options() 2534void CalendarView::edit_global_options()
2528{ 2535{
2529 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2536 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2530 emit save(); 2537 emit save();
2531 emit saveStopTimer(); 2538 emit saveStopTimer();
2532 mDialogManager->showGlobalOptionsDialog(); 2539 mDialogManager->showGlobalOptionsDialog();
2533 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2540 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2534 emit saveStopTimer(); 2541 emit saveStopTimer();
2535 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2542 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2536 i18n("Timezone settings"),i18n("Reload"))) { 2543 i18n("Timezone settings"),i18n("Reload"))) {
2537 qDebug("KO: TZ reload cancelled "); 2544 qDebug("KO: TZ reload cancelled ");
2538 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2545 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2539 return; 2546 return;
2540 } 2547 }
2541 qDebug("KO: Timezone change "); 2548 qDebug("KO: Timezone change ");
2542 openCalendar( MainWindow::defaultFileName() ); 2549 openCalendar( MainWindow::defaultFileName() );
2543 setModified(true); 2550 setModified(true);
2544 } 2551 }
2545 else 2552 else
2546 qDebug("KO: No tz change "); 2553 qDebug("KO: No tz change ");
2547} 2554}
2548void CalendarView::edit_options() 2555void CalendarView::edit_options()
2549{ 2556{
2550 mDialogManager->showOptionsDialog(); 2557 mDialogManager->showOptionsDialog();
2551} 2558}
2552 2559
2553 2560
2554void CalendarView::slotSelectPickerDate( QDate d) 2561void CalendarView::slotSelectPickerDate( QDate d)
2555{ 2562{
2556 mDateFrame->hide(); 2563 mDateFrame->hide();
2557 if ( mDatePickerMode == 1 ) { 2564 if ( mDatePickerMode == 1 ) {
2558 mNavigator->slotDaySelect( d ); 2565 mNavigator->slotDaySelect( d );
2559 } else if ( mDatePickerMode == 2 ) { 2566 } else if ( mDatePickerMode == 2 ) {
2560 if ( mMoveIncidence->typeID() == todoID ) { 2567 if ( mMoveIncidence->typeID() == todoID ) {
2561 Todo * to = (Todo *) mMoveIncidence; 2568 Todo * to = (Todo *) mMoveIncidence;
2562 QTime tim; 2569 QTime tim;
2563 int len = 0; 2570 int len = 0;
2564 if ( to->hasStartDate() && to->hasDueDate() ) 2571 if ( to->hasStartDate() && to->hasDueDate() )
2565 len = to->dtStart().secsTo( to->dtDue()); 2572 len = to->dtStart().secsTo( to->dtDue());
2566 if ( to->hasDueDate() ) 2573 if ( to->hasDueDate() )
2567 tim = to->dtDue().time(); 2574 tim = to->dtDue().time();
2568 else { 2575 else {
2569 tim = QTime ( 0,0,0 ); 2576 tim = QTime ( 0,0,0 );
2570 to->setFloats( true ); 2577 to->setFloats( true );
2571 to->setHasDueDate( true ); 2578 to->setHasDueDate( true );
2572 } 2579 }
2573 QDateTime dt ( d,tim ); 2580 QDateTime dt ( d,tim );
2574 to->setDtDue( dt ); 2581 to->setDtDue( dt );
2575 2582
2576 if ( to->hasStartDate() ) { 2583 if ( to->hasStartDate() ) {
2577 if ( len>0 ) 2584 if ( len>0 )
2578 to->setDtStart(to->dtDue().addSecs( -len )); 2585 to->setDtStart(to->dtDue().addSecs( -len ));
2579 else 2586 else
2580 if (to->dtStart() > to->dtDue() ) 2587 if (to->dtStart() > to->dtDue() )
2581 to->setDtStart(to->dtDue().addDays( -3 )); 2588 to->setDtStart(to->dtDue().addDays( -3 ));
2582 } 2589 }
2583 2590
2584 todoChanged( to ); 2591 todoChanged( to );
2585 } else { 2592 } else {
2586 if ( mMoveIncidence->doesRecur() ) { 2593 if ( mMoveIncidence->doesRecur() ) {
2587#if 0 2594#if 0
2588 // PENDING implement this 2595 // PENDING implement this
2589 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2596 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2590 mCalendar()->addIncidence( newInc ); 2597 mCalendar()->addIncidence( newInc );
2591 if ( mMoveIncidence->typeID() == todoID ) 2598 if ( mMoveIncidence->typeID() == todoID )
2592 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2599 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2593 else 2600 else
2594 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2601 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2595 mMoveIncidence = newInc; 2602 mMoveIncidence = newInc;
2596 2603
2597#endif 2604#endif
2598 } 2605 }
2599 QTime tim = mMoveIncidence->dtStart().time(); 2606 QTime tim = mMoveIncidence->dtStart().time();
2600 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2607 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2601 QDateTime dt ( d,tim ); 2608 QDateTime dt ( d,tim );
2602 mMoveIncidence->setDtStart( dt ); 2609 mMoveIncidence->setDtStart( dt );
2603 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2610 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2604 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2611 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2605 } 2612 }
2606 2613
2607 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2614 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2608 } 2615 }
2609} 2616}
2610 2617
2611void CalendarView::removeCategories() 2618void CalendarView::removeCategories()
2612{ 2619{
2613 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2620 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2614 QStringList catList = KOPrefs::instance()->mCustomCategories; 2621 QStringList catList = KOPrefs::instance()->mCustomCategories;
2615 QStringList catIncList; 2622 QStringList catIncList;
2616 QStringList newCatList; 2623 QStringList newCatList;
2617 Incidence* inc = incList.first(); 2624 Incidence* inc = incList.first();
2618 int i; 2625 int i;
2619 int count = 0; 2626 int count = 0;
2620 while ( inc ) { 2627 while ( inc ) {
2621 newCatList.clear(); 2628 newCatList.clear();
2622 catIncList = inc->categories() ; 2629 catIncList = inc->categories() ;
2623 for( i = 0; i< catIncList.count(); ++i ) { 2630 for( i = 0; i< catIncList.count(); ++i ) {
2624 if ( catList.contains (catIncList[i])) 2631 if ( catList.contains (catIncList[i]))
2625 newCatList.append( catIncList[i] ); 2632 newCatList.append( catIncList[i] );
2626 } 2633 }
2627 newCatList.sort(); 2634 newCatList.sort();
2628 inc->setCategories( newCatList.join(",") ); 2635 inc->setCategories( newCatList.join(",") );
2629 inc = incList.next(); 2636 inc = incList.next();
2630 } 2637 }
2631} 2638}
2632 2639
2633int CalendarView::addCategories() 2640int CalendarView::addCategories()
2634{ 2641{
2635 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2642 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2636 QStringList catList = KOPrefs::instance()->mCustomCategories; 2643 QStringList catList = KOPrefs::instance()->mCustomCategories;
2637 QStringList catIncList; 2644 QStringList catIncList;
2638 Incidence* inc = incList.first(); 2645 Incidence* inc = incList.first();
2639 int i; 2646 int i;
2640 int count = 0; 2647 int count = 0;
2641 while ( inc ) { 2648 while ( inc ) {
2642 catIncList = inc->categories() ; 2649 catIncList = inc->categories() ;
2643 for( i = 0; i< catIncList.count(); ++i ) { 2650 for( i = 0; i< catIncList.count(); ++i ) {
2644 if ( !catList.contains (catIncList[i])) { 2651 if ( !catList.contains (catIncList[i])) {
2645 catList.append( catIncList[i] ); 2652 catList.append( catIncList[i] );
2646 //qDebug("add cat %s ", catIncList[i].latin1()); 2653 //qDebug("add cat %s ", catIncList[i].latin1());
2647 ++count; 2654 ++count;
2648 } 2655 }
2649 } 2656 }
2650 inc = incList.next(); 2657 inc = incList.next();
2651 } 2658 }
2652 catList.sort(); 2659 catList.sort();
2653 KOPrefs::instance()->mCustomCategories = catList; 2660 KOPrefs::instance()->mCustomCategories = catList;
2654 return count; 2661 return count;
2655} 2662}
2656 2663
2657void CalendarView::manageCategories() 2664void CalendarView::manageCategories()
2658{ 2665{
2659 KOCatPrefs* cp = new KOCatPrefs(); 2666 KOCatPrefs* cp = new KOCatPrefs();
2660 cp->show(); 2667 cp->show();
2661 int w =cp->sizeHint().width() ; 2668 int w =cp->sizeHint().width() ;
2662 int h = cp->sizeHint().height() ; 2669 int h = cp->sizeHint().height() ;
2663 int dw = QApplication::desktop()->width(); 2670 int dw = QApplication::desktop()->width();
2664 int dh = QApplication::desktop()->height(); 2671 int dh = QApplication::desktop()->height();
2665 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2672 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2666 if ( !cp->exec() ) { 2673 if ( !cp->exec() ) {
2667 delete cp; 2674 delete cp;
2668 return; 2675 return;
2669 } 2676 }
2670 int count = 0; 2677 int count = 0;
2671 if ( cp->addCat() ) { 2678 if ( cp->addCat() ) {
2672 count = addCategories(); 2679 count = addCategories();
2673 if ( count ) { 2680 if ( count ) {
2674 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2681 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2675 writeSettings(); 2682 writeSettings();
2676 } else 2683 } else
2677 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2684 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2678 } else { 2685 } else {
2679 removeCategories(); 2686 removeCategories();
2680 updateView(); 2687 updateView();
2681 } 2688 }
2682 delete cp; 2689 delete cp;
2683} 2690}
2684 2691
2685void CalendarView::beamIncidence(Incidence * Inc) 2692void CalendarView::beamIncidence(Incidence * Inc)
2686{ 2693{
2687 QPtrList<Incidence> delSel ; 2694 QPtrList<Incidence> delSel ;
2688 delSel.append(Inc); 2695 delSel.append(Inc);
2689 beamIncidenceList( delSel ); 2696 beamIncidenceList( delSel );
2690} 2697}
2691void CalendarView::beamCalendar() 2698void CalendarView::beamCalendar()
2692{ 2699{
2693 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2700 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2694 //qDebug("beamCalendar() "); 2701 //qDebug("beamCalendar() ");
2695 beamIncidenceList( delSel ); 2702 beamIncidenceList( delSel );
2696} 2703}
2697void CalendarView::beamFilteredCalendar() 2704void CalendarView::beamFilteredCalendar()
2698{ 2705{
2699 QPtrList<Incidence> delSel = mCalendar->incidences(); 2706 QPtrList<Incidence> delSel = mCalendar->incidences();
2700 //qDebug("beamFilteredCalendar() "); 2707 //qDebug("beamFilteredCalendar() ");
2701 beamIncidenceList( delSel ); 2708 beamIncidenceList( delSel );
2702} 2709}
2703void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2710void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2704{ 2711{
2705 if ( beamDialog->exec () == QDialog::Rejected ) 2712 if ( beamDialog->exec () == QDialog::Rejected )
2706 return; 2713 return;
2707#ifdef DESKTOP_VERSION 2714#ifdef DESKTOP_VERSION
2708 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2715 QString fn = locateLocal( "tmp", "kopibeamfile" );
2709#else 2716#else
2710 QString fn = "/tmp/kopibeamfile"; 2717 QString fn = "/tmp/kopibeamfile";
2711#endif 2718#endif
2712 QString mes; 2719 QString mes;
2713 bool createbup = true; 2720 bool createbup = true;
2714 if ( createbup ) { 2721 if ( createbup ) {
2715 QString description = "\n"; 2722 QString description = "\n";
2716 CalendarLocal* cal = new CalendarLocal(); 2723 CalendarLocal* cal = new CalendarLocal();
2717 if ( beamDialog->beamLocal() ) 2724 if ( beamDialog->beamLocal() )
2718 cal->setLocalTime(); 2725 cal->setLocalTime();
2719 else 2726 else
2720 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2727 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2721 Incidence *incidence = delSel.first(); 2728 Incidence *incidence = delSel.first();
2722 bool addText = false; 2729 bool addText = false;
2723 if ( delSel.count() < 10 ) 2730 if ( delSel.count() < 10 )
2724 addText = true; 2731 addText = true;
2725 else { 2732 else {
2726 description.sprintf(i18n(" %d items?"),delSel.count() ); 2733 description.sprintf(i18n(" %d items?"),delSel.count() );
2727 } 2734 }
2728 while ( incidence ) { 2735 while ( incidence ) {
2729 Incidence *in = incidence->clone(); 2736 Incidence *in = incidence->clone();
2730 if ( ! in->summary().isEmpty() ) { 2737 if ( ! in->summary().isEmpty() ) {
2731 in->setDescription(""); 2738 in->setDescription("");
2732 } else { 2739 } else {
2733 in->setSummary( in->description().left(20)); 2740 in->setSummary( in->description().left(20));
2734 in->setDescription(""); 2741 in->setDescription("");
2735 } 2742 }
2736 if ( addText ) 2743 if ( addText )
2737 description += in->summary() + "\n"; 2744 description += in->summary() + "\n";
2738 cal->addIncidence( in ); 2745 cal->addIncidence( in );
2739 incidence = delSel.next(); 2746 incidence = delSel.next();
2740 } 2747 }
2741 if ( beamDialog->beamVcal() ) { 2748 if ( beamDialog->beamVcal() ) {
2742 fn += ".vcs"; 2749 fn += ".vcs";
2743 FileStorage storage( cal, fn, new VCalFormat ); 2750 FileStorage storage( cal, fn, new VCalFormat );
2744 storage.save(); 2751 storage.save();
2745 } else { 2752 } else {
2746 fn += ".ics"; 2753 fn += ".ics";
2747 FileStorage storage( cal, fn, new ICalFormat( ) ); 2754 FileStorage storage( cal, fn, new ICalFormat( ) );
2748 storage.save(); 2755 storage.save();
2749 } 2756 }
2750 delete cal; 2757 delete cal;
2751 mes = i18n("KO/Pi: Ready for beaming"); 2758 mes = i18n("KO/Pi: Ready for beaming");
2752 topLevelWidget()->setCaption(mes); 2759 topLevelWidget()->setCaption(mes);
2753 KApplication::convert2latin1( fn ); 2760 KApplication::convert2latin1( fn );
2754#ifndef DESKTOP_VERSION 2761#ifndef DESKTOP_VERSION
2755 Ir *ir = new Ir( this ); 2762 Ir *ir = new Ir( this );
2756 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2763 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2757 ir->send( fn, description, "text/x-vCalendar" ); 2764 ir->send( fn, description, "text/x-vCalendar" );
2758#endif 2765#endif
2759 } 2766 }
2760} 2767}
2761void CalendarView::beamDone( Ir *ir ) 2768void CalendarView::beamDone( Ir *ir )
2762{ 2769{
2763#ifndef DESKTOP_VERSION 2770#ifndef DESKTOP_VERSION
2764 delete ir; 2771 delete ir;
2765#endif 2772#endif
2766 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2773 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2767 topLevelWidget()->raise(); 2774 topLevelWidget()->raise();
2768} 2775}
2769 2776
2770void CalendarView::moveIncidence(Incidence * inc ) 2777void CalendarView::moveIncidence(Incidence * inc )
2771{ 2778{
2772 if ( !inc ) return; 2779 if ( !inc ) return;
2773 showDatePickerPopup(); 2780 showDatePickerPopup();
2774 mDatePickerMode = 2; 2781 mDatePickerMode = 2;
2775 mMoveIncidence = inc ; 2782 mMoveIncidence = inc ;
2776 QDate da; 2783 QDate da;
2777 if ( mMoveIncidence->typeID() == todoID ) { 2784 if ( mMoveIncidence->typeID() == todoID ) {
2778 Todo * to = (Todo *) mMoveIncidence; 2785 Todo * to = (Todo *) mMoveIncidence;
2779 if ( to->hasDueDate() ) 2786 if ( to->hasDueDate() )
2780 da = to->dtDue().date(); 2787 da = to->dtDue().date();
2781 else 2788 else
2782 da = QDate::currentDate(); 2789 da = QDate::currentDate();
2783 } else { 2790 } else {
2784 da = mMoveIncidence->dtStart().date(); 2791 da = mMoveIncidence->dtStart().date();
2785 } 2792 }
2786 //PENDING set date for recurring incidence to date of recurrence 2793 //PENDING set date for recurring incidence to date of recurrence
2787 //mMoveIncidenceOldDate; 2794 //mMoveIncidenceOldDate;
2788 mDatePicker->setDate( da ); 2795 mDatePicker->setDate( da );
2789} 2796}
2790void CalendarView::showDatePickerPopup() 2797void CalendarView::showDatePickerPopup()
2791{ 2798{
2792 if ( mDateFrame->isVisible() ) 2799 if ( mDateFrame->isVisible() )
2793 mDateFrame->hide(); 2800 mDateFrame->hide();
2794 else { 2801 else {
2795 int offX = 0, offY = 0; 2802 int offX = 0, offY = 0;
2796#ifdef DESKTOP_VERSION 2803#ifdef DESKTOP_VERSION
2797 int w =mDatePicker->sizeHint().width() ; 2804 int w =mDatePicker->sizeHint().width() ;
2798 int h = mDatePicker->sizeHint().height() ; 2805 int h = mDatePicker->sizeHint().height() ;
2799 int dw = topLevelWidget()->width(); 2806 int dw = topLevelWidget()->width();
2800 int dh = topLevelWidget()->height(); 2807 int dh = topLevelWidget()->height();
2801 offX = topLevelWidget()->x(); 2808 offX = topLevelWidget()->x();
2802 offY = topLevelWidget()->y(); 2809 offY = topLevelWidget()->y();
2803#else 2810#else
2804 int w =mDatePicker->sizeHint().width() ; 2811 int w =mDatePicker->sizeHint().width() ;
2805 int h = mDatePicker->sizeHint().height() ; 2812 int h = mDatePicker->sizeHint().height() ;
2806 int dw = QApplication::desktop()->width(); 2813 int dw = QApplication::desktop()->width();
2807 int dh = QApplication::desktop()->height(); 2814 int dh = QApplication::desktop()->height();
2808#endif 2815#endif
2809 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2816 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2810 mDateFrame->show(); 2817 mDateFrame->show();
2811 } 2818 }
2812} 2819}
2813void CalendarView::showDatePicker( ) 2820void CalendarView::showDatePicker( )
2814{ 2821{
2815 showDatePickerPopup(); 2822 showDatePickerPopup();
2816 mDatePickerMode = 1; 2823 mDatePickerMode = 1;
2817 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2824 mDatePicker->setDate( mNavigator->selectedDates().first() );
2818} 2825}
2819 2826
2820void CalendarView::showEventEditor() 2827void CalendarView::showEventEditor()
2821{ 2828{
2822#ifdef DESKTOP_VERSION 2829#ifdef DESKTOP_VERSION
2823 int x,y,w,h; 2830 int x,y,w,h;
2824 x = mEventEditor->geometry().x(); 2831 x = mEventEditor->geometry().x();
2825 y = mEventEditor->geometry().y(); 2832 y = mEventEditor->geometry().y();
2826 w = mEventEditor->width(); 2833 w = mEventEditor->width();
2827 h = mEventEditor->height(); 2834 h = mEventEditor->height();
2828 mEventEditor->show(); 2835 mEventEditor->show();
2829 mEventEditor->setGeometry(x,y,w,h); 2836 mEventEditor->setGeometry(x,y,w,h);
2830#else 2837#else
2831 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2838 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2832 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2839 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2833 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2840 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2834 qApp->processEvents(); 2841 qApp->processEvents();
2835 delete mEventEditor; 2842 delete mEventEditor;
2836 mEventEditor = mDialogManager->getEventEditor(); 2843 mEventEditor = mDialogManager->getEventEditor();
2837 topLevelWidget()->setCaption( i18n("") ); 2844 topLevelWidget()->setCaption( i18n("") );
2838 } 2845 }
2839 mEventEditor->showMaximized(); 2846 mEventEditor->showMaximized();
2840#endif 2847#endif
2841} 2848}
2842void CalendarView::showTodoEditor() 2849void CalendarView::showTodoEditor()
2843{ 2850{
2844#ifdef DESKTOP_VERSION 2851#ifdef DESKTOP_VERSION
2845 int x,y,w,h; 2852 int x,y,w,h;
2846 x = mTodoEditor->geometry().x(); 2853 x = mTodoEditor->geometry().x();
2847 y = mTodoEditor->geometry().y(); 2854 y = mTodoEditor->geometry().y();
2848 w = mTodoEditor->width(); 2855 w = mTodoEditor->width();
2849 h = mTodoEditor->height(); 2856 h = mTodoEditor->height();
2850 mTodoEditor->show(); 2857 mTodoEditor->show();
2851 mTodoEditor->setGeometry(x,y,w,h); 2858 mTodoEditor->setGeometry(x,y,w,h);
2852#else 2859#else
2853 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2860 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2854 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2861 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2855 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2862 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2856 qApp->processEvents(); 2863 qApp->processEvents();
2857 delete mTodoEditor; 2864 delete mTodoEditor;
2858 mTodoEditor = mDialogManager->getTodoEditor(); 2865 mTodoEditor = mDialogManager->getTodoEditor();
2859 topLevelWidget()->setCaption( i18n("") ); 2866 topLevelWidget()->setCaption( i18n("") );
2860 } 2867 }
2861 mTodoEditor->showMaximized(); 2868 mTodoEditor->showMaximized();
2862#endif 2869#endif
2863} 2870}
2864 2871
2865void CalendarView::cloneIncidence() 2872void CalendarView::cloneIncidence()
2866{ 2873{
2867 Incidence *incidence = currentSelection(); 2874 Incidence *incidence = currentSelection();
2868 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2875 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2869 if ( incidence ) { 2876 if ( incidence ) {
2870 cloneIncidence(incidence); 2877 cloneIncidence(incidence);
2871 } 2878 }
2872} 2879}
2873void CalendarView::moveIncidence() 2880void CalendarView::moveIncidence()
2874{ 2881{
2875 Incidence *incidence = currentSelection(); 2882 Incidence *incidence = currentSelection();
2876 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2883 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2877 if ( incidence ) { 2884 if ( incidence ) {
2878 moveIncidence(incidence); 2885 moveIncidence(incidence);
2879 } 2886 }
2880} 2887}
2881void CalendarView::beamIncidence() 2888void CalendarView::beamIncidence()
2882{ 2889{
2883 Incidence *incidence = currentSelection(); 2890 Incidence *incidence = currentSelection();
2884 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2891 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2885 if ( incidence ) { 2892 if ( incidence ) {
2886 beamIncidence(incidence); 2893 beamIncidence(incidence);
2887 } 2894 }
2888} 2895}
2889void CalendarView::toggleCancelIncidence() 2896void CalendarView::toggleCancelIncidence()
2890{ 2897{
2891 Incidence *incidence = currentSelection(); 2898 Incidence *incidence = currentSelection();
2892 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2899 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2893 if ( incidence ) { 2900 if ( incidence ) {
2894 cancelIncidence(incidence); 2901 cancelIncidence(incidence);
2895 } 2902 }
2896} 2903}
2897 2904
2898 2905
2899void CalendarView::cancelIncidence(Incidence * inc ) 2906void CalendarView::cancelIncidence(Incidence * inc )
2900{ 2907{
2901 inc->setCancelled( ! inc->cancelled() ); 2908 inc->setCancelled( ! inc->cancelled() );
2902 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2909 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2903 updateView(); 2910 updateView();
2904} 2911}
2905void CalendarView::cloneIncidence(Incidence * orgInc ) 2912void CalendarView::cloneIncidence(Incidence * orgInc )
2906{ 2913{
2907 Incidence * newInc = orgInc->clone(); 2914 Incidence * newInc = orgInc->clone();
2908 newInc->recreate(); 2915 newInc->recreate();
2909 2916
2910 if ( newInc->typeID() == todoID ) { 2917 if ( newInc->typeID() == todoID ) {
2911 Todo* t = (Todo*) newInc; 2918 Todo* t = (Todo*) newInc;
2912 bool cloneSub = false; 2919 bool cloneSub = false;
2913 if ( orgInc->relations().count() ) { 2920 if ( orgInc->relations().count() ) {
2914 int result = KMessageBox::warningYesNoCancel(this, 2921 int result = KMessageBox::warningYesNoCancel(this,
2915 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 ) ), 2922 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2916 i18n("Todo has subtodos"), 2923 i18n("Todo has subtodos"),
2917 i18n("Yes"), 2924 i18n("Yes"),
2918 i18n("No")); 2925 i18n("No"));
2919 2926
2920 if ( result == KMessageBox::Cancel ) { 2927 if ( result == KMessageBox::Cancel ) {
2921 delete t; 2928 delete t;
2922 return; 2929 return;
2923 } 2930 }
2924 if (result == KMessageBox::Yes) cloneSub = true; 2931 if (result == KMessageBox::Yes) cloneSub = true;
2925 } 2932 }
2926 showTodoEditor(); 2933 showTodoEditor();
2927 mTodoEditor->editTodo( t ); 2934 mTodoEditor->editTodo( t );
2928 if ( mTodoEditor->exec() ) { 2935 if ( mTodoEditor->exec() ) {
2929 if ( cloneSub ) { 2936 if ( cloneSub ) {
2930 orgInc->cloneRelations( t ); 2937 orgInc->cloneRelations( t );
2931 mCalendar->addIncidenceBranch( t ); 2938 mCalendar->addIncidenceBranch( t );
2932 updateView(); 2939 updateView();
2933 2940
2934 } else { 2941 } else {
2935 mCalendar->addTodo( t ); 2942 mCalendar->addTodo( t );
2936 updateView(); 2943 updateView();
2937 } 2944 }
2938 } else { 2945 } else {
2939 delete t; 2946 delete t;
2940 } 2947 }
2941 } 2948 }
2942 else { 2949 else {
2943 Event* e = (Event*) newInc; 2950 Event* e = (Event*) newInc;
2944 showEventEditor(); 2951 showEventEditor();
2945 mEventEditor->editEvent( e ); 2952 mEventEditor->editEvent( e );
2946 if ( mEventEditor->exec() ) { 2953 if ( mEventEditor->exec() ) {
2947 mCalendar->addEvent( e ); 2954 mCalendar->addEvent( e );
2948 updateView(); 2955 updateView();
2949 } else { 2956 } else {
2950 delete e; 2957 delete e;
2951 } 2958 }
2952 } 2959 }
2953 setActiveWindow(); 2960 setActiveWindow();
2954} 2961}
2955 2962
2956void CalendarView::newEvent() 2963void CalendarView::newEvent()
2957{ 2964{
2958 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2965 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2959 KOAgendaView *aView = mViewManager->agendaView(); 2966 KOAgendaView *aView = mViewManager->agendaView();
2960 if (aView) { 2967 if (aView) {
2961 if (aView->selectionStart().isValid()) { 2968 if (aView->selectionStart().isValid()) {
2962 if (aView->selectedIsAllDay()) { 2969 if (aView->selectedIsAllDay()) {
2963 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2970 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2964 } else { 2971 } else {
2965 newEvent(aView->selectionStart(),aView->selectionEnd()); 2972 newEvent(aView->selectionStart(),aView->selectionEnd());
2966 } 2973 }
2967 return; 2974 return;
2968 } 2975 }
2969 } 2976 }
2970 2977
2971 QDate date = mNavigator->selectedDates().first(); 2978 QDate date = mNavigator->selectedDates().first();
2972 QDateTime current = QDateTime::currentDateTime(); 2979 QDateTime current = QDateTime::currentDateTime();
2973 if ( date <= current.date() ) { 2980 if ( date <= current.date() ) {
2974 int hour = current.time().hour() +1; 2981 int hour = current.time().hour() +1;
2975 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2982 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2976 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2983 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2977 } else 2984 } else
2978 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2985 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2979 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2986 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2980 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2987 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2981} 2988}
2982 2989
2983void CalendarView::newEvent(QDateTime fh) 2990void CalendarView::newEvent(QDateTime fh)
2984{ 2991{
2985 newEvent(fh, 2992 newEvent(fh,
2986 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2993 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2987} 2994}
2988 2995
2989void CalendarView::newEvent(QDate dt) 2996void CalendarView::newEvent(QDate dt)
2990{ 2997{
2991 newEvent(QDateTime(dt, QTime(0,0,0)), 2998 newEvent(QDateTime(dt, QTime(0,0,0)),
2992 QDateTime(dt, QTime(0,0,0)), true); 2999 QDateTime(dt, QTime(0,0,0)), true);
2993} 3000}
2994void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3001void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2995{ 3002{
2996 newEvent(fromHint, toHint, false); 3003 newEvent(fromHint, toHint, false);
2997} 3004}
2998void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3005void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2999{ 3006{
3000 3007
3001 showEventEditor(); 3008 showEventEditor();
3002 mEventEditor->newEvent(fromHint,toHint,allDay); 3009 mEventEditor->newEvent(fromHint,toHint,allDay);
3003 if ( mFilterView->filtersEnabled() ) { 3010 if ( mFilterView->filtersEnabled() ) {
3004 CalFilter *filter = mFilterView->selectedFilter(); 3011 CalFilter *filter = mFilterView->selectedFilter();
3005 if (filter && filter->showCategories()) { 3012 if (filter && filter->showCategories()) {
3006 mEventEditor->setCategories(filter->categoryList().join(",") ); 3013 mEventEditor->setCategories(filter->categoryList().join(",") );
3007 } 3014 }
3008 if ( filter ) 3015 if ( filter )
3009 mEventEditor->setSecrecy( filter->getSecrecy() ); 3016 mEventEditor->setSecrecy( filter->getSecrecy() );
3010 } 3017 }
3011 mEventEditor->exec(); 3018 mEventEditor->exec();
3012 setActiveWindow(); 3019 setActiveWindow();
3013} 3020}
3014void CalendarView::todoAdded(Todo * t) 3021void CalendarView::todoAdded(Todo * t)
3015{ 3022{
3016 3023
3017 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3024 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3018 updateTodoViews(); 3025 updateTodoViews();
3019} 3026}
3020void CalendarView::todoChanged(Todo * t) 3027void CalendarView::todoChanged(Todo * t)
3021{ 3028{
3022 emit todoModified( t, 4 ); 3029 emit todoModified( t, 4 );
3023 // updateTodoViews(); 3030 // updateTodoViews();
3024} 3031}
3025void CalendarView::todoToBeDeleted(Todo *) 3032void CalendarView::todoToBeDeleted(Todo *)
3026{ 3033{
3027 //qDebug("todoToBeDeleted(Todo *) "); 3034 //qDebug("todoToBeDeleted(Todo *) ");
3028 updateTodoViews(); 3035 updateTodoViews();
3029} 3036}
3030void CalendarView::todoDeleted() 3037void CalendarView::todoDeleted()
3031{ 3038{
3032 //qDebug(" todoDeleted()"); 3039 //qDebug(" todoDeleted()");
3033 updateTodoViews(); 3040 updateTodoViews();
3034} 3041}
3035 3042
3036 3043
3037void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3044void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3038{ 3045{
3039 showTodoEditor(); 3046 showTodoEditor();
3040 mTodoEditor->newTodo(dt,0,allday); 3047 mTodoEditor->newTodo(dt,0,allday);
3041 if ( mFilterView->filtersEnabled() ) { 3048 if ( mFilterView->filtersEnabled() ) {
3042 CalFilter *filter = mFilterView->selectedFilter(); 3049 CalFilter *filter = mFilterView->selectedFilter();
3043 if (filter && filter->showCategories()) { 3050 if (filter && filter->showCategories()) {
3044 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3051 mTodoEditor->setCategories(filter->categoryList().join(",") );
3045 } 3052 }
3046 if ( filter ) 3053 if ( filter )
3047 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3054 mTodoEditor->setSecrecy( filter->getSecrecy() );
3048 } 3055 }
3049 mTodoEditor->exec(); 3056 mTodoEditor->exec();
3050 setActiveWindow(); 3057 setActiveWindow();
3051} 3058}
3052 3059
3053void CalendarView::newTodo() 3060void CalendarView::newTodo()
3054{ 3061{
3055 newTodoDateTime( QDateTime(),true ); 3062 newTodoDateTime( QDateTime(),true );
3056} 3063}
3057 3064
3058void CalendarView::newSubTodo() 3065void CalendarView::newSubTodo()
3059{ 3066{
3060 Todo *todo = selectedTodo(); 3067 Todo *todo = selectedTodo();
3061 if ( todo ) newSubTodo( todo ); 3068 if ( todo ) newSubTodo( todo );
3062} 3069}
3063 3070
3064void CalendarView::newSubTodo(Todo *parentEvent) 3071void CalendarView::newSubTodo(Todo *parentEvent)
3065{ 3072{
3066 3073
3067 showTodoEditor(); 3074 showTodoEditor();
3068 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3075 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3069 mTodoEditor->exec(); 3076 mTodoEditor->exec();
3070 setActiveWindow(); 3077 setActiveWindow();
3071} 3078}
3072 3079
3073void CalendarView::newFloatingEvent() 3080void CalendarView::newFloatingEvent()
3074{ 3081{
3075 DateList tmpList = mNavigator->selectedDates(); 3082 DateList tmpList = mNavigator->selectedDates();
3076 QDate date = tmpList.first(); 3083 QDate date = tmpList.first();
3077 3084
3078 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3085 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3079 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3086 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3080} 3087}
3081 3088
3082 3089
3083void CalendarView::editEvent( Event *event ) 3090void CalendarView::editEvent( Event *event )
3084{ 3091{
3085 3092
3086 if ( !event ) return; 3093 if ( !event ) return;
3087 if ( event->isReadOnly() ) { 3094 if ( event->isReadOnly() ) {
3088 showEvent( event ); 3095 showEvent( event );
3089 return; 3096 return;
3090 } 3097 }
3091 showEventEditor(); 3098 showEventEditor();
3092 mEventEditor->editEvent( event , mFlagEditDescription); 3099 mEventEditor->editEvent( event , mFlagEditDescription);
3093 mEventEditor->exec(); 3100 mEventEditor->exec();
3094 setActiveWindow(); 3101 setActiveWindow();
3095 3102
3096} 3103}
3097void CalendarView::editJournal( Journal *jour ) 3104void CalendarView::editJournal( Journal *jour )
3098{ 3105{
3099 if ( !jour ) return; 3106 if ( !jour ) return;
3100 mDialogManager->hideSearchDialog(); 3107 mDialogManager->hideSearchDialog();
3101 mViewManager->showJournalView(); 3108 mViewManager->showJournalView();
3102 mNavigator->slotDaySelect( jour->dtStart().date() ); 3109 mNavigator->slotDaySelect( jour->dtStart().date() );
3103} 3110}
3104void CalendarView::editTodo( Todo *todo ) 3111void CalendarView::editTodo( Todo *todo )
3105{ 3112{
3106 if ( !todo ) return; 3113 if ( !todo ) return;
3107 3114
3108 if ( todo->isReadOnly() ) { 3115 if ( todo->isReadOnly() ) {
3109 showTodo( todo ); 3116 showTodo( todo );
3110 return; 3117 return;
3111 } 3118 }
3112 showTodoEditor(); 3119 showTodoEditor();
3113 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3120 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3114 mTodoEditor->exec(); 3121 mTodoEditor->exec();
3115 setActiveWindow(); 3122 setActiveWindow();
3116 3123
3117} 3124}
3118 3125
3119KOEventViewerDialog* CalendarView::getEventViewerDialog() 3126KOEventViewerDialog* CalendarView::getEventViewerDialog()
3120{ 3127{
3121 if ( !mEventViewerDialog ) { 3128 if ( !mEventViewerDialog ) {
3122 mEventViewerDialog = new KOEventViewerDialog(0); 3129 mEventViewerDialog = new KOEventViewerDialog(0);
3123 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3130 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3124 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3131 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3125 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3132 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3126 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3133 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3127 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3134 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3128 viewManager(), SLOT( showAgendaView( bool ) ) ); 3135 viewManager(), SLOT( showAgendaView( bool ) ) );
3129 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3136 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3130 this, SLOT( slotViewerClosed() ) ); 3137 this, SLOT( slotViewerClosed() ) );
3131 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3138 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3132 this, SLOT( todoChanged(Todo *) ) ); 3139 this, SLOT( todoChanged(Todo *) ) );
3133 mEventViewerDialog->resize( 640, 480 ); 3140 mEventViewerDialog->resize( 640, 480 );
3134 3141
3135 } 3142 }
3136 return mEventViewerDialog; 3143 return mEventViewerDialog;
3137} 3144}
3138void CalendarView::showEvent(Event *event) 3145void CalendarView::showEvent(Event *event)
3139{ 3146{
3140 getEventViewerDialog()->setEvent(event); 3147 getEventViewerDialog()->setEvent(event);
3141 getEventViewerDialog()->showMe(); 3148 getEventViewerDialog()->showMe();
3142} 3149}
3143 3150
3144void CalendarView::showTodo(Todo *event) 3151void CalendarView::showTodo(Todo *event)
3145{ 3152{
3146 getEventViewerDialog()->setTodo(event); 3153 getEventViewerDialog()->setTodo(event);
3147 getEventViewerDialog()->showMe(); 3154 getEventViewerDialog()->showMe();
3148} 3155}
3149void CalendarView::showJournal( Journal *jour ) 3156void CalendarView::showJournal( Journal *jour )
3150{ 3157{
3151 getEventViewerDialog()->setJournal(jour); 3158 getEventViewerDialog()->setJournal(jour);
3152 getEventViewerDialog()->showMe(); 3159 getEventViewerDialog()->showMe();
3153 3160
3154} 3161}
3155// void CalendarView::todoModified (Todo *event, int changed) 3162// void CalendarView::todoModified (Todo *event, int changed)
3156// { 3163// {
3157// // if (mDialogList.find (event) != mDialogList.end ()) { 3164// // if (mDialogList.find (event) != mDialogList.end ()) {
3158// // kdDebug() << "Todo modified and open" << endl; 3165// // kdDebug() << "Todo modified and open" << endl;
3159// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3166// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3160// // temp->modified (changed); 3167// // temp->modified (changed);
3161 3168
3162// // } 3169// // }
3163 3170
3164// mViewManager->updateView(); 3171// mViewManager->updateView();
3165// } 3172// }
3166 3173
3167void CalendarView::appointment_show() 3174void CalendarView::appointment_show()
3168{ 3175{
3169 Event *anEvent = 0; 3176 Event *anEvent = 0;
3170 3177
3171 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3178 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3172 3179
3173 if (mViewManager->currentView()->isEventView()) { 3180 if (mViewManager->currentView()->isEventView()) {
3174 if ( incidence && incidence->typeID() == eventID ) { 3181 if ( incidence && incidence->typeID() == eventID ) {
3175 anEvent = static_cast<Event *>(incidence); 3182 anEvent = static_cast<Event *>(incidence);
3176 } 3183 }
3177 } 3184 }
3178 3185
3179 if (!anEvent) { 3186 if (!anEvent) {
3180 KNotifyClient::beep(); 3187 KNotifyClient::beep();
3181 return; 3188 return;
3182 } 3189 }
3183 3190
3184 showEvent(anEvent); 3191 showEvent(anEvent);
3185} 3192}
3186 3193
3187void CalendarView::appointment_edit() 3194void CalendarView::appointment_edit()
3188{ 3195{
3189 Event *anEvent = 0; 3196 Event *anEvent = 0;
3190 3197
3191 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3198 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3192 3199
3193 if (mViewManager->currentView()->isEventView()) { 3200 if (mViewManager->currentView()->isEventView()) {
3194 if ( incidence && incidence->typeID() == eventID ) { 3201 if ( incidence && incidence->typeID() == eventID ) {
3195 anEvent = static_cast<Event *>(incidence); 3202 anEvent = static_cast<Event *>(incidence);
3196 } 3203 }
3197 } 3204 }
3198 3205
3199 if (!anEvent) { 3206 if (!anEvent) {
3200 KNotifyClient::beep(); 3207 KNotifyClient::beep();
3201 return; 3208 return;
3202 } 3209 }
3203 3210
3204 editEvent(anEvent); 3211 editEvent(anEvent);
3205} 3212}
3206 3213
3207void CalendarView::appointment_delete() 3214void CalendarView::appointment_delete()
3208{ 3215{
3209 Event *anEvent = 0; 3216 Event *anEvent = 0;
3210 3217
3211 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3218 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3212 3219
3213 if (mViewManager->currentView()->isEventView()) { 3220 if (mViewManager->currentView()->isEventView()) {
3214 if ( incidence && incidence->typeID() == eventID ) { 3221 if ( incidence && incidence->typeID() == eventID ) {
3215 anEvent = static_cast<Event *>(incidence); 3222 anEvent = static_cast<Event *>(incidence);
3216 } 3223 }
3217 } 3224 }
3218 3225
3219 if (!anEvent) { 3226 if (!anEvent) {
3220 KNotifyClient::beep(); 3227 KNotifyClient::beep();
3221 return; 3228 return;
3222 } 3229 }
3223 3230
3224 deleteEvent(anEvent); 3231 deleteEvent(anEvent);
3225} 3232}
3226 3233
3227void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3234void CalendarView::todo_resub( Todo * parent, Todo * sub )
3228{ 3235{
3229 if (!sub) return; 3236 if (!sub) return;
3230 if ( sub->relatedTo() == parent ) 3237 if ( sub->relatedTo() == parent )
3231 return; 3238 return;
3232 sub->setRelatedTo(parent); 3239 sub->setRelatedTo(parent);
3233 sub->updated(); 3240 sub->updated();
3234 setModified(true); 3241 setModified(true);
3235 updateView(); 3242 updateView();
3236} 3243}
3237void CalendarView::todo_unsub(Todo *anTodo ) 3244void CalendarView::todo_unsub(Todo *anTodo )
3238{ 3245{
3239 todo_resub( 0, anTodo ); 3246 todo_resub( 0, anTodo );
3240} 3247}
3241 3248
3242void CalendarView::deleteTodo(Todo *todo) 3249void CalendarView::deleteTodo(Todo *todo)
3243{ 3250{
3244 if (!todo) { 3251 if (!todo) {
3245 KNotifyClient::beep(); 3252 KNotifyClient::beep();
3246 return; 3253 return;
3247 } 3254 }
3248 if (KOPrefs::instance()->mConfirm) { 3255 if (KOPrefs::instance()->mConfirm) {
3249 QString text = todo->summary().left(20); 3256 QString text = todo->summary().left(20);
3250 if (!todo->relations().isEmpty()) { 3257 if (!todo->relations().isEmpty()) {
3251 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3258 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3252 3259
3253 } 3260 }
3254 switch (msgItemDelete(text)) { 3261 switch (msgItemDelete(text)) {
3255 case KMessageBox::Continue: // OK 3262 case KMessageBox::Continue: // OK
3256 bool deleteT = false; 3263 bool deleteT = false;
3257 if (!todo->relations().isEmpty()) { 3264 if (!todo->relations().isEmpty()) {
3258 deleteT = removeCompletedSubTodos( todo ); 3265 deleteT = removeCompletedSubTodos( todo );
3259 } 3266 }
3260 // deleteT == true: todo already deleted in removeCompletedSubTodos 3267 // deleteT == true: todo already deleted in removeCompletedSubTodos
3261 if ( !deleteT ) { 3268 if ( !deleteT ) {
3262 checkExternalId( todo ); 3269 checkExternalId( todo );
3263 calendar()->deleteTodo(todo); 3270 calendar()->deleteTodo(todo);
3264 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3271 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3265 updateView(); 3272 updateView();
3266 } 3273 }
3267 break; 3274 break;
3268 } // switch 3275 } // switch
3269 } else { 3276 } else {
3270 checkExternalId( todo ); 3277 checkExternalId( todo );
3271 mCalendar->deleteTodo(todo); 3278 mCalendar->deleteTodo(todo);
3272 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3279 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3273 updateView(); 3280 updateView();
3274 } 3281 }
3275 3282
3276 emit updateSearchDialog(); 3283 emit updateSearchDialog();
3277} 3284}
3278void CalendarView::deleteJournal(Journal *jour) 3285void CalendarView::deleteJournal(Journal *jour)
3279{ 3286{
3280 if (!jour) { 3287 if (!jour) {
3281 KNotifyClient::beep(); 3288 KNotifyClient::beep();
3282 return; 3289 return;
3283 } 3290 }
3284 if (KOPrefs::instance()->mConfirm) { 3291 if (KOPrefs::instance()->mConfirm) {
3285 switch (msgItemDelete( jour->description().left(20))) { 3292 switch (msgItemDelete( jour->description().left(20))) {
3286 case KMessageBox::Continue: // OK 3293 case KMessageBox::Continue: // OK
3287 calendar()->deleteJournal(jour); 3294 calendar()->deleteJournal(jour);
3288 updateView(); 3295 updateView();
3289 break; 3296 break;
3290 } // switch 3297 } // switch
3291 } else { 3298 } else {
3292 calendar()->deleteJournal(jour);; 3299 calendar()->deleteJournal(jour);;
3293 updateView(); 3300 updateView();
3294 } 3301 }
3295 emit updateSearchDialog(); 3302 emit updateSearchDialog();
3296} 3303}
3297 3304
3298void CalendarView::deleteEvent(Event *anEvent) 3305void CalendarView::deleteEvent(Event *anEvent)
3299{ 3306{
3300 if (!anEvent) { 3307 if (!anEvent) {
3301 KNotifyClient::beep(); 3308 KNotifyClient::beep();
3302 return; 3309 return;
3303 } 3310 }
3304 3311
3305 if (anEvent->recurrence()->doesRecur()) { 3312 if (anEvent->recurrence()->doesRecur()) {
3306 QDate itemDate = mViewManager->currentSelectionDate(); 3313 QDate itemDate = mViewManager->currentSelectionDate();
3307 int km; 3314 int km;
3308 if (!itemDate.isValid()) { 3315 if (!itemDate.isValid()) {
3309 //kdDebug() << "Date Not Valid" << endl; 3316 //kdDebug() << "Date Not Valid" << endl;
3310 if (KOPrefs::instance()->mConfirm) { 3317 if (KOPrefs::instance()->mConfirm) {
3311 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3318 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3312 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3319 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3313 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3320 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3314 if ( km == KMessageBox::Continue ) 3321 if ( km == KMessageBox::Continue )
3315 km = KMessageBox::No; // No = all below 3322 km = KMessageBox::No; // No = all below
3316 } else 3323 } else
3317 km = KMessageBox::No; 3324 km = KMessageBox::No;
3318 } else { 3325 } else {
3319 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3326 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3320 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3327 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3321 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3328 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3322 i18n("KO/Pi Confirmation"),i18n("Current"), 3329 i18n("KO/Pi Confirmation"),i18n("Current"),
3323 i18n("All")); 3330 i18n("All"));
3324 } 3331 }
3325 switch(km) { 3332 switch(km) {
3326 3333
3327 case KMessageBox::No: // Continue // all 3334 case KMessageBox::No: // Continue // all
3328 //qDebug("KMessageBox::No "); 3335 //qDebug("KMessageBox::No ");
3329 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3336 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3330 schedule(Scheduler::Cancel,anEvent); 3337 schedule(Scheduler::Cancel,anEvent);
3331 3338
3332 checkExternalId( anEvent); 3339 checkExternalId( anEvent);
3333 mCalendar->deleteEvent(anEvent); 3340 mCalendar->deleteEvent(anEvent);
3334 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3341 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3335 break; 3342 break;
3336 3343
3337 // Disabled because it does not work 3344 // Disabled because it does not work
3338 //#if 0 3345 //#if 0
3339 case KMessageBox::Yes: // just this one 3346 case KMessageBox::Yes: // just this one
3340 //QDate qd = mNavigator->selectedDates().first(); 3347 //QDate qd = mNavigator->selectedDates().first();
3341 //if (!qd.isValid()) { 3348 //if (!qd.isValid()) {
3342 // kdDebug() << "no date selected, or invalid date" << endl; 3349 // kdDebug() << "no date selected, or invalid date" << endl;
3343 // KNotifyClient::beep(); 3350 // KNotifyClient::beep();
3344 // return; 3351 // return;
3345 //} 3352 //}
3346 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3353 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3347 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3354 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3348 anEvent->addExDate(itemDate); 3355 anEvent->addExDate(itemDate);
3349 int duration = anEvent->recurrence()->duration(); 3356 int duration = anEvent->recurrence()->duration();
3350 if ( duration > 0 ) { 3357 if ( duration > 0 ) {
3351 anEvent->recurrence()->setDuration( duration - 1 ); 3358 anEvent->recurrence()->setDuration( duration - 1 );
3352 } 3359 }
3353 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3360 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3354 } 3361 }
3355 break; 3362 break;
3356 //#endif 3363 //#endif
3357 } // switch 3364 } // switch
3358 } else { 3365 } else {
3359 if (KOPrefs::instance()->mConfirm) { 3366 if (KOPrefs::instance()->mConfirm) {
3360 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3367 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3361 i18n("\nAre you sure you want\nto delete this event?"), 3368 i18n("\nAre you sure you want\nto delete this event?"),
3362 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3369 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3363 case KMessageBox::Continue: // OK 3370 case KMessageBox::Continue: // OK
3364 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3371 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3365 schedule(Scheduler::Cancel,anEvent); 3372 schedule(Scheduler::Cancel,anEvent);
3366 checkExternalId( anEvent); 3373 checkExternalId( anEvent);
3367 mCalendar->deleteEvent(anEvent); 3374 mCalendar->deleteEvent(anEvent);
3368 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3375 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3369 break; 3376 break;
3370 } // switch 3377 } // switch
3371 } else { 3378 } else {
3372 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3379 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3373 schedule(Scheduler::Cancel,anEvent); 3380 schedule(Scheduler::Cancel,anEvent);
3374 checkExternalId( anEvent); 3381 checkExternalId( anEvent);
3375 mCalendar->deleteEvent(anEvent); 3382 mCalendar->deleteEvent(anEvent);
3376 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3383 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3377 } 3384 }
3378 } // if-else 3385 } // if-else
3379 emit updateSearchDialog(); 3386 emit updateSearchDialog();
3380} 3387}
3381 3388
3382bool CalendarView::deleteEvent(const QString &uid) 3389bool CalendarView::deleteEvent(const QString &uid)
3383{ 3390{
3384 Event *ev = mCalendar->event(uid); 3391 Event *ev = mCalendar->event(uid);
3385 if (ev) { 3392 if (ev) {
3386 deleteEvent(ev); 3393 deleteEvent(ev);
3387 return true; 3394 return true;
3388 } else { 3395 } else {
3389 return false; 3396 return false;
3390 } 3397 }
3391} 3398}
3392 3399
3393/*****************************************************************************/ 3400/*****************************************************************************/
3394 3401
3395void CalendarView::action_mail() 3402void CalendarView::action_mail()
3396{ 3403{
3397#ifndef KORG_NOMAIL 3404#ifndef KORG_NOMAIL
3398 KOMailClient mailClient; 3405 KOMailClient mailClient;
3399 3406
3400 Incidence *incidence = currentSelection(); 3407 Incidence *incidence = currentSelection();
3401 3408
3402 if (!incidence) { 3409 if (!incidence) {
3403 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3410 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3404 return; 3411 return;
3405 } 3412 }
3406 if(incidence->attendeeCount() == 0 ) { 3413 if(incidence->attendeeCount() == 0 ) {
3407 KMessageBox::sorry(this, 3414 KMessageBox::sorry(this,
3408 i18n("Can't generate mail:\nNo attendees defined.\n")); 3415 i18n("Can't generate mail:\nNo attendees defined.\n"));
3409 return; 3416 return;
3410 } 3417 }
3411 3418
3412 CalendarLocal cal_tmp; 3419 CalendarLocal cal_tmp;
3413 Event *event = 0; 3420 Event *event = 0;
3414 Event *ev = 0; 3421 Event *ev = 0;
3415 if ( incidence && incidence->typeID() == eventID ) { 3422 if ( incidence && incidence->typeID() == eventID ) {
3416 event = static_cast<Event *>(incidence); 3423 event = static_cast<Event *>(incidence);
3417 ev = new Event(*event); 3424 ev = new Event(*event);
3418 cal_tmp.addEvent(ev); 3425 cal_tmp.addEvent(ev);
3419 } 3426 }
3420 ICalFormat mForm(); 3427 ICalFormat mForm();
3421 QString attachment = mForm.toString( &cal_tmp ); 3428 QString attachment = mForm.toString( &cal_tmp );
3422 if (ev) delete(ev); 3429 if (ev) delete(ev);
3423 3430
3424 mailClient.mailAttendees(currentSelection(), attachment); 3431 mailClient.mailAttendees(currentSelection(), attachment);
3425 3432
3426#endif 3433#endif
3427 3434
3428#if 0 3435#if 0
3429 Event *anEvent = 0; 3436 Event *anEvent = 0;
3430 if (mViewManager->currentView()->isEventView()) { 3437 if (mViewManager->currentView()->isEventView()) {
3431 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3438 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3432 } 3439 }
3433 3440
3434 if (!anEvent) { 3441 if (!anEvent) {
3435 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3442 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3436 return; 3443 return;
3437 } 3444 }
3438 if(anEvent->attendeeCount() == 0 ) { 3445 if(anEvent->attendeeCount() == 0 ) {
3439 KMessageBox::sorry(this, 3446 KMessageBox::sorry(this,
3440 i18n("Can't generate mail:\nNo attendees defined.\n")); 3447 i18n("Can't generate mail:\nNo attendees defined.\n"));
3441 return; 3448 return;
3442 } 3449 }
3443 3450
3444 mailobject.emailEvent(anEvent); 3451 mailobject.emailEvent(anEvent);
3445#endif 3452#endif
3446} 3453}
3447 3454
3448 3455
3449void CalendarView::schedule_publish(Incidence *incidence) 3456void CalendarView::schedule_publish(Incidence *incidence)
3450{ 3457{
3451 Event *event = 0; 3458 Event *event = 0;
3452 Todo *todo = 0; 3459 Todo *todo = 0;
3453 3460
3454 if (incidence == 0) { 3461 if (incidence == 0) {
3455 incidence = mViewManager->currentView()->selectedIncidences().first(); 3462 incidence = mViewManager->currentView()->selectedIncidences().first();
3456 if (incidence == 0) { 3463 if (incidence == 0) {
3457 incidence = mTodoList->selectedIncidences().first(); 3464 incidence = mTodoList->selectedIncidences().first();
3458 } 3465 }
3459 } 3466 }
3460 if ( incidence && incidence->typeID() == eventID ) { 3467 if ( incidence && incidence->typeID() == eventID ) {
3461 event = static_cast<Event *>(incidence); 3468 event = static_cast<Event *>(incidence);
3462 } else { 3469 } else {
3463 if ( incidence && incidence->typeID() == todoID ) { 3470 if ( incidence && incidence->typeID() == todoID ) {
3464 todo = static_cast<Todo *>(incidence); 3471 todo = static_cast<Todo *>(incidence);
3465 } 3472 }
3466 } 3473 }
3467 3474
3468 if (!event && !todo) { 3475 if (!event && !todo) {
3469 KMessageBox::sorry(this,i18n("No event selected.")); 3476 KMessageBox::sorry(this,i18n("No event selected."));
3470 return; 3477 return;
3471 } 3478 }
3472 3479
3473 PublishDialog *publishdlg = new PublishDialog(); 3480 PublishDialog *publishdlg = new PublishDialog();
3474 if (incidence->attendeeCount()>0) { 3481 if (incidence->attendeeCount()>0) {
3475 QPtrList<Attendee> attendees = incidence->attendees(); 3482 QPtrList<Attendee> attendees = incidence->attendees();
3476 attendees.first(); 3483 attendees.first();
3477 while ( attendees.current()!=0 ) { 3484 while ( attendees.current()!=0 ) {
3478 publishdlg->addAttendee(attendees.current()); 3485 publishdlg->addAttendee(attendees.current());
3479 attendees.next(); 3486 attendees.next();
3480 } 3487 }
3481 } 3488 }
3482 bool send = true; 3489 bool send = true;
3483 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3490 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3484 if ( publishdlg->exec() != QDialog::Accepted ) 3491 if ( publishdlg->exec() != QDialog::Accepted )
3485 send = false; 3492 send = false;
3486 } 3493 }
3487 if ( send ) { 3494 if ( send ) {
3488 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3495 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3489 if ( event ) { 3496 if ( event ) {
3490 Event *ev = new Event(*event); 3497 Event *ev = new Event(*event);
3491 ev->registerObserver(0); 3498 ev->registerObserver(0);
3492 ev->clearAttendees(); 3499 ev->clearAttendees();
3493 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3500 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3494 delete(ev); 3501 delete(ev);
3495 } 3502 }
3496 } else { 3503 } else {
3497 if ( todo ) { 3504 if ( todo ) {
3498 Todo *ev = new Todo(*todo); 3505 Todo *ev = new Todo(*todo);
3499 ev->registerObserver(0); 3506 ev->registerObserver(0);
3500 ev->clearAttendees(); 3507 ev->clearAttendees();
3501 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3508 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3502 delete(ev); 3509 delete(ev);
3503 } 3510 }
3504 } 3511 }
3505 } 3512 }
3506 } 3513 }
3507 delete publishdlg; 3514 delete publishdlg;
3508} 3515}
3509 3516
3510void CalendarView::schedule_request(Incidence *incidence) 3517void CalendarView::schedule_request(Incidence *incidence)
3511{ 3518{
3512 schedule(Scheduler::Request,incidence); 3519 schedule(Scheduler::Request,incidence);
3513} 3520}
3514 3521
3515void CalendarView::schedule_refresh(Incidence *incidence) 3522void CalendarView::schedule_refresh(Incidence *incidence)
3516{ 3523{
3517 schedule(Scheduler::Refresh,incidence); 3524 schedule(Scheduler::Refresh,incidence);
3518} 3525}
3519 3526
3520void CalendarView::schedule_cancel(Incidence *incidence) 3527void CalendarView::schedule_cancel(Incidence *incidence)
3521{ 3528{
3522 schedule(Scheduler::Cancel,incidence); 3529 schedule(Scheduler::Cancel,incidence);
3523} 3530}
3524 3531
3525void CalendarView::schedule_add(Incidence *incidence) 3532void CalendarView::schedule_add(Incidence *incidence)
3526{ 3533{
3527 schedule(Scheduler::Add,incidence); 3534 schedule(Scheduler::Add,incidence);
3528} 3535}
3529 3536
3530void CalendarView::schedule_reply(Incidence *incidence) 3537void CalendarView::schedule_reply(Incidence *incidence)
3531{ 3538{
3532 schedule(Scheduler::Reply,incidence); 3539 schedule(Scheduler::Reply,incidence);
3533} 3540}
3534 3541
3535void CalendarView::schedule_counter(Incidence *incidence) 3542void CalendarView::schedule_counter(Incidence *incidence)
3536{ 3543{
3537 schedule(Scheduler::Counter,incidence); 3544 schedule(Scheduler::Counter,incidence);
3538} 3545}
3539 3546
3540void CalendarView::schedule_declinecounter(Incidence *incidence) 3547void CalendarView::schedule_declinecounter(Incidence *incidence)
3541{ 3548{
3542 schedule(Scheduler::Declinecounter,incidence); 3549 schedule(Scheduler::Declinecounter,incidence);
3543} 3550}
3544 3551
3545void CalendarView::schedule_publish_freebusy(int daysToPublish) 3552void CalendarView::schedule_publish_freebusy(int daysToPublish)
3546{ 3553{
3547 QDateTime start = QDateTime::currentDateTime(); 3554 QDateTime start = QDateTime::currentDateTime();
3548 QDateTime end = start.addDays(daysToPublish); 3555 QDateTime end = start.addDays(daysToPublish);
3549 3556
3550 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3557 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3551 freebusy->setOrganizer(KOPrefs::instance()->email()); 3558 freebusy->setOrganizer(KOPrefs::instance()->email());
3552 3559
3553 3560
3554 PublishDialog *publishdlg = new PublishDialog(); 3561 PublishDialog *publishdlg = new PublishDialog();
3555 if ( publishdlg->exec() == QDialog::Accepted ) { 3562 if ( publishdlg->exec() == QDialog::Accepted ) {
3556 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3563 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3557 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3564 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3558 delete(freebusy); 3565 delete(freebusy);
3559 } 3566 }
3560 } 3567 }
3561 delete publishdlg; 3568 delete publishdlg;
3562} 3569}
3563 3570
3564void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3571void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3565{ 3572{
3566 Event *event = 0; 3573 Event *event = 0;
3567 Todo *todo = 0; 3574 Todo *todo = 0;
3568 3575
3569 if (incidence == 0) { 3576 if (incidence == 0) {
3570 incidence = mViewManager->currentView()->selectedIncidences().first(); 3577 incidence = mViewManager->currentView()->selectedIncidences().first();
3571 if (incidence == 0) { 3578 if (incidence == 0) {
3572 incidence = mTodoList->selectedIncidences().first(); 3579 incidence = mTodoList->selectedIncidences().first();
3573 } 3580 }
3574 } 3581 }
3575 if ( incidence && incidence->typeID() == eventID ) { 3582 if ( incidence && incidence->typeID() == eventID ) {
3576 event = static_cast<Event *>(incidence); 3583 event = static_cast<Event *>(incidence);
3577 } 3584 }
3578 if ( incidence && incidence->typeID() == todoID ) { 3585 if ( incidence && incidence->typeID() == todoID ) {
3579 todo = static_cast<Todo *>(incidence); 3586 todo = static_cast<Todo *>(incidence);
3580 } 3587 }
3581 3588
3582 if (!event && !todo) { 3589 if (!event && !todo) {
3583 KMessageBox::sorry(this,i18n("No event selected.")); 3590 KMessageBox::sorry(this,i18n("No event selected."));
3584 return; 3591 return;
3585 } 3592 }
3586 3593
3587 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3594 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3588 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3595 KMessageBox::sorry(this,i18n("The event has no attendees."));
3589 return; 3596 return;
3590 } 3597 }
3591 3598
3592 Event *ev = 0; 3599 Event *ev = 0;
3593 if (event) ev = new Event(*event); 3600 if (event) ev = new Event(*event);
3594 Todo *to = 0; 3601 Todo *to = 0;
3595 if (todo) to = new Todo(*todo); 3602 if (todo) to = new Todo(*todo);
3596 3603
3597 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3604 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3598 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3605 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3599 if (!me) { 3606 if (!me) {
3600 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3607 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3601 return; 3608 return;
3602 } 3609 }
3603 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3610 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3604 StatusDialog *statdlg = new StatusDialog(this); 3611 StatusDialog *statdlg = new StatusDialog(this);
3605 if (!statdlg->exec()==QDialog::Accepted) return; 3612 if (!statdlg->exec()==QDialog::Accepted) return;
3606 me->setStatus( statdlg->status() ); 3613 me->setStatus( statdlg->status() );
3607 delete(statdlg); 3614 delete(statdlg);
3608 } 3615 }
3609 Attendee *menew = new Attendee(*me); 3616 Attendee *menew = new Attendee(*me);
3610 if (ev) { 3617 if (ev) {
3611 ev->clearAttendees(); 3618 ev->clearAttendees();
3612 ev->addAttendee(menew,false); 3619 ev->addAttendee(menew,false);
3613 } else { 3620 } else {
3614 if (to) { 3621 if (to) {
3615 todo->clearAttendees(); 3622 todo->clearAttendees();
3616 todo->addAttendee(menew,false); 3623 todo->addAttendee(menew,false);
3617 } 3624 }
3618 } 3625 }
3619 } 3626 }
3620 3627
3621 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3628 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3622 if (ev) { 3629 if (ev) {
3623 if ( !dlg->addMessage(ev,method) ) delete(ev); 3630 if ( !dlg->addMessage(ev,method) ) delete(ev);
3624 } else { 3631 } else {
3625 if (to) { 3632 if (to) {
3626 if ( !dlg->addMessage(to,method) ) delete(to); 3633 if ( !dlg->addMessage(to,method) ) delete(to);
3627 } 3634 }
3628 } 3635 }
3629} 3636}
3630 3637
3631void CalendarView::openAddressbook() 3638void CalendarView::openAddressbook()
3632{ 3639{
3633 KRun::runCommand("kaddressbook"); 3640 KRun::runCommand("kaddressbook");
3634} 3641}
3635 3642
3636void CalendarView::setModified(bool modified) 3643void CalendarView::setModified(bool modified)
3637{ 3644{
3638 if ( modified ) 3645 if ( modified )
3639 emit signalmodified(); 3646 emit signalmodified();
3640 if (mModified != modified) { 3647 if (mModified != modified) {
3641 mModified = modified; 3648 mModified = modified;
3642 emit modifiedChanged(mModified); 3649 emit modifiedChanged(mModified);
3643 } 3650 }
3644} 3651}
3645 3652
3646bool CalendarView::isReadOnly() 3653bool CalendarView::isReadOnly()
3647{ 3654{
3648 return mReadOnly; 3655 return mReadOnly;
3649} 3656}
3650 3657
3651void CalendarView::setReadOnly(bool readOnly) 3658void CalendarView::setReadOnly(bool readOnly)
3652{ 3659{
3653 if (mReadOnly != readOnly) { 3660 if (mReadOnly != readOnly) {
3654 mReadOnly = readOnly; 3661 mReadOnly = readOnly;
3655 emit readOnlyChanged(mReadOnly); 3662 emit readOnlyChanged(mReadOnly);
3656 } 3663 }
3657} 3664}
3658 3665
3659bool CalendarView::isModified() 3666bool CalendarView::isModified()
3660{ 3667{
3661 return mModified; 3668 return mModified;
3662} 3669}
3663void CalendarView::slotprintSelInc() 3670void CalendarView::slotprintSelInc()
3664{ 3671{
3665 if ( currentSelection() == 0 ) { 3672 if ( currentSelection() == 0 ) {
3666 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3673 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3667 return; 3674 return;
3668 } 3675 }
3669 showIncidence(); 3676 showIncidence();
3670 getEventViewerDialog()->print(); 3677 getEventViewerDialog()->print();
3671 3678
3672} 3679}
3673void CalendarView::printSetup() 3680void CalendarView::printSetup()
3674{ 3681{
3675#ifndef KORG_NOPRINTER 3682#ifndef KORG_NOPRINTER
3676 createPrinter(); 3683 createPrinter();
3677 3684
3678 mCalPrinter->setupPrinter(); 3685 mCalPrinter->setupPrinter();
3679#endif 3686#endif
3680} 3687}
3681 3688
3682void CalendarView::print() 3689void CalendarView::print()
3683{ 3690{
3684#ifndef KORG_NOPRINTER 3691#ifndef KORG_NOPRINTER
3685 createPrinter(); 3692 createPrinter();
3686 3693
3687 DateList tmpDateList = mNavigator->selectedDates(); 3694 DateList tmpDateList = mNavigator->selectedDates();
3688 mCalPrinter->print(CalPrinter::Month, 3695 mCalPrinter->print(CalPrinter::Month,
3689 tmpDateList.first(), tmpDateList.last()); 3696 tmpDateList.first(), tmpDateList.last());
3690#endif 3697#endif
3691} 3698}
3692 3699
3693void CalendarView::printPreview() 3700void CalendarView::printPreview()
3694{ 3701{
3695#ifndef KORG_NOPRINTER 3702#ifndef KORG_NOPRINTER
3696 kdDebug() << "CalendarView::printPreview()" << endl; 3703 kdDebug() << "CalendarView::printPreview()" << endl;
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index d3797ae..a0f9d2e 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -1,984 +1,986 @@
1/* 1/*
2 This file is part of KdePim/Pi. 2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h> 37#include <qbuttongroup.h>
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qvbox.h> 40#include <qvbox.h>
41#include <qdir.h> 41#include <qdir.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44 44
45#include <kdialog.h> 45#include <kdialog.h>
46#include <kprefsdialog.h> 46#include <kprefsdialog.h>
47#include <klocale.h> 47#include <klocale.h>
48#include <kglobalsettings.h> 48#include <kglobalsettings.h>
49#include <kdateedit.h> 49#include <kdateedit.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <stdlib.h> 51#include <stdlib.h>
52 52
53/*US 53/*US
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qframe.h> 55#include <qframe.h>
56#include <qpushbutton.h> 56#include <qpushbutton.h>
57#include <qcombobox.h> 57#include <qcombobox.h>
58#include <qlineedit.h> 58#include <qlineedit.h>
59#include <qlabel.h> 59#include <qlabel.h>
60#include <qfile.h> 60#include <qfile.h>
61 61
62#include <kconfig.h> 62#include <kconfig.h>
63#include <kdebug.h> 63#include <kdebug.h>
64#include <kdialog.h> 64#include <kdialog.h>
65#include <klistview.h> 65#include <klistview.h>
66#include <klocale.h> 66#include <klocale.h>
67#include <kglobal.h> 67#include <kglobal.h>
68#include <kmessagebox.h> 68#include <kmessagebox.h>
69#include <kstandarddirs.h> 69#include <kstandarddirs.h>
70 70
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72#include <ktrader.h> 72#include <ktrader.h>
73#else // KAB_EMBEDDED 73#else // KAB_EMBEDDED
74#include <mergewidget.h> 74#include <mergewidget.h>
75#include <distributionlistwidget.h> 75#include <distributionlistwidget.h>
76#endif // KAB_EMBEDDED 76#endif // KAB_EMBEDDED
77 77
78#include "addresseewidget.h" 78#include "addresseewidget.h"
79#include "extensionconfigdialog.h" 79#include "extensionconfigdialog.h"
80#include "extensionwidget.h" 80#include "extensionwidget.h"
81*/ 81*/
82 82
83#include "qapplication.h" 83#include "qapplication.h"
84 84
85#include "kpimglobalprefs.h" 85#include "kpimglobalprefs.h"
86 86
87#include "kdepimconfigwidget.h" 87#include "kdepimconfigwidget.h"
88#include <kprefs.h> 88#include <kprefs.h>
89#include <kmessagebox.h> 89#include <kmessagebox.h>
90 90
91 91
92KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) 92KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
93 : KPrefsWidget(prefs, parent, name ) 93 : KPrefsWidget(prefs, parent, name )
94{ 94{
95 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 95 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
96 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 96 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
97 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 97 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
98 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 98 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
99 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 99 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
100 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 100 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
101 101
102 102
103 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 103 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
104 KDialog::spacingHint() ); 104 KDialog::spacingHint() );
105 105
106 tabWidget = new QTabWidget( this ); 106 tabWidget = new QTabWidget( this );
107 topLayout->addWidget( tabWidget ); 107 topLayout->addWidget( tabWidget );
108 108
109 109
110 setupLocaleTab(); 110 setupLocaleTab();
111 setupLocaleDateTab(); 111 setupLocaleDateTab();
112 setupTimeZoneTab(); 112 setupTimeZoneTab();
113 setupExternalAppTab(); 113 setupExternalAppTab();
114 setupStoreTab(); 114 setupStoreTab();
115 setupBackupTab(); 115 setupBackupTab();
116} 116}
117void KDEPIMConfigWidget::showTimeZoneTab() 117void KDEPIMConfigWidget::showTimeZoneTab()
118{ 118{
119 tabWidget->setCurrentPage ( 3 ) ; 119 tabWidget->setCurrentPage ( 3 ) ;
120} 120}
121void KDEPIMConfigWidget::setupBackupTab() 121void KDEPIMConfigWidget::setupBackupTab()
122{ 122{
123 QVBox *colorPage = new QVBox( this ); 123 QVBox *colorPage = new QVBox( this );
124 tabWidget->addTab( colorPage, i18n( "Backup" ) ); 124 tabWidget->addTab( colorPage, i18n( "Backup" ) );
125 QWidget* topFrame = new QWidget( colorPage ); 125 QWidget* topFrame = new QWidget( colorPage );
126 QVBoxLayout *topLayout = new QVBoxLayout(topFrame); 126 QVBoxLayout *topLayout = new QVBoxLayout(topFrame);
127 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"), 127 KPrefsWidBool *sb = addWidBool(i18n("Backup enabled"),
128 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame); 128 &(KPimGlobalPrefs::instance()->mBackupEnabled),topFrame);
129 topLayout->addWidget((QWidget*)sb->checkBox()); 129 topLayout->addWidget((QWidget*)sb->checkBox());
130 QWidget* bupFrame = new QWidget( topFrame ); 130 QWidget* bupFrame = new QWidget( topFrame );
131 topLayout->addWidget((bupFrame)); 131 topLayout->addWidget((bupFrame));
132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) ); 132 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), bupFrame, SLOT ( setEnabled( bool ) ) );
133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame); 133 QVBoxLayout *bupLayout = new QVBoxLayout(bupFrame);
134 sb = addWidBool(i18n("Use standard backup dir"), 134 sb = addWidBool(i18n("Use standard backup dir"),
135 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame); 135 &(KPimGlobalPrefs::instance()->mBackupUseDefaultDir),bupFrame);
136 bupLayout->addWidget((QWidget*)sb->checkBox()); 136 bupLayout->addWidget((QWidget*)sb->checkBox());
137 mBackupUrl = new KURLRequester( bupFrame ); 137 mBackupUrl = new KURLRequester( bupFrame );
138 mBackupUrl->setPathIsDir();
138 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 139 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
139 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) ); 140 QObject::connect ( sb->checkBox(), SIGNAL (toggled ( bool ) ), mBackupUrl ,SLOT ( setDisabled( bool ) ) );
140 bupLayout->addWidget( mBackupUrl ); 141 bupLayout->addWidget( mBackupUrl );
141 142
142 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir ); 143 mBackupUrl->setEnabled( !KPimGlobalPrefs::instance()->mBackupUseDefaultDir );
143 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled ); 144 bupFrame->setEnabled( KPimGlobalPrefs::instance()->mBackupEnabled );
144 QHBox *dummy = new QHBox(bupFrame); 145 QHBox *dummy = new QHBox(bupFrame);
145 new QLabel(i18n("Number of Backups:"),dummy); 146 new QLabel(i18n("Number of Backups:"),dummy);
146 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy); 147 mBackupNumbersSpin = new QSpinBox(1,21,1,dummy);
147 new QLabel(i18n(" "),dummy); 148 new QLabel(i18n(" "),dummy);
148 bupLayout->addWidget( dummy ); 149 bupLayout->addWidget( dummy );
149 150
150 dummy = new QHBox(bupFrame); 151 dummy = new QHBox(bupFrame);
151 new QLabel(i18n("Make backup every "),dummy); 152 new QLabel(i18n("Make backup every "),dummy);
152 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy); 153 mBackupDayCountSpin = new QSpinBox(1,28,1,dummy);
153 new QLabel(i18n(" days"),dummy); 154 new QLabel(i18n(" days"),dummy);
154 new QLabel(i18n(" "),dummy); 155 new QLabel(i18n(" "),dummy);
155 bupLayout->addWidget( dummy ); 156 bupLayout->addWidget( dummy );
156 QString localKdeDir; 157 QString localKdeDir;
157 localKdeDir = readEnvPath("LOCALMICROKDEHOME"); 158 localKdeDir = readEnvPath("LOCALMICROKDEHOME");
158 if ( ! localKdeDir.isEmpty() ) { 159 if ( ! localKdeDir.isEmpty() ) {
159 sb->checkBox()->setEnabled( false ); 160 sb->checkBox()->setEnabled( false );
160 sb->checkBox()->setChecked( true ); 161 sb->checkBox()->setChecked( true );
161 mBackupUrl->setEnabled( false ); 162 mBackupUrl->setEnabled( false );
162 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true; 163 KPimGlobalPrefs::instance()->mBackupUseDefaultDir = true;
163 } 164 }
164 165
165} 166}
166void KDEPIMConfigWidget::setupStoreTab() 167void KDEPIMConfigWidget::setupStoreTab()
167{ 168{
168 QVBox *colorPage = new QVBox( this ); 169 QVBox *colorPage = new QVBox( this );
169 tabWidget->addTab( colorPage, i18n( "Colors" ) ); 170 tabWidget->addTab( colorPage, i18n( "Colors" ) );
170 QWidget* cw = new QWidget( colorPage ); 171 QWidget* cw = new QWidget( colorPage );
171 KPrefsWidColor *holidayColor = 172 KPrefsWidColor *holidayColor =
172 addWidColor(i18n("Alternating background of list views"), 173 addWidColor(i18n("Alternating background of list views"),
173 &(KPimGlobalPrefs::instance()->mAlternateColor),cw); 174 &(KPimGlobalPrefs::instance()->mAlternateColor),cw);
174 QHBoxLayout *topLayout = new QHBoxLayout(cw); 175 QHBoxLayout *topLayout = new QHBoxLayout(cw);
175 topLayout->addWidget(holidayColor->label()); 176 topLayout->addWidget(holidayColor->label());
176 topLayout->addWidget( (QWidget* )holidayColor->button()); 177 topLayout->addWidget( (QWidget* )holidayColor->button());
177 178
178 179
179 QVBox *storePage = new QVBox( this ); 180 QVBox *storePage = new QVBox( this );
180 if ( QApplication::desktop()->height() > 240 ) 181 if ( QApplication::desktop()->height() > 240 )
181 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage ); 182 new QLabel( i18n("Your current storage dir is:\n%1\nYour mail is stored in:\n(storagedir)/apps/kopiemail/localmail").arg(KGlobal::dirs()->localkdedir()), storePage );
182 new QLabel( i18n("<b>New data storage dir:</b>"), storePage ); 183 new QLabel( i18n("<b>New data storage dir:</b>"), storePage );
183 mStoreUrl = new KURLRequester( storePage ); 184 mStoreUrl = new KURLRequester( storePage );
185 mStoreUrl->setPathIsDir();
184 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() ); 186 mStoreUrl->setURL( KGlobal::dirs()->localkdedir() );
185#ifdef DESKTOP_VERSION 187#ifdef DESKTOP_VERSION
186 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; 188 QString confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
187 QFileInfo fi ( confFile ); 189 QFileInfo fi ( confFile );
188 if ( fi.exists() ) { 190 if ( fi.exists() ) {
189 KConfig cfg ( confFile ); 191 KConfig cfg ( confFile );
190 cfg.setGroup("Global"); 192 cfg.setGroup("Global");
191 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" ); 193 QString localKdeDir = cfg.readEntry( "MICROKDEHOME", "x_x_x" );
192 if ( localKdeDir != "x_x_x" ) { 194 if ( localKdeDir != "x_x_x" ) {
193 mStoreUrl->setURL( localKdeDir ); 195 mStoreUrl->setURL( localKdeDir );
194 qDebug("Reading config from %s ", confFile.latin1()); 196 qDebug("Reading config from %s ", confFile.latin1());
195 } 197 }
196 } 198 }
197 199
198#endif 200#endif
199 new QLabel( i18n("New dirs are created automatically"), storePage ); 201 new QLabel( i18n("New dirs are created automatically"), storePage );
200 QHBox *bb = new QHBox( storePage ); 202 QHBox *bb = new QHBox( storePage );
201 QPushButton * pb; 203 QPushButton * pb;
202 if ( QApplication::desktop()->width() < 640 ) 204 if ( QApplication::desktop()->width() < 640 )
203 pb = new QPushButton ( i18n("Save"), bb ); 205 pb = new QPushButton ( i18n("Save"), bb );
204 else 206 else
205 pb = new QPushButton ( i18n("Save settings"), bb ); 207 pb = new QPushButton ( i18n("Save settings"), bb );
206 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) ); 208 connect(pb, SIGNAL( clicked() ), this, SLOT ( saveStoreSettings() ) );
207 pb = new QPushButton ( i18n("Save standard"), bb ); 209 pb = new QPushButton ( i18n("Save standard"), bb );
208 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) ); 210 connect(pb, SIGNAL( clicked() ), this, SLOT ( setStandardStore() ) );
209#ifdef DESKTOP_VERSION 211#ifdef DESKTOP_VERSION
210 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb ); 212 pb = new QPushButton ( i18n("Save using LOCAL storage"), bb );
211 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) ); 213 connect(pb, SIGNAL( clicked() ), this, SLOT ( setLocalStore() ) );
212#endif 214#endif
213 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage ); 215 new QLabel( i18n("<b>New settings are used\nafter a restart</b>"), storePage );
214 new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage ); 216 new QLabel( i18n("Settings are stored in\n%1").arg(QDir::homeDirPath() + "/.microkdehome" ), storePage );
215 tabWidget->addTab( storePage, i18n( "Data storage path" ) ); 217 tabWidget->addTab( storePage, i18n( "Data storage path" ) );
216} 218}
217void KDEPIMConfigWidget::setLocalStore() 219void KDEPIMConfigWidget::setLocalStore()
218{ 220{
219 mStoreUrl->setURL( "LOCAL:kdepimpi" ); 221 mStoreUrl->setURL( "LOCAL:kdepimpi" );
220 saveStoreSettings(); 222 saveStoreSettings();
221 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data."); 223 QString message = i18n("'LOCAL' mode makes is possible to run\nKA/Pi and KO/Pi from a USB memory stick.\nIn LOCAL mode the data is stored\nin a path relative to the executable.\nNote, that in LOCAL mode only addressbook\nresource files in\n <path of the executable>/<dirname after LOCAL:>/apps/kabc/*.vcf\n are supported.\nIf you use the standard addressbook settings\nyou do not have to reconfigure any path,\njust restart the application and import\nyour addressbook and calendar data.");
222 KMessageBox::information( this, message); 224 KMessageBox::information( this, message);
223} 225}
224void KDEPIMConfigWidget::setStandardStore() 226void KDEPIMConfigWidget::setStandardStore()
225{ 227{
226 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 228 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
227 saveStoreSettings(); 229 saveStoreSettings();
228} 230}
229void KDEPIMConfigWidget::saveStoreSettings() 231void KDEPIMConfigWidget::saveStoreSettings()
230{ 232{
231 if ( !mStoreUrl->url().isEmpty() ) { 233 if ( !mStoreUrl->url().isEmpty() ) {
232 QString path = QDir::homeDirPath(); 234 QString path = QDir::homeDirPath();
233 QString url = mStoreUrl->url(); 235 QString url = mStoreUrl->url();
234#ifdef DESKTOP_VERSION 236#ifdef DESKTOP_VERSION
235 if ( url.startsWith( "LOCAL:" ) ) { 237 if ( url.startsWith( "LOCAL:" ) ) {
236 path = qApp->applicationDirPath () ; 238 path = qApp->applicationDirPath () ;
237 } 239 }
238#endif 240#endif
239 KConfig cfg ( path + "/.microkdehome" ); 241 KConfig cfg ( path + "/.microkdehome" );
240 cfg.setGroup("Global"); 242 cfg.setGroup("Global");
241 cfg.writeEntry( "MICROKDEHOME", url ); 243 cfg.writeEntry( "MICROKDEHOME", url );
242 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1()); 244 qDebug("cfg.writeEntry( MICROKDEHOME, %s ", url.latin1());
243 cfg.sync(); 245 cfg.sync();
244 } else { 246 } else {
245 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" ); 247 mStoreUrl->setURL( QDir::homeDirPath() + "/kdepim" );
246 saveStoreSettings(); 248 saveStoreSettings();
247 } 249 }
248} 250}
249void KDEPIMConfigWidget::setupExternalAppTab() 251void KDEPIMConfigWidget::setupExternalAppTab()
250{ 252{
251 QWidget *externalAppsPage = new QWidget( this ); 253 QWidget *externalAppsPage = new QWidget( this );
252 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 254 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
253 KDialog::spacingHintSmall() ); 255 KDialog::spacingHintSmall() );
254 256
255 mExternalApps = new QComboBox( externalAppsPage ); 257 mExternalApps = new QComboBox( externalAppsPage );
256 258
257 QMap<ExternalAppHandler::Types, QString>::Iterator it; 259 QMap<ExternalAppHandler::Types, QString>::Iterator it;
258 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 260 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
259 mExternalApps->insertItem( it.data(), it.key() ); 261 mExternalApps->insertItem( it.data(), it.key() );
260 262
261 layout->addWidget( mExternalApps ); 263 layout->addWidget( mExternalApps );
262 264
263 connect( mExternalApps, SIGNAL( activated( int ) ), 265 connect( mExternalApps, SIGNAL( activated( int ) ),
264 this, SLOT (externalapp_changed( int ) ) ); 266 this, SLOT (externalapp_changed( int ) ) );
265 267
266 268
267 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 269 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
268 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 270 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
269 mExternalAppGroupBox->layout()->setMargin(4); 271 mExternalAppGroupBox->layout()->setMargin(4);
270 272
271 mClient = new QComboBox( mExternalAppGroupBox ); 273 mClient = new QComboBox( mExternalAppGroupBox );
272 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 274 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
273 275
274 connect( mClient, SIGNAL( activated( int ) ), 276 connect( mClient, SIGNAL( activated( int ) ),
275 this, SLOT (client_changed( int ) ) ); 277 this, SLOT (client_changed( int ) ) );
276 278
277 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 279 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
278 boxLayout->addWidget( lab, 1, 0 ); 280 boxLayout->addWidget( lab, 1, 0 );
279 mChannel = new QLineEdit(mExternalAppGroupBox); 281 mChannel = new QLineEdit(mExternalAppGroupBox);
280 mChannel->setReadOnly(true); 282 mChannel->setReadOnly(true);
281 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); 283 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 );
282 284
283 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); 285 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox);
284 boxLayout->addWidget( lab, 3, 0 ); 286 boxLayout->addWidget( lab, 3, 0 );
285 mMessage = new QLineEdit(mExternalAppGroupBox); 287 mMessage = new QLineEdit(mExternalAppGroupBox);
286 mMessage->setReadOnly(true); 288 mMessage->setReadOnly(true);
287 boxLayout->addWidget( mMessage , 4, 0); 289 boxLayout->addWidget( mMessage , 4, 0);
288 290
289 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); 291 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox);
290 boxLayout->addWidget( lab, 3, 1 ); 292 boxLayout->addWidget( lab, 3, 1 );
291 mParameters = new QLineEdit(mExternalAppGroupBox); 293 mParameters = new QLineEdit(mExternalAppGroupBox);
292 mParameters->setReadOnly(true); 294 mParameters->setReadOnly(true);
293 boxLayout->addWidget( mParameters, 4, 1 ); 295 boxLayout->addWidget( mParameters, 4, 1 );
294 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); 296 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox);
295 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); 297 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 );
296 298
297 299
298 if ( QApplication::desktop()->height() > 240 ) { 300 if ( QApplication::desktop()->height() > 240 ) {
299 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); 301 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox);
300 boxLayout->addWidget( lab, 6, 0 ); 302 boxLayout->addWidget( lab, 6, 0 );
301 mMessage2 = new QLineEdit(mExternalAppGroupBox); 303 mMessage2 = new QLineEdit(mExternalAppGroupBox);
302 mMessage2->setReadOnly(true); 304 mMessage2->setReadOnly(true);
303 boxLayout->addWidget( mMessage2 , 7, 0); 305 boxLayout->addWidget( mMessage2 , 7, 0);
304 306
305 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); 307 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox);
306 boxLayout->addWidget( lab, 6, 1 ); 308 boxLayout->addWidget( lab, 6, 1 );
307 mParameters2 = new QLineEdit(mExternalAppGroupBox); 309 mParameters2 = new QLineEdit(mExternalAppGroupBox);
308 mParameters2->setReadOnly(true); 310 mParameters2->setReadOnly(true);
309 boxLayout->addWidget( mParameters2, 7, 1 ); 311 boxLayout->addWidget( mParameters2, 7, 1 );
310 312
311 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 313 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
312 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 314 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
313 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 315 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
314 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 316 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
315 } else { 317 } else {
316 mMessage2 = 0; 318 mMessage2 = 0;
317 mParameters2 = 0; 319 mParameters2 = 0;
318 } 320 }
319 321
320 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 322 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
321 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 323 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
322 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 324 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
323 325
324 326
325 layout->addWidget( mExternalAppGroupBox ); 327 layout->addWidget( mExternalAppGroupBox );
326 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 328 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
327 329
328} 330}
329 331
330 332
331void KDEPIMConfigWidget::setupLocaleDateTab() 333void KDEPIMConfigWidget::setupLocaleDateTab()
332{ 334{
333 QWidget *topFrame = new QWidget( this ); 335 QWidget *topFrame = new QWidget( this );
334 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); 336 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2);
335 337
336 topLayout->setSpacing(KDialog::spacingHintSmall()); 338 topLayout->setSpacing(KDialog::spacingHintSmall());
337 topLayout->setMargin(KDialog::marginHintSmall()); 339 topLayout->setMargin(KDialog::marginHintSmall());
338 int iii = 0; 340 int iii = 0;
339 341
340 342
341 KPrefsWidRadios *syncPrefsGroup = 343 KPrefsWidRadios *syncPrefsGroup =
342 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); 344 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
343 QString format; 345 QString format;
344 if ( QApplication::desktop()->width() < 480 ) 346 if ( QApplication::desktop()->width() < 480 )
345 format = "(%d.%m.%Y)"; 347 format = "(%d.%m.%Y)";
346 else 348 else
347 format = "(%d.%m.%Y|%A %d %B %Y)"; 349 format = "(%d.%m.%Y|%A %d %B %Y)";
348 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 350 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
349 if ( QApplication::desktop()->width() < 480 ) 351 if ( QApplication::desktop()->width() < 480 )
350 format = "(%m.%d.%Y)"; 352 format = "(%m.%d.%Y)";
351 else 353 else
352 format = "(%m.%d.%Y|%A %B %d %Y)"; 354 format = "(%m.%d.%Y|%A %B %d %Y)";
353 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 355 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
354 if ( QApplication::desktop()->width() < 480 ) 356 if ( QApplication::desktop()->width() < 480 )
355 format = "(%Y-%m-%d)"; 357 format = "(%Y-%m-%d)";
356 else 358 else
357 format = "(%Y-%m-%d|%A %Y %B %d)"; 359 format = "(%Y-%m-%d|%A %Y %B %d)";
358 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 360 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
359 syncPrefsGroup->addRadio(i18n("User defined")); 361 syncPrefsGroup->addRadio(i18n("User defined"));
360 if ( QApplication::desktop()->width() < 480 ) { 362 if ( QApplication::desktop()->width() < 480 ) {
361 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 363 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
362 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 364 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
363 } 365 }
364 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 366 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
365 ++iii; 367 ++iii;
366 ++iii; 368 ++iii;
367 QLabel * lab; 369 QLabel * lab;
368 mUserDateFormatLong = new QLineEdit(topFrame); 370 mUserDateFormatLong = new QLineEdit(topFrame);
369 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 371 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
370 topLayout->addWidget(lab ,iii,0); 372 topLayout->addWidget(lab ,iii,0);
371 topLayout->addWidget(mUserDateFormatLong,iii,1); 373 topLayout->addWidget(mUserDateFormatLong,iii,1);
372 ++iii; 374 ++iii;
373 mUserDateFormatShort = new QLineEdit(topFrame); 375 mUserDateFormatShort = new QLineEdit(topFrame);
374 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 376 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
375 topLayout->addWidget(lab ,iii,0); 377 topLayout->addWidget(lab ,iii,0);
376 topLayout->addWidget(mUserDateFormatShort,iii,1); 378 topLayout->addWidget(mUserDateFormatShort,iii,1);
377 ++iii; 379 ++iii;
378 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 380 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
379 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 381 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
380 ++iii; 382 ++iii;
381 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() ); 383 //qDebug(" QApplication::desktop()->height()xx %d ", QApplication::desktop()->height() );
382 if ( QApplication::desktop()->height() > 240 ) { 384 if ( QApplication::desktop()->height() > 240 ) {
383 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 385 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
384 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 386 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
385 ++iii; 387 ++iii;
386 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 388 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
387 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 389 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
388 ++iii; 390 ++iii;
389 } 391 }
390 392
391 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 393 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
392 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 394 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
393 395
394 396
395 tabWidget->addTab( topFrame, i18n( "Date Format" ) ); 397 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
396} 398}
397 399
398void KDEPIMConfigWidget::setupLocaleTab() 400void KDEPIMConfigWidget::setupLocaleTab()
399{ 401{
400 402
401 QWidget *topFrame = new QWidget( this ); 403 QWidget *topFrame = new QWidget( this );
402 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 404 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
403 405
404 topLayout->setSpacing(KDialog::spacingHint()); 406 topLayout->setSpacing(KDialog::spacingHint());
405 topLayout->setMargin(KDialog::marginHint()); 407 topLayout->setMargin(KDialog::marginHint());
406 int iii = 0; 408 int iii = 0;
407 KPrefsWidRadios *syncPrefsGroup = 409 KPrefsWidRadios *syncPrefsGroup =
408 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); 410 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
409 syncPrefsGroup->addRadio(i18n("English")); 411 syncPrefsGroup->addRadio(i18n("English"));
410 syncPrefsGroup->addRadio(i18n("German")); 412 syncPrefsGroup->addRadio(i18n("German"));
411 syncPrefsGroup->addRadio(i18n("French")); 413 syncPrefsGroup->addRadio(i18n("French"));
412 syncPrefsGroup->addRadio(i18n("Italian")); 414 syncPrefsGroup->addRadio(i18n("Italian"));
413 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 415 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
414 if ( QApplication::desktop()->width() < 300 ) { 416 if ( QApplication::desktop()->width() < 300 ) {
415 syncPrefsGroup->groupBox()->layout()->setMargin( 5 ); 417 syncPrefsGroup->groupBox()->layout()->setMargin( 5 );
416 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 ); 418 syncPrefsGroup->groupBox()->layout()->setSpacing( 0 );
417 } 419 }
418 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 420 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
419 ++iii; 421 ++iii;
420 422
421 423
422 tabWidget->addTab( topFrame, i18n( "Language" ) ); 424 tabWidget->addTab( topFrame, i18n( "Language" ) );
423 topFrame = new QWidget( this ); 425 topFrame = new QWidget( this );
424 topLayout = new QGridLayout(topFrame,4,2); 426 topLayout = new QGridLayout(topFrame,4,2);
425 427
426 topLayout->setSpacing(KDialog::spacingHint()); 428 topLayout->setSpacing(KDialog::spacingHint());
427 topLayout->setMargin(KDialog::marginHint()); 429 topLayout->setMargin(KDialog::marginHint());
428 iii = 0; 430 iii = 0;
429 syncPrefsGroup = 431 syncPrefsGroup =
430 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); 432 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
431 if ( QApplication::desktop()->width() > 300 ) 433 if ( QApplication::desktop()->width() > 300 )
432 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 434 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
433 syncPrefsGroup->addRadio(i18n("24:00")); 435 syncPrefsGroup->addRadio(i18n("24:00"));
434 syncPrefsGroup->addRadio(i18n("12:00am")); 436 syncPrefsGroup->addRadio(i18n("12:00am"));
435 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 437 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
436 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 438 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
437 ++iii; 439 ++iii;
438 440
439 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), 441 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
440 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); 442 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
441 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 443 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
442 ++iii; 444 ++iii;
443 445
444 446
445 tabWidget->addTab( topFrame, i18n( "Time Format" ) ); 447 tabWidget->addTab( topFrame, i18n( "Time Format" ) );
446 448
447} 449}
448 450
449 451
450void KDEPIMConfigWidget::setupTimeZoneTab() 452void KDEPIMConfigWidget::setupTimeZoneTab()
451{ 453{
452 QWidget *topFrame; 454 QWidget *topFrame;
453 QGridLayout *topLayout ; 455 QGridLayout *topLayout ;
454 456
455 457
456 458
457 459
458 460
459 461
460 topFrame = new QWidget( this ); 462 topFrame = new QWidget( this );
461 topLayout = new QGridLayout( topFrame, 5, 2); 463 topLayout = new QGridLayout( topFrame, 5, 2);
462 topLayout->setSpacing(KDialog::spacingHintSmall()); 464 topLayout->setSpacing(KDialog::spacingHintSmall());
463 topLayout->setMargin(KDialog::marginHintSmall()); 465 topLayout->setMargin(KDialog::marginHintSmall());
464 466
465 QHBox *timeZoneBox = new QHBox( topFrame ); 467 QHBox *timeZoneBox = new QHBox( topFrame );
466 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 468 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
467 469
468 new QLabel( i18n("Timezone:"), timeZoneBox ); 470 new QLabel( i18n("Timezone:"), timeZoneBox );
469 mTimeZoneCombo = new QComboBox( timeZoneBox ); 471 mTimeZoneCombo = new QComboBox( timeZoneBox );
470 if ( QApplication::desktop()->width() < 300 ) { 472 if ( QApplication::desktop()->width() < 300 ) {
471 mTimeZoneCombo->setMaximumWidth(150); 473 mTimeZoneCombo->setMaximumWidth(150);
472 } 474 }
473 475
474 QStringList list; 476 QStringList list;
475 list = KGlobal::locale()->timeZoneList(); 477 list = KGlobal::locale()->timeZoneList();
476 mTimeZoneCombo->insertStringList(list); 478 mTimeZoneCombo->insertStringList(list);
477 479
478 // find the currently set time zone and select it 480 // find the currently set time zone and select it
479 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; 481 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
480 int nCurrentlySet = 11; 482 int nCurrentlySet = 11;
481 for (int i = 0; i < mTimeZoneCombo->count(); i++) 483 for (int i = 0; i < mTimeZoneCombo->count(); i++)
482 { 484 {
483 if (mTimeZoneCombo->text(i) == sCurrentlySet) 485 if (mTimeZoneCombo->text(i) == sCurrentlySet)
484 { 486 {
485 nCurrentlySet = i; 487 nCurrentlySet = i;
486 break; 488 break;
487 } 489 }
488 } 490 }
489 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 491 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
490 int iii = 1; 492 int iii = 1;
491 KPrefsWidBool *sb = 493 KPrefsWidBool *sb =
492 addWidBool(i18n("Add 30 min to selected Timezone"), 494 addWidBool(i18n("Add 30 min to selected Timezone"),
493 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame); 495 &(KPimGlobalPrefs::instance()->mTimeZoneAdd30min),topFrame);
494 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 496 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
495 ++iii; 497 ++iii;
496 sb = 498 sb =
497 addWidBool(i18n("Timezone has daylight saving"), 499 addWidBool(i18n("Timezone has daylight saving"),
498 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); 500 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
499 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 501 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
500 ++iii; 502 ++iii;
501 QLabel* lab; 503 QLabel* lab;
502 504
503 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 505 lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
504 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 506 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
505 ++iii; 507 ++iii;
506 508
507 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 509 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
508 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 510 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
509 ++iii; 511 ++iii;
510 lab = new QLabel( i18n("Daylight start:"), topFrame ); 512 lab = new QLabel( i18n("Daylight start:"), topFrame );
511 topLayout->addWidget(lab, iii,0); 513 topLayout->addWidget(lab, iii,0);
512 mStartDateSavingEdit = new KDateEdit(topFrame); 514 mStartDateSavingEdit = new KDateEdit(topFrame);
513 topLayout->addWidget(mStartDateSavingEdit, iii,1); 515 topLayout->addWidget(mStartDateSavingEdit, iii,1);
514 ++iii; 516 ++iii;
515 517
516 lab = new QLabel( i18n("Daylight end:"), topFrame ); 518 lab = new QLabel( i18n("Daylight end:"), topFrame );
517 topLayout->addWidget(lab, iii,0); 519 topLayout->addWidget(lab, iii,0);
518 mEndDateSavingEdit = new KDateEdit(topFrame); 520 mEndDateSavingEdit = new KDateEdit(topFrame);
519 topLayout->addWidget(mEndDateSavingEdit, iii,1); 521 topLayout->addWidget(mEndDateSavingEdit, iii,1);
520 ++iii; 522 ++iii;
521 QDate current ( 2001, 1,1); 523 QDate current ( 2001, 1,1);
522 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); 524 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
523 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); 525 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
524 526
525 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 527 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
526 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 528 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
527 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); 529 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
528 tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); 530 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
529 531
530 532
531 topFrame = new QWidget( this ); 533 topFrame = new QWidget( this );
532 topLayout = new QGridLayout( topFrame, 3, 2); 534 topLayout = new QGridLayout( topFrame, 3, 2);
533 topLayout->setSpacing(KDialog::spacingHintSmall()); 535 topLayout->setSpacing(KDialog::spacingHintSmall());
534 topLayout->setMargin(KDialog::marginHintSmall()); 536 topLayout->setMargin(KDialog::marginHintSmall());
535 tabWidget->addTab( topFrame, i18n( "Fonts" ) ); 537 tabWidget->addTab( topFrame, i18n( "Fonts" ) );
536 538
537 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame ); 539 QLabel* labb = new QLabel( i18n("Global application font for all apps:"), topFrame );
538 topLayout->addMultiCellWidget(labb,0,0,0,2); 540 topLayout->addMultiCellWidget(labb,0,0,0,2);
539 int i = 1; 541 int i = 1;
540 KPrefsWidFont *timeLabelsFont = 542 KPrefsWidFont *timeLabelsFont =
541 addWidFont(i18n("Kx/Pi"),i18n("Application Font"), 543 addWidFont(i18n("Kx/Pi"),i18n("Application Font"),
542 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame); 544 &(KPimGlobalPrefs::instance()->mApplicationFont),topFrame);
543 topLayout->addWidget(timeLabelsFont->label(),i,0); 545 topLayout->addWidget(timeLabelsFont->label(),i,0);
544 topLayout->addWidget(timeLabelsFont->preview(),i,1); 546 topLayout->addWidget(timeLabelsFont->preview(),i,1);
545 topLayout->addWidget(timeLabelsFont->button(),i,2); 547 topLayout->addWidget(timeLabelsFont->button(),i,2);
546} 548}
547 549
548void KDEPIMConfigWidget::externalapp_changed( int newApp ) 550void KDEPIMConfigWidget::externalapp_changed( int newApp )
549{ 551{
550 // first store the current data 552 // first store the current data
551 saveEditFieldSettings(); 553 saveEditFieldSettings();
552 554
553 // set mCurrentApp 555 // set mCurrentApp
554 mCurrentApp = (ExternalAppHandler::Types)newApp; 556 mCurrentApp = (ExternalAppHandler::Types)newApp;
555 557
556 // set mCurrentClient 558 // set mCurrentClient
557 switch(mCurrentApp) 559 switch(mCurrentApp)
558 { 560 {
559 case(ExternalAppHandler::EMAIL): 561 case(ExternalAppHandler::EMAIL):
560 mCurrentClient = mEmailClient; 562 mCurrentClient = mEmailClient;
561 break; 563 break;
562 case(ExternalAppHandler::PHONE): 564 case(ExternalAppHandler::PHONE):
563 mCurrentClient = mPhoneClient; 565 mCurrentClient = mPhoneClient;
564 break; 566 break;
565 case(ExternalAppHandler::SMS): 567 case(ExternalAppHandler::SMS):
566 mCurrentClient = mSMSClient; 568 mCurrentClient = mSMSClient;
567 break; 569 break;
568 case(ExternalAppHandler::FAX): 570 case(ExternalAppHandler::FAX):
569 mCurrentClient = mFaxClient; 571 mCurrentClient = mFaxClient;
570 break; 572 break;
571 case(ExternalAppHandler::PAGER): 573 case(ExternalAppHandler::PAGER):
572 mCurrentClient = mPagerClient; 574 mCurrentClient = mPagerClient;
573 break; 575 break;
574 case(ExternalAppHandler::SIP): 576 case(ExternalAppHandler::SIP):
575 mCurrentClient = mSipClient; 577 mCurrentClient = mSipClient;
576 break; 578 break;
577 default: 579 default:
578 return; 580 return;
579 } 581 }
580 582
581 // and at last update the widgets 583 // and at last update the widgets
582 updateClientWidgets(); 584 updateClientWidgets();
583} 585}
584 586
585 587
586 588
587void KDEPIMConfigWidget::client_changed( int newClient ) 589void KDEPIMConfigWidget::client_changed( int newClient )
588{ 590{
589 if (newClient == mCurrentClient) 591 if (newClient == mCurrentClient)
590 return; 592 return;
591 593
592 // first store the current data 594 // first store the current data
593 saveEditFieldSettings(); 595 saveEditFieldSettings();
594 596
595 597
596 //then reset the clientvariable 598 //then reset the clientvariable
597 mCurrentClient = newClient; 599 mCurrentClient = newClient;
598 600
599 // and at last update the widgets 601 // and at last update the widgets
600 updateClientWidgets(); 602 updateClientWidgets();
601 603
602 KPrefsWidget::modified(); 604 KPrefsWidget::modified();
603} 605}
604 606
605void KDEPIMConfigWidget::saveEditFieldSettings() 607void KDEPIMConfigWidget::saveEditFieldSettings()
606{ 608{
607 609
608 switch(mCurrentApp) 610 switch(mCurrentApp)
609 { 611 {
610 case(ExternalAppHandler::EMAIL): 612 case(ExternalAppHandler::EMAIL):
611 mEmailClient = mClient->currentItem(); 613 mEmailClient = mClient->currentItem();
612 break; 614 break;
613 case(ExternalAppHandler::PHONE): 615 case(ExternalAppHandler::PHONE):
614 mPhoneClient= mClient->currentItem(); 616 mPhoneClient= mClient->currentItem();
615 break; 617 break;
616 case(ExternalAppHandler::SMS): 618 case(ExternalAppHandler::SMS):
617 mSMSClient = mClient->currentItem(); 619 mSMSClient = mClient->currentItem();
618 break; 620 break;
619 case(ExternalAppHandler::FAX): 621 case(ExternalAppHandler::FAX):
620 mFaxClient = mClient->currentItem(); 622 mFaxClient = mClient->currentItem();
621 break; 623 break;
622 case(ExternalAppHandler::PAGER): 624 case(ExternalAppHandler::PAGER):
623 mPagerClient = mClient->currentItem(); 625 mPagerClient = mClient->currentItem();
624 break; 626 break;
625 case(ExternalAppHandler::SIP): 627 case(ExternalAppHandler::SIP):
626 mSipClient = mClient->currentItem(); 628 mSipClient = mClient->currentItem();
627 break; 629 break;
628 default: 630 default:
629 return; 631 return;
630 } 632 }
631 633
632 //store the current data back to the apropriate membervariables if we had set it to "other" 634 //store the current data back to the apropriate membervariables if we had set it to "other"
633 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 635 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
634 { 636 {
635 mEmailOtherChannel = mChannel->text(); 637 mEmailOtherChannel = mChannel->text();
636 mEmailOtherMessage = mMessage->text(); 638 mEmailOtherMessage = mMessage->text();
637 mEmailOtherMessageParameters = mParameters->text(); 639 mEmailOtherMessageParameters = mParameters->text();
638 if ( mMessage2 ) 640 if ( mMessage2 )
639 mEmailOtherMessage2 = mMessage2->text(); 641 mEmailOtherMessage2 = mMessage2->text();
640 if ( mParameters2 ) 642 if ( mParameters2 )
641 mEmailOtherMessageParameters2 = mParameters2->text(); 643 mEmailOtherMessageParameters2 = mParameters2->text();
642 } 644 }
643 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 645 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
644 { 646 {
645 mPhoneOtherChannel = mChannel->text(); 647 mPhoneOtherChannel = mChannel->text();
646 mPhoneOtherMessage = mMessage->text(); 648 mPhoneOtherMessage = mMessage->text();
647 mPhoneOtherMessageParameters = mParameters->text(); 649 mPhoneOtherMessageParameters = mParameters->text();
648 } 650 }
649 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 651 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
650 { 652 {
651 mSMSOtherChannel = mChannel->text(); 653 mSMSOtherChannel = mChannel->text();
652 mSMSOtherMessage = mMessage->text(); 654 mSMSOtherMessage = mMessage->text();
653 mSMSOtherMessageParameters = mParameters->text(); 655 mSMSOtherMessageParameters = mParameters->text();
654 } 656 }
655 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 657 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
656 { 658 {
657 mFaxOtherChannel = mChannel->text(); 659 mFaxOtherChannel = mChannel->text();
658 mFaxOtherMessage = mMessage->text(); 660 mFaxOtherMessage = mMessage->text();
659 mFaxOtherMessageParameters = mParameters->text(); 661 mFaxOtherMessageParameters = mParameters->text();
660 } 662 }
661 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 663 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
662 { 664 {
663 mPagerOtherChannel = mChannel->text(); 665 mPagerOtherChannel = mChannel->text();
664 mPagerOtherMessage = mMessage->text(); 666 mPagerOtherMessage = mMessage->text();
665 mPagerOtherMessageParameters = mParameters->text(); 667 mPagerOtherMessageParameters = mParameters->text();
666 } 668 }
667 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 669 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
668 { 670 {
669 mSipOtherChannel = mChannel->text(); 671 mSipOtherChannel = mChannel->text();
670 mSipOtherMessage = mMessage->text(); 672 mSipOtherMessage = mMessage->text();
671 mSipOtherMessageParameters = mParameters->text(); 673 mSipOtherMessageParameters = mParameters->text();
672 } 674 }
673 675
674 676
675} 677}
676 678
677void KDEPIMConfigWidget::updateClientWidgets() 679void KDEPIMConfigWidget::updateClientWidgets()
678{ 680{
679 bool blocked = signalsBlocked(); 681 bool blocked = signalsBlocked();
680 blockSignals( true ); 682 blockSignals( true );
681 683
682 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display 684 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display
683 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); 685 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp );
684 if (it == mExternalAppsMap.end()) 686 if (it == mExternalAppsMap.end())
685 return; 687 return;
686 688
687 // update group box 689 // update group box
688 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); 690 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data()));
689 691
690 //update the entries in the client combobox 692 //update the entries in the client combobox
691 mClient->clear(); 693 mClient->clear();
692 694
693 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); 695 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp);
694 DefaultAppItem* dai; 696 DefaultAppItem* dai;
695 for ( dai=items.first(); dai != 0; dai=items.next() ) 697 for ( dai=items.first(); dai != 0; dai=items.next() )
696 { 698 {
697 mClient->insertItem( i18n(dai->_label), dai->_id ); 699 mClient->insertItem( i18n(dai->_label), dai->_id );
698 700
699 if (dai->_id == mCurrentClient) 701 if (dai->_id == mCurrentClient)
700 { 702 {
701 //restore the edit fields with the data of the local membervariables if we had set it to "other". 703 //restore the edit fields with the data of the local membervariables if we had set it to "other".
702 //Otherwise take the default data from externalapphandler. 704 //Otherwise take the default data from externalapphandler.
703 mChannel->setText(dai->_channel); 705 mChannel->setText(dai->_channel);
704 mMessage->setText(dai->_message); 706 mMessage->setText(dai->_message);
705 mParameters->setText(dai->_parameters); 707 mParameters->setText(dai->_parameters);
706 if ( mMessage2 ) 708 if ( mMessage2 )
707 mMessage2->setText(dai->_message2); 709 mMessage2->setText(dai->_message2);
708 if ( mParameters2 ) 710 if ( mParameters2 )
709 mParameters2->setText(dai->_parameters2); 711 mParameters2->setText(dai->_parameters2);
710 712
711 713
712 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 714 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
713 { 715 {
714 mChannel->setText(mEmailOtherChannel); 716 mChannel->setText(mEmailOtherChannel);
715 mMessage->setText(mEmailOtherMessage); 717 mMessage->setText(mEmailOtherMessage);
716 mParameters->setText(mEmailOtherMessageParameters); 718 mParameters->setText(mEmailOtherMessageParameters);
717 if ( mMessage2 ) 719 if ( mMessage2 )
718 mMessage2->setText(mEmailOtherMessage2); 720 mMessage2->setText(mEmailOtherMessage2);
719 if ( mParameters2 ) 721 if ( mParameters2 )
720 mParameters2->setText(mEmailOtherMessageParameters2); 722 mParameters2->setText(mEmailOtherMessageParameters2);
721 } 723 }
722 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 724 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
723 { 725 {
724 mChannel->setText(mPhoneOtherChannel); 726 mChannel->setText(mPhoneOtherChannel);
725 mMessage->setText(mPhoneOtherMessage); 727 mMessage->setText(mPhoneOtherMessage);
726 mParameters->setText(mPhoneOtherMessageParameters); 728 mParameters->setText(mPhoneOtherMessageParameters);
727 } 729 }
728 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 730 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
729 { 731 {
730 mChannel->setText(mSMSOtherChannel); 732 mChannel->setText(mSMSOtherChannel);
731 mMessage->setText(mSMSOtherMessage); 733 mMessage->setText(mSMSOtherMessage);
732 mParameters->setText(mSMSOtherMessageParameters); 734 mParameters->setText(mSMSOtherMessageParameters);
733 } 735 }
734 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 736 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
735 { 737 {
736 mChannel->setText(mFaxOtherChannel); 738 mChannel->setText(mFaxOtherChannel);
737 mMessage->setText(mFaxOtherMessage); 739 mMessage->setText(mFaxOtherMessage);
738 mParameters->setText(mFaxOtherMessageParameters); 740 mParameters->setText(mFaxOtherMessageParameters);
739 } 741 }
740 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 742 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
741 { 743 {
742 mChannel->setText(mPagerOtherChannel); 744 mChannel->setText(mPagerOtherChannel);
743 mMessage->setText(mPagerOtherMessage); 745 mMessage->setText(mPagerOtherMessage);
744 mParameters->setText(mPagerOtherMessageParameters); 746 mParameters->setText(mPagerOtherMessageParameters);
745 } 747 }
746 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 748 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
747 { 749 {
748 mChannel->setText(mSipOtherChannel); 750 mChannel->setText(mSipOtherChannel);
749 mMessage->setText(mSipOtherMessage); 751 mMessage->setText(mSipOtherMessage);
750 mParameters->setText(mSipOtherMessageParameters); 752 mParameters->setText(mSipOtherMessageParameters);
751 } 753 }
752 } 754 }
753 755
754 } 756 }
755 757
756 bool readonly; 758 bool readonly;
757 bool enabled; 759 bool enabled;
758 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 760 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
759 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 761 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
760 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 762 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
761 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 763 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
762 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 764 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
763 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) 765 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)))
764 { 766 {
765 readonly = false; 767 readonly = false;
766 } 768 }
767 else 769 else
768 { 770 {
769 readonly = true; 771 readonly = true;
770 } 772 }
771 773
772 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) 774 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC))
773 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) 775 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC))
774 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) 776 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC))
775 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) 777 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC))
776 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) 778 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))
777 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) 779 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC)))
778 { 780 {
779 enabled = false; 781 enabled = false;
780 } 782 }
781 else 783 else
782 { 784 {
783 enabled = true; 785 enabled = true;
784 } 786 }
785 787
786 788
787 mChannel->setReadOnly(readonly); 789 mChannel->setReadOnly(readonly);
788 mMessage->setReadOnly(readonly); 790 mMessage->setReadOnly(readonly);
789 mParameters->setReadOnly(readonly); 791 mParameters->setReadOnly(readonly);
790 if ( mMessage2 ) 792 if ( mMessage2 )
791 mMessage2->setReadOnly(readonly); 793 mMessage2->setReadOnly(readonly);
792 if ( mParameters2 ) 794 if ( mParameters2 )
793 mParameters2->setReadOnly(readonly); 795 mParameters2->setReadOnly(readonly);
794 796
795 mChannel->setEnabled(enabled); 797 mChannel->setEnabled(enabled);
796 mMessage->setEnabled(enabled); 798 mMessage->setEnabled(enabled);
797 mParameters->setEnabled(enabled); 799 mParameters->setEnabled(enabled);
798 if ( mMessage2 ) 800 if ( mMessage2 )
799 mMessage2->setEnabled(enabled); 801 mMessage2->setEnabled(enabled);
800 if ( mParameters2 ) 802 if ( mParameters2 )
801 mParameters2->setEnabled(enabled); 803 mParameters2->setEnabled(enabled);
802 804
803 805
804 806
805 mClient->setCurrentItem(mCurrentClient); 807 mClient->setCurrentItem(mCurrentClient);
806 808
807 809
808 // enable/disable the extra message/parameter field 810 // enable/disable the extra message/parameter field
809 if (mCurrentApp == ExternalAppHandler::EMAIL) 811 if (mCurrentApp == ExternalAppHandler::EMAIL)
810 { 812 {
811 } 813 }
812 else 814 else
813 { 815 {
814 if ( mMessage2 ) 816 if ( mMessage2 )
815 mMessage2->setText( "" ); 817 mMessage2->setText( "" );
816 if ( mParameters2 ) 818 if ( mParameters2 )
817 mParameters2->setText( "" ); 819 mParameters2->setText( "" );
818 } 820 }
819 821
820 if (enabled == true) { 822 if (enabled == true) {
821 if ( mMessage2 ) 823 if ( mMessage2 )
822 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 824 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
823 if ( mParameters2 ) 825 if ( mParameters2 )
824 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 826 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
825 } 827 }
826 828
827 829
828 blockSignals( blocked ); 830 blockSignals( blocked );
829 831
830} 832}
831 833
832void KDEPIMConfigWidget::usrReadConfig() 834void KDEPIMConfigWidget::usrReadConfig()
833{ 835{
834 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 836 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
835 837
836 bool blocked = signalsBlocked(); 838 bool blocked = signalsBlocked();
837 blockSignals( true ); 839 blockSignals( true );
838 840
839 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir ) 841 if (KPimGlobalPrefs::instance()->mBackupUseDefaultDir )
840 mBackupUrl->setURL( KGlobalSettings::backupDataDir() ); 842 mBackupUrl->setURL( KGlobalSettings::backupDataDir() );
841 else 843 else
842 mBackupUrl->setURL(prefs->mBackupDatadir); 844 mBackupUrl->setURL(prefs->mBackupDatadir);
843 mBackupNumbersSpin->setValue( prefs->mBackupNumbers ); 845 mBackupNumbersSpin->setValue( prefs->mBackupNumbers );
844 mBackupDayCountSpin->setValue( prefs->mBackupDayCount); 846 mBackupDayCountSpin->setValue( prefs->mBackupDayCount);
845 847
846 QString dummy = prefs->mUserDateFormatLong; 848 QString dummy = prefs->mUserDateFormatLong;
847 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 849 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
848 dummy = prefs->mUserDateFormatShort; 850 dummy = prefs->mUserDateFormatShort;
849 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 851 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
850 852
851 QDate current ( 2001, 1,1); 853 QDate current ( 2001, 1,1);
852 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 854 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
853 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 855 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
854 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 856 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
855 857
856 mEmailClient = prefs->mEmailClient; 858 mEmailClient = prefs->mEmailClient;
857 mEmailOtherChannel = prefs->mEmailOtherChannel; 859 mEmailOtherChannel = prefs->mEmailOtherChannel;
858 mEmailOtherMessage = prefs->mEmailOtherMessage; 860 mEmailOtherMessage = prefs->mEmailOtherMessage;
859 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 861 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
860 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 862 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
861 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 863 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
862 864
863 mPhoneClient = prefs->mPhoneClient; 865 mPhoneClient = prefs->mPhoneClient;
864 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 866 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
865 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 867 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
866 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 868 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
867 869
868 mFaxClient = prefs->mFaxClient; 870 mFaxClient = prefs->mFaxClient;
869 mFaxOtherChannel = prefs->mFaxOtherChannel; 871 mFaxOtherChannel = prefs->mFaxOtherChannel;
870 mFaxOtherMessage = prefs->mFaxOtherMessage; 872 mFaxOtherMessage = prefs->mFaxOtherMessage;
871 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 873 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
872 874
873 mSMSClient = prefs->mSMSClient; 875 mSMSClient = prefs->mSMSClient;
874 mSMSOtherChannel = prefs->mSMSOtherChannel; 876 mSMSOtherChannel = prefs->mSMSOtherChannel;
875 mSMSOtherMessage = prefs->mSMSOtherMessage; 877 mSMSOtherMessage = prefs->mSMSOtherMessage;
876 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; 878 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters;
877 879
878 mPagerClient = prefs->mPagerClient; 880 mPagerClient = prefs->mPagerClient;
879 mPagerOtherChannel = prefs->mPagerOtherChannel; 881 mPagerOtherChannel = prefs->mPagerOtherChannel;
880 mPagerOtherMessage = prefs->mPagerOtherMessage; 882 mPagerOtherMessage = prefs->mPagerOtherMessage;
881 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; 883 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters;
882 884
883 mSipClient = prefs->mSipClient; 885 mSipClient = prefs->mSipClient;
884 mSipOtherChannel = prefs->mSipOtherChannel; 886 mSipOtherChannel = prefs->mSipOtherChannel;
885 mSipOtherMessage = prefs->mSipOtherMessage; 887 mSipOtherMessage = prefs->mSipOtherMessage;
886 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 888 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
887 889
888 mCurrentApp = ExternalAppHandler::EMAIL; 890 mCurrentApp = ExternalAppHandler::EMAIL;
889 mCurrentClient = mEmailClient; 891 mCurrentClient = mEmailClient;
890 892
891 updateClientWidgets(); 893 updateClientWidgets();
892 894
893 blockSignals( blocked ); 895 blockSignals( blocked );
894 896
895} 897}
896 898
897void KDEPIMConfigWidget::usrWriteConfig() 899void KDEPIMConfigWidget::usrWriteConfig()
898{ 900{
899 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 901 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
900 902
901 saveEditFieldSettings(); 903 saveEditFieldSettings();
902 904
903 prefs->mBackupNumbers = mBackupNumbersSpin->value(); 905 prefs->mBackupNumbers = mBackupNumbersSpin->value();
904 prefs->mBackupDayCount = mBackupDayCountSpin->value(); 906 prefs->mBackupDayCount = mBackupDayCountSpin->value();
905 prefs->mBackupDatadir = mBackupUrl->url(); 907 prefs->mBackupDatadir = mBackupUrl->url();
906 908
907 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 909 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
908 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 910 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
909 911
910 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 912 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
911 QDate date; 913 QDate date;
912 date = mStartDateSavingEdit->date(); 914 date = mStartDateSavingEdit->date();
913 int sub = 0; 915 int sub = 0;
914 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 916 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
915 sub = 1; 917 sub = 1;
916 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 918 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
917 date = mEndDateSavingEdit->date(); 919 date = mEndDateSavingEdit->date();
918 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 920 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
919 sub = 1; 921 sub = 1;
920 else 922 else
921 sub = 0; 923 sub = 0;
922 prefs->mDaylightsavingEnd = date.dayOfYear()-sub; 924 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
923 925
924 926
925 prefs->mEmailClient = mEmailClient; 927 prefs->mEmailClient = mEmailClient;
926 prefs->mEmailOtherChannel = mEmailOtherChannel; 928 prefs->mEmailOtherChannel = mEmailOtherChannel;
927 prefs->mEmailOtherMessage = mEmailOtherMessage; 929 prefs->mEmailOtherMessage = mEmailOtherMessage;
928 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 930 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
929 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 931 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
930 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 932 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
931 933
932 prefs->mPhoneClient = mPhoneClient; 934 prefs->mPhoneClient = mPhoneClient;
933 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 935 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
934 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 936 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
935 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 937 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
936 938
937 prefs->mFaxClient = mFaxClient; 939 prefs->mFaxClient = mFaxClient;
938 prefs->mFaxOtherChannel = mFaxOtherChannel; 940 prefs->mFaxOtherChannel = mFaxOtherChannel;
939 prefs->mFaxOtherMessage = mFaxOtherMessage; 941 prefs->mFaxOtherMessage = mFaxOtherMessage;
940 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; 942 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters;
941 943
942 prefs->mSMSClient = mSMSClient; 944 prefs->mSMSClient = mSMSClient;
943 prefs->mSMSOtherChannel = mSMSOtherChannel; 945 prefs->mSMSOtherChannel = mSMSOtherChannel;
944 prefs->mSMSOtherMessage = mSMSOtherMessage; 946 prefs->mSMSOtherMessage = mSMSOtherMessage;
945 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; 947 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters;
946 948
947 prefs->mPagerClient = mPagerClient; 949 prefs->mPagerClient = mPagerClient;
948 prefs->mPagerOtherChannel = mPagerOtherChannel; 950 prefs->mPagerOtherChannel = mPagerOtherChannel;
949 prefs->mPagerOtherMessage = mPagerOtherMessage; 951 prefs->mPagerOtherMessage = mPagerOtherMessage;
950 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 952 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
951 953
952 954
953 prefs->mSipClient = mSipClient; 955 prefs->mSipClient = mSipClient;
954 prefs->mSipOtherChannel = mSipOtherChannel; 956 prefs->mSipOtherChannel = mSipOtherChannel;
955 prefs->mSipOtherMessage = mSipOtherMessage; 957 prefs->mSipOtherMessage = mSipOtherMessage;
956 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 958 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
957 959
958 //release the cache that other views can access the changed values instantanious 960 //release the cache that other views can access the changed values instantanious
959 ExternalAppHandler::instance()->loadConfig(); 961 ExternalAppHandler::instance()->loadConfig();
960 KPimGlobalPrefs::instance()->setGlobalConfig(); 962 KPimGlobalPrefs::instance()->setGlobalConfig();
961} 963}
962 964
963 965
964void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, 966void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
965 const QStringList *tags) 967 const QStringList *tags)
966{ 968{
967 if (tags) { 969 if (tags) {
968 int i = tags->findIndex(text); 970 int i = tags->findIndex(text);
969 if (i > 0) combo->setCurrentItem(i); 971 if (i > 0) combo->setCurrentItem(i);
970 } else { 972 } else {
971 for(int i=0;i<combo->count();++i) { 973 for(int i=0;i<combo->count();++i) {
972 if (combo->text(i) == text) { 974 if (combo->text(i) == text) {
973 combo->setCurrentItem(i); 975 combo->setCurrentItem(i);
974 break; 976 break;
975 } 977 }
976 } 978 }
977 } 979 }
978} 980}
979 981
980 982
981void KDEPIMConfigWidget::textChanged( const QString& text ) 983void KDEPIMConfigWidget::textChanged( const QString& text )
982{ 984{
983 emit changed( true ); 985 emit changed( true );
984} 986}
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp
index 6be1580..c64f325 100644
--- a/microkde/kfiledialog.cpp
+++ b/microkde/kfiledialog.cpp
@@ -1,79 +1,88 @@
1#include <kfiledialog.h> 1#include <kfiledialog.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#ifndef DESKTOP_VERSION 8#ifndef DESKTOP_VERSION
9//US orig#include <ofileselector.h> 9//US orig#include <ofileselector.h>
10#include <ofileselector_p.h> 10#include <ofileselector_p.h>
11QString KFileDialog::getSaveFileName( const QString & fn, 11QString KFileDialog::getSaveFileName( const QString & fn,
12 const QString & cap , QWidget * par ) 12 const QString & cap , QWidget * par )
13{ 13{
14 QString retfile = ""; 14 QString retfile = "";
15 QDialog dia ( par, "input-dialog", true ); 15 QDialog dia ( par, "input-dialog", true );
16 QVBoxLayout lay( &dia ); 16 QVBoxLayout lay( &dia );
17 lay.setMargin(7); 17 lay.setMargin(7);
18 lay.setSpacing(7); 18 lay.setSpacing(7);
19 QString file = fn; 19 QString file = fn;
20 if ( file.isEmpty() ) 20 if ( file.isEmpty() )
21 file = QDir::homeDirPath()+"/*"; 21 file = QDir::homeDirPath()+"/*";
22 QFileInfo fi ( file ); 22 QFileInfo fi ( file );
23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() ); 23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() );
24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
25 lay.addWidget( &o); 25 lay.addWidget( &o);
26 // o.setNewVisible( true ); 26 // o.setNewVisible( true );
27 // o.setNameVisible( true ); 27 // o.setNameVisible( true );
28 dia.showMaximized(); 28 dia.showMaximized();
29 if ( cap.isEmpty() ) 29 if ( cap.isEmpty() )
30 dia.setCaption( file ); 30 dia.setCaption( file );
31 else 31 else
32 dia.setCaption( cap ); 32 dia.setCaption( cap );
33 int res = dia.exec(); 33 int res = dia.exec();
34 if ( res ) 34 if ( res )
35 retfile = o.selectedName(); 35 retfile = o.selectedName();
36 return retfile; 36 return retfile;
37} 37}
38 38
39QString KFileDialog::getOpenFileName( const QString & fn, 39QString KFileDialog::getOpenFileName( const QString & fn,
40 const QString & cap, QWidget * par ) 40 const QString & cap, QWidget * par )
41{ 41{
42 QString retfile = ""; 42 QString retfile = "";
43 QDialog dia ( par, "input-dialog", true ); 43 QDialog dia ( par, "input-dialog", true );
44 // QLineEdit lab ( &dia ); 44 // QLineEdit lab ( &dia );
45 QVBoxLayout lay( &dia ); 45 QVBoxLayout lay( &dia );
46 lay.setMargin(7); 46 lay.setMargin(7);
47 lay.setSpacing(7); 47 lay.setSpacing(7);
48 QString file = fn; 48 QString file = fn;
49 if ( file.isEmpty() ) 49 if ( file.isEmpty() )
50 file = QDir::homeDirPath()+"/*";; 50 file = QDir::homeDirPath()+"/*";;
51 QFileInfo fi ( file ); 51 QFileInfo fi ( file );
52 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() ); 52 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() );
53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
54 lay.addWidget( &o); 54 lay.addWidget( &o);
55 dia.showMaximized(); 55 dia.showMaximized();
56 dia.setCaption( cap ); 56 dia.setCaption( cap );
57 int res = dia.exec(); 57 int res = dia.exec();
58 if ( res ) 58 if ( res )
59 retfile = o.selectedName(); 59 retfile = o.selectedName();
60 return retfile; 60 return retfile;
61} 61}
62 62QString KFileDialog::getExistingDirectory( const QString & fn,
63 const QString & cap, QWidget * par )
64{
65 return KFileDialog::getSaveFileName( fn, cap, pr );
66}
63#else 67#else
64 68
65#include <qfiledialog.h> 69#include <qfiledialog.h>
66 70
67QString KFileDialog::getSaveFileName( const QString & fn, 71QString KFileDialog::getSaveFileName( const QString & fn,
68 const QString & cap , QWidget * par ) 72 const QString & cap , QWidget * par )
69{ 73{
70 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); 74 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap );
71} 75}
72QString KFileDialog::getOpenFileName( const QString & fn, 76QString KFileDialog::getOpenFileName( const QString & fn,
73 const QString & cap, QWidget * par ) 77 const QString & cap, QWidget * par )
74{ 78{
75 79
76 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); 80 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap );
77} 81}
82QString KFileDialog::getExistingDirectory( const QString & fn,
83 const QString & cap, QWidget * par )
84{
85 return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap );
86}
78#endif 87#endif
79 88
diff --git a/microkde/kfiledialog.h b/microkde/kfiledialog.h
index 0825872..90709cd 100644
--- a/microkde/kfiledialog.h
+++ b/microkde/kfiledialog.h
@@ -1,20 +1,22 @@
1#ifndef MICROKDE_KFILEDIALOG_H 1#ifndef MICROKDE_KFILEDIALOG_H
2#define MICROKDE_KFILEDIALOG_H 2#define MICROKDE_KFILEDIALOG_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qwidget.h> 5#include <qwidget.h>
6 6
7class KFileDialog 7class KFileDialog
8{ 8{
9 public: 9 public:
10 10
11 static QString getSaveFileName( const QString &, 11 static QString getSaveFileName( const QString &,
12 const QString &, QWidget * ); 12 const QString &, QWidget * );
13 13
14 14
15 static QString getOpenFileName( const QString &, 15 static QString getOpenFileName( const QString &,
16 const QString &, QWidget * ); 16 const QString &, QWidget * );
17 17
18 static QString getExistingDirectory( const QString &,
19 const QString &, QWidget * );
18}; 20};
19 21
20#endif 22#endif
diff --git a/microkde/kio/kfile/kurlrequester.cpp b/microkde/kio/kfile/kurlrequester.cpp
index 991c8be..ca94570 100644
--- a/microkde/kio/kfile/kurlrequester.cpp
+++ b/microkde/kio/kfile/kurlrequester.cpp
@@ -1,406 +1,409 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#include <sys/stat.h> 20#include <sys/stat.h>
21#ifdef _WIN32_ 21#ifdef _WIN32_
22 22
23#else 23#else
24#include <unistd.h> 24#include <unistd.h>
25#endif 25#endif
26#include <qstring.h> 26#include <qstring.h>
27//US #include <qtooltip.h> 27//US #include <qtooltip.h>
28 28
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30 30
31//US #include <kaccel.h> 31//US #include <kaccel.h>
32//US #include <kcombobox.h> 32//US #include <kcombobox.h>
33#include <kdebug.h> 33#include <kdebug.h>
34#include <kdialog.h> 34#include <kdialog.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <klineedit.h> 38#include <klineedit.h>
39#include <klocale.h> 39#include <klocale.h>
40//US #include <kurlcompletion.h> 40//US #include <kurlcompletion.h>
41//US #include <kurldrag.h> 41//US #include <kurldrag.h>
42//US #include <kprotocolinfo.h> 42//US #include <kprotocolinfo.h>
43 43
44 44
45#include "kurlrequester.h" 45#include "kurlrequester.h"
46 46
47 47
48class KURLDragPushButton : public QPushButton 48class KURLDragPushButton : public QPushButton
49{ 49{
50public: 50public:
51 KURLDragPushButton( QWidget *parent, const char *name=0 ) 51 KURLDragPushButton( QWidget *parent, const char *name=0 )
52 : QPushButton( parent, name ) { 52 : QPushButton( parent, name ) {
53 //US setDragEnabled( true ); 53 //US setDragEnabled( true );
54 } 54 }
55 ~KURLDragPushButton() {} 55 ~KURLDragPushButton() {}
56 56
57 void setURL( const KURL& url ) { 57 void setURL( const KURL& url ) {
58 m_urls.clear(); 58 m_urls.clear();
59 m_urls.append( url ); 59 m_urls.append( url );
60 } 60 }
61 61
62 /* not needed so far 62 /* not needed so far
63 void setURLs( const KURL::List& urls ) { 63 void setURLs( const KURL::List& urls ) {
64 m_urls = urls; 64 m_urls = urls;
65 } 65 }
66 const KURL::List& urls() const { return m_urls; } 66 const KURL::List& urls() const { return m_urls; }
67 */ 67 */
68 68
69protected: 69protected:
70/*US 70/*US
71 virtual QDragObject *dragObject() { 71 virtual QDragObject *dragObject() {
72 if ( m_urls.isEmpty() ) 72 if ( m_urls.isEmpty() )
73 return 0L; 73 return 0L;
74 74
75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" ); 75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" );
76 return drag; 76 return drag;
77 } 77 }
78*/ 78*/
79private: 79private:
80 KURL::List m_urls; 80 KURL::List m_urls;
81 81
82}; 82};
83 83
84 84
85/* 85/*
86************************************************************************* 86*************************************************************************
87*/ 87*/
88 88
89class KURLRequester::KURLRequesterPrivate 89class KURLRequester::KURLRequesterPrivate
90{ 90{
91public: 91public:
92 KURLRequesterPrivate() { 92 KURLRequesterPrivate() {
93 edit = 0L; 93 edit = 0L;
94 //UScombo = 0L; 94 //UScombo = 0L;
95//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly; 95//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly;
96 } 96 }
97 97
98 void setText( const QString& text ) { 98 void setText( const QString& text ) {
99/*US 99/*US
100 if ( combo ) 100 if ( combo )
101 { 101 {
102 if (combo->editable()) 102 if (combo->editable())
103 { 103 {
104 combo->setEditText( text ); 104 combo->setEditText( text );
105 } 105 }
106 else 106 else
107 { 107 {
108 combo->insertItem( text ); 108 combo->insertItem( text );
109 combo->setCurrentItem( combo->count()-1 ); 109 combo->setCurrentItem( combo->count()-1 );
110 } 110 }
111 } 111 }
112 else 112 else
113*/ 113*/
114 { 114 {
115 edit->setText( text ); 115 edit->setText( text );
116 } 116 }
117 } 117 }
118 118
119 void connectSignals( QObject *receiver ) { 119 void connectSignals( QObject *receiver ) {
120 QObject *sender; 120 QObject *sender;
121 /*USif ( combo ) 121 /*USif ( combo )
122 sender = combo; 122 sender = combo;
123 else 123 else
124*/ 124*/
125 sender = edit; 125 sender = edit;
126 126
127 connect( sender, SIGNAL( textChanged( const QString& )), 127 connect( sender, SIGNAL( textChanged( const QString& )),
128 receiver, SIGNAL( textChanged( const QString& ))); 128 receiver, SIGNAL( textChanged( const QString& )));
129 connect( sender, SIGNAL( returnPressed() ), 129 connect( sender, SIGNAL( returnPressed() ),
130 receiver, SIGNAL( returnPressed() )); 130 receiver, SIGNAL( returnPressed() ));
131 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ), 131 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ),
132 //US receiver, SIGNAL( returnPressed( const QString& ) )); 132 //US receiver, SIGNAL( returnPressed( const QString& ) ));
133 } 133 }
134/*US 134/*US
135 void setCompletionObject( KCompletion *comp ) { 135 void setCompletionObject( KCompletion *comp ) {
136 if ( combo ) 136 if ( combo )
137 combo->setCompletionObject( comp ); 137 combo->setCompletionObject( comp );
138 else 138 else
139 edit->setCompletionObject( comp ); 139 edit->setCompletionObject( comp );
140 } 140 }
141 */ 141 */
142 /** 142 /**
143 * replaces ~user or $FOO, if necessary 143 * replaces ~user or $FOO, if necessary
144 */ 144 */
145 QString url() { 145 QString url() {
146 QString txt = /*US combo ? combo->currentText() : */ edit->text(); 146 QString txt = /*US combo ? combo->currentText() : */ edit->text();
147/*US KURLCompletion *comp; 147/*US KURLCompletion *comp;
148 if ( combo ) 148 if ( combo )
149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject()); 149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject());
150 else 150 else
151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject()); 151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject());
152 152
153 if ( comp ) 153 if ( comp )
154 return comp->replacedPath( txt ); 154 return comp->replacedPath( txt );
155 else 155 else
156*/ 156*/
157 return txt; 157 return txt;
158 } 158 }
159 159
160 KLineEdit *edit; 160 KLineEdit *edit;
161//US KComboBox *combo; 161//US KComboBox *combo;
162 int fileDialogMode; 162 int fileDialogMode;
163 QString fileDialogFilter; 163 QString fileDialogFilter;
164}; 164};
165 165
166 166
167/*US 167/*US
168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent, 168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent,
169 const char *name ) 169 const char *name )
170 : QHBox( parent, name ) 170 : QHBox( parent, name )
171{ 171{
172 d = new KURLRequesterPrivate; 172 d = new KURLRequesterPrivate;
173 173
174 // must have this as parent 174 // must have this as parent
175 editWidget->reparent( this, 0, QPoint(0,0) ); 175 editWidget->reparent( this, 0, QPoint(0,0) );
176//US d->edit = dynamic_cast<KLineEdit*>( editWidget ); 176//US d->edit = dynamic_cast<KLineEdit*>( editWidget );
177 d->edit = (KLineEdit*)( editWidget ); 177 d->edit = (KLineEdit*)( editWidget );
178//US d->combo = dynamic_cast<KComboBox*>( editWidget ); 178//US d->combo = dynamic_cast<KComboBox*>( editWidget );
179 179
180 init(); 180 init();
181} 181}
182*/ 182*/
183 183
184KURLRequester::KURLRequester( QWidget *parent, const char *name ) 184KURLRequester::KURLRequester( QWidget *parent, const char *name )
185 : QHBox( parent, name ) 185 : QHBox( parent, name )
186{ 186{
187 d = new KURLRequesterPrivate; 187 d = new KURLRequesterPrivate;
188 init(); 188 init();
189} 189}
190 190
191 191
192KURLRequester::KURLRequester( const QString& url, QWidget *parent, 192KURLRequester::KURLRequester( const QString& url, QWidget *parent,
193 const char *name ) 193 const char *name )
194 : QHBox( parent, name ) 194 : QHBox( parent, name )
195{ 195{
196 d = new KURLRequesterPrivate; 196 d = new KURLRequesterPrivate;
197 init(); 197 init();
198 setURL( url ); 198 setURL( url );
199} 199}
200 200
201 201
202KURLRequester::~KURLRequester() 202KURLRequester::~KURLRequester()
203{ 203{
204//US delete myCompletion; 204//US delete myCompletion;
205 delete myFileDialog; 205 delete myFileDialog;
206 delete d; 206 delete d;
207} 207}
208 208
209 209
210void KURLRequester::init() 210void KURLRequester::init()
211{ 211{
212 myFileDialog = 0L; 212 myFileDialog = 0L;
213 myShowLocalProt = false; 213 myShowLocalProt = false;
214 214 mPathIsDir = false;
215 if (/*US !d->combo && */ !d->edit ) 215 if (/*US !d->combo && */ !d->edit )
216 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); 216 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" );
217 217
218 myButton = new KURLDragPushButton( this, "kfile button"); 218 myButton = new KURLDragPushButton( this, "kfile button");
219 QIconSet iconSet = SmallIconSet("fileopen"); 219 QIconSet iconSet = SmallIconSet("fileopen");
220 QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); 220 QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal );
221 myButton->setIconSet( iconSet ); 221 myButton->setIconSet( iconSet );
222 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); 222 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
223//US QToolTip::add(myButton, i18n("Open file dialog")); 223//US QToolTip::add(myButton, i18n("Open file dialog"));
224 224
225 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() )); 225 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() ));
226 226
227 setSpacing( KDialog::spacingHint() ); 227 setSpacing( KDialog::spacingHint() );
228 228
229 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit; 229 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit;
230 setFocusProxy( widget ); 230 setFocusProxy( widget );
231 231
232 d->connectSignals( this ); 232 d->connectSignals( this );
233 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() )); 233 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() ));
234/*US 234/*US
235 myCompletion = new KURLCompletion(); 235 myCompletion = new KURLCompletion();
236 d->setCompletionObject( myCompletion ); 236 d->setCompletionObject( myCompletion );
237 237
238 KAccel *accel = new KAccel( this ); 238 KAccel *accel = new KAccel( this );
239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() )); 239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() ));
240 accel->readSettings(); 240 accel->readSettings();
241*/ 241*/
242} 242}
243 243
244 244
245void KURLRequester::setURL( const QString& url ) 245void KURLRequester::setURL( const QString& url )
246{ 246{
247 bool hasLocalPrefix = (url.startsWith("file:")); 247 bool hasLocalPrefix = (url.startsWith("file:"));
248 248
249 if ( !myShowLocalProt && hasLocalPrefix ) 249 if ( !myShowLocalProt && hasLocalPrefix )
250 d->setText( url.mid( 5, url.length()-5 )); 250 d->setText( url.mid( 5, url.length()-5 ));
251 else 251 else
252 d->setText( url ); 252 d->setText( url );
253} 253}
254 254
255void KURLRequester::setCaption( const QString& caption ) 255void KURLRequester::setCaption( const QString& caption )
256{ 256{
257 //USfileDialog()->setCaption( caption ); 257 //USfileDialog()->setCaption( caption );
258 //USQWidget::setCaption( caption ); 258 //USQWidget::setCaption( caption );
259} 259}
260 260
261QString KURLRequester::url() const 261QString KURLRequester::url() const
262{ 262{
263 return d->url(); 263 return d->url();
264} 264}
265 265
266 266
267void KURLRequester::slotOpenDialog() 267void KURLRequester::slotOpenDialog()
268{ 268{
269 emit openFileDialog( this ); 269 emit openFileDialog( this );
270 270
271//US use our special KFIleDialog instead 271//US use our special KFIleDialog instead
272 KURL u( url() ); 272 KURL u( url() );
273 //QString fn = u.url(); 273 //QString fn = u.url();
274 QString fn = d->edit->text(); 274 QString fn = d->edit->text();
275 fn = KFileDialog::getSaveFileName( fn, "", this ); 275 if ( mPathIsDir )
276 fn = KFileDialog::getExistingDirectory ( fn, "", this );
277 else
278 fn = KFileDialog::getSaveFileName( fn, "", this );
276 279
277 if ( fn == "" ) 280 if ( fn == "" )
278 return; 281 return;
279 282
280 setURL( fn ); 283 setURL( fn );
281 emit urlSelected( d->url() ); 284 emit urlSelected( d->url() );
282/*US 285/*US
283 KFileDialog *dlg = fileDialog(); 286 KFileDialog *dlg = fileDialog();
284 if ( !d->url().isEmpty() ) { 287 if ( !d->url().isEmpty() ) {
285 KURL u( url() ); 288 KURL u( url() );
286 // If we won't be able to list it (e.g. http), then don't try :) 289 // If we won't be able to list it (e.g. http), then don't try :)
287 if ( KProtocolInfo::supportsListing( u.protocol() ) ) 290 if ( KProtocolInfo::supportsListing( u.protocol() ) )
288 dlg->setSelection( u.url() ); 291 dlg->setSelection( u.url() );
289 } 292 }
290 293
291 if ( dlg->exec() == QDialog::Accepted ) 294 if ( dlg->exec() == QDialog::Accepted )
292 { 295 {
293 setURL( dlg->selectedURL().prettyURL() ); 296 setURL( dlg->selectedURL().prettyURL() );
294 emit urlSelected( d->url() ); 297 emit urlSelected( d->url() );
295 } 298 }
296*/ 299*/
297 300
298} 301}
299 302
300void KURLRequester::setMode(unsigned int mode) 303void KURLRequester::setMode(unsigned int mode)
301{ 304{
302/*US 305/*US
303 Q_ASSERT( (mode & KFile::Files) == 0 ); 306 Q_ASSERT( (mode & KFile::Files) == 0 );
304 d->fileDialogMode = mode; 307 d->fileDialogMode = mode;
305 if ( (mode & KFile::Directory) && !(mode & KFile::File) ) 308 if ( (mode & KFile::Directory) && !(mode & KFile::File) )
306 myCompletion->setMode( KURLCompletion::DirCompletion ); 309 myCompletion->setMode( KURLCompletion::DirCompletion );
307 310
308 if (myFileDialog) 311 if (myFileDialog)
309 myFileDialog->setMode( d->fileDialogMode ); 312 myFileDialog->setMode( d->fileDialogMode );
310*/ 313*/
311} 314}
312 315
313void KURLRequester::setFilter(const QString &filter) 316void KURLRequester::setFilter(const QString &filter)
314{ 317{
315/*US 318/*US
316 d->fileDialogFilter = filter; 319 d->fileDialogFilter = filter;
317 if (myFileDialog) 320 if (myFileDialog)
318 myFileDialog->setFilter( d->fileDialogFilter ); 321 myFileDialog->setFilter( d->fileDialogFilter );
319*/ 322*/
320} 323}
321 324
322KFileDialog * KURLRequester::fileDialog() const 325KFileDialog * KURLRequester::fileDialog() const
323{ 326{
324/*US 327/*US
325 if ( !myFileDialog ) { 328 if ( !myFileDialog ) {
326 QWidget *p = parentWidget(); 329 QWidget *p = parentWidget();
327 myFileDialog = new KFileDialog( QString::null, QString::null, p, 330 myFileDialog = new KFileDialog( QString::null, QString::null, p,
328 "file dialog", true ); 331 "file dialog", true );
329 332
330 myFileDialog->setMode( d->fileDialogMode ); 333 myFileDialog->setMode( d->fileDialogMode );
331 myFileDialog->setFilter( d->fileDialogFilter ); 334 myFileDialog->setFilter( d->fileDialogFilter );
332 } 335 }
333 336
334 return myFileDialog; 337 return myFileDialog;
335*/ 338*/
336 return 0; 339 return 0;
337} 340}
338 341
339 342
340void KURLRequester::setShowLocalProtocol( bool b ) 343void KURLRequester::setShowLocalProtocol( bool b )
341{ 344{
342 if ( myShowLocalProt == b ) 345 if ( myShowLocalProt == b )
343 return; 346 return;
344 347
345 myShowLocalProt = b; 348 myShowLocalProt = b;
346 setURL( url() ); 349 setURL( url() );
347} 350}
348 351
349void KURLRequester::clear() 352void KURLRequester::clear()
350{ 353{
351 d->setText( QString::null ); 354 d->setText( QString::null );
352} 355}
353 356
354KLineEdit * KURLRequester::lineEdit() const 357KLineEdit * KURLRequester::lineEdit() const
355{ 358{
356 return d->edit; 359 return d->edit;
357} 360}
358/*US 361/*US
359KComboBox * KURLRequester::comboBox() const 362KComboBox * KURLRequester::comboBox() const
360{ 363{
361 return d->combo; 364 return d->combo;
362} 365}
363*/ 366*/
364void KURLRequester::slotUpdateURL() 367void KURLRequester::slotUpdateURL()
365{ 368{
366 // bin compat, myButton is declared as QPushButton 369 // bin compat, myButton is declared as QPushButton
367//US KURL u( QDir::currentDirPath() + '/', url() ); 370//US KURL u( QDir::currentDirPath() + '/', url() );
368 KURL u( url() ); 371 KURL u( url() );
369 (static_cast<KURLDragPushButton *>( myButton))->setURL( u ); 372 (static_cast<KURLDragPushButton *>( myButton))->setURL( u );
370} 373}
371 374
372QPushButton * KURLRequester::button() const 375QPushButton * KURLRequester::button() const
373{ 376{
374 return myButton; 377 return myButton;
375} 378}
376/*US 379/*US
377KEditListBox::CustomEditor KURLRequester::customEditor() 380KEditListBox::CustomEditor KURLRequester::customEditor()
378{ 381{
379 setSizePolicy(QSizePolicy( QSizePolicy::Preferred, 382 setSizePolicy(QSizePolicy( QSizePolicy::Preferred,
380 QSizePolicy::Fixed)); 383 QSizePolicy::Fixed));
381 384
382 KLineEdit *edit = d->edit; 385 KLineEdit *edit = d->edit;
383 if ( !edit && d->combo ) 386 if ( !edit && d->combo )
384 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() ); 387 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() );
385 388
386#ifndef NDEBUG 389#ifndef NDEBUG
387 if ( !edit ) 390 if ( !edit )
388 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n"; 391 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n";
389#endif 392#endif
390 393
391 KEditListBox::CustomEditor editor( this, edit ); 394 KEditListBox::CustomEditor editor( this, edit );
392 return editor; 395 return editor;
393} 396}
394*/ 397*/
395void KURLRequester::virtual_hook( int, void* ) 398void KURLRequester::virtual_hook( int, void* )
396{ /*BASE::virtual_hook( id, data );*/ } 399{ /*BASE::virtual_hook( id, data );*/ }
397 400
398/*US 401/*US
399KURLComboRequester::KURLComboRequester( QWidget *parent, 402KURLComboRequester::KURLComboRequester( QWidget *parent,
400 const char *name ) 403 const char *name )
401 : KURLRequester( new KComboBox(false), parent, name) 404 : KURLRequester( new KComboBox(false), parent, name)
402{ 405{
403} 406}
404*/ 407*/
405 408
406//US #include "kurlrequester.moc" 409//US #include "kurlrequester.moc"
diff --git a/microkde/kio/kfile/kurlrequester.h b/microkde/kio/kfile/kurlrequester.h
index 3253dd5..faa3326 100644
--- a/microkde/kio/kfile/kurlrequester.h
+++ b/microkde/kio/kfile/kurlrequester.h
@@ -1,269 +1,271 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#ifndef KURLREQUESTER_H 20#ifndef KURLREQUESTER_H
21#define KURLREQUESTER_H 21#define KURLREQUESTER_H
22 22
23#include <qhbox.h> 23#include <qhbox.h>
24 24
25#include <keditlistbox.h> 25#include <keditlistbox.h>
26//US #include <kfile.h> 26//US #include <kfile.h>
27//US #include <kpushbutton.h> 27//US #include <kpushbutton.h>
28#include <kurl.h> 28#include <kurl.h>
29 29
30//US class KComboBox; 30//US class KComboBox;
31 31
32class KFileDialog; 32class KFileDialog;
33class KLineEdit; 33class KLineEdit;
34//US class KURLCompletion; 34//US class KURLCompletion;
35class KURLDragPushButton; 35class KURLDragPushButton;
36 36
37class QPushButton; 37class QPushButton;
38class QString; 38class QString;
39class QTimer; 39class QTimer;
40 40
41/** 41/**
42 * This class is a widget showing a lineedit and a button, which invokes a 42 * This class is a widget showing a lineedit and a button, which invokes a
43 * filedialog. File name completion is available in the lineedit. 43 * filedialog. File name completion is available in the lineedit.
44 * 44 *
45 * The defaults for the filedialog are to ask for one existing local file, i.e. 45 * The defaults for the filedialog are to ask for one existing local file, i.e.
46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ) 46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly )
47 * The default filter is "*", i.e. show all files, and the start directory is 47 * The default filter is "*", i.e. show all files, and the start directory is
48 * the current working directory, or the last directory where a file has been 48 * the current working directory, or the last directory where a file has been
49 * selected. 49 * selected.
50 * 50 *
51 * You can change this behavior by using @ref setMode() or @ref setFilter(). 51 * You can change this behavior by using @ref setMode() or @ref setFilter().
52 * 52 *
53 * @short A widget to request a filename/url from the user 53 * @short A widget to request a filename/url from the user
54 * @author Carsten Pfeiffer <pfeiffer@kde.org> 54 * @author Carsten Pfeiffer <pfeiffer@kde.org>
55 */ 55 */
56class KURLRequester : public QHBox 56class KURLRequester : public QHBox
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 Q_PROPERTY( QString url READ url WRITE setURL ) 59 Q_PROPERTY( QString url READ url WRITE setURL )
60 60
61public: 61public:
62 /** 62 /**
63 * Constructs a KURLRequester widget. 63 * Constructs a KURLRequester widget.
64 */ 64 */
65 KURLRequester( QWidget *parent=0, const char *name=0 ); 65 KURLRequester( QWidget *parent=0, const char *name=0 );
66 66
67 /** 67 /**
68 * Constructs a KURLRequester widget with the initial URL @p url. 68 * Constructs a KURLRequester widget with the initial URL @p url.
69 */ 69 */
70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 ); 70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 );
71 71
72 /** 72 /**
73 * Special constructor, which creates a KURLRequester widget with a custom 73 * Special constructor, which creates a KURLRequester widget with a custom
74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit 74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit
75 * (or inherited thereof). Note: for geometry management reasons, the 75 * (or inherited thereof). Note: for geometry management reasons, the
76 * edit-widget is reparented to have the KURLRequester as parent. 76 * edit-widget is reparented to have the KURLRequester as parent.
77 * @param modal specifies whether the filedialog should be opened as modal 77 * @param modal specifies whether the filedialog should be opened as modal
78 * or not. 78 * or not.
79 */ 79 */
80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 ); 80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 );
81 /** 81 /**
82 * Destructs the KURLRequester. 82 * Destructs the KURLRequester.
83 */ 83 */
84 ~KURLRequester(); 84 ~KURLRequester();
85 85
86 /** 86 /**
87 * @returns the current url in the lineedit. May be malformed, if the user 87 * @returns the current url in the lineedit. May be malformed, if the user
88 * entered something weird. ~user or environment variables are substituted 88 * entered something weird. ~user or environment variables are substituted
89 * for local files. 89 * for local files.
90 */ 90 */
91 QString url() const; 91 QString url() const;
92 92
93 /** 93 /**
94 * Enables/disables showing file:/ in the lineedit, when a local file has 94 * Enables/disables showing file:/ in the lineedit, when a local file has
95 * been selected in the filedialog or was set via @ref setURL(). 95 * been selected in the filedialog or was set via @ref setURL().
96 * Default is false, not showing file:/ 96 * Default is false, not showing file:/
97 * @see #showLocalProtocol 97 * @see #showLocalProtocol
98 */ 98 */
99 void setShowLocalProtocol( bool b ); 99 void setShowLocalProtocol( bool b );
100 100
101 /** 101 /**
102 * Sets the mode of the file dialog. 102 * Sets the mode of the file dialog.
103 * Note: you can only select one file with the filedialog, 103 * Note: you can only select one file with the filedialog,
104 * so KFile::Files doesn't make much sense. 104 * so KFile::Files doesn't make much sense.
105 * @see KFileDialog::setMode() 105 * @see KFileDialog::setMode()
106 */ 106 */
107 void setMode( unsigned int m ); 107 void setMode( unsigned int m );
108 void setPathIsDir( ) {mPathIsDir = true;}
108 109
109 /** 110 /**
110 * Sets the filter for the file dialog. 111 * Sets the filter for the file dialog.
111 * @see KFileDialog::setFilter() 112 * @see KFileDialog::setFilter()
112 */ 113 */
113 void setFilter( const QString& filter ); 114 void setFilter( const QString& filter );
114 115
115 /** 116 /**
116 * @returns whether local files will be prefixed with file:/ in the 117 * @returns whether local files will be prefixed with file:/ in the
117 * lineedit 118 * lineedit
118 * @see #setShowLocalProtocol 119 * @see #setShowLocalProtocol
119 */ 120 */
120 bool showLocalProtocol() const { return myShowLocalProt; } 121 bool showLocalProtocol() const { return myShowLocalProt; }
121 122
122 /** 123 /**
123 * @returns a pointer to the filedialog 124 * @returns a pointer to the filedialog
124 * You can use this to customize the dialog, e.g. to specify a filter. 125 * You can use this to customize the dialog, e.g. to specify a filter.
125 * Never returns 0L. 126 * Never returns 0L.
126 */ 127 */
127 virtual KFileDialog * fileDialog() const; 128 virtual KFileDialog * fileDialog() const;
128 129
129 /** 130 /**
130 * @returns a pointer to the lineedit, either the default one, or the 131 * @returns a pointer to the lineedit, either the default one, or the
131 * special one, if you used the special constructor. 132 * special one, if you used the special constructor.
132 * 133 *
133 * It is provided so that you can e.g. set an own completion object 134 * It is provided so that you can e.g. set an own completion object
134 * (e.g. @ref KShellCompletion) into it. 135 * (e.g. @ref KShellCompletion) into it.
135 */ 136 */
136 KLineEdit * lineEdit() const; 137 KLineEdit * lineEdit() const;
137 138
138 /** 139 /**
139 * @returns a pointer to the combobox, in case you have set one using the 140 * @returns a pointer to the combobox, in case you have set one using the
140 * special constructor. Returns 0L otherwise. 141 * special constructor. Returns 0L otherwise.
141 */ 142 */
142//US KComboBox * comboBox() const; 143//US KComboBox * comboBox() const;
143 144
144 /** 145 /**
145 * @returns a pointer to the pushbutton. It is provided so that you can 146 * @returns a pointer to the pushbutton. It is provided so that you can
146 * specify an own pixmap or a text, if you really need to. 147 * specify an own pixmap or a text, if you really need to.
147 */ 148 */
148 QPushButton * button() const; 149 QPushButton * button() const;
149 150
150 /** 151 /**
151 * @returns the KURLCompletion object used in the lineedit/combobox. 152 * @returns the KURLCompletion object used in the lineedit/combobox.
152 */ 153 */
153//US KURLCompletion *completionObject() const { return myCompletion; } 154//US KURLCompletion *completionObject() const { return myCompletion; }
154 155
155 /** 156 /**
156 * @returns an object, suitable for use with KEditListBox. It allows you 157 * @returns an object, suitable for use with KEditListBox. It allows you
157 * to put this KURLRequester into a KEditListBox. 158 * to put this KURLRequester into a KEditListBox.
158 * Basically, do it like this: 159 * Basically, do it like this:
159 * <pre> 160 * <pre>
160 * KURLRequester *req = new KURLRequester( someWidget ); 161 * KURLRequester *req = new KURLRequester( someWidget );
161 * [...] 162 * [...]
162 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget ); 163 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget );
163 * </pre> 164 * </pre>
164 * @since 3.1 165 * @since 3.1
165 */ 166 */
166//US KEditListBox::CustomEditor customEditor(); 167//US KEditListBox::CustomEditor customEditor();
167 168
168public slots: 169public slots:
169 /** 170 /**
170 * Sets the url in the lineedit to @p url. Depending on the state of 171 * Sets the url in the lineedit to @p url. Depending on the state of
171 * @ref showLocalProtocol(), file:/ on local files will be shown or not. 172 * @ref showLocalProtocol(), file:/ on local files will be shown or not.
172 * @since 3.1 173 * @since 3.1
173 */ 174 */
174 void setURL( const QString& url ); 175 void setURL( const QString& url );
175 176
176 /** 177 /**
177 * @reimp 178 * @reimp
178 * Sets the caption of the file dialog. 179 * Sets the caption of the file dialog.
179 * @since 3.1 180 * @since 3.1
180 */ 181 */
181 virtual void setCaption( const QString& caption ); 182 virtual void setCaption( const QString& caption );
182 183
183 /** 184 /**
184 * Clears the lineedit/combobox. 185 * Clears the lineedit/combobox.
185 */ 186 */
186 void clear(); 187 void clear();
187 188
188signals: 189signals:
189 // forwards from LineEdit 190 // forwards from LineEdit
190 /** 191 /**
191 * Emitted when the text in the lineedit changes. 192 * Emitted when the text in the lineedit changes.
192 * The parameter contains the contents of the lineedit. 193 * The parameter contains the contents of the lineedit.
193 * @since 3.1 194 * @since 3.1
194 */ 195 */
195 void textChanged( const QString& ); 196 void textChanged( const QString& );
196 197
197 /** 198 /**
198 * Emitted when return or enter was pressed in the lineedit. 199 * Emitted when return or enter was pressed in the lineedit.
199 */ 200 */
200 void returnPressed(); 201 void returnPressed();
201 202
202 /** 203 /**
203 * Emitted when return or enter was pressed in the lineedit. 204 * Emitted when return or enter was pressed in the lineedit.
204 * The parameter contains the contents of the lineedit. 205 * The parameter contains the contents of the lineedit.
205 */ 206 */
206 void returnPressed( const QString& ); 207 void returnPressed( const QString& );
207 208
208 /** 209 /**
209 * Emitted before the filedialog is going to open. Connect 210 * Emitted before the filedialog is going to open. Connect
210 * to this signal to "configure" the filedialog, e.g. set the 211 * to this signal to "configure" the filedialog, e.g. set the
211 * filefilter, the mode, a preview-widget, etc. It's usually 212 * filefilter, the mode, a preview-widget, etc. It's usually
212 * not necessary to set a URL for the filedialog, as it will 213 * not necessary to set a URL for the filedialog, as it will
213 * get set properly from the editfield contents. 214 * get set properly from the editfield contents.
214 * 215 *
215 * If you use multiple KURLRequesters, you can connect all of them 216 * If you use multiple KURLRequesters, you can connect all of them
216 * to the same slot and use the given KURLRequester pointer to know 217 * to the same slot and use the given KURLRequester pointer to know
217 * which one is going to open. 218 * which one is going to open.
218 */ 219 */
219 void openFileDialog( KURLRequester * ); 220 void openFileDialog( KURLRequester * );
220 221
221 /** 222 /**
222 * Emitted when the user changed the URL via the file dialog. 223 * Emitted when the user changed the URL via the file dialog.
223 * The parameter contains the contents of the lineedit. 224 * The parameter contains the contents of the lineedit.
224 */ 225 */
225 void urlSelected( const QString& ); 226 void urlSelected( const QString& );
226 227
227protected: 228protected:
228 void init(); 229 void init();
229 230
230//US KURLCompletion * myCompletion; 231//US KURLCompletion * myCompletion;
231 232
232 233
233private: 234private:
234 KURLDragPushButton * myButton; 235 KURLDragPushButton * myButton;
235 bool myShowLocalProt; 236 bool myShowLocalProt;
236 mutable KFileDialog * myFileDialog; 237 mutable KFileDialog * myFileDialog;
238 bool mPathIsDir;
237 239
238 240
239protected slots: 241protected slots:
240 /** 242 /**
241 * Called when the button is pressed to open the filedialog. 243 * Called when the button is pressed to open the filedialog.
242 * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. 244 * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed.
243 */ 245 */
244 void slotOpenDialog(); 246 void slotOpenDialog();
245 247
246private slots: 248private slots:
247 void slotUpdateURL(); 249 void slotUpdateURL();
248 250
249protected: 251protected:
250 virtual void virtual_hook( int id, void* data ); 252 virtual void virtual_hook( int id, void* data );
251private: 253private:
252 class KURLRequesterPrivate; 254 class KURLRequesterPrivate;
253 KURLRequesterPrivate *d; 255 KURLRequesterPrivate *d;
254}; 256};
255/*US 257/*US
256class KURLComboRequester : public KURLRequester // For use in Qt Designer 258class KURLComboRequester : public KURLRequester // For use in Qt Designer
257{ 259{
258 Q_OBJECT 260 Q_OBJECT
259public: 261public:
260*/ 262*/
261 /** 263 /**
262 * Constructs a KURLRequester widget with a combobox. 264 * Constructs a KURLRequester widget with a combobox.
263 */ 265 */
264/*US 266/*US
265 KURLComboRequester( QWidget *parent=0, const char *name=0 ); 267 KURLComboRequester( QWidget *parent=0, const char *name=0 );
266}; 268};
267*/ 269*/
268 270
269#endif // KURLREQUESTER_H 271#endif // KURLREQUESTER_H