summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-11-25 17:41:25 (UTC)
committer zautrix <zautrix>2005-11-25 17:41:25 (UTC)
commit279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (unidiff)
tree43ab776cd108874819e7c6e73070a7d989a9078f /korganizer
parent794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff)
downloadkdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2
sync
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp73
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp14
-rw-r--r--korganizer/mainwindow.h4
4 files changed, 78 insertions, 17 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8965d3b..307027a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,5189 +1,5244 @@
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 mMultiResourceSync = false;
369 flag_blockConflict = false; 370 flag_blockConflict = false;
370 flag_blockScrollBar = false; 371 flag_blockScrollBar = false;
371 flag_checkFileFirsttime = true; 372 flag_checkFileFirsttime = true;
372 flag_clearallviewsEventDisplay = false; 373 flag_clearallviewsEventDisplay = false;
373 flag_clearallviewsupdateView = false; 374 flag_clearallviewsupdateView = false;
374 mNextAlarmDateTime = QDateTime::currentDateTime(); 375 mNextAlarmDateTime = QDateTime::currentDateTime();
375 setFocusPolicy (NoFocus ); 376 setFocusPolicy (NoFocus );
376 mViewerCallerIsSearchDialog = false; 377 mViewerCallerIsSearchDialog = false;
377 mBlockShowDates = false; 378 mBlockShowDates = false;
378 mConflictingEvent = 0; 379 mConflictingEvent = 0;
379 mDatePickerMode = 0; 380 mDatePickerMode = 0;
380 mCurrentSyncDevice = ""; 381 mCurrentSyncDevice = "";
381 mViewManager = new KOViewManager( this ); 382 mViewManager = new KOViewManager( this );
382 mDialogManager = new KODialogManager( this ); 383 mDialogManager = new KODialogManager( this );
383 mEventViewerDialog = 0; 384 mEventViewerDialog = 0;
384 mModified = false; 385 mModified = false;
385 mReadOnly = false; 386 mReadOnly = false;
386 mSelectedIncidence = 0; 387 mSelectedIncidence = 0;
387 mCalPrinter = 0; 388 mCalPrinter = 0;
388 mFilters.setAutoDelete(true); 389 mFilters.setAutoDelete(true);
389 390
390 mCalendar->registerObserver( this ); 391 mCalendar->registerObserver( this );
391 // TODO: Make sure that view is updated, when calendar is changed. 392 // TODO: Make sure that view is updated, when calendar is changed.
392 393
393 mStorage = new FileStorage( mCalendar ); 394 mStorage = new FileStorage( mCalendar );
394 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 395 mNavigator = new DateNavigator( this, "datevav", mViewManager );
395 396
396 QBoxLayout *topLayout = (QBoxLayout*)layout(); 397 QBoxLayout *topLayout = (QBoxLayout*)layout();
397#ifndef KORG_NOSPLITTER 398#ifndef KORG_NOSPLITTER
398 // create the main layout frames. 399 // create the main layout frames.
399 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 400 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
400 topLayout->addWidget(mPanner); 401 topLayout->addWidget(mPanner);
401 402
402 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 403 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
403 "CalendarView::LeftFrame"); 404 "CalendarView::LeftFrame");
404 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 405 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
405 406
406 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 407 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
407 "CalendarView::DateNavigator" ); 408 "CalendarView::DateNavigator" );
408 409
409 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 410 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
410 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 411 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
411 mTodoList->setNavigator( mNavigator ); 412 mTodoList->setNavigator( mNavigator );
412 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 413 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
413 414
414#ifdef KORG_NORESOURCEVIEW 415#ifdef KORG_NORESOURCEVIEW
415 mResourceView = 0; 416 mResourceView = 0;
416#else 417#else
417 if ( mResourceManager ) { 418 if ( mResourceManager ) {
418 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 419 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
419 mResourceView->updateView(); 420 mResourceView->updateView();
420 connect( mResourceView, SIGNAL( resourcesChanged() ), 421 connect( mResourceView, SIGNAL( resourcesChanged() ),
421 SLOT( updateView() ) ); 422 SLOT( updateView() ) );
422 } else { 423 } else {
423 mResourceView = 0; 424 mResourceView = 0;
424 } 425 }
425#endif 426#endif
426 QWidget *rightBox = new QWidget( mPanner ); 427 QWidget *rightBox = new QWidget( mPanner );
427 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 428 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
428 429
429 mRightFrame = new QWidgetStack( rightBox ); 430 mRightFrame = new QWidgetStack( rightBox );
430 rightLayout->addWidget( mRightFrame, 1 ); 431 rightLayout->addWidget( mRightFrame, 1 );
431 432
432 mLeftFrame = mLeftSplitter; 433 mLeftFrame = mLeftSplitter;
433#else 434#else
434 //QWidget *mainBox = new QWidget( this ); 435 //QWidget *mainBox = new QWidget( this );
435 //QWidget *leftFrame = new QWidget( mainBox ); 436 //QWidget *leftFrame = new QWidget( mainBox );
436 //QBoxLayout * mainBoxLayout; 437 //QBoxLayout * mainBoxLayout;
437 if ( KOPrefs::instance()->mVerticalScreen ) { 438 if ( KOPrefs::instance()->mVerticalScreen ) {
438 //mainBoxLayout = new QVBoxLayout(mainBox); 439 //mainBoxLayout = new QVBoxLayout(mainBox);
439 //leftFrameLayout = new QHBoxLayout(leftFrame ); 440 //leftFrameLayout = new QHBoxLayout(leftFrame );
440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
444 } else { 445 } else {
445 //mainBoxLayout = new QHBoxLayout(mainBox); 446 //mainBoxLayout = new QHBoxLayout(mainBox);
446 //leftFrameLayout = new QVBoxLayout(leftFrame ); 447 //leftFrameLayout = new QVBoxLayout(leftFrame );
447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 448 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 449 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 450 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 451 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
451 } 452 }
452 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 453 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
453 //QBoxLayout * leftFrameLayout; 454 //QBoxLayout * leftFrameLayout;
454 topLayout->addWidget( mMainFrame ); 455 topLayout->addWidget( mMainFrame );
455#ifdef DESKTOP_VERSION 456#ifdef DESKTOP_VERSION
456 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 457 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
457 topLayout->addWidget( mDateScrollBar ); 458 topLayout->addWidget( mDateScrollBar );
458 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 459 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
459 if ( QApplication::desktop()->width() < 800 ) 460 if ( QApplication::desktop()->width() < 800 )
460 mDateScrollBar->hide(); 461 mDateScrollBar->hide();
461#endif 462#endif
462 //mainBoxLayout->addWidget (mLeftFrame); 463 //mainBoxLayout->addWidget (mLeftFrame);
463 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 464 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
464 "CalendarView::DateNavigator" ); 465 "CalendarView::DateNavigator" );
465#if 0 466#if 0
466 // FIXME 467 // FIXME
467 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 468 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
468 "CalendarView::DateNavigator", QDate::currentDate()); 469 "CalendarView::DateNavigator", QDate::currentDate());
469#endif 470#endif
470 // mDateNavigator->blockSignals( true ); 471 // mDateNavigator->blockSignals( true );
471 //leftFrameLayout->addWidget( mDateNavigator ); 472 //leftFrameLayout->addWidget( mDateNavigator );
472 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 473 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
473 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 474 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
474 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 475 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
475 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 476 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
476 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 477 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
477 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 478 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
478 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 480 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
480 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 481 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
481 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 482 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
482 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 483 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
483 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 484 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
484 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 485 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
485 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 486 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
486 487
487 488
488 mTodoList->setNavigator( mNavigator ); 489 mTodoList->setNavigator( mNavigator );
489#if 0 490#if 0
490 if ( QApplication::desktop()->width() < 480 ) { 491 if ( QApplication::desktop()->width() < 480 ) {
491 leftFrameLayout->addWidget(mFilterView); 492 leftFrameLayout->addWidget(mFilterView);
492 leftFrameLayout->addWidget(mTodoList, 2 ); 493 leftFrameLayout->addWidget(mTodoList, 2 );
493 494
494 } else { 495 } else {
495 leftFrameLayout->addWidget(mTodoList,2 ); 496 leftFrameLayout->addWidget(mTodoList,2 );
496 leftFrameLayout->addWidget(mFilterView ); 497 leftFrameLayout->addWidget(mFilterView );
497 } 498 }
498#endif 499#endif
499 mFilterView->hide(); 500 mFilterView->hide();
500 mCalEditView->hide(); 501 mCalEditView->hide();
501 QWidget *rightBox = new QWidget( mMainFrame ); 502 QWidget *rightBox = new QWidget( mMainFrame );
502 //mainBoxLayout->addWidget ( rightBox, 10 ); 503 //mainBoxLayout->addWidget ( rightBox, 10 );
503 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 504 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
504 mRightFrame = new QWidgetStack( rightBox ); 505 mRightFrame = new QWidgetStack( rightBox );
505 rightLayout->addWidget( mRightFrame, 10 ); 506 rightLayout->addWidget( mRightFrame, 10 );
506 507
507 //mLeftFrame = (QWidget *)leftFrame; 508 //mLeftFrame = (QWidget *)leftFrame;
508 if ( KOPrefs::instance()->mVerticalScreen ) { 509 if ( KOPrefs::instance()->mVerticalScreen ) {
509 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 510 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
510 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 511 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
511 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 512 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
512 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 513 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
513 } else { 514 } else {
514 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 515 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
515 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 516 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
516 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 517 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
517 } 518 }
518 if ( !KOPrefs::instance()->mShowDateNavigator) 519 if ( !KOPrefs::instance()->mShowDateNavigator)
519 mDateNavigator->hide(); 520 mDateNavigator->hide();
520 //qDebug("Calendarview Size %d %d ", width(), height()); 521 //qDebug("Calendarview Size %d %d ", width(), height());
521#endif 522#endif
522 523
523 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 524 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
524 SLOT( showDates( const KCal::DateList & ) ) ); 525 SLOT( showDates( const KCal::DateList & ) ) );
525 526
526 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 527 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
527 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 528 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
528 529
529 530
530 531
531 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 532 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
532 mViewManager, SLOT( showMonth( const QDate & ) ) ); 533 mViewManager, SLOT( showMonth( const QDate & ) ) );
533 534
534 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 535 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
535 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 536 mNavigator, SLOT( selectWeek( const QDate & ) ) );
536 537
537 connect( mDateNavigator, SIGNAL( goPrevYear() ), 538 connect( mDateNavigator, SIGNAL( goPrevYear() ),
538 mNavigator, SLOT( selectPreviousYear() ) ); 539 mNavigator, SLOT( selectPreviousYear() ) );
539 connect( mDateNavigator, SIGNAL( goNextYear() ), 540 connect( mDateNavigator, SIGNAL( goNextYear() ),
540 mNavigator, SLOT( selectNextYear() ) ); 541 mNavigator, SLOT( selectNextYear() ) );
541 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 542 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
542 mNavigator, SLOT( selectPreviousMonth() ) ); 543 mNavigator, SLOT( selectPreviousMonth() ) );
543 connect( mDateNavigator, SIGNAL( goNextMonth() ), 544 connect( mDateNavigator, SIGNAL( goNextMonth() ),
544 mNavigator, SLOT( selectNextMonth() ) ); 545 mNavigator, SLOT( selectNextMonth() ) );
545 546
546 connect( mDateNavigator, SIGNAL( goPrevious() ), 547 connect( mDateNavigator, SIGNAL( goPrevious() ),
547 mNavigator, SLOT( selectPrevious() ) ); 548 mNavigator, SLOT( selectPrevious() ) );
548 connect( mDateNavigator, SIGNAL( goNext() ), 549 connect( mDateNavigator, SIGNAL( goNext() ),
549 mNavigator, SLOT( selectNext() ) ); 550 mNavigator, SLOT( selectNext() ) );
550 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 551 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
551 mNavigator, SLOT( slotMonthSelect( int ) ) ); 552 mNavigator, SLOT( slotMonthSelect( int ) ) );
552 553
553 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 554 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
554 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 555 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
555#if 0 556#if 0
556 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 557 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
557 SLOT( incidenceAdded( Incidence *) ) ); 558 SLOT( incidenceAdded( Incidence *) ) );
558#endif 559#endif
559 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 560 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
560 561
561 connect( this, SIGNAL( configChanged() ), 562 connect( this, SIGNAL( configChanged() ),
562 mDateNavigator, SLOT( updateConfig() ) ); 563 mDateNavigator, SLOT( updateConfig() ) );
563 564
564 connect( mTodoList, SIGNAL( newTodoSignal() ), 565 connect( mTodoList, SIGNAL( newTodoSignal() ),
565 SLOT( newTodo() ) ); 566 SLOT( newTodo() ) );
566 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 567 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
567 SLOT( newSubTodo( Todo * ) ) ); 568 SLOT( newSubTodo( Todo * ) ) );
568 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 569 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
569 SLOT( editTodo( Todo * ) ) ); 570 SLOT( editTodo( Todo * ) ) );
570 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 571 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
571 SLOT( showTodo( Todo *) ) ); 572 SLOT( showTodo( Todo *) ) );
572 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 573 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
573 SLOT( deleteTodo( Todo *) ) ); 574 SLOT( deleteTodo( Todo *) ) );
574 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 575 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
575 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 576 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
576 SLOT( purgeCompleted() ) ); 577 SLOT( purgeCompleted() ) );
577 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 578 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
578 SIGNAL( todoModified( Todo *, int ) ) ); 579 SIGNAL( todoModified( Todo *, int ) ) );
579 580
580 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 581 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
581 this, SLOT ( cloneIncidence( Incidence * ) ) ); 582 this, SLOT ( cloneIncidence( Incidence * ) ) );
582 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 583 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
583 this, SLOT (cancelIncidence( Incidence * ) ) ); 584 this, SLOT (cancelIncidence( Incidence * ) ) );
584 585
585 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 586 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
586 this, SLOT ( moveIncidence( Incidence * ) ) ); 587 this, SLOT ( moveIncidence( Incidence * ) ) );
587 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 588 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
588 this, SLOT ( beamIncidence( Incidence * ) ) ); 589 this, SLOT ( beamIncidence( Incidence * ) ) );
589 590
590 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 591 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
591 this, SLOT ( todo_unsub( Todo * ) ) ); 592 this, SLOT ( todo_unsub( Todo * ) ) );
592 593
593 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 594 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
594 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 595 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
595 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 596 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
596 SLOT( updateTodo( Todo *, int ) ) ); 597 SLOT( updateTodo( Todo *, int ) ) );
597 connect( this, SIGNAL( todoModified( Todo *, int )), this, 598 connect( this, SIGNAL( todoModified( Todo *, int )), this,
598 SLOT( changeTodoDisplay( Todo *, int ) ) ); 599 SLOT( changeTodoDisplay( Todo *, int ) ) );
599 600
600 601
601 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 602 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
602 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 603 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
603 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 604 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
604 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 605 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
605 606
606 607
607 608
608 609
609 610
610 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 611 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
611 SLOT(checkClipboard())); 612 SLOT(checkClipboard()));
612 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 613 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
613 SLOT( processTodoListSelection( Incidence * ) ) ); 614 SLOT( processTodoListSelection( Incidence * ) ) );
614 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 615 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
615 616
616 // kdDebug() << "CalendarView::CalendarView() done" << endl; 617 // kdDebug() << "CalendarView::CalendarView() done" << endl;
617 618
618 mDateFrame = new QVBox(0,0,WType_Popup); 619 mDateFrame = new QVBox(0,0,WType_Popup);
619 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 620 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
620 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 621 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
621 mDateFrame->setLineWidth(3); 622 mDateFrame->setLineWidth(3);
622 mDateFrame->hide(); 623 mDateFrame->hide();
623 mDateFrame->setCaption( i18n( "Pick a date to display")); 624 mDateFrame->setCaption( i18n( "Pick a date to display"));
624 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 625 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
625 626
626 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 627 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
627 628
628 mEventEditor = mDialogManager->getEventEditor(); 629 mEventEditor = mDialogManager->getEventEditor();
629 mTodoEditor = mDialogManager->getTodoEditor(); 630 mTodoEditor = mDialogManager->getTodoEditor();
630 631
631 mFlagEditDescription = false; 632 mFlagEditDescription = false;
632 633
633 mSuspendTimer = new QTimer( this ); 634 mSuspendTimer = new QTimer( this );
634 mAlarmTimer = new QTimer( this ); 635 mAlarmTimer = new QTimer( this );
635 mRecheckAlarmTimer = new QTimer( this ); 636 mRecheckAlarmTimer = new QTimer( this );
636 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 637 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
637 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 638 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
638 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 639 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
639 mAlarmDialog = new AlarmDialog( this ); 640 mAlarmDialog = new AlarmDialog( this );
640 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 641 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
641 mAlarmDialog->setServerNotification( false ); 642 mAlarmDialog->setServerNotification( false );
642 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 643 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
643 644
644 645
645#ifndef DESKTOP_VERSION 646#ifndef DESKTOP_VERSION
646//US listen for arriving address resultsets 647//US listen for arriving address resultsets
647 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 648 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
648 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 649 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
649#endif 650#endif
650 mDateNavigator->setCalendar( mCalendar ); 651 mDateNavigator->setCalendar( mCalendar );
651} 652}
652 653
653 654
654CalendarView::~CalendarView() 655CalendarView::~CalendarView()
655{ 656{
656 // kdDebug() << "~CalendarView()" << endl; 657 // kdDebug() << "~CalendarView()" << endl;
657 //qDebug("CalendarView::~CalendarView() "); 658 //qDebug("CalendarView::~CalendarView() ");
658 delete mDialogManager; 659 delete mDialogManager;
659 delete mViewManager; 660 delete mViewManager;
660 delete mStorage; 661 delete mStorage;
661 delete mDateFrame ; 662 delete mDateFrame ;
662 delete mEventViewerDialog; 663 delete mEventViewerDialog;
663 //kdDebug() << "~CalendarView() done" << endl; 664 //kdDebug() << "~CalendarView() done" << endl;
664} 665}
665 666
666 667
667void CalendarView::nextConflict( bool all, bool allday ) 668void CalendarView::nextConflict( bool all, bool allday )
668{ 669{
669 if ( flag_blockConflict ) return; 670 if ( flag_blockConflict ) return;
670 flag_blockConflict = true; 671 flag_blockConflict = true;
671 QPtrList<Event> testlist = mCalendar->events(); 672 QPtrList<Event> testlist = mCalendar->events();
672 Event * test = testlist.first(); 673 Event * test = testlist.first();
673 while ( test ) { 674 while ( test ) {
674 test->setTagged( false ); 675 test->setTagged( false );
675 test = testlist.next(); 676 test = testlist.next();
676 } 677 }
677 QTime st ( 0,0,0); 678 QTime st ( 0,0,0);
678 if ( mViewManager->currentView() == mViewManager->agendaView() ) 679 if ( mViewManager->currentView() == mViewManager->agendaView() )
679 st = mViewManager->agendaView()->agenda()->getEndTime(); 680 st = mViewManager->agendaView()->agenda()->getEndTime();
680 //qDebug("time %s ", st.toString().latin1()); 681 //qDebug("time %s ", st.toString().latin1());
681 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 682 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
682 QDateTime conflict; 683 QDateTime conflict;
683 QDateTime retVal; 684 QDateTime retVal;
684 bool found = false; 685 bool found = false;
685 Event * cE = 0; 686 Event * cE = 0;
686 Event * cE2 = 0; 687 Event * cE2 = 0;
687 QPtrList<Event> testlist2 = testlist; 688 QPtrList<Event> testlist2 = testlist;
688 test = testlist.first(); 689 test = testlist.first();
689 bool skip = false; 690 bool skip = false;
690 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 691 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
691 //QTime tm; 692 //QTime tm;
692 //tm.start(); 693 //tm.start();
693 while ( test ) { 694 while ( test ) {
694 qApp->processEvents(); 695 qApp->processEvents();
695 skip = false; 696 skip = false;
696 if ( !all ) skip = ( allday != test->doesFloat() ); 697 if ( !all ) skip = ( allday != test->doesFloat() );
697 if ( !skip ) { 698 if ( !skip ) {
698 if ( found ) 699 if ( found )
699 skip = !test->matchTime( &startDT, &conflict ); 700 skip = !test->matchTime( &startDT, &conflict );
700 else 701 else
701 skip = !test->matchTime( &startDT, 0 ); 702 skip = !test->matchTime( &startDT, 0 );
702 } 703 }
703 if ( !skip ) { 704 if ( !skip ) {
704 Event * test2 = testlist2.first(); 705 Event * test2 = testlist2.first();
705 while ( test2 ) { 706 while ( test2 ) {
706 skip = test2->isTagged(); 707 skip = test2->isTagged();
707 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 708 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
708 if ( !skip ) { 709 if ( !skip ) {
709 if ( found ) 710 if ( found )
710 skip = !test2->matchTime( &startDT, &conflict ); 711 skip = !test2->matchTime( &startDT, &conflict );
711 else 712 else
712 skip = !test2->matchTime( &startDT, 0 ); 713 skip = !test2->matchTime( &startDT, 0 );
713 } 714 }
714 if ( !skip ) { 715 if ( !skip ) {
715 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 716 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
716 //qDebug("overlap "); 717 //qDebug("overlap ");
717 if ( ! found ) { 718 if ( ! found ) {
718 if ( retVal >= startDT ) { 719 if ( retVal >= startDT ) {
719 conflict = retVal; 720 conflict = retVal;
720 cE = test; 721 cE = test;
721 cE2 = test2; 722 cE2 = test2;
722 found = true; 723 found = true;
723 } 724 }
724 } else { 725 } else {
725 if ( retVal >= startDT && retVal < conflict ) { 726 if ( retVal >= startDT && retVal < conflict ) {
726 conflict = retVal; 727 conflict = retVal;
727 cE = test; 728 cE = test;
728 cE2 = test2; 729 cE2 = test2;
729 } 730 }
730 } 731 }
731 } 732 }
732 } 733 }
733 test2 = testlist2.next(); 734 test2 = testlist2.next();
734 } 735 }
735 } 736 }
736 test->setTagged( true ); 737 test->setTagged( true );
737 test = testlist.next(); 738 test = testlist.next();
738 } 739 }
739 //qDebug("Search time : %d", tm.elapsed()); 740 //qDebug("Search time : %d", tm.elapsed());
740 if ( found ) { 741 if ( found ) {
741 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 742 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
742 mViewManager->showDayView(); 743 mViewManager->showDayView();
743 mNavigator->slotDaySelect( conflict.date() ); 744 mNavigator->slotDaySelect( conflict.date() );
744 int hour = conflict.time().hour(); 745 int hour = conflict.time().hour();
745 mViewManager->agendaView()->setStartHour( hour ); 746 mViewManager->agendaView()->setStartHour( hour );
746 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 747 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
747 flag_blockConflict = false; 748 flag_blockConflict = false;
748 return; 749 return;
749 } 750 }
750 751
751 topLevelWidget()->setCaption( i18n("No conflict found") ); 752 topLevelWidget()->setCaption( i18n("No conflict found") );
752 //qDebug("No conflict found "); 753 //qDebug("No conflict found ");
753 flag_blockConflict = false; 754 flag_blockConflict = false;
754 return; 755 return;
755} 756}
756 757
757void CalendarView::conflictAll() 758void CalendarView::conflictAll()
758{ 759{
759 nextConflict ( true, true ); 760 nextConflict ( true, true );
760} 761}
761void CalendarView::conflictAllday() 762void CalendarView::conflictAllday()
762{ 763{
763 nextConflict ( false, true ); 764 nextConflict ( false, true );
764} 765}
765void CalendarView::conflictNotAll() 766void CalendarView::conflictNotAll()
766{ 767{
767 nextConflict ( false, false ); 768 nextConflict ( false, false );
768} 769}
769 770
770void CalendarView::setCalReadOnly( int id, bool readO ) 771void CalendarView::setCalReadOnly( int id, bool readO )
771{ 772{
772 if ( readO ) { 773 if ( readO ) {
773 emit save(); 774 emit save();
774 } 775 }
775 mCalendar->setReadOnly( id, readO ); 776 mCalendar->setReadOnly( id, readO );
776} 777}
777void CalendarView::setScrollBarStep(int val ) 778void CalendarView::setScrollBarStep(int val )
778{ 779{
779#ifdef DESKTOP_VERSION 780#ifdef DESKTOP_VERSION
780 mDateScrollBar->setLineStep ( val ); 781 mDateScrollBar->setLineStep ( val );
781#endif 782#endif
782} 783}
783void CalendarView::scrollBarValue(int val ) 784void CalendarView::scrollBarValue(int val )
784{ 785{
785#ifdef DESKTOP_VERSION 786#ifdef DESKTOP_VERSION
786 if ( QApplication::desktop()->width() < 800 ) return; 787 if ( QApplication::desktop()->width() < 800 ) return;
787 if ( flag_blockScrollBar ) return; 788 if ( flag_blockScrollBar ) return;
788 flag_blockScrollBar = true; 789 flag_blockScrollBar = true;
789 int count = mNavigator->selectedDates().count(); 790 int count = mNavigator->selectedDates().count();
790 int day = mNavigator->selectedDates().first().dayOfYear(); 791 int day = mNavigator->selectedDates().first().dayOfYear();
791 int stepdays = val; 792 int stepdays = val;
792 if ( mDateScrollBar->lineStep () <= count ) { 793 if ( mDateScrollBar->lineStep () <= count ) {
793 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 794 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
794 //qDebug("VAL %d ",val ); 795 //qDebug("VAL %d ",val );
795 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 796 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
796 stepdays = day+stepdays; 797 stepdays = day+stepdays;
797 if ( stepdays < 0 ) stepdays = 0; 798 if ( stepdays < 0 ) stepdays = 0;
798 } 799 }
799 if ( stepdays == day ) { 800 if ( stepdays == day ) {
800 flag_blockScrollBar = false; 801 flag_blockScrollBar = false;
801 return; 802 return;
802 } 803 }
803 int year = mNavigator->selectedDates().first().year(); 804 int year = mNavigator->selectedDates().first().year();
804 QDate d ( year,1,1 ); 805 QDate d ( year,1,1 );
805 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 806 mNavigator->selectDates( d.addDays( stepdays-1) , count );
806 flag_blockScrollBar = false; 807 flag_blockScrollBar = false;
807#endif 808#endif
808 809
809} 810}
810void CalendarView::updateView(const QDate &start, const QDate &end) 811void CalendarView::updateView(const QDate &start, const QDate &end)
811{ 812{
812#ifdef DESKTOP_VERSION 813#ifdef DESKTOP_VERSION
813 if ( ! mDateScrollBar->draggingSlider () ) { 814 if ( ! mDateScrollBar->draggingSlider () ) {
814 int dof = start.dayOfYear(); 815 int dof = start.dayOfYear();
815 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 816 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
816 if ( dof != mDateScrollBar->value() ) { 817 if ( dof != mDateScrollBar->value() ) {
817 mDateScrollBar->blockSignals( true ); 818 mDateScrollBar->blockSignals( true );
818 mDateScrollBar->setValue( start.dayOfYear()); 819 mDateScrollBar->setValue( start.dayOfYear());
819 mDateScrollBar->blockSignals( false ); 820 mDateScrollBar->blockSignals( false );
820 } 821 }
821 } 822 }
822#endif 823#endif
823 mTodoList->updateView(); 824 mTodoList->updateView();
824 mViewManager->updateView(start, end); 825 mViewManager->updateView(start, end);
825 //mDateNavigator->updateView(); 826 //mDateNavigator->updateView();
826} 827}
827 828
828 829
829 830
830void CalendarView::checkFiles() 831void CalendarView::checkFiles()
831{ 832{
832 QString message; 833 QString message;
833 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 834 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
834 KopiCalendarFile * cal = calendars.first(); 835 KopiCalendarFile * cal = calendars.first();
835 while ( cal ) { 836 while ( cal ) {
836 if ( cal->mErrorOnLoad ) { 837 if ( cal->mErrorOnLoad ) {
837 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 838 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
838 } 839 }
839 cal = calendars.next(); 840 cal = calendars.next();
840 } 841 }
841 if ( !message.isEmpty() ) { 842 if ( !message.isEmpty() ) {
842 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); 843 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);
843 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); 844 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
844 } 845 }
845 if ( flag_checkFileFirsttime ) { 846 if ( flag_checkFileFirsttime ) {
846 flag_checkFileFirsttime = false; 847 flag_checkFileFirsttime = false;
847 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 848 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
848 } 849 }
849} 850}
850void CalendarView::checkAlarms() 851void CalendarView::checkAlarms()
851{ 852{
852 KConfig *config = KOGlobals::config(); 853 KConfig *config = KOGlobals::config();
853 config->setGroup( "AppRun" ); 854 config->setGroup( "AppRun" );
854 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 855 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
855 int daysto = dt.daysTo( QDate::currentDate() ); 856 int daysto = dt.daysTo( QDate::currentDate() );
856 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 857 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
857 dt = dt.addDays( days ); 858 dt = dt.addDays( days );
858 int secto = dt.secsTo( QDateTime::currentDateTime() ); 859 int secto = dt.secsTo( QDateTime::currentDateTime() );
859 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 860 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
860 //qDebug("KO: Reading program stop %d ", secs); 861 //qDebug("KO: Reading program stop %d ", secs);
861 //secs -= ( 3600 * 24*3 ); // debug only 862 //secs -= ( 3600 * 24*3 ); // debug only
862 QDateTime latest = dt.addSecs ( secs ); 863 QDateTime latest = dt.addSecs ( secs );
863 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 864 qDebug("KO: Last termination on %s ", latest.toString().latin1());
864 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 865 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
865 QPtrList<Incidence> el = mCalendar->rawIncidences(); 866 QPtrList<Incidence> el = mCalendar->rawIncidences();
866 QPtrList<Incidence> al; 867 QPtrList<Incidence> al;
867 Incidence* inL = el.first(); 868 Incidence* inL = el.first();
868 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 869 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
869 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 870 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
870 while ( inL ) { 871 while ( inL ) {
871 bool ok = false; 872 bool ok = false;
872 int offset = 0; 873 int offset = 0;
873 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 874 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
874 if ( ok ) { 875 if ( ok ) {
875 //qDebug("OK %s",next.toString().latin1()); 876 //qDebug("OK %s",next.toString().latin1());
876 if ( next < cur ) { 877 if ( next < cur ) {
877 al.append( inL ); 878 al.append( inL );
878 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 879 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
879 } 880 }
880 } 881 }
881 inL = el.next(); 882 inL = el.next();
882 } 883 }
883 if ( al.count() ) { 884 if ( al.count() ) {
884 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 885 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
885 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 886 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
886 QVBoxLayout* lay = new QVBoxLayout( dia ); 887 QVBoxLayout* lay = new QVBoxLayout( dia );
887 lay->setSpacing( 0 ); 888 lay->setSpacing( 0 );
888 lay->setMargin( 0 ); 889 lay->setMargin( 0 );
889 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 890 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
890 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 891 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
891 lay->addWidget( matb ); 892 lay->addWidget( matb );
892 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 893 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
893 int wid = 210; 894 int wid = 210;
894 int x = QApplication::desktop()->width() - wid - 7; 895 int x = QApplication::desktop()->width() - wid - 7;
895 int y = QApplication::desktop()->height() - wid - 70; 896 int y = QApplication::desktop()->height() - wid - 70;
896 dia->setGeometry ( x,y,wid,wid); 897 dia->setGeometry ( x,y,wid,wid);
897 } else { 898 } else {
898 int si = 220; 899 int si = 220;
899 if ( QApplication::desktop()->width() > 470 ) 900 if ( QApplication::desktop()->width() > 470 )
900 si = 400; 901 si = 400;
901 dia->resize(si,si/2); 902 dia->resize(si,si/2);
902 } 903 }
903 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 904 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
904 dia->show(); 905 dia->show();
905 906
906 } 907 }
907#if 0 908#if 0
908 // for creating timetracker test data 909 // for creating timetracker test data
909 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 910 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
910 Todo * nt; 911 Todo * nt;
911 mCalendar->close(); 912 mCalendar->close();
912 { 913 {
913 Todo * root1 = new Todo; 914 Todo * root1 = new Todo;
914 mCalendar->addTodo( root1 ); 915 mCalendar->addTodo( root1 );
915 root1->setSummary( "Project1"); 916 root1->setSummary( "Project1");
916 root1->setPriority( 1 ); 917 root1->setPriority( 1 );
917 root1->setCategories( QString( "Cat_Pro1") ); 918 root1->setCategories( QString( "Cat_Pro1") );
918 root1->setDescription( "This is a test description of a root Project" ); 919 root1->setDescription( "This is a test description of a root Project" );
919 root1->setPercentComplete( 20 ); 920 root1->setPercentComplete( 20 );
920 updateView(); 921 updateView();
921 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 922 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
922 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 923 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
923 924
924 nt = new Todo; 925 nt = new Todo;
925 mCalendar->addTodo( nt ); 926 mCalendar->addTodo( nt );
926 nt->setSummary( "Planning Project1"); 927 nt->setSummary( "Planning Project1");
927 nt->setPriority( 1 ); 928 nt->setPriority( 1 );
928 nt->setDescription( "This is a test description of Planning Project1" ); 929 nt->setDescription( "This is a test description of Planning Project1" );
929 nt->setPercentComplete( 20 ); 930 nt->setPercentComplete( 20 );
930 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 931 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
931 932
932 933
933 Todo * sub1 = nt; 934 Todo * sub1 = nt;
934 sub1->setRelatedTo( root1 ); 935 sub1->setRelatedTo( root1 );
935 936
936 nt = new Todo; 937 nt = new Todo;
937 mCalendar->addTodo( nt ); 938 mCalendar->addTodo( nt );
938 nt->setSummary( "Planning Project1: Lutz"); 939 nt->setSummary( "Planning Project1: Lutz");
939 nt->setPriority( 1 ); 940 nt->setPriority( 1 );
940 nt->setDescription( "This todo counts the actual work of a person on a project" ); 941 nt->setDescription( "This todo counts the actual work of a person on a project" );
941 nt->setPercentComplete( 20 ); 942 nt->setPercentComplete( 20 );
942 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); 943 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") );
943 Todo * workLutz11 = nt; 944 Todo * workLutz11 = nt;
944 workLutz11->setRelatedTo( sub1 ); 945 workLutz11->setRelatedTo( sub1 );
945 946
946 nt = new Todo; 947 nt = new Todo;
947 mCalendar->addTodo( nt ); 948 mCalendar->addTodo( nt );
948 nt->setSummary( "Planning Project1: Norbert"); 949 nt->setSummary( "Planning Project1: Norbert");
949 nt->setPriority( 1 ); 950 nt->setPriority( 1 );
950 nt->setDescription( "This todo counts the actual work of a person on a project" ); 951 nt->setDescription( "This todo counts the actual work of a person on a project" );
951 nt->setPercentComplete( 20 ); 952 nt->setPercentComplete( 20 );
952 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); 953 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") );
953 Todo * workNorbert11 = nt; 954 Todo * workNorbert11 = nt;
954 workNorbert11->setRelatedTo( sub1 ); 955 workNorbert11->setRelatedTo( sub1 );
955 956
956 nt = new Todo; 957 nt = new Todo;
957 mCalendar->addTodo( nt ); 958 mCalendar->addTodo( nt );
958 nt->setSummary( "Work on 1"); 959 nt->setSummary( "Work on 1");
959 nt->setPriority( 1 ); 960 nt->setPriority( 1 );
960 nt->setDescription( "This is a test description of Work Project_1" ); 961 nt->setDescription( "This is a test description of Work Project_1" );
961 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); 962 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") );
962 nt->setPercentComplete( 20 ); 963 nt->setPercentComplete( 20 );
963 964
964 Todo * sub2 = nt; 965 Todo * sub2 = nt;
965 sub2->setRelatedTo( root1 ); 966 sub2->setRelatedTo( root1 );
966 967
967 968
968 nt = new Todo; 969 nt = new Todo;
969 mCalendar->addTodo( nt ); 970 mCalendar->addTodo( nt );
970 nt->setSummary( "Work on 1: Lutz"); 971 nt->setSummary( "Work on 1: Lutz");
971 nt->setPriority( 1 ); 972 nt->setPriority( 1 );
972 nt->setDescription( "This todo counts the actual work of a person on a project" ); 973 nt->setDescription( "This todo counts the actual work of a person on a project" );
973 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); 974 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") );
974 nt->setPercentComplete( 20 ); 975 nt->setPercentComplete( 20 );
975 Todo * workLutz12 = nt; 976 Todo * workLutz12 = nt;
976 workLutz12->setRelatedTo( sub2 ); 977 workLutz12->setRelatedTo( sub2 );
977 978
978 nt = new Todo; 979 nt = new Todo;
979 mCalendar->addTodo( nt ); 980 mCalendar->addTodo( nt );
980 nt->setSummary( "Work on 1: Norbert"); 981 nt->setSummary( "Work on 1: Norbert");
981 nt->setPriority( 1 ); 982 nt->setPriority( 1 );
982 nt->setDescription( "This todo counts the actual work of a person on a project" ); 983 nt->setDescription( "This todo counts the actual work of a person on a project" );
983 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); 984 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") );
984 nt->setPercentComplete( 20 ); 985 nt->setPercentComplete( 20 );
985 Todo * workNorbert12 = nt; 986 Todo * workNorbert12 = nt;
986 workNorbert12->setRelatedTo( sub2 ); 987 workNorbert12->setRelatedTo( sub2 );
987 988
988 int secLenRunning = 7200; 989 int secLenRunning = 7200;
989 int secLenPausing = 3600 * 3; 990 int secLenPausing = 3600 * 3;
990 int dayInterval = 1; 991 int dayInterval = 1;
991 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 992 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
992 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 993 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
993 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 994 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
994 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 995 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
995 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 996 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
996 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 997 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
997 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 998 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
998 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 999 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
999 1000
1000 } 1001 }
1001 1002
1002 { 1003 {
1003 Todo * root1 = new Todo; 1004 Todo * root1 = new Todo;
1004 mCalendar->addTodo( root1 ); 1005 mCalendar->addTodo( root1 );
1005 root1->setSummary( "Project2"); 1006 root1->setSummary( "Project2");
1006 root1->setPriority( 1 ); 1007 root1->setPriority( 1 );
1007 root1->setDescription( "This is a test description of a root Project 2" ); 1008 root1->setDescription( "This is a test description of a root Project 2" );
1008 root1->setPercentComplete( 20 ); 1009 root1->setPercentComplete( 20 );
1009 root1->setCategories( QString( "Cat_Pro2") ); 1010 root1->setCategories( QString( "Cat_Pro2") );
1010 updateView(); 1011 updateView();
1011 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 1012 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1012 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 1013 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
1013 int secLenRunning = 7200; 1014 int secLenRunning = 7200;
1014 int secLenPausing = 3600 * 3; 1015 int secLenPausing = 3600 * 3;
1015 int dayInterval = 1; 1016 int dayInterval = 1;
1016 1017
1017 nt = new Todo; 1018 nt = new Todo;
1018 mCalendar->addTodo( nt ); 1019 mCalendar->addTodo( nt );
1019 nt->setSummary( "Planning Project2"); 1020 nt->setSummary( "Planning Project2");
1020 nt->setPriority( 1 ); 1021 nt->setPriority( 1 );
1021 nt->setDescription( "This is a test description of Planning_Project_2" ); 1022 nt->setDescription( "This is a test description of Planning_Project_2" );
1022 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); 1023 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") );
1023 nt->setPercentComplete( 20 ); 1024 nt->setPercentComplete( 20 );
1024 1025
1025 1026
1026 Todo * sub1 = nt; 1027 Todo * sub1 = nt;
1027 sub1->setRelatedTo( root1 ); 1028 sub1->setRelatedTo( root1 );
1028 1029
1029 nt = new Todo; 1030 nt = new Todo;
1030 mCalendar->addTodo( nt ); 1031 mCalendar->addTodo( nt );
1031 nt->setSummary( "Planning Project2: Lutz"); 1032 nt->setSummary( "Planning Project2: Lutz");
1032 nt->setPriority( 1 ); 1033 nt->setPriority( 1 );
1033 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1034 nt->setDescription( "This todo counts the actual work of a person on a project" );
1034 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); 1035 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") );
1035 nt->setPercentComplete( 20 ); 1036 nt->setPercentComplete( 20 );
1036 Todo * workLutz11 = nt; 1037 Todo * workLutz11 = nt;
1037 workLutz11->setRelatedTo( sub1 ); 1038 workLutz11->setRelatedTo( sub1 );
1038 1039
1039 nt = new Todo; 1040 nt = new Todo;
1040 mCalendar->addTodo( nt ); 1041 mCalendar->addTodo( nt );
1041 nt->setSummary( "Planning Project2: Norbert"); 1042 nt->setSummary( "Planning Project2: Norbert");
1042 nt->setPriority( 1 ); 1043 nt->setPriority( 1 );
1043 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1044 nt->setDescription( "This todo counts the actual work of a person on a project" );
1044 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); 1045 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") );
1045 nt->setPercentComplete( 20 ); 1046 nt->setPercentComplete( 20 );
1046 Todo * workNorbert11 = nt; 1047 Todo * workNorbert11 = nt;
1047 workNorbert11->setRelatedTo( sub1 ); 1048 workNorbert11->setRelatedTo( sub1 );
1048 1049
1049 nt = new Todo; 1050 nt = new Todo;
1050 mCalendar->addTodo( nt ); 1051 mCalendar->addTodo( nt );
1051 nt->setSummary( "Work on 2"); 1052 nt->setSummary( "Work on 2");
1052 nt->setPriority( 1 ); 1053 nt->setPriority( 1 );
1053 nt->setDescription( "This is a test description of Work Project_2" ); 1054 nt->setDescription( "This is a test description of Work Project_2" );
1054 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); 1055 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") );
1055 nt->setPercentComplete( 20 ); 1056 nt->setPercentComplete( 20 );
1056 1057
1057 Todo * sub2 = nt; 1058 Todo * sub2 = nt;
1058 sub2->setRelatedTo( root1 ); 1059 sub2->setRelatedTo( root1 );
1059 1060
1060 1061
1061 nt = new Todo; 1062 nt = new Todo;
1062 mCalendar->addTodo( nt ); 1063 mCalendar->addTodo( nt );
1063 nt->setSummary( "Work on 2: Lutz"); 1064 nt->setSummary( "Work on 2: Lutz");
1064 nt->setPriority( 1 ); 1065 nt->setPriority( 1 );
1065 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1066 nt->setDescription( "This todo counts the actual work of a person on a project" );
1066 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); 1067 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") );
1067 nt->setPercentComplete( 20 ); 1068 nt->setPercentComplete( 20 );
1068 Todo * workLutz12 = nt; 1069 Todo * workLutz12 = nt;
1069 workLutz12->setRelatedTo( sub2 ); 1070 workLutz12->setRelatedTo( sub2 );
1070 1071
1071 nt = new Todo; 1072 nt = new Todo;
1072 mCalendar->addTodo( nt ); 1073 mCalendar->addTodo( nt );
1073 nt->setSummary( "Work on 2: Norbert"); 1074 nt->setSummary( "Work on 2: Norbert");
1074 nt->setPriority( 1 ); 1075 nt->setPriority( 1 );
1075 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1076 nt->setDescription( "This todo counts the actual work of a person on a project" );
1076 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); 1077 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") );
1077 nt->setPercentComplete( 20 ); 1078 nt->setPercentComplete( 20 );
1078 Todo * workNorbert12 = nt; 1079 Todo * workNorbert12 = nt;
1079 workNorbert12->setRelatedTo( sub2 ); 1080 workNorbert12->setRelatedTo( sub2 );
1080 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1081 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1081 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1082 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1082 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1083 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1083 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1084 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1084 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1085 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1085 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1086 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1086 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1087 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1087 } 1088 }
1088 updateView(); 1089 updateView();
1089#endif 1090#endif
1090 1091
1091} 1092}
1092void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1093void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1093{ 1094{
1094 static int ccc = 0; 1095 static int ccc = 0;
1095 ++ccc; 1096 ++ccc;
1096 QDateTime t_start = start; 1097 QDateTime t_start = start;
1097 runT->setPriority( 5 ); 1098 runT->setPriority( 5 );
1098 runT->setPercentComplete( 0 ); 1099 runT->setPercentComplete( 0 );
1099 int count = 0; 1100 int count = 0;
1100 int prio = 5; 1101 int prio = 5;
1101 int complete = 0; 1102 int complete = 0;
1102 while ( t_start < end ) { 1103 while ( t_start < end ) {
1103 ++count; 1104 ++count;
1104 if ( count > ccc ) { 1105 if ( count > ccc ) {
1105 count = 0; 1106 count = 0;
1106 --prio; 1107 --prio;
1107 if ( prio == 0 ) prio = 5; 1108 if ( prio == 0 ) prio = 5;
1108 complete += 20; 1109 complete += 20;
1109 if ( complete > 100 ) complete = 0; 1110 if ( complete > 100 ) complete = 0;
1110 runT->setPriority( prio ); 1111 runT->setPriority( prio );
1111 runT->setPercentComplete( complete ); 1112 runT->setPercentComplete( complete );
1112 } 1113 }
1113 runT->setRunning( true ); 1114 runT->setRunning( true );
1114 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1115 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1115 if ( dayInterval ) 1116 if ( dayInterval )
1116 t_start = t_start.addDays( dayInterval ); 1117 t_start = t_start.addDays( dayInterval );
1117 else { 1118 else {
1118 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1119 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1119 } 1120 }
1120 } 1121 }
1121} 1122}
1122 1123
1123void CalendarView::showDay( QDate d ) 1124void CalendarView::showDay( QDate d )
1124{ 1125{
1125 dateNavigator()->blockSignals( true ); 1126 dateNavigator()->blockSignals( true );
1126 dateNavigator()->selectDate( d ); 1127 dateNavigator()->selectDate( d );
1127 dateNavigator()->blockSignals( false ); 1128 dateNavigator()->blockSignals( false );
1128 mViewManager->showDayView(); 1129 mViewManager->showDayView();
1129 //dateNavigator()->selectDate( d ); 1130 //dateNavigator()->selectDate( d );
1130} 1131}
1131void CalendarView::timerAlarm() 1132void CalendarView::timerAlarm()
1132{ 1133{
1133 //qDebug("CalendarView::timerAlarm() "); 1134 //qDebug("CalendarView::timerAlarm() ");
1134 computeAlarm(mAlarmNotification ); 1135 computeAlarm(mAlarmNotification );
1135} 1136}
1136 1137
1137void CalendarView::suspendAlarm() 1138void CalendarView::suspendAlarm()
1138{ 1139{
1139 //qDebug(" CalendarView::suspendAlarm() "); 1140 //qDebug(" CalendarView::suspendAlarm() ");
1140 computeAlarm(mSuspendAlarmNotification ); 1141 computeAlarm(mSuspendAlarmNotification );
1141 1142
1142} 1143}
1143 1144
1144void CalendarView::startAlarm( QString mess , QString filename) 1145void CalendarView::startAlarm( QString mess , QString filename)
1145{ 1146{
1146 1147
1147 topLevelWidget()->showNormal(); 1148 topLevelWidget()->showNormal();
1148 topLevelWidget()->setActiveWindow(); 1149 topLevelWidget()->setActiveWindow();
1149 topLevelWidget()->raise(); 1150 topLevelWidget()->raise();
1150 1151
1151 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1152 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1152 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1153 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1153 1154
1154} 1155}
1155 1156
1156void CalendarView::checkNextTimerAlarm() 1157void CalendarView::checkNextTimerAlarm()
1157{ 1158{
1158 mCalendar->checkAlarmForIncidence( 0, true ); 1159 mCalendar->checkAlarmForIncidence( 0, true );
1159} 1160}
1160 1161
1161void CalendarView::computeAlarm( QString msg ) 1162void CalendarView::computeAlarm( QString msg )
1162{ 1163{
1163 1164
1164 QString mess = msg; 1165 QString mess = msg;
1165 QString mAlarmMessage = mess.mid( 9 ); 1166 QString mAlarmMessage = mess.mid( 9 );
1166 QString filename = MainWindow::resourcePath(); 1167 QString filename = MainWindow::resourcePath();
1167 filename += "koalarm.wav"; 1168 filename += "koalarm.wav";
1168 QString tempfilename; 1169 QString tempfilename;
1169 if ( mess.left( 13 ) == "suspend_alarm") { 1170 if ( mess.left( 13 ) == "suspend_alarm") {
1170 bool error = false; 1171 bool error = false;
1171 int len = mess.mid( 13 ).find("+++"); 1172 int len = mess.mid( 13 ).find("+++");
1172 if ( len < 2 ) 1173 if ( len < 2 )
1173 error = true; 1174 error = true;
1174 else { 1175 else {
1175 tempfilename = mess.mid( 13, len ); 1176 tempfilename = mess.mid( 13, len );
1176 if ( !QFile::exists( tempfilename ) ) 1177 if ( !QFile::exists( tempfilename ) )
1177 error = true; 1178 error = true;
1178 } 1179 }
1179 if ( ! error ) { 1180 if ( ! error ) {
1180 filename = tempfilename; 1181 filename = tempfilename;
1181 } 1182 }
1182 mAlarmMessage = mess.mid( 13+len+3 ); 1183 mAlarmMessage = mess.mid( 13+len+3 );
1183 //qDebug("suspend file %s ",tempfilename.latin1() ); 1184 //qDebug("suspend file %s ",tempfilename.latin1() );
1184 startAlarm( mAlarmMessage, filename); 1185 startAlarm( mAlarmMessage, filename);
1185 return; 1186 return;
1186 } 1187 }
1187 if ( mess.left( 11 ) == "timer_alarm") { 1188 if ( mess.left( 11 ) == "timer_alarm") {
1188 //mTimerTime = 0; 1189 //mTimerTime = 0;
1189 startAlarm( mess.mid( 11 ), filename ); 1190 startAlarm( mess.mid( 11 ), filename );
1190 return; 1191 return;
1191 } 1192 }
1192 if ( mess.left( 10 ) == "proc_alarm") { 1193 if ( mess.left( 10 ) == "proc_alarm") {
1193 bool error = false; 1194 bool error = false;
1194 int len = mess.mid( 10 ).find("+++"); 1195 int len = mess.mid( 10 ).find("+++");
1195 if ( len < 2 ) 1196 if ( len < 2 )
1196 error = true; 1197 error = true;
1197 else { 1198 else {
1198 tempfilename = mess.mid( 10, len ); 1199 tempfilename = mess.mid( 10, len );
1199 if ( !QFile::exists( tempfilename ) ) 1200 if ( !QFile::exists( tempfilename ) )
1200 error = true; 1201 error = true;
1201 } 1202 }
1202 if ( error ) { 1203 if ( error ) {
1203 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1204 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1204 mAlarmMessage += mess.mid( 10+len+3+9 ); 1205 mAlarmMessage += mess.mid( 10+len+3+9 );
1205 } else { 1206 } else {
1206 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1207 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1207 //qDebug("-----system command %s ",tempfilename.latin1() ); 1208 //qDebug("-----system command %s ",tempfilename.latin1() );
1208#ifndef _WIN32_ 1209#ifndef _WIN32_
1209 if ( vfork () == 0 ) { 1210 if ( vfork () == 0 ) {
1210 execl ( tempfilename.latin1(), 0 ); 1211 execl ( tempfilename.latin1(), 0 );
1211 return; 1212 return;
1212 } 1213 }
1213#else 1214#else
1214 QProcess* p = new QProcess(); 1215 QProcess* p = new QProcess();
1215 p->addArgument( tempfilename.latin1() ); 1216 p->addArgument( tempfilename.latin1() );
1216 p->start(); 1217 p->start();
1217 return; 1218 return;
1218#endif 1219#endif
1219 1220
1220 return; 1221 return;
1221 } 1222 }
1222 1223
1223 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1224 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1224 } 1225 }
1225 if ( mess.left( 11 ) == "audio_alarm") { 1226 if ( mess.left( 11 ) == "audio_alarm") {
1226 bool error = false; 1227 bool error = false;
1227 int len = mess.mid( 11 ).find("+++"); 1228 int len = mess.mid( 11 ).find("+++");
1228 if ( len < 2 ) 1229 if ( len < 2 )
1229 error = true; 1230 error = true;
1230 else { 1231 else {
1231 tempfilename = mess.mid( 11, len ); 1232 tempfilename = mess.mid( 11, len );
1232 if ( !QFile::exists( tempfilename ) ) 1233 if ( !QFile::exists( tempfilename ) )
1233 error = true; 1234 error = true;
1234 } 1235 }
1235 if ( ! error ) { 1236 if ( ! error ) {
1236 filename = tempfilename; 1237 filename = tempfilename;
1237 } 1238 }
1238 mAlarmMessage = mess.mid( 11+len+3+9 ); 1239 mAlarmMessage = mess.mid( 11+len+3+9 );
1239 //qDebug("audio file command %s ",tempfilename.latin1() ); 1240 //qDebug("audio file command %s ",tempfilename.latin1() );
1240 } 1241 }
1241 if ( mess.left( 9 ) == "cal_alarm") { 1242 if ( mess.left( 9 ) == "cal_alarm") {
1242 mAlarmMessage = mess.mid( 9 ) ; 1243 mAlarmMessage = mess.mid( 9 ) ;
1243 } 1244 }
1244 1245
1245 startAlarm( mAlarmMessage, filename ); 1246 startAlarm( mAlarmMessage, filename );
1246 1247
1247 1248
1248} 1249}
1249 1250
1250void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1251void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1251{ 1252{
1252 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1253 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1253 1254
1254 mSuspendAlarmNotification = noti; 1255 mSuspendAlarmNotification = noti;
1255 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1256 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1256 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1257 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1257 mSuspendTimer->start( ms , true ); 1258 mSuspendTimer->start( ms , true );
1258#ifdef DESKTOP_VERSION 1259#ifdef DESKTOP_VERSION
1259 if ( QApplication::desktop()->width() < 1024 ) { 1260 if ( QApplication::desktop()->width() < 1024 ) {
1260 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1261 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1261 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1262 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1262 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1263 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1263 QFile file( fn ); 1264 QFile file( fn );
1264 if (!file.open( IO_WriteOnly ) ) { 1265 if (!file.open( IO_WriteOnly ) ) {
1265 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1266 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1266 } else { 1267 } else {
1267 QTextStream ts( &file ); 1268 QTextStream ts( &file );
1268 ts << mess; 1269 ts << mess;
1269 file.close(); 1270 file.close();
1270 } 1271 }
1271 } 1272 }
1272#endif 1273#endif
1273 1274
1274} 1275}
1275 1276
1276void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1277void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1277{ 1278{
1278 mNextAlarmDateTime = qdt; 1279 mNextAlarmDateTime = qdt;
1279 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1280 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1280 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1281 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1281#ifndef DESKTOP_VERSION 1282#ifndef DESKTOP_VERSION
1282 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1283 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1283#endif 1284#endif
1284 return; 1285 return;
1285 } 1286 }
1286#ifdef DESKTOP_VERSION 1287#ifdef DESKTOP_VERSION
1287 if ( QApplication::desktop()->width() < 1024 ) { 1288 if ( QApplication::desktop()->width() < 1024 ) {
1288 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1289 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1289 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1290 //qDebug("nextalarm = \n%s ",mess.latin1() );
1290 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1291 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1291 QFile file( fn ); 1292 QFile file( fn );
1292 if (!file.open( IO_WriteOnly ) ) { 1293 if (!file.open( IO_WriteOnly ) ) {
1293 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1294 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1294 } else { 1295 } else {
1295 QTextStream ts( &file ); 1296 QTextStream ts( &file );
1296 ts << mess; 1297 ts << mess;
1297 file.close(); 1298 file.close();
1298 } 1299 }
1299 } 1300 }
1300#endif 1301#endif
1301 int maxSec; 1302 int maxSec;
1302 //maxSec = 5; //testing only 1303 //maxSec = 5; //testing only
1303 maxSec = 86400+3600; // one day+1hour 1304 maxSec = 86400+3600; // one day+1hour
1304 mAlarmNotification = noti; 1305 mAlarmNotification = noti;
1305 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1306 int sec = QDateTime::currentDateTime().secsTo( qdt );
1306 if ( sec > maxSec ) { 1307 if ( sec > maxSec ) {
1307 mRecheckAlarmTimer->start( maxSec * 1000 ); 1308 mRecheckAlarmTimer->start( maxSec * 1000 );
1308 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1309 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1309 return; 1310 return;
1310 } else { 1311 } else {
1311 mRecheckAlarmTimer->stop(); 1312 mRecheckAlarmTimer->stop();
1312 } 1313 }
1313 //qDebug("Alarm timer started with secs: %d ", sec); 1314 //qDebug("Alarm timer started with secs: %d ", sec);
1314 mAlarmTimer->start( sec * 1000 , true ); 1315 mAlarmTimer->start( sec * 1000 , true );
1315 1316
1316} 1317}
1317// called by mRecheckAlarmTimer to get next alarm 1318// called by mRecheckAlarmTimer to get next alarm
1318// we need this, because a QTimer has only a max range of 25 days 1319// we need this, because a QTimer has only a max range of 25 days
1319void CalendarView::recheckTimerAlarm() 1320void CalendarView::recheckTimerAlarm()
1320{ 1321{
1321 mAlarmTimer->stop(); 1322 mAlarmTimer->stop();
1322 mRecheckAlarmTimer->stop(); 1323 mRecheckAlarmTimer->stop();
1323 mCalendar->checkAlarmForIncidence( 0, true ); 1324 mCalendar->checkAlarmForIncidence( 0, true );
1324} 1325}
1325#ifndef DESKTOP_VERSION 1326#ifndef DESKTOP_VERSION
1326void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1327void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1327#else 1328#else
1328void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1329void CalendarView::removeAlarm(const QDateTime &, const QString & )
1329#endif 1330#endif
1330{ 1331{
1331 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1332 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1332 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1333 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1333#ifndef DESKTOP_VERSION 1334#ifndef DESKTOP_VERSION
1334 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1335 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1335#endif 1336#endif
1336 return; 1337 return;
1337 } 1338 }
1338 mAlarmTimer->stop(); 1339 mAlarmTimer->stop();
1339} 1340}
1340void CalendarView::selectWeekNum ( int num ) 1341void CalendarView::selectWeekNum ( int num )
1341{ 1342{
1342 dateNavigator()->blockSignals( true ); 1343 dateNavigator()->blockSignals( true );
1343 dateNavigator()->selectWeek( num ); 1344 dateNavigator()->selectWeek( num );
1344 dateNavigator()->blockSignals( false ); 1345 dateNavigator()->blockSignals( false );
1345 mViewManager->showWeekView(); 1346 mViewManager->showWeekView();
1346} 1347}
1347KOViewManager *CalendarView::viewManager() 1348KOViewManager *CalendarView::viewManager()
1348{ 1349{
1349 return mViewManager; 1350 return mViewManager;
1350} 1351}
1351 1352
1352KODialogManager *CalendarView::dialogManager() 1353KODialogManager *CalendarView::dialogManager()
1353{ 1354{
1354 return mDialogManager; 1355 return mDialogManager;
1355} 1356}
1356 1357
1357QDate CalendarView::startDate() 1358QDate CalendarView::startDate()
1358{ 1359{
1359 DateList dates = mNavigator->selectedDates(); 1360 DateList dates = mNavigator->selectedDates();
1360 1361
1361 return dates.first(); 1362 return dates.first();
1362} 1363}
1363 1364
1364QDate CalendarView::endDate() 1365QDate CalendarView::endDate()
1365{ 1366{
1366 DateList dates = mNavigator->selectedDates(); 1367 DateList dates = mNavigator->selectedDates();
1367 1368
1368 return dates.last(); 1369 return dates.last();
1369} 1370}
1370 1371
1371 1372
1372void CalendarView::createPrinter() 1373void CalendarView::createPrinter()
1373{ 1374{
1374#ifndef KORG_NOPRINTER 1375#ifndef KORG_NOPRINTER
1375 if (!mCalPrinter) { 1376 if (!mCalPrinter) {
1376 mCalPrinter = new CalPrinter(this, mCalendar); 1377 mCalPrinter = new CalPrinter(this, mCalendar);
1377 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1378 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1378 } 1379 }
1379#endif 1380#endif
1380} 1381}
1381 1382
1382 1383
1383//KOPrefs::instance()->mWriteBackFile 1384//KOPrefs::instance()->mWriteBackFile
1384//KOPrefs::instance()->mWriteBackExistingOnly 1385//KOPrefs::instance()->mWriteBackExistingOnly
1385 1386
1386// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1387// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1387// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1388// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1388// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1389// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1389// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1390// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1390// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1391// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1391// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1392// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1392 1393
1393int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1394int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1394{ 1395{
1395 1396
1396 // 0 equal 1397 // 0 equal
1397 // 1 take local 1398 // 1 take local
1398 // 2 take remote 1399 // 2 take remote
1399 // 3 cancel 1400 // 3 cancel
1400 QDateTime lastSync = mLastCalendarSync; 1401 QDateTime lastSync = mLastCalendarSync;
1401 QDateTime localMod = local->lastModified(); 1402 QDateTime localMod = local->lastModified();
1402 QDateTime remoteMod = remote->lastModified(); 1403 QDateTime remoteMod = remote->lastModified();
1403 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1404 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1404 bool remCh, locCh; 1405 bool remCh, locCh;
1405 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1406 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1406 //if ( remCh ) 1407 //if ( remCh )
1407 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1408 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1408 locCh = ( localMod > mLastCalendarSync ); 1409 locCh = ( localMod > mLastCalendarSync );
1409 if ( !remCh && ! locCh ) { 1410 if ( !remCh && ! locCh ) {
1410 //qDebug("both not changed "); 1411 //qDebug("both not changed ");
1411 lastSync = localMod.addDays(1); 1412 lastSync = localMod.addDays(1);
1412 if ( mode <= SYNC_PREF_ASK ) 1413 if ( mode <= SYNC_PREF_ASK )
1413 return 0; 1414 return 0;
1414 } else { 1415 } else {
1415 if ( locCh ) { 1416 if ( locCh ) {
1416 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1417 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1417 lastSync = localMod.addDays( -1 ); 1418 lastSync = localMod.addDays( -1 );
1418 if ( !remCh ) 1419 if ( !remCh )
1419 remoteMod = ( lastSync.addDays( -1 ) ); 1420 remoteMod = ( lastSync.addDays( -1 ) );
1420 } else { 1421 } else {
1421 //qDebug(" not loc changed "); 1422 //qDebug(" not loc changed ");
1422 lastSync = localMod.addDays( 1 ); 1423 lastSync = localMod.addDays( 1 );
1423 if ( remCh ) 1424 if ( remCh )
1424 remoteMod =( lastSync.addDays( 1 ) ); 1425 remoteMod =( lastSync.addDays( 1 ) );
1425 1426
1426 } 1427 }
1427 } 1428 }
1428 full = true; 1429 full = true;
1429 if ( mode < SYNC_PREF_ASK ) 1430 if ( mode < SYNC_PREF_ASK )
1430 mode = SYNC_PREF_ASK; 1431 mode = SYNC_PREF_ASK;
1431 } else { 1432 } else {
1432 if ( localMod == remoteMod ) 1433 if ( localMod == remoteMod )
1433 // if ( local->revision() == remote->revision() ) 1434 // if ( local->revision() == remote->revision() )
1434 return 0; 1435 return 0;
1435 1436
1436 } 1437 }
1437 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1438 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1438 1439
1439 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1440 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1440 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1441 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1441 //full = true; //debug only 1442 //full = true; //debug only
1442 if ( full ) { 1443 if ( full ) {
1443 bool equ = false; 1444 bool equ = false;
1444 if ( local->typeID() == eventID ) { 1445 if ( local->typeID() == eventID ) {
1445 equ = (*((Event*) local) == *((Event*) remote)); 1446 equ = (*((Event*) local) == *((Event*) remote));
1446 } 1447 }
1447 else if ( local->typeID() == todoID ) 1448 else if ( local->typeID() == todoID )
1448 equ = (*((Todo*) local) == (*(Todo*) remote)); 1449 equ = (*((Todo*) local) == (*(Todo*) remote));
1449 else if ( local->typeID() == journalID ) 1450 else if ( local->typeID() == journalID )
1450 equ = (*((Journal*) local) == *((Journal*) remote)); 1451 equ = (*((Journal*) local) == *((Journal*) remote));
1451 if ( equ ) { 1452 if ( equ ) {
1452 //qDebug("equal "); 1453 //qDebug("equal ");
1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1454 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1454 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1455 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1455 } 1456 }
1456 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1457 if ( mode < SYNC_PREF_FORCE_LOCAL )
1457 return 0; 1458 return 0;
1458 1459
1459 }//else //debug only 1460 }//else //debug only
1460 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1461 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1461 } 1462 }
1462 int result; 1463 int result;
1463 bool localIsNew; 1464 bool localIsNew;
1464 //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() ); 1465 //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() );
1465 1466
1466 1467
1467 // ************************************************ 1468 // ************************************************
1468 // ************************************************ 1469 // ************************************************
1469 // ************************************************ 1470 // ************************************************
1470 // We may have that lastSync > remoteMod AND lastSync > localMod 1471 // We may have that lastSync > remoteMod AND lastSync > localMod
1471 // BUT remoteMod != localMod 1472 // BUT remoteMod != localMod
1472 1473
1473 1474
1474 if ( full && mode < SYNC_PREF_NEWEST ) 1475 if ( full && mode < SYNC_PREF_NEWEST )
1475 mode = SYNC_PREF_ASK; 1476 mode = SYNC_PREF_ASK;
1476 1477
1477 switch( mode ) { 1478 switch( mode ) {
1478 case SYNC_PREF_LOCAL: 1479 case SYNC_PREF_LOCAL:
1479 if ( lastSync > remoteMod ) 1480 if ( lastSync > remoteMod )
1480 return 1; 1481 return 1;
1481 if ( lastSync > localMod ) 1482 if ( lastSync > localMod )
1482 return 2; 1483 return 2;
1483 return 1; 1484 return 1;
1484 break; 1485 break;
1485 case SYNC_PREF_REMOTE: 1486 case SYNC_PREF_REMOTE:
1486 if ( lastSync > localMod ) 1487 if ( lastSync > localMod )
1487 return 2; 1488 return 2;
1488 if ( lastSync > remoteMod ) 1489 if ( lastSync > remoteMod )
1489 return 1; 1490 return 1;
1490 return 2; 1491 return 2;
1491 break; 1492 break;
1492 case SYNC_PREF_NEWEST: 1493 case SYNC_PREF_NEWEST:
1493 if ( localMod >= remoteMod ) 1494 if ( localMod >= remoteMod )
1494 return 1; 1495 return 1;
1495 else 1496 else
1496 return 2; 1497 return 2;
1497 break; 1498 break;
1498 case SYNC_PREF_ASK: 1499 case SYNC_PREF_ASK:
1499 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1500 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1500 if ( lastSync > remoteMod && lastSync > localMod) 1501 if ( lastSync > remoteMod && lastSync > localMod)
1501 return 0; 1502 return 0;
1502 if ( lastSync > remoteMod ) 1503 if ( lastSync > remoteMod )
1503 return 1; 1504 return 1;
1504 if ( lastSync > localMod ) 1505 if ( lastSync > localMod )
1505 return 2; 1506 return 2;
1506 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1507 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1507 localIsNew = localMod >= remoteMod; 1508 localIsNew = localMod >= remoteMod;
1508 if ( localIsNew ) 1509 if ( localIsNew )
1509 getEventViewerDialog()->setColorMode( 1 ); 1510 getEventViewerDialog()->setColorMode( 1 );
1510 else 1511 else
1511 getEventViewerDialog()->setColorMode( 2 ); 1512 getEventViewerDialog()->setColorMode( 2 );
1512 getEventViewerDialog()->setIncidence(local); 1513 getEventViewerDialog()->setIncidence(local);
1513 if ( localIsNew ) 1514 if ( localIsNew )
1514 getEventViewerDialog()->setColorMode( 2 ); 1515 getEventViewerDialog()->setColorMode( 2 );
1515 else 1516 else
1516 getEventViewerDialog()->setColorMode( 1 ); 1517 getEventViewerDialog()->setColorMode( 1 );
1517 getEventViewerDialog()->addIncidence(remote); 1518 getEventViewerDialog()->addIncidence(remote);
1518 getEventViewerDialog()->setColorMode( 0 ); 1519 getEventViewerDialog()->setColorMode( 0 );
1519 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1520 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1520 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1521 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1521 getEventViewerDialog()->showMe(); 1522 getEventViewerDialog()->showMe();
1522 result = getEventViewerDialog()->executeS( localIsNew ); 1523 result = getEventViewerDialog()->executeS( localIsNew );
1523 return result; 1524 return result;
1524 1525
1525 break; 1526 break;
1526 case SYNC_PREF_FORCE_LOCAL: 1527 case SYNC_PREF_FORCE_LOCAL:
1527 return 1; 1528 return 1;
1528 break; 1529 break;
1529 case SYNC_PREF_FORCE_REMOTE: 1530 case SYNC_PREF_FORCE_REMOTE:
1530 return 2; 1531 return 2;
1531 break; 1532 break;
1532 1533
1533 default: 1534 default:
1534 // SYNC_PREF_TAKE_BOTH not implemented 1535 // SYNC_PREF_TAKE_BOTH not implemented
1535 break; 1536 break;
1536 } 1537 }
1537 return 0; 1538 return 0;
1538} 1539}
1539Event* CalendarView::getLastSyncEvent() 1540Event* CalendarView::getLastSyncEvent()
1540{ 1541{
1541 Event* lse; 1542 Event* lse;
1542 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1543 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1543 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1544 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1544 if (!lse) { 1545 if (!lse) {
1545 lse = new Event(); 1546 lse = new Event();
1546 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1547 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1547 QString sum = ""; 1548 QString sum = "";
1548 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1549 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1549 sum = "E: "; 1550 sum = "E: ";
1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1551 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1551 lse->setDtStart( mLastCalendarSync ); 1552 lse->setDtStart( mLastCalendarSync );
1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1553 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1553 lse->setCategories( i18n("SyncEvent") ); 1554 lse->setCategories( i18n("SyncEvent") );
1554 lse->setReadOnly( true ); 1555 lse->setReadOnly( true );
1556 lse->setCalID( 1 );
1555 mCalendar->addEvent( lse ); 1557 mCalendar->addEvent( lse );
1556 } 1558 }
1557 1559
1558 return lse; 1560 return lse;
1559 1561
1560} 1562}
1561 1563
1562// we check, if the to delete event has a id for a profile 1564// we check, if the to delete event has a id for a profile
1563// if yes, we set this id in the profile to delete 1565// if yes, we set this id in the profile to delete
1564void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1566void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1565{ 1567{
1566 if ( lastSync.count() == 0 ) { 1568 if ( lastSync.count() == 0 ) {
1567 //qDebug(" lastSync.count() == 0"); 1569 //qDebug(" lastSync.count() == 0");
1568 return; 1570 return;
1569 } 1571 }
1570 if ( toDelete->typeID() == journalID ) 1572 if ( toDelete->typeID() == journalID )
1571 return; 1573 return;
1572 1574
1573 Event* eve = lastSync.first(); 1575 Event* eve = lastSync.first();
1574 1576
1575 while ( eve ) { 1577 while ( eve ) {
1576 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1578 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1577 if ( !id.isEmpty() ) { 1579 if ( !id.isEmpty() ) {
1578 QString des = eve->description(); 1580 QString des = eve->description();
1579 QString pref = "e"; 1581 QString pref = "e";
1580 if ( toDelete->typeID() == todoID ) 1582 if ( toDelete->typeID() == todoID )
1581 pref = "t"; 1583 pref = "t";
1582 des += pref+ id + ","; 1584 des += pref+ id + ",";
1583 eve->setReadOnly( false ); 1585 eve->setReadOnly( false );
1584 eve->setDescription( des ); 1586 eve->setDescription( des );
1585 //qDebug("setdes %s ", des.latin1()); 1587 //qDebug("setdes %s ", des.latin1());
1586 eve->setReadOnly( true ); 1588 eve->setReadOnly( true );
1587 } 1589 }
1588 eve = lastSync.next(); 1590 eve = lastSync.next();
1589 } 1591 }
1590 1592
1591} 1593}
1592void CalendarView::checkExternalId( Incidence * inc ) 1594void CalendarView::checkExternalId( Incidence * inc )
1593{ 1595{
1594 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1596 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1595 checkExternSyncEvent( lastSync, inc ); 1597 checkExternSyncEvent( lastSync, inc );
1596 1598
1597} 1599}
1598bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1600bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1599{ 1601{
1600 bool syncOK = true; 1602 bool syncOK = true;
1601 int addedEvent = 0; 1603 int addedEvent = 0;
1602 int addedEventR = 0; 1604 int addedEventR = 0;
1603 int deletedEventR = 0; 1605 int deletedEventR = 0;
1604 int deletedEventL = 0; 1606 int deletedEventL = 0;
1605 int changedLocal = 0; 1607 int changedLocal = 0;
1606 int changedRemote = 0; 1608 int changedRemote = 0;
1607 int filteredIN = 0; 1609 int filteredIN = 0;
1608 int filteredOUT = 0; 1610 int filteredOUT = 0;
1609 //QPtrList<Event> el = local->rawEvents(); 1611 //QPtrList<Event> el = local->rawEvents();
1610 Event* eventR; 1612 Event* eventR;
1611 QString uid; 1613 QString uid;
1612 int take; 1614 int take;
1613 Event* eventRSync; 1615 Event* eventRSync;
1614 Event* eventLSync; 1616 Event* eventLSync;
1615 clearAllViews(); 1617 clearAllViews();
1616 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1618 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1617 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1619 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1618 bool fullDateRange = false; 1620 bool fullDateRange = false;
1619 local->resetTempSyncStat(); 1621 local->resetTempSyncStat();
1620 mLastCalendarSync = QDateTime::currentDateTime(); 1622 mLastCalendarSync = QDateTime::currentDateTime();
1621 if ( mSyncManager->syncWithDesktop() ) { 1623 if ( mSyncManager->syncWithDesktop() ) {
1622 remote->resetPilotStat(1); 1624 remote->resetPilotStat(1);
1623 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1625 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1624 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1626 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1625 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1627 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1626 } else { 1628 } else {
1627 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1629 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1628 } 1630 }
1629 } 1631 }
1630 QDateTime modifiedCalendar = mLastCalendarSync; 1632 QDateTime modifiedCalendar = mLastCalendarSync;
1631 eventLSync = getLastSyncEvent(); 1633 eventLSync = getLastSyncEvent();
1632 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1634 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1633 if ( eventR ) { 1635 if ( eventR ) {
1634 qDebug("last-syncEvent on remote found "); 1636 qDebug("last-syncEvent on remote found ");
1635 eventRSync = (Event*) eventR->clone(); 1637 eventRSync = (Event*) eventR->clone();
1636 remote->deleteEvent(eventR ); 1638 remote->deleteEvent(eventR );
1637 1639
1638 } else { 1640 } else {
1639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1641 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1640 eventRSync = (Event*)eventLSync->clone(); 1642 eventRSync = (Event*)eventLSync->clone();
1641 } else { 1643 } else {
1642 fullDateRange = true; 1644 fullDateRange = true;
1643 eventRSync = new Event(); 1645 eventRSync = new Event();
1644 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1646 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1645 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1647 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1646 eventRSync->setDtStart( mLastCalendarSync ); 1648 eventRSync->setDtStart( mLastCalendarSync );
1647 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1649 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1648 eventRSync->setCategories( i18n("SyncEvent") ); 1650 eventRSync->setCategories( i18n("SyncEvent") );
1649 } 1651 }
1650 } 1652 }
1651 if ( eventLSync->dtStart() == mLastCalendarSync ) 1653 if ( eventLSync->dtStart() == mLastCalendarSync )
1652 fullDateRange = true; 1654 fullDateRange = true;
1653 1655
1654 if ( ! fullDateRange ) { 1656 if ( ! fullDateRange ) {
1655 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1657 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1656 1658
1657 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1659 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1658 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1660 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1659 fullDateRange = true; 1661 fullDateRange = true;
1660 } 1662 }
1661 } 1663 }
1662 if ( mSyncManager->syncWithDesktop() ) { 1664 if ( mSyncManager->syncWithDesktop() ) {
1663 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1665 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1664 } 1666 }
1665 if ( fullDateRange ) 1667 if ( fullDateRange )
1666 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1668 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1667 else 1669 else
1668 mLastCalendarSync = eventLSync->dtStart(); 1670 mLastCalendarSync = eventLSync->dtStart();
1669 // for resyncing if own file has changed 1671 // for resyncing if own file has changed
1670 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1672 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1671 mLastCalendarSync = loadedFileVersion; 1673 mLastCalendarSync = loadedFileVersion;
1672 //qDebug("setting mLastCalendarSync "); 1674 //qDebug("setting mLastCalendarSync ");
1673 } 1675 }
1674 //qDebug("*************************** "); 1676 //qDebug("*************************** ");
1675 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1677 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1676 QPtrList<Incidence> er = remote->rawIncidences(); 1678 QPtrList<Incidence> er = remote->rawIncidences();
1677 Incidence* inR = er.first(); 1679 Incidence* inR = er.first();
1678 Incidence* inL; 1680 Incidence* inL;
1679 QProgressBar bar( er.count(),0 ); 1681 QProgressBar bar( er.count(),0 );
1680 bar.setCaption (i18n("Syncing - close to abort!") ); 1682 bar.setCaption (i18n("Syncing - close to abort!") );
1681 1683
1682 // ************** setting up filter ************* 1684 // ************** setting up filter *************
1683 CalFilter *filterIN = 0; 1685 CalFilter *filterIN = 0;
1684 CalFilter *filterOUT = 0; 1686 CalFilter *filterOUT = 0;
1685 CalFilter *filter = mFilters.first(); 1687 CalFilter *filter = mFilters.first();
1686 while(filter) { 1688 while(filter) {
1687 if ( filter->name() == mSyncManager->mFilterInCal ) 1689 if ( filter->name() == mSyncManager->mFilterInCal )
1688 filterIN = filter; 1690 filterIN = filter;
1689 if ( filter->name() == mSyncManager->mFilterOutCal ) 1691 if ( filter->name() == mSyncManager->mFilterOutCal )
1690 filterOUT = filter; 1692 filterOUT = filter;
1691 filter = mFilters.next(); 1693 filter = mFilters.next();
1692 } 1694 }
1693 int w = 300; 1695 int w = 300;
1694 if ( QApplication::desktop()->width() < 320 ) 1696 if ( QApplication::desktop()->width() < 320 )
1695 w = 220; 1697 w = 220;
1696 int h = bar.sizeHint().height() ; 1698 int h = bar.sizeHint().height() ;
1697 int dw = QApplication::desktop()->width(); 1699 int dw = QApplication::desktop()->width();
1698 int dh = QApplication::desktop()->height(); 1700 int dh = QApplication::desktop()->height();
1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1701 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1700 bar.show(); 1702 bar.show();
1701 int modulo = (er.count()/10)+1; 1703 int modulo = (er.count()/10)+1;
1702 int incCounter = 0; 1704 int incCounter = 0;
1703 while ( inR ) { 1705 while ( inR ) {
1704 if ( ! bar.isVisible() ) 1706 if ( ! bar.isVisible() )
1705 return false; 1707 return false;
1706 if ( incCounter % modulo == 0 ) 1708 if ( incCounter % modulo == 0 )
1707 bar.setProgress( incCounter ); 1709 bar.setProgress( incCounter );
1708 ++incCounter; 1710 ++incCounter;
1709 uid = inR->uid(); 1711 uid = inR->uid();
1710 bool skipIncidence = false; 1712 bool skipIncidence = false;
1711 if ( uid.left(15) == QString("last-syncEvent-") ) 1713 if ( uid.left(15) == QString("last-syncEvent-") )
1712 skipIncidence = true; 1714 skipIncidence = true;
1713 QString idS; 1715 QString idS;
1714 qApp->processEvents(); 1716 qApp->processEvents();
1715 if ( !skipIncidence ) { 1717 if ( !skipIncidence ) {
1716 inL = local->incidenceForUid( uid , false ); 1718 inL = local->incidenceForUid( uid , false );
1717 if ( inL ) { // maybe conflict - same uid in both calendars 1719 if ( inL ) { // maybe conflict - same uid in both calendars
1718 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1720 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1719 //qDebug("take %d %s ", take, inL->summary().latin1()); 1721 //qDebug("take %d %s ", take, inL->summary().latin1());
1720 if ( take == 3 ) 1722 if ( take == 3 )
1721 return false; 1723 return false;
1722 if ( take == 1 ) {// take local ********************** 1724 if ( take == 1 ) {// take local **********************
1723 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1725 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1726 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1725 else 1727 else
1726 idS = inR->IDStr(); 1728 idS = inR->IDStr();
1727 int calID = inR->calID(); 1729 int calID = inR->calID();
1728 remote->deleteIncidence( inR ); 1730 remote->deleteIncidence( inR );
1729 inR = inL->clone(); 1731 inR = inL->clone();
1730 inR->setCalID( calID ); 1732 inR->setCalID( calID );
1731 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1733 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1732 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1734 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1733 inR->setIDStr( idS ); 1735 inR->setIDStr( idS );
1734 remote->addIncidence( inR ); 1736 remote->addIncidence( inR );
1735 if ( mSyncManager->syncWithDesktop() ) 1737 if ( mSyncManager->syncWithDesktop() )
1736 inR->setPilotId( 2 ); 1738 inR->setPilotId( 2 );
1737 ++changedRemote; 1739 ++changedRemote;
1738 } else {// take remote ********************** 1740 } else {// take remote **********************
1739 if ( !inL->isReadOnly() ) { 1741 if ( !inL->isReadOnly() ) {
1740 idS = inL->IDStr(); 1742 idS = inL->IDStr();
1741 int pid = inL->pilotId(); 1743 int pid = inL->pilotId();
1742 int calID = inL->calID(); 1744 int calID = inL->calID();
1743 local->deleteIncidence( inL ); 1745 local->deleteIncidence( inL );
1744 inL = inR->clone(); 1746 inL = inR->clone();
1745 inL->setCalID( calID ); 1747 inL->setCalID( calID );
1746 if ( mSyncManager->syncWithDesktop() ) 1748 if ( mSyncManager->syncWithDesktop() )
1747 inL->setPilotId( pid ); 1749 inL->setPilotId( pid );
1748 inL->setIDStr( idS ); 1750 inL->setIDStr( idS );
1749 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1750 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1752 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1751 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1753 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1752 } 1754 }
1753 local->addIncidence( inL ); 1755 local->addIncidence( inL );
1754 ++changedLocal; 1756 ++changedLocal;
1755 } 1757 }
1756 } 1758 }
1757 } 1759 }
1758 } else { // no conflict ********** add or delete remote 1760 } else { // no conflict ********** add or delete remote
1759 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1761 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1762 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1761 QString des = eventLSync->description(); 1763 QString des = eventLSync->description();
1762 QString pref = "e"; 1764 QString pref = "e";
1763 if ( inR->typeID() == todoID ) 1765 if ( inR->typeID() == todoID )
1764 pref = "t"; 1766 pref = "t";
1765 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1767 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1766 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1768 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1767 //remote->deleteIncidence( inR ); 1769 //remote->deleteIncidence( inR );
1768 ++deletedEventR; 1770 ++deletedEventR;
1769 } else { 1771 } else {
1770 inR->setLastModified( modifiedCalendar ); 1772 inR->setLastModified( modifiedCalendar );
1771 inL = inR->clone(); 1773 inL = inR->clone();
1772 inL->setIDStr( ":" ); 1774 inL->setIDStr( ":" );
1773 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1775 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1774 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1776 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1775 1777
1776 inL->setCalID( 0 );// add to default cal 1778 inL->setCalID( 0 );// add to default cal
1777 local->addIncidence( inL ); 1779 local->addIncidence( inL );
1778 ++addedEvent; 1780 ++addedEvent;
1779 1781
1780 } 1782 }
1781 } else { 1783 } else {
1782 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1784 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1783 inR->setLastModified( modifiedCalendar ); 1785 inR->setLastModified( modifiedCalendar );
1784 inL = inR->clone(); 1786 inL = inR->clone();
1785 inL->setIDStr( ":" ); 1787 inL->setIDStr( ":" );
1786 inL->setCalID( 0 );// add to default cal 1788 inL->setCalID( 0 );// add to default cal
1787 local->addIncidence( inL ); 1789 local->addIncidence( inL );
1788 ++addedEvent; 1790 ++addedEvent;
1789 1791
1790 } else { 1792 } else {
1791 checkExternSyncEvent(eventRSyncSharp, inR); 1793 checkExternSyncEvent(eventRSyncSharp, inR);
1792 remote->deleteIncidence( inR ); 1794 remote->deleteIncidence( inR );
1793 ++deletedEventR; 1795 ++deletedEventR;
1794 } 1796 }
1795 } 1797 }
1796 } else { 1798 } else {
1797 ++filteredIN; 1799 ++filteredIN;
1798 } 1800 }
1799 } 1801 }
1800 } 1802 }
1801 inR = er.next(); 1803 inR = er.next();
1802 } 1804 }
1803 QPtrList<Incidence> el = local->rawIncidences(); 1805 QPtrList<Incidence> el = local->rawIncidences();
1804 inL = el.first(); 1806 inL = el.first();
1805 modulo = (el.count()/10)+1; 1807 modulo = (el.count()/10)+1;
1806 bar.setCaption (i18n("Add / remove events") ); 1808 bar.setCaption (i18n("Add / remove events") );
1807 bar.setTotalSteps ( el.count() ) ; 1809 bar.setTotalSteps ( el.count() ) ;
1808 bar.show(); 1810 bar.show();
1809 incCounter = 0; 1811 incCounter = 0;
1810 1812
1811 while ( inL ) { 1813 while ( inL ) {
1812 1814
1813 qApp->processEvents(); 1815 qApp->processEvents();
1814 if ( ! bar.isVisible() ) 1816 if ( ! bar.isVisible() )
1815 return false; 1817 return false;
1816 if ( incCounter % modulo == 0 ) 1818 if ( incCounter % modulo == 0 )
1817 bar.setProgress( incCounter ); 1819 bar.setProgress( incCounter );
1818 ++incCounter; 1820 ++incCounter;
1819 uid = inL->uid(); 1821 uid = inL->uid();
1820 bool skipIncidence = false; 1822 bool skipIncidence = false;
1821 if ( uid.left(15) == QString("last-syncEvent-") ) 1823 if ( uid.left(15) == QString("last-syncEvent-") )
1822 skipIncidence = true; 1824 skipIncidence = true;
1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1825 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1824 skipIncidence = true; 1826 skipIncidence = true;
1825 if ( !skipIncidence ) { 1827 if ( !skipIncidence ) {
1826 inR = remote->incidenceForUid( uid , true ); 1828 inR = remote->incidenceForUid( uid , true );
1827 if ( ! inR ) { 1829 if ( ! inR ) {
1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1830 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1829 // no conflict ********** add or delete local 1831 // no conflict ********** add or delete local
1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1832 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1833 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1832 checkExternSyncEvent(eventLSyncSharp, inL); 1834 checkExternSyncEvent(eventLSyncSharp, inL);
1833 local->deleteIncidence( inL ); 1835 local->deleteIncidence( inL );
1834 ++deletedEventL; 1836 ++deletedEventL;
1835 } else { 1837 } else {
1836 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1838 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1837 inL->removeID(mCurrentSyncDevice ); 1839 inL->removeID(mCurrentSyncDevice );
1838 ++addedEventR; 1840 ++addedEventR;
1839 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1841 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1840 inL->setLastModified( modifiedCalendar ); 1842 inL->setLastModified( modifiedCalendar );
1841 inR = inL->clone(); 1843 inR = inL->clone();
1842 inR->setIDStr( ":" ); 1844 inR->setIDStr( ":" );
1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1845 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1844 inR->setCalID( 0 );// add to default cal 1846 inR->setCalID( 0 );// add to default cal
1845 remote->addIncidence( inR ); 1847 remote->addIncidence( inR );
1846 } 1848 }
1847 } 1849 }
1848 } else { 1850 } else {
1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1851 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1850 checkExternSyncEvent(eventLSyncSharp, inL); 1852 checkExternSyncEvent(eventLSyncSharp, inL);
1851 local->deleteIncidence( inL ); 1853 local->deleteIncidence( inL );
1852 ++deletedEventL; 1854 ++deletedEventL;
1853 } else { 1855 } else {
1854 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1856 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1855 ++addedEventR; 1857 ++addedEventR;
1856 inL->setLastModified( modifiedCalendar ); 1858 inL->setLastModified( modifiedCalendar );
1857 inR = inL->clone(); 1859 inR = inL->clone();
1858 inR->setIDStr( ":" ); 1860 inR->setIDStr( ":" );
1859 inR->setCalID( 0 );// add to default cal 1861 inR->setCalID( 0 );// add to default cal
1860 remote->addIncidence( inR ); 1862 remote->addIncidence( inR );
1861 } 1863 }
1862 } 1864 }
1863 } 1865 }
1864 } else { 1866 } else {
1865 ++filteredOUT; 1867 ++filteredOUT;
1866 } 1868 }
1867 } 1869 }
1868 } 1870 }
1869 inL = el.next(); 1871 inL = el.next();
1870 } 1872 }
1871 int delFut = 0; 1873 int delFut = 0;
1872 int remRem = 0; 1874 int remRem = 0;
1873 if ( mSyncManager->mWriteBackInFuture ) { 1875 if ( mSyncManager->mWriteBackInFuture ) {
1874 er = remote->rawIncidences(); 1876 er = remote->rawIncidences();
1875 remRem = er.count(); 1877 remRem = er.count();
1876 inR = er.first(); 1878 inR = er.first();
1877 QDateTime dt; 1879 QDateTime dt;
1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1880 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1881 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1880 while ( inR ) { 1882 while ( inR ) {
1881 if ( inR->typeID() == todoID ) { 1883 if ( inR->typeID() == todoID ) {
1882 Todo * t = (Todo*)inR; 1884 Todo * t = (Todo*)inR;
1883 if ( t->hasDueDate() ) 1885 if ( t->hasDueDate() )
1884 dt = t->dtDue(); 1886 dt = t->dtDue();
1885 else 1887 else
1886 dt = cur.addSecs( 62 ); 1888 dt = cur.addSecs( 62 );
1887 } 1889 }
1888 else if (inR->typeID() == eventID ) { 1890 else if (inR->typeID() == eventID ) {
1889 bool ok; 1891 bool ok;
1890 dt = inR->getNextOccurence( cur, &ok ); 1892 dt = inR->getNextOccurence( cur, &ok );
1891 if ( !ok ) 1893 if ( !ok )
1892 dt = cur.addSecs( -62 ); 1894 dt = cur.addSecs( -62 );
1893 } 1895 }
1894 else 1896 else
1895 dt = inR->dtStart(); 1897 dt = inR->dtStart();
1896 if ( dt < cur || dt > end ) { 1898 if ( dt < cur || dt > end ) {
1897 remote->deleteIncidence( inR ); 1899 remote->deleteIncidence( inR );
1898 ++delFut; 1900 ++delFut;
1899 } 1901 }
1900 inR = er.next(); 1902 inR = er.next();
1901 } 1903 }
1902 } 1904 }
1903 bar.hide(); 1905 bar.hide();
1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1906 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1905 eventLSync->setReadOnly( false ); 1907 if ( mMultiResourceSync ) {
1906 eventLSync->setDtStart( mLastCalendarSync ); 1908 remote->removeSyncInfo( "" ); //all
1907 eventRSync->setDtStart( mLastCalendarSync ); 1909
1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1910 } else {
1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1911 eventLSync->setReadOnly( false );
1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1912 eventLSync->setDtStart( mLastCalendarSync );
1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1913 eventRSync->setDtStart( mLastCalendarSync );
1912 eventLSync->setReadOnly( true ); 1914 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1915 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1916 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1917 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1918 eventLSync->setReadOnly( true );
1919 }
1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1920 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1921 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal...
1915 remote->addEvent( eventRSync ); 1922 remote->addEvent( eventRSync );
1916 else 1923 else
1917 delete eventRSync; 1924 delete eventRSync;
1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1925 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1919 QString mes; 1926 QString mes;
1920 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 ); 1927 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 );
1921 QString delmess; 1928 QString delmess;
1922 if ( delFut ) { 1929 if ( delFut ) {
1923 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); 1930 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);
1924 mes += delmess; 1931 mes += delmess;
1925 } 1932 }
1926 mes = i18n("Local calendar changed!\n") +mes; 1933 mes = i18n("Local calendar changed!\n") +mes;
1927 mCalendar->checkAlarmForIncidence( 0, true ); 1934 mCalendar->checkAlarmForIncidence( 0, true );
1928 qDebug( mes ); 1935 qDebug( mes );
1929 if ( mSyncManager->mShowSyncSummary ) { 1936 if ( mSyncManager->mShowSyncSummary ) {
1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1937 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1938 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1932 qDebug("KO: WB cancelled "); 1939 qDebug("KO: WB cancelled ");
1933 mSyncManager->mWriteBackFile = false; 1940 mSyncManager->mWriteBackFile = false;
1934 return syncOK; 1941 return syncOK;
1935 } 1942 }
1936 } 1943 }
1937 return syncOK; 1944 return syncOK;
1938} 1945}
1939 1946
1940void CalendarView::setSyncDevice( QString s ) 1947void CalendarView::setSyncDevice( QString s )
1941{ 1948{
1942 mCurrentSyncDevice= s; 1949 mCurrentSyncDevice= s;
1943} 1950}
1944void CalendarView::setSyncName( QString s ) 1951void CalendarView::setSyncName( QString s )
1945{ 1952{
1946 mCurrentSyncName= s; 1953 mCurrentSyncName= s;
1947} 1954}
1948bool CalendarView::syncCalendar(QString filename, int mode) 1955bool CalendarView::syncCalendar(QString filename, int mode)
1949{ 1956{
1950 //qDebug("syncCalendar %s ", filename.latin1()); 1957 //qDebug("syncCalendar %s ", filename.latin1());
1951 mGlobalSyncMode = SYNC_MODE_NORMAL; 1958 mGlobalSyncMode = SYNC_MODE_NORMAL;
1952 CalendarLocal* calendar = new CalendarLocal(); 1959 CalendarLocal* calendar = new CalendarLocal();
1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1960 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1954 FileStorage* storage = new FileStorage( calendar ); 1961 FileStorage* storage = new FileStorage( calendar );
1955 bool syncOK = false; 1962 bool syncOK = false;
1956 storage->setFileName( filename ); 1963 storage->setFileName( filename );
1957 // qDebug("loading ... "); 1964 // qDebug("loading ... ");
1958 if ( storage->load() ) { 1965 if ( storage->load() ) {
1959 getEventViewerDialog()->setSyncMode( true ); 1966 getEventViewerDialog()->setSyncMode( true );
1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1967 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1961 getEventViewerDialog()->setSyncMode( false ); 1968 getEventViewerDialog()->setSyncMode( false );
1962 if ( syncOK ) { 1969 if ( syncOK ) {
1963 if ( mSyncManager->mWriteBackFile ) 1970 if ( mSyncManager->mWriteBackFile )
1964 { 1971 {
1965 storage->setSaveFormat( new ICalFormat() ); 1972 storage->setSaveFormat( new ICalFormat() );
1966 storage->save(); 1973 storage->save();
1967 } 1974 }
1968 } 1975 }
1969 setModified( true ); 1976 setModified( true );
1970 } 1977 }
1971 delete storage; 1978 delete storage;
1972 delete calendar; 1979 delete calendar;
1973 if ( syncOK ) 1980 if ( syncOK )
1974 updateView(); 1981 updateView();
1975 return syncOK; 1982 return syncOK;
1976} 1983}
1977 1984
1978void CalendarView::syncExternal( int mode ) 1985void CalendarView::syncExternal( int mode )
1979{ 1986{
1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1987 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1981 qApp->processEvents(); 1988 qApp->processEvents();
1982 CalendarLocal* calendar = new CalendarLocal(); 1989 CalendarLocal* calendar = new CalendarLocal();
1983 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1990 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1984 bool syncOK = false; 1991 bool syncOK = false;
1985 bool loadSuccess = false; 1992 bool loadSuccess = false;
1986 PhoneFormat* phoneFormat = 0; 1993 PhoneFormat* phoneFormat = 0;
1987 emit tempDisableBR(true); 1994 emit tempDisableBR(true);
1988#ifndef DESKTOP_VERSION 1995#ifndef DESKTOP_VERSION
1989 SharpFormat* sharpFormat = 0; 1996 SharpFormat* sharpFormat = 0;
1990 if ( mode == 0 ) { // sharp 1997 if ( mode == 0 ) { // sharp
1991 sharpFormat = new SharpFormat () ; 1998 sharpFormat = new SharpFormat () ;
1992 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1999 loadSuccess = sharpFormat->load( calendar, mCalendar );
1993 2000
1994 } else 2001 } else
1995#endif 2002#endif
1996 if ( mode == 1 ) { // phone 2003 if ( mode == 1 ) { // phone
1997 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 2004 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1998 mSyncManager->mPhoneDevice, 2005 mSyncManager->mPhoneDevice,
1999 mSyncManager->mPhoneConnection, 2006 mSyncManager->mPhoneConnection,
2000 mSyncManager->mPhoneModel); 2007 mSyncManager->mPhoneModel);
2001 loadSuccess = phoneFormat->load( calendar,mCalendar); 2008 loadSuccess = phoneFormat->load( calendar,mCalendar);
2002 2009
2003 } else { 2010 } else {
2004 emit tempDisableBR(false); 2011 emit tempDisableBR(false);
2005 return; 2012 return;
2006 } 2013 }
2007 if ( loadSuccess ) { 2014 if ( loadSuccess ) {
2008 getEventViewerDialog()->setSyncMode( true ); 2015 getEventViewerDialog()->setSyncMode( true );
2009 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2016 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2010 getEventViewerDialog()->setSyncMode( false ); 2017 getEventViewerDialog()->setSyncMode( false );
2011 qApp->processEvents(); 2018 qApp->processEvents();
2012 if ( syncOK ) { 2019 if ( syncOK ) {
2013 if ( mSyncManager->mWriteBackFile ) 2020 if ( mSyncManager->mWriteBackFile )
2014 { 2021 {
2015 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2022 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2016 Incidence* inc = iL.first(); 2023 Incidence* inc = iL.first();
2017 if ( phoneFormat ) { 2024 if ( phoneFormat ) {
2018 while ( inc ) { 2025 while ( inc ) {
2019 inc->removeID(mCurrentSyncDevice); 2026 inc->removeID(mCurrentSyncDevice);
2020 inc = iL.next(); 2027 inc = iL.next();
2021 } 2028 }
2022 } 2029 }
2023#ifndef DESKTOP_VERSION 2030#ifndef DESKTOP_VERSION
2024 if ( sharpFormat ) 2031 if ( sharpFormat )
2025 sharpFormat->save(calendar); 2032 sharpFormat->save(calendar);
2026#endif 2033#endif
2027 if ( phoneFormat ) 2034 if ( phoneFormat )
2028 phoneFormat->save(calendar); 2035 phoneFormat->save(calendar);
2029 iL = calendar->rawIncidences(); 2036 iL = calendar->rawIncidences();
2030 inc = iL.first(); 2037 inc = iL.first();
2031 Incidence* loc; 2038 Incidence* loc;
2032 while ( inc ) { 2039 while ( inc ) {
2033 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2040 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2034 loc = mCalendar->incidence(inc->uid() ); 2041 loc = mCalendar->incidence(inc->uid() );
2035 if ( loc ) { 2042 if ( loc ) {
2036 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2043 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2037 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2044 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2038 } 2045 }
2039 } 2046 }
2040 inc = iL.next(); 2047 inc = iL.next();
2041 } 2048 }
2042 Incidence* lse = getLastSyncEvent(); 2049 Incidence* lse = getLastSyncEvent();
2043 if ( lse ) { 2050 if ( lse ) {
2044 lse->setReadOnly( false ); 2051 lse->setReadOnly( false );
2045 lse->setDescription( "" ); 2052 lse->setDescription( "" );
2046 lse->setReadOnly( true ); 2053 lse->setReadOnly( true );
2047 } 2054 }
2048 } 2055 }
2049 } else { 2056 } else {
2050 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2057 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2051 } 2058 }
2052 setModified( true ); 2059 setModified( true );
2053 } else { 2060 } else {
2054 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2061 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2055 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2062 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2056 question, i18n("Ok")) ; 2063 question, i18n("Ok")) ;
2057 2064
2058 } 2065 }
2059 delete calendar; 2066 delete calendar;
2060 updateView(); 2067 updateView();
2061 emit tempDisableBR(false); 2068 emit tempDisableBR(false);
2062 return ;//syncOK; 2069 return ;//syncOK;
2063 2070
2064} 2071}
2065 2072
2066bool CalendarView::importBday() 2073bool CalendarView::importBday()
2067{ 2074{
2068#ifndef KORG_NOKABC 2075#ifndef KORG_NOKABC
2069 2076
2070#ifdef DESKTOP_VERSION 2077#ifdef DESKTOP_VERSION
2071 int curCal = mCalendar->defaultCalendar(); 2078 int curCal = mCalendar->defaultCalendar();
2072 int bd = mCalEditView->getBirtdayID(); 2079 int bd = mCalEditView->getBirtdayID();
2073 if ( bd == 0 ) 2080 if ( bd == 0 )
2074 return false; 2081 return false;
2075 mCalendar->setDefaultCalendar( bd ); 2082 mCalendar->setDefaultCalendar( bd );
2076 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2083 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2077 KABC::AddressBook::Iterator it; 2084 KABC::AddressBook::Iterator it;
2078 int count = 0; 2085 int count = 0;
2079 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2086 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2080 ++count; 2087 ++count;
2081 } 2088 }
2082 QProgressBar bar(count,0 ); 2089 QProgressBar bar(count,0 );
2083 int w = 300; 2090 int w = 300;
2084 if ( QApplication::desktop()->width() < 320 ) 2091 if ( QApplication::desktop()->width() < 320 )
2085 w = 220; 2092 w = 220;
2086 int h = bar.sizeHint().height() ; 2093 int h = bar.sizeHint().height() ;
2087 int dw = QApplication::desktop()->width(); 2094 int dw = QApplication::desktop()->width();
2088 int dh = QApplication::desktop()->height(); 2095 int dh = QApplication::desktop()->height();
2089 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2096 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2090 bar.show(); 2097 bar.show();
2091 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2098 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2092 qApp->processEvents(); 2099 qApp->processEvents();
2093 count = 0; 2100 count = 0;
2094 int addCount = 0; 2101 int addCount = 0;
2095 KCal::Attendee* a = 0; 2102 KCal::Attendee* a = 0;
2096 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2103 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2097 if ( ! bar.isVisible() ) 2104 if ( ! bar.isVisible() )
2098 return false; 2105 return false;
2099 bar.setProgress( count++ ); 2106 bar.setProgress( count++ );
2100 qApp->processEvents(); 2107 qApp->processEvents();
2101 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2108 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2102 if ( (*it).birthday().date().isValid() ){ 2109 if ( (*it).birthday().date().isValid() ){
2103 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2110 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2104 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2111 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2105 ++addCount; 2112 ++addCount;
2106 } 2113 }
2107 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2114 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2108 if ( anni.isValid() ){ 2115 if ( anni.isValid() ){
2109 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2116 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2110 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2117 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2111 ++addCount; 2118 ++addCount;
2112 } 2119 }
2113 } 2120 }
2114 mCalendar->setDefaultCalendar( curCal ); 2121 mCalendar->setDefaultCalendar( curCal );
2115 updateView(); 2122 updateView();
2116 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2123 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2117#else //DESKTOP_VERSION 2124#else //DESKTOP_VERSION
2118 2125
2119 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2126 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2120 // the result should now arrive through method insertBirthdays 2127 // the result should now arrive through method insertBirthdays
2121 2128
2122#endif //DESKTOP_VERSION 2129#endif //DESKTOP_VERSION
2123 2130
2124#endif //KORG_NOKABC 2131#endif //KORG_NOKABC
2125 2132
2126 2133
2127 return true; 2134 return true;
2128} 2135}
2129 2136
2130// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2137// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2131void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2138void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2132 const QStringList& anniversaryList, const QStringList& realNameList, 2139 const QStringList& anniversaryList, const QStringList& realNameList,
2133 const QStringList& emailList, const QStringList& assembledNameList, 2140 const QStringList& emailList, const QStringList& assembledNameList,
2134 const QStringList& uidList) 2141 const QStringList& uidList)
2135{ 2142{
2136 2143
2137 //qDebug("KO::CalendarView::insertBirthdays"); 2144 //qDebug("KO::CalendarView::insertBirthdays");
2138 if (uid == this->name()) 2145 if (uid == this->name())
2139 { 2146 {
2140 int curCal = mCalendar->defaultCalendar(); 2147 int curCal = mCalendar->defaultCalendar();
2141 int bd = mCalEditView->getBirtdayID(); 2148 int bd = mCalEditView->getBirtdayID();
2142 if ( bd == 0 ) 2149 if ( bd == 0 )
2143 return; 2150 return;
2144 mCalendar->setDefaultCalendar( bd ); 2151 mCalendar->setDefaultCalendar( bd );
2145 2152
2146 2153
2147 int count = birthdayList.count(); 2154 int count = birthdayList.count();
2148 int addCount = 0; 2155 int addCount = 0;
2149 KCal::Attendee* a = 0; 2156 KCal::Attendee* a = 0;
2150 2157
2151 //qDebug("CalView 1 %i", count); 2158 //qDebug("CalView 1 %i", count);
2152 2159
2153 QProgressBar bar(count,0 ); 2160 QProgressBar bar(count,0 );
2154 int w = 300; 2161 int w = 300;
2155 if ( QApplication::desktop()->width() < 320 ) 2162 if ( QApplication::desktop()->width() < 320 )
2156 w = 220; 2163 w = 220;
2157 int h = bar.sizeHint().height() ; 2164 int h = bar.sizeHint().height() ;
2158 int dw = QApplication::desktop()->width(); 2165 int dw = QApplication::desktop()->width();
2159 int dh = QApplication::desktop()->height(); 2166 int dh = QApplication::desktop()->height();
2160 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2167 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2161 bar.show(); 2168 bar.show();
2162 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2169 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2163 qApp->processEvents(); 2170 qApp->processEvents();
2164 2171
2165 QDate birthday; 2172 QDate birthday;
2166 QDate anniversary; 2173 QDate anniversary;
2167 QString realName; 2174 QString realName;
2168 QString email; 2175 QString email;
2169 QString assembledName; 2176 QString assembledName;
2170 QString uid; 2177 QString uid;
2171 bool ok = true; 2178 bool ok = true;
2172 for ( int i = 0; i < count; i++) 2179 for ( int i = 0; i < count; i++)
2173 { 2180 {
2174 if ( ! bar.isVisible() ) 2181 if ( ! bar.isVisible() )
2175 return; 2182 return;
2176 bar.setProgress( i ); 2183 bar.setProgress( i );
2177 qApp->processEvents(); 2184 qApp->processEvents();
2178 2185
2179 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2186 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2180 if (!ok) { 2187 if (!ok) {
2181 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2188 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2182 } 2189 }
2183 2190
2184 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2191 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2185 if (!ok) { 2192 if (!ok) {
2186 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2193 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2187 } 2194 }
2188 realName = realNameList[i]; 2195 realName = realNameList[i];
2189 email = emailList[i]; 2196 email = emailList[i];
2190 assembledName = assembledNameList[i]; 2197 assembledName = assembledNameList[i];
2191 uid = uidList[i]; 2198 uid = uidList[i];
2192 //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() ); 2199 //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() );
2193 2200
2194 if ( birthday.isValid() ){ 2201 if ( birthday.isValid() ){
2195 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2202 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2196 KCal::Attendee::ReqParticipant,uid) ; 2203 KCal::Attendee::ReqParticipant,uid) ;
2197 if ( addAnniversary( birthday, assembledName, a, true ) ) 2204 if ( addAnniversary( birthday, assembledName, a, true ) )
2198 ++addCount; 2205 ++addCount;
2199 } 2206 }
2200 2207
2201 if ( anniversary.isValid() ){ 2208 if ( anniversary.isValid() ){
2202 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2209 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2203 KCal::Attendee::ReqParticipant,uid) ; 2210 KCal::Attendee::ReqParticipant,uid) ;
2204 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2211 if ( addAnniversary( anniversary, assembledName, a, false ) )
2205 ++addCount; 2212 ++addCount;
2206 } 2213 }
2207 } 2214 }
2208 2215
2209 mCalendar->setDefaultCalendar( curCal ); 2216 mCalendar->setDefaultCalendar( curCal );
2210 updateView(); 2217 updateView();
2211 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2218 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2212 2219
2213 } 2220 }
2214 2221
2215} 2222}
2216 2223
2217 2224
2218 2225
2219bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2226bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2220{ 2227{
2221 //qDebug("addAnni "); 2228 //qDebug("addAnni ");
2222 Event * ev = new Event(); 2229 Event * ev = new Event();
2223 ev->setOrganizer(KOPrefs::instance()->email()); 2230 ev->setOrganizer(KOPrefs::instance()->email());
2224 if ( a ) { 2231 if ( a ) {
2225 ev->addAttendee( a ); 2232 ev->addAttendee( a );
2226 } 2233 }
2227 QString kind; 2234 QString kind;
2228 if ( birthday ) { 2235 if ( birthday ) {
2229 kind = i18n( "Birthday" ); 2236 kind = i18n( "Birthday" );
2230 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2237 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2231 } 2238 }
2232 else { 2239 else {
2233 kind = i18n( "Anniversary" ); 2240 kind = i18n( "Anniversary" );
2234 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2241 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2235 } 2242 }
2236 ev->setCategories( kind ); 2243 ev->setCategories( kind );
2237 ev->setDtStart( QDateTime(date) ); 2244 ev->setDtStart( QDateTime(date) );
2238 ev->setDtEnd( QDateTime(date) ); 2245 ev->setDtEnd( QDateTime(date) );
2239 ev->setFloats( true ); 2246 ev->setFloats( true );
2240 Recurrence * rec = ev->recurrence(); 2247 Recurrence * rec = ev->recurrence();
2241 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2248 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2242 rec->addYearlyNum( date.month() ); 2249 rec->addYearlyNum( date.month() );
2243 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2250 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2244 delete ev; 2251 delete ev;
2245 return false; 2252 return false;
2246 } 2253 }
2247 return true; 2254 return true;
2248 2255
2249} 2256}
2250bool CalendarView::importQtopia( const QString &categories, 2257bool CalendarView::importQtopia( const QString &categories,
2251 const QString &datebook, 2258 const QString &datebook,
2252 const QString &todolist ) 2259 const QString &todolist )
2253{ 2260{
2254 2261
2255 QtopiaFormat qtopiaFormat; 2262 QtopiaFormat qtopiaFormat;
2256 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2263 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2257 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2264 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2258 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2265 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2259 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2266 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2260 2267
2261 updateView(); 2268 updateView();
2262 return true; 2269 return true;
2263 2270
2264#if 0 2271#if 0
2265 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2272 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2266 mCurrentSyncDevice = "qtopia-XML"; 2273 mCurrentSyncDevice = "qtopia-XML";
2267 if ( mSyncManager->mAskForPreferences ) 2274 if ( mSyncManager->mAskForPreferences )
2268 edit_sync_options(); 2275 edit_sync_options();
2269 qApp->processEvents(); 2276 qApp->processEvents();
2270 CalendarLocal* calendar = new CalendarLocal(); 2277 CalendarLocal* calendar = new CalendarLocal();
2271 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2278 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2272 bool syncOK = false; 2279 bool syncOK = false;
2273 QtopiaFormat qtopiaFormat; 2280 QtopiaFormat qtopiaFormat;
2274 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2281 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2275 bool loadOk = true; 2282 bool loadOk = true;
2276 if ( !categories.isEmpty() ) 2283 if ( !categories.isEmpty() )
2277 loadOk = qtopiaFormat.load( calendar, categories ); 2284 loadOk = qtopiaFormat.load( calendar, categories );
2278 if ( loadOk && !datebook.isEmpty() ) 2285 if ( loadOk && !datebook.isEmpty() )
2279 loadOk = qtopiaFormat.load( calendar, datebook ); 2286 loadOk = qtopiaFormat.load( calendar, datebook );
2280 if ( loadOk && !todolist.isEmpty() ) 2287 if ( loadOk && !todolist.isEmpty() )
2281 loadOk = qtopiaFormat.load( calendar, todolist ); 2288 loadOk = qtopiaFormat.load( calendar, todolist );
2282 2289
2283 if ( loadOk ) { 2290 if ( loadOk ) {
2284 getEventViewerDialog()->setSyncMode( true ); 2291 getEventViewerDialog()->setSyncMode( true );
2285 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2286 getEventViewerDialog()->setSyncMode( false ); 2293 getEventViewerDialog()->setSyncMode( false );
2287 qApp->processEvents(); 2294 qApp->processEvents();
2288 if ( syncOK ) { 2295 if ( syncOK ) {
2289 if ( mSyncManager->mWriteBackFile ) 2296 if ( mSyncManager->mWriteBackFile )
2290 { 2297 {
2291 // write back XML file 2298 // write back XML file
2292 2299
2293 } 2300 }
2294 setModified( true ); 2301 setModified( true );
2295 } 2302 }
2296 } else { 2303 } else {
2297 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2304 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2298 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2305 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2299 question, i18n("Ok")) ; 2306 question, i18n("Ok")) ;
2300 } 2307 }
2301 delete calendar; 2308 delete calendar;
2302 updateView(); 2309 updateView();
2303 return syncOK; 2310 return syncOK;
2304 2311
2305 2312
2306#endif 2313#endif
2307 2314
2308} 2315}
2309 2316
2310void CalendarView::setSyncEventsReadOnly() 2317void CalendarView::setSyncEventsReadOnly()
2311{ 2318{
2312 mCalendar->setSyncEventsReadOnly(); 2319 mCalendar->setSyncEventsReadOnly();
2313} 2320}
2314 2321
2315bool CalendarView::loadCalendars() 2322bool CalendarView::loadCalendars()
2316{ 2323{
2317 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2324 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2318 KopiCalendarFile * cal = calendars.first(); 2325 KopiCalendarFile * cal = calendars.first();
2319 mCalendar->setDefaultCalendar( 1 ); 2326 mCalendar->setDefaultCalendar( 1 );
2320 openCalendar( MainWindow::defaultFileName(), false ); 2327 openCalendar( MainWindow::defaultFileName(), false );
2321 cal = calendars.next(); 2328 cal = calendars.next();
2322 while ( cal ) { 2329 while ( cal ) {
2323 addCalendar( cal ); 2330 addCalendar( cal );
2324 cal = calendars.next(); 2331 cal = calendars.next();
2325 } 2332 }
2326 restoreCalendarSettings(); 2333 restoreCalendarSettings();
2327 return true; 2334 return true;
2328} 2335}
2329bool CalendarView::restoreCalendarSettings() 2336bool CalendarView::restoreCalendarSettings()
2330{ 2337{
2331 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2338 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2332 KopiCalendarFile * cal = calendars.first(); 2339 KopiCalendarFile * cal = calendars.first();
2333 while ( cal ) { 2340 while ( cal ) {
2334 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2341 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2335 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2342 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2336 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2343 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2337 if ( cal->isStandard ) 2344 if ( cal->isStandard )
2338 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2345 mCalendar->setDefaultCalendar( cal->mCalNumber );
2339 cal = calendars.next(); 2346 cal = calendars.next();
2340 } 2347 }
2341 setSyncEventsReadOnly(); 2348 setSyncEventsReadOnly();
2342 mCalendar->reInitAlarmSettings(); 2349 mCalendar->reInitAlarmSettings();
2343 updateUnmanagedViews(); 2350 updateUnmanagedViews();
2344 updateView(); 2351 updateView();
2345 return true; 2352 return true;
2346} 2353}
2347void CalendarView::addCalendarId( int id ) 2354void CalendarView::addCalendarId( int id )
2348{ 2355{
2349 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2356 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2350 if ( cal ) 2357 if ( cal )
2351 addCalendar( cal ); 2358 addCalendar( cal );
2352} 2359}
2353bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2360bool CalendarView::addCalendar( KopiCalendarFile * cal )
2354{ 2361{
2355 cal->mErrorOnLoad = false; 2362 cal->mErrorOnLoad = false;
2356 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2363 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2357 cal->mLoadDt = QDateTime::currentDateTime(); 2364 cal->mLoadDt = QDateTime::currentDateTime();
2358 return true; 2365 return true;
2359 } 2366 }
2360 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2367 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2361 cal->mErrorOnLoad = true; 2368 cal->mErrorOnLoad = true;
2362 return false; 2369 return false;
2363} 2370}
2364bool CalendarView::openCalendar(QString filename, bool merge) 2371bool CalendarView::openCalendar(QString filename, bool merge)
2365{ 2372{
2366 2373
2367 if (filename.isEmpty()) { 2374 if (filename.isEmpty()) {
2368 return false; 2375 return false;
2369 } 2376 }
2370 2377
2371 if (!QFile::exists(filename)) { 2378 if (!QFile::exists(filename)) {
2372 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2379 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2373 return false; 2380 return false;
2374 } 2381 }
2375 2382
2376 globalFlagBlockAgenda = 1; 2383 globalFlagBlockAgenda = 1;
2377 clearAllViews(); 2384 clearAllViews();
2378 if (!merge) { 2385 if (!merge) {
2379 mViewManager->setDocumentId( filename ); 2386 mViewManager->setDocumentId( filename );
2380 mCalendar->close(); 2387 mCalendar->close();
2381 } 2388 }
2382 mStorage->setFileName( filename ); 2389 mStorage->setFileName( filename );
2383 2390
2384 if ( mStorage->load() ) { 2391 if ( mStorage->load() ) {
2385 if ( merge ) ;//setModified( true ); 2392 if ( merge ) ;//setModified( true );
2386 else { 2393 else {
2387 //setModified( true ); 2394 //setModified( true );
2388 mViewManager->setDocumentId( filename ); 2395 mViewManager->setDocumentId( filename );
2389 mDialogManager->setDocumentId( filename ); 2396 mDialogManager->setDocumentId( filename );
2390 mTodoList->setDocumentId( filename ); 2397 mTodoList->setDocumentId( filename );
2391 } 2398 }
2392 globalFlagBlockAgenda = 2; 2399 globalFlagBlockAgenda = 2;
2393 // if ( getLastSyncEvent() ) 2400 // if ( getLastSyncEvent() )
2394 // getLastSyncEvent()->setReadOnly( true ); 2401 // getLastSyncEvent()->setReadOnly( true );
2395 mCalendar->reInitAlarmSettings(); 2402 mCalendar->reInitAlarmSettings();
2396 setSyncEventsReadOnly(); 2403 setSyncEventsReadOnly();
2397 //updateUnmanagedViews(); 2404 //updateUnmanagedViews();
2398 //updateView(); 2405 //updateView();
2399 if ( filename != MainWindow::defaultFileName() ) { 2406 if ( filename != MainWindow::defaultFileName() ) {
2400 saveCalendar( MainWindow::defaultFileName() ); 2407 saveCalendar( MainWindow::defaultFileName() );
2401 } else { 2408 } else {
2402 QFileInfo finf ( MainWindow::defaultFileName()); 2409 QFileInfo finf ( MainWindow::defaultFileName());
2403 if ( finf.exists() ) { 2410 if ( finf.exists() ) {
2404 setLoadedFileVersion( finf.lastModified () ); 2411 setLoadedFileVersion( finf.lastModified () );
2405 } 2412 }
2406 } 2413 }
2407 return true; 2414 return true;
2408 } else { 2415 } else {
2409 // while failing to load, the calendar object could 2416 // while failing to load, the calendar object could
2410 // have become partially populated. Clear it out. 2417 // have become partially populated. Clear it out.
2411 if ( !merge ) { 2418 if ( !merge ) {
2412 mCalendar->close(); 2419 mCalendar->close();
2413 mViewManager->setDocumentId( filename ); 2420 mViewManager->setDocumentId( filename );
2414 mDialogManager->setDocumentId( filename ); 2421 mDialogManager->setDocumentId( filename );
2415 mTodoList->setDocumentId( filename ); 2422 mTodoList->setDocumentId( filename );
2416 } 2423 }
2417 2424
2418 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2425 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2419 2426
2420 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2427 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2421 globalFlagBlockAgenda = 2; 2428 globalFlagBlockAgenda = 2;
2422 mCalendar->reInitAlarmSettings(); 2429 mCalendar->reInitAlarmSettings();
2423 setSyncEventsReadOnly(); 2430 setSyncEventsReadOnly();
2424 updateUnmanagedViews(); 2431 updateUnmanagedViews();
2425 updateView(); 2432 updateView();
2426 } 2433 }
2427 return false; 2434 return false;
2428} 2435}
2429void CalendarView::mergeFile( QString fn ) 2436void CalendarView::mergeFile( QString fn )
2430{ 2437{
2431 clearAllViews(); 2438 clearAllViews();
2432 mCalendar->mergeCalendarFile( fn ); 2439 mCalendar->mergeCalendarFile( fn );
2433 mCalendar->reInitAlarmSettings(); 2440 mCalendar->reInitAlarmSettings();
2434 setSyncEventsReadOnly(); 2441 setSyncEventsReadOnly();
2435 updateUnmanagedViews(); 2442 updateUnmanagedViews();
2436 updateView(); 2443 updateView();
2437} 2444}
2445void CalendarView::mergeFileResource( QString fn ,QString resource )
2446{
2447
2448 if ( resource == "ALL" ) {
2449 mergeFile( fn );
2450 return;
2451 }
2452
2453 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2454 if ( !exclusiveResource ) {
2455 qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
2456 return;
2457 }
2458 clearAllViews();
2459 mCalendar->setCalendarRemove( exclusiveResource );
2460 int def = mCalendar->defaultCalendar();
2461 mCalendar->setDefaultCalendar(exclusiveResource);
2462 if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
2463 qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
2464 }
2465 mCalendar->setDefaultCalendar( def );
2466 mCalendar->reInitAlarmSettings();
2467 setSyncEventsReadOnly();
2468 updateUnmanagedViews();
2469 updateView();
2470}
2438void CalendarView::showOpenError() 2471void CalendarView::showOpenError()
2439{ 2472{
2440 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2473 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2441} 2474}
2442void CalendarView::setLoadedFileVersion(QDateTime dt) 2475void CalendarView::setLoadedFileVersion(QDateTime dt)
2443{ 2476{
2444 loadedFileVersion = dt; 2477 loadedFileVersion = dt;
2445} 2478}
2446bool CalendarView::checkFileChanged(QString fn) 2479bool CalendarView::checkFileChanged(QString fn)
2447{ 2480{
2448 QFileInfo finf ( fn ); 2481 QFileInfo finf ( fn );
2449 if ( !finf.exists() ) 2482 if ( !finf.exists() )
2450 return true; 2483 return true;
2451 QDateTime dt = finf.lastModified (); 2484 QDateTime dt = finf.lastModified ();
2452 if ( dt <= loadedFileVersion ) 2485 if ( dt <= loadedFileVersion )
2453 return false; 2486 return false;
2454 return true; 2487 return true;
2455 2488
2456} 2489}
2457void CalendarView::watchSavedFile() 2490void CalendarView::watchSavedFile()
2458{ 2491{
2459 QFileInfo finf ( MainWindow::defaultFileName()); 2492 QFileInfo finf ( MainWindow::defaultFileName());
2460 if ( !finf.exists() ) 2493 if ( !finf.exists() )
2461 return; 2494 return;
2462 QDateTime dt = finf.lastModified (); 2495 QDateTime dt = finf.lastModified ();
2463 if ( dt < loadedFileVersion ) { 2496 if ( dt < loadedFileVersion ) {
2464 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2497 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2465 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2498 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2466 return; 2499 return;
2467 } 2500 }
2468 loadedFileVersion = dt; 2501 loadedFileVersion = dt;
2469} 2502}
2470bool CalendarView::checkAllFileVersions() 2503bool CalendarView::checkAllFileVersions()
2471{ 2504{
2472 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2505 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2473 KopiCalendarFile * cal = calendars.first(); 2506 KopiCalendarFile * cal = calendars.first();
2474 mCalendar->setDefaultCalendar( 1 ); 2507 mCalendar->setDefaultCalendar( 1 );
2475 mCalendar->setDefaultCalendarEnabledOnly(); 2508 mCalendar->setDefaultCalendarEnabledOnly();
2476 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2509 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2477 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2510 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2478 restoreCalendarSettings(); 2511 restoreCalendarSettings();
2479 return false; 2512 return false;
2480 } 2513 }
2481 } 2514 }
2482 cal = calendars.next(); 2515 cal = calendars.next();
2483 QDateTime storeTemp = loadedFileVersion; 2516 QDateTime storeTemp = loadedFileVersion;
2484 while ( cal ) { 2517 while ( cal ) {
2485 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2518 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2486 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2519 mCalendar->setDefaultCalendar( cal->mCalNumber );
2487 mCalendar->setDefaultCalendarEnabledOnly(); 2520 mCalendar->setDefaultCalendarEnabledOnly();
2488 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2521 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2489 if ( !checkFileVersion(cal->mFileName )) { 2522 if ( !checkFileVersion(cal->mFileName )) {
2490 loadedFileVersion = storeTemp; 2523 loadedFileVersion = storeTemp;
2491 restoreCalendarSettings(); 2524 restoreCalendarSettings();
2492 return false; 2525 return false;
2493 } 2526 }
2494 } 2527 }
2495 cal = calendars.next(); 2528 cal = calendars.next();
2496 } 2529 }
2497 loadedFileVersion = storeTemp; 2530 loadedFileVersion = storeTemp;
2498 return true; 2531 return true;
2499} 2532}
2500bool CalendarView::checkFileVersion(QString fn) 2533bool CalendarView::checkFileVersion(QString fn)
2501{ 2534{
2502 QFileInfo finf ( fn ); 2535 QFileInfo finf ( fn );
2503 if ( !finf.exists() ) 2536 if ( !finf.exists() )
2504 return true; 2537 return true;
2505 QDateTime dt = finf.lastModified (); 2538 QDateTime dt = finf.lastModified ();
2506 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2539 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2507 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2540 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2508 if ( dt <= loadedFileVersion ) 2541 if ( dt <= loadedFileVersion )
2509 return true; 2542 return true;
2510 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)) , 2543 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)) ,
2511 i18n("KO/Pi Warning"),i18n("Overwrite"), 2544 i18n("KO/Pi Warning"),i18n("Overwrite"),
2512 i18n("Sync+save")); 2545 i18n("Sync+save"));
2513 2546
2514 if ( km == KMessageBox::Cancel ) 2547 if ( km == KMessageBox::Cancel )
2515 return false; 2548 return false;
2516 if ( km == KMessageBox::Yes ) 2549 if ( km == KMessageBox::Yes )
2517 return true; 2550 return true;
2518 2551
2519 setSyncDevice("deleteaftersync" ); 2552 setSyncDevice("deleteaftersync" );
2520 mSyncManager->mAskForPreferences = true; 2553 mSyncManager->mAskForPreferences = true;
2521 mSyncManager->mSyncAlgoPrefs = 3; 2554 mSyncManager->mSyncAlgoPrefs = 3;
2522 mSyncManager->mWriteBackFile = false; 2555 mSyncManager->mWriteBackFile = false;
2523 mSyncManager->mWriteBackExistingOnly = false; 2556 mSyncManager->mWriteBackExistingOnly = false;
2524 mSyncManager->mShowSyncSummary = false; 2557 mSyncManager->mShowSyncSummary = false;
2558 mMultiResourceSync = false;
2525 syncCalendar( fn, 3 ); 2559 syncCalendar( fn, 3 );
2526 Event * e = getLastSyncEvent(); 2560 Event * e = getLastSyncEvent();
2527 if ( e ) 2561 if ( e )
2528 mCalendar->deleteEvent( e ); 2562 mCalendar->deleteEvent( e );
2529 return true; 2563 return true;
2530} 2564}
2531bool CalendarView::saveCalendars() 2565bool CalendarView::saveCalendars()
2532{ 2566{
2533 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2567 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2534 KopiCalendarFile * cal = calendars.first(); 2568 KopiCalendarFile * cal = calendars.first();
2535 mCalendar->setDefaultCalendar( 1 ); 2569 mCalendar->setDefaultCalendar( 1 );
2536 mCalendar->setDefaultCalendarEnabledOnly(); 2570 mCalendar->setDefaultCalendarEnabledOnly();
2537 QString saveError; 2571 QString saveError;
2538 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2572 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2539 saveError = cal->mName +"\n"; 2573 saveError = cal->mName +"\n";
2540 cal = calendars.next(); 2574 cal = calendars.next();
2541 while ( cal ) { 2575 while ( cal ) {
2542 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2576 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2543 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2577 mCalendar->setDefaultCalendar( cal->mCalNumber );
2544 mCalendar->setDefaultCalendarEnabledOnly(); 2578 mCalendar->setDefaultCalendarEnabledOnly();
2545 if ( saveCalendar( cal->mFileName ) ) 2579 if ( saveCalendar( cal->mFileName ) )
2546 cal->mLoadDt = QDateTime::currentDateTime(); 2580 cal->mLoadDt = QDateTime::currentDateTime();
2547 else 2581 else
2548 saveError += cal->mName + "\n"; 2582 saveError += cal->mName + "\n";
2549 } 2583 }
2550 cal = calendars.next(); 2584 cal = calendars.next();
2551 } 2585 }
2552 restoreCalendarSettings(); 2586 restoreCalendarSettings();
2553 //saveError = "test error"; 2587 //saveError = "test error";
2554 if ( !saveError.isEmpty() ) { 2588 if ( !saveError.isEmpty() ) {
2555 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2589 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2556 KMessageBox::error(this, saveError, i18n("Error saving data")); 2590 KMessageBox::error(this, saveError, i18n("Error saving data"));
2557 return false; 2591 return false;
2558 } 2592 }
2559 return true; 2593 return true;
2560} 2594}
2595bool CalendarView::saveCalendarResource(QString filename, QString resource)
2596{
2597 if ( resource == "ALL" )
2598 return saveCalendar( filename );
2599 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2600 if ( !exclusiveResource ) {
2601 qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
2602 return false;
2603 }
2604 mCalendar->setDefaultCalendar( exclusiveResource );
2605 mCalendar->setDefaultCalendarEnabledOnly();
2606 mCalendar->setSyncEventsEnabled();
2607 bool res = saveCalendar( filename );
2608 restoreCalendarSettings();
2609 return res;
2610
2611}
2561bool CalendarView::saveCalendar( QString filename ) 2612bool CalendarView::saveCalendar( QString filename )
2562{ 2613{
2563 2614
2564 // Store back all unsaved data into calendar object 2615 // Store back all unsaved data into calendar object
2565 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2616 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2566 if ( mViewManager->currentView() ) 2617 if ( mViewManager->currentView() )
2567 mViewManager->currentView()->flushView(); 2618 mViewManager->currentView()->flushView();
2568 2619
2569 2620
2570 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2621 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2571 mStorage->setSaveFormat( new ICalFormat() ); 2622 mStorage->setSaveFormat( new ICalFormat() );
2572 mStorage->setFileName( filename ); 2623 mStorage->setFileName( filename );
2573 bool success; 2624 bool success;
2574 success = mStorage->save(); 2625 success = mStorage->save();
2575 if ( !success ) { 2626 if ( !success ) {
2576 return false; 2627 return false;
2577 } 2628 }
2578 if ( filename == MainWindow::defaultFileName() ) { 2629 if ( filename == MainWindow::defaultFileName() ) {
2579 setLoadedFileVersion( lfv ); 2630 setLoadedFileVersion( lfv );
2580 watchSavedFile(); 2631 watchSavedFile();
2581 } 2632 }
2582 return true; 2633 return true;
2583} 2634}
2584 2635
2585void CalendarView::closeCalendar() 2636void CalendarView::closeCalendar()
2586{ 2637{
2587 2638
2588 // child windows no longer valid 2639 // child windows no longer valid
2589 clearAllViews(); 2640 clearAllViews();
2590 emit closingDown(); 2641 emit closingDown();
2591 2642
2592 mCalendar->close(); 2643 mCalendar->close();
2593 setModified(false); 2644 setModified(false);
2594 updateView(); 2645 updateView();
2595} 2646}
2596 2647
2597void CalendarView::archiveCalendar() 2648void CalendarView::archiveCalendar()
2598{ 2649{
2599 mDialogManager->showArchiveDialog(); 2650 mDialogManager->showArchiveDialog();
2600} 2651}
2601 2652
2602 2653
2603void CalendarView::readSettings() 2654void CalendarView::readSettings()
2604{ 2655{
2605 2656
2606 2657
2607 // mViewManager->showAgendaView(); 2658 // mViewManager->showAgendaView();
2608 QString str; 2659 QString str;
2609 //qDebug("CalendarView::readSettings() "); 2660 //qDebug("CalendarView::readSettings() ");
2610 // read settings from the KConfig, supplying reasonable 2661 // read settings from the KConfig, supplying reasonable
2611 // defaults where none are to be found 2662 // defaults where none are to be found
2612 KConfig *config = KOGlobals::config(); 2663 KConfig *config = KOGlobals::config();
2613#ifndef KORG_NOSPLITTER 2664#ifndef KORG_NOSPLITTER
2614 config->setGroup("KOrganizer Geometry"); 2665 config->setGroup("KOrganizer Geometry");
2615 2666
2616 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2667 QValueList<int> sizes = config->readIntListEntry("Separator1");
2617 if (sizes.count() != 2) { 2668 if (sizes.count() != 2) {
2618 sizes << mDateNavigator->minimumSizeHint().width(); 2669 sizes << mDateNavigator->minimumSizeHint().width();
2619 sizes << 300; 2670 sizes << 300;
2620 } 2671 }
2621 mPanner->setSizes(sizes); 2672 mPanner->setSizes(sizes);
2622 2673
2623 sizes = config->readIntListEntry("Separator2"); 2674 sizes = config->readIntListEntry("Separator2");
2624 if ( ( mResourceView && sizes.count() == 4 ) || 2675 if ( ( mResourceView && sizes.count() == 4 ) ||
2625 ( !mResourceView && sizes.count() == 3 ) ) { 2676 ( !mResourceView && sizes.count() == 3 ) ) {
2626 mLeftSplitter->setSizes(sizes); 2677 mLeftSplitter->setSizes(sizes);
2627 } 2678 }
2628#endif 2679#endif
2629 globalFlagBlockAgenda = 1; 2680 globalFlagBlockAgenda = 1;
2630 mViewManager->showAgendaView(); 2681 mViewManager->showAgendaView();
2631 //mViewManager->readSettings( config ); 2682 //mViewManager->readSettings( config );
2632 mTodoList->restoreLayout(config,QString("Todo Layout")); 2683 mTodoList->restoreLayout(config,QString("Todo Layout"));
2633 readFilterSettings(config); 2684 readFilterSettings(config);
2634 2685
2635#ifdef DESKTOP_VERSION 2686#ifdef DESKTOP_VERSION
2636 config->setGroup("WidgetLayout"); 2687 config->setGroup("WidgetLayout");
2637 QStringList list; 2688 QStringList list;
2638 list = config->readListEntry("MainLayout"); 2689 list = config->readListEntry("MainLayout");
2639 int x,y,w,h; 2690 int x,y,w,h;
2640 if ( ! list.isEmpty() ) { 2691 if ( ! list.isEmpty() ) {
2641 x = list[0].toInt(); 2692 x = list[0].toInt();
2642 y = list[1].toInt(); 2693 y = list[1].toInt();
2643 w = list[2].toInt(); 2694 w = list[2].toInt();
2644 h = list[3].toInt(); 2695 h = list[3].toInt();
2645 KApplication::testCoords( &x,&y,&w,&h ); 2696 KApplication::testCoords( &x,&y,&w,&h );
2646 topLevelWidget()->setGeometry(x,y,w,h); 2697 topLevelWidget()->setGeometry(x,y,w,h);
2647 2698
2648 } else { 2699 } else {
2649 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2700 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2650 } 2701 }
2651 list = config->readListEntry("EditEventLayout"); 2702 list = config->readListEntry("EditEventLayout");
2652 if ( ! list.isEmpty() ) { 2703 if ( ! list.isEmpty() ) {
2653 x = list[0].toInt(); 2704 x = list[0].toInt();
2654 y = list[1].toInt(); 2705 y = list[1].toInt();
2655 w = list[2].toInt(); 2706 w = list[2].toInt();
2656 h = list[3].toInt(); 2707 h = list[3].toInt();
2657 KApplication::testCoords( &x,&y,&w,&h ); 2708 KApplication::testCoords( &x,&y,&w,&h );
2658 mEventEditor->setGeometry(x,y,w,h); 2709 mEventEditor->setGeometry(x,y,w,h);
2659 2710
2660 } 2711 }
2661 list = config->readListEntry("EditTodoLayout"); 2712 list = config->readListEntry("EditTodoLayout");
2662 if ( ! list.isEmpty() ) { 2713 if ( ! list.isEmpty() ) {
2663 x = list[0].toInt(); 2714 x = list[0].toInt();
2664 y = list[1].toInt(); 2715 y = list[1].toInt();
2665 w = list[2].toInt(); 2716 w = list[2].toInt();
2666 h = list[3].toInt(); 2717 h = list[3].toInt();
2667 KApplication::testCoords( &x,&y,&w,&h ); 2718 KApplication::testCoords( &x,&y,&w,&h );
2668 mTodoEditor->setGeometry(x,y,w,h); 2719 mTodoEditor->setGeometry(x,y,w,h);
2669 2720
2670 } 2721 }
2671 list = config->readListEntry("ViewerLayout"); 2722 list = config->readListEntry("ViewerLayout");
2672 if ( ! list.isEmpty() ) { 2723 if ( ! list.isEmpty() ) {
2673 x = list[0].toInt(); 2724 x = list[0].toInt();
2674 y = list[1].toInt(); 2725 y = list[1].toInt();
2675 w = list[2].toInt(); 2726 w = list[2].toInt();
2676 h = list[3].toInt(); 2727 h = list[3].toInt();
2677 KApplication::testCoords( &x,&y,&w,&h ); 2728 KApplication::testCoords( &x,&y,&w,&h );
2678 getEventViewerDialog()->setGeometry(x,y,w,h); 2729 getEventViewerDialog()->setGeometry(x,y,w,h);
2679 } 2730 }
2680#endif 2731#endif
2681 config->setGroup( "Views" ); 2732 config->setGroup( "Views" );
2682 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2733 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2683 2734
2684 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2735 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2685 2736
2686 int resetval = 0; 2737 int resetval = 0;
2687 int maxVal = 0; 2738 int maxVal = 0;
2688 if (sizes.count() != 3) { 2739 if (sizes.count() != 3) {
2689 if ( KOPrefs::instance()->mVerticalScreen ) { 2740 if ( KOPrefs::instance()->mVerticalScreen ) {
2690 resetval = mDateNavigator->sizeHint().width()+2; 2741 resetval = mDateNavigator->sizeHint().width()+2;
2691 } else { 2742 } else {
2692 resetval = mDateNavigator->sizeHint().height()+2; 2743 resetval = mDateNavigator->sizeHint().height()+2;
2693 } 2744 }
2694 } 2745 }
2695 if ( resetval ) { 2746 if ( resetval ) {
2696 sizes.clear(); 2747 sizes.clear();
2697 if ( KOPrefs::instance()->mVerticalScreen ) { 2748 if ( KOPrefs::instance()->mVerticalScreen ) {
2698 maxVal = QApplication::desktop()->width() -10; 2749 maxVal = QApplication::desktop()->width() -10;
2699 } else { 2750 } else {
2700 maxVal = QApplication::desktop()->height()-10; 2751 maxVal = QApplication::desktop()->height()-10;
2701 } 2752 }
2702 sizes << resetval; 2753 sizes << resetval;
2703 if ( maxVal < resetval + resetval) 2754 if ( maxVal < resetval + resetval)
2704 resetval = maxVal - resetval; 2755 resetval = maxVal - resetval;
2705 sizes << resetval; 2756 sizes << resetval;
2706 sizes << 100; 2757 sizes << 100;
2707 } 2758 }
2708 mLeftFrame->setSizes(sizes); 2759 mLeftFrame->setSizes(sizes);
2709 sizes = config->readIntListEntry("Main Splitter Frame"); 2760 sizes = config->readIntListEntry("Main Splitter Frame");
2710 resetval = 0; 2761 resetval = 0;
2711 maxVal = 0; 2762 maxVal = 0;
2712 if (sizes.count() != 2) { 2763 if (sizes.count() != 2) {
2713 if ( !KOPrefs::instance()->mVerticalScreen ) { 2764 if ( !KOPrefs::instance()->mVerticalScreen ) {
2714 resetval = mDateNavigator->sizeHint().width()+2; 2765 resetval = mDateNavigator->sizeHint().width()+2;
2715 } else { 2766 } else {
2716 resetval = mDateNavigator->sizeHint().height()+2; 2767 resetval = mDateNavigator->sizeHint().height()+2;
2717 } 2768 }
2718 } 2769 }
2719 if ( resetval ) { 2770 if ( resetval ) {
2720 sizes.clear(); 2771 sizes.clear();
2721 if ( !KOPrefs::instance()->mVerticalScreen ) { 2772 if ( !KOPrefs::instance()->mVerticalScreen ) {
2722 maxVal = QApplication::desktop()->width() -10; 2773 maxVal = QApplication::desktop()->width() -10;
2723 } else { 2774 } else {
2724 maxVal = QApplication::desktop()->height()-10; 2775 maxVal = QApplication::desktop()->height()-10;
2725 } 2776 }
2726 sizes << resetval; 2777 sizes << resetval;
2727 if ( maxVal < resetval + resetval) 2778 if ( maxVal < resetval + resetval)
2728 resetval = maxVal - resetval; 2779 resetval = maxVal - resetval;
2729 sizes << resetval; 2780 sizes << resetval;
2730 } 2781 }
2731 mMainFrame->setSizes(sizes); 2782 mMainFrame->setSizes(sizes);
2732 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2783 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2733 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2784 else if ( dateCount == 7 ) mNavigator->selectWeek();
2734 else mNavigator->selectDates( dateCount ); 2785 else mNavigator->selectDates( dateCount );
2735 // mViewManager->readSettings( config ); 2786 // mViewManager->readSettings( config );
2736 updateConfig(); 2787 updateConfig();
2737 globalFlagBlockAgenda = 2; 2788 globalFlagBlockAgenda = 2;
2738 mViewManager->readSettings( config ); 2789 mViewManager->readSettings( config );
2739 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2790 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2740} 2791}
2741 2792
2742void CalendarView::checkSuspendAlarm() 2793void CalendarView::checkSuspendAlarm()
2743{ 2794{
2744 if ( mSuspendTimer->isActive() ) { 2795 if ( mSuspendTimer->isActive() ) {
2745 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2796 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2746 } 2797 }
2747} 2798}
2748void CalendarView::writeSettings() 2799void CalendarView::writeSettings()
2749{ 2800{
2750 // kdDebug() << "CalendarView::writeSettings" << endl; 2801 // kdDebug() << "CalendarView::writeSettings" << endl;
2751 2802
2752 KConfig *config = KOGlobals::config(); 2803 KConfig *config = KOGlobals::config();
2753 2804
2754 mViewManager->writeSettings( config ); 2805 mViewManager->writeSettings( config );
2755 mTodoList->saveLayout(config,QString("Todo Layout")); 2806 mTodoList->saveLayout(config,QString("Todo Layout"));
2756 mDialogManager->writeSettings( config ); 2807 mDialogManager->writeSettings( config );
2757 //KOPrefs::instance()->usrWriteConfig(); 2808 //KOPrefs::instance()->usrWriteConfig();
2758 KOPrefs::instance()->writeConfig(); 2809 KOPrefs::instance()->writeConfig();
2759 2810
2760 writeFilterSettings(config); 2811 writeFilterSettings(config);
2761 config->setGroup( "AppRun" ); 2812 config->setGroup( "AppRun" );
2762 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2813 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2763 int days = dt.daysTo( QDate::currentDate() ); 2814 int days = dt.daysTo( QDate::currentDate() );
2764 dt = dt.addDays( days ); 2815 dt = dt.addDays( days );
2765 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2816 int secs = dt.secsTo( QDateTime::currentDateTime() );
2766 config->writeEntry( "LatestProgramStopDays", days ); 2817 config->writeEntry( "LatestProgramStopDays", days );
2767 config->writeEntry( "LatestProgramStopSecs", secs ); 2818 config->writeEntry( "LatestProgramStopSecs", secs );
2768 //qDebug("KO: Writing stop time: %d ", secs); 2819 //qDebug("KO: Writing stop time: %d ", secs);
2769 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2820 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2770 //QDateTime latest = dt.addSecs ( secs ); 2821 //QDateTime latest = dt.addSecs ( secs );
2771 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2822 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2772 config->setGroup( "Views" ); 2823 config->setGroup( "Views" );
2773 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2824 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2774 2825
2775#if 0 2826#if 0
2776 qDebug("********************* "); 2827 qDebug("********************* ");
2777 qDebug("Testcode secsto "); 2828 qDebug("Testcode secsto ");
2778 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2829 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2779 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2830 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2780 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2831 int secsto = dt_nodaylight.secsTo( dt_daylight );
2781 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2832 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2782 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2833 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2783 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2834 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2784 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2835 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2785 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2836 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2786 qDebug("********************* testcode end"); 2837 qDebug("********************* testcode end");
2787 2838
2788#endif 2839#endif
2789 2840
2790 QValueList<int> listINT = mLeftFrame->sizes(); 2841 QValueList<int> listINT = mLeftFrame->sizes();
2791 config->writeEntry("Left Splitter Frame",listINT); 2842 config->writeEntry("Left Splitter Frame",listINT);
2792 QValueList<int> listINT2 = mMainFrame->sizes(); 2843 QValueList<int> listINT2 = mMainFrame->sizes();
2793 config->writeEntry("Main Splitter Frame",listINT2); 2844 config->writeEntry("Main Splitter Frame",listINT2);
2794#ifdef DESKTOP_VERSION 2845#ifdef DESKTOP_VERSION
2795 config->setGroup("WidgetLayout"); 2846 config->setGroup("WidgetLayout");
2796 QStringList list ;//= config->readListEntry("MainLayout"); 2847 QStringList list ;//= config->readListEntry("MainLayout");
2797 int x,y,w,h; 2848 int x,y,w,h;
2798 QWidget* wid; 2849 QWidget* wid;
2799 wid = topLevelWidget(); 2850 wid = topLevelWidget();
2800 x = wid->geometry().x(); 2851 x = wid->geometry().x();
2801 y = wid->geometry().y(); 2852 y = wid->geometry().y();
2802 w = wid->width(); 2853 w = wid->width();
2803 h = wid->height(); 2854 h = wid->height();
2804 list.clear(); 2855 list.clear();
2805 list << QString::number( x ); 2856 list << QString::number( x );
2806 list << QString::number( y ); 2857 list << QString::number( y );
2807 list << QString::number( w ); 2858 list << QString::number( w );
2808 list << QString::number( h ); 2859 list << QString::number( h );
2809 config->writeEntry("MainLayout",list ); 2860 config->writeEntry("MainLayout",list );
2810 2861
2811 wid = mEventEditor; 2862 wid = mEventEditor;
2812 x = wid->geometry().x(); 2863 x = wid->geometry().x();
2813 y = wid->geometry().y(); 2864 y = wid->geometry().y();
2814 w = wid->width(); 2865 w = wid->width();
2815 h = wid->height(); 2866 h = wid->height();
2816 list.clear(); 2867 list.clear();
2817 list << QString::number( x ); 2868 list << QString::number( x );
2818 list << QString::number( y ); 2869 list << QString::number( y );
2819 list << QString::number( w ); 2870 list << QString::number( w );
2820 list << QString::number( h ); 2871 list << QString::number( h );
2821 config->writeEntry("EditEventLayout",list ); 2872 config->writeEntry("EditEventLayout",list );
2822 2873
2823 wid = mTodoEditor; 2874 wid = mTodoEditor;
2824 x = wid->geometry().x(); 2875 x = wid->geometry().x();
2825 y = wid->geometry().y(); 2876 y = wid->geometry().y();
2826 w = wid->width(); 2877 w = wid->width();
2827 h = wid->height(); 2878 h = wid->height();
2828 list.clear(); 2879 list.clear();
2829 list << QString::number( x ); 2880 list << QString::number( x );
2830 list << QString::number( y ); 2881 list << QString::number( y );
2831 list << QString::number( w ); 2882 list << QString::number( w );
2832 list << QString::number( h ); 2883 list << QString::number( h );
2833 config->writeEntry("EditTodoLayout",list ); 2884 config->writeEntry("EditTodoLayout",list );
2834 wid = getEventViewerDialog(); 2885 wid = getEventViewerDialog();
2835 x = wid->geometry().x(); 2886 x = wid->geometry().x();
2836 y = wid->geometry().y(); 2887 y = wid->geometry().y();
2837 w = wid->width(); 2888 w = wid->width();
2838 h = wid->height(); 2889 h = wid->height();
2839 list.clear(); 2890 list.clear();
2840 list << QString::number( x ); 2891 list << QString::number( x );
2841 list << QString::number( y ); 2892 list << QString::number( y );
2842 list << QString::number( w ); 2893 list << QString::number( w );
2843 list << QString::number( h ); 2894 list << QString::number( h );
2844 config->writeEntry("ViewerLayout",list ); 2895 config->writeEntry("ViewerLayout",list );
2845 wid = mDialogManager->getSearchDialog(); 2896 wid = mDialogManager->getSearchDialog();
2846 if ( wid ) { 2897 if ( wid ) {
2847 x = wid->geometry().x(); 2898 x = wid->geometry().x();
2848 y = wid->geometry().y(); 2899 y = wid->geometry().y();
2849 w = wid->width(); 2900 w = wid->width();
2850 h = wid->height(); 2901 h = wid->height();
2851 list.clear(); 2902 list.clear();
2852 list << QString::number( x ); 2903 list << QString::number( x );
2853 list << QString::number( y ); 2904 list << QString::number( y );
2854 list << QString::number( w ); 2905 list << QString::number( w );
2855 list << QString::number( h ); 2906 list << QString::number( h );
2856 config->writeEntry("SearchLayout",list ); 2907 config->writeEntry("SearchLayout",list );
2857 } 2908 }
2858#endif 2909#endif
2859 2910
2860 2911
2861 config->sync(); 2912 config->sync();
2862} 2913}
2863 2914
2864void CalendarView::readFilterSettings(KConfig *config) 2915void CalendarView::readFilterSettings(KConfig *config)
2865{ 2916{
2866 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2917 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2867 2918
2868 mFilters.clear(); 2919 mFilters.clear();
2869 2920
2870 config->setGroup("General"); 2921 config->setGroup("General");
2871 QStringList filterList = config->readListEntry("CalendarFilters"); 2922 QStringList filterList = config->readListEntry("CalendarFilters");
2872 2923
2873 QStringList::ConstIterator it = filterList.begin(); 2924 QStringList::ConstIterator it = filterList.begin();
2874 QStringList::ConstIterator end = filterList.end(); 2925 QStringList::ConstIterator end = filterList.end();
2875 while(it != end) { 2926 while(it != end) {
2876 // kdDebug() << " filter: " << (*it) << endl; 2927 // kdDebug() << " filter: " << (*it) << endl;
2877 2928
2878 CalFilter *filter; 2929 CalFilter *filter;
2879 filter = new CalFilter(*it); 2930 filter = new CalFilter(*it);
2880 config->setGroup("Filter_" + (*it).utf8()); 2931 config->setGroup("Filter_" + (*it).utf8());
2881 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2932 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2882 filter->setCriteria(config->readNumEntry("Criteria",0)); 2933 filter->setCriteria(config->readNumEntry("Criteria",0));
2883 filter->setCategoryList(config->readListEntry("CategoryList")); 2934 filter->setCategoryList(config->readListEntry("CategoryList"));
2884 mFilters.append(filter); 2935 mFilters.append(filter);
2885 2936
2886 ++it; 2937 ++it;
2887 } 2938 }
2888 2939
2889 if (mFilters.count() == 0) { 2940 if (mFilters.count() == 0) {
2890 CalFilter *filter = new CalFilter(i18n("Default")); 2941 CalFilter *filter = new CalFilter(i18n("Default"));
2891 mFilters.append(filter); 2942 mFilters.append(filter);
2892 } 2943 }
2893 mFilterView->updateFilters(); 2944 mFilterView->updateFilters();
2894 config->setGroup("FilterView"); 2945 config->setGroup("FilterView");
2895 2946
2896 mFilterView->blockSignals(true); 2947 mFilterView->blockSignals(true);
2897 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2948 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2898 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2949 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2899 mFilterView->blockSignals(false); 2950 mFilterView->blockSignals(false);
2900 // We do it manually to avoid it being done twice by the above calls 2951 // We do it manually to avoid it being done twice by the above calls
2901 updateFilter(); 2952 updateFilter();
2902} 2953}
2903 2954
2904void CalendarView::writeFilterSettings(KConfig *config) 2955void CalendarView::writeFilterSettings(KConfig *config)
2905{ 2956{
2906 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2957 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2907 2958
2908 QStringList filterList; 2959 QStringList filterList;
2909 2960
2910 CalFilter *filter = mFilters.first(); 2961 CalFilter *filter = mFilters.first();
2911 while(filter) { 2962 while(filter) {
2912 // kdDebug() << " fn: " << filter->name() << endl; 2963 // kdDebug() << " fn: " << filter->name() << endl;
2913 filterList << filter->name(); 2964 filterList << filter->name();
2914 config->setGroup("Filter_" + filter->name().utf8()); 2965 config->setGroup("Filter_" + filter->name().utf8());
2915 config->writeEntry("Criteria",filter->criteria()); 2966 config->writeEntry("Criteria",filter->criteria());
2916 config->writeEntry("CategoryList",filter->categoryList()); 2967 config->writeEntry("CategoryList",filter->categoryList());
2917 filter = mFilters.next(); 2968 filter = mFilters.next();
2918 } 2969 }
2919 config->setGroup("General"); 2970 config->setGroup("General");
2920 config->writeEntry("CalendarFilters",filterList); 2971 config->writeEntry("CalendarFilters",filterList);
2921 2972
2922 config->setGroup("FilterView"); 2973 config->setGroup("FilterView");
2923 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2974 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2924 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2975 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2925} 2976}
2926 2977
2927 2978
2928void CalendarView::goToday() 2979void CalendarView::goToday()
2929{ 2980{
2930 if ( mViewManager->currentView()->isMonthView() ) 2981 if ( mViewManager->currentView()->isMonthView() )
2931 mNavigator->selectTodayMonth(); 2982 mNavigator->selectTodayMonth();
2932 else 2983 else
2933 mNavigator->selectToday(); 2984 mNavigator->selectToday();
2934} 2985}
2935 2986
2936void CalendarView::goNext() 2987void CalendarView::goNext()
2937{ 2988{
2938 mNavigator->selectNext(); 2989 mNavigator->selectNext();
2939} 2990}
2940 2991
2941void CalendarView::goPrevious() 2992void CalendarView::goPrevious()
2942{ 2993{
2943 mNavigator->selectPrevious(); 2994 mNavigator->selectPrevious();
2944} 2995}
2945void CalendarView::goNextMonth() 2996void CalendarView::goNextMonth()
2946{ 2997{
2947 mNavigator->selectNextMonth(); 2998 mNavigator->selectNextMonth();
2948} 2999}
2949 3000
2950void CalendarView::goPreviousMonth() 3001void CalendarView::goPreviousMonth()
2951{ 3002{
2952 mNavigator->selectPreviousMonth(); 3003 mNavigator->selectPreviousMonth();
2953} 3004}
2954 3005
2955void CalendarView::updateConfig() 3006void CalendarView::updateConfig()
2956{ 3007{
2957 if ( KOPrefs::instance()->mUseAppColors ) 3008 if ( KOPrefs::instance()->mUseAppColors )
2958 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 3009 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2959 emit configChanged(); 3010 emit configChanged();
2960 mTodoList->updateConfig(); 3011 mTodoList->updateConfig();
2961 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 3012 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2962 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3013 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2963 // To make the "fill window" configurations work 3014 // To make the "fill window" configurations work
2964 //mViewManager->raiseCurrentView(); 3015 //mViewManager->raiseCurrentView();
2965} 3016}
2966 3017
2967 3018
2968void CalendarView::eventChanged(Event *event) 3019void CalendarView::eventChanged(Event *event)
2969{ 3020{
2970 changeEventDisplay(event,KOGlobals::EVENTEDITED); 3021 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2971 //updateUnmanagedViews(); 3022 //updateUnmanagedViews();
2972} 3023}
2973 3024
2974void CalendarView::eventAdded(Event *event) 3025void CalendarView::eventAdded(Event *event)
2975{ 3026{
2976 changeEventDisplay(event,KOGlobals::EVENTADDED); 3027 changeEventDisplay(event,KOGlobals::EVENTADDED);
2977} 3028}
2978 3029
2979void CalendarView::eventToBeDeleted(Event *) 3030void CalendarView::eventToBeDeleted(Event *)
2980{ 3031{
2981 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 3032 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2982} 3033}
2983 3034
2984void CalendarView::eventDeleted() 3035void CalendarView::eventDeleted()
2985{ 3036{
2986 changeEventDisplay(0,KOGlobals::EVENTDELETED); 3037 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2987} 3038}
2988void CalendarView::changeTodoDisplay(Todo *which, int action) 3039void CalendarView::changeTodoDisplay(Todo *which, int action)
2989{ 3040{
2990 changeIncidenceDisplay((Incidence *)which, action); 3041 changeIncidenceDisplay((Incidence *)which, action);
2991 mDateNavigator->updateView(); //LR 3042 mDateNavigator->updateView(); //LR
2992 //mDialogManager->updateSearchDialog(); 3043 //mDialogManager->updateSearchDialog();
2993 3044
2994 if (which) { 3045 if (which) {
2995 mViewManager->updateWNview(); 3046 mViewManager->updateWNview();
2996 //mTodoList->updateView(); 3047 //mTodoList->updateView();
2997 } 3048 }
2998 3049
2999} 3050}
3000 3051
3001void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 3052void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
3002{ 3053{
3003 updateUnmanagedViews(); 3054 updateUnmanagedViews();
3004 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 3055 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
3005 if ( action == KOGlobals::EVENTDELETED ) { //delete 3056 if ( action == KOGlobals::EVENTDELETED ) { //delete
3006 mCalendar->checkAlarmForIncidence( 0, true ); 3057 mCalendar->checkAlarmForIncidence( 0, true );
3007 if ( mEventViewerDialog ) 3058 if ( mEventViewerDialog )
3008 mEventViewerDialog->hide(); 3059 mEventViewerDialog->hide();
3009 } 3060 }
3010 else 3061 else
3011 mCalendar->checkAlarmForIncidence( which , false ); 3062 mCalendar->checkAlarmForIncidence( which , false );
3012} 3063}
3013 3064
3014// most of the changeEventDisplays() right now just call the view's 3065// most of the changeEventDisplays() right now just call the view's
3015// total update mode, but they SHOULD be recoded to be more refresh-efficient. 3066// total update mode, but they SHOULD be recoded to be more refresh-efficient.
3016void CalendarView::changeEventDisplay(Event *which, int action) 3067void CalendarView::changeEventDisplay(Event *which, int action)
3017{ 3068{
3018 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 3069 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
3019 changeIncidenceDisplay((Incidence *)which, action); 3070 changeIncidenceDisplay((Incidence *)which, action);
3020 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3071 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3021 if ( flag_clearallviewsEventDisplay ) { 3072 if ( flag_clearallviewsEventDisplay ) {
3022 clearAllViews(); 3073 clearAllViews();
3023 flag_clearallviewsEventDisplay = false; 3074 flag_clearallviewsEventDisplay = false;
3024 } 3075 }
3025 return; 3076 return;
3026 } 3077 }
3027 flag_clearallviewsEventDisplay = true; 3078 flag_clearallviewsEventDisplay = true;
3028 mDateNavigator->updateView(); 3079 mDateNavigator->updateView();
3029 //mDialogManager->updateSearchDialog(); 3080 //mDialogManager->updateSearchDialog();
3030 if (which) { 3081 if (which) {
3031 // If there is an event view visible update the display 3082 // If there is an event view visible update the display
3032 mViewManager->currentView()->changeEventDisplay(which,action); 3083 mViewManager->currentView()->changeEventDisplay(which,action);
3033 // TODO: check, if update needed 3084 // TODO: check, if update needed
3034 // if (which->getTodoStatus()) { 3085 // if (which->getTodoStatus()) {
3035 mTodoList->updateView(); 3086 mTodoList->updateView();
3036 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { 3087 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) {
3037 mConflictingEvent = which ; 3088 mConflictingEvent = which ;
3038 int time = 1000; 3089 int time = 1000;
3039#ifdef DESKTOP_VERSION 3090#ifdef DESKTOP_VERSION
3040 time = 500; 3091 time = 500;
3041#endif 3092#endif
3042 bool checkC = false; 3093 bool checkC = false;
3043 if ( mConflictingEvent->doesFloat() ) { 3094 if ( mConflictingEvent->doesFloat() ) {
3044 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay 3095 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay
3045 || KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3096 || KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3046 } else { 3097 } else {
3047 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay 3098 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay
3048 || KOPrefs::instance()->mCheckConflictsNonADNonAD; 3099 || KOPrefs::instance()->mCheckConflictsNonADNonAD;
3049 } 3100 }
3050 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) 3101 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent )
3051 checkC = false; 3102 checkC = false;
3052 if ( checkC ) 3103 if ( checkC )
3053 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3104 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3054 } 3105 }
3055 // } 3106 // }
3056 } else { 3107 } else {
3057 mViewManager->currentView()->updateView(); 3108 mViewManager->currentView()->updateView();
3058 } 3109 }
3059} 3110}
3060void CalendarView::checkConflictForEvent() 3111void CalendarView::checkConflictForEvent()
3061{ 3112{
3062 3113
3063 if (!KOPrefs::instance()->mConfirm) 3114 if (!KOPrefs::instance()->mConfirm)
3064 return; 3115 return;
3065 if ( ! mConflictingEvent ) return; 3116 if ( ! mConflictingEvent ) return;
3066 Event * conflictingEvent = mConflictingEvent; 3117 Event * conflictingEvent = mConflictingEvent;
3067 mConflictingEvent = 0; 3118 mConflictingEvent = 0;
3068 QDateTime current = QDateTime::currentDateTime(); 3119 QDateTime current = QDateTime::currentDateTime();
3069 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3120 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3070 return; 3121 return;
3071 } 3122 }
3072 CalFilter *filterIN = 0; 3123 CalFilter *filterIN = 0;
3073 CalFilter *filterALL = 0; 3124 CalFilter *filterALL = 0;
3074 CalFilter *filter = mFilters.first(); 3125 CalFilter *filter = mFilters.first();
3075 while(filter) { 3126 while(filter) {
3076 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3127 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3077 filterIN = filter; 3128 filterIN = filter;
3078 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3129 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3079 filterALL = filter; 3130 filterALL = filter;
3080 filter = mFilters.next(); 3131 filter = mFilters.next();
3081 } 3132 }
3082 if ( filterIN ) { 3133 if ( filterIN ) {
3083 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3134 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3084 return; 3135 return;
3085 } 3136 }
3086 } 3137 }
3087 QPtrList<Event> testlist = mCalendar->events(); 3138 QPtrList<Event> testlist = mCalendar->events();
3088 Event * test = testlist.first(); 3139 Event * test = testlist.first();
3089 QDateTime conflict; 3140 QDateTime conflict;
3090 QDateTime retVal; 3141 QDateTime retVal;
3091 bool found = false; 3142 bool found = false;
3092 Event * cE = 0; 3143 Event * cE = 0;
3093 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3144 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3094 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3145 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3095 if ( !conflictingEvent->doesFloat() ) { 3146 if ( !conflictingEvent->doesFloat() ) {
3096 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3147 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3097 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3148 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3098 } 3149 }
3099 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3150 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3100 while ( test ) { 3151 while ( test ) {
3101 qApp->processEvents(); 3152 qApp->processEvents();
3102 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3153 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3103 3154
3104 if ( !skip ) { 3155 if ( !skip ) {
3105 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) 3156 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent )
3106 skip = true; 3157 skip = true;
3107 } 3158 }
3108 if ( !skip ) { 3159 if ( !skip ) {
3109 if ( filterALL ) { 3160 if ( filterALL ) {
3110 if ( !filterALL->filterCalendarItem( test ) ) { 3161 if ( !filterALL->filterCalendarItem( test ) ) {
3111 skip = true; 3162 skip = true;
3112 } 3163 }
3113 } 3164 }
3114 if ( !skip ) { 3165 if ( !skip ) {
3115 if ( found ) 3166 if ( found )
3116 skip = !test->matchTime( &current, &conflict ); 3167 skip = !test->matchTime( &current, &conflict );
3117 else 3168 else
3118 skip = !test->matchTime( &current, 0 ); 3169 skip = !test->matchTime( &current, 0 );
3119 if ( !skip ) { 3170 if ( !skip ) {
3120 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3171 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3121 if ( ! found ) { 3172 if ( ! found ) {
3122 conflict = retVal; 3173 conflict = retVal;
3123 cE = test; 3174 cE = test;
3124 } else { 3175 } else {
3125 if ( retVal < conflict ) { 3176 if ( retVal < conflict ) {
3126 conflict = retVal; 3177 conflict = retVal;
3127 cE = test; 3178 cE = test;
3128 } 3179 }
3129 } 3180 }
3130 found = true; 3181 found = true;
3131 } 3182 }
3132 } 3183 }
3133 } 3184 }
3134 } 3185 }
3135 test = testlist.next(); 3186 test = testlist.next();
3136 } 3187 }
3137 topLevelWidget()->setCaption( i18n("KO/Pi") ); 3188 topLevelWidget()->setCaption( i18n("KO/Pi") );
3138 if ( found ) { 3189 if ( found ) {
3139 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()) ) ; 3190 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()) ) ;
3140 qApp->processEvents(); 3191 qApp->processEvents();
3141 int km = KMessageBox::warningContinueCancel(this,mess, 3192 int km = KMessageBox::warningContinueCancel(this,mess,
3142 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); 3193 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!"));
3143 if ( km != KMessageBox::Continue ) { 3194 if ( km != KMessageBox::Continue ) {
3144 return; 3195 return;
3145 } 3196 }
3146 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 3197 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
3147 mViewManager->showDayView(); 3198 mViewManager->showDayView();
3148 mNavigator->slotDaySelect( conflict.date() ); 3199 mNavigator->slotDaySelect( conflict.date() );
3149 int hour = conflict.time().hour(); 3200 int hour = conflict.time().hour();
3150 mViewManager->agendaView()->setStartHour( hour ); 3201 mViewManager->agendaView()->setStartHour( hour );
3151 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 3202 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
3152 } else 3203 } else
3153 topLevelWidget()->setCaption( i18n("No conflict found") ); 3204 topLevelWidget()->setCaption( i18n("No conflict found") );
3154 return; 3205 return;
3155 3206
3156} 3207}
3157 3208
3158void CalendarView::updateTodoViews() 3209void CalendarView::updateTodoViews()
3159{ 3210{
3160 mTodoList->updateView(); 3211 mTodoList->updateView();
3161 mViewManager->currentView()->updateView(); 3212 mViewManager->currentView()->updateView();
3162 3213
3163} 3214}
3164 3215
3165 3216
3166 3217
3167void CalendarView::clearAllViews() 3218void CalendarView::clearAllViews()
3168{ 3219{
3169 mTodoList->clearList(); 3220 mTodoList->clearList();
3170 mViewManager->clearAllViews(); 3221 mViewManager->clearAllViews();
3171 SearchDialog * sd = mDialogManager->getSearchDialog(); 3222 SearchDialog * sd = mDialogManager->getSearchDialog();
3172 if ( sd ) { 3223 if ( sd ) {
3173 KOListView* kol = sd->listview(); 3224 KOListView* kol = sd->listview();
3174 if ( kol ) 3225 if ( kol )
3175 kol->clearList(); 3226 kol->clearList();
3176 } 3227 }
3177} 3228}
3178void CalendarView::updateView() 3229void CalendarView::updateView()
3179{ 3230{
3180 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3231 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3181 if ( flag_clearallviewsupdateView ) { 3232 if ( flag_clearallviewsupdateView ) {
3182 clearAllViews(); 3233 clearAllViews();
3183 flag_clearallviewsupdateView = false; 3234 flag_clearallviewsupdateView = false;
3184 } 3235 }
3185 return; 3236 return;
3186 } 3237 }
3187 flag_clearallviewsupdateView = true; 3238 flag_clearallviewsupdateView = true;
3188 DateList tmpList = mNavigator->selectedDates(); 3239 DateList tmpList = mNavigator->selectedDates();
3189 3240
3190 if ( KOPrefs::instance()->mHideNonStartedTodos ) 3241 if ( KOPrefs::instance()->mHideNonStartedTodos )
3191 mTodoList->updateView(); 3242 mTodoList->updateView();
3192 // We assume that the navigator only selects consecutive days. 3243 // We assume that the navigator only selects consecutive days.
3193 updateView( tmpList.first(), tmpList.last() ); 3244 updateView( tmpList.first(), tmpList.last() );
3194} 3245}
3195 3246
3196void CalendarView::updateUnmanagedViews() 3247void CalendarView::updateUnmanagedViews()
3197{ 3248{
3198 mDateNavigator->updateDayMatrix(); 3249 mDateNavigator->updateDayMatrix();
3199} 3250}
3200 3251
3201int CalendarView::msgItemDelete(const QString name) 3252int CalendarView::msgItemDelete(const QString name)
3202{ 3253{
3203 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 3254 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
3204 i18n("This item will be\npermanently deleted."), 3255 i18n("This item will be\npermanently deleted."),
3205 i18n("KO/Pi Confirmation"),i18n("Delete")); 3256 i18n("KO/Pi Confirmation"),i18n("Delete"));
3206} 3257}
3207 3258
3208 3259
3209void CalendarView::edit_cut() 3260void CalendarView::edit_cut()
3210{ 3261{
3211 Event *anEvent=0; 3262 Event *anEvent=0;
3212 3263
3213 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3264 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3214 3265
3215 if (mViewManager->currentView()->isEventView()) { 3266 if (mViewManager->currentView()->isEventView()) {
3216 if ( incidence && incidence->typeID() == eventID ) { 3267 if ( incidence && incidence->typeID() == eventID ) {
3217 anEvent = static_cast<Event *>(incidence); 3268 anEvent = static_cast<Event *>(incidence);
3218 } 3269 }
3219 } 3270 }
3220 3271
3221 if (!anEvent) { 3272 if (!anEvent) {
3222 KNotifyClient::beep(); 3273 KNotifyClient::beep();
3223 return; 3274 return;
3224 } 3275 }
3225 DndFactory factory( mCalendar ); 3276 DndFactory factory( mCalendar );
3226 factory.cutIncidence(anEvent); 3277 factory.cutIncidence(anEvent);
3227 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3278 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3228} 3279}
3229 3280
3230void CalendarView::edit_copy() 3281void CalendarView::edit_copy()
3231{ 3282{
3232 Event *anEvent=0; 3283 Event *anEvent=0;
3233 3284
3234 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3285 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3235 3286
3236 if (mViewManager->currentView()->isEventView()) { 3287 if (mViewManager->currentView()->isEventView()) {
3237 if ( incidence && incidence->typeID() == eventID ) { 3288 if ( incidence && incidence->typeID() == eventID ) {
3238 anEvent = static_cast<Event *>(incidence); 3289 anEvent = static_cast<Event *>(incidence);
3239 } 3290 }
3240 } 3291 }
3241 3292
3242 if (!anEvent) { 3293 if (!anEvent) {
3243 KNotifyClient::beep(); 3294 KNotifyClient::beep();
3244 return; 3295 return;
3245 } 3296 }
3246 DndFactory factory( mCalendar ); 3297 DndFactory factory( mCalendar );
3247 factory.copyIncidence(anEvent); 3298 factory.copyIncidence(anEvent);
3248} 3299}
3249 3300
3250void CalendarView::edit_paste() 3301void CalendarView::edit_paste()
3251{ 3302{
3252 QDate date = mNavigator->selectedDates().first(); 3303 QDate date = mNavigator->selectedDates().first();
3253 3304
3254 DndFactory factory( mCalendar ); 3305 DndFactory factory( mCalendar );
3255 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 3306 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
3256 3307
3257 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 3308 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
3258} 3309}
3259void CalendarView::edit_global_options() 3310void CalendarView::edit_global_options()
3260{ 3311{
3261 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 3312 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
3262 emit save(); 3313 emit save();
3263 emit saveStopTimer(); 3314 emit saveStopTimer();
3264 mDialogManager->showGlobalOptionsDialog(); 3315 mDialogManager->showGlobalOptionsDialog();
3265 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 3316 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
3266 emit saveStopTimer(); 3317 emit saveStopTimer();
3267 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!"), 3318 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!"),
3268 i18n("Timezone settings"),i18n("Reload"))) { 3319 i18n("Timezone settings"),i18n("Reload"))) {
3269 qDebug("KO: TZ reload cancelled "); 3320 qDebug("KO: TZ reload cancelled ");
3270 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3321 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3271 return; 3322 return;
3272 } 3323 }
3273 qDebug("KO: Timezone change "); 3324 qDebug("KO: Timezone change ");
3274 loadCalendars(); 3325 loadCalendars();
3275 setModified(true); 3326 setModified(true);
3276 } 3327 }
3277 else 3328 else
3278 qDebug("KO: No tz change "); 3329 qDebug("KO: No tz change ");
3279} 3330}
3280void CalendarView::edit_options() 3331void CalendarView::edit_options()
3281{ 3332{
3282 mDialogManager->showOptionsDialog(); 3333 mDialogManager->showOptionsDialog();
3283} 3334}
3284 3335
3285 3336
3286void CalendarView::slotSelectPickerDate( QDate d) 3337void CalendarView::slotSelectPickerDate( QDate d)
3287{ 3338{
3288 mDateFrame->hide(); 3339 mDateFrame->hide();
3289 if ( mDatePickerMode == 1 ) { 3340 if ( mDatePickerMode == 1 ) {
3290 mNavigator->slotDaySelect( d ); 3341 mNavigator->slotDaySelect( d );
3291 } else if ( mDatePickerMode == 2 ) { 3342 } else if ( mDatePickerMode == 2 ) {
3292 if ( mMoveIncidence->typeID() == todoID ) { 3343 if ( mMoveIncidence->typeID() == todoID ) {
3293 Todo * to = (Todo *) mMoveIncidence; 3344 Todo * to = (Todo *) mMoveIncidence;
3294 QTime tim; 3345 QTime tim;
3295 int len = 0; 3346 int len = 0;
3296 if ( to->hasStartDate() && to->hasDueDate() ) 3347 if ( to->hasStartDate() && to->hasDueDate() )
3297 len = to->dtStart().secsTo( to->dtDue()); 3348 len = to->dtStart().secsTo( to->dtDue());
3298 if ( to->hasDueDate() ) 3349 if ( to->hasDueDate() )
3299 tim = to->dtDue().time(); 3350 tim = to->dtDue().time();
3300 else { 3351 else {
3301 tim = QTime ( 0,0,0 ); 3352 tim = QTime ( 0,0,0 );
3302 to->setFloats( true ); 3353 to->setFloats( true );
3303 to->setHasDueDate( true ); 3354 to->setHasDueDate( true );
3304 } 3355 }
3305 QDateTime dt ( d,tim ); 3356 QDateTime dt ( d,tim );
3306 to->setDtDue( dt ); 3357 to->setDtDue( dt );
3307 3358
3308 if ( to->hasStartDate() ) { 3359 if ( to->hasStartDate() ) {
3309 if ( len>0 ) 3360 if ( len>0 )
3310 to->setDtStart(to->dtDue().addSecs( -len )); 3361 to->setDtStart(to->dtDue().addSecs( -len ));
3311 else 3362 else
3312 if (to->dtStart() > to->dtDue() ) 3363 if (to->dtStart() > to->dtDue() )
3313 to->setDtStart(to->dtDue().addDays( -3 )); 3364 to->setDtStart(to->dtDue().addDays( -3 ));
3314 } 3365 }
3315 3366
3316 todoChanged( to ); 3367 todoChanged( to );
3317 } else if ( mMoveIncidence->typeID() == eventID ) { 3368 } else if ( mMoveIncidence->typeID() == eventID ) {
3318 if ( mMoveIncidence->doesRecur() ) { 3369 if ( mMoveIncidence->doesRecur() ) {
3319#if 0 3370#if 0
3320 // PENDING implement this 3371 // PENDING implement this
3321 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3372 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3322 mCalendar()->addIncidence( newInc ); 3373 mCalendar()->addIncidence( newInc );
3323 if ( mMoveIncidence->typeID() == todoID ) 3374 if ( mMoveIncidence->typeID() == todoID )
3324 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3375 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3325 else 3376 else
3326 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3377 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3327 mMoveIncidence = newInc; 3378 mMoveIncidence = newInc;
3328 3379
3329#endif 3380#endif
3330 } 3381 }
3331 QTime tim = mMoveIncidence->dtStart().time(); 3382 QTime tim = mMoveIncidence->dtStart().time();
3332 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3383 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3333 QDateTime dt ( d,tim ); 3384 QDateTime dt ( d,tim );
3334 mMoveIncidence->setDtStart( dt ); 3385 mMoveIncidence->setDtStart( dt );
3335 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3386 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3336 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3387 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3337 } else if ( mMoveIncidence->typeID() == journalID ) { 3388 } else if ( mMoveIncidence->typeID() == journalID ) {
3338 QTime tim = mMoveIncidence->dtStart().time(); 3389 QTime tim = mMoveIncidence->dtStart().time();
3339 QDateTime dt ( d,tim ); 3390 QDateTime dt ( d,tim );
3340 mMoveIncidence->setDtStart( dt ); 3391 mMoveIncidence->setDtStart( dt );
3341 updateView(); 3392 updateView();
3342 } 3393 }
3343 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3394 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3344 } 3395 }
3345} 3396}
3346 3397
3347void CalendarView::removeCategories() 3398void CalendarView::removeCategories()
3348{ 3399{
3349 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3400 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3350 QStringList catList = KOPrefs::instance()->mCustomCategories; 3401 QStringList catList = KOPrefs::instance()->mCustomCategories;
3351 QStringList catIncList; 3402 QStringList catIncList;
3352 QStringList newCatList; 3403 QStringList newCatList;
3353 Incidence* inc = incList.first(); 3404 Incidence* inc = incList.first();
3354 uint i; 3405 uint i;
3355 while ( inc ) { 3406 while ( inc ) {
3356 newCatList.clear(); 3407 newCatList.clear();
3357 catIncList = inc->categories() ; 3408 catIncList = inc->categories() ;
3358 for( i = 0; i< catIncList.count(); ++i ) { 3409 for( i = 0; i< catIncList.count(); ++i ) {
3359 if ( catList.contains (catIncList[i])) 3410 if ( catList.contains (catIncList[i]))
3360 newCatList.append( catIncList[i] ); 3411 newCatList.append( catIncList[i] );
3361 } 3412 }
3362 newCatList.sort(); 3413 newCatList.sort();
3363 inc->setCategories( newCatList.join(",") ); 3414 inc->setCategories( newCatList.join(",") );
3364 inc = incList.next(); 3415 inc = incList.next();
3365 } 3416 }
3366} 3417}
3367 3418
3368int CalendarView::addCategories() 3419int CalendarView::addCategories()
3369{ 3420{
3370 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3421 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3371 QStringList catList = KOPrefs::instance()->mCustomCategories; 3422 QStringList catList = KOPrefs::instance()->mCustomCategories;
3372 QStringList catIncList; 3423 QStringList catIncList;
3373 Incidence* inc = incList.first(); 3424 Incidence* inc = incList.first();
3374 uint i; 3425 uint i;
3375 int count = 0; 3426 int count = 0;
3376 while ( inc ) { 3427 while ( inc ) {
3377 catIncList = inc->categories() ; 3428 catIncList = inc->categories() ;
3378 for( i = 0; i< catIncList.count(); ++i ) { 3429 for( i = 0; i< catIncList.count(); ++i ) {
3379 if ( !catList.contains (catIncList[i])) { 3430 if ( !catList.contains (catIncList[i])) {
3380 catList.append( catIncList[i] ); 3431 catList.append( catIncList[i] );
3381 //qDebug("add cat %s ", catIncList[i].latin1()); 3432 //qDebug("add cat %s ", catIncList[i].latin1());
3382 ++count; 3433 ++count;
3383 } 3434 }
3384 } 3435 }
3385 inc = incList.next(); 3436 inc = incList.next();
3386 } 3437 }
3387 catList.sort(); 3438 catList.sort();
3388 KOPrefs::instance()->mCustomCategories = catList; 3439 KOPrefs::instance()->mCustomCategories = catList;
3389 return count; 3440 return count;
3390} 3441}
3391 3442
3392void CalendarView::editCategories() 3443void CalendarView::editCategories()
3393{ 3444{
3394 qDebug("CalendarView::editCategories() "); 3445 qDebug("CalendarView::editCategories() ");
3395 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3446 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3396 ced.exec(); 3447 ced.exec();
3397} 3448}
3398void CalendarView::manageCategories() 3449void CalendarView::manageCategories()
3399{ 3450{
3400 KOCatPrefs* cp = new KOCatPrefs(); 3451 KOCatPrefs* cp = new KOCatPrefs();
3401 cp->show(); 3452 cp->show();
3402 int w =cp->sizeHint().width() ; 3453 int w =cp->sizeHint().width() ;
3403 int h = cp->sizeHint().height() ; 3454 int h = cp->sizeHint().height() ;
3404 int dw = QApplication::desktop()->width(); 3455 int dw = QApplication::desktop()->width();
3405 int dh = QApplication::desktop()->height(); 3456 int dh = QApplication::desktop()->height();
3406 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3457 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3407 if ( !cp->exec() ) { 3458 if ( !cp->exec() ) {
3408 delete cp; 3459 delete cp;
3409 return; 3460 return;
3410 } 3461 }
3411 int count = 0; 3462 int count = 0;
3412 if ( cp->addCat() ) { 3463 if ( cp->addCat() ) {
3413 count = addCategories(); 3464 count = addCategories();
3414 if ( count ) { 3465 if ( count ) {
3415 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3466 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3416 writeSettings(); 3467 writeSettings();
3417 } else 3468 } else
3418 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3469 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3419 } else { 3470 } else {
3420 removeCategories(); 3471 removeCategories();
3421 updateView(); 3472 updateView();
3422 } 3473 }
3423 delete cp; 3474 delete cp;
3424} 3475}
3425 3476
3426void CalendarView::beamIncidence(Incidence * Inc) 3477void CalendarView::beamIncidence(Incidence * Inc)
3427{ 3478{
3428 QPtrList<Incidence> delSel ; 3479 QPtrList<Incidence> delSel ;
3429 delSel.append(Inc); 3480 delSel.append(Inc);
3430 beamIncidenceList( delSel ); 3481 beamIncidenceList( delSel );
3431} 3482}
3432void CalendarView::beamCalendar() 3483void CalendarView::beamCalendar()
3433{ 3484{
3434 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3485 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3435 //qDebug("beamCalendar() "); 3486 //qDebug("beamCalendar() ");
3436 beamIncidenceList( delSel ); 3487 beamIncidenceList( delSel );
3437} 3488}
3438void CalendarView::beamFilteredCalendar() 3489void CalendarView::beamFilteredCalendar()
3439{ 3490{
3440 QPtrList<Incidence> delSel = mCalendar->incidences(); 3491 QPtrList<Incidence> delSel = mCalendar->incidences();
3441 //qDebug("beamFilteredCalendar() "); 3492 //qDebug("beamFilteredCalendar() ");
3442 beamIncidenceList( delSel ); 3493 beamIncidenceList( delSel );
3443} 3494}
3444void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3495void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3445{ 3496{
3446 3497
3447 KOBeamPrefs beamDialog; 3498 KOBeamPrefs beamDialog;
3448 if ( beamDialog.exec () == QDialog::Rejected ) 3499 if ( beamDialog.exec () == QDialog::Rejected )
3449 return; 3500 return;
3450#ifdef DESKTOP_VERSION 3501#ifdef DESKTOP_VERSION
3451 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3502 QString fn = locateLocal( "tmp", "kopibeamfile" );
3452#else 3503#else
3453 QString fn = "/tmp/kopibeamfile"; 3504 QString fn = "/tmp/kopibeamfile";
3454#endif 3505#endif
3455 QString mes; 3506 QString mes;
3456 bool createbup = true; 3507 bool createbup = true;
3457 if ( createbup ) { 3508 if ( createbup ) {
3458 QString description = "\n"; 3509 QString description = "\n";
3459 CalendarLocal* cal = new CalendarLocal(); 3510 CalendarLocal* cal = new CalendarLocal();
3460 if ( beamDialog.beamLocal() ) 3511 if ( beamDialog.beamLocal() )
3461 cal->setLocalTime(); 3512 cal->setLocalTime();
3462 else 3513 else
3463 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3514 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3464 Incidence *incidence = delSel.first(); 3515 Incidence *incidence = delSel.first();
3465 bool addText = false; 3516 bool addText = false;
3466 if ( delSel.count() < 10 ) 3517 if ( delSel.count() < 10 )
3467 addText = true; 3518 addText = true;
3468 else { 3519 else {
3469 description.sprintf(i18n(" %d items?"),delSel.count() ); 3520 description.sprintf(i18n(" %d items?"),delSel.count() );
3470 } 3521 }
3471 while ( incidence ) { 3522 while ( incidence ) {
3472 Incidence *in = incidence->clone(); 3523 Incidence *in = incidence->clone();
3473 if ( ! in->summary().isEmpty() ) { 3524 if ( ! in->summary().isEmpty() ) {
3474 in->setDescription(""); 3525 in->setDescription("");
3475 } else { 3526 } else {
3476 in->setSummary( in->description().left(20)); 3527 in->setSummary( in->description().left(20));
3477 in->setDescription(""); 3528 in->setDescription("");
3478 } 3529 }
3479 if ( addText ) 3530 if ( addText )
3480 description += in->summary() + "\n"; 3531 description += in->summary() + "\n";
3481 cal->addIncidence( in ); 3532 cal->addIncidence( in );
3482 incidence = delSel.next(); 3533 incidence = delSel.next();
3483 } 3534 }
3484 if ( beamDialog.beamVcal() ) { 3535 if ( beamDialog.beamVcal() ) {
3485 fn += ".vcs"; 3536 fn += ".vcs";
3486 FileStorage storage( cal, fn, new VCalFormat ); 3537 FileStorage storage( cal, fn, new VCalFormat );
3487 storage.save(); 3538 storage.save();
3488 } else { 3539 } else {
3489 fn += ".ics"; 3540 fn += ".ics";
3490 FileStorage storage( cal, fn, new ICalFormat( ) ); 3541 FileStorage storage( cal, fn, new ICalFormat( ) );
3491 storage.save(); 3542 storage.save();
3492 } 3543 }
3493 delete cal; 3544 delete cal;
3494 mes = i18n("KO/Pi: Ready for beaming"); 3545 mes = i18n("KO/Pi: Ready for beaming");
3495 topLevelWidget()->setCaption(mes); 3546 topLevelWidget()->setCaption(mes);
3496 KApplication::convert2latin1( fn ); 3547 KApplication::convert2latin1( fn );
3497#ifndef DESKTOP_VERSION 3548#ifndef DESKTOP_VERSION
3498 Ir *ir = new Ir( this ); 3549 Ir *ir = new Ir( this );
3499 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3550 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3500 ir->send( fn, description, "text/x-vCalendar" ); 3551 ir->send( fn, description, "text/x-vCalendar" );
3501#endif 3552#endif
3502 } 3553 }
3503} 3554}
3504 3555
3505#ifndef DESKTOP_VERSION 3556#ifndef DESKTOP_VERSION
3506void CalendarView::beamDone( Ir *ir ) 3557void CalendarView::beamDone( Ir *ir )
3507{ 3558{
3508 delete ir; 3559 delete ir;
3509 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3560 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3510 topLevelWidget()->raise(); 3561 topLevelWidget()->raise();
3511} 3562}
3512#else 3563#else
3513void CalendarView::beamDone( Ir *){;} 3564void CalendarView::beamDone( Ir *){;}
3514#endif 3565#endif
3515void CalendarView::moveIncidence(Incidence * inc ) 3566void CalendarView::moveIncidence(Incidence * inc )
3516{ 3567{
3517 if ( !inc ) return; 3568 if ( !inc ) return;
3518 showDatePickerPopup(); 3569 showDatePickerPopup();
3519 mDatePickerMode = 2; 3570 mDatePickerMode = 2;
3520 mMoveIncidence = inc ; 3571 mMoveIncidence = inc ;
3521 QDate da; 3572 QDate da;
3522 if ( mMoveIncidence->typeID() == todoID ) { 3573 if ( mMoveIncidence->typeID() == todoID ) {
3523 Todo * to = (Todo *) mMoveIncidence; 3574 Todo * to = (Todo *) mMoveIncidence;
3524 if ( to->hasDueDate() ) 3575 if ( to->hasDueDate() )
3525 da = to->dtDue().date(); 3576 da = to->dtDue().date();
3526 else 3577 else
3527 da = QDate::currentDate(); 3578 da = QDate::currentDate();
3528 } else { 3579 } else {
3529 da = mMoveIncidence->dtStart().date(); 3580 da = mMoveIncidence->dtStart().date();
3530 } 3581 }
3531 //PENDING set date for recurring incidence to date of recurrence 3582 //PENDING set date for recurring incidence to date of recurrence
3532 //mMoveIncidenceOldDate; 3583 //mMoveIncidenceOldDate;
3533 mDatePicker->setDate( da ); 3584 mDatePicker->setDate( da );
3534} 3585}
3535void CalendarView::showDatePickerPopup() 3586void CalendarView::showDatePickerPopup()
3536{ 3587{
3537 if ( mDateFrame->isVisible() ) 3588 if ( mDateFrame->isVisible() )
3538 mDateFrame->hide(); 3589 mDateFrame->hide();
3539 else { 3590 else {
3540 int offX = 0, offY = 0; 3591 int offX = 0, offY = 0;
3541#ifdef DESKTOP_VERSION 3592#ifdef DESKTOP_VERSION
3542 int w =mDatePicker->sizeHint().width() ; 3593 int w =mDatePicker->sizeHint().width() ;
3543 int h = mDatePicker->sizeHint().height() ; 3594 int h = mDatePicker->sizeHint().height() ;
3544 int dw = topLevelWidget()->width(); 3595 int dw = topLevelWidget()->width();
3545 int dh = topLevelWidget()->height(); 3596 int dh = topLevelWidget()->height();
3546 offX = topLevelWidget()->x(); 3597 offX = topLevelWidget()->x();
3547 offY = topLevelWidget()->y(); 3598 offY = topLevelWidget()->y();
3548#else 3599#else
3549 int w =mDatePicker->sizeHint().width() ; 3600 int w =mDatePicker->sizeHint().width() ;
3550 int h = mDatePicker->sizeHint().height() ; 3601 int h = mDatePicker->sizeHint().height() ;
3551 int dw = QApplication::desktop()->width(); 3602 int dw = QApplication::desktop()->width();
3552 int dh = QApplication::desktop()->height(); 3603 int dh = QApplication::desktop()->height();
3553#endif 3604#endif
3554 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3605 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3555 mDateFrame->show(); 3606 mDateFrame->show();
3556 } 3607 }
3557} 3608}
3558void CalendarView::showDatePicker( ) 3609void CalendarView::showDatePicker( )
3559{ 3610{
3560 showDatePickerPopup(); 3611 showDatePickerPopup();
3561 mDatePickerMode = 1; 3612 mDatePickerMode = 1;
3562 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3613 mDatePicker->setDate( mNavigator->selectedDates().first() );
3563} 3614}
3564 3615
3565void CalendarView::showEventEditor() 3616void CalendarView::showEventEditor()
3566{ 3617{
3567#ifdef DESKTOP_VERSION 3618#ifdef DESKTOP_VERSION
3568 int x,y,w,h; 3619 int x,y,w,h;
3569 x = mEventEditor->geometry().x(); 3620 x = mEventEditor->geometry().x();
3570 y = mEventEditor->geometry().y(); 3621 y = mEventEditor->geometry().y();
3571 w = mEventEditor->width(); 3622 w = mEventEditor->width();
3572 h = mEventEditor->height(); 3623 h = mEventEditor->height();
3573 mEventEditor->show(); 3624 mEventEditor->show();
3574 mEventEditor->setGeometry(x,y,w,h); 3625 mEventEditor->setGeometry(x,y,w,h);
3575#else 3626#else
3576 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3627 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3577 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3628 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3578 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3629 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3579 qApp->processEvents(); 3630 qApp->processEvents();
3580 delete mEventEditor; 3631 delete mEventEditor;
3581 mEventEditor = mDialogManager->getEventEditor(); 3632 mEventEditor = mDialogManager->getEventEditor();
3582 topLevelWidget()->setCaption( i18n("") ); 3633 topLevelWidget()->setCaption( i18n("") );
3583 } 3634 }
3584 mEventEditor->showMaximized(); 3635 mEventEditor->showMaximized();
3585#endif 3636#endif
3586} 3637}
3587void CalendarView::showTodoEditor() 3638void CalendarView::showTodoEditor()
3588{ 3639{
3589#ifdef DESKTOP_VERSION 3640#ifdef DESKTOP_VERSION
3590 int x,y,w,h; 3641 int x,y,w,h;
3591 x = mTodoEditor->geometry().x(); 3642 x = mTodoEditor->geometry().x();
3592 y = mTodoEditor->geometry().y(); 3643 y = mTodoEditor->geometry().y();
3593 w = mTodoEditor->width(); 3644 w = mTodoEditor->width();
3594 h = mTodoEditor->height(); 3645 h = mTodoEditor->height();
3595 mTodoEditor->show(); 3646 mTodoEditor->show();
3596 mTodoEditor->setGeometry(x,y,w,h); 3647 mTodoEditor->setGeometry(x,y,w,h);
3597#else 3648#else
3598 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3649 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3599 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3650 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3600 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3651 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3601 qApp->processEvents(); 3652 qApp->processEvents();
3602 delete mTodoEditor; 3653 delete mTodoEditor;
3603 mTodoEditor = mDialogManager->getTodoEditor(); 3654 mTodoEditor = mDialogManager->getTodoEditor();
3604 topLevelWidget()->setCaption( i18n("") ); 3655 topLevelWidget()->setCaption( i18n("") );
3605 } 3656 }
3606 mTodoEditor->showMaximized(); 3657 mTodoEditor->showMaximized();
3607#endif 3658#endif
3608} 3659}
3609 3660
3610void CalendarView::cloneIncidence() 3661void CalendarView::cloneIncidence()
3611{ 3662{
3612 Incidence *incidence = currentSelection(); 3663 Incidence *incidence = currentSelection();
3613 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3664 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3614 if ( incidence ) { 3665 if ( incidence ) {
3615 cloneIncidence(incidence); 3666 cloneIncidence(incidence);
3616 } 3667 }
3617} 3668}
3618void CalendarView::moveIncidence() 3669void CalendarView::moveIncidence()
3619{ 3670{
3620 Incidence *incidence = currentSelection(); 3671 Incidence *incidence = currentSelection();
3621 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3672 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3622 if ( incidence ) { 3673 if ( incidence ) {
3623 moveIncidence(incidence); 3674 moveIncidence(incidence);
3624 } 3675 }
3625} 3676}
3626void CalendarView::beamIncidence() 3677void CalendarView::beamIncidence()
3627{ 3678{
3628 Incidence *incidence = currentSelection(); 3679 Incidence *incidence = currentSelection();
3629 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3680 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3630 if ( incidence ) { 3681 if ( incidence ) {
3631 beamIncidence(incidence); 3682 beamIncidence(incidence);
3632 } 3683 }
3633} 3684}
3634void CalendarView::toggleCancelIncidence() 3685void CalendarView::toggleCancelIncidence()
3635{ 3686{
3636 Incidence *incidence = currentSelection(); 3687 Incidence *incidence = currentSelection();
3637 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3688 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3638 if ( incidence ) { 3689 if ( incidence ) {
3639 cancelIncidence(incidence); 3690 cancelIncidence(incidence);
3640 } 3691 }
3641} 3692}
3642 3693
3643 3694
3644void CalendarView::cancelIncidence(Incidence * inc ) 3695void CalendarView::cancelIncidence(Incidence * inc )
3645{ 3696{
3646 inc->setCancelled( ! inc->cancelled() ); 3697 inc->setCancelled( ! inc->cancelled() );
3647 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3698 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3648 updateView(); 3699 updateView();
3649} 3700}
3650void CalendarView::cloneIncidence(Incidence * orgInc ) 3701void CalendarView::cloneIncidence(Incidence * orgInc )
3651{ 3702{
3652 Incidence * newInc = orgInc->clone(); 3703 Incidence * newInc = orgInc->clone();
3653 newInc->recreate(); 3704 newInc->recreate();
3654 3705
3655 if ( newInc->typeID() == todoID ) { 3706 if ( newInc->typeID() == todoID ) {
3656 Todo* t = (Todo*) newInc; 3707 Todo* t = (Todo*) newInc;
3657 bool cloneSub = false; 3708 bool cloneSub = false;
3658 if ( orgInc->relations().count() ) { 3709 if ( orgInc->relations().count() ) {
3659 int result = KMessageBox::warningYesNoCancel(this, 3710 int result = KMessageBox::warningYesNoCancel(this,
3660 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 ) ), 3711 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 ) ),
3661 i18n("Todo has subtodos"), 3712 i18n("Todo has subtodos"),
3662 i18n("Yes"), 3713 i18n("Yes"),
3663 i18n("No")); 3714 i18n("No"));
3664 3715
3665 if ( result == KMessageBox::Cancel ) { 3716 if ( result == KMessageBox::Cancel ) {
3666 delete t; 3717 delete t;
3667 return; 3718 return;
3668 } 3719 }
3669 if (result == KMessageBox::Yes) cloneSub = true; 3720 if (result == KMessageBox::Yes) cloneSub = true;
3670 } 3721 }
3671 showTodoEditor(); 3722 showTodoEditor();
3672 mTodoEditor->editTodo( t ); 3723 mTodoEditor->editTodo( t );
3673 if ( mTodoEditor->exec() ) { 3724 if ( mTodoEditor->exec() ) {
3674 if ( cloneSub ) { 3725 if ( cloneSub ) {
3675 orgInc->cloneRelations( t ); 3726 orgInc->cloneRelations( t );
3676 mCalendar->addIncidenceBranch( t ); 3727 mCalendar->addIncidenceBranch( t );
3677 updateView(); 3728 updateView();
3678 3729
3679 } else { 3730 } else {
3680 mCalendar->addTodo( t ); 3731 mCalendar->addTodo( t );
3681 updateView(); 3732 updateView();
3682 } 3733 }
3683 } else { 3734 } else {
3684 delete t; 3735 delete t;
3685 } 3736 }
3686 } 3737 }
3687 else if ( newInc->typeID() == eventID ) { 3738 else if ( newInc->typeID() == eventID ) {
3688 Event* e = (Event*) newInc; 3739 Event* e = (Event*) newInc;
3689 showEventEditor(); 3740 showEventEditor();
3690 mEventEditor->editEvent( e ); 3741 mEventEditor->editEvent( e );
3691 if ( mEventEditor->exec() ) { 3742 if ( mEventEditor->exec() ) {
3692 mCalendar->addEvent( e ); 3743 mCalendar->addEvent( e );
3693 updateView(); 3744 updateView();
3694 } else { 3745 } else {
3695 delete e; 3746 delete e;
3696 } 3747 }
3697 } else if ( newInc->typeID() == journalID ) { 3748 } else if ( newInc->typeID() == journalID ) {
3698 mCalendar->addJournal( (Journal*) newInc ); 3749 mCalendar->addJournal( (Journal*) newInc );
3699 editJournal( (Journal*) newInc ); 3750 editJournal( (Journal*) newInc );
3700 } 3751 }
3701 setActiveWindow(); 3752 setActiveWindow();
3702} 3753}
3703 3754
3704void CalendarView::newEvent() 3755void CalendarView::newEvent()
3705{ 3756{
3706 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3757 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3707 KOAgendaView *aView = mViewManager->agendaView(); 3758 KOAgendaView *aView = mViewManager->agendaView();
3708 if (aView) { 3759 if (aView) {
3709 if (aView->selectionStart().isValid()) { 3760 if (aView->selectionStart().isValid()) {
3710 if (aView->selectedIsAllDay()) { 3761 if (aView->selectedIsAllDay()) {
3711 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3762 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3712 } else { 3763 } else {
3713 newEvent(aView->selectionStart(),aView->selectionEnd()); 3764 newEvent(aView->selectionStart(),aView->selectionEnd());
3714 } 3765 }
3715 return; 3766 return;
3716 } 3767 }
3717 } 3768 }
3718 3769
3719 QDate date = mNavigator->selectedDates().first(); 3770 QDate date = mNavigator->selectedDates().first();
3720#if 0 3771#if 0
3721 QDateTime current = QDateTime::currentDateTime(); 3772 QDateTime current = QDateTime::currentDateTime();
3722 if ( date <= current.date() ) { 3773 if ( date <= current.date() ) {
3723 int hour = current.time().hour() +1; 3774 int hour = current.time().hour() +1;
3724 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3775 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3725 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3776 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3726 } else 3777 } else
3727#endif 3778#endif
3728 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3779 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3729 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3780 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3730 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3781 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3731} 3782}
3732 3783
3733void CalendarView::newEvent(QDateTime fh) 3784void CalendarView::newEvent(QDateTime fh)
3734{ 3785{
3735 newEvent(fh, 3786 newEvent(fh,
3736 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3787 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3737} 3788}
3738 3789
3739void CalendarView::newEvent(QDate dt) 3790void CalendarView::newEvent(QDate dt)
3740{ 3791{
3741 newEvent(QDateTime(dt, QTime(0,0,0)), 3792 newEvent(QDateTime(dt, QTime(0,0,0)),
3742 QDateTime(dt, QTime(0,0,0)), true); 3793 QDateTime(dt, QTime(0,0,0)), true);
3743} 3794}
3744void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3795void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3745{ 3796{
3746 newEvent(fromHint, toHint, false); 3797 newEvent(fromHint, toHint, false);
3747} 3798}
3748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3799void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3749{ 3800{
3750 3801
3751 showEventEditor(); 3802 showEventEditor();
3752 mEventEditor->newEvent(fromHint,toHint,allDay); 3803 mEventEditor->newEvent(fromHint,toHint,allDay);
3753 if ( mFilterView->filtersEnabled() ) { 3804 if ( mFilterView->filtersEnabled() ) {
3754 CalFilter *filter = mFilterView->selectedFilter(); 3805 CalFilter *filter = mFilterView->selectedFilter();
3755 if (filter && filter->showCategories()) { 3806 if (filter && filter->showCategories()) {
3756 mEventEditor->setCategories(filter->categoryList().join(",") ); 3807 mEventEditor->setCategories(filter->categoryList().join(",") );
3757 } 3808 }
3758 if ( filter ) 3809 if ( filter )
3759 mEventEditor->setSecrecy( filter->getSecrecy() ); 3810 mEventEditor->setSecrecy( filter->getSecrecy() );
3760 } 3811 }
3761 mEventEditor->exec(); 3812 mEventEditor->exec();
3762 setActiveWindow(); 3813 setActiveWindow();
3763} 3814}
3764void CalendarView::todoAdded(Todo * t) 3815void CalendarView::todoAdded(Todo * t)
3765{ 3816{
3766 3817
3767 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3818 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3768 updateTodoViews(); 3819 updateTodoViews();
3769} 3820}
3770void CalendarView::todoChanged(Todo * t) 3821void CalendarView::todoChanged(Todo * t)
3771{ 3822{
3772 emit todoModified( t, 4 ); 3823 emit todoModified( t, 4 );
3773 // updateTodoViews(); 3824 // updateTodoViews();
3774} 3825}
3775void CalendarView::todoToBeDeleted(Todo *) 3826void CalendarView::todoToBeDeleted(Todo *)
3776{ 3827{
3777 //qDebug("todoToBeDeleted(Todo *) "); 3828 //qDebug("todoToBeDeleted(Todo *) ");
3778 updateTodoViews(); 3829 updateTodoViews();
3779} 3830}
3780void CalendarView::todoDeleted() 3831void CalendarView::todoDeleted()
3781{ 3832{
3782 //qDebug(" todoDeleted()"); 3833 //qDebug(" todoDeleted()");
3783 updateTodoViews(); 3834 updateTodoViews();
3784} 3835}
3785 3836
3786 3837
3787void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3838void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3788{ 3839{
3789 showTodoEditor(); 3840 showTodoEditor();
3790 mTodoEditor->newTodo(dt,0,allday); 3841 mTodoEditor->newTodo(dt,0,allday);
3791 if ( mFilterView->filtersEnabled() ) { 3842 if ( mFilterView->filtersEnabled() ) {
3792 CalFilter *filter = mFilterView->selectedFilter(); 3843 CalFilter *filter = mFilterView->selectedFilter();
3793 if (filter && filter->showCategories()) { 3844 if (filter && filter->showCategories()) {
3794 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3845 mTodoEditor->setCategories(filter->categoryList().join(",") );
3795 } 3846 }
3796 if ( filter ) 3847 if ( filter )
3797 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3848 mTodoEditor->setSecrecy( filter->getSecrecy() );
3798 } 3849 }
3799 mTodoEditor->exec(); 3850 mTodoEditor->exec();
3800 setActiveWindow(); 3851 setActiveWindow();
3801} 3852}
3802 3853
3803void CalendarView::newTodo() 3854void CalendarView::newTodo()
3804{ 3855{
3805 newTodoDateTime( QDateTime(),true ); 3856 newTodoDateTime( QDateTime(),true );
3806} 3857}
3807 3858
3808void CalendarView::newSubTodo() 3859void CalendarView::newSubTodo()
3809{ 3860{
3810 Todo *todo = selectedTodo(); 3861 Todo *todo = selectedTodo();
3811 if ( todo ) newSubTodo( todo ); 3862 if ( todo ) newSubTodo( todo );
3812} 3863}
3813 3864
3814void CalendarView::newSubTodo(Todo *parentEvent) 3865void CalendarView::newSubTodo(Todo *parentEvent)
3815{ 3866{
3816 3867
3817 showTodoEditor(); 3868 showTodoEditor();
3818 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3869 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3819 mTodoEditor->exec(); 3870 mTodoEditor->exec();
3820 setActiveWindow(); 3871 setActiveWindow();
3821} 3872}
3822 3873
3823void CalendarView::newFloatingEvent() 3874void CalendarView::newFloatingEvent()
3824{ 3875{
3825 DateList tmpList = mNavigator->selectedDates(); 3876 DateList tmpList = mNavigator->selectedDates();
3826 QDate date = tmpList.first(); 3877 QDate date = tmpList.first();
3827 3878
3828 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3879 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3829 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3880 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3830} 3881}
3831 3882
3832 3883
3833void CalendarView::editEvent( Event *event ) 3884void CalendarView::editEvent( Event *event )
3834{ 3885{
3835 3886
3836 if ( !event ) return; 3887 if ( !event ) return;
3837 if ( event->isReadOnly() ) { 3888 if ( event->isReadOnly() ) {
3838 showEvent( event ); 3889 showEvent( event );
3839 return; 3890 return;
3840 } 3891 }
3841 showEventEditor(); 3892 showEventEditor();
3842 mEventEditor->editEvent( event , mFlagEditDescription); 3893 mEventEditor->editEvent( event , mFlagEditDescription);
3843 mEventEditor->exec(); 3894 mEventEditor->exec();
3844 setActiveWindow(); 3895 setActiveWindow();
3845 3896
3846} 3897}
3847void CalendarView::editJournal( Journal *jour ) 3898void CalendarView::editJournal( Journal *jour )
3848{ 3899{
3849 if ( !jour ) return; 3900 if ( !jour ) return;
3850 mDialogManager->hideSearchDialog(); 3901 mDialogManager->hideSearchDialog();
3851 mViewManager->showJournalView(); 3902 mViewManager->showJournalView();
3852 mNavigator->slotDaySelect( jour->dtStart().date() ); 3903 mNavigator->slotDaySelect( jour->dtStart().date() );
3853} 3904}
3854void CalendarView::editTodo( Todo *todo ) 3905void CalendarView::editTodo( Todo *todo )
3855{ 3906{
3856 if ( !todo ) return; 3907 if ( !todo ) return;
3857 3908
3858 if ( todo->isReadOnly() ) { 3909 if ( todo->isReadOnly() ) {
3859 showTodo( todo ); 3910 showTodo( todo );
3860 return; 3911 return;
3861 } 3912 }
3862 showTodoEditor(); 3913 showTodoEditor();
3863 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3914 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3864 mTodoEditor->exec(); 3915 mTodoEditor->exec();
3865 setActiveWindow(); 3916 setActiveWindow();
3866 3917
3867} 3918}
3868 3919
3869KOEventViewerDialog* CalendarView::getEventViewerDialog() 3920KOEventViewerDialog* CalendarView::getEventViewerDialog()
3870{ 3921{
3871 if ( !mEventViewerDialog ) { 3922 if ( !mEventViewerDialog ) {
3872 mEventViewerDialog = new KOEventViewerDialog(0); 3923 mEventViewerDialog = new KOEventViewerDialog(0);
3873 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3924 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3874 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3925 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3875 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3926 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3876 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3927 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3877 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3928 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3878 viewManager(), SLOT( showAgendaView( bool ) ) ); 3929 viewManager(), SLOT( showAgendaView( bool ) ) );
3879 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3930 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3880 this, SLOT( slotViewerClosed() ) ); 3931 this, SLOT( slotViewerClosed() ) );
3881 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3932 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3882 this, SLOT( todoChanged(Todo *) ) ); 3933 this, SLOT( todoChanged(Todo *) ) );
3883 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3934 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3884 mEventViewerDialog->resize( 640, 480 ); 3935 mEventViewerDialog->resize( 640, 480 );
3885 3936
3886 } 3937 }
3887 return mEventViewerDialog; 3938 return mEventViewerDialog;
3888} 3939}
3889void CalendarView::showEvent(Event *event) 3940void CalendarView::showEvent(Event *event)
3890{ 3941{
3891 getEventViewerDialog()->setEvent(event); 3942 getEventViewerDialog()->setEvent(event);
3892 getEventViewerDialog()->showMe(); 3943 getEventViewerDialog()->showMe();
3893} 3944}
3894 3945
3895void CalendarView::showTodo(Todo *event) 3946void CalendarView::showTodo(Todo *event)
3896{ 3947{
3897 getEventViewerDialog()->setTodo(event); 3948 getEventViewerDialog()->setTodo(event);
3898 getEventViewerDialog()->showMe(); 3949 getEventViewerDialog()->showMe();
3899} 3950}
3900void CalendarView::showJournal( Journal *jour ) 3951void CalendarView::showJournal( Journal *jour )
3901{ 3952{
3902 getEventViewerDialog()->setJournal(jour); 3953 getEventViewerDialog()->setJournal(jour);
3903 getEventViewerDialog()->showMe(); 3954 getEventViewerDialog()->showMe();
3904 3955
3905} 3956}
3906// void CalendarView::todoModified (Todo *event, int changed) 3957// void CalendarView::todoModified (Todo *event, int changed)
3907// { 3958// {
3908// // if (mDialogList.find (event) != mDialogList.end ()) { 3959// // if (mDialogList.find (event) != mDialogList.end ()) {
3909// // kdDebug() << "Todo modified and open" << endl; 3960// // kdDebug() << "Todo modified and open" << endl;
3910// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3961// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3911// // temp->modified (changed); 3962// // temp->modified (changed);
3912 3963
3913// // } 3964// // }
3914 3965
3915// mViewManager->updateView(); 3966// mViewManager->updateView();
3916// } 3967// }
3917 3968
3918void CalendarView::appointment_show() 3969void CalendarView::appointment_show()
3919{ 3970{
3920 Event *anEvent = 0; 3971 Event *anEvent = 0;
3921 3972
3922 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3973 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3923 3974
3924 if (mViewManager->currentView()->isEventView()) { 3975 if (mViewManager->currentView()->isEventView()) {
3925 if ( incidence && incidence->typeID() == eventID ) { 3976 if ( incidence && incidence->typeID() == eventID ) {
3926 anEvent = static_cast<Event *>(incidence); 3977 anEvent = static_cast<Event *>(incidence);
3927 } 3978 }
3928 } 3979 }
3929 3980
3930 if (!anEvent) { 3981 if (!anEvent) {
3931 KNotifyClient::beep(); 3982 KNotifyClient::beep();
3932 return; 3983 return;
3933 } 3984 }
3934 3985
3935 showEvent(anEvent); 3986 showEvent(anEvent);
3936} 3987}
3937 3988
3938void CalendarView::appointment_edit() 3989void CalendarView::appointment_edit()
3939{ 3990{
3940 Event *anEvent = 0; 3991 Event *anEvent = 0;
3941 3992
3942 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3993 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3943 3994
3944 if (mViewManager->currentView()->isEventView()) { 3995 if (mViewManager->currentView()->isEventView()) {
3945 if ( incidence && incidence->typeID() == eventID ) { 3996 if ( incidence && incidence->typeID() == eventID ) {
3946 anEvent = static_cast<Event *>(incidence); 3997 anEvent = static_cast<Event *>(incidence);
3947 } 3998 }
3948 } 3999 }
3949 4000
3950 if (!anEvent) { 4001 if (!anEvent) {
3951 KNotifyClient::beep(); 4002 KNotifyClient::beep();
3952 return; 4003 return;
3953 } 4004 }
3954 4005
3955 editEvent(anEvent); 4006 editEvent(anEvent);
3956} 4007}
3957 4008
3958void CalendarView::appointment_delete() 4009void CalendarView::appointment_delete()
3959{ 4010{
3960 Event *anEvent = 0; 4011 Event *anEvent = 0;
3961 4012
3962 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 4013 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3963 4014
3964 if (mViewManager->currentView()->isEventView()) { 4015 if (mViewManager->currentView()->isEventView()) {
3965 if ( incidence && incidence->typeID() == eventID ) { 4016 if ( incidence && incidence->typeID() == eventID ) {
3966 anEvent = static_cast<Event *>(incidence); 4017 anEvent = static_cast<Event *>(incidence);
3967 } 4018 }
3968 } 4019 }
3969 4020
3970 if (!anEvent) { 4021 if (!anEvent) {
3971 KNotifyClient::beep(); 4022 KNotifyClient::beep();
3972 return; 4023 return;
3973 } 4024 }
3974 4025
3975 deleteEvent(anEvent); 4026 deleteEvent(anEvent);
3976} 4027}
3977 4028
3978void CalendarView::todo_resub( Todo * parent, Todo * sub ) 4029void CalendarView::todo_resub( Todo * parent, Todo * sub )
3979{ 4030{
3980 if (!sub) return; 4031 if (!sub) return;
3981 if ( sub->relatedTo() == parent ) 4032 if ( sub->relatedTo() == parent )
3982 return; 4033 return;
3983 sub->setRelatedTo(parent); 4034 sub->setRelatedTo(parent);
3984 sub->updated(); 4035 sub->updated();
3985 setModified(true); 4036 setModified(true);
3986 updateView(); 4037 updateView();
3987} 4038}
3988void CalendarView::todo_unsub(Todo *anTodo ) 4039void CalendarView::todo_unsub(Todo *anTodo )
3989{ 4040{
3990 todo_resub( 0, anTodo ); 4041 todo_resub( 0, anTodo );
3991} 4042}
3992 4043
3993void CalendarView::deleteTodo(Todo *todo) 4044void CalendarView::deleteTodo(Todo *todo)
3994{ 4045{
3995 if (!todo) { 4046 if (!todo) {
3996 KNotifyClient::beep(); 4047 KNotifyClient::beep();
3997 return; 4048 return;
3998 } 4049 }
3999 if (KOPrefs::instance()->mConfirm) { 4050 if (KOPrefs::instance()->mConfirm) {
4000 QString text = KGlobal::formatMessage ( todo->summary(),0 ); 4051 QString text = KGlobal::formatMessage ( todo->summary(),0 );
4001 if (!todo->relations().isEmpty()) { 4052 if (!todo->relations().isEmpty()) {
4002 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 4053 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
4003 4054
4004 } 4055 }
4005 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { 4056 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
4006 case KMessageBox::Continue: // OK 4057 case KMessageBox::Continue: // OK
4007 bool deleteT = false; 4058 bool deleteT = false;
4008 if (!todo->relations().isEmpty()) { 4059 if (!todo->relations().isEmpty()) {
4009 deleteT = removeCompletedSubTodos( todo ); 4060 deleteT = removeCompletedSubTodos( todo );
4010 } 4061 }
4011 // deleteT == true: todo already deleted in removeCompletedSubTodos 4062 // deleteT == true: todo already deleted in removeCompletedSubTodos
4012 if ( !deleteT ) { 4063 if ( !deleteT ) {
4013 checkExternalId( todo ); 4064 checkExternalId( todo );
4014 calendar()->deleteTodo(todo); 4065 calendar()->deleteTodo(todo);
4015 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4066 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4016 } 4067 }
4017 updateView(); 4068 updateView();
4018 break; 4069 break;
4019 } // switch 4070 } // switch
4020 } else { 4071 } else {
4021 checkExternalId( todo ); 4072 checkExternalId( todo );
4022 mCalendar->deleteTodo(todo); 4073 mCalendar->deleteTodo(todo);
4023 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4074 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4024 updateView(); 4075 updateView();
4025 } 4076 }
4026 4077
4027 emit updateSearchDialog(); 4078 emit updateSearchDialog();
4028} 4079}
4029void CalendarView::deleteJournal(Journal *jour) 4080void CalendarView::deleteJournal(Journal *jour)
4030{ 4081{
4031 if (!jour) { 4082 if (!jour) {
4032 KNotifyClient::beep(); 4083 KNotifyClient::beep();
4033 return; 4084 return;
4034 } 4085 }
4035 if (KOPrefs::instance()->mConfirm) { 4086 if (KOPrefs::instance()->mConfirm) {
4036 4087
4037 QString des; 4088 QString des;
4038 if ( !jour->summary().isEmpty() ) { 4089 if ( !jour->summary().isEmpty() ) {
4039 des = jour->summary(); 4090 des = jour->summary();
4040 } else { 4091 } else {
4041 des = jour->description().left(30); 4092 des = jour->description().left(30);
4042 des = des.simplifyWhiteSpace (); 4093 des = des.simplifyWhiteSpace ();
4043 des.replace (QRegExp ("\\n"),"" ); 4094 des.replace (QRegExp ("\\n"),"" );
4044 des.replace (QRegExp ("\\r"),"" ); 4095 des.replace (QRegExp ("\\r"),"" );
4045 } 4096 }
4046 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { 4097 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
4047 case KMessageBox::Continue: // OK 4098 case KMessageBox::Continue: // OK
4048 calendar()->deleteJournal(jour); 4099 calendar()->deleteJournal(jour);
4049 updateView(); 4100 updateView();
4050 break; 4101 break;
4051 } // switch 4102 } // switch
4052 } else { 4103 } else {
4053 calendar()->deleteJournal(jour);; 4104 calendar()->deleteJournal(jour);;
4054 updateView(); 4105 updateView();
4055 } 4106 }
4056 emit updateSearchDialog(); 4107 emit updateSearchDialog();
4057} 4108}
4058 4109
4059void CalendarView::deleteEvent(Event *anEvent) 4110void CalendarView::deleteEvent(Event *anEvent)
4060{ 4111{
4061 if (!anEvent) { 4112 if (!anEvent) {
4062 KNotifyClient::beep(); 4113 KNotifyClient::beep();
4063 return; 4114 return;
4064 } 4115 }
4065 4116
4066 if (anEvent->doesRecur()) { 4117 if (anEvent->doesRecur()) {
4067 QDate itemDate = mViewManager->currentSelectionDate(); 4118 QDate itemDate = mViewManager->currentSelectionDate();
4068 int km; 4119 int km;
4069 if (!itemDate.isValid()) { 4120 if (!itemDate.isValid()) {
4070 //kdDebug() << "Date Not Valid" << endl; 4121 //kdDebug() << "Date Not Valid" << endl;
4071 if (KOPrefs::instance()->mConfirm) { 4122 if (KOPrefs::instance()->mConfirm) {
4072 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4123 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4073 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 4124 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
4074 i18n("KO/Pi Confirmation"),i18n("Delete All")); 4125 i18n("KO/Pi Confirmation"),i18n("Delete All"));
4075 if ( km == KMessageBox::Continue ) 4126 if ( km == KMessageBox::Continue )
4076 km = KMessageBox::No; // No = all below 4127 km = KMessageBox::No; // No = all below
4077 } else 4128 } else
4078 km = KMessageBox::No; 4129 km = KMessageBox::No;
4079 } else { 4130 } else {
4080 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4131 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4081 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 4132 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
4082 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 4133 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
4083 i18n("KO/Pi Confirmation"),i18n("Current"), 4134 i18n("KO/Pi Confirmation"),i18n("Current"),
4084 i18n("All")); 4135 i18n("All"));
4085 } 4136 }
4086 switch(km) { 4137 switch(km) {
4087 4138
4088 case KMessageBox::No: // Continue // all 4139 case KMessageBox::No: // Continue // all
4089 //qDebug("KMessageBox::No "); 4140 //qDebug("KMessageBox::No ");
4090 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4141 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4091 schedule(Scheduler::Cancel,anEvent); 4142 schedule(Scheduler::Cancel,anEvent);
4092 4143
4093 checkExternalId( anEvent); 4144 checkExternalId( anEvent);
4094 mCalendar->deleteEvent(anEvent); 4145 mCalendar->deleteEvent(anEvent);
4095 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 4146 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
4096 break; 4147 break;
4097 4148
4098 // Disabled because it does not work 4149 // Disabled because it does not work
4099 //#if 0 4150 //#if 0
4100 case KMessageBox::Yes: // just this one 4151 case KMessageBox::Yes: // just this one
4101 //QDate qd = mNavigator->selectedDates().first(); 4152 //QDate qd = mNavigator->selectedDates().first();
4102 //if (!qd.isValid()) { 4153 //if (!qd.isValid()) {
4103 // kdDebug() << "no date selected, or invalid date" << endl; 4154 // kdDebug() << "no date selected, or invalid date" << endl;
4104 // KNotifyClient::beep(); 4155 // KNotifyClient::beep();
4105 // return; 4156 // return;
4106 //} 4157 //}
4107 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 4158 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
4108 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 4159 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
4109 anEvent->addExDate(itemDate); 4160 anEvent->addExDate(itemDate);
4110 int duration = anEvent->recurrence()->duration(); 4161 int duration = anEvent->recurrence()->duration();
4111 if ( duration > 0 ) { 4162 if ( duration > 0 ) {
4112 anEvent->recurrence()->setDuration( duration - 1 ); 4163 anEvent->recurrence()->setDuration( duration - 1 );
4113 } 4164 }
4114 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 4165 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
4115 } 4166 }
4116 break; 4167 break;
4117 //#endif 4168 //#endif
4118 } // switch 4169 } // switch
4119 } else { 4170 } else {
4120 if (KOPrefs::instance()->mConfirm) { 4171 if (KOPrefs::instance()->mConfirm) {
4121 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4172 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4122 i18n("\nAre you sure you want\nto delete this event?"), 4173 i18n("\nAre you sure you want\nto delete this event?"),
4123 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 4174 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
4124 case KMessageBox::Continue: // OK 4175 case KMessageBox::Continue: // OK
4125 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4176 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4126 schedule(Scheduler::Cancel,anEvent); 4177 schedule(Scheduler::Cancel,anEvent);
4127 checkExternalId( anEvent); 4178 checkExternalId( anEvent);
4128 mCalendar->deleteEvent(anEvent); 4179 mCalendar->deleteEvent(anEvent);
4129 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4180 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4130 break; 4181 break;
4131 } // switch 4182 } // switch
4132 } else { 4183 } else {
4133 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4184 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4134 schedule(Scheduler::Cancel,anEvent); 4185 schedule(Scheduler::Cancel,anEvent);
4135 checkExternalId( anEvent); 4186 checkExternalId( anEvent);
4136 mCalendar->deleteEvent(anEvent); 4187 mCalendar->deleteEvent(anEvent);
4137 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4188 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4138 } 4189 }
4139 } // if-else 4190 } // if-else
4140 emit updateSearchDialog(); 4191 emit updateSearchDialog();
4141} 4192}
4142 4193
4143bool CalendarView::deleteEvent(const QString &uid) 4194bool CalendarView::deleteEvent(const QString &uid)
4144{ 4195{
4145 Event *ev = mCalendar->event(uid); 4196 Event *ev = mCalendar->event(uid);
4146 if (ev) { 4197 if (ev) {
4147 deleteEvent(ev); 4198 deleteEvent(ev);
4148 return true; 4199 return true;
4149 } else { 4200 } else {
4150 return false; 4201 return false;
4151 } 4202 }
4152} 4203}
4153 4204
4154/*****************************************************************************/ 4205/*****************************************************************************/
4155 4206
4156void CalendarView::action_mail() 4207void CalendarView::action_mail()
4157{ 4208{
4158#ifndef KORG_NOMAIL 4209#ifndef KORG_NOMAIL
4159 KOMailClient mailClient; 4210 KOMailClient mailClient;
4160 4211
4161 Incidence *incidence = currentSelection(); 4212 Incidence *incidence = currentSelection();
4162 4213
4163 if (!incidence) { 4214 if (!incidence) {
4164 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4215 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4165 return; 4216 return;
4166 } 4217 }
4167 if(incidence->attendeeCount() == 0 ) { 4218 if(incidence->attendeeCount() == 0 ) {
4168 KMessageBox::sorry(this, 4219 KMessageBox::sorry(this,
4169 i18n("Can't generate mail:\nNo attendees defined.\n")); 4220 i18n("Can't generate mail:\nNo attendees defined.\n"));
4170 return; 4221 return;
4171 } 4222 }
4172 4223
4173 CalendarLocal cal_tmp; 4224 CalendarLocal cal_tmp;
4174 Event *event = 0; 4225 Event *event = 0;
4175 Event *ev = 0; 4226 Event *ev = 0;
4176 if ( incidence && incidence->typeID() == eventID ) { 4227 if ( incidence && incidence->typeID() == eventID ) {
4177 event = static_cast<Event *>(incidence); 4228 event = static_cast<Event *>(incidence);
4178 ev = new Event(*event); 4229 ev = new Event(*event);
4179 cal_tmp.addEvent(ev); 4230 cal_tmp.addEvent(ev);
4180 } 4231 }
4181 ICalFormat mForm(); 4232 ICalFormat mForm();
4182 QString attachment = mForm.toString( &cal_tmp ); 4233 QString attachment = mForm.toString( &cal_tmp );
4183 if (ev) delete(ev); 4234 if (ev) delete(ev);
4184 4235
4185 mailClient.mailAttendees(currentSelection(), attachment); 4236 mailClient.mailAttendees(currentSelection(), attachment);
4186 4237
4187#endif 4238#endif
4188 4239
4189#if 0 4240#if 0
4190 Event *anEvent = 0; 4241 Event *anEvent = 0;
4191 if (mViewManager->currentView()->isEventView()) { 4242 if (mViewManager->currentView()->isEventView()) {
4192 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 4243 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
4193 } 4244 }
4194 4245
4195 if (!anEvent) { 4246 if (!anEvent) {
4196 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4247 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4197 return; 4248 return;
4198 } 4249 }
4199 if(anEvent->attendeeCount() == 0 ) { 4250 if(anEvent->attendeeCount() == 0 ) {
4200 KMessageBox::sorry(this, 4251 KMessageBox::sorry(this,
4201 i18n("Can't generate mail:\nNo attendees defined.\n")); 4252 i18n("Can't generate mail:\nNo attendees defined.\n"));
4202 return; 4253 return;
4203 } 4254 }
4204 4255
4205 mailobject.emailEvent(anEvent); 4256 mailobject.emailEvent(anEvent);
4206#endif 4257#endif
4207} 4258}
4208 4259
4209 4260
4210void CalendarView::schedule_publish(Incidence *incidence) 4261void CalendarView::schedule_publish(Incidence *incidence)
4211{ 4262{
4212 Event *event = 0; 4263 Event *event = 0;
4213 Todo *todo = 0; 4264 Todo *todo = 0;
4214 4265
4215 if (incidence == 0) { 4266 if (incidence == 0) {
4216 incidence = mViewManager->currentView()->selectedIncidences().first(); 4267 incidence = mViewManager->currentView()->selectedIncidences().first();
4217 if (incidence == 0) { 4268 if (incidence == 0) {
4218 incidence = mTodoList->selectedIncidences().first(); 4269 incidence = mTodoList->selectedIncidences().first();
4219 } 4270 }
4220 } 4271 }
4221 if ( incidence && incidence->typeID() == eventID ) { 4272 if ( incidence && incidence->typeID() == eventID ) {
4222 event = static_cast<Event *>(incidence); 4273 event = static_cast<Event *>(incidence);
4223 } else { 4274 } else {
4224 if ( incidence && incidence->typeID() == todoID ) { 4275 if ( incidence && incidence->typeID() == todoID ) {
4225 todo = static_cast<Todo *>(incidence); 4276 todo = static_cast<Todo *>(incidence);
4226 } 4277 }
4227 } 4278 }
4228 4279
4229 if (!event && !todo) { 4280 if (!event && !todo) {
4230 KMessageBox::sorry(this,i18n("No event selected.")); 4281 KMessageBox::sorry(this,i18n("No event selected."));
4231 return; 4282 return;
4232 } 4283 }
4233 4284
4234 PublishDialog *publishdlg = new PublishDialog(); 4285 PublishDialog *publishdlg = new PublishDialog();
4235 if (incidence->attendeeCount()>0) { 4286 if (incidence->attendeeCount()>0) {
4236 QPtrList<Attendee> attendees = incidence->attendees(); 4287 QPtrList<Attendee> attendees = incidence->attendees();
4237 attendees.first(); 4288 attendees.first();
4238 while ( attendees.current()!=0 ) { 4289 while ( attendees.current()!=0 ) {
4239 publishdlg->addAttendee(attendees.current()); 4290 publishdlg->addAttendee(attendees.current());
4240 attendees.next(); 4291 attendees.next();
4241 } 4292 }
4242 } 4293 }
4243 bool send = true; 4294 bool send = true;
4244 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 4295 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
4245 if ( publishdlg->exec() != QDialog::Accepted ) 4296 if ( publishdlg->exec() != QDialog::Accepted )
4246 send = false; 4297 send = false;
4247 } 4298 }
4248 if ( send ) { 4299 if ( send ) {
4249 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4300 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4250 if ( event ) { 4301 if ( event ) {
4251 Event *ev = new Event(*event); 4302 Event *ev = new Event(*event);
4252 ev->registerObserver(0); 4303 ev->registerObserver(0);
4253 ev->clearAttendees(); 4304 ev->clearAttendees();
4254 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4305 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4255 delete(ev); 4306 delete(ev);
4256 } 4307 }
4257 } else { 4308 } else {
4258 if ( todo ) { 4309 if ( todo ) {
4259 Todo *ev = new Todo(*todo); 4310 Todo *ev = new Todo(*todo);
4260 ev->registerObserver(0); 4311 ev->registerObserver(0);
4261 ev->clearAttendees(); 4312 ev->clearAttendees();
4262 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4313 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4263 delete(ev); 4314 delete(ev);
4264 } 4315 }
4265 } 4316 }
4266 } 4317 }
4267 } 4318 }
4268 delete publishdlg; 4319 delete publishdlg;
4269} 4320}
4270 4321
4271void CalendarView::schedule_request(Incidence *incidence) 4322void CalendarView::schedule_request(Incidence *incidence)
4272{ 4323{
4273 schedule(Scheduler::Request,incidence); 4324 schedule(Scheduler::Request,incidence);
4274} 4325}
4275 4326
4276void CalendarView::schedule_refresh(Incidence *incidence) 4327void CalendarView::schedule_refresh(Incidence *incidence)
4277{ 4328{
4278 schedule(Scheduler::Refresh,incidence); 4329 schedule(Scheduler::Refresh,incidence);
4279} 4330}
4280 4331
4281void CalendarView::schedule_cancel(Incidence *incidence) 4332void CalendarView::schedule_cancel(Incidence *incidence)
4282{ 4333{
4283 schedule(Scheduler::Cancel,incidence); 4334 schedule(Scheduler::Cancel,incidence);
4284} 4335}
4285 4336
4286void CalendarView::schedule_add(Incidence *incidence) 4337void CalendarView::schedule_add(Incidence *incidence)
4287{ 4338{
4288 schedule(Scheduler::Add,incidence); 4339 schedule(Scheduler::Add,incidence);
4289} 4340}
4290 4341
4291void CalendarView::schedule_reply(Incidence *incidence) 4342void CalendarView::schedule_reply(Incidence *incidence)
4292{ 4343{
4293 schedule(Scheduler::Reply,incidence); 4344 schedule(Scheduler::Reply,incidence);
4294} 4345}
4295 4346
4296void CalendarView::schedule_counter(Incidence *incidence) 4347void CalendarView::schedule_counter(Incidence *incidence)
4297{ 4348{
4298 schedule(Scheduler::Counter,incidence); 4349 schedule(Scheduler::Counter,incidence);
4299} 4350}
4300 4351
4301void CalendarView::schedule_declinecounter(Incidence *incidence) 4352void CalendarView::schedule_declinecounter(Incidence *incidence)
4302{ 4353{
4303 schedule(Scheduler::Declinecounter,incidence); 4354 schedule(Scheduler::Declinecounter,incidence);
4304} 4355}
4305 4356
4306void CalendarView::schedule_publish_freebusy(int daysToPublish) 4357void CalendarView::schedule_publish_freebusy(int daysToPublish)
4307{ 4358{
4308 QDateTime start = QDateTime::currentDateTime(); 4359 QDateTime start = QDateTime::currentDateTime();
4309 QDateTime end = start.addDays(daysToPublish); 4360 QDateTime end = start.addDays(daysToPublish);
4310 4361
4311 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 4362 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
4312 freebusy->setOrganizer(KOPrefs::instance()->email()); 4363 freebusy->setOrganizer(KOPrefs::instance()->email());
4313 4364
4314 4365
4315 PublishDialog *publishdlg = new PublishDialog(); 4366 PublishDialog *publishdlg = new PublishDialog();
4316 if ( publishdlg->exec() == QDialog::Accepted ) { 4367 if ( publishdlg->exec() == QDialog::Accepted ) {
4317 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4368 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4318 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 4369 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
4319 delete(freebusy); 4370 delete(freebusy);
4320 } 4371 }
4321 } 4372 }
4322 delete publishdlg; 4373 delete publishdlg;
4323} 4374}
4324 4375
4325void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 4376void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
4326{ 4377{
4327 Event *event = 0; 4378 Event *event = 0;
4328 Todo *todo = 0; 4379 Todo *todo = 0;
4329 4380
4330 if (incidence == 0) { 4381 if (incidence == 0) {
4331 incidence = mViewManager->currentView()->selectedIncidences().first(); 4382 incidence = mViewManager->currentView()->selectedIncidences().first();
4332 if (incidence == 0) { 4383 if (incidence == 0) {
4333 incidence = mTodoList->selectedIncidences().first(); 4384 incidence = mTodoList->selectedIncidences().first();
4334 } 4385 }
4335 } 4386 }
4336 if ( incidence && incidence->typeID() == eventID ) { 4387 if ( incidence && incidence->typeID() == eventID ) {
4337 event = static_cast<Event *>(incidence); 4388 event = static_cast<Event *>(incidence);
4338 } 4389 }
4339 if ( incidence && incidence->typeID() == todoID ) { 4390 if ( incidence && incidence->typeID() == todoID ) {
4340 todo = static_cast<Todo *>(incidence); 4391 todo = static_cast<Todo *>(incidence);
4341 } 4392 }
4342 4393
4343 if (!event && !todo) { 4394 if (!event && !todo) {
4344 KMessageBox::sorry(this,i18n("No event selected.")); 4395 KMessageBox::sorry(this,i18n("No event selected."));
4345 return; 4396 return;
4346 } 4397 }
4347 4398
4348 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 4399 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
4349 KMessageBox::sorry(this,i18n("The event has no attendees.")); 4400 KMessageBox::sorry(this,i18n("The event has no attendees."));
4350 return; 4401 return;
4351 } 4402 }
4352 4403
4353 Event *ev = 0; 4404 Event *ev = 0;
4354 if (event) ev = new Event(*event); 4405 if (event) ev = new Event(*event);
4355 Todo *to = 0; 4406 Todo *to = 0;
4356 if (todo) to = new Todo(*todo); 4407 if (todo) to = new Todo(*todo);
4357 4408
4358 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4409 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4359 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4410 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4360 if (!me) { 4411 if (!me) {
4361 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4412 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4362 return; 4413 return;
4363 } 4414 }
4364 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4415 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4365 StatusDialog *statdlg = new StatusDialog(this); 4416 StatusDialog *statdlg = new StatusDialog(this);
4366 if (!statdlg->exec()==QDialog::Accepted) return; 4417 if (!statdlg->exec()==QDialog::Accepted) return;
4367 me->setStatus( statdlg->status() ); 4418 me->setStatus( statdlg->status() );
4368 delete(statdlg); 4419 delete(statdlg);
4369 } 4420 }
4370 Attendee *menew = new Attendee(*me); 4421 Attendee *menew = new Attendee(*me);
4371 if (ev) { 4422 if (ev) {
4372 ev->clearAttendees(); 4423 ev->clearAttendees();
4373 ev->addAttendee(menew,false); 4424 ev->addAttendee(menew,false);
4374 } else { 4425 } else {
4375 if (to) { 4426 if (to) {
4376 todo->clearAttendees(); 4427 todo->clearAttendees();
4377 todo->addAttendee(menew,false); 4428 todo->addAttendee(menew,false);
4378 } 4429 }
4379 } 4430 }
4380 } 4431 }
4381 4432
4382 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4433 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4383 if (ev) { 4434 if (ev) {
4384 if ( !dlg->addMessage(ev,method) ) delete(ev); 4435 if ( !dlg->addMessage(ev,method) ) delete(ev);
4385 } else { 4436 } else {
4386 if (to) { 4437 if (to) {
4387 if ( !dlg->addMessage(to,method) ) delete(to); 4438 if ( !dlg->addMessage(to,method) ) delete(to);
4388 } 4439 }
4389 } 4440 }
4390} 4441}
4391 4442
4392void CalendarView::openAddressbook() 4443void CalendarView::openAddressbook()
4393{ 4444{
4394 KRun::runCommand("kaddressbook"); 4445 KRun::runCommand("kaddressbook");
4395} 4446}
4396 4447
4397void CalendarView::setModified(bool modified) 4448void CalendarView::setModified(bool modified)
4398{ 4449{
4399 //qDebug("CalendarView::setModified %d ", modified); 4450 //qDebug("CalendarView::setModified %d ", modified);
4400 if ( modified ) 4451 if ( modified )
4401 emit signalmodified(); 4452 emit signalmodified();
4402 mModified = modified; 4453 mModified = modified;
4403 if ( mModified ) 4454 if ( mModified )
4404 emit modifiedChanged(mModified); 4455 emit modifiedChanged(mModified);
4405 4456
4406} 4457}
4407 4458
4408bool CalendarView::isReadOnly() 4459bool CalendarView::isReadOnly()
4409{ 4460{
4410 return mReadOnly; 4461 return mReadOnly;
4411} 4462}
4412 4463
4413void CalendarView::setReadOnly(bool readOnly) 4464void CalendarView::setReadOnly(bool readOnly)
4414{ 4465{
4415 if (mReadOnly != readOnly) { 4466 if (mReadOnly != readOnly) {
4416 mReadOnly = readOnly; 4467 mReadOnly = readOnly;
4417 emit readOnlyChanged(mReadOnly); 4468 emit readOnlyChanged(mReadOnly);
4418 } 4469 }
4419} 4470}
4420 4471
4421bool CalendarView::isModified() 4472bool CalendarView::isModified()
4422{ 4473{
4423 return mModified; 4474 return mModified;
4424} 4475}
4425void CalendarView::slotprintSelInc() 4476void CalendarView::slotprintSelInc()
4426{ 4477{
4427 if ( currentSelection() == 0 ) { 4478 if ( currentSelection() == 0 ) {
4428 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4479 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4429 return; 4480 return;
4430 } 4481 }
4431 showIncidence(); 4482 showIncidence();
4432 getEventViewerDialog()->print(); 4483 getEventViewerDialog()->print();
4433 4484
4434} 4485}
4435void CalendarView::printSetup() 4486void CalendarView::printSetup()
4436{ 4487{
4437#ifndef KORG_NOPRINTER 4488#ifndef KORG_NOPRINTER
4438 createPrinter(); 4489 createPrinter();
4439 4490
4440 mCalPrinter->setupPrinter(); 4491 mCalPrinter->setupPrinter();
4441#endif 4492#endif
4442} 4493}
4443 4494
4444void CalendarView::print() 4495void CalendarView::print()
4445{ 4496{
4446#ifndef KORG_NOPRINTER 4497#ifndef KORG_NOPRINTER
4447 createPrinter(); 4498 createPrinter();
4448 4499
4449 DateList tmpDateList = mNavigator->selectedDates(); 4500 DateList tmpDateList = mNavigator->selectedDates();
4450 mCalPrinter->print(CalPrinter::Month, 4501 mCalPrinter->print(CalPrinter::Month,
4451 tmpDateList.first(), tmpDateList.last()); 4502 tmpDateList.first(), tmpDateList.last());
4452#endif 4503#endif
4453} 4504}
4454 4505
4455void CalendarView::printPreview() 4506void CalendarView::printPreview()
4456{ 4507{
4457#ifndef KORG_NOPRINTER 4508#ifndef KORG_NOPRINTER
4458 kdDebug() << "CalendarView::printPreview()" << endl; 4509 kdDebug() << "CalendarView::printPreview()" << endl;
4459 4510
4460 createPrinter(); 4511 createPrinter();
4461 4512
4462 DateList tmpDateList = mNavigator->selectedDates(); 4513 DateList tmpDateList = mNavigator->selectedDates();
4463 4514
4464 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 4515 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
4465 tmpDateList.last()); 4516 tmpDateList.last());
4466#endif 4517#endif
4467} 4518}
4468bool CalendarView::exportICalendar( QString filename ) 4519bool CalendarView::exportICalendar( QString filename )
4469{ 4520{
4470 // Force correct extension 4521 // Force correct extension
4471 if (filename.right(4) != ".ics") filename += ".ics"; 4522 if (filename.right(4) != ".ics") filename += ".ics";
4472 4523
4473 FileStorage storage( mCalendar, filename, new ICalFormat() ); 4524 FileStorage storage( mCalendar, filename, new ICalFormat() );
4474 return storage.save(); 4525 return storage.save();
4475} 4526}
4476 4527
4477bool CalendarView::exportICalendar() 4528bool CalendarView::exportICalendar()
4478{ 4529{
4479 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); 4530 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) );
4480} 4531}
4481 4532
4482bool CalendarView::exportVCalendar( QString filename ) 4533bool CalendarView::exportVCalendar( QString filename )
4483{ 4534{
4484 if (mCalendar->journals().count() > 0) { 4535 if (mCalendar->journals().count() > 0) {
4485 int result = KMessageBox::warningContinueCancel(this, 4536 int result = KMessageBox::warningContinueCancel(this,
4486 i18n("The journal entries can not be\nexported to a vCalendar file."), 4537 i18n("The journal entries can not be\nexported to a vCalendar file."),
4487 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 4538 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
4488 true); 4539 true);
4489 if (result != KMessageBox::Continue) return false; 4540 if (result != KMessageBox::Continue) return false;
4490 } 4541 }
4491 4542
4492 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 4543 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
4493 4544
4494 // Force correct extension 4545 // Force correct extension
4495 if (filename.right(4) != ".vcs") filename += ".vcs"; 4546 if (filename.right(4) != ".vcs") filename += ".vcs";
4496 4547
4497 FileStorage storage( mCalendar, filename, new VCalFormat ); 4548 FileStorage storage( mCalendar, filename, new VCalFormat );
4498 return storage.save(); 4549 return storage.save();
4499 4550
4500} 4551}
4501 4552
4502void CalendarView::eventUpdated(Incidence *) 4553void CalendarView::eventUpdated(Incidence *)
4503{ 4554{
4504 setModified(); 4555 setModified();
4505 // Don't call updateView here. The code, which has caused the update of the 4556 // Don't call updateView here. The code, which has caused the update of the
4506 // event is responsible for updating the view. 4557 // event is responsible for updating the view.
4507 // updateView(); 4558 // updateView();
4508} 4559}
4509 4560
4510void CalendarView::adaptNavigationUnits() 4561void CalendarView::adaptNavigationUnits()
4511{ 4562{
4512 if (mViewManager->currentView()->isEventView()) { 4563 if (mViewManager->currentView()->isEventView()) {
4513 int days = mViewManager->currentView()->currentDateCount(); 4564 int days = mViewManager->currentView()->currentDateCount();
4514 if (days == 1) { 4565 if (days == 1) {
4515 emit changeNavStringPrev(i18n("&Previous Day")); 4566 emit changeNavStringPrev(i18n("&Previous Day"));
4516 emit changeNavStringNext(i18n("&Next Day")); 4567 emit changeNavStringNext(i18n("&Next Day"));
4517 } else { 4568 } else {
4518 emit changeNavStringPrev(i18n("&Previous Week")); 4569 emit changeNavStringPrev(i18n("&Previous Week"));
4519 emit changeNavStringNext(i18n("&Next Week")); 4570 emit changeNavStringNext(i18n("&Next Week"));
4520 } 4571 }
4521 } 4572 }
4522} 4573}
4523 4574
4524void CalendarView::processMainViewSelection( Incidence *incidence ) 4575void CalendarView::processMainViewSelection( Incidence *incidence )
4525{ 4576{
4526 if ( incidence ) mTodoList->clearSelection(); 4577 if ( incidence ) mTodoList->clearSelection();
4527 processIncidenceSelection( incidence ); 4578 processIncidenceSelection( incidence );
4528} 4579}
4529 4580
4530void CalendarView::processTodoListSelection( Incidence *incidence ) 4581void CalendarView::processTodoListSelection( Incidence *incidence )
4531{ 4582{
4532 if ( incidence && mViewManager->currentView() ) { 4583 if ( incidence && mViewManager->currentView() ) {
4533 mViewManager->currentView()->clearSelection(); 4584 mViewManager->currentView()->clearSelection();
4534 } 4585 }
4535 processIncidenceSelection( incidence ); 4586 processIncidenceSelection( incidence );
4536} 4587}
4537 4588
4538void CalendarView::processIncidenceSelection( Incidence *incidence ) 4589void CalendarView::processIncidenceSelection( Incidence *incidence )
4539{ 4590{
4540 emit incidenceSelected( incidence ); 4591 emit incidenceSelected( incidence );
4541 if ( incidence == mSelectedIncidence ) return; 4592 if ( incidence == mSelectedIncidence ) return;
4542 mSelectedIncidence = incidence; 4593 mSelectedIncidence = incidence;
4543 4594
4544 if ( incidence && incidence->typeID() == eventID ) { 4595 if ( incidence && incidence->typeID() == eventID ) {
4545 Event *event = static_cast<Event *>( incidence ); 4596 Event *event = static_cast<Event *>( incidence );
4546 if ( event->organizer() == KOPrefs::instance()->email() ) { 4597 if ( event->organizer() == KOPrefs::instance()->email() ) {
4547 emit organizerEventsSelected( true ); 4598 emit organizerEventsSelected( true );
4548 } else { 4599 } else {
4549 emit organizerEventsSelected(false); 4600 emit organizerEventsSelected(false);
4550 } 4601 }
4551 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4602 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4552 KOPrefs::instance()->email() ) ) { 4603 KOPrefs::instance()->email() ) ) {
4553 emit groupEventsSelected( true ); 4604 emit groupEventsSelected( true );
4554 } else { 4605 } else {
4555 emit groupEventsSelected(false); 4606 emit groupEventsSelected(false);
4556 } 4607 }
4557 return; 4608 return;
4558 } else { 4609 } else {
4559 if ( incidence && incidence->typeID() == todoID ) { 4610 if ( incidence && incidence->typeID() == todoID ) {
4560 emit todoSelected( true ); 4611 emit todoSelected( true );
4561 Todo *event = static_cast<Todo *>( incidence ); 4612 Todo *event = static_cast<Todo *>( incidence );
4562 if ( event->organizer() == KOPrefs::instance()->email() ) { 4613 if ( event->organizer() == KOPrefs::instance()->email() ) {
4563 emit organizerEventsSelected( true ); 4614 emit organizerEventsSelected( true );
4564 } else { 4615 } else {
4565 emit organizerEventsSelected(false); 4616 emit organizerEventsSelected(false);
4566 } 4617 }
4567 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4618 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4568 KOPrefs::instance()->email() ) ) { 4619 KOPrefs::instance()->email() ) ) {
4569 emit groupEventsSelected( true ); 4620 emit groupEventsSelected( true );
4570 } else { 4621 } else {
4571 emit groupEventsSelected(false); 4622 emit groupEventsSelected(false);
4572 } 4623 }
4573 return; 4624 return;
4574 } else { 4625 } else {
4575 emit todoSelected( false ); 4626 emit todoSelected( false );
4576 emit organizerEventsSelected(false); 4627 emit organizerEventsSelected(false);
4577 emit groupEventsSelected(false); 4628 emit groupEventsSelected(false);
4578 } 4629 }
4579 return; 4630 return;
4580 } 4631 }
4581 4632
4582 /* if ( incidence && incidence->typeID() == todoID ) { 4633 /* if ( incidence && incidence->typeID() == todoID ) {
4583 emit todoSelected( true ); 4634 emit todoSelected( true );
4584 } else { 4635 } else {
4585 emit todoSelected( false ); 4636 emit todoSelected( false );
4586 }*/ 4637 }*/
4587} 4638}
4588 4639
4589 4640
4590void CalendarView::checkClipboard() 4641void CalendarView::checkClipboard()
4591{ 4642{
4592#ifndef KORG_NODND 4643#ifndef KORG_NODND
4593 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4644 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4594 emit pasteEnabled(true); 4645 emit pasteEnabled(true);
4595 } else { 4646 } else {
4596 emit pasteEnabled(false); 4647 emit pasteEnabled(false);
4597 } 4648 }
4598#endif 4649#endif
4599} 4650}
4600 4651
4601void CalendarView::showDates(const DateList &selectedDates) 4652void CalendarView::showDates(const DateList &selectedDates)
4602{ 4653{
4603 // kdDebug() << "CalendarView::selectDates()" << endl; 4654 // kdDebug() << "CalendarView::selectDates()" << endl;
4604 4655
4605 4656
4606 if ( !mBlockShowDates ) { 4657 if ( !mBlockShowDates ) {
4607 if ( mViewManager->currentView() ) { 4658 if ( mViewManager->currentView() ) {
4608 updateView( selectedDates.first(), selectedDates.last() ); 4659 updateView( selectedDates.first(), selectedDates.last() );
4609 } else { 4660 } else {
4610 mViewManager->showAgendaView(); 4661 mViewManager->showAgendaView();
4611 } 4662 }
4612 } 4663 }
4613 4664
4614 QDate date = selectedDates.first(); 4665 QDate date = selectedDates.first();
4615 if ( ! date.isValid() ) { 4666 if ( ! date.isValid() ) {
4616 topLevelWidget()->setCaption(""); 4667 topLevelWidget()->setCaption("");
4617 return; 4668 return;
4618 } 4669 }
4619 4670
4620 QString selDates; 4671 QString selDates;
4621 selDates = KGlobal::locale()->formatDate( date, true); 4672 selDates = KGlobal::locale()->formatDate( date, true);
4622 if (selectedDates.first() < selectedDates.last() ) 4673 if (selectedDates.first() < selectedDates.last() )
4623 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4674 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4624 else { 4675 else {
4625 QString addString; 4676 QString addString;
4626 if ( date == QDateTime::currentDateTime().date() ) 4677 if ( date == QDateTime::currentDateTime().date() )
4627 addString = i18n("Today"); 4678 addString = i18n("Today");
4628 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4679 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4629 addString = i18n("Tomorrow"); 4680 addString = i18n("Tomorrow");
4630 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4681 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4631 addString = i18n("Yesterday"); 4682 addString = i18n("Yesterday");
4632 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4683 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4633 addString = i18n("Day before yesterday"); 4684 addString = i18n("Day before yesterday");
4634 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4685 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4635 addString = i18n("Day after tomorrow"); 4686 addString = i18n("Day after tomorrow");
4636 if ( !addString.isEmpty() ) { 4687 if ( !addString.isEmpty() ) {
4637 topLevelWidget()->setCaption( addString+", " + selDates ); 4688 topLevelWidget()->setCaption( addString+", " + selDates );
4638 return; 4689 return;
4639 } 4690 }
4640 } 4691 }
4641 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4692 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4642 4693
4643} 4694}
4644 4695
4645QPtrList<CalFilter> CalendarView::filters() 4696QPtrList<CalFilter> CalendarView::filters()
4646{ 4697{
4647 return mFilters; 4698 return mFilters;
4648 4699
4649} 4700}
4650void CalendarView::editFilters() 4701void CalendarView::editFilters()
4651{ 4702{
4652 // kdDebug() << "CalendarView::editFilters()" << endl; 4703 // kdDebug() << "CalendarView::editFilters()" << endl;
4653 4704
4654 CalFilter *filter = mFilters.first(); 4705 CalFilter *filter = mFilters.first();
4655 while(filter) { 4706 while(filter) {
4656 filter = mFilters.next(); 4707 filter = mFilters.next();
4657 } 4708 }
4658 4709
4659 mDialogManager->showFilterEditDialog(&mFilters); 4710 mDialogManager->showFilterEditDialog(&mFilters);
4660 updateFilter(); 4711 updateFilter();
4661} 4712}
4662void CalendarView::toggleFilter() 4713void CalendarView::toggleFilter()
4663{ 4714{
4664 if ( mLeftFrame->isHidden() ) { 4715 if ( mLeftFrame->isHidden() ) {
4665 toggleExpand(); 4716 toggleExpand();
4666 showFilter( true ); 4717 showFilter( true );
4667 } else 4718 } else
4668 showFilter(! mCalEditView->isVisible()); 4719 showFilter(! mCalEditView->isVisible());
4669} 4720}
4670 4721
4671KOFilterView *CalendarView::filterView() 4722KOFilterView *CalendarView::filterView()
4672{ 4723{
4673 return mFilterView; 4724 return mFilterView;
4674} 4725}
4675void CalendarView::selectFilter( int fil ) 4726void CalendarView::selectFilter( int fil )
4676{ 4727{
4677 mFilterView->setSelectedFilter( fil ); 4728 mFilterView->setSelectedFilter( fil );
4678 updateUnmanagedViews(); 4729 updateUnmanagedViews();
4679} 4730}
4680void CalendarView::showFilter(bool visible) 4731void CalendarView::showFilter(bool visible)
4681{ 4732{
4682#if 1 4733#if 1
4683 if (visible) { 4734 if (visible) {
4684 mCalEditView->readConfig(); 4735 mCalEditView->readConfig();
4685 mCalEditView->show(); 4736 mCalEditView->show();
4686 QValueList<int> sizes; 4737 QValueList<int> sizes;
4687 sizes = mLeftFrame->sizes(); 4738 sizes = mLeftFrame->sizes();
4688 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4739 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4689 sizes.clear(); 4740 sizes.clear();
4690 sizes << 100; 4741 sizes << 100;
4691 sizes << 0; 4742 sizes << 0;
4692 sizes << 0; 4743 sizes << 0;
4693 sizes << 100; 4744 sizes << 100;
4694 mLeftFrame->setSizes(sizes); 4745 mLeftFrame->setSizes(sizes);
4695 } 4746 }
4696#if 0 4747#if 0
4697 sizes = mLeftFrame->sizes(); 4748 sizes = mLeftFrame->sizes();
4698 int ccc = 0; 4749 int ccc = 0;
4699 while ( ccc < sizes.count()) { 4750 while ( ccc < sizes.count()) {
4700 qDebug("size %d %d ", ccc, sizes[ccc]); 4751 qDebug("size %d %d ", ccc, sizes[ccc]);
4701 ++ccc; 4752 ++ccc;
4702 } 4753 }
4703#endif 4754#endif
4704 4755
4705 } 4756 }
4706 else { 4757 else {
4707 mCalEditView->hide(); 4758 mCalEditView->hide();
4708 } 4759 }
4709#else 4760#else
4710 if (visible) mFilterView->show(); 4761 if (visible) mFilterView->show();
4711 else mFilterView->hide(); 4762 else mFilterView->hide();
4712#endif 4763#endif
4713} 4764}
4714void CalendarView::toggleFilerEnabled( ) 4765void CalendarView::toggleFilerEnabled( )
4715{ 4766{
4716 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4767 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4717 if ( !mFilterView->filtersEnabled() ) 4768 if ( !mFilterView->filtersEnabled() )
4718 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4769 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4719 updateUnmanagedViews(); 4770 updateUnmanagedViews();
4720 4771
4721} 4772}
4722void CalendarView::updateFilter() 4773void CalendarView::updateFilter()
4723{ 4774{
4724 CalFilter *filter = mFilterView->selectedFilter(); 4775 CalFilter *filter = mFilterView->selectedFilter();
4725 if (filter) { 4776 if (filter) {
4726 QString mess; 4777 QString mess;
4727 if (mFilterView->filtersEnabled()) { 4778 if (mFilterView->filtersEnabled()) {
4728 mess = i18n("Filter selected: ")+filter->name(); 4779 mess = i18n("Filter selected: ")+filter->name();
4729 filter->setEnabled(true); 4780 filter->setEnabled(true);
4730 } 4781 }
4731 else filter->setEnabled(false); 4782 else filter->setEnabled(false);
4732 mCalendar->setFilter(filter); 4783 mCalendar->setFilter(filter);
4733 updateView(); 4784 updateView();
4734 if ( !mess.isEmpty() ) 4785 if ( !mess.isEmpty() )
4735 topLevelWidget()->setCaption( mess ); 4786 topLevelWidget()->setCaption( mess );
4736 4787
4737 } 4788 }
4738 emit filtersUpdated(); 4789 emit filtersUpdated();
4739} 4790}
4740 4791
4741void CalendarView::filterEdited() 4792void CalendarView::filterEdited()
4742{ 4793{
4743 mFilterView->updateFilters(); 4794 mFilterView->updateFilters();
4744 updateFilter(); 4795 updateFilter();
4745 writeSettings(); 4796 writeSettings();
4746} 4797}
4747 4798
4748 4799
4749void CalendarView::takeOverEvent() 4800void CalendarView::takeOverEvent()
4750{ 4801{
4751 Incidence *incidence = currentSelection(); 4802 Incidence *incidence = currentSelection();
4752 4803
4753 if (!incidence) return; 4804 if (!incidence) return;
4754 4805
4755 incidence->setOrganizer(KOPrefs::instance()->email()); 4806 incidence->setOrganizer(KOPrefs::instance()->email());
4756 incidence->recreate(); 4807 incidence->recreate();
4757 incidence->setReadOnly(false); 4808 incidence->setReadOnly(false);
4758 4809
4759 updateView(); 4810 updateView();
4760} 4811}
4761 4812
4762void CalendarView::takeOverCalendar() 4813void CalendarView::takeOverCalendar()
4763{ 4814{
4764 // TODO: Create Calendar::allIncidences() function and use it here 4815 // TODO: Create Calendar::allIncidences() function and use it here
4765 4816
4766 clearAllViews(); 4817 clearAllViews();
4767 QPtrList<Event> events = mCalendar->events(); 4818 QPtrList<Event> events = mCalendar->events();
4768 for(uint i=0; i<events.count(); ++i) { 4819 for(uint i=0; i<events.count(); ++i) {
4769 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4820 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4770 events.at(i)->recreate(); 4821 events.at(i)->recreate();
4771 events.at(i)->setReadOnly(false); 4822 events.at(i)->setReadOnly(false);
4772 } 4823 }
4773 4824
4774 QPtrList<Todo> todos = mCalendar->todos(); 4825 QPtrList<Todo> todos = mCalendar->todos();
4775 for(uint i=0; i<todos.count(); ++i) { 4826 for(uint i=0; i<todos.count(); ++i) {
4776 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4827 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4777 todos.at(i)->recreate(); 4828 todos.at(i)->recreate();
4778 todos.at(i)->setReadOnly(false); 4829 todos.at(i)->setReadOnly(false);
4779 } 4830 }
4780 4831
4781 QPtrList<Journal> journals = mCalendar->journals(); 4832 QPtrList<Journal> journals = mCalendar->journals();
4782 for(uint i=0; i<journals.count(); ++i) { 4833 for(uint i=0; i<journals.count(); ++i) {
4783 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4834 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4784 journals.at(i)->recreate(); 4835 journals.at(i)->recreate();
4785 journals.at(i)->setReadOnly(false); 4836 journals.at(i)->setReadOnly(false);
4786 } 4837 }
4787 4838
4788 updateView(); 4839 updateView();
4789} 4840}
4790 4841
4791void CalendarView::showIntro() 4842void CalendarView::showIntro()
4792{ 4843{
4793 kdDebug() << "To be implemented." << endl; 4844 kdDebug() << "To be implemented." << endl;
4794} 4845}
4795 4846
4796QWidgetStack *CalendarView::viewStack() 4847QWidgetStack *CalendarView::viewStack()
4797{ 4848{
4798 return mRightFrame; 4849 return mRightFrame;
4799} 4850}
4800 4851
4801QWidget *CalendarView::leftFrame() 4852QWidget *CalendarView::leftFrame()
4802{ 4853{
4803 return ( QWidget *)mLeftFrame; 4854 return ( QWidget *)mLeftFrame;
4804} 4855}
4805 4856
4806DateNavigator *CalendarView::dateNavigator() 4857DateNavigator *CalendarView::dateNavigator()
4807{ 4858{
4808 return mNavigator; 4859 return mNavigator;
4809} 4860}
4810 4861
4811KDateNavigator* CalendarView::dateNavigatorWidget() 4862KDateNavigator* CalendarView::dateNavigatorWidget()
4812{ 4863{
4813 return mDateNavigator->navigatorView(); 4864 return mDateNavigator->navigatorView();
4814} 4865}
4815void CalendarView::toggleDateNavigatorWidget() 4866void CalendarView::toggleDateNavigatorWidget()
4816{ 4867{
4817 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4868 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4818 4869
4819 if (!KOPrefs::instance()->mShowDateNavigator ) 4870 if (!KOPrefs::instance()->mShowDateNavigator )
4820 mDateNavigator->hide(); 4871 mDateNavigator->hide();
4821 else 4872 else
4822 mDateNavigator->show(); 4873 mDateNavigator->show();
4823} 4874}
4824void CalendarView::addView(KOrg::BaseView *view) 4875void CalendarView::addView(KOrg::BaseView *view)
4825{ 4876{
4826 mViewManager->addView(view); 4877 mViewManager->addView(view);
4827} 4878}
4828 4879
4829void CalendarView::showView(KOrg::BaseView *view) 4880void CalendarView::showView(KOrg::BaseView *view)
4830{ 4881{
4831 mViewManager->showView(view, mLeftFrame->isVisible()); 4882 mViewManager->showView(view, mLeftFrame->isVisible());
4832} 4883}
4833 4884
4834Incidence *CalendarView::currentSelection() 4885Incidence *CalendarView::currentSelection()
4835{ 4886{
4836 return mViewManager->currentSelection(); 4887 return mViewManager->currentSelection();
4837} 4888}
4838void CalendarView::toggleAllDaySize() 4889void CalendarView::toggleAllDaySize()
4839{ 4890{
4840 /* 4891 /*
4841 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4892 if ( KOPrefs::instance()->mAllDaySize > 47 )
4842 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4893 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4843 else 4894 else
4844 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4895 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4845 */ 4896 */
4846 viewManager()->agendaView()->toggleAllDay(); 4897 viewManager()->agendaView()->toggleAllDay();
4847} 4898}
4848void CalendarView::toggleExpand() 4899void CalendarView::toggleExpand()
4849{ 4900{
4850 // if ( mLeftFrame->isHidden() ) { 4901 // if ( mLeftFrame->isHidden() ) {
4851 // mLeftFrame->show(); 4902 // mLeftFrame->show();
4852 // emit calendarViewExpanded( false ); 4903 // emit calendarViewExpanded( false );
4853 // } else { 4904 // } else {
4854 // mLeftFrame->hide(); 4905 // mLeftFrame->hide();
4855 // emit calendarViewExpanded( true ); 4906 // emit calendarViewExpanded( true );
4856 // } 4907 // }
4857 //qDebug(" CalendarView::toggleExpand()"); 4908 //qDebug(" CalendarView::toggleExpand()");
4858 globalFlagBlockAgenda = 1; 4909 globalFlagBlockAgenda = 1;
4859 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4910 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4860 globalFlagBlockAgenda = 5; 4911 globalFlagBlockAgenda = 5;
4861 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4912 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4862 //mViewManager->showView( 0, true ); 4913 //mViewManager->showView( 0, true );
4863} 4914}
4864 4915
4865void CalendarView::calendarModified( bool modified, Calendar * ) 4916void CalendarView::calendarModified( bool modified, Calendar * )
4866{ 4917{
4867 setModified( modified ); 4918 setModified( modified );
4868} 4919}
4869 4920
4870Todo *CalendarView::selectedTodo() 4921Todo *CalendarView::selectedTodo()
4871{ 4922{
4872 Incidence *incidence = currentSelection(); 4923 Incidence *incidence = currentSelection();
4873 if ( incidence && incidence->typeID() == todoID ) { 4924 if ( incidence && incidence->typeID() == todoID ) {
4874 return static_cast<Todo *>( incidence ); 4925 return static_cast<Todo *>( incidence );
4875 } 4926 }
4876 4927
4877 incidence = mTodoList->selectedIncidences().first(); 4928 incidence = mTodoList->selectedIncidences().first();
4878 if ( incidence && incidence->typeID() == todoID ) { 4929 if ( incidence && incidence->typeID() == todoID ) {
4879 return static_cast<Todo *>( incidence ); 4930 return static_cast<Todo *>( incidence );
4880 } 4931 }
4881 4932
4882 return 0; 4933 return 0;
4883} 4934}
4884 4935
4885void CalendarView::showIncidence() 4936void CalendarView::showIncidence()
4886{ 4937{
4887 mViewerCallerIsSearchDialog = false; 4938 mViewerCallerIsSearchDialog = false;
4888 Incidence *incidence = currentSelection(); 4939 Incidence *incidence = currentSelection();
4889 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4940 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4890 if ( incidence ) { 4941 if ( incidence ) {
4891 ShowIncidenceVisitor v; 4942 ShowIncidenceVisitor v;
4892 v.act( incidence, this ); 4943 v.act( incidence, this );
4893 } 4944 }
4894} 4945}
4895void CalendarView::editIncidenceDescription() 4946void CalendarView::editIncidenceDescription()
4896{ 4947{
4897 mFlagEditDescription = true; 4948 mFlagEditDescription = true;
4898 editIncidence(); 4949 editIncidence();
4899 mFlagEditDescription = false; 4950 mFlagEditDescription = false;
4900} 4951}
4901void CalendarView::editIncidence() 4952void CalendarView::editIncidence()
4902{ 4953{
4903 // qDebug("editIncidence() "); 4954 // qDebug("editIncidence() ");
4904 Incidence *incidence = currentSelection(); 4955 Incidence *incidence = currentSelection();
4905 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4956 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4906 if ( incidence ) { 4957 if ( incidence ) {
4907 EditIncidenceVisitor v; 4958 EditIncidenceVisitor v;
4908 v.act( incidence, this ); 4959 v.act( incidence, this );
4909 } 4960 }
4910} 4961}
4911 4962
4912void CalendarView::deleteIncidence() 4963void CalendarView::deleteIncidence()
4913{ 4964{
4914 Incidence *incidence = currentSelection(); 4965 Incidence *incidence = currentSelection();
4915 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4966 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4916 if ( incidence ) { 4967 if ( incidence ) {
4917 deleteIncidence(incidence); 4968 deleteIncidence(incidence);
4918 } 4969 }
4919} 4970}
4920void CalendarView::showIncidence(QString uid) 4971void CalendarView::showIncidence(QString uid)
4921{ 4972{
4922 Incidence *inc = mCalendar->incidence( uid ); 4973 Incidence *inc = mCalendar->incidence( uid );
4923 if ( inc ) 4974 if ( inc )
4924 showIncidence( inc ); 4975 showIncidence( inc );
4925} 4976}
4926void CalendarView::showIncidence(Incidence *incidence) 4977void CalendarView::showIncidence(Incidence *incidence)
4927{ 4978{
4928 mViewerCallerIsSearchDialog = false; 4979 mViewerCallerIsSearchDialog = false;
4929 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4980 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4930 if ( sender() && mDialogManager->getSearchDialog() ) { 4981 if ( sender() && mDialogManager->getSearchDialog() ) {
4931 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4982 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4932 mViewerCallerIsSearchDialog = true; 4983 mViewerCallerIsSearchDialog = true;
4933 } 4984 }
4934 } 4985 }
4935 if ( incidence ) { 4986 if ( incidence ) {
4936 ShowIncidenceVisitor v; 4987 ShowIncidenceVisitor v;
4937 v.act( incidence, this ); 4988 v.act( incidence, this );
4938 } 4989 }
4939} 4990}
4940 4991
4941void CalendarView::editIncidence(Incidence *incidence) 4992void CalendarView::editIncidence(Incidence *incidence)
4942{ 4993{
4943 if ( incidence ) { 4994 if ( incidence ) {
4944 4995
4945 EditIncidenceVisitor v; 4996 EditIncidenceVisitor v;
4946 v.act( incidence, this ); 4997 v.act( incidence, this );
4947 4998
4948 } 4999 }
4949} 5000}
4950 5001
4951void CalendarView::deleteIncidence(Incidence *incidence) 5002void CalendarView::deleteIncidence(Incidence *incidence)
4952{ 5003{
4953 //qDebug(" CalendarView::deleteIncidence "); 5004 //qDebug(" CalendarView::deleteIncidence ");
4954 if ( incidence == 0 ) { 5005 if ( incidence == 0 ) {
4955 updateView(); 5006 updateView();
4956 emit updateSearchDialog(); 5007 emit updateSearchDialog();
4957 return; 5008 return;
4958 } 5009 }
4959 if ( incidence ) { 5010 if ( incidence ) {
4960 DeleteIncidenceVisitor v; 5011 DeleteIncidenceVisitor v;
4961 v.act( incidence, this ); 5012 v.act( incidence, this );
4962 } 5013 }
4963} 5014}
4964 5015
4965 5016
4966void CalendarView::lookForOutgoingMessages() 5017void CalendarView::lookForOutgoingMessages()
4967{ 5018{
4968 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 5019 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4969 ogd->loadMessages(); 5020 ogd->loadMessages();
4970} 5021}
4971 5022
4972void CalendarView::lookForIncomingMessages() 5023void CalendarView::lookForIncomingMessages()
4973{ 5024{
4974 IncomingDialog *icd = mDialogManager->incomingDialog(); 5025 IncomingDialog *icd = mDialogManager->incomingDialog();
4975 icd->retrieve(); 5026 icd->retrieve();
4976} 5027}
4977 5028
4978bool CalendarView::removeCompletedSubTodos( Todo* t ) 5029bool CalendarView::removeCompletedSubTodos( Todo* t )
4979{ 5030{
4980 bool deleteTodo = true; 5031 bool deleteTodo = true;
4981 QPtrList<Incidence> subTodos; 5032 QPtrList<Incidence> subTodos;
4982 Incidence *aTodo; 5033 Incidence *aTodo;
4983 subTodos = t->relations(); 5034 subTodos = t->relations();
4984 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 5035 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4985 if (! removeCompletedSubTodos( (Todo*) aTodo )) 5036 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4986 deleteTodo = false; 5037 deleteTodo = false;
4987 } 5038 }
4988 if ( deleteTodo ) { 5039 if ( deleteTodo ) {
4989 if ( t->isCompleted() && !t->doesRecur()) { 5040 if ( t->isCompleted() && !t->doesRecur()) {
4990 checkExternalId( t ); 5041 checkExternalId( t );
4991 mCalendar->deleteTodo( t ); 5042 mCalendar->deleteTodo( t );
4992 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 5043 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4993 } 5044 }
4994 else 5045 else
4995 deleteTodo = false; 5046 deleteTodo = false;
4996 } 5047 }
4997 return deleteTodo; 5048 return deleteTodo;
4998 5049
4999} 5050}
5000void CalendarView::purgeCompleted() 5051void CalendarView::purgeCompleted()
5001{ 5052{
5002 int result = KMessageBox::warningContinueCancel(this, 5053 int result = KMessageBox::warningContinueCancel(this,
5003 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5054 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5004 5055
5005 if (result == KMessageBox::Continue) { 5056 if (result == KMessageBox::Continue) {
5006 5057
5007 QPtrList<Todo> todoCal; 5058 QPtrList<Todo> todoCal;
5008 QPtrList<Todo> rootTodos; 5059 QPtrList<Todo> rootTodos;
5009 //QPtrList<Incidence> rel; 5060 //QPtrList<Incidence> rel;
5010 Todo *aTodo; 5061 Todo *aTodo;
5011 todoCal = calendar()->todos(); 5062 todoCal = calendar()->todos();
5012 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5063 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5013 if ( !aTodo->relatedTo() ) 5064 if ( !aTodo->relatedTo() )
5014 rootTodos.append( aTodo ); 5065 rootTodos.append( aTodo );
5015 } 5066 }
5016 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5067 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5017 removeCompletedSubTodos( aTodo ); 5068 removeCompletedSubTodos( aTodo );
5018 } 5069 }
5019 5070
5020 updateView(); 5071 updateView();
5021 } 5072 }
5022} 5073}
5023 5074
5024void CalendarView::slotCalendarChanged() 5075void CalendarView::slotCalendarChanged()
5025{ 5076{
5026 ; 5077 ;
5027} 5078}
5028 5079
5029void CalendarView::keyPressEvent ( QKeyEvent *e) 5080void CalendarView::keyPressEvent ( QKeyEvent *e)
5030{ 5081{
5031 //qDebug("CalendarView::keyPressEvent "); 5082 //qDebug("CalendarView::keyPressEvent ");
5032 e->ignore(); 5083 e->ignore();
5033} 5084}
5034 5085
5086void CalendarView::multiResourceSyncStart( bool start )
5087{
5088 mMultiResourceSync = start;
5035 5089
5090}
5036bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) 5091bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5037{ 5092{
5038 5093
5039 if ( manager != mSyncManager) 5094 if ( manager != mSyncManager)
5040 qDebug("KO: Internal error-1. SyncManager mismatch "); 5095 qDebug("KO: Internal error-1. SyncManager mismatch ");
5041 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5096 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5042 qDebug("KO: SyncKDE request detected!"); 5097 qDebug("KO: SyncKDE request detected!");
5043 } 5098 }
5044 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5099 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5045 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5100 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5046 if ( !resource.isEmpty() ) { 5101 if ( !resource.isEmpty() ) {
5047 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); 5102 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
5048 qDebug( "KO: Sync request for resource: %s", resource.latin1() ); 5103 qDebug( "KO: Sync request for resource: %s", resource.latin1() );
5049 5104
5050 if ( !exclusiveSyncResource ) { 5105 if ( !exclusiveSyncResource ) {
5051 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); 5106 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
5052 return false; 5107 return false;
5053 } 5108 }
5054 mCalendar->setDefaultCalendar( exclusiveSyncResource ); 5109 mCalendar->setDefaultCalendar( exclusiveSyncResource );
5055 mCalendar->setDefaultCalendarEnabledOnly(); 5110 mCalendar->setDefaultCalendarEnabledOnly();
5056 } 5111 }
5057 bool result = syncCalendar( filename, mode ); 5112 bool result = syncCalendar( filename, mode );
5058 if ( !resource.isEmpty() ) 5113 if ( !resource.isEmpty() )
5059 restoreCalendarSettings(); 5114 restoreCalendarSettings();
5060 return result; 5115 return result;
5061} 5116}
5062bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 5117bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
5063{ 5118{
5064 //mSyncManager = manager; 5119 //mSyncManager = manager;
5065 if ( manager != mSyncManager) 5120 if ( manager != mSyncManager)
5066 qDebug("KO: Internal error-2. SyncManager mismatch "); 5121 qDebug("KO: Internal error-2. SyncManager mismatch ");
5067 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5122 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5068 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5123 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5069 if ( resource == "sharp" ) 5124 if ( resource == "sharp" )
5070 syncExternal( 0 ); 5125 syncExternal( 0 );
5071 if ( resource == "phone" ) 5126 if ( resource == "phone" )
5072 syncExternal( 1 ); 5127 syncExternal( 1 );
5073 // pending setmodified 5128 // pending setmodified
5074 return true; 5129 return true;
5075} 5130}
5076void CalendarView::setSyncManager(KSyncManager* manager) 5131void CalendarView::setSyncManager(KSyncManager* manager)
5077{ 5132{
5078 mSyncManager = manager; 5133 mSyncManager = manager;
5079} 5134}
5080 5135
5081void CalendarView::removeSyncInfo( QString syncProfile) 5136void CalendarView::removeSyncInfo( QString syncProfile)
5082{ 5137{
5083 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 5138 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
5084 mCalendar->removeSyncInfo( syncProfile ); 5139 mCalendar->removeSyncInfo( syncProfile );
5085 5140
5086} 5141}
5087 5142
5088void CalendarView::undo_delete() 5143void CalendarView::undo_delete()
5089{ 5144{
5090 //qDebug("undo_delete() "); 5145 //qDebug("undo_delete() ");
5091 Incidence* undo = mCalendar->undoIncidence(); 5146 Incidence* undo = mCalendar->undoIncidence();
5092 if ( !undo ) { 5147 if ( !undo ) {
5093 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 5148 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
5094 i18n("KO/Pi")); 5149 i18n("KO/Pi"));
5095 return; 5150 return;
5096 } 5151 }
5097 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 5152 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
5098 i18n("\nAre you sure you want\nto restore this?"), 5153 i18n("\nAre you sure you want\nto restore this?"),
5099 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 5154 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
5100 mCalendar->undoDeleteIncidence(); 5155 mCalendar->undoDeleteIncidence();
5101 updateView(); 5156 updateView();
5102 } 5157 }
5103} 5158}
5104 5159
5105void CalendarView::slotViewerClosed() 5160void CalendarView::slotViewerClosed()
5106{ 5161{
5107 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 5162 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
5108} 5163}
5109 5164
5110void CalendarView::resetFocus() 5165void CalendarView::resetFocus()
5111{ 5166{
5112 if ( mViewerCallerIsSearchDialog ) { 5167 if ( mViewerCallerIsSearchDialog ) {
5113 if ( mDialogManager->getSearchDialog()->isVisible() ){ 5168 if ( mDialogManager->getSearchDialog()->isVisible() ){
5114 mDialogManager->getSearchDialog()->raise(); 5169 mDialogManager->getSearchDialog()->raise();
5115 mDialogManager->getSearchDialog()->setActiveWindow(); 5170 mDialogManager->getSearchDialog()->setActiveWindow();
5116 mDialogManager->getSearchDialog()->listview()->resetFocus(); 5171 mDialogManager->getSearchDialog()->listview()->resetFocus();
5117 } else 5172 } else
5118 mViewerCallerIsSearchDialog = false; 5173 mViewerCallerIsSearchDialog = false;
5119 } 5174 }
5120 if ( !mViewerCallerIsSearchDialog ) { 5175 if ( !mViewerCallerIsSearchDialog ) {
5121 //mViewManager->currentView()->setFocus(); 5176 //mViewManager->currentView()->setFocus();
5122 //qDebug("sssssssssssssssset focus "); 5177 //qDebug("sssssssssssssssset focus ");
5123 topLevelWidget()->raise(); 5178 topLevelWidget()->raise();
5124 setActiveWindow(); 5179 setActiveWindow();
5125 //setFocus(); 5180 //setFocus();
5126 } 5181 }
5127 mViewerCallerIsSearchDialog = false; 5182 mViewerCallerIsSearchDialog = false;
5128} 5183}
5129 5184
5130void CalendarView::showNextAlarms() 5185void CalendarView::showNextAlarms()
5131{ 5186{
5132 QString message; 5187 QString message;
5133 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 5188 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
5134 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 5189 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
5135 QString sum = mCalendar->nextSummary(); 5190 QString sum = mCalendar->nextSummary();
5136 QDateTime nextA = mNextAlarmDateTime; 5191 QDateTime nextA = mNextAlarmDateTime;
5137 QDateTime cur = QDateTime::currentDateTime(); 5192 QDateTime cur = QDateTime::currentDateTime();
5138 int secs = cur.secsTo( nextA ); 5193 int secs = cur.secsTo( nextA );
5139 int min = secs /60; 5194 int min = secs /60;
5140 int hours = min /60; 5195 int hours = min /60;
5141 min = min % 60; 5196 min = min % 60;
5142 int days = hours /24; 5197 int days = hours /24;
5143 hours = hours % 24; 5198 hours = hours % 24;
5144 5199
5145 //message = i18n("The next alarm is in:\n"); 5200 //message = i18n("The next alarm is in:\n");
5146 if ( days > 1 ) 5201 if ( days > 1 )
5147 message += i18n("%1 days\n").arg( days ); 5202 message += i18n("%1 days\n").arg( days );
5148 else if ( days == 1 ) 5203 else if ( days == 1 )
5149 message += i18n("1 day\n"); 5204 message += i18n("1 day\n");
5150 if ( hours > 1 ) 5205 if ( hours > 1 )
5151 message += i18n("%1 hours\n").arg( hours ); 5206 message += i18n("%1 hours\n").arg( hours );
5152 else if ( hours == 1 ) 5207 else if ( hours == 1 )
5153 message += i18n("1 hour\n"); 5208 message += i18n("1 hour\n");
5154 if ( min > 1 ) 5209 if ( min > 1 )
5155 message += i18n("%1 minutes\n").arg( min ); 5210 message += i18n("%1 minutes\n").arg( min );
5156 else if ( min == 1 ) 5211 else if ( min == 1 )
5157 message += i18n("1 minute\n"); 5212 message += i18n("1 minute\n");
5158 if ( message.isEmpty() ) 5213 if ( message.isEmpty() )
5159 message = i18n("The next alarm is in\nless than one minute!"); 5214 message = i18n("The next alarm is in\nless than one minute!");
5160 else 5215 else
5161 message = i18n("The next alarm is in:\n") + message; 5216 message = i18n("The next alarm is in:\n") + message;
5162 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 5217 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
5163 } else { 5218 } else {
5164 message = i18n("There is no next alarm."); 5219 message = i18n("There is no next alarm.");
5165 5220
5166 } 5221 }
5167#ifdef DESKTOP_VERSION 5222#ifdef DESKTOP_VERSION
5168 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 5223 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
5169 message += i18n("\nThe internal alarm notification is disabled!\n"); 5224 message += i18n("\nThe internal alarm notification is disabled!\n");
5170 message += i18n("Enable it in the settings menu, TAB alarm."); 5225 message += i18n("Enable it in the settings menu, TAB alarm.");
5171 } 5226 }
5172 5227
5173#endif 5228#endif
5174 KMessageBox::information( this, message); 5229 KMessageBox::information( this, message);
5175} 5230}
5176 5231
5177void CalendarView::displayCalendarInfo( int id ) 5232void CalendarView::displayCalendarInfo( int id )
5178{ 5233{
5179 int e, t,j; 5234 int e, t,j;
5180 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 5235 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
5181 QString name = kkf->mName; 5236 QString name = kkf->mName;
5182 mCalendar->getIncidenceCount( id, e, t, j ); 5237 mCalendar->getIncidenceCount( id, e, t, j );
5183 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 5238 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
5184 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); 5239 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file);
5185 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); 5240 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j );
5186 KMessageBox::information( this, mess ); 5241 KMessageBox::information( this, mess );
5187 5242
5188 5243
5189} 5244}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index f85b6a3..60b1276 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,675 +1,679 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#include <qscrollbar.h> 33#include <qscrollbar.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qtopia/ir.h> 35#include <qtopia/ir.h>
36#else 36#else
37#define Ir char 37#define Ir char
38#endif 38#endif
39#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
40#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
44 44
45#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
46 46
47#include <ksyncmanager.h> 47#include <ksyncmanager.h>
48//#include <koprefs.h> 48//#include <koprefs.h>
49 49
50class QWidgetStack; 50class QWidgetStack;
51class QSplitter; 51class QSplitter;
52class KopiCalendarFile; 52class KopiCalendarFile;
53class CalPrinter; 53class CalPrinter;
54class KOFilterView; 54class KOFilterView;
55class KOCalEditView; 55class KOCalEditView;
56class KOViewManager; 56class KOViewManager;
57class KODialogManager; 57class KODialogManager;
58class KOTodoView; 58class KOTodoView;
59class KDateNavigator; 59class KDateNavigator;
60class DateNavigatorContainer; 60class DateNavigatorContainer;
61class DateNavigator; 61class DateNavigator;
62class KOIncidenceEditor; 62class KOIncidenceEditor;
63class KDatePicker; 63class KDatePicker;
64class ResourceView; 64class ResourceView;
65class KOEventEditor; 65class KOEventEditor;
66class KOTodoEditor ; 66class KOTodoEditor ;
67class KOEventViewerDialog; 67class KOEventViewerDialog;
68class KOBeamPrefs; 68class KOBeamPrefs;
69class KSyncProfile; 69class KSyncProfile;
70class AlarmDialog; 70class AlarmDialog;
71class KCal::Attendee; 71class KCal::Attendee;
72 72
73namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
74 74
75using namespace KCal; 75using namespace KCal;
76 76
77/** 77/**
78 This is the main calendar widget. It provides the different vies on t he 78 This is the main calendar widget. It provides the different vies on t he
79 calendar data as well as the date navigator. It also handles synchronisation 79 calendar data as well as the date navigator. It also handles synchronisation
80 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
81 event editor, search dialog etc. 81 event editor, search dialog etc.
82 82
83 @short main calendar view widget 83 @short main calendar view widget
84 @author Cornelius Schumacher 84 @author Cornelius Schumacher
85*/ 85*/
86 86
87#include <qtextbrowser.h> 87#include <qtextbrowser.h>
88#include <qtextcodec.h> 88#include <qtextcodec.h>
89 89
90class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
91 Q_OBJECT 91 Q_OBJECT
92 public: 92 public:
93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
94 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
95 void setSource(const QString & n); 95 void setSource(const QString & n);
96 96
97 private: 97 private:
98 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
99 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
100 signals: 100 signals:
101 void showIncidence( QString uid); 101 void showIncidence( QString uid);
102}; 102};
103 103
104 104
105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 public: 108 public:
109 /** 109 /**
110 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
111 111
112 @param calendar calendar document 112 @param calendar calendar document
113 @param parent parent window 113 @param parent parent window
114 @param name Qt internal widget object name 114 @param name Qt internal widget object name
115 */ 115 */
116 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
119 const char *name = 0 ); 119 const char *name = 0 );
120 virtual ~CalendarView(); 120 virtual ~CalendarView();
121 121
122 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
123 123
124 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
125 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
126 126
127 QDate startDate(); 127 QDate startDate();
128 QDate endDate(); 128 QDate endDate();
129 129
130 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
131 QWidget *leftFrame(); 131 QWidget *leftFrame();
132 132
133 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
134 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
135 135
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 void mergeFileResource( QString fn ,QString res);
142 143
143 signals: 144 signals:
144 void save (); 145 void save ();
145 void saveStopTimer (); 146 void saveStopTimer ();
146 void tempDisableBR(bool); 147 void tempDisableBR(bool);
147 /** This todo has been modified */ 148 /** This todo has been modified */
148 void todoModified(Todo *, int); 149 void todoModified(Todo *, int);
149 150
150 /** when change is made to options dialog, the topwidget will catch this 151 /** when change is made to options dialog, the topwidget will catch this
151 * and emit this signal which notifies all widgets which have registered 152 * and emit this signal which notifies all widgets which have registered
152 * for notification to update their settings. */ 153 * for notification to update their settings. */
153 void configChanged(); 154 void configChanged();
154 /** emitted when the topwidget is closing down, so that any attached 155 /** emitted when the topwidget is closing down, so that any attached
155 child windows can also close. */ 156 child windows can also close. */
156 void closingDown(); 157 void closingDown();
157 /** emitted right before we die */ 158 /** emitted right before we die */
158 void closed(QWidget *); 159 void closed(QWidget *);
159 160
160 /** Emitted when state of modified flag changes */ 161 /** Emitted when state of modified flag changes */
161 void modifiedChanged(bool); 162 void modifiedChanged(bool);
162 void signalmodified(); 163 void signalmodified();
163 164
164 /** Emitted when state of read-only flag changes */ 165 /** Emitted when state of read-only flag changes */
165 void readOnlyChanged(bool); 166 void readOnlyChanged(bool);
166 167
167 /** Emitted when the unit of navigation changes */ 168 /** Emitted when the unit of navigation changes */
168 void changeNavStringPrev(const QString &); 169 void changeNavStringPrev(const QString &);
169 void changeNavStringNext(const QString &); 170 void changeNavStringNext(const QString &);
170 171
171 /** Emitted when state of events selection has changed and user is organizer*/ 172 /** Emitted when state of events selection has changed and user is organizer*/
172 void organizerEventsSelected(bool); 173 void organizerEventsSelected(bool);
173 /** Emitted when state of events selection has changed and user is attendee*/ 174 /** Emitted when state of events selection has changed and user is attendee*/
174 void groupEventsSelected(bool); 175 void groupEventsSelected(bool);
175 /** 176 /**
176 Emitted when an incidence gets selected. If the selection is cleared the 177 Emitted when an incidence gets selected. If the selection is cleared the
177 signal is emitted with 0 as argument. 178 signal is emitted with 0 as argument.
178 */ 179 */
179 void incidenceSelected( Incidence * ); 180 void incidenceSelected( Incidence * );
180 /** Emitted, when a todoitem is selected or deselected. */ 181 /** Emitted, when a todoitem is selected or deselected. */
181 void todoSelected( bool ); 182 void todoSelected( bool );
182 183
183 /** 184 /**
184 Emitted, when clipboard content changes. Parameter indicates if paste 185 Emitted, when clipboard content changes. Parameter indicates if paste
185 is possible or not. 186 is possible or not.
186 */ 187 */
187 void pasteEnabled(bool); 188 void pasteEnabled(bool);
188 189
189 /** Emitted, when the number of incoming messages has changed. */ 190 /** Emitted, when the number of incoming messages has changed. */
190 void numIncomingChanged(int); 191 void numIncomingChanged(int);
191 192
192 /** Emitted, when the number of outgoing messages has changed. */ 193 /** Emitted, when the number of outgoing messages has changed. */
193 void numOutgoingChanged(int); 194 void numOutgoingChanged(int);
194 195
195 /** Send status message, which can e.g. be displayed in the status bar. */ 196 /** Send status message, which can e.g. be displayed in the status bar. */
196 void statusMessage(const QString &); 197 void statusMessage(const QString &);
197 198
198 void calendarViewExpanded( bool ); 199 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 200 void updateSearchDialog();
200 void filtersUpdated(); 201 void filtersUpdated();
201 202
202 203
203 public slots: 204 public slots:
205 void multiResourceSyncStart( bool );
204 void displayCalendarInfo( int id ); 206 void displayCalendarInfo( int id );
205 void nextConflict( bool all, bool allday ); 207 void nextConflict( bool all, bool allday );
206 void conflictAll(); 208 void conflictAll();
207 void conflictAllday(); 209 void conflictAllday();
208 void conflictNotAll(); 210 void conflictNotAll();
209 void setCalReadOnly( int id, bool readO ); 211 void setCalReadOnly( int id, bool readO );
210 void checkAlarms(); 212 void checkAlarms();
211 void checkFiles(); 213 void checkFiles();
212 void slotprintSelInc(); 214 void slotprintSelInc();
213 void showNextAlarms(); 215 void showNextAlarms();
214 void showOpenError(); 216 void showOpenError();
215 void watchSavedFile(); 217 void watchSavedFile();
216 void recheckTimerAlarm(); 218 void recheckTimerAlarm();
217 void checkNextTimerAlarm(); 219 void checkNextTimerAlarm();
218 void addAlarm(const QDateTime &qdt, const QString &noti ); 220 void addAlarm(const QDateTime &qdt, const QString &noti );
219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 221 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
220 void removeAlarm(const QDateTime &qdt, const QString &noti ); 222 void removeAlarm(const QDateTime &qdt, const QString &noti );
221 223
222 /** options dialog made a changed to the configuration. we catch this 224 /** options dialog made a changed to the configuration. we catch this
223 * and notify all widgets which need to update their configuration. */ 225 * and notify all widgets which need to update their configuration. */
224 void updateConfig(); 226 void updateConfig();
225 227
226 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 228 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
227 const QStringList& anniversaryList, const QStringList& realNameList, 229 const QStringList& anniversaryList, const QStringList& realNameList,
228 const QStringList& emailList, const QStringList& assembledNameList, 230 const QStringList& emailList, const QStringList& assembledNameList,
229 const QStringList& uidList); 231 const QStringList& uidList);
230 232
231 /** 233 /**
232 Load calendar from file \a filename. If \a merge is true, load 234 Load calendar from file \a filename. If \a merge is true, load
233 calendar into existing one, if it is false, clear calendar, before 235 calendar into existing one, if it is false, clear calendar, before
234 loading. Return true, if calendar could be successfully loaded. 236 loading. Return true, if calendar could be successfully loaded.
235 */ 237 */
236 bool openCalendar(QString filename, bool merge=false); 238 bool openCalendar(QString filename, bool merge=false);
237 bool loadCalendars(); 239 bool loadCalendars();
238 bool saveCalendars(); 240 bool saveCalendars();
239 bool restoreCalendarSettings(); 241 bool restoreCalendarSettings();
240 bool addCalendar( KopiCalendarFile * ); 242 bool addCalendar( KopiCalendarFile * );
241 void addCalendarId( int id ); 243 void addCalendarId( int id );
242 bool syncCalendar(QString filename,int mode = 0 ); 244 bool syncCalendar(QString filename,int mode = 0 );
243 245
244 /** 246 /**
245 Save calendar data to file. Return true if calendar could be 247 Save calendar data to file. Return true if calendar could be
246 successfully saved. 248 successfully saved.
247 */ 249 */
248 bool saveCalendar(QString filename); 250 bool saveCalendar(QString filename);
251 bool saveCalendarResource(QString filename, QString resource);
249 252
250 /** 253 /**
251 Close calendar. Clear calendar data and reset views to display an empty 254 Close calendar. Clear calendar data and reset views to display an empty
252 calendar. 255 calendar.
253 */ 256 */
254 void closeCalendar(); 257 void closeCalendar();
255 258
256 /** Archive old events of calendar */ 259 /** Archive old events of calendar */
257 void archiveCalendar(); 260 void archiveCalendar();
258 261
259 void showIncidence(); 262 void showIncidence();
260 void editIncidence(); 263 void editIncidence();
261 void editIncidenceDescription(); 264 void editIncidenceDescription();
262 void deleteIncidence(); 265 void deleteIncidence();
263 void cloneIncidence(); 266 void cloneIncidence();
264 void moveIncidence(); 267 void moveIncidence();
265 void beamIncidence(); 268 void beamIncidence();
266 void toggleCancelIncidence(); 269 void toggleCancelIncidence();
267 270
268 /** create an editeventwin with supplied date/time, and if bool is true, 271 /** create an editeventwin with supplied date/time, and if bool is true,
269 * make the event take all day. */ 272 * make the event take all day. */
270 void newEvent(QDateTime, QDateTime, bool allDay ); 273 void newEvent(QDateTime, QDateTime, bool allDay );
271 void newEvent(QDateTime, QDateTime); 274 void newEvent(QDateTime, QDateTime);
272 void newEvent(QDateTime fh); 275 void newEvent(QDateTime fh);
273 void newEvent(QDate dt); 276 void newEvent(QDate dt);
274 /** create new event without having a date hint. Takes current date as 277 /** create new event without having a date hint. Takes current date as
275 default hint. */ 278 default hint. */
276 void newEvent(); 279 void newEvent();
277 void newFloatingEvent(); 280 void newFloatingEvent();
278 281
279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 282 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
280 void showIncidence(Incidence *); 283 void showIncidence(Incidence *);
281 void showIncidence(QString uid); 284 void showIncidence(QString uid);
282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 285 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
283 void editIncidence(Incidence *); 286 void editIncidence(Incidence *);
284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 287 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
285 void deleteIncidence(Incidence *); 288 void deleteIncidence(Incidence *);
286 void cloneIncidence(Incidence *); 289 void cloneIncidence(Incidence *);
287 void cancelIncidence(Incidence *); 290 void cancelIncidence(Incidence *);
288 /** Create an editor for the supplied event. */ 291 /** Create an editor for the supplied event. */
289 void editEvent(Event *); 292 void editEvent(Event *);
290 /** Delete the supplied event. */ 293 /** Delete the supplied event. */
291 void deleteEvent(Event *); 294 void deleteEvent(Event *);
292 /** Delete the event with the given unique ID. Returns false, if event wasn't 295 /** Delete the event with the given unique ID. Returns false, if event wasn't
293 found. */ 296 found. */
294 bool deleteEvent(const QString &uid); 297 bool deleteEvent(const QString &uid);
295 /** Create a read-only viewer dialog for the supplied event. */ 298 /** Create a read-only viewer dialog for the supplied event. */
296 void showEvent(Event *); 299 void showEvent(Event *);
297 300
298 void editJournal(Journal *); 301 void editJournal(Journal *);
299 void showJournal(Journal *); 302 void showJournal(Journal *);
300 void deleteJournal(Journal *); 303 void deleteJournal(Journal *);
301 /** Create an editor dialog for a todo */ 304 /** Create an editor dialog for a todo */
302 void editTodo(Todo *); 305 void editTodo(Todo *);
303 /** Create a read-only viewer dialog for the supplied todo */ 306 /** Create a read-only viewer dialog for the supplied todo */
304 void showTodo(Todo *); 307 void showTodo(Todo *);
305 /** create new todo */ 308 /** create new todo */
306 void newTodo(); 309 void newTodo();
307 void newTodoDateTime(QDateTime, bool allday); 310 void newTodoDateTime(QDateTime, bool allday);
308 /** create new todo with a parent todo */ 311 /** create new todo with a parent todo */
309 void newSubTodo(); 312 void newSubTodo();
310 /** create new todo with a parent todo */ 313 /** create new todo with a parent todo */
311 void newSubTodo(Todo *); 314 void newSubTodo(Todo *);
312 /** Delete todo */ 315 /** Delete todo */
313 void deleteTodo(Todo *); 316 void deleteTodo(Todo *);
314 317
315 318
316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 319 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
317 * emitted as result. */ 320 * emitted as result. */
318 void checkClipboard(); 321 void checkClipboard();
319 322
320 /** using the KConfig associated with the kapp variable, read in the 323 /** using the KConfig associated with the kapp variable, read in the
321 * settings from the config file. 324 * settings from the config file.
322 */ 325 */
323 void readSettings(); 326 void readSettings();
324 327
325 /** write current state to config file. */ 328 /** write current state to config file. */
326 void writeSettings(); 329 void writeSettings();
327 330
328 /** read settings for calendar filters */ 331 /** read settings for calendar filters */
329 void readFilterSettings(KConfig *config); 332 void readFilterSettings(KConfig *config);
330 333
331 /** write settings for calendar filters */ 334 /** write settings for calendar filters */
332 void writeFilterSettings(KConfig *config); 335 void writeFilterSettings(KConfig *config);
333 336
334 /** passes on the message that an event has changed to the currently 337 /** passes on the message that an event has changed to the currently
335 * activated view so that it can make appropriate display changes. */ 338 * activated view so that it can make appropriate display changes. */
336 void changeEventDisplay(Event *, int); 339 void changeEventDisplay(Event *, int);
337 void changeIncidenceDisplay(Incidence *, int); 340 void changeIncidenceDisplay(Incidence *, int);
338 void changeTodoDisplay(Todo *, int); 341 void changeTodoDisplay(Todo *, int);
339 342
340 void eventAdded(Event *); 343 void eventAdded(Event *);
341 void eventChanged(Event *); 344 void eventChanged(Event *);
342 void eventToBeDeleted(Event *); 345 void eventToBeDeleted(Event *);
343 void eventDeleted(); 346 void eventDeleted();
344 347
345 void todoAdded(Todo *); 348 void todoAdded(Todo *);
346 void todoChanged(Todo *); 349 void todoChanged(Todo *);
347 void todoToBeDeleted(Todo *); 350 void todoToBeDeleted(Todo *);
348 void todoDeleted(); 351 void todoDeleted();
349 352
350 void updateView(const QDate &start, const QDate &end); 353 void updateView(const QDate &start, const QDate &end);
351 void updateView(); 354 void updateView();
352 void clearAllViews(); 355 void clearAllViews();
353 356
354 /** Full update of visible todo views */ 357 /** Full update of visible todo views */
355 void updateTodoViews(); 358 void updateTodoViews();
356 359
357 void updateUnmanagedViews(); 360 void updateUnmanagedViews();
358 361
359 /** cut the current appointment to the clipboard */ 362 /** cut the current appointment to the clipboard */
360 void edit_cut(); 363 void edit_cut();
361 364
362 /** copy the current appointment(s) to the clipboard */ 365 /** copy the current appointment(s) to the clipboard */
363 void edit_copy(); 366 void edit_copy();
364 367
365 /** paste the current vobject(s) in the clipboard buffer into calendar */ 368 /** paste the current vobject(s) in the clipboard buffer into calendar */
366 void edit_paste(); 369 void edit_paste();
367 370
368 /** edit viewing and configuration options. */ 371 /** edit viewing and configuration options. */
369 void edit_options(); 372 void edit_options();
370 void edit_global_options(); 373 void edit_global_options();
371 /** 374 /**
372 Functions for printing, previewing a print, and setting up printing 375 Functions for printing, previewing a print, and setting up printing
373 parameters. 376 parameters.
374 */ 377 */
375 void print(); 378 void print();
376 void printSetup(); 379 void printSetup();
377 void printPreview(); 380 void printPreview();
378 381
379 /** Export as iCalendar file */ 382 /** Export as iCalendar file */
380 bool exportICalendar(); 383 bool exportICalendar();
381 bool exportICalendar( QString fn ); 384 bool exportICalendar( QString fn );
382 385
383 /** Export as vCalendar file */ 386 /** Export as vCalendar file */
384 bool exportVCalendar( QString fn); 387 bool exportVCalendar( QString fn);
385 388
386 /** pop up a dialog to show an existing appointment. */ 389 /** pop up a dialog to show an existing appointment. */
387 void appointment_show(); 390 void appointment_show();
388 /** 391 /**
389 * pop up an Appointment Dialog to edit an existing appointment.Get 392 * pop up an Appointment Dialog to edit an existing appointment.Get
390 * information on the appointment from the list of unique IDs that is 393 * information on the appointment from the list of unique IDs that is
391 * currently in the View, called currIds. 394 * currently in the View, called currIds.
392 */ 395 */
393 void appointment_edit(); 396 void appointment_edit();
394 /** 397 /**
395 * pop up dialog confirming deletion of currently selected event in the 398 * pop up dialog confirming deletion of currently selected event in the
396 * View. 399 * View.
397 */ 400 */
398 void appointment_delete(); 401 void appointment_delete();
399 402
400 /** mails the currently selected event to a particular user as a vCalendar 403 /** mails the currently selected event to a particular user as a vCalendar
401 attachment. */ 404 attachment. */
402 void action_mail(); 405 void action_mail();
403 406
404 /* frees a subtodo from it's relation */ 407 /* frees a subtodo from it's relation */
405 void todo_unsub( Todo * ); 408 void todo_unsub( Todo * );
406 void todo_resub( Todo * parent, Todo * sub ); 409 void todo_resub( Todo * parent, Todo * sub );
407 410
408 /** Take ownership of selected event. */ 411 /** Take ownership of selected event. */
409 void takeOverEvent(); 412 void takeOverEvent();
410 413
411 /** Take ownership of all events in calendar. */ 414 /** Take ownership of all events in calendar. */
412 void takeOverCalendar(); 415 void takeOverCalendar();
413 416
414 /** query whether or not the calendar is "dirty". */ 417 /** query whether or not the calendar is "dirty". */
415 bool isModified(); 418 bool isModified();
416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 419 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
417 void setModified(bool modified=true); 420 void setModified(bool modified=true);
418 421
419 /** query if the calendar is read-only. */ 422 /** query if the calendar is read-only. */
420 bool isReadOnly(); 423 bool isReadOnly();
421 /** set state of calendar to read-only */ 424 /** set state of calendar to read-only */
422 void setReadOnly(bool readOnly=true); 425 void setReadOnly(bool readOnly=true);
423 426
424 void eventUpdated(Incidence *); 427 void eventUpdated(Incidence *);
425 428
426 /* iTIP scheduling actions */ 429 /* iTIP scheduling actions */
427 void schedule_publish(Incidence *incidence = 0); 430 void schedule_publish(Incidence *incidence = 0);
428 void schedule_request(Incidence *incidence = 0); 431 void schedule_request(Incidence *incidence = 0);
429 void schedule_refresh(Incidence *incidence = 0); 432 void schedule_refresh(Incidence *incidence = 0);
430 void schedule_cancel(Incidence *incidence = 0); 433 void schedule_cancel(Incidence *incidence = 0);
431 void schedule_add(Incidence *incidence = 0); 434 void schedule_add(Incidence *incidence = 0);
432 void schedule_reply(Incidence *incidence = 0); 435 void schedule_reply(Incidence *incidence = 0);
433 void schedule_counter(Incidence *incidence = 0); 436 void schedule_counter(Incidence *incidence = 0);
434 void schedule_declinecounter(Incidence *incidence = 0); 437 void schedule_declinecounter(Incidence *incidence = 0);
435 void schedule_publish_freebusy(int daysToPublish = 30); 438 void schedule_publish_freebusy(int daysToPublish = 30);
436 439
437 void openAddressbook(); 440 void openAddressbook();
438 441
439 void editFilters(); 442 void editFilters();
440 void toggleFilerEnabled(); 443 void toggleFilerEnabled();
441 QPtrList<CalFilter> filters(); 444 QPtrList<CalFilter> filters();
442 void toggleFilter(); 445 void toggleFilter();
443 void showFilter(bool visible); 446 void showFilter(bool visible);
444 void updateFilter(); 447 void updateFilter();
445 void filterEdited(); 448 void filterEdited();
446 void selectFilter( int ); 449 void selectFilter( int );
447 KOFilterView *filterView(); 450 KOFilterView *filterView();
448 451
449 void showIntro(); 452 void showIntro();
450 453
451 /** Move the curdatepient view date to today */ 454 /** Move the curdatepient view date to today */
452 void goToday(); 455 void goToday();
453 456
454 /** Move to the next date(s) in the current view */ 457 /** Move to the next date(s) in the current view */
455 void goNext(); 458 void goNext();
456 459
457 /** Move to the previous date(s) in the current view */ 460 /** Move to the previous date(s) in the current view */
458 void goPrevious(); 461 void goPrevious();
459 /** Move to the next date(s) in the current view */ 462 /** Move to the next date(s) in the current view */
460 void goNextMonth(); 463 void goNextMonth();
461 464
462 /** Move to the previous date(s) in the current view */ 465 /** Move to the previous date(s) in the current view */
463 void goPreviousMonth(); 466 void goPreviousMonth();
464 467
465 void toggleExpand(); 468 void toggleExpand();
466 void toggleDateNavigatorWidget(); 469 void toggleDateNavigatorWidget();
467 void toggleAllDaySize(); 470 void toggleAllDaySize();
468 471
469 /** Look for new messages in the inbox */ 472 /** Look for new messages in the inbox */
470 void lookForIncomingMessages(); 473 void lookForIncomingMessages();
471 /** Look for new messages in the outbox */ 474 /** Look for new messages in the outbox */
472 void lookForOutgoingMessages(); 475 void lookForOutgoingMessages();
473 476
474 void processMainViewSelection( Incidence * ); 477 void processMainViewSelection( Incidence * );
475 void processTodoListSelection( Incidence * ); 478 void processTodoListSelection( Incidence * );
476 479
477 void processIncidenceSelection( Incidence * ); 480 void processIncidenceSelection( Incidence * );
478 481
479 void purgeCompleted(); 482 void purgeCompleted();
480 bool removeCompletedSubTodos( Todo* ); 483 bool removeCompletedSubTodos( Todo* );
481 void slotCalendarChanged(); 484 void slotCalendarChanged();
482 bool importBday(); 485 bool importBday();
483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 486 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
484 bool importQtopia( const QString &categoriesFile, 487 bool importQtopia( const QString &categoriesFile,
485 const QString &datebookFile, 488 const QString &datebookFile,
486 const QString &tasklistFile ); 489 const QString &tasklistFile );
487 void syncExternal( int mode ); 490 void syncExternal( int mode );
488 void slotSelectPickerDate( QDate ) ; 491 void slotSelectPickerDate( QDate ) ;
489 void showDatePicker() ; 492 void showDatePicker() ;
490 void showDatePickerPopup() ; 493 void showDatePickerPopup() ;
491 void moveIncidence(Incidence *) ; 494 void moveIncidence(Incidence *) ;
492 void beamIncidence(Incidence *) ; 495 void beamIncidence(Incidence *) ;
493 void beamCalendar() ; 496 void beamCalendar() ;
494 void beamFilteredCalendar() ; 497 void beamFilteredCalendar() ;
495 void beamIncidenceList(QPtrList<Incidence>) ; 498 void beamIncidenceList(QPtrList<Incidence>) ;
496 void manageCategories(); 499 void manageCategories();
497 void editCategories(); 500 void editCategories();
498 int addCategories(); 501 int addCategories();
499 void removeCategories(); 502 void removeCategories();
500 void setSyncDevice( QString ); 503 void setSyncDevice( QString );
501 void setSyncName( QString ); 504 void setSyncName( QString );
502 void showDay( QDate ); 505 void showDay( QDate );
503 void undo_delete(); 506 void undo_delete();
504 protected slots: 507 protected slots:
505 void resetFocus(); 508 void resetFocus();
506 void scrollBarValue(int); 509 void scrollBarValue(int);
507 void slotViewerClosed(); 510 void slotViewerClosed();
508 void timerAlarm(); 511 void timerAlarm();
509 void suspendAlarm(); 512 void suspendAlarm();
510 void beamDone( Ir *ir ); 513 void beamDone( Ir *ir );
511 /** Select a view or adapt the current view to display the specified dates. */ 514 /** Select a view or adapt the current view to display the specified dates. */
512 void showDates( const KCal::DateList & ); 515 void showDates( const KCal::DateList & );
513 void selectWeekNum ( int ); 516 void selectWeekNum ( int );
514 void checkConflictForEvent(); 517 void checkConflictForEvent();
515 518
516 public: 519 public:
517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); 520 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval );
518 // show a standard warning 521 // show a standard warning
519 // returns KMsgBox::yesNoCancel() 522 // returns KMsgBox::yesNoCancel()
520 int msgCalModified(); 523 int msgCalModified();
521 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource); 524 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
522 525
523 virtual bool syncExternal(KSyncManager* manager, QString resource); 526 virtual bool syncExternal(KSyncManager* manager, QString resource);
524 virtual void removeSyncInfo( QString syncProfile); 527 virtual void removeSyncInfo( QString syncProfile);
525 void setSyncManager(KSyncManager* manager); 528 void setSyncManager(KSyncManager* manager);
526 void setLoadedFileVersion(QDateTime); 529 void setLoadedFileVersion(QDateTime);
527 bool checkFileVersion(QString fn); 530 bool checkFileVersion(QString fn);
528 bool checkAllFileVersions(); 531 bool checkAllFileVersions();
529 bool checkFileChanged(QString fn); 532 bool checkFileChanged(QString fn);
530 Event* getLastSyncEvent(); 533 Event* getLastSyncEvent();
531 /** Adapt navigation units correpsonding to step size of navigation of the 534 /** Adapt navigation units correpsonding to step size of navigation of the
532 * current view. 535 * current view.
533 */ 536 */
534 void adaptNavigationUnits(); 537 void adaptNavigationUnits();
535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 538 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 539 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 540 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 541 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 542 void setScrollBarStep(int val );
540 543
541 protected: 544 protected:
545 bool mMultiResourceSync;
542 Event *mConflictingEvent; 546 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 547 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 548
545 // returns KMsgBox::OKCandel() 549 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 550 int msgItemDelete(const QString name);
547 void showEventEditor(); 551 void showEventEditor();
548 void showTodoEditor(); 552 void showTodoEditor();
549 Todo *selectedTodo(); 553 Todo *selectedTodo();
550 private: 554 private:
551#ifdef DESKTOP_VERSION 555#ifdef DESKTOP_VERSION
552 QScrollBar * mDateScrollBar; 556 QScrollBar * mDateScrollBar;
553#endif 557#endif
554 bool flag_blockConflict; 558 bool flag_blockConflict;
555 bool flag_blockScrollBar; 559 bool flag_blockScrollBar;
556 bool flag_checkFileFirsttime; 560 bool flag_checkFileFirsttime;
557 bool flag_clearallviewsEventDisplay; 561 bool flag_clearallviewsEventDisplay;
558 bool flag_clearallviewsupdateView; 562 bool flag_clearallviewsupdateView;
559 QDateTime mNextAlarmDateTime; 563 QDateTime mNextAlarmDateTime;
560 bool mViewerCallerIsSearchDialog; 564 bool mViewerCallerIsSearchDialog;
561 bool mBlockShowDates; 565 bool mBlockShowDates;
562 KSyncManager* mSyncManager; 566 KSyncManager* mSyncManager;
563 AlarmDialog * mAlarmDialog; 567 AlarmDialog * mAlarmDialog;
564 QString mAlarmNotification; 568 QString mAlarmNotification;
565 QString mSuspendAlarmNotification; 569 QString mSuspendAlarmNotification;
566 QTimer* mSuspendTimer; 570 QTimer* mSuspendTimer;
567 QTimer* mAlarmTimer; 571 QTimer* mAlarmTimer;
568 QTimer* mRecheckAlarmTimer; 572 QTimer* mRecheckAlarmTimer;
569 void computeAlarm( QString ); 573 void computeAlarm( QString );
570 void startAlarm( QString, QString ); 574 void startAlarm( QString, QString );
571 void setSyncEventsReadOnly(); 575 void setSyncEventsReadOnly();
572 576
573 QDateTime loadedFileVersion; 577 QDateTime loadedFileVersion;
574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 578 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
575 void checkExternalId( Incidence * inc ); 579 void checkExternalId( Incidence * inc );
576 int mGlobalSyncMode; 580 int mGlobalSyncMode;
577 QString mCurrentSyncDevice; 581 QString mCurrentSyncDevice;
578 QString mCurrentSyncName; 582 QString mCurrentSyncName;
579 void init(); 583 void init();
580 int mDatePickerMode; 584 int mDatePickerMode;
581 bool mFlagEditDescription; 585 bool mFlagEditDescription;
582 QDateTime mLastCalendarSync; 586 QDateTime mLastCalendarSync;
583 void createPrinter(); 587 void createPrinter();
584 588
585 void calendarModified( bool, Calendar * ); 589 void calendarModified( bool, Calendar * );
586 590
587 CalPrinter *mCalPrinter; 591 CalPrinter *mCalPrinter;
588 592
589 QSplitter *mPanner; 593 QSplitter *mPanner;
590 QSplitter *mLeftSplitter; 594 QSplitter *mLeftSplitter;
591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 595 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
592 QWidgetStack *mRightFrame; 596 QWidgetStack *mRightFrame;
593 597
594 KDatePicker* mDatePicker; 598 KDatePicker* mDatePicker;
595 QVBox* mDateFrame; 599 QVBox* mDateFrame;
596 600
597 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 601 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
598 602
599 KOFilterView *mFilterView; 603 KOFilterView *mFilterView;
600 KOCalEditView *mCalEditView; 604 KOCalEditView *mCalEditView;
601 605
602 ResourceView *mResourceView; 606 ResourceView *mResourceView;
603 607
604 // calendar object for this viewing instance 608 // calendar object for this viewing instance
605 Calendar *mCalendar; 609 Calendar *mCalendar;
606 610
607 CalendarResourceManager *mResourceManager; 611 CalendarResourceManager *mResourceManager;
608 612
609 FileStorage *mStorage; 613 FileStorage *mStorage;
610 614
611 DateNavigator *mNavigator; 615 DateNavigator *mNavigator;
612 616
613 KOViewManager *mViewManager; 617 KOViewManager *mViewManager;
614 KODialogManager *mDialogManager; 618 KODialogManager *mDialogManager;
615 619
616 // Calendar filters 620 // Calendar filters
617 QPtrList<CalFilter> mFilters; 621 QPtrList<CalFilter> mFilters;
618 622
619 // various housekeeping variables. 623 // various housekeeping variables.
620 bool mModified; // flag indicating if calendar is modified 624 bool mModified; // flag indicating if calendar is modified
621 bool mReadOnly; // flag indicating if calendar is read-only 625 bool mReadOnly; // flag indicating if calendar is read-only
622 QDate mSaveSingleDate; 626 QDate mSaveSingleDate;
623 627
624 Incidence *mSelectedIncidence; 628 Incidence *mSelectedIncidence;
625 Incidence *mMoveIncidence; 629 Incidence *mMoveIncidence;
626 QDate mMoveIncidenceOldDate; 630 QDate mMoveIncidenceOldDate;
627 KOTodoView *mTodoList; 631 KOTodoView *mTodoList;
628 KOEventEditor * mEventEditor; 632 KOEventEditor * mEventEditor;
629 KOTodoEditor * mTodoEditor; 633 KOTodoEditor * mTodoEditor;
630 KOEventViewerDialog * mEventViewerDialog; 634 KOEventViewerDialog * mEventViewerDialog;
631 void keyPressEvent ( QKeyEvent *e) ; 635 void keyPressEvent ( QKeyEvent *e) ;
632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 636 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
633}; 637};
634 638
635 639
636class CalendarViewVisitor : public Incidence::Visitor 640class CalendarViewVisitor : public Incidence::Visitor
637{ 641{
638 public: 642 public:
639 CalendarViewVisitor() : mView( 0 ) {} 643 CalendarViewVisitor() : mView( 0 ) {}
640 644
641 bool act( Incidence *incidence, CalendarView *view ) 645 bool act( Incidence *incidence, CalendarView *view )
642 { 646 {
643 mView = view; 647 mView = view;
644 return incidence->accept( *this ); 648 return incidence->accept( *this );
645 } 649 }
646 650
647 protected: 651 protected:
648 CalendarView *mView; 652 CalendarView *mView;
649}; 653};
650 654
651class ShowIncidenceVisitor : public CalendarViewVisitor 655class ShowIncidenceVisitor : public CalendarViewVisitor
652{ 656{
653 protected: 657 protected:
654 bool visit( Event *event ) { mView->showEvent( event ); return true; } 658 bool visit( Event *event ) { mView->showEvent( event ); return true; }
655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 659 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
656 bool visit( Journal * j ) { mView->showJournal( j );return true; } 660 bool visit( Journal * j ) { mView->showJournal( j );return true; }
657}; 661};
658 662
659class EditIncidenceVisitor : public CalendarViewVisitor 663class EditIncidenceVisitor : public CalendarViewVisitor
660{ 664{
661 protected: 665 protected:
662 bool visit( Event *event ) { mView->editEvent( event ); return true; } 666 bool visit( Event *event ) { mView->editEvent( event ); return true; }
663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 667 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
664 bool visit( Journal *j ) { mView->editJournal( j); return true; } 668 bool visit( Journal *j ) { mView->editJournal( j); return true; }
665}; 669};
666 670
667class DeleteIncidenceVisitor : public CalendarViewVisitor 671class DeleteIncidenceVisitor : public CalendarViewVisitor
668{ 672{
669 protected: 673 protected:
670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 674 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 675 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 676 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
673}; 677};
674 678
675#endif 679#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2821 +1,2823 @@
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 mAutoSaveDisabled = false; 173 mAutoSaveDisabled = false;
174 mClosed = false; 174 mClosed = false;
175 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 175 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
176 QString confFile = locateLocal("config","korganizerrc"); 176 QString confFile = locateLocal("config","korganizerrc");
177 QFileInfo finf ( confFile ); 177 QFileInfo finf ( confFile );
178 bool showWarning = !finf.exists(); 178 bool showWarning = !finf.exists();
179 setIcon(SmallIcon( "ko24" ) ); 179 setIcon(SmallIcon( "ko24" ) );
180 mBlockAtStartup = true; 180 mBlockAtStartup = true;
181 mFlagKeyPressed = false; 181 mFlagKeyPressed = false;
182 setCaption("KO/Pi"); 182 setCaption("KO/Pi");
183 KOPrefs *p = KOPrefs::instance(); 183 KOPrefs *p = KOPrefs::instance();
184 //KPimGlobalPrefs::instance()->setGlobalConfig(); 184 //KPimGlobalPrefs::instance()->setGlobalConfig();
185 p->mCurrentDisplayedView = 0; 185 p->mCurrentDisplayedView = 0;
186 if ( p->mHourSize > 22 ) 186 if ( p->mHourSize > 22 )
187 p->mHourSize = 22; 187 p->mHourSize = 22;
188 QMainWindow::ToolBarDock tbd; 188 QMainWindow::ToolBarDock tbd;
189 if ( p->mToolBarHor ) { 189 if ( p->mToolBarHor ) {
190 if ( p->mToolBarUp ) 190 if ( p->mToolBarUp )
191 tbd = Bottom; 191 tbd = Bottom;
192 else 192 else
193 tbd = Top; 193 tbd = Top;
194 } 194 }
195 else { 195 else {
196 if ( p->mToolBarUp ) 196 if ( p->mToolBarUp )
197 tbd = Right; 197 tbd = Right;
198 else 198 else
199 tbd = Left; 199 tbd = Left;
200 } 200 }
201 if ( KOPrefs::instance()->mUseAppColors ) 201 if ( KOPrefs::instance()->mUseAppColors )
202 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 202 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
203 globalFlagBlockStartup = 1; 203 globalFlagBlockStartup = 1;
204 iconToolBar = new QPEToolBar( this ); 204 iconToolBar = new QPEToolBar( this );
205 addToolBar (iconToolBar , tbd ); 205 addToolBar (iconToolBar , tbd );
206 206
207#ifdef DESKTOP_VERSION 207#ifdef DESKTOP_VERSION
208 if ( KOPrefs::instance()->mShowIconFilter ) 208 if ( KOPrefs::instance()->mShowIconFilter )
209#else 209#else
210 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) ) 210 if ( KOPrefs::instance()->mShowIconFilter || ( !p->mShowIconOnetoolbar &&!p->mShowIconFilterview ) )
211#endif 211#endif
212 212
213{ 213{
214 if ( p->mToolBarHorF ) { 214 if ( p->mToolBarHorF ) {
215 if ( p->mToolBarUpF ) 215 if ( p->mToolBarUpF )
216 tbd = Bottom; 216 tbd = Bottom;
217 else 217 else
218 tbd = Top; 218 tbd = Top;
219 } 219 }
220 else { 220 else {
221 if ( p->mToolBarUpF ) 221 if ( p->mToolBarUpF )
222 tbd = Right; 222 tbd = Right;
223 else 223 else
224 tbd = Left; 224 tbd = Left;
225 } 225 }
226 filterToolBar = new QPEToolBar ( this ); 226 filterToolBar = new QPEToolBar ( this );
227 filterMenubar = new KMenuBar( 0 ); 227 filterMenubar = new KMenuBar( 0 );
228 QFontMetrics fm ( filterMenubar->font() ); 228 QFontMetrics fm ( filterMenubar->font() );
229#ifndef DESKTOP_VERSION 229#ifndef DESKTOP_VERSION
230 filterToolBar->setFocusPolicy( NoFocus ); 230 filterToolBar->setFocusPolicy( NoFocus );
231 filterMenubar->setFocusPolicy( NoFocus ); 231 filterMenubar->setFocusPolicy( NoFocus );
232#endif 232#endif
233 filterPopupMenu = new QPopupMenu( this ); 233 filterPopupMenu = new QPopupMenu( this );
234 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 234 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
235 QString addTest = "A"; 235 QString addTest = "A";
236 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 236 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
237#ifdef DESKTOP_VERSION 237#ifdef DESKTOP_VERSION
238 addTest = "AAAAAABBBCCCx"; 238 addTest = "AAAAAABBBCCCx";
239#else 239#else
240 addTest = "AAAAAx"; 240 addTest = "AAAAAx";
241#endif 241#endif
242 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 242 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
243 addToolBar (filterToolBar , tbd ); 243 addToolBar (filterToolBar , tbd );
244 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 244 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
245 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 245 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
246 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 246 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
247 filterToolBar->hide(); 247 filterToolBar->hide();
248 } else { 248 } else {
249 filterToolBar = 0; 249 filterToolBar = 0;
250 filterMenubar = 0; 250 filterMenubar = 0;
251 filterPopupMenu = 0; 251 filterPopupMenu = 0;
252 } 252 }
253 if ( p->mShowIconOnetoolbar ) { 253 if ( p->mShowIconOnetoolbar ) {
254 viewToolBar = iconToolBar ; 254 viewToolBar = iconToolBar ;
255 navigatorToolBar = iconToolBar ; 255 navigatorToolBar = iconToolBar ;
256 } else { 256 } else {
257#ifndef DESKTOP_VERSION 257#ifndef DESKTOP_VERSION
258 setToolBarsMovable( false ); 258 setToolBarsMovable( false );
259#endif 259#endif
260 if ( p->mToolBarHorV ) { 260 if ( p->mToolBarHorV ) {
261 if ( p->mToolBarUpV ) 261 if ( p->mToolBarUpV )
262 tbd = Bottom; 262 tbd = Bottom;
263 else 263 else
264 tbd = Top; 264 tbd = Top;
265 } 265 }
266 else { 266 else {
267 if ( p->mToolBarUpV ) 267 if ( p->mToolBarUpV )
268 tbd = Right; 268 tbd = Right;
269 else 269 else
270 tbd = Left; 270 tbd = Left;
271 } 271 }
272 viewToolBar = new QPEToolBar( this ); 272 viewToolBar = new QPEToolBar( this );
273 addToolBar (viewToolBar , tbd ); 273 addToolBar (viewToolBar , tbd );
274 if ( p->mToolBarHorN ) { 274 if ( p->mToolBarHorN ) {
275 if ( p->mToolBarUpN ) 275 if ( p->mToolBarUpN )
276 tbd = Bottom; 276 tbd = Bottom;
277 else 277 else
278 tbd = Top; 278 tbd = Top;
279 } 279 }
280 else { 280 else {
281 if ( p->mToolBarUpN ) 281 if ( p->mToolBarUpN )
282 tbd = Right; 282 tbd = Right;
283 else 283 else
284 tbd = Left; 284 tbd = Left;
285 } 285 }
286 navigatorToolBar = new QPEToolBar( this ); 286 navigatorToolBar = new QPEToolBar( this );
287 addToolBar (navigatorToolBar , tbd ); 287 addToolBar (navigatorToolBar , tbd );
288 } 288 }
289 289
290 290
291 291
292 mCalendarModifiedFlag = false; 292 mCalendarModifiedFlag = false;
293 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 293 // QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
294 //splash->setAlignment ( AlignCenter ); 294 //splash->setAlignment ( AlignCenter );
295 //setCentralWidget( splash ); 295 //setCentralWidget( splash );
296#ifndef DESKTOP_VERSION 296#ifndef DESKTOP_VERSION
297 //showMaximized(); 297 //showMaximized();
298#endif 298#endif
299 299
300 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 300 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
301 setDefaultPreferences(); 301 setDefaultPreferences();
302 mCalendar = new CalendarLocal(); 302 mCalendar = new CalendarLocal();
303 mView = new CalendarView( mCalendar, this,"mCalendar " ); 303 mView = new CalendarView( mCalendar, this,"mCalendar " );
304 setCentralWidget( mView ); 304 setCentralWidget( mView );
305 //mView->hide(); 305 //mView->hide();
306 //mView->resize(splash->size() ); 306 //mView->resize(splash->size() );
307 initActions(); 307 initActions();
308 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 308 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
309 mSyncManager->setBlockSave(false); 309 mSyncManager->setBlockSave(false);
310 mView->setSyncManager(mSyncManager); 310 mView->setSyncManager(mSyncManager);
311#ifndef DESKTOP_VERSION 311#ifndef DESKTOP_VERSION
312 iconToolBar->show(); 312 iconToolBar->show();
313 qApp->processEvents(); 313 qApp->processEvents();
314#endif 314#endif
315 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 315 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
316 int vh = height() ; 316 int vh = height() ;
317 int vw = width(); 317 int vw = width();
318 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 318 //qDebug("Toolbar hei %d ",iconToolBar->height() );
319 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 319 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
320 vh -= iconToolBar->height(); 320 vh -= iconToolBar->height();
321 } else { 321 } else {
322 vw -= iconToolBar->height(); 322 vw -= iconToolBar->height();
323 } 323 }
324 //mView->setMaximumSize( splash->size() ); 324 //mView->setMaximumSize( splash->size() );
325 //mView->resize( splash->size() ); 325 //mView->resize( splash->size() );
326 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 326 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
327 mView->readSettings(); 327 mView->readSettings();
328 bool newFile = false; 328 bool newFile = false;
329 if( !QFile::exists( defaultFileName() ) ) { 329 if( !QFile::exists( defaultFileName() ) ) {
330 QFileInfo finfo ( defaultFileName() ); 330 QFileInfo finfo ( defaultFileName() );
331 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 331 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
332 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"; 332 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";
333 finfo.setFile( oldFile ); 333 finfo.setFile( oldFile );
334 if (finfo.exists() ) { 334 if (finfo.exists() ) {
335 KMessageBox::information( this, message); 335 KMessageBox::information( this, message);
336 mView->openCalendar( oldFile ); 336 mView->openCalendar( oldFile );
337 qApp->processEvents(); 337 qApp->processEvents();
338 } else { 338 } else {
339 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 339 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
340 finfo.setFile( oldFile ); 340 finfo.setFile( oldFile );
341 if (finfo.exists() ) { 341 if (finfo.exists() ) {
342 KMessageBox::information( this, message); 342 KMessageBox::information( this, message);
343 mView->openCalendar( oldFile ); 343 mView->openCalendar( oldFile );
344 qApp->processEvents(); 344 qApp->processEvents();
345 } 345 }
346 } 346 }
347 mView->saveCalendar( defaultFileName() ); 347 mView->saveCalendar( defaultFileName() );
348 newFile = true; 348 newFile = true;
349 } 349 }
350 350
351 //QTime neededSaveTime = QDateTime::currentDateTime().time(); 351 //QTime neededSaveTime = QDateTime::currentDateTime().time();
352 //mView->loadCalendars(); 352 //mView->loadCalendars();
353 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 353 //int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
354 //qDebug("KO: Calendar loading time: %d ms",msNeeded ); 354 //qDebug("KO: Calendar loading time: %d ms",msNeeded );
355 355
356 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 356 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
357 KOPrefs::instance()->setAllDefaults(); 357 KOPrefs::instance()->setAllDefaults();
358 } 358 }
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 setCentralWidget( mView ); 364 setCentralWidget( mView );
365 globalFlagBlockStartup = 0; 365 globalFlagBlockStartup = 0;
366 //mView->show(); 366 //mView->show();
367 //delete splash; 367 //delete splash;
368 if ( newFile ) 368 if ( newFile )
369 mView->updateConfig(); 369 mView->updateConfig();
370 // qApp->processEvents(); 370 // qApp->processEvents();
371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 371 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
372 //fillSyncMenu(); 372 //fillSyncMenu();
373 373
374 374
375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 375 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 376 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
377 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 377 connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) );
378 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 378 connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) );
379 connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) );
380
379 mSyncManager->setDefaultFileName( sentSyncFile()); 381 mSyncManager->setDefaultFileName( sentSyncFile());
380 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 382 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
381 mSyncManager->fillSyncMenu(); 383 mSyncManager->fillSyncMenu();
382 384
383 385
384 386
385 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 387 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
386 if ( showWarning ) { 388 if ( showWarning ) {
387 KMessageBox::information( this, 389 KMessageBox::information( this,
388 "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"); 390 "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");
389 //qApp->processEvents(); 391 //qApp->processEvents();
390 mView->dialogManager()->showSyncOptions(); 392 mView->dialogManager()->showSyncOptions();
391 } 393 }
392 394
393 //US listen for result adressed from Ka/Pi 395 //US listen for result adressed from Ka/Pi
394 396
395#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
396 infrared = 0; 398 infrared = 0;
397#endif 399#endif
398 updateFilterToolbar(); 400 updateFilterToolbar();
399 updateWeek( mView->startDate() ); 401 updateWeek( mView->startDate() );
400 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 402 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
401 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 403 SLOT( updateWeekNum( const KCal::DateList & ) ) );
402 mBRdisabled = false; 404 mBRdisabled = false;
403 //toggleBeamReceive(); 405 //toggleBeamReceive();
404 406
405 setCaption(i18n("Loading calendar files ... please wait" )); 407 setCaption(i18n("Loading calendar files ... please wait" ));
406 mSaveDelay = 0; 408 mSaveDelay = 0;
407 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() )); 409 QTimer::singleShot( 10, this, SLOT ( loadDataAfterStart() ));
408} 410}
409MainWindow::~MainWindow() 411MainWindow::~MainWindow()
410{ 412{
411 //qDebug("MainWindow::~MainWindow() "); 413 //qDebug("MainWindow::~MainWindow() ");
412 //save toolbar location 414 //save toolbar location
413 delete mCalendar; 415 delete mCalendar;
414 delete mSyncManager; 416 delete mSyncManager;
415#ifndef DESKTOP_VERSION 417#ifndef DESKTOP_VERSION
416 if ( infrared ) 418 if ( infrared )
417 delete infrared; 419 delete infrared;
418#endif 420#endif
419 421
420 422
421} 423}
422 424
423void MainWindow::loadDataAfterStart() 425void MainWindow::loadDataAfterStart()
424{ 426{
425 qDebug("KO: Start loading files..." ); 427 qDebug("KO: Start loading files..." );
426 QTime neededSaveTime = QDateTime::currentDateTime().time(); 428 QTime neededSaveTime = QDateTime::currentDateTime().time();
427 mView->loadCalendars(); 429 mView->loadCalendars();
428 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 430 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
429 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 431 qDebug("KO: Calendar loading time: %d ms",msNeeded );
430 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 432 //QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
431 mView->setModified( false ); 433 mView->setModified( false );
432 mBlockAtStartup = false; 434 mBlockAtStartup = false;
433 mView->setModified( false ); 435 mView->setModified( false );
434 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 436 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
435 processIncidenceSelection( 0 ); 437 processIncidenceSelection( 0 );
436 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 438 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
437 SLOT( processIncidenceSelection( Incidence * ) ) ); 439 SLOT( processIncidenceSelection( Incidence * ) ) );
438 connect( mView, SIGNAL( modifiedChanged( bool ) ), 440 connect( mView, SIGNAL( modifiedChanged( bool ) ),
439 SLOT( slotModifiedChanged( bool ) ) ); 441 SLOT( slotModifiedChanged( bool ) ) );
440#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
441 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 443 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
442 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& ))); 444 connect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(recieve( const QCString&, const QByteArray& )));
443 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& ))); 445 disconnect( qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT(receiveStart( const QCString&, const QByteArray& )));
444 if ( !mCStringMess.isEmpty() ) 446 if ( !mCStringMess.isEmpty() )
445 recieve( mCStringMess, mByteData ); 447 recieve( mCStringMess, mByteData );
446#endif 448#endif
447 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 449 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
448} 450}
449 451
450void MainWindow::slotResetFocus() 452void MainWindow::slotResetFocus()
451{ 453{
452 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar); 454 //qDebug(" CalendarView::slotResetFocus() %x %x %x %x", qApp->focusWidget(), menuBar1, mView,iconToolBar);
453 mFocusLoop = 3; 455 mFocusLoop = 3;
454 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 456 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
455} 457}
456void MainWindow::slotResetFocusLoop() 458void MainWindow::slotResetFocusLoop()
457{ 459{
458 --mFocusLoop; 460 --mFocusLoop;
459 QWidget* fw = mView->viewManager()->currentView(); 461 QWidget* fw = mView->viewManager()->currentView();
460 if ( fw ) { 462 if ( fw ) {
461 //qDebug("loop "); 463 //qDebug("loop ");
462 fw->setFocus(); 464 fw->setFocus();
463 if ( qApp->focusWidget() != fw && mFocusLoop > 0 ) 465 if ( qApp->focusWidget() != fw && mFocusLoop > 0 )
464 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() )); 466 QTimer::singleShot( 0, this, SLOT(slotResetFocusLoop() ));
465 } 467 }
466 468
467} 469}
468void MainWindow::disableBR(bool b) 470void MainWindow::disableBR(bool b)
469{ 471{
470#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
471 if ( b ) { 473 if ( b ) {
472 if ( infrared ) { 474 if ( infrared ) {
473 toggleBeamReceive(); 475 toggleBeamReceive();
474 mBRdisabled = true; 476 mBRdisabled = true;
475 } 477 }
476 mBRdisabled = true; 478 mBRdisabled = true;
477 } else { 479 } else {
478 if ( mBRdisabled ) { 480 if ( mBRdisabled ) {
479 mBRdisabled = false; 481 mBRdisabled = false;
480 //makes no sense,because other cal ap is probably running 482 //makes no sense,because other cal ap is probably running
481 // toggleBeamReceive(); 483 // toggleBeamReceive();
482 } 484 }
483 } 485 }
484#endif 486#endif
485 487
486} 488}
487bool MainWindow::beamReceiveEnabled() 489bool MainWindow::beamReceiveEnabled()
488{ 490{
489#ifndef DESKTOP_VERSION 491#ifndef DESKTOP_VERSION
490 return ( infrared != 0 ); 492 return ( infrared != 0 );
491#endif 493#endif
492 return false; 494 return false;
493} 495}
494 496
495void MainWindow::toggleBeamReceive() 497void MainWindow::toggleBeamReceive()
496{ 498{
497 if ( mBRdisabled ) 499 if ( mBRdisabled )
498 return; 500 return;
499#ifndef DESKTOP_VERSION 501#ifndef DESKTOP_VERSION
500 if ( infrared ) { 502 if ( infrared ) {
501 qDebug("KO: Disable BeamReceive "); 503 qDebug("KO: Disable BeamReceive ");
502 delete infrared; 504 delete infrared;
503 infrared = 0; 505 infrared = 0;
504 brAction->setOn(false); 506 brAction->setOn(false);
505 return; 507 return;
506 } 508 }
507 qDebug("KO: Enable BeamReceive "); 509 qDebug("KO: Enable BeamReceive ");
508 brAction->setOn(true); 510 brAction->setOn(true);
509 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 511 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
510 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 512 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
511#endif 513#endif
512} 514}
513void MainWindow::showMaximized () 515void MainWindow::showMaximized ()
514{ 516{
515#ifndef DESKTOP_VERSION 517#ifndef DESKTOP_VERSION
516 if ( ! globalFlagBlockStartup ) 518 if ( ! globalFlagBlockStartup )
517 if ( mClosed ) 519 if ( mClosed )
518 mView->goToday(); 520 mView->goToday();
519#endif 521#endif
520 QWidget::showMaximized () ; 522 QWidget::showMaximized () ;
521 mClosed = false; 523 mClosed = false;
522} 524}
523 525
524bool MainWindow::askForQuitOnSaveError() 526bool MainWindow::askForQuitOnSaveError()
525{ 527{
526 bool retval = false; 528 bool retval = false;
527 switch( QMessageBox::information( this, "KO/Pi", 529 switch( QMessageBox::information( this, "KO/Pi",
528 i18n("Error saving data") + "!\n" + 530 i18n("Error saving data") + "!\n" +
529 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" + 531 i18n("You can save all data\nto another file via\nFile->Export->Export All Data") + "!\n" +
530 i18n("Do you really want\nto close KO/Pi?"), 532 i18n("Do you really want\nto close KO/Pi?"),
531 i18n(" Yes, close "), i18n("No"), 533 i18n(" Yes, close "), i18n("No"),
532 0, 1 ) ) { 534 0, 1 ) ) {
533 case 0: 535 case 0:
534 retval = true; 536 retval = true;
535 break; 537 break;
536 default: 538 default:
537 break; 539 break;
538 } 540 }
539 return retval; 541 return retval;
540} 542}
541bool MainWindow::checkAutosave() 543bool MainWindow::checkAutosave()
542{ 544{
543 bool savedata = true; 545 bool savedata = true;
544 if ( mAutoSaveDisabled && mCalendarModifiedFlag ) { 546 if ( mAutoSaveDisabled && mCalendarModifiedFlag ) {
545 switch( QMessageBox::information( this, "KO/Pi", 547 switch( QMessageBox::information( this, "KO/Pi",
546 i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"), 548 i18n("Calendar is modified\nbut Autosave is disabled!\nDo you want\nto save the data?"),
547 i18n("Yes, Save!"), i18n("No"), 549 i18n("Yes, Save!"), i18n("No"),
548 0, 0 ) ) { 550 0, 0 ) ) {
549 case 1: 551 case 1:
550 case 2: 552 case 2:
551 savedata = false; 553 savedata = false;
552 break; 554 break;
553 default: 555 default:
554 break; 556 break;
555 } 557 }
556 } 558 }
557 return savedata; 559 return savedata;
558} 560}
559void MainWindow::closeEvent( QCloseEvent* ce ) 561void MainWindow::closeEvent( QCloseEvent* ce )
560{ 562{
561 if ( ! KOPrefs::instance()->mAskForQuit ) { 563 if ( ! KOPrefs::instance()->mAskForQuit ) {
562 if ( checkAutosave() ) { 564 if ( checkAutosave() ) {
563 saveOnClose(); 565 saveOnClose();
564 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { 566 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
565 ce->ignore(); 567 ce->ignore();
566 return; 568 return;
567 } 569 }
568 } 570 }
569 mClosed = true; 571 mClosed = true;
570 ce->accept(); 572 ce->accept();
571 return; 573 return;
572 574
573 } 575 }
574 576
575 switch( QMessageBox::information( this, "KO/Pi", 577 switch( QMessageBox::information( this, "KO/Pi",
576 i18n("Do you really want\nto close KO/Pi?"), 578 i18n("Do you really want\nto close KO/Pi?"),
577 i18n("Close"), i18n("No"), 579 i18n("Close"), i18n("No"),
578 0, 0 ) ) { 580 0, 0 ) ) {
579 case 0: 581 case 0:
580 if ( checkAutosave() ) { 582 if ( checkAutosave() ) {
581 saveOnClose(); 583 saveOnClose();
582 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) { 584 if ( mCalendarModifiedFlag && !askForQuitOnSaveError() ) {
583 ce->ignore(); 585 ce->ignore();
584 return; 586 return;
585 } 587 }
586 } 588 }
587 mClosed = true; 589 mClosed = true;
588 ce->accept(); 590 ce->accept();
589 break; 591 break;
590 case 1: 592 case 1:
591 ce->ignore(); 593 ce->ignore();
592 break; 594 break;
593 case 2: 595 case 2:
594 596
595 default: 597 default:
596 break; 598 break;
597 } 599 }
598 600
599 601
600} 602}
601void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data ) 603void MainWindow::receiveStart( const QCString& cmsg, const QByteArray& data )
602{ 604{
603 qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 605 qDebug("KO: QCOP start message received: %s ", cmsg.data() );
604 mCStringMess = cmsg; 606 mCStringMess = cmsg;
605 mByteData = data; 607 mByteData = data;
606} 608}
607void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 609void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
608{ 610{
609 QDataStream stream( data, IO_ReadOnly ); 611 QDataStream stream( data, IO_ReadOnly );
610 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 612 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
611 //QString datamess; 613 //QString datamess;
612 //qDebug("message "); 614 //qDebug("message ");
613 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 615 qDebug("KO: QCOP message received: %s ", cmsg.data() );
614 616
615 if ( cmsg == "setDocument(QString)" ) { 617 if ( cmsg == "setDocument(QString)" ) {
616 QDataStream stream( data, IO_ReadOnly ); 618 QDataStream stream( data, IO_ReadOnly );
617 QString fileName; 619 QString fileName;
618 stream >> fileName; 620 stream >> fileName;
619 //qDebug("filename %s ", fileName.latin1()); 621 //qDebug("filename %s ", fileName.latin1());
620 showMaximized(); 622 showMaximized();
621 raise(); 623 raise();
622 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 624 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
623 mSyncManager->slotSyncMenu( 1002 ); 625 mSyncManager->slotSyncMenu( 1002 );
624 return; 626 return;
625 } 627 }
626 628
627 if ( cmsg == "-writeFile" ) { 629 if ( cmsg == "-writeFile" ) {
628 // I made from the "-writeFile" an "-writeAlarm" 630 // I made from the "-writeFile" an "-writeAlarm"
629 mView->viewManager()->showWhatsNextView(); 631 mView->viewManager()->showWhatsNextView();
630 mCalendar->checkAlarmForIncidence( 0, true); 632 mCalendar->checkAlarmForIncidence( 0, true);
631 showMaximized(); 633 showMaximized();
632 raise(); 634 raise();
633 return; 635 return;
634 636
635 } 637 }
636 if ( cmsg == "-writeFileSilent" ) { 638 if ( cmsg == "-writeFileSilent" ) {
637 // I made from the "-writeFile" an "-writeAlarm" 639 // I made from the "-writeFile" an "-writeAlarm"
638 // mView->viewManager()->showWhatsNextView(); 640 // mView->viewManager()->showWhatsNextView();
639 mCalendar->checkAlarmForIncidence( 0, true); 641 mCalendar->checkAlarmForIncidence( 0, true);
640 //showMaximized(); 642 //showMaximized();
641 //raise(); 643 //raise();
642 //hide(); 644 //hide();
643 return; 645 return;
644 } 646 }
645 if ( cmsg == "-newCountdown" ) { 647 if ( cmsg == "-newCountdown" ) {
646 qDebug("newCountdown "); 648 qDebug("newCountdown ");
647 649
648 } 650 }
649 QString msg ; 651 QString msg ;
650 QString allmsg = cmsg; 652 QString allmsg = cmsg;
651 while ( allmsg.length() > 0 ) { 653 while ( allmsg.length() > 0 ) {
652 int nextC = allmsg.find( "-", 1 ); 654 int nextC = allmsg.find( "-", 1 );
653 if ( nextC == -1 ) { 655 if ( nextC == -1 ) {
654 msg = allmsg; 656 msg = allmsg;
655 allmsg = ""; 657 allmsg = "";
656 } else{ 658 } else{
657 msg = allmsg.left( nextC ); 659 msg = allmsg.left( nextC );
658 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 660 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
659 } 661 }
660 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 662 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
661 if ( msg == "-newEvent" ) { 663 if ( msg == "-newEvent" ) {
662 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 664 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
663 } 665 }
664 if ( msg == "-newTodo" ) { 666 if ( msg == "-newTodo" ) {
665 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 667 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
666 } 668 }
667 if ( msg == "-showWN" ) { 669 if ( msg == "-showWN" ) {
668 mView->viewManager()->showWhatsNextView(); 670 mView->viewManager()->showWhatsNextView();
669 } 671 }
670 if ( msg == "-showList" ) { 672 if ( msg == "-showList" ) {
671 mView->viewManager()->showListView(); 673 mView->viewManager()->showListView();
672 } 674 }
673 else if ( msg == "-showDay" ) { 675 else if ( msg == "-showDay" ) {
674 mView->viewManager()->showDayView(); 676 mView->viewManager()->showDayView();
675 } 677 }
676 else if ( msg == "-showWWeek" ) { 678 else if ( msg == "-showWWeek" ) {
677 mView->viewManager()->showWorkWeekView(); 679 mView->viewManager()->showWorkWeekView();
678 } 680 }
679 else if ( msg == "-ringSync" ) { 681 else if ( msg == "-ringSync" ) {
680 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 682 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
681 } 683 }
682 else if ( msg == "-showWeek" ) { 684 else if ( msg == "-showWeek" ) {
683 mView->viewManager()->showWeekView(); 685 mView->viewManager()->showWeekView();
684 } 686 }
685 else if ( msg == "-showTodo" ) { 687 else if ( msg == "-showTodo" ) {
686 mView->viewManager()->showTodoView(); 688 mView->viewManager()->showTodoView();
687 } 689 }
688 else if ( msg == "-showJournal" ) { 690 else if ( msg == "-showJournal" ) {
689 mView->dateNavigator()->selectDates( 1 ); 691 mView->dateNavigator()->selectDates( 1 );
690 mView->dateNavigator()->selectToday(); 692 mView->dateNavigator()->selectToday();
691 mView->viewManager()->showJournalView(); 693 mView->viewManager()->showJournalView();
692 } 694 }
693 else if ( msg == "-showKO" ) { 695 else if ( msg == "-showKO" ) {
694 mView->viewManager()->showNextXView(); 696 mView->viewManager()->showNextXView();
695 } 697 }
696 else if ( msg == "-showWNext" ) { 698 else if ( msg == "-showWNext" ) {
697 mView->viewManager()->showWhatsNextView(); 699 mView->viewManager()->showWhatsNextView();
698 } 700 }
699 else if ( msg == "nextView()" ) { 701 else if ( msg == "nextView()" ) {
700 mView->viewManager()->showNextView(); 702 mView->viewManager()->showNextView();
701 } 703 }
702 else if ( msg == "-showNextXView" ) { 704 else if ( msg == "-showNextXView" ) {
703 mView->viewManager()->showNextXView(); 705 mView->viewManager()->showNextXView();
704 } 706 }
705 707
706 708
707 } 709 }
708 710
709 showMaximized(); 711 showMaximized();
710 raise(); 712 raise();
711} 713}
712void MainWindow::startMultiSync() 714void MainWindow::startMultiSync()
713{ 715{
714 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 716 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
715 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 717 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
716 question, 718 question,
717 i18n("Yes"), i18n("No"), 719 i18n("Yes"), i18n("No"),
718 0, 0 ) != 0 ) { 720 0, 0 ) != 0 ) {
719 setCaption(i18n("Aborted! Nothing synced!")); 721 setCaption(i18n("Aborted! Nothing synced!"));
720 return; 722 return;
721 } 723 }
722 mSyncManager->multiSync( false ); 724 mSyncManager->multiSync( false );
723#ifndef DESKTOP_VERSION 725#ifndef DESKTOP_VERSION
724 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 726 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
725#endif 727#endif
726} 728}
727QPixmap MainWindow::loadPixmap( QString name ) 729QPixmap MainWindow::loadPixmap( QString name )
728{ 730{
729 return SmallIcon( name ); 731 return SmallIcon( name );
730 732
731} 733}
732void MainWindow::setUsesBigPixmaps ( bool b ) 734void MainWindow::setUsesBigPixmaps ( bool b )
733{ 735{
734 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 736 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
735 if ( b ) 737 if ( b )
736 qDebug("KO: BigPixmaps are not supported "); 738 qDebug("KO: BigPixmaps are not supported ");
737} 739}
738void MainWindow::initActions() 740void MainWindow::initActions()
739{ 741{
740 //KOPrefs::instance()->mShowFullMenu 742 //KOPrefs::instance()->mShowFullMenu
741 iconToolBar->clear(); 743 iconToolBar->clear();
742 KOPrefs *p = KOPrefs::instance(); 744 KOPrefs *p = KOPrefs::instance();
743 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 745 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
744 746
745 QPopupMenu *viewMenu = new QPopupMenu( this ); 747 QPopupMenu *viewMenu = new QPopupMenu( this );
746 QPopupMenu *actionMenu = new QPopupMenu( this ); 748 QPopupMenu *actionMenu = new QPopupMenu( this );
747 mCurrentItemMenu = new QPopupMenu ( this ); 749 mCurrentItemMenu = new QPopupMenu ( this );
748 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 750 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
749 QPopupMenu *importMenu = new QPopupMenu( this ); 751 QPopupMenu *importMenu = new QPopupMenu( this );
750 QPopupMenu *importMenu_X = new QPopupMenu( this ); 752 QPopupMenu *importMenu_X = new QPopupMenu( this );
751 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 753 QPopupMenu *exportMenu_X = new QPopupMenu( this );
752 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 754 QPopupMenu *beamMenu_X = new QPopupMenu( this );
753 selectFilterMenu = new QPopupMenu( this ); 755 selectFilterMenu = new QPopupMenu( this );
754 selectFilterMenu->setCheckable( true ); 756 selectFilterMenu->setCheckable( true );
755 syncMenu = new QPopupMenu( this ); 757 syncMenu = new QPopupMenu( this );
756 configureAgendaMenu = new QPopupMenu( this ); 758 configureAgendaMenu = new QPopupMenu( this );
757 configureToolBarMenu = new QPopupMenu( this ); 759 configureToolBarMenu = new QPopupMenu( this );
758 QPopupMenu *helpMenu = new QPopupMenu( this ); 760 QPopupMenu *helpMenu = new QPopupMenu( this );
759 QIconSet icon; 761 QIconSet icon;
760 int pixWid = 22, pixHei = 22; 762 int pixWid = 22, pixHei = 22;
761 QString pathString = ""; 763 QString pathString = "";
762 if ( !p->mToolBarMiniIcons ) { 764 if ( !p->mToolBarMiniIcons ) {
763 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 765 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
764 pathString += "icons16/"; 766 pathString += "icons16/";
765 pixWid = 18; pixHei = 16; 767 pixWid = 18; pixHei = 16;
766 } 768 }
767 } else { 769 } else {
768 pathString += "iconsmini/"; 770 pathString += "iconsmini/";
769 pixWid = 18; pixHei = 16; 771 pixWid = 18; pixHei = 16;
770 } 772 }
771 773
772 if ( KOPrefs::instance()->mShowFullMenu ) { 774 if ( KOPrefs::instance()->mShowFullMenu ) {
773 menuBar1 = new KMenuBar( this );//menuBar(); 775 menuBar1 = new KMenuBar( this );//menuBar();
774 //setMenuBar( menuBar1 ); 776 //setMenuBar( menuBar1 );
775 menuBar1->show(); 777 menuBar1->show();
776 menuBar1->insertItem( i18n("File"), importMenu ); 778 menuBar1->insertItem( i18n("File"), importMenu );
777 menuBar1->insertItem( i18n("View"), viewMenu ); 779 menuBar1->insertItem( i18n("View"), viewMenu );
778 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 780 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
779 menuBar1->insertItem( i18n("Action"), actionMenu ); 781 menuBar1->insertItem( i18n("Action"), actionMenu );
780#ifdef DESKTOP_VERSION 782#ifdef DESKTOP_VERSION
781 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 783 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
782 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 784 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
783#else 785#else
784 menuBar1->insertItem( i18n("Sync"), syncMenu ); 786 menuBar1->insertItem( i18n("Sync"), syncMenu );
785 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 787 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
786#endif 788#endif
787 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 789 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
788 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 790 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
789 menuBar1->insertItem( i18n("Help"), helpMenu ); 791 menuBar1->insertItem( i18n("Help"), helpMenu );
790 } else { 792 } else {
791 menuBar1 = new KMenuBar( iconToolBar ); 793 menuBar1 = new KMenuBar( iconToolBar );
792 QPopupMenu *menuBar = new QPopupMenu( this ); 794 QPopupMenu *menuBar = new QPopupMenu( this );
793 icon = loadPixmap( pathString + "z_menu" ); 795 icon = loadPixmap( pathString + "z_menu" );
794 menuBar1->insertItem( icon.pixmap(), menuBar); 796 menuBar1->insertItem( icon.pixmap(), menuBar);
795 //menuBar1->insertItem( i18n("ME"), menuBar); 797 //menuBar1->insertItem( i18n("ME"), menuBar);
796 menuBar->insertItem( i18n("File"), importMenu ); 798 menuBar->insertItem( i18n("File"), importMenu );
797 menuBar->insertItem( i18n("View"), viewMenu ); 799 menuBar->insertItem( i18n("View"), viewMenu );
798 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 800 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
799 menuBar->insertItem( i18n("Action"), actionMenu ); 801 menuBar->insertItem( i18n("Action"), actionMenu );
800 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 802 menuBar->insertItem( i18n("Synchronize"), syncMenu );
801 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 803 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
802 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 804 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
803 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 805 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
804 menuBar->insertItem( i18n("Help"), helpMenu ); 806 menuBar->insertItem( i18n("Help"), helpMenu );
805 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 807 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
806 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 808 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
807 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) ); 809 connect ( menuBar, SIGNAL( aboutToHide () ), this, SLOT ( slotResetFocus() ) );
808 } 810 }
809 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 811 connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
810 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) ); 812 //connect ( menuBar1, SIGNAL( lostFocus () ), this, SLOT ( slotResetFocus() ) );
811 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 813 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
812 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 814 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
813 815
814 816
815 mWeekBgColor = iconToolBar->backgroundColor(); 817 mWeekBgColor = iconToolBar->backgroundColor();
816 mWeekPixmap.resize( pixWid , pixHei ); 818 mWeekPixmap.resize( pixWid , pixHei );
817 mWeekPixmap.fill( mWeekBgColor ); 819 mWeekPixmap.fill( mWeekBgColor );
818 icon = mWeekPixmap; 820 icon = mWeekPixmap;
819 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 821 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
820 if ( p-> mShowIconWeekNum ) 822 if ( p-> mShowIconWeekNum )
821 mWeekAction->addTo( iconToolBar ); 823 mWeekAction->addTo( iconToolBar );
822 mWeekFont = font(); 824 mWeekFont = font();
823 825
824 int fontPoint = mWeekFont.pointSize(); 826 int fontPoint = mWeekFont.pointSize();
825 QFontMetrics f( mWeekFont ); 827 QFontMetrics f( mWeekFont );
826 int fontWid = f.width( "30" ); 828 int fontWid = f.width( "30" );
827 while ( fontWid > pixWid ) { 829 while ( fontWid > pixWid ) {
828 --fontPoint; 830 --fontPoint;
829 mWeekFont.setPointSize( fontPoint ); 831 mWeekFont.setPointSize( fontPoint );
830 QFontMetrics f( mWeekFont ); 832 QFontMetrics f( mWeekFont );
831 fontWid = f.width( "30" ); 833 fontWid = f.width( "30" );
832 //qDebug("dec-- "); 834 //qDebug("dec-- ");
833 } 835 }
834 836
835 connect( mWeekAction, SIGNAL( activated() ), 837 connect( mWeekAction, SIGNAL( activated() ),
836 this, SLOT( weekAction() ) ); 838 this, SLOT( weekAction() ) );
837 839
838 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 840 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
839 if ( p->mShowIconFilterview ) { 841 if ( p->mShowIconFilterview ) {
840 icon = loadPixmap( pathString + "filter" ); 842 icon = loadPixmap( pathString + "filter" );
841 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 843 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
842 connect( actionFilterMenuTB, SIGNAL( activated() ), 844 connect( actionFilterMenuTB, SIGNAL( activated() ),
843 this, SLOT( fillFilterMenuTB() ) ); 845 this, SLOT( fillFilterMenuTB() ) );
844 actionFilterMenuTB->addTo( iconToolBar ); 846 actionFilterMenuTB->addTo( iconToolBar );
845 selectFilterMenuTB = new QPopupMenu( this ); 847 selectFilterMenuTB = new QPopupMenu( this );
846 selectFilterMenuTB->setCheckable( true ); 848 selectFilterMenuTB->setCheckable( true );
847 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 849 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
848 } 850 }
849 851
850 //#endif 852 //#endif
851 // ****************** 853 // ******************
852 QAction *action; 854 QAction *action;
853 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 855 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
854 configureToolBarMenu->setCheckable( true ); 856 configureToolBarMenu->setCheckable( true );
855 857
856 858
857 configureAgendaMenu->setCheckable( true ); 859 configureAgendaMenu->setCheckable( true );
858 int iii ; 860 int iii ;
859 for ( iii = 1;iii<= 10 ;++iii ){ 861 for ( iii = 1;iii<= 10 ;++iii ){
860 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 862 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
861 } 863 }
862 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 864 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
863 865
864 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 866 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
865 this, SLOT( showConfigureAgenda( ) ) ); 867 this, SLOT( showConfigureAgenda( ) ) );
866 icon = loadPixmap( pathString + "today" ); 868 icon = loadPixmap( pathString + "today" );
867 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 869 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
868 today_action->addTo( actionMenu ); 870 today_action->addTo( actionMenu );
869 connect( today_action, SIGNAL( activated() ), 871 connect( today_action, SIGNAL( activated() ),
870 mView, SLOT( goToday() ) ); 872 mView, SLOT( goToday() ) );
871 873
872 icon = loadPixmap( pathString + "picker" ); 874 icon = loadPixmap( pathString + "picker" );
873 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); 875 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this );
874 dPickerAction->addTo( actionMenu ); 876 dPickerAction->addTo( actionMenu );
875 connect( dPickerAction, SIGNAL( activated() ), 877 connect( dPickerAction, SIGNAL( activated() ),
876 mView, SLOT( showDatePicker() ) ); 878 mView, SLOT( showDatePicker() ) );
877 879
878 icon = loadPixmap( pathString + "search" ); 880 icon = loadPixmap( pathString + "search" );
879 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 881 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
880 search_action->addTo( actionMenu ); 882 search_action->addTo( actionMenu );
881 connect( search_action, SIGNAL( activated() ), 883 connect( search_action, SIGNAL( activated() ),
882 mView->dialogManager(), SLOT( showSearchDialog() ) ); 884 mView->dialogManager(), SLOT( showSearchDialog() ) );
883 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); 885 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu );
884 886
885 action = new QAction( "Undo Delete", i18n("All events"), 0, this ); 887 action = new QAction( "Undo Delete", i18n("All events"), 0, this );
886 action->addTo( nextConflictMenu ); 888 action->addTo( nextConflictMenu );
887 connect( action, SIGNAL( activated() ), 889 connect( action, SIGNAL( activated() ),
888 mView, SLOT( conflictAll() ) ); 890 mView, SLOT( conflictAll() ) );
889 891
890 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); 892 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this );
891 action->addTo( nextConflictMenu ); 893 action->addTo( nextConflictMenu );
892 connect( action, SIGNAL( activated() ), 894 connect( action, SIGNAL( activated() ),
893 mView, SLOT( conflictAllday() ) ); 895 mView, SLOT( conflictAllday() ) );
894 896
895 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); 897 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this );
896 action->addTo( nextConflictMenu ); 898 action->addTo( nextConflictMenu );
897 connect( action, SIGNAL( activated() ), 899 connect( action, SIGNAL( activated() ),
898 mView, SLOT( conflictNotAll() ) ); 900 mView, SLOT( conflictNotAll() ) );
899 901
900 actionMenu->insertSeparator(); 902 actionMenu->insertSeparator();
901 903
902 icon = loadPixmap( pathString + "newevent" ); 904 icon = loadPixmap( pathString + "newevent" );
903 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 905 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
904 ne_action->addTo( mCurrentItemMenu ); 906 ne_action->addTo( mCurrentItemMenu );
905 connect( ne_action, SIGNAL( activated() ), 907 connect( ne_action, SIGNAL( activated() ),
906 mView, SLOT( newEvent() ) ); 908 mView, SLOT( newEvent() ) );
907 icon = loadPixmap( pathString + "newtodo" ); 909 icon = loadPixmap( pathString + "newtodo" );
908 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 910 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
909 nt_action->addTo( mCurrentItemMenu ); 911 nt_action->addTo( mCurrentItemMenu );
910 connect( nt_action, SIGNAL( activated() ), 912 connect( nt_action, SIGNAL( activated() ),
911 mView, SLOT( newTodo() ) ); 913 mView, SLOT( newTodo() ) );
912 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 914 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
913 this ); 915 this );
914 mNewSubTodoAction->addTo( mCurrentItemMenu ); 916 mNewSubTodoAction->addTo( mCurrentItemMenu );
915 connect( mNewSubTodoAction, SIGNAL( activated() ), 917 connect( mNewSubTodoAction, SIGNAL( activated() ),
916 mView, SLOT( newSubTodo() ) ); 918 mView, SLOT( newSubTodo() ) );
917 919
918 mCurrentItemMenu->insertSeparator(); 920 mCurrentItemMenu->insertSeparator();
919 icon = loadPixmap( pathString + "newevent" ); 921 icon = loadPixmap( pathString + "newevent" );
920 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 922 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
921 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 923 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
922 configureToolBarMenu->insertSeparator(); 924 configureToolBarMenu->insertSeparator();
923 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 925 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
924 configureToolBarMenu->insertSeparator(); 926 configureToolBarMenu->insertSeparator();
925 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 927 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
926 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 928 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
927 icon = loadPixmap( pathString + "newtodo" ); 929 icon = loadPixmap( pathString + "newtodo" );
928 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 930 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
929 931
930 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); 932 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu);
931 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); 933 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this );
932 mShowAction->addTo( mCurrentItemMenu ); 934 mShowAction->addTo( mCurrentItemMenu );
933 connect( mShowAction, SIGNAL( activated() ), 935 connect( mShowAction, SIGNAL( activated() ),
934 mView, SLOT( showIncidence() ) ); 936 mView, SLOT( showIncidence() ) );
935 937
936 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 938 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
937 mEditAction->addTo( mCurrentItemMenu ); 939 mEditAction->addTo( mCurrentItemMenu );
938 connect( mEditAction, SIGNAL( activated() ), 940 connect( mEditAction, SIGNAL( activated() ),
939 mView, SLOT( editIncidence() ) ); 941 mView, SLOT( editIncidence() ) );
940 942
941 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 943 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
942 mDeleteAction->addTo( mCurrentItemMenu ); 944 mDeleteAction->addTo( mCurrentItemMenu );
943 connect( mDeleteAction, SIGNAL( activated() ), 945 connect( mDeleteAction, SIGNAL( activated() ),
944 mView, SLOT( deleteIncidence() ) ); 946 mView, SLOT( deleteIncidence() ) );
945 947
946 948
947 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 949 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
948 mCloneAction->addTo( mCurrentItemMenu ); 950 mCloneAction->addTo( mCurrentItemMenu );
949 connect( mCloneAction, SIGNAL( activated() ), 951 connect( mCloneAction, SIGNAL( activated() ),
950 mView, SLOT( cloneIncidence() ) ); 952 mView, SLOT( cloneIncidence() ) );
951 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 953 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
952 mMoveAction->addTo( mCurrentItemMenu ); 954 mMoveAction->addTo( mCurrentItemMenu );
953 connect( mMoveAction, SIGNAL( activated() ), 955 connect( mMoveAction, SIGNAL( activated() ),
954 mView, SLOT( moveIncidence() ) ); 956 mView, SLOT( moveIncidence() ) );
955#ifndef DESKTOP_VERSION 957#ifndef DESKTOP_VERSION
956 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 958 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
957 mBeamAction->addTo(mCurrentItemMenu ); 959 mBeamAction->addTo(mCurrentItemMenu );
958 connect( mBeamAction, SIGNAL( activated() ), 960 connect( mBeamAction, SIGNAL( activated() ),
959 mView, SLOT( beamIncidence() ) ); 961 mView, SLOT( beamIncidence() ) );
960#endif 962#endif
961 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 963 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
962 mCancelAction->addTo( mCurrentItemMenu ); 964 mCancelAction->addTo( mCurrentItemMenu );
963 connect( mCancelAction, SIGNAL( activated() ), 965 connect( mCancelAction, SIGNAL( activated() ),
964 mView, SLOT( toggleCancelIncidence() ) ); 966 mView, SLOT( toggleCancelIncidence() ) );
965 967
966 968
967 mCurrentItemMenu->insertSeparator(); 969 mCurrentItemMenu->insertSeparator();
968 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 970 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
969 action->addTo( mCurrentItemMenu ); 971 action->addTo( mCurrentItemMenu );
970 connect( action, SIGNAL( activated() ), 972 connect( action, SIGNAL( activated() ),
971 mView, SLOT( undo_delete() ) ); 973 mView, SLOT( undo_delete() ) );
972 974
973 // *********************** 975 // ***********************
974 if ( KOPrefs::instance()->mVerticalScreen ) { 976 if ( KOPrefs::instance()->mVerticalScreen ) {
975 icon = SmallIcon( "1updownarrow" ); 977 icon = SmallIcon( "1updownarrow" );
976 } else { 978 } else {
977 icon = SmallIcon("1leftrightarrow" ); 979 icon = SmallIcon("1leftrightarrow" );
978 } 980 }
979 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 981 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
980 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 982 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
981 FSaction->addTo( viewMenu ); 983 FSaction->addTo( viewMenu );
982 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 984 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
983 985
984 986
985 icon = loadPixmap( pathString + "filter" ); 987 icon = loadPixmap( pathString + "filter" );
986 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 988 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
987 icon = loadPixmap( pathString + "configure" ); 989 icon = loadPixmap( pathString + "configure" );
988 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 990 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
989 action->addTo( viewMenu ); 991 action->addTo( viewMenu );
990 connect( action, SIGNAL( activated() ), 992 connect( action, SIGNAL( activated() ),
991 mView, SLOT( toggleFilter() ) ); 993 mView, SLOT( toggleFilter() ) );
992 mToggleFilter = action; 994 mToggleFilter = action;
993 icon = loadPixmap( pathString + "navi" ); 995 icon = loadPixmap( pathString + "navi" );
994 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 996 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
995 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 997 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
996 action->addTo( viewMenu ); 998 action->addTo( viewMenu );
997 connect( action, SIGNAL( activated() ), 999 connect( action, SIGNAL( activated() ),
998 mView, SLOT( toggleDateNavigatorWidget() ) ); 1000 mView, SLOT( toggleDateNavigatorWidget() ) );
999 mToggleNav = action ; 1001 mToggleNav = action ;
1000 icon = loadPixmap( pathString + "allday" ); 1002 icon = loadPixmap( pathString + "allday" );
1001 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 1003 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
1002 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 1004 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
1003 action->addTo( viewMenu ); 1005 action->addTo( viewMenu );
1004 connect( action, SIGNAL( activated() ), 1006 connect( action, SIGNAL( activated() ),
1005 mView, SLOT( toggleAllDaySize() ) ); 1007 mView, SLOT( toggleAllDaySize() ) );
1006 mToggleAllday = action; 1008 mToggleAllday = action;
1007 1009
1008 1010
1009 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 1011 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
1010 mToggleNav, SLOT( setEnabled ( bool ) ) ); 1012 mToggleNav, SLOT( setEnabled ( bool ) ) );
1011 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 1013 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
1012 // mToggleFilter, SLOT( setEnabled ( bool ) ) ); 1014 // mToggleFilter, SLOT( setEnabled ( bool ) ) );
1013 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 1015 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
1014 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 1016 mToggleAllday, SLOT( setEnabled ( bool ) ) );
1015 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 1017 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
1016 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 1018 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
1017 1019
1018 1020
1019 dPickerAction->addTo( iconToolBar ); 1021 dPickerAction->addTo( iconToolBar );
1020 viewMenu->insertSeparator(); 1022 viewMenu->insertSeparator();
1021 1023
1022 if ( p-> mShowIconToggleFull ) 1024 if ( p-> mShowIconToggleFull )
1023 FSaction->addTo( iconToolBar ); 1025 FSaction->addTo( iconToolBar );
1024 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 1026 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
1025 1027
1026 //******************** 1028 //********************
1027 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 1029 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
1028 1030
1029 1031
1030 icon = loadPixmap( pathString + "whatsnext" ); 1032 icon = loadPixmap( pathString + "whatsnext" );
1031 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 1033 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
1032 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 1034 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
1033 whatsnext_action->addTo( viewMenu ); 1035 whatsnext_action->addTo( viewMenu );
1034 connect( whatsnext_action, SIGNAL( activated() ), 1036 connect( whatsnext_action, SIGNAL( activated() ),
1035 mView->viewManager(), SLOT( showWhatsNextView() ) ); 1037 mView->viewManager(), SLOT( showWhatsNextView() ) );
1036 1038
1037 icon = loadPixmap( pathString + "xdays" ); 1039 icon = loadPixmap( pathString + "xdays" );
1038 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 1040 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
1039 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 1041 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
1040 xdays_action->addTo( viewMenu ); 1042 xdays_action->addTo( viewMenu );
1041 connect( xdays_action, SIGNAL( activated() ), 1043 connect( xdays_action, SIGNAL( activated() ),
1042 mView->viewManager(), SLOT( showNextXView() ) ); 1044 mView->viewManager(), SLOT( showNextXView() ) );
1043 1045
1044 1046
1045 icon = loadPixmap( pathString + "journal" ); 1047 icon = loadPixmap( pathString + "journal" );
1046 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 1048 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
1047 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 1049 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
1048 viewjournal_action->addTo( viewMenu ); 1050 viewjournal_action->addTo( viewMenu );
1049 connect( viewjournal_action, SIGNAL( activated() ), 1051 connect( viewjournal_action, SIGNAL( activated() ),
1050 mView->viewManager(), SLOT( showJournalView() ) ); 1052 mView->viewManager(), SLOT( showJournalView() ) );
1051 1053
1052 1054
1053 icon = loadPixmap( pathString + "day" ); 1055 icon = loadPixmap( pathString + "day" );
1054 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 1056 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
1055 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 1057 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
1056 day1_action->addTo( viewMenu ); 1058 day1_action->addTo( viewMenu );
1057 // action->addTo( toolBar ); 1059 // action->addTo( toolBar );
1058 connect( day1_action, SIGNAL( activated() ), 1060 connect( day1_action, SIGNAL( activated() ),
1059 mView->viewManager(), SLOT( showDayView() ) ); 1061 mView->viewManager(), SLOT( showDayView() ) );
1060 1062
1061 icon = loadPixmap( pathString + "workweek" ); 1063 icon = loadPixmap( pathString + "workweek" );
1062 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 1064 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
1063 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 1065 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
1064 day5_action->addTo( viewMenu ); 1066 day5_action->addTo( viewMenu );
1065 connect( day5_action, SIGNAL( activated() ), 1067 connect( day5_action, SIGNAL( activated() ),
1066 mView->viewManager(), SLOT( showWorkWeekView() ) ); 1068 mView->viewManager(), SLOT( showWorkWeekView() ) );
1067 1069
1068 icon = loadPixmap( pathString + "week" ); 1070 icon = loadPixmap( pathString + "week" );
1069 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 1071 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
1070 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 1072 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
1071 day7_action->addTo( viewMenu ); 1073 day7_action->addTo( viewMenu );
1072 connect( day7_action, SIGNAL( activated() ), 1074 connect( day7_action, SIGNAL( activated() ),
1073 mView->viewManager(), SLOT( showWeekView() ) ); 1075 mView->viewManager(), SLOT( showWeekView() ) );
1074 1076
1075 icon = loadPixmap( pathString + "workweek2" ); 1077 icon = loadPixmap( pathString + "workweek2" );
1076 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 1078 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
1077 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 1079 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
1078 day6_action->addTo( viewMenu ); 1080 day6_action->addTo( viewMenu );
1079 connect( day6_action, SIGNAL( activated() ), 1081 connect( day6_action, SIGNAL( activated() ),
1080 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 1082 mView->viewManager(), SLOT( showMonthViewWeek() ) );
1081 1083
1082 icon = loadPixmap( pathString + "month" ); 1084 icon = loadPixmap( pathString + "month" );
1083 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 1085 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
1084 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 1086 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
1085 month_action->addTo( viewMenu ); 1087 month_action->addTo( viewMenu );
1086 connect( month_action, SIGNAL( activated() ), 1088 connect( month_action, SIGNAL( activated() ),
1087 mView->viewManager(), SLOT( showMonthView() ) ); 1089 mView->viewManager(), SLOT( showMonthView() ) );
1088 1090
1089 icon = loadPixmap( pathString + "list" ); 1091 icon = loadPixmap( pathString + "list" );
1090 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 1092 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
1091 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 1093 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
1092 showlist_action->addTo( viewMenu ); 1094 showlist_action->addTo( viewMenu );
1093 connect( showlist_action, SIGNAL( activated() ), 1095 connect( showlist_action, SIGNAL( activated() ),
1094 mView->viewManager(), SLOT( showListView() ) ); 1096 mView->viewManager(), SLOT( showListView() ) );
1095 1097
1096 icon = loadPixmap( pathString + "todo" ); 1098 icon = loadPixmap( pathString + "todo" );
1097 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 1099 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
1098 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 1100 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
1099 todoview_action->addTo( viewMenu ); 1101 todoview_action->addTo( viewMenu );
1100 connect( todoview_action, SIGNAL( activated() ), 1102 connect( todoview_action, SIGNAL( activated() ),
1101 mView->viewManager(), SLOT( showTodoView() ) ); 1103 mView->viewManager(), SLOT( showTodoView() ) );
1102 1104
1103 1105
1104 1106
1105#if 0 1107#if 0
1106 action = new QAction( "view_timespan", "Time Span", 0, this ); 1108 action = new QAction( "view_timespan", "Time Span", 0, this );
1107 action->addTo( viewMenu ); 1109 action->addTo( viewMenu );
1108 connect( action, SIGNAL( activated() ), 1110 connect( action, SIGNAL( activated() ),
1109 mView->viewManager(), SLOT( showTimeSpanView() ) ); 1111 mView->viewManager(), SLOT( showTimeSpanView() ) );
1110#endif 1112#endif
1111 1113
1112 1114
1113 1115
1114 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, 1116 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0,
1115 this ); 1117 this );
1116 action->addTo( actionMenu ); 1118 action->addTo( actionMenu );
1117 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 1119 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
1118 1120
1119 1121
1120 icon = loadPixmap( pathString + "search" ); 1122 icon = loadPixmap( pathString + "search" );
1121 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 1123 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
1122 1124
1123 1125
1124 1126
1125 actionMenu->insertSeparator(); 1127 actionMenu->insertSeparator();
1126 action = new QAction( "manage cat", i18n("Edit category list..."), 0, 1128 action = new QAction( "manage cat", i18n("Edit category list..."), 0,
1127 this ); 1129 this );
1128 action->addTo( actionMenu ); 1130 action->addTo( actionMenu );
1129 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); 1131 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) );
1130 1132
1131 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1133 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1132 this ); 1134 this );
1133 action->addTo( actionMenu ); 1135 action->addTo( actionMenu );
1134 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1136 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1135 1137
1136 1138
1137 actionMenu->insertSeparator(); 1139 actionMenu->insertSeparator();
1138 icon = loadPixmap( pathString + "configure" ); 1140 icon = loadPixmap( pathString + "configure" );
1139 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 1141 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
1140 action->addTo( actionMenu ); 1142 action->addTo( actionMenu );
1141 connect( action, SIGNAL( activated() ), 1143 connect( action, SIGNAL( activated() ),
1142 mView, SLOT( edit_options() ) ); 1144 mView, SLOT( edit_options() ) );
1143 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); 1145 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this );
1144 action->addTo( actionMenu ); 1146 action->addTo( actionMenu );
1145 connect( action, SIGNAL( activated() ), 1147 connect( action, SIGNAL( activated() ),
1146 this, SLOT( calHint() ) ); 1148 this, SLOT( calHint() ) );
1147 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 1149 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
1148 action->addTo( actionMenu ); 1150 action->addTo( actionMenu );
1149 connect( action, SIGNAL( activated() ), 1151 connect( action, SIGNAL( activated() ),
1150 mView, SLOT( edit_global_options() ) ); 1152 mView, SLOT( edit_global_options() ) );
1151 if ( KOPrefs::instance()->mShowFullMenu ) { 1153 if ( KOPrefs::instance()->mShowFullMenu ) {
1152 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 1154 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
1153 1155
1154 } 1156 }
1155 // actionMenu->insertSeparator(); 1157 // actionMenu->insertSeparator();
1156 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 1158 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
1157 this ); 1159 this );
1158 action->addTo( importMenu_X ); 1160 action->addTo( importMenu_X );
1159 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 1161 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
1160 action = new QAction( "import_quick", i18n("Import last file"), 0, 1162 action = new QAction( "import_quick", i18n("Import last file"), 0,
1161 this ); 1163 this );
1162 action->addTo( importMenu_X ); 1164 action->addTo( importMenu_X );
1163 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 1165 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
1164 importMenu_X->insertSeparator(); 1166 importMenu_X->insertSeparator();
1165 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 1167 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
1166 this ); 1168 this );
1167 action->addTo( importMenu_X ); 1169 action->addTo( importMenu_X );
1168 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 1170 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
1169 //#ifndef DESKTOP_VERSION 1171 //#ifndef DESKTOP_VERSION
1170 importMenu_X->insertSeparator(); 1172 importMenu_X->insertSeparator();
1171 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 1173 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
1172 this ); 1174 this );
1173 action->addTo( importMenu_X ); 1175 action->addTo( importMenu_X );
1174 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1176 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1175 //#else 1177 //#else
1176#ifdef _OL_IMPORT_ 1178#ifdef _OL_IMPORT_
1177 importMenu_X->insertSeparator(); 1179 importMenu_X->insertSeparator();
1178 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1180 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1179 this ); 1181 this );
1180 action->addTo( importMenu_X ); 1182 action->addTo( importMenu_X );
1181 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1183 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1182#endif 1184#endif
1183 //#endif 1185 //#endif
1184 1186
1185 //importMenu->insertSeparator(); 1187 //importMenu->insertSeparator();
1186#if 0 1188#if 0
1187 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1189 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1188 this ); 1190 this );
1189 action->addTo( importMenu ); 1191 action->addTo( importMenu );
1190 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1192 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1191#endif 1193#endif
1192 action = new QAction( "save_cal", i18n("Save Backup..."), 0, 1194 action = new QAction( "save_cal", i18n("Save Backup..."), 0,
1193 this ); 1195 this );
1194 action->addTo( importMenu ); 1196 action->addTo( importMenu );
1195 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1197 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1196 importMenu->insertSeparator(); 1198 importMenu->insertSeparator();
1197 importMenu->insertItem( i18n("Import"), importMenu_X ); 1199 importMenu->insertItem( i18n("Import"), importMenu_X );
1198 //importMenu->insertSeparator(); 1200 //importMenu->insertSeparator();
1199 action = new QAction( "export ical", i18n("Export All Data"), 0, 1201 action = new QAction( "export ical", i18n("Export All Data"), 0,
1200 this ); 1202 this );
1201 action->addTo( exportMenu_X ); 1203 action->addTo( exportMenu_X );
1202 connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) ); 1204 connect( action, SIGNAL( activated() ), SLOT( exportICalendar() ) );
1203 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1205 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1204 this ); 1206 this );
1205 action->addTo( exportMenu_X ); 1207 action->addTo( exportMenu_X );
1206 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1208 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1207 1209
1208 1210
1209 //LR 1211 //LR
1210 QPopupMenu *ex2phone = new QPopupMenu( this ); 1212 QPopupMenu *ex2phone = new QPopupMenu( this );
1211 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1213 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1212 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1214 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1213 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1215 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1214 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1216 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1215 1217
1216 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1218 importMenu->insertItem( i18n("Export"), exportMenu_X );
1217 mPrintSelAction = 0; 1219 mPrintSelAction = 0;
1218#ifndef DESKTOP_VERSION 1220#ifndef DESKTOP_VERSION
1219 //importMenu->insertSeparator(); 1221 //importMenu->insertSeparator();
1220 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1222 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1221 this ); 1223 this );
1222 brAction->addTo( beamMenu_X ); 1224 brAction->addTo( beamMenu_X );
1223 brAction->setToggleAction (true ) ; 1225 brAction->setToggleAction (true ) ;
1224 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1226 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1225 1227
1226 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1228 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1227 this ); 1229 this );
1228 action->addTo( beamMenu_X ); 1230 action->addTo( beamMenu_X );
1229 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1231 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1230 1232
1231 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1233 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1232 this ); 1234 this );
1233 action->addTo( beamMenu_X ); 1235 action->addTo( beamMenu_X );
1234 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1236 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1235 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1237 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1236#else 1238#else
1237 //importMenu->insertSeparator(); 1239 //importMenu->insertSeparator();
1238 icon = loadPixmap( pathString + "print" ); 1240 icon = loadPixmap( pathString + "print" );
1239 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1241 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1240 action->addTo( beamMenu_X ); 1242 action->addTo( beamMenu_X );
1241 connect( action, SIGNAL( activated() ), 1243 connect( action, SIGNAL( activated() ),
1242 this, SLOT( printCal() ) ); 1244 this, SLOT( printCal() ) );
1243 1245
1244 icon = loadPixmap( pathString + "week" ); 1246 icon = loadPixmap( pathString + "week" );
1245 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1247 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1246 action->addTo( beamMenu_X ); 1248 action->addTo( beamMenu_X );
1247 connect( action, SIGNAL( activated() ), 1249 connect( action, SIGNAL( activated() ),
1248 this, SLOT( printSel() ) ); 1250 this, SLOT( printSel() ) );
1249 icon = loadPixmap( pathString + "whatsnext" ); 1251 icon = loadPixmap( pathString + "whatsnext" );
1250 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1252 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1251 action->addTo( beamMenu_X ); 1253 action->addTo( beamMenu_X );
1252 connect( action, SIGNAL( activated() ), 1254 connect( action, SIGNAL( activated() ),
1253 mView->viewManager(), SLOT( slotprintWNV() ) ); 1255 mView->viewManager(), SLOT( slotprintWNV() ) );
1254 1256
1255 1257
1256 icon = loadPixmap( pathString + "list" ); 1258 icon = loadPixmap( pathString + "list" );
1257 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1259 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1258 action->addTo( beamMenu_X ); 1260 action->addTo( beamMenu_X );
1259 connect( action, SIGNAL( activated() ), 1261 connect( action, SIGNAL( activated() ),
1260 this, SLOT( printListView() ) ); 1262 this, SLOT( printListView() ) );
1261 1263
1262 icon = loadPixmap( pathString + "newevent" ); 1264 icon = loadPixmap( pathString + "newevent" );
1263 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1265 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1264 action->addTo( beamMenu_X ); 1266 action->addTo( beamMenu_X );
1265 connect( action, SIGNAL( activated() ), 1267 connect( action, SIGNAL( activated() ),
1266 mView, SLOT( slotprintSelInc() ) ); 1268 mView, SLOT( slotprintSelInc() ) );
1267 mPrintSelAction = action; 1269 mPrintSelAction = action;
1268 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1270 importMenu->insertItem( i18n("Print"), beamMenu_X );
1269#endif 1271#endif
1270 1272
1271 importMenu->insertSeparator(); 1273 importMenu->insertSeparator();
1272 action = new QAction( "beam all", i18n("Save"), 0, 1274 action = new QAction( "beam all", i18n("Save"), 0,
1273 this ); 1275 this );
1274 action->addTo( importMenu ); 1276 action->addTo( importMenu );
1275 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1277 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1276 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1278 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1277 this ); 1279 this );
1278 action->addTo( importMenu ); 1280 action->addTo( importMenu );
1279 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1281 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1280 1282
1281 //menuBar->insertItem( "Configure",configureMenu ); 1283 //menuBar->insertItem( "Configure",configureMenu );
1282 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1284 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1283 icon = loadPixmap( "korganizer/korganizer" ); 1285 icon = loadPixmap( "korganizer/korganizer" );
1284 1286
1285 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1287 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1286 action->addTo( helpMenu ); 1288 action->addTo( helpMenu );
1287 connect( action, SIGNAL( activated() ), 1289 connect( action, SIGNAL( activated() ),
1288 SLOT( whatsNew() ) ); 1290 SLOT( whatsNew() ) );
1289 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1291 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1290 action->addTo( helpMenu ); 1292 action->addTo( helpMenu );
1291 connect( action, SIGNAL( activated() ), 1293 connect( action, SIGNAL( activated() ),
1292 SLOT( features() ) ); 1294 SLOT( features() ) );
1293 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1295 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1294 action->addTo( helpMenu ); 1296 action->addTo( helpMenu );
1295 connect( action, SIGNAL( activated() ), 1297 connect( action, SIGNAL( activated() ),
1296 SLOT( keyBindings() ) ); 1298 SLOT( keyBindings() ) );
1297 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1299 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1298 action->addTo( helpMenu ); 1300 action->addTo( helpMenu );
1299 connect( action, SIGNAL( activated() ), 1301 connect( action, SIGNAL( activated() ),
1300 SLOT( storagehowto() ) ); 1302 SLOT( storagehowto() ) );
1301 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1303 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1302 action->addTo( helpMenu ); 1304 action->addTo( helpMenu );
1303 connect( action, SIGNAL( activated() ), 1305 connect( action, SIGNAL( activated() ),
1304 SLOT( timetrackinghowto() ) ); 1306 SLOT( timetrackinghowto() ) );
1305 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1307 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1306 action->addTo( helpMenu ); 1308 action->addTo( helpMenu );
1307 connect( action, SIGNAL( activated() ), 1309 connect( action, SIGNAL( activated() ),
1308 SLOT( synchowto() ) ); 1310 SLOT( synchowto() ) );
1309 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1311 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1310 action->addTo( helpMenu ); 1312 action->addTo( helpMenu );
1311 connect( action, SIGNAL( activated() ), 1313 connect( action, SIGNAL( activated() ),
1312 SLOT( kdesynchowto() ) ); 1314 SLOT( kdesynchowto() ) );
1313 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1315 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1314 action->addTo( helpMenu ); 1316 action->addTo( helpMenu );
1315 connect( action, SIGNAL( activated() ), 1317 connect( action, SIGNAL( activated() ),
1316 SLOT( multisynchowto() ) ); 1318 SLOT( multisynchowto() ) );
1317 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1319 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1318 action->addTo( helpMenu ); 1320 action->addTo( helpMenu );
1319 connect( action, SIGNAL( activated() ), 1321 connect( action, SIGNAL( activated() ),
1320 SLOT( aboutAutoSaving() ) ); 1322 SLOT( aboutAutoSaving() ) );
1321 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1323 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1322 action->addTo( helpMenu ); 1324 action->addTo( helpMenu );
1323 connect( action, SIGNAL( activated() ), 1325 connect( action, SIGNAL( activated() ),
1324 SLOT( aboutKnownBugs() ) ); 1326 SLOT( aboutKnownBugs() ) );
1325 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1327 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1326 action->addTo( helpMenu ); 1328 action->addTo( helpMenu );
1327 connect( action, SIGNAL( activated() ), 1329 connect( action, SIGNAL( activated() ),
1328 SLOT( usertrans() ) ); 1330 SLOT( usertrans() ) );
1329 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1331 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1330 action->addTo( helpMenu ); 1332 action->addTo( helpMenu );
1331 connect( action, SIGNAL( activated() ), 1333 connect( action, SIGNAL( activated() ),
1332 SLOT( faq() ) ); 1334 SLOT( faq() ) );
1333 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1335 action = new QAction( "licence", i18n("Licence..."), 0, this );
1334 action->addTo( helpMenu ); 1336 action->addTo( helpMenu );
1335 connect( action, SIGNAL( activated() ), 1337 connect( action, SIGNAL( activated() ),
1336 SLOT( licence() ) ); 1338 SLOT( licence() ) );
1337 action = new QAction( "about", i18n("About..."), 0, this ); 1339 action = new QAction( "about", i18n("About..."), 0, this );
1338 action->addTo( helpMenu ); 1340 action->addTo( helpMenu );
1339 connect( action, SIGNAL( activated() ), 1341 connect( action, SIGNAL( activated() ),
1340 SLOT( about() ) ); 1342 SLOT( about() ) );
1341 //menuBar->insertSeparator(); 1343 //menuBar->insertSeparator();
1342 1344
1343 // ****************************************************** 1345 // ******************************************************
1344 // menubar icons 1346 // menubar icons
1345 1347
1346 1348
1347 1349
1348 //menuBar->insertItem( iconToolBar ); 1350 //menuBar->insertItem( iconToolBar );
1349 //xdays_action 1351 //xdays_action
1350 if (p-> mShowIconNewEvent) 1352 if (p-> mShowIconNewEvent)
1351 ne_action->addTo( iconToolBar ); 1353 ne_action->addTo( iconToolBar );
1352 if (p->mShowIconNewTodo ) 1354 if (p->mShowIconNewTodo )
1353 nt_action->addTo( iconToolBar ); 1355 nt_action->addTo( iconToolBar );
1354 if (p-> mShowIconSearch) 1356 if (p-> mShowIconSearch)
1355 search_action->addTo( iconToolBar ); 1357 search_action->addTo( iconToolBar );
1356 if (p-> mShowIconWhatsThis) 1358 if (p-> mShowIconWhatsThis)
1357 QWhatsThis::whatsThisButton ( iconToolBar ); 1359 QWhatsThis::whatsThisButton ( iconToolBar );
1358 if (p-> mShowIconNext) 1360 if (p-> mShowIconNext)
1359 whatsnext_action->addTo( viewToolBar ); 1361 whatsnext_action->addTo( viewToolBar );
1360 if (p-> mShowIconNextDays) 1362 if (p-> mShowIconNextDays)
1361 xdays_action->addTo( viewToolBar ); 1363 xdays_action->addTo( viewToolBar );
1362 if (p-> mShowIconJournal) 1364 if (p-> mShowIconJournal)
1363 viewjournal_action->addTo( viewToolBar ); 1365 viewjournal_action->addTo( viewToolBar );
1364 if (p-> mShowIconDay1) 1366 if (p-> mShowIconDay1)
1365 day1_action->addTo( viewToolBar ); 1367 day1_action->addTo( viewToolBar );
1366 if (p-> mShowIconDay5) 1368 if (p-> mShowIconDay5)
1367 day5_action->addTo( viewToolBar ); 1369 day5_action->addTo( viewToolBar );
1368 if (p-> mShowIconDay7) 1370 if (p-> mShowIconDay7)
1369 day7_action->addTo( viewToolBar ); 1371 day7_action->addTo( viewToolBar );
1370 if (p-> mShowIconDay6) 1372 if (p-> mShowIconDay6)
1371 day6_action->addTo( viewToolBar ); 1373 day6_action->addTo( viewToolBar );
1372 if (p-> mShowIconMonth) 1374 if (p-> mShowIconMonth)
1373 month_action->addTo( viewToolBar ); 1375 month_action->addTo( viewToolBar );
1374 if (p-> mShowIconList) 1376 if (p-> mShowIconList)
1375 showlist_action->addTo( viewToolBar ); 1377 showlist_action->addTo( viewToolBar );
1376 if (p-> mShowIconTodoview) 1378 if (p-> mShowIconTodoview)
1377 todoview_action->addTo( viewToolBar ); 1379 todoview_action->addTo( viewToolBar );
1378 1380
1379 icon = loadPixmap( pathString + "2leftarrowB" ); 1381 icon = loadPixmap( pathString + "2leftarrowB" );
1380 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1382 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1381 if (p-> mShowIconBackFast) { 1383 if (p-> mShowIconBackFast) {
1382 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1384 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1383 connect( action, SIGNAL( activated() ), 1385 connect( action, SIGNAL( activated() ),
1384 mView, SLOT( goPreviousMonth() ) ); 1386 mView, SLOT( goPreviousMonth() ) );
1385 action->addTo( navigatorToolBar ); 1387 action->addTo( navigatorToolBar );
1386 } 1388 }
1387 icon = loadPixmap( pathString + "1leftarrowB" ); 1389 icon = loadPixmap( pathString + "1leftarrowB" );
1388 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1390 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1389 if (p-> mShowIconBack) { 1391 if (p-> mShowIconBack) {
1390 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1392 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1391 connect( action, SIGNAL( activated() ), 1393 connect( action, SIGNAL( activated() ),
1392 mView, SLOT( goPrevious() ) ); 1394 mView, SLOT( goPrevious() ) );
1393 action->addTo( navigatorToolBar ); 1395 action->addTo( navigatorToolBar );
1394 } 1396 }
1395 icon = loadPixmap( pathString + "today" ); 1397 icon = loadPixmap( pathString + "today" );
1396 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1398 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1397 if (p-> mShowIconToday) 1399 if (p-> mShowIconToday)
1398 today_action->addTo( navigatorToolBar ); 1400 today_action->addTo( navigatorToolBar );
1399 icon = loadPixmap( pathString + "1rightarrowB" ); 1401 icon = loadPixmap( pathString + "1rightarrowB" );
1400 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1402 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1401 if (p-> mShowIconForward) { 1403 if (p-> mShowIconForward) {
1402 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1404 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1403 connect( action, SIGNAL( activated() ), 1405 connect( action, SIGNAL( activated() ),
1404 mView, SLOT( goNext() ) ); 1406 mView, SLOT( goNext() ) );
1405 action->addTo( navigatorToolBar ); 1407 action->addTo( navigatorToolBar );
1406 } 1408 }
1407 icon = loadPixmap( pathString + "2rightarrowB" ); 1409 icon = loadPixmap( pathString + "2rightarrowB" );
1408 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1410 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1409 if (p-> mShowIconForwardFast) { 1411 if (p-> mShowIconForwardFast) {
1410 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1412 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1411 connect( action, SIGNAL( activated() ), 1413 connect( action, SIGNAL( activated() ),
1412 mView, SLOT( goNextMonth() ) ); 1414 mView, SLOT( goNextMonth() ) );
1413 action->addTo( navigatorToolBar ); 1415 action->addTo( navigatorToolBar );
1414 } 1416 }
1415 1417
1416 1418
1417 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1419 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1418 1420
1419 1421
1420 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1422 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1421 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1423 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1422 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1424 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1423 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1425 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1424 1426
1425 if (p-> mShowIconNewEvent) 1427 if (p-> mShowIconNewEvent)
1426 configureToolBarMenu->setItemChecked( 10, true ); 1428 configureToolBarMenu->setItemChecked( 10, true );
1427 if (p->mShowIconNewTodo ) 1429 if (p->mShowIconNewTodo )
1428 configureToolBarMenu->setItemChecked( 20, true ); 1430 configureToolBarMenu->setItemChecked( 20, true );
1429 if (p-> mShowIconSearch) 1431 if (p-> mShowIconSearch)
1430 configureToolBarMenu->setItemChecked( 120, true ); 1432 configureToolBarMenu->setItemChecked( 120, true );
1431 if (p-> mShowIconList) 1433 if (p-> mShowIconList)
1432 configureToolBarMenu->setItemChecked( 30, true ); 1434 configureToolBarMenu->setItemChecked( 30, true );
1433 if (p-> mShowIconDay1) 1435 if (p-> mShowIconDay1)
1434 configureToolBarMenu->setItemChecked( 40, true ); 1436 configureToolBarMenu->setItemChecked( 40, true );
1435 if (p-> mShowIconDay5) 1437 if (p-> mShowIconDay5)
1436 configureToolBarMenu->setItemChecked( 50, true ); 1438 configureToolBarMenu->setItemChecked( 50, true );
1437 if (p-> mShowIconDay6) 1439 if (p-> mShowIconDay6)
1438 configureToolBarMenu->setItemChecked( 75, true ); 1440 configureToolBarMenu->setItemChecked( 75, true );
1439 if (p-> mShowIconDay7) 1441 if (p-> mShowIconDay7)
1440 configureToolBarMenu->setItemChecked( 60, true ); 1442 configureToolBarMenu->setItemChecked( 60, true );
1441 if (p-> mShowIconMonth) 1443 if (p-> mShowIconMonth)
1442 configureToolBarMenu->setItemChecked( 70, true ); 1444 configureToolBarMenu->setItemChecked( 70, true );
1443 if (p-> mShowIconTodoview) 1445 if (p-> mShowIconTodoview)
1444 configureToolBarMenu->setItemChecked( 80, true ); 1446 configureToolBarMenu->setItemChecked( 80, true );
1445 if (p-> mShowIconBackFast) 1447 if (p-> mShowIconBackFast)
1446 configureToolBarMenu->setItemChecked( 200, true ); 1448 configureToolBarMenu->setItemChecked( 200, true );
1447 if (p-> mShowIconBack) 1449 if (p-> mShowIconBack)
1448 configureToolBarMenu->setItemChecked( 210, true ); 1450 configureToolBarMenu->setItemChecked( 210, true );
1449 if (p-> mShowIconToday) 1451 if (p-> mShowIconToday)
1450 configureToolBarMenu->setItemChecked( 130, true ); 1452 configureToolBarMenu->setItemChecked( 130, true );
1451 if (p-> mShowIconForward) 1453 if (p-> mShowIconForward)
1452 configureToolBarMenu->setItemChecked( 220, true ); 1454 configureToolBarMenu->setItemChecked( 220, true );
1453 if (p-> mShowIconForwardFast) 1455 if (p-> mShowIconForwardFast)
1454 configureToolBarMenu->setItemChecked( 230, true ); 1456 configureToolBarMenu->setItemChecked( 230, true );
1455 if (p-> mShowIconNextDays) 1457 if (p-> mShowIconNextDays)
1456 configureToolBarMenu->setItemChecked( 100, true ); 1458 configureToolBarMenu->setItemChecked( 100, true );
1457 if (p-> mShowIconNext) 1459 if (p-> mShowIconNext)
1458 configureToolBarMenu->setItemChecked( 110, true ); 1460 configureToolBarMenu->setItemChecked( 110, true );
1459 if (p-> mShowIconJournal) 1461 if (p-> mShowIconJournal)
1460 configureToolBarMenu->setItemChecked( 90, true ); 1462 configureToolBarMenu->setItemChecked( 90, true );
1461 if (p-> mShowIconWhatsThis) 1463 if (p-> mShowIconWhatsThis)
1462 configureToolBarMenu->setItemChecked( 300, true ); 1464 configureToolBarMenu->setItemChecked( 300, true );
1463 if (p-> mShowIconWeekNum) 1465 if (p-> mShowIconWeekNum)
1464 configureToolBarMenu->setItemChecked( 400, true ); 1466 configureToolBarMenu->setItemChecked( 400, true );
1465 if (!p-> mShowIconStretch) { 1467 if (!p-> mShowIconStretch) {
1466 QLabel* dummy = new QLabel( iconToolBar ); 1468 QLabel* dummy = new QLabel( iconToolBar );
1467 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1469 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1468 dummy->setMinimumWidth( 0 ); 1470 dummy->setMinimumWidth( 0 );
1469 iconToolBar->setStretchableWidget ( dummy ) ; 1471 iconToolBar->setStretchableWidget ( dummy ) ;
1470 } 1472 }
1471 else { 1473 else {
1472 iconToolBar->setHorizontalStretchable (true ); 1474 iconToolBar->setHorizontalStretchable (true );
1473 viewToolBar->setHorizontalStretchable (true ); 1475 viewToolBar->setHorizontalStretchable (true );
1474 navigatorToolBar->setHorizontalStretchable (true ); 1476 navigatorToolBar->setHorizontalStretchable (true );
1475 iconToolBar->setVerticalStretchable (true ); 1477 iconToolBar->setVerticalStretchable (true );
1476 viewToolBar->setVerticalStretchable (true ); 1478 viewToolBar->setVerticalStretchable (true );
1477 navigatorToolBar->setVerticalStretchable (true ); 1479 navigatorToolBar->setVerticalStretchable (true );
1478 configureToolBarMenu->setItemChecked( 5, true ); 1480 configureToolBarMenu->setItemChecked( 5, true );
1479 } 1481 }
1480 if (p-> mShowIconFilter) 1482 if (p-> mShowIconFilter)
1481 configureToolBarMenu->setItemChecked( 7, true ); 1483 configureToolBarMenu->setItemChecked( 7, true );
1482 if (p-> mShowIconOnetoolbar) 1484 if (p-> mShowIconOnetoolbar)
1483 configureToolBarMenu->setItemChecked( 6, true ); 1485 configureToolBarMenu->setItemChecked( 6, true );
1484 1486
1485 1487
1486 if ( filterMenubar ) { 1488 if ( filterMenubar ) {
1487 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1489 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1488 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1490 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1489 } 1491 }
1490 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1492 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1491 configureAgenda( p->mHourSize ); 1493 configureAgenda( p->mHourSize );
1492 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1494 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1493} 1495}
1494void MainWindow::calHint() 1496void MainWindow::calHint()
1495{ 1497{
1496 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>."); 1498 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>.");
1497 1499
1498 KMessageBox::information( this, message); 1500 KMessageBox::information( this, message);
1499} 1501}
1500void MainWindow::exportToPhone( int mode ) 1502void MainWindow::exportToPhone( int mode )
1501{ 1503{
1502 1504
1503 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1505 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1504 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1506 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1505 KOex2phonePrefs ex2phone; 1507 KOex2phonePrefs ex2phone;
1506 1508
1507 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1509 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1508 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1510 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1509 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1511 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1510 if ( mode == 1 ) 1512 if ( mode == 1 )
1511 ex2phone.setCaption(i18n("Export complete calendar")); 1513 ex2phone.setCaption(i18n("Export complete calendar"));
1512 if ( mode == 2 ) 1514 if ( mode == 2 )
1513 ex2phone.setCaption(i18n("Export filtered calendar")); 1515 ex2phone.setCaption(i18n("Export filtered calendar"));
1514 1516
1515 if ( !ex2phone.exec() ) { 1517 if ( !ex2phone.exec() ) {
1516 return; 1518 return;
1517 } 1519 }
1518 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1520 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1519 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1521 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1520 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1522 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1521 1523
1522 int inFuture = 0; 1524 int inFuture = 0;
1523 if ( ex2phone.mWriteBackFuture->isChecked() ) 1525 if ( ex2phone.mWriteBackFuture->isChecked() )
1524 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1526 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1525 QPtrList<Incidence> delSel; 1527 QPtrList<Incidence> delSel;
1526 if ( mode == 1 ) 1528 if ( mode == 1 )
1527 delSel = mCalendar->rawIncidences(); 1529 delSel = mCalendar->rawIncidences();
1528 if ( mode == 2 ) 1530 if ( mode == 2 )
1529 delSel = mCalendar->incidences(); 1531 delSel = mCalendar->incidences();
1530 CalendarLocal* cal = new CalendarLocal(); 1532 CalendarLocal* cal = new CalendarLocal();
1531 cal->setLocalTime(); 1533 cal->setLocalTime();
1532 Incidence *incidence = delSel.first(); 1534 Incidence *incidence = delSel.first();
1533 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1535 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1534 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1536 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1535 while ( incidence ) { 1537 while ( incidence ) {
1536 if ( incidence->typeID() != journalID ) { 1538 if ( incidence->typeID() != journalID ) {
1537 bool add = true; 1539 bool add = true;
1538 if ( inFuture ) { 1540 if ( inFuture ) {
1539 QDateTime dt; 1541 QDateTime dt;
1540 if ( incidence->typeID() == todoID ) { 1542 if ( incidence->typeID() == todoID ) {
1541 Todo * t = (Todo*)incidence; 1543 Todo * t = (Todo*)incidence;
1542 if ( t->hasDueDate() ) 1544 if ( t->hasDueDate() )
1543 dt = t->dtDue(); 1545 dt = t->dtDue();
1544 else 1546 else
1545 dt = cur.addSecs( 62 ); 1547 dt = cur.addSecs( 62 );
1546 } 1548 }
1547 else { 1549 else {
1548 bool ok; 1550 bool ok;
1549 dt = incidence->getNextOccurence( cur, &ok ); 1551 dt = incidence->getNextOccurence( cur, &ok );
1550 if ( !ok ) 1552 if ( !ok )
1551 dt = cur.addSecs( -62 ); 1553 dt = cur.addSecs( -62 );
1552 } 1554 }
1553 if ( dt < cur || dt > end ) { 1555 if ( dt < cur || dt > end ) {
1554 add = false; 1556 add = false;
1555 } 1557 }
1556 } 1558 }
1557 if ( add ) { 1559 if ( add ) {
1558 Incidence *in = incidence->clone(); 1560 Incidence *in = incidence->clone();
1559 cal->addIncidence( in ); 1561 cal->addIncidence( in );
1560 } 1562 }
1561 } 1563 }
1562 incidence = delSel.next(); 1564 incidence = delSel.next();
1563 } 1565 }
1564 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1566 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1565 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1567 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1566 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1568 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1567 1569
1568 setCaption( i18n("Writing to phone...")); 1570 setCaption( i18n("Writing to phone..."));
1569 if ( PhoneFormat::writeToPhone( cal ) ) 1571 if ( PhoneFormat::writeToPhone( cal ) )
1570 setCaption( i18n("Export to phone successful!")); 1572 setCaption( i18n("Export to phone successful!"));
1571 else 1573 else
1572 setCaption( i18n("Error exporting to phone!")); 1574 setCaption( i18n("Error exporting to phone!"));
1573 delete cal; 1575 delete cal;
1574} 1576}
1575 1577
1576 1578
1577void MainWindow::setDefaultPreferences() 1579void MainWindow::setDefaultPreferences()
1578{ 1580{
1579 KOPrefs *p = KOPrefs::instance(); 1581 KOPrefs *p = KOPrefs::instance();
1580 1582
1581 p->mCompactDialogs = true; 1583 p->mCompactDialogs = true;
1582 p->mConfirm = true; 1584 p->mConfirm = true;
1583 // p->mEnableQuickTodo = false; 1585 // p->mEnableQuickTodo = false;
1584 1586
1585} 1587}
1586 1588
1587QString MainWindow::resourcePath() 1589QString MainWindow::resourcePath()
1588{ 1590{
1589 return KGlobal::iconLoader()->iconPath(); 1591 return KGlobal::iconLoader()->iconPath();
1590} 1592}
1591 1593
1592void MainWindow::displayText( QString text ,QString cap ) 1594void MainWindow::displayText( QString text ,QString cap )
1593{ 1595{
1594 QDialog dia( this, "name", true ); ; 1596 QDialog dia( this, "name", true ); ;
1595 dia.setCaption( cap ); 1597 dia.setCaption( cap );
1596 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1598 QVBoxLayout* lay = new QVBoxLayout( &dia );
1597 lay->setSpacing( 3 ); 1599 lay->setSpacing( 3 );
1598 lay->setMargin( 3 ); 1600 lay->setMargin( 3 );
1599 QTextBrowser tb ( &dia ); 1601 QTextBrowser tb ( &dia );
1600 lay->addWidget( &tb ); 1602 lay->addWidget( &tb );
1601 tb.setText( text ); 1603 tb.setText( text );
1602#ifdef DESKTOP_VERSION 1604#ifdef DESKTOP_VERSION
1603 dia.resize( 640, 480); 1605 dia.resize( 640, 480);
1604#else 1606#else
1605 dia.showMaximized(); 1607 dia.showMaximized();
1606#endif 1608#endif
1607 dia.exec(); 1609 dia.exec();
1608} 1610}
1609 1611
1610void MainWindow::features() 1612void MainWindow::features()
1611{ 1613{
1612 1614
1613 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1615 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1614} 1616}
1615 1617
1616void MainWindow::usertrans() 1618void MainWindow::usertrans()
1617{ 1619{
1618 1620
1619 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1621 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1620} 1622}
1621 1623
1622void MainWindow::storagehowto() 1624void MainWindow::storagehowto()
1623{ 1625{
1624 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1626 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1625} 1627}
1626void MainWindow::timetrackinghowto() 1628void MainWindow::timetrackinghowto()
1627{ 1629{
1628 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1630 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1629} 1631}
1630void MainWindow::kdesynchowto() 1632void MainWindow::kdesynchowto()
1631{ 1633{
1632 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1634 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1633} 1635}
1634void MainWindow::multisynchowto() 1636void MainWindow::multisynchowto()
1635{ 1637{
1636 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1638 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1637} 1639}
1638void MainWindow::synchowto() 1640void MainWindow::synchowto()
1639{ 1641{
1640 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1642 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1641} 1643}
1642void MainWindow::faq() 1644void MainWindow::faq()
1643{ 1645{
1644 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1646 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1645 1647
1646} 1648}
1647void MainWindow::whatsNew() 1649void MainWindow::whatsNew()
1648{ 1650{
1649 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1651 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1650 1652
1651} 1653}
1652void MainWindow::licence() 1654void MainWindow::licence()
1653{ 1655{
1654 KApplication::showLicence(); 1656 KApplication::showLicence();
1655 1657
1656} 1658}
1657void MainWindow::about() 1659void MainWindow::about()
1658{ 1660{
1659 QString version; 1661 QString version;
1660#include <../version> 1662#include <../version>
1661 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1663 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1662 i18n("KOrganizer/Platform-independent\n") + 1664 i18n("KOrganizer/Platform-independent\n") +
1663 "(KO/Pi) " + version + " - " + 1665 "(KO/Pi) " + version + " - " +
1664 1666
1665#ifdef DESKTOP_VERSION 1667#ifdef DESKTOP_VERSION
1666 i18n("Desktop Edition\n") + 1668 i18n("Desktop Edition\n") +
1667#else 1669#else
1668 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1670 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1669#endif 1671#endif
1670 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!") ); 1672 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!") );
1671} 1673}
1672void MainWindow::keyBindings() 1674void MainWindow::keyBindings()
1673{ 1675{
1674 QString cap = i18n("KO/Pi Keys + Colors"); 1676 QString cap = i18n("KO/Pi Keys + Colors");
1675 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1677 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1676 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1678 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1677 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1679 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1678 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1680 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1679 i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") + 1681 i18n("<p><b>C+ctrl</b>: Dis/enable automatic saving</p>\n") +
1680 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1682 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1681 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1683 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1682 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1684 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1683 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1685 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1684 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1686 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1685 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1687 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1686 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1688 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1687 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1689 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1688 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1690 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1689 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1691 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1690 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1692 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1691 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1693 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1692 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1694 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1693 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1695 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1694 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1696 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1695 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1697 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1696 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1698 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1697 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1699 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1698 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1700 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1699 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1701 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1700 i18n("<p><h3>In agenda view:</h3></p>\n") + 1702 i18n("<p><h3>In agenda view:</h3></p>\n") +
1701 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1703 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1702 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1704 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1703 i18n("<p><h3>In todo view:</h3></p>\n") + 1705 i18n("<p><h3>In todo view:</h3></p>\n") +
1704 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1706 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1705 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1707 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1706 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1708 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1707 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1709 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1708 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1710 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1709 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1711 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1710 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1712 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1711 i18n("<p><h3>In list view:</h3></p>\n") + 1713 i18n("<p><h3>In list view:</h3></p>\n") +
1712 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1714 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1713 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1715 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1714 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1716 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1715 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1717 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1716 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1718 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1717 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1719 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1718 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1720 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1719 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1721 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1720 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1722 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1721 i18n("<p><b>E</b>: Edit item</p>\n") + 1723 i18n("<p><b>E</b>: Edit item</p>\n") +
1722 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1724 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1723 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1725 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1724 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1726 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1725 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1727 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1726 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1728 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1727 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1729 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1728 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1730 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1729 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1731 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1730 i18n("<p><b>White</b>: Item readonly</p>\n"); 1732 i18n("<p><b>White</b>: Item readonly</p>\n");
1731 displayText( text, cap); 1733 displayText( text, cap);
1732} 1734}
1733void MainWindow::aboutAutoSaving() 1735void MainWindow::aboutAutoSaving()
1734{ 1736{
1735 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"); 1737 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");
1736 1738
1737 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1739 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1738 1740
1739} 1741}
1740void MainWindow::aboutKnownBugs() 1742void MainWindow::aboutKnownBugs()
1741{ 1743{
1742 QMessageBox* msg; 1744 QMessageBox* msg;
1743 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1745 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1744 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")+ 1746 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")+
1745 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1747 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1746 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1748 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1747 i18n("\nor report them in the bugtracker on\n") + 1749 i18n("\nor report them in the bugtracker on\n") +
1748 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1750 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1749 QMessageBox::NoIcon, 1751 QMessageBox::NoIcon,
1750 QMessageBox::Ok, 1752 QMessageBox::Ok,
1751 QMessageBox::NoButton, 1753 QMessageBox::NoButton,
1752 QMessageBox::NoButton); 1754 QMessageBox::NoButton);
1753 msg->exec(); 1755 msg->exec();
1754 delete msg; 1756 delete msg;
1755 1757
1756} 1758}
1757 1759
1758QString MainWindow::defaultFileName() 1760QString MainWindow::defaultFileName()
1759{ 1761{
1760 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 1762 return QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
1761} 1763}
1762QString MainWindow::syncFileName() 1764QString MainWindow::syncFileName()
1763{ 1765{
1764#ifdef DESKTOP_VERSION 1766#ifdef DESKTOP_VERSION
1765 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) ); 1767 return QDir::convertSeparators( locateLocal( "tmp", "synccalendar.ics" ) );
1766#else 1768#else
1767 return QString( "/tmp/synccalendar.ics" ); 1769 return QString( "/tmp/synccalendar.ics" );
1768#endif 1770#endif
1769} 1771}
1770#include "koglobals.h" 1772#include "koglobals.h"
1771#include <kcalendarsystem.h> 1773#include <kcalendarsystem.h>
1772void MainWindow::updateWeek(QDate seda) 1774void MainWindow::updateWeek(QDate seda)
1773{ 1775{
1774 int weekNum = KGlobal::locale()->weekNum ( seda ); 1776 int weekNum = KGlobal::locale()->weekNum ( seda );
1775 mWeekPixmap.fill( mWeekBgColor ); 1777 mWeekPixmap.fill( mWeekBgColor );
1776 QPainter p ( &mWeekPixmap ); 1778 QPainter p ( &mWeekPixmap );
1777 p.setFont( mWeekFont ); 1779 p.setFont( mWeekFont );
1778 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1780 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1779 p.end(); 1781 p.end();
1780 QIconSet icon3 ( mWeekPixmap ); 1782 QIconSet icon3 ( mWeekPixmap );
1781 mWeekAction->setIconSet ( icon3 ); 1783 mWeekAction->setIconSet ( icon3 );
1782 1784
1783} 1785}
1784void MainWindow::updateWeekNum(const DateList &selectedDates) 1786void MainWindow::updateWeekNum(const DateList &selectedDates)
1785{ 1787{
1786 updateWeek( selectedDates.first() ); 1788 updateWeek( selectedDates.first() );
1787} 1789}
1788void MainWindow::processIncidenceSelection( Incidence *incidence ) 1790void MainWindow::processIncidenceSelection( Incidence *incidence )
1789{ 1791{
1790 if ( !incidence ) { 1792 if ( !incidence ) {
1791 mShowAction->setMenuText( i18n("Show") ); 1793 mShowAction->setMenuText( i18n("Show") );
1792 enableIncidenceActions( false ); 1794 enableIncidenceActions( false );
1793 mNewSubTodoAction->setEnabled( false ); 1795 mNewSubTodoAction->setEnabled( false );
1794 setCaptionToDates(); 1796 setCaptionToDates();
1795 return; 1797 return;
1796 } 1798 }
1797 QString startString = ""; 1799 QString startString = "";
1798 if ( incidence->typeID() != todoID ) { 1800 if ( incidence->typeID() != todoID ) {
1799 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1801 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1800 if ( incidence->doesFloat() ) { 1802 if ( incidence->doesFloat() ) {
1801 startString += ": "+incidence->dtStartDateStr( true ); 1803 startString += ": "+incidence->dtStartDateStr( true );
1802 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1804 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1803 } else { 1805 } else {
1804 startString = ": "+incidence->dtStartStr(true); 1806 startString = ": "+incidence->dtStartStr(true);
1805 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1807 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1806 } 1808 }
1807 } else { 1809 } else {
1808 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1810 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1809 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1811 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1810 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1812 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1811 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1813 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1812 bool ok; 1814 bool ok;
1813 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1815 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1814 if ( ok ) { 1816 if ( ok ) {
1815 int years = noc.date().year() - incidence->dtStart().date().year(); 1817 int years = noc.date().year() - incidence->dtStart().date().year();
1816 startString += i18n(" (%1 y.)"). arg( years ); 1818 startString += i18n(" (%1 y.)"). arg( years );
1817 } 1819 }
1818 } 1820 }
1819 else 1821 else
1820 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1822 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1821 } 1823 }
1822 } 1824 }
1823 else { 1825 else {
1824 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1826 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1825 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1827 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1826 else 1828 else
1827 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1829 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1828 } 1830 }
1829 if ( !incidence->location().isEmpty() ) 1831 if ( !incidence->location().isEmpty() )
1830 startString += " (" +incidence->location()+")"; 1832 startString += " (" +incidence->location()+")";
1831 setCaption( incidence->summary()+startString); 1833 setCaption( incidence->summary()+startString);
1832 enableIncidenceActions( true ); 1834 enableIncidenceActions( true );
1833 if ( incidence->typeID() == eventID ) { 1835 if ( incidence->typeID() == eventID ) {
1834 mShowAction->setMenuText( i18n("Show Event") ); 1836 mShowAction->setMenuText( i18n("Show Event") );
1835 mNewSubTodoAction->setEnabled( false ); 1837 mNewSubTodoAction->setEnabled( false );
1836 } else if ( incidence->typeID() == todoID ) { 1838 } else if ( incidence->typeID() == todoID ) {
1837 mShowAction->setMenuText( i18n("Show Todo") ); 1839 mShowAction->setMenuText( i18n("Show Todo") );
1838 mNewSubTodoAction->setEnabled( true ); 1840 mNewSubTodoAction->setEnabled( true );
1839 } else { 1841 } else {
1840 mShowAction->setMenuText( i18n("Show") ); 1842 mShowAction->setMenuText( i18n("Show") );
1841 mNewSubTodoAction->setEnabled( false ); 1843 mNewSubTodoAction->setEnabled( false );
1842 } 1844 }
1843#ifdef DESKTOP_VERSION 1845#ifdef DESKTOP_VERSION
1844 static QPixmap jP = SmallIcon( "journal" ); 1846 static QPixmap jP = SmallIcon( "journal" );
1845 static QPixmap eP = SmallIcon( "newevent" ); 1847 static QPixmap eP = SmallIcon( "newevent" );
1846 static QPixmap tP = SmallIcon( "newtodo" ); 1848 static QPixmap tP = SmallIcon( "newtodo" );
1847 QIconSet icon; 1849 QIconSet icon;
1848 if ( incidence->typeID() == todoID ) 1850 if ( incidence->typeID() == todoID )
1849 icon = QIconSet ( tP ); 1851 icon = QIconSet ( tP );
1850 else if ( incidence->typeID() == eventID ) 1852 else if ( incidence->typeID() == eventID )
1851 icon = QIconSet ( eP ); 1853 icon = QIconSet ( eP );
1852 else if ( incidence->typeID() == journalID ) 1854 else if ( incidence->typeID() == journalID )
1853 icon = QIconSet ( jP ); 1855 icon = QIconSet ( jP );
1854 mPrintSelAction->setIconSet ( icon ); 1856 mPrintSelAction->setIconSet ( icon );
1855#endif 1857#endif
1856} 1858}
1857 1859
1858void MainWindow::enableIncidenceActions( bool enabled ) 1860void MainWindow::enableIncidenceActions( bool enabled )
1859{ 1861{
1860 mShowAction->setEnabled( enabled ); 1862 mShowAction->setEnabled( enabled );
1861 mEditAction->setEnabled( enabled ); 1863 mEditAction->setEnabled( enabled );
1862 mDeleteAction->setEnabled( enabled ); 1864 mDeleteAction->setEnabled( enabled );
1863 1865
1864 mCloneAction->setEnabled( enabled ); 1866 mCloneAction->setEnabled( enabled );
1865 mMoveAction->setEnabled( enabled ); 1867 mMoveAction->setEnabled( enabled );
1866#ifndef DESKTOP_VERSION 1868#ifndef DESKTOP_VERSION
1867 mBeamAction->setEnabled( enabled ); 1869 mBeamAction->setEnabled( enabled );
1868#else 1870#else
1869 mPrintSelAction->setEnabled( enabled ); 1871 mPrintSelAction->setEnabled( enabled );
1870#endif 1872#endif
1871 mCancelAction->setEnabled( enabled ); 1873 mCancelAction->setEnabled( enabled );
1872} 1874}
1873 1875
1874void MainWindow::importOL() 1876void MainWindow::importOL()
1875{ 1877{
1876#ifdef _OL_IMPORT_ 1878#ifdef _OL_IMPORT_
1877 mView->clearAllViews(); 1879 mView->clearAllViews();
1878 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1880 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1879 id->exec(); 1881 id->exec();
1880 delete id; 1882 delete id;
1881 mView->calendar()->checkAlarmForIncidence( 0, true ); 1883 mView->calendar()->checkAlarmForIncidence( 0, true );
1882 mView->updateView(); 1884 mView->updateView();
1883#endif 1885#endif
1884} 1886}
1885void MainWindow::importBday() 1887void MainWindow::importBday()
1886{ 1888{
1887 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1889 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1888 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1890 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1889 i18n("Import!"), i18n("Cancel"), 0, 1891 i18n("Import!"), i18n("Cancel"), 0,
1890 0, 1 ); 1892 0, 1 );
1891 if ( result == 0 ) { 1893 if ( result == 0 ) {
1892 mView->importBday(); 1894 mView->importBday();
1893 1895
1894 } 1896 }
1895 1897
1896 1898
1897} 1899}
1898void MainWindow::importQtopia() 1900void MainWindow::importQtopia()
1899{ 1901{
1900 //#ifndef DESKTOP_VERSION 1902 //#ifndef DESKTOP_VERSION
1901 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"); 1903 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");
1902#ifdef DESKTOP_VERSION 1904#ifdef DESKTOP_VERSION
1903 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"); 1905 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");
1904#endif 1906#endif
1905 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1907 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1906 i18n("Import!"), i18n("Cancel"), 0, 1908 i18n("Import!"), i18n("Cancel"), 0,
1907 0, 1 ); 1909 0, 1 );
1908 if ( result == 0 ) { 1910 if ( result == 0 ) {
1909#ifndef DESKTOP_VERSION 1911#ifndef DESKTOP_VERSION
1910 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1912 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1911 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1913 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1912 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1914 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1913#else 1915#else
1914 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1916 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1915 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1917 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1916 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1918 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1917#endif 1919#endif
1918 mView->importQtopia( categories, datebook, todolist ); 1920 mView->importQtopia( categories, datebook, todolist );
1919 } 1921 }
1920 mView->calendar()->reInitAlarmSettings(); 1922 mView->calendar()->reInitAlarmSettings();
1921#if 0 1923#if 0
1922 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1924 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1923 i18n("Not supported \non desktop!\n"), 1925 i18n("Not supported \non desktop!\n"),
1924 i18n("Ok"), i18n("Cancel"), 0, 1926 i18n("Ok"), i18n("Cancel"), 0,
1925 0, 1 ); 1927 0, 1 );
1926 1928
1927#endif 1929#endif
1928} 1930}
1929 1931
1930void MainWindow::saveOnClose() 1932void MainWindow::saveOnClose()
1931{ 1933{
1932 KOPrefs *p = KOPrefs::instance(); 1934 KOPrefs *p = KOPrefs::instance();
1933 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1935 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1934 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1936 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1935 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1937 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1936 if ( filterToolBar ) { 1938 if ( filterToolBar ) {
1937 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1939 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1938 } 1940 }
1939#ifdef DESKTOP_VERSION 1941#ifdef DESKTOP_VERSION
1940 1942
1941 QPoint myP; 1943 QPoint myP;
1942 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1944 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1943 if ( p->mToolBarHor ) 1945 if ( p->mToolBarHor )
1944 p->mToolBarUp = myP.y() > height()/2; 1946 p->mToolBarUp = myP.y() > height()/2;
1945 else 1947 else
1946 p->mToolBarUp = myP.x() > width()/2; 1948 p->mToolBarUp = myP.x() > width()/2;
1947 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1949 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1948 if ( p->mToolBarHorV ) 1950 if ( p->mToolBarHorV )
1949 p->mToolBarUpV = myP.y() > height()/2; 1951 p->mToolBarUpV = myP.y() > height()/2;
1950 else 1952 else
1951 p->mToolBarUpV = myP.x() > width()/2 ; 1953 p->mToolBarUpV = myP.x() > width()/2 ;
1952 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1954 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1953 if ( p->mToolBarHorN ) 1955 if ( p->mToolBarHorN )
1954 p->mToolBarUpN = myP.y() > height()/2; 1956 p->mToolBarUpN = myP.y() > height()/2;
1955 else 1957 else
1956 p->mToolBarUpN = myP.x() > width()/2 ; 1958 p->mToolBarUpN = myP.x() > width()/2 ;
1957 if ( filterToolBar ) { 1959 if ( filterToolBar ) {
1958 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1960 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1959 if ( p->mToolBarHorF ) 1961 if ( p->mToolBarHorF )
1960 p->mToolBarUpF = myP.y() > height()/2; 1962 p->mToolBarUpF = myP.y() > height()/2;
1961 else 1963 else
1962 p->mToolBarUpF = myP.x() > width()/2 ; 1964 p->mToolBarUpF = myP.x() > width()/2 ;
1963 } 1965 }
1964#else 1966#else
1965 if ( p->mToolBarHor ) 1967 if ( p->mToolBarHor )
1966 p->mToolBarUp = iconToolBar->y() > height()/2; 1968 p->mToolBarUp = iconToolBar->y() > height()/2;
1967 else 1969 else
1968 p->mToolBarUp = iconToolBar->x() > width()/2; 1970 p->mToolBarUp = iconToolBar->x() > width()/2;
1969 if ( p->mToolBarHorV ) 1971 if ( p->mToolBarHorV )
1970 p->mToolBarUpV = viewToolBar->y() > height()/2; 1972 p->mToolBarUpV = viewToolBar->y() > height()/2;
1971 else 1973 else
1972 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1974 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1973 1975
1974 if ( p->mToolBarHorN ) 1976 if ( p->mToolBarHorN )
1975 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1977 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1976 else 1978 else
1977 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1979 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1978 if ( filterToolBar ) { 1980 if ( filterToolBar ) {
1979 if ( p->mToolBarHorF ) 1981 if ( p->mToolBarHorF )
1980 p->mToolBarUpF = filterToolBar->y() > height()/2; 1982 p->mToolBarUpF = filterToolBar->y() > height()/2;
1981 else 1983 else
1982 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1984 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1983 } 1985 }
1984#endif 1986#endif
1985 save(); 1987 save();
1986 mView->writeSettings(); 1988 mView->writeSettings();
1987 mView->checkSuspendAlarm(); 1989 mView->checkSuspendAlarm();
1988} 1990}
1989void MainWindow::slotModifiedChanged( bool ) 1991void MainWindow::slotModifiedChanged( bool )
1990{ 1992{
1991 if ( mBlockAtStartup ) 1993 if ( mBlockAtStartup )
1992 return; 1994 return;
1993 1995
1994 int msec; 1996 int msec;
1995 if ( mAutoSaveDisabled ) { 1997 if ( mAutoSaveDisabled ) {
1996 QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) ); 1998 QTimer::singleShot( 0, this , SLOT ( autoSaveWarning() ) );
1997 qDebug("KO: Autosave disabled (data change deteced)!"); 1999 qDebug("KO: Autosave disabled (data change deteced)!");
1998 } 2000 }
1999 if ( mCalendarModifiedFlag ) { 2001 if ( mCalendarModifiedFlag ) {
2000 //qDebug(" MainWindow timer is running "); 2002 //qDebug(" MainWindow timer is running ");
2001 return; 2003 return;
2002 } 2004 }
2003 mCalendarModifiedFlag = true; 2005 mCalendarModifiedFlag = true;
2004 if ( mAutoSaveDisabled ) { 2006 if ( mAutoSaveDisabled ) {
2005 return; 2007 return;
2006 } 2008 }
2007 // we store the changes after 1 minute, 2009 // we store the changes after 1 minute,
2008 // and for safety reasons after 10 minutes again 2010 // and for safety reasons after 10 minutes again
2009 if ( !mSyncManager->blockSave() ) 2011 if ( !mSyncManager->blockSave() )
2010 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 2012 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
2011 else 2013 else
2012 msec = 1000 * 600; 2014 msec = 1000 * 600;
2013 mSaveTimer.start( msec, true ); // 1 minute 2015 mSaveTimer.start( msec, true ); // 1 minute
2014 mSaveTimerStart = QDateTime::currentDateTime(); 2016 mSaveTimerStart = QDateTime::currentDateTime();
2015 mSaveDelay = msec/1000; 2017 mSaveDelay = msec/1000;
2016 qDebug("KO: Saving File in %d secs!", msec/1000); 2018 qDebug("KO: Saving File in %d secs!", msec/1000);
2017} 2019}
2018void MainWindow::autoSaveWarning() 2020void MainWindow::autoSaveWarning()
2019{ 2021{
2020 setCaption(i18n("Autosave disabled!" )); 2022 setCaption(i18n("Autosave disabled!" ));
2021} 2023}
2022void MainWindow::saveStopTimer() 2024void MainWindow::saveStopTimer()
2023{ 2025{
2024 mSaveTimer.stop(); 2026 mSaveTimer.stop();
2025 mSaveDelay = 0; 2027 mSaveDelay = 0;
2026} 2028}
2027void MainWindow::backupAllFiles() 2029void MainWindow::backupAllFiles()
2028{ 2030{
2029 QDate reference ( 2000,1,1); 2031 QDate reference ( 2000,1,1);
2030 int daysTo = reference.daysTo ( QDate::currentDate() ); 2032 int daysTo = reference.daysTo ( QDate::currentDate() );
2031 setCaption(i18n("Creating backup ... please wait ..." )); 2033 setCaption(i18n("Creating backup ... please wait ..." ));
2032 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 2034 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
2033 // we need the file path, the backup dir and the number of bups as param 2035 // we need the file path, the backup dir and the number of bups as param
2034 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2036 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2035 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2037 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2036 bupDir = KGlobalSettings::backupDataDir(); 2038 bupDir = KGlobalSettings::backupDataDir();
2037 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2039 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2038 if ( retval == 0 ) { 2040 if ( retval == 0 ) {
2039 setCaption(i18n("Backup cancelled" )); 2041 setCaption(i18n("Backup cancelled" ));
2040 qDebug("KO: Backup cancelled. Will try again tomorrow "); 2042 qDebug("KO: Backup cancelled. Will try again tomorrow ");
2041 // retval == 0 : backup skipped for today, try again tomorrow 2043 // retval == 0 : backup skipped for today, try again tomorrow
2042 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 2044 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
2043 } else if ( retval == 1 ){ 2045 } else if ( retval == 1 ){
2044 qDebug("KO: Backup created."); 2046 qDebug("KO: Backup created.");
2045 // backup ok 2047 // backup ok
2046 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2048 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2047 KopiCalendarFile * cal = calendars.first(); 2049 KopiCalendarFile * cal = calendars.first();
2048 cal = calendars.next(); 2050 cal = calendars.next();
2049 while ( cal ) { 2051 while ( cal ) {
2050 if ( !cal->mErrorOnLoad ) { 2052 if ( !cal->mErrorOnLoad ) {
2051 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 2053 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
2052 } 2054 }
2053 cal = calendars.next(); 2055 cal = calendars.next();
2054 } 2056 }
2055 KOPrefs::instance()->mLastBackupDate = daysTo; 2057 KOPrefs::instance()->mLastBackupDate = daysTo;
2056 setCaption(i18n("Backup succesfully finished" )); 2058 setCaption(i18n("Backup succesfully finished" ));
2057 } else if ( retval == 2 ){ 2059 } else if ( retval == 2 ){
2058 setCaption(i18n("Backup globally disabled" )); 2060 setCaption(i18n("Backup globally disabled" ));
2059 qDebug("KO: Backup globally cancelled."); 2061 qDebug("KO: Backup globally cancelled.");
2060 // backup globally cancelled 2062 // backup globally cancelled
2061 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2063 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2062 } 2064 }
2063 // retval == 3: do nothing, try again later 2065 // retval == 3: do nothing, try again later
2064} 2066}
2065void MainWindow::save() 2067void MainWindow::save()
2066{ 2068{
2067 if ( mSaveDelay ) { 2069 if ( mSaveDelay ) {
2068 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() ); 2070 int elapsed = mSaveTimerStart.secsTo( QDateTime::currentDateTime() );
2069 if ( mSaveDelay < elapsed ) { 2071 if ( mSaveDelay < elapsed ) {
2070 qDebug("KO: Pending save after wakeup from suspend detected."); 2072 qDebug("KO: Pending save after wakeup from suspend detected.");
2071 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed ); 2073 qDebug("KO: Save delay %d sec. Elapsed save time %d sec.", mSaveDelay, elapsed );
2072 qDebug("KO: Restarting save timer to save in 10 sec."); 2074 qDebug("KO: Restarting save timer to save in 10 sec.");
2073 int msec = 10000; 2075 int msec = 10000;
2074 mSaveTimer.start( msec, true ); 2076 mSaveTimer.start( msec, true );
2075 mSaveTimerStart = QDateTime::currentDateTime(); 2077 mSaveTimerStart = QDateTime::currentDateTime();
2076 mSaveDelay = msec/1000; 2078 mSaveDelay = msec/1000;
2077 return; 2079 return;
2078 } 2080 }
2079 } 2081 }
2080 if ( mView->viewManager()->journalView() ) 2082 if ( mView->viewManager()->journalView() )
2081 mView->viewManager()->journalView()->checkModified(); 2083 mView->viewManager()->journalView()->checkModified();
2082 if ( !mCalendarModifiedFlag ) { 2084 if ( !mCalendarModifiedFlag ) {
2083 qDebug("KO: Calendar not modified. Nothing saved."); 2085 qDebug("KO: Calendar not modified. Nothing saved.");
2084 return; 2086 return;
2085 } 2087 }
2086 if ( mSyncManager->blockSave() ) { 2088 if ( mSyncManager->blockSave() ) {
2087 slotModifiedChanged( true ); 2089 slotModifiedChanged( true );
2088 return; 2090 return;
2089 } 2091 }
2090#ifndef DESKTOP_VERSION 2092#ifndef DESKTOP_VERSION
2091 // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); 2093 // QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
2092#endif 2094#endif
2093 mSaveDelay = 0; 2095 mSaveDelay = 0;
2094 mSyncManager->setBlockSave(true); 2096 mSyncManager->setBlockSave(true);
2095 if ( mView->checkAllFileVersions() ) { 2097 if ( mView->checkAllFileVersions() ) {
2096 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 2098 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
2097 QDate reference ( 2000,1,1); 2099 QDate reference ( 2000,1,1);
2098 int daysTo = reference.daysTo ( QDate::currentDate() ); 2100 int daysTo = reference.daysTo ( QDate::currentDate() );
2099 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 2101 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
2100 backupAllFiles(); 2102 backupAllFiles();
2101 } 2103 }
2102 ; // KPimGlobalPrefs::instance()->mLastBackupDate 2104 ; // KPimGlobalPrefs::instance()->mLastBackupDate
2103 } 2105 }
2104 QTime neededSaveTime; 2106 QTime neededSaveTime;
2105 neededSaveTime.start(); 2107 neededSaveTime.start();
2106 if ( !isMinimized () ) 2108 if ( !isMinimized () )
2107 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 2109 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
2108 qDebug("KO: Start saving data to file!"); 2110 qDebug("KO: Start saving data to file!");
2109 if ( mView->saveCalendars() ) 2111 if ( mView->saveCalendars() )
2110 mCalendarModifiedFlag = false; 2112 mCalendarModifiedFlag = false;
2111 int msNeeded = neededSaveTime.elapsed(); 2113 int msNeeded = neededSaveTime.elapsed();
2112 qDebug("KO: Needed %d ms for saving.",msNeeded ); 2114 qDebug("KO: Needed %d ms for saving.",msNeeded );
2113 QString savemes; 2115 QString savemes;
2114 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 2116 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
2115 if ( !isMinimized () ) 2117 if ( !isMinimized () )
2116 setCaption(savemes); 2118 setCaption(savemes);
2117 else 2119 else
2118 qDebug(savemes); 2120 qDebug(savemes);
2119 } else { 2121 } else {
2120 setCaption(i18n("Saving cancelled!")); 2122 setCaption(i18n("Saving cancelled!"));
2121 mCalendarModifiedFlag = false; 2123 mCalendarModifiedFlag = false;
2122 slotModifiedChanged( true ); 2124 slotModifiedChanged( true );
2123 } 2125 }
2124 mSyncManager->setBlockSave( false ); 2126 mSyncManager->setBlockSave( false );
2125#ifndef DESKTOP_VERSION 2127#ifndef DESKTOP_VERSION
2126 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); 2128 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
2127#endif 2129#endif
2128} 2130}
2129 2131
2130void MainWindow::keyReleaseEvent ( QKeyEvent * e) 2132void MainWindow::keyReleaseEvent ( QKeyEvent * e)
2131{ 2133{
2132 if ( !e->isAutoRepeat() ) { 2134 if ( !e->isAutoRepeat() ) {
2133 mFlagKeyPressed = false; 2135 mFlagKeyPressed = false;
2134 } 2136 }
2135} 2137}
2136void MainWindow::keyPressEvent ( QKeyEvent * e ) 2138void MainWindow::keyPressEvent ( QKeyEvent * e )
2137{ 2139{
2138 qApp->processEvents(); 2140 qApp->processEvents();
2139 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2141 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2140 e->ignore(); 2142 e->ignore();
2141 // qDebug(" ignore %d",e->isAutoRepeat() ); 2143 // qDebug(" ignore %d",e->isAutoRepeat() );
2142 return; 2144 return;
2143 } 2145 }
2144 if (! e->isAutoRepeat() ) 2146 if (! e->isAutoRepeat() )
2145 mFlagKeyPressed = true; 2147 mFlagKeyPressed = true;
2146 KOPrefs *p = KOPrefs::instance(); 2148 KOPrefs *p = KOPrefs::instance();
2147 bool showSelectedDates = false; 2149 bool showSelectedDates = false;
2148 int size; 2150 int size;
2149 int pro = 0; 2151 int pro = 0;
2150 //qDebug("MainWindow::keyPressEvent "); 2152 //qDebug("MainWindow::keyPressEvent ");
2151 switch ( e->key() ) { 2153 switch ( e->key() ) {
2152 case Qt::Key_Right: 2154 case Qt::Key_Right:
2153 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2155 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2154 mView->goNextMonth(); 2156 mView->goNextMonth();
2155 else 2157 else
2156 mView->goNext(); 2158 mView->goNext();
2157 showSelectedDates = true; 2159 showSelectedDates = true;
2158 break; 2160 break;
2159 case Qt::Key_Left: 2161 case Qt::Key_Left:
2160 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2162 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2161 mView->goPreviousMonth(); 2163 mView->goPreviousMonth();
2162 else 2164 else
2163 mView->goPrevious(); 2165 mView->goPrevious();
2164 showSelectedDates = true; 2166 showSelectedDates = true;
2165 break; 2167 break;
2166 case Qt::Key_Down: 2168 case Qt::Key_Down:
2167 mView->viewManager()->agendaView()->scrollOneHourDown(); 2169 mView->viewManager()->agendaView()->scrollOneHourDown();
2168 break; 2170 break;
2169 case Qt::Key_Up: 2171 case Qt::Key_Up:
2170 mView->viewManager()->agendaView()->scrollOneHourUp(); 2172 mView->viewManager()->agendaView()->scrollOneHourUp();
2171 break; 2173 break;
2172 case Qt::Key_K: 2174 case Qt::Key_K:
2173 mView->viewManager()->showMonthViewWeek(); 2175 mView->viewManager()->showMonthViewWeek();
2174 break; 2176 break;
2175 case Qt::Key_I: 2177 case Qt::Key_I:
2176 mView->showIncidence(); 2178 mView->showIncidence();
2177 break; 2179 break;
2178 case Qt::Key_Delete: 2180 case Qt::Key_Delete:
2179 case Qt::Key_Backspace: 2181 case Qt::Key_Backspace:
2180 mView->deleteIncidence(); 2182 mView->deleteIncidence();
2181 break; 2183 break;
2182 case Qt::Key_D: 2184 case Qt::Key_D:
2183 mView->viewManager()->showDayView(); 2185 mView->viewManager()->showDayView();
2184 showSelectedDates = true; 2186 showSelectedDates = true;
2185 break; 2187 break;
2186 case Qt::Key_O: 2188 case Qt::Key_O:
2187 mView->toggleFilerEnabled( ); 2189 mView->toggleFilerEnabled( );
2188 break; 2190 break;
2189 case Qt::Key_0: 2191 case Qt::Key_0:
2190 case Qt::Key_1: 2192 case Qt::Key_1:
2191 case Qt::Key_2: 2193 case Qt::Key_2:
2192 case Qt::Key_3: 2194 case Qt::Key_3:
2193 case Qt::Key_4: 2195 case Qt::Key_4:
2194 case Qt::Key_5: 2196 case Qt::Key_5:
2195 case Qt::Key_6: 2197 case Qt::Key_6:
2196 case Qt::Key_7: 2198 case Qt::Key_7:
2197 case Qt::Key_8: 2199 case Qt::Key_8:
2198 case Qt::Key_9: 2200 case Qt::Key_9:
2199 pro = e->key()-48; 2201 pro = e->key()-48;
2200 if ( pro == 0 ) 2202 if ( pro == 0 )
2201 pro = 10; 2203 pro = 10;
2202 if ( e->state() == Qt::ControlButton) 2204 if ( e->state() == Qt::ControlButton)
2203 pro += 10; 2205 pro += 10;
2204 break; 2206 break;
2205 case Qt::Key_M: 2207 case Qt::Key_M:
2206 mView->viewManager()->showMonthView(); 2208 mView->viewManager()->showMonthView();
2207 showSelectedDates = true; 2209 showSelectedDates = true;
2208 break; 2210 break;
2209 case Qt::Key_Insert: 2211 case Qt::Key_Insert:
2210 mView->newEvent(); 2212 mView->newEvent();
2211 break; 2213 break;
2212 case Qt::Key_S : 2214 case Qt::Key_S :
2213 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2215 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2214 mView->newSubTodo(); 2216 mView->newSubTodo();
2215 else 2217 else
2216 mView->dialogManager()->showSearchDialog(); 2218 mView->dialogManager()->showSearchDialog();
2217 break; 2219 break;
2218 case Qt::Key_Y : 2220 case Qt::Key_Y :
2219 case Qt::Key_Z : 2221 case Qt::Key_Z :
2220 mView->viewManager()->showWorkWeekView(); 2222 mView->viewManager()->showWorkWeekView();
2221 showSelectedDates = true; 2223 showSelectedDates = true;
2222 break; 2224 break;
2223 case Qt::Key_U : 2225 case Qt::Key_U :
2224 mView->viewManager()->showWeekView(); 2226 mView->viewManager()->showWeekView();
2225 showSelectedDates = true; 2227 showSelectedDates = true;
2226 break; 2228 break;
2227 case Qt::Key_H : 2229 case Qt::Key_H :
2228 keyBindings(); 2230 keyBindings();
2229 break; 2231 break;
2230 case Qt::Key_W: 2232 case Qt::Key_W:
2231 mView->viewManager()->showWhatsNextView(); 2233 mView->viewManager()->showWhatsNextView();
2232 break; 2234 break;
2233 case Qt::Key_L: 2235 case Qt::Key_L:
2234 mView->viewManager()->showListView(); 2236 mView->viewManager()->showListView();
2235 break; 2237 break;
2236 case Qt::Key_N: 2238 case Qt::Key_N:
2237 mView->viewManager()->showNextView(); 2239 mView->viewManager()->showNextView();
2238 break; 2240 break;
2239 case Qt::Key_V: 2241 case Qt::Key_V:
2240 mView->viewManager()->showTodoView(); 2242 mView->viewManager()->showTodoView();
2241 break; 2243 break;
2242 case Qt::Key_C: 2244 case Qt::Key_C:
2243 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 2245 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
2244 if ( mAutoSaveDisabled ) { 2246 if ( mAutoSaveDisabled ) {
2245 mAutoSaveDisabled = false; 2247 mAutoSaveDisabled = false;
2246 setCaption(i18n("Autosave enabled!" )); 2248 setCaption(i18n("Autosave enabled!" ));
2247 return; 2249 return;
2248 } else { 2250 } else {
2249 mAutoSaveDisabled = true; 2251 mAutoSaveDisabled = true;
2250 saveStopTimer(); 2252 saveStopTimer();
2251 setCaption(i18n("Autosave disabled! Save timer stopped!" )); 2253 setCaption(i18n("Autosave disabled! Save timer stopped!" ));
2252 } 2254 }
2253 } else 2255 } else
2254 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2256 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2255 break; 2257 break;
2256 case Qt::Key_P: 2258 case Qt::Key_P:
2257 mView->showDatePicker( ); 2259 mView->showDatePicker( );
2258 break; 2260 break;
2259 case Qt::Key_F: 2261 case Qt::Key_F:
2260 mView->editFilters(); 2262 mView->editFilters();
2261 break; 2263 break;
2262 case Qt::Key_R: 2264 case Qt::Key_R:
2263 mView->toggleFilter(); 2265 mView->toggleFilter();
2264 break; 2266 break;
2265 case Qt::Key_X: 2267 case Qt::Key_X:
2266 if ( e->state() == Qt::ControlButton ) 2268 if ( e->state() == Qt::ControlButton )
2267 mView->toggleDateNavigatorWidget(); 2269 mView->toggleDateNavigatorWidget();
2268 else { 2270 else {
2269 mView->viewManager()->showNextXView(); 2271 mView->viewManager()->showNextXView();
2270 showSelectedDates = true; 2272 showSelectedDates = true;
2271 } 2273 }
2272 break; 2274 break;
2273 case Qt::Key_Space: 2275 case Qt::Key_Space:
2274 mView->toggleExpand(); 2276 mView->toggleExpand();
2275 break; 2277 break;
2276 case Qt::Key_A: 2278 case Qt::Key_A:
2277 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2279 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2278 mView->showNextAlarms(); 2280 mView->showNextAlarms();
2279 else 2281 else
2280 mView->toggleAllDaySize(); 2282 mView->toggleAllDaySize();
2281 break; 2283 break;
2282 case Qt::Key_T: 2284 case Qt::Key_T:
2283 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2285 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2284 mView->newTodo(); 2286 mView->newTodo();
2285 else { 2287 else {
2286 mView->goToday(); 2288 mView->goToday();
2287 showSelectedDates = true; 2289 showSelectedDates = true;
2288 } 2290 }
2289 break; 2291 break;
2290 case Qt::Key_Q: 2292 case Qt::Key_Q:
2291 if ( e->state() == Qt::ControlButton ) 2293 if ( e->state() == Qt::ControlButton )
2292 mView->conflictNotAll(); 2294 mView->conflictNotAll();
2293 else if ( e->state() == Qt::ShiftButton ) 2295 else if ( e->state() == Qt::ShiftButton )
2294 mView->conflictAllday(); 2296 mView->conflictAllday();
2295 else 2297 else
2296 mView->conflictAll(); 2298 mView->conflictAll();
2297 break; 2299 break;
2298 case Qt::Key_J: 2300 case Qt::Key_J:
2299 mView->viewManager()->showJournalView(); 2301 mView->viewManager()->showJournalView();
2300 break; 2302 break;
2301 case Qt::Key_B: 2303 case Qt::Key_B:
2302 mView->editIncidenceDescription();; 2304 mView->editIncidenceDescription();;
2303 break; 2305 break;
2304 // case Qt::Key_Return: 2306 // case Qt::Key_Return:
2305 case Qt::Key_E: 2307 case Qt::Key_E:
2306 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2308 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2307 mView->newEvent(); 2309 mView->newEvent();
2308 else 2310 else
2309 mView->editIncidence(); 2311 mView->editIncidence();
2310 break; 2312 break;
2311 case Qt::Key_Plus: 2313 case Qt::Key_Plus:
2312 size = p->mHourSize +2; 2314 size = p->mHourSize +2;
2313 if ( size <= 22 ) 2315 if ( size <= 22 )
2314 configureAgenda( size ); 2316 configureAgenda( size );
2315 break; 2317 break;
2316 case Qt::Key_Minus: 2318 case Qt::Key_Minus:
2317 size = p->mHourSize - 2; 2319 size = p->mHourSize - 2;
2318 if ( size >= 4 ) 2320 if ( size >= 4 )
2319 configureAgenda( size ); 2321 configureAgenda( size );
2320 break; 2322 break;
2321 2323
2322 2324
2323 default: 2325 default:
2324 e->ignore(); 2326 e->ignore();
2325 } 2327 }
2326 if ( pro > 0 ) { 2328 if ( pro > 0 ) {
2327 selectFilter( pro+1 ); 2329 selectFilter( pro+1 );
2328 } 2330 }
2329 if ( showSelectedDates ) { 2331 if ( showSelectedDates ) {
2330 ;// setCaptionToDates(); 2332 ;// setCaptionToDates();
2331 } 2333 }
2332 2334
2333} 2335}
2334void MainWindow::fillFilterMenuTB() 2336void MainWindow::fillFilterMenuTB()
2335{ 2337{
2336 selectFilterMenuTB->clear(); 2338 selectFilterMenuTB->clear();
2337 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2339 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2338 selectFilterMenuTB->insertSeparator(); 2340 selectFilterMenuTB->insertSeparator();
2339 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2341 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2340 2342
2341 selectFilterMenuTB->insertSeparator(); 2343 selectFilterMenuTB->insertSeparator();
2342 QPtrList<CalFilter> fili = mView->filters(); 2344 QPtrList<CalFilter> fili = mView->filters();
2343 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2345 CalFilter *curfilter = mView->filterView()->selectedFilter();
2344 CalFilter *filter = fili.first(); 2346 CalFilter *filter = fili.first();
2345 int iii = 2; 2347 int iii = 2;
2346 bool checkitem = mView->filterView()->filtersEnabled(); 2348 bool checkitem = mView->filterView()->filtersEnabled();
2347 while(filter) { 2349 while(filter) {
2348 selectFilterMenuTB->insertItem( filter->name(), iii ); 2350 selectFilterMenuTB->insertItem( filter->name(), iii );
2349 if ( filter == curfilter) 2351 if ( filter == curfilter)
2350 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2352 selectFilterMenuTB->setItemChecked( iii, checkitem );
2351 filter = fili.next(); 2353 filter = fili.next();
2352 ++iii; 2354 ++iii;
2353 } 2355 }
2354 if ( !checkitem ) 2356 if ( !checkitem )
2355 selectFilterMenuTB->setItemChecked( 1, true ); 2357 selectFilterMenuTB->setItemChecked( 1, true );
2356 2358
2357 int x = 0; 2359 int x = 0;
2358 int y = iconToolBar->height(); 2360 int y = iconToolBar->height();
2359 int dX = 0; 2361 int dX = 0;
2360 int dY = 0; 2362 int dY = 0;
2361 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2363 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2362 if ( iconToolBar->y() > height()/2 ) { 2364 if ( iconToolBar->y() > height()/2 ) {
2363 dY = selectFilterMenuTB->sizeHint().height()+8; 2365 dY = selectFilterMenuTB->sizeHint().height()+8;
2364 y = 0; 2366 y = 0;
2365 } 2367 }
2366 } else { 2368 } else {
2367 if ( iconToolBar->x() > width()/2 ) { // right side 2369 if ( iconToolBar->x() > width()/2 ) { // right side
2368 x=0; 2370 x=0;
2369 dX= selectFilterMenuTB->sizeHint().width()+8; 2371 dX= selectFilterMenuTB->sizeHint().width()+8;
2370 y = 0; 2372 y = 0;
2371 } else { 2373 } else {
2372 x= iconToolBar->width(); 2374 x= iconToolBar->width();
2373 y = 0; 2375 y = 0;
2374 } 2376 }
2375 } 2377 }
2376 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2378 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2377 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2379 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2378} 2380}
2379void MainWindow::fillFilterMenu() 2381void MainWindow::fillFilterMenu()
2380{ 2382{
2381 selectFilterMenu->clear(); 2383 selectFilterMenu->clear();
2382 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2384 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2383 selectFilterMenu->insertSeparator(); 2385 selectFilterMenu->insertSeparator();
2384 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2386 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2385 2387
2386 selectFilterMenu->insertSeparator(); 2388 selectFilterMenu->insertSeparator();
2387 QPtrList<CalFilter> fili = mView->filters(); 2389 QPtrList<CalFilter> fili = mView->filters();
2388 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2390 CalFilter *curfilter = mView->filterView()->selectedFilter();
2389 CalFilter *filter = fili.first(); 2391 CalFilter *filter = fili.first();
2390 int iii = 2; 2392 int iii = 2;
2391 bool checkitem = mView->filterView()->filtersEnabled(); 2393 bool checkitem = mView->filterView()->filtersEnabled();
2392 while(filter) { 2394 while(filter) {
2393 selectFilterMenu->insertItem( filter->name(), iii ); 2395 selectFilterMenu->insertItem( filter->name(), iii );
2394 if ( filter == curfilter) 2396 if ( filter == curfilter)
2395 selectFilterMenu->setItemChecked( iii, checkitem ); 2397 selectFilterMenu->setItemChecked( iii, checkitem );
2396 filter = fili.next(); 2398 filter = fili.next();
2397 ++iii; 2399 ++iii;
2398 } 2400 }
2399 if ( !checkitem ) 2401 if ( !checkitem )
2400 selectFilterMenu->setItemChecked( 1, true ); 2402 selectFilterMenu->setItemChecked( 1, true );
2401} 2403}
2402void MainWindow::fillFilterMenuPopup() 2404void MainWindow::fillFilterMenuPopup()
2403{ 2405{
2404 filterPopupMenu->clear(); 2406 filterPopupMenu->clear();
2405 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2407 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2406 2408
2407 filterPopupMenu->insertSeparator(); 2409 filterPopupMenu->insertSeparator();
2408 QPtrList<CalFilter> fili = mView->filters(); 2410 QPtrList<CalFilter> fili = mView->filters();
2409 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2411 CalFilter *curfilter = mView->filterView()->selectedFilter();
2410 CalFilter *filter = fili.first(); 2412 CalFilter *filter = fili.first();
2411 int iii = 1; 2413 int iii = 1;
2412 bool checkitem = mView->filterView()->filtersEnabled(); 2414 bool checkitem = mView->filterView()->filtersEnabled();
2413 while(filter) { 2415 while(filter) {
2414 filterPopupMenu->insertItem( filter->name(), iii ); 2416 filterPopupMenu->insertItem( filter->name(), iii );
2415 if ( filter == curfilter) 2417 if ( filter == curfilter)
2416 filterPopupMenu->setItemChecked( iii, checkitem ); 2418 filterPopupMenu->setItemChecked( iii, checkitem );
2417 filter = fili.next(); 2419 filter = fili.next();
2418 ++iii; 2420 ++iii;
2419 } 2421 }
2420 if ( !checkitem ) 2422 if ( !checkitem )
2421 filterPopupMenu->setItemChecked( 0, true ); 2423 filterPopupMenu->setItemChecked( 0, true );
2422} 2424}
2423void MainWindow::selectFilter( int fil ) 2425void MainWindow::selectFilter( int fil )
2424{ 2426{
2425 2427
2426 if ( fil == 0 ) { 2428 if ( fil == 0 ) {
2427 mView->editFilters( ); 2429 mView->editFilters( );
2428 } else if ( fil == 1 ){ 2430 } else if ( fil == 1 ){
2429 if ( mView->filterView()->filtersEnabled() ) 2431 if ( mView->filterView()->filtersEnabled() )
2430 mView->toggleFilerEnabled( ); 2432 mView->toggleFilerEnabled( );
2431 } else { 2433 } else {
2432 if ( !mView->filterView()->filtersEnabled() ) { 2434 if ( !mView->filterView()->filtersEnabled() ) {
2433 mView->filterView()->blockSignals( true ); 2435 mView->filterView()->blockSignals( true );
2434 mView->toggleFilerEnabled( ); 2436 mView->toggleFilerEnabled( );
2435 mView->filterView()->blockSignals( false ); 2437 mView->filterView()->blockSignals( false );
2436 } 2438 }
2437 mView->selectFilter( fil-2 ); 2439 mView->selectFilter( fil-2 );
2438 } 2440 }
2439} 2441}
2440void MainWindow::updateFilterToolbar() 2442void MainWindow::updateFilterToolbar()
2441{ 2443{
2442 if ( filterMenubar ) { 2444 if ( filterMenubar ) {
2443 if ( !mView->filterView()->filtersEnabled() ) { 2445 if ( !mView->filterView()->filtersEnabled() ) {
2444 filterMenubar->changeItem( 0, i18n("No Filter") ); 2446 filterMenubar->changeItem( 0, i18n("No Filter") );
2445 } else { 2447 } else {
2446 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2448 CalFilter *curfilter = mView->filterView()->selectedFilter();
2447 if ( curfilter ) { 2449 if ( curfilter ) {
2448 QString name = curfilter->name(); 2450 QString name = curfilter->name();
2449 if ( name.length() > 12 ) 2451 if ( name.length() > 12 )
2450 name = name.left(10)+"..."; 2452 name = name.left(10)+"...";
2451 filterMenubar->changeItem( 0, name ); 2453 filterMenubar->changeItem( 0, name );
2452 } 2454 }
2453 } 2455 }
2454 } 2456 }
2455} 2457}
2456void MainWindow::selectFilterPopup( int fil ) 2458void MainWindow::selectFilterPopup( int fil )
2457{ 2459{
2458 selectFilter( fil + 1 ); 2460 selectFilter( fil + 1 );
2459 2461
2460} 2462}
2461void MainWindow::configureToolBar( int item ) 2463void MainWindow::configureToolBar( int item )
2462{ 2464{
2463 2465
2464 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2466 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2465 KOPrefs *p = KOPrefs::instance(); 2467 KOPrefs *p = KOPrefs::instance();
2466 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2468 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2467 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2469 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2468 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2470 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2469 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2471 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2470 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2472 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2471 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2473 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2472 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2474 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2473 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2475 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2474 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2476 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2475 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2477 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2476 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2478 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2477 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2479 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2478 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2480 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2479 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2481 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2480 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2482 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2481 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2483 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2482 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2484 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2483 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2485 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2484 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2486 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2485 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2487 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2486 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2488 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2487 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2489 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2488 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2490 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2489 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2491 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2490 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2492 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2491 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2493 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2492 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2494 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2493 // initActions(); 2495 // initActions();
2494 setCaption ( i18n("Toolbar changes needs a restart!") ); 2496 setCaption ( i18n("Toolbar changes needs a restart!") );
2495} 2497}
2496void MainWindow::setCaption ( const QString & c ) 2498void MainWindow::setCaption ( const QString & c )
2497{ 2499{
2498 QString cap = c; 2500 QString cap = c;
2499 cap.replace( QRegExp("\n"), " " ); 2501 cap.replace( QRegExp("\n"), " " );
2500 cap = cap.stripWhiteSpace(); 2502 cap = cap.stripWhiteSpace();
2501 if ( cap.isEmpty() ) 2503 if ( cap.isEmpty() )
2502 cap = "KO/Pi"; 2504 cap = "KO/Pi";
2503 QWidget::setCaption( cap ); 2505 QWidget::setCaption( cap );
2504} 2506}
2505void MainWindow::setCaptionToDates() 2507void MainWindow::setCaptionToDates()
2506{ 2508{
2507 QString selDates; 2509 QString selDates;
2508 QDate date = mView->startDate(); 2510 QDate date = mView->startDate();
2509 if ( ! date.isValid() ) { 2511 if ( ! date.isValid() ) {
2510 setCaption(""); 2512 setCaption("");
2511 return; 2513 return;
2512 } 2514 }
2513 selDates = KGlobal::locale()->formatDate( date, true); 2515 selDates = KGlobal::locale()->formatDate( date, true);
2514 if (mView->startDate() < mView->endDate() ) 2516 if (mView->startDate() < mView->endDate() )
2515 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2517 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2516 else { 2518 else {
2517 QString addString; 2519 QString addString;
2518 if ( date == QDateTime::currentDateTime().date() ) 2520 if ( date == QDateTime::currentDateTime().date() )
2519 addString = i18n("Today"); 2521 addString = i18n("Today");
2520 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2522 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2521 addString = i18n("Tomorrow"); 2523 addString = i18n("Tomorrow");
2522 if ( !addString.isEmpty() ) 2524 if ( !addString.isEmpty() )
2523 selDates = addString+", "+selDates ; 2525 selDates = addString+", "+selDates ;
2524 } 2526 }
2525 setCaption( i18n("Dates: ") + selDates ); 2527 setCaption( i18n("Dates: ") + selDates );
2526 2528
2527} 2529}
2528void MainWindow::showConfigureAgenda( ) 2530void MainWindow::showConfigureAgenda( )
2529{ 2531{
2530 int iii; 2532 int iii;
2531 for ( iii = 1;iii<= 10 ;++iii ){ 2533 for ( iii = 1;iii<= 10 ;++iii ){
2532 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2534 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2533 } 2535 }
2534 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2536 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2535} 2537}
2536void MainWindow::configureAgenda( int item ) 2538void MainWindow::configureAgenda( int item )
2537{ 2539{
2538 if ( KOPrefs::instance()->mHourSize == item ) 2540 if ( KOPrefs::instance()->mHourSize == item )
2539 return; 2541 return;
2540 KOPrefs::instance()->mHourSize=item; 2542 KOPrefs::instance()->mHourSize=item;
2541 mView->viewManager()->agendaView()->updateConfig(); 2543 mView->viewManager()->agendaView()->updateConfig();
2542} 2544}
2543 2545
2544void MainWindow::saveCalendar() 2546void MainWindow::saveCalendar()
2545{ 2547{
2546 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2548 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2547 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2549 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2548 bupDir = KGlobalSettings::backupDataDir(); 2550 bupDir = KGlobalSettings::backupDataDir();
2549 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2551 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2550 QString bupHint; 2552 QString bupHint;
2551 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2553 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2552 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2554 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2553 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; 2555 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;
2554 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2556 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2555 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2557 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2556 save(); 2558 save();
2557#ifndef DESKTOP_VERSION 2559#ifndef DESKTOP_VERSION
2558 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); 2560 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable );
2559#endif 2561#endif
2560 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2562 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2561 backupAllFiles(); 2563 backupAllFiles();
2562#ifndef DESKTOP_VERSION 2564#ifndef DESKTOP_VERSION
2563 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); 2565 //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable );
2564#endif 2566#endif
2565} 2567}
2566void MainWindow::loadCalendar() 2568void MainWindow::loadCalendar()
2567{ 2569{
2568 2570
2569 2571
2570#if 0 2572#if 0
2571 QString fn = KOPrefs::instance()->mLastLoadFile; 2573 QString fn = KOPrefs::instance()->mLastLoadFile;
2572 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2574 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2573 2575
2574 if ( fn == "" ) 2576 if ( fn == "" )
2575 return; 2577 return;
2576 QFileInfo info; 2578 QFileInfo info;
2577 info.setFile( fn ); 2579 info.setFile( fn );
2578 QString mess; 2580 QString mess;
2579 bool loadbup = true; 2581 bool loadbup = true;
2580 if ( info. exists() ) { 2582 if ( info. exists() ) {
2581 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2583 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2582 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2584 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2583 mess, 2585 mess,
2584 i18n("Load!"), i18n("Cancel"), 0, 2586 i18n("Load!"), i18n("Cancel"), 0,
2585 0, 1 ); 2587 0, 1 );
2586 if ( result != 0 ) { 2588 if ( result != 0 ) {
2587 loadbup = false; 2589 loadbup = false;
2588 } 2590 }
2589 } else { 2591 } else {
2590 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2592 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2591 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2593 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2592 0, 1 ); 2594 0, 1 );
2593 2595
2594 return; 2596 return;
2595 } 2597 }
2596 if ( loadbup ) { 2598 if ( loadbup ) {
2597 mView->openCalendar( fn ); 2599 mView->openCalendar( fn );
2598 KOPrefs::instance()->mLastLoadFile = fn; 2600 KOPrefs::instance()->mLastLoadFile = fn;
2599 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2601 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2600 setCaption(mess); 2602 setCaption(mess);
2601 } 2603 }
2602#endif 2604#endif
2603 2605
2604} 2606}
2605void MainWindow::quickImportIcal() 2607void MainWindow::quickImportIcal()
2606{ 2608{
2607 importFile( KOPrefs::instance()->mLastImportFile, false ); 2609 importFile( KOPrefs::instance()->mLastImportFile, false );
2608} 2610}
2609void MainWindow::importFile( QString fn, bool quick ) 2611void MainWindow::importFile( QString fn, bool quick )
2610{ 2612{
2611 QFileInfo info; 2613 QFileInfo info;
2612 info.setFile( fn ); 2614 info.setFile( fn );
2613 QString mess; 2615 QString mess;
2614 if ( !info. exists() ) { 2616 if ( !info. exists() ) {
2615 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2617 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2616 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2618 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2617 mess ); 2619 mess );
2618 return; 2620 return;
2619 } 2621 }
2620 int result = 0; 2622 int result = 0;
2621 if ( !quick ) { 2623 if ( !quick ) {
2622 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 )); 2624 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 ));
2623 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2625 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2624 mess, 2626 mess,
2625 "Import", "Cancel", 0, 2627 "Import", "Cancel", 0,
2626 0, 1 ); 2628 0, 1 );
2627 } 2629 }
2628 if ( result == 0 ) { 2630 if ( result == 0 ) {
2629 if ( mView->openCalendar( fn, true )) { 2631 if ( mView->openCalendar( fn, true )) {
2630 KOPrefs::instance()->mLastImportFile = fn; 2632 KOPrefs::instance()->mLastImportFile = fn;
2631 setCaption(i18n("Imported file successfully")); 2633 setCaption(i18n("Imported file successfully"));
2632 } else { 2634 } else {
2633 setCaption(i18n("Error importing file")); 2635 setCaption(i18n("Error importing file"));
2634 } 2636 }
2635 mView->updateView(); 2637 mView->updateView();
2636 } 2638 }
2637} 2639}
2638 2640
2639void MainWindow::importIcal() 2641void MainWindow::importIcal()
2640{ 2642{
2641 2643
2642 QString fn =KOPrefs::instance()->mLastImportFile; 2644 QString fn =KOPrefs::instance()->mLastImportFile;
2643 2645
2644 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2646 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2645 if ( fn == "" ) 2647 if ( fn == "" )
2646 return; 2648 return;
2647 importFile( fn, true ); 2649 importFile( fn, true );
2648 2650
2649} 2651}
2650void MainWindow::exportCalendar( bool iCalFormat ) 2652void MainWindow::exportCalendar( bool iCalFormat )
2651{ 2653{
2652 QString fn = KOPrefs::instance()->mLastVcalFile; 2654 QString fn = KOPrefs::instance()->mLastVcalFile;
2653 if ( iCalFormat ) { 2655 if ( iCalFormat ) {
2654 fn = QDir::homeDirPath()+"/kopiexport.ics"; 2656 fn = QDir::homeDirPath()+"/kopiexport.ics";
2655 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this ); 2657 fn = KFileDialog::getSaveFileName( fn, i18n("Export iCal filename(*.ics)"), this );
2656 } 2658 }
2657 else 2659 else
2658 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2660 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2659 if ( fn == "" ) 2661 if ( fn == "" )
2660 return; 2662 return;
2661 QFileInfo info; 2663 QFileInfo info;
2662 info.setFile( fn ); 2664 info.setFile( fn );
2663 QString mes; 2665 QString mes;
2664 bool createbup = true; 2666 bool createbup = true;
2665 if ( info. exists() ) { 2667 if ( info. exists() ) {
2666 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2668 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2667 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2669 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2668 i18n("Overwrite!"), i18n("Cancel"), 0, 2670 i18n("Overwrite!"), i18n("Cancel"), 0,
2669 0, 1 ); 2671 0, 1 );
2670 if ( result != 0 ) { 2672 if ( result != 0 ) {
2671 createbup = false; 2673 createbup = false;
2672 } 2674 }
2673 } 2675 }
2674 if ( createbup ) { 2676 if ( createbup ) {
2675 bool success = false; 2677 bool success = false;
2676 if ( iCalFormat ) 2678 if ( iCalFormat )
2677 success = mView->exportICalendar( fn ); 2679 success = mView->exportICalendar( fn );
2678 else 2680 else
2679 success = mView->exportVCalendar( fn ); 2681 success = mView->exportVCalendar( fn );
2680 if ( success ) { 2682 if ( success ) {
2681 if ( fn.length() > 20 ) 2683 if ( fn.length() > 20 )
2682 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2684 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2683 else 2685 else
2684 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2686 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2685 setCaption(mes); 2687 setCaption(mes);
2686 } 2688 }
2687 } 2689 }
2688 2690
2689} 2691}
2690void MainWindow::exportICalendar() 2692void MainWindow::exportICalendar()
2691{ 2693{
2692 exportCalendar( true ); 2694 exportCalendar( true );
2693} 2695}
2694void MainWindow::exportVCalendar() 2696void MainWindow::exportVCalendar()
2695{ 2697{
2696 exportCalendar( false ); 2698 exportCalendar( false );
2697} 2699}
2698QString MainWindow::sentSyncFile() 2700QString MainWindow::sentSyncFile()
2699{ 2701{
2700#ifdef DESKTOP_VERSION 2702#ifdef DESKTOP_VERSION
2701 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) ); 2703 return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
2702#else 2704#else
2703 return QString( "/tmp/copysynccal.ics" ); 2705 return QString( "/tmp/copysynccal.ics" );
2704#endif 2706#endif
2705} 2707}
2706 2708
2707void MainWindow::syncFileRequest() 2709void MainWindow::syncFileRequest(const QString& resource)
2708{ 2710{
2709 while ( mSyncManager->blockSave() ) { 2711 while ( mSyncManager->blockSave() ) {
2710 qApp->processEvents(); 2712 qApp->processEvents();
2711 } 2713 }
2712 mSyncManager->setBlockSave(true); 2714 mSyncManager->setBlockSave(true);
2713 2715
2714 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2716 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2715 mSyncManager->slotSyncMenu( 999 ); 2717 mSyncManager->slotSyncMenu( 999 );
2716 } 2718 }
2717 2719
2718 setCaption(i18n("Saving Data to temp file ..." )); 2720 setCaption(i18n("Saving Data to temp file ..." ));
2719 mView->saveCalendar( sentSyncFile() ); 2721 mView->saveCalendarResource( sentSyncFile(), resource );
2720 setCaption(i18n("Data saved to temp file!" )); 2722 setCaption(i18n("Data saved to temp file!" ));
2721 mSyncManager->setBlockSave( false ); 2723 mSyncManager->setBlockSave( false );
2722 2724
2723} 2725}
2724void MainWindow::getFile( bool success ) 2726void MainWindow::getFile( bool success ,const QString& resource)
2725{ 2727{
2726 if ( ! success ) { 2728 if ( ! success ) {
2727 setCaption( i18n("Error receiving file. Nothing changed!") ); 2729 setCaption( i18n("Error receiving file. Nothing changed!") );
2728 return; 2730 return;
2729 } 2731 }
2730 mView->mergeFile( sentSyncFile() ); 2732 mView->mergeFileResource( sentSyncFile(), resource);
2731 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2733 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2732 mSyncManager->slotSyncMenu( 999 ); 2734 mSyncManager->slotSyncMenu( 999 );
2733 } 2735 }
2734 setCaption( i18n("Pi-Sync successful!") ); 2736 setCaption( i18n("Pi-Sync successful!") );
2735} 2737}
2736void MainWindow::printListView() 2738void MainWindow::printListView()
2737{ 2739{
2738 2740
2739 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."); 2741 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.");
2740 2742
2741 KMessageBox::information( this, message); 2743 KMessageBox::information( this, message);
2742} 2744}
2743void MainWindow::printSel( ) 2745void MainWindow::printSel( )
2744{ 2746{
2745 mView->viewManager()->agendaView()->agenda()->printSelection(); 2747 mView->viewManager()->agendaView()->agenda()->printSelection();
2746} 2748}
2747 2749
2748void MainWindow::printCal() 2750void MainWindow::printCal()
2749{ 2751{
2750 mView->print();//mCp->showDialog(); 2752 mView->print();//mCp->showDialog();
2751} 2753}
2752 2754
2753 2755
2754#include "libkdepim/kdatepicker.h" 2756#include "libkdepim/kdatepicker.h"
2755#include <kdatetbl.h> 2757#include <kdatetbl.h>
2756 2758
2757void MainWindow::weekAction() 2759void MainWindow::weekAction()
2758{ 2760{
2759 int month; 2761 int month;
2760 KPopupFrame* popup = new KPopupFrame(this); 2762 KPopupFrame* popup = new KPopupFrame(this);
2761 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2763 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2762 // ----- 2764 // -----
2763 picker->resize(picker->sizeHint()); 2765 picker->resize(picker->sizeHint());
2764 popup->setMainWidget(picker); 2766 popup->setMainWidget(picker);
2765 picker->setFocus(); 2767 picker->setFocus();
2766 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2768 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2767 int x = 0; 2769 int x = 0;
2768 int y = iconToolBar->height(); 2770 int y = iconToolBar->height();
2769 int dX = 0; 2771 int dX = 0;
2770 int dY = 0; 2772 int dY = 0;
2771 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2773 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2772 if ( iconToolBar->y() > height()/2 ) { 2774 if ( iconToolBar->y() > height()/2 ) {
2773 dY = picker->sizeHint().height()+8; 2775 dY = picker->sizeHint().height()+8;
2774 y = 0; 2776 y = 0;
2775 } 2777 }
2776 } else { 2778 } else {
2777 if ( iconToolBar->x() > width()/2 ) { // right side 2779 if ( iconToolBar->x() > width()/2 ) { // right side
2778 x=0; 2780 x=0;
2779 dX= picker->sizeHint().width()+8; 2781 dX= picker->sizeHint().width()+8;
2780 y = 0; 2782 y = 0;
2781 } else { 2783 } else {
2782 x= iconToolBar->width(); 2784 x= iconToolBar->width();
2783 y = 0; 2785 y = 0;
2784 } 2786 }
2785 } 2787 }
2786 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2788 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2787 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2789 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2788 { 2790 {
2789 month = picker->getResult(); 2791 month = picker->getResult();
2790 emit selectWeek ( month ); 2792 emit selectWeek ( month );
2791 //qDebug("weekSelected %d ", month); 2793 //qDebug("weekSelected %d ", month);
2792 } 2794 }
2793 delete popup; 2795 delete popup;
2794} 2796}
2795 2797
2796void MainWindow::hideEvent ( QHideEvent * ) 2798void MainWindow::hideEvent ( QHideEvent * )
2797{ 2799{
2798 QString message; 2800 QString message;
2799 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2801 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2800 if ( nextA.isValid() ) { 2802 if ( nextA.isValid() ) {
2801 QString sum = mCalendar->nextSummary(); 2803 QString sum = mCalendar->nextSummary();
2802 2804
2803 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)); 2805 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));
2804 setCaption( message ); 2806 setCaption( message );
2805 } 2807 }
2806} 2808}
2807 2809
2808void MainWindow::resizeEvent( QResizeEvent* e) 2810void MainWindow::resizeEvent( QResizeEvent* e)
2809{ 2811{
2810#ifndef DESKTOP_VERSION 2812#ifndef DESKTOP_VERSION
2811 if ( filterToolBar ) { 2813 if ( filterToolBar ) {
2812 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2814 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2813 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2815 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2814 filterToolBar->hide(); 2816 filterToolBar->hide();
2815 else 2817 else
2816 filterToolBar->show(); 2818 filterToolBar->show();
2817 } 2819 }
2818 } 2820 }
2819#endif 2821#endif
2820 QMainWindow::resizeEvent( e); 2822 QMainWindow::resizeEvent( e);
2821} 2823}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,191 +1,191 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#include <kpopupmenu.h> 14#include <kpopupmenu.h>
15#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
16#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
17#endif 17#endif
18class QAction; 18class QAction;
19class CalendarView; 19class CalendarView;
20class KSyncProfile; 20class KSyncProfile;
21#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
22 22
23#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26 26
27 27
28namespace KCal { 28namespace KCal {
29class CalendarLocal; 29class CalendarLocal;
30} 30}
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 MainWindow( QWidget *parent = 0, const char *name = 0 ); 38 MainWindow( QWidget *parent = 0, const char *name = 0 );
39 ~MainWindow(); 39 ~MainWindow();
40 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
41 static QString defaultFileName(); 41 static QString defaultFileName();
42 static QString syncFileName(); 42 static QString syncFileName();
43 static QString resourcePath(); 43 static QString resourcePath();
44 public slots: 44 public slots:
45 void setUsesBigPixmaps ( bool ); 45 void setUsesBigPixmaps ( bool );
46 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
47 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
48 void updateWeek(QDate); 48 void updateWeek(QDate);
49 void updateFilterToolbar(); 49 void updateFilterToolbar();
50 virtual void showMaximized (); 50 virtual void showMaximized ();
51 void configureAgenda( int ); 51 void configureAgenda( int );
52 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
53 void receiveStart( const QCString& msg, const QByteArray& data ); 53 void receiveStart( const QCString& msg, const QByteArray& data );
54 protected slots: 54 protected slots:
55 void autoSaveWarning(); 55 void autoSaveWarning();
56 void loadDataAfterStart(); 56 void loadDataAfterStart();
57 void calHint(); 57 void calHint();
58 void startMultiSync(); 58 void startMultiSync();
59 void setCaptionToDates(); 59 void setCaptionToDates();
60 void weekAction(); 60 void weekAction();
61 void about(); 61 void about();
62 void licence(); 62 void licence();
63 void faq(); 63 void faq();
64 void usertrans(); 64 void usertrans();
65 void features(); 65 void features();
66 void synchowto(); 66 void synchowto();
67 void storagehowto(); 67 void storagehowto();
68 void timetrackinghowto(); 68 void timetrackinghowto();
69 void kdesynchowto(); 69 void kdesynchowto();
70 void multisynchowto(); 70 void multisynchowto();
71 void whatsNew(); 71 void whatsNew();
72 void keyBindings(); 72 void keyBindings();
73 void aboutAutoSaving();; 73 void aboutAutoSaving();;
74 void aboutKnownBugs(); 74 void aboutKnownBugs();
75 75
76 void processIncidenceSelection( Incidence * ); 76 void processIncidenceSelection( Incidence * );
77 77
78 void importQtopia(); 78 void importQtopia();
79 void importBday(); 79 void importBday();
80 void importOL(); 80 void importOL();
81 void importIcal(); 81 void importIcal();
82 void importFile( QString, bool ); 82 void importFile( QString, bool );
83 void quickImportIcal(); 83 void quickImportIcal();
84 84
85 void slotModifiedChanged( bool ); 85 void slotModifiedChanged( bool );
86 86
87 void save(); 87 void save();
88 void backupAllFiles(); 88 void backupAllFiles();
89 void saveStopTimer(); 89 void saveStopTimer();
90 void configureToolBar( int ); 90 void configureToolBar( int );
91 void printSel(); 91 void printSel();
92 void printCal(); 92 void printCal();
93 void printListView(); 93 void printListView();
94 void saveCalendar(); 94 void saveCalendar();
95 void loadCalendar(); 95 void loadCalendar();
96 void exportVCalendar(); 96 void exportVCalendar();
97 void exportICalendar(); 97 void exportICalendar();
98 void exportCalendar( bool ); 98 void exportCalendar( bool );
99 void fillFilterMenu(); 99 void fillFilterMenu();
100 void fillFilterMenuTB(); 100 void fillFilterMenuTB();
101 void selectFilter( int ); 101 void selectFilter( int );
102 void fillFilterMenuPopup(); 102 void fillFilterMenuPopup();
103 void selectFilterPopup( int ); 103 void selectFilterPopup( int );
104 void exportToPhone( int ); 104 void exportToPhone( int );
105 void toggleBeamReceive(); 105 void toggleBeamReceive();
106 void disableBR(bool); 106 void disableBR(bool);
107 signals: 107 signals:
108 void selectWeek ( int ); 108 void selectWeek ( int );
109 private slots: 109 private slots:
110 void slotResetFocus(); 110 void slotResetFocus();
111 void slotResetFocusLoop(); 111 void slotResetFocusLoop();
112 void showConfigureAgenda(); 112 void showConfigureAgenda();
113 void getFile( bool ); 113 void getFile( bool ,const QString &);
114 void syncFileRequest(); 114 void syncFileRequest(const QString &);
115 115
116 protected: 116 protected:
117 int mFocusLoop; 117 int mFocusLoop;
118 void hideEvent ( QHideEvent * ); 118 void hideEvent ( QHideEvent * );
119 QString sentSyncFile(); 119 QString sentSyncFile();
120 void displayText( QString, QString); 120 void displayText( QString, QString);
121 void enableIncidenceActions( bool ); 121 void enableIncidenceActions( bool );
122 bool askForQuitOnSaveError(); 122 bool askForQuitOnSaveError();
123 123
124 private: 124 private:
125 bool mAutoSaveDisabled; 125 bool mAutoSaveDisabled;
126 bool checkAutosave(); 126 bool checkAutosave();
127 QCString mCStringMess; 127 QCString mCStringMess;
128 QByteArray mByteData; 128 QByteArray mByteData;
129 129
130 //void setMenuBar( QMenuBar * ); 130 //void setMenuBar( QMenuBar * );
131 bool mBRdisabled; 131 bool mBRdisabled;
132#ifndef DESKTOP_VERSION 132#ifndef DESKTOP_VERSION
133 QCopChannel* infrared; 133 QCopChannel* infrared;
134#endif 134#endif
135 QAction* brAction; 135 QAction* brAction;
136 KSyncManager* mSyncManager; 136 KSyncManager* mSyncManager;
137 bool mClosed; 137 bool mClosed;
138 void saveOnClose(); 138 void saveOnClose();
139 bool mFlagKeyPressed; 139 bool mFlagKeyPressed;
140 bool mBlockAtStartup; 140 bool mBlockAtStartup;
141 KMenuBar *menuBar1; 141 KMenuBar *menuBar1;
142 QPEToolBar *iconToolBar; 142 QPEToolBar *iconToolBar;
143 QPEToolBar *viewToolBar; 143 QPEToolBar *viewToolBar;
144 QPEToolBar *navigatorToolBar; 144 QPEToolBar *navigatorToolBar;
145 QPEToolBar *filterToolBar; 145 QPEToolBar *filterToolBar;
146 KMenuBar *filterMenubar; 146 KMenuBar *filterMenubar;
147 QPopupMenu * filterPopupMenu; 147 QPopupMenu * filterPopupMenu;
148 QPopupMenu * mCurrentItemMenu; 148 QPopupMenu * mCurrentItemMenu;
149 void initActions(); 149 void initActions();
150 void setDefaultPreferences(); 150 void setDefaultPreferences();
151 void resizeEvent( QResizeEvent* e); 151 void resizeEvent( QResizeEvent* e);
152 void keyPressEvent ( QKeyEvent * ) ; 152 void keyPressEvent ( QKeyEvent * ) ;
153 void keyReleaseEvent ( QKeyEvent * ) ; 153 void keyReleaseEvent ( QKeyEvent * ) ;
154 QPopupMenu *configureToolBarMenu; 154 QPopupMenu *configureToolBarMenu;
155 QPopupMenu *selectFilterMenu; 155 QPopupMenu *selectFilterMenu;
156 QPopupMenu *selectFilterMenuTB; 156 QPopupMenu *selectFilterMenuTB;
157 QPopupMenu *configureAgendaMenu, *syncMenu; 157 QPopupMenu *configureAgendaMenu, *syncMenu;
158 CalendarLocal *mCalendar; 158 CalendarLocal *mCalendar;
159 CalendarView *mView; 159 CalendarView *mView;
160 QAction *mNewSubTodoAction; 160 QAction *mNewSubTodoAction;
161 QAction *mWeekAction; 161 QAction *mWeekAction;
162 QFont mWeekFont; 162 QFont mWeekFont;
163 QPixmap mWeekPixmap; 163 QPixmap mWeekPixmap;
164 QColor mWeekBgColor; 164 QColor mWeekBgColor;
165 165
166 QAction *mShowAction; 166 QAction *mShowAction;
167 QAction *mEditAction; 167 QAction *mEditAction;
168 QAction *mDeleteAction; 168 QAction *mDeleteAction;
169 QAction *mCloneAction; 169 QAction *mCloneAction;
170 QAction *mMoveAction; 170 QAction *mMoveAction;
171 QAction *mBeamAction; 171 QAction *mBeamAction;
172 QAction *mCancelAction; 172 QAction *mCancelAction;
173 QAction *mPrintSelAction; 173 QAction *mPrintSelAction;
174 174
175 QAction *mToggleNav; 175 QAction *mToggleNav;
176 QAction *mToggleFilter; 176 QAction *mToggleFilter;
177 QAction *mToggleAllday; 177 QAction *mToggleAllday;
178 QAction *actionFilterMenuTB; 178 QAction *actionFilterMenuTB;
179 179
180 void closeEvent( QCloseEvent* ce ); 180 void closeEvent( QCloseEvent* ce );
181 QTimer mSaveTimer; 181 QTimer mSaveTimer;
182 QDateTime mSaveTimerStart; 182 QDateTime mSaveTimerStart;
183 int mSaveDelay; 183 int mSaveDelay;
184 //bool mBlockSaveFlag; 184 //bool mBlockSaveFlag;
185 bool mCalendarModifiedFlag; 185 bool mCalendarModifiedFlag;
186 QPixmap loadPixmap( QString ); 186 QPixmap loadPixmap( QString );
187 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; 187 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
188}; 188};
189 189
190 190
191#endif 191#endif