summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp21
-rw-r--r--korganizer/mainwindow.cpp12
2 files changed, 21 insertions, 12 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3ab4bb4..a76f2ed 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4854 +1,4855 @@
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 "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy (NoFocus ); 370 setFocusPolicy (NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 373 mConflictingEvent = 0;
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 423
424 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
426 426
427 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
428#else 428#else
429 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 439 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 446 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
456#endif 456#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
460#if 0 460#if 0
461 // FIXME 461 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 464#endif
465 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 480
481 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
482#if 0 482#if 0
483 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
484 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
485 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
486 486
487 } else { 487 } else {
488 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
489 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
490 } 490 }
491#endif 491#endif
492 mFilterView->hide(); 492 mFilterView->hide();
493 mCalEditView->hide(); 493 mCalEditView->hide();
494 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
495 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
497 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
498 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
499 499
500 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
501 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
506 } else { 506 } else {
507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
510 } 510 }
511 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
512 mDateNavigator->hide(); 512 mDateNavigator->hide();
513 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
514#endif 514#endif
515 515
516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
517 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
518 518
519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
521 521
522 522
523 523
524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
525 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
528 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
529 529
530 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
531 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
532 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
533 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
534 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
535 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
536 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
537 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
538 538
539 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
540 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
541 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
542 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
544 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
545 545
546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
548#if 0 548#if 0
549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
550 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
551#endif 551#endif
552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
553 553
554 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
555 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
556 556
557 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
558 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
560 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
562 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
564 SLOT( showTodo( Todo *) ) ); 564 SLOT( showTodo( Todo *) ) );
565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
566 SLOT( deleteTodo( Todo *) ) ); 566 SLOT( deleteTodo( Todo *) ) );
567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
569 SLOT( purgeCompleted() ) ); 569 SLOT( purgeCompleted() ) );
570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
571 SIGNAL( todoModified( Todo *, int ) ) ); 571 SIGNAL( todoModified( Todo *, int ) ) );
572 572
573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
574 this, SLOT ( cloneIncidence( Incidence * ) ) ); 574 this, SLOT ( cloneIncidence( Incidence * ) ) );
575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
576 this, SLOT (cancelIncidence( Incidence * ) ) ); 576 this, SLOT (cancelIncidence( Incidence * ) ) );
577 577
578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
579 this, SLOT ( moveIncidence( Incidence * ) ) ); 579 this, SLOT ( moveIncidence( Incidence * ) ) );
580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
581 this, SLOT ( beamIncidence( Incidence * ) ) ); 581 this, SLOT ( beamIncidence( Incidence * ) ) );
582 582
583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
584 this, SLOT ( todo_unsub( Todo * ) ) ); 584 this, SLOT ( todo_unsub( Todo * ) ) );
585 585
586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
587 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 587 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
589 SLOT( updateTodo( Todo *, int ) ) ); 589 SLOT( updateTodo( Todo *, int ) ) );
590 connect( this, SIGNAL( todoModified( Todo *, int )), this, 590 connect( this, SIGNAL( todoModified( Todo *, int )), this,
591 SLOT( changeTodoDisplay( Todo *, int ) ) ); 591 SLOT( changeTodoDisplay( Todo *, int ) ) );
592 592
593 593
594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
598 598
599 599
600 600
601 601
602 602
603 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
604 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
606 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
608 608
609 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
610 610
611 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
614 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
615 mDateFrame->hide(); 615 mDateFrame->hide();
616 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
618 618
619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
620 620
621 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
622 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
623 623
624 mFlagEditDescription = false; 624 mFlagEditDescription = false;
625 625
626 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
627 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
628 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
632 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
634 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
636 636
637 637
638#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
639//US listen for arriving address resultsets 639//US listen for arriving address resultsets
640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
642#endif 642#endif
643 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
644} 644}
645 645
646 646
647CalendarView::~CalendarView() 647CalendarView::~CalendarView()
648{ 648{
649 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658 658
659 659
660void CalendarView::nextConflict( bool all, bool allday ) 660void CalendarView::nextConflict( bool all, bool allday )
661{ 661{
662 static bool block = false; 662 static bool block = false;
663 if ( block ) return; 663 if ( block ) return;
664 block = true; 664 block = true;
665 QPtrList<Event> testlist = mCalendar->events(); 665 QPtrList<Event> testlist = mCalendar->events();
666 Event * test = testlist.first(); 666 Event * test = testlist.first();
667 while ( test ) { 667 while ( test ) {
668 test->setTagged( false ); 668 test->setTagged( false );
669 test = testlist.next(); 669 test = testlist.next();
670 } 670 }
671 QTime st ( 0,0,0); 671 QTime st ( 0,0,0);
672 if ( mViewManager->currentView() == mViewManager->agendaView() ) 672 if ( mViewManager->currentView() == mViewManager->agendaView() )
673 st = mViewManager->agendaView()->agenda()->getEndTime(); 673 st = mViewManager->agendaView()->agenda()->getEndTime();
674 //qDebug("time %s ", st.toString().latin1()); 674 //qDebug("time %s ", st.toString().latin1());
675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
676 QDateTime conflict; 676 QDateTime conflict;
677 QDateTime retVal; 677 QDateTime retVal;
678 bool found = false; 678 bool found = false;
679 Event * cE = 0; 679 Event * cE = 0;
680 Event * cE2 = 0; 680 Event * cE2 = 0;
681 QPtrList<Event> testlist2 = testlist; 681 QPtrList<Event> testlist2 = testlist;
682 test = testlist.first(); 682 test = testlist.first();
683 bool skip = false; 683 bool skip = false;
684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
685 //QTime tm; 685 //QTime tm;
686 //tm.start(); 686 //tm.start();
687 while ( test ) { 687 while ( test ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 skip = false; 689 skip = false;
690 if ( !all ) skip = ( allday != test->doesFloat() ); 690 if ( !all ) skip = ( allday != test->doesFloat() );
691 if ( !skip ) { 691 if ( !skip ) {
692 if ( found ) 692 if ( found )
693 skip = !test->matchTime( &startDT, &conflict ); 693 skip = !test->matchTime( &startDT, &conflict );
694 else 694 else
695 skip = !test->matchTime( &startDT, 0 ); 695 skip = !test->matchTime( &startDT, 0 );
696 } 696 }
697 if ( !skip ) { 697 if ( !skip ) {
698 Event * test2 = testlist2.first(); 698 Event * test2 = testlist2.first();
699 while ( test2 ) { 699 while ( test2 ) {
700 skip = test2->isTagged(); 700 skip = test2->isTagged();
701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
702 if ( !skip ) { 702 if ( !skip ) {
703 if ( found ) 703 if ( found )
704 skip = !test2->matchTime( &startDT, &conflict ); 704 skip = !test2->matchTime( &startDT, &conflict );
705 else 705 else
706 skip = !test2->matchTime( &startDT, 0 ); 706 skip = !test2->matchTime( &startDT, 0 );
707 } 707 }
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
710 //qDebug("overlap "); 710 //qDebug("overlap ");
711 if ( ! found ) { 711 if ( ! found ) {
712 if ( retVal >= startDT ) { 712 if ( retVal >= startDT ) {
713 conflict = retVal; 713 conflict = retVal;
714 cE = test; 714 cE = test;
715 cE2 = test2; 715 cE2 = test2;
716 found = true; 716 found = true;
717 } 717 }
718 } else { 718 } else {
719 if ( retVal >= startDT && retVal < conflict ) { 719 if ( retVal >= startDT && retVal < conflict ) {
720 conflict = retVal; 720 conflict = retVal;
721 cE = test; 721 cE = test;
722 cE2 = test2; 722 cE2 = test2;
723 } 723 }
724 } 724 }
725 } 725 }
726 } 726 }
727 test2 = testlist2.next(); 727 test2 = testlist2.next();
728 } 728 }
729 } 729 }
730 test->setTagged( true ); 730 test->setTagged( true );
731 test = testlist.next(); 731 test = testlist.next();
732 } 732 }
733 //qDebug("Search time : %d", tm.elapsed()); 733 //qDebug("Search time : %d", tm.elapsed());
734 if ( found ) { 734 if ( found ) {
735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
736 mViewManager->showDayView(); 736 mViewManager->showDayView();
737 mNavigator->slotDaySelect( conflict.date() ); 737 mNavigator->slotDaySelect( conflict.date() );
738 int hour = conflict.time().hour(); 738 int hour = conflict.time().hour();
739 mViewManager->agendaView()->setStartHour( hour ); 739 mViewManager->agendaView()->setStartHour( hour );
740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
741 block = false; 741 block = false;
742 return; 742 return;
743 } 743 }
744 744
745 topLevelWidget()->setCaption( i18n("No conflict found") ); 745 topLevelWidget()->setCaption( i18n("No conflict found") );
746 //qDebug("No conflict found "); 746 //qDebug("No conflict found ");
747 block = false; 747 block = false;
748 return; 748 return;
749} 749}
750 750
751void CalendarView::conflictAll() 751void CalendarView::conflictAll()
752{ 752{
753 nextConflict ( true, true ); 753 nextConflict ( true, true );
754} 754}
755void CalendarView::conflictAllday() 755void CalendarView::conflictAllday()
756{ 756{
757 nextConflict ( false, true ); 757 nextConflict ( false, true );
758} 758}
759void CalendarView::conflictNotAll() 759void CalendarView::conflictNotAll()
760{ 760{
761 nextConflict ( false, false ); 761 nextConflict ( false, false );
762} 762}
763 763
764void CalendarView::setCalReadOnly( int id, bool readO ) 764void CalendarView::setCalReadOnly( int id, bool readO )
765{ 765{
766 if ( readO ) { 766 if ( readO ) {
767 emit save(); 767 emit save();
768 } 768 }
769 mCalendar->setReadOnly( id, readO ); 769 mCalendar->setReadOnly( id, readO );
770} 770}
771void CalendarView::setScrollBarStep(int val ) 771void CalendarView::setScrollBarStep(int val )
772{ 772{
773#ifdef DESKTOP_VERSION 773#ifdef DESKTOP_VERSION
774 mDateScrollBar->setLineStep ( val ); 774 mDateScrollBar->setLineStep ( val );
775#endif 775#endif
776} 776}
777void CalendarView::scrollBarValue(int val ) 777void CalendarView::scrollBarValue(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 if ( QApplication::desktop()->width() < 800 ) return; 780 if ( QApplication::desktop()->width() < 800 ) return;
781 static bool block = false; 781 static bool block = false;
782 if ( block ) return; 782 if ( block ) return;
783 block = true; 783 block = true;
784 int count = mNavigator->selectedDates().count(); 784 int count = mNavigator->selectedDates().count();
785 int day = mNavigator->selectedDates().first().dayOfYear(); 785 int day = mNavigator->selectedDates().first().dayOfYear();
786 int stepdays = val; 786 int stepdays = val;
787 if ( mDateScrollBar->lineStep () <= count ) { 787 if ( mDateScrollBar->lineStep () <= count ) {
788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
789 //qDebug("VAL %d ",val ); 789 //qDebug("VAL %d ",val );
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void CalendarView::checkFiles()
826{ 826{
827 QString message; 827 QString message;
828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
829 KopiCalendarFile * cal = calendars.first(); 829 KopiCalendarFile * cal = calendars.first();
830 while ( cal ) { 830 while ( cal ) {
831 if ( cal->mErrorOnLoad ) { 831 if ( cal->mErrorOnLoad ) {
832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
833 } 833 }
834 cal = calendars.next(); 834 cal = calendars.next();
835 } 835 }
836 if ( !message.isEmpty() ) { 836 if ( !message.isEmpty() ) {
837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
839 } 839 }
840 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 840 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
841} 841}
842void CalendarView::checkAlarms() 842void CalendarView::checkAlarms()
843{ 843{
844 844
845 845
846 KConfig *config = KOGlobals::config(); 846 KConfig *config = KOGlobals::config();
847 config->setGroup( "AppRun" ); 847 config->setGroup( "AppRun" );
848 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 848 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
849 int daysto = dt.daysTo( QDate::currentDate() ); 849 int daysto = dt.daysTo( QDate::currentDate() );
850 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 850 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
851 dt = dt.addDays( days ); 851 dt = dt.addDays( days );
852 int secto = dt.secsTo( QDateTime::currentDateTime() ); 852 int secto = dt.secsTo( QDateTime::currentDateTime() );
853 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 853 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
854 //qDebug("KO: Reading program stop %d ", secs); 854 //qDebug("KO: Reading program stop %d ", secs);
855 //secs -= ( 3600 * 24*3 ); // debug only 855 //secs -= ( 3600 * 24*3 ); // debug only
856 QDateTime latest = dt.addSecs ( secs ); 856 QDateTime latest = dt.addSecs ( secs );
857 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 857 qDebug("KO: Last termination on %s ", latest.toString().latin1());
858 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 858 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
859 QPtrList<Incidence> el = mCalendar->rawIncidences(); 859 QPtrList<Incidence> el = mCalendar->rawIncidences();
860 QPtrList<Incidence> al; 860 QPtrList<Incidence> al;
861 Incidence* inL = el.first(); 861 Incidence* inL = el.first();
862 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 862 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
863 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 863 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
864 while ( inL ) { 864 while ( inL ) {
865 bool ok = false; 865 bool ok = false;
866 int offset = 0; 866 int offset = 0;
867 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 867 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
868 if ( ok ) { 868 if ( ok ) {
869 //qDebug("OK %s",next.toString().latin1()); 869 //qDebug("OK %s",next.toString().latin1());
870 if ( next < cur ) { 870 if ( next < cur ) {
871 al.append( inL ); 871 al.append( inL );
872 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 872 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
873 } 873 }
874 } 874 }
875 inL = el.next(); 875 inL = el.next();
876 } 876 }
877 if ( al.count() ) { 877 if ( al.count() ) {
878 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 878 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
879 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 879 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
880 QVBoxLayout* lay = new QVBoxLayout( dia ); 880 QVBoxLayout* lay = new QVBoxLayout( dia );
881 lay->setSpacing( 0 ); 881 lay->setSpacing( 0 );
882 lay->setMargin( 0 ); 882 lay->setMargin( 0 );
883 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 883 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
884 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 884 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
885 lay->addWidget( matb ); 885 lay->addWidget( matb );
886 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 886 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
887 int wid = 210; 887 int wid = 210;
888 int x = QApplication::desktop()->width() - wid - 7; 888 int x = QApplication::desktop()->width() - wid - 7;
889 int y = QApplication::desktop()->height() - wid - 70; 889 int y = QApplication::desktop()->height() - wid - 70;
890 dia->setGeometry ( x,y,wid,wid); 890 dia->setGeometry ( x,y,wid,wid);
891 } else { 891 } else {
892 int si = 220; 892 int si = 220;
893 if ( QApplication::desktop()->width() > 470 ) 893 if ( QApplication::desktop()->width() > 470 )
894 si = 400; 894 si = 400;
895 dia->resize(si,si/2); 895 dia->resize(si,si/2);
896 } 896 }
897 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 897 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
898 dia->show(); 898 dia->show();
899 899
900 } 900 }
901} 901}
902void CalendarView::showDay( QDate d ) 902void CalendarView::showDay( QDate d )
903{ 903{
904 dateNavigator()->blockSignals( true ); 904 dateNavigator()->blockSignals( true );
905 dateNavigator()->selectDate( d ); 905 dateNavigator()->selectDate( d );
906 dateNavigator()->blockSignals( false ); 906 dateNavigator()->blockSignals( false );
907 mViewManager->showDayView(); 907 mViewManager->showDayView();
908 //dateNavigator()->selectDate( d ); 908 //dateNavigator()->selectDate( d );
909} 909}
910void CalendarView::timerAlarm() 910void CalendarView::timerAlarm()
911{ 911{
912 //qDebug("CalendarView::timerAlarm() "); 912 //qDebug("CalendarView::timerAlarm() ");
913 computeAlarm(mAlarmNotification ); 913 computeAlarm(mAlarmNotification );
914} 914}
915 915
916void CalendarView::suspendAlarm() 916void CalendarView::suspendAlarm()
917{ 917{
918 //qDebug(" CalendarView::suspendAlarm() "); 918 //qDebug(" CalendarView::suspendAlarm() ");
919 computeAlarm(mSuspendAlarmNotification ); 919 computeAlarm(mSuspendAlarmNotification );
920 920
921} 921}
922 922
923void CalendarView::startAlarm( QString mess , QString filename) 923void CalendarView::startAlarm( QString mess , QString filename)
924{ 924{
925 925
926 topLevelWidget()->showNormal(); 926 topLevelWidget()->showNormal();
927 topLevelWidget()->setActiveWindow(); 927 topLevelWidget()->setActiveWindow();
928 topLevelWidget()->raise(); 928 topLevelWidget()->raise();
929 929
930 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 930 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
931 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 931 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
932 932
933} 933}
934 934
935void CalendarView::checkNextTimerAlarm() 935void CalendarView::checkNextTimerAlarm()
936{ 936{
937 mCalendar->checkAlarmForIncidence( 0, true ); 937 mCalendar->checkAlarmForIncidence( 0, true );
938} 938}
939 939
940void CalendarView::computeAlarm( QString msg ) 940void CalendarView::computeAlarm( QString msg )
941{ 941{
942 942
943 QString mess = msg; 943 QString mess = msg;
944 QString mAlarmMessage = mess.mid( 9 ); 944 QString mAlarmMessage = mess.mid( 9 );
945 QString filename = MainWindow::resourcePath(); 945 QString filename = MainWindow::resourcePath();
946 filename += "koalarm.wav"; 946 filename += "koalarm.wav";
947 QString tempfilename; 947 QString tempfilename;
948 if ( mess.left( 13 ) == "suspend_alarm") { 948 if ( mess.left( 13 ) == "suspend_alarm") {
949 bool error = false; 949 bool error = false;
950 int len = mess.mid( 13 ).find("+++"); 950 int len = mess.mid( 13 ).find("+++");
951 if ( len < 2 ) 951 if ( len < 2 )
952 error = true; 952 error = true;
953 else { 953 else {
954 tempfilename = mess.mid( 13, len ); 954 tempfilename = mess.mid( 13, len );
955 if ( !QFile::exists( tempfilename ) ) 955 if ( !QFile::exists( tempfilename ) )
956 error = true; 956 error = true;
957 } 957 }
958 if ( ! error ) { 958 if ( ! error ) {
959 filename = tempfilename; 959 filename = tempfilename;
960 } 960 }
961 mAlarmMessage = mess.mid( 13+len+3 ); 961 mAlarmMessage = mess.mid( 13+len+3 );
962 //qDebug("suspend file %s ",tempfilename.latin1() ); 962 //qDebug("suspend file %s ",tempfilename.latin1() );
963 startAlarm( mAlarmMessage, filename); 963 startAlarm( mAlarmMessage, filename);
964 return; 964 return;
965 } 965 }
966 if ( mess.left( 11 ) == "timer_alarm") { 966 if ( mess.left( 11 ) == "timer_alarm") {
967 //mTimerTime = 0; 967 //mTimerTime = 0;
968 startAlarm( mess.mid( 11 ), filename ); 968 startAlarm( mess.mid( 11 ), filename );
969 return; 969 return;
970 } 970 }
971 if ( mess.left( 10 ) == "proc_alarm") { 971 if ( mess.left( 10 ) == "proc_alarm") {
972 bool error = false; 972 bool error = false;
973 int len = mess.mid( 10 ).find("+++"); 973 int len = mess.mid( 10 ).find("+++");
974 if ( len < 2 ) 974 if ( len < 2 )
975 error = true; 975 error = true;
976 else { 976 else {
977 tempfilename = mess.mid( 10, len ); 977 tempfilename = mess.mid( 10, len );
978 if ( !QFile::exists( tempfilename ) ) 978 if ( !QFile::exists( tempfilename ) )
979 error = true; 979 error = true;
980 } 980 }
981 if ( error ) { 981 if ( error ) {
982 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 982 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
983 mAlarmMessage += mess.mid( 10+len+3+9 ); 983 mAlarmMessage += mess.mid( 10+len+3+9 );
984 } else { 984 } else {
985 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 985 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
986 //qDebug("-----system command %s ",tempfilename.latin1() ); 986 //qDebug("-----system command %s ",tempfilename.latin1() );
987#ifndef _WIN32_ 987#ifndef _WIN32_
988 if ( vfork () == 0 ) { 988 if ( vfork () == 0 ) {
989 execl ( tempfilename.latin1(), 0 ); 989 execl ( tempfilename.latin1(), 0 );
990 return; 990 return;
991 } 991 }
992#else 992#else
993 QProcess* p = new QProcess(); 993 QProcess* p = new QProcess();
994 p->addArgument( tempfilename.latin1() ); 994 p->addArgument( tempfilename.latin1() );
995 p->start(); 995 p->start();
996 return; 996 return;
997#endif 997#endif
998 998
999 return; 999 return;
1000 } 1000 }
1001 1001
1002 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1002 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1003 } 1003 }
1004 if ( mess.left( 11 ) == "audio_alarm") { 1004 if ( mess.left( 11 ) == "audio_alarm") {
1005 bool error = false; 1005 bool error = false;
1006 int len = mess.mid( 11 ).find("+++"); 1006 int len = mess.mid( 11 ).find("+++");
1007 if ( len < 2 ) 1007 if ( len < 2 )
1008 error = true; 1008 error = true;
1009 else { 1009 else {
1010 tempfilename = mess.mid( 11, len ); 1010 tempfilename = mess.mid( 11, len );
1011 if ( !QFile::exists( tempfilename ) ) 1011 if ( !QFile::exists( tempfilename ) )
1012 error = true; 1012 error = true;
1013 } 1013 }
1014 if ( ! error ) { 1014 if ( ! error ) {
1015 filename = tempfilename; 1015 filename = tempfilename;
1016 } 1016 }
1017 mAlarmMessage = mess.mid( 11+len+3+9 ); 1017 mAlarmMessage = mess.mid( 11+len+3+9 );
1018 //qDebug("audio file command %s ",tempfilename.latin1() ); 1018 //qDebug("audio file command %s ",tempfilename.latin1() );
1019 } 1019 }
1020 if ( mess.left( 9 ) == "cal_alarm") { 1020 if ( mess.left( 9 ) == "cal_alarm") {
1021 mAlarmMessage = mess.mid( 9 ) ; 1021 mAlarmMessage = mess.mid( 9 ) ;
1022 } 1022 }
1023 1023
1024 startAlarm( mAlarmMessage, filename ); 1024 startAlarm( mAlarmMessage, filename );
1025 1025
1026 1026
1027} 1027}
1028 1028
1029void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1029void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1030{ 1030{
1031 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1031 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1032 1032
1033 mSuspendAlarmNotification = noti; 1033 mSuspendAlarmNotification = noti;
1034 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1034 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1035 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1035 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1036 mSuspendTimer->start( ms , true ); 1036 mSuspendTimer->start( ms , true );
1037 1037
1038} 1038}
1039 1039
1040void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1040void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1041{ 1041{
1042 mNextAlarmDateTime = qdt; 1042 mNextAlarmDateTime = qdt;
1043 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1043 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1044 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1044 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1045#ifndef DESKTOP_VERSION 1045#ifndef DESKTOP_VERSION
1046 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1046 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1047#endif 1047#endif
1048 return; 1048 return;
1049 } 1049 }
1050 int maxSec; 1050 int maxSec;
1051 //maxSec = 5; //testing only 1051 //maxSec = 5; //testing only
1052 maxSec = 86400+3600; // one day+1hour 1052 maxSec = 86400+3600; // one day+1hour
1053 mAlarmNotification = noti; 1053 mAlarmNotification = noti;
1054 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1054 int sec = QDateTime::currentDateTime().secsTo( qdt );
1055 if ( sec > maxSec ) { 1055 if ( sec > maxSec ) {
1056 mRecheckAlarmTimer->start( maxSec * 1000 ); 1056 mRecheckAlarmTimer->start( maxSec * 1000 );
1057 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1057 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1058 return; 1058 return;
1059 } else { 1059 } else {
1060 mRecheckAlarmTimer->stop(); 1060 mRecheckAlarmTimer->stop();
1061 } 1061 }
1062 //qDebug("Alarm timer started with secs: %d ", sec); 1062 //qDebug("Alarm timer started with secs: %d ", sec);
1063 mAlarmTimer->start( sec *1000 , true ); 1063 mAlarmTimer->start( sec *1000 , true );
1064 1064
1065} 1065}
1066// called by mRecheckAlarmTimer to get next alarm 1066// called by mRecheckAlarmTimer to get next alarm
1067// we need this, because a QTimer has only a max range of 25 days 1067// we need this, because a QTimer has only a max range of 25 days
1068void CalendarView::recheckTimerAlarm() 1068void CalendarView::recheckTimerAlarm()
1069{ 1069{
1070 mAlarmTimer->stop(); 1070 mAlarmTimer->stop();
1071 mRecheckAlarmTimer->stop(); 1071 mRecheckAlarmTimer->stop();
1072 mCalendar->checkAlarmForIncidence( 0, true ); 1072 mCalendar->checkAlarmForIncidence( 0, true );
1073} 1073}
1074#ifndef DESKTOP_VERSION 1074#ifndef DESKTOP_VERSION
1075void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1075void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1076#else 1076#else
1077void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1077void CalendarView::removeAlarm(const QDateTime &, const QString & )
1078#endif 1078#endif
1079{ 1079{
1080 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1080 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1081 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1081 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1082#ifndef DESKTOP_VERSION 1082#ifndef DESKTOP_VERSION
1083 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1083 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1084#endif 1084#endif
1085 return; 1085 return;
1086 } 1086 }
1087 mAlarmTimer->stop(); 1087 mAlarmTimer->stop();
1088} 1088}
1089void CalendarView::selectWeekNum ( int num ) 1089void CalendarView::selectWeekNum ( int num )
1090{ 1090{
1091 dateNavigator()->blockSignals( true ); 1091 dateNavigator()->blockSignals( true );
1092 dateNavigator()->selectWeek( num ); 1092 dateNavigator()->selectWeek( num );
1093 dateNavigator()->blockSignals( false ); 1093 dateNavigator()->blockSignals( false );
1094 mViewManager->showWeekView(); 1094 mViewManager->showWeekView();
1095} 1095}
1096KOViewManager *CalendarView::viewManager() 1096KOViewManager *CalendarView::viewManager()
1097{ 1097{
1098 return mViewManager; 1098 return mViewManager;
1099} 1099}
1100 1100
1101KODialogManager *CalendarView::dialogManager() 1101KODialogManager *CalendarView::dialogManager()
1102{ 1102{
1103 return mDialogManager; 1103 return mDialogManager;
1104} 1104}
1105 1105
1106QDate CalendarView::startDate() 1106QDate CalendarView::startDate()
1107{ 1107{
1108 DateList dates = mNavigator->selectedDates(); 1108 DateList dates = mNavigator->selectedDates();
1109 1109
1110 return dates.first(); 1110 return dates.first();
1111} 1111}
1112 1112
1113QDate CalendarView::endDate() 1113QDate CalendarView::endDate()
1114{ 1114{
1115 DateList dates = mNavigator->selectedDates(); 1115 DateList dates = mNavigator->selectedDates();
1116 1116
1117 return dates.last(); 1117 return dates.last();
1118} 1118}
1119 1119
1120 1120
1121void CalendarView::createPrinter() 1121void CalendarView::createPrinter()
1122{ 1122{
1123#ifndef KORG_NOPRINTER 1123#ifndef KORG_NOPRINTER
1124 if (!mCalPrinter) { 1124 if (!mCalPrinter) {
1125 mCalPrinter = new CalPrinter(this, mCalendar); 1125 mCalPrinter = new CalPrinter(this, mCalendar);
1126 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1126 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1127 } 1127 }
1128#endif 1128#endif
1129} 1129}
1130 1130
1131 1131
1132//KOPrefs::instance()->mWriteBackFile 1132//KOPrefs::instance()->mWriteBackFile
1133//KOPrefs::instance()->mWriteBackExistingOnly 1133//KOPrefs::instance()->mWriteBackExistingOnly
1134 1134
1135// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1135// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1136// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1136// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1137// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1137// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1138// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1138// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1139// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1139// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1140// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1140// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1141 1141
1142int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1142int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1143{ 1143{
1144 1144
1145 // 0 equal 1145 // 0 equal
1146 // 1 take local 1146 // 1 take local
1147 // 2 take remote 1147 // 2 take remote
1148 // 3 cancel 1148 // 3 cancel
1149 QDateTime lastSync = mLastCalendarSync; 1149 QDateTime lastSync = mLastCalendarSync;
1150 QDateTime localMod = local->lastModified(); 1150 QDateTime localMod = local->lastModified();
1151 QDateTime remoteMod = remote->lastModified(); 1151 QDateTime remoteMod = remote->lastModified();
1152 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1152 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1153 bool remCh, locCh; 1153 bool remCh, locCh;
1154 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1154 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1155 //if ( remCh ) 1155 //if ( remCh )
1156 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1156 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1157 locCh = ( localMod > mLastCalendarSync ); 1157 locCh = ( localMod > mLastCalendarSync );
1158 if ( !remCh && ! locCh ) { 1158 if ( !remCh && ! locCh ) {
1159 //qDebug("both not changed "); 1159 //qDebug("both not changed ");
1160 lastSync = localMod.addDays(1); 1160 lastSync = localMod.addDays(1);
1161 if ( mode <= SYNC_PREF_ASK ) 1161 if ( mode <= SYNC_PREF_ASK )
1162 return 0; 1162 return 0;
1163 } else { 1163 } else {
1164 if ( locCh ) { 1164 if ( locCh ) {
1165 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1165 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1166 lastSync = localMod.addDays( -1 ); 1166 lastSync = localMod.addDays( -1 );
1167 if ( !remCh ) 1167 if ( !remCh )
1168 remoteMod = ( lastSync.addDays( -1 ) ); 1168 remoteMod = ( lastSync.addDays( -1 ) );
1169 } else { 1169 } else {
1170 //qDebug(" not loc changed "); 1170 //qDebug(" not loc changed ");
1171 lastSync = localMod.addDays( 1 ); 1171 lastSync = localMod.addDays( 1 );
1172 if ( remCh ) 1172 if ( remCh )
1173 remoteMod =( lastSync.addDays( 1 ) ); 1173 remoteMod =( lastSync.addDays( 1 ) );
1174 1174
1175 } 1175 }
1176 } 1176 }
1177 full = true; 1177 full = true;
1178 if ( mode < SYNC_PREF_ASK ) 1178 if ( mode < SYNC_PREF_ASK )
1179 mode = SYNC_PREF_ASK; 1179 mode = SYNC_PREF_ASK;
1180 } else { 1180 } else {
1181 if ( localMod == remoteMod ) 1181 if ( localMod == remoteMod )
1182 // if ( local->revision() == remote->revision() ) 1182 // if ( local->revision() == remote->revision() )
1183 return 0; 1183 return 0;
1184 1184
1185 } 1185 }
1186 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1186 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1187 1187
1188 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1188 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1189 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1189 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1190 //full = true; //debug only 1190 //full = true; //debug only
1191 if ( full ) { 1191 if ( full ) {
1192 bool equ = false; 1192 bool equ = false;
1193 if ( local->typeID() == eventID ) { 1193 if ( local->typeID() == eventID ) {
1194 equ = (*((Event*) local) == *((Event*) remote)); 1194 equ = (*((Event*) local) == *((Event*) remote));
1195 } 1195 }
1196 else if ( local->typeID() == todoID ) 1196 else if ( local->typeID() == todoID )
1197 equ = (*((Todo*) local) == (*(Todo*) remote)); 1197 equ = (*((Todo*) local) == (*(Todo*) remote));
1198 else if ( local->typeID() == journalID ) 1198 else if ( local->typeID() == journalID )
1199 equ = (*((Journal*) local) == *((Journal*) remote)); 1199 equ = (*((Journal*) local) == *((Journal*) remote));
1200 if ( equ ) { 1200 if ( equ ) {
1201 //qDebug("equal "); 1201 //qDebug("equal ");
1202 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1202 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1203 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1203 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1204 } 1204 }
1205 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1205 if ( mode < SYNC_PREF_FORCE_LOCAL )
1206 return 0; 1206 return 0;
1207 1207
1208 }//else //debug only 1208 }//else //debug only
1209 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1209 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1210 } 1210 }
1211 int result; 1211 int result;
1212 bool localIsNew; 1212 bool localIsNew;
1213 //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() ); 1213 //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() );
1214 1214
1215 1215
1216 // ************************************************ 1216 // ************************************************
1217 // ************************************************ 1217 // ************************************************
1218 // ************************************************ 1218 // ************************************************
1219 // We may have that lastSync > remoteMod AND lastSync > localMod 1219 // We may have that lastSync > remoteMod AND lastSync > localMod
1220 // BUT remoteMod != localMod 1220 // BUT remoteMod != localMod
1221 1221
1222 1222
1223 if ( full && mode < SYNC_PREF_NEWEST ) 1223 if ( full && mode < SYNC_PREF_NEWEST )
1224 mode = SYNC_PREF_ASK; 1224 mode = SYNC_PREF_ASK;
1225 1225
1226 switch( mode ) { 1226 switch( mode ) {
1227 case SYNC_PREF_LOCAL: 1227 case SYNC_PREF_LOCAL:
1228 if ( lastSync > remoteMod ) 1228 if ( lastSync > remoteMod )
1229 return 1; 1229 return 1;
1230 if ( lastSync > localMod ) 1230 if ( lastSync > localMod )
1231 return 2; 1231 return 2;
1232 return 1; 1232 return 1;
1233 break; 1233 break;
1234 case SYNC_PREF_REMOTE: 1234 case SYNC_PREF_REMOTE:
1235 if ( lastSync > localMod ) 1235 if ( lastSync > localMod )
1236 return 2; 1236 return 2;
1237 if ( lastSync > remoteMod ) 1237 if ( lastSync > remoteMod )
1238 return 1; 1238 return 1;
1239 return 2; 1239 return 2;
1240 break; 1240 break;
1241 case SYNC_PREF_NEWEST: 1241 case SYNC_PREF_NEWEST:
1242 if ( localMod >= remoteMod ) 1242 if ( localMod >= remoteMod )
1243 return 1; 1243 return 1;
1244 else 1244 else
1245 return 2; 1245 return 2;
1246 break; 1246 break;
1247 case SYNC_PREF_ASK: 1247 case SYNC_PREF_ASK:
1248 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1248 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1249 if ( lastSync > remoteMod && lastSync > localMod) 1249 if ( lastSync > remoteMod && lastSync > localMod)
1250 return 0; 1250 return 0;
1251 if ( lastSync > remoteMod ) 1251 if ( lastSync > remoteMod )
1252 return 1; 1252 return 1;
1253 if ( lastSync > localMod ) 1253 if ( lastSync > localMod )
1254 return 2; 1254 return 2;
1255 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1255 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1256 localIsNew = localMod >= remoteMod; 1256 localIsNew = localMod >= remoteMod;
1257 if ( localIsNew ) 1257 if ( localIsNew )
1258 getEventViewerDialog()->setColorMode( 1 ); 1258 getEventViewerDialog()->setColorMode( 1 );
1259 else 1259 else
1260 getEventViewerDialog()->setColorMode( 2 ); 1260 getEventViewerDialog()->setColorMode( 2 );
1261 getEventViewerDialog()->setIncidence(local); 1261 getEventViewerDialog()->setIncidence(local);
1262 if ( localIsNew ) 1262 if ( localIsNew )
1263 getEventViewerDialog()->setColorMode( 2 ); 1263 getEventViewerDialog()->setColorMode( 2 );
1264 else 1264 else
1265 getEventViewerDialog()->setColorMode( 1 ); 1265 getEventViewerDialog()->setColorMode( 1 );
1266 getEventViewerDialog()->addIncidence(remote); 1266 getEventViewerDialog()->addIncidence(remote);
1267 getEventViewerDialog()->setColorMode( 0 ); 1267 getEventViewerDialog()->setColorMode( 0 );
1268 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1268 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1269 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1269 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1270 getEventViewerDialog()->showMe(); 1270 getEventViewerDialog()->showMe();
1271 result = getEventViewerDialog()->executeS( localIsNew ); 1271 result = getEventViewerDialog()->executeS( localIsNew );
1272 return result; 1272 return result;
1273 1273
1274 break; 1274 break;
1275 case SYNC_PREF_FORCE_LOCAL: 1275 case SYNC_PREF_FORCE_LOCAL:
1276 return 1; 1276 return 1;
1277 break; 1277 break;
1278 case SYNC_PREF_FORCE_REMOTE: 1278 case SYNC_PREF_FORCE_REMOTE:
1279 return 2; 1279 return 2;
1280 break; 1280 break;
1281 1281
1282 default: 1282 default:
1283 // SYNC_PREF_TAKE_BOTH not implemented 1283 // SYNC_PREF_TAKE_BOTH not implemented
1284 break; 1284 break;
1285 } 1285 }
1286 return 0; 1286 return 0;
1287} 1287}
1288Event* CalendarView::getLastSyncEvent() 1288Event* CalendarView::getLastSyncEvent()
1289{ 1289{
1290 Event* lse; 1290 Event* lse;
1291 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1291 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1292 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1292 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1293 if (!lse) { 1293 if (!lse) {
1294 lse = new Event(); 1294 lse = new Event();
1295 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1295 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1296 QString sum = ""; 1296 QString sum = "";
1297 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1297 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1298 sum = "E: "; 1298 sum = "E: ";
1299 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1299 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1300 lse->setDtStart( mLastCalendarSync ); 1300 lse->setDtStart( mLastCalendarSync );
1301 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1301 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1302 lse->setCategories( i18n("SyncEvent") ); 1302 lse->setCategories( i18n("SyncEvent") );
1303 lse->setReadOnly( true ); 1303 lse->setReadOnly( true );
1304 mCalendar->addEvent( lse ); 1304 mCalendar->addEvent( lse );
1305 } 1305 }
1306 1306
1307 return lse; 1307 return lse;
1308 1308
1309} 1309}
1310 1310
1311// we check, if the to delete event has a id for a profile 1311// we check, if the to delete event has a id for a profile
1312// if yes, we set this id in the profile to delete 1312// if yes, we set this id in the profile to delete
1313void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1313void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1314{ 1314{
1315 if ( lastSync.count() == 0 ) { 1315 if ( lastSync.count() == 0 ) {
1316 //qDebug(" lastSync.count() == 0"); 1316 //qDebug(" lastSync.count() == 0");
1317 return; 1317 return;
1318 } 1318 }
1319 if ( toDelete->typeID() == journalID ) 1319 if ( toDelete->typeID() == journalID )
1320 return; 1320 return;
1321 1321
1322 Event* eve = lastSync.first(); 1322 Event* eve = lastSync.first();
1323 1323
1324 while ( eve ) { 1324 while ( eve ) {
1325 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1325 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1326 if ( !id.isEmpty() ) { 1326 if ( !id.isEmpty() ) {
1327 QString des = eve->description(); 1327 QString des = eve->description();
1328 QString pref = "e"; 1328 QString pref = "e";
1329 if ( toDelete->typeID() == todoID ) 1329 if ( toDelete->typeID() == todoID )
1330 pref = "t"; 1330 pref = "t";
1331 des += pref+ id + ","; 1331 des += pref+ id + ",";
1332 eve->setReadOnly( false ); 1332 eve->setReadOnly( false );
1333 eve->setDescription( des ); 1333 eve->setDescription( des );
1334 //qDebug("setdes %s ", des.latin1()); 1334 //qDebug("setdes %s ", des.latin1());
1335 eve->setReadOnly( true ); 1335 eve->setReadOnly( true );
1336 } 1336 }
1337 eve = lastSync.next(); 1337 eve = lastSync.next();
1338 } 1338 }
1339 1339
1340} 1340}
1341void CalendarView::checkExternalId( Incidence * inc ) 1341void CalendarView::checkExternalId( Incidence * inc )
1342{ 1342{
1343 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1343 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1344 checkExternSyncEvent( lastSync, inc ); 1344 checkExternSyncEvent( lastSync, inc );
1345 1345
1346} 1346}
1347bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1347bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1348{ 1348{
1349 bool syncOK = true; 1349 bool syncOK = true;
1350 int addedEvent = 0; 1350 int addedEvent = 0;
1351 int addedEventR = 0; 1351 int addedEventR = 0;
1352 int deletedEventR = 0; 1352 int deletedEventR = 0;
1353 int deletedEventL = 0; 1353 int deletedEventL = 0;
1354 int changedLocal = 0; 1354 int changedLocal = 0;
1355 int changedRemote = 0; 1355 int changedRemote = 0;
1356 int filteredIN = 0; 1356 int filteredIN = 0;
1357 int filteredOUT = 0; 1357 int filteredOUT = 0;
1358 //QPtrList<Event> el = local->rawEvents(); 1358 //QPtrList<Event> el = local->rawEvents();
1359 Event* eventR; 1359 Event* eventR;
1360 QString uid; 1360 QString uid;
1361 int take; 1361 int take;
1362 Event* eventRSync; 1362 Event* eventRSync;
1363 Event* eventLSync; 1363 Event* eventLSync;
1364 clearAllViews(); 1364 clearAllViews();
1365 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1365 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1366 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1366 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1367 bool fullDateRange = false; 1367 bool fullDateRange = false;
1368 local->resetTempSyncStat(); 1368 local->resetTempSyncStat();
1369 mLastCalendarSync = QDateTime::currentDateTime(); 1369 mLastCalendarSync = QDateTime::currentDateTime();
1370 if ( mSyncManager->syncWithDesktop() ) { 1370 if ( mSyncManager->syncWithDesktop() ) {
1371 remote->resetPilotStat(1); 1371 remote->resetPilotStat(1);
1372 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1372 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1373 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1373 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1374 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1374 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1375 } else { 1375 } else {
1376 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1376 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1377 } 1377 }
1378 } 1378 }
1379 QDateTime modifiedCalendar = mLastCalendarSync; 1379 QDateTime modifiedCalendar = mLastCalendarSync;
1380 eventLSync = getLastSyncEvent(); 1380 eventLSync = getLastSyncEvent();
1381 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1381 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1382 if ( eventR ) { 1382 if ( eventR ) {
1383 qDebug("last-syncEvent on remote found "); 1383 qDebug("last-syncEvent on remote found ");
1384 eventRSync = (Event*) eventR->clone(); 1384 eventRSync = (Event*) eventR->clone();
1385 remote->deleteEvent(eventR ); 1385 remote->deleteEvent(eventR );
1386 1386
1387 } else { 1387 } else {
1388 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1388 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1389 eventRSync = (Event*)eventLSync->clone(); 1389 eventRSync = (Event*)eventLSync->clone();
1390 } else { 1390 } else {
1391 fullDateRange = true; 1391 fullDateRange = true;
1392 eventRSync = new Event(); 1392 eventRSync = new Event();
1393 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1393 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1394 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1394 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1395 eventRSync->setDtStart( mLastCalendarSync ); 1395 eventRSync->setDtStart( mLastCalendarSync );
1396 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1396 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1397 eventRSync->setCategories( i18n("SyncEvent") ); 1397 eventRSync->setCategories( i18n("SyncEvent") );
1398 } 1398 }
1399 } 1399 }
1400 if ( eventLSync->dtStart() == mLastCalendarSync ) 1400 if ( eventLSync->dtStart() == mLastCalendarSync )
1401 fullDateRange = true; 1401 fullDateRange = true;
1402 1402
1403 if ( ! fullDateRange ) { 1403 if ( ! fullDateRange ) {
1404 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1404 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1405 1405
1406 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1406 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1407 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1407 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1408 fullDateRange = true; 1408 fullDateRange = true;
1409 } 1409 }
1410 } 1410 }
1411 if ( mSyncManager->syncWithDesktop() ) { 1411 if ( mSyncManager->syncWithDesktop() ) {
1412 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1412 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1413 } 1413 }
1414 if ( fullDateRange ) 1414 if ( fullDateRange )
1415 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1415 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1416 else 1416 else
1417 mLastCalendarSync = eventLSync->dtStart(); 1417 mLastCalendarSync = eventLSync->dtStart();
1418 // for resyncing if own file has changed 1418 // for resyncing if own file has changed
1419 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1419 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1420 mLastCalendarSync = loadedFileVersion; 1420 mLastCalendarSync = loadedFileVersion;
1421 //qDebug("setting mLastCalendarSync "); 1421 //qDebug("setting mLastCalendarSync ");
1422 } 1422 }
1423 //qDebug("*************************** "); 1423 //qDebug("*************************** ");
1424 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1424 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1425 QPtrList<Incidence> er = remote->rawIncidences(); 1425 QPtrList<Incidence> er = remote->rawIncidences();
1426 Incidence* inR = er.first(); 1426 Incidence* inR = er.first();
1427 Incidence* inL; 1427 Incidence* inL;
1428 QProgressBar bar( er.count(),0 ); 1428 QProgressBar bar( er.count(),0 );
1429 bar.setCaption (i18n("Syncing - close to abort!") ); 1429 bar.setCaption (i18n("Syncing - close to abort!") );
1430 1430
1431 // ************** setting up filter ************* 1431 // ************** setting up filter *************
1432 CalFilter *filterIN = 0; 1432 CalFilter *filterIN = 0;
1433 CalFilter *filterOUT = 0; 1433 CalFilter *filterOUT = 0;
1434 CalFilter *filter = mFilters.first(); 1434 CalFilter *filter = mFilters.first();
1435 while(filter) { 1435 while(filter) {
1436 if ( filter->name() == mSyncManager->mFilterInCal ) 1436 if ( filter->name() == mSyncManager->mFilterInCal )
1437 filterIN = filter; 1437 filterIN = filter;
1438 if ( filter->name() == mSyncManager->mFilterOutCal ) 1438 if ( filter->name() == mSyncManager->mFilterOutCal )
1439 filterOUT = filter; 1439 filterOUT = filter;
1440 filter = mFilters.next(); 1440 filter = mFilters.next();
1441 } 1441 }
1442 int w = 300; 1442 int w = 300;
1443 if ( QApplication::desktop()->width() < 320 ) 1443 if ( QApplication::desktop()->width() < 320 )
1444 w = 220; 1444 w = 220;
1445 int h = bar.sizeHint().height() ; 1445 int h = bar.sizeHint().height() ;
1446 int dw = QApplication::desktop()->width(); 1446 int dw = QApplication::desktop()->width();
1447 int dh = QApplication::desktop()->height(); 1447 int dh = QApplication::desktop()->height();
1448 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1448 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1449 bar.show(); 1449 bar.show();
1450 int modulo = (er.count()/10)+1; 1450 int modulo = (er.count()/10)+1;
1451 int incCounter = 0; 1451 int incCounter = 0;
1452 while ( inR ) { 1452 while ( inR ) {
1453 if ( ! bar.isVisible() ) 1453 if ( ! bar.isVisible() )
1454 return false; 1454 return false;
1455 if ( incCounter % modulo == 0 ) 1455 if ( incCounter % modulo == 0 )
1456 bar.setProgress( incCounter ); 1456 bar.setProgress( incCounter );
1457 ++incCounter; 1457 ++incCounter;
1458 uid = inR->uid(); 1458 uid = inR->uid();
1459 bool skipIncidence = false; 1459 bool skipIncidence = false;
1460 if ( uid.left(15) == QString("last-syncEvent-") ) 1460 if ( uid.left(15) == QString("last-syncEvent-") )
1461 skipIncidence = true; 1461 skipIncidence = true;
1462 QString idS; 1462 QString idS;
1463 qApp->processEvents(); 1463 qApp->processEvents();
1464 if ( !skipIncidence ) { 1464 if ( !skipIncidence ) {
1465 inL = local->incidenceForUid( uid , false ); 1465 inL = local->incidenceForUid( uid , false );
1466 if ( inL ) { // maybe conflict - same uid in both calendars 1466 if ( inL ) { // maybe conflict - same uid in both calendars
1467 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1467 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1468 //qDebug("take %d %s ", take, inL->summary().latin1()); 1468 //qDebug("take %d %s ", take, inL->summary().latin1());
1469 if ( take == 3 ) 1469 if ( take == 3 )
1470 return false; 1470 return false;
1471 if ( take == 1 ) {// take local ********************** 1471 if ( take == 1 ) {// take local **********************
1472 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1472 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1473 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1473 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1474 else 1474 else
1475 idS = inR->IDStr(); 1475 idS = inR->IDStr();
1476 int calID = inR->calID(); 1476 int calID = inR->calID();
1477 remote->deleteIncidence( inR ); 1477 remote->deleteIncidence( inR );
1478 inR = inL->clone(); 1478 inR = inL->clone();
1479 inR->setCalID( calID ); 1479 inR->setCalID( calID );
1480 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1480 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1481 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1481 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1482 inR->setIDStr( idS ); 1482 inR->setIDStr( idS );
1483 remote->addIncidence( inR ); 1483 remote->addIncidence( inR );
1484 if ( mSyncManager->syncWithDesktop() ) 1484 if ( mSyncManager->syncWithDesktop() )
1485 inR->setPilotId( 2 ); 1485 inR->setPilotId( 2 );
1486 ++changedRemote; 1486 ++changedRemote;
1487 } else {// take remote ********************** 1487 } else {// take remote **********************
1488 if ( !inL->isReadOnly() ) { 1488 if ( !inL->isReadOnly() ) {
1489 idS = inL->IDStr(); 1489 idS = inL->IDStr();
1490 int pid = inL->pilotId(); 1490 int pid = inL->pilotId();
1491 int calID = inL->calID(); 1491 int calID = inL->calID();
1492 local->deleteIncidence( inL ); 1492 local->deleteIncidence( inL );
1493 inL = inR->clone(); 1493 inL = inR->clone();
1494 inL->setCalID( calID ); 1494 inL->setCalID( calID );
1495 if ( mSyncManager->syncWithDesktop() ) 1495 if ( mSyncManager->syncWithDesktop() )
1496 inL->setPilotId( pid ); 1496 inL->setPilotId( pid );
1497 inL->setIDStr( idS ); 1497 inL->setIDStr( idS );
1498 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1498 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1499 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1499 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1500 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1500 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1501 } 1501 }
1502 local->addIncidence( inL ); 1502 local->addIncidence( inL );
1503 ++changedLocal; 1503 ++changedLocal;
1504 } 1504 }
1505 } 1505 }
1506 } 1506 }
1507 } else { // no conflict ********** add or delete remote 1507 } else { // no conflict ********** add or delete remote
1508 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1508 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1509 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1509 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1510 QString des = eventLSync->description(); 1510 QString des = eventLSync->description();
1511 QString pref = "e"; 1511 QString pref = "e";
1512 if ( inR->typeID() == todoID ) 1512 if ( inR->typeID() == todoID )
1513 pref = "t"; 1513 pref = "t";
1514 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1514 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1515 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1515 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1516 //remote->deleteIncidence( inR ); 1516 //remote->deleteIncidence( inR );
1517 ++deletedEventR; 1517 ++deletedEventR;
1518 } else { 1518 } else {
1519 inR->setLastModified( modifiedCalendar ); 1519 inR->setLastModified( modifiedCalendar );
1520 inL = inR->clone(); 1520 inL = inR->clone();
1521 inL->setIDStr( ":" ); 1521 inL->setIDStr( ":" );
1522 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1522 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1523 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1523 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1524 1524
1525 inL->setCalID( 0 );// add to default cal 1525 inL->setCalID( 0 );// add to default cal
1526 local->addIncidence( inL ); 1526 local->addIncidence( inL );
1527 ++addedEvent; 1527 ++addedEvent;
1528 1528
1529 } 1529 }
1530 } else { 1530 } else {
1531 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1531 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1532 inR->setLastModified( modifiedCalendar ); 1532 inR->setLastModified( modifiedCalendar );
1533 inL = inR->clone(); 1533 inL = inR->clone();
1534 inL->setIDStr( ":" ); 1534 inL->setIDStr( ":" );
1535 inL->setCalID( 0 );// add to default cal 1535 inL->setCalID( 0 );// add to default cal
1536 local->addIncidence( inL ); 1536 local->addIncidence( inL );
1537 ++addedEvent; 1537 ++addedEvent;
1538 1538
1539 } else { 1539 } else {
1540 checkExternSyncEvent(eventRSyncSharp, inR); 1540 checkExternSyncEvent(eventRSyncSharp, inR);
1541 remote->deleteIncidence( inR ); 1541 remote->deleteIncidence( inR );
1542 ++deletedEventR; 1542 ++deletedEventR;
1543 } 1543 }
1544 } 1544 }
1545 } else { 1545 } else {
1546 ++filteredIN; 1546 ++filteredIN;
1547 } 1547 }
1548 } 1548 }
1549 } 1549 }
1550 inR = er.next(); 1550 inR = er.next();
1551 } 1551 }
1552 QPtrList<Incidence> el = local->rawIncidences(); 1552 QPtrList<Incidence> el = local->rawIncidences();
1553 inL = el.first(); 1553 inL = el.first();
1554 modulo = (el.count()/10)+1; 1554 modulo = (el.count()/10)+1;
1555 bar.setCaption (i18n("Add / remove events") ); 1555 bar.setCaption (i18n("Add / remove events") );
1556 bar.setTotalSteps ( el.count() ) ; 1556 bar.setTotalSteps ( el.count() ) ;
1557 bar.show(); 1557 bar.show();
1558 incCounter = 0; 1558 incCounter = 0;
1559 1559
1560 while ( inL ) { 1560 while ( inL ) {
1561 1561
1562 qApp->processEvents(); 1562 qApp->processEvents();
1563 if ( ! bar.isVisible() ) 1563 if ( ! bar.isVisible() )
1564 return false; 1564 return false;
1565 if ( incCounter % modulo == 0 ) 1565 if ( incCounter % modulo == 0 )
1566 bar.setProgress( incCounter ); 1566 bar.setProgress( incCounter );
1567 ++incCounter; 1567 ++incCounter;
1568 uid = inL->uid(); 1568 uid = inL->uid();
1569 bool skipIncidence = false; 1569 bool skipIncidence = false;
1570 if ( uid.left(15) == QString("last-syncEvent-") ) 1570 if ( uid.left(15) == QString("last-syncEvent-") )
1571 skipIncidence = true; 1571 skipIncidence = true;
1572 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1572 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1573 skipIncidence = true; 1573 skipIncidence = true;
1574 if ( !skipIncidence ) { 1574 if ( !skipIncidence ) {
1575 inR = remote->incidenceForUid( uid , true ); 1575 inR = remote->incidenceForUid( uid , true );
1576 if ( ! inR ) { 1576 if ( ! inR ) {
1577 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1577 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1578 // no conflict ********** add or delete local 1578 // no conflict ********** add or delete local
1579 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1579 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1580 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1580 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1581 checkExternSyncEvent(eventLSyncSharp, inL); 1581 checkExternSyncEvent(eventLSyncSharp, inL);
1582 local->deleteIncidence( inL ); 1582 local->deleteIncidence( inL );
1583 ++deletedEventL; 1583 ++deletedEventL;
1584 } else { 1584 } else {
1585 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1585 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1586 inL->removeID(mCurrentSyncDevice ); 1586 inL->removeID(mCurrentSyncDevice );
1587 ++addedEventR; 1587 ++addedEventR;
1588 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1588 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1589 inL->setLastModified( modifiedCalendar ); 1589 inL->setLastModified( modifiedCalendar );
1590 inR = inL->clone(); 1590 inR = inL->clone();
1591 inR->setIDStr( ":" ); 1591 inR->setIDStr( ":" );
1592 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1592 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1593 inR->setCalID( 0 );// add to default cal 1593 inR->setCalID( 0 );// add to default cal
1594 remote->addIncidence( inR ); 1594 remote->addIncidence( inR );
1595 } 1595 }
1596 } 1596 }
1597 } else { 1597 } else {
1598 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1598 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1599 checkExternSyncEvent(eventLSyncSharp, inL); 1599 checkExternSyncEvent(eventLSyncSharp, inL);
1600 local->deleteIncidence( inL ); 1600 local->deleteIncidence( inL );
1601 ++deletedEventL; 1601 ++deletedEventL;
1602 } else { 1602 } else {
1603 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1603 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1604 ++addedEventR; 1604 ++addedEventR;
1605 inL->setLastModified( modifiedCalendar ); 1605 inL->setLastModified( modifiedCalendar );
1606 inR = inL->clone(); 1606 inR = inL->clone();
1607 inR->setIDStr( ":" ); 1607 inR->setIDStr( ":" );
1608 inR->setCalID( 0 );// add to default cal 1608 inR->setCalID( 0 );// add to default cal
1609 remote->addIncidence( inR ); 1609 remote->addIncidence( inR );
1610 } 1610 }
1611 } 1611 }
1612 } 1612 }
1613 } else { 1613 } else {
1614 ++filteredOUT; 1614 ++filteredOUT;
1615 } 1615 }
1616 } 1616 }
1617 } 1617 }
1618 inL = el.next(); 1618 inL = el.next();
1619 } 1619 }
1620 int delFut = 0; 1620 int delFut = 0;
1621 int remRem = 0; 1621 int remRem = 0;
1622 if ( mSyncManager->mWriteBackInFuture ) { 1622 if ( mSyncManager->mWriteBackInFuture ) {
1623 er = remote->rawIncidences(); 1623 er = remote->rawIncidences();
1624 remRem = er.count(); 1624 remRem = er.count();
1625 inR = er.first(); 1625 inR = er.first();
1626 QDateTime dt; 1626 QDateTime dt;
1627 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1627 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1628 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1628 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1629 while ( inR ) { 1629 while ( inR ) {
1630 if ( inR->typeID() == todoID ) { 1630 if ( inR->typeID() == todoID ) {
1631 Todo * t = (Todo*)inR; 1631 Todo * t = (Todo*)inR;
1632 if ( t->hasDueDate() ) 1632 if ( t->hasDueDate() )
1633 dt = t->dtDue(); 1633 dt = t->dtDue();
1634 else 1634 else
1635 dt = cur.addSecs( 62 ); 1635 dt = cur.addSecs( 62 );
1636 } 1636 }
1637 else if (inR->typeID() == eventID ) { 1637 else if (inR->typeID() == eventID ) {
1638 bool ok; 1638 bool ok;
1639 dt = inR->getNextOccurence( cur, &ok ); 1639 dt = inR->getNextOccurence( cur, &ok );
1640 if ( !ok ) 1640 if ( !ok )
1641 dt = cur.addSecs( -62 ); 1641 dt = cur.addSecs( -62 );
1642 } 1642 }
1643 else 1643 else
1644 dt = inR->dtStart(); 1644 dt = inR->dtStart();
1645 if ( dt < cur || dt > end ) { 1645 if ( dt < cur || dt > end ) {
1646 remote->deleteIncidence( inR ); 1646 remote->deleteIncidence( inR );
1647 ++delFut; 1647 ++delFut;
1648 } 1648 }
1649 inR = er.next(); 1649 inR = er.next();
1650 } 1650 }
1651 } 1651 }
1652 bar.hide(); 1652 bar.hide();
1653 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1653 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1654 eventLSync->setReadOnly( false ); 1654 eventLSync->setReadOnly( false );
1655 eventLSync->setDtStart( mLastCalendarSync ); 1655 eventLSync->setDtStart( mLastCalendarSync );
1656 eventRSync->setDtStart( mLastCalendarSync ); 1656 eventRSync->setDtStart( mLastCalendarSync );
1657 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1657 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1658 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1658 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1659 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1659 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1660 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1660 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1661 eventLSync->setReadOnly( true ); 1661 eventLSync->setReadOnly( true );
1662 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1662 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1663 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1663 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1664 remote->addEvent( eventRSync ); 1664 remote->addEvent( eventRSync );
1665 else 1665 else
1666 delete eventRSync; 1666 delete eventRSync;
1667 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1667 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1668 QString mes; 1668 QString mes;
1669 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 ); 1669 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 );
1670 QString delmess; 1670 QString delmess;
1671 if ( delFut ) { 1671 if ( delFut ) {
1672 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); 1672 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);
1673 mes += delmess; 1673 mes += delmess;
1674 } 1674 }
1675 mes = i18n("Local calendar changed!\n") +mes; 1675 mes = i18n("Local calendar changed!\n") +mes;
1676 mCalendar->checkAlarmForIncidence( 0, true ); 1676 mCalendar->checkAlarmForIncidence( 0, true );
1677 qDebug( mes ); 1677 qDebug( mes );
1678 if ( mSyncManager->mShowSyncSummary ) { 1678 if ( mSyncManager->mShowSyncSummary ) {
1679 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1679 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1680 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1680 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1681 qDebug("KO: WB cancelled "); 1681 qDebug("KO: WB cancelled ");
1682 mSyncManager->mWriteBackFile = false; 1682 mSyncManager->mWriteBackFile = false;
1683 return syncOK; 1683 return syncOK;
1684 } 1684 }
1685 } 1685 }
1686 return syncOK; 1686 return syncOK;
1687} 1687}
1688 1688
1689void CalendarView::setSyncDevice( QString s ) 1689void CalendarView::setSyncDevice( QString s )
1690{ 1690{
1691 mCurrentSyncDevice= s; 1691 mCurrentSyncDevice= s;
1692} 1692}
1693void CalendarView::setSyncName( QString s ) 1693void CalendarView::setSyncName( QString s )
1694{ 1694{
1695 mCurrentSyncName= s; 1695 mCurrentSyncName= s;
1696} 1696}
1697bool CalendarView::syncCalendar(QString filename, int mode) 1697bool CalendarView::syncCalendar(QString filename, int mode)
1698{ 1698{
1699 //qDebug("syncCalendar %s ", filename.latin1()); 1699 //qDebug("syncCalendar %s ", filename.latin1());
1700 mGlobalSyncMode = SYNC_MODE_NORMAL; 1700 mGlobalSyncMode = SYNC_MODE_NORMAL;
1701 CalendarLocal* calendar = new CalendarLocal(); 1701 CalendarLocal* calendar = new CalendarLocal();
1702 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1702 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1703 FileStorage* storage = new FileStorage( calendar ); 1703 FileStorage* storage = new FileStorage( calendar );
1704 bool syncOK = false; 1704 bool syncOK = false;
1705 storage->setFileName( filename ); 1705 storage->setFileName( filename );
1706 // qDebug("loading ... "); 1706 // qDebug("loading ... ");
1707 if ( storage->load() ) { 1707 if ( storage->load() ) {
1708 getEventViewerDialog()->setSyncMode( true ); 1708 getEventViewerDialog()->setSyncMode( true );
1709 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1709 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1710 getEventViewerDialog()->setSyncMode( false ); 1710 getEventViewerDialog()->setSyncMode( false );
1711 if ( syncOK ) { 1711 if ( syncOK ) {
1712 if ( mSyncManager->mWriteBackFile ) 1712 if ( mSyncManager->mWriteBackFile )
1713 { 1713 {
1714 storage->setSaveFormat( new ICalFormat() ); 1714 storage->setSaveFormat( new ICalFormat() );
1715 storage->save(); 1715 storage->save();
1716 } 1716 }
1717 } 1717 }
1718 setModified( true ); 1718 setModified( true );
1719 } 1719 }
1720 delete storage; 1720 delete storage;
1721 delete calendar; 1721 delete calendar;
1722 if ( syncOK ) 1722 if ( syncOK )
1723 updateView(); 1723 updateView();
1724 return syncOK; 1724 return syncOK;
1725} 1725}
1726 1726
1727void CalendarView::syncExternal( int mode ) 1727void CalendarView::syncExternal( int mode )
1728{ 1728{
1729 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1729 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1730 1730
1731 qApp->processEvents(); 1731 qApp->processEvents();
1732 CalendarLocal* calendar = new CalendarLocal(); 1732 CalendarLocal* calendar = new CalendarLocal();
1733 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1733 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1734 bool syncOK = false; 1734 bool syncOK = false;
1735 bool loadSuccess = false; 1735 bool loadSuccess = false;
1736 PhoneFormat* phoneFormat = 0; 1736 PhoneFormat* phoneFormat = 0;
1737 emit tempDisableBR(true); 1737 emit tempDisableBR(true);
1738#ifndef DESKTOP_VERSION 1738#ifndef DESKTOP_VERSION
1739 SharpFormat* sharpFormat = 0; 1739 SharpFormat* sharpFormat = 0;
1740 if ( mode == 0 ) { // sharp 1740 if ( mode == 0 ) { // sharp
1741 sharpFormat = new SharpFormat () ; 1741 sharpFormat = new SharpFormat () ;
1742 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1742 loadSuccess = sharpFormat->load( calendar, mCalendar );
1743 1743
1744 } else 1744 } else
1745#endif 1745#endif
1746 if ( mode == 1 ) { // phone 1746 if ( mode == 1 ) { // phone
1747 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1747 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1748 mSyncManager->mPhoneDevice, 1748 mSyncManager->mPhoneDevice,
1749 mSyncManager->mPhoneConnection, 1749 mSyncManager->mPhoneConnection,
1750 mSyncManager->mPhoneModel); 1750 mSyncManager->mPhoneModel);
1751 loadSuccess = phoneFormat->load( calendar,mCalendar); 1751 loadSuccess = phoneFormat->load( calendar,mCalendar);
1752 1752
1753 } else { 1753 } else {
1754 emit tempDisableBR(false); 1754 emit tempDisableBR(false);
1755 return; 1755 return;
1756 } 1756 }
1757 if ( loadSuccess ) { 1757 if ( loadSuccess ) {
1758 getEventViewerDialog()->setSyncMode( true ); 1758 getEventViewerDialog()->setSyncMode( true );
1759 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1759 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1760 getEventViewerDialog()->setSyncMode( false ); 1760 getEventViewerDialog()->setSyncMode( false );
1761 qApp->processEvents(); 1761 qApp->processEvents();
1762 if ( syncOK ) { 1762 if ( syncOK ) {
1763 if ( mSyncManager->mWriteBackFile ) 1763 if ( mSyncManager->mWriteBackFile )
1764 { 1764 {
1765 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1765 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1766 Incidence* inc = iL.first(); 1766 Incidence* inc = iL.first();
1767 if ( phoneFormat ) { 1767 if ( phoneFormat ) {
1768 while ( inc ) { 1768 while ( inc ) {
1769 inc->removeID(mCurrentSyncDevice); 1769 inc->removeID(mCurrentSyncDevice);
1770 inc = iL.next(); 1770 inc = iL.next();
1771 } 1771 }
1772 } 1772 }
1773#ifndef DESKTOP_VERSION 1773#ifndef DESKTOP_VERSION
1774 if ( sharpFormat ) 1774 if ( sharpFormat )
1775 sharpFormat->save(calendar); 1775 sharpFormat->save(calendar);
1776#endif 1776#endif
1777 if ( phoneFormat ) 1777 if ( phoneFormat )
1778 phoneFormat->save(calendar); 1778 phoneFormat->save(calendar);
1779 iL = calendar->rawIncidences(); 1779 iL = calendar->rawIncidences();
1780 inc = iL.first(); 1780 inc = iL.first();
1781 Incidence* loc; 1781 Incidence* loc;
1782 while ( inc ) { 1782 while ( inc ) {
1783 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1783 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1784 loc = mCalendar->incidence(inc->uid() ); 1784 loc = mCalendar->incidence(inc->uid() );
1785 if ( loc ) { 1785 if ( loc ) {
1786 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1786 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1787 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1787 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1788 } 1788 }
1789 } 1789 }
1790 inc = iL.next(); 1790 inc = iL.next();
1791 } 1791 }
1792 Incidence* lse = getLastSyncEvent(); 1792 Incidence* lse = getLastSyncEvent();
1793 if ( lse ) { 1793 if ( lse ) {
1794 lse->setReadOnly( false ); 1794 lse->setReadOnly( false );
1795 lse->setDescription( "" ); 1795 lse->setDescription( "" );
1796 lse->setReadOnly( true ); 1796 lse->setReadOnly( true );
1797 } 1797 }
1798 } 1798 }
1799 } else { 1799 } else {
1800 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1800 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1801 } 1801 }
1802 setModified( true ); 1802 setModified( true );
1803 } else { 1803 } else {
1804 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1804 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1805 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1805 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1806 question, i18n("Ok")) ; 1806 question, i18n("Ok")) ;
1807 1807
1808 } 1808 }
1809 delete calendar; 1809 delete calendar;
1810 updateView(); 1810 updateView();
1811 emit tempDisableBR(false); 1811 emit tempDisableBR(false);
1812 return ;//syncOK; 1812 return ;//syncOK;
1813 1813
1814} 1814}
1815 1815
1816bool CalendarView::importBday() 1816bool CalendarView::importBday()
1817{ 1817{
1818#ifndef KORG_NOKABC 1818#ifndef KORG_NOKABC
1819 1819
1820#ifdef DESKTOP_VERSION 1820#ifdef DESKTOP_VERSION
1821 int curCal = mCalendar->defaultCalendar(); 1821 int curCal = mCalendar->defaultCalendar();
1822 int bd = mCalEditView->getBirtdayID(); 1822 int bd = mCalEditView->getBirtdayID();
1823 if ( bd == 0 ) 1823 if ( bd == 0 )
1824 return false; 1824 return false;
1825 mCalendar->setDefaultCalendar( bd ); 1825 mCalendar->setDefaultCalendar( bd );
1826 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1826 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1827 KABC::AddressBook::Iterator it; 1827 KABC::AddressBook::Iterator it;
1828 int count = 0; 1828 int count = 0;
1829 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1829 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1830 ++count; 1830 ++count;
1831 } 1831 }
1832 QProgressBar bar(count,0 ); 1832 QProgressBar bar(count,0 );
1833 int w = 300; 1833 int w = 300;
1834 if ( QApplication::desktop()->width() < 320 ) 1834 if ( QApplication::desktop()->width() < 320 )
1835 w = 220; 1835 w = 220;
1836 int h = bar.sizeHint().height() ; 1836 int h = bar.sizeHint().height() ;
1837 int dw = QApplication::desktop()->width(); 1837 int dw = QApplication::desktop()->width();
1838 int dh = QApplication::desktop()->height(); 1838 int dh = QApplication::desktop()->height();
1839 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1839 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1840 bar.show(); 1840 bar.show();
1841 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1841 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1842 qApp->processEvents(); 1842 qApp->processEvents();
1843 count = 0; 1843 count = 0;
1844 int addCount = 0; 1844 int addCount = 0;
1845 KCal::Attendee* a = 0; 1845 KCal::Attendee* a = 0;
1846 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1846 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1847 if ( ! bar.isVisible() ) 1847 if ( ! bar.isVisible() )
1848 return false; 1848 return false;
1849 bar.setProgress( count++ ); 1849 bar.setProgress( count++ );
1850 qApp->processEvents(); 1850 qApp->processEvents();
1851 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1851 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1852 if ( (*it).birthday().date().isValid() ){ 1852 if ( (*it).birthday().date().isValid() ){
1853 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1853 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1854 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1854 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1855 ++addCount; 1855 ++addCount;
1856 } 1856 }
1857 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1857 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1858 if ( anni.isValid() ){ 1858 if ( anni.isValid() ){
1859 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1859 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1860 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1860 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1861 ++addCount; 1861 ++addCount;
1862 } 1862 }
1863 } 1863 }
1864 mCalendar->setDefaultCalendar( curCal ); 1864 mCalendar->setDefaultCalendar( curCal );
1865 updateView(); 1865 updateView();
1866 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1866 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1867#else //DESKTOP_VERSION 1867#else //DESKTOP_VERSION
1868 1868
1869 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1869 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1870 // the result should now arrive through method insertBirthdays 1870 // the result should now arrive through method insertBirthdays
1871 1871
1872#endif //DESKTOP_VERSION 1872#endif //DESKTOP_VERSION
1873 1873
1874#endif //KORG_NOKABC 1874#endif //KORG_NOKABC
1875 1875
1876 1876
1877 return true; 1877 return true;
1878} 1878}
1879 1879
1880// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1880// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1881void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1881void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1882 const QStringList& anniversaryList, const QStringList& realNameList, 1882 const QStringList& anniversaryList, const QStringList& realNameList,
1883 const QStringList& emailList, const QStringList& assembledNameList, 1883 const QStringList& emailList, const QStringList& assembledNameList,
1884 const QStringList& uidList) 1884 const QStringList& uidList)
1885{ 1885{
1886 1886
1887 //qDebug("KO::CalendarView::insertBirthdays"); 1887 //qDebug("KO::CalendarView::insertBirthdays");
1888 if (uid == this->name()) 1888 if (uid == this->name())
1889 { 1889 {
1890 int curCal = mCalendar->defaultCalendar(); 1890 int curCal = mCalendar->defaultCalendar();
1891 int bd = mCalEditView->getBirtdayID(); 1891 int bd = mCalEditView->getBirtdayID();
1892 if ( bd == 0 ) 1892 if ( bd == 0 )
1893 return; 1893 return;
1894 mCalendar->setDefaultCalendar( bd ); 1894 mCalendar->setDefaultCalendar( bd );
1895 1895
1896 1896
1897 int count = birthdayList.count(); 1897 int count = birthdayList.count();
1898 int addCount = 0; 1898 int addCount = 0;
1899 KCal::Attendee* a = 0; 1899 KCal::Attendee* a = 0;
1900 1900
1901 //qDebug("CalView 1 %i", count); 1901 //qDebug("CalView 1 %i", count);
1902 1902
1903 QProgressBar bar(count,0 ); 1903 QProgressBar bar(count,0 );
1904 int w = 300; 1904 int w = 300;
1905 if ( QApplication::desktop()->width() < 320 ) 1905 if ( QApplication::desktop()->width() < 320 )
1906 w = 220; 1906 w = 220;
1907 int h = bar.sizeHint().height() ; 1907 int h = bar.sizeHint().height() ;
1908 int dw = QApplication::desktop()->width(); 1908 int dw = QApplication::desktop()->width();
1909 int dh = QApplication::desktop()->height(); 1909 int dh = QApplication::desktop()->height();
1910 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1910 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1911 bar.show(); 1911 bar.show();
1912 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1912 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1913 qApp->processEvents(); 1913 qApp->processEvents();
1914 1914
1915 QDate birthday; 1915 QDate birthday;
1916 QDate anniversary; 1916 QDate anniversary;
1917 QString realName; 1917 QString realName;
1918 QString email; 1918 QString email;
1919 QString assembledName; 1919 QString assembledName;
1920 QString uid; 1920 QString uid;
1921 bool ok = true; 1921 bool ok = true;
1922 for ( int i = 0; i < count; i++) 1922 for ( int i = 0; i < count; i++)
1923 { 1923 {
1924 if ( ! bar.isVisible() ) 1924 if ( ! bar.isVisible() )
1925 return; 1925 return;
1926 bar.setProgress( i ); 1926 bar.setProgress( i );
1927 qApp->processEvents(); 1927 qApp->processEvents();
1928 1928
1929 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1929 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1930 if (!ok) { 1930 if (!ok) {
1931 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1931 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1932 } 1932 }
1933 1933
1934 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1934 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1935 if (!ok) { 1935 if (!ok) {
1936 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1936 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1937 } 1937 }
1938 realName = realNameList[i]; 1938 realName = realNameList[i];
1939 email = emailList[i]; 1939 email = emailList[i];
1940 assembledName = assembledNameList[i]; 1940 assembledName = assembledNameList[i];
1941 uid = uidList[i]; 1941 uid = uidList[i];
1942 //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() ); 1942 //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() );
1943 1943
1944 if ( birthday.isValid() ){ 1944 if ( birthday.isValid() ){
1945 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1945 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1946 KCal::Attendee::ReqParticipant,uid) ; 1946 KCal::Attendee::ReqParticipant,uid) ;
1947 if ( addAnniversary( birthday, assembledName, a, true ) ) 1947 if ( addAnniversary( birthday, assembledName, a, true ) )
1948 ++addCount; 1948 ++addCount;
1949 } 1949 }
1950 1950
1951 if ( anniversary.isValid() ){ 1951 if ( anniversary.isValid() ){
1952 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1952 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1953 KCal::Attendee::ReqParticipant,uid) ; 1953 KCal::Attendee::ReqParticipant,uid) ;
1954 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1954 if ( addAnniversary( anniversary, assembledName, a, false ) )
1955 ++addCount; 1955 ++addCount;
1956 } 1956 }
1957 } 1957 }
1958 1958
1959 mCalendar->setDefaultCalendar( curCal ); 1959 mCalendar->setDefaultCalendar( curCal );
1960 updateView(); 1960 updateView();
1961 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1961 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1962 1962
1963 } 1963 }
1964 1964
1965} 1965}
1966 1966
1967 1967
1968 1968
1969bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1969bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1970{ 1970{
1971 //qDebug("addAnni "); 1971 //qDebug("addAnni ");
1972 Event * ev = new Event(); 1972 Event * ev = new Event();
1973 ev->setOrganizer(KOPrefs::instance()->email()); 1973 ev->setOrganizer(KOPrefs::instance()->email());
1974 if ( a ) { 1974 if ( a ) {
1975 ev->addAttendee( a ); 1975 ev->addAttendee( a );
1976 } 1976 }
1977 QString kind; 1977 QString kind;
1978 if ( birthday ) { 1978 if ( birthday ) {
1979 kind = i18n( "Birthday" ); 1979 kind = i18n( "Birthday" );
1980 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1980 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1981 } 1981 }
1982 else { 1982 else {
1983 kind = i18n( "Anniversary" ); 1983 kind = i18n( "Anniversary" );
1984 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1984 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1985 } 1985 }
1986 ev->setCategories( kind ); 1986 ev->setCategories( kind );
1987 ev->setDtStart( QDateTime(date) ); 1987 ev->setDtStart( QDateTime(date) );
1988 ev->setDtEnd( QDateTime(date) ); 1988 ev->setDtEnd( QDateTime(date) );
1989 ev->setFloats( true ); 1989 ev->setFloats( true );
1990 Recurrence * rec = ev->recurrence(); 1990 Recurrence * rec = ev->recurrence();
1991 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1991 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1992 rec->addYearlyNum( date.month() ); 1992 rec->addYearlyNum( date.month() );
1993 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1993 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1994 delete ev; 1994 delete ev;
1995 return false; 1995 return false;
1996 } 1996 }
1997 return true; 1997 return true;
1998 1998
1999} 1999}
2000bool CalendarView::importQtopia( const QString &categories, 2000bool CalendarView::importQtopia( const QString &categories,
2001 const QString &datebook, 2001 const QString &datebook,
2002 const QString &todolist ) 2002 const QString &todolist )
2003{ 2003{
2004 2004
2005 QtopiaFormat qtopiaFormat; 2005 QtopiaFormat qtopiaFormat;
2006 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2006 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2007 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2007 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2008 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2008 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2009 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2009 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2010 2010
2011 updateView(); 2011 updateView();
2012 return true; 2012 return true;
2013 2013
2014#if 0 2014#if 0
2015 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2015 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2016 mCurrentSyncDevice = "qtopia-XML"; 2016 mCurrentSyncDevice = "qtopia-XML";
2017 if ( mSyncManager->mAskForPreferences ) 2017 if ( mSyncManager->mAskForPreferences )
2018 edit_sync_options(); 2018 edit_sync_options();
2019 qApp->processEvents(); 2019 qApp->processEvents();
2020 CalendarLocal* calendar = new CalendarLocal(); 2020 CalendarLocal* calendar = new CalendarLocal();
2021 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2021 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2022 bool syncOK = false; 2022 bool syncOK = false;
2023 QtopiaFormat qtopiaFormat; 2023 QtopiaFormat qtopiaFormat;
2024 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2024 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2025 bool loadOk = true; 2025 bool loadOk = true;
2026 if ( !categories.isEmpty() ) 2026 if ( !categories.isEmpty() )
2027 loadOk = qtopiaFormat.load( calendar, categories ); 2027 loadOk = qtopiaFormat.load( calendar, categories );
2028 if ( loadOk && !datebook.isEmpty() ) 2028 if ( loadOk && !datebook.isEmpty() )
2029 loadOk = qtopiaFormat.load( calendar, datebook ); 2029 loadOk = qtopiaFormat.load( calendar, datebook );
2030 if ( loadOk && !todolist.isEmpty() ) 2030 if ( loadOk && !todolist.isEmpty() )
2031 loadOk = qtopiaFormat.load( calendar, todolist ); 2031 loadOk = qtopiaFormat.load( calendar, todolist );
2032 2032
2033 if ( loadOk ) { 2033 if ( loadOk ) {
2034 getEventViewerDialog()->setSyncMode( true ); 2034 getEventViewerDialog()->setSyncMode( true );
2035 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2035 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2036 getEventViewerDialog()->setSyncMode( false ); 2036 getEventViewerDialog()->setSyncMode( false );
2037 qApp->processEvents(); 2037 qApp->processEvents();
2038 if ( syncOK ) { 2038 if ( syncOK ) {
2039 if ( mSyncManager->mWriteBackFile ) 2039 if ( mSyncManager->mWriteBackFile )
2040 { 2040 {
2041 // write back XML file 2041 // write back XML file
2042 2042
2043 } 2043 }
2044 setModified( true ); 2044 setModified( true );
2045 } 2045 }
2046 } else { 2046 } else {
2047 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2047 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2048 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2048 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2049 question, i18n("Ok")) ; 2049 question, i18n("Ok")) ;
2050 } 2050 }
2051 delete calendar; 2051 delete calendar;
2052 updateView(); 2052 updateView();
2053 return syncOK; 2053 return syncOK;
2054 2054
2055 2055
2056#endif 2056#endif
2057 2057
2058} 2058}
2059 2059
2060void CalendarView::setSyncEventsReadOnly() 2060void CalendarView::setSyncEventsReadOnly()
2061{ 2061{
2062 mCalendar->setSyncEventsReadOnly(); 2062 mCalendar->setSyncEventsReadOnly();
2063} 2063}
2064 2064
2065bool CalendarView::loadCalendars() 2065bool CalendarView::loadCalendars()
2066{ 2066{
2067 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2067 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2068 KopiCalendarFile * cal = calendars.first(); 2068 KopiCalendarFile * cal = calendars.first();
2069 mCalendar->setDefaultCalendar( 1 ); 2069 mCalendar->setDefaultCalendar( 1 );
2070 openCalendar( MainWindow::defaultFileName(), false ); 2070 openCalendar( MainWindow::defaultFileName(), false );
2071 cal = calendars.next(); 2071 cal = calendars.next();
2072 while ( cal ) { 2072 while ( cal ) {
2073 addCalendar( cal ); 2073 addCalendar( cal );
2074 cal = calendars.next(); 2074 cal = calendars.next();
2075 } 2075 }
2076 restoreCalendarSettings(); 2076 restoreCalendarSettings();
2077 return true; 2077 return true;
2078} 2078}
2079bool CalendarView::restoreCalendarSettings() 2079bool CalendarView::restoreCalendarSettings()
2080{ 2080{
2081 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2081 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2082 KopiCalendarFile * cal = calendars.first(); 2082 KopiCalendarFile * cal = calendars.first();
2083 while ( cal ) { 2083 while ( cal ) {
2084 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2084 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2085 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2085 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2086 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2086 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2087 if ( cal->isStandard ) 2087 if ( cal->isStandard )
2088 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2088 mCalendar->setDefaultCalendar( cal->mCalNumber );
2089 cal = calendars.next(); 2089 cal = calendars.next();
2090 } 2090 }
2091 setSyncEventsReadOnly(); 2091 setSyncEventsReadOnly();
2092 mCalendar->reInitAlarmSettings(); 2092 mCalendar->reInitAlarmSettings();
2093 updateUnmanagedViews(); 2093 updateUnmanagedViews();
2094 updateView(); 2094 updateView();
2095 return true; 2095 return true;
2096} 2096}
2097void CalendarView::addCalendarId( int id ) 2097void CalendarView::addCalendarId( int id )
2098{ 2098{
2099 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2099 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2100 if ( cal ) 2100 if ( cal )
2101 addCalendar( cal ); 2101 addCalendar( cal );
2102} 2102}
2103bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2103bool CalendarView::addCalendar( KopiCalendarFile * cal )
2104{ 2104{
2105 cal->mErrorOnLoad = false; 2105 cal->mErrorOnLoad = false;
2106 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2106 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2107 cal->mLoadDt = QDateTime::currentDateTime(); 2107 cal->mLoadDt = QDateTime::currentDateTime();
2108 return true; 2108 return true;
2109 } 2109 }
2110 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2110 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2111 cal->mErrorOnLoad = true; 2111 cal->mErrorOnLoad = true;
2112 return false; 2112 return false;
2113} 2113}
2114bool CalendarView::openCalendar(QString filename, bool merge) 2114bool CalendarView::openCalendar(QString filename, bool merge)
2115{ 2115{
2116 2116
2117 if (filename.isEmpty()) { 2117 if (filename.isEmpty()) {
2118 return false; 2118 return false;
2119 } 2119 }
2120 2120
2121 if (!QFile::exists(filename)) { 2121 if (!QFile::exists(filename)) {
2122 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2122 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2123 return false; 2123 return false;
2124 } 2124 }
2125 2125
2126 globalFlagBlockAgenda = 1; 2126 globalFlagBlockAgenda = 1;
2127 clearAllViews(); 2127 clearAllViews();
2128 if (!merge) { 2128 if (!merge) {
2129 mViewManager->setDocumentId( filename ); 2129 mViewManager->setDocumentId( filename );
2130 mCalendar->close(); 2130 mCalendar->close();
2131 } 2131 }
2132 mStorage->setFileName( filename ); 2132 mStorage->setFileName( filename );
2133 2133
2134 if ( mStorage->load() ) { 2134 if ( mStorage->load() ) {
2135 if ( merge ) ;//setModified( true ); 2135 if ( merge ) ;//setModified( true );
2136 else { 2136 else {
2137 //setModified( true ); 2137 //setModified( true );
2138 mViewManager->setDocumentId( filename ); 2138 mViewManager->setDocumentId( filename );
2139 mDialogManager->setDocumentId( filename ); 2139 mDialogManager->setDocumentId( filename );
2140 mTodoList->setDocumentId( filename ); 2140 mTodoList->setDocumentId( filename );
2141 } 2141 }
2142 globalFlagBlockAgenda = 2; 2142 globalFlagBlockAgenda = 2;
2143 // if ( getLastSyncEvent() ) 2143 // if ( getLastSyncEvent() )
2144 // getLastSyncEvent()->setReadOnly( true ); 2144 // getLastSyncEvent()->setReadOnly( true );
2145 mCalendar->reInitAlarmSettings(); 2145 mCalendar->reInitAlarmSettings();
2146 setSyncEventsReadOnly(); 2146 setSyncEventsReadOnly();
2147 updateUnmanagedViews(); 2147 updateUnmanagedViews();
2148 updateView(); 2148 updateView();
2149 if ( filename != MainWindow::defaultFileName() ) { 2149 if ( filename != MainWindow::defaultFileName() ) {
2150 saveCalendar( MainWindow::defaultFileName() ); 2150 saveCalendar( MainWindow::defaultFileName() );
2151 } else { 2151 } else {
2152 QFileInfo finf ( MainWindow::defaultFileName()); 2152 QFileInfo finf ( MainWindow::defaultFileName());
2153 if ( finf.exists() ) { 2153 if ( finf.exists() ) {
2154 setLoadedFileVersion( finf.lastModified () ); 2154 setLoadedFileVersion( finf.lastModified () );
2155 } 2155 }
2156 } 2156 }
2157 return true; 2157 return true;
2158 } else { 2158 } else {
2159 // while failing to load, the calendar object could 2159 // while failing to load, the calendar object could
2160 // have become partially populated. Clear it out. 2160 // have become partially populated. Clear it out.
2161 if ( !merge ) { 2161 if ( !merge ) {
2162 mCalendar->close(); 2162 mCalendar->close();
2163 mViewManager->setDocumentId( filename ); 2163 mViewManager->setDocumentId( filename );
2164 mDialogManager->setDocumentId( filename ); 2164 mDialogManager->setDocumentId( filename );
2165 mTodoList->setDocumentId( filename ); 2165 mTodoList->setDocumentId( filename );
2166 } 2166 }
2167 2167
2168 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2168 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2169 2169
2170 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2170 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2171 globalFlagBlockAgenda = 2; 2171 globalFlagBlockAgenda = 2;
2172 mCalendar->reInitAlarmSettings(); 2172 mCalendar->reInitAlarmSettings();
2173 setSyncEventsReadOnly(); 2173 setSyncEventsReadOnly();
2174 updateUnmanagedViews(); 2174 updateUnmanagedViews();
2175 updateView(); 2175 updateView();
2176 } 2176 }
2177 return false; 2177 return false;
2178} 2178}
2179void CalendarView::mergeFile( QString fn ) 2179void CalendarView::mergeFile( QString fn )
2180{ 2180{
2181 clearAllViews(); 2181 clearAllViews();
2182 mCalendar->mergeCalendarFile( fn ); 2182 mCalendar->mergeCalendarFile( fn );
2183 mCalendar->reInitAlarmSettings(); 2183 mCalendar->reInitAlarmSettings();
2184 setSyncEventsReadOnly(); 2184 setSyncEventsReadOnly();
2185 updateUnmanagedViews(); 2185 updateUnmanagedViews();
2186 updateView(); 2186 updateView();
2187} 2187}
2188void CalendarView::showOpenError() 2188void CalendarView::showOpenError()
2189{ 2189{
2190 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2190 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2191} 2191}
2192void CalendarView::setLoadedFileVersion(QDateTime dt) 2192void CalendarView::setLoadedFileVersion(QDateTime dt)
2193{ 2193{
2194 loadedFileVersion = dt; 2194 loadedFileVersion = dt;
2195} 2195}
2196bool CalendarView::checkFileChanged(QString fn) 2196bool CalendarView::checkFileChanged(QString fn)
2197{ 2197{
2198 QFileInfo finf ( fn ); 2198 QFileInfo finf ( fn );
2199 if ( !finf.exists() ) 2199 if ( !finf.exists() )
2200 return true; 2200 return true;
2201 QDateTime dt = finf.lastModified (); 2201 QDateTime dt = finf.lastModified ();
2202 if ( dt <= loadedFileVersion ) 2202 if ( dt <= loadedFileVersion )
2203 return false; 2203 return false;
2204 return true; 2204 return true;
2205 2205
2206} 2206}
2207void CalendarView::watchSavedFile() 2207void CalendarView::watchSavedFile()
2208{ 2208{
2209 QFileInfo finf ( MainWindow::defaultFileName()); 2209 QFileInfo finf ( MainWindow::defaultFileName());
2210 if ( !finf.exists() ) 2210 if ( !finf.exists() )
2211 return; 2211 return;
2212 QDateTime dt = finf.lastModified (); 2212 QDateTime dt = finf.lastModified ();
2213 if ( dt < loadedFileVersion ) { 2213 if ( dt < loadedFileVersion ) {
2214 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2214 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2215 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2215 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2216 return; 2216 return;
2217 } 2217 }
2218 loadedFileVersion = dt; 2218 loadedFileVersion = dt;
2219} 2219}
2220bool CalendarView::checkAllFileVersions() 2220bool CalendarView::checkAllFileVersions()
2221{ 2221{
2222 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2222 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2223 KopiCalendarFile * cal = calendars.first(); 2223 KopiCalendarFile * cal = calendars.first();
2224 mCalendar->setDefaultCalendar( 1 ); 2224 mCalendar->setDefaultCalendar( 1 );
2225 mCalendar->setDefaultCalendarEnabledOnly(); 2225 mCalendar->setDefaultCalendarEnabledOnly();
2226 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2226 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2227 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2227 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2228 restoreCalendarSettings(); 2228 restoreCalendarSettings();
2229 return false; 2229 return false;
2230 } 2230 }
2231 } 2231 }
2232 cal = calendars.next(); 2232 cal = calendars.next();
2233 QDateTime storeTemp = loadedFileVersion; 2233 QDateTime storeTemp = loadedFileVersion;
2234 while ( cal ) { 2234 while ( cal ) {
2235 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2235 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2236 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2236 mCalendar->setDefaultCalendar( cal->mCalNumber );
2237 mCalendar->setDefaultCalendarEnabledOnly(); 2237 mCalendar->setDefaultCalendarEnabledOnly();
2238 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2238 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2239 if ( !checkFileVersion(cal->mFileName )) { 2239 if ( !checkFileVersion(cal->mFileName )) {
2240 loadedFileVersion = storeTemp; 2240 loadedFileVersion = storeTemp;
2241 restoreCalendarSettings(); 2241 restoreCalendarSettings();
2242 return false; 2242 return false;
2243 } 2243 }
2244 } 2244 }
2245 cal = calendars.next(); 2245 cal = calendars.next();
2246 } 2246 }
2247 loadedFileVersion = storeTemp; 2247 loadedFileVersion = storeTemp;
2248 return true; 2248 return true;
2249} 2249}
2250bool CalendarView::checkFileVersion(QString fn) 2250bool CalendarView::checkFileVersion(QString fn)
2251{ 2251{
2252 QFileInfo finf ( fn ); 2252 QFileInfo finf ( fn );
2253 if ( !finf.exists() ) 2253 if ( !finf.exists() )
2254 return true; 2254 return true;
2255 QDateTime dt = finf.lastModified (); 2255 QDateTime dt = finf.lastModified ();
2256 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2256 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2257 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2257 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2258 if ( dt <= loadedFileVersion ) 2258 if ( dt <= loadedFileVersion )
2259 return true; 2259 return true;
2260 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2260 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2261 i18n("KO/Pi Warning"),i18n("Overwrite"), 2261 i18n("KO/Pi Warning"),i18n("Overwrite"),
2262 i18n("Sync+save")); 2262 i18n("Sync+save"));
2263 2263
2264 if ( km == KMessageBox::Cancel ) 2264 if ( km == KMessageBox::Cancel )
2265 return false; 2265 return false;
2266 if ( km == KMessageBox::Yes ) 2266 if ( km == KMessageBox::Yes )
2267 return true; 2267 return true;
2268 2268
2269 setSyncDevice("deleteaftersync" ); 2269 setSyncDevice("deleteaftersync" );
2270 mSyncManager->mAskForPreferences = true; 2270 mSyncManager->mAskForPreferences = true;
2271 mSyncManager->mSyncAlgoPrefs = 3; 2271 mSyncManager->mSyncAlgoPrefs = 3;
2272 mSyncManager->mWriteBackFile = false; 2272 mSyncManager->mWriteBackFile = false;
2273 mSyncManager->mWriteBackExistingOnly = false; 2273 mSyncManager->mWriteBackExistingOnly = false;
2274 mSyncManager->mShowSyncSummary = false; 2274 mSyncManager->mShowSyncSummary = false;
2275 syncCalendar( fn, 3 ); 2275 syncCalendar( fn, 3 );
2276 Event * e = getLastSyncEvent(); 2276 Event * e = getLastSyncEvent();
2277 if ( e ) 2277 if ( e )
2278 mCalendar->deleteEvent( e ); 2278 mCalendar->deleteEvent( e );
2279 return true; 2279 return true;
2280} 2280}
2281bool CalendarView::saveCalendars() 2281bool CalendarView::saveCalendars()
2282{ 2282{
2283 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2283 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2284 KopiCalendarFile * cal = calendars.first(); 2284 KopiCalendarFile * cal = calendars.first();
2285 mCalendar->setDefaultCalendar( 1 ); 2285 mCalendar->setDefaultCalendar( 1 );
2286 mCalendar->setDefaultCalendarEnabledOnly(); 2286 mCalendar->setDefaultCalendarEnabledOnly();
2287 saveCalendar( MainWindow::defaultFileName() ); 2287 saveCalendar( MainWindow::defaultFileName() );
2288 cal = calendars.next(); 2288 cal = calendars.next();
2289 while ( cal ) { 2289 while ( cal ) {
2290 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2290 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2291 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2291 mCalendar->setDefaultCalendar( cal->mCalNumber );
2292 mCalendar->setDefaultCalendarEnabledOnly(); 2292 mCalendar->setDefaultCalendarEnabledOnly();
2293 if ( saveCalendar( cal->mFileName ) ) 2293 if ( saveCalendar( cal->mFileName ) )
2294 cal->mLoadDt = QDateTime::currentDateTime(); 2294 cal->mLoadDt = QDateTime::currentDateTime();
2295 } 2295 }
2296 cal = calendars.next(); 2296 cal = calendars.next();
2297 } 2297 }
2298 restoreCalendarSettings(); 2298 restoreCalendarSettings();
2299 return true; 2299 return true;
2300} 2300}
2301bool CalendarView::saveCalendar( QString filename ) 2301bool CalendarView::saveCalendar( QString filename )
2302{ 2302{
2303 2303
2304 // Store back all unsaved data into calendar object 2304 // Store back all unsaved data into calendar object
2305 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2305 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2306 if ( mViewManager->currentView() ) 2306 if ( mViewManager->currentView() )
2307 mViewManager->currentView()->flushView(); 2307 mViewManager->currentView()->flushView();
2308 2308
2309 2309
2310 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2310 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2311 mStorage->setSaveFormat( new ICalFormat() ); 2311 mStorage->setSaveFormat( new ICalFormat() );
2312 mStorage->setFileName( filename ); 2312 mStorage->setFileName( filename );
2313 bool success; 2313 bool success;
2314 success = mStorage->save(); 2314 success = mStorage->save();
2315 if ( !success ) { 2315 if ( !success ) {
2316 return false; 2316 return false;
2317 } 2317 }
2318 if ( filename == MainWindow::defaultFileName() ) { 2318 if ( filename == MainWindow::defaultFileName() ) {
2319 setLoadedFileVersion( lfv ); 2319 setLoadedFileVersion( lfv );
2320 watchSavedFile(); 2320 watchSavedFile();
2321 } 2321 }
2322 return true; 2322 return true;
2323} 2323}
2324 2324
2325void CalendarView::closeCalendar() 2325void CalendarView::closeCalendar()
2326{ 2326{
2327 2327
2328 // child windows no longer valid 2328 // child windows no longer valid
2329 clearAllViews(); 2329 clearAllViews();
2330 emit closingDown(); 2330 emit closingDown();
2331 2331
2332 mCalendar->close(); 2332 mCalendar->close();
2333 setModified(false); 2333 setModified(false);
2334 updateView(); 2334 updateView();
2335} 2335}
2336 2336
2337void CalendarView::archiveCalendar() 2337void CalendarView::archiveCalendar()
2338{ 2338{
2339 mDialogManager->showArchiveDialog(); 2339 mDialogManager->showArchiveDialog();
2340} 2340}
2341 2341
2342 2342
2343void CalendarView::readSettings() 2343void CalendarView::readSettings()
2344{ 2344{
2345 2345
2346 2346
2347 // mViewManager->showAgendaView(); 2347 // mViewManager->showAgendaView();
2348 QString str; 2348 QString str;
2349 //qDebug("CalendarView::readSettings() "); 2349 //qDebug("CalendarView::readSettings() ");
2350 // read settings from the KConfig, supplying reasonable 2350 // read settings from the KConfig, supplying reasonable
2351 // defaults where none are to be found 2351 // defaults where none are to be found
2352 KConfig *config = KOGlobals::config(); 2352 KConfig *config = KOGlobals::config();
2353#ifndef KORG_NOSPLITTER 2353#ifndef KORG_NOSPLITTER
2354 config->setGroup("KOrganizer Geometry"); 2354 config->setGroup("KOrganizer Geometry");
2355 2355
2356 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2356 QValueList<int> sizes = config->readIntListEntry("Separator1");
2357 if (sizes.count() != 2) { 2357 if (sizes.count() != 2) {
2358 sizes << mDateNavigator->minimumSizeHint().width(); 2358 sizes << mDateNavigator->minimumSizeHint().width();
2359 sizes << 300; 2359 sizes << 300;
2360 } 2360 }
2361 mPanner->setSizes(sizes); 2361 mPanner->setSizes(sizes);
2362 2362
2363 sizes = config->readIntListEntry("Separator2"); 2363 sizes = config->readIntListEntry("Separator2");
2364 if ( ( mResourceView && sizes.count() == 4 ) || 2364 if ( ( mResourceView && sizes.count() == 4 ) ||
2365 ( !mResourceView && sizes.count() == 3 ) ) { 2365 ( !mResourceView && sizes.count() == 3 ) ) {
2366 mLeftSplitter->setSizes(sizes); 2366 mLeftSplitter->setSizes(sizes);
2367 } 2367 }
2368#endif 2368#endif
2369 globalFlagBlockAgenda = 1; 2369 globalFlagBlockAgenda = 1;
2370 mViewManager->showAgendaView(); 2370 mViewManager->showAgendaView();
2371 //mViewManager->readSettings( config ); 2371 //mViewManager->readSettings( config );
2372 mTodoList->restoreLayout(config,QString("Todo Layout")); 2372 mTodoList->restoreLayout(config,QString("Todo Layout"));
2373 readFilterSettings(config); 2373 readFilterSettings(config);
2374 2374
2375#ifdef DESKTOP_VERSION 2375#ifdef DESKTOP_VERSION
2376 config->setGroup("WidgetLayout"); 2376 config->setGroup("WidgetLayout");
2377 QStringList list; 2377 QStringList list;
2378 list = config->readListEntry("MainLayout"); 2378 list = config->readListEntry("MainLayout");
2379 int x,y,w,h; 2379 int x,y,w,h;
2380 if ( ! list.isEmpty() ) { 2380 if ( ! list.isEmpty() ) {
2381 x = list[0].toInt(); 2381 x = list[0].toInt();
2382 y = list[1].toInt(); 2382 y = list[1].toInt();
2383 w = list[2].toInt(); 2383 w = list[2].toInt();
2384 h = list[3].toInt(); 2384 h = list[3].toInt();
2385 KApplication::testCoords( &x,&y,&w,&h ); 2385 KApplication::testCoords( &x,&y,&w,&h );
2386 topLevelWidget()->setGeometry(x,y,w,h); 2386 topLevelWidget()->setGeometry(x,y,w,h);
2387 2387
2388 } else { 2388 } else {
2389 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2389 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2390 } 2390 }
2391 list = config->readListEntry("EditEventLayout"); 2391 list = config->readListEntry("EditEventLayout");
2392 if ( ! list.isEmpty() ) { 2392 if ( ! list.isEmpty() ) {
2393 x = list[0].toInt(); 2393 x = list[0].toInt();
2394 y = list[1].toInt(); 2394 y = list[1].toInt();
2395 w = list[2].toInt(); 2395 w = list[2].toInt();
2396 h = list[3].toInt(); 2396 h = list[3].toInt();
2397 KApplication::testCoords( &x,&y,&w,&h ); 2397 KApplication::testCoords( &x,&y,&w,&h );
2398 mEventEditor->setGeometry(x,y,w,h); 2398 mEventEditor->setGeometry(x,y,w,h);
2399 2399
2400 } 2400 }
2401 list = config->readListEntry("EditTodoLayout"); 2401 list = config->readListEntry("EditTodoLayout");
2402 if ( ! list.isEmpty() ) { 2402 if ( ! list.isEmpty() ) {
2403 x = list[0].toInt(); 2403 x = list[0].toInt();
2404 y = list[1].toInt(); 2404 y = list[1].toInt();
2405 w = list[2].toInt(); 2405 w = list[2].toInt();
2406 h = list[3].toInt(); 2406 h = list[3].toInt();
2407 KApplication::testCoords( &x,&y,&w,&h ); 2407 KApplication::testCoords( &x,&y,&w,&h );
2408 mTodoEditor->setGeometry(x,y,w,h); 2408 mTodoEditor->setGeometry(x,y,w,h);
2409 2409
2410 } 2410 }
2411 list = config->readListEntry("ViewerLayout"); 2411 list = config->readListEntry("ViewerLayout");
2412 if ( ! list.isEmpty() ) { 2412 if ( ! list.isEmpty() ) {
2413 x = list[0].toInt(); 2413 x = list[0].toInt();
2414 y = list[1].toInt(); 2414 y = list[1].toInt();
2415 w = list[2].toInt(); 2415 w = list[2].toInt();
2416 h = list[3].toInt(); 2416 h = list[3].toInt();
2417 KApplication::testCoords( &x,&y,&w,&h ); 2417 KApplication::testCoords( &x,&y,&w,&h );
2418 getEventViewerDialog()->setGeometry(x,y,w,h); 2418 getEventViewerDialog()->setGeometry(x,y,w,h);
2419 } 2419 }
2420#endif 2420#endif
2421 config->setGroup( "Views" ); 2421 config->setGroup( "Views" );
2422 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2422 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2423 2423
2424 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2424 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2425 2425
2426 int resetval = 0; 2426 int resetval = 0;
2427 int maxVal = 0; 2427 int maxVal = 0;
2428 if (sizes.count() != 3) { 2428 if (sizes.count() != 3) {
2429 if ( KOPrefs::instance()->mVerticalScreen ) { 2429 if ( KOPrefs::instance()->mVerticalScreen ) {
2430 resetval = mDateNavigator->sizeHint().width()+2; 2430 resetval = mDateNavigator->sizeHint().width()+2;
2431 } else { 2431 } else {
2432 resetval = mDateNavigator->sizeHint().height()+2; 2432 resetval = mDateNavigator->sizeHint().height()+2;
2433 } 2433 }
2434 } 2434 }
2435 if ( resetval ) { 2435 if ( resetval ) {
2436 sizes.clear(); 2436 sizes.clear();
2437 if ( KOPrefs::instance()->mVerticalScreen ) { 2437 if ( KOPrefs::instance()->mVerticalScreen ) {
2438 maxVal = QApplication::desktop()->width() -10; 2438 maxVal = QApplication::desktop()->width() -10;
2439 } else { 2439 } else {
2440 maxVal = QApplication::desktop()->height()-10; 2440 maxVal = QApplication::desktop()->height()-10;
2441 } 2441 }
2442 sizes << resetval; 2442 sizes << resetval;
2443 if ( maxVal < resetval + resetval) 2443 if ( maxVal < resetval + resetval)
2444 resetval = maxVal - resetval; 2444 resetval = maxVal - resetval;
2445 sizes << resetval; 2445 sizes << resetval;
2446 sizes << 100; 2446 sizes << 100;
2447 } 2447 }
2448 mLeftFrame->setSizes(sizes); 2448 mLeftFrame->setSizes(sizes);
2449 sizes = config->readIntListEntry("Main Splitter Frame"); 2449 sizes = config->readIntListEntry("Main Splitter Frame");
2450 resetval = 0; 2450 resetval = 0;
2451 maxVal = 0; 2451 maxVal = 0;
2452 if (sizes.count() != 2) { 2452 if (sizes.count() != 2) {
2453 if ( !KOPrefs::instance()->mVerticalScreen ) { 2453 if ( !KOPrefs::instance()->mVerticalScreen ) {
2454 resetval = mDateNavigator->sizeHint().width()+2; 2454 resetval = mDateNavigator->sizeHint().width()+2;
2455 } else { 2455 } else {
2456 resetval = mDateNavigator->sizeHint().height()+2; 2456 resetval = mDateNavigator->sizeHint().height()+2;
2457 } 2457 }
2458 } 2458 }
2459 if ( resetval ) { 2459 if ( resetval ) {
2460 sizes.clear(); 2460 sizes.clear();
2461 if ( !KOPrefs::instance()->mVerticalScreen ) { 2461 if ( !KOPrefs::instance()->mVerticalScreen ) {
2462 maxVal = QApplication::desktop()->width() -10; 2462 maxVal = QApplication::desktop()->width() -10;
2463 } else { 2463 } else {
2464 maxVal = QApplication::desktop()->height()-10; 2464 maxVal = QApplication::desktop()->height()-10;
2465 } 2465 }
2466 sizes << resetval; 2466 sizes << resetval;
2467 if ( maxVal < resetval + resetval) 2467 if ( maxVal < resetval + resetval)
2468 resetval = maxVal - resetval; 2468 resetval = maxVal - resetval;
2469 sizes << resetval; 2469 sizes << resetval;
2470 } 2470 }
2471 mMainFrame->setSizes(sizes); 2471 mMainFrame->setSizes(sizes);
2472 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2472 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2473 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2473 else if ( dateCount == 7 ) mNavigator->selectWeek();
2474 else mNavigator->selectDates( dateCount ); 2474 else mNavigator->selectDates( dateCount );
2475 // mViewManager->readSettings( config ); 2475 // mViewManager->readSettings( config );
2476 updateConfig(); 2476 updateConfig();
2477 globalFlagBlockAgenda = 2; 2477 globalFlagBlockAgenda = 2;
2478 mViewManager->readSettings( config ); 2478 mViewManager->readSettings( config );
2479 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2479 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2480} 2480}
2481 2481
2482void CalendarView::checkSuspendAlarm() 2482void CalendarView::checkSuspendAlarm()
2483{ 2483{
2484 if ( mSuspendTimer->isActive() ) { 2484 if ( mSuspendTimer->isActive() ) {
2485 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2485 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2486 } 2486 }
2487} 2487}
2488void CalendarView::writeSettings() 2488void CalendarView::writeSettings()
2489{ 2489{
2490 // kdDebug() << "CalendarView::writeSettings" << endl; 2490 // kdDebug() << "CalendarView::writeSettings" << endl;
2491 2491
2492 KConfig *config = KOGlobals::config(); 2492 KConfig *config = KOGlobals::config();
2493 2493
2494 mViewManager->writeSettings( config ); 2494 mViewManager->writeSettings( config );
2495 mTodoList->saveLayout(config,QString("Todo Layout")); 2495 mTodoList->saveLayout(config,QString("Todo Layout"));
2496 mDialogManager->writeSettings( config ); 2496 mDialogManager->writeSettings( config );
2497 //KOPrefs::instance()->usrWriteConfig(); 2497 //KOPrefs::instance()->usrWriteConfig();
2498 KOPrefs::instance()->writeConfig(); 2498 KOPrefs::instance()->writeConfig();
2499 2499
2500 writeFilterSettings(config); 2500 writeFilterSettings(config);
2501 config->setGroup( "AppRun" ); 2501 config->setGroup( "AppRun" );
2502 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2502 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2503 int days = dt.daysTo( QDate::currentDate() ); 2503 int days = dt.daysTo( QDate::currentDate() );
2504 dt = dt.addDays( days ); 2504 dt = dt.addDays( days );
2505 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2505 int secs = dt.secsTo( QDateTime::currentDateTime() );
2506 config->writeEntry( "LatestProgramStopDays", days ); 2506 config->writeEntry( "LatestProgramStopDays", days );
2507 config->writeEntry( "LatestProgramStopSecs", secs ); 2507 config->writeEntry( "LatestProgramStopSecs", secs );
2508 //qDebug("KO: Writing stop time: %d ", secs); 2508 //qDebug("KO: Writing stop time: %d ", secs);
2509 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2509 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2510 //QDateTime latest = dt.addSecs ( secs ); 2510 //QDateTime latest = dt.addSecs ( secs );
2511 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2511 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2512 config->setGroup( "Views" ); 2512 config->setGroup( "Views" );
2513 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2513 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2514 2514
2515#if 0 2515#if 0
2516 qDebug("********************* "); 2516 qDebug("********************* ");
2517 qDebug("Testcode secsto "); 2517 qDebug("Testcode secsto ");
2518 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2518 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2519 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2519 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2520 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2520 int secsto = dt_nodaylight.secsTo( dt_daylight );
2521 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2521 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2522 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2522 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2523 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2523 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2524 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2524 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2525 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2525 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2526 qDebug("********************* testcode end"); 2526 qDebug("********************* testcode end");
2527 2527
2528#endif 2528#endif
2529 2529
2530 QValueList<int> listINT = mLeftFrame->sizes(); 2530 QValueList<int> listINT = mLeftFrame->sizes();
2531 config->writeEntry("Left Splitter Frame",listINT); 2531 config->writeEntry("Left Splitter Frame",listINT);
2532 QValueList<int> listINT2 = mMainFrame->sizes(); 2532 QValueList<int> listINT2 = mMainFrame->sizes();
2533 config->writeEntry("Main Splitter Frame",listINT2); 2533 config->writeEntry("Main Splitter Frame",listINT2);
2534#ifdef DESKTOP_VERSION 2534#ifdef DESKTOP_VERSION
2535 config->setGroup("WidgetLayout"); 2535 config->setGroup("WidgetLayout");
2536 QStringList list ;//= config->readListEntry("MainLayout"); 2536 QStringList list ;//= config->readListEntry("MainLayout");
2537 int x,y,w,h; 2537 int x,y,w,h;
2538 QWidget* wid; 2538 QWidget* wid;
2539 wid = topLevelWidget(); 2539 wid = topLevelWidget();
2540 x = wid->geometry().x(); 2540 x = wid->geometry().x();
2541 y = wid->geometry().y(); 2541 y = wid->geometry().y();
2542 w = wid->width(); 2542 w = wid->width();
2543 h = wid->height(); 2543 h = wid->height();
2544 list.clear(); 2544 list.clear();
2545 list << QString::number( x ); 2545 list << QString::number( x );
2546 list << QString::number( y ); 2546 list << QString::number( y );
2547 list << QString::number( w ); 2547 list << QString::number( w );
2548 list << QString::number( h ); 2548 list << QString::number( h );
2549 config->writeEntry("MainLayout",list ); 2549 config->writeEntry("MainLayout",list );
2550 2550
2551 wid = mEventEditor; 2551 wid = mEventEditor;
2552 x = wid->geometry().x(); 2552 x = wid->geometry().x();
2553 y = wid->geometry().y(); 2553 y = wid->geometry().y();
2554 w = wid->width(); 2554 w = wid->width();
2555 h = wid->height(); 2555 h = wid->height();
2556 list.clear(); 2556 list.clear();
2557 list << QString::number( x ); 2557 list << QString::number( x );
2558 list << QString::number( y ); 2558 list << QString::number( y );
2559 list << QString::number( w ); 2559 list << QString::number( w );
2560 list << QString::number( h ); 2560 list << QString::number( h );
2561 config->writeEntry("EditEventLayout",list ); 2561 config->writeEntry("EditEventLayout",list );
2562 2562
2563 wid = mTodoEditor; 2563 wid = mTodoEditor;
2564 x = wid->geometry().x(); 2564 x = wid->geometry().x();
2565 y = wid->geometry().y(); 2565 y = wid->geometry().y();
2566 w = wid->width(); 2566 w = wid->width();
2567 h = wid->height(); 2567 h = wid->height();
2568 list.clear(); 2568 list.clear();
2569 list << QString::number( x ); 2569 list << QString::number( x );
2570 list << QString::number( y ); 2570 list << QString::number( y );
2571 list << QString::number( w ); 2571 list << QString::number( w );
2572 list << QString::number( h ); 2572 list << QString::number( h );
2573 config->writeEntry("EditTodoLayout",list ); 2573 config->writeEntry("EditTodoLayout",list );
2574 wid = getEventViewerDialog(); 2574 wid = getEventViewerDialog();
2575 x = wid->geometry().x(); 2575 x = wid->geometry().x();
2576 y = wid->geometry().y(); 2576 y = wid->geometry().y();
2577 w = wid->width(); 2577 w = wid->width();
2578 h = wid->height(); 2578 h = wid->height();
2579 list.clear(); 2579 list.clear();
2580 list << QString::number( x ); 2580 list << QString::number( x );
2581 list << QString::number( y ); 2581 list << QString::number( y );
2582 list << QString::number( w ); 2582 list << QString::number( w );
2583 list << QString::number( h ); 2583 list << QString::number( h );
2584 config->writeEntry("ViewerLayout",list ); 2584 config->writeEntry("ViewerLayout",list );
2585 wid = mDialogManager->getSearchDialog(); 2585 wid = mDialogManager->getSearchDialog();
2586 if ( wid ) { 2586 if ( wid ) {
2587 x = wid->geometry().x(); 2587 x = wid->geometry().x();
2588 y = wid->geometry().y(); 2588 y = wid->geometry().y();
2589 w = wid->width(); 2589 w = wid->width();
2590 h = wid->height(); 2590 h = wid->height();
2591 list.clear(); 2591 list.clear();
2592 list << QString::number( x ); 2592 list << QString::number( x );
2593 list << QString::number( y ); 2593 list << QString::number( y );
2594 list << QString::number( w ); 2594 list << QString::number( w );
2595 list << QString::number( h ); 2595 list << QString::number( h );
2596 config->writeEntry("SearchLayout",list ); 2596 config->writeEntry("SearchLayout",list );
2597 } 2597 }
2598#endif 2598#endif
2599 2599
2600 2600
2601 config->sync(); 2601 config->sync();
2602} 2602}
2603 2603
2604void CalendarView::readFilterSettings(KConfig *config) 2604void CalendarView::readFilterSettings(KConfig *config)
2605{ 2605{
2606 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2606 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2607 2607
2608 mFilters.clear(); 2608 mFilters.clear();
2609 2609
2610 config->setGroup("General"); 2610 config->setGroup("General");
2611 QStringList filterList = config->readListEntry("CalendarFilters"); 2611 QStringList filterList = config->readListEntry("CalendarFilters");
2612 2612
2613 QStringList::ConstIterator it = filterList.begin(); 2613 QStringList::ConstIterator it = filterList.begin();
2614 QStringList::ConstIterator end = filterList.end(); 2614 QStringList::ConstIterator end = filterList.end();
2615 while(it != end) { 2615 while(it != end) {
2616 // kdDebug() << " filter: " << (*it) << endl; 2616 // kdDebug() << " filter: " << (*it) << endl;
2617 2617
2618 CalFilter *filter; 2618 CalFilter *filter;
2619 filter = new CalFilter(*it); 2619 filter = new CalFilter(*it);
2620 config->setGroup("Filter_" + (*it).utf8()); 2620 config->setGroup("Filter_" + (*it).utf8());
2621 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2621 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2622 filter->setCriteria(config->readNumEntry("Criteria",0)); 2622 filter->setCriteria(config->readNumEntry("Criteria",0));
2623 filter->setCategoryList(config->readListEntry("CategoryList")); 2623 filter->setCategoryList(config->readListEntry("CategoryList"));
2624 mFilters.append(filter); 2624 mFilters.append(filter);
2625 2625
2626 ++it; 2626 ++it;
2627 } 2627 }
2628 2628
2629 if (mFilters.count() == 0) { 2629 if (mFilters.count() == 0) {
2630 CalFilter *filter = new CalFilter(i18n("Default")); 2630 CalFilter *filter = new CalFilter(i18n("Default"));
2631 mFilters.append(filter); 2631 mFilters.append(filter);
2632 } 2632 }
2633 mFilterView->updateFilters(); 2633 mFilterView->updateFilters();
2634 config->setGroup("FilterView"); 2634 config->setGroup("FilterView");
2635 2635
2636 mFilterView->blockSignals(true); 2636 mFilterView->blockSignals(true);
2637 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2637 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2638 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2638 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2639 mFilterView->blockSignals(false); 2639 mFilterView->blockSignals(false);
2640 // We do it manually to avoid it being done twice by the above calls 2640 // We do it manually to avoid it being done twice by the above calls
2641 updateFilter(); 2641 updateFilter();
2642} 2642}
2643 2643
2644void CalendarView::writeFilterSettings(KConfig *config) 2644void CalendarView::writeFilterSettings(KConfig *config)
2645{ 2645{
2646 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2646 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2647 2647
2648 QStringList filterList; 2648 QStringList filterList;
2649 2649
2650 CalFilter *filter = mFilters.first(); 2650 CalFilter *filter = mFilters.first();
2651 while(filter) { 2651 while(filter) {
2652 // kdDebug() << " fn: " << filter->name() << endl; 2652 // kdDebug() << " fn: " << filter->name() << endl;
2653 filterList << filter->name(); 2653 filterList << filter->name();
2654 config->setGroup("Filter_" + filter->name().utf8()); 2654 config->setGroup("Filter_" + filter->name().utf8());
2655 config->writeEntry("Criteria",filter->criteria()); 2655 config->writeEntry("Criteria",filter->criteria());
2656 config->writeEntry("CategoryList",filter->categoryList()); 2656 config->writeEntry("CategoryList",filter->categoryList());
2657 filter = mFilters.next(); 2657 filter = mFilters.next();
2658 } 2658 }
2659 config->setGroup("General"); 2659 config->setGroup("General");
2660 config->writeEntry("CalendarFilters",filterList); 2660 config->writeEntry("CalendarFilters",filterList);
2661 2661
2662 config->setGroup("FilterView"); 2662 config->setGroup("FilterView");
2663 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2663 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2664 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2664 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2665} 2665}
2666 2666
2667 2667
2668void CalendarView::goToday() 2668void CalendarView::goToday()
2669{ 2669{
2670 if ( mViewManager->currentView()->isMonthView() ) 2670 if ( mViewManager->currentView()->isMonthView() )
2671 mNavigator->selectTodayMonth(); 2671 mNavigator->selectTodayMonth();
2672 else 2672 else
2673 mNavigator->selectToday(); 2673 mNavigator->selectToday();
2674} 2674}
2675 2675
2676void CalendarView::goNext() 2676void CalendarView::goNext()
2677{ 2677{
2678 mNavigator->selectNext(); 2678 mNavigator->selectNext();
2679} 2679}
2680 2680
2681void CalendarView::goPrevious() 2681void CalendarView::goPrevious()
2682{ 2682{
2683 mNavigator->selectPrevious(); 2683 mNavigator->selectPrevious();
2684} 2684}
2685void CalendarView::goNextMonth() 2685void CalendarView::goNextMonth()
2686{ 2686{
2687 mNavigator->selectNextMonth(); 2687 mNavigator->selectNextMonth();
2688} 2688}
2689 2689
2690void CalendarView::goPreviousMonth() 2690void CalendarView::goPreviousMonth()
2691{ 2691{
2692 mNavigator->selectPreviousMonth(); 2692 mNavigator->selectPreviousMonth();
2693} 2693}
2694 2694
2695void CalendarView::updateConfig() 2695void CalendarView::updateConfig()
2696{ 2696{
2697 if ( KOPrefs::instance()->mUseAppColors ) 2697 if ( KOPrefs::instance()->mUseAppColors )
2698 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2698 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2699 emit configChanged(); 2699 emit configChanged();
2700 mTodoList->updateConfig(); 2700 mTodoList->updateConfig();
2701 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2701 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2702 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2702 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2703 // To make the "fill window" configurations work 2703 // To make the "fill window" configurations work
2704 //mViewManager->raiseCurrentView(); 2704 //mViewManager->raiseCurrentView();
2705} 2705}
2706 2706
2707 2707
2708void CalendarView::eventChanged(Event *event) 2708void CalendarView::eventChanged(Event *event)
2709{ 2709{
2710 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2710 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2711 //updateUnmanagedViews(); 2711 //updateUnmanagedViews();
2712} 2712}
2713 2713
2714void CalendarView::eventAdded(Event *event) 2714void CalendarView::eventAdded(Event *event)
2715{ 2715{
2716 changeEventDisplay(event,KOGlobals::EVENTADDED); 2716 changeEventDisplay(event,KOGlobals::EVENTADDED);
2717} 2717}
2718 2718
2719void CalendarView::eventToBeDeleted(Event *) 2719void CalendarView::eventToBeDeleted(Event *)
2720{ 2720{
2721 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2721 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2722} 2722}
2723 2723
2724void CalendarView::eventDeleted() 2724void CalendarView::eventDeleted()
2725{ 2725{
2726 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2726 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2727} 2727}
2728void CalendarView::changeTodoDisplay(Todo *which, int action) 2728void CalendarView::changeTodoDisplay(Todo *which, int action)
2729{ 2729{
2730 changeIncidenceDisplay((Incidence *)which, action); 2730 changeIncidenceDisplay((Incidence *)which, action);
2731 mDateNavigator->updateView(); //LR 2731 mDateNavigator->updateView(); //LR
2732 //mDialogManager->updateSearchDialog(); 2732 //mDialogManager->updateSearchDialog();
2733 2733
2734 if (which) { 2734 if (which) {
2735 mViewManager->updateWNview(); 2735 mViewManager->updateWNview();
2736 //mTodoList->updateView(); 2736 //mTodoList->updateView();
2737 } 2737 }
2738 2738
2739} 2739}
2740 2740
2741void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2741void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2742{ 2742{
2743 updateUnmanagedViews(); 2743 updateUnmanagedViews();
2744 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2744 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2745 if ( action == KOGlobals::EVENTDELETED ) { //delete 2745 if ( action == KOGlobals::EVENTDELETED ) { //delete
2746 mCalendar->checkAlarmForIncidence( 0, true ); 2746 mCalendar->checkAlarmForIncidence( 0, true );
2747 if ( mEventViewerDialog ) 2747 if ( mEventViewerDialog )
2748 mEventViewerDialog->hide(); 2748 mEventViewerDialog->hide();
2749 } 2749 }
2750 else 2750 else
2751 mCalendar->checkAlarmForIncidence( which , false ); 2751 mCalendar->checkAlarmForIncidence( which , false );
2752} 2752}
2753 2753
2754// most of the changeEventDisplays() right now just call the view's 2754// most of the changeEventDisplays() right now just call the view's
2755// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2755// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2756void CalendarView::changeEventDisplay(Event *which, int action) 2756void CalendarView::changeEventDisplay(Event *which, int action)
2757{ 2757{
2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2758 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2759 changeIncidenceDisplay((Incidence *)which, action); 2759 changeIncidenceDisplay((Incidence *)which, action);
2760 static bool clearallviews = false; 2760 static bool clearallviews = false;
2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2761 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2762 if ( clearallviews ) { 2762 if ( clearallviews ) {
2763 clearAllViews(); 2763 clearAllViews();
2764 clearallviews = false; 2764 clearallviews = false;
2765 } 2765 }
2766 return; 2766 return;
2767 } 2767 }
2768 clearallviews = true; 2768 clearallviews = true;
2769 mDateNavigator->updateView(); 2769 mDateNavigator->updateView();
2770 //mDialogManager->updateSearchDialog(); 2770 //mDialogManager->updateSearchDialog();
2771 if (which) { 2771 if (which) {
2772 // If there is an event view visible update the display 2772 // If there is an event view visible update the display
2773 mViewManager->currentView()->changeEventDisplay(which,action); 2773 mViewManager->currentView()->changeEventDisplay(which,action);
2774 // TODO: check, if update needed 2774 // TODO: check, if update needed
2775 // if (which->getTodoStatus()) { 2775 // if (which->getTodoStatus()) {
2776 mTodoList->updateView(); 2776 mTodoList->updateView();
2777 if ( action != KOGlobals::EVENTDELETED ) { 2777 if ( action != KOGlobals::EVENTDELETED ) {
2778 mConflictingEvent = which ; 2778 mConflictingEvent = which ;
2779 int time = 1000; 2779 int time = 1000;
2780#ifdef DESKTOP_VERSION 2780#ifdef DESKTOP_VERSION
2781 time = 500; 2781 time = 500;
2782#endif 2782#endif
2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 2783 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
2784 } 2784 }
2785 // } 2785 // }
2786 } else { 2786 } else {
2787 mViewManager->currentView()->updateView(); 2787 mViewManager->currentView()->updateView();
2788 } 2788 }
2789} 2789}
2790void CalendarView::checkConflictForEvent() 2790void CalendarView::checkConflictForEvent()
2791{ 2791{
2792 2792
2793 if (!KOPrefs::instance()->mConfirm) 2793 if (!KOPrefs::instance()->mConfirm)
2794 return; 2794 return;
2795 if ( ! mConflictingEvent ) return; 2795 if ( ! mConflictingEvent ) return;
2796 Event * conflictingEvent = mConflictingEvent;
2797 mConflictingEvent = 0;
2796 QDateTime current = QDateTime::currentDateTime(); 2798 QDateTime current = QDateTime::currentDateTime();
2797 if ( ! mConflictingEvent->matchTime( &current, 0 ) ) { 2799 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
2798 mConflictingEvent = 0;
2799 return; 2800 return;
2800 } 2801 }
2801 QPtrList<Event> testlist = mCalendar->events(); 2802 QPtrList<Event> testlist = mCalendar->events();
2802 Event * test = testlist.first(); 2803 Event * test = testlist.first();
2803 QDateTime conflict; 2804 QDateTime conflict;
2804 QDateTime retVal; 2805 QDateTime retVal;
2805 bool found = false; 2806 bool found = false;
2806 Event * cE = 0; 2807 Event * cE = 0;
2807 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 2808 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
2808 while ( test ) { 2809 while ( test ) {
2809 qApp->processEvents(); 2810 qApp->processEvents();
2810 bool skip = false; 2811 bool skip = false;
2811 if ( found ) 2812 if ( found )
2812 skip = !test->matchTime( &current, &conflict ); 2813 skip = !test->matchTime( &current, &conflict );
2813 else 2814 else
2814 skip = !test->matchTime( &current, 0 ); 2815 skip = !test->matchTime( &current, 0 );
2815 if ( !skip && !test->doesFloat() ) { 2816 if ( !skip && !test->doesFloat() ) {
2816 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 2817 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
2817 if ( ! found ) { 2818 if ( ! found ) {
2818 conflict = retVal; 2819 conflict = retVal;
2819 cE = test; 2820 cE = test;
2820 } else { 2821 } else {
2821 if ( retVal < conflict ) { 2822 if ( retVal < conflict ) {
2822 conflict = retVal; 2823 conflict = retVal;
2823 cE = test; 2824 cE = test;
2824 } 2825 }
2825 } 2826 }
2826 found = true; 2827 found = true;
2827 } 2828 }
2828 } 2829 }
2829 test = testlist.next(); 2830 test = testlist.next();
2830 } 2831 }
2831 topLevelWidget()->setCaption( i18n("KO/Pi") ); 2832 topLevelWidget()->setCaption( i18n("KO/Pi") );
2832 if ( found ) { 2833 if ( found ) {
2833 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 2834 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
2834 qApp->processEvents(); 2835 qApp->processEvents();
2835 int km = KMessageBox::warningContinueCancel(this,mess, 2836 int km = KMessageBox::warningContinueCancel(this,mess,
2836 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 2837 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2837 if ( km != KMessageBox::Continue ) { 2838 if ( km != KMessageBox::Continue ) {
2838 return; 2839 return;
2839 } 2840 }
2840 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 2841 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2841 mViewManager->showDayView(); 2842 mViewManager->showDayView();
2842 mNavigator->slotDaySelect( conflict.date() ); 2843 mNavigator->slotDaySelect( conflict.date() );
2843 int hour = conflict.time().hour(); 2844 int hour = conflict.time().hour();
2844 mViewManager->agendaView()->setStartHour( hour ); 2845 mViewManager->agendaView()->setStartHour( hour );
2845 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 2846 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2846 } else 2847 } else
2847 topLevelWidget()->setCaption( i18n("No conflict found") ); 2848 topLevelWidget()->setCaption( i18n("No conflict found") );
2848 mConflictingEvent = 0;
2849 return; 2849 return;
2850 2850
2851} 2851}
2852 2852
2853void CalendarView::updateTodoViews() 2853void CalendarView::updateTodoViews()
2854{ 2854{
2855 mTodoList->updateView(); 2855 mTodoList->updateView();
2856 mViewManager->currentView()->updateView(); 2856 mViewManager->currentView()->updateView();
2857 2857
2858} 2858}
2859 2859
2860 2860
2861 2861
2862void CalendarView::clearAllViews() 2862void CalendarView::clearAllViews()
2863{ 2863{
2864 mTodoList->clearList(); 2864 mTodoList->clearList();
2865 mViewManager->clearAllViews(); 2865 mViewManager->clearAllViews();
2866 SearchDialog * sd = mDialogManager->getSearchDialog(); 2866 SearchDialog * sd = mDialogManager->getSearchDialog();
2867 if ( sd ) { 2867 if ( sd ) {
2868 KOListView* kol = sd->listview(); 2868 KOListView* kol = sd->listview();
2869 if ( kol ) 2869 if ( kol )
2870 kol->clearList(); 2870 kol->clearList();
2871 } 2871 }
2872} 2872}
2873void CalendarView::updateView() 2873void CalendarView::updateView()
2874{ 2874{
2875 static bool clearallviews = false; 2875 static bool clearallviews = false;
2876 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2876 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2877 if ( clearallviews ) { 2877 if ( clearallviews ) {
2878 clearAllViews(); 2878 clearAllViews();
2879 clearallviews = false; 2879 clearallviews = false;
2880 } 2880 }
2881 return; 2881 return;
2882 } 2882 }
2883 clearallviews = true; 2883 clearallviews = true;
2884 DateList tmpList = mNavigator->selectedDates(); 2884 DateList tmpList = mNavigator->selectedDates();
2885 2885
2886 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2886 if ( KOPrefs::instance()->mHideNonStartedTodos )
2887 mTodoList->updateView(); 2887 mTodoList->updateView();
2888 // We assume that the navigator only selects consecutive days. 2888 // We assume that the navigator only selects consecutive days.
2889 updateView( tmpList.first(), tmpList.last() ); 2889 updateView( tmpList.first(), tmpList.last() );
2890} 2890}
2891 2891
2892void CalendarView::updateUnmanagedViews() 2892void CalendarView::updateUnmanagedViews()
2893{ 2893{
2894 mDateNavigator->updateDayMatrix(); 2894 mDateNavigator->updateDayMatrix();
2895} 2895}
2896 2896
2897int CalendarView::msgItemDelete(const QString name) 2897int CalendarView::msgItemDelete(const QString name)
2898{ 2898{
2899 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2899 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2900 i18n("This item will be\npermanently deleted."), 2900 i18n("This item will be\npermanently deleted."),
2901 i18n("KO/Pi Confirmation"),i18n("Delete")); 2901 i18n("KO/Pi Confirmation"),i18n("Delete"));
2902} 2902}
2903 2903
2904 2904
2905void CalendarView::edit_cut() 2905void CalendarView::edit_cut()
2906{ 2906{
2907 Event *anEvent=0; 2907 Event *anEvent=0;
2908 2908
2909 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2909 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2910 2910
2911 if (mViewManager->currentView()->isEventView()) { 2911 if (mViewManager->currentView()->isEventView()) {
2912 if ( incidence && incidence->typeID() == eventID ) { 2912 if ( incidence && incidence->typeID() == eventID ) {
2913 anEvent = static_cast<Event *>(incidence); 2913 anEvent = static_cast<Event *>(incidence);
2914 } 2914 }
2915 } 2915 }
2916 2916
2917 if (!anEvent) { 2917 if (!anEvent) {
2918 KNotifyClient::beep(); 2918 KNotifyClient::beep();
2919 return; 2919 return;
2920 } 2920 }
2921 DndFactory factory( mCalendar ); 2921 DndFactory factory( mCalendar );
2922 factory.cutIncidence(anEvent); 2922 factory.cutIncidence(anEvent);
2923 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2923 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2924} 2924}
2925 2925
2926void CalendarView::edit_copy() 2926void CalendarView::edit_copy()
2927{ 2927{
2928 Event *anEvent=0; 2928 Event *anEvent=0;
2929 2929
2930 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2930 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2931 2931
2932 if (mViewManager->currentView()->isEventView()) { 2932 if (mViewManager->currentView()->isEventView()) {
2933 if ( incidence && incidence->typeID() == eventID ) { 2933 if ( incidence && incidence->typeID() == eventID ) {
2934 anEvent = static_cast<Event *>(incidence); 2934 anEvent = static_cast<Event *>(incidence);
2935 } 2935 }
2936 } 2936 }
2937 2937
2938 if (!anEvent) { 2938 if (!anEvent) {
2939 KNotifyClient::beep(); 2939 KNotifyClient::beep();
2940 return; 2940 return;
2941 } 2941 }
2942 DndFactory factory( mCalendar ); 2942 DndFactory factory( mCalendar );
2943 factory.copyIncidence(anEvent); 2943 factory.copyIncidence(anEvent);
2944} 2944}
2945 2945
2946void CalendarView::edit_paste() 2946void CalendarView::edit_paste()
2947{ 2947{
2948 QDate date = mNavigator->selectedDates().first(); 2948 QDate date = mNavigator->selectedDates().first();
2949 2949
2950 DndFactory factory( mCalendar ); 2950 DndFactory factory( mCalendar );
2951 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2951 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2952 2952
2953 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2953 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2954} 2954}
2955void CalendarView::edit_global_options() 2955void CalendarView::edit_global_options()
2956{ 2956{
2957 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2957 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2958 emit save(); 2958 emit save();
2959 emit saveStopTimer(); 2959 emit saveStopTimer();
2960 mDialogManager->showGlobalOptionsDialog(); 2960 mDialogManager->showGlobalOptionsDialog();
2961 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2961 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2962 emit saveStopTimer(); 2962 emit saveStopTimer();
2963 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2963 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2964 i18n("Timezone settings"),i18n("Reload"))) { 2964 i18n("Timezone settings"),i18n("Reload"))) {
2965 qDebug("KO: TZ reload cancelled "); 2965 qDebug("KO: TZ reload cancelled ");
2966 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2966 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2967 return; 2967 return;
2968 } 2968 }
2969 qDebug("KO: Timezone change "); 2969 qDebug("KO: Timezone change ");
2970 loadCalendars(); 2970 loadCalendars();
2971 setModified(true); 2971 setModified(true);
2972 } 2972 }
2973 else 2973 else
2974 qDebug("KO: No tz change "); 2974 qDebug("KO: No tz change ");
2975} 2975}
2976void CalendarView::edit_options() 2976void CalendarView::edit_options()
2977{ 2977{
2978 mDialogManager->showOptionsDialog(); 2978 mDialogManager->showOptionsDialog();
2979} 2979}
2980 2980
2981 2981
2982void CalendarView::slotSelectPickerDate( QDate d) 2982void CalendarView::slotSelectPickerDate( QDate d)
2983{ 2983{
2984 mDateFrame->hide(); 2984 mDateFrame->hide();
2985 if ( mDatePickerMode == 1 ) { 2985 if ( mDatePickerMode == 1 ) {
2986 mNavigator->slotDaySelect( d ); 2986 mNavigator->slotDaySelect( d );
2987 } else if ( mDatePickerMode == 2 ) { 2987 } else if ( mDatePickerMode == 2 ) {
2988 if ( mMoveIncidence->typeID() == todoID ) { 2988 if ( mMoveIncidence->typeID() == todoID ) {
2989 Todo * to = (Todo *) mMoveIncidence; 2989 Todo * to = (Todo *) mMoveIncidence;
2990 QTime tim; 2990 QTime tim;
2991 int len = 0; 2991 int len = 0;
2992 if ( to->hasStartDate() && to->hasDueDate() ) 2992 if ( to->hasStartDate() && to->hasDueDate() )
2993 len = to->dtStart().secsTo( to->dtDue()); 2993 len = to->dtStart().secsTo( to->dtDue());
2994 if ( to->hasDueDate() ) 2994 if ( to->hasDueDate() )
2995 tim = to->dtDue().time(); 2995 tim = to->dtDue().time();
2996 else { 2996 else {
2997 tim = QTime ( 0,0,0 ); 2997 tim = QTime ( 0,0,0 );
2998 to->setFloats( true ); 2998 to->setFloats( true );
2999 to->setHasDueDate( true ); 2999 to->setHasDueDate( true );
3000 } 3000 }
3001 QDateTime dt ( d,tim ); 3001 QDateTime dt ( d,tim );
3002 to->setDtDue( dt ); 3002 to->setDtDue( dt );
3003 3003
3004 if ( to->hasStartDate() ) { 3004 if ( to->hasStartDate() ) {
3005 if ( len>0 ) 3005 if ( len>0 )
3006 to->setDtStart(to->dtDue().addSecs( -len )); 3006 to->setDtStart(to->dtDue().addSecs( -len ));
3007 else 3007 else
3008 if (to->dtStart() > to->dtDue() ) 3008 if (to->dtStart() > to->dtDue() )
3009 to->setDtStart(to->dtDue().addDays( -3 )); 3009 to->setDtStart(to->dtDue().addDays( -3 ));
3010 } 3010 }
3011 3011
3012 todoChanged( to ); 3012 todoChanged( to );
3013 } else if ( mMoveIncidence->typeID() == eventID ) { 3013 } else if ( mMoveIncidence->typeID() == eventID ) {
3014 if ( mMoveIncidence->doesRecur() ) { 3014 if ( mMoveIncidence->doesRecur() ) {
3015#if 0 3015#if 0
3016 // PENDING implement this 3016 // PENDING implement this
3017 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3017 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3018 mCalendar()->addIncidence( newInc ); 3018 mCalendar()->addIncidence( newInc );
3019 if ( mMoveIncidence->typeID() == todoID ) 3019 if ( mMoveIncidence->typeID() == todoID )
3020 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3020 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3021 else 3021 else
3022 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3022 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3023 mMoveIncidence = newInc; 3023 mMoveIncidence = newInc;
3024 3024
3025#endif 3025#endif
3026 } 3026 }
3027 QTime tim = mMoveIncidence->dtStart().time(); 3027 QTime tim = mMoveIncidence->dtStart().time();
3028 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3028 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3029 QDateTime dt ( d,tim ); 3029 QDateTime dt ( d,tim );
3030 mMoveIncidence->setDtStart( dt ); 3030 mMoveIncidence->setDtStart( dt );
3031 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3031 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3032 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3032 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3033 } else if ( mMoveIncidence->typeID() == journalID ) { 3033 } else if ( mMoveIncidence->typeID() == journalID ) {
3034 QTime tim = mMoveIncidence->dtStart().time(); 3034 QTime tim = mMoveIncidence->dtStart().time();
3035 QDateTime dt ( d,tim ); 3035 QDateTime dt ( d,tim );
3036 mMoveIncidence->setDtStart( dt ); 3036 mMoveIncidence->setDtStart( dt );
3037 updateView(); 3037 updateView();
3038 } 3038 }
3039 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3039 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3040 } 3040 }
3041} 3041}
3042 3042
3043void CalendarView::removeCategories() 3043void CalendarView::removeCategories()
3044{ 3044{
3045 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3045 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3046 QStringList catList = KOPrefs::instance()->mCustomCategories; 3046 QStringList catList = KOPrefs::instance()->mCustomCategories;
3047 QStringList catIncList; 3047 QStringList catIncList;
3048 QStringList newCatList; 3048 QStringList newCatList;
3049 Incidence* inc = incList.first(); 3049 Incidence* inc = incList.first();
3050 uint i; 3050 uint i;
3051 while ( inc ) { 3051 while ( inc ) {
3052 newCatList.clear(); 3052 newCatList.clear();
3053 catIncList = inc->categories() ; 3053 catIncList = inc->categories() ;
3054 for( i = 0; i< catIncList.count(); ++i ) { 3054 for( i = 0; i< catIncList.count(); ++i ) {
3055 if ( catList.contains (catIncList[i])) 3055 if ( catList.contains (catIncList[i]))
3056 newCatList.append( catIncList[i] ); 3056 newCatList.append( catIncList[i] );
3057 } 3057 }
3058 newCatList.sort(); 3058 newCatList.sort();
3059 inc->setCategories( newCatList.join(",") ); 3059 inc->setCategories( newCatList.join(",") );
3060 inc = incList.next(); 3060 inc = incList.next();
3061 } 3061 }
3062} 3062}
3063 3063
3064int CalendarView::addCategories() 3064int CalendarView::addCategories()
3065{ 3065{
3066 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3066 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3067 QStringList catList = KOPrefs::instance()->mCustomCategories; 3067 QStringList catList = KOPrefs::instance()->mCustomCategories;
3068 QStringList catIncList; 3068 QStringList catIncList;
3069 Incidence* inc = incList.first(); 3069 Incidence* inc = incList.first();
3070 uint i; 3070 uint i;
3071 int count = 0; 3071 int count = 0;
3072 while ( inc ) { 3072 while ( inc ) {
3073 catIncList = inc->categories() ; 3073 catIncList = inc->categories() ;
3074 for( i = 0; i< catIncList.count(); ++i ) { 3074 for( i = 0; i< catIncList.count(); ++i ) {
3075 if ( !catList.contains (catIncList[i])) { 3075 if ( !catList.contains (catIncList[i])) {
3076 catList.append( catIncList[i] ); 3076 catList.append( catIncList[i] );
3077 //qDebug("add cat %s ", catIncList[i].latin1()); 3077 //qDebug("add cat %s ", catIncList[i].latin1());
3078 ++count; 3078 ++count;
3079 } 3079 }
3080 } 3080 }
3081 inc = incList.next(); 3081 inc = incList.next();
3082 } 3082 }
3083 catList.sort(); 3083 catList.sort();
3084 KOPrefs::instance()->mCustomCategories = catList; 3084 KOPrefs::instance()->mCustomCategories = catList;
3085 return count; 3085 return count;
3086} 3086}
3087 3087
3088void CalendarView::editCategories() 3088void CalendarView::editCategories()
3089{ 3089{
3090 qDebug("CalendarView::editCategories() "); 3090 qDebug("CalendarView::editCategories() ");
3091 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3091 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3092 ced.exec(); 3092 ced.exec();
3093} 3093}
3094void CalendarView::manageCategories() 3094void CalendarView::manageCategories()
3095{ 3095{
3096 KOCatPrefs* cp = new KOCatPrefs(); 3096 KOCatPrefs* cp = new KOCatPrefs();
3097 cp->show(); 3097 cp->show();
3098 int w =cp->sizeHint().width() ; 3098 int w =cp->sizeHint().width() ;
3099 int h = cp->sizeHint().height() ; 3099 int h = cp->sizeHint().height() ;
3100 int dw = QApplication::desktop()->width(); 3100 int dw = QApplication::desktop()->width();
3101 int dh = QApplication::desktop()->height(); 3101 int dh = QApplication::desktop()->height();
3102 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3102 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3103 if ( !cp->exec() ) { 3103 if ( !cp->exec() ) {
3104 delete cp; 3104 delete cp;
3105 return; 3105 return;
3106 } 3106 }
3107 int count = 0; 3107 int count = 0;
3108 if ( cp->addCat() ) { 3108 if ( cp->addCat() ) {
3109 count = addCategories(); 3109 count = addCategories();
3110 if ( count ) { 3110 if ( count ) {
3111 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3111 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3112 writeSettings(); 3112 writeSettings();
3113 } else 3113 } else
3114 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3114 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3115 } else { 3115 } else {
3116 removeCategories(); 3116 removeCategories();
3117 updateView(); 3117 updateView();
3118 } 3118 }
3119 delete cp; 3119 delete cp;
3120} 3120}
3121 3121
3122void CalendarView::beamIncidence(Incidence * Inc) 3122void CalendarView::beamIncidence(Incidence * Inc)
3123{ 3123{
3124 QPtrList<Incidence> delSel ; 3124 QPtrList<Incidence> delSel ;
3125 delSel.append(Inc); 3125 delSel.append(Inc);
3126 beamIncidenceList( delSel ); 3126 beamIncidenceList( delSel );
3127} 3127}
3128void CalendarView::beamCalendar() 3128void CalendarView::beamCalendar()
3129{ 3129{
3130 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3130 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3131 //qDebug("beamCalendar() "); 3131 //qDebug("beamCalendar() ");
3132 beamIncidenceList( delSel ); 3132 beamIncidenceList( delSel );
3133} 3133}
3134void CalendarView::beamFilteredCalendar() 3134void CalendarView::beamFilteredCalendar()
3135{ 3135{
3136 QPtrList<Incidence> delSel = mCalendar->incidences(); 3136 QPtrList<Incidence> delSel = mCalendar->incidences();
3137 //qDebug("beamFilteredCalendar() "); 3137 //qDebug("beamFilteredCalendar() ");
3138 beamIncidenceList( delSel ); 3138 beamIncidenceList( delSel );
3139} 3139}
3140void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3140void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3141{ 3141{
3142 3142
3143 KOBeamPrefs beamDialog; 3143 KOBeamPrefs beamDialog;
3144 if ( beamDialog.exec () == QDialog::Rejected ) 3144 if ( beamDialog.exec () == QDialog::Rejected )
3145 return; 3145 return;
3146#ifdef DESKTOP_VERSION 3146#ifdef DESKTOP_VERSION
3147 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3147 QString fn = locateLocal( "tmp", "kopibeamfile" );
3148#else 3148#else
3149 QString fn = "/tmp/kopibeamfile"; 3149 QString fn = "/tmp/kopibeamfile";
3150#endif 3150#endif
3151 QString mes; 3151 QString mes;
3152 bool createbup = true; 3152 bool createbup = true;
3153 if ( createbup ) { 3153 if ( createbup ) {
3154 QString description = "\n"; 3154 QString description = "\n";
3155 CalendarLocal* cal = new CalendarLocal(); 3155 CalendarLocal* cal = new CalendarLocal();
3156 if ( beamDialog.beamLocal() ) 3156 if ( beamDialog.beamLocal() )
3157 cal->setLocalTime(); 3157 cal->setLocalTime();
3158 else 3158 else
3159 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3159 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3160 Incidence *incidence = delSel.first(); 3160 Incidence *incidence = delSel.first();
3161 bool addText = false; 3161 bool addText = false;
3162 if ( delSel.count() < 10 ) 3162 if ( delSel.count() < 10 )
3163 addText = true; 3163 addText = true;
3164 else { 3164 else {
3165 description.sprintf(i18n(" %d items?"),delSel.count() ); 3165 description.sprintf(i18n(" %d items?"),delSel.count() );
3166 } 3166 }
3167 while ( incidence ) { 3167 while ( incidence ) {
3168 Incidence *in = incidence->clone(); 3168 Incidence *in = incidence->clone();
3169 if ( ! in->summary().isEmpty() ) { 3169 if ( ! in->summary().isEmpty() ) {
3170 in->setDescription(""); 3170 in->setDescription("");
3171 } else { 3171 } else {
3172 in->setSummary( in->description().left(20)); 3172 in->setSummary( in->description().left(20));
3173 in->setDescription(""); 3173 in->setDescription("");
3174 } 3174 }
3175 if ( addText ) 3175 if ( addText )
3176 description += in->summary() + "\n"; 3176 description += in->summary() + "\n";
3177 cal->addIncidence( in ); 3177 cal->addIncidence( in );
3178 incidence = delSel.next(); 3178 incidence = delSel.next();
3179 } 3179 }
3180 if ( beamDialog.beamVcal() ) { 3180 if ( beamDialog.beamVcal() ) {
3181 fn += ".vcs"; 3181 fn += ".vcs";
3182 FileStorage storage( cal, fn, new VCalFormat ); 3182 FileStorage storage( cal, fn, new VCalFormat );
3183 storage.save(); 3183 storage.save();
3184 } else { 3184 } else {
3185 fn += ".ics"; 3185 fn += ".ics";
3186 FileStorage storage( cal, fn, new ICalFormat( ) ); 3186 FileStorage storage( cal, fn, new ICalFormat( ) );
3187 storage.save(); 3187 storage.save();
3188 } 3188 }
3189 delete cal; 3189 delete cal;
3190 mes = i18n("KO/Pi: Ready for beaming"); 3190 mes = i18n("KO/Pi: Ready for beaming");
3191 topLevelWidget()->setCaption(mes); 3191 topLevelWidget()->setCaption(mes);
3192 KApplication::convert2latin1( fn ); 3192 KApplication::convert2latin1( fn );
3193#ifndef DESKTOP_VERSION 3193#ifndef DESKTOP_VERSION
3194 Ir *ir = new Ir( this ); 3194 Ir *ir = new Ir( this );
3195 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3195 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3196 ir->send( fn, description, "text/x-vCalendar" ); 3196 ir->send( fn, description, "text/x-vCalendar" );
3197#endif 3197#endif
3198 } 3198 }
3199} 3199}
3200 3200
3201#ifndef DESKTOP_VERSION 3201#ifndef DESKTOP_VERSION
3202void CalendarView::beamDone( Ir *ir ) 3202void CalendarView::beamDone( Ir *ir )
3203{ 3203{
3204 delete ir; 3204 delete ir;
3205 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3205 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3206 topLevelWidget()->raise(); 3206 topLevelWidget()->raise();
3207} 3207}
3208#else 3208#else
3209void CalendarView::beamDone( Ir *){;} 3209void CalendarView::beamDone( Ir *){;}
3210#endif 3210#endif
3211void CalendarView::moveIncidence(Incidence * inc ) 3211void CalendarView::moveIncidence(Incidence * inc )
3212{ 3212{
3213 if ( !inc ) return; 3213 if ( !inc ) return;
3214 showDatePickerPopup(); 3214 showDatePickerPopup();
3215 mDatePickerMode = 2; 3215 mDatePickerMode = 2;
3216 mMoveIncidence = inc ; 3216 mMoveIncidence = inc ;
3217 QDate da; 3217 QDate da;
3218 if ( mMoveIncidence->typeID() == todoID ) { 3218 if ( mMoveIncidence->typeID() == todoID ) {
3219 Todo * to = (Todo *) mMoveIncidence; 3219 Todo * to = (Todo *) mMoveIncidence;
3220 if ( to->hasDueDate() ) 3220 if ( to->hasDueDate() )
3221 da = to->dtDue().date(); 3221 da = to->dtDue().date();
3222 else 3222 else
3223 da = QDate::currentDate(); 3223 da = QDate::currentDate();
3224 } else { 3224 } else {
3225 da = mMoveIncidence->dtStart().date(); 3225 da = mMoveIncidence->dtStart().date();
3226 } 3226 }
3227 //PENDING set date for recurring incidence to date of recurrence 3227 //PENDING set date for recurring incidence to date of recurrence
3228 //mMoveIncidenceOldDate; 3228 //mMoveIncidenceOldDate;
3229 mDatePicker->setDate( da ); 3229 mDatePicker->setDate( da );
3230} 3230}
3231void CalendarView::showDatePickerPopup() 3231void CalendarView::showDatePickerPopup()
3232{ 3232{
3233 if ( mDateFrame->isVisible() ) 3233 if ( mDateFrame->isVisible() )
3234 mDateFrame->hide(); 3234 mDateFrame->hide();
3235 else { 3235 else {
3236 int offX = 0, offY = 0; 3236 int offX = 0, offY = 0;
3237#ifdef DESKTOP_VERSION 3237#ifdef DESKTOP_VERSION
3238 int w =mDatePicker->sizeHint().width() ; 3238 int w =mDatePicker->sizeHint().width() ;
3239 int h = mDatePicker->sizeHint().height() ; 3239 int h = mDatePicker->sizeHint().height() ;
3240 int dw = topLevelWidget()->width(); 3240 int dw = topLevelWidget()->width();
3241 int dh = topLevelWidget()->height(); 3241 int dh = topLevelWidget()->height();
3242 offX = topLevelWidget()->x(); 3242 offX = topLevelWidget()->x();
3243 offY = topLevelWidget()->y(); 3243 offY = topLevelWidget()->y();
3244#else 3244#else
3245 int w =mDatePicker->sizeHint().width() ; 3245 int w =mDatePicker->sizeHint().width() ;
3246 int h = mDatePicker->sizeHint().height() ; 3246 int h = mDatePicker->sizeHint().height() ;
3247 int dw = QApplication::desktop()->width(); 3247 int dw = QApplication::desktop()->width();
3248 int dh = QApplication::desktop()->height(); 3248 int dh = QApplication::desktop()->height();
3249#endif 3249#endif
3250 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3250 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3251 mDateFrame->show(); 3251 mDateFrame->show();
3252 } 3252 }
3253} 3253}
3254void CalendarView::showDatePicker( ) 3254void CalendarView::showDatePicker( )
3255{ 3255{
3256 showDatePickerPopup(); 3256 showDatePickerPopup();
3257 mDatePickerMode = 1; 3257 mDatePickerMode = 1;
3258 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3258 mDatePicker->setDate( mNavigator->selectedDates().first() );
3259} 3259}
3260 3260
3261void CalendarView::showEventEditor() 3261void CalendarView::showEventEditor()
3262{ 3262{
3263#ifdef DESKTOP_VERSION 3263#ifdef DESKTOP_VERSION
3264 int x,y,w,h; 3264 int x,y,w,h;
3265 x = mEventEditor->geometry().x(); 3265 x = mEventEditor->geometry().x();
3266 y = mEventEditor->geometry().y(); 3266 y = mEventEditor->geometry().y();
3267 w = mEventEditor->width(); 3267 w = mEventEditor->width();
3268 h = mEventEditor->height(); 3268 h = mEventEditor->height();
3269 mEventEditor->show(); 3269 mEventEditor->show();
3270 mEventEditor->setGeometry(x,y,w,h); 3270 mEventEditor->setGeometry(x,y,w,h);
3271#else 3271#else
3272 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3272 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3273 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3273 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3274 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3274 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3275 qApp->processEvents(); 3275 qApp->processEvents();
3276 delete mEventEditor; 3276 delete mEventEditor;
3277 mEventEditor = mDialogManager->getEventEditor(); 3277 mEventEditor = mDialogManager->getEventEditor();
3278 topLevelWidget()->setCaption( i18n("") ); 3278 topLevelWidget()->setCaption( i18n("") );
3279 } 3279 }
3280 mEventEditor->showMaximized(); 3280 mEventEditor->showMaximized();
3281#endif 3281#endif
3282} 3282}
3283void CalendarView::showTodoEditor() 3283void CalendarView::showTodoEditor()
3284{ 3284{
3285#ifdef DESKTOP_VERSION 3285#ifdef DESKTOP_VERSION
3286 int x,y,w,h; 3286 int x,y,w,h;
3287 x = mTodoEditor->geometry().x(); 3287 x = mTodoEditor->geometry().x();
3288 y = mTodoEditor->geometry().y(); 3288 y = mTodoEditor->geometry().y();
3289 w = mTodoEditor->width(); 3289 w = mTodoEditor->width();
3290 h = mTodoEditor->height(); 3290 h = mTodoEditor->height();
3291 mTodoEditor->show(); 3291 mTodoEditor->show();
3292 mTodoEditor->setGeometry(x,y,w,h); 3292 mTodoEditor->setGeometry(x,y,w,h);
3293#else 3293#else
3294 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3294 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3295 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3295 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3296 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3296 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3297 qApp->processEvents(); 3297 qApp->processEvents();
3298 delete mTodoEditor; 3298 delete mTodoEditor;
3299 mTodoEditor = mDialogManager->getTodoEditor(); 3299 mTodoEditor = mDialogManager->getTodoEditor();
3300 topLevelWidget()->setCaption( i18n("") ); 3300 topLevelWidget()->setCaption( i18n("") );
3301 } 3301 }
3302 mTodoEditor->showMaximized(); 3302 mTodoEditor->showMaximized();
3303#endif 3303#endif
3304} 3304}
3305 3305
3306void CalendarView::cloneIncidence() 3306void CalendarView::cloneIncidence()
3307{ 3307{
3308 Incidence *incidence = currentSelection(); 3308 Incidence *incidence = currentSelection();
3309 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3309 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3310 if ( incidence ) { 3310 if ( incidence ) {
3311 cloneIncidence(incidence); 3311 cloneIncidence(incidence);
3312 } 3312 }
3313} 3313}
3314void CalendarView::moveIncidence() 3314void CalendarView::moveIncidence()
3315{ 3315{
3316 Incidence *incidence = currentSelection(); 3316 Incidence *incidence = currentSelection();
3317 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3317 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3318 if ( incidence ) { 3318 if ( incidence ) {
3319 moveIncidence(incidence); 3319 moveIncidence(incidence);
3320 } 3320 }
3321} 3321}
3322void CalendarView::beamIncidence() 3322void CalendarView::beamIncidence()
3323{ 3323{
3324 Incidence *incidence = currentSelection(); 3324 Incidence *incidence = currentSelection();
3325 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3325 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3326 if ( incidence ) { 3326 if ( incidence ) {
3327 beamIncidence(incidence); 3327 beamIncidence(incidence);
3328 } 3328 }
3329} 3329}
3330void CalendarView::toggleCancelIncidence() 3330void CalendarView::toggleCancelIncidence()
3331{ 3331{
3332 Incidence *incidence = currentSelection(); 3332 Incidence *incidence = currentSelection();
3333 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3333 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3334 if ( incidence ) { 3334 if ( incidence ) {
3335 cancelIncidence(incidence); 3335 cancelIncidence(incidence);
3336 } 3336 }
3337} 3337}
3338 3338
3339 3339
3340void CalendarView::cancelIncidence(Incidence * inc ) 3340void CalendarView::cancelIncidence(Incidence * inc )
3341{ 3341{
3342 inc->setCancelled( ! inc->cancelled() ); 3342 inc->setCancelled( ! inc->cancelled() );
3343 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3343 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3344 updateView(); 3344 updateView();
3345} 3345}
3346void CalendarView::cloneIncidence(Incidence * orgInc ) 3346void CalendarView::cloneIncidence(Incidence * orgInc )
3347{ 3347{
3348 Incidence * newInc = orgInc->clone(); 3348 Incidence * newInc = orgInc->clone();
3349 newInc->recreate(); 3349 newInc->recreate();
3350 3350
3351 if ( newInc->typeID() == todoID ) { 3351 if ( newInc->typeID() == todoID ) {
3352 Todo* t = (Todo*) newInc; 3352 Todo* t = (Todo*) newInc;
3353 bool cloneSub = false; 3353 bool cloneSub = false;
3354 if ( orgInc->relations().count() ) { 3354 if ( orgInc->relations().count() ) {
3355 int result = KMessageBox::warningYesNoCancel(this, 3355 int result = KMessageBox::warningYesNoCancel(this,
3356 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), 3356 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
3357 i18n("Todo has subtodos"), 3357 i18n("Todo has subtodos"),
3358 i18n("Yes"), 3358 i18n("Yes"),
3359 i18n("No")); 3359 i18n("No"));
3360 3360
3361 if ( result == KMessageBox::Cancel ) { 3361 if ( result == KMessageBox::Cancel ) {
3362 delete t; 3362 delete t;
3363 return; 3363 return;
3364 } 3364 }
3365 if (result == KMessageBox::Yes) cloneSub = true; 3365 if (result == KMessageBox::Yes) cloneSub = true;
3366 } 3366 }
3367 showTodoEditor(); 3367 showTodoEditor();
3368 mTodoEditor->editTodo( t ); 3368 mTodoEditor->editTodo( t );
3369 if ( mTodoEditor->exec() ) { 3369 if ( mTodoEditor->exec() ) {
3370 if ( cloneSub ) { 3370 if ( cloneSub ) {
3371 orgInc->cloneRelations( t ); 3371 orgInc->cloneRelations( t );
3372 mCalendar->addIncidenceBranch( t ); 3372 mCalendar->addIncidenceBranch( t );
3373 updateView(); 3373 updateView();
3374 3374
3375 } else { 3375 } else {
3376 mCalendar->addTodo( t ); 3376 mCalendar->addTodo( t );
3377 updateView(); 3377 updateView();
3378 } 3378 }
3379 } else { 3379 } else {
3380 delete t; 3380 delete t;
3381 } 3381 }
3382 } 3382 }
3383 else if ( newInc->typeID() == eventID ) { 3383 else if ( newInc->typeID() == eventID ) {
3384 Event* e = (Event*) newInc; 3384 Event* e = (Event*) newInc;
3385 showEventEditor(); 3385 showEventEditor();
3386 mEventEditor->editEvent( e ); 3386 mEventEditor->editEvent( e );
3387 if ( mEventEditor->exec() ) { 3387 if ( mEventEditor->exec() ) {
3388 mCalendar->addEvent( e ); 3388 mCalendar->addEvent( e );
3389 updateView(); 3389 updateView();
3390 } else { 3390 } else {
3391 delete e; 3391 delete e;
3392 } 3392 }
3393 } if ( newInc->typeID() == journalID ) { 3393 } if ( newInc->typeID() == journalID ) {
3394 mCalendar->addJournal( (Journal*) newInc ); 3394 mCalendar->addJournal( (Journal*) newInc );
3395 editJournal( (Journal*) newInc ); 3395 editJournal( (Journal*) newInc );
3396 } 3396 }
3397 setActiveWindow(); 3397 setActiveWindow();
3398} 3398}
3399 3399
3400void CalendarView::newEvent() 3400void CalendarView::newEvent()
3401{ 3401{
3402 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3402 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3403 KOAgendaView *aView = mViewManager->agendaView(); 3403 KOAgendaView *aView = mViewManager->agendaView();
3404 if (aView) { 3404 if (aView) {
3405 if (aView->selectionStart().isValid()) { 3405 if (aView->selectionStart().isValid()) {
3406 if (aView->selectedIsAllDay()) { 3406 if (aView->selectedIsAllDay()) {
3407 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3407 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3408 } else { 3408 } else {
3409 newEvent(aView->selectionStart(),aView->selectionEnd()); 3409 newEvent(aView->selectionStart(),aView->selectionEnd());
3410 } 3410 }
3411 return; 3411 return;
3412 } 3412 }
3413 } 3413 }
3414 3414
3415 QDate date = mNavigator->selectedDates().first(); 3415 QDate date = mNavigator->selectedDates().first();
3416#if 0 3416#if 0
3417 QDateTime current = QDateTime::currentDateTime(); 3417 QDateTime current = QDateTime::currentDateTime();
3418 if ( date <= current.date() ) { 3418 if ( date <= current.date() ) {
3419 int hour = current.time().hour() +1; 3419 int hour = current.time().hour() +1;
3420 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3420 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3421 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3421 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3422 } else 3422 } else
3423#endif 3423#endif
3424 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3424 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3425 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3425 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3426 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3426 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3427} 3427}
3428 3428
3429void CalendarView::newEvent(QDateTime fh) 3429void CalendarView::newEvent(QDateTime fh)
3430{ 3430{
3431 newEvent(fh, 3431 newEvent(fh,
3432 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3432 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3433} 3433}
3434 3434
3435void CalendarView::newEvent(QDate dt) 3435void CalendarView::newEvent(QDate dt)
3436{ 3436{
3437 newEvent(QDateTime(dt, QTime(0,0,0)), 3437 newEvent(QDateTime(dt, QTime(0,0,0)),
3438 QDateTime(dt, QTime(0,0,0)), true); 3438 QDateTime(dt, QTime(0,0,0)), true);
3439} 3439}
3440void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3440void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3441{ 3441{
3442 newEvent(fromHint, toHint, false); 3442 newEvent(fromHint, toHint, false);
3443} 3443}
3444void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3444void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3445{ 3445{
3446 3446
3447 showEventEditor(); 3447 showEventEditor();
3448 mEventEditor->newEvent(fromHint,toHint,allDay); 3448 mEventEditor->newEvent(fromHint,toHint,allDay);
3449 if ( mFilterView->filtersEnabled() ) { 3449 if ( mFilterView->filtersEnabled() ) {
3450 CalFilter *filter = mFilterView->selectedFilter(); 3450 CalFilter *filter = mFilterView->selectedFilter();
3451 if (filter && filter->showCategories()) { 3451 if (filter && filter->showCategories()) {
3452 mEventEditor->setCategories(filter->categoryList().join(",") ); 3452 mEventEditor->setCategories(filter->categoryList().join(",") );
3453 } 3453 }
3454 if ( filter ) 3454 if ( filter )
3455 mEventEditor->setSecrecy( filter->getSecrecy() ); 3455 mEventEditor->setSecrecy( filter->getSecrecy() );
3456 } 3456 }
3457 mEventEditor->exec(); 3457 mEventEditor->exec();
3458 setActiveWindow(); 3458 setActiveWindow();
3459} 3459}
3460void CalendarView::todoAdded(Todo * t) 3460void CalendarView::todoAdded(Todo * t)
3461{ 3461{
3462 3462
3463 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3463 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3464 updateTodoViews(); 3464 updateTodoViews();
3465} 3465}
3466void CalendarView::todoChanged(Todo * t) 3466void CalendarView::todoChanged(Todo * t)
3467{ 3467{
3468 emit todoModified( t, 4 ); 3468 emit todoModified( t, 4 );
3469 // updateTodoViews(); 3469 // updateTodoViews();
3470} 3470}
3471void CalendarView::todoToBeDeleted(Todo *) 3471void CalendarView::todoToBeDeleted(Todo *)
3472{ 3472{
3473 //qDebug("todoToBeDeleted(Todo *) "); 3473 //qDebug("todoToBeDeleted(Todo *) ");
3474 updateTodoViews(); 3474 updateTodoViews();
3475} 3475}
3476void CalendarView::todoDeleted() 3476void CalendarView::todoDeleted()
3477{ 3477{
3478 //qDebug(" todoDeleted()"); 3478 //qDebug(" todoDeleted()");
3479 updateTodoViews(); 3479 updateTodoViews();
3480} 3480}
3481 3481
3482 3482
3483void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3483void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3484{ 3484{
3485 showTodoEditor(); 3485 showTodoEditor();
3486 mTodoEditor->newTodo(dt,0,allday); 3486 mTodoEditor->newTodo(dt,0,allday);
3487 if ( mFilterView->filtersEnabled() ) { 3487 if ( mFilterView->filtersEnabled() ) {
3488 CalFilter *filter = mFilterView->selectedFilter(); 3488 CalFilter *filter = mFilterView->selectedFilter();
3489 if (filter && filter->showCategories()) { 3489 if (filter && filter->showCategories()) {
3490 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3490 mTodoEditor->setCategories(filter->categoryList().join(",") );
3491 } 3491 }
3492 if ( filter ) 3492 if ( filter )
3493 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3493 mTodoEditor->setSecrecy( filter->getSecrecy() );
3494 } 3494 }
3495 mTodoEditor->exec(); 3495 mTodoEditor->exec();
3496 setActiveWindow(); 3496 setActiveWindow();
3497} 3497}
3498 3498
3499void CalendarView::newTodo() 3499void CalendarView::newTodo()
3500{ 3500{
3501 newTodoDateTime( QDateTime(),true ); 3501 newTodoDateTime( QDateTime(),true );
3502} 3502}
3503 3503
3504void CalendarView::newSubTodo() 3504void CalendarView::newSubTodo()
3505{ 3505{
3506 Todo *todo = selectedTodo(); 3506 Todo *todo = selectedTodo();
3507 if ( todo ) newSubTodo( todo ); 3507 if ( todo ) newSubTodo( todo );
3508} 3508}
3509 3509
3510void CalendarView::newSubTodo(Todo *parentEvent) 3510void CalendarView::newSubTodo(Todo *parentEvent)
3511{ 3511{
3512 3512
3513 showTodoEditor(); 3513 showTodoEditor();
3514 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3514 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3515 mTodoEditor->exec(); 3515 mTodoEditor->exec();
3516 setActiveWindow(); 3516 setActiveWindow();
3517} 3517}
3518 3518
3519void CalendarView::newFloatingEvent() 3519void CalendarView::newFloatingEvent()
3520{ 3520{
3521 DateList tmpList = mNavigator->selectedDates(); 3521 DateList tmpList = mNavigator->selectedDates();
3522 QDate date = tmpList.first(); 3522 QDate date = tmpList.first();
3523 3523
3524 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3524 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3525 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3525 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3526} 3526}
3527 3527
3528 3528
3529void CalendarView::editEvent( Event *event ) 3529void CalendarView::editEvent( Event *event )
3530{ 3530{
3531 3531
3532 if ( !event ) return; 3532 if ( !event ) return;
3533 if ( event->isReadOnly() ) { 3533 if ( event->isReadOnly() ) {
3534 showEvent( event ); 3534 showEvent( event );
3535 return; 3535 return;
3536 } 3536 }
3537 showEventEditor(); 3537 showEventEditor();
3538 mEventEditor->editEvent( event , mFlagEditDescription); 3538 mEventEditor->editEvent( event , mFlagEditDescription);
3539 mEventEditor->exec(); 3539 mEventEditor->exec();
3540 setActiveWindow(); 3540 setActiveWindow();
3541 3541
3542} 3542}
3543void CalendarView::editJournal( Journal *jour ) 3543void CalendarView::editJournal( Journal *jour )
3544{ 3544{
3545 if ( !jour ) return; 3545 if ( !jour ) return;
3546 mDialogManager->hideSearchDialog(); 3546 mDialogManager->hideSearchDialog();
3547 mViewManager->showJournalView(); 3547 mViewManager->showJournalView();
3548 mNavigator->slotDaySelect( jour->dtStart().date() ); 3548 mNavigator->slotDaySelect( jour->dtStart().date() );
3549} 3549}
3550void CalendarView::editTodo( Todo *todo ) 3550void CalendarView::editTodo( Todo *todo )
3551{ 3551{
3552 if ( !todo ) return; 3552 if ( !todo ) return;
3553 3553
3554 if ( todo->isReadOnly() ) { 3554 if ( todo->isReadOnly() ) {
3555 showTodo( todo ); 3555 showTodo( todo );
3556 return; 3556 return;
3557 } 3557 }
3558 showTodoEditor(); 3558 showTodoEditor();
3559 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3559 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3560 mTodoEditor->exec(); 3560 mTodoEditor->exec();
3561 setActiveWindow(); 3561 setActiveWindow();
3562 3562
3563} 3563}
3564 3564
3565KOEventViewerDialog* CalendarView::getEventViewerDialog() 3565KOEventViewerDialog* CalendarView::getEventViewerDialog()
3566{ 3566{
3567 if ( !mEventViewerDialog ) { 3567 if ( !mEventViewerDialog ) {
3568 mEventViewerDialog = new KOEventViewerDialog(0); 3568 mEventViewerDialog = new KOEventViewerDialog(0);
3569 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3569 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3570 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3570 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3571 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3571 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3572 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3572 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3573 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3573 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3574 viewManager(), SLOT( showAgendaView( bool ) ) ); 3574 viewManager(), SLOT( showAgendaView( bool ) ) );
3575 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3575 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3576 this, SLOT( slotViewerClosed() ) ); 3576 this, SLOT( slotViewerClosed() ) );
3577 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3577 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3578 this, SLOT( todoChanged(Todo *) ) ); 3578 this, SLOT( todoChanged(Todo *) ) );
3579 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3579 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3580 mEventViewerDialog->resize( 640, 480 ); 3580 mEventViewerDialog->resize( 640, 480 );
3581 3581
3582 } 3582 }
3583 return mEventViewerDialog; 3583 return mEventViewerDialog;
3584} 3584}
3585void CalendarView::showEvent(Event *event) 3585void CalendarView::showEvent(Event *event)
3586{ 3586{
3587 getEventViewerDialog()->setEvent(event); 3587 getEventViewerDialog()->setEvent(event);
3588 getEventViewerDialog()->showMe(); 3588 getEventViewerDialog()->showMe();
3589} 3589}
3590 3590
3591void CalendarView::showTodo(Todo *event) 3591void CalendarView::showTodo(Todo *event)
3592{ 3592{
3593 getEventViewerDialog()->setTodo(event); 3593 getEventViewerDialog()->setTodo(event);
3594 getEventViewerDialog()->showMe(); 3594 getEventViewerDialog()->showMe();
3595} 3595}
3596void CalendarView::showJournal( Journal *jour ) 3596void CalendarView::showJournal( Journal *jour )
3597{ 3597{
3598 getEventViewerDialog()->setJournal(jour); 3598 getEventViewerDialog()->setJournal(jour);
3599 getEventViewerDialog()->showMe(); 3599 getEventViewerDialog()->showMe();
3600 3600
3601} 3601}
3602// void CalendarView::todoModified (Todo *event, int changed) 3602// void CalendarView::todoModified (Todo *event, int changed)
3603// { 3603// {
3604// // if (mDialogList.find (event) != mDialogList.end ()) { 3604// // if (mDialogList.find (event) != mDialogList.end ()) {
3605// // kdDebug() << "Todo modified and open" << endl; 3605// // kdDebug() << "Todo modified and open" << endl;
3606// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3606// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3607// // temp->modified (changed); 3607// // temp->modified (changed);
3608 3608
3609// // } 3609// // }
3610 3610
3611// mViewManager->updateView(); 3611// mViewManager->updateView();
3612// } 3612// }
3613 3613
3614void CalendarView::appointment_show() 3614void CalendarView::appointment_show()
3615{ 3615{
3616 Event *anEvent = 0; 3616 Event *anEvent = 0;
3617 3617
3618 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3618 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3619 3619
3620 if (mViewManager->currentView()->isEventView()) { 3620 if (mViewManager->currentView()->isEventView()) {
3621 if ( incidence && incidence->typeID() == eventID ) { 3621 if ( incidence && incidence->typeID() == eventID ) {
3622 anEvent = static_cast<Event *>(incidence); 3622 anEvent = static_cast<Event *>(incidence);
3623 } 3623 }
3624 } 3624 }
3625 3625
3626 if (!anEvent) { 3626 if (!anEvent) {
3627 KNotifyClient::beep(); 3627 KNotifyClient::beep();
3628 return; 3628 return;
3629 } 3629 }
3630 3630
3631 showEvent(anEvent); 3631 showEvent(anEvent);
3632} 3632}
3633 3633
3634void CalendarView::appointment_edit() 3634void CalendarView::appointment_edit()
3635{ 3635{
3636 Event *anEvent = 0; 3636 Event *anEvent = 0;
3637 3637
3638 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3638 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3639 3639
3640 if (mViewManager->currentView()->isEventView()) { 3640 if (mViewManager->currentView()->isEventView()) {
3641 if ( incidence && incidence->typeID() == eventID ) { 3641 if ( incidence && incidence->typeID() == eventID ) {
3642 anEvent = static_cast<Event *>(incidence); 3642 anEvent = static_cast<Event *>(incidence);
3643 } 3643 }
3644 } 3644 }
3645 3645
3646 if (!anEvent) { 3646 if (!anEvent) {
3647 KNotifyClient::beep(); 3647 KNotifyClient::beep();
3648 return; 3648 return;
3649 } 3649 }
3650 3650
3651 editEvent(anEvent); 3651 editEvent(anEvent);
3652} 3652}
3653 3653
3654void CalendarView::appointment_delete() 3654void CalendarView::appointment_delete()
3655{ 3655{
3656 Event *anEvent = 0; 3656 Event *anEvent = 0;
3657 3657
3658 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3658 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3659 3659
3660 if (mViewManager->currentView()->isEventView()) { 3660 if (mViewManager->currentView()->isEventView()) {
3661 if ( incidence && incidence->typeID() == eventID ) { 3661 if ( incidence && incidence->typeID() == eventID ) {
3662 anEvent = static_cast<Event *>(incidence); 3662 anEvent = static_cast<Event *>(incidence);
3663 } 3663 }
3664 } 3664 }
3665 3665
3666 if (!anEvent) { 3666 if (!anEvent) {
3667 KNotifyClient::beep(); 3667 KNotifyClient::beep();
3668 return; 3668 return;
3669 } 3669 }
3670 3670
3671 deleteEvent(anEvent); 3671 deleteEvent(anEvent);
3672} 3672}
3673 3673
3674void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3674void CalendarView::todo_resub( Todo * parent, Todo * sub )
3675{ 3675{
3676 if (!sub) return; 3676 if (!sub) return;
3677 if ( sub->relatedTo() == parent ) 3677 if ( sub->relatedTo() == parent )
3678 return; 3678 return;
3679 sub->setRelatedTo(parent); 3679 sub->setRelatedTo(parent);
3680 sub->updated(); 3680 sub->updated();
3681 setModified(true); 3681 setModified(true);
3682 updateView(); 3682 updateView();
3683} 3683}
3684void CalendarView::todo_unsub(Todo *anTodo ) 3684void CalendarView::todo_unsub(Todo *anTodo )
3685{ 3685{
3686 todo_resub( 0, anTodo ); 3686 todo_resub( 0, anTodo );
3687} 3687}
3688 3688
3689void CalendarView::deleteTodo(Todo *todo) 3689void CalendarView::deleteTodo(Todo *todo)
3690{ 3690{
3691 if (!todo) { 3691 if (!todo) {
3692 KNotifyClient::beep(); 3692 KNotifyClient::beep();
3693 return; 3693 return;
3694 } 3694 }
3695 if (KOPrefs::instance()->mConfirm) { 3695 if (KOPrefs::instance()->mConfirm) {
3696 QString text = KGlobal::formatMessage ( todo->summary(),0 ); 3696 QString text = KGlobal::formatMessage ( todo->summary(),0 );
3697 if (!todo->relations().isEmpty()) { 3697 if (!todo->relations().isEmpty()) {
3698 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3698 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3699 3699
3700 } 3700 }
3701 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { 3701 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
3702 case KMessageBox::Continue: // OK 3702 case KMessageBox::Continue: // OK
3703 bool deleteT = false; 3703 bool deleteT = false;
3704 if (!todo->relations().isEmpty()) { 3704 if (!todo->relations().isEmpty()) {
3705 deleteT = removeCompletedSubTodos( todo ); 3705 deleteT = removeCompletedSubTodos( todo );
3706 } 3706 }
3707 // deleteT == true: todo already deleted in removeCompletedSubTodos 3707 // deleteT == true: todo already deleted in removeCompletedSubTodos
3708 if ( !deleteT ) { 3708 if ( !deleteT ) {
3709 checkExternalId( todo ); 3709 checkExternalId( todo );
3710 calendar()->deleteTodo(todo); 3710 calendar()->deleteTodo(todo);
3711 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3711 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3712 updateView(); 3712 updateView();
3713 } 3713 }
3714 break; 3714 break;
3715 } // switch 3715 } // switch
3716 } else { 3716 } else {
3717 checkExternalId( todo ); 3717 checkExternalId( todo );
3718 mCalendar->deleteTodo(todo); 3718 mCalendar->deleteTodo(todo);
3719 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3719 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3720 updateView(); 3720 updateView();
3721 } 3721 }
3722 3722
3723 emit updateSearchDialog(); 3723 emit updateSearchDialog();
3724} 3724}
3725void CalendarView::deleteJournal(Journal *jour) 3725void CalendarView::deleteJournal(Journal *jour)
3726{ 3726{
3727 if (!jour) { 3727 if (!jour) {
3728 KNotifyClient::beep(); 3728 KNotifyClient::beep();
3729 return; 3729 return;
3730 } 3730 }
3731 if (KOPrefs::instance()->mConfirm) { 3731 if (KOPrefs::instance()->mConfirm) {
3732 3732
3733 QString des; 3733 QString des;
3734 if ( !jour->summary().isEmpty() ) { 3734 if ( !jour->summary().isEmpty() ) {
3735 des = jour->summary(); 3735 des = jour->summary();
3736 } else { 3736 } else {
3737 des = jour->description().left(30); 3737 des = jour->description().left(30);
3738 des = des.simplifyWhiteSpace (); 3738 des = des.simplifyWhiteSpace ();
3739 des.replace (QRegExp ("\\n"),"" ); 3739 des.replace (QRegExp ("\\n"),"" );
3740 des.replace (QRegExp ("\\r"),"" ); 3740 des.replace (QRegExp ("\\r"),"" );
3741 } 3741 }
3742 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { 3742 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
3743 case KMessageBox::Continue: // OK 3743 case KMessageBox::Continue: // OK
3744 calendar()->deleteJournal(jour); 3744 calendar()->deleteJournal(jour);
3745 updateView(); 3745 updateView();
3746 break; 3746 break;
3747 } // switch 3747 } // switch
3748 } else { 3748 } else {
3749 calendar()->deleteJournal(jour);; 3749 calendar()->deleteJournal(jour);;
3750 updateView(); 3750 updateView();
3751 } 3751 }
3752 emit updateSearchDialog(); 3752 emit updateSearchDialog();
3753} 3753}
3754 3754
3755void CalendarView::deleteEvent(Event *anEvent) 3755void CalendarView::deleteEvent(Event *anEvent)
3756{ 3756{
3757 if (!anEvent) { 3757 if (!anEvent) {
3758 KNotifyClient::beep(); 3758 KNotifyClient::beep();
3759 return; 3759 return;
3760 } 3760 }
3761 3761
3762 if (anEvent->recurrence()->doesRecur()) { 3762 if (anEvent->recurrence()->doesRecur()) {
3763 QDate itemDate = mViewManager->currentSelectionDate(); 3763 QDate itemDate = mViewManager->currentSelectionDate();
3764 int km; 3764 int km;
3765 if (!itemDate.isValid()) { 3765 if (!itemDate.isValid()) {
3766 //kdDebug() << "Date Not Valid" << endl; 3766 //kdDebug() << "Date Not Valid" << endl;
3767 if (KOPrefs::instance()->mConfirm) { 3767 if (KOPrefs::instance()->mConfirm) {
3768 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3768 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3769 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3769 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3770 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3770 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3771 if ( km == KMessageBox::Continue ) 3771 if ( km == KMessageBox::Continue )
3772 km = KMessageBox::No; // No = all below 3772 km = KMessageBox::No; // No = all below
3773 } else 3773 } else
3774 km = KMessageBox::No; 3774 km = KMessageBox::No;
3775 } else { 3775 } else {
3776 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3776 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3777 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3777 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3778 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3778 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3779 i18n("KO/Pi Confirmation"),i18n("Current"), 3779 i18n("KO/Pi Confirmation"),i18n("Current"),
3780 i18n("All")); 3780 i18n("All"));
3781 } 3781 }
3782 switch(km) { 3782 switch(km) {
3783 3783
3784 case KMessageBox::No: // Continue // all 3784 case KMessageBox::No: // Continue // all
3785 //qDebug("KMessageBox::No "); 3785 //qDebug("KMessageBox::No ");
3786 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3786 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3787 schedule(Scheduler::Cancel,anEvent); 3787 schedule(Scheduler::Cancel,anEvent);
3788 3788
3789 checkExternalId( anEvent); 3789 checkExternalId( anEvent);
3790 mCalendar->deleteEvent(anEvent); 3790 mCalendar->deleteEvent(anEvent);
3791 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3791 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3792 break; 3792 break;
3793 3793
3794 // Disabled because it does not work 3794 // Disabled because it does not work
3795 //#if 0 3795 //#if 0
3796 case KMessageBox::Yes: // just this one 3796 case KMessageBox::Yes: // just this one
3797 //QDate qd = mNavigator->selectedDates().first(); 3797 //QDate qd = mNavigator->selectedDates().first();
3798 //if (!qd.isValid()) { 3798 //if (!qd.isValid()) {
3799 // kdDebug() << "no date selected, or invalid date" << endl; 3799 // kdDebug() << "no date selected, or invalid date" << endl;
3800 // KNotifyClient::beep(); 3800 // KNotifyClient::beep();
3801 // return; 3801 // return;
3802 //} 3802 //}
3803 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3803 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3804 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3804 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3805 anEvent->addExDate(itemDate); 3805 anEvent->addExDate(itemDate);
3806 int duration = anEvent->recurrence()->duration(); 3806 int duration = anEvent->recurrence()->duration();
3807 if ( duration > 0 ) { 3807 if ( duration > 0 ) {
3808 anEvent->recurrence()->setDuration( duration - 1 ); 3808 anEvent->recurrence()->setDuration( duration - 1 );
3809 } 3809 }
3810 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3810 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3811 } 3811 }
3812 break; 3812 break;
3813 //#endif 3813 //#endif
3814 } // switch 3814 } // switch
3815 } else { 3815 } else {
3816 if (KOPrefs::instance()->mConfirm) { 3816 if (KOPrefs::instance()->mConfirm) {
3817 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3817 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3818 i18n("\nAre you sure you want\nto delete this event?"), 3818 i18n("\nAre you sure you want\nto delete this event?"),
3819 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3819 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3820 case KMessageBox::Continue: // OK 3820 case KMessageBox::Continue: // OK
3821 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3821 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3822 schedule(Scheduler::Cancel,anEvent); 3822 schedule(Scheduler::Cancel,anEvent);
3823 checkExternalId( anEvent); 3823 checkExternalId( anEvent);
3824 mCalendar->deleteEvent(anEvent); 3824 mCalendar->deleteEvent(anEvent);
3825 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3825 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3826 break; 3826 break;
3827 } // switch 3827 } // switch
3828 } else { 3828 } else {
3829 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3829 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3830 schedule(Scheduler::Cancel,anEvent); 3830 schedule(Scheduler::Cancel,anEvent);
3831 checkExternalId( anEvent); 3831 checkExternalId( anEvent);
3832 mCalendar->deleteEvent(anEvent); 3832 mCalendar->deleteEvent(anEvent);
3833 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3833 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3834 } 3834 }
3835 } // if-else 3835 } // if-else
3836 emit updateSearchDialog(); 3836 emit updateSearchDialog();
3837} 3837}
3838 3838
3839bool CalendarView::deleteEvent(const QString &uid) 3839bool CalendarView::deleteEvent(const QString &uid)
3840{ 3840{
3841 Event *ev = mCalendar->event(uid); 3841 Event *ev = mCalendar->event(uid);
3842 if (ev) { 3842 if (ev) {
3843 deleteEvent(ev); 3843 deleteEvent(ev);
3844 return true; 3844 return true;
3845 } else { 3845 } else {
3846 return false; 3846 return false;
3847 } 3847 }
3848} 3848}
3849 3849
3850/*****************************************************************************/ 3850/*****************************************************************************/
3851 3851
3852void CalendarView::action_mail() 3852void CalendarView::action_mail()
3853{ 3853{
3854#ifndef KORG_NOMAIL 3854#ifndef KORG_NOMAIL
3855 KOMailClient mailClient; 3855 KOMailClient mailClient;
3856 3856
3857 Incidence *incidence = currentSelection(); 3857 Incidence *incidence = currentSelection();
3858 3858
3859 if (!incidence) { 3859 if (!incidence) {
3860 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3860 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3861 return; 3861 return;
3862 } 3862 }
3863 if(incidence->attendeeCount() == 0 ) { 3863 if(incidence->attendeeCount() == 0 ) {
3864 KMessageBox::sorry(this, 3864 KMessageBox::sorry(this,
3865 i18n("Can't generate mail:\nNo attendees defined.\n")); 3865 i18n("Can't generate mail:\nNo attendees defined.\n"));
3866 return; 3866 return;
3867 } 3867 }
3868 3868
3869 CalendarLocal cal_tmp; 3869 CalendarLocal cal_tmp;
3870 Event *event = 0; 3870 Event *event = 0;
3871 Event *ev = 0; 3871 Event *ev = 0;
3872 if ( incidence && incidence->typeID() == eventID ) { 3872 if ( incidence && incidence->typeID() == eventID ) {
3873 event = static_cast<Event *>(incidence); 3873 event = static_cast<Event *>(incidence);
3874 ev = new Event(*event); 3874 ev = new Event(*event);
3875 cal_tmp.addEvent(ev); 3875 cal_tmp.addEvent(ev);
3876 } 3876 }
3877 ICalFormat mForm(); 3877 ICalFormat mForm();
3878 QString attachment = mForm.toString( &cal_tmp ); 3878 QString attachment = mForm.toString( &cal_tmp );
3879 if (ev) delete(ev); 3879 if (ev) delete(ev);
3880 3880
3881 mailClient.mailAttendees(currentSelection(), attachment); 3881 mailClient.mailAttendees(currentSelection(), attachment);
3882 3882
3883#endif 3883#endif
3884 3884
3885#if 0 3885#if 0
3886 Event *anEvent = 0; 3886 Event *anEvent = 0;
3887 if (mViewManager->currentView()->isEventView()) { 3887 if (mViewManager->currentView()->isEventView()) {
3888 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3888 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3889 } 3889 }
3890 3890
3891 if (!anEvent) { 3891 if (!anEvent) {
3892 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3892 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3893 return; 3893 return;
3894 } 3894 }
3895 if(anEvent->attendeeCount() == 0 ) { 3895 if(anEvent->attendeeCount() == 0 ) {
3896 KMessageBox::sorry(this, 3896 KMessageBox::sorry(this,
3897 i18n("Can't generate mail:\nNo attendees defined.\n")); 3897 i18n("Can't generate mail:\nNo attendees defined.\n"));
3898 return; 3898 return;
3899 } 3899 }
3900 3900
3901 mailobject.emailEvent(anEvent); 3901 mailobject.emailEvent(anEvent);
3902#endif 3902#endif
3903} 3903}
3904 3904
3905 3905
3906void CalendarView::schedule_publish(Incidence *incidence) 3906void CalendarView::schedule_publish(Incidence *incidence)
3907{ 3907{
3908 Event *event = 0; 3908 Event *event = 0;
3909 Todo *todo = 0; 3909 Todo *todo = 0;
3910 3910
3911 if (incidence == 0) { 3911 if (incidence == 0) {
3912 incidence = mViewManager->currentView()->selectedIncidences().first(); 3912 incidence = mViewManager->currentView()->selectedIncidences().first();
3913 if (incidence == 0) { 3913 if (incidence == 0) {
3914 incidence = mTodoList->selectedIncidences().first(); 3914 incidence = mTodoList->selectedIncidences().first();
3915 } 3915 }
3916 } 3916 }
3917 if ( incidence && incidence->typeID() == eventID ) { 3917 if ( incidence && incidence->typeID() == eventID ) {
3918 event = static_cast<Event *>(incidence); 3918 event = static_cast<Event *>(incidence);
3919 } else { 3919 } else {
3920 if ( incidence && incidence->typeID() == todoID ) { 3920 if ( incidence && incidence->typeID() == todoID ) {
3921 todo = static_cast<Todo *>(incidence); 3921 todo = static_cast<Todo *>(incidence);
3922 } 3922 }
3923 } 3923 }
3924 3924
3925 if (!event && !todo) { 3925 if (!event && !todo) {
3926 KMessageBox::sorry(this,i18n("No event selected.")); 3926 KMessageBox::sorry(this,i18n("No event selected."));
3927 return; 3927 return;
3928 } 3928 }
3929 3929
3930 PublishDialog *publishdlg = new PublishDialog(); 3930 PublishDialog *publishdlg = new PublishDialog();
3931 if (incidence->attendeeCount()>0) { 3931 if (incidence->attendeeCount()>0) {
3932 QPtrList<Attendee> attendees = incidence->attendees(); 3932 QPtrList<Attendee> attendees = incidence->attendees();
3933 attendees.first(); 3933 attendees.first();
3934 while ( attendees.current()!=0 ) { 3934 while ( attendees.current()!=0 ) {
3935 publishdlg->addAttendee(attendees.current()); 3935 publishdlg->addAttendee(attendees.current());
3936 attendees.next(); 3936 attendees.next();
3937 } 3937 }
3938 } 3938 }
3939 bool send = true; 3939 bool send = true;
3940 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3940 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3941 if ( publishdlg->exec() != QDialog::Accepted ) 3941 if ( publishdlg->exec() != QDialog::Accepted )
3942 send = false; 3942 send = false;
3943 } 3943 }
3944 if ( send ) { 3944 if ( send ) {
3945 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3945 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3946 if ( event ) { 3946 if ( event ) {
3947 Event *ev = new Event(*event); 3947 Event *ev = new Event(*event);
3948 ev->registerObserver(0); 3948 ev->registerObserver(0);
3949 ev->clearAttendees(); 3949 ev->clearAttendees();
3950 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3950 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3951 delete(ev); 3951 delete(ev);
3952 } 3952 }
3953 } else { 3953 } else {
3954 if ( todo ) { 3954 if ( todo ) {
3955 Todo *ev = new Todo(*todo); 3955 Todo *ev = new Todo(*todo);
3956 ev->registerObserver(0); 3956 ev->registerObserver(0);
3957 ev->clearAttendees(); 3957 ev->clearAttendees();
3958 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3958 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3959 delete(ev); 3959 delete(ev);
3960 } 3960 }
3961 } 3961 }
3962 } 3962 }
3963 } 3963 }
3964 delete publishdlg; 3964 delete publishdlg;
3965} 3965}
3966 3966
3967void CalendarView::schedule_request(Incidence *incidence) 3967void CalendarView::schedule_request(Incidence *incidence)
3968{ 3968{
3969 schedule(Scheduler::Request,incidence); 3969 schedule(Scheduler::Request,incidence);
3970} 3970}
3971 3971
3972void CalendarView::schedule_refresh(Incidence *incidence) 3972void CalendarView::schedule_refresh(Incidence *incidence)
3973{ 3973{
3974 schedule(Scheduler::Refresh,incidence); 3974 schedule(Scheduler::Refresh,incidence);
3975} 3975}
3976 3976
3977void CalendarView::schedule_cancel(Incidence *incidence) 3977void CalendarView::schedule_cancel(Incidence *incidence)
3978{ 3978{
3979 schedule(Scheduler::Cancel,incidence); 3979 schedule(Scheduler::Cancel,incidence);
3980} 3980}
3981 3981
3982void CalendarView::schedule_add(Incidence *incidence) 3982void CalendarView::schedule_add(Incidence *incidence)
3983{ 3983{
3984 schedule(Scheduler::Add,incidence); 3984 schedule(Scheduler::Add,incidence);
3985} 3985}
3986 3986
3987void CalendarView::schedule_reply(Incidence *incidence) 3987void CalendarView::schedule_reply(Incidence *incidence)
3988{ 3988{
3989 schedule(Scheduler::Reply,incidence); 3989 schedule(Scheduler::Reply,incidence);
3990} 3990}
3991 3991
3992void CalendarView::schedule_counter(Incidence *incidence) 3992void CalendarView::schedule_counter(Incidence *incidence)
3993{ 3993{
3994 schedule(Scheduler::Counter,incidence); 3994 schedule(Scheduler::Counter,incidence);
3995} 3995}
3996 3996
3997void CalendarView::schedule_declinecounter(Incidence *incidence) 3997void CalendarView::schedule_declinecounter(Incidence *incidence)
3998{ 3998{
3999 schedule(Scheduler::Declinecounter,incidence); 3999 schedule(Scheduler::Declinecounter,incidence);
4000} 4000}
4001 4001
4002void CalendarView::schedule_publish_freebusy(int daysToPublish) 4002void CalendarView::schedule_publish_freebusy(int daysToPublish)
4003{ 4003{
4004 QDateTime start = QDateTime::currentDateTime(); 4004 QDateTime start = QDateTime::currentDateTime();
4005 QDateTime end = start.addDays(daysToPublish); 4005 QDateTime end = start.addDays(daysToPublish);
4006 4006
4007 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 4007 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
4008 freebusy->setOrganizer(KOPrefs::instance()->email()); 4008 freebusy->setOrganizer(KOPrefs::instance()->email());
4009 4009
4010 4010
4011 PublishDialog *publishdlg = new PublishDialog(); 4011 PublishDialog *publishdlg = new PublishDialog();
4012 if ( publishdlg->exec() == QDialog::Accepted ) { 4012 if ( publishdlg->exec() == QDialog::Accepted ) {
4013 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4013 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4014 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 4014 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
4015 delete(freebusy); 4015 delete(freebusy);
4016 } 4016 }
4017 } 4017 }
4018 delete publishdlg; 4018 delete publishdlg;
4019} 4019}
4020 4020
4021void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 4021void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
4022{ 4022{
4023 Event *event = 0; 4023 Event *event = 0;
4024 Todo *todo = 0; 4024 Todo *todo = 0;
4025 4025
4026 if (incidence == 0) { 4026 if (incidence == 0) {
4027 incidence = mViewManager->currentView()->selectedIncidences().first(); 4027 incidence = mViewManager->currentView()->selectedIncidences().first();
4028 if (incidence == 0) { 4028 if (incidence == 0) {
4029 incidence = mTodoList->selectedIncidences().first(); 4029 incidence = mTodoList->selectedIncidences().first();
4030 } 4030 }
4031 } 4031 }
4032 if ( incidence && incidence->typeID() == eventID ) { 4032 if ( incidence && incidence->typeID() == eventID ) {
4033 event = static_cast<Event *>(incidence); 4033 event = static_cast<Event *>(incidence);
4034 } 4034 }
4035 if ( incidence && incidence->typeID() == todoID ) { 4035 if ( incidence && incidence->typeID() == todoID ) {
4036 todo = static_cast<Todo *>(incidence); 4036 todo = static_cast<Todo *>(incidence);
4037 } 4037 }
4038 4038
4039 if (!event && !todo) { 4039 if (!event && !todo) {
4040 KMessageBox::sorry(this,i18n("No event selected.")); 4040 KMessageBox::sorry(this,i18n("No event selected."));
4041 return; 4041 return;
4042 } 4042 }
4043 4043
4044 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 4044 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
4045 KMessageBox::sorry(this,i18n("The event has no attendees.")); 4045 KMessageBox::sorry(this,i18n("The event has no attendees."));
4046 return; 4046 return;
4047 } 4047 }
4048 4048
4049 Event *ev = 0; 4049 Event *ev = 0;
4050 if (event) ev = new Event(*event); 4050 if (event) ev = new Event(*event);
4051 Todo *to = 0; 4051 Todo *to = 0;
4052 if (todo) to = new Todo(*todo); 4052 if (todo) to = new Todo(*todo);
4053 4053
4054 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4054 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4055 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4055 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4056 if (!me) { 4056 if (!me) {
4057 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4057 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4058 return; 4058 return;
4059 } 4059 }
4060 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4060 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4061 StatusDialog *statdlg = new StatusDialog(this); 4061 StatusDialog *statdlg = new StatusDialog(this);
4062 if (!statdlg->exec()==QDialog::Accepted) return; 4062 if (!statdlg->exec()==QDialog::Accepted) return;
4063 me->setStatus( statdlg->status() ); 4063 me->setStatus( statdlg->status() );
4064 delete(statdlg); 4064 delete(statdlg);
4065 } 4065 }
4066 Attendee *menew = new Attendee(*me); 4066 Attendee *menew = new Attendee(*me);
4067 if (ev) { 4067 if (ev) {
4068 ev->clearAttendees(); 4068 ev->clearAttendees();
4069 ev->addAttendee(menew,false); 4069 ev->addAttendee(menew,false);
4070 } else { 4070 } else {
4071 if (to) { 4071 if (to) {
4072 todo->clearAttendees(); 4072 todo->clearAttendees();
4073 todo->addAttendee(menew,false); 4073 todo->addAttendee(menew,false);
4074 } 4074 }
4075 } 4075 }
4076 } 4076 }
4077 4077
4078 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4078 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4079 if (ev) { 4079 if (ev) {
4080 if ( !dlg->addMessage(ev,method) ) delete(ev); 4080 if ( !dlg->addMessage(ev,method) ) delete(ev);
4081 } else { 4081 } else {
4082 if (to) { 4082 if (to) {
4083 if ( !dlg->addMessage(to,method) ) delete(to); 4083 if ( !dlg->addMessage(to,method) ) delete(to);
4084 } 4084 }
4085 } 4085 }
4086} 4086}
4087 4087
4088void CalendarView::openAddressbook() 4088void CalendarView::openAddressbook()
4089{ 4089{
4090 KRun::runCommand("kaddressbook"); 4090 KRun::runCommand("kaddressbook");
4091} 4091}
4092 4092
4093void CalendarView::setModified(bool modified) 4093void CalendarView::setModified(bool modified)
4094{ 4094{
4095 //qDebug("CalendarView::setModified %d ", modified);
4095 if ( modified ) 4096 if ( modified )
4096 emit signalmodified(); 4097 emit signalmodified();
4097 if (mModified != modified) { 4098 mModified = modified;
4098 mModified = modified; 4099 if ( mModified )
4099 emit modifiedChanged(mModified); 4100 emit modifiedChanged(mModified);
4100 } 4101
4101} 4102}
4102 4103
4103bool CalendarView::isReadOnly() 4104bool CalendarView::isReadOnly()
4104{ 4105{
4105 return mReadOnly; 4106 return mReadOnly;
4106} 4107}
4107 4108
4108void CalendarView::setReadOnly(bool readOnly) 4109void CalendarView::setReadOnly(bool readOnly)
4109{ 4110{
4110 if (mReadOnly != readOnly) { 4111 if (mReadOnly != readOnly) {
4111 mReadOnly = readOnly; 4112 mReadOnly = readOnly;
4112 emit readOnlyChanged(mReadOnly); 4113 emit readOnlyChanged(mReadOnly);
4113 } 4114 }
4114} 4115}
4115 4116
4116bool CalendarView::isModified() 4117bool CalendarView::isModified()
4117{ 4118{
4118 return mModified; 4119 return mModified;
4119} 4120}
4120void CalendarView::slotprintSelInc() 4121void CalendarView::slotprintSelInc()
4121{ 4122{
4122 if ( currentSelection() == 0 ) { 4123 if ( currentSelection() == 0 ) {
4123 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4124 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4124 return; 4125 return;
4125 } 4126 }
4126 showIncidence(); 4127 showIncidence();
4127 getEventViewerDialog()->print(); 4128 getEventViewerDialog()->print();
4128 4129
4129} 4130}
4130void CalendarView::printSetup() 4131void CalendarView::printSetup()
4131{ 4132{
4132#ifndef KORG_NOPRINTER 4133#ifndef KORG_NOPRINTER
4133 createPrinter(); 4134 createPrinter();
4134 4135
4135 mCalPrinter->setupPrinter(); 4136 mCalPrinter->setupPrinter();
4136#endif 4137#endif
4137} 4138}
4138 4139
4139void CalendarView::print() 4140void CalendarView::print()
4140{ 4141{
4141#ifndef KORG_NOPRINTER 4142#ifndef KORG_NOPRINTER
4142 createPrinter(); 4143 createPrinter();
4143 4144
4144 DateList tmpDateList = mNavigator->selectedDates(); 4145 DateList tmpDateList = mNavigator->selectedDates();
4145 mCalPrinter->print(CalPrinter::Month, 4146 mCalPrinter->print(CalPrinter::Month,
4146 tmpDateList.first(), tmpDateList.last()); 4147 tmpDateList.first(), tmpDateList.last());
4147#endif 4148#endif
4148} 4149}
4149 4150
4150void CalendarView::printPreview() 4151void CalendarView::printPreview()
4151{ 4152{
4152#ifndef KORG_NOPRINTER 4153#ifndef KORG_NOPRINTER
4153 kdDebug() << "CalendarView::printPreview()" << endl; 4154 kdDebug() << "CalendarView::printPreview()" << endl;
4154 4155
4155 createPrinter(); 4156 createPrinter();
4156 4157
4157 DateList tmpDateList = mNavigator->selectedDates(); 4158 DateList tmpDateList = mNavigator->selectedDates();
4158 4159
4159 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 4160 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
4160 tmpDateList.last()); 4161 tmpDateList.last());
4161#endif 4162#endif
4162} 4163}
4163 4164
4164void CalendarView::exportICalendar() 4165void CalendarView::exportICalendar()
4165{ 4166{
4166 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 4167 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
4167 4168
4168 // Force correct extension 4169 // Force correct extension
4169 if (filename.right(4) != ".ics") filename += ".ics"; 4170 if (filename.right(4) != ".ics") filename += ".ics";
4170 4171
4171 FileStorage storage( mCalendar, filename, new ICalFormat() ); 4172 FileStorage storage( mCalendar, filename, new ICalFormat() );
4172 storage.save(); 4173 storage.save();
4173} 4174}
4174 4175
4175bool CalendarView::exportVCalendar( QString filename ) 4176bool CalendarView::exportVCalendar( QString filename )
4176{ 4177{
4177 if (mCalendar->journals().count() > 0) { 4178 if (mCalendar->journals().count() > 0) {
4178 int result = KMessageBox::warningContinueCancel(this, 4179 int result = KMessageBox::warningContinueCancel(this,
4179 i18n("The journal entries can not be\nexported to a vCalendar file."), 4180 i18n("The journal entries can not be\nexported to a vCalendar file."),
4180 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 4181 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
4181 true); 4182 true);
4182 if (result != KMessageBox::Continue) return false; 4183 if (result != KMessageBox::Continue) return false;
4183 } 4184 }
4184 4185
4185 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 4186 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
4186 4187
4187 // Force correct extension 4188 // Force correct extension
4188 if (filename.right(4) != ".vcs") filename += ".vcs"; 4189 if (filename.right(4) != ".vcs") filename += ".vcs";
4189 4190
4190 FileStorage storage( mCalendar, filename, new VCalFormat ); 4191 FileStorage storage( mCalendar, filename, new VCalFormat );
4191 return storage.save(); 4192 return storage.save();
4192 4193
4193} 4194}
4194 4195
4195void CalendarView::eventUpdated(Incidence *) 4196void CalendarView::eventUpdated(Incidence *)
4196{ 4197{
4197 setModified(); 4198 setModified();
4198 // Don't call updateView here. The code, which has caused the update of the 4199 // Don't call updateView here. The code, which has caused the update of the
4199 // event is responsible for updating the view. 4200 // event is responsible for updating the view.
4200 // updateView(); 4201 // updateView();
4201} 4202}
4202 4203
4203void CalendarView::adaptNavigationUnits() 4204void CalendarView::adaptNavigationUnits()
4204{ 4205{
4205 if (mViewManager->currentView()->isEventView()) { 4206 if (mViewManager->currentView()->isEventView()) {
4206 int days = mViewManager->currentView()->currentDateCount(); 4207 int days = mViewManager->currentView()->currentDateCount();
4207 if (days == 1) { 4208 if (days == 1) {
4208 emit changeNavStringPrev(i18n("&Previous Day")); 4209 emit changeNavStringPrev(i18n("&Previous Day"));
4209 emit changeNavStringNext(i18n("&Next Day")); 4210 emit changeNavStringNext(i18n("&Next Day"));
4210 } else { 4211 } else {
4211 emit changeNavStringPrev(i18n("&Previous Week")); 4212 emit changeNavStringPrev(i18n("&Previous Week"));
4212 emit changeNavStringNext(i18n("&Next Week")); 4213 emit changeNavStringNext(i18n("&Next Week"));
4213 } 4214 }
4214 } 4215 }
4215} 4216}
4216 4217
4217void CalendarView::processMainViewSelection( Incidence *incidence ) 4218void CalendarView::processMainViewSelection( Incidence *incidence )
4218{ 4219{
4219 if ( incidence ) mTodoList->clearSelection(); 4220 if ( incidence ) mTodoList->clearSelection();
4220 processIncidenceSelection( incidence ); 4221 processIncidenceSelection( incidence );
4221} 4222}
4222 4223
4223void CalendarView::processTodoListSelection( Incidence *incidence ) 4224void CalendarView::processTodoListSelection( Incidence *incidence )
4224{ 4225{
4225 if ( incidence && mViewManager->currentView() ) { 4226 if ( incidence && mViewManager->currentView() ) {
4226 mViewManager->currentView()->clearSelection(); 4227 mViewManager->currentView()->clearSelection();
4227 } 4228 }
4228 processIncidenceSelection( incidence ); 4229 processIncidenceSelection( incidence );
4229} 4230}
4230 4231
4231void CalendarView::processIncidenceSelection( Incidence *incidence ) 4232void CalendarView::processIncidenceSelection( Incidence *incidence )
4232{ 4233{
4233 emit incidenceSelected( incidence ); 4234 emit incidenceSelected( incidence );
4234 if ( incidence == mSelectedIncidence ) return; 4235 if ( incidence == mSelectedIncidence ) return;
4235 mSelectedIncidence = incidence; 4236 mSelectedIncidence = incidence;
4236 4237
4237 if ( incidence && incidence->typeID() == eventID ) { 4238 if ( incidence && incidence->typeID() == eventID ) {
4238 Event *event = static_cast<Event *>( incidence ); 4239 Event *event = static_cast<Event *>( incidence );
4239 if ( event->organizer() == KOPrefs::instance()->email() ) { 4240 if ( event->organizer() == KOPrefs::instance()->email() ) {
4240 emit organizerEventsSelected( true ); 4241 emit organizerEventsSelected( true );
4241 } else { 4242 } else {
4242 emit organizerEventsSelected(false); 4243 emit organizerEventsSelected(false);
4243 } 4244 }
4244 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4245 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4245 KOPrefs::instance()->email() ) ) { 4246 KOPrefs::instance()->email() ) ) {
4246 emit groupEventsSelected( true ); 4247 emit groupEventsSelected( true );
4247 } else { 4248 } else {
4248 emit groupEventsSelected(false); 4249 emit groupEventsSelected(false);
4249 } 4250 }
4250 return; 4251 return;
4251 } else { 4252 } else {
4252 if ( incidence && incidence->typeID() == todoID ) { 4253 if ( incidence && incidence->typeID() == todoID ) {
4253 emit todoSelected( true ); 4254 emit todoSelected( true );
4254 Todo *event = static_cast<Todo *>( incidence ); 4255 Todo *event = static_cast<Todo *>( incidence );
4255 if ( event->organizer() == KOPrefs::instance()->email() ) { 4256 if ( event->organizer() == KOPrefs::instance()->email() ) {
4256 emit organizerEventsSelected( true ); 4257 emit organizerEventsSelected( true );
4257 } else { 4258 } else {
4258 emit organizerEventsSelected(false); 4259 emit organizerEventsSelected(false);
4259 } 4260 }
4260 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4261 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4261 KOPrefs::instance()->email() ) ) { 4262 KOPrefs::instance()->email() ) ) {
4262 emit groupEventsSelected( true ); 4263 emit groupEventsSelected( true );
4263 } else { 4264 } else {
4264 emit groupEventsSelected(false); 4265 emit groupEventsSelected(false);
4265 } 4266 }
4266 return; 4267 return;
4267 } else { 4268 } else {
4268 emit todoSelected( false ); 4269 emit todoSelected( false );
4269 emit organizerEventsSelected(false); 4270 emit organizerEventsSelected(false);
4270 emit groupEventsSelected(false); 4271 emit groupEventsSelected(false);
4271 } 4272 }
4272 return; 4273 return;
4273 } 4274 }
4274 4275
4275 /* if ( incidence && incidence->typeID() == todoID ) { 4276 /* if ( incidence && incidence->typeID() == todoID ) {
4276 emit todoSelected( true ); 4277 emit todoSelected( true );
4277 } else { 4278 } else {
4278 emit todoSelected( false ); 4279 emit todoSelected( false );
4279 }*/ 4280 }*/
4280} 4281}
4281 4282
4282 4283
4283void CalendarView::checkClipboard() 4284void CalendarView::checkClipboard()
4284{ 4285{
4285#ifndef KORG_NODND 4286#ifndef KORG_NODND
4286 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4287 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4287 emit pasteEnabled(true); 4288 emit pasteEnabled(true);
4288 } else { 4289 } else {
4289 emit pasteEnabled(false); 4290 emit pasteEnabled(false);
4290 } 4291 }
4291#endif 4292#endif
4292} 4293}
4293 4294
4294void CalendarView::showDates(const DateList &selectedDates) 4295void CalendarView::showDates(const DateList &selectedDates)
4295{ 4296{
4296 // kdDebug() << "CalendarView::selectDates()" << endl; 4297 // kdDebug() << "CalendarView::selectDates()" << endl;
4297 4298
4298 4299
4299 if ( !mBlockShowDates ) { 4300 if ( !mBlockShowDates ) {
4300 if ( mViewManager->currentView() ) { 4301 if ( mViewManager->currentView() ) {
4301 updateView( selectedDates.first(), selectedDates.last() ); 4302 updateView( selectedDates.first(), selectedDates.last() );
4302 } else { 4303 } else {
4303 mViewManager->showAgendaView(); 4304 mViewManager->showAgendaView();
4304 } 4305 }
4305 } 4306 }
4306 4307
4307 QDate date = selectedDates.first(); 4308 QDate date = selectedDates.first();
4308 if ( ! date.isValid() ) { 4309 if ( ! date.isValid() ) {
4309 topLevelWidget()->setCaption(""); 4310 topLevelWidget()->setCaption("");
4310 return; 4311 return;
4311 } 4312 }
4312 4313
4313 QString selDates; 4314 QString selDates;
4314 selDates = KGlobal::locale()->formatDate( date, true); 4315 selDates = KGlobal::locale()->formatDate( date, true);
4315 if (selectedDates.first() < selectedDates.last() ) 4316 if (selectedDates.first() < selectedDates.last() )
4316 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4317 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4317 else { 4318 else {
4318 QString addString; 4319 QString addString;
4319 if ( date == QDateTime::currentDateTime().date() ) 4320 if ( date == QDateTime::currentDateTime().date() )
4320 addString = i18n("Today"); 4321 addString = i18n("Today");
4321 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4322 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4322 addString = i18n("Tomorrow"); 4323 addString = i18n("Tomorrow");
4323 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4324 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4324 addString = i18n("Yesterday"); 4325 addString = i18n("Yesterday");
4325 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4326 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4326 addString = i18n("Day before yesterday"); 4327 addString = i18n("Day before yesterday");
4327 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4328 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4328 addString = i18n("Day after tomorrow"); 4329 addString = i18n("Day after tomorrow");
4329 if ( !addString.isEmpty() ) { 4330 if ( !addString.isEmpty() ) {
4330 topLevelWidget()->setCaption( addString+", " + selDates ); 4331 topLevelWidget()->setCaption( addString+", " + selDates );
4331 return; 4332 return;
4332 } 4333 }
4333 } 4334 }
4334 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4335 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4335 4336
4336} 4337}
4337 4338
4338QPtrList<CalFilter> CalendarView::filters() 4339QPtrList<CalFilter> CalendarView::filters()
4339{ 4340{
4340 return mFilters; 4341 return mFilters;
4341 4342
4342} 4343}
4343void CalendarView::editFilters() 4344void CalendarView::editFilters()
4344{ 4345{
4345 // kdDebug() << "CalendarView::editFilters()" << endl; 4346 // kdDebug() << "CalendarView::editFilters()" << endl;
4346 4347
4347 CalFilter *filter = mFilters.first(); 4348 CalFilter *filter = mFilters.first();
4348 while(filter) { 4349 while(filter) {
4349 filter = mFilters.next(); 4350 filter = mFilters.next();
4350 } 4351 }
4351 4352
4352 mDialogManager->showFilterEditDialog(&mFilters); 4353 mDialogManager->showFilterEditDialog(&mFilters);
4353 updateFilter(); 4354 updateFilter();
4354} 4355}
4355void CalendarView::toggleFilter() 4356void CalendarView::toggleFilter()
4356{ 4357{
4357 if ( mLeftFrame->isHidden() ) { 4358 if ( mLeftFrame->isHidden() ) {
4358 toggleExpand(); 4359 toggleExpand();
4359 showFilter( true ); 4360 showFilter( true );
4360 } else 4361 } else
4361 showFilter(! mCalEditView->isVisible()); 4362 showFilter(! mCalEditView->isVisible());
4362} 4363}
4363 4364
4364KOFilterView *CalendarView::filterView() 4365KOFilterView *CalendarView::filterView()
4365{ 4366{
4366 return mFilterView; 4367 return mFilterView;
4367} 4368}
4368void CalendarView::selectFilter( int fil ) 4369void CalendarView::selectFilter( int fil )
4369{ 4370{
4370 mFilterView->setSelectedFilter( fil ); 4371 mFilterView->setSelectedFilter( fil );
4371 updateUnmanagedViews(); 4372 updateUnmanagedViews();
4372} 4373}
4373void CalendarView::showFilter(bool visible) 4374void CalendarView::showFilter(bool visible)
4374{ 4375{
4375#if 1 4376#if 1
4376 if (visible) { 4377 if (visible) {
4377 mCalEditView->readConfig(); 4378 mCalEditView->readConfig();
4378 mCalEditView->show(); 4379 mCalEditView->show();
4379 QValueList<int> sizes; 4380 QValueList<int> sizes;
4380 sizes = mLeftFrame->sizes(); 4381 sizes = mLeftFrame->sizes();
4381 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4382 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4382 sizes.clear(); 4383 sizes.clear();
4383 sizes << 100; 4384 sizes << 100;
4384 sizes << 0; 4385 sizes << 0;
4385 sizes << 0; 4386 sizes << 0;
4386 sizes << 100; 4387 sizes << 100;
4387 mLeftFrame->setSizes(sizes); 4388 mLeftFrame->setSizes(sizes);
4388 } 4389 }
4389#if 0 4390#if 0
4390 sizes = mLeftFrame->sizes(); 4391 sizes = mLeftFrame->sizes();
4391 int ccc = 0; 4392 int ccc = 0;
4392 while ( ccc < sizes.count()) { 4393 while ( ccc < sizes.count()) {
4393 qDebug("size %d %d ", ccc, sizes[ccc]); 4394 qDebug("size %d %d ", ccc, sizes[ccc]);
4394 ++ccc; 4395 ++ccc;
4395 } 4396 }
4396#endif 4397#endif
4397 4398
4398 } 4399 }
4399 else { 4400 else {
4400 mCalEditView->hide(); 4401 mCalEditView->hide();
4401 } 4402 }
4402#else 4403#else
4403 if (visible) mFilterView->show(); 4404 if (visible) mFilterView->show();
4404 else mFilterView->hide(); 4405 else mFilterView->hide();
4405#endif 4406#endif
4406} 4407}
4407void CalendarView::toggleFilerEnabled( ) 4408void CalendarView::toggleFilerEnabled( )
4408{ 4409{
4409 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4410 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4410 if ( !mFilterView->filtersEnabled() ) 4411 if ( !mFilterView->filtersEnabled() )
4411 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4412 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4412 updateUnmanagedViews(); 4413 updateUnmanagedViews();
4413 4414
4414} 4415}
4415void CalendarView::updateFilter() 4416void CalendarView::updateFilter()
4416{ 4417{
4417 CalFilter *filter = mFilterView->selectedFilter(); 4418 CalFilter *filter = mFilterView->selectedFilter();
4418 if (filter) { 4419 if (filter) {
4419 QString mess; 4420 QString mess;
4420 if (mFilterView->filtersEnabled()) { 4421 if (mFilterView->filtersEnabled()) {
4421 mess = i18n("Filter selected: ")+filter->name(); 4422 mess = i18n("Filter selected: ")+filter->name();
4422 filter->setEnabled(true); 4423 filter->setEnabled(true);
4423 } 4424 }
4424 else filter->setEnabled(false); 4425 else filter->setEnabled(false);
4425 mCalendar->setFilter(filter); 4426 mCalendar->setFilter(filter);
4426 updateView(); 4427 updateView();
4427 if ( !mess.isEmpty() ) 4428 if ( !mess.isEmpty() )
4428 topLevelWidget()->setCaption( mess ); 4429 topLevelWidget()->setCaption( mess );
4429 4430
4430 } 4431 }
4431 emit filtersUpdated(); 4432 emit filtersUpdated();
4432} 4433}
4433 4434
4434void CalendarView::filterEdited() 4435void CalendarView::filterEdited()
4435{ 4436{
4436 mFilterView->updateFilters(); 4437 mFilterView->updateFilters();
4437 updateFilter(); 4438 updateFilter();
4438 writeSettings(); 4439 writeSettings();
4439} 4440}
4440 4441
4441 4442
4442void CalendarView::takeOverEvent() 4443void CalendarView::takeOverEvent()
4443{ 4444{
4444 Incidence *incidence = currentSelection(); 4445 Incidence *incidence = currentSelection();
4445 4446
4446 if (!incidence) return; 4447 if (!incidence) return;
4447 4448
4448 incidence->setOrganizer(KOPrefs::instance()->email()); 4449 incidence->setOrganizer(KOPrefs::instance()->email());
4449 incidence->recreate(); 4450 incidence->recreate();
4450 incidence->setReadOnly(false); 4451 incidence->setReadOnly(false);
4451 4452
4452 updateView(); 4453 updateView();
4453} 4454}
4454 4455
4455void CalendarView::takeOverCalendar() 4456void CalendarView::takeOverCalendar()
4456{ 4457{
4457 // TODO: Create Calendar::allIncidences() function and use it here 4458 // TODO: Create Calendar::allIncidences() function and use it here
4458 4459
4459 clearAllViews(); 4460 clearAllViews();
4460 QPtrList<Event> events = mCalendar->events(); 4461 QPtrList<Event> events = mCalendar->events();
4461 for(uint i=0; i<events.count(); ++i) { 4462 for(uint i=0; i<events.count(); ++i) {
4462 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4463 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4463 events.at(i)->recreate(); 4464 events.at(i)->recreate();
4464 events.at(i)->setReadOnly(false); 4465 events.at(i)->setReadOnly(false);
4465 } 4466 }
4466 4467
4467 QPtrList<Todo> todos = mCalendar->todos(); 4468 QPtrList<Todo> todos = mCalendar->todos();
4468 for(uint i=0; i<todos.count(); ++i) { 4469 for(uint i=0; i<todos.count(); ++i) {
4469 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4470 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4470 todos.at(i)->recreate(); 4471 todos.at(i)->recreate();
4471 todos.at(i)->setReadOnly(false); 4472 todos.at(i)->setReadOnly(false);
4472 } 4473 }
4473 4474
4474 QPtrList<Journal> journals = mCalendar->journals(); 4475 QPtrList<Journal> journals = mCalendar->journals();
4475 for(uint i=0; i<journals.count(); ++i) { 4476 for(uint i=0; i<journals.count(); ++i) {
4476 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4477 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4477 journals.at(i)->recreate(); 4478 journals.at(i)->recreate();
4478 journals.at(i)->setReadOnly(false); 4479 journals.at(i)->setReadOnly(false);
4479 } 4480 }
4480 4481
4481 updateView(); 4482 updateView();
4482} 4483}
4483 4484
4484void CalendarView::showIntro() 4485void CalendarView::showIntro()
4485{ 4486{
4486 kdDebug() << "To be implemented." << endl; 4487 kdDebug() << "To be implemented." << endl;
4487} 4488}
4488 4489
4489QWidgetStack *CalendarView::viewStack() 4490QWidgetStack *CalendarView::viewStack()
4490{ 4491{
4491 return mRightFrame; 4492 return mRightFrame;
4492} 4493}
4493 4494
4494QWidget *CalendarView::leftFrame() 4495QWidget *CalendarView::leftFrame()
4495{ 4496{
4496 return ( QWidget *)mLeftFrame; 4497 return ( QWidget *)mLeftFrame;
4497} 4498}
4498 4499
4499DateNavigator *CalendarView::dateNavigator() 4500DateNavigator *CalendarView::dateNavigator()
4500{ 4501{
4501 return mNavigator; 4502 return mNavigator;
4502} 4503}
4503 4504
4504KDateNavigator* CalendarView::dateNavigatorWidget() 4505KDateNavigator* CalendarView::dateNavigatorWidget()
4505{ 4506{
4506 return mDateNavigator->navigatorView(); 4507 return mDateNavigator->navigatorView();
4507} 4508}
4508void CalendarView::toggleDateNavigatorWidget() 4509void CalendarView::toggleDateNavigatorWidget()
4509{ 4510{
4510 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4511 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4511 4512
4512 if (!KOPrefs::instance()->mShowDateNavigator ) 4513 if (!KOPrefs::instance()->mShowDateNavigator )
4513 mDateNavigator->hide(); 4514 mDateNavigator->hide();
4514 else 4515 else
4515 mDateNavigator->show(); 4516 mDateNavigator->show();
4516} 4517}
4517void CalendarView::addView(KOrg::BaseView *view) 4518void CalendarView::addView(KOrg::BaseView *view)
4518{ 4519{
4519 mViewManager->addView(view); 4520 mViewManager->addView(view);
4520} 4521}
4521 4522
4522void CalendarView::showView(KOrg::BaseView *view) 4523void CalendarView::showView(KOrg::BaseView *view)
4523{ 4524{
4524 mViewManager->showView(view, mLeftFrame->isVisible()); 4525 mViewManager->showView(view, mLeftFrame->isVisible());
4525} 4526}
4526 4527
4527Incidence *CalendarView::currentSelection() 4528Incidence *CalendarView::currentSelection()
4528{ 4529{
4529 return mViewManager->currentSelection(); 4530 return mViewManager->currentSelection();
4530} 4531}
4531void CalendarView::toggleAllDaySize() 4532void CalendarView::toggleAllDaySize()
4532{ 4533{
4533 /* 4534 /*
4534 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4535 if ( KOPrefs::instance()->mAllDaySize > 47 )
4535 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4536 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4536 else 4537 else
4537 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4538 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4538 */ 4539 */
4539 viewManager()->agendaView()->toggleAllDay(); 4540 viewManager()->agendaView()->toggleAllDay();
4540} 4541}
4541void CalendarView::toggleExpand() 4542void CalendarView::toggleExpand()
4542{ 4543{
4543 // if ( mLeftFrame->isHidden() ) { 4544 // if ( mLeftFrame->isHidden() ) {
4544 // mLeftFrame->show(); 4545 // mLeftFrame->show();
4545 // emit calendarViewExpanded( false ); 4546 // emit calendarViewExpanded( false );
4546 // } else { 4547 // } else {
4547 // mLeftFrame->hide(); 4548 // mLeftFrame->hide();
4548 // emit calendarViewExpanded( true ); 4549 // emit calendarViewExpanded( true );
4549 // } 4550 // }
4550 //qDebug(" CalendarView::toggleExpand()"); 4551 //qDebug(" CalendarView::toggleExpand()");
4551 globalFlagBlockAgenda = 1; 4552 globalFlagBlockAgenda = 1;
4552 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4553 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4553 globalFlagBlockAgenda = 5; 4554 globalFlagBlockAgenda = 5;
4554 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4555 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4555 //mViewManager->showView( 0, true ); 4556 //mViewManager->showView( 0, true );
4556} 4557}
4557 4558
4558void CalendarView::calendarModified( bool modified, Calendar * ) 4559void CalendarView::calendarModified( bool modified, Calendar * )
4559{ 4560{
4560 setModified( modified ); 4561 setModified( modified );
4561} 4562}
4562 4563
4563Todo *CalendarView::selectedTodo() 4564Todo *CalendarView::selectedTodo()
4564{ 4565{
4565 Incidence *incidence = currentSelection(); 4566 Incidence *incidence = currentSelection();
4566 if ( incidence && incidence->typeID() == todoID ) { 4567 if ( incidence && incidence->typeID() == todoID ) {
4567 return static_cast<Todo *>( incidence ); 4568 return static_cast<Todo *>( incidence );
4568 } 4569 }
4569 4570
4570 incidence = mTodoList->selectedIncidences().first(); 4571 incidence = mTodoList->selectedIncidences().first();
4571 if ( incidence && incidence->typeID() == todoID ) { 4572 if ( incidence && incidence->typeID() == todoID ) {
4572 return static_cast<Todo *>( incidence ); 4573 return static_cast<Todo *>( incidence );
4573 } 4574 }
4574 4575
4575 return 0; 4576 return 0;
4576} 4577}
4577 4578
4578void CalendarView::showIncidence() 4579void CalendarView::showIncidence()
4579{ 4580{
4580 mViewerCallerIsSearchDialog = false; 4581 mViewerCallerIsSearchDialog = false;
4581 Incidence *incidence = currentSelection(); 4582 Incidence *incidence = currentSelection();
4582 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4583 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4583 if ( incidence ) { 4584 if ( incidence ) {
4584 ShowIncidenceVisitor v; 4585 ShowIncidenceVisitor v;
4585 v.act( incidence, this ); 4586 v.act( incidence, this );
4586 } 4587 }
4587} 4588}
4588void CalendarView::editIncidenceDescription() 4589void CalendarView::editIncidenceDescription()
4589{ 4590{
4590 mFlagEditDescription = true; 4591 mFlagEditDescription = true;
4591 editIncidence(); 4592 editIncidence();
4592 mFlagEditDescription = false; 4593 mFlagEditDescription = false;
4593} 4594}
4594void CalendarView::editIncidence() 4595void CalendarView::editIncidence()
4595{ 4596{
4596 // qDebug("editIncidence() "); 4597 // qDebug("editIncidence() ");
4597 Incidence *incidence = currentSelection(); 4598 Incidence *incidence = currentSelection();
4598 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4599 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4599 if ( incidence ) { 4600 if ( incidence ) {
4600 EditIncidenceVisitor v; 4601 EditIncidenceVisitor v;
4601 v.act( incidence, this ); 4602 v.act( incidence, this );
4602 } 4603 }
4603} 4604}
4604 4605
4605void CalendarView::deleteIncidence() 4606void CalendarView::deleteIncidence()
4606{ 4607{
4607 Incidence *incidence = currentSelection(); 4608 Incidence *incidence = currentSelection();
4608 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4609 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4609 if ( incidence ) { 4610 if ( incidence ) {
4610 deleteIncidence(incidence); 4611 deleteIncidence(incidence);
4611 } 4612 }
4612} 4613}
4613void CalendarView::showIncidence(QString uid) 4614void CalendarView::showIncidence(QString uid)
4614{ 4615{
4615 Incidence *inc = mCalendar->incidence( uid ); 4616 Incidence *inc = mCalendar->incidence( uid );
4616 if ( inc ) 4617 if ( inc )
4617 showIncidence( inc ); 4618 showIncidence( inc );
4618} 4619}
4619void CalendarView::showIncidence(Incidence *incidence) 4620void CalendarView::showIncidence(Incidence *incidence)
4620{ 4621{
4621 mViewerCallerIsSearchDialog = false; 4622 mViewerCallerIsSearchDialog = false;
4622 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4623 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4623 if ( sender() && mDialogManager->getSearchDialog() ) { 4624 if ( sender() && mDialogManager->getSearchDialog() ) {
4624 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4625 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4625 mViewerCallerIsSearchDialog = true; 4626 mViewerCallerIsSearchDialog = true;
4626 } 4627 }
4627 } 4628 }
4628 if ( incidence ) { 4629 if ( incidence ) {
4629 ShowIncidenceVisitor v; 4630 ShowIncidenceVisitor v;
4630 v.act( incidence, this ); 4631 v.act( incidence, this );
4631 } 4632 }
4632} 4633}
4633 4634
4634void CalendarView::editIncidence(Incidence *incidence) 4635void CalendarView::editIncidence(Incidence *incidence)
4635{ 4636{
4636 if ( incidence ) { 4637 if ( incidence ) {
4637 4638
4638 EditIncidenceVisitor v; 4639 EditIncidenceVisitor v;
4639 v.act( incidence, this ); 4640 v.act( incidence, this );
4640 4641
4641 } 4642 }
4642} 4643}
4643 4644
4644void CalendarView::deleteIncidence(Incidence *incidence) 4645void CalendarView::deleteIncidence(Incidence *incidence)
4645{ 4646{
4646 //qDebug(" CalendarView::deleteIncidence "); 4647 //qDebug(" CalendarView::deleteIncidence ");
4647 if ( incidence == 0 ) { 4648 if ( incidence == 0 ) {
4648 updateView(); 4649 updateView();
4649 emit updateSearchDialog(); 4650 emit updateSearchDialog();
4650 return; 4651 return;
4651 } 4652 }
4652 if ( incidence ) { 4653 if ( incidence ) {
4653 DeleteIncidenceVisitor v; 4654 DeleteIncidenceVisitor v;
4654 v.act( incidence, this ); 4655 v.act( incidence, this );
4655 } 4656 }
4656} 4657}
4657 4658
4658 4659
4659void CalendarView::lookForOutgoingMessages() 4660void CalendarView::lookForOutgoingMessages()
4660{ 4661{
4661 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4662 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4662 ogd->loadMessages(); 4663 ogd->loadMessages();
4663} 4664}
4664 4665
4665void CalendarView::lookForIncomingMessages() 4666void CalendarView::lookForIncomingMessages()
4666{ 4667{
4667 IncomingDialog *icd = mDialogManager->incomingDialog(); 4668 IncomingDialog *icd = mDialogManager->incomingDialog();
4668 icd->retrieve(); 4669 icd->retrieve();
4669} 4670}
4670 4671
4671bool CalendarView::removeCompletedSubTodos( Todo* t ) 4672bool CalendarView::removeCompletedSubTodos( Todo* t )
4672{ 4673{
4673 bool deleteTodo = true; 4674 bool deleteTodo = true;
4674 QPtrList<Incidence> subTodos; 4675 QPtrList<Incidence> subTodos;
4675 Incidence *aTodo; 4676 Incidence *aTodo;
4676 subTodos = t->relations(); 4677 subTodos = t->relations();
4677 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4678 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4678 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4679 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4679 deleteTodo = false; 4680 deleteTodo = false;
4680 } 4681 }
4681 if ( deleteTodo ) { 4682 if ( deleteTodo ) {
4682 if ( t->isCompleted() && !t->doesRecur()) { 4683 if ( t->isCompleted() && !t->doesRecur()) {
4683 checkExternalId( t ); 4684 checkExternalId( t );
4684 mCalendar->deleteTodo( t ); 4685 mCalendar->deleteTodo( t );
4685 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4686 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4686 } 4687 }
4687 else 4688 else
4688 deleteTodo = false; 4689 deleteTodo = false;
4689 } 4690 }
4690 return deleteTodo; 4691 return deleteTodo;
4691 4692
4692} 4693}
4693void CalendarView::purgeCompleted() 4694void CalendarView::purgeCompleted()
4694{ 4695{
4695 int result = KMessageBox::warningContinueCancel(this, 4696 int result = KMessageBox::warningContinueCancel(this,
4696 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4697 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4697 4698
4698 if (result == KMessageBox::Continue) { 4699 if (result == KMessageBox::Continue) {
4699 4700
4700 QPtrList<Todo> todoCal; 4701 QPtrList<Todo> todoCal;
4701 QPtrList<Todo> rootTodos; 4702 QPtrList<Todo> rootTodos;
4702 //QPtrList<Incidence> rel; 4703 //QPtrList<Incidence> rel;
4703 Todo *aTodo; 4704 Todo *aTodo;
4704 todoCal = calendar()->todos(); 4705 todoCal = calendar()->todos();
4705 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4706 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4706 if ( !aTodo->relatedTo() ) 4707 if ( !aTodo->relatedTo() )
4707 rootTodos.append( aTodo ); 4708 rootTodos.append( aTodo );
4708 } 4709 }
4709 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4710 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4710 removeCompletedSubTodos( aTodo ); 4711 removeCompletedSubTodos( aTodo );
4711 } 4712 }
4712 4713
4713 updateView(); 4714 updateView();
4714 } 4715 }
4715} 4716}
4716 4717
4717void CalendarView::slotCalendarChanged() 4718void CalendarView::slotCalendarChanged()
4718{ 4719{
4719 ; 4720 ;
4720} 4721}
4721 4722
4722void CalendarView::keyPressEvent ( QKeyEvent *e) 4723void CalendarView::keyPressEvent ( QKeyEvent *e)
4723{ 4724{
4724 //qDebug("CalendarView::keyPressEvent "); 4725 //qDebug("CalendarView::keyPressEvent ");
4725 e->ignore(); 4726 e->ignore();
4726} 4727}
4727 4728
4728 4729
4729bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4730bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4730{ 4731{
4731 4732
4732 if ( manager != mSyncManager) 4733 if ( manager != mSyncManager)
4733 qDebug("KO: Internal error-1. SyncManager mismatch "); 4734 qDebug("KO: Internal error-1. SyncManager mismatch ");
4734 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4735 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4735 qDebug("KO: SyncKDE request detected!"); 4736 qDebug("KO: SyncKDE request detected!");
4736 } 4737 }
4737 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4738 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4738 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4739 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4739 return syncCalendar( filename, mode ); 4740 return syncCalendar( filename, mode );
4740} 4741}
4741bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4742bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4742{ 4743{
4743 //mSyncManager = manager; 4744 //mSyncManager = manager;
4744 if ( manager != mSyncManager) 4745 if ( manager != mSyncManager)
4745 qDebug("KO: Internal error-2. SyncManager mismatch "); 4746 qDebug("KO: Internal error-2. SyncManager mismatch ");
4746 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4747 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4747 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4748 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4748 if ( resource == "sharp" ) 4749 if ( resource == "sharp" )
4749 syncExternal( 0 ); 4750 syncExternal( 0 );
4750 if ( resource == "phone" ) 4751 if ( resource == "phone" )
4751 syncExternal( 1 ); 4752 syncExternal( 1 );
4752 // pending setmodified 4753 // pending setmodified
4753 return true; 4754 return true;
4754} 4755}
4755void CalendarView::setSyncManager(KSyncManager* manager) 4756void CalendarView::setSyncManager(KSyncManager* manager)
4756{ 4757{
4757 mSyncManager = manager; 4758 mSyncManager = manager;
4758} 4759}
4759 4760
4760void CalendarView::removeSyncInfo( QString syncProfile) 4761void CalendarView::removeSyncInfo( QString syncProfile)
4761{ 4762{
4762 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4763 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4763 mCalendar->removeSyncInfo( syncProfile ); 4764 mCalendar->removeSyncInfo( syncProfile );
4764 4765
4765} 4766}
4766 4767
4767void CalendarView::undo_delete() 4768void CalendarView::undo_delete()
4768{ 4769{
4769 //qDebug("undo_delete() "); 4770 //qDebug("undo_delete() ");
4770 Incidence* undo = mCalendar->undoIncidence(); 4771 Incidence* undo = mCalendar->undoIncidence();
4771 if ( !undo ) { 4772 if ( !undo ) {
4772 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4773 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4773 i18n("KO/Pi")); 4774 i18n("KO/Pi"));
4774 return; 4775 return;
4775 } 4776 }
4776 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 4777 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
4777 i18n("\nAre you sure you want\nto restore this?"), 4778 i18n("\nAre you sure you want\nto restore this?"),
4778 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4779 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4779 mCalendar->undoDeleteIncidence(); 4780 mCalendar->undoDeleteIncidence();
4780 updateView(); 4781 updateView();
4781 } 4782 }
4782} 4783}
4783 4784
4784void CalendarView::slotViewerClosed() 4785void CalendarView::slotViewerClosed()
4785{ 4786{
4786 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4787 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4787} 4788}
4788 4789
4789void CalendarView::resetFocus() 4790void CalendarView::resetFocus()
4790{ 4791{
4791 if ( mViewerCallerIsSearchDialog ) { 4792 if ( mViewerCallerIsSearchDialog ) {
4792 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4793 if ( mDialogManager->getSearchDialog()->isVisible() ){
4793 mDialogManager->getSearchDialog()->raise(); 4794 mDialogManager->getSearchDialog()->raise();
4794 mDialogManager->getSearchDialog()->setActiveWindow(); 4795 mDialogManager->getSearchDialog()->setActiveWindow();
4795 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4796 mDialogManager->getSearchDialog()->listview()->resetFocus();
4796 } else 4797 } else
4797 mViewerCallerIsSearchDialog = false; 4798 mViewerCallerIsSearchDialog = false;
4798 } 4799 }
4799 if ( !mViewerCallerIsSearchDialog ) { 4800 if ( !mViewerCallerIsSearchDialog ) {
4800 //mViewManager->currentView()->setFocus(); 4801 //mViewManager->currentView()->setFocus();
4801 //qDebug("sssssssssssssssset focus "); 4802 //qDebug("sssssssssssssssset focus ");
4802 topLevelWidget()->raise(); 4803 topLevelWidget()->raise();
4803 setActiveWindow(); 4804 setActiveWindow();
4804 //setFocus(); 4805 //setFocus();
4805 } 4806 }
4806 mViewerCallerIsSearchDialog = false; 4807 mViewerCallerIsSearchDialog = false;
4807} 4808}
4808 4809
4809void CalendarView::showNextAlarms() 4810void CalendarView::showNextAlarms()
4810{ 4811{
4811 QString message; 4812 QString message;
4812 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4813 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4813 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4814 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4814 QString sum = mCalendar->nextSummary(); 4815 QString sum = mCalendar->nextSummary();
4815 QDateTime nextA = mNextAlarmDateTime; 4816 QDateTime nextA = mNextAlarmDateTime;
4816 QDateTime cur = QDateTime::currentDateTime(); 4817 QDateTime cur = QDateTime::currentDateTime();
4817 int secs = cur.secsTo( nextA ); 4818 int secs = cur.secsTo( nextA );
4818 int min = secs /60; 4819 int min = secs /60;
4819 int hours = min /60; 4820 int hours = min /60;
4820 min = min % 60; 4821 min = min % 60;
4821 int days = hours /24; 4822 int days = hours /24;
4822 hours = hours % 24; 4823 hours = hours % 24;
4823 4824
4824 //message = i18n("The next alarm is in:\n"); 4825 //message = i18n("The next alarm is in:\n");
4825 if ( days > 1 ) 4826 if ( days > 1 )
4826 message += i18n("%1 days\n").arg( days ); 4827 message += i18n("%1 days\n").arg( days );
4827 else if ( days == 1 ) 4828 else if ( days == 1 )
4828 message += i18n("1 day\n"); 4829 message += i18n("1 day\n");
4829 if ( hours > 1 ) 4830 if ( hours > 1 )
4830 message += i18n("%1 hours\n").arg( hours ); 4831 message += i18n("%1 hours\n").arg( hours );
4831 else if ( hours == 1 ) 4832 else if ( hours == 1 )
4832 message += i18n("1 hour\n"); 4833 message += i18n("1 hour\n");
4833 if ( min > 1 ) 4834 if ( min > 1 )
4834 message += i18n("%1 minutes\n").arg( min ); 4835 message += i18n("%1 minutes\n").arg( min );
4835 else if ( min == 1 ) 4836 else if ( min == 1 )
4836 message += i18n("1 minute\n"); 4837 message += i18n("1 minute\n");
4837 if ( message.isEmpty() ) 4838 if ( message.isEmpty() )
4838 message = i18n("The next alarm is in\nless than one minute!"); 4839 message = i18n("The next alarm is in\nless than one minute!");
4839 else 4840 else
4840 message = i18n("The next alarm is in:\n") + message; 4841 message = i18n("The next alarm is in:\n") + message;
4841 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4842 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4842 } else { 4843 } else {
4843 message = i18n("There is no next alarm."); 4844 message = i18n("There is no next alarm.");
4844 4845
4845 } 4846 }
4846#ifdef DESKTOP_VERSION 4847#ifdef DESKTOP_VERSION
4847 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4848 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4848 message += i18n("\nThe internal alarm notification is disabled!\n"); 4849 message += i18n("\nThe internal alarm notification is disabled!\n");
4849 message += i18n("Enable it in the settings menu, TAB alarm."); 4850 message += i18n("Enable it in the settings menu, TAB alarm.");
4850 } 4851 }
4851 4852
4852#endif 4853#endif
4853 KMessageBox::information( this, message); 4854 KMessageBox::information( this, message);
4854} 4855}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 279955f..77d0ac8 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2655 +1,2663 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
25#include <qpe/resource.h> 25#include <qpe/resource.h>
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
27#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
28#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
29#include <unistd.h> // for sleep 29#include <unistd.h> // for sleep
30#else 30#else
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
39#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
40#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
41#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
42#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
43 43
44#include "calendarview.h" 44#include "calendarview.h"
45#include "koviewmanager.h" 45#include "koviewmanager.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47#include "koagendaview.h" 47#include "koagendaview.h"
48#include "kojournalview.h" 48#include "kojournalview.h"
49#include "koagenda.h" 49#include "koagenda.h"
50#include "kodialogmanager.h" 50#include "kodialogmanager.h"
51#include "kdialogbase.h" 51#include "kdialogbase.h"
52#include "kapplication.h" 52#include "kapplication.h"
53#include "kofilterview.h" 53#include "kofilterview.h"
54#include "kstandarddirs.h" 54#include "kstandarddirs.h"
55#include "koprefs.h" 55#include "koprefs.h"
56#include "kfiledialog.h" 56#include "kfiledialog.h"
57#include "koglobals.h" 57#include "koglobals.h"
58#include "kglobal.h" 58#include "kglobal.h"
59#include "ktoolbar.h" 59#include "ktoolbar.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "externalapphandler.h" 62#include "externalapphandler.h"
63#include <kglobalsettings.h> 63#include <kglobalsettings.h>
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
132QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
133 133
134 134
135int globalFlagBlockStartup; 135int globalFlagBlockStartup;
136MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
137 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
138{ 138{
139 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
140 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
141 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
142 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
143 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
144 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
145 //int size = 12; 145 //int size = 12;
146 { 146 {
147 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
148 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
149 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
150 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
151 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
152 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
153 int iii = 0; 153 int iii = 0;
154 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
155 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
156 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
157 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
158 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
159 if ( iii ) 159 if ( iii )
160 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
161 } 161 }
162 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
163 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
164 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
165 { 165 {
166 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
167 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
168 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
169 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
170 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
171 } 171 }
172 } 172 }
173 mClosed = false; 173 mClosed = false;
174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
175 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
176 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
177 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
178 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
179 mBlockAtStartup = true; 179 mBlockAtStartup = true;
180 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
181 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
182 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
183 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
184 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
185 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
186 p->mHourSize = 22; 186 p->mHourSize = 22;
187 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
188 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
189 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
190 tbd = Bottom; 190 tbd = Bottom;
191 else 191 else
192 tbd = Top; 192 tbd = Top;
193 } 193 }
194 else { 194 else {
195 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
196 tbd = Right; 196 tbd = Right;
197 else 197 else
198 tbd = Left; 198 tbd = Left;
199 } 199 }
200 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
202 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
203 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
204 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
205 205
206#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
207 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
208#else 208#else
209 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 209 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
210#endif 210#endif
211 211
212{ 212{
213 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
214 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
215 tbd = Bottom; 215 tbd = Bottom;
216 else 216 else
217 tbd = Top; 217 tbd = Top;
218 } 218 }
219 else { 219 else {
220 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
221 tbd = Right; 221 tbd = Right;
222 else 222 else
223 tbd = Left; 223 tbd = Left;
224 } 224 }
225 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
226 filterMenubar = new KMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
227 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
228 228
229 filterPopupMenu = new QPopupMenu( this ); 229 filterPopupMenu = new QPopupMenu( this );
230 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 230 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
231 QString addTest = "A"; 231 QString addTest = "A";
232 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 232 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
233#ifdef DESKTOP_VERSION 233#ifdef DESKTOP_VERSION
234 addTest = "AAABBBCCCx"; 234 addTest = "AAABBBCCCx";
235#else 235#else
236 addTest = "AAx"; 236 addTest = "AAx";
237#endif 237#endif
238 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 238 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
239 addToolBar (filterToolBar , tbd ); 239 addToolBar (filterToolBar , tbd );
240 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 240 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
241 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 241 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
242 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 242 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
243 filterToolBar->hide(); 243 filterToolBar->hide();
244 } else { 244 } else {
245 filterToolBar = 0; 245 filterToolBar = 0;
246 filterMenubar = 0; 246 filterMenubar = 0;
247 filterPopupMenu = 0; 247 filterPopupMenu = 0;
248 } 248 }
249 if ( p->mShowIconOnetoolbar ) { 249 if ( p->mShowIconOnetoolbar ) {
250 viewToolBar = iconToolBar ; 250 viewToolBar = iconToolBar ;
251 navigatorToolBar = iconToolBar ; 251 navigatorToolBar = iconToolBar ;
252 } else { 252 } else {
253#ifndef DESKTOP_VERSION 253#ifndef DESKTOP_VERSION
254 setToolBarsMovable( false ); 254 setToolBarsMovable( false );
255#endif 255#endif
256 if ( p->mToolBarHorV ) { 256 if ( p->mToolBarHorV ) {
257 if ( p->mToolBarUpV ) 257 if ( p->mToolBarUpV )
258 tbd = Bottom; 258 tbd = Bottom;
259 else 259 else
260 tbd = Top; 260 tbd = Top;
261 } 261 }
262 else { 262 else {
263 if ( p->mToolBarUpV ) 263 if ( p->mToolBarUpV )
264 tbd = Right; 264 tbd = Right;
265 else 265 else
266 tbd = Left; 266 tbd = Left;
267 } 267 }
268 viewToolBar = new QPEToolBar( this ); 268 viewToolBar = new QPEToolBar( this );
269 addToolBar (viewToolBar , tbd ); 269 addToolBar (viewToolBar , tbd );
270 if ( p->mToolBarHorN ) { 270 if ( p->mToolBarHorN ) {
271 if ( p->mToolBarUpN ) 271 if ( p->mToolBarUpN )
272 tbd = Bottom; 272 tbd = Bottom;
273 else 273 else
274 tbd = Top; 274 tbd = Top;
275 } 275 }
276 else { 276 else {
277 if ( p->mToolBarUpN ) 277 if ( p->mToolBarUpN )
278 tbd = Right; 278 tbd = Right;
279 else 279 else
280 tbd = Left; 280 tbd = Left;
281 } 281 }
282 navigatorToolBar = new QPEToolBar( this ); 282 navigatorToolBar = new QPEToolBar( this );
283 addToolBar (navigatorToolBar , tbd ); 283 addToolBar (navigatorToolBar , tbd );
284 } 284 }
285 285
286 286
287 287
288 mCalendarModifiedFlag = false; 288 mCalendarModifiedFlag = false;
289 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 289 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
290 splash->setAlignment ( AlignCenter ); 290 splash->setAlignment ( AlignCenter );
291 setCentralWidget( splash ); 291 setCentralWidget( splash );
292#ifndef DESKTOP_VERSION 292#ifndef DESKTOP_VERSION
293 showMaximized(); 293 showMaximized();
294#endif 294#endif
295 295
296 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 296 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
297 setDefaultPreferences(); 297 setDefaultPreferences();
298 mCalendar = new CalendarLocal(); 298 mCalendar = new CalendarLocal();
299 mView = new CalendarView( mCalendar, this,"mCalendar " ); 299 mView = new CalendarView( mCalendar, this,"mCalendar " );
300 mView->hide(); 300 mView->hide();
301 //mView->resize(splash->size() ); 301 //mView->resize(splash->size() );
302 initActions(); 302 initActions();
303 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 303 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
304 mSyncManager->setBlockSave(false); 304 mSyncManager->setBlockSave(false);
305 mView->setSyncManager(mSyncManager); 305 mView->setSyncManager(mSyncManager);
306#ifndef DESKTOP_VERSION 306#ifndef DESKTOP_VERSION
307 iconToolBar->show(); 307 iconToolBar->show();
308 qApp->processEvents(); 308 qApp->processEvents();
309#endif 309#endif
310 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 310 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
311 int vh = height() ; 311 int vh = height() ;
312 int vw = width(); 312 int vw = width();
313 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 313 //qDebug("Toolbar hei %d ",iconToolBar->height() );
314 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 314 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
315 vh -= iconToolBar->height(); 315 vh -= iconToolBar->height();
316 } else { 316 } else {
317 vw -= iconToolBar->height(); 317 vw -= iconToolBar->height();
318 } 318 }
319 //mView->setMaximumSize( splash->size() ); 319 //mView->setMaximumSize( splash->size() );
320 //mView->resize( splash->size() ); 320 //mView->resize( splash->size() );
321 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 321 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
322 mView->readSettings(); 322 mView->readSettings();
323 bool newFile = false; 323 bool newFile = false;
324 if( !QFile::exists( defaultFileName() ) ) { 324 if( !QFile::exists( defaultFileName() ) ) {
325 QFileInfo finfo ( defaultFileName() ); 325 QFileInfo finfo ( defaultFileName() );
326 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 326 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
327 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 327 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
328 finfo.setFile( oldFile ); 328 finfo.setFile( oldFile );
329 if (finfo.exists() ) { 329 if (finfo.exists() ) {
330 KMessageBox::information( this, message); 330 KMessageBox::information( this, message);
331 mView->openCalendar( oldFile ); 331 mView->openCalendar( oldFile );
332 qApp->processEvents(); 332 qApp->processEvents();
333 } else { 333 } else {
334 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 334 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
335 finfo.setFile( oldFile ); 335 finfo.setFile( oldFile );
336 if (finfo.exists() ) { 336 if (finfo.exists() ) {
337 KMessageBox::information( this, message); 337 KMessageBox::information( this, message);
338 mView->openCalendar( oldFile ); 338 mView->openCalendar( oldFile );
339 qApp->processEvents(); 339 qApp->processEvents();
340 } 340 }
341 } 341 }
342 mView->saveCalendar( defaultFileName() ); 342 mView->saveCalendar( defaultFileName() );
343 newFile = true; 343 newFile = true;
344 } 344 }
345 345
346 QTime neededSaveTime = QDateTime::currentDateTime().time(); 346 QTime neededSaveTime = QDateTime::currentDateTime().time();
347 mView->loadCalendars(); 347 mView->loadCalendars();
348 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 348 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
349 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 349 qDebug("KO: Calendar loading time: %d ms",msNeeded );
350 350
351 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 351 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
352 KOPrefs::instance()->setAllDefaults(); 352 KOPrefs::instance()->setAllDefaults();
353 } 353 }
354 processIncidenceSelection( 0 ); 354 processIncidenceSelection( 0 );
355 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 355 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
356 SLOT( processIncidenceSelection( Incidence * ) ) ); 356 SLOT( processIncidenceSelection( Incidence * ) ) );
357 connect( mView, SIGNAL( modifiedChanged( bool ) ), 357 connect( mView, SIGNAL( modifiedChanged( bool ) ),
358 SLOT( slotModifiedChanged( bool ) ) ); 358 SLOT( slotModifiedChanged( bool ) ) );
359 359
360 360
361 connect( mView, SIGNAL( tempDisableBR(bool) ), 361 connect( mView, SIGNAL( tempDisableBR(bool) ),
362 SLOT( disableBR(bool) ) ); 362 SLOT( disableBR(bool) ) );
363 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 363 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
364 mView->setModified( false ); 364 mView->setModified( false );
365 mBlockAtStartup = false; 365 mBlockAtStartup = false;
366 mView->setModified( false ); 366 mView->setModified( false );
367 setCentralWidget( mView ); 367 setCentralWidget( mView );
368 globalFlagBlockStartup = 0; 368 globalFlagBlockStartup = 0;
369 mView->show(); 369 mView->show();
370 delete splash; 370 delete splash;
371 if ( newFile ) 371 if ( newFile )
372 mView->updateConfig(); 372 mView->updateConfig();
373 // qApp->processEvents(); 373 // qApp->processEvents();
374 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 374 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
375 //fillSyncMenu(); 375 //fillSyncMenu();
376 376
377 377
378 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 378 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
379 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 379 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
380 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 380 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
381 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 381 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
382 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 382 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
383 mSyncManager->setDefaultFileName( sentSyncFile()); 383 mSyncManager->setDefaultFileName( sentSyncFile());
384 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 384 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
385 mSyncManager->fillSyncMenu(); 385 mSyncManager->fillSyncMenu();
386 386
387 387
388 388
389 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 389 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
390 if ( showWarning ) { 390 if ( showWarning ) {
391 KMessageBox::information( this, 391 KMessageBox::information( this,
392 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 392 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
393 qApp->processEvents(); 393 qApp->processEvents();
394 mView->dialogManager()->showSyncOptions(); 394 mView->dialogManager()->showSyncOptions();
395 } 395 }
396 396
397 //US listen for result adressed from Ka/Pi 397 //US listen for result adressed from Ka/Pi
398#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
399 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 399 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
400#endif 400#endif
401#ifndef DESKTOP_VERSION 401#ifndef DESKTOP_VERSION
402 infrared = 0; 402 infrared = 0;
403#endif 403#endif
404 updateFilterToolbar(); 404 updateFilterToolbar();
405 updateWeek( mView->startDate() ); 405 updateWeek( mView->startDate() );
406 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 406 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
407 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 407 SLOT( updateWeekNum( const KCal::DateList & ) ) );
408 mBRdisabled = false; 408 mBRdisabled = false;
409 //toggleBeamReceive(); 409 //toggleBeamReceive();
410 410
411 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 411 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
412} 412}
413MainWindow::~MainWindow() 413MainWindow::~MainWindow()
414{ 414{
415 //qDebug("MainWindow::~MainWindow() "); 415 //qDebug("MainWindow::~MainWindow() ");
416 //save toolbar location 416 //save toolbar location
417 delete mCalendar; 417 delete mCalendar;
418 delete mSyncManager; 418 delete mSyncManager;
419#ifndef DESKTOP_VERSION 419#ifndef DESKTOP_VERSION
420 if ( infrared ) 420 if ( infrared )
421 delete infrared; 421 delete infrared;
422#endif 422#endif
423 423
424 424
425} 425}
426void MainWindow::slotResetFocus() 426void MainWindow::slotResetFocus()
427{ 427{
428 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 428 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
429 mFocusLoop = 3; 429 mFocusLoop = 3;
430 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 430 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
431} 431}
432void MainWindow::slotResetFocusLoop() 432void MainWindow::slotResetFocusLoop()
433{ 433{
434 --mFocusLoop; 434 --mFocusLoop;
435 QWidget* fw = mView->viewManager()->currentView(); 435 QWidget* fw = mView->viewManager()->currentView();
436 if ( fw ) { 436 if ( fw ) {
437 //qDebug("loop "); 437 //qDebug("loop ");
438 fw->setFocus(); 438 fw->setFocus();
439 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 439 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
440 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 440 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
441 } 441 }
442 442
443} 443}
444void MainWindow::disableBR(bool b) 444void MainWindow::disableBR(bool b)
445{ 445{
446#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
447 if ( b ) { 447 if ( b ) {
448 if ( infrared ) { 448 if ( infrared ) {
449 toggleBeamReceive(); 449 toggleBeamReceive();
450 mBRdisabled = true; 450 mBRdisabled = true;
451 } 451 }
452 mBRdisabled = true; 452 mBRdisabled = true;
453 } else { 453 } else {
454 if ( mBRdisabled ) { 454 if ( mBRdisabled ) {
455 mBRdisabled = false; 455 mBRdisabled = false;
456 //makes no sense,because other cal ap is probably running 456 //makes no sense,because other cal ap is probably running
457 // toggleBeamReceive(); 457 // toggleBeamReceive();
458 } 458 }
459 } 459 }
460#endif 460#endif
461 461
462} 462}
463bool MainWindow::beamReceiveEnabled() 463bool MainWindow::beamReceiveEnabled()
464{ 464{
465#ifndef DESKTOP_VERSION 465#ifndef DESKTOP_VERSION
466 return ( infrared != 0 ); 466 return ( infrared != 0 );
467#endif 467#endif
468 return false; 468 return false;
469} 469}
470 470
471void MainWindow::toggleBeamReceive() 471void MainWindow::toggleBeamReceive()
472{ 472{
473 if ( mBRdisabled ) 473 if ( mBRdisabled )
474 return; 474 return;
475#ifndef DESKTOP_VERSION 475#ifndef DESKTOP_VERSION
476 if ( infrared ) { 476 if ( infrared ) {
477 qDebug("KO: Disable BeamReceive "); 477 qDebug("KO: Disable BeamReceive ");
478 delete infrared; 478 delete infrared;
479 infrared = 0; 479 infrared = 0;
480 brAction->setOn(false); 480 brAction->setOn(false);
481 return; 481 return;
482 } 482 }
483 qDebug("KO: Enable BeamReceive "); 483 qDebug("KO: Enable BeamReceive ");
484 brAction->setOn(true); 484 brAction->setOn(true);
485 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 485 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
486 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 486 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
487#endif 487#endif
488} 488}
489void MainWindow::showMaximized () 489void MainWindow::showMaximized ()
490{ 490{
491#ifndef DESKTOP_VERSION 491#ifndef DESKTOP_VERSION
492 if ( ! globalFlagBlockStartup ) 492 if ( ! globalFlagBlockStartup )
493 if ( mClosed ) 493 if ( mClosed )
494 mView->goToday(); 494 mView->goToday();
495#endif 495#endif
496 QWidget::showMaximized () ; 496 QWidget::showMaximized () ;
497 mClosed = false; 497 mClosed = false;
498} 498}
499void MainWindow::closeEvent( QCloseEvent* ce ) 499void MainWindow::closeEvent( QCloseEvent* ce )
500{ 500{
501 501
502 502
503 503
504 if ( ! KOPrefs::instance()->mAskForQuit ) { 504 if ( ! KOPrefs::instance()->mAskForQuit ) {
505 saveOnClose(); 505 saveOnClose();
506 mClosed = true; 506 mClosed = true;
507 ce->accept(); 507 ce->accept();
508 return; 508 return;
509 509
510 } 510 }
511 511
512 switch( QMessageBox::information( this, "KO/Pi", 512 switch( QMessageBox::information( this, "KO/Pi",
513 i18n("Do you really want\nto close KO/Pi?"), 513 i18n("Do you really want\nto close KO/Pi?"),
514 i18n("Close"), i18n("No"), 514 i18n("Close"), i18n("No"),
515 0, 0 ) ) { 515 0, 0 ) ) {
516 case 0: 516 case 0:
517 saveOnClose(); 517 saveOnClose();
518 mClosed = true; 518 mClosed = true;
519 ce->accept(); 519 ce->accept();
520 break; 520 break;
521 case 1: 521 case 1:
522 ce->ignore(); 522 ce->ignore();
523 break; 523 break;
524 case 2: 524 case 2:
525 525
526 default: 526 default:
527 break; 527 break;
528 } 528 }
529 529
530 530
531} 531}
532 532
533void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 533void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
534{ 534{
535 QDataStream stream( data, IO_ReadOnly ); 535 QDataStream stream( data, IO_ReadOnly );
536 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 536 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
537 //QString datamess; 537 //QString datamess;
538 //qDebug("message "); 538 //qDebug("message ");
539 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 539 qDebug("KO: QCOP message received: %s ", cmsg.data() );
540 540
541 if ( cmsg == "setDocument(QString)" ) { 541 if ( cmsg == "setDocument(QString)" ) {
542 QDataStream stream( data, IO_ReadOnly ); 542 QDataStream stream( data, IO_ReadOnly );
543 QString fileName; 543 QString fileName;
544 stream >> fileName; 544 stream >> fileName;
545 //qDebug("filename %s ", fileName.latin1()); 545 //qDebug("filename %s ", fileName.latin1());
546 showMaximized(); 546 showMaximized();
547 raise(); 547 raise();
548 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 548 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
549 mSyncManager->slotSyncMenu( 1002 ); 549 mSyncManager->slotSyncMenu( 1002 );
550 return; 550 return;
551 } 551 }
552 552
553 if ( cmsg == "-writeFile" ) { 553 if ( cmsg == "-writeFile" ) {
554 // I made from the "-writeFile" an "-writeAlarm" 554 // I made from the "-writeFile" an "-writeAlarm"
555 mView->viewManager()->showWhatsNextView(); 555 mView->viewManager()->showWhatsNextView();
556 mCalendar->checkAlarmForIncidence( 0, true); 556 mCalendar->checkAlarmForIncidence( 0, true);
557 showMaximized(); 557 showMaximized();
558 raise(); 558 raise();
559 return; 559 return;
560 560
561 } 561 }
562 if ( cmsg == "-writeFileSilent" ) { 562 if ( cmsg == "-writeFileSilent" ) {
563 // I made from the "-writeFile" an "-writeAlarm" 563 // I made from the "-writeFile" an "-writeAlarm"
564 // mView->viewManager()->showWhatsNextView(); 564 // mView->viewManager()->showWhatsNextView();
565 mCalendar->checkAlarmForIncidence( 0, true); 565 mCalendar->checkAlarmForIncidence( 0, true);
566 //showMaximized(); 566 //showMaximized();
567 //raise(); 567 //raise();
568 hide(); 568 hide();
569 return; 569 return;
570 } 570 }
571 if ( cmsg == "-newCountdown" ) { 571 if ( cmsg == "-newCountdown" ) {
572 qDebug("newCountdown "); 572 qDebug("newCountdown ");
573 573
574 } 574 }
575 QString msg ; 575 QString msg ;
576 QString allmsg = cmsg; 576 QString allmsg = cmsg;
577 while ( allmsg.length() > 0 ) { 577 while ( allmsg.length() > 0 ) {
578 int nextC = allmsg.find( "-", 1 ); 578 int nextC = allmsg.find( "-", 1 );
579 if ( nextC == -1 ) { 579 if ( nextC == -1 ) {
580 msg = allmsg; 580 msg = allmsg;
581 allmsg = ""; 581 allmsg = "";
582 } else{ 582 } else{
583 msg = allmsg.left( nextC ); 583 msg = allmsg.left( nextC );
584 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 584 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
585 } 585 }
586 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 586 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
587 if ( msg == "-newEvent" ) { 587 if ( msg == "-newEvent" ) {
588 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 588 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
589 } 589 }
590 if ( msg == "-newTodo" ) { 590 if ( msg == "-newTodo" ) {
591 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 591 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
592 } 592 }
593 if ( msg == "-showWN" ) { 593 if ( msg == "-showWN" ) {
594 mView->viewManager()->showWhatsNextView(); 594 mView->viewManager()->showWhatsNextView();
595 } 595 }
596 if ( msg == "-showTodo" ) { 596 if ( msg == "-showTodo" ) {
597 mView->viewManager()->showTodoView(); 597 mView->viewManager()->showTodoView();
598 } 598 }
599 if ( msg == "-showList" ) { 599 if ( msg == "-showList" ) {
600 mView->viewManager()->showListView(); 600 mView->viewManager()->showListView();
601 } 601 }
602 else if ( msg == "-showDay" ) { 602 else if ( msg == "-showDay" ) {
603 mView->viewManager()->showDayView(); 603 mView->viewManager()->showDayView();
604 } 604 }
605 else if ( msg == "-showWWeek" ) { 605 else if ( msg == "-showWWeek" ) {
606 mView->viewManager()->showWorkWeekView(); 606 mView->viewManager()->showWorkWeekView();
607 } 607 }
608 else if ( msg == "-ringSync" ) { 608 else if ( msg == "-ringSync" ) {
609 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 609 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
610 } 610 }
611 else if ( msg == "-showWeek" ) { 611 else if ( msg == "-showWeek" ) {
612 mView->viewManager()->showWeekView(); 612 mView->viewManager()->showWeekView();
613 } 613 }
614 else if ( msg == "-showTodo" ) { 614 else if ( msg == "-showTodo" ) {
615 mView->viewManager()->showTodoView(); 615 mView->viewManager()->showTodoView();
616 } 616 }
617 else if ( msg == "-showJournal" ) { 617 else if ( msg == "-showJournal" ) {
618 mView->dateNavigator()->selectDates( 1 ); 618 mView->dateNavigator()->selectDates( 1 );
619 mView->dateNavigator()->selectToday(); 619 mView->dateNavigator()->selectToday();
620 mView->viewManager()->showJournalView(); 620 mView->viewManager()->showJournalView();
621 } 621 }
622 else if ( msg == "-showKO" ) { 622 else if ( msg == "-showKO" ) {
623 mView->viewManager()->showNextXView(); 623 mView->viewManager()->showNextXView();
624 } 624 }
625 else if ( msg == "-showWNext" ) { 625 else if ( msg == "-showWNext" ) {
626 mView->viewManager()->showWhatsNextView(); 626 mView->viewManager()->showWhatsNextView();
627 } 627 }
628 else if ( msg == "nextView()" ) { 628 else if ( msg == "nextView()" ) {
629 mView->viewManager()->showNextView(); 629 mView->viewManager()->showNextView();
630 } 630 }
631 else if ( msg == "-showNextXView" ) { 631 else if ( msg == "-showNextXView" ) {
632 mView->viewManager()->showNextXView(); 632 mView->viewManager()->showNextXView();
633 } 633 }
634 634
635 635
636 } 636 }
637 637
638 showMaximized(); 638 showMaximized();
639 raise(); 639 raise();
640} 640}
641void MainWindow::startMultiSync() 641void MainWindow::startMultiSync()
642{ 642{
643 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 643 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
644 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 644 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
645 question, 645 question,
646 i18n("Yes"), i18n("No"), 646 i18n("Yes"), i18n("No"),
647 0, 0 ) != 0 ) { 647 0, 0 ) != 0 ) {
648 setCaption(i18n("Aborted! Nothing synced!")); 648 setCaption(i18n("Aborted! Nothing synced!"));
649 return; 649 return;
650 } 650 }
651 mSyncManager->multiSync( false ); 651 mSyncManager->multiSync( false );
652#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
653 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 653 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
654#endif 654#endif
655} 655}
656QPixmap MainWindow::loadPixmap( QString name ) 656QPixmap MainWindow::loadPixmap( QString name )
657{ 657{
658 return SmallIcon( name ); 658 return SmallIcon( name );
659 659
660} 660}
661void MainWindow::setUsesBigPixmaps ( bool b ) 661void MainWindow::setUsesBigPixmaps ( bool b )
662{ 662{
663 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 663 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
664 if ( b ) 664 if ( b )
665 qDebug("KO: BigPixmaps are not supported "); 665 qDebug("KO: BigPixmaps are not supported ");
666} 666}
667void MainWindow::initActions() 667void MainWindow::initActions()
668{ 668{
669 //KOPrefs::instance()->mShowFullMenu 669 //KOPrefs::instance()->mShowFullMenu
670 iconToolBar->clear(); 670 iconToolBar->clear();
671 KOPrefs *p = KOPrefs::instance(); 671 KOPrefs *p = KOPrefs::instance();
672 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 672 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
673 673
674 QPopupMenu *viewMenu = new QPopupMenu( this ); 674 QPopupMenu *viewMenu = new QPopupMenu( this );
675 QPopupMenu *actionMenu = new QPopupMenu( this ); 675 QPopupMenu *actionMenu = new QPopupMenu( this );
676 mCurrentItemMenu = new QPopupMenu ( this ); 676 mCurrentItemMenu = new QPopupMenu ( this );
677 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 677 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
678 QPopupMenu *importMenu = new QPopupMenu( this ); 678 QPopupMenu *importMenu = new QPopupMenu( this );
679 QPopupMenu *importMenu_X = new QPopupMenu( this ); 679 QPopupMenu *importMenu_X = new QPopupMenu( this );
680 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 680 QPopupMenu *exportMenu_X = new QPopupMenu( this );
681 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 681 QPopupMenu *beamMenu_X = new QPopupMenu( this );
682 selectFilterMenu = new QPopupMenu( this ); 682 selectFilterMenu = new QPopupMenu( this );
683 selectFilterMenu->setCheckable( true ); 683 selectFilterMenu->setCheckable( true );
684 syncMenu = new QPopupMenu( this ); 684 syncMenu = new QPopupMenu( this );
685 configureAgendaMenu = new QPopupMenu( this ); 685 configureAgendaMenu = new QPopupMenu( this );
686 configureToolBarMenu = new QPopupMenu( this ); 686 configureToolBarMenu = new QPopupMenu( this );
687 QPopupMenu *helpMenu = new QPopupMenu( this ); 687 QPopupMenu *helpMenu = new QPopupMenu( this );
688 QIconSet icon; 688 QIconSet icon;
689 int pixWid = 22, pixHei = 22; 689 int pixWid = 22, pixHei = 22;
690 QString pathString = ""; 690 QString pathString = "";
691 if ( !p->mToolBarMiniIcons ) { 691 if ( !p->mToolBarMiniIcons ) {
692 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 692 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
693 pathString += "icons16/"; 693 pathString += "icons16/";
694 pixWid = 18; pixHei = 16; 694 pixWid = 18; pixHei = 16;
695 } 695 }
696 } else { 696 } else {
697 pathString += "iconsmini/"; 697 pathString += "iconsmini/";
698 pixWid = 18; pixHei = 16; 698 pixWid = 18; pixHei = 16;
699 } 699 }
700 700
701 if ( KOPrefs::instance()->mShowFullMenu ) { 701 if ( KOPrefs::instance()->mShowFullMenu ) {
702 menuBar1 = new KMenuBar( this );//menuBar(); 702 menuBar1 = new KMenuBar( this );//menuBar();
703 //setMenuBar( menuBar1 ); 703 //setMenuBar( menuBar1 );
704 menuBar1->show(); 704 menuBar1->show();
705 menuBar1->insertItem( i18n("File"), importMenu ); 705 menuBar1->insertItem( i18n("File"), importMenu );
706 menuBar1->insertItem( i18n("View"), viewMenu ); 706 menuBar1->insertItem( i18n("View"), viewMenu );
707 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 707 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
708 menuBar1->insertItem( i18n("Action"), actionMenu ); 708 menuBar1->insertItem( i18n("Action"), actionMenu );
709#ifdef DESKTOP_VERSION 709#ifdef DESKTOP_VERSION
710 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 710 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
711 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 711 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
712#else 712#else
713 menuBar1->insertItem( i18n("Sync"), syncMenu ); 713 menuBar1->insertItem( i18n("Sync"), syncMenu );
714 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 714 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
715#endif 715#endif
716 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 716 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
717 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 717 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
718 menuBar1->insertItem( i18n("Help"), helpMenu ); 718 menuBar1->insertItem( i18n("Help"), helpMenu );
719 } else { 719 } else {
720 menuBar1 = new KMenuBar( iconToolBar ); 720 menuBar1 = new KMenuBar( iconToolBar );
721 QPopupMenu *menuBar = new QPopupMenu( this ); 721 QPopupMenu *menuBar = new QPopupMenu( this );
722 icon = loadPixmap( pathString + "z_menu" ); 722 icon = loadPixmap( pathString + "z_menu" );
723 menuBar1->insertItem( icon.pixmap(), menuBar); 723 menuBar1->insertItem( icon.pixmap(), menuBar);
724 //menuBar1->insertItem( i18n("ME"), menuBar); 724 //menuBar1->insertItem( i18n("ME"), menuBar);
725 menuBar->insertItem( i18n("File"), importMenu ); 725 menuBar->insertItem( i18n("File"), importMenu );
726 menuBar->insertItem( i18n("View"), viewMenu ); 726 menuBar->insertItem( i18n("View"), viewMenu );
727 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 727 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
728 menuBar->insertItem( i18n("Action"), actionMenu ); 728 menuBar->insertItem( i18n("Action"), actionMenu );
729 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 729 menuBar->insertItem( i18n("Synchronize"), syncMenu );
730 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 730 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
731 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 731 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
732 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 732 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
733 menuBar->insertItem( i18n("Help"), helpMenu ); 733 menuBar->insertItem( i18n("Help"), helpMenu );
734 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 734 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
735 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 735 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
736 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 736 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
737 } 737 }
738 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 738 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
739 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 739 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
740 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 740 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
741 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 741 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
742 742
743 743
744 mWeekBgColor = iconToolBar->backgroundColor(); 744 mWeekBgColor = iconToolBar->backgroundColor();
745 mWeekPixmap.resize( pixWid , pixHei ); 745 mWeekPixmap.resize( pixWid , pixHei );
746 mWeekPixmap.fill( mWeekBgColor ); 746 mWeekPixmap.fill( mWeekBgColor );
747 icon = mWeekPixmap; 747 icon = mWeekPixmap;
748 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 748 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
749 if ( p-> mShowIconWeekNum ) 749 if ( p-> mShowIconWeekNum )
750 mWeekAction->addTo( iconToolBar ); 750 mWeekAction->addTo( iconToolBar );
751 mWeekFont = font(); 751 mWeekFont = font();
752 752
753 int fontPoint = mWeekFont.pointSize(); 753 int fontPoint = mWeekFont.pointSize();
754 QFontMetrics f( mWeekFont ); 754 QFontMetrics f( mWeekFont );
755 int fontWid = f.width( "30" ); 755 int fontWid = f.width( "30" );
756 while ( fontWid > pixWid ) { 756 while ( fontWid > pixWid ) {
757 --fontPoint; 757 --fontPoint;
758 mWeekFont.setPointSize( fontPoint ); 758 mWeekFont.setPointSize( fontPoint );
759 QFontMetrics f( mWeekFont ); 759 QFontMetrics f( mWeekFont );
760 fontWid = f.width( "30" ); 760 fontWid = f.width( "30" );
761 //qDebug("dec-- "); 761 //qDebug("dec-- ");
762 } 762 }
763 763
764 connect( mWeekAction, SIGNAL( activated() ), 764 connect( mWeekAction, SIGNAL( activated() ),
765 this, SLOT( weekAction() ) ); 765 this, SLOT( weekAction() ) );
766 766
767 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 767 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
768 if ( p->mShowIconFilterview ) { 768 if ( p->mShowIconFilterview ) {
769 icon = loadPixmap( pathString + "filter" ); 769 icon = loadPixmap( pathString + "filter" );
770 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 770 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
771 connect( actionFilterMenuTB, SIGNAL( activated() ), 771 connect( actionFilterMenuTB, SIGNAL( activated() ),
772 this, SLOT( fillFilterMenuTB() ) ); 772 this, SLOT( fillFilterMenuTB() ) );
773 actionFilterMenuTB->addTo( iconToolBar ); 773 actionFilterMenuTB->addTo( iconToolBar );
774 selectFilterMenuTB = new QPopupMenu( this ); 774 selectFilterMenuTB = new QPopupMenu( this );
775 selectFilterMenuTB->setCheckable( true ); 775 selectFilterMenuTB->setCheckable( true );
776 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 776 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
777 } 777 }
778 778
779 //#endif 779 //#endif
780 // ****************** 780 // ******************
781 QAction *action; 781 QAction *action;
782 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 782 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
783 configureToolBarMenu->setCheckable( true ); 783 configureToolBarMenu->setCheckable( true );
784 784
785 785
786 configureAgendaMenu->setCheckable( true ); 786 configureAgendaMenu->setCheckable( true );
787 int iii ; 787 int iii ;
788 for ( iii = 1;iii<= 10 ;++iii ){ 788 for ( iii = 1;iii<= 10 ;++iii ){
789 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 789 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
790 } 790 }
791 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 791 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
792 792
793 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 793 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
794 this, SLOT( showConfigureAgenda( ) ) ); 794 this, SLOT( showConfigureAgenda( ) ) );
795 icon = loadPixmap( pathString + "today" ); 795 icon = loadPixmap( pathString + "today" );
796 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 796 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
797 today_action->addTo( actionMenu ); 797 today_action->addTo( actionMenu );
798 connect( today_action, SIGNAL( activated() ), 798 connect( today_action, SIGNAL( activated() ),
799 mView, SLOT( goToday() ) ); 799 mView, SLOT( goToday() ) );
800 800
801 icon = loadPixmap( pathString + "picker" ); 801 icon = loadPixmap( pathString + "picker" );
802 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); 802 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this );
803 dPickerAction->addTo( actionMenu ); 803 dPickerAction->addTo( actionMenu );
804 connect( dPickerAction, SIGNAL( activated() ), 804 connect( dPickerAction, SIGNAL( activated() ),
805 mView, SLOT( showDatePicker() ) ); 805 mView, SLOT( showDatePicker() ) );
806 806
807 icon = loadPixmap( pathString + "search" ); 807 icon = loadPixmap( pathString + "search" );
808 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 808 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
809 search_action->addTo( actionMenu ); 809 search_action->addTo( actionMenu );
810 connect( search_action, SIGNAL( activated() ), 810 connect( search_action, SIGNAL( activated() ),
811 mView->dialogManager(), SLOT( showSearchDialog() ) ); 811 mView->dialogManager(), SLOT( showSearchDialog() ) );
812 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); 812 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu );
813 813
814 action = new QAction( "Undo Delete", i18n("All events"), 0, this ); 814 action = new QAction( "Undo Delete", i18n("All events"), 0, this );
815 action->addTo( nextConflictMenu ); 815 action->addTo( nextConflictMenu );
816 connect( action, SIGNAL( activated() ), 816 connect( action, SIGNAL( activated() ),
817 mView, SLOT( conflictAll() ) ); 817 mView, SLOT( conflictAll() ) );
818 818
819 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); 819 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this );
820 action->addTo( nextConflictMenu ); 820 action->addTo( nextConflictMenu );
821 connect( action, SIGNAL( activated() ), 821 connect( action, SIGNAL( activated() ),
822 mView, SLOT( conflictAllday() ) ); 822 mView, SLOT( conflictAllday() ) );
823 823
824 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); 824 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this );
825 action->addTo( nextConflictMenu ); 825 action->addTo( nextConflictMenu );
826 connect( action, SIGNAL( activated() ), 826 connect( action, SIGNAL( activated() ),
827 mView, SLOT( conflictNotAll() ) ); 827 mView, SLOT( conflictNotAll() ) );
828 828
829 actionMenu->insertSeparator(); 829 actionMenu->insertSeparator();
830 830
831 icon = loadPixmap( pathString + "newevent" ); 831 icon = loadPixmap( pathString + "newevent" );
832 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 832 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
833 ne_action->addTo( mCurrentItemMenu ); 833 ne_action->addTo( mCurrentItemMenu );
834 connect( ne_action, SIGNAL( activated() ), 834 connect( ne_action, SIGNAL( activated() ),
835 mView, SLOT( newEvent() ) ); 835 mView, SLOT( newEvent() ) );
836 icon = loadPixmap( pathString + "newtodo" ); 836 icon = loadPixmap( pathString + "newtodo" );
837 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 837 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
838 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 838 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
839 nt_action->addTo( mCurrentItemMenu ); 839 nt_action->addTo( mCurrentItemMenu );
840 connect( nt_action, SIGNAL( activated() ), 840 connect( nt_action, SIGNAL( activated() ),
841 mView, SLOT( newTodo() ) ); 841 mView, SLOT( newTodo() ) );
842 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 842 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
843 this ); 843 this );
844 mNewSubTodoAction->addTo( mCurrentItemMenu ); 844 mNewSubTodoAction->addTo( mCurrentItemMenu );
845 connect( mNewSubTodoAction, SIGNAL( activated() ), 845 connect( mNewSubTodoAction, SIGNAL( activated() ),
846 mView, SLOT( newSubTodo() ) ); 846 mView, SLOT( newSubTodo() ) );
847 847
848 mCurrentItemMenu->insertSeparator(); 848 mCurrentItemMenu->insertSeparator();
849 icon = loadPixmap( pathString + "newevent" ); 849 icon = loadPixmap( pathString + "newevent" );
850 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 850 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
851 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 851 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
852 configureToolBarMenu->insertSeparator(); 852 configureToolBarMenu->insertSeparator();
853 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 853 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
854 configureToolBarMenu->insertSeparator(); 854 configureToolBarMenu->insertSeparator();
855 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 855 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
856 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 856 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
857 857
858 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); 858 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu);
859 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); 859 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this );
860 mShowAction->addTo( mCurrentItemMenu ); 860 mShowAction->addTo( mCurrentItemMenu );
861 connect( mShowAction, SIGNAL( activated() ), 861 connect( mShowAction, SIGNAL( activated() ),
862 mView, SLOT( showIncidence() ) ); 862 mView, SLOT( showIncidence() ) );
863 863
864 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 864 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
865 mEditAction->addTo( mCurrentItemMenu ); 865 mEditAction->addTo( mCurrentItemMenu );
866 connect( mEditAction, SIGNAL( activated() ), 866 connect( mEditAction, SIGNAL( activated() ),
867 mView, SLOT( editIncidence() ) ); 867 mView, SLOT( editIncidence() ) );
868 868
869 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 869 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
870 mDeleteAction->addTo( mCurrentItemMenu ); 870 mDeleteAction->addTo( mCurrentItemMenu );
871 connect( mDeleteAction, SIGNAL( activated() ), 871 connect( mDeleteAction, SIGNAL( activated() ),
872 mView, SLOT( deleteIncidence() ) ); 872 mView, SLOT( deleteIncidence() ) );
873 873
874 874
875 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 875 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
876 mCloneAction->addTo( mCurrentItemMenu ); 876 mCloneAction->addTo( mCurrentItemMenu );
877 connect( mCloneAction, SIGNAL( activated() ), 877 connect( mCloneAction, SIGNAL( activated() ),
878 mView, SLOT( cloneIncidence() ) ); 878 mView, SLOT( cloneIncidence() ) );
879 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 879 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
880 mMoveAction->addTo( mCurrentItemMenu ); 880 mMoveAction->addTo( mCurrentItemMenu );
881 connect( mMoveAction, SIGNAL( activated() ), 881 connect( mMoveAction, SIGNAL( activated() ),
882 mView, SLOT( moveIncidence() ) ); 882 mView, SLOT( moveIncidence() ) );
883#ifndef DESKTOP_VERSION 883#ifndef DESKTOP_VERSION
884 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 884 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
885 mBeamAction->addTo(mCurrentItemMenu ); 885 mBeamAction->addTo(mCurrentItemMenu );
886 connect( mBeamAction, SIGNAL( activated() ), 886 connect( mBeamAction, SIGNAL( activated() ),
887 mView, SLOT( beamIncidence() ) ); 887 mView, SLOT( beamIncidence() ) );
888#endif 888#endif
889 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 889 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
890 mCancelAction->addTo( mCurrentItemMenu ); 890 mCancelAction->addTo( mCurrentItemMenu );
891 connect( mCancelAction, SIGNAL( activated() ), 891 connect( mCancelAction, SIGNAL( activated() ),
892 mView, SLOT( toggleCancelIncidence() ) ); 892 mView, SLOT( toggleCancelIncidence() ) );
893 893
894 894
895 mCurrentItemMenu->insertSeparator(); 895 mCurrentItemMenu->insertSeparator();
896 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 896 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
897 action->addTo( mCurrentItemMenu ); 897 action->addTo( mCurrentItemMenu );
898 connect( action, SIGNAL( activated() ), 898 connect( action, SIGNAL( activated() ),
899 mView, SLOT( undo_delete() ) ); 899 mView, SLOT( undo_delete() ) );
900 900
901 // *********************** 901 // ***********************
902 if ( KOPrefs::instance()->mVerticalScreen ) { 902 if ( KOPrefs::instance()->mVerticalScreen ) {
903 icon = SmallIcon( "1updownarrow" ); 903 icon = SmallIcon( "1updownarrow" );
904 } else { 904 } else {
905 icon = SmallIcon("1leftrightarrow" ); 905 icon = SmallIcon("1leftrightarrow" );
906 } 906 }
907 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 907 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
908 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 908 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
909 FSaction->addTo( viewMenu ); 909 FSaction->addTo( viewMenu );
910 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 910 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
911 911
912 912
913 icon = loadPixmap( pathString + "filter" ); 913 icon = loadPixmap( pathString + "filter" );
914 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 914 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
915 icon = loadPixmap( pathString + "configure" ); 915 icon = loadPixmap( pathString + "configure" );
916 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 916 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
917 action->addTo( viewMenu ); 917 action->addTo( viewMenu );
918 connect( action, SIGNAL( activated() ), 918 connect( action, SIGNAL( activated() ),
919 mView, SLOT( toggleFilter() ) ); 919 mView, SLOT( toggleFilter() ) );
920 mToggleFilter = action; 920 mToggleFilter = action;
921 icon = loadPixmap( pathString + "navi" ); 921 icon = loadPixmap( pathString + "navi" );
922 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 922 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
923 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 923 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
924 action->addTo( viewMenu ); 924 action->addTo( viewMenu );
925 connect( action, SIGNAL( activated() ), 925 connect( action, SIGNAL( activated() ),
926 mView, SLOT( toggleDateNavigatorWidget() ) ); 926 mView, SLOT( toggleDateNavigatorWidget() ) );
927 mToggleNav = action ; 927 mToggleNav = action ;
928 icon = loadPixmap( pathString + "allday" ); 928 icon = loadPixmap( pathString + "allday" );
929 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 929 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
930 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 930 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
931 action->addTo( viewMenu ); 931 action->addTo( viewMenu );
932 connect( action, SIGNAL( activated() ), 932 connect( action, SIGNAL( activated() ),
933 mView, SLOT( toggleAllDaySize() ) ); 933 mView, SLOT( toggleAllDaySize() ) );
934 mToggleAllday = action; 934 mToggleAllday = action;
935 935
936 936
937 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 937 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
938 mToggleNav, SLOT( setEnabled ( bool ) ) ); 938 mToggleNav, SLOT( setEnabled ( bool ) ) );
939 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 939 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
940 // mToggleFilter, SLOT( setEnabled ( bool ) ) ); 940 // mToggleFilter, SLOT( setEnabled ( bool ) ) );
941 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 941 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
942 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 942 mToggleAllday, SLOT( setEnabled ( bool ) ) );
943 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 943 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
944 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 944 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
945 945
946 946
947 dPickerAction->addTo( iconToolBar ); 947 dPickerAction->addTo( iconToolBar );
948 viewMenu->insertSeparator(); 948 viewMenu->insertSeparator();
949 949
950 if ( p-> mShowIconToggleFull ) 950 if ( p-> mShowIconToggleFull )
951 FSaction->addTo( iconToolBar ); 951 FSaction->addTo( iconToolBar );
952 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 952 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
953 953
954 //******************** 954 //********************
955 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 955 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
956 956
957 957
958 icon = loadPixmap( pathString + "whatsnext" ); 958 icon = loadPixmap( pathString + "whatsnext" );
959 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 959 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
960 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 960 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
961 whatsnext_action->addTo( viewMenu ); 961 whatsnext_action->addTo( viewMenu );
962 connect( whatsnext_action, SIGNAL( activated() ), 962 connect( whatsnext_action, SIGNAL( activated() ),
963 mView->viewManager(), SLOT( showWhatsNextView() ) ); 963 mView->viewManager(), SLOT( showWhatsNextView() ) );
964 964
965 icon = loadPixmap( pathString + "xdays" ); 965 icon = loadPixmap( pathString + "xdays" );
966 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 966 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
967 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 967 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
968 xdays_action->addTo( viewMenu ); 968 xdays_action->addTo( viewMenu );
969 connect( xdays_action, SIGNAL( activated() ), 969 connect( xdays_action, SIGNAL( activated() ),
970 mView->viewManager(), SLOT( showNextXView() ) ); 970 mView->viewManager(), SLOT( showNextXView() ) );
971 971
972 972
973 icon = loadPixmap( pathString + "journal" ); 973 icon = loadPixmap( pathString + "journal" );
974 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 974 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
975 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 975 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
976 viewjournal_action->addTo( viewMenu ); 976 viewjournal_action->addTo( viewMenu );
977 connect( viewjournal_action, SIGNAL( activated() ), 977 connect( viewjournal_action, SIGNAL( activated() ),
978 mView->viewManager(), SLOT( showJournalView() ) ); 978 mView->viewManager(), SLOT( showJournalView() ) );
979 979
980 980
981 icon = loadPixmap( pathString + "day" ); 981 icon = loadPixmap( pathString + "day" );
982 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 982 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
983 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 983 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
984 day1_action->addTo( viewMenu ); 984 day1_action->addTo( viewMenu );
985 // action->addTo( toolBar ); 985 // action->addTo( toolBar );
986 connect( day1_action, SIGNAL( activated() ), 986 connect( day1_action, SIGNAL( activated() ),
987 mView->viewManager(), SLOT( showDayView() ) ); 987 mView->viewManager(), SLOT( showDayView() ) );
988 988
989 icon = loadPixmap( pathString + "workweek" ); 989 icon = loadPixmap( pathString + "workweek" );
990 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 990 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
991 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 991 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
992 day5_action->addTo( viewMenu ); 992 day5_action->addTo( viewMenu );
993 connect( day5_action, SIGNAL( activated() ), 993 connect( day5_action, SIGNAL( activated() ),
994 mView->viewManager(), SLOT( showWorkWeekView() ) ); 994 mView->viewManager(), SLOT( showWorkWeekView() ) );
995 995
996 icon = loadPixmap( pathString + "week" ); 996 icon = loadPixmap( pathString + "week" );
997 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 997 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
998 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 998 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
999 day7_action->addTo( viewMenu ); 999 day7_action->addTo( viewMenu );
1000 connect( day7_action, SIGNAL( activated() ), 1000 connect( day7_action, SIGNAL( activated() ),
1001 mView->viewManager(), SLOT( showWeekView() ) ); 1001 mView->viewManager(), SLOT( showWeekView() ) );
1002 1002
1003 icon = loadPixmap( pathString + "workweek2" ); 1003 icon = loadPixmap( pathString + "workweek2" );
1004 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 1004 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
1005 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 1005 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
1006 day6_action->addTo( viewMenu ); 1006 day6_action->addTo( viewMenu );
1007 connect( day6_action, SIGNAL( activated() ), 1007 connect( day6_action, SIGNAL( activated() ),
1008 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 1008 mView->viewManager(), SLOT( showMonthViewWeek() ) );
1009 1009
1010 icon = loadPixmap( pathString + "month" ); 1010 icon = loadPixmap( pathString + "month" );
1011 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 1011 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
1012 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 1012 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
1013 month_action->addTo( viewMenu ); 1013 month_action->addTo( viewMenu );
1014 connect( month_action, SIGNAL( activated() ), 1014 connect( month_action, SIGNAL( activated() ),
1015 mView->viewManager(), SLOT( showMonthView() ) ); 1015 mView->viewManager(), SLOT( showMonthView() ) );
1016 1016
1017 icon = loadPixmap( pathString + "list" ); 1017 icon = loadPixmap( pathString + "list" );
1018 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 1018 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
1019 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 1019 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
1020 showlist_action->addTo( viewMenu ); 1020 showlist_action->addTo( viewMenu );
1021 connect( showlist_action, SIGNAL( activated() ), 1021 connect( showlist_action, SIGNAL( activated() ),
1022 mView->viewManager(), SLOT( showListView() ) ); 1022 mView->viewManager(), SLOT( showListView() ) );
1023 1023
1024 icon = loadPixmap( pathString + "todo" ); 1024 icon = loadPixmap( pathString + "todo" );
1025 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 1025 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
1026 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 1026 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
1027 todoview_action->addTo( viewMenu ); 1027 todoview_action->addTo( viewMenu );
1028 connect( todoview_action, SIGNAL( activated() ), 1028 connect( todoview_action, SIGNAL( activated() ),
1029 mView->viewManager(), SLOT( showTodoView() ) ); 1029 mView->viewManager(), SLOT( showTodoView() ) );
1030 1030
1031 1031
1032 1032
1033#if 0 1033#if 0
1034 action = new QAction( "view_timespan", "Time Span", 0, this ); 1034 action = new QAction( "view_timespan", "Time Span", 0, this );
1035 action->addTo( viewMenu ); 1035 action->addTo( viewMenu );
1036 connect( action, SIGNAL( activated() ), 1036 connect( action, SIGNAL( activated() ),
1037 mView->viewManager(), SLOT( showTimeSpanView() ) ); 1037 mView->viewManager(), SLOT( showTimeSpanView() ) );
1038#endif 1038#endif
1039 1039
1040 1040
1041 1041
1042 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, 1042 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0,
1043 this ); 1043 this );
1044 action->addTo( actionMenu ); 1044 action->addTo( actionMenu );
1045 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 1045 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
1046 1046
1047 1047
1048 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 1048 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
1049 1049
1050 1050
1051 1051
1052 actionMenu->insertSeparator(); 1052 actionMenu->insertSeparator();
1053 action = new QAction( "manage cat", i18n("Edit category list..."), 0, 1053 action = new QAction( "manage cat", i18n("Edit category list..."), 0,
1054 this ); 1054 this );
1055 action->addTo( actionMenu ); 1055 action->addTo( actionMenu );
1056 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); 1056 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) );
1057 1057
1058 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1058 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1059 this ); 1059 this );
1060 action->addTo( actionMenu ); 1060 action->addTo( actionMenu );
1061 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1061 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1062 1062
1063 1063
1064 actionMenu->insertSeparator(); 1064 actionMenu->insertSeparator();
1065 icon = loadPixmap( pathString + "configure" ); 1065 icon = loadPixmap( pathString + "configure" );
1066 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 1066 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
1067 action->addTo( actionMenu ); 1067 action->addTo( actionMenu );
1068 connect( action, SIGNAL( activated() ), 1068 connect( action, SIGNAL( activated() ),
1069 mView, SLOT( edit_options() ) ); 1069 mView, SLOT( edit_options() ) );
1070 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); 1070 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this );
1071 action->addTo( actionMenu ); 1071 action->addTo( actionMenu );
1072 connect( action, SIGNAL( activated() ), 1072 connect( action, SIGNAL( activated() ),
1073 this, SLOT( calHint() ) ); 1073 this, SLOT( calHint() ) );
1074 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 1074 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
1075 action->addTo( actionMenu ); 1075 action->addTo( actionMenu );
1076 connect( action, SIGNAL( activated() ), 1076 connect( action, SIGNAL( activated() ),
1077 mView, SLOT( edit_global_options() ) ); 1077 mView, SLOT( edit_global_options() ) );
1078 if ( KOPrefs::instance()->mShowFullMenu ) { 1078 if ( KOPrefs::instance()->mShowFullMenu ) {
1079 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 1079 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
1080 1080
1081 } 1081 }
1082 // actionMenu->insertSeparator(); 1082 // actionMenu->insertSeparator();
1083 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 1083 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
1084 this ); 1084 this );
1085 action->addTo( importMenu_X ); 1085 action->addTo( importMenu_X );
1086 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 1086 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
1087 action = new QAction( "import_quick", i18n("Import last file"), 0, 1087 action = new QAction( "import_quick", i18n("Import last file"), 0,
1088 this ); 1088 this );
1089 action->addTo( importMenu_X ); 1089 action->addTo( importMenu_X );
1090 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 1090 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
1091 importMenu_X->insertSeparator(); 1091 importMenu_X->insertSeparator();
1092 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 1092 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
1093 this ); 1093 this );
1094 action->addTo( importMenu_X ); 1094 action->addTo( importMenu_X );
1095 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 1095 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
1096 //#ifndef DESKTOP_VERSION 1096 //#ifndef DESKTOP_VERSION
1097 importMenu_X->insertSeparator(); 1097 importMenu_X->insertSeparator();
1098 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 1098 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
1099 this ); 1099 this );
1100 action->addTo( importMenu_X ); 1100 action->addTo( importMenu_X );
1101 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1101 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1102 //#else 1102 //#else
1103#ifdef _OL_IMPORT_ 1103#ifdef _OL_IMPORT_
1104 importMenu_X->insertSeparator(); 1104 importMenu_X->insertSeparator();
1105 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1105 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1106 this ); 1106 this );
1107 action->addTo( importMenu_X ); 1107 action->addTo( importMenu_X );
1108 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1108 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1109#endif 1109#endif
1110 //#endif 1110 //#endif
1111 1111
1112 //importMenu->insertSeparator(); 1112 //importMenu->insertSeparator();
1113#if 0 1113#if 0
1114 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1114 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1115 this ); 1115 this );
1116 action->addTo( importMenu ); 1116 action->addTo( importMenu );
1117 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1117 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1118#endif 1118#endif
1119 action = new QAction( "save_cal", i18n("Save Backup..."), 0, 1119 action = new QAction( "save_cal", i18n("Save Backup..."), 0,
1120 this ); 1120 this );
1121 action->addTo( importMenu ); 1121 action->addTo( importMenu );
1122 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1122 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1123 importMenu->insertSeparator(); 1123 importMenu->insertSeparator();
1124 importMenu->insertItem( i18n("Import"), importMenu_X ); 1124 importMenu->insertItem( i18n("Import"), importMenu_X );
1125 //importMenu->insertSeparator(); 1125 //importMenu->insertSeparator();
1126 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1126 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1127 this ); 1127 this );
1128 action->addTo( exportMenu_X ); 1128 action->addTo( exportMenu_X );
1129 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1129 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1130 1130
1131 1131
1132 //LR 1132 //LR
1133 QPopupMenu *ex2phone = new QPopupMenu( this ); 1133 QPopupMenu *ex2phone = new QPopupMenu( this );
1134 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1134 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1135 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1135 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1136 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1136 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1137 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1137 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1138 1138
1139 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1139 importMenu->insertItem( i18n("Export"), exportMenu_X );
1140 mPrintSelAction = 0; 1140 mPrintSelAction = 0;
1141#ifndef DESKTOP_VERSION 1141#ifndef DESKTOP_VERSION
1142 //importMenu->insertSeparator(); 1142 //importMenu->insertSeparator();
1143 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1143 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1144 this ); 1144 this );
1145 brAction->addTo( beamMenu_X ); 1145 brAction->addTo( beamMenu_X );
1146 brAction->setToggleAction (true ) ; 1146 brAction->setToggleAction (true ) ;
1147 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1147 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1148 1148
1149 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1149 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1150 this ); 1150 this );
1151 action->addTo( beamMenu_X ); 1151 action->addTo( beamMenu_X );
1152 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1152 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1153 1153
1154 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1154 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1155 this ); 1155 this );
1156 action->addTo( beamMenu_X ); 1156 action->addTo( beamMenu_X );
1157 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1157 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1158 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1158 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1159#else 1159#else
1160 //importMenu->insertSeparator(); 1160 //importMenu->insertSeparator();
1161 icon = loadPixmap( pathString + "print" ); 1161 icon = loadPixmap( pathString + "print" );
1162 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1162 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1163 action->addTo( beamMenu_X ); 1163 action->addTo( beamMenu_X );
1164 connect( action, SIGNAL( activated() ), 1164 connect( action, SIGNAL( activated() ),
1165 this, SLOT( printCal() ) ); 1165 this, SLOT( printCal() ) );
1166 1166
1167 icon = loadPixmap( pathString + "week" ); 1167 icon = loadPixmap( pathString + "week" );
1168 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1168 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1169 action->addTo( beamMenu_X ); 1169 action->addTo( beamMenu_X );
1170 connect( action, SIGNAL( activated() ), 1170 connect( action, SIGNAL( activated() ),
1171 this, SLOT( printSel() ) ); 1171 this, SLOT( printSel() ) );
1172 icon = loadPixmap( pathString + "whatsnext" ); 1172 icon = loadPixmap( pathString + "whatsnext" );
1173 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1173 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1174 action->addTo( beamMenu_X ); 1174 action->addTo( beamMenu_X );
1175 connect( action, SIGNAL( activated() ), 1175 connect( action, SIGNAL( activated() ),
1176 mView->viewManager(), SLOT( slotprintWNV() ) ); 1176 mView->viewManager(), SLOT( slotprintWNV() ) );
1177 1177
1178 1178
1179 icon = loadPixmap( pathString + "list" ); 1179 icon = loadPixmap( pathString + "list" );
1180 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1180 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1181 action->addTo( beamMenu_X ); 1181 action->addTo( beamMenu_X );
1182 connect( action, SIGNAL( activated() ), 1182 connect( action, SIGNAL( activated() ),
1183 this, SLOT( printListView() ) ); 1183 this, SLOT( printListView() ) );
1184 1184
1185 icon = loadPixmap( pathString + "newevent" ); 1185 icon = loadPixmap( pathString + "newevent" );
1186 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1186 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1187 action->addTo( beamMenu_X ); 1187 action->addTo( beamMenu_X );
1188 connect( action, SIGNAL( activated() ), 1188 connect( action, SIGNAL( activated() ),
1189 mView, SLOT( slotprintSelInc() ) ); 1189 mView, SLOT( slotprintSelInc() ) );
1190 mPrintSelAction = action; 1190 mPrintSelAction = action;
1191 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1191 importMenu->insertItem( i18n("Print"), beamMenu_X );
1192#endif 1192#endif
1193 1193
1194 importMenu->insertSeparator(); 1194 importMenu->insertSeparator();
1195 action = new QAction( "beam all", i18n("Save"), 0, 1195 action = new QAction( "beam all", i18n("Save"), 0,
1196 this ); 1196 this );
1197 action->addTo( importMenu ); 1197 action->addTo( importMenu );
1198 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1198 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1199 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1199 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1200 this ); 1200 this );
1201 action->addTo( importMenu ); 1201 action->addTo( importMenu );
1202 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1202 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1203 1203
1204 //menuBar->insertItem( "Configure",configureMenu ); 1204 //menuBar->insertItem( "Configure",configureMenu );
1205 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1205 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1206 icon = loadPixmap( "korganizer/korganizer" ); 1206 icon = loadPixmap( "korganizer/korganizer" );
1207 1207
1208 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1208 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1209 action->addTo( helpMenu ); 1209 action->addTo( helpMenu );
1210 connect( action, SIGNAL( activated() ), 1210 connect( action, SIGNAL( activated() ),
1211 SLOT( whatsNew() ) ); 1211 SLOT( whatsNew() ) );
1212 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1212 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1213 action->addTo( helpMenu ); 1213 action->addTo( helpMenu );
1214 connect( action, SIGNAL( activated() ), 1214 connect( action, SIGNAL( activated() ),
1215 SLOT( features() ) ); 1215 SLOT( features() ) );
1216 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1216 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1217 action->addTo( helpMenu ); 1217 action->addTo( helpMenu );
1218 connect( action, SIGNAL( activated() ), 1218 connect( action, SIGNAL( activated() ),
1219 SLOT( keyBindings() ) ); 1219 SLOT( keyBindings() ) );
1220 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1220 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1221 action->addTo( helpMenu ); 1221 action->addTo( helpMenu );
1222 connect( action, SIGNAL( activated() ), 1222 connect( action, SIGNAL( activated() ),
1223 SLOT( storagehowto() ) ); 1223 SLOT( storagehowto() ) );
1224 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1224 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1225 action->addTo( helpMenu ); 1225 action->addTo( helpMenu );
1226 connect( action, SIGNAL( activated() ), 1226 connect( action, SIGNAL( activated() ),
1227 SLOT( timetrackinghowto() ) ); 1227 SLOT( timetrackinghowto() ) );
1228 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1228 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1229 action->addTo( helpMenu ); 1229 action->addTo( helpMenu );
1230 connect( action, SIGNAL( activated() ), 1230 connect( action, SIGNAL( activated() ),
1231 SLOT( synchowto() ) ); 1231 SLOT( synchowto() ) );
1232 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1232 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1233 action->addTo( helpMenu ); 1233 action->addTo( helpMenu );
1234 connect( action, SIGNAL( activated() ), 1234 connect( action, SIGNAL( activated() ),
1235 SLOT( kdesynchowto() ) ); 1235 SLOT( kdesynchowto() ) );
1236 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1236 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1237 action->addTo( helpMenu ); 1237 action->addTo( helpMenu );
1238 connect( action, SIGNAL( activated() ), 1238 connect( action, SIGNAL( activated() ),
1239 SLOT( multisynchowto() ) ); 1239 SLOT( multisynchowto() ) );
1240 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1240 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1241 action->addTo( helpMenu ); 1241 action->addTo( helpMenu );
1242 connect( action, SIGNAL( activated() ), 1242 connect( action, SIGNAL( activated() ),
1243 SLOT( aboutAutoSaving() ) ); 1243 SLOT( aboutAutoSaving() ) );
1244 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1244 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1245 action->addTo( helpMenu ); 1245 action->addTo( helpMenu );
1246 connect( action, SIGNAL( activated() ), 1246 connect( action, SIGNAL( activated() ),
1247 SLOT( aboutKnownBugs() ) ); 1247 SLOT( aboutKnownBugs() ) );
1248 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1248 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1249 action->addTo( helpMenu ); 1249 action->addTo( helpMenu );
1250 connect( action, SIGNAL( activated() ), 1250 connect( action, SIGNAL( activated() ),
1251 SLOT( usertrans() ) ); 1251 SLOT( usertrans() ) );
1252 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1252 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1253 action->addTo( helpMenu ); 1253 action->addTo( helpMenu );
1254 connect( action, SIGNAL( activated() ), 1254 connect( action, SIGNAL( activated() ),
1255 SLOT( faq() ) ); 1255 SLOT( faq() ) );
1256 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1256 action = new QAction( "licence", i18n("Licence..."), 0, this );
1257 action->addTo( helpMenu ); 1257 action->addTo( helpMenu );
1258 connect( action, SIGNAL( activated() ), 1258 connect( action, SIGNAL( activated() ),
1259 SLOT( licence() ) ); 1259 SLOT( licence() ) );
1260 action = new QAction( "about", i18n("About..."), 0, this ); 1260 action = new QAction( "about", i18n("About..."), 0, this );
1261 action->addTo( helpMenu ); 1261 action->addTo( helpMenu );
1262 connect( action, SIGNAL( activated() ), 1262 connect( action, SIGNAL( activated() ),
1263 SLOT( about() ) ); 1263 SLOT( about() ) );
1264 //menuBar->insertSeparator(); 1264 //menuBar->insertSeparator();
1265 1265
1266 // ****************************************************** 1266 // ******************************************************
1267 // menubar icons 1267 // menubar icons
1268 1268
1269 1269
1270 1270
1271 //menuBar->insertItem( iconToolBar ); 1271 //menuBar->insertItem( iconToolBar );
1272 //xdays_action 1272 //xdays_action
1273 if (p-> mShowIconNewEvent) 1273 if (p-> mShowIconNewEvent)
1274 ne_action->addTo( iconToolBar ); 1274 ne_action->addTo( iconToolBar );
1275 if (p->mShowIconNewTodo ) 1275 if (p->mShowIconNewTodo )
1276 nt_action->addTo( iconToolBar ); 1276 nt_action->addTo( iconToolBar );
1277 if (p-> mShowIconSearch) 1277 if (p-> mShowIconSearch)
1278 search_action->addTo( iconToolBar ); 1278 search_action->addTo( iconToolBar );
1279 if (p-> mShowIconWhatsThis) 1279 if (p-> mShowIconWhatsThis)
1280 QWhatsThis::whatsThisButton ( iconToolBar ); 1280 QWhatsThis::whatsThisButton ( iconToolBar );
1281 if (p-> mShowIconNext) 1281 if (p-> mShowIconNext)
1282 whatsnext_action->addTo( viewToolBar ); 1282 whatsnext_action->addTo( viewToolBar );
1283 if (p-> mShowIconNextDays) 1283 if (p-> mShowIconNextDays)
1284 xdays_action->addTo( viewToolBar ); 1284 xdays_action->addTo( viewToolBar );
1285 if (p-> mShowIconJournal) 1285 if (p-> mShowIconJournal)
1286 viewjournal_action->addTo( viewToolBar ); 1286 viewjournal_action->addTo( viewToolBar );
1287 if (p-> mShowIconDay1) 1287 if (p-> mShowIconDay1)
1288 day1_action->addTo( viewToolBar ); 1288 day1_action->addTo( viewToolBar );
1289 if (p-> mShowIconDay5) 1289 if (p-> mShowIconDay5)
1290 day5_action->addTo( viewToolBar ); 1290 day5_action->addTo( viewToolBar );
1291 if (p-> mShowIconDay7) 1291 if (p-> mShowIconDay7)
1292 day7_action->addTo( viewToolBar ); 1292 day7_action->addTo( viewToolBar );
1293 if (p-> mShowIconDay6) 1293 if (p-> mShowIconDay6)
1294 day6_action->addTo( viewToolBar ); 1294 day6_action->addTo( viewToolBar );
1295 if (p-> mShowIconMonth) 1295 if (p-> mShowIconMonth)
1296 month_action->addTo( viewToolBar ); 1296 month_action->addTo( viewToolBar );
1297 if (p-> mShowIconList) 1297 if (p-> mShowIconList)
1298 showlist_action->addTo( viewToolBar ); 1298 showlist_action->addTo( viewToolBar );
1299 if (p-> mShowIconTodoview) 1299 if (p-> mShowIconTodoview)
1300 todoview_action->addTo( viewToolBar ); 1300 todoview_action->addTo( viewToolBar );
1301 1301
1302 icon = loadPixmap( pathString + "2leftarrowB" ); 1302 icon = loadPixmap( pathString + "2leftarrowB" );
1303 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1303 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1304 if (p-> mShowIconBackFast) { 1304 if (p-> mShowIconBackFast) {
1305 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1305 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1306 connect( action, SIGNAL( activated() ), 1306 connect( action, SIGNAL( activated() ),
1307 mView, SLOT( goPreviousMonth() ) ); 1307 mView, SLOT( goPreviousMonth() ) );
1308 action->addTo( navigatorToolBar ); 1308 action->addTo( navigatorToolBar );
1309 } 1309 }
1310 icon = loadPixmap( pathString + "1leftarrowB" ); 1310 icon = loadPixmap( pathString + "1leftarrowB" );
1311 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1311 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1312 if (p-> mShowIconBack) { 1312 if (p-> mShowIconBack) {
1313 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1313 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1314 connect( action, SIGNAL( activated() ), 1314 connect( action, SIGNAL( activated() ),
1315 mView, SLOT( goPrevious() ) ); 1315 mView, SLOT( goPrevious() ) );
1316 action->addTo( navigatorToolBar ); 1316 action->addTo( navigatorToolBar );
1317 } 1317 }
1318 icon = loadPixmap( pathString + "today" ); 1318 icon = loadPixmap( pathString + "today" );
1319 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1319 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1320 if (p-> mShowIconToday) 1320 if (p-> mShowIconToday)
1321 today_action->addTo( navigatorToolBar ); 1321 today_action->addTo( navigatorToolBar );
1322 icon = loadPixmap( pathString + "1rightarrowB" ); 1322 icon = loadPixmap( pathString + "1rightarrowB" );
1323 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1323 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1324 if (p-> mShowIconForward) { 1324 if (p-> mShowIconForward) {
1325 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1325 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1326 connect( action, SIGNAL( activated() ), 1326 connect( action, SIGNAL( activated() ),
1327 mView, SLOT( goNext() ) ); 1327 mView, SLOT( goNext() ) );
1328 action->addTo( navigatorToolBar ); 1328 action->addTo( navigatorToolBar );
1329 } 1329 }
1330 icon = loadPixmap( pathString + "2rightarrowB" ); 1330 icon = loadPixmap( pathString + "2rightarrowB" );
1331 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1331 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1332 if (p-> mShowIconForwardFast) { 1332 if (p-> mShowIconForwardFast) {
1333 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1333 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1334 connect( action, SIGNAL( activated() ), 1334 connect( action, SIGNAL( activated() ),
1335 mView, SLOT( goNextMonth() ) ); 1335 mView, SLOT( goNextMonth() ) );
1336 action->addTo( navigatorToolBar ); 1336 action->addTo( navigatorToolBar );
1337 } 1337 }
1338 1338
1339 1339
1340 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1340 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1341 1341
1342 1342
1343 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1343 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1344 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1344 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1345 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1345 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1346 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1346 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1347 1347
1348 if (p-> mShowIconNewEvent) 1348 if (p-> mShowIconNewEvent)
1349 configureToolBarMenu->setItemChecked( 10, true ); 1349 configureToolBarMenu->setItemChecked( 10, true );
1350 if (p->mShowIconNewTodo ) 1350 if (p->mShowIconNewTodo )
1351 configureToolBarMenu->setItemChecked( 20, true ); 1351 configureToolBarMenu->setItemChecked( 20, true );
1352 if (p-> mShowIconSearch) 1352 if (p-> mShowIconSearch)
1353 configureToolBarMenu->setItemChecked( 120, true ); 1353 configureToolBarMenu->setItemChecked( 120, true );
1354 if (p-> mShowIconList) 1354 if (p-> mShowIconList)
1355 configureToolBarMenu->setItemChecked( 30, true ); 1355 configureToolBarMenu->setItemChecked( 30, true );
1356 if (p-> mShowIconDay1) 1356 if (p-> mShowIconDay1)
1357 configureToolBarMenu->setItemChecked( 40, true ); 1357 configureToolBarMenu->setItemChecked( 40, true );
1358 if (p-> mShowIconDay5) 1358 if (p-> mShowIconDay5)
1359 configureToolBarMenu->setItemChecked( 50, true ); 1359 configureToolBarMenu->setItemChecked( 50, true );
1360 if (p-> mShowIconDay6) 1360 if (p-> mShowIconDay6)
1361 configureToolBarMenu->setItemChecked( 75, true ); 1361 configureToolBarMenu->setItemChecked( 75, true );
1362 if (p-> mShowIconDay7) 1362 if (p-> mShowIconDay7)
1363 configureToolBarMenu->setItemChecked( 60, true ); 1363 configureToolBarMenu->setItemChecked( 60, true );
1364 if (p-> mShowIconMonth) 1364 if (p-> mShowIconMonth)
1365 configureToolBarMenu->setItemChecked( 70, true ); 1365 configureToolBarMenu->setItemChecked( 70, true );
1366 if (p-> mShowIconTodoview) 1366 if (p-> mShowIconTodoview)
1367 configureToolBarMenu->setItemChecked( 80, true ); 1367 configureToolBarMenu->setItemChecked( 80, true );
1368 if (p-> mShowIconBackFast) 1368 if (p-> mShowIconBackFast)
1369 configureToolBarMenu->setItemChecked( 200, true ); 1369 configureToolBarMenu->setItemChecked( 200, true );
1370 if (p-> mShowIconBack) 1370 if (p-> mShowIconBack)
1371 configureToolBarMenu->setItemChecked( 210, true ); 1371 configureToolBarMenu->setItemChecked( 210, true );
1372 if (p-> mShowIconToday) 1372 if (p-> mShowIconToday)
1373 configureToolBarMenu->setItemChecked( 130, true ); 1373 configureToolBarMenu->setItemChecked( 130, true );
1374 if (p-> mShowIconForward) 1374 if (p-> mShowIconForward)
1375 configureToolBarMenu->setItemChecked( 220, true ); 1375 configureToolBarMenu->setItemChecked( 220, true );
1376 if (p-> mShowIconForwardFast) 1376 if (p-> mShowIconForwardFast)
1377 configureToolBarMenu->setItemChecked( 230, true ); 1377 configureToolBarMenu->setItemChecked( 230, true );
1378 if (p-> mShowIconNextDays) 1378 if (p-> mShowIconNextDays)
1379 configureToolBarMenu->setItemChecked( 100, true ); 1379 configureToolBarMenu->setItemChecked( 100, true );
1380 if (p-> mShowIconNext) 1380 if (p-> mShowIconNext)
1381 configureToolBarMenu->setItemChecked( 110, true ); 1381 configureToolBarMenu->setItemChecked( 110, true );
1382 if (p-> mShowIconJournal) 1382 if (p-> mShowIconJournal)
1383 configureToolBarMenu->setItemChecked( 90, true ); 1383 configureToolBarMenu->setItemChecked( 90, true );
1384 if (p-> mShowIconWhatsThis) 1384 if (p-> mShowIconWhatsThis)
1385 configureToolBarMenu->setItemChecked( 300, true ); 1385 configureToolBarMenu->setItemChecked( 300, true );
1386 if (p-> mShowIconWeekNum) 1386 if (p-> mShowIconWeekNum)
1387 configureToolBarMenu->setItemChecked( 400, true ); 1387 configureToolBarMenu->setItemChecked( 400, true );
1388 if (!p-> mShowIconStretch) { 1388 if (!p-> mShowIconStretch) {
1389 QLabel* dummy = new QLabel( iconToolBar ); 1389 QLabel* dummy = new QLabel( iconToolBar );
1390 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1390 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1391 dummy->setMinimumWidth( 0 ); 1391 dummy->setMinimumWidth( 0 );
1392 iconToolBar->setStretchableWidget ( dummy ) ; 1392 iconToolBar->setStretchableWidget ( dummy ) ;
1393 } 1393 }
1394 else { 1394 else {
1395 iconToolBar->setHorizontalStretchable (true ); 1395 iconToolBar->setHorizontalStretchable (true );
1396 viewToolBar->setHorizontalStretchable (true ); 1396 viewToolBar->setHorizontalStretchable (true );
1397 navigatorToolBar->setHorizontalStretchable (true ); 1397 navigatorToolBar->setHorizontalStretchable (true );
1398 iconToolBar->setVerticalStretchable (true ); 1398 iconToolBar->setVerticalStretchable (true );
1399 viewToolBar->setVerticalStretchable (true ); 1399 viewToolBar->setVerticalStretchable (true );
1400 navigatorToolBar->setVerticalStretchable (true ); 1400 navigatorToolBar->setVerticalStretchable (true );
1401 configureToolBarMenu->setItemChecked( 5, true ); 1401 configureToolBarMenu->setItemChecked( 5, true );
1402 } 1402 }
1403 if (p-> mShowIconFilter) 1403 if (p-> mShowIconFilter)
1404 configureToolBarMenu->setItemChecked( 7, true ); 1404 configureToolBarMenu->setItemChecked( 7, true );
1405 if (p-> mShowIconOnetoolbar) 1405 if (p-> mShowIconOnetoolbar)
1406 configureToolBarMenu->setItemChecked( 6, true ); 1406 configureToolBarMenu->setItemChecked( 6, true );
1407 1407
1408 1408
1409 if ( filterMenubar ) { 1409 if ( filterMenubar ) {
1410 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1410 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1411 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1411 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1412 } 1412 }
1413 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1413 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1414 configureAgenda( p->mHourSize ); 1414 configureAgenda( p->mHourSize );
1415 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1415 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1416} 1416}
1417void MainWindow::calHint() 1417void MainWindow::calHint()
1418{ 1418{
1419 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); 1419 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.");
1420 1420
1421 KMessageBox::information( this, message); 1421 KMessageBox::information( this, message);
1422} 1422}
1423void MainWindow::exportToPhone( int mode ) 1423void MainWindow::exportToPhone( int mode )
1424{ 1424{
1425 1425
1426 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1426 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1427 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1427 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1428 KOex2phonePrefs ex2phone; 1428 KOex2phonePrefs ex2phone;
1429 1429
1430 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1430 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1431 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1431 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1432 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1432 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1433 if ( mode == 1 ) 1433 if ( mode == 1 )
1434 ex2phone.setCaption(i18n("Export complete calendar")); 1434 ex2phone.setCaption(i18n("Export complete calendar"));
1435 if ( mode == 2 ) 1435 if ( mode == 2 )
1436 ex2phone.setCaption(i18n("Export filtered calendar")); 1436 ex2phone.setCaption(i18n("Export filtered calendar"));
1437 1437
1438 if ( !ex2phone.exec() ) { 1438 if ( !ex2phone.exec() ) {
1439 return; 1439 return;
1440 } 1440 }
1441 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1441 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1442 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1442 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1443 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1443 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1444 1444
1445 int inFuture = 0; 1445 int inFuture = 0;
1446 if ( ex2phone.mWriteBackFuture->isChecked() ) 1446 if ( ex2phone.mWriteBackFuture->isChecked() )
1447 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1447 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1448 QPtrList<Incidence> delSel; 1448 QPtrList<Incidence> delSel;
1449 if ( mode == 1 ) 1449 if ( mode == 1 )
1450 delSel = mCalendar->rawIncidences(); 1450 delSel = mCalendar->rawIncidences();
1451 if ( mode == 2 ) 1451 if ( mode == 2 )
1452 delSel = mCalendar->incidences(); 1452 delSel = mCalendar->incidences();
1453 CalendarLocal* cal = new CalendarLocal(); 1453 CalendarLocal* cal = new CalendarLocal();
1454 cal->setLocalTime(); 1454 cal->setLocalTime();
1455 Incidence *incidence = delSel.first(); 1455 Incidence *incidence = delSel.first();
1456 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1456 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1457 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1457 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1458 while ( incidence ) { 1458 while ( incidence ) {
1459 if ( incidence->typeID() != journalID ) { 1459 if ( incidence->typeID() != journalID ) {
1460 bool add = true; 1460 bool add = true;
1461 if ( inFuture ) { 1461 if ( inFuture ) {
1462 QDateTime dt; 1462 QDateTime dt;
1463 if ( incidence->typeID() == todoID ) { 1463 if ( incidence->typeID() == todoID ) {
1464 Todo * t = (Todo*)incidence; 1464 Todo * t = (Todo*)incidence;
1465 if ( t->hasDueDate() ) 1465 if ( t->hasDueDate() )
1466 dt = t->dtDue(); 1466 dt = t->dtDue();
1467 else 1467 else
1468 dt = cur.addSecs( 62 ); 1468 dt = cur.addSecs( 62 );
1469 } 1469 }
1470 else { 1470 else {
1471 bool ok; 1471 bool ok;
1472 dt = incidence->getNextOccurence( cur, &ok ); 1472 dt = incidence->getNextOccurence( cur, &ok );
1473 if ( !ok ) 1473 if ( !ok )
1474 dt = cur.addSecs( -62 ); 1474 dt = cur.addSecs( -62 );
1475 } 1475 }
1476 if ( dt < cur || dt > end ) { 1476 if ( dt < cur || dt > end ) {
1477 add = false; 1477 add = false;
1478 } 1478 }
1479 } 1479 }
1480 if ( add ) { 1480 if ( add ) {
1481 Incidence *in = incidence->clone(); 1481 Incidence *in = incidence->clone();
1482 cal->addIncidence( in ); 1482 cal->addIncidence( in );
1483 } 1483 }
1484 } 1484 }
1485 incidence = delSel.next(); 1485 incidence = delSel.next();
1486 } 1486 }
1487 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1487 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1488 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1488 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1489 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1489 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1490 1490
1491 setCaption( i18n("Writing to phone...")); 1491 setCaption( i18n("Writing to phone..."));
1492 if ( PhoneFormat::writeToPhone( cal ) ) 1492 if ( PhoneFormat::writeToPhone( cal ) )
1493 setCaption( i18n("Export to phone successful!")); 1493 setCaption( i18n("Export to phone successful!"));
1494 else 1494 else
1495 setCaption( i18n("Error exporting to phone!")); 1495 setCaption( i18n("Error exporting to phone!"));
1496 delete cal; 1496 delete cal;
1497} 1497}
1498 1498
1499 1499
1500void MainWindow::setDefaultPreferences() 1500void MainWindow::setDefaultPreferences()
1501{ 1501{
1502 KOPrefs *p = KOPrefs::instance(); 1502 KOPrefs *p = KOPrefs::instance();
1503 1503
1504 p->mCompactDialogs = true; 1504 p->mCompactDialogs = true;
1505 p->mConfirm = true; 1505 p->mConfirm = true;
1506 // p->mEnableQuickTodo = false; 1506 // p->mEnableQuickTodo = false;
1507 1507
1508} 1508}
1509 1509
1510QString MainWindow::resourcePath() 1510QString MainWindow::resourcePath()
1511{ 1511{
1512 return KGlobal::iconLoader()->iconPath(); 1512 return KGlobal::iconLoader()->iconPath();
1513} 1513}
1514 1514
1515void MainWindow::displayText( QString text ,QString cap ) 1515void MainWindow::displayText( QString text ,QString cap )
1516{ 1516{
1517 QDialog dia( this, "name", true ); ; 1517 QDialog dia( this, "name", true ); ;
1518 dia.setCaption( cap ); 1518 dia.setCaption( cap );
1519 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1519 QVBoxLayout* lay = new QVBoxLayout( &dia );
1520 lay->setSpacing( 3 ); 1520 lay->setSpacing( 3 );
1521 lay->setMargin( 3 ); 1521 lay->setMargin( 3 );
1522 QTextBrowser tb ( &dia ); 1522 QTextBrowser tb ( &dia );
1523 lay->addWidget( &tb ); 1523 lay->addWidget( &tb );
1524 tb.setText( text ); 1524 tb.setText( text );
1525#ifdef DESKTOP_VERSION 1525#ifdef DESKTOP_VERSION
1526 dia.resize( 640, 480); 1526 dia.resize( 640, 480);
1527#else 1527#else
1528 dia.showMaximized(); 1528 dia.showMaximized();
1529#endif 1529#endif
1530 dia.exec(); 1530 dia.exec();
1531} 1531}
1532 1532
1533void MainWindow::features() 1533void MainWindow::features()
1534{ 1534{
1535 1535
1536 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1536 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1537} 1537}
1538 1538
1539void MainWindow::usertrans() 1539void MainWindow::usertrans()
1540{ 1540{
1541 1541
1542 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1542 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1543} 1543}
1544 1544
1545void MainWindow::storagehowto() 1545void MainWindow::storagehowto()
1546{ 1546{
1547 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1547 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1548} 1548}
1549void MainWindow::timetrackinghowto() 1549void MainWindow::timetrackinghowto()
1550{ 1550{
1551 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1551 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1552} 1552}
1553void MainWindow::kdesynchowto() 1553void MainWindow::kdesynchowto()
1554{ 1554{
1555 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1555 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1556} 1556}
1557void MainWindow::multisynchowto() 1557void MainWindow::multisynchowto()
1558{ 1558{
1559 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1559 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1560} 1560}
1561void MainWindow::synchowto() 1561void MainWindow::synchowto()
1562{ 1562{
1563 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1563 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1564} 1564}
1565void MainWindow::faq() 1565void MainWindow::faq()
1566{ 1566{
1567 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1567 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1568 1568
1569} 1569}
1570void MainWindow::whatsNew() 1570void MainWindow::whatsNew()
1571{ 1571{
1572 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1572 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1573 1573
1574} 1574}
1575void MainWindow::licence() 1575void MainWindow::licence()
1576{ 1576{
1577 KApplication::showLicence(); 1577 KApplication::showLicence();
1578 1578
1579} 1579}
1580void MainWindow::about() 1580void MainWindow::about()
1581{ 1581{
1582 QString version; 1582 QString version;
1583#include <../version> 1583#include <../version>
1584 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1584 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1585 i18n("KOrganizer/Platform-independent\n") + 1585 i18n("KOrganizer/Platform-independent\n") +
1586 "(KO/Pi) " + version + " - " + 1586 "(KO/Pi) " + version + " - " +
1587 1587
1588#ifdef DESKTOP_VERSION 1588#ifdef DESKTOP_VERSION
1589 i18n("Desktop Edition\n") + 1589 i18n("Desktop Edition\n") +
1590#else 1590#else
1591 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1591 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1592#endif 1592#endif
1593 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1593 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1594} 1594}
1595void MainWindow::keyBindings() 1595void MainWindow::keyBindings()
1596{ 1596{
1597 QString cap = i18n("KO/Pi Keys + Colors"); 1597 QString cap = i18n("KO/Pi Keys + Colors");
1598 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1598 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1599 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1599 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1600 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1600 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1601 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1601 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1602 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1602 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1603 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1603 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1604 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1604 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1605 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1605 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1606 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1606 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1607 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1607 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1608 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1608 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1609 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1609 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1610 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1610 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1611 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1611 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1612 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1612 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1613 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1613 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1614 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1614 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1615 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1615 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1616 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1616 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1617 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1617 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1618 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1618 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1619 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1619 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1620 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1620 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1621 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1621 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1622 i18n("<p><h3>In agenda view:</h3></p>\n") + 1622 i18n("<p><h3>In agenda view:</h3></p>\n") +
1623 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1623 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1624 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1624 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1625 i18n("<p><h3>In todo view:</h3></p>\n") + 1625 i18n("<p><h3>In todo view:</h3></p>\n") +
1626 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1626 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1627 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1627 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1628 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1628 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1629 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1629 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1630 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1630 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1631 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1631 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1632 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1632 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1633 i18n("<p><h3>In list view:</h3></p>\n") + 1633 i18n("<p><h3>In list view:</h3></p>\n") +
1634 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1634 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1635 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1635 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1636 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1636 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1637 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1637 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1638 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1638 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1639 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1639 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1640 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1640 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1641 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1641 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1642 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1642 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1643 i18n("<p><b>E</b>: Edit item</p>\n") + 1643 i18n("<p><b>E</b>: Edit item</p>\n") +
1644 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1644 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1645 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1645 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1646 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1646 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1647 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1647 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1648 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1648 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1649 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1649 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1650 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1650 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1651 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1651 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1652 i18n("<p><b>White</b>: Item readonly</p>\n"); 1652 i18n("<p><b>White</b>: Item readonly</p>\n");
1653 displayText( text, cap); 1653 displayText( text, cap);
1654} 1654}
1655void MainWindow::aboutAutoSaving() 1655void MainWindow::aboutAutoSaving()
1656{ 1656{
1657 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1657 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1658 1658
1659 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1659 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1660 1660
1661} 1661}
1662void MainWindow::aboutKnownBugs() 1662void MainWindow::aboutKnownBugs()
1663{ 1663{
1664 QMessageBox* msg; 1664 QMessageBox* msg;
1665 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1665 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1666 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1666 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1667 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1667 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1668 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1668 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1669 i18n("\nor report them in the bugtracker on\n") + 1669 i18n("\nor report them in the bugtracker on\n") +
1670 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1670 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1671 QMessageBox::NoIcon, 1671 QMessageBox::NoIcon,
1672 QMessageBox::Ok, 1672 QMessageBox::Ok,
1673 QMessageBox::NoButton, 1673 QMessageBox::NoButton,
1674 QMessageBox::NoButton); 1674 QMessageBox::NoButton);
1675 msg->exec(); 1675 msg->exec();
1676 delete msg; 1676 delete msg;
1677 1677
1678} 1678}
1679 1679
1680QString MainWindow::defaultFileName() 1680QString MainWindow::defaultFileName()
1681{ 1681{
1682 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1682 return locateLocal( "data", "korganizer/mycalendar.ics" );
1683} 1683}
1684QString MainWindow::syncFileName() 1684QString MainWindow::syncFileName()
1685{ 1685{
1686#ifdef DESKTOP_VERSION 1686#ifdef DESKTOP_VERSION
1687 return locateLocal( "tmp", "synccalendar.ics" ); 1687 return locateLocal( "tmp", "synccalendar.ics" );
1688#else 1688#else
1689 return QString( "/tmp/synccalendar.ics" ); 1689 return QString( "/tmp/synccalendar.ics" );
1690#endif 1690#endif
1691} 1691}
1692#include "koglobals.h" 1692#include "koglobals.h"
1693#include <kcalendarsystem.h> 1693#include <kcalendarsystem.h>
1694void MainWindow::updateWeek(QDate seda) 1694void MainWindow::updateWeek(QDate seda)
1695{ 1695{
1696 int weekNum = KGlobal::locale()->weekNum ( seda ); 1696 int weekNum = KGlobal::locale()->weekNum ( seda );
1697 mWeekPixmap.fill( mWeekBgColor ); 1697 mWeekPixmap.fill( mWeekBgColor );
1698 QPainter p ( &mWeekPixmap ); 1698 QPainter p ( &mWeekPixmap );
1699 p.setFont( mWeekFont ); 1699 p.setFont( mWeekFont );
1700 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1700 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1701 p.end(); 1701 p.end();
1702 QIconSet icon3 ( mWeekPixmap ); 1702 QIconSet icon3 ( mWeekPixmap );
1703 mWeekAction->setIconSet ( icon3 ); 1703 mWeekAction->setIconSet ( icon3 );
1704 1704
1705} 1705}
1706void MainWindow::updateWeekNum(const DateList &selectedDates) 1706void MainWindow::updateWeekNum(const DateList &selectedDates)
1707{ 1707{
1708 updateWeek( selectedDates.first() ); 1708 updateWeek( selectedDates.first() );
1709} 1709}
1710void MainWindow::processIncidenceSelection( Incidence *incidence ) 1710void MainWindow::processIncidenceSelection( Incidence *incidence )
1711{ 1711{
1712 if ( !incidence ) { 1712 if ( !incidence ) {
1713 mShowAction->setMenuText( i18n("Show") ); 1713 mShowAction->setMenuText( i18n("Show") );
1714 enableIncidenceActions( false ); 1714 enableIncidenceActions( false );
1715 mNewSubTodoAction->setEnabled( false ); 1715 mNewSubTodoAction->setEnabled( false );
1716 setCaptionToDates(); 1716 setCaptionToDates();
1717 return; 1717 return;
1718 } 1718 }
1719 QString startString = ""; 1719 QString startString = "";
1720 if ( incidence->typeID() != todoID ) { 1720 if ( incidence->typeID() != todoID ) {
1721 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1721 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1722 if ( incidence->doesFloat() ) { 1722 if ( incidence->doesFloat() ) {
1723 startString += ": "+incidence->dtStartDateStr( true ); 1723 startString += ": "+incidence->dtStartDateStr( true );
1724 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1724 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1725 } else { 1725 } else {
1726 startString = ": "+incidence->dtStartStr(true); 1726 startString = ": "+incidence->dtStartStr(true);
1727 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1727 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1728 } 1728 }
1729 } else { 1729 } else {
1730 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1730 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1731 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1731 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1732 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1732 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1733 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1733 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1734 bool ok; 1734 bool ok;
1735 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1735 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1736 if ( ok ) { 1736 if ( ok ) {
1737 int years = noc.date().year() - incidence->dtStart().date().year(); 1737 int years = noc.date().year() - incidence->dtStart().date().year();
1738 startString += i18n(" (%1 y.)"). arg( years ); 1738 startString += i18n(" (%1 y.)"). arg( years );
1739 } 1739 }
1740 } 1740 }
1741 else 1741 else
1742 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1742 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1743 } 1743 }
1744 } 1744 }
1745 else { 1745 else {
1746 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1746 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1747 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1747 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1748 else 1748 else
1749 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1749 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1750 } 1750 }
1751 if ( !incidence->location().isEmpty() ) 1751 if ( !incidence->location().isEmpty() )
1752 startString += " (" +incidence->location()+")"; 1752 startString += " (" +incidence->location()+")";
1753 setCaption( incidence->summary()+startString); 1753 setCaption( incidence->summary()+startString);
1754 enableIncidenceActions( true ); 1754 enableIncidenceActions( true );
1755 if ( incidence->typeID() == eventID ) { 1755 if ( incidence->typeID() == eventID ) {
1756 mShowAction->setMenuText( i18n("Show Event") ); 1756 mShowAction->setMenuText( i18n("Show Event") );
1757 mNewSubTodoAction->setEnabled( false ); 1757 mNewSubTodoAction->setEnabled( false );
1758 } else if ( incidence->typeID() == todoID ) { 1758 } else if ( incidence->typeID() == todoID ) {
1759 mShowAction->setMenuText( i18n("Show Todo") ); 1759 mShowAction->setMenuText( i18n("Show Todo") );
1760 mNewSubTodoAction->setEnabled( true ); 1760 mNewSubTodoAction->setEnabled( true );
1761 } else { 1761 } else {
1762 mShowAction->setMenuText( i18n("Show") ); 1762 mShowAction->setMenuText( i18n("Show") );
1763 mNewSubTodoAction->setEnabled( false ); 1763 mNewSubTodoAction->setEnabled( false );
1764 } 1764 }
1765 static QPixmap jP = SmallIcon( "journal" ); 1765 static QPixmap jP = SmallIcon( "journal" );
1766 static QPixmap eP = SmallIcon( "newevent" ); 1766 static QPixmap eP = SmallIcon( "newevent" );
1767 static QPixmap tP = SmallIcon( "newtodo" ); 1767 static QPixmap tP = SmallIcon( "newtodo" );
1768#ifdef DESKTOP_VERSION 1768#ifdef DESKTOP_VERSION
1769 QIconSet icon; 1769 QIconSet icon;
1770 if ( incidence->typeID() == todoID ) 1770 if ( incidence->typeID() == todoID )
1771 icon = QIconSet ( tP ); 1771 icon = QIconSet ( tP );
1772 else if ( incidence->typeID() == eventID ) 1772 else if ( incidence->typeID() == eventID )
1773 icon = QIconSet ( eP ); 1773 icon = QIconSet ( eP );
1774 else if ( incidence->typeID() == journalID ) 1774 else if ( incidence->typeID() == journalID )
1775 icon = QIconSet ( jP ); 1775 icon = QIconSet ( jP );
1776 mPrintSelAction->setIconSet ( icon ); 1776 mPrintSelAction->setIconSet ( icon );
1777#endif 1777#endif
1778} 1778}
1779 1779
1780void MainWindow::enableIncidenceActions( bool enabled ) 1780void MainWindow::enableIncidenceActions( bool enabled )
1781{ 1781{
1782 mShowAction->setEnabled( enabled ); 1782 mShowAction->setEnabled( enabled );
1783 mEditAction->setEnabled( enabled ); 1783 mEditAction->setEnabled( enabled );
1784 mDeleteAction->setEnabled( enabled ); 1784 mDeleteAction->setEnabled( enabled );
1785 1785
1786 mCloneAction->setEnabled( enabled ); 1786 mCloneAction->setEnabled( enabled );
1787 mMoveAction->setEnabled( enabled ); 1787 mMoveAction->setEnabled( enabled );
1788#ifndef DESKTOP_VERSION 1788#ifndef DESKTOP_VERSION
1789 mBeamAction->setEnabled( enabled ); 1789 mBeamAction->setEnabled( enabled );
1790#else 1790#else
1791 mPrintSelAction->setEnabled( enabled ); 1791 mPrintSelAction->setEnabled( enabled );
1792#endif 1792#endif
1793 mCancelAction->setEnabled( enabled ); 1793 mCancelAction->setEnabled( enabled );
1794} 1794}
1795 1795
1796void MainWindow::importOL() 1796void MainWindow::importOL()
1797{ 1797{
1798#ifdef _OL_IMPORT_ 1798#ifdef _OL_IMPORT_
1799 mView->clearAllViews(); 1799 mView->clearAllViews();
1800 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1800 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1801 id->exec(); 1801 id->exec();
1802 delete id; 1802 delete id;
1803 mView->calendar()->checkAlarmForIncidence( 0, true ); 1803 mView->calendar()->checkAlarmForIncidence( 0, true );
1804 mView->updateView(); 1804 mView->updateView();
1805#endif 1805#endif
1806} 1806}
1807void MainWindow::importBday() 1807void MainWindow::importBday()
1808{ 1808{
1809 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1809 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1810 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1810 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1811 i18n("Import!"), i18n("Cancel"), 0, 1811 i18n("Import!"), i18n("Cancel"), 0,
1812 0, 1 ); 1812 0, 1 );
1813 if ( result == 0 ) { 1813 if ( result == 0 ) {
1814 mView->importBday(); 1814 mView->importBday();
1815 1815
1816 } 1816 }
1817 1817
1818 1818
1819} 1819}
1820void MainWindow::importQtopia() 1820void MainWindow::importQtopia()
1821{ 1821{
1822 //#ifndef DESKTOP_VERSION 1822 //#ifndef DESKTOP_VERSION
1823 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1823 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1824#ifdef DESKTOP_VERSION 1824#ifdef DESKTOP_VERSION
1825 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1825 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1826#endif 1826#endif
1827 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1827 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1828 i18n("Import!"), i18n("Cancel"), 0, 1828 i18n("Import!"), i18n("Cancel"), 0,
1829 0, 1 ); 1829 0, 1 );
1830 if ( result == 0 ) { 1830 if ( result == 0 ) {
1831#ifndef DESKTOP_VERSION 1831#ifndef DESKTOP_VERSION
1832 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1832 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1833 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1833 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1834 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1834 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1835#else 1835#else
1836 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1836 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1837 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1837 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1838 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1838 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1839#endif 1839#endif
1840 mView->importQtopia( categories, datebook, todolist ); 1840 mView->importQtopia( categories, datebook, todolist );
1841 } 1841 }
1842 mView->calendar()->reInitAlarmSettings(); 1842 mView->calendar()->reInitAlarmSettings();
1843#if 0 1843#if 0
1844 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1844 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1845 i18n("Not supported \non desktop!\n"), 1845 i18n("Not supported \non desktop!\n"),
1846 i18n("Ok"), i18n("Cancel"), 0, 1846 i18n("Ok"), i18n("Cancel"), 0,
1847 0, 1 ); 1847 0, 1 );
1848 1848
1849#endif 1849#endif
1850} 1850}
1851 1851
1852void MainWindow::saveOnClose() 1852void MainWindow::saveOnClose()
1853{ 1853{
1854 KOPrefs *p = KOPrefs::instance(); 1854 KOPrefs *p = KOPrefs::instance();
1855 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1855 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1856 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1856 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1857 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1857 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1858 if ( filterToolBar ) { 1858 if ( filterToolBar ) {
1859 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1859 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1860 } 1860 }
1861#ifdef DESKTOP_VERSION 1861#ifdef DESKTOP_VERSION
1862 1862
1863 QPoint myP; 1863 QPoint myP;
1864 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1864 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1865 if ( p->mToolBarHor ) 1865 if ( p->mToolBarHor )
1866 p->mToolBarUp = myP.y() > height()/2; 1866 p->mToolBarUp = myP.y() > height()/2;
1867 else 1867 else
1868 p->mToolBarUp = myP.x() > width()/2; 1868 p->mToolBarUp = myP.x() > width()/2;
1869 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1869 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1870 if ( p->mToolBarHorV ) 1870 if ( p->mToolBarHorV )
1871 p->mToolBarUpV = myP.y() > height()/2; 1871 p->mToolBarUpV = myP.y() > height()/2;
1872 else 1872 else
1873 p->mToolBarUpV = myP.x() > width()/2 ; 1873 p->mToolBarUpV = myP.x() > width()/2 ;
1874 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1874 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1875 if ( p->mToolBarHorN ) 1875 if ( p->mToolBarHorN )
1876 p->mToolBarUpN = myP.y() > height()/2; 1876 p->mToolBarUpN = myP.y() > height()/2;
1877 else 1877 else
1878 p->mToolBarUpN = myP.x() > width()/2 ; 1878 p->mToolBarUpN = myP.x() > width()/2 ;
1879 if ( filterToolBar ) { 1879 if ( filterToolBar ) {
1880 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1880 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1881 if ( p->mToolBarHorF ) 1881 if ( p->mToolBarHorF )
1882 p->mToolBarUpF = myP.y() > height()/2; 1882 p->mToolBarUpF = myP.y() > height()/2;
1883 else 1883 else
1884 p->mToolBarUpF = myP.x() > width()/2 ; 1884 p->mToolBarUpF = myP.x() > width()/2 ;
1885 } 1885 }
1886#else 1886#else
1887 if ( p->mToolBarHor ) 1887 if ( p->mToolBarHor )
1888 p->mToolBarUp = iconToolBar->y() > height()/2; 1888 p->mToolBarUp = iconToolBar->y() > height()/2;
1889 else 1889 else
1890 p->mToolBarUp = iconToolBar->x() > width()/2; 1890 p->mToolBarUp = iconToolBar->x() > width()/2;
1891 if ( p->mToolBarHorV ) 1891 if ( p->mToolBarHorV )
1892 p->mToolBarUpV = viewToolBar->y() > height()/2; 1892 p->mToolBarUpV = viewToolBar->y() > height()/2;
1893 else 1893 else
1894 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1894 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1895 1895
1896 if ( p->mToolBarHorN ) 1896 if ( p->mToolBarHorN )
1897 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1897 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1898 else 1898 else
1899 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1899 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1900 if ( filterToolBar ) { 1900 if ( filterToolBar ) {
1901 if ( p->mToolBarHorF ) 1901 if ( p->mToolBarHorF )
1902 p->mToolBarUpF = filterToolBar->y() > height()/2; 1902 p->mToolBarUpF = filterToolBar->y() > height()/2;
1903 else 1903 else
1904 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1904 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1905 } 1905 }
1906#endif 1906#endif
1907 save(); 1907 save();
1908 mView->writeSettings(); 1908 mView->writeSettings();
1909 mView->checkSuspendAlarm(); 1909 mView->checkSuspendAlarm();
1910} 1910}
1911void MainWindow::slotModifiedChanged( bool ) 1911void MainWindow::slotModifiedChanged( bool )
1912{ 1912{
1913 if ( mBlockAtStartup ) 1913 if ( mBlockAtStartup )
1914 return; 1914 return;
1915 1915
1916 int msec; 1916 int msec;
1917 if ( mCalendarModifiedFlag ) {
1918 //qDebug(" MainWindow timer is running ");
1919 return;
1920 }
1917 // we store the changes after 1 minute, 1921 // we store the changes after 1 minute,
1918 // and for safety reasons after 10 minutes again 1922 // and for safety reasons after 10 minutes again
1919 if ( !mSyncManager->blockSave() ) 1923 if ( !mSyncManager->blockSave() )
1920 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1924 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1921 else 1925 else
1922 msec = 1000 * 600; 1926 msec = 1000 * 600;
1923 mSaveTimer.start( msec, true ); // 1 minute 1927 mSaveTimer.start( msec, true ); // 1 minute
1924 qDebug("KO: Saving File in %d secs!", msec/1000); 1928 qDebug("KO: Saving File in %d secs!", msec/1000);
1925 mCalendarModifiedFlag = true; 1929 mCalendarModifiedFlag = true;
1926} 1930}
1927void MainWindow::saveStopTimer() 1931void MainWindow::saveStopTimer()
1928{ 1932{
1929 mSaveTimer.stop(); 1933 mSaveTimer.stop();
1930} 1934}
1931void MainWindow::backupAllFiles() 1935void MainWindow::backupAllFiles()
1932{ 1936{
1933 QDate reference ( 2000,1,1); 1937 QDate reference ( 2000,1,1);
1934 int daysTo = reference.daysTo ( QDate::currentDate() ); 1938 int daysTo = reference.daysTo ( QDate::currentDate() );
1935 setCaption(i18n("Creating backup ... please wait ..." )); 1939 setCaption(i18n("Creating backup ... please wait ..." ));
1936 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1940 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1937 // we need the file path, the backup dir and the number of bups as param 1941 // we need the file path, the backup dir and the number of bups as param
1938 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1942 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1939 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1943 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1940 bupDir = KGlobalSettings::backupDataDir(); 1944 bupDir = KGlobalSettings::backupDataDir();
1941 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1945 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1942 if ( retval == 0 ) { 1946 if ( retval == 0 ) {
1943 setCaption(i18n("Backup cancelled" )); 1947 setCaption(i18n("Backup cancelled" ));
1944 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1948 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1945 // retval == 0 : backup skipped for today, try again tomorrow 1949 // retval == 0 : backup skipped for today, try again tomorrow
1946 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1950 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1947 } else if ( retval == 1 ){ 1951 } else if ( retval == 1 ){
1948 qDebug("KO: Backup created."); 1952 qDebug("KO: Backup created.");
1949 // backup ok 1953 // backup ok
1950 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1954 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1951 KopiCalendarFile * cal = calendars.first(); 1955 KopiCalendarFile * cal = calendars.first();
1952 cal = calendars.next(); 1956 cal = calendars.next();
1953 while ( cal ) { 1957 while ( cal ) {
1954 if ( !cal->mErrorOnLoad ) { 1958 if ( !cal->mErrorOnLoad ) {
1955 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1959 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1956 } 1960 }
1957 cal = calendars.next(); 1961 cal = calendars.next();
1958 } 1962 }
1959 KOPrefs::instance()->mLastBackupDate = daysTo; 1963 KOPrefs::instance()->mLastBackupDate = daysTo;
1960 setCaption(i18n("Backup succesfully finished" )); 1964 setCaption(i18n("Backup succesfully finished" ));
1961 } else if ( retval == 2 ){ 1965 } else if ( retval == 2 ){
1962 setCaption(i18n("Backup globally disabled" )); 1966 setCaption(i18n("Backup globally disabled" ));
1963 qDebug("KO: Backup globally cancelled."); 1967 qDebug("KO: Backup globally cancelled.");
1964 // backup globally cancelled 1968 // backup globally cancelled
1965 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1969 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1966 } 1970 }
1967 // retval == 3: do nothing, try again later 1971 // retval == 3: do nothing, try again later
1968} 1972}
1969void MainWindow::save() 1973void MainWindow::save()
1970{ 1974{
1971 1975
1972 if ( mView->viewManager()->journalView() ) 1976 if ( mView->viewManager()->journalView() )
1973 mView->viewManager()->journalView()->checkModified(); 1977 mView->viewManager()->journalView()->checkModified();
1974 if ( !mCalendarModifiedFlag ) { 1978 if ( !mCalendarModifiedFlag ) {
1975 qDebug("KO: Calendar not modified. Nothing saved."); 1979 qDebug("KO: Calendar not modified. Nothing saved.");
1976 return; 1980 return;
1977 } 1981 }
1978 if ( mSyncManager->blockSave() ) 1982 if ( mSyncManager->blockSave() ) {
1979 return; 1983 return;
1984 }
1980 mSyncManager->setBlockSave(true); 1985 mSyncManager->setBlockSave(true);
1981 if ( mView->checkAllFileVersions() ) { 1986 if ( mView->checkAllFileVersions() ) {
1982 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1987 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1983 QDate reference ( 2000,1,1); 1988 QDate reference ( 2000,1,1);
1984 int daysTo = reference.daysTo ( QDate::currentDate() ); 1989 int daysTo = reference.daysTo ( QDate::currentDate() );
1985 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1990 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1986 backupAllFiles(); 1991 backupAllFiles();
1987 } 1992 }
1988 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1993 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1989 } 1994 }
1990 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1995 QTime neededSaveTime = QDateTime::currentDateTime().time();
1991 if ( !isMinimized () ) 1996 if ( !isMinimized () )
1992 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1997 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1993 qDebug("KO: Start saving data to file!"); 1998 qDebug("KO: Start saving data to file!");
1994 mView->saveCalendars(); 1999 mView->saveCalendars();
1995 mCalendarModifiedFlag = false; 2000 mCalendarModifiedFlag = false;
1996 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 2001 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1997 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2002 qDebug("KO: Needed %d ms for saving.",msNeeded );
1998 QString savemes; 2003 QString savemes;
1999 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2004 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2000 if ( !isMinimized () ) 2005 if ( !isMinimized () )
2001 setCaption(savemes); 2006 setCaption(savemes);
2002 else 2007 else
2003 qDebug(savemes); 2008 qDebug(savemes);
2004 } else 2009 } else {
2005 setCaption(i18n("Saving cancelled!")); 2010 setCaption(i18n("Saving cancelled!"));
2011 mCalendarModifiedFlag = false;
2012 slotModifiedChanged( true );
2013 }
2006 mSyncManager->setBlockSave( false ); 2014 mSyncManager->setBlockSave( false );
2007} 2015}
2008 2016
2009void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2017void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2010{ 2018{
2011 if ( !e->isAutoRepeat() ) { 2019 if ( !e->isAutoRepeat() ) {
2012 mFlagKeyPressed = false; 2020 mFlagKeyPressed = false;
2013 } 2021 }
2014} 2022}
2015void MainWindow::keyPressEvent ( QKeyEvent * e ) 2023void MainWindow::keyPressEvent ( QKeyEvent * e )
2016{ 2024{
2017 qApp->processEvents(); 2025 qApp->processEvents();
2018 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2026 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2019 e->ignore(); 2027 e->ignore();
2020 // qDebug(" ignore %d",e->isAutoRepeat() ); 2028 // qDebug(" ignore %d",e->isAutoRepeat() );
2021 return; 2029 return;
2022 } 2030 }
2023 if (! e->isAutoRepeat() ) 2031 if (! e->isAutoRepeat() )
2024 mFlagKeyPressed = true; 2032 mFlagKeyPressed = true;
2025 KOPrefs *p = KOPrefs::instance(); 2033 KOPrefs *p = KOPrefs::instance();
2026 bool showSelectedDates = false; 2034 bool showSelectedDates = false;
2027 int size; 2035 int size;
2028 int pro = 0; 2036 int pro = 0;
2029 //qDebug("MainWindow::keyPressEvent "); 2037 //qDebug("MainWindow::keyPressEvent ");
2030 switch ( e->key() ) { 2038 switch ( e->key() ) {
2031 case Qt::Key_Right: 2039 case Qt::Key_Right:
2032 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2040 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2033 mView->goNextMonth(); 2041 mView->goNextMonth();
2034 else 2042 else
2035 mView->goNext(); 2043 mView->goNext();
2036 showSelectedDates = true; 2044 showSelectedDates = true;
2037 break; 2045 break;
2038 case Qt::Key_Left: 2046 case Qt::Key_Left:
2039 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2047 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2040 mView->goPreviousMonth(); 2048 mView->goPreviousMonth();
2041 else 2049 else
2042 mView->goPrevious(); 2050 mView->goPrevious();
2043 showSelectedDates = true; 2051 showSelectedDates = true;
2044 break; 2052 break;
2045 case Qt::Key_Down: 2053 case Qt::Key_Down:
2046 mView->viewManager()->agendaView()->scrollOneHourDown(); 2054 mView->viewManager()->agendaView()->scrollOneHourDown();
2047 break; 2055 break;
2048 case Qt::Key_Up: 2056 case Qt::Key_Up:
2049 mView->viewManager()->agendaView()->scrollOneHourUp(); 2057 mView->viewManager()->agendaView()->scrollOneHourUp();
2050 break; 2058 break;
2051 case Qt::Key_K: 2059 case Qt::Key_K:
2052 mView->viewManager()->showMonthViewWeek(); 2060 mView->viewManager()->showMonthViewWeek();
2053 break; 2061 break;
2054 case Qt::Key_I: 2062 case Qt::Key_I:
2055 mView->showIncidence(); 2063 mView->showIncidence();
2056 break; 2064 break;
2057 case Qt::Key_Delete: 2065 case Qt::Key_Delete:
2058 case Qt::Key_Backspace: 2066 case Qt::Key_Backspace:
2059 mView->deleteIncidence(); 2067 mView->deleteIncidence();
2060 break; 2068 break;
2061 case Qt::Key_D: 2069 case Qt::Key_D:
2062 mView->viewManager()->showDayView(); 2070 mView->viewManager()->showDayView();
2063 showSelectedDates = true; 2071 showSelectedDates = true;
2064 break; 2072 break;
2065 case Qt::Key_O: 2073 case Qt::Key_O:
2066 mView->toggleFilerEnabled( ); 2074 mView->toggleFilerEnabled( );
2067 break; 2075 break;
2068 case Qt::Key_0: 2076 case Qt::Key_0:
2069 case Qt::Key_1: 2077 case Qt::Key_1:
2070 case Qt::Key_2: 2078 case Qt::Key_2:
2071 case Qt::Key_3: 2079 case Qt::Key_3:
2072 case Qt::Key_4: 2080 case Qt::Key_4:
2073 case Qt::Key_5: 2081 case Qt::Key_5:
2074 case Qt::Key_6: 2082 case Qt::Key_6:
2075 case Qt::Key_7: 2083 case Qt::Key_7:
2076 case Qt::Key_8: 2084 case Qt::Key_8:
2077 case Qt::Key_9: 2085 case Qt::Key_9:
2078 pro = e->key()-48; 2086 pro = e->key()-48;
2079 if ( pro == 0 ) 2087 if ( pro == 0 )
2080 pro = 10; 2088 pro = 10;
2081 if ( e->state() == Qt::ControlButton) 2089 if ( e->state() == Qt::ControlButton)
2082 pro += 10; 2090 pro += 10;
2083 break; 2091 break;
2084 case Qt::Key_M: 2092 case Qt::Key_M:
2085 mView->viewManager()->showMonthView(); 2093 mView->viewManager()->showMonthView();
2086 showSelectedDates = true; 2094 showSelectedDates = true;
2087 break; 2095 break;
2088 case Qt::Key_Insert: 2096 case Qt::Key_Insert:
2089 mView->newEvent(); 2097 mView->newEvent();
2090 break; 2098 break;
2091 case Qt::Key_S : 2099 case Qt::Key_S :
2092 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2100 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2093 mView->newSubTodo(); 2101 mView->newSubTodo();
2094 else 2102 else
2095 mView->dialogManager()->showSearchDialog(); 2103 mView->dialogManager()->showSearchDialog();
2096 break; 2104 break;
2097 case Qt::Key_Y : 2105 case Qt::Key_Y :
2098 case Qt::Key_Z : 2106 case Qt::Key_Z :
2099 mView->viewManager()->showWorkWeekView(); 2107 mView->viewManager()->showWorkWeekView();
2100 showSelectedDates = true; 2108 showSelectedDates = true;
2101 break; 2109 break;
2102 case Qt::Key_U : 2110 case Qt::Key_U :
2103 mView->viewManager()->showWeekView(); 2111 mView->viewManager()->showWeekView();
2104 showSelectedDates = true; 2112 showSelectedDates = true;
2105 break; 2113 break;
2106 case Qt::Key_H : 2114 case Qt::Key_H :
2107 keyBindings(); 2115 keyBindings();
2108 break; 2116 break;
2109 case Qt::Key_W: 2117 case Qt::Key_W:
2110 mView->viewManager()->showWhatsNextView(); 2118 mView->viewManager()->showWhatsNextView();
2111 break; 2119 break;
2112 case Qt::Key_L: 2120 case Qt::Key_L:
2113 mView->viewManager()->showListView(); 2121 mView->viewManager()->showListView();
2114 break; 2122 break;
2115 case Qt::Key_N: 2123 case Qt::Key_N:
2116 mView->viewManager()->showNextView(); 2124 mView->viewManager()->showNextView();
2117 break; 2125 break;
2118 case Qt::Key_V: 2126 case Qt::Key_V:
2119 mView->viewManager()->showTodoView(); 2127 mView->viewManager()->showTodoView();
2120 break; 2128 break;
2121 case Qt::Key_C: 2129 case Qt::Key_C:
2122 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2130 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2123 break; 2131 break;
2124 case Qt::Key_P: 2132 case Qt::Key_P:
2125 mView->showDatePicker( ); 2133 mView->showDatePicker( );
2126 break; 2134 break;
2127 case Qt::Key_F: 2135 case Qt::Key_F:
2128 mView->editFilters(); 2136 mView->editFilters();
2129 break; 2137 break;
2130 case Qt::Key_R: 2138 case Qt::Key_R:
2131 mView->toggleFilter(); 2139 mView->toggleFilter();
2132 break; 2140 break;
2133 case Qt::Key_X: 2141 case Qt::Key_X:
2134 if ( e->state() == Qt::ControlButton ) 2142 if ( e->state() == Qt::ControlButton )
2135 mView->toggleDateNavigatorWidget(); 2143 mView->toggleDateNavigatorWidget();
2136 else { 2144 else {
2137 mView->viewManager()->showNextXView(); 2145 mView->viewManager()->showNextXView();
2138 showSelectedDates = true; 2146 showSelectedDates = true;
2139 } 2147 }
2140 break; 2148 break;
2141 case Qt::Key_Space: 2149 case Qt::Key_Space:
2142 mView->toggleExpand(); 2150 mView->toggleExpand();
2143 break; 2151 break;
2144 case Qt::Key_A: 2152 case Qt::Key_A:
2145 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2153 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2146 mView->showNextAlarms(); 2154 mView->showNextAlarms();
2147 else 2155 else
2148 mView->toggleAllDaySize(); 2156 mView->toggleAllDaySize();
2149 break; 2157 break;
2150 case Qt::Key_T: 2158 case Qt::Key_T:
2151 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2159 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2152 mView->newTodo(); 2160 mView->newTodo();
2153 else { 2161 else {
2154 mView->goToday(); 2162 mView->goToday();
2155 showSelectedDates = true; 2163 showSelectedDates = true;
2156 } 2164 }
2157 break; 2165 break;
2158 case Qt::Key_Q: 2166 case Qt::Key_Q:
2159 if ( e->state() == Qt::ControlButton ) 2167 if ( e->state() == Qt::ControlButton )
2160 mView->conflictNotAll(); 2168 mView->conflictNotAll();
2161 else if ( e->state() == Qt::ShiftButton ) 2169 else if ( e->state() == Qt::ShiftButton )
2162 mView->conflictAllday(); 2170 mView->conflictAllday();
2163 else 2171 else
2164 mView->conflictAll(); 2172 mView->conflictAll();
2165 break; 2173 break;
2166 case Qt::Key_J: 2174 case Qt::Key_J:
2167 mView->viewManager()->showJournalView(); 2175 mView->viewManager()->showJournalView();
2168 break; 2176 break;
2169 case Qt::Key_B: 2177 case Qt::Key_B:
2170 mView->editIncidenceDescription();; 2178 mView->editIncidenceDescription();;
2171 break; 2179 break;
2172 // case Qt::Key_Return: 2180 // case Qt::Key_Return:
2173 case Qt::Key_E: 2181 case Qt::Key_E:
2174 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2182 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2175 mView->newEvent(); 2183 mView->newEvent();
2176 else 2184 else
2177 mView->editIncidence(); 2185 mView->editIncidence();
2178 break; 2186 break;
2179 case Qt::Key_Plus: 2187 case Qt::Key_Plus:
2180 size = p->mHourSize +2; 2188 size = p->mHourSize +2;
2181 if ( size <= 22 ) 2189 if ( size <= 22 )
2182 configureAgenda( size ); 2190 configureAgenda( size );
2183 break; 2191 break;
2184 case Qt::Key_Minus: 2192 case Qt::Key_Minus:
2185 size = p->mHourSize - 2; 2193 size = p->mHourSize - 2;
2186 if ( size >= 4 ) 2194 if ( size >= 4 )
2187 configureAgenda( size ); 2195 configureAgenda( size );
2188 break; 2196 break;
2189 2197
2190 2198
2191 default: 2199 default:
2192 e->ignore(); 2200 e->ignore();
2193 } 2201 }
2194 if ( pro > 0 ) { 2202 if ( pro > 0 ) {
2195 selectFilter( pro+1 ); 2203 selectFilter( pro+1 );
2196 } 2204 }
2197 if ( showSelectedDates ) { 2205 if ( showSelectedDates ) {
2198 ;// setCaptionToDates(); 2206 ;// setCaptionToDates();
2199 } 2207 }
2200 2208
2201} 2209}
2202void MainWindow::fillFilterMenuTB() 2210void MainWindow::fillFilterMenuTB()
2203{ 2211{
2204 selectFilterMenuTB->clear(); 2212 selectFilterMenuTB->clear();
2205 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2213 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2206 selectFilterMenuTB->insertSeparator(); 2214 selectFilterMenuTB->insertSeparator();
2207 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2215 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2208 2216
2209 selectFilterMenuTB->insertSeparator(); 2217 selectFilterMenuTB->insertSeparator();
2210 QPtrList<CalFilter> fili = mView->filters(); 2218 QPtrList<CalFilter> fili = mView->filters();
2211 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2219 CalFilter *curfilter = mView->filterView()->selectedFilter();
2212 CalFilter *filter = fili.first(); 2220 CalFilter *filter = fili.first();
2213 int iii = 2; 2221 int iii = 2;
2214 bool checkitem = mView->filterView()->filtersEnabled(); 2222 bool checkitem = mView->filterView()->filtersEnabled();
2215 while(filter) { 2223 while(filter) {
2216 selectFilterMenuTB->insertItem( filter->name(), iii ); 2224 selectFilterMenuTB->insertItem( filter->name(), iii );
2217 if ( filter == curfilter) 2225 if ( filter == curfilter)
2218 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2226 selectFilterMenuTB->setItemChecked( iii, checkitem );
2219 filter = fili.next(); 2227 filter = fili.next();
2220 ++iii; 2228 ++iii;
2221 } 2229 }
2222 if ( !checkitem ) 2230 if ( !checkitem )
2223 selectFilterMenuTB->setItemChecked( 1, true ); 2231 selectFilterMenuTB->setItemChecked( 1, true );
2224 2232
2225 int x = 0; 2233 int x = 0;
2226 int y = iconToolBar->height(); 2234 int y = iconToolBar->height();
2227 int dX = 0; 2235 int dX = 0;
2228 int dY = 0; 2236 int dY = 0;
2229 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2237 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2230 if ( iconToolBar->y() > height()/2 ) { 2238 if ( iconToolBar->y() > height()/2 ) {
2231 dY = selectFilterMenuTB->sizeHint().height()+8; 2239 dY = selectFilterMenuTB->sizeHint().height()+8;
2232 y = 0; 2240 y = 0;
2233 } 2241 }
2234 } else { 2242 } else {
2235 if ( iconToolBar->x() > width()/2 ) { // right side 2243 if ( iconToolBar->x() > width()/2 ) { // right side
2236 x=0; 2244 x=0;
2237 dX= selectFilterMenuTB->sizeHint().width()+8; 2245 dX= selectFilterMenuTB->sizeHint().width()+8;
2238 y = 0; 2246 y = 0;
2239 } else { 2247 } else {
2240 x= iconToolBar->width(); 2248 x= iconToolBar->width();
2241 y = 0; 2249 y = 0;
2242 } 2250 }
2243 } 2251 }
2244 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2252 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2245 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2253 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2246} 2254}
2247void MainWindow::fillFilterMenu() 2255void MainWindow::fillFilterMenu()
2248{ 2256{
2249 selectFilterMenu->clear(); 2257 selectFilterMenu->clear();
2250 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2258 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2251 selectFilterMenu->insertSeparator(); 2259 selectFilterMenu->insertSeparator();
2252 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2260 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2253 2261
2254 selectFilterMenu->insertSeparator(); 2262 selectFilterMenu->insertSeparator();
2255 QPtrList<CalFilter> fili = mView->filters(); 2263 QPtrList<CalFilter> fili = mView->filters();
2256 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2264 CalFilter *curfilter = mView->filterView()->selectedFilter();
2257 CalFilter *filter = fili.first(); 2265 CalFilter *filter = fili.first();
2258 int iii = 2; 2266 int iii = 2;
2259 bool checkitem = mView->filterView()->filtersEnabled(); 2267 bool checkitem = mView->filterView()->filtersEnabled();
2260 while(filter) { 2268 while(filter) {
2261 selectFilterMenu->insertItem( filter->name(), iii ); 2269 selectFilterMenu->insertItem( filter->name(), iii );
2262 if ( filter == curfilter) 2270 if ( filter == curfilter)
2263 selectFilterMenu->setItemChecked( iii, checkitem ); 2271 selectFilterMenu->setItemChecked( iii, checkitem );
2264 filter = fili.next(); 2272 filter = fili.next();
2265 ++iii; 2273 ++iii;
2266 } 2274 }
2267 if ( !checkitem ) 2275 if ( !checkitem )
2268 selectFilterMenu->setItemChecked( 1, true ); 2276 selectFilterMenu->setItemChecked( 1, true );
2269} 2277}
2270void MainWindow::fillFilterMenuPopup() 2278void MainWindow::fillFilterMenuPopup()
2271{ 2279{
2272 filterPopupMenu->clear(); 2280 filterPopupMenu->clear();
2273 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2281 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2274 2282
2275 filterPopupMenu->insertSeparator(); 2283 filterPopupMenu->insertSeparator();
2276 QPtrList<CalFilter> fili = mView->filters(); 2284 QPtrList<CalFilter> fili = mView->filters();
2277 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2285 CalFilter *curfilter = mView->filterView()->selectedFilter();
2278 CalFilter *filter = fili.first(); 2286 CalFilter *filter = fili.first();
2279 int iii = 1; 2287 int iii = 1;
2280 bool checkitem = mView->filterView()->filtersEnabled(); 2288 bool checkitem = mView->filterView()->filtersEnabled();
2281 while(filter) { 2289 while(filter) {
2282 filterPopupMenu->insertItem( filter->name(), iii ); 2290 filterPopupMenu->insertItem( filter->name(), iii );
2283 if ( filter == curfilter) 2291 if ( filter == curfilter)
2284 filterPopupMenu->setItemChecked( iii, checkitem ); 2292 filterPopupMenu->setItemChecked( iii, checkitem );
2285 filter = fili.next(); 2293 filter = fili.next();
2286 ++iii; 2294 ++iii;
2287 } 2295 }
2288 if ( !checkitem ) 2296 if ( !checkitem )
2289 filterPopupMenu->setItemChecked( 0, true ); 2297 filterPopupMenu->setItemChecked( 0, true );
2290} 2298}
2291void MainWindow::selectFilter( int fil ) 2299void MainWindow::selectFilter( int fil )
2292{ 2300{
2293 2301
2294 if ( fil == 0 ) { 2302 if ( fil == 0 ) {
2295 mView->editFilters( ); 2303 mView->editFilters( );
2296 } else if ( fil == 1 ){ 2304 } else if ( fil == 1 ){
2297 if ( mView->filterView()->filtersEnabled() ) 2305 if ( mView->filterView()->filtersEnabled() )
2298 mView->toggleFilerEnabled( ); 2306 mView->toggleFilerEnabled( );
2299 } else { 2307 } else {
2300 if ( !mView->filterView()->filtersEnabled() ) { 2308 if ( !mView->filterView()->filtersEnabled() ) {
2301 mView->filterView()->blockSignals( true ); 2309 mView->filterView()->blockSignals( true );
2302 mView->toggleFilerEnabled( ); 2310 mView->toggleFilerEnabled( );
2303 mView->filterView()->blockSignals( false ); 2311 mView->filterView()->blockSignals( false );
2304 } 2312 }
2305 mView->selectFilter( fil-2 ); 2313 mView->selectFilter( fil-2 );
2306 } 2314 }
2307} 2315}
2308void MainWindow::updateFilterToolbar() 2316void MainWindow::updateFilterToolbar()
2309{ 2317{
2310 if ( filterMenubar ) { 2318 if ( filterMenubar ) {
2311 if ( !mView->filterView()->filtersEnabled() ) { 2319 if ( !mView->filterView()->filtersEnabled() ) {
2312 filterMenubar->changeItem( 0, i18n("No Filter") ); 2320 filterMenubar->changeItem( 0, i18n("No Filter") );
2313 } else { 2321 } else {
2314 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2322 CalFilter *curfilter = mView->filterView()->selectedFilter();
2315 if ( curfilter ) { 2323 if ( curfilter ) {
2316 filterMenubar->changeItem( 0, curfilter->name() ); 2324 filterMenubar->changeItem( 0, curfilter->name() );
2317 } 2325 }
2318 } 2326 }
2319 } 2327 }
2320} 2328}
2321void MainWindow::selectFilterPopup( int fil ) 2329void MainWindow::selectFilterPopup( int fil )
2322{ 2330{
2323 selectFilter( fil + 1 ); 2331 selectFilter( fil + 1 );
2324 2332
2325} 2333}
2326void MainWindow::configureToolBar( int item ) 2334void MainWindow::configureToolBar( int item )
2327{ 2335{
2328 2336
2329 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2337 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2330 KOPrefs *p = KOPrefs::instance(); 2338 KOPrefs *p = KOPrefs::instance();
2331 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2339 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2332 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2340 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2333 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2341 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2334 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2342 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2335 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2343 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2336 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2344 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2337 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2345 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2338 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2346 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2339 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2347 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2340 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2348 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2341 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2349 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2342 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2350 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2343 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2351 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2344 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2352 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2345 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2353 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2346 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2354 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2347 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2355 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2348 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2356 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2349 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2357 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2350 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2358 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2351 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2359 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2352 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2360 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2353 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2361 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2354 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2362 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2355 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2363 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2356 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2364 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2357 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2365 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2358 // initActions(); 2366 // initActions();
2359 setCaption ( i18n("Toolbar changes needs a restart!") ); 2367 setCaption ( i18n("Toolbar changes needs a restart!") );
2360} 2368}
2361void MainWindow::setCaption ( const QString & c ) 2369void MainWindow::setCaption ( const QString & c )
2362{ 2370{
2363 QString cap = c; 2371 QString cap = c;
2364 cap.replace( QRegExp("\n"), " " ); 2372 cap.replace( QRegExp("\n"), " " );
2365 cap = cap.stripWhiteSpace(); 2373 cap = cap.stripWhiteSpace();
2366 if ( cap.isEmpty() ) 2374 if ( cap.isEmpty() )
2367 cap = "KO/Pi"; 2375 cap = "KO/Pi";
2368 QWidget::setCaption( cap ); 2376 QWidget::setCaption( cap );
2369} 2377}
2370void MainWindow::setCaptionToDates() 2378void MainWindow::setCaptionToDates()
2371{ 2379{
2372 QString selDates; 2380 QString selDates;
2373 QDate date = mView->startDate(); 2381 QDate date = mView->startDate();
2374 if ( ! date.isValid() ) { 2382 if ( ! date.isValid() ) {
2375 setCaption(""); 2383 setCaption("");
2376 return; 2384 return;
2377 } 2385 }
2378 selDates = KGlobal::locale()->formatDate( date, true); 2386 selDates = KGlobal::locale()->formatDate( date, true);
2379 if (mView->startDate() < mView->endDate() ) 2387 if (mView->startDate() < mView->endDate() )
2380 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2388 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2381 else { 2389 else {
2382 QString addString; 2390 QString addString;
2383 if ( date == QDateTime::currentDateTime().date() ) 2391 if ( date == QDateTime::currentDateTime().date() )
2384 addString = i18n("Today"); 2392 addString = i18n("Today");
2385 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2393 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2386 addString = i18n("Tomorrow"); 2394 addString = i18n("Tomorrow");
2387 if ( !addString.isEmpty() ) 2395 if ( !addString.isEmpty() )
2388 selDates = addString+", "+selDates ; 2396 selDates = addString+", "+selDates ;
2389 } 2397 }
2390 setCaption( i18n("Dates: ") + selDates ); 2398 setCaption( i18n("Dates: ") + selDates );
2391 2399
2392} 2400}
2393void MainWindow::showConfigureAgenda( ) 2401void MainWindow::showConfigureAgenda( )
2394{ 2402{
2395 int iii; 2403 int iii;
2396 for ( iii = 1;iii<= 10 ;++iii ){ 2404 for ( iii = 1;iii<= 10 ;++iii ){
2397 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2405 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2398 } 2406 }
2399 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2407 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2400} 2408}
2401void MainWindow::configureAgenda( int item ) 2409void MainWindow::configureAgenda( int item )
2402{ 2410{
2403 if ( KOPrefs::instance()->mHourSize == item ) 2411 if ( KOPrefs::instance()->mHourSize == item )
2404 return; 2412 return;
2405 KOPrefs::instance()->mHourSize=item; 2413 KOPrefs::instance()->mHourSize=item;
2406 mView->viewManager()->agendaView()->updateConfig(); 2414 mView->viewManager()->agendaView()->updateConfig();
2407} 2415}
2408 2416
2409void MainWindow::saveCalendar() 2417void MainWindow::saveCalendar()
2410{ 2418{
2411 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2419 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2412 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2420 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2413 bupDir = KGlobalSettings::backupDataDir(); 2421 bupDir = KGlobalSettings::backupDataDir();
2414 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2422 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2415 QString bupHint; 2423 QString bupHint;
2416 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2424 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2417 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2425 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2418 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2426 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2419 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2427 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2420 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2428 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2421 save(); 2429 save();
2422 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2430 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2423 backupAllFiles(); 2431 backupAllFiles();
2424} 2432}
2425void MainWindow::loadCalendar() 2433void MainWindow::loadCalendar()
2426{ 2434{
2427 2435
2428 2436
2429#if 0 2437#if 0
2430 QString fn = KOPrefs::instance()->mLastLoadFile; 2438 QString fn = KOPrefs::instance()->mLastLoadFile;
2431 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2439 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2432 2440
2433 if ( fn == "" ) 2441 if ( fn == "" )
2434 return; 2442 return;
2435 QFileInfo info; 2443 QFileInfo info;
2436 info.setFile( fn ); 2444 info.setFile( fn );
2437 QString mess; 2445 QString mess;
2438 bool loadbup = true; 2446 bool loadbup = true;
2439 if ( info. exists() ) { 2447 if ( info. exists() ) {
2440 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2448 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2441 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2449 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2442 mess, 2450 mess,
2443 i18n("Load!"), i18n("Cancel"), 0, 2451 i18n("Load!"), i18n("Cancel"), 0,
2444 0, 1 ); 2452 0, 1 );
2445 if ( result != 0 ) { 2453 if ( result != 0 ) {
2446 loadbup = false; 2454 loadbup = false;
2447 } 2455 }
2448 } else { 2456 } else {
2449 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2457 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2450 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2458 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2451 0, 1 ); 2459 0, 1 );
2452 2460
2453 return; 2461 return;
2454 } 2462 }
2455 if ( loadbup ) { 2463 if ( loadbup ) {
2456 mView->openCalendar( fn ); 2464 mView->openCalendar( fn );
2457 KOPrefs::instance()->mLastLoadFile = fn; 2465 KOPrefs::instance()->mLastLoadFile = fn;
2458 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2466 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2459 setCaption(mess); 2467 setCaption(mess);
2460 } 2468 }
2461#endif 2469#endif
2462 2470
2463} 2471}
2464void MainWindow::quickImportIcal() 2472void MainWindow::quickImportIcal()
2465{ 2473{
2466 importFile( KOPrefs::instance()->mLastImportFile, false ); 2474 importFile( KOPrefs::instance()->mLastImportFile, false );
2467} 2475}
2468void MainWindow::importFile( QString fn, bool quick ) 2476void MainWindow::importFile( QString fn, bool quick )
2469{ 2477{
2470 QFileInfo info; 2478 QFileInfo info;
2471 info.setFile( fn ); 2479 info.setFile( fn );
2472 QString mess; 2480 QString mess;
2473 if ( !info. exists() ) { 2481 if ( !info. exists() ) {
2474 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2482 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2475 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2483 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2476 mess ); 2484 mess );
2477 return; 2485 return;
2478 } 2486 }
2479 int result = 0; 2487 int result = 0;
2480 if ( !quick ) { 2488 if ( !quick ) {
2481 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2489 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2482 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2490 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2483 mess, 2491 mess,
2484 "Import", "Cancel", 0, 2492 "Import", "Cancel", 0,
2485 0, 1 ); 2493 0, 1 );
2486 } 2494 }
2487 if ( result == 0 ) { 2495 if ( result == 0 ) {
2488 if ( mView->openCalendar( fn, true )) { 2496 if ( mView->openCalendar( fn, true )) {
2489 KOPrefs::instance()->mLastImportFile = fn; 2497 KOPrefs::instance()->mLastImportFile = fn;
2490 setCaption(i18n("Imported file successfully")); 2498 setCaption(i18n("Imported file successfully"));
2491 } else { 2499 } else {
2492 setCaption(i18n("Error importing file")); 2500 setCaption(i18n("Error importing file"));
2493 } 2501 }
2494 } 2502 }
2495} 2503}
2496 2504
2497void MainWindow::importIcal() 2505void MainWindow::importIcal()
2498{ 2506{
2499 2507
2500 QString fn =KOPrefs::instance()->mLastImportFile; 2508 QString fn =KOPrefs::instance()->mLastImportFile;
2501 2509
2502 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2510 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2503 if ( fn == "" ) 2511 if ( fn == "" )
2504 return; 2512 return;
2505 importFile( fn, true ); 2513 importFile( fn, true );
2506 2514
2507} 2515}
2508 2516
2509void MainWindow::exportVCalendar() 2517void MainWindow::exportVCalendar()
2510{ 2518{
2511 QString fn = KOPrefs::instance()->mLastVcalFile; 2519 QString fn = KOPrefs::instance()->mLastVcalFile;
2512 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2520 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2513 if ( fn == "" ) 2521 if ( fn == "" )
2514 return; 2522 return;
2515 QFileInfo info; 2523 QFileInfo info;
2516 info.setFile( fn ); 2524 info.setFile( fn );
2517 QString mes; 2525 QString mes;
2518 bool createbup = true; 2526 bool createbup = true;
2519 if ( info. exists() ) { 2527 if ( info. exists() ) {
2520 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2528 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2521 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2529 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2522 i18n("Overwrite!"), i18n("Cancel"), 0, 2530 i18n("Overwrite!"), i18n("Cancel"), 0,
2523 0, 1 ); 2531 0, 1 );
2524 if ( result != 0 ) { 2532 if ( result != 0 ) {
2525 createbup = false; 2533 createbup = false;
2526 } 2534 }
2527 } 2535 }
2528 if ( createbup ) { 2536 if ( createbup ) {
2529 if ( mView->exportVCalendar( fn ) ) { 2537 if ( mView->exportVCalendar( fn ) ) {
2530 KOPrefs::instance()->mLastVcalFile = fn; 2538 KOPrefs::instance()->mLastVcalFile = fn;
2531 if ( fn.length() > 20 ) 2539 if ( fn.length() > 20 )
2532 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2540 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2533 else 2541 else
2534 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2542 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2535 setCaption(mes); 2543 setCaption(mes);
2536 } 2544 }
2537 } 2545 }
2538 2546
2539} 2547}
2540QString MainWindow::sentSyncFile() 2548QString MainWindow::sentSyncFile()
2541{ 2549{
2542#ifdef DESKTOP_VERSION 2550#ifdef DESKTOP_VERSION
2543 return locateLocal( "tmp", "copysynccal.ics" ); 2551 return locateLocal( "tmp", "copysynccal.ics" );
2544#else 2552#else
2545 return QString( "/tmp/copysynccal.ics" ); 2553 return QString( "/tmp/copysynccal.ics" );
2546#endif 2554#endif
2547} 2555}
2548 2556
2549void MainWindow::syncFileRequest() 2557void MainWindow::syncFileRequest()
2550{ 2558{
2551 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2559 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2552 mSyncManager->slotSyncMenu( 999 ); 2560 mSyncManager->slotSyncMenu( 999 );
2553 } 2561 }
2554 2562
2555 setCaption(i18n("Saving Data to temp file ..." )); 2563 setCaption(i18n("Saving Data to temp file ..." ));
2556 mView->saveCalendar( sentSyncFile() ); 2564 mView->saveCalendar( sentSyncFile() );
2557 setCaption(i18n("Data saved to temp file!" )); 2565 setCaption(i18n("Data saved to temp file!" ));
2558 2566
2559} 2567}
2560void MainWindow::getFile( bool success ) 2568void MainWindow::getFile( bool success )
2561{ 2569{
2562 if ( ! success ) { 2570 if ( ! success ) {
2563 setCaption( i18n("Error receiving file. Nothing changed!") ); 2571 setCaption( i18n("Error receiving file. Nothing changed!") );
2564 return; 2572 return;
2565 } 2573 }
2566 mView->mergeFile( sentSyncFile() ); 2574 mView->mergeFile( sentSyncFile() );
2567 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2575 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2568 mSyncManager->slotSyncMenu( 999 ); 2576 mSyncManager->slotSyncMenu( 999 );
2569 } 2577 }
2570 setCaption( i18n("Pi-Sync successful!") ); 2578 setCaption( i18n("Pi-Sync successful!") );
2571} 2579}
2572void MainWindow::printListView() 2580void MainWindow::printListView()
2573{ 2581{
2574 2582
2575 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2583 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2576 2584
2577 KMessageBox::information( this, message); 2585 KMessageBox::information( this, message);
2578} 2586}
2579void MainWindow::printSel( ) 2587void MainWindow::printSel( )
2580{ 2588{
2581 mView->viewManager()->agendaView()->agenda()->printSelection(); 2589 mView->viewManager()->agendaView()->agenda()->printSelection();
2582} 2590}
2583 2591
2584void MainWindow::printCal() 2592void MainWindow::printCal()
2585{ 2593{
2586 mView->print();//mCp->showDialog(); 2594 mView->print();//mCp->showDialog();
2587} 2595}
2588 2596
2589 2597
2590#include "libkdepim/kdatepicker.h" 2598#include "libkdepim/kdatepicker.h"
2591#include <kdatetbl.h> 2599#include <kdatetbl.h>
2592 2600
2593void MainWindow::weekAction() 2601void MainWindow::weekAction()
2594{ 2602{
2595 int month; 2603 int month;
2596 KPopupFrame* popup = new KPopupFrame(this); 2604 KPopupFrame* popup = new KPopupFrame(this);
2597 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2605 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2598 // ----- 2606 // -----
2599 picker->resize(picker->sizeHint()); 2607 picker->resize(picker->sizeHint());
2600 popup->setMainWidget(picker); 2608 popup->setMainWidget(picker);
2601 picker->setFocus(); 2609 picker->setFocus();
2602 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2610 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2603 int x = 0; 2611 int x = 0;
2604 int y = iconToolBar->height(); 2612 int y = iconToolBar->height();
2605 int dX = 0; 2613 int dX = 0;
2606 int dY = 0; 2614 int dY = 0;
2607 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2615 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2608 if ( iconToolBar->y() > height()/2 ) { 2616 if ( iconToolBar->y() > height()/2 ) {
2609 dY = picker->sizeHint().height()+8; 2617 dY = picker->sizeHint().height()+8;
2610 y = 0; 2618 y = 0;
2611 } 2619 }
2612 } else { 2620 } else {
2613 if ( iconToolBar->x() > width()/2 ) { // right side 2621 if ( iconToolBar->x() > width()/2 ) { // right side
2614 x=0; 2622 x=0;
2615 dX= picker->sizeHint().width()+8; 2623 dX= picker->sizeHint().width()+8;
2616 y = 0; 2624 y = 0;
2617 } else { 2625 } else {
2618 x= iconToolBar->width(); 2626 x= iconToolBar->width();
2619 y = 0; 2627 y = 0;
2620 } 2628 }
2621 } 2629 }
2622 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2630 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2623 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2631 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2624 { 2632 {
2625 month = picker->getResult(); 2633 month = picker->getResult();
2626 emit selectWeek ( month ); 2634 emit selectWeek ( month );
2627 //qDebug("weekSelected %d ", month); 2635 //qDebug("weekSelected %d ", month);
2628 } 2636 }
2629 delete popup; 2637 delete popup;
2630} 2638}
2631 2639
2632void MainWindow::hideEvent ( QHideEvent * ) 2640void MainWindow::hideEvent ( QHideEvent * )
2633{ 2641{
2634 QString message; 2642 QString message;
2635 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2643 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2636 if ( nextA.isValid() ) { 2644 if ( nextA.isValid() ) {
2637 QString sum = mCalendar->nextSummary(); 2645 QString sum = mCalendar->nextSummary();
2638 2646
2639 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2647 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2640 setCaption( message ); 2648 setCaption( message );
2641 } 2649 }
2642} 2650}
2643 2651
2644void MainWindow::resizeEvent( QResizeEvent* e) 2652void MainWindow::resizeEvent( QResizeEvent* e)
2645{ 2653{
2646#ifndef DESKTOP_VERSION 2654#ifndef DESKTOP_VERSION
2647 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2655 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2648 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2656 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2649 filterToolBar->hide(); 2657 filterToolBar->hide();
2650 else 2658 else
2651 filterToolBar->show(); 2659 filterToolBar->show();
2652 } 2660 }
2653#endif 2661#endif
2654 QMainWindow::resizeEvent( e); 2662 QMainWindow::resizeEvent( e);
2655} 2663}