summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-06-04 09:25:09 (UTC)
committer zautrix <zautrix>2005-06-04 09:25:09 (UTC)
commitd40cf5135c640506011334364274b8ee5df9998b (patch) (unidiff)
tree56895a78e170856ff641dfa13f2f6eb4cc2b3488 /korganizer
parent0e0ac7a92ac2fe052b3e72d49e505a078b05e7f3 (diff)
downloadkdepimpi-d40cf5135c640506011334364274b8ee5df9998b.zip
kdepimpi-d40cf5135c640506011334364274b8ee5df9998b.tar.gz
kdepimpi-d40cf5135c640506011334364274b8ee5df9998b.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp10
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp7
3 files changed, 13 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 5132f98..42166ab 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4321 +1,4325 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 setBackgroundColor( QColor( 86, 153, 205 ) ); 145 setBackgroundColor( QColor( 86, 153, 205 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 mText += "<table>"; 166 mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->type() == "Event" ) { 173 if ( inc->type() == "Event" ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->type() == "Todo" ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->type() == "Todo" ) 179 if ( inc->type() == "Todo" )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() == QDate::currentDate() && time == 0 ) { 190 if ( dt.date() == QDate::currentDate() && time == 0 ) {
191 time = 1; 191 time = 1;
192 mText +="</table>"; 192 mText +="</table>";
193 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 195
196 } 196 }
197 if ( dt.date() > QDate::currentDate() && time != 2 ) { 197 if ( dt.date() > QDate::currentDate() && time != 2 ) {
198 time = 2; 198 time = 2;
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 } 202 }
203 mText +="<tr><td><b>"; 203 mText +="<tr><td><b>";
204 mText += timestr; 204 mText += timestr;
205 mText += "</b></td><td>"; 205 mText += "</b></td><td>";
206 mText += tempText; 206 mText += tempText;
207 mText += "</td></tr>\n"; 207 mText += "</td></tr>\n";
208 inc = getNextInc( start ); 208 inc = getNextInc( start );
209 } 209 }
210 mText +="</table>"; 210 mText +="</table>";
211 setText( mText ); 211 setText( mText );
212} 212}
213 213
214MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
215{
216 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
217}
214Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 218Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
215{ 219{
216 QDateTime dt ; 220 QDateTime dt ;
217 Incidence * retInc; 221 Incidence * retInc;
218 Incidence * inc = mAlarms.first(); 222 Incidence * inc = mAlarms.first();
219 if ( inc == 0 ) 223 if ( inc == 0 )
220 return 0; 224 return 0;
221 bool ok; 225 bool ok;
222 dt = inc->getNextOccurence( start, &ok ); 226 dt = inc->getNextOccurence( start, &ok );
223 if ( ! ok ) return 0; 227 if ( ! ok ) return 0;
224 QDateTime dtn ; 228 QDateTime dtn ;
225 retInc = inc; 229 retInc = inc;
226 inc = mAlarms.next(); 230 inc = mAlarms.next();
227 while ( inc ) { 231 while ( inc ) {
228 dtn = inc->getNextOccurence( start, &ok ); 232 dtn = inc->getNextOccurence( start, &ok );
229 if ( ! ok ) return 0; 233 if ( ! ok ) return 0;
230 if ( dtn < dt ) { 234 if ( dtn < dt ) {
231 dt = dtn; 235 dt = dtn;
232 retInc = inc; 236 retInc = inc;
233 } 237 }
234 inc = mAlarms.next(); 238 inc = mAlarms.next();
235 } 239 }
236 mAlarms.remove( retInc ); 240 mAlarms.remove( retInc );
237 return retInc; 241 return retInc;
238 242
239} 243}
240void MissedAlarmTextBrowser::setSource(const QString & n) 244void MissedAlarmTextBrowser::setSource(const QString & n)
241{ 245{
242 if (n.startsWith("event:")) { 246 if (n.startsWith("event:")) {
243#ifdef DESKTOP_VERSION 247#ifdef DESKTOP_VERSION
244 emit showIncidence(n.mid(8)); 248 emit showIncidence(n.mid(8));
245#else 249#else
246 emit showIncidence(n.mid(6)); 250 emit showIncidence(n.mid(6));
247#endif 251#endif
248 return; 252 return;
249 } else if (n.startsWith("todo:")) { 253 } else if (n.startsWith("todo:")) {
250#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
251 emit showIncidence(n.mid(7)); 255 emit showIncidence(n.mid(7));
252#else 256#else
253 emit showIncidence(n.mid(5)); 257 emit showIncidence(n.mid(5));
254#endif 258#endif
255 return; 259 return;
256 } 260 }
257} 261}
258 262
259 263
260class KOBeamPrefs : public QDialog 264class KOBeamPrefs : public QDialog
261{ 265{
262 public: 266 public:
263 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 267 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
264 QDialog( parent, name, true ) 268 QDialog( parent, name, true )
265 { 269 {
266 setCaption( i18n("Beam Options") ); 270 setCaption( i18n("Beam Options") );
267 QVBoxLayout* lay = new QVBoxLayout( this ); 271 QVBoxLayout* lay = new QVBoxLayout( this );
268 lay->setSpacing( 3 ); 272 lay->setSpacing( 3 );
269 lay->setMargin( 3 ); 273 lay->setMargin( 3 );
270 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 274 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
271 lay->addWidget( format ); 275 lay->addWidget( format );
272 format->setExclusive ( true ) ; 276 format->setExclusive ( true ) ;
273 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 277 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
274 lay->addWidget( time ); time->setExclusive ( true ) ; 278 lay->addWidget( time ); time->setExclusive ( true ) ;
275 vcal = new QRadioButton(" vCalendar ", format ); 279 vcal = new QRadioButton(" vCalendar ", format );
276 ical = new QRadioButton(" iCalendar ", format ); 280 ical = new QRadioButton(" iCalendar ", format );
277 vcal->setChecked( true ); 281 vcal->setChecked( true );
278 tz = new QRadioButton(i18n(" With timezone "), time ); 282 tz = new QRadioButton(i18n(" With timezone "), time );
279 local = new QRadioButton(i18n(" Local time "), time ); 283 local = new QRadioButton(i18n(" Local time "), time );
280 tz->setChecked( true ); 284 tz->setChecked( true );
281 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 285 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
282 lay->addWidget( ok ); 286 lay->addWidget( ok );
283 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 287 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
284 lay->addWidget( cancel ); 288 lay->addWidget( cancel );
285 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 289 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
286 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 290 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
287 resize( 200, 200 ); 291 resize( 200, 200 );
288 } 292 }
289 293
290 bool beamVcal() { return vcal->isChecked(); } 294 bool beamVcal() { return vcal->isChecked(); }
291 bool beamLocal() { return local->isChecked(); } 295 bool beamLocal() { return local->isChecked(); }
292private: 296private:
293 QRadioButton* vcal, *ical, *local, *tz; 297 QRadioButton* vcal, *ical, *local, *tz;
294}; 298};
295class KOCatPrefs : public QDialog 299class KOCatPrefs : public QDialog
296{ 300{
297 public: 301 public:
298 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 302 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
299 QDialog( parent, name, true ) 303 QDialog( parent, name, true )
300 { 304 {
301 setCaption( i18n("Manage new Categories") ); 305 setCaption( i18n("Manage new Categories") );
302 QVBoxLayout* lay = new QVBoxLayout( this ); 306 QVBoxLayout* lay = new QVBoxLayout( this );
303 lay->setSpacing( 3 ); 307 lay->setSpacing( 3 );
304 lay->setMargin( 3 ); 308 lay->setMargin( 3 );
305 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 309 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
306 lay->addWidget( lab ); 310 lay->addWidget( lab );
307 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 311 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
308 lay->addWidget( format ); 312 lay->addWidget( format );
309 format->setExclusive ( true ) ; 313 format->setExclusive ( true ) ;
310 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 314 addCatBut = new QRadioButton(i18n("Add to category list"), format );
311 new QRadioButton(i18n("Remove from Events/Todos"), format ); 315 new QRadioButton(i18n("Remove from Events/Todos"), format );
312 addCatBut->setChecked( true ); 316 addCatBut->setChecked( true );
313 QPushButton * ok = new QPushButton( i18n("OK"), this ); 317 QPushButton * ok = new QPushButton( i18n("OK"), this );
314 lay->addWidget( ok ); 318 lay->addWidget( ok );
315 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 319 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
316 lay->addWidget( cancel ); 320 lay->addWidget( cancel );
317 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 321 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
318 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 322 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
319 resize( 200, 200 ); 323 resize( 200, 200 );
320 } 324 }
321 325
322 bool addCat() { return addCatBut->isChecked(); } 326 bool addCat() { return addCatBut->isChecked(); }
323private: 327private:
324 QRadioButton* addCatBut; 328 QRadioButton* addCatBut;
325}; 329};
326 330
327 331
328 332
329CalendarView::CalendarView( CalendarResources *calendar, 333CalendarView::CalendarView( CalendarResources *calendar,
330 QWidget *parent, const char *name ) 334 QWidget *parent, const char *name )
331 : CalendarViewBase( parent, name ), 335 : CalendarViewBase( parent, name ),
332 mCalendar( calendar ), 336 mCalendar( calendar ),
333 mResourceManager( calendar->resourceManager() ) 337 mResourceManager( calendar->resourceManager() )
334{ 338{
335 339
336 mEventEditor = 0; 340 mEventEditor = 0;
337 mTodoEditor = 0; 341 mTodoEditor = 0;
338 342
339 init(); 343 init();
340} 344}
341 345
342CalendarView::CalendarView( Calendar *calendar, 346CalendarView::CalendarView( Calendar *calendar,
343 QWidget *parent, const char *name ) 347 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 348 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 349 mCalendar( calendar ),
346 mResourceManager( 0 ) 350 mResourceManager( 0 )
347{ 351{
348 352
349 mEventEditor = 0; 353 mEventEditor = 0;
350 mTodoEditor = 0; 354 mTodoEditor = 0;
351 init(); 355 init();
352} 356}
353 357
354void CalendarView::init() 358void CalendarView::init()
355{ 359{
356 mNextAlarmDateTime = QDateTime::currentDateTime(); 360 mNextAlarmDateTime = QDateTime::currentDateTime();
357 setFocusPolicy ( NoFocus ); 361 setFocusPolicy ( NoFocus );
358 mViewerCallerIsSearchDialog = false; 362 mViewerCallerIsSearchDialog = false;
359 mBlockShowDates = false; 363 mBlockShowDates = false;
360 beamDialog = new KOBeamPrefs(); 364 beamDialog = new KOBeamPrefs();
361 mDatePickerMode = 0; 365 mDatePickerMode = 0;
362 mCurrentSyncDevice = ""; 366 mCurrentSyncDevice = "";
363 writeLocale(); 367 writeLocale();
364 mViewManager = new KOViewManager( this ); 368 mViewManager = new KOViewManager( this );
365 mDialogManager = new KODialogManager( this ); 369 mDialogManager = new KODialogManager( this );
366 mEventViewerDialog = 0; 370 mEventViewerDialog = 0;
367 mModified = false; 371 mModified = false;
368 mReadOnly = false; 372 mReadOnly = false;
369 mSelectedIncidence = 0; 373 mSelectedIncidence = 0;
370 mCalPrinter = 0; 374 mCalPrinter = 0;
371 mFilters.setAutoDelete(true); 375 mFilters.setAutoDelete(true);
372 376
373 mCalendar->registerObserver( this ); 377 mCalendar->registerObserver( this );
374 // TODO: Make sure that view is updated, when calendar is changed. 378 // TODO: Make sure that view is updated, when calendar is changed.
375 379
376 mStorage = new FileStorage( mCalendar ); 380 mStorage = new FileStorage( mCalendar );
377 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 381 mNavigator = new DateNavigator( this, "datevav", mViewManager );
378 382
379 QBoxLayout *topLayout = (QBoxLayout*)layout(); 383 QBoxLayout *topLayout = (QBoxLayout*)layout();
380#ifndef KORG_NOSPLITTER 384#ifndef KORG_NOSPLITTER
381 // create the main layout frames. 385 // create the main layout frames.
382 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 386 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
383 topLayout->addWidget(mPanner); 387 topLayout->addWidget(mPanner);
384 388
385 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 389 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
386 "CalendarView::LeftFrame"); 390 "CalendarView::LeftFrame");
387 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 391 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
388 392
389 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 393 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
390 "CalendarView::DateNavigator" ); 394 "CalendarView::DateNavigator" );
391 395
392 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 396 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
393 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 397 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
394 mTodoList->setNavigator( mNavigator ); 398 mTodoList->setNavigator( mNavigator );
395 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 399 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
396 400
397#ifdef KORG_NORESOURCEVIEW 401#ifdef KORG_NORESOURCEVIEW
398 mResourceView = 0; 402 mResourceView = 0;
399#else 403#else
400 if ( mResourceManager ) { 404 if ( mResourceManager ) {
401 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 405 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
402 mResourceView->updateView(); 406 mResourceView->updateView();
403 connect( mResourceView, SIGNAL( resourcesChanged() ), 407 connect( mResourceView, SIGNAL( resourcesChanged() ),
404 SLOT( updateView() ) ); 408 SLOT( updateView() ) );
405 } else { 409 } else {
406 mResourceView = 0; 410 mResourceView = 0;
407 } 411 }
408#endif 412#endif
409 QWidget *rightBox = new QWidget( mPanner ); 413 QWidget *rightBox = new QWidget( mPanner );
410 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 414 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
411 415
412 mRightFrame = new QWidgetStack( rightBox ); 416 mRightFrame = new QWidgetStack( rightBox );
413 rightLayout->addWidget( mRightFrame, 1 ); 417 rightLayout->addWidget( mRightFrame, 1 );
414 418
415 mLeftFrame = mLeftSplitter; 419 mLeftFrame = mLeftSplitter;
416#else 420#else
417 //QWidget *mainBox = new QWidget( this ); 421 //QWidget *mainBox = new QWidget( this );
418 //QWidget *leftFrame = new QWidget( mainBox ); 422 //QWidget *leftFrame = new QWidget( mainBox );
419 //QBoxLayout * mainBoxLayout; 423 //QBoxLayout * mainBoxLayout;
420 if ( KOPrefs::instance()->mVerticalScreen ) { 424 if ( KOPrefs::instance()->mVerticalScreen ) {
421 //mainBoxLayout = new QVBoxLayout(mainBox); 425 //mainBoxLayout = new QVBoxLayout(mainBox);
422 //leftFrameLayout = new QHBoxLayout(leftFrame ); 426 //leftFrameLayout = new QHBoxLayout(leftFrame );
423 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 427 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
424 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 428 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
425 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 429 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
426 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 430 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
427 } else { 431 } else {
428 //mainBoxLayout = new QHBoxLayout(mainBox); 432 //mainBoxLayout = new QHBoxLayout(mainBox);
429 //leftFrameLayout = new QVBoxLayout(leftFrame ); 433 //leftFrameLayout = new QVBoxLayout(leftFrame );
430 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
431 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
432 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
433 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
434 } 438 }
435 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 439 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
436 //QBoxLayout * leftFrameLayout; 440 //QBoxLayout * leftFrameLayout;
437 topLayout->addWidget( mMainFrame ); 441 topLayout->addWidget( mMainFrame );
438 //mainBoxLayout->addWidget (mLeftFrame); 442 //mainBoxLayout->addWidget (mLeftFrame);
439 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 443 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
440 "CalendarView::DateNavigator" ); 444 "CalendarView::DateNavigator" );
441#if 0 445#if 0
442 // FIXME 446 // FIXME
443 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 447 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
444 "CalendarView::DateNavigator", QDate::currentDate()); 448 "CalendarView::DateNavigator", QDate::currentDate());
445#endif 449#endif
446 // mDateNavigator->blockSignals( true ); 450 // mDateNavigator->blockSignals( true );
447 //leftFrameLayout->addWidget( mDateNavigator ); 451 //leftFrameLayout->addWidget( mDateNavigator );
448 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 452 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
449 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 453 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
450 mTodoList->setNavigator( mNavigator ); 454 mTodoList->setNavigator( mNavigator );
451#if 0 455#if 0
452 if ( QApplication::desktop()->width() < 480 ) { 456 if ( QApplication::desktop()->width() < 480 ) {
453 leftFrameLayout->addWidget(mFilterView); 457 leftFrameLayout->addWidget(mFilterView);
454 leftFrameLayout->addWidget(mTodoList, 2 ); 458 leftFrameLayout->addWidget(mTodoList, 2 );
455 459
456 } else { 460 } else {
457 leftFrameLayout->addWidget(mTodoList,2 ); 461 leftFrameLayout->addWidget(mTodoList,2 );
458 leftFrameLayout->addWidget(mFilterView ); 462 leftFrameLayout->addWidget(mFilterView );
459 } 463 }
460#endif 464#endif
461 mFilterView->hide(); 465 mFilterView->hide();
462 QWidget *rightBox = new QWidget( mMainFrame ); 466 QWidget *rightBox = new QWidget( mMainFrame );
463 //mainBoxLayout->addWidget ( rightBox, 10 ); 467 //mainBoxLayout->addWidget ( rightBox, 10 );
464 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 468 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
465 mRightFrame = new QWidgetStack( rightBox ); 469 mRightFrame = new QWidgetStack( rightBox );
466 rightLayout->addWidget( mRightFrame, 10 ); 470 rightLayout->addWidget( mRightFrame, 10 );
467 471
468 //mLeftFrame = (QWidget *)leftFrame; 472 //mLeftFrame = (QWidget *)leftFrame;
469 if ( KOPrefs::instance()->mVerticalScreen ) { 473 if ( KOPrefs::instance()->mVerticalScreen ) {
470 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 474 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
471 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 475 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
472 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 476 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
473 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 477 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
474 } else { 478 } else {
475 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 479 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
476 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 480 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
477 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 481 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
478 } 482 }
479 if ( !KOPrefs::instance()->mShowDateNavigator) 483 if ( !KOPrefs::instance()->mShowDateNavigator)
480 mDateNavigator->hide(); 484 mDateNavigator->hide();
481 //qDebug("Calendarview Size %d %d ", width(), height()); 485 //qDebug("Calendarview Size %d %d ", width(), height());
482#endif 486#endif
483 487
484 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 488 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
485 SLOT( showDates( const KCal::DateList & ) ) ); 489 SLOT( showDates( const KCal::DateList & ) ) );
486 490
487 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 491 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
488 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 492 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
489 493
490 494
491 495
492 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 496 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
493 mViewManager, SLOT( showMonth( const QDate & ) ) ); 497 mViewManager, SLOT( showMonth( const QDate & ) ) );
494 498
495 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 499 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
496 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 500 mNavigator, SLOT( selectWeek( const QDate & ) ) );
497 501
498 connect( mDateNavigator, SIGNAL( goPrevYear() ), 502 connect( mDateNavigator, SIGNAL( goPrevYear() ),
499 mNavigator, SLOT( selectPreviousYear() ) ); 503 mNavigator, SLOT( selectPreviousYear() ) );
500 connect( mDateNavigator, SIGNAL( goNextYear() ), 504 connect( mDateNavigator, SIGNAL( goNextYear() ),
501 mNavigator, SLOT( selectNextYear() ) ); 505 mNavigator, SLOT( selectNextYear() ) );
502 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 506 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
503 mNavigator, SLOT( selectPreviousMonth() ) ); 507 mNavigator, SLOT( selectPreviousMonth() ) );
504 connect( mDateNavigator, SIGNAL( goNextMonth() ), 508 connect( mDateNavigator, SIGNAL( goNextMonth() ),
505 mNavigator, SLOT( selectNextMonth() ) ); 509 mNavigator, SLOT( selectNextMonth() ) );
506 510
507 connect( mDateNavigator, SIGNAL( goPrevious() ), 511 connect( mDateNavigator, SIGNAL( goPrevious() ),
508 mNavigator, SLOT( selectPrevious() ) ); 512 mNavigator, SLOT( selectPrevious() ) );
509 connect( mDateNavigator, SIGNAL( goNext() ), 513 connect( mDateNavigator, SIGNAL( goNext() ),
510 mNavigator, SLOT( selectNext() ) ); 514 mNavigator, SLOT( selectNext() ) );
511 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 515 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
512 mNavigator, SLOT( slotMonthSelect( int ) ) ); 516 mNavigator, SLOT( slotMonthSelect( int ) ) );
513 517
514 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 518 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
515 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 519 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
516#if 0 520#if 0
517 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 521 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
518 SLOT( incidenceAdded( Incidence *) ) ); 522 SLOT( incidenceAdded( Incidence *) ) );
519#endif 523#endif
520 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 524 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
521 525
522 connect( this, SIGNAL( configChanged() ), 526 connect( this, SIGNAL( configChanged() ),
523 mDateNavigator, SLOT( updateConfig() ) ); 527 mDateNavigator, SLOT( updateConfig() ) );
524 528
525 connect( mTodoList, SIGNAL( newTodoSignal() ), 529 connect( mTodoList, SIGNAL( newTodoSignal() ),
526 SLOT( newTodo() ) ); 530 SLOT( newTodo() ) );
527 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 531 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
528 SLOT( newSubTodo( Todo * ) ) ); 532 SLOT( newSubTodo( Todo * ) ) );
529 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 533 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
530 SLOT( editTodo( Todo * ) ) ); 534 SLOT( editTodo( Todo * ) ) );
531 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 535 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
532 SLOT( showTodo( Todo *) ) ); 536 SLOT( showTodo( Todo *) ) );
533 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 537 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
534 SLOT( deleteTodo( Todo *) ) ); 538 SLOT( deleteTodo( Todo *) ) );
535 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 539 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
536 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 540 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
537 SLOT( purgeCompleted() ) ); 541 SLOT( purgeCompleted() ) );
538 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 542 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
539 SIGNAL( todoModified( Todo *, int ) ) ); 543 SIGNAL( todoModified( Todo *, int ) ) );
540 544
541 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 545 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
542 this, SLOT ( cloneIncidence( Incidence * ) ) ); 546 this, SLOT ( cloneIncidence( Incidence * ) ) );
543 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 547 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
544 this, SLOT (cancelIncidence( Incidence * ) ) ); 548 this, SLOT (cancelIncidence( Incidence * ) ) );
545 549
546 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 550 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
547 this, SLOT ( moveIncidence( Incidence * ) ) ); 551 this, SLOT ( moveIncidence( Incidence * ) ) );
548 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 552 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
549 this, SLOT ( beamIncidence( Incidence * ) ) ); 553 this, SLOT ( beamIncidence( Incidence * ) ) );
550 554
551 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 555 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
552 this, SLOT ( todo_unsub( Todo * ) ) ); 556 this, SLOT ( todo_unsub( Todo * ) ) );
553 557
554 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 558 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
555 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 559 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
556 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 560 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
557 SLOT( updateTodo( Todo *, int ) ) ); 561 SLOT( updateTodo( Todo *, int ) ) );
558 connect( this, SIGNAL( todoModified( Todo *, int )), this, 562 connect( this, SIGNAL( todoModified( Todo *, int )), this,
559 SLOT( changeTodoDisplay( Todo *, int ) ) ); 563 SLOT( changeTodoDisplay( Todo *, int ) ) );
560 564
561 565
562 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 566 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
563 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 567 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
564 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 568 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
565 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 569 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
566 570
567 571
568 572
569 573
570 574
571 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 575 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
572 SLOT(checkClipboard())); 576 SLOT(checkClipboard()));
573 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 577 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
574 SLOT( processTodoListSelection( Incidence * ) ) ); 578 SLOT( processTodoListSelection( Incidence * ) ) );
575 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 579 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
576 580
577 // kdDebug() << "CalendarView::CalendarView() done" << endl; 581 // kdDebug() << "CalendarView::CalendarView() done" << endl;
578 582
579 mDateFrame = new QVBox(0,0,WType_Popup); 583 mDateFrame = new QVBox(0,0,WType_Popup);
580 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 584 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
581 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 585 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
582 mDateFrame->setLineWidth(3); 586 mDateFrame->setLineWidth(3);
583 mDateFrame->hide(); 587 mDateFrame->hide();
584 mDateFrame->setCaption( i18n( "Pick a date to display")); 588 mDateFrame->setCaption( i18n( "Pick a date to display"));
585 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 589 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
586 590
587 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 591 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
588 592
589 mEventEditor = mDialogManager->getEventEditor(); 593 mEventEditor = mDialogManager->getEventEditor();
590 mTodoEditor = mDialogManager->getTodoEditor(); 594 mTodoEditor = mDialogManager->getTodoEditor();
591 595
592 mFlagEditDescription = false; 596 mFlagEditDescription = false;
593 597
594 mSuspendTimer = new QTimer( this ); 598 mSuspendTimer = new QTimer( this );
595 mAlarmTimer = new QTimer( this ); 599 mAlarmTimer = new QTimer( this );
596 mRecheckAlarmTimer = new QTimer( this ); 600 mRecheckAlarmTimer = new QTimer( this );
597 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 601 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
598 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 602 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
599 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 603 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
600 mAlarmDialog = new AlarmDialog( this ); 604 mAlarmDialog = new AlarmDialog( this );
601 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 605 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
602 mAlarmDialog->setServerNotification( false ); 606 mAlarmDialog->setServerNotification( false );
603 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 607 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
604 608
605 609
606#ifndef DESKTOP_VERSION 610#ifndef DESKTOP_VERSION
607//US listen for arriving address resultsets 611//US listen for arriving address resultsets
608 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 612 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
609 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 613 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
610#endif 614#endif
611 mDateNavigator->setCalendar( mCalendar ); 615 mDateNavigator->setCalendar( mCalendar );
612} 616}
613 617
614 618
615CalendarView::~CalendarView() 619CalendarView::~CalendarView()
616{ 620{
617 // kdDebug() << "~CalendarView()" << endl; 621 // kdDebug() << "~CalendarView()" << endl;
618 //qDebug("CalendarView::~CalendarView() "); 622 //qDebug("CalendarView::~CalendarView() ");
619 delete mDialogManager; 623 delete mDialogManager;
620 delete mViewManager; 624 delete mViewManager;
621 delete mStorage; 625 delete mStorage;
622 delete mDateFrame ; 626 delete mDateFrame ;
623 delete beamDialog; 627 delete beamDialog;
624 delete mEventViewerDialog; 628 delete mEventViewerDialog;
625 //kdDebug() << "~CalendarView() done" << endl; 629 //kdDebug() << "~CalendarView() done" << endl;
626} 630}
627void CalendarView::checkAlarms() 631void CalendarView::checkAlarms()
628{ 632{
629 KConfig *config = KOGlobals::config(); 633 KConfig *config = KOGlobals::config();
630 config->setGroup( "AppRun" ); 634 config->setGroup( "AppRun" );
631 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 635 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
632 int secs = config->readNumEntry( "LatestProgramStop" ) - 30; 636 int secs = config->readNumEntry( "LatestProgramStop" ) - 30;
633 secs -= ( 3600 * 24*3 ); // debug only 637 secs -= ( 3600 * 24*3 ); // debug only
634 QDateTime latest = dt.addSecs ( secs ); 638 QDateTime latest = dt.addSecs ( secs );
635 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 639 qDebug("KO: Last termination on %s ", latest.toString().latin1());
636 QPtrList<Incidence> el = mCalendar->rawIncidences(); 640 QPtrList<Incidence> el = mCalendar->rawIncidences();
637 QPtrList<Incidence> al; 641 QPtrList<Incidence> al;
638 Incidence* inL = el.first(); 642 Incidence* inL = el.first();
639 while ( inL ) { 643 while ( inL ) {
640 bool ok = false; 644 bool ok = false;
641 int offset = 0; 645 int offset = 0;
642 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 646 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
643 if ( ok ) { 647 if ( ok ) {
644 //qDebug("OK %s",next.toString().latin1()); 648 //qDebug("OK %s",next.toString().latin1());
645 if ( next < QDateTime::currentDateTime() ) { 649 if ( next < QDateTime::currentDateTime() ) {
646 al.append( inL ); 650 al.append( inL );
647 qDebug("found missed alarm: %s ", inL->summary().latin1() ); 651 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
648 } 652 }
649 } 653 }
650 inL = el.next(); 654 inL = el.next();
651 } 655 }
652 if ( al.count() ) { 656 if ( al.count() ) {
653 QDialog* dia = new QDialog( this, "huhu", false ); 657 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
654 dia->setCaption( i18n("KO/Pi: Missing alarm notification!") ); 658 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
655 QVBoxLayout* lay = new QVBoxLayout( dia ); 659 QVBoxLayout* lay = new QVBoxLayout( dia );
656 lay->setSpacing( 0 ); 660 lay->setSpacing( 0 );
657 lay->setMargin( 0 ); 661 lay->setMargin( 0 );
658 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 662 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
659 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 663 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
660 lay->addWidget( matb ); 664 lay->addWidget( matb );
661 int si = 220; 665 int si = 220;
662 if ( QApplication::desktop()->width() > 470 ) 666 if ( QApplication::desktop()->width() > 470 )
663 si = 400; 667 si = 400;
664 dia->resize(si,si/2); 668 dia->resize(si,si/2);
665 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 669 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
666 dia->show(); 670 dia->show();
667 671
668 } 672 }
669} 673}
670void CalendarView::showDay( QDate d ) 674void CalendarView::showDay( QDate d )
671{ 675{
672 dateNavigator()->blockSignals( true ); 676 dateNavigator()->blockSignals( true );
673 dateNavigator()->selectDate( d ); 677 dateNavigator()->selectDate( d );
674 dateNavigator()->blockSignals( false ); 678 dateNavigator()->blockSignals( false );
675 mViewManager->showDayView(); 679 mViewManager->showDayView();
676 //dateNavigator()->selectDate( d ); 680 //dateNavigator()->selectDate( d );
677} 681}
678void CalendarView::timerAlarm() 682void CalendarView::timerAlarm()
679{ 683{
680 //qDebug("CalendarView::timerAlarm() "); 684 //qDebug("CalendarView::timerAlarm() ");
681 computeAlarm(mAlarmNotification ); 685 computeAlarm(mAlarmNotification );
682} 686}
683 687
684void CalendarView::suspendAlarm() 688void CalendarView::suspendAlarm()
685{ 689{
686 //qDebug(" CalendarView::suspendAlarm() "); 690 //qDebug(" CalendarView::suspendAlarm() ");
687 computeAlarm(mSuspendAlarmNotification ); 691 computeAlarm(mSuspendAlarmNotification );
688 692
689} 693}
690 694
691void CalendarView::startAlarm( QString mess , QString filename) 695void CalendarView::startAlarm( QString mess , QString filename)
692{ 696{
693 697
694 topLevelWidget()->showNormal(); 698 topLevelWidget()->showNormal();
695 topLevelWidget()->setActiveWindow(); 699 topLevelWidget()->setActiveWindow();
696 topLevelWidget()->raise(); 700 topLevelWidget()->raise();
697 701
698 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 702 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
699 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 703 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
700 704
701} 705}
702 706
703void CalendarView::checkNextTimerAlarm() 707void CalendarView::checkNextTimerAlarm()
704{ 708{
705 mCalendar->checkAlarmForIncidence( 0, true ); 709 mCalendar->checkAlarmForIncidence( 0, true );
706} 710}
707 711
708void CalendarView::computeAlarm( QString msg ) 712void CalendarView::computeAlarm( QString msg )
709{ 713{
710 714
711 QString mess = msg; 715 QString mess = msg;
712 QString mAlarmMessage = mess.mid( 9 ); 716 QString mAlarmMessage = mess.mid( 9 );
713 QString filename = MainWindow::resourcePath(); 717 QString filename = MainWindow::resourcePath();
714 filename += "koalarm.wav"; 718 filename += "koalarm.wav";
715 QString tempfilename; 719 QString tempfilename;
716 if ( mess.left( 13 ) == "suspend_alarm") { 720 if ( mess.left( 13 ) == "suspend_alarm") {
717 bool error = false; 721 bool error = false;
718 int len = mess.mid( 13 ).find("+++"); 722 int len = mess.mid( 13 ).find("+++");
719 if ( len < 2 ) 723 if ( len < 2 )
720 error = true; 724 error = true;
721 else { 725 else {
722 tempfilename = mess.mid( 13, len ); 726 tempfilename = mess.mid( 13, len );
723 if ( !QFile::exists( tempfilename ) ) 727 if ( !QFile::exists( tempfilename ) )
724 error = true; 728 error = true;
725 } 729 }
726 if ( ! error ) { 730 if ( ! error ) {
727 filename = tempfilename; 731 filename = tempfilename;
728 } 732 }
729 mAlarmMessage = mess.mid( 13+len+3 ); 733 mAlarmMessage = mess.mid( 13+len+3 );
730 //qDebug("suspend file %s ",tempfilename.latin1() ); 734 //qDebug("suspend file %s ",tempfilename.latin1() );
731 startAlarm( mAlarmMessage, filename); 735 startAlarm( mAlarmMessage, filename);
732 return; 736 return;
733 } 737 }
734 if ( mess.left( 11 ) == "timer_alarm") { 738 if ( mess.left( 11 ) == "timer_alarm") {
735 //mTimerTime = 0; 739 //mTimerTime = 0;
736 startAlarm( mess.mid( 11 ), filename ); 740 startAlarm( mess.mid( 11 ), filename );
737 return; 741 return;
738 } 742 }
739 if ( mess.left( 10 ) == "proc_alarm") { 743 if ( mess.left( 10 ) == "proc_alarm") {
740 bool error = false; 744 bool error = false;
741 int len = mess.mid( 10 ).find("+++"); 745 int len = mess.mid( 10 ).find("+++");
742 if ( len < 2 ) 746 if ( len < 2 )
743 error = true; 747 error = true;
744 else { 748 else {
745 tempfilename = mess.mid( 10, len ); 749 tempfilename = mess.mid( 10, len );
746 if ( !QFile::exists( tempfilename ) ) 750 if ( !QFile::exists( tempfilename ) )
747 error = true; 751 error = true;
748 } 752 }
749 if ( error ) { 753 if ( error ) {
750 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 754 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
751 mAlarmMessage += mess.mid( 10+len+3+9 ); 755 mAlarmMessage += mess.mid( 10+len+3+9 );
752 } else { 756 } else {
753 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 757 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
754 //qDebug("-----system command %s ",tempfilename.latin1() ); 758 //qDebug("-----system command %s ",tempfilename.latin1() );
755#ifndef _WIN32_ 759#ifndef _WIN32_
756 if ( vfork () == 0 ) { 760 if ( vfork () == 0 ) {
757 execl ( tempfilename.latin1(), 0 ); 761 execl ( tempfilename.latin1(), 0 );
758 return; 762 return;
759 } 763 }
760#else 764#else
761 QProcess* p = new QProcess(); 765 QProcess* p = new QProcess();
762 p->addArgument( tempfilename.latin1() ); 766 p->addArgument( tempfilename.latin1() );
763 p->start(); 767 p->start();
764 return; 768 return;
765#endif 769#endif
766 770
767 return; 771 return;
768 } 772 }
769 773
770 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 774 //qDebug("+++++++system command %s ",tempfilename.latin1() );
771 } 775 }
772 if ( mess.left( 11 ) == "audio_alarm") { 776 if ( mess.left( 11 ) == "audio_alarm") {
773 bool error = false; 777 bool error = false;
774 int len = mess.mid( 11 ).find("+++"); 778 int len = mess.mid( 11 ).find("+++");
775 if ( len < 2 ) 779 if ( len < 2 )
776 error = true; 780 error = true;
777 else { 781 else {
778 tempfilename = mess.mid( 11, len ); 782 tempfilename = mess.mid( 11, len );
779 if ( !QFile::exists( tempfilename ) ) 783 if ( !QFile::exists( tempfilename ) )
780 error = true; 784 error = true;
781 } 785 }
782 if ( ! error ) { 786 if ( ! error ) {
783 filename = tempfilename; 787 filename = tempfilename;
784 } 788 }
785 mAlarmMessage = mess.mid( 11+len+3+9 ); 789 mAlarmMessage = mess.mid( 11+len+3+9 );
786 //qDebug("audio file command %s ",tempfilename.latin1() ); 790 //qDebug("audio file command %s ",tempfilename.latin1() );
787 } 791 }
788 if ( mess.left( 9 ) == "cal_alarm") { 792 if ( mess.left( 9 ) == "cal_alarm") {
789 mAlarmMessage = mess.mid( 9 ) ; 793 mAlarmMessage = mess.mid( 9 ) ;
790 } 794 }
791 795
792 startAlarm( mAlarmMessage, filename ); 796 startAlarm( mAlarmMessage, filename );
793 797
794 798
795} 799}
796 800
797void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 801void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
798{ 802{
799 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 803 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
800 804
801 mSuspendAlarmNotification = noti; 805 mSuspendAlarmNotification = noti;
802 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 806 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
803 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 807 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
804 mSuspendTimer->start( ms , true ); 808 mSuspendTimer->start( ms , true );
805 809
806} 810}
807 811
808void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 812void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
809{ 813{
810 mNextAlarmDateTime = qdt; 814 mNextAlarmDateTime = qdt;
811 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 815 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
812 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 816 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
813#ifndef DESKTOP_VERSION 817#ifndef DESKTOP_VERSION
814 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 818 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
815#endif 819#endif
816 return; 820 return;
817 } 821 }
818 int maxSec; 822 int maxSec;
819 //maxSec = 5; //testing only 823 //maxSec = 5; //testing only
820 maxSec = 86400+3600; // one day+1hour 824 maxSec = 86400+3600; // one day+1hour
821 mAlarmNotification = noti; 825 mAlarmNotification = noti;
822 int sec = QDateTime::currentDateTime().secsTo( qdt ); 826 int sec = QDateTime::currentDateTime().secsTo( qdt );
823 if ( sec > maxSec ) { 827 if ( sec > maxSec ) {
824 mRecheckAlarmTimer->start( maxSec * 1000 ); 828 mRecheckAlarmTimer->start( maxSec * 1000 );
825 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 829 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
826 return; 830 return;
827 } else { 831 } else {
828 mRecheckAlarmTimer->stop(); 832 mRecheckAlarmTimer->stop();
829 } 833 }
830 //qDebug("Alarm timer started with secs: %d ", sec); 834 //qDebug("Alarm timer started with secs: %d ", sec);
831 mAlarmTimer->start( sec *1000 , true ); 835 mAlarmTimer->start( sec *1000 , true );
832 836
833} 837}
834// called by mRecheckAlarmTimer to get next alarm 838// called by mRecheckAlarmTimer to get next alarm
835// we need this, because a QTimer has only a max range of 25 days 839// we need this, because a QTimer has only a max range of 25 days
836void CalendarView::recheckTimerAlarm() 840void CalendarView::recheckTimerAlarm()
837{ 841{
838 mAlarmTimer->stop(); 842 mAlarmTimer->stop();
839 mRecheckAlarmTimer->stop(); 843 mRecheckAlarmTimer->stop();
840 mCalendar->checkAlarmForIncidence( 0, true ); 844 mCalendar->checkAlarmForIncidence( 0, true );
841} 845}
842void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 846void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
843{ 847{
844 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 848 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
845 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 849 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
846#ifndef DESKTOP_VERSION 850#ifndef DESKTOP_VERSION
847 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 851 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
848#endif 852#endif
849 return; 853 return;
850 } 854 }
851 mAlarmTimer->stop(); 855 mAlarmTimer->stop();
852} 856}
853void CalendarView::selectWeekNum ( int num ) 857void CalendarView::selectWeekNum ( int num )
854{ 858{
855 dateNavigator()->blockSignals( true ); 859 dateNavigator()->blockSignals( true );
856 dateNavigator()->selectWeek( num ); 860 dateNavigator()->selectWeek( num );
857 dateNavigator()->blockSignals( false ); 861 dateNavigator()->blockSignals( false );
858 mViewManager->showWeekView(); 862 mViewManager->showWeekView();
859} 863}
860KOViewManager *CalendarView::viewManager() 864KOViewManager *CalendarView::viewManager()
861{ 865{
862 return mViewManager; 866 return mViewManager;
863} 867}
864 868
865KODialogManager *CalendarView::dialogManager() 869KODialogManager *CalendarView::dialogManager()
866{ 870{
867 return mDialogManager; 871 return mDialogManager;
868} 872}
869 873
870QDate CalendarView::startDate() 874QDate CalendarView::startDate()
871{ 875{
872 DateList dates = mNavigator->selectedDates(); 876 DateList dates = mNavigator->selectedDates();
873 877
874 return dates.first(); 878 return dates.first();
875} 879}
876 880
877QDate CalendarView::endDate() 881QDate CalendarView::endDate()
878{ 882{
879 DateList dates = mNavigator->selectedDates(); 883 DateList dates = mNavigator->selectedDates();
880 884
881 return dates.last(); 885 return dates.last();
882} 886}
883 887
884 888
885void CalendarView::createPrinter() 889void CalendarView::createPrinter()
886{ 890{
887#ifndef KORG_NOPRINTER 891#ifndef KORG_NOPRINTER
888 if (!mCalPrinter) { 892 if (!mCalPrinter) {
889 mCalPrinter = new CalPrinter(this, mCalendar); 893 mCalPrinter = new CalPrinter(this, mCalendar);
890 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 894 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
891 } 895 }
892#endif 896#endif
893} 897}
894 898
895 899
896//KOPrefs::instance()->mWriteBackFile 900//KOPrefs::instance()->mWriteBackFile
897//KOPrefs::instance()->mWriteBackExistingOnly 901//KOPrefs::instance()->mWriteBackExistingOnly
898 902
899// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 903// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
900// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 904// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
901// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 905// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
902// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 906// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
903// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 907// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
904// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 908// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
905 909
906int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 910int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
907{ 911{
908 912
909 // 0 equal 913 // 0 equal
910 // 1 take local 914 // 1 take local
911 // 2 take remote 915 // 2 take remote
912 // 3 cancel 916 // 3 cancel
913 QDateTime lastSync = mLastCalendarSync; 917 QDateTime lastSync = mLastCalendarSync;
914 QDateTime localMod = local->lastModified(); 918 QDateTime localMod = local->lastModified();
915 QDateTime remoteMod = remote->lastModified(); 919 QDateTime remoteMod = remote->lastModified();
916 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 920 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
917 bool remCh, locCh; 921 bool remCh, locCh;
918 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 922 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
919 //if ( remCh ) 923 //if ( remCh )
920 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 924 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
921 locCh = ( localMod > mLastCalendarSync ); 925 locCh = ( localMod > mLastCalendarSync );
922 if ( !remCh && ! locCh ) { 926 if ( !remCh && ! locCh ) {
923 //qDebug("both not changed "); 927 //qDebug("both not changed ");
924 lastSync = localMod.addDays(1); 928 lastSync = localMod.addDays(1);
925 if ( mode <= SYNC_PREF_ASK ) 929 if ( mode <= SYNC_PREF_ASK )
926 return 0; 930 return 0;
927 } else { 931 } else {
928 if ( locCh ) { 932 if ( locCh ) {
929 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 933 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
930 lastSync = localMod.addDays( -1 ); 934 lastSync = localMod.addDays( -1 );
931 if ( !remCh ) 935 if ( !remCh )
932 remoteMod = ( lastSync.addDays( -1 ) ); 936 remoteMod = ( lastSync.addDays( -1 ) );
933 } else { 937 } else {
934 //qDebug(" not loc changed "); 938 //qDebug(" not loc changed ");
935 lastSync = localMod.addDays( 1 ); 939 lastSync = localMod.addDays( 1 );
936 if ( remCh ) 940 if ( remCh )
937 remoteMod =( lastSync.addDays( 1 ) ); 941 remoteMod =( lastSync.addDays( 1 ) );
938 942
939 } 943 }
940 } 944 }
941 full = true; 945 full = true;
942 if ( mode < SYNC_PREF_ASK ) 946 if ( mode < SYNC_PREF_ASK )
943 mode = SYNC_PREF_ASK; 947 mode = SYNC_PREF_ASK;
944 } else { 948 } else {
945 if ( localMod == remoteMod ) 949 if ( localMod == remoteMod )
946 // if ( local->revision() == remote->revision() ) 950 // if ( local->revision() == remote->revision() )
947 return 0; 951 return 0;
948 952
949 } 953 }
950 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 954 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
951 955
952 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 956 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
953 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 957 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
954 //full = true; //debug only 958 //full = true; //debug only
955 if ( full ) { 959 if ( full ) {
956 bool equ = false; 960 bool equ = false;
957 if ( local->type() == "Event" ) { 961 if ( local->type() == "Event" ) {
958 equ = (*((Event*) local) == *((Event*) remote)); 962 equ = (*((Event*) local) == *((Event*) remote));
959 } 963 }
960 else if ( local->type() =="Todo" ) 964 else if ( local->type() =="Todo" )
961 equ = (*((Todo*) local) == (*(Todo*) remote)); 965 equ = (*((Todo*) local) == (*(Todo*) remote));
962 else if ( local->type() =="Journal" ) 966 else if ( local->type() =="Journal" )
963 equ = (*((Journal*) local) == *((Journal*) remote)); 967 equ = (*((Journal*) local) == *((Journal*) remote));
964 if ( equ ) { 968 if ( equ ) {
965 //qDebug("equal "); 969 //qDebug("equal ");
966 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 970 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
967 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 971 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
968 } 972 }
969 if ( mode < SYNC_PREF_FORCE_LOCAL ) 973 if ( mode < SYNC_PREF_FORCE_LOCAL )
970 return 0; 974 return 0;
971 975
972 }//else //debug only 976 }//else //debug only
973 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 977 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
974 } 978 }
975 int result; 979 int result;
976 bool localIsNew; 980 bool localIsNew;
977 //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() ); 981 //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() );
978 982
979 983
980 // ************************************************ 984 // ************************************************
981 // ************************************************ 985 // ************************************************
982 // ************************************************ 986 // ************************************************
983 // We may have that lastSync > remoteMod AND lastSync > localMod 987 // We may have that lastSync > remoteMod AND lastSync > localMod
984 // BUT remoteMod != localMod 988 // BUT remoteMod != localMod
985 989
986 990
987 if ( full && mode < SYNC_PREF_NEWEST ) 991 if ( full && mode < SYNC_PREF_NEWEST )
988 mode = SYNC_PREF_ASK; 992 mode = SYNC_PREF_ASK;
989 993
990 switch( mode ) { 994 switch( mode ) {
991 case SYNC_PREF_LOCAL: 995 case SYNC_PREF_LOCAL:
992 if ( lastSync > remoteMod ) 996 if ( lastSync > remoteMod )
993 return 1; 997 return 1;
994 if ( lastSync > localMod ) 998 if ( lastSync > localMod )
995 return 2; 999 return 2;
996 return 1; 1000 return 1;
997 break; 1001 break;
998 case SYNC_PREF_REMOTE: 1002 case SYNC_PREF_REMOTE:
999 if ( lastSync > localMod ) 1003 if ( lastSync > localMod )
1000 return 2; 1004 return 2;
1001 if ( lastSync > remoteMod ) 1005 if ( lastSync > remoteMod )
1002 return 1; 1006 return 1;
1003 return 2; 1007 return 2;
1004 break; 1008 break;
1005 case SYNC_PREF_NEWEST: 1009 case SYNC_PREF_NEWEST:
1006 if ( localMod >= remoteMod ) 1010 if ( localMod >= remoteMod )
1007 return 1; 1011 return 1;
1008 else 1012 else
1009 return 2; 1013 return 2;
1010 break; 1014 break;
1011 case SYNC_PREF_ASK: 1015 case SYNC_PREF_ASK:
1012 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1016 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1013 if ( lastSync > remoteMod && lastSync > localMod) 1017 if ( lastSync > remoteMod && lastSync > localMod)
1014 return 0; 1018 return 0;
1015 if ( lastSync > remoteMod ) 1019 if ( lastSync > remoteMod )
1016 return 1; 1020 return 1;
1017 if ( lastSync > localMod ) 1021 if ( lastSync > localMod )
1018 return 2; 1022 return 2;
1019 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1023 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1020 localIsNew = localMod >= remoteMod; 1024 localIsNew = localMod >= remoteMod;
1021 if ( localIsNew ) 1025 if ( localIsNew )
1022 getEventViewerDialog()->setColorMode( 1 ); 1026 getEventViewerDialog()->setColorMode( 1 );
1023 else 1027 else
1024 getEventViewerDialog()->setColorMode( 2 ); 1028 getEventViewerDialog()->setColorMode( 2 );
1025 getEventViewerDialog()->setIncidence(local); 1029 getEventViewerDialog()->setIncidence(local);
1026 if ( localIsNew ) 1030 if ( localIsNew )
1027 getEventViewerDialog()->setColorMode( 2 ); 1031 getEventViewerDialog()->setColorMode( 2 );
1028 else 1032 else
1029 getEventViewerDialog()->setColorMode( 1 ); 1033 getEventViewerDialog()->setColorMode( 1 );
1030 getEventViewerDialog()->addIncidence(remote); 1034 getEventViewerDialog()->addIncidence(remote);
1031 getEventViewerDialog()->setColorMode( 0 ); 1035 getEventViewerDialog()->setColorMode( 0 );
1032 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1036 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1033 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1037 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1034 getEventViewerDialog()->showMe(); 1038 getEventViewerDialog()->showMe();
1035 result = getEventViewerDialog()->executeS( localIsNew ); 1039 result = getEventViewerDialog()->executeS( localIsNew );
1036 return result; 1040 return result;
1037 1041
1038 break; 1042 break;
1039 case SYNC_PREF_FORCE_LOCAL: 1043 case SYNC_PREF_FORCE_LOCAL:
1040 return 1; 1044 return 1;
1041 break; 1045 break;
1042 case SYNC_PREF_FORCE_REMOTE: 1046 case SYNC_PREF_FORCE_REMOTE:
1043 return 2; 1047 return 2;
1044 break; 1048 break;
1045 1049
1046 default: 1050 default:
1047 // SYNC_PREF_TAKE_BOTH not implemented 1051 // SYNC_PREF_TAKE_BOTH not implemented
1048 break; 1052 break;
1049 } 1053 }
1050 return 0; 1054 return 0;
1051} 1055}
1052Event* CalendarView::getLastSyncEvent() 1056Event* CalendarView::getLastSyncEvent()
1053{ 1057{
1054 Event* lse; 1058 Event* lse;
1055 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1059 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1056 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1060 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1057 if (!lse) { 1061 if (!lse) {
1058 lse = new Event(); 1062 lse = new Event();
1059 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1063 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1060 QString sum = ""; 1064 QString sum = "";
1061 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1065 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1062 sum = "E: "; 1066 sum = "E: ";
1063 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1067 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1064 lse->setDtStart( mLastCalendarSync ); 1068 lse->setDtStart( mLastCalendarSync );
1065 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1069 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1066 lse->setCategories( i18n("SyncEvent") ); 1070 lse->setCategories( i18n("SyncEvent") );
1067 lse->setReadOnly( true ); 1071 lse->setReadOnly( true );
1068 mCalendar->addEvent( lse ); 1072 mCalendar->addEvent( lse );
1069 } 1073 }
1070 1074
1071 return lse; 1075 return lse;
1072 1076
1073} 1077}
1074 1078
1075// we check, if the to delete event has a id for a profile 1079// we check, if the to delete event has a id for a profile
1076// if yes, we set this id in the profile to delete 1080// if yes, we set this id in the profile to delete
1077void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1081void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1078{ 1082{
1079 if ( lastSync.count() == 0 ) { 1083 if ( lastSync.count() == 0 ) {
1080 //qDebug(" lastSync.count() == 0"); 1084 //qDebug(" lastSync.count() == 0");
1081 return; 1085 return;
1082 } 1086 }
1083 if ( toDelete->type() == "Journal" ) 1087 if ( toDelete->type() == "Journal" )
1084 return; 1088 return;
1085 1089
1086 Event* eve = lastSync.first(); 1090 Event* eve = lastSync.first();
1087 1091
1088 while ( eve ) { 1092 while ( eve ) {
1089 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1093 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1090 if ( !id.isEmpty() ) { 1094 if ( !id.isEmpty() ) {
1091 QString des = eve->description(); 1095 QString des = eve->description();
1092 QString pref = "e"; 1096 QString pref = "e";
1093 if ( toDelete->type() == "Todo" ) 1097 if ( toDelete->type() == "Todo" )
1094 pref = "t"; 1098 pref = "t";
1095 des += pref+ id + ","; 1099 des += pref+ id + ",";
1096 eve->setReadOnly( false ); 1100 eve->setReadOnly( false );
1097 eve->setDescription( des ); 1101 eve->setDescription( des );
1098 //qDebug("setdes %s ", des.latin1()); 1102 //qDebug("setdes %s ", des.latin1());
1099 eve->setReadOnly( true ); 1103 eve->setReadOnly( true );
1100 } 1104 }
1101 eve = lastSync.next(); 1105 eve = lastSync.next();
1102 } 1106 }
1103 1107
1104} 1108}
1105void CalendarView::checkExternalId( Incidence * inc ) 1109void CalendarView::checkExternalId( Incidence * inc )
1106{ 1110{
1107 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1111 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1108 checkExternSyncEvent( lastSync, inc ); 1112 checkExternSyncEvent( lastSync, inc );
1109 1113
1110} 1114}
1111bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1115bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1112{ 1116{
1113 bool syncOK = true; 1117 bool syncOK = true;
1114 int addedEvent = 0; 1118 int addedEvent = 0;
1115 int addedEventR = 0; 1119 int addedEventR = 0;
1116 int deletedEventR = 0; 1120 int deletedEventR = 0;
1117 int deletedEventL = 0; 1121 int deletedEventL = 0;
1118 int changedLocal = 0; 1122 int changedLocal = 0;
1119 int changedRemote = 0; 1123 int changedRemote = 0;
1120 int filteredIN = 0; 1124 int filteredIN = 0;
1121 int filteredOUT = 0; 1125 int filteredOUT = 0;
1122 //QPtrList<Event> el = local->rawEvents(); 1126 //QPtrList<Event> el = local->rawEvents();
1123 Event* eventR; 1127 Event* eventR;
1124 QString uid; 1128 QString uid;
1125 int take; 1129 int take;
1126 Event* eventL; 1130 Event* eventL;
1127 Event* eventRSync; 1131 Event* eventRSync;
1128 Event* eventLSync; 1132 Event* eventLSync;
1129 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1133 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1130 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1134 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1131 bool fullDateRange = false; 1135 bool fullDateRange = false;
1132 local->resetTempSyncStat(); 1136 local->resetTempSyncStat();
1133 mLastCalendarSync = QDateTime::currentDateTime(); 1137 mLastCalendarSync = QDateTime::currentDateTime();
1134 if ( mSyncManager->syncWithDesktop() ) { 1138 if ( mSyncManager->syncWithDesktop() ) {
1135 remote->resetPilotStat(1); 1139 remote->resetPilotStat(1);
1136 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1140 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1137 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1141 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1138 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1142 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1139 } else { 1143 } else {
1140 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1144 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1141 } 1145 }
1142 } 1146 }
1143 QDateTime modifiedCalendar = mLastCalendarSync; 1147 QDateTime modifiedCalendar = mLastCalendarSync;
1144 eventLSync = getLastSyncEvent(); 1148 eventLSync = getLastSyncEvent();
1145 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1149 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1146 if ( eventR ) { 1150 if ( eventR ) {
1147 eventRSync = (Event*) eventR->clone(); 1151 eventRSync = (Event*) eventR->clone();
1148 remote->deleteEvent(eventR ); 1152 remote->deleteEvent(eventR );
1149 1153
1150 } else { 1154 } else {
1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1155 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1152 eventRSync = (Event*)eventLSync->clone(); 1156 eventRSync = (Event*)eventLSync->clone();
1153 } else { 1157 } else {
1154 fullDateRange = true; 1158 fullDateRange = true;
1155 eventRSync = new Event(); 1159 eventRSync = new Event();
1156 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1160 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1157 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1161 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1158 eventRSync->setDtStart( mLastCalendarSync ); 1162 eventRSync->setDtStart( mLastCalendarSync );
1159 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1163 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1160 eventRSync->setCategories( i18n("SyncEvent") ); 1164 eventRSync->setCategories( i18n("SyncEvent") );
1161 } 1165 }
1162 } 1166 }
1163 if ( eventLSync->dtStart() == mLastCalendarSync ) 1167 if ( eventLSync->dtStart() == mLastCalendarSync )
1164 fullDateRange = true; 1168 fullDateRange = true;
1165 1169
1166 if ( ! fullDateRange ) { 1170 if ( ! fullDateRange ) {
1167 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1171 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1168 1172
1169 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1173 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1170 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1174 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1171 fullDateRange = true; 1175 fullDateRange = true;
1172 } 1176 }
1173 } 1177 }
1174 if ( mSyncManager->syncWithDesktop() ) { 1178 if ( mSyncManager->syncWithDesktop() ) {
1175 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1179 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1176 } 1180 }
1177 if ( fullDateRange ) 1181 if ( fullDateRange )
1178 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1182 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1179 else 1183 else
1180 mLastCalendarSync = eventLSync->dtStart(); 1184 mLastCalendarSync = eventLSync->dtStart();
1181 // for resyncing if own file has changed 1185 // for resyncing if own file has changed
1182 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1186 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1183 mLastCalendarSync = loadedFileVersion; 1187 mLastCalendarSync = loadedFileVersion;
1184 //qDebug("setting mLastCalendarSync "); 1188 //qDebug("setting mLastCalendarSync ");
1185 } 1189 }
1186 //qDebug("*************************** "); 1190 //qDebug("*************************** ");
1187 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1191 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1188 QPtrList<Incidence> er = remote->rawIncidences(); 1192 QPtrList<Incidence> er = remote->rawIncidences();
1189 Incidence* inR = er.first(); 1193 Incidence* inR = er.first();
1190 Incidence* inL; 1194 Incidence* inL;
1191 QProgressBar bar( er.count(),0 ); 1195 QProgressBar bar( er.count(),0 );
1192 bar.setCaption (i18n("Syncing - close to abort!") ); 1196 bar.setCaption (i18n("Syncing - close to abort!") );
1193 1197
1194 // ************** setting up filter ************* 1198 // ************** setting up filter *************
1195 CalFilter *filterIN = 0; 1199 CalFilter *filterIN = 0;
1196 CalFilter *filterOUT = 0; 1200 CalFilter *filterOUT = 0;
1197 CalFilter *filter = mFilters.first(); 1201 CalFilter *filter = mFilters.first();
1198 while(filter) { 1202 while(filter) {
1199 if ( filter->name() == mSyncManager->mFilterInCal ) 1203 if ( filter->name() == mSyncManager->mFilterInCal )
1200 filterIN = filter; 1204 filterIN = filter;
1201 if ( filter->name() == mSyncManager->mFilterOutCal ) 1205 if ( filter->name() == mSyncManager->mFilterOutCal )
1202 filterOUT = filter; 1206 filterOUT = filter;
1203 filter = mFilters.next(); 1207 filter = mFilters.next();
1204 } 1208 }
1205 int w = 300; 1209 int w = 300;
1206 if ( QApplication::desktop()->width() < 320 ) 1210 if ( QApplication::desktop()->width() < 320 )
1207 w = 220; 1211 w = 220;
1208 int h = bar.sizeHint().height() ; 1212 int h = bar.sizeHint().height() ;
1209 int dw = QApplication::desktop()->width(); 1213 int dw = QApplication::desktop()->width();
1210 int dh = QApplication::desktop()->height(); 1214 int dh = QApplication::desktop()->height();
1211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1215 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1212 bar.show(); 1216 bar.show();
1213 int modulo = (er.count()/10)+1; 1217 int modulo = (er.count()/10)+1;
1214 int incCounter = 0; 1218 int incCounter = 0;
1215 while ( inR ) { 1219 while ( inR ) {
1216 if ( ! bar.isVisible() ) 1220 if ( ! bar.isVisible() )
1217 return false; 1221 return false;
1218 if ( incCounter % modulo == 0 ) 1222 if ( incCounter % modulo == 0 )
1219 bar.setProgress( incCounter ); 1223 bar.setProgress( incCounter );
1220 ++incCounter; 1224 ++incCounter;
1221 uid = inR->uid(); 1225 uid = inR->uid();
1222 bool skipIncidence = false; 1226 bool skipIncidence = false;
1223 if ( uid.left(15) == QString("last-syncEvent-") ) 1227 if ( uid.left(15) == QString("last-syncEvent-") )
1224 skipIncidence = true; 1228 skipIncidence = true;
1225 QString idS; 1229 QString idS;
1226 qApp->processEvents(); 1230 qApp->processEvents();
1227 if ( !skipIncidence ) { 1231 if ( !skipIncidence ) {
1228 inL = local->incidence( uid ); 1232 inL = local->incidence( uid );
1229 if ( inL ) { // maybe conflict - same uid in both calendars 1233 if ( inL ) { // maybe conflict - same uid in both calendars
1230 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1234 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1231 //qDebug("take %d %s ", take, inL->summary().latin1()); 1235 //qDebug("take %d %s ", take, inL->summary().latin1());
1232 if ( take == 3 ) 1236 if ( take == 3 )
1233 return false; 1237 return false;
1234 if ( take == 1 ) {// take local ********************** 1238 if ( take == 1 ) {// take local **********************
1235 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1239 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1236 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1240 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1237 else 1241 else
1238 idS = inR->IDStr(); 1242 idS = inR->IDStr();
1239 remote->deleteIncidence( inR ); 1243 remote->deleteIncidence( inR );
1240 inR = inL->clone(); 1244 inR = inL->clone();
1241 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1245 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1242 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1246 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1243 inR->setIDStr( idS ); 1247 inR->setIDStr( idS );
1244 remote->addIncidence( inR ); 1248 remote->addIncidence( inR );
1245 if ( mSyncManager->syncWithDesktop() ) 1249 if ( mSyncManager->syncWithDesktop() )
1246 inR->setPilotId( 2 ); 1250 inR->setPilotId( 2 );
1247 ++changedRemote; 1251 ++changedRemote;
1248 } else {// take remote ********************** 1252 } else {// take remote **********************
1249 idS = inL->IDStr(); 1253 idS = inL->IDStr();
1250 int pid = inL->pilotId(); 1254 int pid = inL->pilotId();
1251 local->deleteIncidence( inL ); 1255 local->deleteIncidence( inL );
1252 inL = inR->clone(); 1256 inL = inR->clone();
1253 if ( mSyncManager->syncWithDesktop() ) 1257 if ( mSyncManager->syncWithDesktop() )
1254 inL->setPilotId( pid ); 1258 inL->setPilotId( pid );
1255 inL->setIDStr( idS ); 1259 inL->setIDStr( idS );
1256 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1260 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1257 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1261 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1258 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1262 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1259 } 1263 }
1260 local->addIncidence( inL ); 1264 local->addIncidence( inL );
1261 ++changedLocal; 1265 ++changedLocal;
1262 } 1266 }
1263 } 1267 }
1264 } else { // no conflict ********** add or delete remote 1268 } else { // no conflict ********** add or delete remote
1265 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1269 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1266 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1270 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1267 QString des = eventLSync->description(); 1271 QString des = eventLSync->description();
1268 QString pref = "e"; 1272 QString pref = "e";
1269 if ( inR->type() == "Todo" ) 1273 if ( inR->type() == "Todo" )
1270 pref = "t"; 1274 pref = "t";
1271 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1275 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1272 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1276 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1273 //remote->deleteIncidence( inR ); 1277 //remote->deleteIncidence( inR );
1274 ++deletedEventR; 1278 ++deletedEventR;
1275 } else { 1279 } else {
1276 inR->setLastModified( modifiedCalendar ); 1280 inR->setLastModified( modifiedCalendar );
1277 inL = inR->clone(); 1281 inL = inR->clone();
1278 inL->setIDStr( ":" ); 1282 inL->setIDStr( ":" );
1279 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1283 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1280 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1284 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1281 local->addIncidence( inL ); 1285 local->addIncidence( inL );
1282 ++addedEvent; 1286 ++addedEvent;
1283 1287
1284 } 1288 }
1285 } else { 1289 } else {
1286 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1290 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1287 inR->setLastModified( modifiedCalendar ); 1291 inR->setLastModified( modifiedCalendar );
1288 inL = inR->clone(); 1292 inL = inR->clone();
1289 inL->setIDStr( ":" ); 1293 inL->setIDStr( ":" );
1290 local->addIncidence( inL ); 1294 local->addIncidence( inL );
1291 ++addedEvent; 1295 ++addedEvent;
1292 1296
1293 } else { 1297 } else {
1294 checkExternSyncEvent(eventRSyncSharp, inR); 1298 checkExternSyncEvent(eventRSyncSharp, inR);
1295 remote->deleteIncidence( inR ); 1299 remote->deleteIncidence( inR );
1296 ++deletedEventR; 1300 ++deletedEventR;
1297 } 1301 }
1298 } 1302 }
1299 } else { 1303 } else {
1300 ++filteredIN; 1304 ++filteredIN;
1301 } 1305 }
1302 } 1306 }
1303 } 1307 }
1304 inR = er.next(); 1308 inR = er.next();
1305 } 1309 }
1306 QPtrList<Incidence> el = local->rawIncidences(); 1310 QPtrList<Incidence> el = local->rawIncidences();
1307 inL = el.first(); 1311 inL = el.first();
1308 modulo = (el.count()/10)+1; 1312 modulo = (el.count()/10)+1;
1309 bar.setCaption (i18n("Add / remove events") ); 1313 bar.setCaption (i18n("Add / remove events") );
1310 bar.setTotalSteps ( el.count() ) ; 1314 bar.setTotalSteps ( el.count() ) ;
1311 bar.show(); 1315 bar.show();
1312 incCounter = 0; 1316 incCounter = 0;
1313 1317
1314 while ( inL ) { 1318 while ( inL ) {
1315 1319
1316 qApp->processEvents(); 1320 qApp->processEvents();
1317 if ( ! bar.isVisible() ) 1321 if ( ! bar.isVisible() )
1318 return false; 1322 return false;
1319 if ( incCounter % modulo == 0 ) 1323 if ( incCounter % modulo == 0 )
1320 bar.setProgress( incCounter ); 1324 bar.setProgress( incCounter );
1321 ++incCounter; 1325 ++incCounter;
1322 uid = inL->uid(); 1326 uid = inL->uid();
1323 bool skipIncidence = false; 1327 bool skipIncidence = false;
1324 if ( uid.left(15) == QString("last-syncEvent-") ) 1328 if ( uid.left(15) == QString("last-syncEvent-") )
1325 skipIncidence = true; 1329 skipIncidence = true;
1326 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1330 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1327 skipIncidence = true; 1331 skipIncidence = true;
1328 if ( !skipIncidence ) { 1332 if ( !skipIncidence ) {
1329 inR = remote->incidence( uid ); 1333 inR = remote->incidence( uid );
1330 if ( ! inR ) { 1334 if ( ! inR ) {
1331 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1335 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1332 // no conflict ********** add or delete local 1336 // no conflict ********** add or delete local
1333 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1337 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1334 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1338 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1335 checkExternSyncEvent(eventLSyncSharp, inL); 1339 checkExternSyncEvent(eventLSyncSharp, inL);
1336 local->deleteIncidence( inL ); 1340 local->deleteIncidence( inL );
1337 ++deletedEventL; 1341 ++deletedEventL;
1338 } else { 1342 } else {
1339 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1343 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1340 inL->removeID(mCurrentSyncDevice ); 1344 inL->removeID(mCurrentSyncDevice );
1341 ++addedEventR; 1345 ++addedEventR;
1342 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1346 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1343 inL->setLastModified( modifiedCalendar ); 1347 inL->setLastModified( modifiedCalendar );
1344 inR = inL->clone(); 1348 inR = inL->clone();
1345 inR->setIDStr( ":" ); 1349 inR->setIDStr( ":" );
1346 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1350 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1347 remote->addIncidence( inR ); 1351 remote->addIncidence( inR );
1348 } 1352 }
1349 } 1353 }
1350 } else { 1354 } else {
1351 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1355 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1352 checkExternSyncEvent(eventLSyncSharp, inL); 1356 checkExternSyncEvent(eventLSyncSharp, inL);
1353 local->deleteIncidence( inL ); 1357 local->deleteIncidence( inL );
1354 ++deletedEventL; 1358 ++deletedEventL;
1355 } else { 1359 } else {
1356 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1360 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1357 ++addedEventR; 1361 ++addedEventR;
1358 inL->setLastModified( modifiedCalendar ); 1362 inL->setLastModified( modifiedCalendar );
1359 inR = inL->clone(); 1363 inR = inL->clone();
1360 inR->setIDStr( ":" ); 1364 inR->setIDStr( ":" );
1361 remote->addIncidence( inR ); 1365 remote->addIncidence( inR );
1362 } 1366 }
1363 } 1367 }
1364 } 1368 }
1365 } else { 1369 } else {
1366 ++filteredOUT; 1370 ++filteredOUT;
1367 } 1371 }
1368 } 1372 }
1369 } 1373 }
1370 inL = el.next(); 1374 inL = el.next();
1371 } 1375 }
1372 int delFut = 0; 1376 int delFut = 0;
1373 int remRem = 0; 1377 int remRem = 0;
1374 if ( mSyncManager->mWriteBackInFuture ) { 1378 if ( mSyncManager->mWriteBackInFuture ) {
1375 er = remote->rawIncidences(); 1379 er = remote->rawIncidences();
1376 remRem = er.count(); 1380 remRem = er.count();
1377 inR = er.first(); 1381 inR = er.first();
1378 QDateTime dt; 1382 QDateTime dt;
1379 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1383 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1380 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1384 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1381 while ( inR ) { 1385 while ( inR ) {
1382 if ( inR->type() == "Todo" ) { 1386 if ( inR->type() == "Todo" ) {
1383 Todo * t = (Todo*)inR; 1387 Todo * t = (Todo*)inR;
1384 if ( t->hasDueDate() ) 1388 if ( t->hasDueDate() )
1385 dt = t->dtDue(); 1389 dt = t->dtDue();
1386 else 1390 else
1387 dt = cur.addSecs( 62 ); 1391 dt = cur.addSecs( 62 );
1388 } 1392 }
1389 else if (inR->type() == "Event" ) { 1393 else if (inR->type() == "Event" ) {
1390 bool ok; 1394 bool ok;
1391 dt = inR->getNextOccurence( cur, &ok ); 1395 dt = inR->getNextOccurence( cur, &ok );
1392 if ( !ok ) 1396 if ( !ok )
1393 dt = cur.addSecs( -62 ); 1397 dt = cur.addSecs( -62 );
1394 } 1398 }
1395 else 1399 else
1396 dt = inR->dtStart(); 1400 dt = inR->dtStart();
1397 if ( dt < cur || dt > end ) { 1401 if ( dt < cur || dt > end ) {
1398 remote->deleteIncidence( inR ); 1402 remote->deleteIncidence( inR );
1399 ++delFut; 1403 ++delFut;
1400 } 1404 }
1401 inR = er.next(); 1405 inR = er.next();
1402 } 1406 }
1403 } 1407 }
1404 bar.hide(); 1408 bar.hide();
1405 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1409 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1406 eventLSync->setReadOnly( false ); 1410 eventLSync->setReadOnly( false );
1407 eventLSync->setDtStart( mLastCalendarSync ); 1411 eventLSync->setDtStart( mLastCalendarSync );
1408 eventRSync->setDtStart( mLastCalendarSync ); 1412 eventRSync->setDtStart( mLastCalendarSync );
1409 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1413 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1410 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1414 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1411 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1415 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1412 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1416 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1413 eventLSync->setReadOnly( true ); 1417 eventLSync->setReadOnly( true );
1414 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1418 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1415 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1419 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1416 remote->addEvent( eventRSync ); 1420 remote->addEvent( eventRSync );
1417 else 1421 else
1418 delete eventRSync; 1422 delete eventRSync;
1419 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1423 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1420 QString mes; 1424 QString mes;
1421 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 ); 1425 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 );
1422 QString delmess; 1426 QString delmess;
1423 if ( delFut ) { 1427 if ( delFut ) {
1424 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); 1428 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);
1425 mes += delmess; 1429 mes += delmess;
1426 } 1430 }
1427 mes = i18n("Local calendar changed!\n") +mes; 1431 mes = i18n("Local calendar changed!\n") +mes;
1428 mCalendar->checkAlarmForIncidence( 0, true ); 1432 mCalendar->checkAlarmForIncidence( 0, true );
1429 qDebug( mes ); 1433 qDebug( mes );
1430 if ( mSyncManager->mShowSyncSummary ) { 1434 if ( mSyncManager->mShowSyncSummary ) {
1431 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1435 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1432 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1436 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1433 qDebug("KO: WB cancelled "); 1437 qDebug("KO: WB cancelled ");
1434 mSyncManager->mWriteBackFile = false; 1438 mSyncManager->mWriteBackFile = false;
1435 return syncOK; 1439 return syncOK;
1436 } 1440 }
1437 } 1441 }
1438 return syncOK; 1442 return syncOK;
1439} 1443}
1440 1444
1441void CalendarView::setSyncDevice( QString s ) 1445void CalendarView::setSyncDevice( QString s )
1442{ 1446{
1443 mCurrentSyncDevice= s; 1447 mCurrentSyncDevice= s;
1444} 1448}
1445void CalendarView::setSyncName( QString s ) 1449void CalendarView::setSyncName( QString s )
1446{ 1450{
1447 mCurrentSyncName= s; 1451 mCurrentSyncName= s;
1448} 1452}
1449bool CalendarView::syncCalendar(QString filename, int mode) 1453bool CalendarView::syncCalendar(QString filename, int mode)
1450{ 1454{
1451 //qDebug("syncCalendar %s ", filename.latin1()); 1455 //qDebug("syncCalendar %s ", filename.latin1());
1452 mGlobalSyncMode = SYNC_MODE_NORMAL; 1456 mGlobalSyncMode = SYNC_MODE_NORMAL;
1453 CalendarLocal* calendar = new CalendarLocal(); 1457 CalendarLocal* calendar = new CalendarLocal();
1454 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1458 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1455 FileStorage* storage = new FileStorage( calendar ); 1459 FileStorage* storage = new FileStorage( calendar );
1456 bool syncOK = false; 1460 bool syncOK = false;
1457 storage->setFileName( filename ); 1461 storage->setFileName( filename );
1458 // qDebug("loading ... "); 1462 // qDebug("loading ... ");
1459 if ( storage->load() ) { 1463 if ( storage->load() ) {
1460 getEventViewerDialog()->setSyncMode( true ); 1464 getEventViewerDialog()->setSyncMode( true );
1461 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1465 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1462 getEventViewerDialog()->setSyncMode( false ); 1466 getEventViewerDialog()->setSyncMode( false );
1463 if ( syncOK ) { 1467 if ( syncOK ) {
1464 if ( mSyncManager->mWriteBackFile ) 1468 if ( mSyncManager->mWriteBackFile )
1465 { 1469 {
1466 storage->setSaveFormat( new ICalFormat() ); 1470 storage->setSaveFormat( new ICalFormat() );
1467 storage->save(); 1471 storage->save();
1468 } 1472 }
1469 } 1473 }
1470 setModified( true ); 1474 setModified( true );
1471 } 1475 }
1472 delete storage; 1476 delete storage;
1473 delete calendar; 1477 delete calendar;
1474 if ( syncOK ) 1478 if ( syncOK )
1475 updateView(); 1479 updateView();
1476 return syncOK; 1480 return syncOK;
1477} 1481}
1478 1482
1479void CalendarView::syncExternal( int mode ) 1483void CalendarView::syncExternal( int mode )
1480{ 1484{
1481 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1485 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1482 1486
1483 qApp->processEvents(); 1487 qApp->processEvents();
1484 CalendarLocal* calendar = new CalendarLocal(); 1488 CalendarLocal* calendar = new CalendarLocal();
1485 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1489 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1486 bool syncOK = false; 1490 bool syncOK = false;
1487 bool loadSuccess = false; 1491 bool loadSuccess = false;
1488 PhoneFormat* phoneFormat = 0; 1492 PhoneFormat* phoneFormat = 0;
1489 emit tempDisableBR(true); 1493 emit tempDisableBR(true);
1490#ifndef DESKTOP_VERSION 1494#ifndef DESKTOP_VERSION
1491 SharpFormat* sharpFormat = 0; 1495 SharpFormat* sharpFormat = 0;
1492 if ( mode == 0 ) { // sharp 1496 if ( mode == 0 ) { // sharp
1493 sharpFormat = new SharpFormat () ; 1497 sharpFormat = new SharpFormat () ;
1494 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1498 loadSuccess = sharpFormat->load( calendar, mCalendar );
1495 1499
1496 } else 1500 } else
1497#endif 1501#endif
1498 if ( mode == 1 ) { // phone 1502 if ( mode == 1 ) { // phone
1499 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1503 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1500 mSyncManager->mPhoneDevice, 1504 mSyncManager->mPhoneDevice,
1501 mSyncManager->mPhoneConnection, 1505 mSyncManager->mPhoneConnection,
1502 mSyncManager->mPhoneModel); 1506 mSyncManager->mPhoneModel);
1503 loadSuccess = phoneFormat->load( calendar,mCalendar); 1507 loadSuccess = phoneFormat->load( calendar,mCalendar);
1504 1508
1505 } else { 1509 } else {
1506 emit tempDisableBR(false); 1510 emit tempDisableBR(false);
1507 return; 1511 return;
1508 } 1512 }
1509 if ( loadSuccess ) { 1513 if ( loadSuccess ) {
1510 getEventViewerDialog()->setSyncMode( true ); 1514 getEventViewerDialog()->setSyncMode( true );
1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1515 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1512 getEventViewerDialog()->setSyncMode( false ); 1516 getEventViewerDialog()->setSyncMode( false );
1513 qApp->processEvents(); 1517 qApp->processEvents();
1514 if ( syncOK ) { 1518 if ( syncOK ) {
1515 if ( mSyncManager->mWriteBackFile ) 1519 if ( mSyncManager->mWriteBackFile )
1516 { 1520 {
1517 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1521 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1518 Incidence* inc = iL.first(); 1522 Incidence* inc = iL.first();
1519 if ( phoneFormat ) { 1523 if ( phoneFormat ) {
1520 while ( inc ) { 1524 while ( inc ) {
1521 inc->removeID(mCurrentSyncDevice); 1525 inc->removeID(mCurrentSyncDevice);
1522 inc = iL.next(); 1526 inc = iL.next();
1523 } 1527 }
1524 } 1528 }
1525#ifndef DESKTOP_VERSION 1529#ifndef DESKTOP_VERSION
1526 if ( sharpFormat ) 1530 if ( sharpFormat )
1527 sharpFormat->save(calendar); 1531 sharpFormat->save(calendar);
1528#endif 1532#endif
1529 if ( phoneFormat ) 1533 if ( phoneFormat )
1530 phoneFormat->save(calendar); 1534 phoneFormat->save(calendar);
1531 iL = calendar->rawIncidences(); 1535 iL = calendar->rawIncidences();
1532 inc = iL.first(); 1536 inc = iL.first();
1533 Incidence* loc; 1537 Incidence* loc;
1534 while ( inc ) { 1538 while ( inc ) {
1535 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1539 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1536 loc = mCalendar->incidence(inc->uid() ); 1540 loc = mCalendar->incidence(inc->uid() );
1537 if ( loc ) { 1541 if ( loc ) {
1538 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1542 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1539 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1543 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1540 } 1544 }
1541 } 1545 }
1542 inc = iL.next(); 1546 inc = iL.next();
1543 } 1547 }
1544 Incidence* lse = getLastSyncEvent(); 1548 Incidence* lse = getLastSyncEvent();
1545 if ( lse ) { 1549 if ( lse ) {
1546 lse->setReadOnly( false ); 1550 lse->setReadOnly( false );
1547 lse->setDescription( "" ); 1551 lse->setDescription( "" );
1548 lse->setReadOnly( true ); 1552 lse->setReadOnly( true );
1549 } 1553 }
1550 } 1554 }
1551 } else { 1555 } else {
1552 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1556 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1553 } 1557 }
1554 setModified( true ); 1558 setModified( true );
1555 } else { 1559 } else {
1556 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1560 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1557 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1561 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1558 question, i18n("Ok")) ; 1562 question, i18n("Ok")) ;
1559 1563
1560 } 1564 }
1561 delete calendar; 1565 delete calendar;
1562 updateView(); 1566 updateView();
1563 emit tempDisableBR(false); 1567 emit tempDisableBR(false);
1564 return ;//syncOK; 1568 return ;//syncOK;
1565 1569
1566} 1570}
1567 1571
1568bool CalendarView::importBday() 1572bool CalendarView::importBday()
1569{ 1573{
1570#ifndef KORG_NOKABC 1574#ifndef KORG_NOKABC
1571 1575
1572#ifdef DESKTOP_VERSION 1576#ifdef DESKTOP_VERSION
1573 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1577 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1574 KABC::AddressBook::Iterator it; 1578 KABC::AddressBook::Iterator it;
1575 int count = 0; 1579 int count = 0;
1576 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1580 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1577 ++count; 1581 ++count;
1578 } 1582 }
1579 QProgressBar bar(count,0 ); 1583 QProgressBar bar(count,0 );
1580 int w = 300; 1584 int w = 300;
1581 if ( QApplication::desktop()->width() < 320 ) 1585 if ( QApplication::desktop()->width() < 320 )
1582 w = 220; 1586 w = 220;
1583 int h = bar.sizeHint().height() ; 1587 int h = bar.sizeHint().height() ;
1584 int dw = QApplication::desktop()->width(); 1588 int dw = QApplication::desktop()->width();
1585 int dh = QApplication::desktop()->height(); 1589 int dh = QApplication::desktop()->height();
1586 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1590 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1587 bar.show(); 1591 bar.show();
1588 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1592 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1589 qApp->processEvents(); 1593 qApp->processEvents();
1590 count = 0; 1594 count = 0;
1591 int addCount = 0; 1595 int addCount = 0;
1592 KCal::Attendee* a = 0; 1596 KCal::Attendee* a = 0;
1593 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1597 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1594 if ( ! bar.isVisible() ) 1598 if ( ! bar.isVisible() )
1595 return false; 1599 return false;
1596 bar.setProgress( count++ ); 1600 bar.setProgress( count++ );
1597 qApp->processEvents(); 1601 qApp->processEvents();
1598 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1602 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1599 if ( (*it).birthday().date().isValid() ){ 1603 if ( (*it).birthday().date().isValid() ){
1600 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1604 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1601 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1605 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1602 ++addCount; 1606 ++addCount;
1603 } 1607 }
1604 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1608 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1605 if ( anni.isValid() ){ 1609 if ( anni.isValid() ){
1606 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1610 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1607 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1611 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1608 ++addCount; 1612 ++addCount;
1609 } 1613 }
1610 } 1614 }
1611 updateView(); 1615 updateView();
1612 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1616 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1613#else //DESKTOP_VERSION 1617#else //DESKTOP_VERSION
1614 1618
1615 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1619 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1616 // the result should now arrive through method insertBirthdays 1620 // the result should now arrive through method insertBirthdays
1617 1621
1618#endif //DESKTOP_VERSION 1622#endif //DESKTOP_VERSION
1619 1623
1620#endif //KORG_NOKABC 1624#endif //KORG_NOKABC
1621 1625
1622 1626
1623 return true; 1627 return true;
1624} 1628}
1625 1629
1626// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1630// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1627void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1631void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1628 const QStringList& anniversaryList, const QStringList& realNameList, 1632 const QStringList& anniversaryList, const QStringList& realNameList,
1629 const QStringList& emailList, const QStringList& assembledNameList, 1633 const QStringList& emailList, const QStringList& assembledNameList,
1630 const QStringList& uidList) 1634 const QStringList& uidList)
1631{ 1635{
1632 //qDebug("KO::CalendarView::insertBirthdays"); 1636 //qDebug("KO::CalendarView::insertBirthdays");
1633 if (uid == this->name()) 1637 if (uid == this->name())
1634 { 1638 {
1635 int count = birthdayList.count(); 1639 int count = birthdayList.count();
1636 int addCount = 0; 1640 int addCount = 0;
1637 KCal::Attendee* a = 0; 1641 KCal::Attendee* a = 0;
1638 1642
1639 //qDebug("CalView 1 %i", count); 1643 //qDebug("CalView 1 %i", count);
1640 1644
1641 QProgressBar bar(count,0 ); 1645 QProgressBar bar(count,0 );
1642 int w = 300; 1646 int w = 300;
1643 if ( QApplication::desktop()->width() < 320 ) 1647 if ( QApplication::desktop()->width() < 320 )
1644 w = 220; 1648 w = 220;
1645 int h = bar.sizeHint().height() ; 1649 int h = bar.sizeHint().height() ;
1646 int dw = QApplication::desktop()->width(); 1650 int dw = QApplication::desktop()->width();
1647 int dh = QApplication::desktop()->height(); 1651 int dh = QApplication::desktop()->height();
1648 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1652 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1649 bar.show(); 1653 bar.show();
1650 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1654 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1651 qApp->processEvents(); 1655 qApp->processEvents();
1652 1656
1653 QDate birthday; 1657 QDate birthday;
1654 QDate anniversary; 1658 QDate anniversary;
1655 QString realName; 1659 QString realName;
1656 QString email; 1660 QString email;
1657 QString assembledName; 1661 QString assembledName;
1658 QString uid; 1662 QString uid;
1659 bool ok = true; 1663 bool ok = true;
1660 for ( int i = 0; i < count; i++) 1664 for ( int i = 0; i < count; i++)
1661 { 1665 {
1662 if ( ! bar.isVisible() ) 1666 if ( ! bar.isVisible() )
1663 return; 1667 return;
1664 bar.setProgress( i ); 1668 bar.setProgress( i );
1665 qApp->processEvents(); 1669 qApp->processEvents();
1666 1670
1667 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1671 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1668 if (!ok) { 1672 if (!ok) {
1669 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1673 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1670 } 1674 }
1671 1675
1672 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1676 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1673 if (!ok) { 1677 if (!ok) {
1674 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1678 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1675 } 1679 }
1676 realName = realNameList[i]; 1680 realName = realNameList[i];
1677 email = emailList[i]; 1681 email = emailList[i];
1678 assembledName = assembledNameList[i]; 1682 assembledName = assembledNameList[i];
1679 uid = uidList[i]; 1683 uid = uidList[i];
1680 //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() ); 1684 //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() );
1681 1685
1682 if ( birthday.isValid() ){ 1686 if ( birthday.isValid() ){
1683 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1687 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1684 KCal::Attendee::ReqParticipant,uid) ; 1688 KCal::Attendee::ReqParticipant,uid) ;
1685 if ( addAnniversary( birthday, assembledName, a, true ) ) 1689 if ( addAnniversary( birthday, assembledName, a, true ) )
1686 ++addCount; 1690 ++addCount;
1687 } 1691 }
1688 1692
1689 if ( anniversary.isValid() ){ 1693 if ( anniversary.isValid() ){
1690 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1694 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1691 KCal::Attendee::ReqParticipant,uid) ; 1695 KCal::Attendee::ReqParticipant,uid) ;
1692 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1696 if ( addAnniversary( anniversary, assembledName, a, false ) )
1693 ++addCount; 1697 ++addCount;
1694 } 1698 }
1695 } 1699 }
1696 1700
1697 updateView(); 1701 updateView();
1698 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1702 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1699 1703
1700 } 1704 }
1701 1705
1702} 1706}
1703 1707
1704 1708
1705 1709
1706bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1710bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1707{ 1711{
1708 //qDebug("addAnni "); 1712 //qDebug("addAnni ");
1709 Event * ev = new Event(); 1713 Event * ev = new Event();
1710 ev->setOrganizer(KOPrefs::instance()->email()); 1714 ev->setOrganizer(KOPrefs::instance()->email());
1711 if ( a ) { 1715 if ( a ) {
1712 ev->addAttendee( a ); 1716 ev->addAttendee( a );
1713 } 1717 }
1714 QString kind; 1718 QString kind;
1715 if ( birthday ) { 1719 if ( birthday ) {
1716 kind = i18n( "Birthday" ); 1720 kind = i18n( "Birthday" );
1717 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1721 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1718 } 1722 }
1719 else { 1723 else {
1720 kind = i18n( "Anniversary" ); 1724 kind = i18n( "Anniversary" );
1721 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1725 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1722 } 1726 }
1723 ev->setCategories( kind ); 1727 ev->setCategories( kind );
1724 ev->setDtStart( QDateTime(date) ); 1728 ev->setDtStart( QDateTime(date) );
1725 ev->setDtEnd( QDateTime(date) ); 1729 ev->setDtEnd( QDateTime(date) );
1726 ev->setFloats( true ); 1730 ev->setFloats( true );
1727 Recurrence * rec = ev->recurrence(); 1731 Recurrence * rec = ev->recurrence();
1728 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1732 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1729 rec->addYearlyNum( date.month() ); 1733 rec->addYearlyNum( date.month() );
1730 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1734 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1731 delete ev; 1735 delete ev;
1732 return false; 1736 return false;
1733 } 1737 }
1734 return true; 1738 return true;
1735 1739
1736} 1740}
1737bool CalendarView::importQtopia( const QString &categories, 1741bool CalendarView::importQtopia( const QString &categories,
1738 const QString &datebook, 1742 const QString &datebook,
1739 const QString &todolist ) 1743 const QString &todolist )
1740{ 1744{
1741 1745
1742 QtopiaFormat qtopiaFormat; 1746 QtopiaFormat qtopiaFormat;
1743 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1747 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1744 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1748 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1745 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1749 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1746 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1750 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1747 1751
1748 updateView(); 1752 updateView();
1749 return true; 1753 return true;
1750 1754
1751#if 0 1755#if 0
1752 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1756 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1753 mCurrentSyncDevice = "qtopia-XML"; 1757 mCurrentSyncDevice = "qtopia-XML";
1754 if ( mSyncManager->mAskForPreferences ) 1758 if ( mSyncManager->mAskForPreferences )
1755 edit_sync_options(); 1759 edit_sync_options();
1756 qApp->processEvents(); 1760 qApp->processEvents();
1757 CalendarLocal* calendar = new CalendarLocal(); 1761 CalendarLocal* calendar = new CalendarLocal();
1758 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1762 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1759 bool syncOK = false; 1763 bool syncOK = false;
1760 QtopiaFormat qtopiaFormat; 1764 QtopiaFormat qtopiaFormat;
1761 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1765 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1762 bool loadOk = true; 1766 bool loadOk = true;
1763 if ( !categories.isEmpty() ) 1767 if ( !categories.isEmpty() )
1764 loadOk = qtopiaFormat.load( calendar, categories ); 1768 loadOk = qtopiaFormat.load( calendar, categories );
1765 if ( loadOk && !datebook.isEmpty() ) 1769 if ( loadOk && !datebook.isEmpty() )
1766 loadOk = qtopiaFormat.load( calendar, datebook ); 1770 loadOk = qtopiaFormat.load( calendar, datebook );
1767 if ( loadOk && !todolist.isEmpty() ) 1771 if ( loadOk && !todolist.isEmpty() )
1768 loadOk = qtopiaFormat.load( calendar, todolist ); 1772 loadOk = qtopiaFormat.load( calendar, todolist );
1769 1773
1770 if ( loadOk ) { 1774 if ( loadOk ) {
1771 getEventViewerDialog()->setSyncMode( true ); 1775 getEventViewerDialog()->setSyncMode( true );
1772 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1776 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1773 getEventViewerDialog()->setSyncMode( false ); 1777 getEventViewerDialog()->setSyncMode( false );
1774 qApp->processEvents(); 1778 qApp->processEvents();
1775 if ( syncOK ) { 1779 if ( syncOK ) {
1776 if ( mSyncManager->mWriteBackFile ) 1780 if ( mSyncManager->mWriteBackFile )
1777 { 1781 {
1778 // write back XML file 1782 // write back XML file
1779 1783
1780 } 1784 }
1781 setModified( true ); 1785 setModified( true );
1782 } 1786 }
1783 } else { 1787 } else {
1784 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1788 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1785 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1789 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1786 question, i18n("Ok")) ; 1790 question, i18n("Ok")) ;
1787 } 1791 }
1788 delete calendar; 1792 delete calendar;
1789 updateView(); 1793 updateView();
1790 return syncOK; 1794 return syncOK;
1791 1795
1792 1796
1793#endif 1797#endif
1794 1798
1795} 1799}
1796 1800
1797void CalendarView::setSyncEventsReadOnly() 1801void CalendarView::setSyncEventsReadOnly()
1798{ 1802{
1799 Event * ev; 1803 Event * ev;
1800 QPtrList<Event> eL = mCalendar->rawEvents(); 1804 QPtrList<Event> eL = mCalendar->rawEvents();
1801 ev = eL.first(); 1805 ev = eL.first();
1802 while ( ev ) { 1806 while ( ev ) {
1803 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1807 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1804 ev->setReadOnly( true ); 1808 ev->setReadOnly( true );
1805 ev = eL.next(); 1809 ev = eL.next();
1806 } 1810 }
1807} 1811}
1808bool CalendarView::openCalendar(QString filename, bool merge) 1812bool CalendarView::openCalendar(QString filename, bool merge)
1809{ 1813{
1810 1814
1811 if (filename.isEmpty()) { 1815 if (filename.isEmpty()) {
1812 return false; 1816 return false;
1813 } 1817 }
1814 1818
1815 if (!QFile::exists(filename)) { 1819 if (!QFile::exists(filename)) {
1816 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1820 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1817 return false; 1821 return false;
1818 } 1822 }
1819 1823
1820 globalFlagBlockAgenda = 1; 1824 globalFlagBlockAgenda = 1;
1821 if (!merge) { 1825 if (!merge) {
1822 mTodoList->clearList(); 1826 mTodoList->clearList();
1823 mViewManager->setDocumentId( filename ); 1827 mViewManager->setDocumentId( filename );
1824 mCalendar->close(); 1828 mCalendar->close();
1825 } 1829 }
1826 mStorage->setFileName( filename ); 1830 mStorage->setFileName( filename );
1827 1831
1828 if ( mStorage->load() ) { 1832 if ( mStorage->load() ) {
1829 if ( merge ) ;//setModified( true ); 1833 if ( merge ) ;//setModified( true );
1830 else { 1834 else {
1831 //setModified( true ); 1835 //setModified( true );
1832 mViewManager->setDocumentId( filename ); 1836 mViewManager->setDocumentId( filename );
1833 mDialogManager->setDocumentId( filename ); 1837 mDialogManager->setDocumentId( filename );
1834 mTodoList->setDocumentId( filename ); 1838 mTodoList->setDocumentId( filename );
1835 } 1839 }
1836 globalFlagBlockAgenda = 2; 1840 globalFlagBlockAgenda = 2;
1837 // if ( getLastSyncEvent() ) 1841 // if ( getLastSyncEvent() )
1838 // getLastSyncEvent()->setReadOnly( true ); 1842 // getLastSyncEvent()->setReadOnly( true );
1839 mCalendar->reInitAlarmSettings(); 1843 mCalendar->reInitAlarmSettings();
1840 setSyncEventsReadOnly(); 1844 setSyncEventsReadOnly();
1841 updateUnmanagedViews(); 1845 updateUnmanagedViews();
1842 updateView(); 1846 updateView();
1843 if ( filename != MainWindow::defaultFileName() ) { 1847 if ( filename != MainWindow::defaultFileName() ) {
1844 saveCalendar( MainWindow::defaultFileName() ); 1848 saveCalendar( MainWindow::defaultFileName() );
1845 } else { 1849 } else {
1846 QFileInfo finf ( MainWindow::defaultFileName()); 1850 QFileInfo finf ( MainWindow::defaultFileName());
1847 if ( finf.exists() ) { 1851 if ( finf.exists() ) {
1848 setLoadedFileVersion( finf.lastModified () ); 1852 setLoadedFileVersion( finf.lastModified () );
1849 } 1853 }
1850 } 1854 }
1851 return true; 1855 return true;
1852 } else { 1856 } else {
1853 // while failing to load, the calendar object could 1857 // while failing to load, the calendar object could
1854 // have become partially populated. Clear it out. 1858 // have become partially populated. Clear it out.
1855 if ( !merge ) { 1859 if ( !merge ) {
1856 mCalendar->close(); 1860 mCalendar->close();
1857 mViewManager->setDocumentId( filename ); 1861 mViewManager->setDocumentId( filename );
1858 mDialogManager->setDocumentId( filename ); 1862 mDialogManager->setDocumentId( filename );
1859 mTodoList->setDocumentId( filename ); 1863 mTodoList->setDocumentId( filename );
1860 } 1864 }
1861 1865
1862 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1866 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1863 1867
1864 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1868 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1865 globalFlagBlockAgenda = 2; 1869 globalFlagBlockAgenda = 2;
1866 mCalendar->reInitAlarmSettings(); 1870 mCalendar->reInitAlarmSettings();
1867 setSyncEventsReadOnly(); 1871 setSyncEventsReadOnly();
1868 updateUnmanagedViews(); 1872 updateUnmanagedViews();
1869 updateView(); 1873 updateView();
1870 } 1874 }
1871 return false; 1875 return false;
1872} 1876}
1873void CalendarView::showOpenError() 1877void CalendarView::showOpenError()
1874{ 1878{
1875 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1879 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1876} 1880}
1877void CalendarView::setLoadedFileVersion(QDateTime dt) 1881void CalendarView::setLoadedFileVersion(QDateTime dt)
1878{ 1882{
1879 loadedFileVersion = dt; 1883 loadedFileVersion = dt;
1880} 1884}
1881bool CalendarView::checkFileChanged(QString fn) 1885bool CalendarView::checkFileChanged(QString fn)
1882{ 1886{
1883 QFileInfo finf ( fn ); 1887 QFileInfo finf ( fn );
1884 if ( !finf.exists() ) 1888 if ( !finf.exists() )
1885 return true; 1889 return true;
1886 QDateTime dt = finf.lastModified (); 1890 QDateTime dt = finf.lastModified ();
1887 if ( dt <= loadedFileVersion ) 1891 if ( dt <= loadedFileVersion )
1888 return false; 1892 return false;
1889 return true; 1893 return true;
1890 1894
1891} 1895}
1892void CalendarView::watchSavedFile() 1896void CalendarView::watchSavedFile()
1893{ 1897{
1894 QFileInfo finf ( MainWindow::defaultFileName()); 1898 QFileInfo finf ( MainWindow::defaultFileName());
1895 if ( !finf.exists() ) 1899 if ( !finf.exists() )
1896 return; 1900 return;
1897 QDateTime dt = finf.lastModified (); 1901 QDateTime dt = finf.lastModified ();
1898 if ( dt < loadedFileVersion ) { 1902 if ( dt < loadedFileVersion ) {
1899 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1903 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1900 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1904 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1901 return; 1905 return;
1902 } 1906 }
1903 loadedFileVersion = dt; 1907 loadedFileVersion = dt;
1904} 1908}
1905 1909
1906bool CalendarView::checkFileVersion(QString fn) 1910bool CalendarView::checkFileVersion(QString fn)
1907{ 1911{
1908 QFileInfo finf ( fn ); 1912 QFileInfo finf ( fn );
1909 if ( !finf.exists() ) 1913 if ( !finf.exists() )
1910 return true; 1914 return true;
1911 QDateTime dt = finf.lastModified (); 1915 QDateTime dt = finf.lastModified ();
1912 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1916 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1913 //qDebug("file on disk version %s",dt.toString().latin1()); 1917 //qDebug("file on disk version %s",dt.toString().latin1());
1914 if ( dt <= loadedFileVersion ) 1918 if ( dt <= loadedFileVersion )
1915 return true; 1919 return true;
1916 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1920 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1917 i18n("KO/Pi Warning"),i18n("Overwrite"), 1921 i18n("KO/Pi Warning"),i18n("Overwrite"),
1918 i18n("Sync+save")); 1922 i18n("Sync+save"));
1919 1923
1920 if ( km == KMessageBox::Cancel ) 1924 if ( km == KMessageBox::Cancel )
1921 return false; 1925 return false;
1922 if ( km == KMessageBox::Yes ) 1926 if ( km == KMessageBox::Yes )
1923 return true; 1927 return true;
1924 1928
1925 setSyncDevice("deleteaftersync" ); 1929 setSyncDevice("deleteaftersync" );
1926 mSyncManager->mAskForPreferences = true; 1930 mSyncManager->mAskForPreferences = true;
1927 mSyncManager->mSyncAlgoPrefs = 3; 1931 mSyncManager->mSyncAlgoPrefs = 3;
1928 mSyncManager->mWriteBackFile = false; 1932 mSyncManager->mWriteBackFile = false;
1929 mSyncManager->mWriteBackExistingOnly = false; 1933 mSyncManager->mWriteBackExistingOnly = false;
1930 mSyncManager->mShowSyncSummary = false; 1934 mSyncManager->mShowSyncSummary = false;
1931 syncCalendar( fn, 3 ); 1935 syncCalendar( fn, 3 );
1932 Event * e = getLastSyncEvent(); 1936 Event * e = getLastSyncEvent();
1933 mCalendar->deleteEvent ( e ); 1937 mCalendar->deleteEvent ( e );
1934 updateView(); 1938 updateView();
1935 return true; 1939 return true;
1936} 1940}
1937 1941
1938bool CalendarView::saveCalendar( QString filename ) 1942bool CalendarView::saveCalendar( QString filename )
1939{ 1943{
1940 1944
1941 // Store back all unsaved data into calendar object 1945 // Store back all unsaved data into calendar object
1942 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1946 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1943 if ( mViewManager->currentView() ) 1947 if ( mViewManager->currentView() )
1944 mViewManager->currentView()->flushView(); 1948 mViewManager->currentView()->flushView();
1945 1949
1946 1950
1947 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1951 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1948 mStorage->setSaveFormat( new ICalFormat() ); 1952 mStorage->setSaveFormat( new ICalFormat() );
1949 mStorage->setFileName( filename ); 1953 mStorage->setFileName( filename );
1950 bool success; 1954 bool success;
1951 success = mStorage->save(); 1955 success = mStorage->save();
1952 if ( !success ) { 1956 if ( !success ) {
1953 return false; 1957 return false;
1954 } 1958 }
1955 if ( filename == MainWindow::defaultFileName() ) { 1959 if ( filename == MainWindow::defaultFileName() ) {
1956 setLoadedFileVersion( lfv ); 1960 setLoadedFileVersion( lfv );
1957 watchSavedFile(); 1961 watchSavedFile();
1958 } 1962 }
1959 return true; 1963 return true;
1960} 1964}
1961 1965
1962void CalendarView::closeCalendar() 1966void CalendarView::closeCalendar()
1963{ 1967{
1964 1968
1965 // child windows no longer valid 1969 // child windows no longer valid
1966 emit closingDown(); 1970 emit closingDown();
1967 1971
1968 mCalendar->close(); 1972 mCalendar->close();
1969 setModified(false); 1973 setModified(false);
1970 updateView(); 1974 updateView();
1971} 1975}
1972 1976
1973void CalendarView::archiveCalendar() 1977void CalendarView::archiveCalendar()
1974{ 1978{
1975 mDialogManager->showArchiveDialog(); 1979 mDialogManager->showArchiveDialog();
1976} 1980}
1977 1981
1978 1982
1979void CalendarView::readSettings() 1983void CalendarView::readSettings()
1980{ 1984{
1981 1985
1982 1986
1983 // mViewManager->showAgendaView(); 1987 // mViewManager->showAgendaView();
1984 QString str; 1988 QString str;
1985 //qDebug("CalendarView::readSettings() "); 1989 //qDebug("CalendarView::readSettings() ");
1986 // read settings from the KConfig, supplying reasonable 1990 // read settings from the KConfig, supplying reasonable
1987 // defaults where none are to be found 1991 // defaults where none are to be found
1988 KConfig *config = KOGlobals::config(); 1992 KConfig *config = KOGlobals::config();
1989#ifndef KORG_NOSPLITTER 1993#ifndef KORG_NOSPLITTER
1990 config->setGroup("KOrganizer Geometry"); 1994 config->setGroup("KOrganizer Geometry");
1991 1995
1992 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1996 QValueList<int> sizes = config->readIntListEntry("Separator1");
1993 if (sizes.count() != 2) { 1997 if (sizes.count() != 2) {
1994 sizes << mDateNavigator->minimumSizeHint().width(); 1998 sizes << mDateNavigator->minimumSizeHint().width();
1995 sizes << 300; 1999 sizes << 300;
1996 } 2000 }
1997 mPanner->setSizes(sizes); 2001 mPanner->setSizes(sizes);
1998 2002
1999 sizes = config->readIntListEntry("Separator2"); 2003 sizes = config->readIntListEntry("Separator2");
2000 if ( ( mResourceView && sizes.count() == 4 ) || 2004 if ( ( mResourceView && sizes.count() == 4 ) ||
2001 ( !mResourceView && sizes.count() == 3 ) ) { 2005 ( !mResourceView && sizes.count() == 3 ) ) {
2002 mLeftSplitter->setSizes(sizes); 2006 mLeftSplitter->setSizes(sizes);
2003 } 2007 }
2004#endif 2008#endif
2005 globalFlagBlockAgenda = 1; 2009 globalFlagBlockAgenda = 1;
2006 mViewManager->showAgendaView(); 2010 mViewManager->showAgendaView();
2007 //mViewManager->readSettings( config ); 2011 //mViewManager->readSettings( config );
2008 mTodoList->restoreLayout(config,QString("Todo Layout")); 2012 mTodoList->restoreLayout(config,QString("Todo Layout"));
2009 readFilterSettings(config); 2013 readFilterSettings(config);
2010 2014
2011#ifdef DESKTOP_VERSION 2015#ifdef DESKTOP_VERSION
2012 config->setGroup("WidgetLayout"); 2016 config->setGroup("WidgetLayout");
2013 QStringList list; 2017 QStringList list;
2014 list = config->readListEntry("MainLayout"); 2018 list = config->readListEntry("MainLayout");
2015 int x,y,w,h; 2019 int x,y,w,h;
2016 if ( ! list.isEmpty() ) { 2020 if ( ! list.isEmpty() ) {
2017 x = list[0].toInt(); 2021 x = list[0].toInt();
2018 y = list[1].toInt(); 2022 y = list[1].toInt();
2019 w = list[2].toInt(); 2023 w = list[2].toInt();
2020 h = list[3].toInt(); 2024 h = list[3].toInt();
2021 KApplication::testCoords( &x,&y,&w,&h ); 2025 KApplication::testCoords( &x,&y,&w,&h );
2022 topLevelWidget()->setGeometry(x,y,w,h); 2026 topLevelWidget()->setGeometry(x,y,w,h);
2023 2027
2024 } else { 2028 } else {
2025 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2029 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2026 } 2030 }
2027 list = config->readListEntry("EditEventLayout"); 2031 list = config->readListEntry("EditEventLayout");
2028 if ( ! list.isEmpty() ) { 2032 if ( ! list.isEmpty() ) {
2029 x = list[0].toInt(); 2033 x = list[0].toInt();
2030 y = list[1].toInt(); 2034 y = list[1].toInt();
2031 w = list[2].toInt(); 2035 w = list[2].toInt();
2032 h = list[3].toInt(); 2036 h = list[3].toInt();
2033 KApplication::testCoords( &x,&y,&w,&h ); 2037 KApplication::testCoords( &x,&y,&w,&h );
2034 mEventEditor->setGeometry(x,y,w,h); 2038 mEventEditor->setGeometry(x,y,w,h);
2035 2039
2036 } 2040 }
2037 list = config->readListEntry("EditTodoLayout"); 2041 list = config->readListEntry("EditTodoLayout");
2038 if ( ! list.isEmpty() ) { 2042 if ( ! list.isEmpty() ) {
2039 x = list[0].toInt(); 2043 x = list[0].toInt();
2040 y = list[1].toInt(); 2044 y = list[1].toInt();
2041 w = list[2].toInt(); 2045 w = list[2].toInt();
2042 h = list[3].toInt(); 2046 h = list[3].toInt();
2043 KApplication::testCoords( &x,&y,&w,&h ); 2047 KApplication::testCoords( &x,&y,&w,&h );
2044 mTodoEditor->setGeometry(x,y,w,h); 2048 mTodoEditor->setGeometry(x,y,w,h);
2045 2049
2046 } 2050 }
2047 list = config->readListEntry("ViewerLayout"); 2051 list = config->readListEntry("ViewerLayout");
2048 if ( ! list.isEmpty() ) { 2052 if ( ! list.isEmpty() ) {
2049 x = list[0].toInt(); 2053 x = list[0].toInt();
2050 y = list[1].toInt(); 2054 y = list[1].toInt();
2051 w = list[2].toInt(); 2055 w = list[2].toInt();
2052 h = list[3].toInt(); 2056 h = list[3].toInt();
2053 KApplication::testCoords( &x,&y,&w,&h ); 2057 KApplication::testCoords( &x,&y,&w,&h );
2054 getEventViewerDialog()->setGeometry(x,y,w,h); 2058 getEventViewerDialog()->setGeometry(x,y,w,h);
2055 } 2059 }
2056#endif 2060#endif
2057 config->setGroup( "Views" ); 2061 config->setGroup( "Views" );
2058 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2062 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2059 2063
2060 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2064 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2061 2065
2062 int resetval = 0; 2066 int resetval = 0;
2063 int maxVal = 0; 2067 int maxVal = 0;
2064 if (sizes.count() != 3) { 2068 if (sizes.count() != 3) {
2065 if ( KOPrefs::instance()->mVerticalScreen ) { 2069 if ( KOPrefs::instance()->mVerticalScreen ) {
2066 resetval = mDateNavigator->sizeHint().width()+2; 2070 resetval = mDateNavigator->sizeHint().width()+2;
2067 } else { 2071 } else {
2068 resetval = mDateNavigator->sizeHint().height()+2; 2072 resetval = mDateNavigator->sizeHint().height()+2;
2069 } 2073 }
2070 } 2074 }
2071 if ( resetval ) { 2075 if ( resetval ) {
2072 sizes.clear(); 2076 sizes.clear();
2073 if ( KOPrefs::instance()->mVerticalScreen ) { 2077 if ( KOPrefs::instance()->mVerticalScreen ) {
2074 maxVal = QApplication::desktop()->width() -10; 2078 maxVal = QApplication::desktop()->width() -10;
2075 } else { 2079 } else {
2076 maxVal = QApplication::desktop()->height()-10; 2080 maxVal = QApplication::desktop()->height()-10;
2077 } 2081 }
2078 sizes << resetval; 2082 sizes << resetval;
2079 if ( maxVal < resetval + resetval) 2083 if ( maxVal < resetval + resetval)
2080 resetval = maxVal - resetval; 2084 resetval = maxVal - resetval;
2081 sizes << resetval; 2085 sizes << resetval;
2082 sizes << 100; 2086 sizes << 100;
2083 } 2087 }
2084 mLeftFrame->setSizes(sizes); 2088 mLeftFrame->setSizes(sizes);
2085 sizes = config->readIntListEntry("Main Splitter Frame"); 2089 sizes = config->readIntListEntry("Main Splitter Frame");
2086 resetval = 0; 2090 resetval = 0;
2087 maxVal = 0; 2091 maxVal = 0;
2088 if (sizes.count() != 2) { 2092 if (sizes.count() != 2) {
2089 if ( !KOPrefs::instance()->mVerticalScreen ) { 2093 if ( !KOPrefs::instance()->mVerticalScreen ) {
2090 resetval = mDateNavigator->sizeHint().width()+2; 2094 resetval = mDateNavigator->sizeHint().width()+2;
2091 } else { 2095 } else {
2092 resetval = mDateNavigator->sizeHint().height()+2; 2096 resetval = mDateNavigator->sizeHint().height()+2;
2093 } 2097 }
2094 } 2098 }
2095 if ( resetval ) { 2099 if ( resetval ) {
2096 sizes.clear(); 2100 sizes.clear();
2097 if ( !KOPrefs::instance()->mVerticalScreen ) { 2101 if ( !KOPrefs::instance()->mVerticalScreen ) {
2098 maxVal = QApplication::desktop()->width() -10; 2102 maxVal = QApplication::desktop()->width() -10;
2099 } else { 2103 } else {
2100 maxVal = QApplication::desktop()->height()-10; 2104 maxVal = QApplication::desktop()->height()-10;
2101 } 2105 }
2102 sizes << resetval; 2106 sizes << resetval;
2103 if ( maxVal < resetval + resetval) 2107 if ( maxVal < resetval + resetval)
2104 resetval = maxVal - resetval; 2108 resetval = maxVal - resetval;
2105 sizes << resetval; 2109 sizes << resetval;
2106 } 2110 }
2107 mMainFrame->setSizes(sizes); 2111 mMainFrame->setSizes(sizes);
2108 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2112 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2109 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2113 else if ( dateCount == 7 ) mNavigator->selectWeek();
2110 else mNavigator->selectDates( dateCount ); 2114 else mNavigator->selectDates( dateCount );
2111 // mViewManager->readSettings( config ); 2115 // mViewManager->readSettings( config );
2112 updateConfig(); 2116 updateConfig();
2113 globalFlagBlockAgenda = 2; 2117 globalFlagBlockAgenda = 2;
2114 mViewManager->readSettings( config ); 2118 mViewManager->readSettings( config );
2115 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2119 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2116} 2120}
2117 2121
2118 2122
2119void CalendarView::writeSettings() 2123void CalendarView::writeSettings()
2120{ 2124{
2121 // kdDebug() << "CalendarView::writeSettings" << endl; 2125 // kdDebug() << "CalendarView::writeSettings" << endl;
2122 2126
2123 KConfig *config = KOGlobals::config(); 2127 KConfig *config = KOGlobals::config();
2124 2128
2125 mViewManager->writeSettings( config ); 2129 mViewManager->writeSettings( config );
2126 mTodoList->saveLayout(config,QString("Todo Layout")); 2130 mTodoList->saveLayout(config,QString("Todo Layout"));
2127 mDialogManager->writeSettings( config ); 2131 mDialogManager->writeSettings( config );
2128 //KOPrefs::instance()->usrWriteConfig(); 2132 //KOPrefs::instance()->usrWriteConfig();
2129 KOPrefs::instance()->writeConfig(); 2133 KOPrefs::instance()->writeConfig();
2130 2134
2131 writeFilterSettings(config); 2135 writeFilterSettings(config);
2132 config->setGroup( "AppRun" ); 2136 config->setGroup( "AppRun" );
2133 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2137 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2134 config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); 2138 config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) );
2135 config->setGroup( "Views" ); 2139 config->setGroup( "Views" );
2136 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2140 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2137 2141
2138 QValueList<int> listINT = mLeftFrame->sizes(); 2142 QValueList<int> listINT = mLeftFrame->sizes();
2139 config->writeEntry("Left Splitter Frame",listINT); 2143 config->writeEntry("Left Splitter Frame",listINT);
2140 QValueList<int> listINT2 = mMainFrame->sizes(); 2144 QValueList<int> listINT2 = mMainFrame->sizes();
2141 config->writeEntry("Main Splitter Frame",listINT2); 2145 config->writeEntry("Main Splitter Frame",listINT2);
2142#ifdef DESKTOP_VERSION 2146#ifdef DESKTOP_VERSION
2143 config->setGroup("WidgetLayout"); 2147 config->setGroup("WidgetLayout");
2144 QStringList list ;//= config->readListEntry("MainLayout"); 2148 QStringList list ;//= config->readListEntry("MainLayout");
2145 int x,y,w,h; 2149 int x,y,w,h;
2146 QWidget* wid; 2150 QWidget* wid;
2147 wid = topLevelWidget(); 2151 wid = topLevelWidget();
2148 x = wid->geometry().x(); 2152 x = wid->geometry().x();
2149 y = wid->geometry().y(); 2153 y = wid->geometry().y();
2150 w = wid->width(); 2154 w = wid->width();
2151 h = wid->height(); 2155 h = wid->height();
2152 list.clear(); 2156 list.clear();
2153 list << QString::number( x ); 2157 list << QString::number( x );
2154 list << QString::number( y ); 2158 list << QString::number( y );
2155 list << QString::number( w ); 2159 list << QString::number( w );
2156 list << QString::number( h ); 2160 list << QString::number( h );
2157 config->writeEntry("MainLayout",list ); 2161 config->writeEntry("MainLayout",list );
2158 2162
2159 wid = mEventEditor; 2163 wid = mEventEditor;
2160 x = wid->geometry().x(); 2164 x = wid->geometry().x();
2161 y = wid->geometry().y(); 2165 y = wid->geometry().y();
2162 w = wid->width(); 2166 w = wid->width();
2163 h = wid->height(); 2167 h = wid->height();
2164 list.clear(); 2168 list.clear();
2165 list << QString::number( x ); 2169 list << QString::number( x );
2166 list << QString::number( y ); 2170 list << QString::number( y );
2167 list << QString::number( w ); 2171 list << QString::number( w );
2168 list << QString::number( h ); 2172 list << QString::number( h );
2169 config->writeEntry("EditEventLayout",list ); 2173 config->writeEntry("EditEventLayout",list );
2170 2174
2171 wid = mTodoEditor; 2175 wid = mTodoEditor;
2172 x = wid->geometry().x(); 2176 x = wid->geometry().x();
2173 y = wid->geometry().y(); 2177 y = wid->geometry().y();
2174 w = wid->width(); 2178 w = wid->width();
2175 h = wid->height(); 2179 h = wid->height();
2176 list.clear(); 2180 list.clear();
2177 list << QString::number( x ); 2181 list << QString::number( x );
2178 list << QString::number( y ); 2182 list << QString::number( y );
2179 list << QString::number( w ); 2183 list << QString::number( w );
2180 list << QString::number( h ); 2184 list << QString::number( h );
2181 config->writeEntry("EditTodoLayout",list ); 2185 config->writeEntry("EditTodoLayout",list );
2182 wid = getEventViewerDialog(); 2186 wid = getEventViewerDialog();
2183 x = wid->geometry().x(); 2187 x = wid->geometry().x();
2184 y = wid->geometry().y(); 2188 y = wid->geometry().y();
2185 w = wid->width(); 2189 w = wid->width();
2186 h = wid->height(); 2190 h = wid->height();
2187 list.clear(); 2191 list.clear();
2188 list << QString::number( x ); 2192 list << QString::number( x );
2189 list << QString::number( y ); 2193 list << QString::number( y );
2190 list << QString::number( w ); 2194 list << QString::number( w );
2191 list << QString::number( h ); 2195 list << QString::number( h );
2192 config->writeEntry("ViewerLayout",list ); 2196 config->writeEntry("ViewerLayout",list );
2193 wid = mDialogManager->getSearchDialog(); 2197 wid = mDialogManager->getSearchDialog();
2194 if ( wid ) { 2198 if ( wid ) {
2195 x = wid->geometry().x(); 2199 x = wid->geometry().x();
2196 y = wid->geometry().y(); 2200 y = wid->geometry().y();
2197 w = wid->width(); 2201 w = wid->width();
2198 h = wid->height(); 2202 h = wid->height();
2199 list.clear(); 2203 list.clear();
2200 list << QString::number( x ); 2204 list << QString::number( x );
2201 list << QString::number( y ); 2205 list << QString::number( y );
2202 list << QString::number( w ); 2206 list << QString::number( w );
2203 list << QString::number( h ); 2207 list << QString::number( h );
2204 config->writeEntry("SearchLayout",list ); 2208 config->writeEntry("SearchLayout",list );
2205 } 2209 }
2206#endif 2210#endif
2207 2211
2208 2212
2209 config->sync(); 2213 config->sync();
2210} 2214}
2211 2215
2212void CalendarView::readFilterSettings(KConfig *config) 2216void CalendarView::readFilterSettings(KConfig *config)
2213{ 2217{
2214 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2218 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2215 2219
2216 mFilters.clear(); 2220 mFilters.clear();
2217 2221
2218 config->setGroup("General"); 2222 config->setGroup("General");
2219 QStringList filterList = config->readListEntry("CalendarFilters"); 2223 QStringList filterList = config->readListEntry("CalendarFilters");
2220 2224
2221 QStringList::ConstIterator it = filterList.begin(); 2225 QStringList::ConstIterator it = filterList.begin();
2222 QStringList::ConstIterator end = filterList.end(); 2226 QStringList::ConstIterator end = filterList.end();
2223 while(it != end) { 2227 while(it != end) {
2224 // kdDebug() << " filter: " << (*it) << endl; 2228 // kdDebug() << " filter: " << (*it) << endl;
2225 2229
2226 CalFilter *filter; 2230 CalFilter *filter;
2227 filter = new CalFilter(*it); 2231 filter = new CalFilter(*it);
2228 config->setGroup("Filter_" + (*it).utf8()); 2232 config->setGroup("Filter_" + (*it).utf8());
2229 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2233 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2230 filter->setCriteria(config->readNumEntry("Criteria",0)); 2234 filter->setCriteria(config->readNumEntry("Criteria",0));
2231 filter->setCategoryList(config->readListEntry("CategoryList")); 2235 filter->setCategoryList(config->readListEntry("CategoryList"));
2232 mFilters.append(filter); 2236 mFilters.append(filter);
2233 2237
2234 ++it; 2238 ++it;
2235 } 2239 }
2236 2240
2237 if (mFilters.count() == 0) { 2241 if (mFilters.count() == 0) {
2238 CalFilter *filter = new CalFilter(i18n("Default")); 2242 CalFilter *filter = new CalFilter(i18n("Default"));
2239 mFilters.append(filter); 2243 mFilters.append(filter);
2240 } 2244 }
2241 mFilterView->updateFilters(); 2245 mFilterView->updateFilters();
2242 config->setGroup("FilterView"); 2246 config->setGroup("FilterView");
2243 2247
2244 mFilterView->blockSignals(true); 2248 mFilterView->blockSignals(true);
2245 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2249 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2246 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2250 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2247 mFilterView->blockSignals(false); 2251 mFilterView->blockSignals(false);
2248 // We do it manually to avoid it being done twice by the above calls 2252 // We do it manually to avoid it being done twice by the above calls
2249 updateFilter(); 2253 updateFilter();
2250} 2254}
2251 2255
2252void CalendarView::writeFilterSettings(KConfig *config) 2256void CalendarView::writeFilterSettings(KConfig *config)
2253{ 2257{
2254 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2258 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2255 2259
2256 QStringList filterList; 2260 QStringList filterList;
2257 2261
2258 CalFilter *filter = mFilters.first(); 2262 CalFilter *filter = mFilters.first();
2259 while(filter) { 2263 while(filter) {
2260 // kdDebug() << " fn: " << filter->name() << endl; 2264 // kdDebug() << " fn: " << filter->name() << endl;
2261 filterList << filter->name(); 2265 filterList << filter->name();
2262 config->setGroup("Filter_" + filter->name().utf8()); 2266 config->setGroup("Filter_" + filter->name().utf8());
2263 config->writeEntry("Criteria",filter->criteria()); 2267 config->writeEntry("Criteria",filter->criteria());
2264 config->writeEntry("CategoryList",filter->categoryList()); 2268 config->writeEntry("CategoryList",filter->categoryList());
2265 filter = mFilters.next(); 2269 filter = mFilters.next();
2266 } 2270 }
2267 config->setGroup("General"); 2271 config->setGroup("General");
2268 config->writeEntry("CalendarFilters",filterList); 2272 config->writeEntry("CalendarFilters",filterList);
2269 2273
2270 config->setGroup("FilterView"); 2274 config->setGroup("FilterView");
2271 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2275 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2272 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2276 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2273} 2277}
2274 2278
2275 2279
2276void CalendarView::goToday() 2280void CalendarView::goToday()
2277{ 2281{
2278 if ( mViewManager->currentView()->isMonthView() ) 2282 if ( mViewManager->currentView()->isMonthView() )
2279 mNavigator->selectTodayMonth(); 2283 mNavigator->selectTodayMonth();
2280 else 2284 else
2281 mNavigator->selectToday(); 2285 mNavigator->selectToday();
2282} 2286}
2283 2287
2284void CalendarView::goNext() 2288void CalendarView::goNext()
2285{ 2289{
2286 mNavigator->selectNext(); 2290 mNavigator->selectNext();
2287} 2291}
2288 2292
2289void CalendarView::goPrevious() 2293void CalendarView::goPrevious()
2290{ 2294{
2291 mNavigator->selectPrevious(); 2295 mNavigator->selectPrevious();
2292} 2296}
2293void CalendarView::goNextMonth() 2297void CalendarView::goNextMonth()
2294{ 2298{
2295 mNavigator->selectNextMonth(); 2299 mNavigator->selectNextMonth();
2296} 2300}
2297 2301
2298void CalendarView::goPreviousMonth() 2302void CalendarView::goPreviousMonth()
2299{ 2303{
2300 mNavigator->selectPreviousMonth(); 2304 mNavigator->selectPreviousMonth();
2301} 2305}
2302void CalendarView::writeLocale() 2306void CalendarView::writeLocale()
2303{ 2307{
2304 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2308 //KPimGlobalPrefs::instance()->setGlobalConfig();
2305#if 0 2309#if 0
2306 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2310 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2307 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2311 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2308 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2312 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2309 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2313 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2310 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2314 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2311 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2315 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2312 dummy = KOPrefs::instance()->mUserDateFormatShort; 2316 dummy = KOPrefs::instance()->mUserDateFormatShort;
2313 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2317 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2314 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2318 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2315 KOPrefs::instance()->mDaylightsavingStart, 2319 KOPrefs::instance()->mDaylightsavingStart,
2316 KOPrefs::instance()->mDaylightsavingEnd ); 2320 KOPrefs::instance()->mDaylightsavingEnd );
2317 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2321 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2318#endif 2322#endif
2319} 2323}
2320void CalendarView::updateConfig() 2324void CalendarView::updateConfig()
2321{ 2325{
2322 writeLocale(); 2326 writeLocale();
2323 if ( KOPrefs::instance()->mUseAppColors ) 2327 if ( KOPrefs::instance()->mUseAppColors )
2324 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2328 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2325 emit configChanged(); 2329 emit configChanged();
2326 mTodoList->updateConfig(); 2330 mTodoList->updateConfig();
2327 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2331 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2328 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2332 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2329 // To make the "fill window" configurations work 2333 // To make the "fill window" configurations work
2330 //mViewManager->raiseCurrentView(); 2334 //mViewManager->raiseCurrentView();
2331} 2335}
2332 2336
2333 2337
2334void CalendarView::eventChanged(Event *event) 2338void CalendarView::eventChanged(Event *event)
2335{ 2339{
2336 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2340 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2337 //updateUnmanagedViews(); 2341 //updateUnmanagedViews();
2338} 2342}
2339 2343
2340void CalendarView::eventAdded(Event *event) 2344void CalendarView::eventAdded(Event *event)
2341{ 2345{
2342 changeEventDisplay(event,KOGlobals::EVENTADDED); 2346 changeEventDisplay(event,KOGlobals::EVENTADDED);
2343} 2347}
2344 2348
2345void CalendarView::eventToBeDeleted(Event *) 2349void CalendarView::eventToBeDeleted(Event *)
2346{ 2350{
2347 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2351 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2348} 2352}
2349 2353
2350void CalendarView::eventDeleted() 2354void CalendarView::eventDeleted()
2351{ 2355{
2352 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2356 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2353} 2357}
2354void CalendarView::changeTodoDisplay(Todo *which, int action) 2358void CalendarView::changeTodoDisplay(Todo *which, int action)
2355{ 2359{
2356 changeIncidenceDisplay((Incidence *)which, action); 2360 changeIncidenceDisplay((Incidence *)which, action);
2357 mDateNavigator->updateView(); //LR 2361 mDateNavigator->updateView(); //LR
2358 //mDialogManager->updateSearchDialog(); 2362 //mDialogManager->updateSearchDialog();
2359 2363
2360 if (which) { 2364 if (which) {
2361 mViewManager->updateWNview(); 2365 mViewManager->updateWNview();
2362 //mTodoList->updateView(); 2366 //mTodoList->updateView();
2363 } 2367 }
2364 2368
2365} 2369}
2366 2370
2367void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2371void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2368{ 2372{
2369 updateUnmanagedViews(); 2373 updateUnmanagedViews();
2370 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2374 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2371 if ( action == KOGlobals::EVENTDELETED ) { //delete 2375 if ( action == KOGlobals::EVENTDELETED ) { //delete
2372 mCalendar->checkAlarmForIncidence( 0, true ); 2376 mCalendar->checkAlarmForIncidence( 0, true );
2373 if ( mEventViewerDialog ) 2377 if ( mEventViewerDialog )
2374 mEventViewerDialog->hide(); 2378 mEventViewerDialog->hide();
2375 } 2379 }
2376 else 2380 else
2377 mCalendar->checkAlarmForIncidence( which , false ); 2381 mCalendar->checkAlarmForIncidence( which , false );
2378} 2382}
2379 2383
2380// most of the changeEventDisplays() right now just call the view's 2384// most of the changeEventDisplays() right now just call the view's
2381// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2385// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2382void CalendarView::changeEventDisplay(Event *which, int action) 2386void CalendarView::changeEventDisplay(Event *which, int action)
2383{ 2387{
2384 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2388 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2385 changeIncidenceDisplay((Incidence *)which, action); 2389 changeIncidenceDisplay((Incidence *)which, action);
2386 mDateNavigator->updateView(); 2390 mDateNavigator->updateView();
2387 //mDialogManager->updateSearchDialog(); 2391 //mDialogManager->updateSearchDialog();
2388 2392
2389 if (which) { 2393 if (which) {
2390 // If there is an event view visible update the display 2394 // If there is an event view visible update the display
2391 mViewManager->currentView()->changeEventDisplay(which,action); 2395 mViewManager->currentView()->changeEventDisplay(which,action);
2392 // TODO: check, if update needed 2396 // TODO: check, if update needed
2393 // if (which->getTodoStatus()) { 2397 // if (which->getTodoStatus()) {
2394 mTodoList->updateView(); 2398 mTodoList->updateView();
2395 // } 2399 // }
2396 } else { 2400 } else {
2397 mViewManager->currentView()->updateView(); 2401 mViewManager->currentView()->updateView();
2398 } 2402 }
2399} 2403}
2400 2404
2401 2405
2402void CalendarView::updateTodoViews() 2406void CalendarView::updateTodoViews()
2403{ 2407{
2404 mTodoList->updateView(); 2408 mTodoList->updateView();
2405 mViewManager->currentView()->updateView(); 2409 mViewManager->currentView()->updateView();
2406 2410
2407} 2411}
2408 2412
2409 2413
2410void CalendarView::updateView(const QDate &start, const QDate &end) 2414void CalendarView::updateView(const QDate &start, const QDate &end)
2411{ 2415{
2412 mTodoList->updateView(); 2416 mTodoList->updateView();
2413 mViewManager->updateView(start, end); 2417 mViewManager->updateView(start, end);
2414 //mDateNavigator->updateView(); 2418 //mDateNavigator->updateView();
2415} 2419}
2416 2420
2417void CalendarView::updateView() 2421void CalendarView::updateView()
2418{ 2422{
2419 DateList tmpList = mNavigator->selectedDates(); 2423 DateList tmpList = mNavigator->selectedDates();
2420 2424
2421 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2425 if ( KOPrefs::instance()->mHideNonStartedTodos )
2422 mTodoList->updateView(); 2426 mTodoList->updateView();
2423 // We assume that the navigator only selects consecutive days. 2427 // We assume that the navigator only selects consecutive days.
2424 updateView( tmpList.first(), tmpList.last() ); 2428 updateView( tmpList.first(), tmpList.last() );
2425} 2429}
2426 2430
2427void CalendarView::updateUnmanagedViews() 2431void CalendarView::updateUnmanagedViews()
2428{ 2432{
2429 mDateNavigator->updateDayMatrix(); 2433 mDateNavigator->updateDayMatrix();
2430} 2434}
2431 2435
2432int CalendarView::msgItemDelete(const QString name) 2436int CalendarView::msgItemDelete(const QString name)
2433{ 2437{
2434 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2438 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2435 i18n("This item will be\npermanently deleted."), 2439 i18n("This item will be\npermanently deleted."),
2436 i18n("KO/Pi Confirmation"),i18n("Delete")); 2440 i18n("KO/Pi Confirmation"),i18n("Delete"));
2437} 2441}
2438 2442
2439 2443
2440void CalendarView::edit_cut() 2444void CalendarView::edit_cut()
2441{ 2445{
2442 Event *anEvent=0; 2446 Event *anEvent=0;
2443 2447
2444 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2448 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2445 2449
2446 if (mViewManager->currentView()->isEventView()) { 2450 if (mViewManager->currentView()->isEventView()) {
2447 if ( incidence && incidence->type() == "Event" ) { 2451 if ( incidence && incidence->type() == "Event" ) {
2448 anEvent = static_cast<Event *>(incidence); 2452 anEvent = static_cast<Event *>(incidence);
2449 } 2453 }
2450 } 2454 }
2451 2455
2452 if (!anEvent) { 2456 if (!anEvent) {
2453 KNotifyClient::beep(); 2457 KNotifyClient::beep();
2454 return; 2458 return;
2455 } 2459 }
2456 DndFactory factory( mCalendar ); 2460 DndFactory factory( mCalendar );
2457 factory.cutIncidence(anEvent); 2461 factory.cutIncidence(anEvent);
2458 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2462 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2459} 2463}
2460 2464
2461void CalendarView::edit_copy() 2465void CalendarView::edit_copy()
2462{ 2466{
2463 Event *anEvent=0; 2467 Event *anEvent=0;
2464 2468
2465 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2469 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2466 2470
2467 if (mViewManager->currentView()->isEventView()) { 2471 if (mViewManager->currentView()->isEventView()) {
2468 if ( incidence && incidence->type() == "Event" ) { 2472 if ( incidence && incidence->type() == "Event" ) {
2469 anEvent = static_cast<Event *>(incidence); 2473 anEvent = static_cast<Event *>(incidence);
2470 } 2474 }
2471 } 2475 }
2472 2476
2473 if (!anEvent) { 2477 if (!anEvent) {
2474 KNotifyClient::beep(); 2478 KNotifyClient::beep();
2475 return; 2479 return;
2476 } 2480 }
2477 DndFactory factory( mCalendar ); 2481 DndFactory factory( mCalendar );
2478 factory.copyIncidence(anEvent); 2482 factory.copyIncidence(anEvent);
2479} 2483}
2480 2484
2481void CalendarView::edit_paste() 2485void CalendarView::edit_paste()
2482{ 2486{
2483 QDate date = mNavigator->selectedDates().first(); 2487 QDate date = mNavigator->selectedDates().first();
2484 2488
2485 DndFactory factory( mCalendar ); 2489 DndFactory factory( mCalendar );
2486 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2490 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2487 2491
2488 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2492 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2489} 2493}
2490 2494
2491void CalendarView::edit_options() 2495void CalendarView::edit_options()
2492{ 2496{
2493 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2497 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2494 emit save(); 2498 emit save();
2495 emit saveStopTimer(); 2499 emit saveStopTimer();
2496 mDialogManager->showOptionsDialog(); 2500 mDialogManager->showOptionsDialog();
2497 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2501 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2498 emit saveStopTimer(); 2502 emit saveStopTimer();
2499 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2503 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2500 i18n("Timezone settings"),i18n("Reload"))) { 2504 i18n("Timezone settings"),i18n("Reload"))) {
2501 qDebug("KO: TZ reload cancelled "); 2505 qDebug("KO: TZ reload cancelled ");
2502 return; 2506 return;
2503 } 2507 }
2504 qDebug("KO: Timezone change "); 2508 qDebug("KO: Timezone change ");
2505 openCalendar( MainWindow::defaultFileName() ); 2509 openCalendar( MainWindow::defaultFileName() );
2506 setModified(true); 2510 setModified(true);
2507 } 2511 }
2508 else 2512 else
2509 qDebug("KO: No tz change "); 2513 qDebug("KO: No tz change ");
2510 2514
2511} 2515}
2512 2516
2513 2517
2514void CalendarView::slotSelectPickerDate( QDate d) 2518void CalendarView::slotSelectPickerDate( QDate d)
2515{ 2519{
2516 mDateFrame->hide(); 2520 mDateFrame->hide();
2517 if ( mDatePickerMode == 1 ) { 2521 if ( mDatePickerMode == 1 ) {
2518 mNavigator->slotDaySelect( d ); 2522 mNavigator->slotDaySelect( d );
2519 } else if ( mDatePickerMode == 2 ) { 2523 } else if ( mDatePickerMode == 2 ) {
2520 if ( mMoveIncidence->type() == "Todo" ) { 2524 if ( mMoveIncidence->type() == "Todo" ) {
2521 Todo * to = (Todo *) mMoveIncidence; 2525 Todo * to = (Todo *) mMoveIncidence;
2522 QTime tim; 2526 QTime tim;
2523 int len = 0; 2527 int len = 0;
2524 if ( to->hasStartDate() && to->hasDueDate() ) 2528 if ( to->hasStartDate() && to->hasDueDate() )
2525 len = to->dtStart().secsTo( to->dtDue()); 2529 len = to->dtStart().secsTo( to->dtDue());
2526 if ( to->hasDueDate() ) 2530 if ( to->hasDueDate() )
2527 tim = to->dtDue().time(); 2531 tim = to->dtDue().time();
2528 else { 2532 else {
2529 tim = QTime ( 0,0,0 ); 2533 tim = QTime ( 0,0,0 );
2530 to->setFloats( true ); 2534 to->setFloats( true );
2531 to->setHasDueDate( true ); 2535 to->setHasDueDate( true );
2532 } 2536 }
2533 QDateTime dt ( d,tim ); 2537 QDateTime dt ( d,tim );
2534 to->setDtDue( dt ); 2538 to->setDtDue( dt );
2535 2539
2536 if ( to->hasStartDate() ) { 2540 if ( to->hasStartDate() ) {
2537 if ( len>0 ) 2541 if ( len>0 )
2538 to->setDtStart(to->dtDue().addSecs( -len )); 2542 to->setDtStart(to->dtDue().addSecs( -len ));
2539 else 2543 else
2540 if (to->dtStart() > to->dtDue() ) 2544 if (to->dtStart() > to->dtDue() )
2541 to->setDtStart(to->dtDue().addDays( -3 )); 2545 to->setDtStart(to->dtDue().addDays( -3 ));
2542 } 2546 }
2543 2547
2544 todoChanged( to ); 2548 todoChanged( to );
2545 } else { 2549 } else {
2546 if ( mMoveIncidence->doesRecur() ) { 2550 if ( mMoveIncidence->doesRecur() ) {
2547#if 0 2551#if 0
2548 // PENDING implement this 2552 // PENDING implement this
2549 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2553 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2550 mCalendar()->addIncidence( newInc ); 2554 mCalendar()->addIncidence( newInc );
2551 if ( mMoveIncidence->type() == "Todo" ) 2555 if ( mMoveIncidence->type() == "Todo" )
2552 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2556 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2553 else 2557 else
2554 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2558 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2555 mMoveIncidence = newInc; 2559 mMoveIncidence = newInc;
2556 2560
2557#endif 2561#endif
2558 } 2562 }
2559 QTime tim = mMoveIncidence->dtStart().time(); 2563 QTime tim = mMoveIncidence->dtStart().time();
2560 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2564 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2561 QDateTime dt ( d,tim ); 2565 QDateTime dt ( d,tim );
2562 mMoveIncidence->setDtStart( dt ); 2566 mMoveIncidence->setDtStart( dt );
2563 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2567 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2564 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2568 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2565 } 2569 }
2566 2570
2567 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2571 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2568 } 2572 }
2569} 2573}
2570 2574
2571void CalendarView::removeCategories() 2575void CalendarView::removeCategories()
2572{ 2576{
2573 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2577 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2574 QStringList catList = KOPrefs::instance()->mCustomCategories; 2578 QStringList catList = KOPrefs::instance()->mCustomCategories;
2575 QStringList catIncList; 2579 QStringList catIncList;
2576 QStringList newCatList; 2580 QStringList newCatList;
2577 Incidence* inc = incList.first(); 2581 Incidence* inc = incList.first();
2578 int i; 2582 int i;
2579 int count = 0; 2583 int count = 0;
2580 while ( inc ) { 2584 while ( inc ) {
2581 newCatList.clear(); 2585 newCatList.clear();
2582 catIncList = inc->categories() ; 2586 catIncList = inc->categories() ;
2583 for( i = 0; i< catIncList.count(); ++i ) { 2587 for( i = 0; i< catIncList.count(); ++i ) {
2584 if ( catList.contains (catIncList[i])) 2588 if ( catList.contains (catIncList[i]))
2585 newCatList.append( catIncList[i] ); 2589 newCatList.append( catIncList[i] );
2586 } 2590 }
2587 newCatList.sort(); 2591 newCatList.sort();
2588 inc->setCategories( newCatList.join(",") ); 2592 inc->setCategories( newCatList.join(",") );
2589 inc = incList.next(); 2593 inc = incList.next();
2590 } 2594 }
2591} 2595}
2592 2596
2593int CalendarView::addCategories() 2597int CalendarView::addCategories()
2594{ 2598{
2595 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2599 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2596 QStringList catList = KOPrefs::instance()->mCustomCategories; 2600 QStringList catList = KOPrefs::instance()->mCustomCategories;
2597 QStringList catIncList; 2601 QStringList catIncList;
2598 Incidence* inc = incList.first(); 2602 Incidence* inc = incList.first();
2599 int i; 2603 int i;
2600 int count = 0; 2604 int count = 0;
2601 while ( inc ) { 2605 while ( inc ) {
2602 catIncList = inc->categories() ; 2606 catIncList = inc->categories() ;
2603 for( i = 0; i< catIncList.count(); ++i ) { 2607 for( i = 0; i< catIncList.count(); ++i ) {
2604 if ( !catList.contains (catIncList[i])) { 2608 if ( !catList.contains (catIncList[i])) {
2605 catList.append( catIncList[i] ); 2609 catList.append( catIncList[i] );
2606 //qDebug("add cat %s ", catIncList[i].latin1()); 2610 //qDebug("add cat %s ", catIncList[i].latin1());
2607 ++count; 2611 ++count;
2608 } 2612 }
2609 } 2613 }
2610 inc = incList.next(); 2614 inc = incList.next();
2611 } 2615 }
2612 catList.sort(); 2616 catList.sort();
2613 KOPrefs::instance()->mCustomCategories = catList; 2617 KOPrefs::instance()->mCustomCategories = catList;
2614 return count; 2618 return count;
2615} 2619}
2616 2620
2617void CalendarView::manageCategories() 2621void CalendarView::manageCategories()
2618{ 2622{
2619 KOCatPrefs* cp = new KOCatPrefs(); 2623 KOCatPrefs* cp = new KOCatPrefs();
2620 cp->show(); 2624 cp->show();
2621 int w =cp->sizeHint().width() ; 2625 int w =cp->sizeHint().width() ;
2622 int h = cp->sizeHint().height() ; 2626 int h = cp->sizeHint().height() ;
2623 int dw = QApplication::desktop()->width(); 2627 int dw = QApplication::desktop()->width();
2624 int dh = QApplication::desktop()->height(); 2628 int dh = QApplication::desktop()->height();
2625 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2629 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2626 if ( !cp->exec() ) { 2630 if ( !cp->exec() ) {
2627 delete cp; 2631 delete cp;
2628 return; 2632 return;
2629 } 2633 }
2630 int count = 0; 2634 int count = 0;
2631 if ( cp->addCat() ) { 2635 if ( cp->addCat() ) {
2632 count = addCategories(); 2636 count = addCategories();
2633 if ( count ) { 2637 if ( count ) {
2634 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2638 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2635 writeSettings(); 2639 writeSettings();
2636 } else 2640 } else
2637 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2641 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2638 } else { 2642 } else {
2639 removeCategories(); 2643 removeCategories();
2640 updateView(); 2644 updateView();
2641 } 2645 }
2642 delete cp; 2646 delete cp;
2643} 2647}
2644 2648
2645void CalendarView::beamIncidence(Incidence * Inc) 2649void CalendarView::beamIncidence(Incidence * Inc)
2646{ 2650{
2647 QPtrList<Incidence> delSel ; 2651 QPtrList<Incidence> delSel ;
2648 delSel.append(Inc); 2652 delSel.append(Inc);
2649 beamIncidenceList( delSel ); 2653 beamIncidenceList( delSel );
2650} 2654}
2651void CalendarView::beamCalendar() 2655void CalendarView::beamCalendar()
2652{ 2656{
2653 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2657 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2654 //qDebug("beamCalendar() "); 2658 //qDebug("beamCalendar() ");
2655 beamIncidenceList( delSel ); 2659 beamIncidenceList( delSel );
2656} 2660}
2657void CalendarView::beamFilteredCalendar() 2661void CalendarView::beamFilteredCalendar()
2658{ 2662{
2659 QPtrList<Incidence> delSel = mCalendar->incidences(); 2663 QPtrList<Incidence> delSel = mCalendar->incidences();
2660 //qDebug("beamFilteredCalendar() "); 2664 //qDebug("beamFilteredCalendar() ");
2661 beamIncidenceList( delSel ); 2665 beamIncidenceList( delSel );
2662} 2666}
2663void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2667void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2664{ 2668{
2665 if ( beamDialog->exec () == QDialog::Rejected ) 2669 if ( beamDialog->exec () == QDialog::Rejected )
2666 return; 2670 return;
2667#ifdef DESKTOP_VERSION 2671#ifdef DESKTOP_VERSION
2668 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2672 QString fn = locateLocal( "tmp", "kopibeamfile" );
2669#else 2673#else
2670 QString fn = "/tmp/kopibeamfile"; 2674 QString fn = "/tmp/kopibeamfile";
2671#endif 2675#endif
2672 QString mes; 2676 QString mes;
2673 bool createbup = true; 2677 bool createbup = true;
2674 if ( createbup ) { 2678 if ( createbup ) {
2675 QString description = "\n"; 2679 QString description = "\n";
2676 CalendarLocal* cal = new CalendarLocal(); 2680 CalendarLocal* cal = new CalendarLocal();
2677 if ( beamDialog->beamLocal() ) 2681 if ( beamDialog->beamLocal() )
2678 cal->setLocalTime(); 2682 cal->setLocalTime();
2679 else 2683 else
2680 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2684 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2681 Incidence *incidence = delSel.first(); 2685 Incidence *incidence = delSel.first();
2682 bool addText = false; 2686 bool addText = false;
2683 if ( delSel.count() < 10 ) 2687 if ( delSel.count() < 10 )
2684 addText = true; 2688 addText = true;
2685 else { 2689 else {
2686 description.sprintf(i18n(" %d items?"),delSel.count() ); 2690 description.sprintf(i18n(" %d items?"),delSel.count() );
2687 } 2691 }
2688 while ( incidence ) { 2692 while ( incidence ) {
2689 Incidence *in = incidence->clone(); 2693 Incidence *in = incidence->clone();
2690 if ( ! in->summary().isEmpty() ) { 2694 if ( ! in->summary().isEmpty() ) {
2691 in->setDescription(""); 2695 in->setDescription("");
2692 } else { 2696 } else {
2693 in->setSummary( in->description().left(20)); 2697 in->setSummary( in->description().left(20));
2694 in->setDescription(""); 2698 in->setDescription("");
2695 } 2699 }
2696 if ( addText ) 2700 if ( addText )
2697 description += in->summary() + "\n"; 2701 description += in->summary() + "\n";
2698 cal->addIncidence( in ); 2702 cal->addIncidence( in );
2699 incidence = delSel.next(); 2703 incidence = delSel.next();
2700 } 2704 }
2701 if ( beamDialog->beamVcal() ) { 2705 if ( beamDialog->beamVcal() ) {
2702 fn += ".vcs"; 2706 fn += ".vcs";
2703 FileStorage storage( cal, fn, new VCalFormat ); 2707 FileStorage storage( cal, fn, new VCalFormat );
2704 storage.save(); 2708 storage.save();
2705 } else { 2709 } else {
2706 fn += ".ics"; 2710 fn += ".ics";
2707 FileStorage storage( cal, fn, new ICalFormat( ) ); 2711 FileStorage storage( cal, fn, new ICalFormat( ) );
2708 storage.save(); 2712 storage.save();
2709 } 2713 }
2710 delete cal; 2714 delete cal;
2711 mes = i18n("KO/Pi: Ready for beaming"); 2715 mes = i18n("KO/Pi: Ready for beaming");
2712 topLevelWidget()->setCaption(mes); 2716 topLevelWidget()->setCaption(mes);
2713 KApplication::convert2latin1( fn ); 2717 KApplication::convert2latin1( fn );
2714#ifndef DESKTOP_VERSION 2718#ifndef DESKTOP_VERSION
2715 Ir *ir = new Ir( this ); 2719 Ir *ir = new Ir( this );
2716 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2720 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2717 ir->send( fn, description, "text/x-vCalendar" ); 2721 ir->send( fn, description, "text/x-vCalendar" );
2718#endif 2722#endif
2719 } 2723 }
2720} 2724}
2721void CalendarView::beamDone( Ir *ir ) 2725void CalendarView::beamDone( Ir *ir )
2722{ 2726{
2723#ifndef DESKTOP_VERSION 2727#ifndef DESKTOP_VERSION
2724 delete ir; 2728 delete ir;
2725#endif 2729#endif
2726 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2730 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2727 topLevelWidget()->raise(); 2731 topLevelWidget()->raise();
2728} 2732}
2729 2733
2730void CalendarView::moveIncidence(Incidence * inc ) 2734void CalendarView::moveIncidence(Incidence * inc )
2731{ 2735{
2732 if ( !inc ) return; 2736 if ( !inc ) return;
2733 showDatePickerPopup(); 2737 showDatePickerPopup();
2734 mDatePickerMode = 2; 2738 mDatePickerMode = 2;
2735 mMoveIncidence = inc ; 2739 mMoveIncidence = inc ;
2736 QDate da; 2740 QDate da;
2737 if ( mMoveIncidence->type() == "Todo" ) { 2741 if ( mMoveIncidence->type() == "Todo" ) {
2738 Todo * to = (Todo *) mMoveIncidence; 2742 Todo * to = (Todo *) mMoveIncidence;
2739 if ( to->hasDueDate() ) 2743 if ( to->hasDueDate() )
2740 da = to->dtDue().date(); 2744 da = to->dtDue().date();
2741 else 2745 else
2742 da = QDate::currentDate(); 2746 da = QDate::currentDate();
2743 } else { 2747 } else {
2744 da = mMoveIncidence->dtStart().date(); 2748 da = mMoveIncidence->dtStart().date();
2745 } 2749 }
2746 //PENDING set date for recurring incidence to date of recurrence 2750 //PENDING set date for recurring incidence to date of recurrence
2747 //mMoveIncidenceOldDate; 2751 //mMoveIncidenceOldDate;
2748 mDatePicker->setDate( da ); 2752 mDatePicker->setDate( da );
2749} 2753}
2750void CalendarView::showDatePickerPopup() 2754void CalendarView::showDatePickerPopup()
2751{ 2755{
2752 if ( mDateFrame->isVisible() ) 2756 if ( mDateFrame->isVisible() )
2753 mDateFrame->hide(); 2757 mDateFrame->hide();
2754 else { 2758 else {
2755 int offX = 0, offY = 0; 2759 int offX = 0, offY = 0;
2756#ifdef DESKTOP_VERSION 2760#ifdef DESKTOP_VERSION
2757 int w =mDatePicker->sizeHint().width() ; 2761 int w =mDatePicker->sizeHint().width() ;
2758 int h = mDatePicker->sizeHint().height() ; 2762 int h = mDatePicker->sizeHint().height() ;
2759 int dw = topLevelWidget()->width(); 2763 int dw = topLevelWidget()->width();
2760 int dh = topLevelWidget()->height(); 2764 int dh = topLevelWidget()->height();
2761 offX = topLevelWidget()->x(); 2765 offX = topLevelWidget()->x();
2762 offY = topLevelWidget()->y(); 2766 offY = topLevelWidget()->y();
2763#else 2767#else
2764 int w =mDatePicker->sizeHint().width() ; 2768 int w =mDatePicker->sizeHint().width() ;
2765 int h = mDatePicker->sizeHint().height() ; 2769 int h = mDatePicker->sizeHint().height() ;
2766 int dw = QApplication::desktop()->width(); 2770 int dw = QApplication::desktop()->width();
2767 int dh = QApplication::desktop()->height(); 2771 int dh = QApplication::desktop()->height();
2768#endif 2772#endif
2769 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2773 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2770 mDateFrame->show(); 2774 mDateFrame->show();
2771 } 2775 }
2772} 2776}
2773void CalendarView::showDatePicker( ) 2777void CalendarView::showDatePicker( )
2774{ 2778{
2775 showDatePickerPopup(); 2779 showDatePickerPopup();
2776 mDatePickerMode = 1; 2780 mDatePickerMode = 1;
2777 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2781 mDatePicker->setDate( mNavigator->selectedDates().first() );
2778} 2782}
2779 2783
2780void CalendarView::showEventEditor() 2784void CalendarView::showEventEditor()
2781{ 2785{
2782#ifdef DESKTOP_VERSION 2786#ifdef DESKTOP_VERSION
2783 int x,y,w,h; 2787 int x,y,w,h;
2784 x = mEventEditor->geometry().x(); 2788 x = mEventEditor->geometry().x();
2785 y = mEventEditor->geometry().y(); 2789 y = mEventEditor->geometry().y();
2786 w = mEventEditor->width(); 2790 w = mEventEditor->width();
2787 h = mEventEditor->height(); 2791 h = mEventEditor->height();
2788 mEventEditor->show(); 2792 mEventEditor->show();
2789 mEventEditor->setGeometry(x,y,w,h); 2793 mEventEditor->setGeometry(x,y,w,h);
2790#else 2794#else
2791 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2795 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2792 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2796 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2793 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2797 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2794 qApp->processEvents(); 2798 qApp->processEvents();
2795 delete mEventEditor; 2799 delete mEventEditor;
2796 mEventEditor = mDialogManager->getEventEditor(); 2800 mEventEditor = mDialogManager->getEventEditor();
2797 topLevelWidget()->setCaption( i18n("") ); 2801 topLevelWidget()->setCaption( i18n("") );
2798 } 2802 }
2799 mEventEditor->showMaximized(); 2803 mEventEditor->showMaximized();
2800#endif 2804#endif
2801} 2805}
2802void CalendarView::showTodoEditor() 2806void CalendarView::showTodoEditor()
2803{ 2807{
2804#ifdef DESKTOP_VERSION 2808#ifdef DESKTOP_VERSION
2805 int x,y,w,h; 2809 int x,y,w,h;
2806 x = mTodoEditor->geometry().x(); 2810 x = mTodoEditor->geometry().x();
2807 y = mTodoEditor->geometry().y(); 2811 y = mTodoEditor->geometry().y();
2808 w = mTodoEditor->width(); 2812 w = mTodoEditor->width();
2809 h = mTodoEditor->height(); 2813 h = mTodoEditor->height();
2810 mTodoEditor->show(); 2814 mTodoEditor->show();
2811 mTodoEditor->setGeometry(x,y,w,h); 2815 mTodoEditor->setGeometry(x,y,w,h);
2812#else 2816#else
2813 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2817 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2814 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2818 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2815 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2819 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2816 qApp->processEvents(); 2820 qApp->processEvents();
2817 delete mTodoEditor; 2821 delete mTodoEditor;
2818 mTodoEditor = mDialogManager->getTodoEditor(); 2822 mTodoEditor = mDialogManager->getTodoEditor();
2819 topLevelWidget()->setCaption( i18n("") ); 2823 topLevelWidget()->setCaption( i18n("") );
2820 } 2824 }
2821 mTodoEditor->showMaximized(); 2825 mTodoEditor->showMaximized();
2822#endif 2826#endif
2823} 2827}
2824 2828
2825void CalendarView::cloneIncidence() 2829void CalendarView::cloneIncidence()
2826{ 2830{
2827 Incidence *incidence = currentSelection(); 2831 Incidence *incidence = currentSelection();
2828 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2832 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2829 if ( incidence ) { 2833 if ( incidence ) {
2830 cloneIncidence(incidence); 2834 cloneIncidence(incidence);
2831 } 2835 }
2832} 2836}
2833void CalendarView::moveIncidence() 2837void CalendarView::moveIncidence()
2834{ 2838{
2835 Incidence *incidence = currentSelection(); 2839 Incidence *incidence = currentSelection();
2836 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2840 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2837 if ( incidence ) { 2841 if ( incidence ) {
2838 moveIncidence(incidence); 2842 moveIncidence(incidence);
2839 } 2843 }
2840} 2844}
2841void CalendarView::beamIncidence() 2845void CalendarView::beamIncidence()
2842{ 2846{
2843 Incidence *incidence = currentSelection(); 2847 Incidence *incidence = currentSelection();
2844 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2848 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2845 if ( incidence ) { 2849 if ( incidence ) {
2846 beamIncidence(incidence); 2850 beamIncidence(incidence);
2847 } 2851 }
2848} 2852}
2849void CalendarView::toggleCancelIncidence() 2853void CalendarView::toggleCancelIncidence()
2850{ 2854{
2851 Incidence *incidence = currentSelection(); 2855 Incidence *incidence = currentSelection();
2852 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2856 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2853 if ( incidence ) { 2857 if ( incidence ) {
2854 cancelIncidence(incidence); 2858 cancelIncidence(incidence);
2855 } 2859 }
2856} 2860}
2857 2861
2858 2862
2859void CalendarView::cancelIncidence(Incidence * inc ) 2863void CalendarView::cancelIncidence(Incidence * inc )
2860{ 2864{
2861 inc->setCancelled( ! inc->cancelled() ); 2865 inc->setCancelled( ! inc->cancelled() );
2862 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2866 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2863 updateView(); 2867 updateView();
2864} 2868}
2865void CalendarView::cloneIncidence(Incidence * orgInc ) 2869void CalendarView::cloneIncidence(Incidence * orgInc )
2866{ 2870{
2867 Incidence * newInc = orgInc->clone(); 2871 Incidence * newInc = orgInc->clone();
2868 newInc->recreate(); 2872 newInc->recreate();
2869 2873
2870 if ( newInc->type() == "Todo" ) { 2874 if ( newInc->type() == "Todo" ) {
2871 Todo* t = (Todo*) newInc; 2875 Todo* t = (Todo*) newInc;
2872 bool cloneSub = false; 2876 bool cloneSub = false;
2873 if ( orgInc->relations().count() ) { 2877 if ( orgInc->relations().count() ) {
2874 int result = KMessageBox::warningYesNoCancel(this, 2878 int result = KMessageBox::warningYesNoCancel(this,
2875 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2879 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2876 i18n("Todo has subtodos"), 2880 i18n("Todo has subtodos"),
2877 i18n("Yes"), 2881 i18n("Yes"),
2878 i18n("No")); 2882 i18n("No"));
2879 2883
2880 if ( result == KMessageBox::Cancel ) { 2884 if ( result == KMessageBox::Cancel ) {
2881 delete t; 2885 delete t;
2882 return; 2886 return;
2883 } 2887 }
2884 if (result == KMessageBox::Yes) cloneSub = true; 2888 if (result == KMessageBox::Yes) cloneSub = true;
2885 } 2889 }
2886 showTodoEditor(); 2890 showTodoEditor();
2887 mTodoEditor->editTodo( t ); 2891 mTodoEditor->editTodo( t );
2888 if ( mTodoEditor->exec() ) { 2892 if ( mTodoEditor->exec() ) {
2889 if ( cloneSub ) { 2893 if ( cloneSub ) {
2890 orgInc->cloneRelations( t ); 2894 orgInc->cloneRelations( t );
2891 mCalendar->addIncidenceBranch( t ); 2895 mCalendar->addIncidenceBranch( t );
2892 updateView(); 2896 updateView();
2893 2897
2894 } else { 2898 } else {
2895 mCalendar->addTodo( t ); 2899 mCalendar->addTodo( t );
2896 updateView(); 2900 updateView();
2897 } 2901 }
2898 } else { 2902 } else {
2899 delete t; 2903 delete t;
2900 } 2904 }
2901 } 2905 }
2902 else { 2906 else {
2903 Event* e = (Event*) newInc; 2907 Event* e = (Event*) newInc;
2904 showEventEditor(); 2908 showEventEditor();
2905 mEventEditor->editEvent( e ); 2909 mEventEditor->editEvent( e );
2906 if ( mEventEditor->exec() ) { 2910 if ( mEventEditor->exec() ) {
2907 mCalendar->addEvent( e ); 2911 mCalendar->addEvent( e );
2908 updateView(); 2912 updateView();
2909 } else { 2913 } else {
2910 delete e; 2914 delete e;
2911 } 2915 }
2912 } 2916 }
2913 setActiveWindow(); 2917 setActiveWindow();
2914} 2918}
2915 2919
2916void CalendarView::newEvent() 2920void CalendarView::newEvent()
2917{ 2921{
2918 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2922 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2919 KOAgendaView *aView = mViewManager->agendaView(); 2923 KOAgendaView *aView = mViewManager->agendaView();
2920 if (aView) { 2924 if (aView) {
2921 if (aView->selectionStart().isValid()) { 2925 if (aView->selectionStart().isValid()) {
2922 if (aView->selectedIsAllDay()) { 2926 if (aView->selectedIsAllDay()) {
2923 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2927 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2924 } else { 2928 } else {
2925 newEvent(aView->selectionStart(),aView->selectionEnd()); 2929 newEvent(aView->selectionStart(),aView->selectionEnd());
2926 } 2930 }
2927 return; 2931 return;
2928 } 2932 }
2929 } 2933 }
2930 2934
2931 QDate date = mNavigator->selectedDates().first(); 2935 QDate date = mNavigator->selectedDates().first();
2932 QDateTime current = QDateTime::currentDateTime(); 2936 QDateTime current = QDateTime::currentDateTime();
2933 if ( date <= current.date() ) { 2937 if ( date <= current.date() ) {
2934 int hour = current.time().hour() +1; 2938 int hour = current.time().hour() +1;
2935 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2939 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2936 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2940 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2937 } else 2941 } else
2938 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2942 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2939 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2943 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2940 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2944 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2941} 2945}
2942 2946
2943void CalendarView::newEvent(QDateTime fh) 2947void CalendarView::newEvent(QDateTime fh)
2944{ 2948{
2945 newEvent(fh, 2949 newEvent(fh,
2946 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2950 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2947} 2951}
2948 2952
2949void CalendarView::newEvent(QDate dt) 2953void CalendarView::newEvent(QDate dt)
2950{ 2954{
2951 newEvent(QDateTime(dt, QTime(0,0,0)), 2955 newEvent(QDateTime(dt, QTime(0,0,0)),
2952 QDateTime(dt, QTime(0,0,0)), true); 2956 QDateTime(dt, QTime(0,0,0)), true);
2953} 2957}
2954void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2958void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2955{ 2959{
2956 newEvent(fromHint, toHint, false); 2960 newEvent(fromHint, toHint, false);
2957} 2961}
2958void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2962void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2959{ 2963{
2960 2964
2961 showEventEditor(); 2965 showEventEditor();
2962 mEventEditor->newEvent(fromHint,toHint,allDay); 2966 mEventEditor->newEvent(fromHint,toHint,allDay);
2963 if ( mFilterView->filtersEnabled() ) { 2967 if ( mFilterView->filtersEnabled() ) {
2964 CalFilter *filter = mFilterView->selectedFilter(); 2968 CalFilter *filter = mFilterView->selectedFilter();
2965 if (filter && filter->showCategories()) { 2969 if (filter && filter->showCategories()) {
2966 mEventEditor->setCategories(filter->categoryList().join(",") ); 2970 mEventEditor->setCategories(filter->categoryList().join(",") );
2967 } 2971 }
2968 if ( filter ) 2972 if ( filter )
2969 mEventEditor->setSecrecy( filter->getSecrecy() ); 2973 mEventEditor->setSecrecy( filter->getSecrecy() );
2970 } 2974 }
2971 mEventEditor->exec(); 2975 mEventEditor->exec();
2972 setActiveWindow(); 2976 setActiveWindow();
2973} 2977}
2974void CalendarView::todoAdded(Todo * t) 2978void CalendarView::todoAdded(Todo * t)
2975{ 2979{
2976 2980
2977 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2981 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2978 updateTodoViews(); 2982 updateTodoViews();
2979} 2983}
2980void CalendarView::todoChanged(Todo * t) 2984void CalendarView::todoChanged(Todo * t)
2981{ 2985{
2982 emit todoModified( t, 4 ); 2986 emit todoModified( t, 4 );
2983 // updateTodoViews(); 2987 // updateTodoViews();
2984} 2988}
2985void CalendarView::todoToBeDeleted(Todo *) 2989void CalendarView::todoToBeDeleted(Todo *)
2986{ 2990{
2987 //qDebug("todoToBeDeleted(Todo *) "); 2991 //qDebug("todoToBeDeleted(Todo *) ");
2988 updateTodoViews(); 2992 updateTodoViews();
2989} 2993}
2990void CalendarView::todoDeleted() 2994void CalendarView::todoDeleted()
2991{ 2995{
2992 //qDebug(" todoDeleted()"); 2996 //qDebug(" todoDeleted()");
2993 updateTodoViews(); 2997 updateTodoViews();
2994} 2998}
2995 2999
2996 3000
2997void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3001void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2998{ 3002{
2999 showTodoEditor(); 3003 showTodoEditor();
3000 mTodoEditor->newTodo(dt,0,allday); 3004 mTodoEditor->newTodo(dt,0,allday);
3001 if ( mFilterView->filtersEnabled() ) { 3005 if ( mFilterView->filtersEnabled() ) {
3002 CalFilter *filter = mFilterView->selectedFilter(); 3006 CalFilter *filter = mFilterView->selectedFilter();
3003 if (filter && filter->showCategories()) { 3007 if (filter && filter->showCategories()) {
3004 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3008 mTodoEditor->setCategories(filter->categoryList().join(",") );
3005 } 3009 }
3006 if ( filter ) 3010 if ( filter )
3007 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3011 mTodoEditor->setSecrecy( filter->getSecrecy() );
3008 } 3012 }
3009 mTodoEditor->exec(); 3013 mTodoEditor->exec();
3010 setActiveWindow(); 3014 setActiveWindow();
3011} 3015}
3012 3016
3013void CalendarView::newTodo() 3017void CalendarView::newTodo()
3014{ 3018{
3015 newTodoDateTime( QDateTime(),true ); 3019 newTodoDateTime( QDateTime(),true );
3016} 3020}
3017 3021
3018void CalendarView::newSubTodo() 3022void CalendarView::newSubTodo()
3019{ 3023{
3020 Todo *todo = selectedTodo(); 3024 Todo *todo = selectedTodo();
3021 if ( todo ) newSubTodo( todo ); 3025 if ( todo ) newSubTodo( todo );
3022} 3026}
3023 3027
3024void CalendarView::newSubTodo(Todo *parentEvent) 3028void CalendarView::newSubTodo(Todo *parentEvent)
3025{ 3029{
3026 3030
3027 showTodoEditor(); 3031 showTodoEditor();
3028 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3032 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3029 mTodoEditor->exec(); 3033 mTodoEditor->exec();
3030 setActiveWindow(); 3034 setActiveWindow();
3031} 3035}
3032 3036
3033void CalendarView::newFloatingEvent() 3037void CalendarView::newFloatingEvent()
3034{ 3038{
3035 DateList tmpList = mNavigator->selectedDates(); 3039 DateList tmpList = mNavigator->selectedDates();
3036 QDate date = tmpList.first(); 3040 QDate date = tmpList.first();
3037 3041
3038 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3042 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3039 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3043 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3040} 3044}
3041 3045
3042 3046
3043void CalendarView::editEvent( Event *event ) 3047void CalendarView::editEvent( Event *event )
3044{ 3048{
3045 3049
3046 if ( !event ) return; 3050 if ( !event ) return;
3047 if ( event->isReadOnly() ) { 3051 if ( event->isReadOnly() ) {
3048 showEvent( event ); 3052 showEvent( event );
3049 return; 3053 return;
3050 } 3054 }
3051 showEventEditor(); 3055 showEventEditor();
3052 mEventEditor->editEvent( event , mFlagEditDescription); 3056 mEventEditor->editEvent( event , mFlagEditDescription);
3053 mEventEditor->exec(); 3057 mEventEditor->exec();
3054 setActiveWindow(); 3058 setActiveWindow();
3055 3059
3056} 3060}
3057void CalendarView::editJournal( Journal *jour ) 3061void CalendarView::editJournal( Journal *jour )
3058{ 3062{
3059 if ( !jour ) return; 3063 if ( !jour ) return;
3060 mDialogManager->hideSearchDialog(); 3064 mDialogManager->hideSearchDialog();
3061 mViewManager->showJournalView(); 3065 mViewManager->showJournalView();
3062 mNavigator->slotDaySelect( jour->dtStart().date() ); 3066 mNavigator->slotDaySelect( jour->dtStart().date() );
3063} 3067}
3064void CalendarView::editTodo( Todo *todo ) 3068void CalendarView::editTodo( Todo *todo )
3065{ 3069{
3066 if ( !todo ) return; 3070 if ( !todo ) return;
3067 3071
3068 if ( todo->isReadOnly() ) { 3072 if ( todo->isReadOnly() ) {
3069 showTodo( todo ); 3073 showTodo( todo );
3070 return; 3074 return;
3071 } 3075 }
3072 showTodoEditor(); 3076 showTodoEditor();
3073 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3077 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3074 mTodoEditor->exec(); 3078 mTodoEditor->exec();
3075 setActiveWindow(); 3079 setActiveWindow();
3076 3080
3077} 3081}
3078 3082
3079KOEventViewerDialog* CalendarView::getEventViewerDialog() 3083KOEventViewerDialog* CalendarView::getEventViewerDialog()
3080{ 3084{
3081 if ( !mEventViewerDialog ) { 3085 if ( !mEventViewerDialog ) {
3082 mEventViewerDialog = new KOEventViewerDialog(0); 3086 mEventViewerDialog = new KOEventViewerDialog(0);
3083 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3087 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3084 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3088 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3085 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3089 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3086 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3090 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3087 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3091 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3088 viewManager(), SLOT( showAgendaView( bool ) ) ); 3092 viewManager(), SLOT( showAgendaView( bool ) ) );
3089 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3093 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3090 this, SLOT( slotViewerClosed() ) ); 3094 this, SLOT( slotViewerClosed() ) );
3091 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3095 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3092 this, SLOT( todoChanged(Todo *) ) ); 3096 this, SLOT( todoChanged(Todo *) ) );
3093 mEventViewerDialog->resize( 640, 480 ); 3097 mEventViewerDialog->resize( 640, 480 );
3094 3098
3095 } 3099 }
3096 return mEventViewerDialog; 3100 return mEventViewerDialog;
3097} 3101}
3098void CalendarView::showEvent(Event *event) 3102void CalendarView::showEvent(Event *event)
3099{ 3103{
3100 getEventViewerDialog()->setEvent(event); 3104 getEventViewerDialog()->setEvent(event);
3101 getEventViewerDialog()->showMe(); 3105 getEventViewerDialog()->showMe();
3102} 3106}
3103 3107
3104void CalendarView::showTodo(Todo *event) 3108void CalendarView::showTodo(Todo *event)
3105{ 3109{
3106 getEventViewerDialog()->setTodo(event); 3110 getEventViewerDialog()->setTodo(event);
3107 getEventViewerDialog()->showMe(); 3111 getEventViewerDialog()->showMe();
3108} 3112}
3109void CalendarView::showJournal( Journal *jour ) 3113void CalendarView::showJournal( Journal *jour )
3110{ 3114{
3111 getEventViewerDialog()->setJournal(jour); 3115 getEventViewerDialog()->setJournal(jour);
3112 getEventViewerDialog()->showMe(); 3116 getEventViewerDialog()->showMe();
3113 3117
3114} 3118}
3115// void CalendarView::todoModified (Todo *event, int changed) 3119// void CalendarView::todoModified (Todo *event, int changed)
3116// { 3120// {
3117// // if (mDialogList.find (event) != mDialogList.end ()) { 3121// // if (mDialogList.find (event) != mDialogList.end ()) {
3118// // kdDebug() << "Todo modified and open" << endl; 3122// // kdDebug() << "Todo modified and open" << endl;
3119// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3123// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3120// // temp->modified (changed); 3124// // temp->modified (changed);
3121 3125
3122// // } 3126// // }
3123 3127
3124// mViewManager->updateView(); 3128// mViewManager->updateView();
3125// } 3129// }
3126 3130
3127void CalendarView::appointment_show() 3131void CalendarView::appointment_show()
3128{ 3132{
3129 Event *anEvent = 0; 3133 Event *anEvent = 0;
3130 3134
3131 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3135 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3132 3136
3133 if (mViewManager->currentView()->isEventView()) { 3137 if (mViewManager->currentView()->isEventView()) {
3134 if ( incidence && incidence->type() == "Event" ) { 3138 if ( incidence && incidence->type() == "Event" ) {
3135 anEvent = static_cast<Event *>(incidence); 3139 anEvent = static_cast<Event *>(incidence);
3136 } 3140 }
3137 } 3141 }
3138 3142
3139 if (!anEvent) { 3143 if (!anEvent) {
3140 KNotifyClient::beep(); 3144 KNotifyClient::beep();
3141 return; 3145 return;
3142 } 3146 }
3143 3147
3144 showEvent(anEvent); 3148 showEvent(anEvent);
3145} 3149}
3146 3150
3147void CalendarView::appointment_edit() 3151void CalendarView::appointment_edit()
3148{ 3152{
3149 Event *anEvent = 0; 3153 Event *anEvent = 0;
3150 3154
3151 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3155 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3152 3156
3153 if (mViewManager->currentView()->isEventView()) { 3157 if (mViewManager->currentView()->isEventView()) {
3154 if ( incidence && incidence->type() == "Event" ) { 3158 if ( incidence && incidence->type() == "Event" ) {
3155 anEvent = static_cast<Event *>(incidence); 3159 anEvent = static_cast<Event *>(incidence);
3156 } 3160 }
3157 } 3161 }
3158 3162
3159 if (!anEvent) { 3163 if (!anEvent) {
3160 KNotifyClient::beep(); 3164 KNotifyClient::beep();
3161 return; 3165 return;
3162 } 3166 }
3163 3167
3164 editEvent(anEvent); 3168 editEvent(anEvent);
3165} 3169}
3166 3170
3167void CalendarView::appointment_delete() 3171void CalendarView::appointment_delete()
3168{ 3172{
3169 Event *anEvent = 0; 3173 Event *anEvent = 0;
3170 3174
3171 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3175 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3172 3176
3173 if (mViewManager->currentView()->isEventView()) { 3177 if (mViewManager->currentView()->isEventView()) {
3174 if ( incidence && incidence->type() == "Event" ) { 3178 if ( incidence && incidence->type() == "Event" ) {
3175 anEvent = static_cast<Event *>(incidence); 3179 anEvent = static_cast<Event *>(incidence);
3176 } 3180 }
3177 } 3181 }
3178 3182
3179 if (!anEvent) { 3183 if (!anEvent) {
3180 KNotifyClient::beep(); 3184 KNotifyClient::beep();
3181 return; 3185 return;
3182 } 3186 }
3183 3187
3184 deleteEvent(anEvent); 3188 deleteEvent(anEvent);
3185} 3189}
3186 3190
3187void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3191void CalendarView::todo_resub( Todo * parent, Todo * sub )
3188{ 3192{
3189 if (!sub) return; 3193 if (!sub) return;
3190 if ( sub->relatedTo() == parent ) 3194 if ( sub->relatedTo() == parent )
3191 return; 3195 return;
3192 sub->setRelatedTo(parent); 3196 sub->setRelatedTo(parent);
3193 sub->updated(); 3197 sub->updated();
3194 setModified(true); 3198 setModified(true);
3195 updateView(); 3199 updateView();
3196} 3200}
3197void CalendarView::todo_unsub(Todo *anTodo ) 3201void CalendarView::todo_unsub(Todo *anTodo )
3198{ 3202{
3199 todo_resub( 0, anTodo ); 3203 todo_resub( 0, anTodo );
3200} 3204}
3201 3205
3202void CalendarView::deleteTodo(Todo *todo) 3206void CalendarView::deleteTodo(Todo *todo)
3203{ 3207{
3204 if (!todo) { 3208 if (!todo) {
3205 KNotifyClient::beep(); 3209 KNotifyClient::beep();
3206 return; 3210 return;
3207 } 3211 }
3208 if (KOPrefs::instance()->mConfirm) { 3212 if (KOPrefs::instance()->mConfirm) {
3209 QString text = todo->summary().left(20); 3213 QString text = todo->summary().left(20);
3210 if (!todo->relations().isEmpty()) { 3214 if (!todo->relations().isEmpty()) {
3211 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3215 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3212 3216
3213 } 3217 }
3214 switch (msgItemDelete(text)) { 3218 switch (msgItemDelete(text)) {
3215 case KMessageBox::Continue: // OK 3219 case KMessageBox::Continue: // OK
3216 bool deleteT = false; 3220 bool deleteT = false;
3217 if (!todo->relations().isEmpty()) { 3221 if (!todo->relations().isEmpty()) {
3218 deleteT = removeCompletedSubTodos( todo ); 3222 deleteT = removeCompletedSubTodos( todo );
3219 } 3223 }
3220 // deleteT == true: todo already deleted in removeCompletedSubTodos 3224 // deleteT == true: todo already deleted in removeCompletedSubTodos
3221 if ( !deleteT ) { 3225 if ( !deleteT ) {
3222 checkExternalId( todo ); 3226 checkExternalId( todo );
3223 calendar()->deleteTodo(todo); 3227 calendar()->deleteTodo(todo);
3224 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3228 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3225 updateView(); 3229 updateView();
3226 } 3230 }
3227 break; 3231 break;
3228 } // switch 3232 } // switch
3229 } else { 3233 } else {
3230 checkExternalId( todo ); 3234 checkExternalId( todo );
3231 mCalendar->deleteTodo(todo); 3235 mCalendar->deleteTodo(todo);
3232 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3236 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3233 updateView(); 3237 updateView();
3234 } 3238 }
3235 3239
3236 emit updateSearchDialog(); 3240 emit updateSearchDialog();
3237} 3241}
3238void CalendarView::deleteJournal(Journal *jour) 3242void CalendarView::deleteJournal(Journal *jour)
3239{ 3243{
3240 if (!jour) { 3244 if (!jour) {
3241 KNotifyClient::beep(); 3245 KNotifyClient::beep();
3242 return; 3246 return;
3243 } 3247 }
3244 if (KOPrefs::instance()->mConfirm) { 3248 if (KOPrefs::instance()->mConfirm) {
3245 switch (msgItemDelete( jour->description().left(20))) { 3249 switch (msgItemDelete( jour->description().left(20))) {
3246 case KMessageBox::Continue: // OK 3250 case KMessageBox::Continue: // OK
3247 calendar()->deleteJournal(jour); 3251 calendar()->deleteJournal(jour);
3248 updateView(); 3252 updateView();
3249 break; 3253 break;
3250 } // switch 3254 } // switch
3251 } else { 3255 } else {
3252 calendar()->deleteJournal(jour);; 3256 calendar()->deleteJournal(jour);;
3253 updateView(); 3257 updateView();
3254 } 3258 }
3255 emit updateSearchDialog(); 3259 emit updateSearchDialog();
3256} 3260}
3257 3261
3258void CalendarView::deleteEvent(Event *anEvent) 3262void CalendarView::deleteEvent(Event *anEvent)
3259{ 3263{
3260 if (!anEvent) { 3264 if (!anEvent) {
3261 KNotifyClient::beep(); 3265 KNotifyClient::beep();
3262 return; 3266 return;
3263 } 3267 }
3264 3268
3265 if (anEvent->recurrence()->doesRecur()) { 3269 if (anEvent->recurrence()->doesRecur()) {
3266 QDate itemDate = mViewManager->currentSelectionDate(); 3270 QDate itemDate = mViewManager->currentSelectionDate();
3267 int km; 3271 int km;
3268 if (!itemDate.isValid()) { 3272 if (!itemDate.isValid()) {
3269 //kdDebug() << "Date Not Valid" << endl; 3273 //kdDebug() << "Date Not Valid" << endl;
3270 if (KOPrefs::instance()->mConfirm) { 3274 if (KOPrefs::instance()->mConfirm) {
3271 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3275 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3272 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3276 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3273 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3277 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3274 if ( km == KMessageBox::Continue ) 3278 if ( km == KMessageBox::Continue )
3275 km = KMessageBox::No; // No = all below 3279 km = KMessageBox::No; // No = all below
3276 } else 3280 } else
3277 km = KMessageBox::No; 3281 km = KMessageBox::No;
3278 } else { 3282 } else {
3279 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3283 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3280 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3284 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3281 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3285 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3282 i18n("KO/Pi Confirmation"),i18n("Current"), 3286 i18n("KO/Pi Confirmation"),i18n("Current"),
3283 i18n("All")); 3287 i18n("All"));
3284 } 3288 }
3285 switch(km) { 3289 switch(km) {
3286 3290
3287 case KMessageBox::No: // Continue // all 3291 case KMessageBox::No: // Continue // all
3288 //qDebug("KMessageBox::No "); 3292 //qDebug("KMessageBox::No ");
3289 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3293 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3290 schedule(Scheduler::Cancel,anEvent); 3294 schedule(Scheduler::Cancel,anEvent);
3291 3295
3292 checkExternalId( anEvent); 3296 checkExternalId( anEvent);
3293 mCalendar->deleteEvent(anEvent); 3297 mCalendar->deleteEvent(anEvent);
3294 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3298 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3295 break; 3299 break;
3296 3300
3297 // Disabled because it does not work 3301 // Disabled because it does not work
3298 //#if 0 3302 //#if 0
3299 case KMessageBox::Yes: // just this one 3303 case KMessageBox::Yes: // just this one
3300 //QDate qd = mNavigator->selectedDates().first(); 3304 //QDate qd = mNavigator->selectedDates().first();
3301 //if (!qd.isValid()) { 3305 //if (!qd.isValid()) {
3302 // kdDebug() << "no date selected, or invalid date" << endl; 3306 // kdDebug() << "no date selected, or invalid date" << endl;
3303 // KNotifyClient::beep(); 3307 // KNotifyClient::beep();
3304 // return; 3308 // return;
3305 //} 3309 //}
3306 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3310 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3307 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3311 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3308 anEvent->addExDate(itemDate); 3312 anEvent->addExDate(itemDate);
3309 int duration = anEvent->recurrence()->duration(); 3313 int duration = anEvent->recurrence()->duration();
3310 if ( duration > 0 ) { 3314 if ( duration > 0 ) {
3311 anEvent->recurrence()->setDuration( duration - 1 ); 3315 anEvent->recurrence()->setDuration( duration - 1 );
3312 } 3316 }
3313 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3317 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3314 } 3318 }
3315 break; 3319 break;
3316 //#endif 3320 //#endif
3317 } // switch 3321 } // switch
3318 } else { 3322 } else {
3319 if (KOPrefs::instance()->mConfirm) { 3323 if (KOPrefs::instance()->mConfirm) {
3320 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3324 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3321 i18n("\nAre you sure you want\nto delete this event?"), 3325 i18n("\nAre you sure you want\nto delete this event?"),
3322 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3326 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3323 case KMessageBox::Continue: // OK 3327 case KMessageBox::Continue: // OK
3324 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3328 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3325 schedule(Scheduler::Cancel,anEvent); 3329 schedule(Scheduler::Cancel,anEvent);
3326 checkExternalId( anEvent); 3330 checkExternalId( anEvent);
3327 mCalendar->deleteEvent(anEvent); 3331 mCalendar->deleteEvent(anEvent);
3328 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3332 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3329 break; 3333 break;
3330 } // switch 3334 } // switch
3331 } else { 3335 } else {
3332 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3336 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3333 schedule(Scheduler::Cancel,anEvent); 3337 schedule(Scheduler::Cancel,anEvent);
3334 checkExternalId( anEvent); 3338 checkExternalId( anEvent);
3335 mCalendar->deleteEvent(anEvent); 3339 mCalendar->deleteEvent(anEvent);
3336 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3340 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3337 } 3341 }
3338 } // if-else 3342 } // if-else
3339 emit updateSearchDialog(); 3343 emit updateSearchDialog();
3340} 3344}
3341 3345
3342bool CalendarView::deleteEvent(const QString &uid) 3346bool CalendarView::deleteEvent(const QString &uid)
3343{ 3347{
3344 Event *ev = mCalendar->event(uid); 3348 Event *ev = mCalendar->event(uid);
3345 if (ev) { 3349 if (ev) {
3346 deleteEvent(ev); 3350 deleteEvent(ev);
3347 return true; 3351 return true;
3348 } else { 3352 } else {
3349 return false; 3353 return false;
3350 } 3354 }
3351} 3355}
3352 3356
3353/*****************************************************************************/ 3357/*****************************************************************************/
3354 3358
3355void CalendarView::action_mail() 3359void CalendarView::action_mail()
3356{ 3360{
3357#ifndef KORG_NOMAIL 3361#ifndef KORG_NOMAIL
3358 KOMailClient mailClient; 3362 KOMailClient mailClient;
3359 3363
3360 Incidence *incidence = currentSelection(); 3364 Incidence *incidence = currentSelection();
3361 3365
3362 if (!incidence) { 3366 if (!incidence) {
3363 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3367 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3364 return; 3368 return;
3365 } 3369 }
3366 if(incidence->attendeeCount() == 0 ) { 3370 if(incidence->attendeeCount() == 0 ) {
3367 KMessageBox::sorry(this, 3371 KMessageBox::sorry(this,
3368 i18n("Can't generate mail:\nNo attendees defined.\n")); 3372 i18n("Can't generate mail:\nNo attendees defined.\n"));
3369 return; 3373 return;
3370 } 3374 }
3371 3375
3372 CalendarLocal cal_tmp; 3376 CalendarLocal cal_tmp;
3373 Event *event = 0; 3377 Event *event = 0;
3374 Event *ev = 0; 3378 Event *ev = 0;
3375 if ( incidence && incidence->type() == "Event" ) { 3379 if ( incidence && incidence->type() == "Event" ) {
3376 event = static_cast<Event *>(incidence); 3380 event = static_cast<Event *>(incidence);
3377 ev = new Event(*event); 3381 ev = new Event(*event);
3378 cal_tmp.addEvent(ev); 3382 cal_tmp.addEvent(ev);
3379 } 3383 }
3380 ICalFormat mForm(); 3384 ICalFormat mForm();
3381 QString attachment = mForm.toString( &cal_tmp ); 3385 QString attachment = mForm.toString( &cal_tmp );
3382 if (ev) delete(ev); 3386 if (ev) delete(ev);
3383 3387
3384 mailClient.mailAttendees(currentSelection(), attachment); 3388 mailClient.mailAttendees(currentSelection(), attachment);
3385 3389
3386#endif 3390#endif
3387 3391
3388#if 0 3392#if 0
3389 Event *anEvent = 0; 3393 Event *anEvent = 0;
3390 if (mViewManager->currentView()->isEventView()) { 3394 if (mViewManager->currentView()->isEventView()) {
3391 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3395 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3392 } 3396 }
3393 3397
3394 if (!anEvent) { 3398 if (!anEvent) {
3395 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3399 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3396 return; 3400 return;
3397 } 3401 }
3398 if(anEvent->attendeeCount() == 0 ) { 3402 if(anEvent->attendeeCount() == 0 ) {
3399 KMessageBox::sorry(this, 3403 KMessageBox::sorry(this,
3400 i18n("Can't generate mail:\nNo attendees defined.\n")); 3404 i18n("Can't generate mail:\nNo attendees defined.\n"));
3401 return; 3405 return;
3402 } 3406 }
3403 3407
3404 mailobject.emailEvent(anEvent); 3408 mailobject.emailEvent(anEvent);
3405#endif 3409#endif
3406} 3410}
3407 3411
3408 3412
3409void CalendarView::schedule_publish(Incidence *incidence) 3413void CalendarView::schedule_publish(Incidence *incidence)
3410{ 3414{
3411 Event *event = 0; 3415 Event *event = 0;
3412 Todo *todo = 0; 3416 Todo *todo = 0;
3413 3417
3414 if (incidence == 0) { 3418 if (incidence == 0) {
3415 incidence = mViewManager->currentView()->selectedIncidences().first(); 3419 incidence = mViewManager->currentView()->selectedIncidences().first();
3416 if (incidence == 0) { 3420 if (incidence == 0) {
3417 incidence = mTodoList->selectedIncidences().first(); 3421 incidence = mTodoList->selectedIncidences().first();
3418 } 3422 }
3419 } 3423 }
3420 if ( incidence && incidence->type() == "Event" ) { 3424 if ( incidence && incidence->type() == "Event" ) {
3421 event = static_cast<Event *>(incidence); 3425 event = static_cast<Event *>(incidence);
3422 } else { 3426 } else {
3423 if ( incidence && incidence->type() == "Todo" ) { 3427 if ( incidence && incidence->type() == "Todo" ) {
3424 todo = static_cast<Todo *>(incidence); 3428 todo = static_cast<Todo *>(incidence);
3425 } 3429 }
3426 } 3430 }
3427 3431
3428 if (!event && !todo) { 3432 if (!event && !todo) {
3429 KMessageBox::sorry(this,i18n("No event selected.")); 3433 KMessageBox::sorry(this,i18n("No event selected."));
3430 return; 3434 return;
3431 } 3435 }
3432 3436
3433 PublishDialog *publishdlg = new PublishDialog(); 3437 PublishDialog *publishdlg = new PublishDialog();
3434 if (incidence->attendeeCount()>0) { 3438 if (incidence->attendeeCount()>0) {
3435 QPtrList<Attendee> attendees = incidence->attendees(); 3439 QPtrList<Attendee> attendees = incidence->attendees();
3436 attendees.first(); 3440 attendees.first();
3437 while ( attendees.current()!=0 ) { 3441 while ( attendees.current()!=0 ) {
3438 publishdlg->addAttendee(attendees.current()); 3442 publishdlg->addAttendee(attendees.current());
3439 attendees.next(); 3443 attendees.next();
3440 } 3444 }
3441 } 3445 }
3442 bool send = true; 3446 bool send = true;
3443 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3447 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3444 if ( publishdlg->exec() != QDialog::Accepted ) 3448 if ( publishdlg->exec() != QDialog::Accepted )
3445 send = false; 3449 send = false;
3446 } 3450 }
3447 if ( send ) { 3451 if ( send ) {
3448 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3452 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3449 if ( event ) { 3453 if ( event ) {
3450 Event *ev = new Event(*event); 3454 Event *ev = new Event(*event);
3451 ev->registerObserver(0); 3455 ev->registerObserver(0);
3452 ev->clearAttendees(); 3456 ev->clearAttendees();
3453 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3457 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3454 delete(ev); 3458 delete(ev);
3455 } 3459 }
3456 } else { 3460 } else {
3457 if ( todo ) { 3461 if ( todo ) {
3458 Todo *ev = new Todo(*todo); 3462 Todo *ev = new Todo(*todo);
3459 ev->registerObserver(0); 3463 ev->registerObserver(0);
3460 ev->clearAttendees(); 3464 ev->clearAttendees();
3461 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3465 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3462 delete(ev); 3466 delete(ev);
3463 } 3467 }
3464 } 3468 }
3465 } 3469 }
3466 } 3470 }
3467 delete publishdlg; 3471 delete publishdlg;
3468} 3472}
3469 3473
3470void CalendarView::schedule_request(Incidence *incidence) 3474void CalendarView::schedule_request(Incidence *incidence)
3471{ 3475{
3472 schedule(Scheduler::Request,incidence); 3476 schedule(Scheduler::Request,incidence);
3473} 3477}
3474 3478
3475void CalendarView::schedule_refresh(Incidence *incidence) 3479void CalendarView::schedule_refresh(Incidence *incidence)
3476{ 3480{
3477 schedule(Scheduler::Refresh,incidence); 3481 schedule(Scheduler::Refresh,incidence);
3478} 3482}
3479 3483
3480void CalendarView::schedule_cancel(Incidence *incidence) 3484void CalendarView::schedule_cancel(Incidence *incidence)
3481{ 3485{
3482 schedule(Scheduler::Cancel,incidence); 3486 schedule(Scheduler::Cancel,incidence);
3483} 3487}
3484 3488
3485void CalendarView::schedule_add(Incidence *incidence) 3489void CalendarView::schedule_add(Incidence *incidence)
3486{ 3490{
3487 schedule(Scheduler::Add,incidence); 3491 schedule(Scheduler::Add,incidence);
3488} 3492}
3489 3493
3490void CalendarView::schedule_reply(Incidence *incidence) 3494void CalendarView::schedule_reply(Incidence *incidence)
3491{ 3495{
3492 schedule(Scheduler::Reply,incidence); 3496 schedule(Scheduler::Reply,incidence);
3493} 3497}
3494 3498
3495void CalendarView::schedule_counter(Incidence *incidence) 3499void CalendarView::schedule_counter(Incidence *incidence)
3496{ 3500{
3497 schedule(Scheduler::Counter,incidence); 3501 schedule(Scheduler::Counter,incidence);
3498} 3502}
3499 3503
3500void CalendarView::schedule_declinecounter(Incidence *incidence) 3504void CalendarView::schedule_declinecounter(Incidence *incidence)
3501{ 3505{
3502 schedule(Scheduler::Declinecounter,incidence); 3506 schedule(Scheduler::Declinecounter,incidence);
3503} 3507}
3504 3508
3505void CalendarView::schedule_publish_freebusy(int daysToPublish) 3509void CalendarView::schedule_publish_freebusy(int daysToPublish)
3506{ 3510{
3507 QDateTime start = QDateTime::currentDateTime(); 3511 QDateTime start = QDateTime::currentDateTime();
3508 QDateTime end = start.addDays(daysToPublish); 3512 QDateTime end = start.addDays(daysToPublish);
3509 3513
3510 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3514 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3511 freebusy->setOrganizer(KOPrefs::instance()->email()); 3515 freebusy->setOrganizer(KOPrefs::instance()->email());
3512 3516
3513 3517
3514 PublishDialog *publishdlg = new PublishDialog(); 3518 PublishDialog *publishdlg = new PublishDialog();
3515 if ( publishdlg->exec() == QDialog::Accepted ) { 3519 if ( publishdlg->exec() == QDialog::Accepted ) {
3516 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3520 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3517 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3521 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3518 delete(freebusy); 3522 delete(freebusy);
3519 } 3523 }
3520 } 3524 }
3521 delete publishdlg; 3525 delete publishdlg;
3522} 3526}
3523 3527
3524void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3528void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3525{ 3529{
3526 Event *event = 0; 3530 Event *event = 0;
3527 Todo *todo = 0; 3531 Todo *todo = 0;
3528 3532
3529 if (incidence == 0) { 3533 if (incidence == 0) {
3530 incidence = mViewManager->currentView()->selectedIncidences().first(); 3534 incidence = mViewManager->currentView()->selectedIncidences().first();
3531 if (incidence == 0) { 3535 if (incidence == 0) {
3532 incidence = mTodoList->selectedIncidences().first(); 3536 incidence = mTodoList->selectedIncidences().first();
3533 } 3537 }
3534 } 3538 }
3535 if ( incidence && incidence->type() == "Event" ) { 3539 if ( incidence && incidence->type() == "Event" ) {
3536 event = static_cast<Event *>(incidence); 3540 event = static_cast<Event *>(incidence);
3537 } 3541 }
3538 if ( incidence && incidence->type() == "Todo" ) { 3542 if ( incidence && incidence->type() == "Todo" ) {
3539 todo = static_cast<Todo *>(incidence); 3543 todo = static_cast<Todo *>(incidence);
3540 } 3544 }
3541 3545
3542 if (!event && !todo) { 3546 if (!event && !todo) {
3543 KMessageBox::sorry(this,i18n("No event selected.")); 3547 KMessageBox::sorry(this,i18n("No event selected."));
3544 return; 3548 return;
3545 } 3549 }
3546 3550
3547 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3551 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3548 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3552 KMessageBox::sorry(this,i18n("The event has no attendees."));
3549 return; 3553 return;
3550 } 3554 }
3551 3555
3552 Event *ev = 0; 3556 Event *ev = 0;
3553 if (event) ev = new Event(*event); 3557 if (event) ev = new Event(*event);
3554 Todo *to = 0; 3558 Todo *to = 0;
3555 if (todo) to = new Todo(*todo); 3559 if (todo) to = new Todo(*todo);
3556 3560
3557 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3561 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3558 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3562 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3559 if (!me) { 3563 if (!me) {
3560 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3564 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3561 return; 3565 return;
3562 } 3566 }
3563 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3567 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3564 StatusDialog *statdlg = new StatusDialog(this); 3568 StatusDialog *statdlg = new StatusDialog(this);
3565 if (!statdlg->exec()==QDialog::Accepted) return; 3569 if (!statdlg->exec()==QDialog::Accepted) return;
3566 me->setStatus( statdlg->status() ); 3570 me->setStatus( statdlg->status() );
3567 delete(statdlg); 3571 delete(statdlg);
3568 } 3572 }
3569 Attendee *menew = new Attendee(*me); 3573 Attendee *menew = new Attendee(*me);
3570 if (ev) { 3574 if (ev) {
3571 ev->clearAttendees(); 3575 ev->clearAttendees();
3572 ev->addAttendee(menew,false); 3576 ev->addAttendee(menew,false);
3573 } else { 3577 } else {
3574 if (to) { 3578 if (to) {
3575 todo->clearAttendees(); 3579 todo->clearAttendees();
3576 todo->addAttendee(menew,false); 3580 todo->addAttendee(menew,false);
3577 } 3581 }
3578 } 3582 }
3579 } 3583 }
3580 3584
3581 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3585 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3582 if (ev) { 3586 if (ev) {
3583 if ( !dlg->addMessage(ev,method) ) delete(ev); 3587 if ( !dlg->addMessage(ev,method) ) delete(ev);
3584 } else { 3588 } else {
3585 if (to) { 3589 if (to) {
3586 if ( !dlg->addMessage(to,method) ) delete(to); 3590 if ( !dlg->addMessage(to,method) ) delete(to);
3587 } 3591 }
3588 } 3592 }
3589} 3593}
3590 3594
3591void CalendarView::openAddressbook() 3595void CalendarView::openAddressbook()
3592{ 3596{
3593 KRun::runCommand("kaddressbook"); 3597 KRun::runCommand("kaddressbook");
3594} 3598}
3595 3599
3596void CalendarView::setModified(bool modified) 3600void CalendarView::setModified(bool modified)
3597{ 3601{
3598 if ( modified ) 3602 if ( modified )
3599 emit signalmodified(); 3603 emit signalmodified();
3600 if (mModified != modified) { 3604 if (mModified != modified) {
3601 mModified = modified; 3605 mModified = modified;
3602 emit modifiedChanged(mModified); 3606 emit modifiedChanged(mModified);
3603 } 3607 }
3604} 3608}
3605 3609
3606bool CalendarView::isReadOnly() 3610bool CalendarView::isReadOnly()
3607{ 3611{
3608 return mReadOnly; 3612 return mReadOnly;
3609} 3613}
3610 3614
3611void CalendarView::setReadOnly(bool readOnly) 3615void CalendarView::setReadOnly(bool readOnly)
3612{ 3616{
3613 if (mReadOnly != readOnly) { 3617 if (mReadOnly != readOnly) {
3614 mReadOnly = readOnly; 3618 mReadOnly = readOnly;
3615 emit readOnlyChanged(mReadOnly); 3619 emit readOnlyChanged(mReadOnly);
3616 } 3620 }
3617} 3621}
3618 3622
3619bool CalendarView::isModified() 3623bool CalendarView::isModified()
3620{ 3624{
3621 return mModified; 3625 return mModified;
3622} 3626}
3623void CalendarView::slotprintSelInc() 3627void CalendarView::slotprintSelInc()
3624{ 3628{
3625 if ( currentSelection() == 0 ) { 3629 if ( currentSelection() == 0 ) {
3626 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3630 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3627 return; 3631 return;
3628 } 3632 }
3629 showIncidence(); 3633 showIncidence();
3630 getEventViewerDialog()->print(); 3634 getEventViewerDialog()->print();
3631 3635
3632} 3636}
3633void CalendarView::printSetup() 3637void CalendarView::printSetup()
3634{ 3638{
3635#ifndef KORG_NOPRINTER 3639#ifndef KORG_NOPRINTER
3636 createPrinter(); 3640 createPrinter();
3637 3641
3638 mCalPrinter->setupPrinter(); 3642 mCalPrinter->setupPrinter();
3639#endif 3643#endif
3640} 3644}
3641 3645
3642void CalendarView::print() 3646void CalendarView::print()
3643{ 3647{
3644#ifndef KORG_NOPRINTER 3648#ifndef KORG_NOPRINTER
3645 createPrinter(); 3649 createPrinter();
3646 3650
3647 DateList tmpDateList = mNavigator->selectedDates(); 3651 DateList tmpDateList = mNavigator->selectedDates();
3648 mCalPrinter->print(CalPrinter::Month, 3652 mCalPrinter->print(CalPrinter::Month,
3649 tmpDateList.first(), tmpDateList.last()); 3653 tmpDateList.first(), tmpDateList.last());
3650#endif 3654#endif
3651} 3655}
3652 3656
3653void CalendarView::printPreview() 3657void CalendarView::printPreview()
3654{ 3658{
3655#ifndef KORG_NOPRINTER 3659#ifndef KORG_NOPRINTER
3656 kdDebug() << "CalendarView::printPreview()" << endl; 3660 kdDebug() << "CalendarView::printPreview()" << endl;
3657 3661
3658 createPrinter(); 3662 createPrinter();
3659 3663
3660 DateList tmpDateList = mNavigator->selectedDates(); 3664 DateList tmpDateList = mNavigator->selectedDates();
3661 3665
3662 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3666 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3663 tmpDateList.last()); 3667 tmpDateList.last());
3664#endif 3668#endif
3665} 3669}
3666 3670
3667void CalendarView::exportICalendar() 3671void CalendarView::exportICalendar()
3668{ 3672{
3669 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3673 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3670 3674
3671 // Force correct extension 3675 // Force correct extension
3672 if (filename.right(4) != ".ics") filename += ".ics"; 3676 if (filename.right(4) != ".ics") filename += ".ics";
3673 3677
3674 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3678 FileStorage storage( mCalendar, filename, new ICalFormat() );
3675 storage.save(); 3679 storage.save();
3676} 3680}
3677 3681
3678bool CalendarView::exportVCalendar( QString filename ) 3682bool CalendarView::exportVCalendar( QString filename )
3679{ 3683{
3680 if (mCalendar->journals().count() > 0) { 3684 if (mCalendar->journals().count() > 0) {
3681 int result = KMessageBox::warningContinueCancel(this, 3685 int result = KMessageBox::warningContinueCancel(this,
3682 i18n("The journal entries can not be\nexported to a vCalendar file."), 3686 i18n("The journal entries can not be\nexported to a vCalendar file."),
3683 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3687 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3684 true); 3688 true);
3685 if (result != KMessageBox::Continue) return false; 3689 if (result != KMessageBox::Continue) return false;
3686 } 3690 }
3687 3691
3688 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3692 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3689 3693
3690 // Force correct extension 3694 // Force correct extension
3691 if (filename.right(4) != ".vcs") filename += ".vcs"; 3695 if (filename.right(4) != ".vcs") filename += ".vcs";
3692 3696
3693 FileStorage storage( mCalendar, filename, new VCalFormat ); 3697 FileStorage storage( mCalendar, filename, new VCalFormat );
3694 return storage.save(); 3698 return storage.save();
3695 3699
3696} 3700}
3697 3701
3698void CalendarView::eventUpdated(Incidence *) 3702void CalendarView::eventUpdated(Incidence *)
3699{ 3703{
3700 setModified(); 3704 setModified();
3701 // Don't call updateView here. The code, which has caused the update of the 3705 // Don't call updateView here. The code, which has caused the update of the
3702 // event is responsible for updating the view. 3706 // event is responsible for updating the view.
3703 // updateView(); 3707 // updateView();
3704} 3708}
3705 3709
3706void CalendarView::adaptNavigationUnits() 3710void CalendarView::adaptNavigationUnits()
3707{ 3711{
3708 if (mViewManager->currentView()->isEventView()) { 3712 if (mViewManager->currentView()->isEventView()) {
3709 int days = mViewManager->currentView()->currentDateCount(); 3713 int days = mViewManager->currentView()->currentDateCount();
3710 if (days == 1) { 3714 if (days == 1) {
3711 emit changeNavStringPrev(i18n("&Previous Day")); 3715 emit changeNavStringPrev(i18n("&Previous Day"));
3712 emit changeNavStringNext(i18n("&Next Day")); 3716 emit changeNavStringNext(i18n("&Next Day"));
3713 } else { 3717 } else {
3714 emit changeNavStringPrev(i18n("&Previous Week")); 3718 emit changeNavStringPrev(i18n("&Previous Week"));
3715 emit changeNavStringNext(i18n("&Next Week")); 3719 emit changeNavStringNext(i18n("&Next Week"));
3716 } 3720 }
3717 } 3721 }
3718} 3722}
3719 3723
3720void CalendarView::processMainViewSelection( Incidence *incidence ) 3724void CalendarView::processMainViewSelection( Incidence *incidence )
3721{ 3725{
3722 if ( incidence ) mTodoList->clearSelection(); 3726 if ( incidence ) mTodoList->clearSelection();
3723 processIncidenceSelection( incidence ); 3727 processIncidenceSelection( incidence );
3724} 3728}
3725 3729
3726void CalendarView::processTodoListSelection( Incidence *incidence ) 3730void CalendarView::processTodoListSelection( Incidence *incidence )
3727{ 3731{
3728 if ( incidence && mViewManager->currentView() ) { 3732 if ( incidence && mViewManager->currentView() ) {
3729 mViewManager->currentView()->clearSelection(); 3733 mViewManager->currentView()->clearSelection();
3730 } 3734 }
3731 processIncidenceSelection( incidence ); 3735 processIncidenceSelection( incidence );
3732} 3736}
3733 3737
3734void CalendarView::processIncidenceSelection( Incidence *incidence ) 3738void CalendarView::processIncidenceSelection( Incidence *incidence )
3735{ 3739{
3736 if ( incidence == mSelectedIncidence ) return; 3740 if ( incidence == mSelectedIncidence ) return;
3737 3741
3738 mSelectedIncidence = incidence; 3742 mSelectedIncidence = incidence;
3739 3743
3740 emit incidenceSelected( mSelectedIncidence ); 3744 emit incidenceSelected( mSelectedIncidence );
3741 3745
3742 if ( incidence && incidence->type() == "Event" ) { 3746 if ( incidence && incidence->type() == "Event" ) {
3743 Event *event = static_cast<Event *>( incidence ); 3747 Event *event = static_cast<Event *>( incidence );
3744 if ( event->organizer() == KOPrefs::instance()->email() ) { 3748 if ( event->organizer() == KOPrefs::instance()->email() ) {
3745 emit organizerEventsSelected( true ); 3749 emit organizerEventsSelected( true );
3746 } else { 3750 } else {
3747 emit organizerEventsSelected(false); 3751 emit organizerEventsSelected(false);
3748 } 3752 }
3749 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3753 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3750 KOPrefs::instance()->email() ) ) { 3754 KOPrefs::instance()->email() ) ) {
3751 emit groupEventsSelected( true ); 3755 emit groupEventsSelected( true );
3752 } else { 3756 } else {
3753 emit groupEventsSelected(false); 3757 emit groupEventsSelected(false);
3754 } 3758 }
3755 return; 3759 return;
3756 } else { 3760 } else {
3757 if ( incidence && incidence->type() == "Todo" ) { 3761 if ( incidence && incidence->type() == "Todo" ) {
3758 emit todoSelected( true ); 3762 emit todoSelected( true );
3759 Todo *event = static_cast<Todo *>( incidence ); 3763 Todo *event = static_cast<Todo *>( incidence );
3760 if ( event->organizer() == KOPrefs::instance()->email() ) { 3764 if ( event->organizer() == KOPrefs::instance()->email() ) {
3761 emit organizerEventsSelected( true ); 3765 emit organizerEventsSelected( true );
3762 } else { 3766 } else {
3763 emit organizerEventsSelected(false); 3767 emit organizerEventsSelected(false);
3764 } 3768 }
3765 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3769 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3766 KOPrefs::instance()->email() ) ) { 3770 KOPrefs::instance()->email() ) ) {
3767 emit groupEventsSelected( true ); 3771 emit groupEventsSelected( true );
3768 } else { 3772 } else {
3769 emit groupEventsSelected(false); 3773 emit groupEventsSelected(false);
3770 } 3774 }
3771 return; 3775 return;
3772 } else { 3776 } else {
3773 emit todoSelected( false ); 3777 emit todoSelected( false );
3774 emit organizerEventsSelected(false); 3778 emit organizerEventsSelected(false);
3775 emit groupEventsSelected(false); 3779 emit groupEventsSelected(false);
3776 } 3780 }
3777 return; 3781 return;
3778 } 3782 }
3779 3783
3780 /* if ( incidence && incidence->type() == "Todo" ) { 3784 /* if ( incidence && incidence->type() == "Todo" ) {
3781 emit todoSelected( true ); 3785 emit todoSelected( true );
3782 } else { 3786 } else {
3783 emit todoSelected( false ); 3787 emit todoSelected( false );
3784 }*/ 3788 }*/
3785} 3789}
3786 3790
3787 3791
3788void CalendarView::checkClipboard() 3792void CalendarView::checkClipboard()
3789{ 3793{
3790#ifndef KORG_NODND 3794#ifndef KORG_NODND
3791 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3795 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3792 emit pasteEnabled(true); 3796 emit pasteEnabled(true);
3793 } else { 3797 } else {
3794 emit pasteEnabled(false); 3798 emit pasteEnabled(false);
3795 } 3799 }
3796#endif 3800#endif
3797} 3801}
3798 3802
3799void CalendarView::showDates(const DateList &selectedDates) 3803void CalendarView::showDates(const DateList &selectedDates)
3800{ 3804{
3801 // kdDebug() << "CalendarView::selectDates()" << endl; 3805 // kdDebug() << "CalendarView::selectDates()" << endl;
3802 3806
3803 3807
3804 if ( !mBlockShowDates ) { 3808 if ( !mBlockShowDates ) {
3805 if ( mViewManager->currentView() ) { 3809 if ( mViewManager->currentView() ) {
3806 updateView( selectedDates.first(), selectedDates.last() ); 3810 updateView( selectedDates.first(), selectedDates.last() );
3807 } else { 3811 } else {
3808 mViewManager->showAgendaView(); 3812 mViewManager->showAgendaView();
3809 } 3813 }
3810 } 3814 }
3811 3815
3812 QDate date = selectedDates.first(); 3816 QDate date = selectedDates.first();
3813 if ( ! date.isValid() ) { 3817 if ( ! date.isValid() ) {
3814 topLevelWidget()->setCaption(""); 3818 topLevelWidget()->setCaption("");
3815 return; 3819 return;
3816 } 3820 }
3817 3821
3818 QString selDates; 3822 QString selDates;
3819 selDates = KGlobal::locale()->formatDate( date, true); 3823 selDates = KGlobal::locale()->formatDate( date, true);
3820 if (selectedDates.first() < selectedDates.last() ) 3824 if (selectedDates.first() < selectedDates.last() )
3821 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3825 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3822 else { 3826 else {
3823 QString addString; 3827 QString addString;
3824 if ( date == QDateTime::currentDateTime().date() ) 3828 if ( date == QDateTime::currentDateTime().date() )
3825 addString = i18n("Today"); 3829 addString = i18n("Today");
3826 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3830 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3827 addString = i18n("Tomorrow"); 3831 addString = i18n("Tomorrow");
3828 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3832 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3829 addString = i18n("Yesterday"); 3833 addString = i18n("Yesterday");
3830 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3834 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3831 addString = i18n("Day before yesterday"); 3835 addString = i18n("Day before yesterday");
3832 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3836 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3833 addString = i18n("Day after tomorrow"); 3837 addString = i18n("Day after tomorrow");
3834 if ( !addString.isEmpty() ) { 3838 if ( !addString.isEmpty() ) {
3835 topLevelWidget()->setCaption( addString+", " + selDates ); 3839 topLevelWidget()->setCaption( addString+", " + selDates );
3836 return; 3840 return;
3837 } 3841 }
3838 } 3842 }
3839 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3843 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3840 3844
3841} 3845}
3842 3846
3843QPtrList<CalFilter> CalendarView::filters() 3847QPtrList<CalFilter> CalendarView::filters()
3844{ 3848{
3845 return mFilters; 3849 return mFilters;
3846 3850
3847} 3851}
3848void CalendarView::editFilters() 3852void CalendarView::editFilters()
3849{ 3853{
3850 // kdDebug() << "CalendarView::editFilters()" << endl; 3854 // kdDebug() << "CalendarView::editFilters()" << endl;
3851 3855
3852 CalFilter *filter = mFilters.first(); 3856 CalFilter *filter = mFilters.first();
3853 while(filter) { 3857 while(filter) {
3854 kdDebug() << " Filter: " << filter->name() << endl; 3858 kdDebug() << " Filter: " << filter->name() << endl;
3855 filter = mFilters.next(); 3859 filter = mFilters.next();
3856 } 3860 }
3857 3861
3858 mDialogManager->showFilterEditDialog(&mFilters); 3862 mDialogManager->showFilterEditDialog(&mFilters);
3859} 3863}
3860void CalendarView::toggleFilter() 3864void CalendarView::toggleFilter()
3861{ 3865{
3862 showFilter(! mFilterView->isVisible()); 3866 showFilter(! mFilterView->isVisible());
3863} 3867}
3864 3868
3865KOFilterView *CalendarView::filterView() 3869KOFilterView *CalendarView::filterView()
3866{ 3870{
3867 return mFilterView; 3871 return mFilterView;
3868} 3872}
3869void CalendarView::selectFilter( int fil ) 3873void CalendarView::selectFilter( int fil )
3870{ 3874{
3871 mFilterView->setSelectedFilter( fil ); 3875 mFilterView->setSelectedFilter( fil );
3872} 3876}
3873void CalendarView::showFilter(bool visible) 3877void CalendarView::showFilter(bool visible)
3874{ 3878{
3875 if (visible) mFilterView->show(); 3879 if (visible) mFilterView->show();
3876 else mFilterView->hide(); 3880 else mFilterView->hide();
3877} 3881}
3878void CalendarView::toggleFilerEnabled( ) 3882void CalendarView::toggleFilerEnabled( )
3879{ 3883{
3880 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3884 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3881 if ( !mFilterView->filtersEnabled() ) 3885 if ( !mFilterView->filtersEnabled() )
3882 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3886 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3883 3887
3884} 3888}
3885void CalendarView::updateFilter() 3889void CalendarView::updateFilter()
3886{ 3890{
3887 CalFilter *filter = mFilterView->selectedFilter(); 3891 CalFilter *filter = mFilterView->selectedFilter();
3888 if (filter) { 3892 if (filter) {
3889 QString mess; 3893 QString mess;
3890 if (mFilterView->filtersEnabled()) { 3894 if (mFilterView->filtersEnabled()) {
3891 mess = i18n("Filter selected: ")+filter->name(); 3895 mess = i18n("Filter selected: ")+filter->name();
3892 filter->setEnabled(true); 3896 filter->setEnabled(true);
3893 } 3897 }
3894 else filter->setEnabled(false); 3898 else filter->setEnabled(false);
3895 mCalendar->setFilter(filter); 3899 mCalendar->setFilter(filter);
3896 updateView(); 3900 updateView();
3897 if ( !mess.isEmpty() ) 3901 if ( !mess.isEmpty() )
3898 topLevelWidget()->setCaption( mess ); 3902 topLevelWidget()->setCaption( mess );
3899 3903
3900 } 3904 }
3901} 3905}
3902 3906
3903void CalendarView::filterEdited() 3907void CalendarView::filterEdited()
3904{ 3908{
3905 mFilterView->updateFilters(); 3909 mFilterView->updateFilters();
3906 updateFilter(); 3910 updateFilter();
3907 writeSettings(); 3911 writeSettings();
3908} 3912}
3909 3913
3910 3914
3911void CalendarView::takeOverEvent() 3915void CalendarView::takeOverEvent()
3912{ 3916{
3913 Incidence *incidence = currentSelection(); 3917 Incidence *incidence = currentSelection();
3914 3918
3915 if (!incidence) return; 3919 if (!incidence) return;
3916 3920
3917 incidence->setOrganizer(KOPrefs::instance()->email()); 3921 incidence->setOrganizer(KOPrefs::instance()->email());
3918 incidence->recreate(); 3922 incidence->recreate();
3919 incidence->setReadOnly(false); 3923 incidence->setReadOnly(false);
3920 3924
3921 updateView(); 3925 updateView();
3922} 3926}
3923 3927
3924void CalendarView::takeOverCalendar() 3928void CalendarView::takeOverCalendar()
3925{ 3929{
3926 // TODO: Create Calendar::allIncidences() function and use it here 3930 // TODO: Create Calendar::allIncidences() function and use it here
3927 3931
3928 QPtrList<Event> events = mCalendar->events(); 3932 QPtrList<Event> events = mCalendar->events();
3929 for(uint i=0; i<events.count(); ++i) { 3933 for(uint i=0; i<events.count(); ++i) {
3930 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3934 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3931 events.at(i)->recreate(); 3935 events.at(i)->recreate();
3932 events.at(i)->setReadOnly(false); 3936 events.at(i)->setReadOnly(false);
3933 } 3937 }
3934 3938
3935 QPtrList<Todo> todos = mCalendar->todos(); 3939 QPtrList<Todo> todos = mCalendar->todos();
3936 for(uint i=0; i<todos.count(); ++i) { 3940 for(uint i=0; i<todos.count(); ++i) {
3937 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3941 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3938 todos.at(i)->recreate(); 3942 todos.at(i)->recreate();
3939 todos.at(i)->setReadOnly(false); 3943 todos.at(i)->setReadOnly(false);
3940 } 3944 }
3941 3945
3942 QPtrList<Journal> journals = mCalendar->journals(); 3946 QPtrList<Journal> journals = mCalendar->journals();
3943 for(uint i=0; i<journals.count(); ++i) { 3947 for(uint i=0; i<journals.count(); ++i) {
3944 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3948 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3945 journals.at(i)->recreate(); 3949 journals.at(i)->recreate();
3946 journals.at(i)->setReadOnly(false); 3950 journals.at(i)->setReadOnly(false);
3947 } 3951 }
3948 3952
3949 updateView(); 3953 updateView();
3950} 3954}
3951 3955
3952void CalendarView::showIntro() 3956void CalendarView::showIntro()
3953{ 3957{
3954 kdDebug() << "To be implemented." << endl; 3958 kdDebug() << "To be implemented." << endl;
3955} 3959}
3956 3960
3957QWidgetStack *CalendarView::viewStack() 3961QWidgetStack *CalendarView::viewStack()
3958{ 3962{
3959 return mRightFrame; 3963 return mRightFrame;
3960} 3964}
3961 3965
3962QWidget *CalendarView::leftFrame() 3966QWidget *CalendarView::leftFrame()
3963{ 3967{
3964 return ( QWidget *)mLeftFrame; 3968 return ( QWidget *)mLeftFrame;
3965} 3969}
3966 3970
3967DateNavigator *CalendarView::dateNavigator() 3971DateNavigator *CalendarView::dateNavigator()
3968{ 3972{
3969 return mNavigator; 3973 return mNavigator;
3970} 3974}
3971 3975
3972KDateNavigator* CalendarView::dateNavigatorWidget() 3976KDateNavigator* CalendarView::dateNavigatorWidget()
3973{ 3977{
3974 return mDateNavigator->navigatorView(); 3978 return mDateNavigator->navigatorView();
3975} 3979}
3976void CalendarView::toggleDateNavigatorWidget() 3980void CalendarView::toggleDateNavigatorWidget()
3977{ 3981{
3978 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3982 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3979 3983
3980 if (!KOPrefs::instance()->mShowDateNavigator ) 3984 if (!KOPrefs::instance()->mShowDateNavigator )
3981 mDateNavigator->hide(); 3985 mDateNavigator->hide();
3982 else 3986 else
3983 mDateNavigator->show(); 3987 mDateNavigator->show();
3984} 3988}
3985void CalendarView::addView(KOrg::BaseView *view) 3989void CalendarView::addView(KOrg::BaseView *view)
3986{ 3990{
3987 mViewManager->addView(view); 3991 mViewManager->addView(view);
3988} 3992}
3989 3993
3990void CalendarView::showView(KOrg::BaseView *view) 3994void CalendarView::showView(KOrg::BaseView *view)
3991{ 3995{
3992 mViewManager->showView(view, mLeftFrame->isVisible()); 3996 mViewManager->showView(view, mLeftFrame->isVisible());
3993} 3997}
3994 3998
3995Incidence *CalendarView::currentSelection() 3999Incidence *CalendarView::currentSelection()
3996{ 4000{
3997 return mViewManager->currentSelection(); 4001 return mViewManager->currentSelection();
3998} 4002}
3999void CalendarView::toggleAllDaySize() 4003void CalendarView::toggleAllDaySize()
4000{ 4004{
4001 /* 4005 /*
4002 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4006 if ( KOPrefs::instance()->mAllDaySize > 47 )
4003 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4007 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4004 else 4008 else
4005 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4009 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4006 */ 4010 */
4007 viewManager()->agendaView()->toggleAllDay(); 4011 viewManager()->agendaView()->toggleAllDay();
4008} 4012}
4009void CalendarView::toggleExpand() 4013void CalendarView::toggleExpand()
4010{ 4014{
4011 // if ( mLeftFrame->isHidden() ) { 4015 // if ( mLeftFrame->isHidden() ) {
4012 // mLeftFrame->show(); 4016 // mLeftFrame->show();
4013 // emit calendarViewExpanded( false ); 4017 // emit calendarViewExpanded( false );
4014 // } else { 4018 // } else {
4015 // mLeftFrame->hide(); 4019 // mLeftFrame->hide();
4016 // emit calendarViewExpanded( true ); 4020 // emit calendarViewExpanded( true );
4017 // } 4021 // }
4018 //qDebug(" CalendarView::toggleExpand()"); 4022 //qDebug(" CalendarView::toggleExpand()");
4019 globalFlagBlockAgenda = 1; 4023 globalFlagBlockAgenda = 1;
4020 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4024 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4021 globalFlagBlockAgenda = 5; 4025 globalFlagBlockAgenda = 5;
4022 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4026 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4023 //mViewManager->showView( 0, true ); 4027 //mViewManager->showView( 0, true );
4024} 4028}
4025 4029
4026void CalendarView::calendarModified( bool modified, Calendar * ) 4030void CalendarView::calendarModified( bool modified, Calendar * )
4027{ 4031{
4028 setModified( modified ); 4032 setModified( modified );
4029} 4033}
4030 4034
4031Todo *CalendarView::selectedTodo() 4035Todo *CalendarView::selectedTodo()
4032{ 4036{
4033 Incidence *incidence = currentSelection(); 4037 Incidence *incidence = currentSelection();
4034 if ( incidence && incidence->type() == "Todo" ) { 4038 if ( incidence && incidence->type() == "Todo" ) {
4035 return static_cast<Todo *>( incidence ); 4039 return static_cast<Todo *>( incidence );
4036 } 4040 }
4037 4041
4038 incidence = mTodoList->selectedIncidences().first(); 4042 incidence = mTodoList->selectedIncidences().first();
4039 if ( incidence && incidence->type() == "Todo" ) { 4043 if ( incidence && incidence->type() == "Todo" ) {
4040 return static_cast<Todo *>( incidence ); 4044 return static_cast<Todo *>( incidence );
4041 } 4045 }
4042 4046
4043 return 0; 4047 return 0;
4044} 4048}
4045 4049
4046void CalendarView::dialogClosing(Incidence *in) 4050void CalendarView::dialogClosing(Incidence *in)
4047{ 4051{
4048 // mDialogList.remove(in); 4052 // mDialogList.remove(in);
4049} 4053}
4050 4054
4051void CalendarView::showIncidence() 4055void CalendarView::showIncidence()
4052{ 4056{
4053 mViewerCallerIsSearchDialog = false; 4057 mViewerCallerIsSearchDialog = false;
4054 Incidence *incidence = currentSelection(); 4058 Incidence *incidence = currentSelection();
4055 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4059 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4056 if ( incidence ) { 4060 if ( incidence ) {
4057 ShowIncidenceVisitor v; 4061 ShowIncidenceVisitor v;
4058 v.act( incidence, this ); 4062 v.act( incidence, this );
4059 } 4063 }
4060} 4064}
4061void CalendarView::editIncidenceDescription() 4065void CalendarView::editIncidenceDescription()
4062{ 4066{
4063 mFlagEditDescription = true; 4067 mFlagEditDescription = true;
4064 editIncidence(); 4068 editIncidence();
4065 mFlagEditDescription = false; 4069 mFlagEditDescription = false;
4066} 4070}
4067void CalendarView::editIncidence() 4071void CalendarView::editIncidence()
4068{ 4072{
4069 // qDebug("editIncidence() "); 4073 // qDebug("editIncidence() ");
4070 Incidence *incidence = currentSelection(); 4074 Incidence *incidence = currentSelection();
4071 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4075 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4072 if ( incidence ) { 4076 if ( incidence ) {
4073 EditIncidenceVisitor v; 4077 EditIncidenceVisitor v;
4074 v.act( incidence, this ); 4078 v.act( incidence, this );
4075 } 4079 }
4076} 4080}
4077 4081
4078void CalendarView::deleteIncidence() 4082void CalendarView::deleteIncidence()
4079{ 4083{
4080 Incidence *incidence = currentSelection(); 4084 Incidence *incidence = currentSelection();
4081 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4085 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4082 if ( incidence ) { 4086 if ( incidence ) {
4083 deleteIncidence(incidence); 4087 deleteIncidence(incidence);
4084 } 4088 }
4085} 4089}
4086void CalendarView::showIncidence(QString uid) 4090void CalendarView::showIncidence(QString uid)
4087{ 4091{
4088 Incidence *inc = mCalendar->incidence( uid ); 4092 Incidence *inc = mCalendar->incidence( uid );
4089 if ( inc ) 4093 if ( inc )
4090 showIncidence( inc ); 4094 showIncidence( inc );
4091} 4095}
4092void CalendarView::showIncidence(Incidence *incidence) 4096void CalendarView::showIncidence(Incidence *incidence)
4093{ 4097{
4094 mViewerCallerIsSearchDialog = false; 4098 mViewerCallerIsSearchDialog = false;
4095 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4099 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4096 if ( sender() && mDialogManager->getSearchDialog() ) { 4100 if ( sender() && mDialogManager->getSearchDialog() ) {
4097 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4101 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4098 mViewerCallerIsSearchDialog = true; 4102 mViewerCallerIsSearchDialog = true;
4099 } 4103 }
4100 } 4104 }
4101 if ( incidence ) { 4105 if ( incidence ) {
4102 ShowIncidenceVisitor v; 4106 ShowIncidenceVisitor v;
4103 v.act( incidence, this ); 4107 v.act( incidence, this );
4104 } 4108 }
4105} 4109}
4106 4110
4107void CalendarView::editIncidence(Incidence *incidence) 4111void CalendarView::editIncidence(Incidence *incidence)
4108{ 4112{
4109 if ( incidence ) { 4113 if ( incidence ) {
4110 4114
4111 EditIncidenceVisitor v; 4115 EditIncidenceVisitor v;
4112 v.act( incidence, this ); 4116 v.act( incidence, this );
4113 4117
4114 } 4118 }
4115} 4119}
4116 4120
4117void CalendarView::deleteIncidence(Incidence *incidence) 4121void CalendarView::deleteIncidence(Incidence *incidence)
4118{ 4122{
4119 //qDebug(" CalendarView::deleteIncidence "); 4123 //qDebug(" CalendarView::deleteIncidence ");
4120 if ( incidence ) { 4124 if ( incidence ) {
4121 DeleteIncidenceVisitor v; 4125 DeleteIncidenceVisitor v;
4122 v.act( incidence, this ); 4126 v.act( incidence, this );
4123 } 4127 }
4124} 4128}
4125 4129
4126 4130
4127void CalendarView::lookForOutgoingMessages() 4131void CalendarView::lookForOutgoingMessages()
4128{ 4132{
4129 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4133 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4130 ogd->loadMessages(); 4134 ogd->loadMessages();
4131} 4135}
4132 4136
4133void CalendarView::lookForIncomingMessages() 4137void CalendarView::lookForIncomingMessages()
4134{ 4138{
4135 IncomingDialog *icd = mDialogManager->incomingDialog(); 4139 IncomingDialog *icd = mDialogManager->incomingDialog();
4136 icd->retrieve(); 4140 icd->retrieve();
4137} 4141}
4138 4142
4139bool CalendarView::removeCompletedSubTodos( Todo* t ) 4143bool CalendarView::removeCompletedSubTodos( Todo* t )
4140{ 4144{
4141 bool deleteTodo = true; 4145 bool deleteTodo = true;
4142 QPtrList<Incidence> subTodos; 4146 QPtrList<Incidence> subTodos;
4143 Incidence *aTodo; 4147 Incidence *aTodo;
4144 subTodos = t->relations(); 4148 subTodos = t->relations();
4145 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4149 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4146 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4150 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4147 deleteTodo = false; 4151 deleteTodo = false;
4148 } 4152 }
4149 if ( deleteTodo ) { 4153 if ( deleteTodo ) {
4150 if ( t->isCompleted() && !t->doesRecur()) { 4154 if ( t->isCompleted() && !t->doesRecur()) {
4151 checkExternalId( t ); 4155 checkExternalId( t );
4152 mCalendar->deleteTodo( t ); 4156 mCalendar->deleteTodo( t );
4153 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4157 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4154 } 4158 }
4155 else 4159 else
4156 deleteTodo = false; 4160 deleteTodo = false;
4157 } 4161 }
4158 return deleteTodo; 4162 return deleteTodo;
4159 4163
4160} 4164}
4161void CalendarView::purgeCompleted() 4165void CalendarView::purgeCompleted()
4162{ 4166{
4163 int result = KMessageBox::warningContinueCancel(this, 4167 int result = KMessageBox::warningContinueCancel(this,
4164 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4168 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4165 4169
4166 if (result == KMessageBox::Continue) { 4170 if (result == KMessageBox::Continue) {
4167 4171
4168 QPtrList<Todo> todoCal; 4172 QPtrList<Todo> todoCal;
4169 QPtrList<Todo> rootTodos; 4173 QPtrList<Todo> rootTodos;
4170 //QPtrList<Incidence> rel; 4174 //QPtrList<Incidence> rel;
4171 Todo *aTodo;//, *rTodo; 4175 Todo *aTodo;//, *rTodo;
4172 Incidence *rIncidence; 4176 Incidence *rIncidence;
4173 bool childDelete = false; 4177 bool childDelete = false;
4174 bool deletedOne = true; 4178 bool deletedOne = true;
4175 todoCal = calendar()->todos(); 4179 todoCal = calendar()->todos();
4176 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4180 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4177 if ( !aTodo->relatedTo() ) 4181 if ( !aTodo->relatedTo() )
4178 rootTodos.append( aTodo ); 4182 rootTodos.append( aTodo );
4179 } 4183 }
4180 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4184 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4181 removeCompletedSubTodos( aTodo ); 4185 removeCompletedSubTodos( aTodo );
4182 } 4186 }
4183 4187
4184 updateView(); 4188 updateView();
4185 } 4189 }
4186} 4190}
4187 4191
4188void CalendarView::slotCalendarChanged() 4192void CalendarView::slotCalendarChanged()
4189{ 4193{
4190 ; 4194 ;
4191} 4195}
4192 4196
4193void CalendarView::keyPressEvent ( QKeyEvent *e) 4197void CalendarView::keyPressEvent ( QKeyEvent *e)
4194{ 4198{
4195 //qDebug(" alendarView::keyPressEvent "); 4199 //qDebug(" alendarView::keyPressEvent ");
4196 e->ignore(); 4200 e->ignore();
4197} 4201}
4198 4202
4199 4203
4200bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4204bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4201{ 4205{
4202 // mSyncManager = manager; 4206 // mSyncManager = manager;
4203 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4207 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4204 qDebug("KO: SyncKDE request detected!"); 4208 qDebug("KO: SyncKDE request detected!");
4205 } 4209 }
4206 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4210 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4207 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4211 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4208 return syncCalendar( filename, mode ); 4212 return syncCalendar( filename, mode );
4209} 4213}
4210bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4214bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4211{ 4215{
4212 //mSyncManager = manager; 4216 //mSyncManager = manager;
4213 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4217 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4214 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4218 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4215 if ( resource == "sharp" ) 4219 if ( resource == "sharp" )
4216 syncExternal( 0 ); 4220 syncExternal( 0 );
4217 if ( resource == "phone" ) 4221 if ( resource == "phone" )
4218 syncExternal( 1 ); 4222 syncExternal( 1 );
4219 // pending setmodified 4223 // pending setmodified
4220 return true; 4224 return true;
4221} 4225}
4222void CalendarView::setSyncManager(KSyncManager* manager) 4226void CalendarView::setSyncManager(KSyncManager* manager)
4223{ 4227{
4224 mSyncManager = manager; 4228 mSyncManager = manager;
4225} 4229}
4226 4230
4227void CalendarView::removeSyncInfo( QString syncProfile) 4231void CalendarView::removeSyncInfo( QString syncProfile)
4228{ 4232{
4229 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4233 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4230 mCalendar->removeSyncInfo( syncProfile ); 4234 mCalendar->removeSyncInfo( syncProfile );
4231 4235
4232} 4236}
4233 4237
4234void CalendarView::undo_delete() 4238void CalendarView::undo_delete()
4235{ 4239{
4236 //qDebug("undo_delete() "); 4240 //qDebug("undo_delete() ");
4237 Incidence* undo = mCalendar->undoIncidence(); 4241 Incidence* undo = mCalendar->undoIncidence();
4238 if ( !undo ) { 4242 if ( !undo ) {
4239 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4243 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4240 i18n("KO/Pi")); 4244 i18n("KO/Pi"));
4241 return; 4245 return;
4242 } 4246 }
4243 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4247 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4244 i18n("\nAre you sure you want\nto restore this?"), 4248 i18n("\nAre you sure you want\nto restore this?"),
4245 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4249 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4246 mCalendar->undoDeleteIncidence(); 4250 mCalendar->undoDeleteIncidence();
4247 updateView(); 4251 updateView();
4248 } 4252 }
4249} 4253}
4250 4254
4251void CalendarView::slotViewerClosed() 4255void CalendarView::slotViewerClosed()
4252{ 4256{
4253 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4257 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4254} 4258}
4255 4259
4256void CalendarView::resetFocus() 4260void CalendarView::resetFocus()
4257{ 4261{
4258 if ( mViewerCallerIsSearchDialog ) { 4262 if ( mViewerCallerIsSearchDialog ) {
4259 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4263 if ( mDialogManager->getSearchDialog()->isVisible() ){
4260 mDialogManager->getSearchDialog()->raise(); 4264 mDialogManager->getSearchDialog()->raise();
4261 mDialogManager->getSearchDialog()->setActiveWindow(); 4265 mDialogManager->getSearchDialog()->setActiveWindow();
4262 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4266 mDialogManager->getSearchDialog()->listview()->resetFocus();
4263 } else 4267 } else
4264 mViewerCallerIsSearchDialog = false; 4268 mViewerCallerIsSearchDialog = false;
4265 } 4269 }
4266 if ( !mViewerCallerIsSearchDialog ) { 4270 if ( !mViewerCallerIsSearchDialog ) {
4267 //mViewManager->currentView()->setFocus(); 4271 //mViewManager->currentView()->setFocus();
4268 //qDebug("sssssssssssssssset focus "); 4272 //qDebug("sssssssssssssssset focus ");
4269 topLevelWidget()->raise(); 4273 topLevelWidget()->raise();
4270 setActiveWindow(); 4274 setActiveWindow();
4271 //setFocus(); 4275 //setFocus();
4272 } 4276 }
4273 mViewerCallerIsSearchDialog = false; 4277 mViewerCallerIsSearchDialog = false;
4274} 4278}
4275 4279
4276void CalendarView::showNextAlarms() 4280void CalendarView::showNextAlarms()
4277{ 4281{
4278 QString message; 4282 QString message;
4279 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4283 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4280 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4284 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4281 QString sum = mCalendar->nextSummary(); 4285 QString sum = mCalendar->nextSummary();
4282 QDateTime nextA = mNextAlarmDateTime; 4286 QDateTime nextA = mNextAlarmDateTime;
4283 QDateTime cur = QDateTime::currentDateTime(); 4287 QDateTime cur = QDateTime::currentDateTime();
4284 int secs = cur.secsTo( nextA ); 4288 int secs = cur.secsTo( nextA );
4285 int min = secs /60; 4289 int min = secs /60;
4286 int hours = min /60; 4290 int hours = min /60;
4287 min = min % 60; 4291 min = min % 60;
4288 int days = hours /24; 4292 int days = hours /24;
4289 hours = hours % 24; 4293 hours = hours % 24;
4290 4294
4291 //message = i18n("The next alarm is in:\n"); 4295 //message = i18n("The next alarm is in:\n");
4292 if ( days > 1 ) 4296 if ( days > 1 )
4293 message += i18n("%1 days\n").arg( days ); 4297 message += i18n("%1 days\n").arg( days );
4294 else if ( days == 1 ) 4298 else if ( days == 1 )
4295 message += i18n("1 day\n"); 4299 message += i18n("1 day\n");
4296 if ( hours > 1 ) 4300 if ( hours > 1 )
4297 message += i18n("%1 hours\n").arg( hours ); 4301 message += i18n("%1 hours\n").arg( hours );
4298 else if ( hours == 1 ) 4302 else if ( hours == 1 )
4299 message += i18n("1 hour\n"); 4303 message += i18n("1 hour\n");
4300 if ( min > 1 ) 4304 if ( min > 1 )
4301 message += i18n("%1 minutes\n").arg( min ); 4305 message += i18n("%1 minutes\n").arg( min );
4302 else if ( min == 1 ) 4306 else if ( min == 1 )
4303 message += i18n("1 minute\n"); 4307 message += i18n("1 minute\n");
4304 if ( message.isEmpty() ) 4308 if ( message.isEmpty() )
4305 message = i18n("The next alarm is in\nless than one minute!"); 4309 message = i18n("The next alarm is in\nless than one minute!");
4306 else 4310 else
4307 message = i18n("The next alarm is in:\n") + message; 4311 message = i18n("The next alarm is in:\n") + message;
4308 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4312 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4309 } else { 4313 } else {
4310 message = i18n("There is no next alarm."); 4314 message = i18n("There is no next alarm.");
4311 4315
4312 } 4316 }
4313#ifdef DESKTOP_VERSION 4317#ifdef DESKTOP_VERSION
4314 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4318 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4315 message += i18n("\nThe internal alarm notification is disabled!\n"); 4319 message += i18n("\nThe internal alarm notification is disabled!\n");
4316 message += i18n("Enable it in the settings menu, TAB alarm."); 4320 message += i18n("Enable it in the settings menu, TAB alarm.");
4317 } 4321 }
4318 4322
4319#endif 4323#endif
4320 KMessageBox::information( this, message); 4324 KMessageBox::information( this, message);
4321} 4325}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 1eca905..084b6db 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,640 +1,641 @@
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#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <KDGanttMinimizeSplitter.h> 42#include <KDGanttMinimizeSplitter.h>
43 43
44#include <korganizer/calendarviewbase.h> 44#include <korganizer/calendarviewbase.h>
45 45
46#include <ksyncmanager.h> 46#include <ksyncmanager.h>
47 47
48class QWidgetStack; 48class QWidgetStack;
49class QSplitter; 49class QSplitter;
50 50
51class CalPrinter; 51class CalPrinter;
52class KOFilterView; 52class KOFilterView;
53class KOViewManager; 53class KOViewManager;
54class KODialogManager; 54class KODialogManager;
55class KOTodoView; 55class KOTodoView;
56class KDateNavigator; 56class KDateNavigator;
57class DateNavigatorContainer; 57class DateNavigatorContainer;
58class DateNavigator; 58class DateNavigator;
59class KOIncidenceEditor; 59class KOIncidenceEditor;
60class KDatePicker; 60class KDatePicker;
61class ResourceView; 61class ResourceView;
62class KOEventEditor; 62class KOEventEditor;
63class KOTodoEditor ; 63class KOTodoEditor ;
64class KOEventViewerDialog; 64class KOEventViewerDialog;
65class KOBeamPrefs; 65class KOBeamPrefs;
66class KSyncProfile; 66class KSyncProfile;
67class AlarmDialog; 67class AlarmDialog;
68class KCal::Attendee; 68class KCal::Attendee;
69 69
70namespace KCal { class FileStorage; } 70namespace KCal { class FileStorage; }
71 71
72using namespace KCal; 72using namespace KCal;
73 73
74/** 74/**
75 This is the main calendar widget. It provides the different vies on t he 75 This is the main calendar widget. It provides the different vies on t he
76 calendar data as well as the date navigator. It also handles synchronisation 76 calendar data as well as the date navigator. It also handles synchronisation
77 of the different views and controls the different dialogs like preferences, 77 of the different views and controls the different dialogs like preferences,
78 event editor, search dialog etc. 78 event editor, search dialog etc.
79 79
80 @short main calendar view widget 80 @short main calendar view widget
81 @author Cornelius Schumacher 81 @author Cornelius Schumacher
82*/ 82*/
83 83
84#include <qtextbrowser.h> 84#include <qtextbrowser.h>
85#include <qtextcodec.h> 85#include <qtextcodec.h>
86 86
87class MissedAlarmTextBrowser : public QTextBrowser { 87class MissedAlarmTextBrowser : public QTextBrowser {
88 Q_OBJECT 88 Q_OBJECT
89 public: 89 public:
90 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 90 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
91 ~MissedAlarmTextBrowser();
91 void setSource(const QString & n); 92 void setSource(const QString & n);
92 93
93 private: 94 private:
94 Incidence * getNextInc(QDateTime start ); 95 Incidence * getNextInc(QDateTime start );
95 QPtrList<Incidence> mAlarms; 96 QPtrList<Incidence> mAlarms;
96 signals: 97 signals:
97 void showIncidence( QString uid); 98 void showIncidence( QString uid);
98}; 99};
99 100
100 101
101class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 102class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
102{ 103{
103 Q_OBJECT 104 Q_OBJECT
104 public: 105 public:
105 /** 106 /**
106 Constructs a new calendar view widget. 107 Constructs a new calendar view widget.
107 108
108 @param calendar calendar document 109 @param calendar calendar document
109 @param parent parent window 110 @param parent parent window
110 @param name Qt internal widget object name 111 @param name Qt internal widget object name
111 */ 112 */
112 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 113 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
113 const char *name = 0 ); 114 const char *name = 0 );
114 CalendarView( Calendar *calendar, QWidget *parent = 0, 115 CalendarView( Calendar *calendar, QWidget *parent = 0,
115 const char *name = 0 ); 116 const char *name = 0 );
116 virtual ~CalendarView(); 117 virtual ~CalendarView();
117 118
118 Calendar *calendar() { return mCalendar; } 119 Calendar *calendar() { return mCalendar; }
119 120
120 KOViewManager *viewManager(); 121 KOViewManager *viewManager();
121 KODialogManager *dialogManager(); 122 KODialogManager *dialogManager();
122 123
123 QDate startDate(); 124 QDate startDate();
124 QDate endDate(); 125 QDate endDate();
125 126
126 QWidgetStack *viewStack(); 127 QWidgetStack *viewStack();
127 QWidget *leftFrame(); 128 QWidget *leftFrame();
128 129
129 DateNavigator *dateNavigator(); 130 DateNavigator *dateNavigator();
130 KDateNavigator *dateNavigatorWidget(); 131 KDateNavigator *dateNavigatorWidget();
131 132
132 void addView(KOrg::BaseView *); 133 void addView(KOrg::BaseView *);
133 void showView(KOrg::BaseView *); 134 void showView(KOrg::BaseView *);
134 KOEventViewerDialog* getEventViewerDialog(); 135 KOEventViewerDialog* getEventViewerDialog();
135 Incidence *currentSelection(); 136 Incidence *currentSelection();
136 137
137 signals: 138 signals:
138 void save (); 139 void save ();
139 void saveStopTimer (); 140 void saveStopTimer ();
140 void tempDisableBR(bool); 141 void tempDisableBR(bool);
141 /** This todo has been modified */ 142 /** This todo has been modified */
142 void todoModified(Todo *, int); 143 void todoModified(Todo *, int);
143 144
144 /** when change is made to options dialog, the topwidget will catch this 145 /** when change is made to options dialog, the topwidget will catch this
145 * and emit this signal which notifies all widgets which have registered 146 * and emit this signal which notifies all widgets which have registered
146 * for notification to update their settings. */ 147 * for notification to update their settings. */
147 void configChanged(); 148 void configChanged();
148 /** emitted when the topwidget is closing down, so that any attached 149 /** emitted when the topwidget is closing down, so that any attached
149 child windows can also close. */ 150 child windows can also close. */
150 void closingDown(); 151 void closingDown();
151 /** emitted right before we die */ 152 /** emitted right before we die */
152 void closed(QWidget *); 153 void closed(QWidget *);
153 154
154 /** Emitted when state of modified flag changes */ 155 /** Emitted when state of modified flag changes */
155 void modifiedChanged(bool); 156 void modifiedChanged(bool);
156 void signalmodified(); 157 void signalmodified();
157 158
158 /** Emitted when state of read-only flag changes */ 159 /** Emitted when state of read-only flag changes */
159 void readOnlyChanged(bool); 160 void readOnlyChanged(bool);
160 161
161 /** Emitted when the unit of navigation changes */ 162 /** Emitted when the unit of navigation changes */
162 void changeNavStringPrev(const QString &); 163 void changeNavStringPrev(const QString &);
163 void changeNavStringNext(const QString &); 164 void changeNavStringNext(const QString &);
164 165
165 /** Emitted when state of events selection has changed and user is organizer*/ 166 /** Emitted when state of events selection has changed and user is organizer*/
166 void organizerEventsSelected(bool); 167 void organizerEventsSelected(bool);
167 /** Emitted when state of events selection has changed and user is attendee*/ 168 /** Emitted when state of events selection has changed and user is attendee*/
168 void groupEventsSelected(bool); 169 void groupEventsSelected(bool);
169 /** 170 /**
170 Emitted when an incidence gets selected. If the selection is cleared the 171 Emitted when an incidence gets selected. If the selection is cleared the
171 signal is emitted with 0 as argument. 172 signal is emitted with 0 as argument.
172 */ 173 */
173 void incidenceSelected( Incidence * ); 174 void incidenceSelected( Incidence * );
174 /** Emitted, when a todoitem is selected or deselected. */ 175 /** Emitted, when a todoitem is selected or deselected. */
175 void todoSelected( bool ); 176 void todoSelected( bool );
176 177
177 /** 178 /**
178 Emitted, when clipboard content changes. Parameter indicates if paste 179 Emitted, when clipboard content changes. Parameter indicates if paste
179 is possible or not. 180 is possible or not.
180 */ 181 */
181 void pasteEnabled(bool); 182 void pasteEnabled(bool);
182 183
183 /** Emitted, when the number of incoming messages has changed. */ 184 /** Emitted, when the number of incoming messages has changed. */
184 void numIncomingChanged(int); 185 void numIncomingChanged(int);
185 186
186 /** Emitted, when the number of outgoing messages has changed. */ 187 /** Emitted, when the number of outgoing messages has changed. */
187 void numOutgoingChanged(int); 188 void numOutgoingChanged(int);
188 189
189 /** Send status message, which can e.g. be displayed in the status bar. */ 190 /** Send status message, which can e.g. be displayed in the status bar. */
190 void statusMessage(const QString &); 191 void statusMessage(const QString &);
191 192
192 void calendarViewExpanded( bool ); 193 void calendarViewExpanded( bool );
193 void updateSearchDialog(); 194 void updateSearchDialog();
194 195
195 196
196 public slots: 197 public slots:
197 void checkAlarms(); 198 void checkAlarms();
198 void slotprintSelInc(); 199 void slotprintSelInc();
199 void showNextAlarms(); 200 void showNextAlarms();
200 void showOpenError(); 201 void showOpenError();
201 void watchSavedFile(); 202 void watchSavedFile();
202 void recheckTimerAlarm(); 203 void recheckTimerAlarm();
203 void checkNextTimerAlarm(); 204 void checkNextTimerAlarm();
204 void addAlarm(const QDateTime &qdt, const QString &noti ); 205 void addAlarm(const QDateTime &qdt, const QString &noti );
205 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 206 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
206 void removeAlarm(const QDateTime &qdt, const QString &noti ); 207 void removeAlarm(const QDateTime &qdt, const QString &noti );
207 208
208 /** options dialog made a changed to the configuration. we catch this 209 /** options dialog made a changed to the configuration. we catch this
209 * and notify all widgets which need to update their configuration. */ 210 * and notify all widgets which need to update their configuration. */
210 void updateConfig(); 211 void updateConfig();
211 212
212 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 213 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
213 const QStringList& anniversaryList, const QStringList& realNameList, 214 const QStringList& anniversaryList, const QStringList& realNameList,
214 const QStringList& emailList, const QStringList& assembledNameList, 215 const QStringList& emailList, const QStringList& assembledNameList,
215 const QStringList& uidList); 216 const QStringList& uidList);
216 217
217 /** 218 /**
218 Load calendar from file \a filename. If \a merge is true, load 219 Load calendar from file \a filename. If \a merge is true, load
219 calendar into existing one, if it is false, clear calendar, before 220 calendar into existing one, if it is false, clear calendar, before
220 loading. Return true, if calendar could be successfully loaded. 221 loading. Return true, if calendar could be successfully loaded.
221 */ 222 */
222 bool openCalendar(QString filename, bool merge=false); 223 bool openCalendar(QString filename, bool merge=false);
223 bool syncCalendar(QString filename,int mode = 0 ); 224 bool syncCalendar(QString filename,int mode = 0 );
224 225
225 /** 226 /**
226 Save calendar data to file. Return true if calendar could be 227 Save calendar data to file. Return true if calendar could be
227 successfully saved. 228 successfully saved.
228 */ 229 */
229 bool saveCalendar(QString filename); 230 bool saveCalendar(QString filename);
230 231
231 /** 232 /**
232 Close calendar. Clear calendar data and reset views to display an empty 233 Close calendar. Clear calendar data and reset views to display an empty
233 calendar. 234 calendar.
234 */ 235 */
235 void closeCalendar(); 236 void closeCalendar();
236 237
237 /** Archive old events of calendar */ 238 /** Archive old events of calendar */
238 void archiveCalendar(); 239 void archiveCalendar();
239 240
240 void showIncidence(); 241 void showIncidence();
241 void editIncidence(); 242 void editIncidence();
242 void editIncidenceDescription(); 243 void editIncidenceDescription();
243 void deleteIncidence(); 244 void deleteIncidence();
244 void cloneIncidence(); 245 void cloneIncidence();
245 void moveIncidence(); 246 void moveIncidence();
246 void beamIncidence(); 247 void beamIncidence();
247 void toggleCancelIncidence(); 248 void toggleCancelIncidence();
248 249
249 /** create an editeventwin with supplied date/time, and if bool is true, 250 /** create an editeventwin with supplied date/time, and if bool is true,
250 * make the event take all day. */ 251 * make the event take all day. */
251 void newEvent(QDateTime, QDateTime, bool allDay ); 252 void newEvent(QDateTime, QDateTime, bool allDay );
252 void newEvent(QDateTime, QDateTime); 253 void newEvent(QDateTime, QDateTime);
253 void newEvent(QDateTime fh); 254 void newEvent(QDateTime fh);
254 void newEvent(QDate dt); 255 void newEvent(QDate dt);
255 /** create new event without having a date hint. Takes current date as 256 /** create new event without having a date hint. Takes current date as
256 default hint. */ 257 default hint. */
257 void newEvent(); 258 void newEvent();
258 void newFloatingEvent(); 259 void newFloatingEvent();
259 260
260 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 261 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
261 void showIncidence(Incidence *); 262 void showIncidence(Incidence *);
262 void showIncidence(QString uid); 263 void showIncidence(QString uid);
263 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 264 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
264 void editIncidence(Incidence *); 265 void editIncidence(Incidence *);
265 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 266 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
266 void deleteIncidence(Incidence *); 267 void deleteIncidence(Incidence *);
267 void cloneIncidence(Incidence *); 268 void cloneIncidence(Incidence *);
268 void cancelIncidence(Incidence *); 269 void cancelIncidence(Incidence *);
269 /** Create an editor for the supplied event. */ 270 /** Create an editor for the supplied event. */
270 void editEvent(Event *); 271 void editEvent(Event *);
271 /** Delete the supplied event. */ 272 /** Delete the supplied event. */
272 void deleteEvent(Event *); 273 void deleteEvent(Event *);
273 /** Delete the event with the given unique ID. Returns false, if event wasn't 274 /** Delete the event with the given unique ID. Returns false, if event wasn't
274 found. */ 275 found. */
275 bool deleteEvent(const QString &uid); 276 bool deleteEvent(const QString &uid);
276 /** Create a read-only viewer dialog for the supplied event. */ 277 /** Create a read-only viewer dialog for the supplied event. */
277 void showEvent(Event *); 278 void showEvent(Event *);
278 279
279 void editJournal(Journal *); 280 void editJournal(Journal *);
280 void showJournal(Journal *); 281 void showJournal(Journal *);
281 void deleteJournal(Journal *); 282 void deleteJournal(Journal *);
282 /** Create an editor dialog for a todo */ 283 /** Create an editor dialog for a todo */
283 void editTodo(Todo *); 284 void editTodo(Todo *);
284 /** Create a read-only viewer dialog for the supplied todo */ 285 /** Create a read-only viewer dialog for the supplied todo */
285 void showTodo(Todo *); 286 void showTodo(Todo *);
286 /** create new todo */ 287 /** create new todo */
287 void newTodo(); 288 void newTodo();
288 void newTodoDateTime(QDateTime, bool allday); 289 void newTodoDateTime(QDateTime, bool allday);
289 /** create new todo with a parent todo */ 290 /** create new todo with a parent todo */
290 void newSubTodo(); 291 void newSubTodo();
291 /** create new todo with a parent todo */ 292 /** create new todo with a parent todo */
292 void newSubTodo(Todo *); 293 void newSubTodo(Todo *);
293 /** Delete todo */ 294 /** Delete todo */
294 void deleteTodo(Todo *); 295 void deleteTodo(Todo *);
295 296
296 297
297 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 298 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
298 * emitted as result. */ 299 * emitted as result. */
299 void checkClipboard(); 300 void checkClipboard();
300 301
301 /** using the KConfig associated with the kapp variable, read in the 302 /** using the KConfig associated with the kapp variable, read in the
302 * settings from the config file. 303 * settings from the config file.
303 */ 304 */
304 void readSettings(); 305 void readSettings();
305 306
306 /** write current state to config file. */ 307 /** write current state to config file. */
307 void writeSettings(); 308 void writeSettings();
308 309
309 /** read settings for calendar filters */ 310 /** read settings for calendar filters */
310 void readFilterSettings(KConfig *config); 311 void readFilterSettings(KConfig *config);
311 312
312 /** write settings for calendar filters */ 313 /** write settings for calendar filters */
313 void writeFilterSettings(KConfig *config); 314 void writeFilterSettings(KConfig *config);
314 315
315 /** passes on the message that an event has changed to the currently 316 /** passes on the message that an event has changed to the currently
316 * activated view so that it can make appropriate display changes. */ 317 * activated view so that it can make appropriate display changes. */
317 void changeEventDisplay(Event *, int); 318 void changeEventDisplay(Event *, int);
318 void changeIncidenceDisplay(Incidence *, int); 319 void changeIncidenceDisplay(Incidence *, int);
319 void changeTodoDisplay(Todo *, int); 320 void changeTodoDisplay(Todo *, int);
320 321
321 void eventAdded(Event *); 322 void eventAdded(Event *);
322 void eventChanged(Event *); 323 void eventChanged(Event *);
323 void eventToBeDeleted(Event *); 324 void eventToBeDeleted(Event *);
324 void eventDeleted(); 325 void eventDeleted();
325 326
326 void todoAdded(Todo *); 327 void todoAdded(Todo *);
327 void todoChanged(Todo *); 328 void todoChanged(Todo *);
328 void todoToBeDeleted(Todo *); 329 void todoToBeDeleted(Todo *);
329 void todoDeleted(); 330 void todoDeleted();
330 331
331 void updateView(const QDate &start, const QDate &end); 332 void updateView(const QDate &start, const QDate &end);
332 void updateView(); 333 void updateView();
333 334
334 /** Full update of visible todo views */ 335 /** Full update of visible todo views */
335 void updateTodoViews(); 336 void updateTodoViews();
336 337
337 void updateUnmanagedViews(); 338 void updateUnmanagedViews();
338 339
339 /** cut the current appointment to the clipboard */ 340 /** cut the current appointment to the clipboard */
340 void edit_cut(); 341 void edit_cut();
341 342
342 /** copy the current appointment(s) to the clipboard */ 343 /** copy the current appointment(s) to the clipboard */
343 void edit_copy(); 344 void edit_copy();
344 345
345 /** paste the current vobject(s) in the clipboard buffer into calendar */ 346 /** paste the current vobject(s) in the clipboard buffer into calendar */
346 void edit_paste(); 347 void edit_paste();
347 348
348 /** edit viewing and configuration options. */ 349 /** edit viewing and configuration options. */
349 void edit_options(); 350 void edit_options();
350 /** 351 /**
351 Functions for printing, previewing a print, and setting up printing 352 Functions for printing, previewing a print, and setting up printing
352 parameters. 353 parameters.
353 */ 354 */
354 void print(); 355 void print();
355 void printSetup(); 356 void printSetup();
356 void printPreview(); 357 void printPreview();
357 358
358 /** Export as iCalendar file */ 359 /** Export as iCalendar file */
359 void exportICalendar(); 360 void exportICalendar();
360 361
361 /** Export as vCalendar file */ 362 /** Export as vCalendar file */
362 bool exportVCalendar( QString fn); 363 bool exportVCalendar( QString fn);
363 364
364 /** pop up a dialog to show an existing appointment. */ 365 /** pop up a dialog to show an existing appointment. */
365 void appointment_show(); 366 void appointment_show();
366 /** 367 /**
367 * pop up an Appointment Dialog to edit an existing appointment.Get 368 * pop up an Appointment Dialog to edit an existing appointment.Get
368 * information on the appointment from the list of unique IDs that is 369 * information on the appointment from the list of unique IDs that is
369 * currently in the View, called currIds. 370 * currently in the View, called currIds.
370 */ 371 */
371 void appointment_edit(); 372 void appointment_edit();
372 /** 373 /**
373 * pop up dialog confirming deletion of currently selected event in the 374 * pop up dialog confirming deletion of currently selected event in the
374 * View. 375 * View.
375 */ 376 */
376 void appointment_delete(); 377 void appointment_delete();
377 378
378 /** mails the currently selected event to a particular user as a vCalendar 379 /** mails the currently selected event to a particular user as a vCalendar
379 attachment. */ 380 attachment. */
380 void action_mail(); 381 void action_mail();
381 382
382 /* frees a subtodo from it's relation */ 383 /* frees a subtodo from it's relation */
383 void todo_unsub( Todo * ); 384 void todo_unsub( Todo * );
384 void todo_resub( Todo * parent, Todo * sub ); 385 void todo_resub( Todo * parent, Todo * sub );
385 386
386 /** Take ownership of selected event. */ 387 /** Take ownership of selected event. */
387 void takeOverEvent(); 388 void takeOverEvent();
388 389
389 /** Take ownership of all events in calendar. */ 390 /** Take ownership of all events in calendar. */
390 void takeOverCalendar(); 391 void takeOverCalendar();
391 392
392 /** query whether or not the calendar is "dirty". */ 393 /** query whether or not the calendar is "dirty". */
393 bool isModified(); 394 bool isModified();
394 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 395 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
395 void setModified(bool modified=true); 396 void setModified(bool modified=true);
396 397
397 /** query if the calendar is read-only. */ 398 /** query if the calendar is read-only. */
398 bool isReadOnly(); 399 bool isReadOnly();
399 /** set state of calendar to read-only */ 400 /** set state of calendar to read-only */
400 void setReadOnly(bool readOnly=true); 401 void setReadOnly(bool readOnly=true);
401 402
402 void eventUpdated(Incidence *); 403 void eventUpdated(Incidence *);
403 404
404 /* iTIP scheduling actions */ 405 /* iTIP scheduling actions */
405 void schedule_publish(Incidence *incidence = 0); 406 void schedule_publish(Incidence *incidence = 0);
406 void schedule_request(Incidence *incidence = 0); 407 void schedule_request(Incidence *incidence = 0);
407 void schedule_refresh(Incidence *incidence = 0); 408 void schedule_refresh(Incidence *incidence = 0);
408 void schedule_cancel(Incidence *incidence = 0); 409 void schedule_cancel(Incidence *incidence = 0);
409 void schedule_add(Incidence *incidence = 0); 410 void schedule_add(Incidence *incidence = 0);
410 void schedule_reply(Incidence *incidence = 0); 411 void schedule_reply(Incidence *incidence = 0);
411 void schedule_counter(Incidence *incidence = 0); 412 void schedule_counter(Incidence *incidence = 0);
412 void schedule_declinecounter(Incidence *incidence = 0); 413 void schedule_declinecounter(Incidence *incidence = 0);
413 void schedule_publish_freebusy(int daysToPublish = 30); 414 void schedule_publish_freebusy(int daysToPublish = 30);
414 415
415 void openAddressbook(); 416 void openAddressbook();
416 417
417 void editFilters(); 418 void editFilters();
418 void toggleFilerEnabled(); 419 void toggleFilerEnabled();
419 QPtrList<CalFilter> filters(); 420 QPtrList<CalFilter> filters();
420 void toggleFilter(); 421 void toggleFilter();
421 void showFilter(bool visible); 422 void showFilter(bool visible);
422 void updateFilter(); 423 void updateFilter();
423 void filterEdited(); 424 void filterEdited();
424 void selectFilter( int ); 425 void selectFilter( int );
425 KOFilterView *filterView(); 426 KOFilterView *filterView();
426 427
427 void showIntro(); 428 void showIntro();
428 429
429 /** Move the curdatepient view date to today */ 430 /** Move the curdatepient view date to today */
430 void goToday(); 431 void goToday();
431 432
432 /** Move to the next date(s) in the current view */ 433 /** Move to the next date(s) in the current view */
433 void goNext(); 434 void goNext();
434 435
435 /** Move to the previous date(s) in the current view */ 436 /** Move to the previous date(s) in the current view */
436 void goPrevious(); 437 void goPrevious();
437 /** Move to the next date(s) in the current view */ 438 /** Move to the next date(s) in the current view */
438 void goNextMonth(); 439 void goNextMonth();
439 440
440 /** Move to the previous date(s) in the current view */ 441 /** Move to the previous date(s) in the current view */
441 void goPreviousMonth(); 442 void goPreviousMonth();
442 443
443 void toggleExpand(); 444 void toggleExpand();
444 void toggleDateNavigatorWidget(); 445 void toggleDateNavigatorWidget();
445 void toggleAllDaySize(); 446 void toggleAllDaySize();
446 void dialogClosing(Incidence *); 447 void dialogClosing(Incidence *);
447 448
448 /** Look for new messages in the inbox */ 449 /** Look for new messages in the inbox */
449 void lookForIncomingMessages(); 450 void lookForIncomingMessages();
450 /** Look for new messages in the outbox */ 451 /** Look for new messages in the outbox */
451 void lookForOutgoingMessages(); 452 void lookForOutgoingMessages();
452 453
453 void processMainViewSelection( Incidence * ); 454 void processMainViewSelection( Incidence * );
454 void processTodoListSelection( Incidence * ); 455 void processTodoListSelection( Incidence * );
455 456
456 void processIncidenceSelection( Incidence * ); 457 void processIncidenceSelection( Incidence * );
457 458
458 void purgeCompleted(); 459 void purgeCompleted();
459 bool removeCompletedSubTodos( Todo* ); 460 bool removeCompletedSubTodos( Todo* );
460 void slotCalendarChanged(); 461 void slotCalendarChanged();
461 bool importBday(); 462 bool importBday();
462 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 463 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
463 bool importQtopia( const QString &categoriesFile, 464 bool importQtopia( const QString &categoriesFile,
464 const QString &datebookFile, 465 const QString &datebookFile,
465 const QString &tasklistFile ); 466 const QString &tasklistFile );
466 void syncExternal( int mode ); 467 void syncExternal( int mode );
467 void slotSelectPickerDate( QDate ) ; 468 void slotSelectPickerDate( QDate ) ;
468 void showDatePicker() ; 469 void showDatePicker() ;
469 void showDatePickerPopup() ; 470 void showDatePickerPopup() ;
470 void moveIncidence(Incidence *) ; 471 void moveIncidence(Incidence *) ;
471 void beamIncidence(Incidence *) ; 472 void beamIncidence(Incidence *) ;
472 void beamCalendar() ; 473 void beamCalendar() ;
473 void beamFilteredCalendar() ; 474 void beamFilteredCalendar() ;
474 void beamIncidenceList(QPtrList<Incidence>) ; 475 void beamIncidenceList(QPtrList<Incidence>) ;
475 void manageCategories(); 476 void manageCategories();
476 int addCategories(); 477 int addCategories();
477 void removeCategories(); 478 void removeCategories();
478 void setSyncDevice( QString ); 479 void setSyncDevice( QString );
479 void setSyncName( QString ); 480 void setSyncName( QString );
480 void showDay( QDate ); 481 void showDay( QDate );
481 void undo_delete(); 482 void undo_delete();
482 protected slots: 483 protected slots:
483 void resetFocus(); 484 void resetFocus();
484 void slotViewerClosed(); 485 void slotViewerClosed();
485 void timerAlarm(); 486 void timerAlarm();
486 void suspendAlarm(); 487 void suspendAlarm();
487 void beamDone( Ir *ir ); 488 void beamDone( Ir *ir );
488 /** Select a view or adapt the current view to display the specified dates. */ 489 /** Select a view or adapt the current view to display the specified dates. */
489 void showDates( const KCal::DateList & ); 490 void showDates( const KCal::DateList & );
490 void selectWeekNum ( int ); 491 void selectWeekNum ( int );
491 492
492 public: 493 public:
493 // show a standard warning 494 // show a standard warning
494 // returns KMsgBox::yesNoCancel() 495 // returns KMsgBox::yesNoCancel()
495 int msgCalModified(); 496 int msgCalModified();
496 virtual bool sync(KSyncManager* manager, QString filename, int mode); 497 virtual bool sync(KSyncManager* manager, QString filename, int mode);
497 498
498 virtual bool syncExternal(KSyncManager* manager, QString resource); 499 virtual bool syncExternal(KSyncManager* manager, QString resource);
499 virtual void removeSyncInfo( QString syncProfile); 500 virtual void removeSyncInfo( QString syncProfile);
500 void setSyncManager(KSyncManager* manager); 501 void setSyncManager(KSyncManager* manager);
501 void setLoadedFileVersion(QDateTime); 502 void setLoadedFileVersion(QDateTime);
502 bool checkFileVersion(QString fn); 503 bool checkFileVersion(QString fn);
503 bool checkFileChanged(QString fn); 504 bool checkFileChanged(QString fn);
504 Event* getLastSyncEvent(); 505 Event* getLastSyncEvent();
505 /** Adapt navigation units correpsonding to step size of navigation of the 506 /** Adapt navigation units correpsonding to step size of navigation of the
506 * current view. 507 * current view.
507 */ 508 */
508 void adaptNavigationUnits(); 509 void adaptNavigationUnits();
509 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 510 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
510 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 511 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
511 //Attendee* getYourAttendee(Event *event); 512 //Attendee* getYourAttendee(Event *event);
512 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 513 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
513 protected: 514 protected:
514 void schedule(Scheduler::Method, Incidence *incidence = 0); 515 void schedule(Scheduler::Method, Incidence *incidence = 0);
515 516
516 // returns KMsgBox::OKCandel() 517 // returns KMsgBox::OKCandel()
517 int msgItemDelete(const QString name); 518 int msgItemDelete(const QString name);
518 void showEventEditor(); 519 void showEventEditor();
519 void showTodoEditor(); 520 void showTodoEditor();
520 void writeLocale(); 521 void writeLocale();
521 Todo *selectedTodo(); 522 Todo *selectedTodo();
522 523
523 private: 524 private:
524 QDateTime mNextAlarmDateTime; 525 QDateTime mNextAlarmDateTime;
525 bool mViewerCallerIsSearchDialog; 526 bool mViewerCallerIsSearchDialog;
526 bool mBlockShowDates; 527 bool mBlockShowDates;
527 KSyncManager* mSyncManager; 528 KSyncManager* mSyncManager;
528 AlarmDialog * mAlarmDialog; 529 AlarmDialog * mAlarmDialog;
529 QString mAlarmNotification; 530 QString mAlarmNotification;
530 QString mSuspendAlarmNotification; 531 QString mSuspendAlarmNotification;
531 QTimer* mSuspendTimer; 532 QTimer* mSuspendTimer;
532 QTimer* mAlarmTimer; 533 QTimer* mAlarmTimer;
533 QTimer* mRecheckAlarmTimer; 534 QTimer* mRecheckAlarmTimer;
534 void computeAlarm( QString ); 535 void computeAlarm( QString );
535 void startAlarm( QString, QString ); 536 void startAlarm( QString, QString );
536 void setSyncEventsReadOnly(); 537 void setSyncEventsReadOnly();
537 538
538 QDateTime loadedFileVersion; 539 QDateTime loadedFileVersion;
539 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 540 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
540 void checkExternalId( Incidence * inc ); 541 void checkExternalId( Incidence * inc );
541 int mGlobalSyncMode; 542 int mGlobalSyncMode;
542 QString mCurrentSyncDevice; 543 QString mCurrentSyncDevice;
543 QString mCurrentSyncName; 544 QString mCurrentSyncName;
544 KOBeamPrefs* beamDialog; 545 KOBeamPrefs* beamDialog;
545 void init(); 546 void init();
546 int mDatePickerMode; 547 int mDatePickerMode;
547 bool mFlagEditDescription; 548 bool mFlagEditDescription;
548 QDateTime mLastCalendarSync; 549 QDateTime mLastCalendarSync;
549 void createPrinter(); 550 void createPrinter();
550 551
551 void calendarModified( bool, Calendar * ); 552 void calendarModified( bool, Calendar * );
552 553
553 CalPrinter *mCalPrinter; 554 CalPrinter *mCalPrinter;
554 555
555 QSplitter *mPanner; 556 QSplitter *mPanner;
556 QSplitter *mLeftSplitter; 557 QSplitter *mLeftSplitter;
557 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 558 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
558 QWidgetStack *mRightFrame; 559 QWidgetStack *mRightFrame;
559 560
560 KDatePicker* mDatePicker; 561 KDatePicker* mDatePicker;
561 QVBox* mDateFrame; 562 QVBox* mDateFrame;
562 563
563 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 564 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
564 565
565 KOFilterView *mFilterView; 566 KOFilterView *mFilterView;
566 567
567 ResourceView *mResourceView; 568 ResourceView *mResourceView;
568 569
569 // calendar object for this viewing instance 570 // calendar object for this viewing instance
570 Calendar *mCalendar; 571 Calendar *mCalendar;
571 572
572 CalendarResourceManager *mResourceManager; 573 CalendarResourceManager *mResourceManager;
573 574
574 FileStorage *mStorage; 575 FileStorage *mStorage;
575 576
576 DateNavigator *mNavigator; 577 DateNavigator *mNavigator;
577 578
578 KOViewManager *mViewManager; 579 KOViewManager *mViewManager;
579 KODialogManager *mDialogManager; 580 KODialogManager *mDialogManager;
580 581
581 // Calendar filters 582 // Calendar filters
582 QPtrList<CalFilter> mFilters; 583 QPtrList<CalFilter> mFilters;
583 584
584 // various housekeeping variables. 585 // various housekeeping variables.
585 bool mModified; // flag indicating if calendar is modified 586 bool mModified; // flag indicating if calendar is modified
586 bool mReadOnly; // flag indicating if calendar is read-only 587 bool mReadOnly; // flag indicating if calendar is read-only
587 QDate mSaveSingleDate; 588 QDate mSaveSingleDate;
588 589
589 Incidence *mSelectedIncidence; 590 Incidence *mSelectedIncidence;
590 Incidence *mMoveIncidence; 591 Incidence *mMoveIncidence;
591 QDate mMoveIncidenceOldDate; 592 QDate mMoveIncidenceOldDate;
592 KOTodoView *mTodoList; 593 KOTodoView *mTodoList;
593 KOEventEditor * mEventEditor; 594 KOEventEditor * mEventEditor;
594 KOTodoEditor * mTodoEditor; 595 KOTodoEditor * mTodoEditor;
595 KOEventViewerDialog * mEventViewerDialog; 596 KOEventViewerDialog * mEventViewerDialog;
596 void keyPressEvent ( QKeyEvent *e) ; 597 void keyPressEvent ( QKeyEvent *e) ;
597 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 598 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
598}; 599};
599 600
600 601
601class CalendarViewVisitor : public Incidence::Visitor 602class CalendarViewVisitor : public Incidence::Visitor
602{ 603{
603 public: 604 public:
604 CalendarViewVisitor() : mView( 0 ) {} 605 CalendarViewVisitor() : mView( 0 ) {}
605 606
606 bool act( Incidence *incidence, CalendarView *view ) 607 bool act( Incidence *incidence, CalendarView *view )
607 { 608 {
608 mView = view; 609 mView = view;
609 return incidence->accept( *this ); 610 return incidence->accept( *this );
610 } 611 }
611 612
612 protected: 613 protected:
613 CalendarView *mView; 614 CalendarView *mView;
614}; 615};
615 616
616class ShowIncidenceVisitor : public CalendarViewVisitor 617class ShowIncidenceVisitor : public CalendarViewVisitor
617{ 618{
618 protected: 619 protected:
619 bool visit( Event *event ) { mView->showEvent( event ); return true; } 620 bool visit( Event *event ) { mView->showEvent( event ); return true; }
620 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 621 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
621 bool visit( Journal * j ) { mView->showJournal( j );return true; } 622 bool visit( Journal * j ) { mView->showJournal( j );return true; }
622}; 623};
623 624
624class EditIncidenceVisitor : public CalendarViewVisitor 625class EditIncidenceVisitor : public CalendarViewVisitor
625{ 626{
626 protected: 627 protected:
627 bool visit( Event *event ) { mView->editEvent( event ); return true; } 628 bool visit( Event *event ) { mView->editEvent( event ); return true; }
628 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 629 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
629 bool visit( Journal *j ) { mView->editJournal( j); return true; } 630 bool visit( Journal *j ) { mView->editJournal( j); return true; }
630}; 631};
631 632
632class DeleteIncidenceVisitor : public CalendarViewVisitor 633class DeleteIncidenceVisitor : public CalendarViewVisitor
633{ 634{
634 protected: 635 protected:
635 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 636 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
636 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 637 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
637 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 638 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
638}; 639};
639 640
640#endif 641#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1320231..63053a5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2494 +1,2497 @@
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/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h> 64#include <kglobalsettings.h>
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0; 148 p->mCurrentDisplayedView = 0;
149 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
150 p->mHourSize = 22; 150 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 169
170#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
171 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
172#else 172#else
173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
174#endif 174#endif
175 175
176{ 176{
177 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
178 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
179 tbd = Bottom; 179 tbd = Bottom;
180 else 180 else
181 tbd = Top; 181 tbd = Top;
182 } 182 }
183 else { 183 else {
184 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
185 tbd = Right; 185 tbd = Right;
186 else 186 else
187 tbd = Left; 187 tbd = Left;
188 } 188 }
189 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
190 filterMenubar = new QMenuBar( 0 ); 190 filterMenubar = new QMenuBar( 0 );
191 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
192 192
193 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
195 QString addTest = "A"; 195 QString addTest = "A";
196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
197#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
198 addTest = "AAABBBCCCx"; 198 addTest = "AAABBBCCCx";
199#else 199#else
200 addTest = "AAx"; 200 addTest = "AAx";
201#endif 201#endif
202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
203 addToolBar (filterToolBar , tbd ); 203 addToolBar (filterToolBar , tbd );
204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
207 filterToolBar->hide(); 207 filterToolBar->hide();
208 } else { 208 } else {
209 filterToolBar = 0; 209 filterToolBar = 0;
210 filterMenubar = 0; 210 filterMenubar = 0;
211 filterPopupMenu = 0; 211 filterPopupMenu = 0;
212 } 212 }
213 if ( p->mShowIconOnetoolbar ) { 213 if ( p->mShowIconOnetoolbar ) {
214 viewToolBar = iconToolBar ; 214 viewToolBar = iconToolBar ;
215 navigatorToolBar = iconToolBar ; 215 navigatorToolBar = iconToolBar ;
216 } else { 216 } else {
217#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
218 setToolBarsMovable( false ); 218 setToolBarsMovable( false );
219#endif 219#endif
220 if ( p->mToolBarHorV ) { 220 if ( p->mToolBarHorV ) {
221 if ( p->mToolBarUpV ) 221 if ( p->mToolBarUpV )
222 tbd = Bottom; 222 tbd = Bottom;
223 else 223 else
224 tbd = Top; 224 tbd = Top;
225 } 225 }
226 else { 226 else {
227 if ( p->mToolBarUpV ) 227 if ( p->mToolBarUpV )
228 tbd = Right; 228 tbd = Right;
229 else 229 else
230 tbd = Left; 230 tbd = Left;
231 } 231 }
232 viewToolBar = new QPEToolBar( this ); 232 viewToolBar = new QPEToolBar( this );
233 addToolBar (viewToolBar , tbd ); 233 addToolBar (viewToolBar , tbd );
234 if ( p->mToolBarHorN ) { 234 if ( p->mToolBarHorN ) {
235 if ( p->mToolBarUpN ) 235 if ( p->mToolBarUpN )
236 tbd = Bottom; 236 tbd = Bottom;
237 else 237 else
238 tbd = Top; 238 tbd = Top;
239 } 239 }
240 else { 240 else {
241 if ( p->mToolBarUpN ) 241 if ( p->mToolBarUpN )
242 tbd = Right; 242 tbd = Right;
243 else 243 else
244 tbd = Left; 244 tbd = Left;
245 } 245 }
246 navigatorToolBar = new QPEToolBar( this ); 246 navigatorToolBar = new QPEToolBar( this );
247 addToolBar (navigatorToolBar , tbd ); 247 addToolBar (navigatorToolBar , tbd );
248 } 248 }
249 249
250 250
251 251
252 mCalendarModifiedFlag = false; 252 mCalendarModifiedFlag = false;
253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
254 splash->setAlignment ( AlignCenter ); 254 splash->setAlignment ( AlignCenter );
255 setCentralWidget( splash ); 255 setCentralWidget( splash );
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 showMaximized(); 257 showMaximized();
258#endif 258#endif
259 259
260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
261 setDefaultPreferences(); 261 setDefaultPreferences();
262 mCalendar = new CalendarLocal(); 262 mCalendar = new CalendarLocal();
263 mView = new CalendarView( mCalendar, this,"mCalendar " ); 263 mView = new CalendarView( mCalendar, this,"mCalendar " );
264 mView->hide(); 264 mView->hide();
265 //mView->resize(splash->size() ); 265 //mView->resize(splash->size() );
266 initActions(); 266 initActions();
267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
268 mSyncManager->setBlockSave(false); 268 mSyncManager->setBlockSave(false);
269 mView->setSyncManager(mSyncManager); 269 mView->setSyncManager(mSyncManager);
270#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
271 iconToolBar->show(); 271 iconToolBar->show();
272 qApp->processEvents(); 272 qApp->processEvents();
273#endif 273#endif
274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
275 int vh = height() ; 275 int vh = height() ;
276 int vw = width(); 276 int vw = width();
277 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 277 //qDebug("Toolbar hei %d ",iconToolBar->height() );
278 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
279 vh -= iconToolBar->height(); 279 vh -= iconToolBar->height();
280 } else { 280 } else {
281 vw -= iconToolBar->height(); 281 vw -= iconToolBar->height();
282 } 282 }
283 //mView->setMaximumSize( splash->size() ); 283 //mView->setMaximumSize( splash->size() );
284 //mView->resize( splash->size() ); 284 //mView->resize( splash->size() );
285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
286 mView->readSettings(); 286 mView->readSettings();
287 bool newFile = false; 287 bool newFile = false;
288 if( !QFile::exists( defaultFileName() ) ) { 288 if( !QFile::exists( defaultFileName() ) ) {
289 QFileInfo finfo ( defaultFileName() ); 289 QFileInfo finfo ( defaultFileName() );
290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
291 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"; 291 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";
292 finfo.setFile( oldFile ); 292 finfo.setFile( oldFile );
293 if (finfo.exists() ) { 293 if (finfo.exists() ) {
294 KMessageBox::information( this, message); 294 KMessageBox::information( this, message);
295 mView->openCalendar( oldFile ); 295 mView->openCalendar( oldFile );
296 qApp->processEvents(); 296 qApp->processEvents();
297 } else { 297 } else {
298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
299 finfo.setFile( oldFile ); 299 finfo.setFile( oldFile );
300 if (finfo.exists() ) { 300 if (finfo.exists() ) {
301 KMessageBox::information( this, message); 301 KMessageBox::information( this, message);
302 mView->openCalendar( oldFile ); 302 mView->openCalendar( oldFile );
303 qApp->processEvents(); 303 qApp->processEvents();
304 } 304 }
305 } 305 }
306 mView->saveCalendar( defaultFileName() ); 306 mView->saveCalendar( defaultFileName() );
307 newFile = true; 307 newFile = true;
308 } 308 }
309 309
310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 310 QTime neededSaveTime = QDateTime::currentDateTime().time();
311 mView->openCalendar( defaultFileName() ); 311 mView->openCalendar( defaultFileName() );
312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
313 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 313 qDebug("KO: Calendar loading time: %d ms",msNeeded );
314 314
315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
316 KOPrefs::instance()->setAllDefaults(); 316 KOPrefs::instance()->setAllDefaults();
317 int count = mView->addCategories(); 317 int count = mView->addCategories();
318 } 318 }
319 processIncidenceSelection( 0 ); 319 processIncidenceSelection( 0 );
320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
321 SLOT( processIncidenceSelection( Incidence * ) ) ); 321 SLOT( processIncidenceSelection( Incidence * ) ) );
322 connect( mView, SIGNAL( modifiedChanged( bool ) ), 322 connect( mView, SIGNAL( modifiedChanged( bool ) ),
323 SLOT( slotModifiedChanged( bool ) ) ); 323 SLOT( slotModifiedChanged( bool ) ) );
324 324
325 325
326 connect( mView, SIGNAL( tempDisableBR(bool) ), 326 connect( mView, SIGNAL( tempDisableBR(bool) ),
327 SLOT( disableBR(bool) ) ); 327 SLOT( disableBR(bool) ) );
328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
329 mView->setModified( false ); 329 mView->setModified( false );
330 mBlockAtStartup = false; 330 mBlockAtStartup = false;
331 mView->setModified( false ); 331 mView->setModified( false );
332 setCentralWidget( mView ); 332 setCentralWidget( mView );
333 globalFlagBlockStartup = 0; 333 globalFlagBlockStartup = 0;
334 mView->show(); 334 mView->show();
335 delete splash; 335 delete splash;
336 if ( newFile ) 336 if ( newFile )
337 mView->updateConfig(); 337 mView->updateConfig();
338 // qApp->processEvents(); 338 // qApp->processEvents();
339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
340 //fillSyncMenu(); 340 //fillSyncMenu();
341 341
342 342
343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
348 mSyncManager->setDefaultFileName( sentSyncFile()); 348 mSyncManager->setDefaultFileName( sentSyncFile());
349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
350 mSyncManager->fillSyncMenu(); 350 mSyncManager->fillSyncMenu();
351 351
352 352
353 353
354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
355 if ( showWarning ) { 355 if ( showWarning ) {
356 KMessageBox::information( this, 356 KMessageBox::information( this,
357 "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"); 357 "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");
358 qApp->processEvents(); 358 qApp->processEvents();
359 mView->dialogManager()->showSyncOptions(); 359 mView->dialogManager()->showSyncOptions();
360 } 360 }
361 361
362 //US listen for result adressed from Ka/Pi 362 //US listen for result adressed from Ka/Pi
363#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
365#endif 365#endif
366#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
367 infrared = 0; 367 infrared = 0;
368#endif 368#endif
369 updateFilterToolbar(); 369 updateFilterToolbar();
370 updateWeek( mView->startDate() ); 370 updateWeek( mView->startDate() );
371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
372 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 372 SLOT( updateWeekNum( const KCal::DateList & ) ) );
373 mBRdisabled = false; 373 mBRdisabled = false;
374 //toggleBeamReceive(); 374 //toggleBeamReceive();
375 375 int tiint= 3000;
376 QTimer::singleShot( 1000, mView, SLOT ( checkAlarms() )); 376#ifndef DESKTOP_VERSION
377 tiint = 5000;
378#endif
379 QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() ));
377} 380}
378MainWindow::~MainWindow() 381MainWindow::~MainWindow()
379{ 382{
380 //qDebug("MainWindow::~MainWindow() "); 383 //qDebug("MainWindow::~MainWindow() ");
381 //save toolbar location 384 //save toolbar location
382 delete mCalendar; 385 delete mCalendar;
383 delete mSyncManager; 386 delete mSyncManager;
384#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
385 if ( infrared ) 388 if ( infrared )
386 delete infrared; 389 delete infrared;
387#endif 390#endif
388 391
389 392
390} 393}
391 394
392void MainWindow::disableBR(bool b) 395void MainWindow::disableBR(bool b)
393{ 396{
394#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
395 if ( b ) { 398 if ( b ) {
396 if ( infrared ) { 399 if ( infrared ) {
397 toggleBeamReceive(); 400 toggleBeamReceive();
398 mBRdisabled = true; 401 mBRdisabled = true;
399 } 402 }
400 mBRdisabled = true; 403 mBRdisabled = true;
401 } else { 404 } else {
402 if ( mBRdisabled ) { 405 if ( mBRdisabled ) {
403 mBRdisabled = false; 406 mBRdisabled = false;
404 //makes no sense,because other cal ap is probably running 407 //makes no sense,because other cal ap is probably running
405 // toggleBeamReceive(); 408 // toggleBeamReceive();
406 } 409 }
407 } 410 }
408#endif 411#endif
409 412
410} 413}
411bool MainWindow::beamReceiveEnabled() 414bool MainWindow::beamReceiveEnabled()
412{ 415{
413#ifndef DESKTOP_VERSION 416#ifndef DESKTOP_VERSION
414 return ( infrared != 0 ); 417 return ( infrared != 0 );
415#endif 418#endif
416 return false; 419 return false;
417} 420}
418 421
419void MainWindow::toggleBeamReceive() 422void MainWindow::toggleBeamReceive()
420{ 423{
421 if ( mBRdisabled ) 424 if ( mBRdisabled )
422 return; 425 return;
423#ifndef DESKTOP_VERSION 426#ifndef DESKTOP_VERSION
424 if ( infrared ) { 427 if ( infrared ) {
425 qDebug("KO: Disable BeamReceive "); 428 qDebug("KO: Disable BeamReceive ");
426 delete infrared; 429 delete infrared;
427 infrared = 0; 430 infrared = 0;
428 brAction->setOn(false); 431 brAction->setOn(false);
429 return; 432 return;
430 } 433 }
431 qDebug("KO: Enable BeamReceive "); 434 qDebug("KO: Enable BeamReceive ");
432 brAction->setOn(true); 435 brAction->setOn(true);
433 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 436 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
434 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 437 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
435#endif 438#endif
436} 439}
437void MainWindow::showMaximized () 440void MainWindow::showMaximized ()
438{ 441{
439#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
440 if ( ! globalFlagBlockStartup ) 443 if ( ! globalFlagBlockStartup )
441 if ( mClosed ) 444 if ( mClosed )
442 mView->goToday(); 445 mView->goToday();
443#endif 446#endif
444 QWidget::showMaximized () ; 447 QWidget::showMaximized () ;
445 mClosed = false; 448 mClosed = false;
446} 449}
447void MainWindow::closeEvent( QCloseEvent* ce ) 450void MainWindow::closeEvent( QCloseEvent* ce )
448{ 451{
449 452
450 453
451 454
452 if ( ! KOPrefs::instance()->mAskForQuit ) { 455 if ( ! KOPrefs::instance()->mAskForQuit ) {
453 saveOnClose(); 456 saveOnClose();
454 mClosed = true; 457 mClosed = true;
455 ce->accept(); 458 ce->accept();
456 return; 459 return;
457 460
458 } 461 }
459 462
460 switch( QMessageBox::information( this, "KO/Pi", 463 switch( QMessageBox::information( this, "KO/Pi",
461 i18n("Do you really want\nto close KO/Pi?"), 464 i18n("Do you really want\nto close KO/Pi?"),
462 i18n("Close"), i18n("No"), 465 i18n("Close"), i18n("No"),
463 0, 0 ) ) { 466 0, 0 ) ) {
464 case 0: 467 case 0:
465 saveOnClose(); 468 saveOnClose();
466 mClosed = true; 469 mClosed = true;
467 ce->accept(); 470 ce->accept();
468 break; 471 break;
469 case 1: 472 case 1:
470 ce->ignore(); 473 ce->ignore();
471 break; 474 break;
472 case 2: 475 case 2:
473 476
474 default: 477 default:
475 break; 478 break;
476 } 479 }
477 480
478 481
479} 482}
480 483
481void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 484void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
482{ 485{
483 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
484 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 487 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
485 //QString datamess; 488 //QString datamess;
486 //qDebug("message "); 489 //qDebug("message ");
487 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 490 qDebug("KO: QCOP message received: %s ", cmsg.data() );
488 491
489 if ( cmsg == "setDocument(QString)" ) { 492 if ( cmsg == "setDocument(QString)" ) {
490 QDataStream stream( data, IO_ReadOnly ); 493 QDataStream stream( data, IO_ReadOnly );
491 QString fileName; 494 QString fileName;
492 stream >> fileName; 495 stream >> fileName;
493 //qDebug("filename %s ", fileName.latin1()); 496 //qDebug("filename %s ", fileName.latin1());
494 showMaximized(); 497 showMaximized();
495 raise(); 498 raise();
496 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 499 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
497 mSyncManager->slotSyncMenu( 1002 ); 500 mSyncManager->slotSyncMenu( 1002 );
498 return; 501 return;
499 } 502 }
500 503
501 if ( cmsg == "-writeFile" ) { 504 if ( cmsg == "-writeFile" ) {
502 // I made from the "-writeFile" an "-writeAlarm" 505 // I made from the "-writeFile" an "-writeAlarm"
503 mView->viewManager()->showWhatsNextView(); 506 mView->viewManager()->showWhatsNextView();
504 mCalendar->checkAlarmForIncidence( 0, true); 507 mCalendar->checkAlarmForIncidence( 0, true);
505 showMaximized(); 508 showMaximized();
506 raise(); 509 raise();
507 return; 510 return;
508 511
509 } 512 }
510 if ( cmsg == "-writeFileSilent" ) { 513 if ( cmsg == "-writeFileSilent" ) {
511 // I made from the "-writeFile" an "-writeAlarm" 514 // I made from the "-writeFile" an "-writeAlarm"
512 // mView->viewManager()->showWhatsNextView(); 515 // mView->viewManager()->showWhatsNextView();
513 mCalendar->checkAlarmForIncidence( 0, true); 516 mCalendar->checkAlarmForIncidence( 0, true);
514 //showMaximized(); 517 //showMaximized();
515 //raise(); 518 //raise();
516 hide(); 519 hide();
517 return; 520 return;
518 } 521 }
519 if ( cmsg == "-newCountdown" ) { 522 if ( cmsg == "-newCountdown" ) {
520 qDebug("newCountdown "); 523 qDebug("newCountdown ");
521 524
522 } 525 }
523 QString msg ; 526 QString msg ;
524 QString allmsg = cmsg; 527 QString allmsg = cmsg;
525 while ( allmsg.length() > 0 ) { 528 while ( allmsg.length() > 0 ) {
526 int nextC = allmsg.find( "-", 1 ); 529 int nextC = allmsg.find( "-", 1 );
527 if ( nextC == -1 ) { 530 if ( nextC == -1 ) {
528 msg = allmsg; 531 msg = allmsg;
529 allmsg = ""; 532 allmsg = "";
530 } else{ 533 } else{
531 msg = allmsg.left( nextC ); 534 msg = allmsg.left( nextC );
532 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 535 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
533 } 536 }
534 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 537 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
535 if ( msg == "-newEvent" ) { 538 if ( msg == "-newEvent" ) {
536 mView->newEvent(); 539 mView->newEvent();
537 } 540 }
538 if ( msg == "-newTodo" ) { 541 if ( msg == "-newTodo" ) {
539 mView->newTodo(); 542 mView->newTodo();
540 543
541 } 544 }
542 if ( msg == "-showWN" ) { 545 if ( msg == "-showWN" ) {
543 mView->viewManager()->showWhatsNextView(); 546 mView->viewManager()->showWhatsNextView();
544 } 547 }
545 if ( msg == "-showTodo" ) { 548 if ( msg == "-showTodo" ) {
546 mView->viewManager()->showTodoView(); 549 mView->viewManager()->showTodoView();
547 } 550 }
548 if ( msg == "-showList" ) { 551 if ( msg == "-showList" ) {
549 mView->viewManager()->showListView(); 552 mView->viewManager()->showListView();
550 } 553 }
551 else if ( msg == "-showDay" ) { 554 else if ( msg == "-showDay" ) {
552 mView->viewManager()->showDayView(); 555 mView->viewManager()->showDayView();
553 } 556 }
554 else if ( msg == "-showWWeek" ) { 557 else if ( msg == "-showWWeek" ) {
555 mView->viewManager()->showWorkWeekView(); 558 mView->viewManager()->showWorkWeekView();
556 } 559 }
557 else if ( msg == "-ringSync" ) { 560 else if ( msg == "-ringSync" ) {
558 mSyncManager->multiSync( false ); 561 mSyncManager->multiSync( false );
559 } 562 }
560 else if ( msg == "-showWeek" ) { 563 else if ( msg == "-showWeek" ) {
561 mView->viewManager()->showWeekView(); 564 mView->viewManager()->showWeekView();
562 } 565 }
563 else if ( msg == "-showTodo" ) { 566 else if ( msg == "-showTodo" ) {
564 mView->viewManager()->showTodoView(); 567 mView->viewManager()->showTodoView();
565 } 568 }
566 else if ( msg == "-showJournal" ) { 569 else if ( msg == "-showJournal" ) {
567 mView->dateNavigator()->selectDates( 1 ); 570 mView->dateNavigator()->selectDates( 1 );
568 mView->dateNavigator()->selectToday(); 571 mView->dateNavigator()->selectToday();
569 mView->viewManager()->showJournalView(); 572 mView->viewManager()->showJournalView();
570 } 573 }
571 else if ( msg == "-showKO" ) { 574 else if ( msg == "-showKO" ) {
572 mView->viewManager()->showNextXView(); 575 mView->viewManager()->showNextXView();
573 } 576 }
574 else if ( msg == "-showWNext" ) { 577 else if ( msg == "-showWNext" ) {
575 mView->viewManager()->showWhatsNextView(); 578 mView->viewManager()->showWhatsNextView();
576 } 579 }
577 else if ( msg == "nextView()" ) { 580 else if ( msg == "nextView()" ) {
578 mView->viewManager()->showNextView(); 581 mView->viewManager()->showNextView();
579 } 582 }
580 else if ( msg == "-showNextXView" ) { 583 else if ( msg == "-showNextXView" ) {
581 mView->viewManager()->showNextXView(); 584 mView->viewManager()->showNextXView();
582 } 585 }
583 586
584 587
585 } 588 }
586 589
587 showMaximized(); 590 showMaximized();
588 raise(); 591 raise();
589} 592}
590 593
591QPixmap MainWindow::loadPixmap( QString name ) 594QPixmap MainWindow::loadPixmap( QString name )
592{ 595{
593 return SmallIcon( name ); 596 return SmallIcon( name );
594 597
595} 598}
596void MainWindow::setUsesBigPixmaps ( bool b ) 599void MainWindow::setUsesBigPixmaps ( bool b )
597{ 600{
598 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 601 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
599 if ( b ) 602 if ( b )
600 qDebug("KO: BigPixmaps are not supported "); 603 qDebug("KO: BigPixmaps are not supported ");
601} 604}
602void MainWindow::initActions() 605void MainWindow::initActions()
603{ 606{
604 //KOPrefs::instance()->mShowFullMenu 607 //KOPrefs::instance()->mShowFullMenu
605 iconToolBar->clear(); 608 iconToolBar->clear();
606 KOPrefs *p = KOPrefs::instance(); 609 KOPrefs *p = KOPrefs::instance();
607 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 610 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
608 611
609 QPopupMenu *viewMenu = new QPopupMenu( this ); 612 QPopupMenu *viewMenu = new QPopupMenu( this );
610 QPopupMenu *actionMenu = new QPopupMenu( this ); 613 QPopupMenu *actionMenu = new QPopupMenu( this );
611 QPopupMenu *importMenu = new QPopupMenu( this ); 614 QPopupMenu *importMenu = new QPopupMenu( this );
612 QPopupMenu *importMenu_X = new QPopupMenu( this ); 615 QPopupMenu *importMenu_X = new QPopupMenu( this );
613 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 616 QPopupMenu *exportMenu_X = new QPopupMenu( this );
614 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 617 QPopupMenu *beamMenu_X = new QPopupMenu( this );
615 selectFilterMenu = new QPopupMenu( this ); 618 selectFilterMenu = new QPopupMenu( this );
616 selectFilterMenu->setCheckable( true ); 619 selectFilterMenu->setCheckable( true );
617 syncMenu = new QPopupMenu( this ); 620 syncMenu = new QPopupMenu( this );
618 configureAgendaMenu = new QPopupMenu( this ); 621 configureAgendaMenu = new QPopupMenu( this );
619 configureToolBarMenu = new QPopupMenu( this ); 622 configureToolBarMenu = new QPopupMenu( this );
620 QPopupMenu *helpMenu = new QPopupMenu( this ); 623 QPopupMenu *helpMenu = new QPopupMenu( this );
621 QIconSet icon; 624 QIconSet icon;
622 int pixWid = 22, pixHei = 22; 625 int pixWid = 22, pixHei = 22;
623 QString pathString = ""; 626 QString pathString = "";
624 if ( !p->mToolBarMiniIcons ) { 627 if ( !p->mToolBarMiniIcons ) {
625 if ( QApplication::desktop()->width() < 480 ) { 628 if ( QApplication::desktop()->width() < 480 ) {
626 pathString += "icons16/"; 629 pathString += "icons16/";
627 pixWid = 18; pixHei = 16; 630 pixWid = 18; pixHei = 16;
628 } 631 }
629 } else { 632 } else {
630 pathString += "iconsmini/"; 633 pathString += "iconsmini/";
631 pixWid = 18; pixHei = 16; 634 pixWid = 18; pixHei = 16;
632 } 635 }
633 if ( KOPrefs::instance()->mShowFullMenu ) { 636 if ( KOPrefs::instance()->mShowFullMenu ) {
634 QMenuBar *menuBar1; 637 QMenuBar *menuBar1;
635 menuBar1 = menuBar(); 638 menuBar1 = menuBar();
636 menuBar1->insertItem( i18n("File"), importMenu ); 639 menuBar1->insertItem( i18n("File"), importMenu );
637 menuBar1->insertItem( i18n("View"), viewMenu ); 640 menuBar1->insertItem( i18n("View"), viewMenu );
638 menuBar1->insertItem( i18n("Actions"), actionMenu ); 641 menuBar1->insertItem( i18n("Actions"), actionMenu );
639#ifdef DESKTOP_VERSION 642#ifdef DESKTOP_VERSION
640 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 643 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
641 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 644 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
642#else 645#else
643 menuBar1->insertItem( i18n("Sync"), syncMenu ); 646 menuBar1->insertItem( i18n("Sync"), syncMenu );
644 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 647 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
645#endif 648#endif
646 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 649 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
647 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 650 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
648 menuBar1->insertItem( i18n("Help"), helpMenu ); 651 menuBar1->insertItem( i18n("Help"), helpMenu );
649 } else { 652 } else {
650 QPEMenuBar *menuBar1; 653 QPEMenuBar *menuBar1;
651 menuBar1 = new QPEMenuBar( iconToolBar ); 654 menuBar1 = new QPEMenuBar( iconToolBar );
652 QPopupMenu *menuBar = new QPopupMenu( this ); 655 QPopupMenu *menuBar = new QPopupMenu( this );
653 icon = loadPixmap( pathString + "z_menu" ); 656 icon = loadPixmap( pathString + "z_menu" );
654 menuBar1->insertItem( icon.pixmap(), menuBar); 657 menuBar1->insertItem( icon.pixmap(), menuBar);
655 //menuBar1->insertItem( i18n("ME"), menuBar); 658 //menuBar1->insertItem( i18n("ME"), menuBar);
656 menuBar->insertItem( i18n("File"), importMenu ); 659 menuBar->insertItem( i18n("File"), importMenu );
657 menuBar->insertItem( i18n("View"), viewMenu ); 660 menuBar->insertItem( i18n("View"), viewMenu );
658 menuBar->insertItem( i18n("Actions"), actionMenu ); 661 menuBar->insertItem( i18n("Actions"), actionMenu );
659 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 662 menuBar->insertItem( i18n("Synchronize"), syncMenu );
660 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 663 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
661 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 664 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
662 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 665 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
663 menuBar->insertItem( i18n("Help"), helpMenu ); 666 menuBar->insertItem( i18n("Help"), helpMenu );
664 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 667 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
665 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 668 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
666 } 669 }
667 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 670 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
668 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 671 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
669 672
670 673
671 mWeekBgColor = iconToolBar->backgroundColor(); 674 mWeekBgColor = iconToolBar->backgroundColor();
672 mWeekPixmap.resize( pixWid , pixHei ); 675 mWeekPixmap.resize( pixWid , pixHei );
673 mWeekPixmap.fill( mWeekBgColor ); 676 mWeekPixmap.fill( mWeekBgColor );
674 icon = mWeekPixmap; 677 icon = mWeekPixmap;
675 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 678 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
676 if ( p-> mShowIconWeekNum ) 679 if ( p-> mShowIconWeekNum )
677 mWeekAction->addTo( iconToolBar ); 680 mWeekAction->addTo( iconToolBar );
678 mWeekFont = font(); 681 mWeekFont = font();
679 682
680 int fontPoint = mWeekFont.pointSize(); 683 int fontPoint = mWeekFont.pointSize();
681 QFontMetrics f( mWeekFont ); 684 QFontMetrics f( mWeekFont );
682 int fontWid = f.width( "30" ); 685 int fontWid = f.width( "30" );
683 while ( fontWid > pixWid ) { 686 while ( fontWid > pixWid ) {
684 --fontPoint; 687 --fontPoint;
685 mWeekFont.setPointSize( fontPoint ); 688 mWeekFont.setPointSize( fontPoint );
686 QFontMetrics f( mWeekFont ); 689 QFontMetrics f( mWeekFont );
687 fontWid = f.width( "30" ); 690 fontWid = f.width( "30" );
688 //qDebug("dec-- "); 691 //qDebug("dec-- ");
689 } 692 }
690 693
691 connect( mWeekAction, SIGNAL( activated() ), 694 connect( mWeekAction, SIGNAL( activated() ),
692 this, SLOT( weekAction() ) ); 695 this, SLOT( weekAction() ) );
693 696
694 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 697 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
695 if ( p->mShowIconFilterview ) { 698 if ( p->mShowIconFilterview ) {
696 icon = loadPixmap( pathString + "filter" ); 699 icon = loadPixmap( pathString + "filter" );
697 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 700 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
698 connect( actionFilterMenuTB, SIGNAL( activated() ), 701 connect( actionFilterMenuTB, SIGNAL( activated() ),
699 this, SLOT( fillFilterMenuTB() ) ); 702 this, SLOT( fillFilterMenuTB() ) );
700 actionFilterMenuTB->addTo( iconToolBar ); 703 actionFilterMenuTB->addTo( iconToolBar );
701 selectFilterMenuTB = new QPopupMenu( this ); 704 selectFilterMenuTB = new QPopupMenu( this );
702 selectFilterMenuTB->setCheckable( true ); 705 selectFilterMenuTB->setCheckable( true );
703 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 706 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
704 } 707 }
705 708
706 //#endif 709 //#endif
707 // ****************** 710 // ******************
708 QAction *action; 711 QAction *action;
709 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 712 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
710 configureToolBarMenu->setCheckable( true ); 713 configureToolBarMenu->setCheckable( true );
711 714
712 715
713 configureAgendaMenu->setCheckable( true ); 716 configureAgendaMenu->setCheckable( true );
714 int iii ; 717 int iii ;
715 for ( iii = 1;iii<= 10 ;++iii ){ 718 for ( iii = 1;iii<= 10 ;++iii ){
716 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 719 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
717 } 720 }
718 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 721 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
719 722
720 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 723 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
721 this, SLOT( showConfigureAgenda( ) ) ); 724 this, SLOT( showConfigureAgenda( ) ) );
722 725
723 icon = loadPixmap( pathString + "configure" ); 726 icon = loadPixmap( pathString + "configure" );
724 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 727 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
725 action->addTo( actionMenu ); 728 action->addTo( actionMenu );
726 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
727 mView, SLOT( edit_options() ) ); 730 mView, SLOT( edit_options() ) );
728 actionMenu->insertSeparator(); 731 actionMenu->insertSeparator();
729 732
730 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 733 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
731 action->addTo( actionMenu ); 734 action->addTo( actionMenu );
732 connect( action, SIGNAL( activated() ), 735 connect( action, SIGNAL( activated() ),
733 mView, SLOT( undo_delete() ) ); 736 mView, SLOT( undo_delete() ) );
734 actionMenu->insertSeparator(); 737 actionMenu->insertSeparator();
735 738
736 icon = loadPixmap( pathString + "newevent" ); 739 icon = loadPixmap( pathString + "newevent" );
737 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 740 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
738 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 741 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
739 configureToolBarMenu->insertSeparator(); 742 configureToolBarMenu->insertSeparator();
740 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 743 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
741 configureToolBarMenu->insertSeparator(); 744 configureToolBarMenu->insertSeparator();
742 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 745 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
743 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 746 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
744 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 747 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
745 ne_action->addTo( actionMenu ); 748 ne_action->addTo( actionMenu );
746 connect( ne_action, SIGNAL( activated() ), 749 connect( ne_action, SIGNAL( activated() ),
747 mView, SLOT( newEvent() ) ); 750 mView, SLOT( newEvent() ) );
748 icon = loadPixmap( pathString + "newtodo" ); 751 icon = loadPixmap( pathString + "newtodo" );
749 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 752 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
750 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 753 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
751 nt_action->addTo( actionMenu ); 754 nt_action->addTo( actionMenu );
752 connect( nt_action, SIGNAL( activated() ), 755 connect( nt_action, SIGNAL( activated() ),
753 mView, SLOT( newTodo() ) ); 756 mView, SLOT( newTodo() ) );
754 757
755 icon = loadPixmap( pathString + "today" ); 758 icon = loadPixmap( pathString + "today" );
756 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 759 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
757 today_action->addTo( viewMenu ); 760 today_action->addTo( viewMenu );
758 connect( today_action, SIGNAL( activated() ), 761 connect( today_action, SIGNAL( activated() ),
759 mView, SLOT( goToday() ) ); 762 mView, SLOT( goToday() ) );
760 viewMenu->insertSeparator(); 763 viewMenu->insertSeparator();
761 764
762 // *********************** 765 // ***********************
763 if ( KOPrefs::instance()->mVerticalScreen ) { 766 if ( KOPrefs::instance()->mVerticalScreen ) {
764 icon = SmallIcon( "1updownarrow" ); 767 icon = SmallIcon( "1updownarrow" );
765 } else { 768 } else {
766 icon = SmallIcon("1leftrightarrow" ); 769 icon = SmallIcon("1leftrightarrow" );
767 } 770 }
768 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 771 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
769 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 772 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
770 FSaction->addTo( viewMenu ); 773 FSaction->addTo( viewMenu );
771 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 774 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
772 775
773 icon = loadPixmap( pathString + "navi" ); 776 icon = loadPixmap( pathString + "navi" );
774 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 777 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
775 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 778 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
776 action->addTo( viewMenu ); 779 action->addTo( viewMenu );
777 connect( action, SIGNAL( activated() ), 780 connect( action, SIGNAL( activated() ),
778 mView, SLOT( toggleDateNavigatorWidget() ) ); 781 mView, SLOT( toggleDateNavigatorWidget() ) );
779 mToggleNav = action ; 782 mToggleNav = action ;
780 icon = loadPixmap( pathString + "filter" ); 783 icon = loadPixmap( pathString + "filter" );
781 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 784 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
782 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 785 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
783 action->addTo( viewMenu ); 786 action->addTo( viewMenu );
784 connect( action, SIGNAL( activated() ), 787 connect( action, SIGNAL( activated() ),
785 mView, SLOT( toggleFilter() ) ); 788 mView, SLOT( toggleFilter() ) );
786 mToggleFilter = action; 789 mToggleFilter = action;
787 icon = loadPixmap( pathString + "allday" ); 790 icon = loadPixmap( pathString + "allday" );
788 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 791 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
789 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 792 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
790 action->addTo( viewMenu ); 793 action->addTo( viewMenu );
791 connect( action, SIGNAL( activated() ), 794 connect( action, SIGNAL( activated() ),
792 mView, SLOT( toggleAllDaySize() ) ); 795 mView, SLOT( toggleAllDaySize() ) );
793 mToggleAllday = action; 796 mToggleAllday = action;
794 797
795 798
796 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 799 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
797 mToggleNav, SLOT( setEnabled ( bool ) ) ); 800 mToggleNav, SLOT( setEnabled ( bool ) ) );
798 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 801 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
799 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 802 mToggleFilter, SLOT( setEnabled ( bool ) ) );
800 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 803 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
801 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 804 mToggleAllday, SLOT( setEnabled ( bool ) ) );
802 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 805 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
803 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 806 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
804 807
805 viewMenu->insertSeparator(); 808 viewMenu->insertSeparator();
806 icon = loadPixmap( pathString + "picker" ); 809 icon = loadPixmap( pathString + "picker" );
807 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 810 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
808 action->addTo( viewMenu ); 811 action->addTo( viewMenu );
809 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
810 mView, SLOT( showDatePicker() ) ); 813 mView, SLOT( showDatePicker() ) );
811 action->addTo( iconToolBar ); 814 action->addTo( iconToolBar );
812 viewMenu->insertSeparator(); 815 viewMenu->insertSeparator();
813 816
814 if ( p-> mShowIconToggleFull ) 817 if ( p-> mShowIconToggleFull )
815 FSaction->addTo( iconToolBar ); 818 FSaction->addTo( iconToolBar );
816 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 819 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
817 820
818 //******************** 821 //********************
819 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 822 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
820 823
821 824
822 icon = loadPixmap( pathString + "whatsnext" ); 825 icon = loadPixmap( pathString + "whatsnext" );
823 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 826 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
824 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 827 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
825 whatsnext_action->addTo( viewMenu ); 828 whatsnext_action->addTo( viewMenu );
826 connect( whatsnext_action, SIGNAL( activated() ), 829 connect( whatsnext_action, SIGNAL( activated() ),
827 mView->viewManager(), SLOT( showWhatsNextView() ) ); 830 mView->viewManager(), SLOT( showWhatsNextView() ) );
828 831
829 icon = loadPixmap( pathString + "xdays" ); 832 icon = loadPixmap( pathString + "xdays" );
830 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 833 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
831 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 834 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
832 xdays_action->addTo( viewMenu ); 835 xdays_action->addTo( viewMenu );
833 connect( xdays_action, SIGNAL( activated() ), 836 connect( xdays_action, SIGNAL( activated() ),
834 mView->viewManager(), SLOT( showNextXView() ) ); 837 mView->viewManager(), SLOT( showNextXView() ) );
835 838
836 839
837 icon = loadPixmap( pathString + "journal" ); 840 icon = loadPixmap( pathString + "journal" );
838 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 841 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
839 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 842 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
840 viewjournal_action->addTo( viewMenu ); 843 viewjournal_action->addTo( viewMenu );
841 connect( viewjournal_action, SIGNAL( activated() ), 844 connect( viewjournal_action, SIGNAL( activated() ),
842 mView->viewManager(), SLOT( showJournalView() ) ); 845 mView->viewManager(), SLOT( showJournalView() ) );
843 846
844 847
845 icon = loadPixmap( pathString + "day" ); 848 icon = loadPixmap( pathString + "day" );
846 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 849 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
847 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 850 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
848 day1_action->addTo( viewMenu ); 851 day1_action->addTo( viewMenu );
849 // action->addTo( toolBar ); 852 // action->addTo( toolBar );
850 connect( day1_action, SIGNAL( activated() ), 853 connect( day1_action, SIGNAL( activated() ),
851 mView->viewManager(), SLOT( showDayView() ) ); 854 mView->viewManager(), SLOT( showDayView() ) );
852 855
853 icon = loadPixmap( pathString + "workweek" ); 856 icon = loadPixmap( pathString + "workweek" );
854 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 857 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
855 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 858 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
856 day5_action->addTo( viewMenu ); 859 day5_action->addTo( viewMenu );
857 connect( day5_action, SIGNAL( activated() ), 860 connect( day5_action, SIGNAL( activated() ),
858 mView->viewManager(), SLOT( showWorkWeekView() ) ); 861 mView->viewManager(), SLOT( showWorkWeekView() ) );
859 862
860 icon = loadPixmap( pathString + "week" ); 863 icon = loadPixmap( pathString + "week" );
861 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 864 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
862 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 865 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
863 day7_action->addTo( viewMenu ); 866 day7_action->addTo( viewMenu );
864 connect( day7_action, SIGNAL( activated() ), 867 connect( day7_action, SIGNAL( activated() ),
865 mView->viewManager(), SLOT( showWeekView() ) ); 868 mView->viewManager(), SLOT( showWeekView() ) );
866 869
867 icon = loadPixmap( pathString + "workweek2" ); 870 icon = loadPixmap( pathString + "workweek2" );
868 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 871 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
869 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 872 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
870 day6_action->addTo( viewMenu ); 873 day6_action->addTo( viewMenu );
871 connect( day6_action, SIGNAL( activated() ), 874 connect( day6_action, SIGNAL( activated() ),
872 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 875 mView->viewManager(), SLOT( showMonthViewWeek() ) );
873 876
874 icon = loadPixmap( pathString + "month" ); 877 icon = loadPixmap( pathString + "month" );
875 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 878 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
876 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 879 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
877 month_action->addTo( viewMenu ); 880 month_action->addTo( viewMenu );
878 connect( month_action, SIGNAL( activated() ), 881 connect( month_action, SIGNAL( activated() ),
879 mView->viewManager(), SLOT( showMonthView() ) ); 882 mView->viewManager(), SLOT( showMonthView() ) );
880 883
881 icon = loadPixmap( pathString + "list" ); 884 icon = loadPixmap( pathString + "list" );
882 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 885 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
883 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 886 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
884 showlist_action->addTo( viewMenu ); 887 showlist_action->addTo( viewMenu );
885 connect( showlist_action, SIGNAL( activated() ), 888 connect( showlist_action, SIGNAL( activated() ),
886 mView->viewManager(), SLOT( showListView() ) ); 889 mView->viewManager(), SLOT( showListView() ) );
887 890
888 icon = loadPixmap( pathString + "todo" ); 891 icon = loadPixmap( pathString + "todo" );
889 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 892 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
890 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 893 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
891 todoview_action->addTo( viewMenu ); 894 todoview_action->addTo( viewMenu );
892 connect( todoview_action, SIGNAL( activated() ), 895 connect( todoview_action, SIGNAL( activated() ),
893 mView->viewManager(), SLOT( showTodoView() ) ); 896 mView->viewManager(), SLOT( showTodoView() ) );
894 897
895 898
896 899
897#if 0 900#if 0
898 action = new QAction( "view_timespan", "Time Span", 0, this ); 901 action = new QAction( "view_timespan", "Time Span", 0, this );
899 action->addTo( viewMenu ); 902 action->addTo( viewMenu );
900 connect( action, SIGNAL( activated() ), 903 connect( action, SIGNAL( activated() ),
901 mView->viewManager(), SLOT( showTimeSpanView() ) ); 904 mView->viewManager(), SLOT( showTimeSpanView() ) );
902#endif 905#endif
903 906
904 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 907 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
905 this ); 908 this );
906 mNewSubTodoAction->addTo( actionMenu ); 909 mNewSubTodoAction->addTo( actionMenu );
907 connect( mNewSubTodoAction, SIGNAL( activated() ), 910 connect( mNewSubTodoAction, SIGNAL( activated() ),
908 mView, SLOT( newSubTodo() ) ); 911 mView, SLOT( newSubTodo() ) );
909 912
910 actionMenu->insertSeparator(); 913 actionMenu->insertSeparator();
911 914
912 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 915 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
913 mShowAction->addTo( actionMenu ); 916 mShowAction->addTo( actionMenu );
914 connect( mShowAction, SIGNAL( activated() ), 917 connect( mShowAction, SIGNAL( activated() ),
915 mView, SLOT( showIncidence() ) ); 918 mView, SLOT( showIncidence() ) );
916 919
917 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 920 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
918 mEditAction->addTo( actionMenu ); 921 mEditAction->addTo( actionMenu );
919 connect( mEditAction, SIGNAL( activated() ), 922 connect( mEditAction, SIGNAL( activated() ),
920 mView, SLOT( editIncidence() ) ); 923 mView, SLOT( editIncidence() ) );
921 924
922 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 925 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
923 mDeleteAction->addTo( actionMenu ); 926 mDeleteAction->addTo( actionMenu );
924 connect( mDeleteAction, SIGNAL( activated() ), 927 connect( mDeleteAction, SIGNAL( activated() ),
925 mView, SLOT( deleteIncidence() ) ); 928 mView, SLOT( deleteIncidence() ) );
926 929
927 930
928 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 931 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
929 mCloneAction->addTo( actionMenu ); 932 mCloneAction->addTo( actionMenu );
930 connect( mCloneAction, SIGNAL( activated() ), 933 connect( mCloneAction, SIGNAL( activated() ),
931 mView, SLOT( cloneIncidence() ) ); 934 mView, SLOT( cloneIncidence() ) );
932 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 935 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
933 mMoveAction->addTo( actionMenu ); 936 mMoveAction->addTo( actionMenu );
934 connect( mMoveAction, SIGNAL( activated() ), 937 connect( mMoveAction, SIGNAL( activated() ),
935 mView, SLOT( moveIncidence() ) ); 938 mView, SLOT( moveIncidence() ) );
936 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 939 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
937 mBeamAction->addTo( actionMenu ); 940 mBeamAction->addTo( actionMenu );
938 connect( mBeamAction, SIGNAL( activated() ), 941 connect( mBeamAction, SIGNAL( activated() ),
939 mView, SLOT( beamIncidence() ) ); 942 mView, SLOT( beamIncidence() ) );
940 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 943 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
941 mCancelAction->addTo( actionMenu ); 944 mCancelAction->addTo( actionMenu );
942 connect( mCancelAction, SIGNAL( activated() ), 945 connect( mCancelAction, SIGNAL( activated() ),
943 mView, SLOT( toggleCancelIncidence() ) ); 946 mView, SLOT( toggleCancelIncidence() ) );
944 947
945 actionMenu->insertSeparator(); 948 actionMenu->insertSeparator();
946 949
947 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 950 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
948 this ); 951 this );
949 action->addTo( actionMenu ); 952 action->addTo( actionMenu );
950 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 953 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
951 954
952 icon = loadPixmap( pathString + "search" ); 955 icon = loadPixmap( pathString + "search" );
953 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 956 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
954 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 957 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
955 search_action->addTo( actionMenu ); 958 search_action->addTo( actionMenu );
956 connect( search_action, SIGNAL( activated() ), 959 connect( search_action, SIGNAL( activated() ),
957 mView->dialogManager(), SLOT( showSearchDialog() ) ); 960 mView->dialogManager(), SLOT( showSearchDialog() ) );
958 961
959 962
960 963
961 if ( KOPrefs::instance()->mShowFullMenu ) { 964 if ( KOPrefs::instance()->mShowFullMenu ) {
962 actionMenu->insertSeparator(); 965 actionMenu->insertSeparator();
963 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 966 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
964 967
965 } 968 }
966 // actionMenu->insertSeparator(); 969 // actionMenu->insertSeparator();
967 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 970 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
968 this ); 971 this );
969 action->addTo( importMenu_X ); 972 action->addTo( importMenu_X );
970 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 973 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
971 action = new QAction( "import_quick", i18n("Import last file"), 0, 974 action = new QAction( "import_quick", i18n("Import last file"), 0,
972 this ); 975 this );
973 action->addTo( importMenu_X ); 976 action->addTo( importMenu_X );
974 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 977 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
975 importMenu_X->insertSeparator(); 978 importMenu_X->insertSeparator();
976 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 979 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
977 this ); 980 this );
978 action->addTo( importMenu_X ); 981 action->addTo( importMenu_X );
979 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 982 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
980 //#ifndef DESKTOP_VERSION 983 //#ifndef DESKTOP_VERSION
981 importMenu_X->insertSeparator(); 984 importMenu_X->insertSeparator();
982 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 985 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
983 this ); 986 this );
984 action->addTo( importMenu_X ); 987 action->addTo( importMenu_X );
985 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
986 //#else 989 //#else
987#ifdef _OL_IMPORT_ 990#ifdef _OL_IMPORT_
988 importMenu_X->insertSeparator(); 991 importMenu_X->insertSeparator();
989 action = new QAction( "import_ol", i18n("Import from OL"), 0, 992 action = new QAction( "import_ol", i18n("Import from OL"), 0,
990 this ); 993 this );
991 action->addTo( importMenu_X ); 994 action->addTo( importMenu_X );
992 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 995 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
993#endif 996#endif
994 //#endif 997 //#endif
995 998
996 //importMenu->insertSeparator(); 999 //importMenu->insertSeparator();
997 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1000 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
998 this ); 1001 this );
999 action->addTo( importMenu ); 1002 action->addTo( importMenu );
1000 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1003 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1001 1004
1002 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 1005 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
1003 this ); 1006 this );
1004 action->addTo( importMenu ); 1007 action->addTo( importMenu );
1005 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1008 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1006 importMenu->insertSeparator(); 1009 importMenu->insertSeparator();
1007 importMenu->insertItem( i18n("Import"), importMenu_X ); 1010 importMenu->insertItem( i18n("Import"), importMenu_X );
1008 //importMenu->insertSeparator(); 1011 //importMenu->insertSeparator();
1009 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1012 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1010 this ); 1013 this );
1011 action->addTo( exportMenu_X ); 1014 action->addTo( exportMenu_X );
1012 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1015 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1013 1016
1014 1017
1015 //LR 1018 //LR
1016 QPopupMenu *ex2phone = new QPopupMenu( this ); 1019 QPopupMenu *ex2phone = new QPopupMenu( this );
1017 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1020 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1018 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1021 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1019 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1022 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1020 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1023 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1021 1024
1022 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1025 importMenu->insertItem( i18n("Export"), exportMenu_X );
1023#ifndef DESKTOP_VERSION 1026#ifndef DESKTOP_VERSION
1024 //importMenu->insertSeparator(); 1027 //importMenu->insertSeparator();
1025 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1028 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1026 this ); 1029 this );
1027 brAction->addTo( beamMenu_X ); 1030 brAction->addTo( beamMenu_X );
1028 brAction->setToggleAction (true ) ; 1031 brAction->setToggleAction (true ) ;
1029 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1032 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1030 1033
1031 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1034 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1032 this ); 1035 this );
1033 action->addTo( beamMenu_X ); 1036 action->addTo( beamMenu_X );
1034 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1037 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1035 1038
1036 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1039 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1037 this ); 1040 this );
1038 action->addTo( beamMenu_X ); 1041 action->addTo( beamMenu_X );
1039 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1042 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1040 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1043 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1041#else 1044#else
1042 //importMenu->insertSeparator(); 1045 //importMenu->insertSeparator();
1043 icon = loadPixmap( pathString + "print" ); 1046 icon = loadPixmap( pathString + "print" );
1044 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1047 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1045 action->addTo( beamMenu_X ); 1048 action->addTo( beamMenu_X );
1046 connect( action, SIGNAL( activated() ), 1049 connect( action, SIGNAL( activated() ),
1047 this, SLOT( printCal() ) ); 1050 this, SLOT( printCal() ) );
1048 1051
1049 icon = loadPixmap( pathString + "print" ); 1052 icon = loadPixmap( pathString + "print" );
1050 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1053 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1051 action->addTo( beamMenu_X ); 1054 action->addTo( beamMenu_X );
1052 connect( action, SIGNAL( activated() ), 1055 connect( action, SIGNAL( activated() ),
1053 this, SLOT( printSel() ) ); 1056 this, SLOT( printSel() ) );
1054 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1057 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1055 action->addTo( beamMenu_X ); 1058 action->addTo( beamMenu_X );
1056 connect( action, SIGNAL( activated() ), 1059 connect( action, SIGNAL( activated() ),
1057 mView->viewManager(), SLOT( slotprintWNV() ) ); 1060 mView->viewManager(), SLOT( slotprintWNV() ) );
1058 1061
1059 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1062 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1060 action->addTo( beamMenu_X ); 1063 action->addTo( beamMenu_X );
1061 connect( action, SIGNAL( activated() ), 1064 connect( action, SIGNAL( activated() ),
1062 mView, SLOT( slotprintSelInc() ) ); 1065 mView, SLOT( slotprintSelInc() ) );
1063 1066
1064 1067
1065 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1068 importMenu->insertItem( i18n("Print"), beamMenu_X );
1066#endif 1069#endif
1067 importMenu->insertSeparator(); 1070 importMenu->insertSeparator();
1068 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1071 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1069 this ); 1072 this );
1070 action->addTo( importMenu ); 1073 action->addTo( importMenu );
1071 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1074 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1072 importMenu->insertSeparator(); 1075 importMenu->insertSeparator();
1073 action = new QAction( "beam all", i18n("Save"), 0, 1076 action = new QAction( "beam all", i18n("Save"), 0,
1074 this ); 1077 this );
1075 action->addTo( importMenu ); 1078 action->addTo( importMenu );
1076 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1079 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1077 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1080 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1078 this ); 1081 this );
1079 action->addTo( importMenu ); 1082 action->addTo( importMenu );
1080 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1083 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1081 1084
1082 //menuBar->insertItem( "Configure",configureMenu ); 1085 //menuBar->insertItem( "Configure",configureMenu );
1083 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1086 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1084 icon = loadPixmap( "korganizer/korganizer" ); 1087 icon = loadPixmap( "korganizer/korganizer" );
1085 1088
1086 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1089 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1087 action->addTo( helpMenu ); 1090 action->addTo( helpMenu );
1088 connect( action, SIGNAL( activated() ), 1091 connect( action, SIGNAL( activated() ),
1089 SLOT( whatsNew() ) ); 1092 SLOT( whatsNew() ) );
1090 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1093 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1091 action->addTo( helpMenu ); 1094 action->addTo( helpMenu );
1092 connect( action, SIGNAL( activated() ), 1095 connect( action, SIGNAL( activated() ),
1093 SLOT( features() ) ); 1096 SLOT( features() ) );
1094 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1097 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1095 action->addTo( helpMenu ); 1098 action->addTo( helpMenu );
1096 connect( action, SIGNAL( activated() ), 1099 connect( action, SIGNAL( activated() ),
1097 SLOT( keyBindings() ) ); 1100 SLOT( keyBindings() ) );
1098 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1101 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1099 action->addTo( helpMenu ); 1102 action->addTo( helpMenu );
1100 connect( action, SIGNAL( activated() ), 1103 connect( action, SIGNAL( activated() ),
1101 SLOT( storagehowto() ) ); 1104 SLOT( storagehowto() ) );
1102 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1105 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1103 action->addTo( helpMenu ); 1106 action->addTo( helpMenu );
1104 connect( action, SIGNAL( activated() ), 1107 connect( action, SIGNAL( activated() ),
1105 SLOT( timetrackinghowto() ) ); 1108 SLOT( timetrackinghowto() ) );
1106 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1109 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1107 action->addTo( helpMenu ); 1110 action->addTo( helpMenu );
1108 connect( action, SIGNAL( activated() ), 1111 connect( action, SIGNAL( activated() ),
1109 SLOT( synchowto() ) ); 1112 SLOT( synchowto() ) );
1110 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1113 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1111 action->addTo( helpMenu ); 1114 action->addTo( helpMenu );
1112 connect( action, SIGNAL( activated() ), 1115 connect( action, SIGNAL( activated() ),
1113 SLOT( kdesynchowto() ) ); 1116 SLOT( kdesynchowto() ) );
1114 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1117 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1115 action->addTo( helpMenu ); 1118 action->addTo( helpMenu );
1116 connect( action, SIGNAL( activated() ), 1119 connect( action, SIGNAL( activated() ),
1117 SLOT( multisynchowto() ) ); 1120 SLOT( multisynchowto() ) );
1118 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1121 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1119 action->addTo( helpMenu ); 1122 action->addTo( helpMenu );
1120 connect( action, SIGNAL( activated() ), 1123 connect( action, SIGNAL( activated() ),
1121 SLOT( aboutAutoSaving() ) ); 1124 SLOT( aboutAutoSaving() ) );
1122 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1125 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1123 action->addTo( helpMenu ); 1126 action->addTo( helpMenu );
1124 connect( action, SIGNAL( activated() ), 1127 connect( action, SIGNAL( activated() ),
1125 SLOT( aboutKnownBugs() ) ); 1128 SLOT( aboutKnownBugs() ) );
1126 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1129 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1127 action->addTo( helpMenu ); 1130 action->addTo( helpMenu );
1128 connect( action, SIGNAL( activated() ), 1131 connect( action, SIGNAL( activated() ),
1129 SLOT( usertrans() ) ); 1132 SLOT( usertrans() ) );
1130 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1133 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1131 action->addTo( helpMenu ); 1134 action->addTo( helpMenu );
1132 connect( action, SIGNAL( activated() ), 1135 connect( action, SIGNAL( activated() ),
1133 SLOT( faq() ) ); 1136 SLOT( faq() ) );
1134 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1137 action = new QAction( "licence", i18n("Licence..."), 0, this );
1135 action->addTo( helpMenu ); 1138 action->addTo( helpMenu );
1136 connect( action, SIGNAL( activated() ), 1139 connect( action, SIGNAL( activated() ),
1137 SLOT( licence() ) ); 1140 SLOT( licence() ) );
1138 action = new QAction( "about", i18n("About..."), 0, this ); 1141 action = new QAction( "about", i18n("About..."), 0, this );
1139 action->addTo( helpMenu ); 1142 action->addTo( helpMenu );
1140 connect( action, SIGNAL( activated() ), 1143 connect( action, SIGNAL( activated() ),
1141 SLOT( about() ) ); 1144 SLOT( about() ) );
1142 //menuBar->insertSeparator(); 1145 //menuBar->insertSeparator();
1143 1146
1144 // ****************************************************** 1147 // ******************************************************
1145 // menubar icons 1148 // menubar icons
1146 1149
1147 1150
1148 1151
1149 //menuBar->insertItem( iconToolBar ); 1152 //menuBar->insertItem( iconToolBar );
1150 //xdays_action 1153 //xdays_action
1151 if (p-> mShowIconNewEvent) 1154 if (p-> mShowIconNewEvent)
1152 ne_action->addTo( iconToolBar ); 1155 ne_action->addTo( iconToolBar );
1153 if (p->mShowIconNewTodo ) 1156 if (p->mShowIconNewTodo )
1154 nt_action->addTo( iconToolBar ); 1157 nt_action->addTo( iconToolBar );
1155 if (p-> mShowIconSearch) 1158 if (p-> mShowIconSearch)
1156 search_action->addTo( iconToolBar ); 1159 search_action->addTo( iconToolBar );
1157 if (p-> mShowIconWhatsThis) 1160 if (p-> mShowIconWhatsThis)
1158 QWhatsThis::whatsThisButton ( iconToolBar ); 1161 QWhatsThis::whatsThisButton ( iconToolBar );
1159 if (p-> mShowIconNext) 1162 if (p-> mShowIconNext)
1160 whatsnext_action->addTo( viewToolBar ); 1163 whatsnext_action->addTo( viewToolBar );
1161 if (p-> mShowIconNextDays) 1164 if (p-> mShowIconNextDays)
1162 xdays_action->addTo( viewToolBar ); 1165 xdays_action->addTo( viewToolBar );
1163 if (p-> mShowIconJournal) 1166 if (p-> mShowIconJournal)
1164 viewjournal_action->addTo( viewToolBar ); 1167 viewjournal_action->addTo( viewToolBar );
1165 if (p-> mShowIconDay1) 1168 if (p-> mShowIconDay1)
1166 day1_action->addTo( viewToolBar ); 1169 day1_action->addTo( viewToolBar );
1167 if (p-> mShowIconDay5) 1170 if (p-> mShowIconDay5)
1168 day5_action->addTo( viewToolBar ); 1171 day5_action->addTo( viewToolBar );
1169 if (p-> mShowIconDay7) 1172 if (p-> mShowIconDay7)
1170 day7_action->addTo( viewToolBar ); 1173 day7_action->addTo( viewToolBar );
1171 if (p-> mShowIconDay6) 1174 if (p-> mShowIconDay6)
1172 day6_action->addTo( viewToolBar ); 1175 day6_action->addTo( viewToolBar );
1173 if (p-> mShowIconMonth) 1176 if (p-> mShowIconMonth)
1174 month_action->addTo( viewToolBar ); 1177 month_action->addTo( viewToolBar );
1175 if (p-> mShowIconList) 1178 if (p-> mShowIconList)
1176 showlist_action->addTo( viewToolBar ); 1179 showlist_action->addTo( viewToolBar );
1177 if (p-> mShowIconTodoview) 1180 if (p-> mShowIconTodoview)
1178 todoview_action->addTo( viewToolBar ); 1181 todoview_action->addTo( viewToolBar );
1179 1182
1180 icon = loadPixmap( pathString + "2leftarrowB" ); 1183 icon = loadPixmap( pathString + "2leftarrowB" );
1181 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1184 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1182 if (p-> mShowIconBackFast) { 1185 if (p-> mShowIconBackFast) {
1183 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1186 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1184 connect( action, SIGNAL( activated() ), 1187 connect( action, SIGNAL( activated() ),
1185 mView, SLOT( goPreviousMonth() ) ); 1188 mView, SLOT( goPreviousMonth() ) );
1186 action->addTo( navigatorToolBar ); 1189 action->addTo( navigatorToolBar );
1187 } 1190 }
1188 icon = loadPixmap( pathString + "1leftarrowB" ); 1191 icon = loadPixmap( pathString + "1leftarrowB" );
1189 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1192 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1190 if (p-> mShowIconBack) { 1193 if (p-> mShowIconBack) {
1191 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1194 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1192 connect( action, SIGNAL( activated() ), 1195 connect( action, SIGNAL( activated() ),
1193 mView, SLOT( goPrevious() ) ); 1196 mView, SLOT( goPrevious() ) );
1194 action->addTo( navigatorToolBar ); 1197 action->addTo( navigatorToolBar );
1195 } 1198 }
1196 icon = loadPixmap( pathString + "today" ); 1199 icon = loadPixmap( pathString + "today" );
1197 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1200 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1198 if (p-> mShowIconToday) 1201 if (p-> mShowIconToday)
1199 today_action->addTo( navigatorToolBar ); 1202 today_action->addTo( navigatorToolBar );
1200 icon = loadPixmap( pathString + "1rightarrowB" ); 1203 icon = loadPixmap( pathString + "1rightarrowB" );
1201 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1204 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1202 if (p-> mShowIconForward) { 1205 if (p-> mShowIconForward) {
1203 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1206 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1204 connect( action, SIGNAL( activated() ), 1207 connect( action, SIGNAL( activated() ),
1205 mView, SLOT( goNext() ) ); 1208 mView, SLOT( goNext() ) );
1206 action->addTo( navigatorToolBar ); 1209 action->addTo( navigatorToolBar );
1207 } 1210 }
1208 icon = loadPixmap( pathString + "2rightarrowB" ); 1211 icon = loadPixmap( pathString + "2rightarrowB" );
1209 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1212 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1210 if (p-> mShowIconForwardFast) { 1213 if (p-> mShowIconForwardFast) {
1211 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1214 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1212 connect( action, SIGNAL( activated() ), 1215 connect( action, SIGNAL( activated() ),
1213 mView, SLOT( goNextMonth() ) ); 1216 mView, SLOT( goNextMonth() ) );
1214 action->addTo( navigatorToolBar ); 1217 action->addTo( navigatorToolBar );
1215 } 1218 }
1216 1219
1217 1220
1218 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1221 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1219 1222
1220 1223
1221 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1224 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1222 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1225 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1223 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1226 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1224 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1227 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1225 1228
1226 if (p-> mShowIconNewEvent) 1229 if (p-> mShowIconNewEvent)
1227 configureToolBarMenu->setItemChecked( 10, true ); 1230 configureToolBarMenu->setItemChecked( 10, true );
1228 if (p->mShowIconNewTodo ) 1231 if (p->mShowIconNewTodo )
1229 configureToolBarMenu->setItemChecked( 20, true ); 1232 configureToolBarMenu->setItemChecked( 20, true );
1230 if (p-> mShowIconSearch) 1233 if (p-> mShowIconSearch)
1231 configureToolBarMenu->setItemChecked( 120, true ); 1234 configureToolBarMenu->setItemChecked( 120, true );
1232 if (p-> mShowIconList) 1235 if (p-> mShowIconList)
1233 configureToolBarMenu->setItemChecked( 30, true ); 1236 configureToolBarMenu->setItemChecked( 30, true );
1234 if (p-> mShowIconDay1) 1237 if (p-> mShowIconDay1)
1235 configureToolBarMenu->setItemChecked( 40, true ); 1238 configureToolBarMenu->setItemChecked( 40, true );
1236 if (p-> mShowIconDay5) 1239 if (p-> mShowIconDay5)
1237 configureToolBarMenu->setItemChecked( 50, true ); 1240 configureToolBarMenu->setItemChecked( 50, true );
1238 if (p-> mShowIconDay6) 1241 if (p-> mShowIconDay6)
1239 configureToolBarMenu->setItemChecked( 75, true ); 1242 configureToolBarMenu->setItemChecked( 75, true );
1240 if (p-> mShowIconDay7) 1243 if (p-> mShowIconDay7)
1241 configureToolBarMenu->setItemChecked( 60, true ); 1244 configureToolBarMenu->setItemChecked( 60, true );
1242 if (p-> mShowIconMonth) 1245 if (p-> mShowIconMonth)
1243 configureToolBarMenu->setItemChecked( 70, true ); 1246 configureToolBarMenu->setItemChecked( 70, true );
1244 if (p-> mShowIconTodoview) 1247 if (p-> mShowIconTodoview)
1245 configureToolBarMenu->setItemChecked( 80, true ); 1248 configureToolBarMenu->setItemChecked( 80, true );
1246 if (p-> mShowIconBackFast) 1249 if (p-> mShowIconBackFast)
1247 configureToolBarMenu->setItemChecked( 200, true ); 1250 configureToolBarMenu->setItemChecked( 200, true );
1248 if (p-> mShowIconBack) 1251 if (p-> mShowIconBack)
1249 configureToolBarMenu->setItemChecked( 210, true ); 1252 configureToolBarMenu->setItemChecked( 210, true );
1250 if (p-> mShowIconToday) 1253 if (p-> mShowIconToday)
1251 configureToolBarMenu->setItemChecked( 130, true ); 1254 configureToolBarMenu->setItemChecked( 130, true );
1252 if (p-> mShowIconForward) 1255 if (p-> mShowIconForward)
1253 configureToolBarMenu->setItemChecked( 220, true ); 1256 configureToolBarMenu->setItemChecked( 220, true );
1254 if (p-> mShowIconForwardFast) 1257 if (p-> mShowIconForwardFast)
1255 configureToolBarMenu->setItemChecked( 230, true ); 1258 configureToolBarMenu->setItemChecked( 230, true );
1256 if (p-> mShowIconNextDays) 1259 if (p-> mShowIconNextDays)
1257 configureToolBarMenu->setItemChecked( 100, true ); 1260 configureToolBarMenu->setItemChecked( 100, true );
1258 if (p-> mShowIconNext) 1261 if (p-> mShowIconNext)
1259 configureToolBarMenu->setItemChecked( 110, true ); 1262 configureToolBarMenu->setItemChecked( 110, true );
1260 if (p-> mShowIconJournal) 1263 if (p-> mShowIconJournal)
1261 configureToolBarMenu->setItemChecked( 90, true ); 1264 configureToolBarMenu->setItemChecked( 90, true );
1262 if (p-> mShowIconWhatsThis) 1265 if (p-> mShowIconWhatsThis)
1263 configureToolBarMenu->setItemChecked( 300, true ); 1266 configureToolBarMenu->setItemChecked( 300, true );
1264 if (p-> mShowIconWeekNum) 1267 if (p-> mShowIconWeekNum)
1265 configureToolBarMenu->setItemChecked( 400, true ); 1268 configureToolBarMenu->setItemChecked( 400, true );
1266 if (!p-> mShowIconStretch) { 1269 if (!p-> mShowIconStretch) {
1267 QLabel* dummy = new QLabel( iconToolBar ); 1270 QLabel* dummy = new QLabel( iconToolBar );
1268 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1271 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1269 dummy->setMinimumWidth( 0 ); 1272 dummy->setMinimumWidth( 0 );
1270 iconToolBar->setStretchableWidget ( dummy ) ; 1273 iconToolBar->setStretchableWidget ( dummy ) ;
1271 } 1274 }
1272 else { 1275 else {
1273 iconToolBar->setHorizontalStretchable (true ); 1276 iconToolBar->setHorizontalStretchable (true );
1274 viewToolBar->setHorizontalStretchable (true ); 1277 viewToolBar->setHorizontalStretchable (true );
1275 navigatorToolBar->setHorizontalStretchable (true ); 1278 navigatorToolBar->setHorizontalStretchable (true );
1276 iconToolBar->setVerticalStretchable (true ); 1279 iconToolBar->setVerticalStretchable (true );
1277 viewToolBar->setVerticalStretchable (true ); 1280 viewToolBar->setVerticalStretchable (true );
1278 navigatorToolBar->setVerticalStretchable (true ); 1281 navigatorToolBar->setVerticalStretchable (true );
1279 configureToolBarMenu->setItemChecked( 5, true ); 1282 configureToolBarMenu->setItemChecked( 5, true );
1280 } 1283 }
1281 if (p-> mShowIconFilter) 1284 if (p-> mShowIconFilter)
1282 configureToolBarMenu->setItemChecked( 7, true ); 1285 configureToolBarMenu->setItemChecked( 7, true );
1283 if (p-> mShowIconOnetoolbar) 1286 if (p-> mShowIconOnetoolbar)
1284 configureToolBarMenu->setItemChecked( 6, true ); 1287 configureToolBarMenu->setItemChecked( 6, true );
1285 1288
1286 1289
1287 if ( filterMenubar ) { 1290 if ( filterMenubar ) {
1288 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1291 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1289 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1292 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1290 } 1293 }
1291 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1294 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1292 configureAgenda( p->mHourSize ); 1295 configureAgenda( p->mHourSize );
1293 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1296 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1294} 1297}
1295 1298
1296void MainWindow::exportToPhone( int mode ) 1299void MainWindow::exportToPhone( int mode )
1297{ 1300{
1298 1301
1299 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1302 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1300 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1303 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1301 KOex2phonePrefs ex2phone; 1304 KOex2phonePrefs ex2phone;
1302 1305
1303 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1306 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1304 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1307 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1305 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1308 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1306 if ( mode == 1 ) 1309 if ( mode == 1 )
1307 ex2phone.setCaption(i18n("Export complete calendar")); 1310 ex2phone.setCaption(i18n("Export complete calendar"));
1308 if ( mode == 2 ) 1311 if ( mode == 2 )
1309 ex2phone.setCaption(i18n("Export filtered calendar")); 1312 ex2phone.setCaption(i18n("Export filtered calendar"));
1310 1313
1311 if ( !ex2phone.exec() ) { 1314 if ( !ex2phone.exec() ) {
1312 return; 1315 return;
1313 } 1316 }
1314 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1317 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1315 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1318 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1316 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1319 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1317 1320
1318 int inFuture = 0; 1321 int inFuture = 0;
1319 if ( ex2phone.mWriteBackFuture->isChecked() ) 1322 if ( ex2phone.mWriteBackFuture->isChecked() )
1320 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1323 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1321 QPtrList<Incidence> delSel; 1324 QPtrList<Incidence> delSel;
1322 if ( mode == 1 ) 1325 if ( mode == 1 )
1323 delSel = mCalendar->rawIncidences(); 1326 delSel = mCalendar->rawIncidences();
1324 if ( mode == 2 ) 1327 if ( mode == 2 )
1325 delSel = mCalendar->incidences(); 1328 delSel = mCalendar->incidences();
1326 CalendarLocal* cal = new CalendarLocal(); 1329 CalendarLocal* cal = new CalendarLocal();
1327 cal->setLocalTime(); 1330 cal->setLocalTime();
1328 Incidence *incidence = delSel.first(); 1331 Incidence *incidence = delSel.first();
1329 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1332 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1330 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1333 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1331 while ( incidence ) { 1334 while ( incidence ) {
1332 if ( incidence->type() != "Journal" ) { 1335 if ( incidence->type() != "Journal" ) {
1333 bool add = true; 1336 bool add = true;
1334 if ( inFuture ) { 1337 if ( inFuture ) {
1335 QDateTime dt; 1338 QDateTime dt;
1336 if ( incidence->type() == "Todo" ) { 1339 if ( incidence->type() == "Todo" ) {
1337 Todo * t = (Todo*)incidence; 1340 Todo * t = (Todo*)incidence;
1338 if ( t->hasDueDate() ) 1341 if ( t->hasDueDate() )
1339 dt = t->dtDue(); 1342 dt = t->dtDue();
1340 else 1343 else
1341 dt = cur.addSecs( 62 ); 1344 dt = cur.addSecs( 62 );
1342 } 1345 }
1343 else { 1346 else {
1344 bool ok; 1347 bool ok;
1345 dt = incidence->getNextOccurence( cur, &ok ); 1348 dt = incidence->getNextOccurence( cur, &ok );
1346 if ( !ok ) 1349 if ( !ok )
1347 dt = cur.addSecs( -62 ); 1350 dt = cur.addSecs( -62 );
1348 } 1351 }
1349 if ( dt < cur || dt > end ) { 1352 if ( dt < cur || dt > end ) {
1350 add = false; 1353 add = false;
1351 } 1354 }
1352 } 1355 }
1353 if ( add ) { 1356 if ( add ) {
1354 Incidence *in = incidence->clone(); 1357 Incidence *in = incidence->clone();
1355 cal->addIncidence( in ); 1358 cal->addIncidence( in );
1356 } 1359 }
1357 } 1360 }
1358 incidence = delSel.next(); 1361 incidence = delSel.next();
1359 } 1362 }
1360 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1363 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1361 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1364 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1362 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1365 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1363 1366
1364 setCaption( i18n("Writing to phone...")); 1367 setCaption( i18n("Writing to phone..."));
1365 if ( PhoneFormat::writeToPhone( cal ) ) 1368 if ( PhoneFormat::writeToPhone( cal ) )
1366 setCaption( i18n("Export to phone successful!")); 1369 setCaption( i18n("Export to phone successful!"));
1367 else 1370 else
1368 setCaption( i18n("Error exporting to phone!")); 1371 setCaption( i18n("Error exporting to phone!"));
1369 delete cal; 1372 delete cal;
1370} 1373}
1371 1374
1372 1375
1373void MainWindow::setDefaultPreferences() 1376void MainWindow::setDefaultPreferences()
1374{ 1377{
1375 KOPrefs *p = KOPrefs::instance(); 1378 KOPrefs *p = KOPrefs::instance();
1376 1379
1377 p->mCompactDialogs = true; 1380 p->mCompactDialogs = true;
1378 p->mConfirm = true; 1381 p->mConfirm = true;
1379 // p->mEnableQuickTodo = false; 1382 // p->mEnableQuickTodo = false;
1380 1383
1381} 1384}
1382 1385
1383QString MainWindow::resourcePath() 1386QString MainWindow::resourcePath()
1384{ 1387{
1385 return KGlobal::iconLoader()->iconPath(); 1388 return KGlobal::iconLoader()->iconPath();
1386} 1389}
1387 1390
1388void MainWindow::displayText( QString text ,QString cap ) 1391void MainWindow::displayText( QString text ,QString cap )
1389{ 1392{
1390 QDialog dia( this, "name", true ); ; 1393 QDialog dia( this, "name", true ); ;
1391 dia.setCaption( cap ); 1394 dia.setCaption( cap );
1392 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1395 QVBoxLayout* lay = new QVBoxLayout( &dia );
1393 lay->setSpacing( 3 ); 1396 lay->setSpacing( 3 );
1394 lay->setMargin( 3 ); 1397 lay->setMargin( 3 );
1395 QTextBrowser tb ( &dia ); 1398 QTextBrowser tb ( &dia );
1396 lay->addWidget( &tb ); 1399 lay->addWidget( &tb );
1397 tb.setText( text ); 1400 tb.setText( text );
1398#ifdef DESKTOP_VERSION 1401#ifdef DESKTOP_VERSION
1399 dia.resize( 640, 480); 1402 dia.resize( 640, 480);
1400#else 1403#else
1401 dia.showMaximized(); 1404 dia.showMaximized();
1402#endif 1405#endif
1403 dia.exec(); 1406 dia.exec();
1404} 1407}
1405 1408
1406void MainWindow::features() 1409void MainWindow::features()
1407{ 1410{
1408 1411
1409 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1412 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1410} 1413}
1411 1414
1412void MainWindow::usertrans() 1415void MainWindow::usertrans()
1413{ 1416{
1414 1417
1415 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1418 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1416} 1419}
1417 1420
1418void MainWindow::storagehowto() 1421void MainWindow::storagehowto()
1419{ 1422{
1420 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1423 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1421} 1424}
1422void MainWindow::timetrackinghowto() 1425void MainWindow::timetrackinghowto()
1423{ 1426{
1424 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1427 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1425} 1428}
1426void MainWindow::kdesynchowto() 1429void MainWindow::kdesynchowto()
1427{ 1430{
1428 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1431 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1429} 1432}
1430void MainWindow::multisynchowto() 1433void MainWindow::multisynchowto()
1431{ 1434{
1432 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1435 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1433} 1436}
1434void MainWindow::synchowto() 1437void MainWindow::synchowto()
1435{ 1438{
1436 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1439 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1437} 1440}
1438void MainWindow::faq() 1441void MainWindow::faq()
1439{ 1442{
1440 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1443 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1441 1444
1442} 1445}
1443void MainWindow::whatsNew() 1446void MainWindow::whatsNew()
1444{ 1447{
1445 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1448 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1446 1449
1447} 1450}
1448void MainWindow::licence() 1451void MainWindow::licence()
1449{ 1452{
1450 KApplication::showLicence(); 1453 KApplication::showLicence();
1451 1454
1452} 1455}
1453void MainWindow::about() 1456void MainWindow::about()
1454{ 1457{
1455 QString version; 1458 QString version;
1456#include <../version> 1459#include <../version>
1457 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1460 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1458 i18n("KOrganizer/Platform-independent\n") + 1461 i18n("KOrganizer/Platform-independent\n") +
1459 "(KO/Pi) " + version + " - " + 1462 "(KO/Pi) " + version + " - " +
1460 1463
1461#ifdef DESKTOP_VERSION 1464#ifdef DESKTOP_VERSION
1462 i18n("Desktop Edition\n") + 1465 i18n("Desktop Edition\n") +
1463#else 1466#else
1464 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1467 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1465#endif 1468#endif
1466 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!") ); 1469 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!") );
1467} 1470}
1468void MainWindow::keyBindings() 1471void MainWindow::keyBindings()
1469{ 1472{
1470 QString cap = i18n("KO/Pi Keys + Colors"); 1473 QString cap = i18n("KO/Pi Keys + Colors");
1471 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1474 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1472 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1475 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1473 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1476 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1474 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1477 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1475 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1478 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1476 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1479 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1477 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1480 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1478 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1481 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1479 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1482 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1480 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1483 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1481 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1484 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1482 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1485 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1483 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1486 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1484 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1487 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1485 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1488 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1486 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1489 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1487 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1490 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1488 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1491 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1489 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1492 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1490 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1493 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1491 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1494 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1492 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1495 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1493 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1496 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1494 i18n("<p><h3>In agenda view:</h3></p>\n") + 1497 i18n("<p><h3>In agenda view:</h3></p>\n") +
1495 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1498 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1496 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1499 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1497 i18n("<p><h3>In todo view:</h3></p>\n") + 1500 i18n("<p><h3>In todo view:</h3></p>\n") +
1498 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1501 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1499 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1502 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1500 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1503 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1501 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1504 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1502 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1505 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1503 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1506 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1504 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1507 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1505 i18n("<p><h3>In list view:</h3></p>\n") + 1508 i18n("<p><h3>In list view:</h3></p>\n") +
1506 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1509 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1507 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1510 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1508 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1511 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1509 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1512 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1510 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1513 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1511 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1514 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1512 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1515 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1513 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1516 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1514 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1517 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1515 i18n("<p><b>E</b>: Edit item</p>\n") + 1518 i18n("<p><b>E</b>: Edit item</p>\n") +
1516 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1519 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1517 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1520 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1518 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1521 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1519 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1522 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1520 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1523 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1521 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1524 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1522 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1525 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1523 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1526 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1524 i18n("<p><b>White</b>: Item readonly</p>\n"); 1527 i18n("<p><b>White</b>: Item readonly</p>\n");
1525 displayText( text, cap); 1528 displayText( text, cap);
1526} 1529}
1527void MainWindow::aboutAutoSaving() 1530void MainWindow::aboutAutoSaving()
1528{ 1531{
1529 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"); 1532 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");
1530 1533
1531 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1534 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1532 1535
1533} 1536}
1534void MainWindow::aboutKnownBugs() 1537void MainWindow::aboutKnownBugs()
1535{ 1538{
1536 QMessageBox* msg; 1539 QMessageBox* msg;
1537 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1540 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1538 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")+ 1541 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")+
1539 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1542 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1540 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1543 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1541 i18n("\nor report them in the bugtracker on\n") + 1544 i18n("\nor report them in the bugtracker on\n") +
1542 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1543 QMessageBox::NoIcon, 1546 QMessageBox::NoIcon,
1544 QMessageBox::Ok, 1547 QMessageBox::Ok,
1545 QMessageBox::NoButton, 1548 QMessageBox::NoButton,
1546 QMessageBox::NoButton); 1549 QMessageBox::NoButton);
1547 msg->exec(); 1550 msg->exec();
1548 delete msg; 1551 delete msg;
1549 1552
1550} 1553}
1551 1554
1552QString MainWindow::defaultFileName() 1555QString MainWindow::defaultFileName()
1553{ 1556{
1554 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1557 return locateLocal( "data", "korganizer/mycalendar.ics" );
1555} 1558}
1556QString MainWindow::syncFileName() 1559QString MainWindow::syncFileName()
1557{ 1560{
1558#ifdef DESKTOP_VERSION 1561#ifdef DESKTOP_VERSION
1559 return locateLocal( "tmp", "synccalendar.ics" ); 1562 return locateLocal( "tmp", "synccalendar.ics" );
1560#else 1563#else
1561 return QString( "/tmp/synccalendar.ics" ); 1564 return QString( "/tmp/synccalendar.ics" );
1562#endif 1565#endif
1563} 1566}
1564#include "koglobals.h" 1567#include "koglobals.h"
1565#include <kcalendarsystem.h> 1568#include <kcalendarsystem.h>
1566void MainWindow::updateWeek(QDate seda) 1569void MainWindow::updateWeek(QDate seda)
1567{ 1570{
1568 int weekNum = KGlobal::locale()->weekNum ( seda ); 1571 int weekNum = KGlobal::locale()->weekNum ( seda );
1569 mWeekPixmap.fill( mWeekBgColor ); 1572 mWeekPixmap.fill( mWeekBgColor );
1570 QPainter p ( &mWeekPixmap ); 1573 QPainter p ( &mWeekPixmap );
1571 p.setFont( mWeekFont ); 1574 p.setFont( mWeekFont );
1572 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1573 p.end(); 1576 p.end();
1574 QIconSet icon3 ( mWeekPixmap ); 1577 QIconSet icon3 ( mWeekPixmap );
1575 mWeekAction->setIconSet ( icon3 ); 1578 mWeekAction->setIconSet ( icon3 );
1576 1579
1577} 1580}
1578void MainWindow::updateWeekNum(const DateList &selectedDates) 1581void MainWindow::updateWeekNum(const DateList &selectedDates)
1579{ 1582{
1580 updateWeek( selectedDates.first() ); 1583 updateWeek( selectedDates.first() );
1581} 1584}
1582void MainWindow::processIncidenceSelection( Incidence *incidence ) 1585void MainWindow::processIncidenceSelection( Incidence *incidence )
1583{ 1586{
1584 1587
1585 if ( !incidence ) { 1588 if ( !incidence ) {
1586 enableIncidenceActions( false ); 1589 enableIncidenceActions( false );
1587 1590
1588 mNewSubTodoAction->setEnabled( false ); 1591 mNewSubTodoAction->setEnabled( false );
1589 setCaptionToDates(); 1592 setCaptionToDates();
1590 return; 1593 return;
1591 1594
1592 } 1595 }
1593 1596
1594 //KGlobal::locale()->formatDateTime(nextA, true); 1597 //KGlobal::locale()->formatDateTime(nextA, true);
1595 QString startString = ""; 1598 QString startString = "";
1596 if ( incidence->type() != "Todo" ) { 1599 if ( incidence->type() != "Todo" ) {
1597 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1598 if ( incidence->doesFloat() ) { 1601 if ( incidence->doesFloat() ) {
1599 startString += ": "+incidence->dtStartDateStr( true ); 1602 startString += ": "+incidence->dtStartDateStr( true );
1600 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1601 1604
1602 } else { 1605 } else {
1603 startString = ": "+incidence->dtStartStr(true); 1606 startString = ": "+incidence->dtStartStr(true);
1604 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1607 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1605 1608
1606 } 1609 }
1607 1610
1608 } else { 1611 } else {
1609 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1610 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1611 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1612 1615
1613 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1614 bool ok; 1617 bool ok;
1615 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1616 if ( ok ) { 1619 if ( ok ) {
1617 int years = noc.date().year() - incidence->dtStart().date().year(); 1620 int years = noc.date().year() - incidence->dtStart().date().year();
1618 startString += i18n(" (%1 y.)"). arg( years ); 1621 startString += i18n(" (%1 y.)"). arg( years );
1619 } 1622 }
1620 } 1623 }
1621 else 1624 else
1622 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1623 } 1626 }
1624 1627
1625 } 1628 }
1626 else 1629 else
1627 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1628 if ( !incidence->location().isEmpty() ) 1631 if ( !incidence->location().isEmpty() )
1629 startString += " (" +incidence->location()+")"; 1632 startString += " (" +incidence->location()+")";
1630 setCaption( incidence->summary()+startString); 1633 setCaption( incidence->summary()+startString);
1631 1634
1632 enableIncidenceActions( true ); 1635 enableIncidenceActions( true );
1633 1636
1634 if ( incidence->type() == "Event" ) { 1637 if ( incidence->type() == "Event" ) {
1635 mShowAction->setText( i18n("Show Event...") ); 1638 mShowAction->setText( i18n("Show Event...") );
1636 mEditAction->setText( i18n("Edit Event...") ); 1639 mEditAction->setText( i18n("Edit Event...") );
1637 mDeleteAction->setText( i18n("Delete Event...") ); 1640 mDeleteAction->setText( i18n("Delete Event...") );
1638 1641
1639 mNewSubTodoAction->setEnabled( false ); 1642 mNewSubTodoAction->setEnabled( false );
1640 } else if ( incidence->type() == "Todo" ) { 1643 } else if ( incidence->type() == "Todo" ) {
1641 mShowAction->setText( i18n("Show Todo...") ); 1644 mShowAction->setText( i18n("Show Todo...") );
1642 mEditAction->setText( i18n("Edit Todo...") ); 1645 mEditAction->setText( i18n("Edit Todo...") );
1643 mDeleteAction->setText( i18n("Delete Todo...") ); 1646 mDeleteAction->setText( i18n("Delete Todo...") );
1644 1647
1645 mNewSubTodoAction->setEnabled( true ); 1648 mNewSubTodoAction->setEnabled( true );
1646 } else { 1649 } else {
1647 mShowAction->setText( i18n("Show...") ); 1650 mShowAction->setText( i18n("Show...") );
1648 mShowAction->setText( i18n("Edit...") ); 1651 mShowAction->setText( i18n("Edit...") );
1649 mShowAction->setText( i18n("Delete...") ); 1652 mShowAction->setText( i18n("Delete...") );
1650 1653
1651 mNewSubTodoAction->setEnabled( false ); 1654 mNewSubTodoAction->setEnabled( false );
1652 } 1655 }
1653} 1656}
1654 1657
1655void MainWindow::enableIncidenceActions( bool enabled ) 1658void MainWindow::enableIncidenceActions( bool enabled )
1656{ 1659{
1657 mShowAction->setEnabled( enabled ); 1660 mShowAction->setEnabled( enabled );
1658 mEditAction->setEnabled( enabled ); 1661 mEditAction->setEnabled( enabled );
1659 mDeleteAction->setEnabled( enabled ); 1662 mDeleteAction->setEnabled( enabled );
1660 1663
1661 mCloneAction->setEnabled( enabled ); 1664 mCloneAction->setEnabled( enabled );
1662 mMoveAction->setEnabled( enabled ); 1665 mMoveAction->setEnabled( enabled );
1663 mBeamAction->setEnabled( enabled ); 1666 mBeamAction->setEnabled( enabled );
1664 mCancelAction->setEnabled( enabled ); 1667 mCancelAction->setEnabled( enabled );
1665} 1668}
1666 1669
1667void MainWindow::importOL() 1670void MainWindow::importOL()
1668{ 1671{
1669#ifdef _OL_IMPORT_ 1672#ifdef _OL_IMPORT_
1670 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1673 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1671 id->exec(); 1674 id->exec();
1672 delete id; 1675 delete id;
1673 mView->updateView(); 1676 mView->updateView();
1674#endif 1677#endif
1675} 1678}
1676void MainWindow::importBday() 1679void MainWindow::importBday()
1677{ 1680{
1678 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1681 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1679 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1682 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1680 i18n("Import!"), i18n("Cancel"), 0, 1683 i18n("Import!"), i18n("Cancel"), 0,
1681 0, 1 ); 1684 0, 1 );
1682 if ( result == 0 ) { 1685 if ( result == 0 ) {
1683 mView->importBday(); 1686 mView->importBday();
1684 1687
1685 } 1688 }
1686 1689
1687 1690
1688} 1691}
1689void MainWindow::importQtopia() 1692void MainWindow::importQtopia()
1690{ 1693{
1691 //#ifndef DESKTOP_VERSION 1694 //#ifndef DESKTOP_VERSION
1692 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"); 1695 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");
1693#ifdef DESKTOP_VERSION 1696#ifdef DESKTOP_VERSION
1694 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"); 1697 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");
1695#endif 1698#endif
1696 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1699 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1697 i18n("Import!"), i18n("Cancel"), 0, 1700 i18n("Import!"), i18n("Cancel"), 0,
1698 0, 1 ); 1701 0, 1 );
1699 if ( result == 0 ) { 1702 if ( result == 0 ) {
1700#ifndef DESKTOP_VERSION 1703#ifndef DESKTOP_VERSION
1701 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1704 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1702 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1705 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1703 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1706 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1704#else 1707#else
1705 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1708 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1706 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1709 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1707 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1710 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1708#endif 1711#endif
1709 mView->importQtopia( categories, datebook, todolist ); 1712 mView->importQtopia( categories, datebook, todolist );
1710 } 1713 }
1711#if 0 1714#if 0
1712 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1715 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1713 i18n("Not supported \non desktop!\n"), 1716 i18n("Not supported \non desktop!\n"),
1714 i18n("Ok"), i18n("Cancel"), 0, 1717 i18n("Ok"), i18n("Cancel"), 0,
1715 0, 1 ); 1718 0, 1 );
1716 1719
1717#endif 1720#endif
1718} 1721}
1719 1722
1720void MainWindow::saveOnClose() 1723void MainWindow::saveOnClose()
1721{ 1724{
1722 KOPrefs *p = KOPrefs::instance(); 1725 KOPrefs *p = KOPrefs::instance();
1723 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1726 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1724 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1727 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1725 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1728 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1726 if ( filterToolBar ) { 1729 if ( filterToolBar ) {
1727 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1730 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1728 } 1731 }
1729#ifdef DESKTOP_VERSION 1732#ifdef DESKTOP_VERSION
1730 1733
1731 QPoint myP; 1734 QPoint myP;
1732 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1735 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1733 if ( p->mToolBarHor ) 1736 if ( p->mToolBarHor )
1734 p->mToolBarUp = myP.y() > height()/2; 1737 p->mToolBarUp = myP.y() > height()/2;
1735 else 1738 else
1736 p->mToolBarUp = myP.x() > width()/2; 1739 p->mToolBarUp = myP.x() > width()/2;
1737 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1740 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1738 if ( p->mToolBarHorV ) 1741 if ( p->mToolBarHorV )
1739 p->mToolBarUpV = myP.y() > height()/2; 1742 p->mToolBarUpV = myP.y() > height()/2;
1740 else 1743 else
1741 p->mToolBarUpV = myP.x() > width()/2 ; 1744 p->mToolBarUpV = myP.x() > width()/2 ;
1742 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1745 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1743 if ( p->mToolBarHorN ) 1746 if ( p->mToolBarHorN )
1744 p->mToolBarUpN = myP.y() > height()/2; 1747 p->mToolBarUpN = myP.y() > height()/2;
1745 else 1748 else
1746 p->mToolBarUpN = myP.x() > width()/2 ; 1749 p->mToolBarUpN = myP.x() > width()/2 ;
1747 if ( filterToolBar ) { 1750 if ( filterToolBar ) {
1748 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1751 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1749 if ( p->mToolBarHorF ) 1752 if ( p->mToolBarHorF )
1750 p->mToolBarUpF = myP.y() > height()/2; 1753 p->mToolBarUpF = myP.y() > height()/2;
1751 else 1754 else
1752 p->mToolBarUpF = myP.x() > width()/2 ; 1755 p->mToolBarUpF = myP.x() > width()/2 ;
1753 } 1756 }
1754#else 1757#else
1755 if ( p->mToolBarHor ) 1758 if ( p->mToolBarHor )
1756 p->mToolBarUp = iconToolBar->y() > height()/2; 1759 p->mToolBarUp = iconToolBar->y() > height()/2;
1757 else 1760 else
1758 p->mToolBarUp = iconToolBar->x() > width()/2; 1761 p->mToolBarUp = iconToolBar->x() > width()/2;
1759 if ( p->mToolBarHorV ) 1762 if ( p->mToolBarHorV )
1760 p->mToolBarUpV = viewToolBar->y() > height()/2; 1763 p->mToolBarUpV = viewToolBar->y() > height()/2;
1761 else 1764 else
1762 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1765 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1763 1766
1764 if ( p->mToolBarHorN ) 1767 if ( p->mToolBarHorN )
1765 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1768 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1766 else 1769 else
1767 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1770 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1768 if ( filterToolBar ) { 1771 if ( filterToolBar ) {
1769 if ( p->mToolBarHorF ) 1772 if ( p->mToolBarHorF )
1770 p->mToolBarUpF = filterToolBar->y() > height()/2; 1773 p->mToolBarUpF = filterToolBar->y() > height()/2;
1771 else 1774 else
1772 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1775 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1773 } 1776 }
1774#endif 1777#endif
1775 1778
1776 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1779 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1777 save(); 1780 save();
1778 mView->writeSettings(); 1781 mView->writeSettings();
1779} 1782}
1780void MainWindow::slotModifiedChanged( bool changed ) 1783void MainWindow::slotModifiedChanged( bool changed )
1781{ 1784{
1782 if ( mBlockAtStartup ) 1785 if ( mBlockAtStartup )
1783 return; 1786 return;
1784 1787
1785 int msec; 1788 int msec;
1786 // we store the changes after 1 minute, 1789 // we store the changes after 1 minute,
1787 // and for safety reasons after 10 minutes again 1790 // and for safety reasons after 10 minutes again
1788 if ( !mSyncManager->blockSave() ) 1791 if ( !mSyncManager->blockSave() )
1789 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1792 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1790 else 1793 else
1791 msec = 1000 * 600; 1794 msec = 1000 * 600;
1792 mSaveTimer.start( msec, true ); // 1 minute 1795 mSaveTimer.start( msec, true ); // 1 minute
1793 qDebug("KO: Saving File in %d secs!", msec/1000); 1796 qDebug("KO: Saving File in %d secs!", msec/1000);
1794 mCalendarModifiedFlag = true; 1797 mCalendarModifiedFlag = true;
1795} 1798}
1796void MainWindow::saveStopTimer() 1799void MainWindow::saveStopTimer()
1797{ 1800{
1798 mSaveTimer.stop(); 1801 mSaveTimer.stop();
1799} 1802}
1800void MainWindow::save() 1803void MainWindow::save()
1801{ 1804{
1802 if ( !mCalendarModifiedFlag ) { 1805 if ( !mCalendarModifiedFlag ) {
1803 qDebug("KO: Calendar not modified. Nothing saved."); 1806 qDebug("KO: Calendar not modified. Nothing saved.");
1804 return; 1807 return;
1805 } 1808 }
1806 if ( mSyncManager->blockSave() ) 1809 if ( mSyncManager->blockSave() )
1807 return; 1810 return;
1808 mSyncManager->setBlockSave(true); 1811 mSyncManager->setBlockSave(true);
1809 if ( mView->checkFileVersion( defaultFileName()) ) { 1812 if ( mView->checkFileVersion( defaultFileName()) ) {
1810 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1813 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1811 QDate reference ( 2000,1,1); 1814 QDate reference ( 2000,1,1);
1812 int daysTo = reference.daysTo ( QDate::currentDate() ); 1815 int daysTo = reference.daysTo ( QDate::currentDate() );
1813 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1816 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1814 setCaption(i18n("Creating backup ... please wait ..." )); 1817 setCaption(i18n("Creating backup ... please wait ..." ));
1815 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1818 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1816 // we need the file path, the backup dir and the number of bups as param 1819 // we need the file path, the backup dir and the number of bups as param
1817 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1820 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1818 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1821 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1819 bupDir = KGlobalSettings::backupDataDir(); 1822 bupDir = KGlobalSettings::backupDataDir();
1820 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1823 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1821 if ( retval == 0 ) { 1824 if ( retval == 0 ) {
1822 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1825 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1823 // retval == 0 : backup skipped for today, try again tomorrow 1826 // retval == 0 : backup skipped for today, try again tomorrow
1824 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1827 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1825 } else if ( retval == 1 ){ 1828 } else if ( retval == 1 ){
1826 qDebug("KO: Backup created."); 1829 qDebug("KO: Backup created.");
1827 // backup ok 1830 // backup ok
1828 KOPrefs::instance()->mLastBackupDate = daysTo; 1831 KOPrefs::instance()->mLastBackupDate = daysTo;
1829 1832
1830 } else if ( retval == 2 ){ 1833 } else if ( retval == 2 ){
1831 qDebug("KO: Backup globally cancelled."); 1834 qDebug("KO: Backup globally cancelled.");
1832 // backup globally cancelled 1835 // backup globally cancelled
1833 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1836 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1834 } 1837 }
1835 // retval == 3: do nothing, try again later 1838 // retval == 3: do nothing, try again later
1836 } 1839 }
1837 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1840 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1838 } 1841 }
1839 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1842 QTime neededSaveTime = QDateTime::currentDateTime().time();
1840 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1843 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1841 qDebug("KO: Start saving data to file!"); 1844 qDebug("KO: Start saving data to file!");
1842 mView->saveCalendar( defaultFileName() ); 1845 mView->saveCalendar( defaultFileName() );
1843 mCalendarModifiedFlag = false; 1846 mCalendarModifiedFlag = false;
1844 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1847 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1845 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1848 qDebug("KO: Needed %d ms for saving.",msNeeded );
1846 QString savemes; 1849 QString savemes;
1847 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1850 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1848 setCaption(savemes); 1851 setCaption(savemes);
1849 } else 1852 } else
1850 setCaption(i18n("Saving cancelled!")); 1853 setCaption(i18n("Saving cancelled!"));
1851 mSyncManager->setBlockSave( false ); 1854 mSyncManager->setBlockSave( false );
1852} 1855}
1853 1856
1854void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1857void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1855{ 1858{
1856 if ( !e->isAutoRepeat() ) { 1859 if ( !e->isAutoRepeat() ) {
1857 mFlagKeyPressed = false; 1860 mFlagKeyPressed = false;
1858 } 1861 }
1859} 1862}
1860void MainWindow::keyPressEvent ( QKeyEvent * e ) 1863void MainWindow::keyPressEvent ( QKeyEvent * e )
1861{ 1864{
1862 qApp->processEvents(); 1865 qApp->processEvents();
1863 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1866 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1864 e->ignore(); 1867 e->ignore();
1865 // qDebug(" ignore %d",e->isAutoRepeat() ); 1868 // qDebug(" ignore %d",e->isAutoRepeat() );
1866 return; 1869 return;
1867 } 1870 }
1868 if (! e->isAutoRepeat() ) 1871 if (! e->isAutoRepeat() )
1869 mFlagKeyPressed = true; 1872 mFlagKeyPressed = true;
1870 KOPrefs *p = KOPrefs::instance(); 1873 KOPrefs *p = KOPrefs::instance();
1871 bool showSelectedDates = false; 1874 bool showSelectedDates = false;
1872 int size; 1875 int size;
1873 int pro = 0; 1876 int pro = 0;
1874 //qDebug("MainWindow::keyPressEvent "); 1877 //qDebug("MainWindow::keyPressEvent ");
1875 switch ( e->key() ) { 1878 switch ( e->key() ) {
1876 case Qt::Key_Right: 1879 case Qt::Key_Right:
1877 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1880 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1878 mView->goNextMonth(); 1881 mView->goNextMonth();
1879 else 1882 else
1880 mView->goNext(); 1883 mView->goNext();
1881 showSelectedDates = true; 1884 showSelectedDates = true;
1882 break; 1885 break;
1883 case Qt::Key_Left: 1886 case Qt::Key_Left:
1884 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1887 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1885 mView->goPreviousMonth(); 1888 mView->goPreviousMonth();
1886 else 1889 else
1887 mView->goPrevious(); 1890 mView->goPrevious();
1888 showSelectedDates = true; 1891 showSelectedDates = true;
1889 break; 1892 break;
1890 case Qt::Key_Down: 1893 case Qt::Key_Down:
1891 mView->viewManager()->agendaView()->scrollOneHourDown(); 1894 mView->viewManager()->agendaView()->scrollOneHourDown();
1892 break; 1895 break;
1893 case Qt::Key_Up: 1896 case Qt::Key_Up:
1894 mView->viewManager()->agendaView()->scrollOneHourUp(); 1897 mView->viewManager()->agendaView()->scrollOneHourUp();
1895 break; 1898 break;
1896 case Qt::Key_K: 1899 case Qt::Key_K:
1897 mView->viewManager()->showMonthViewWeek(); 1900 mView->viewManager()->showMonthViewWeek();
1898 break; 1901 break;
1899 case Qt::Key_I: 1902 case Qt::Key_I:
1900 mView->showIncidence(); 1903 mView->showIncidence();
1901 break; 1904 break;
1902 case Qt::Key_Delete: 1905 case Qt::Key_Delete:
1903 case Qt::Key_Backspace: 1906 case Qt::Key_Backspace:
1904 mView->deleteIncidence(); 1907 mView->deleteIncidence();
1905 break; 1908 break;
1906 case Qt::Key_D: 1909 case Qt::Key_D:
1907 mView->viewManager()->showDayView(); 1910 mView->viewManager()->showDayView();
1908 showSelectedDates = true; 1911 showSelectedDates = true;
1909 break; 1912 break;
1910 case Qt::Key_O: 1913 case Qt::Key_O:
1911 mView->toggleFilerEnabled( ); 1914 mView->toggleFilerEnabled( );
1912 break; 1915 break;
1913 case Qt::Key_0: 1916 case Qt::Key_0:
1914 case Qt::Key_1: 1917 case Qt::Key_1:
1915 case Qt::Key_2: 1918 case Qt::Key_2:
1916 case Qt::Key_3: 1919 case Qt::Key_3:
1917 case Qt::Key_4: 1920 case Qt::Key_4:
1918 case Qt::Key_5: 1921 case Qt::Key_5:
1919 case Qt::Key_6: 1922 case Qt::Key_6:
1920 case Qt::Key_7: 1923 case Qt::Key_7:
1921 case Qt::Key_8: 1924 case Qt::Key_8:
1922 case Qt::Key_9: 1925 case Qt::Key_9:
1923 pro = e->key()-48; 1926 pro = e->key()-48;
1924 if ( pro == 0 ) 1927 if ( pro == 0 )
1925 pro = 10; 1928 pro = 10;
1926 if ( e->state() == Qt::ControlButton) 1929 if ( e->state() == Qt::ControlButton)
1927 pro += 10; 1930 pro += 10;
1928 break; 1931 break;
1929 case Qt::Key_M: 1932 case Qt::Key_M:
1930 mView->viewManager()->showMonthView(); 1933 mView->viewManager()->showMonthView();
1931 showSelectedDates = true; 1934 showSelectedDates = true;
1932 break; 1935 break;
1933 case Qt::Key_Insert: 1936 case Qt::Key_Insert:
1934 mView->newEvent(); 1937 mView->newEvent();
1935 break; 1938 break;
1936 case Qt::Key_S : 1939 case Qt::Key_S :
1937 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1940 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1938 mView->newSubTodo(); 1941 mView->newSubTodo();
1939 else 1942 else
1940 mView->dialogManager()->showSearchDialog(); 1943 mView->dialogManager()->showSearchDialog();
1941 break; 1944 break;
1942 case Qt::Key_Y : 1945 case Qt::Key_Y :
1943 case Qt::Key_Z : 1946 case Qt::Key_Z :
1944 mView->viewManager()->showWorkWeekView(); 1947 mView->viewManager()->showWorkWeekView();
1945 showSelectedDates = true; 1948 showSelectedDates = true;
1946 break; 1949 break;
1947 case Qt::Key_U : 1950 case Qt::Key_U :
1948 mView->viewManager()->showWeekView(); 1951 mView->viewManager()->showWeekView();
1949 showSelectedDates = true; 1952 showSelectedDates = true;
1950 break; 1953 break;
1951 case Qt::Key_H : 1954 case Qt::Key_H :
1952 keyBindings(); 1955 keyBindings();
1953 break; 1956 break;
1954 case Qt::Key_W: 1957 case Qt::Key_W:
1955 mView->viewManager()->showWhatsNextView(); 1958 mView->viewManager()->showWhatsNextView();
1956 break; 1959 break;
1957 case Qt::Key_L: 1960 case Qt::Key_L:
1958 mView->viewManager()->showListView(); 1961 mView->viewManager()->showListView();
1959 break; 1962 break;
1960 case Qt::Key_N: 1963 case Qt::Key_N:
1961 mView->viewManager()->showNextView(); 1964 mView->viewManager()->showNextView();
1962 break; 1965 break;
1963 case Qt::Key_V: 1966 case Qt::Key_V:
1964 mView->viewManager()->showTodoView(); 1967 mView->viewManager()->showTodoView();
1965 break; 1968 break;
1966 case Qt::Key_C: 1969 case Qt::Key_C:
1967 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1970 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1968 break; 1971 break;
1969 case Qt::Key_P: 1972 case Qt::Key_P:
1970 mView->showDatePicker( ); 1973 mView->showDatePicker( );
1971 break; 1974 break;
1972 case Qt::Key_F: 1975 case Qt::Key_F:
1973 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1976 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1974 mView->editFilters(); 1977 mView->editFilters();
1975 else 1978 else
1976 mView->toggleFilter(); 1979 mView->toggleFilter();
1977 break; 1980 break;
1978 case Qt::Key_X: 1981 case Qt::Key_X:
1979 if ( e->state() == Qt::ControlButton ) 1982 if ( e->state() == Qt::ControlButton )
1980 mView->toggleDateNavigatorWidget(); 1983 mView->toggleDateNavigatorWidget();
1981 else { 1984 else {
1982 mView->viewManager()->showNextXView(); 1985 mView->viewManager()->showNextXView();
1983 showSelectedDates = true; 1986 showSelectedDates = true;
1984 } 1987 }
1985 break; 1988 break;
1986 case Qt::Key_Space: 1989 case Qt::Key_Space:
1987 mView->toggleExpand(); 1990 mView->toggleExpand();
1988 break; 1991 break;
1989 case Qt::Key_A: 1992 case Qt::Key_A:
1990 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1993 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1991 mView->showNextAlarms(); 1994 mView->showNextAlarms();
1992 else 1995 else
1993 mView->toggleAllDaySize(); 1996 mView->toggleAllDaySize();
1994 break; 1997 break;
1995 case Qt::Key_T: 1998 case Qt::Key_T:
1996 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1999 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1997 mView->newTodo(); 2000 mView->newTodo();
1998 else { 2001 else {
1999 mView->goToday(); 2002 mView->goToday();
2000 showSelectedDates = true; 2003 showSelectedDates = true;
2001 } 2004 }
2002 break; 2005 break;
2003 case Qt::Key_J: 2006 case Qt::Key_J:
2004 mView->viewManager()->showJournalView(); 2007 mView->viewManager()->showJournalView();
2005 break; 2008 break;
2006 case Qt::Key_B: 2009 case Qt::Key_B:
2007 mView->editIncidenceDescription();; 2010 mView->editIncidenceDescription();;
2008 break; 2011 break;
2009 // case Qt::Key_Return: 2012 // case Qt::Key_Return:
2010 case Qt::Key_E: 2013 case Qt::Key_E:
2011 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2014 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2012 mView->newEvent(); 2015 mView->newEvent();
2013 else 2016 else
2014 mView->editIncidence(); 2017 mView->editIncidence();
2015 break; 2018 break;
2016 case Qt::Key_Plus: 2019 case Qt::Key_Plus:
2017 size = p->mHourSize +2; 2020 size = p->mHourSize +2;
2018 if ( size <= 22 ) 2021 if ( size <= 22 )
2019 configureAgenda( size ); 2022 configureAgenda( size );
2020 break; 2023 break;
2021 case Qt::Key_Minus: 2024 case Qt::Key_Minus:
2022 size = p->mHourSize - 2; 2025 size = p->mHourSize - 2;
2023 if ( size >= 4 ) 2026 if ( size >= 4 )
2024 configureAgenda( size ); 2027 configureAgenda( size );
2025 break; 2028 break;
2026 2029
2027 2030
2028 default: 2031 default:
2029 e->ignore(); 2032 e->ignore();
2030 } 2033 }
2031 if ( pro > 0 ) { 2034 if ( pro > 0 ) {
2032 mView->selectFilter( pro-1 ); 2035 mView->selectFilter( pro-1 );
2033 } 2036 }
2034 if ( showSelectedDates ) { 2037 if ( showSelectedDates ) {
2035 ;// setCaptionToDates(); 2038 ;// setCaptionToDates();
2036 } 2039 }
2037 2040
2038} 2041}
2039void MainWindow::fillFilterMenuTB() 2042void MainWindow::fillFilterMenuTB()
2040{ 2043{
2041 selectFilterMenuTB->clear(); 2044 selectFilterMenuTB->clear();
2042 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2045 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2043 selectFilterMenuTB->insertSeparator(); 2046 selectFilterMenuTB->insertSeparator();
2044 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2047 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2045 2048
2046 selectFilterMenuTB->insertSeparator(); 2049 selectFilterMenuTB->insertSeparator();
2047 QPtrList<CalFilter> fili = mView->filters(); 2050 QPtrList<CalFilter> fili = mView->filters();
2048 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2051 CalFilter *curfilter = mView->filterView()->selectedFilter();
2049 CalFilter *filter = fili.first(); 2052 CalFilter *filter = fili.first();
2050 int iii = 2; 2053 int iii = 2;
2051 bool checkitem = mView->filterView()->filtersEnabled(); 2054 bool checkitem = mView->filterView()->filtersEnabled();
2052 while(filter) { 2055 while(filter) {
2053 selectFilterMenuTB->insertItem( filter->name(), iii ); 2056 selectFilterMenuTB->insertItem( filter->name(), iii );
2054 if ( filter == curfilter) 2057 if ( filter == curfilter)
2055 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2058 selectFilterMenuTB->setItemChecked( iii, checkitem );
2056 filter = fili.next(); 2059 filter = fili.next();
2057 ++iii; 2060 ++iii;
2058 } 2061 }
2059 if ( !checkitem ) 2062 if ( !checkitem )
2060 selectFilterMenuTB->setItemChecked( 1, true ); 2063 selectFilterMenuTB->setItemChecked( 1, true );
2061 2064
2062 int x = 0; 2065 int x = 0;
2063 int y = iconToolBar->height(); 2066 int y = iconToolBar->height();
2064 int dX = 0; 2067 int dX = 0;
2065 int dY = 0; 2068 int dY = 0;
2066 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2069 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2067 if ( iconToolBar->y() > height()/2 ) { 2070 if ( iconToolBar->y() > height()/2 ) {
2068 dY = selectFilterMenuTB->sizeHint().height()+8; 2071 dY = selectFilterMenuTB->sizeHint().height()+8;
2069 y = 0; 2072 y = 0;
2070 } 2073 }
2071 } else { 2074 } else {
2072 if ( iconToolBar->x() > width()/2 ) { // right side 2075 if ( iconToolBar->x() > width()/2 ) { // right side
2073 x=0; 2076 x=0;
2074 dX= selectFilterMenuTB->sizeHint().width()+8; 2077 dX= selectFilterMenuTB->sizeHint().width()+8;
2075 y = 0; 2078 y = 0;
2076 } else { 2079 } else {
2077 x= iconToolBar->width(); 2080 x= iconToolBar->width();
2078 y = 0; 2081 y = 0;
2079 } 2082 }
2080 } 2083 }
2081 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2084 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2082 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2085 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2083} 2086}
2084void MainWindow::fillFilterMenu() 2087void MainWindow::fillFilterMenu()
2085{ 2088{
2086 selectFilterMenu->clear(); 2089 selectFilterMenu->clear();
2087 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2090 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2088 selectFilterMenu->insertSeparator(); 2091 selectFilterMenu->insertSeparator();
2089 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2092 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2090 2093
2091 selectFilterMenu->insertSeparator(); 2094 selectFilterMenu->insertSeparator();
2092 QPtrList<CalFilter> fili = mView->filters(); 2095 QPtrList<CalFilter> fili = mView->filters();
2093 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2096 CalFilter *curfilter = mView->filterView()->selectedFilter();
2094 CalFilter *filter = fili.first(); 2097 CalFilter *filter = fili.first();
2095 int iii = 2; 2098 int iii = 2;
2096 bool checkitem = mView->filterView()->filtersEnabled(); 2099 bool checkitem = mView->filterView()->filtersEnabled();
2097 while(filter) { 2100 while(filter) {
2098 selectFilterMenu->insertItem( filter->name(), iii ); 2101 selectFilterMenu->insertItem( filter->name(), iii );
2099 if ( filter == curfilter) 2102 if ( filter == curfilter)
2100 selectFilterMenu->setItemChecked( iii, checkitem ); 2103 selectFilterMenu->setItemChecked( iii, checkitem );
2101 filter = fili.next(); 2104 filter = fili.next();
2102 ++iii; 2105 ++iii;
2103 } 2106 }
2104 if ( !checkitem ) 2107 if ( !checkitem )
2105 selectFilterMenu->setItemChecked( 1, true ); 2108 selectFilterMenu->setItemChecked( 1, true );
2106} 2109}
2107void MainWindow::fillFilterMenuPopup() 2110void MainWindow::fillFilterMenuPopup()
2108{ 2111{
2109 filterPopupMenu->clear(); 2112 filterPopupMenu->clear();
2110 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2113 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2111 2114
2112 filterPopupMenu->insertSeparator(); 2115 filterPopupMenu->insertSeparator();
2113 QPtrList<CalFilter> fili = mView->filters(); 2116 QPtrList<CalFilter> fili = mView->filters();
2114 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2117 CalFilter *curfilter = mView->filterView()->selectedFilter();
2115 CalFilter *filter = fili.first(); 2118 CalFilter *filter = fili.first();
2116 int iii = 1; 2119 int iii = 1;
2117 bool checkitem = mView->filterView()->filtersEnabled(); 2120 bool checkitem = mView->filterView()->filtersEnabled();
2118 while(filter) { 2121 while(filter) {
2119 filterPopupMenu->insertItem( filter->name(), iii ); 2122 filterPopupMenu->insertItem( filter->name(), iii );
2120 if ( filter == curfilter) 2123 if ( filter == curfilter)
2121 filterPopupMenu->setItemChecked( iii, checkitem ); 2124 filterPopupMenu->setItemChecked( iii, checkitem );
2122 filter = fili.next(); 2125 filter = fili.next();
2123 ++iii; 2126 ++iii;
2124 } 2127 }
2125 if ( !checkitem ) 2128 if ( !checkitem )
2126 filterPopupMenu->setItemChecked( 0, true ); 2129 filterPopupMenu->setItemChecked( 0, true );
2127} 2130}
2128void MainWindow::selectFilter( int fil ) 2131void MainWindow::selectFilter( int fil )
2129{ 2132{
2130 2133
2131 if ( fil == 0 ) { 2134 if ( fil == 0 ) {
2132 mView->editFilters( ); 2135 mView->editFilters( );
2133 } else if ( fil == 1 ){ 2136 } else if ( fil == 1 ){
2134 if ( mView->filterView()->filtersEnabled() ) 2137 if ( mView->filterView()->filtersEnabled() )
2135 mView->toggleFilerEnabled( ); 2138 mView->toggleFilerEnabled( );
2136 } else { 2139 } else {
2137 if ( !mView->filterView()->filtersEnabled() ) { 2140 if ( !mView->filterView()->filtersEnabled() ) {
2138 mView->filterView()->blockSignals( true ); 2141 mView->filterView()->blockSignals( true );
2139 mView->toggleFilerEnabled( ); 2142 mView->toggleFilerEnabled( );
2140 mView->filterView()->blockSignals( false ); 2143 mView->filterView()->blockSignals( false );
2141 } 2144 }
2142 mView->selectFilter( fil-2 ); 2145 mView->selectFilter( fil-2 );
2143 } 2146 }
2144} 2147}
2145void MainWindow::updateFilterToolbar() 2148void MainWindow::updateFilterToolbar()
2146{ 2149{
2147 if ( filterMenubar ) { 2150 if ( filterMenubar ) {
2148 if ( !mView->filterView()->filtersEnabled() ) { 2151 if ( !mView->filterView()->filtersEnabled() ) {
2149 filterMenubar->changeItem( 0, i18n("No Filter") ); 2152 filterMenubar->changeItem( 0, i18n("No Filter") );
2150 } else { 2153 } else {
2151 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2154 CalFilter *curfilter = mView->filterView()->selectedFilter();
2152 if ( curfilter ) { 2155 if ( curfilter ) {
2153 filterMenubar->changeItem( 0, curfilter->name() ); 2156 filterMenubar->changeItem( 0, curfilter->name() );
2154 } 2157 }
2155 } 2158 }
2156 } 2159 }
2157} 2160}
2158void MainWindow::selectFilterPopup( int fil ) 2161void MainWindow::selectFilterPopup( int fil )
2159{ 2162{
2160 selectFilter( fil + 1 ); 2163 selectFilter( fil + 1 );
2161 2164
2162} 2165}
2163void MainWindow::configureToolBar( int item ) 2166void MainWindow::configureToolBar( int item )
2164{ 2167{
2165 2168
2166 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2169 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2167 KOPrefs *p = KOPrefs::instance(); 2170 KOPrefs *p = KOPrefs::instance();
2168 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2171 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2169 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2172 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2170 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2173 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2171 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2174 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2172 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2175 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2173 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2176 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2174 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2177 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2175 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2178 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2176 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2179 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2177 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2180 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2178 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2181 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2179 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2182 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2180 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2183 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2181 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2184 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2182 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2185 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2183 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2186 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2184 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2187 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2185 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2188 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2186 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2189 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2187 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2190 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2188 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2191 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2189 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2192 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2190 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2193 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2191 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2194 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2192 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2195 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2193 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2196 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2194 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2197 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2195 // initActions(); 2198 // initActions();
2196} 2199}
2197void MainWindow::setCaption ( const QString & c ) 2200void MainWindow::setCaption ( const QString & c )
2198{ 2201{
2199 QString cap = c; 2202 QString cap = c;
2200 cap.replace( QRegExp("\n"), " " ); 2203 cap.replace( QRegExp("\n"), " " );
2201 cap = cap.stripWhiteSpace(); 2204 cap = cap.stripWhiteSpace();
2202 if ( cap.isEmpty() ) 2205 if ( cap.isEmpty() )
2203 cap = "KO/Pi"; 2206 cap = "KO/Pi";
2204 QWidget::setCaption( cap ); 2207 QWidget::setCaption( cap );
2205} 2208}
2206void MainWindow::setCaptionToDates() 2209void MainWindow::setCaptionToDates()
2207{ 2210{
2208 QString selDates; 2211 QString selDates;
2209 QDate date = mView->startDate(); 2212 QDate date = mView->startDate();
2210 if ( ! date.isValid() ) { 2213 if ( ! date.isValid() ) {
2211 setCaption(""); 2214 setCaption("");
2212 return; 2215 return;
2213 } 2216 }
2214 selDates = KGlobal::locale()->formatDate( date, true); 2217 selDates = KGlobal::locale()->formatDate( date, true);
2215 if (mView->startDate() < mView->endDate() ) 2218 if (mView->startDate() < mView->endDate() )
2216 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2219 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2217 else { 2220 else {
2218 QString addString; 2221 QString addString;
2219 if ( date == QDateTime::currentDateTime().date() ) 2222 if ( date == QDateTime::currentDateTime().date() )
2220 addString = i18n("Today"); 2223 addString = i18n("Today");
2221 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2224 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2222 addString = i18n("Tomorrow"); 2225 addString = i18n("Tomorrow");
2223 if ( !addString.isEmpty() ) 2226 if ( !addString.isEmpty() )
2224 selDates = addString+", "+selDates ; 2227 selDates = addString+", "+selDates ;
2225 } 2228 }
2226 setCaption( i18n("Dates: ") + selDates ); 2229 setCaption( i18n("Dates: ") + selDates );
2227 2230
2228} 2231}
2229void MainWindow::showConfigureAgenda( ) 2232void MainWindow::showConfigureAgenda( )
2230{ 2233{
2231 int iii; 2234 int iii;
2232 for ( iii = 1;iii<= 10 ;++iii ){ 2235 for ( iii = 1;iii<= 10 ;++iii ){
2233 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2236 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2234 } 2237 }
2235 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2238 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2236} 2239}
2237void MainWindow::configureAgenda( int item ) 2240void MainWindow::configureAgenda( int item )
2238{ 2241{
2239 if ( KOPrefs::instance()->mHourSize == item ) 2242 if ( KOPrefs::instance()->mHourSize == item )
2240 return; 2243 return;
2241 KOPrefs::instance()->mHourSize=item; 2244 KOPrefs::instance()->mHourSize=item;
2242 mView->viewManager()->agendaView()->updateConfig(); 2245 mView->viewManager()->agendaView()->updateConfig();
2243} 2246}
2244 2247
2245void MainWindow::saveCalendar() 2248void MainWindow::saveCalendar()
2246{ 2249{
2247 QString fn = KOPrefs::instance()->mLastSaveFile; 2250 QString fn = KOPrefs::instance()->mLastSaveFile;
2248 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2251 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2249 2252
2250 if ( fn == "" ) 2253 if ( fn == "" )
2251 return; 2254 return;
2252 QFileInfo info; 2255 QFileInfo info;
2253 info.setFile( fn ); 2256 info.setFile( fn );
2254 QString mes; 2257 QString mes;
2255 bool createbup = true; 2258 bool createbup = true;
2256 if ( info. exists() ) { 2259 if ( info. exists() ) {
2257 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 2260 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2258 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2261 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2259 i18n("Overwrite!"), i18n("Cancel"), 0, 2262 i18n("Overwrite!"), i18n("Cancel"), 0,
2260 0, 1 ); 2263 0, 1 );
2261 if ( result != 0 ) { 2264 if ( result != 0 ) {
2262 createbup = false; 2265 createbup = false;
2263 } 2266 }
2264 } 2267 }
2265 if ( createbup ) { 2268 if ( createbup ) {
2266 mView->saveCalendar( fn ); 2269 mView->saveCalendar( fn );
2267 mes = i18n("KO/Pi:Saved %1").arg(fn); 2270 mes = i18n("KO/Pi:Saved %1").arg(fn);
2268 KOPrefs::instance()->mLastSaveFile = fn; 2271 KOPrefs::instance()->mLastSaveFile = fn;
2269 setCaption(mes); 2272 setCaption(mes);
2270 } 2273 }
2271} 2274}
2272void MainWindow::loadCalendar() 2275void MainWindow::loadCalendar()
2273{ 2276{
2274 2277
2275 QString fn = KOPrefs::instance()->mLastLoadFile; 2278 QString fn = KOPrefs::instance()->mLastLoadFile;
2276 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2279 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2277 2280
2278 if ( fn == "" ) 2281 if ( fn == "" )
2279 return; 2282 return;
2280 QFileInfo info; 2283 QFileInfo info;
2281 info.setFile( fn ); 2284 info.setFile( fn );
2282 QString mess; 2285 QString mess;
2283 bool loadbup = true; 2286 bool loadbup = true;
2284 if ( info. exists() ) { 2287 if ( info. exists() ) {
2285 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2288 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2286 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2289 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2287 mess, 2290 mess,
2288 i18n("Load!"), i18n("Cancel"), 0, 2291 i18n("Load!"), i18n("Cancel"), 0,
2289 0, 1 ); 2292 0, 1 );
2290 if ( result != 0 ) { 2293 if ( result != 0 ) {
2291 loadbup = false; 2294 loadbup = false;
2292 } 2295 }
2293 } else { 2296 } else {
2294 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2297 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2295 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2298 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2296 0, 1 ); 2299 0, 1 );
2297 2300
2298 return; 2301 return;
2299 } 2302 }
2300 if ( loadbup ) { 2303 if ( loadbup ) {
2301 mView->openCalendar( fn ); 2304 mView->openCalendar( fn );
2302 KOPrefs::instance()->mLastLoadFile = fn; 2305 KOPrefs::instance()->mLastLoadFile = fn;
2303 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2306 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2304 setCaption(mess); 2307 setCaption(mess);
2305 } 2308 }
2306 2309
2307} 2310}
2308void MainWindow::quickImportIcal() 2311void MainWindow::quickImportIcal()
2309{ 2312{
2310 importFile( KOPrefs::instance()->mLastImportFile, false ); 2313 importFile( KOPrefs::instance()->mLastImportFile, false );
2311} 2314}
2312void MainWindow::importFile( QString fn, bool quick ) 2315void MainWindow::importFile( QString fn, bool quick )
2313{ 2316{
2314 QFileInfo info; 2317 QFileInfo info;
2315 info.setFile( fn ); 2318 info.setFile( fn );
2316 QString mess; 2319 QString mess;
2317 bool loadbup = true; 2320 bool loadbup = true;
2318 if ( !info. exists() ) { 2321 if ( !info. exists() ) {
2319 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2322 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2320 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2321 mess ); 2324 mess );
2322 return; 2325 return;
2323 } 2326 }
2324 int result = 0; 2327 int result = 0;
2325 if ( !quick ) { 2328 if ( !quick ) {
2326 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 )); 2329 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 ));
2327 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2330 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2328 mess, 2331 mess,
2329 "Import", "Cancel", 0, 2332 "Import", "Cancel", 0,
2330 0, 1 ); 2333 0, 1 );
2331 } 2334 }
2332 if ( result == 0 ) { 2335 if ( result == 0 ) {
2333 if ( mView->openCalendar( fn, true )) { 2336 if ( mView->openCalendar( fn, true )) {
2334 KOPrefs::instance()->mLastImportFile = fn; 2337 KOPrefs::instance()->mLastImportFile = fn;
2335 setCaption(i18n("Imported file successfully")); 2338 setCaption(i18n("Imported file successfully"));
2336 } else { 2339 } else {
2337 setCaption(i18n("Error importing file")); 2340 setCaption(i18n("Error importing file"));
2338 } 2341 }
2339 } 2342 }
2340} 2343}
2341 2344
2342void MainWindow::importIcal() 2345void MainWindow::importIcal()
2343{ 2346{
2344 2347
2345 QString fn =KOPrefs::instance()->mLastImportFile; 2348 QString fn =KOPrefs::instance()->mLastImportFile;
2346 2349
2347 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2350 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2348 if ( fn == "" ) 2351 if ( fn == "" )
2349 return; 2352 return;
2350 importFile( fn, true ); 2353 importFile( fn, true );
2351 2354
2352} 2355}
2353 2356
2354void MainWindow::exportVCalendar() 2357void MainWindow::exportVCalendar()
2355{ 2358{
2356 QString fn = KOPrefs::instance()->mLastVcalFile; 2359 QString fn = KOPrefs::instance()->mLastVcalFile;
2357 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2360 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2358 if ( fn == "" ) 2361 if ( fn == "" )
2359 return; 2362 return;
2360 QFileInfo info; 2363 QFileInfo info;
2361 info.setFile( fn ); 2364 info.setFile( fn );
2362 QString mes; 2365 QString mes;
2363 bool createbup = true; 2366 bool createbup = true;
2364 if ( info. exists() ) { 2367 if ( info. exists() ) {
2365 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2368 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2366 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2369 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2367 i18n("Overwrite!"), i18n("Cancel"), 0, 2370 i18n("Overwrite!"), i18n("Cancel"), 0,
2368 0, 1 ); 2371 0, 1 );
2369 if ( result != 0 ) { 2372 if ( result != 0 ) {
2370 createbup = false; 2373 createbup = false;
2371 } 2374 }
2372 } 2375 }
2373 if ( createbup ) { 2376 if ( createbup ) {
2374 if ( mView->exportVCalendar( fn ) ) { 2377 if ( mView->exportVCalendar( fn ) ) {
2375 KOPrefs::instance()->mLastVcalFile = fn; 2378 KOPrefs::instance()->mLastVcalFile = fn;
2376 if ( fn.length() > 20 ) 2379 if ( fn.length() > 20 )
2377 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2380 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2378 else 2381 else
2379 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2382 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2380 setCaption(mes); 2383 setCaption(mes);
2381 } 2384 }
2382 } 2385 }
2383 2386
2384} 2387}
2385QString MainWindow::sentSyncFile() 2388QString MainWindow::sentSyncFile()
2386{ 2389{
2387#ifdef DESKTOP_VERSION 2390#ifdef DESKTOP_VERSION
2388 return locateLocal( "tmp", "copysynccal.ics" ); 2391 return locateLocal( "tmp", "copysynccal.ics" );
2389#else 2392#else
2390 return QString( "/tmp/copysynccal.ics" ); 2393 return QString( "/tmp/copysynccal.ics" );
2391#endif 2394#endif
2392} 2395}
2393 2396
2394void MainWindow::syncFileRequest() 2397void MainWindow::syncFileRequest()
2395{ 2398{
2396 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2399 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2397 mSyncManager->slotSyncMenu( 999 ); 2400 mSyncManager->slotSyncMenu( 999 );
2398 } 2401 }
2399 2402
2400 setCaption(i18n("Saving Data to temp file ..." )); 2403 setCaption(i18n("Saving Data to temp file ..." ));
2401 mView->saveCalendar( sentSyncFile() ); 2404 mView->saveCalendar( sentSyncFile() );
2402 setCaption(i18n("Data saved to temp file!" )); 2405 setCaption(i18n("Data saved to temp file!" ));
2403 2406
2404} 2407}
2405void MainWindow::getFile( bool success ) 2408void MainWindow::getFile( bool success )
2406{ 2409{
2407 if ( ! success ) { 2410 if ( ! success ) {
2408 setCaption( i18n("Error receiving file. Nothing changed!") ); 2411 setCaption( i18n("Error receiving file. Nothing changed!") );
2409 return; 2412 return;
2410 } 2413 }
2411 mView->openCalendar( sentSyncFile() ); 2414 mView->openCalendar( sentSyncFile() );
2412 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2415 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2413 mSyncManager->slotSyncMenu( 999 ); 2416 mSyncManager->slotSyncMenu( 999 );
2414 } 2417 }
2415 setCaption( i18n("Pi-Sync successful!") ); 2418 setCaption( i18n("Pi-Sync successful!") );
2416} 2419}
2417 2420
2418void MainWindow::printSel( ) 2421void MainWindow::printSel( )
2419{ 2422{
2420 mView->viewManager()->agendaView()->agenda()->printSelection(); 2423 mView->viewManager()->agendaView()->agenda()->printSelection();
2421} 2424}
2422 2425
2423void MainWindow::printCal() 2426void MainWindow::printCal()
2424{ 2427{
2425 mView->print();//mCp->showDialog(); 2428 mView->print();//mCp->showDialog();
2426} 2429}
2427 2430
2428 2431
2429#include "libkdepim/kdatepicker.h" 2432#include "libkdepim/kdatepicker.h"
2430#include <kdatetbl.h> 2433#include <kdatetbl.h>
2431 2434
2432void MainWindow::weekAction() 2435void MainWindow::weekAction()
2433{ 2436{
2434 int month; 2437 int month;
2435 KPopupFrame* popup = new KPopupFrame(this); 2438 KPopupFrame* popup = new KPopupFrame(this);
2436 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2439 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2437 // ----- 2440 // -----
2438 picker->resize(picker->sizeHint()); 2441 picker->resize(picker->sizeHint());
2439 popup->setMainWidget(picker); 2442 popup->setMainWidget(picker);
2440 picker->setFocus(); 2443 picker->setFocus();
2441 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2444 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2442 int x = 0; 2445 int x = 0;
2443 int y = iconToolBar->height(); 2446 int y = iconToolBar->height();
2444 int dX = 0; 2447 int dX = 0;
2445 int dY = 0; 2448 int dY = 0;
2446 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2449 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2447 if ( iconToolBar->y() > height()/2 ) { 2450 if ( iconToolBar->y() > height()/2 ) {
2448 dY = picker->sizeHint().height()+8; 2451 dY = picker->sizeHint().height()+8;
2449 y = 0; 2452 y = 0;
2450 } 2453 }
2451 } else { 2454 } else {
2452 if ( iconToolBar->x() > width()/2 ) { // right side 2455 if ( iconToolBar->x() > width()/2 ) { // right side
2453 x=0; 2456 x=0;
2454 dX= picker->sizeHint().width()+8; 2457 dX= picker->sizeHint().width()+8;
2455 y = 0; 2458 y = 0;
2456 } else { 2459 } else {
2457 x= iconToolBar->width(); 2460 x= iconToolBar->width();
2458 y = 0; 2461 y = 0;
2459 } 2462 }
2460 } 2463 }
2461 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2464 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2462 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2465 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2463 { 2466 {
2464 month = picker->getResult(); 2467 month = picker->getResult();
2465 emit selectWeek ( month ); 2468 emit selectWeek ( month );
2466 //qDebug("weekSelected %d ", month); 2469 //qDebug("weekSelected %d ", month);
2467 } 2470 }
2468 delete popup; 2471 delete popup;
2469} 2472}
2470 2473
2471void MainWindow::hideEvent ( QHideEvent * ) 2474void MainWindow::hideEvent ( QHideEvent * )
2472{ 2475{
2473 QString message; 2476 QString message;
2474 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2477 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2475 if ( nextA.isValid() ) { 2478 if ( nextA.isValid() ) {
2476 QString sum = mCalendar->nextSummary(); 2479 QString sum = mCalendar->nextSummary();
2477 2480
2478 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)); 2481 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));
2479 setCaption( message ); 2482 setCaption( message );
2480 } 2483 }
2481} 2484}
2482 2485
2483void MainWindow::resizeEvent( QResizeEvent* e) 2486void MainWindow::resizeEvent( QResizeEvent* e)
2484{ 2487{
2485#ifndef DESKTOP_VERSION 2488#ifndef DESKTOP_VERSION
2486 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2489 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2487 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2490 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2488 filterToolBar->hide(); 2491 filterToolBar->hide();
2489 else 2492 else
2490 filterToolBar->show(); 2493 filterToolBar->show();
2491 } 2494 }
2492#endif 2495#endif
2493 QMainWindow::resizeEvent( e); 2496 QMainWindow::resizeEvent( e);
2494} 2497}