summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp7
-rw-r--r--korganizer/calendarview.h3
-rw-r--r--korganizer/koagenda.cpp5
-rw-r--r--korganizer/mainwindow.cpp12
-rw-r--r--korganizer/mainwindow.h5
-rw-r--r--microkde/kdeui/kbuttonbox.cpp2
-rw-r--r--microkde/kdeui/kpopupmenu.cpp19
-rw-r--r--microkde/kdeui/kpopupmenu.h22
-rw-r--r--microkde/microkde.pro2
-rw-r--r--microkde/microkdeE.pro2
10 files changed, 64 insertions, 15 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 5a2482e..17f1659 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4821 +1,4828 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 //setFocusPolicy ( NoFocus ); 370 //setFocusPolicy ( NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 373
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 423
424 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
426 426
427 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
428#else 428#else
429 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 439 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 446 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
456#endif 456#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
460#if 0 460#if 0
461 // FIXME 461 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 464#endif
465 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 480
481 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
482#if 0 482#if 0
483 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
484 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
485 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
486 486
487 } else { 487 } else {
488 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
489 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
490 } 490 }
491#endif 491#endif
492 mFilterView->hide(); 492 mFilterView->hide();
493 mCalEditView->hide(); 493 mCalEditView->hide();
494 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
495 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
497 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
498 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
499 499
500 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
501 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
506 } else { 506 } else {
507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
510 } 510 }
511 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
512 mDateNavigator->hide(); 512 mDateNavigator->hide();
513 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
514#endif 514#endif
515 515
516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
517 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
518 518
519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
521 521
522 522
523 523
524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
525 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
528 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
529 529
530 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
531 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
532 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
533 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
534 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
535 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
536 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
537 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
538 538
539 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
540 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
541 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
542 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
544 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
545 545
546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
548#if 0 548#if 0
549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
550 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
551#endif 551#endif
552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
553 553
554 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
555 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
556 556
557 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
558 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
560 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
562 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
564 SLOT( showTodo( Todo *) ) ); 564 SLOT( showTodo( Todo *) ) );
565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
566 SLOT( deleteTodo( Todo *) ) ); 566 SLOT( deleteTodo( Todo *) ) );
567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
569 SLOT( purgeCompleted() ) ); 569 SLOT( purgeCompleted() ) );
570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
571 SIGNAL( todoModified( Todo *, int ) ) ); 571 SIGNAL( todoModified( Todo *, int ) ) );
572 572
573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
574 this, SLOT ( cloneIncidence( Incidence * ) ) ); 574 this, SLOT ( cloneIncidence( Incidence * ) ) );
575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
576 this, SLOT (cancelIncidence( Incidence * ) ) ); 576 this, SLOT (cancelIncidence( Incidence * ) ) );
577 577
578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
579 this, SLOT ( moveIncidence( Incidence * ) ) ); 579 this, SLOT ( moveIncidence( Incidence * ) ) );
580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
581 this, SLOT ( beamIncidence( Incidence * ) ) ); 581 this, SLOT ( beamIncidence( Incidence * ) ) );
582 582
583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
584 this, SLOT ( todo_unsub( Todo * ) ) ); 584 this, SLOT ( todo_unsub( Todo * ) ) );
585 585
586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
587 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 587 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
589 SLOT( updateTodo( Todo *, int ) ) ); 589 SLOT( updateTodo( Todo *, int ) ) );
590 connect( this, SIGNAL( todoModified( Todo *, int )), this, 590 connect( this, SIGNAL( todoModified( Todo *, int )), this,
591 SLOT( changeTodoDisplay( Todo *, int ) ) ); 591 SLOT( changeTodoDisplay( Todo *, int ) ) );
592 592
593 593
594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
598 598
599 599
600 600
601 601
602 602
603 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
604 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
606 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
608 608
609 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
610 610
611 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
614 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
615 mDateFrame->hide(); 615 mDateFrame->hide();
616 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
618 618
619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
620 620
621 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
622 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
623 623
624 mFlagEditDescription = false; 624 mFlagEditDescription = false;
625 625
626 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
627 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
628 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
632 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
634 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
636 636
637 637
638#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
639//US listen for arriving address resultsets 639//US listen for arriving address resultsets
640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
642#endif 642#endif
643 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
644} 644}
645 645
646 646
647CalendarView::~CalendarView() 647CalendarView::~CalendarView()
648{ 648{
649 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658
659void CalendarView::slotResetFocus()
660{
661 qDebug(" CalendarView::slotResetFocus() %x", qApp->focusWidget());
662
663}
664
658void CalendarView::nextConflict( bool all, bool allday ) 665void CalendarView::nextConflict( bool all, bool allday )
659{ 666{
660 667
661 QPtrList<Event> testlist = mCalendar->events(); 668 QPtrList<Event> testlist = mCalendar->events();
662 Event * test = testlist.first(); 669 Event * test = testlist.first();
663 while ( test ) { 670 while ( test ) {
664 test->setTagged( false ); 671 test->setTagged( false );
665 test = testlist.next(); 672 test = testlist.next();
666 } 673 }
667 QTime st ( 0,0,0); 674 QTime st ( 0,0,0);
668 if ( mViewManager->currentView() == mViewManager->agendaView() ) 675 if ( mViewManager->currentView() == mViewManager->agendaView() )
669 st = mViewManager->agendaView()->agenda()->getEndTime(); 676 st = mViewManager->agendaView()->agenda()->getEndTime();
670 //qDebug("time %s ", st.toString().latin1()); 677 //qDebug("time %s ", st.toString().latin1());
671 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 678 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
672 QDateTime conflict; 679 QDateTime conflict;
673 QDateTime retVal; 680 QDateTime retVal;
674 bool found = false; 681 bool found = false;
675 Event * cE = 0; 682 Event * cE = 0;
676 Event * cE2 = 0; 683 Event * cE2 = 0;
677 QPtrList<Event> testlist2 = testlist; 684 QPtrList<Event> testlist2 = testlist;
678 test = testlist.first(); 685 test = testlist.first();
679 bool skip = false; 686 bool skip = false;
680 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 687 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
681 while ( test ) { 688 while ( test ) {
682 qApp->processEvents(); 689 qApp->processEvents();
683 skip = false; 690 skip = false;
684 if ( !all ) skip = ( allday != test->doesFloat() ); 691 if ( !all ) skip = ( allday != test->doesFloat() );
685 if ( !skip ) { 692 if ( !skip ) {
686 Event * test2 = testlist2.first(); 693 Event * test2 = testlist2.first();
687 while ( test2 ) { 694 while ( test2 ) {
688 skip = false; 695 skip = false;
689 if ( !all ) skip = ( allday != test2->doesFloat() ); 696 if ( !all ) skip = ( allday != test2->doesFloat() );
690 if ( !skip ) { 697 if ( !skip ) {
691 if ( !test2->isTagged() ) { 698 if ( !test2->isTagged() ) {
692 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 699 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
693 //qDebug("overlap "); 700 //qDebug("overlap ");
694 if ( ! found ) { 701 if ( ! found ) {
695 if ( retVal >= startDT ) { 702 if ( retVal >= startDT ) {
696 conflict = retVal; 703 conflict = retVal;
697 cE = test; 704 cE = test;
698 cE2 = test2; 705 cE2 = test2;
699 found = true; 706 found = true;
700 } 707 }
701 } else { 708 } else {
702 if ( retVal >= startDT && retVal < conflict ) { 709 if ( retVal >= startDT && retVal < conflict ) {
703 conflict = retVal; 710 conflict = retVal;
704 cE = test; 711 cE = test;
705 cE2 = test2; 712 cE2 = test2;
706 } 713 }
707 } 714 }
708 } 715 }
709 } 716 }
710 } 717 }
711 test2 = testlist2.next(); 718 test2 = testlist2.next();
712 } 719 }
713 } 720 }
714 test->setTagged( true ); 721 test->setTagged( true );
715 test = testlist.next(); 722 test = testlist.next();
716 } 723 }
717 if ( found ) { 724 if ( found ) {
718 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 725 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
719 mViewManager->showDayView(); 726 mViewManager->showDayView();
720 mNavigator->slotDaySelect( conflict.date() ); 727 mNavigator->slotDaySelect( conflict.date() );
721 int hour = conflict.time().hour(); 728 int hour = conflict.time().hour();
722 mViewManager->agendaView()->setStartHour( hour ); 729 mViewManager->agendaView()->setStartHour( hour );
723 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 730 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
724 return; 731 return;
725 } 732 }
726 733
727 topLevelWidget()->setCaption( i18n("No conflict found") ); 734 topLevelWidget()->setCaption( i18n("No conflict found") );
728 qDebug("No conflict found "); 735 qDebug("No conflict found ");
729 return; 736 return;
730} 737}
731 738
732void CalendarView::conflictAll() 739void CalendarView::conflictAll()
733{ 740{
734 nextConflict ( true, true ); 741 nextConflict ( true, true );
735} 742}
736void CalendarView::conflictAllday() 743void CalendarView::conflictAllday()
737{ 744{
738 nextConflict ( false, true ); 745 nextConflict ( false, true );
739} 746}
740void CalendarView::conflictNotAll() 747void CalendarView::conflictNotAll()
741{ 748{
742 nextConflict ( false, false ); 749 nextConflict ( false, false );
743} 750}
744 751
745void CalendarView::setCalReadOnly( int id, bool readO ) 752void CalendarView::setCalReadOnly( int id, bool readO )
746{ 753{
747 if ( readO ) { 754 if ( readO ) {
748 emit save(); 755 emit save();
749 } 756 }
750 mCalendar->setReadOnly( id, readO ); 757 mCalendar->setReadOnly( id, readO );
751} 758}
752void CalendarView::setScrollBarStep(int val ) 759void CalendarView::setScrollBarStep(int val )
753{ 760{
754#ifdef DESKTOP_VERSION 761#ifdef DESKTOP_VERSION
755 mDateScrollBar->setLineStep ( val ); 762 mDateScrollBar->setLineStep ( val );
756#endif 763#endif
757} 764}
758void CalendarView::scrollBarValue(int val ) 765void CalendarView::scrollBarValue(int val )
759{ 766{
760#ifdef DESKTOP_VERSION 767#ifdef DESKTOP_VERSION
761 if ( QApplication::desktop()->width() < 800 ) return; 768 if ( QApplication::desktop()->width() < 800 ) return;
762 static bool block = false; 769 static bool block = false;
763 if ( block ) return; 770 if ( block ) return;
764 block = true; 771 block = true;
765 int count = mNavigator->selectedDates().count(); 772 int count = mNavigator->selectedDates().count();
766 int day = mNavigator->selectedDates().first().dayOfYear(); 773 int day = mNavigator->selectedDates().first().dayOfYear();
767 int stepdays = val; 774 int stepdays = val;
768 if ( mDateScrollBar->lineStep () <= count ) { 775 if ( mDateScrollBar->lineStep () <= count ) {
769 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 776 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
770 //qDebug("VAL %d ",val ); 777 //qDebug("VAL %d ",val );
771 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 778 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
772 stepdays = day+stepdays; 779 stepdays = day+stepdays;
773 if ( stepdays < 0 ) stepdays = 0; 780 if ( stepdays < 0 ) stepdays = 0;
774 } 781 }
775 if ( stepdays == day ) { 782 if ( stepdays == day ) {
776 block = false; 783 block = false;
777 return; 784 return;
778 } 785 }
779 int year = mNavigator->selectedDates().first().year(); 786 int year = mNavigator->selectedDates().first().year();
780 QDate d ( year,1,1 ); 787 QDate d ( year,1,1 );
781 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 788 mNavigator->selectDates( d.addDays( stepdays-1) , count );
782 block = false; 789 block = false;
783#endif 790#endif
784 791
785} 792}
786void CalendarView::updateView(const QDate &start, const QDate &end) 793void CalendarView::updateView(const QDate &start, const QDate &end)
787{ 794{
788#ifdef DESKTOP_VERSION 795#ifdef DESKTOP_VERSION
789 if ( ! mDateScrollBar->draggingSlider () ) { 796 if ( ! mDateScrollBar->draggingSlider () ) {
790 int dof = start.dayOfYear(); 797 int dof = start.dayOfYear();
791 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 798 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
792 if ( dof != mDateScrollBar->value() ) { 799 if ( dof != mDateScrollBar->value() ) {
793 mDateScrollBar->blockSignals( true ); 800 mDateScrollBar->blockSignals( true );
794 mDateScrollBar->setValue( start.dayOfYear()); 801 mDateScrollBar->setValue( start.dayOfYear());
795 mDateScrollBar->blockSignals( false ); 802 mDateScrollBar->blockSignals( false );
796 } 803 }
797 } 804 }
798#endif 805#endif
799 mTodoList->updateView(); 806 mTodoList->updateView();
800 mViewManager->updateView(start, end); 807 mViewManager->updateView(start, end);
801 //mDateNavigator->updateView(); 808 //mDateNavigator->updateView();
802} 809}
803 810
804 811
805 812
806void CalendarView::checkFiles() 813void CalendarView::checkFiles()
807{ 814{
808 QString message; 815 QString message;
809 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 816 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
810 KopiCalendarFile * cal = calendars.first(); 817 KopiCalendarFile * cal = calendars.first();
811 while ( cal ) { 818 while ( cal ) {
812 if ( cal->mErrorOnLoad ) { 819 if ( cal->mErrorOnLoad ) {
813 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 820 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
814 } 821 }
815 cal = calendars.next(); 822 cal = calendars.next();
816 } 823 }
817 if ( !message.isEmpty() ) { 824 if ( !message.isEmpty() ) {
818 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 825 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
819 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 826 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
820 } 827 }
821 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 828 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
822} 829}
823void CalendarView::checkAlarms() 830void CalendarView::checkAlarms()
824{ 831{
825 832
826 833
827 KConfig *config = KOGlobals::config(); 834 KConfig *config = KOGlobals::config();
828 config->setGroup( "AppRun" ); 835 config->setGroup( "AppRun" );
829 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 836 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
830 int daysto = dt.daysTo( QDate::currentDate() ); 837 int daysto = dt.daysTo( QDate::currentDate() );
831 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 838 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
832 dt = dt.addDays( days ); 839 dt = dt.addDays( days );
833 int secto = dt.secsTo( QDateTime::currentDateTime() ); 840 int secto = dt.secsTo( QDateTime::currentDateTime() );
834 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 841 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
835 //qDebug("KO: Reading program stop %d ", secs); 842 //qDebug("KO: Reading program stop %d ", secs);
836 //secs -= ( 3600 * 24*3 ); // debug only 843 //secs -= ( 3600 * 24*3 ); // debug only
837 QDateTime latest = dt.addSecs ( secs ); 844 QDateTime latest = dt.addSecs ( secs );
838 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 845 qDebug("KO: Last termination on %s ", latest.toString().latin1());
839 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 846 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
840 QPtrList<Incidence> el = mCalendar->rawIncidences(); 847 QPtrList<Incidence> el = mCalendar->rawIncidences();
841 QPtrList<Incidence> al; 848 QPtrList<Incidence> al;
842 Incidence* inL = el.first(); 849 Incidence* inL = el.first();
843 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 850 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
844 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 851 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
845 while ( inL ) { 852 while ( inL ) {
846 bool ok = false; 853 bool ok = false;
847 int offset = 0; 854 int offset = 0;
848 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 855 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
849 if ( ok ) { 856 if ( ok ) {
850 //qDebug("OK %s",next.toString().latin1()); 857 //qDebug("OK %s",next.toString().latin1());
851 if ( next < cur ) { 858 if ( next < cur ) {
852 al.append( inL ); 859 al.append( inL );
853 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 860 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
854 } 861 }
855 } 862 }
856 inL = el.next(); 863 inL = el.next();
857 } 864 }
858 if ( al.count() ) { 865 if ( al.count() ) {
859 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 866 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
860 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 867 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
861 QVBoxLayout* lay = new QVBoxLayout( dia ); 868 QVBoxLayout* lay = new QVBoxLayout( dia );
862 lay->setSpacing( 0 ); 869 lay->setSpacing( 0 );
863 lay->setMargin( 0 ); 870 lay->setMargin( 0 );
864 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 871 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
865 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 872 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
866 lay->addWidget( matb ); 873 lay->addWidget( matb );
867 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 874 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
868 int wid = 210; 875 int wid = 210;
869 int x = QApplication::desktop()->width() - wid - 7; 876 int x = QApplication::desktop()->width() - wid - 7;
870 int y = QApplication::desktop()->height() - wid - 70; 877 int y = QApplication::desktop()->height() - wid - 70;
871 dia->setGeometry ( x,y,wid,wid); 878 dia->setGeometry ( x,y,wid,wid);
872 } else { 879 } else {
873 int si = 220; 880 int si = 220;
874 if ( QApplication::desktop()->width() > 470 ) 881 if ( QApplication::desktop()->width() > 470 )
875 si = 400; 882 si = 400;
876 dia->resize(si,si/2); 883 dia->resize(si,si/2);
877 } 884 }
878 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 885 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
879 dia->show(); 886 dia->show();
880 887
881 } 888 }
882} 889}
883void CalendarView::showDay( QDate d ) 890void CalendarView::showDay( QDate d )
884{ 891{
885 dateNavigator()->blockSignals( true ); 892 dateNavigator()->blockSignals( true );
886 dateNavigator()->selectDate( d ); 893 dateNavigator()->selectDate( d );
887 dateNavigator()->blockSignals( false ); 894 dateNavigator()->blockSignals( false );
888 mViewManager->showDayView(); 895 mViewManager->showDayView();
889 //dateNavigator()->selectDate( d ); 896 //dateNavigator()->selectDate( d );
890} 897}
891void CalendarView::timerAlarm() 898void CalendarView::timerAlarm()
892{ 899{
893 //qDebug("CalendarView::timerAlarm() "); 900 //qDebug("CalendarView::timerAlarm() ");
894 computeAlarm(mAlarmNotification ); 901 computeAlarm(mAlarmNotification );
895} 902}
896 903
897void CalendarView::suspendAlarm() 904void CalendarView::suspendAlarm()
898{ 905{
899 //qDebug(" CalendarView::suspendAlarm() "); 906 //qDebug(" CalendarView::suspendAlarm() ");
900 computeAlarm(mSuspendAlarmNotification ); 907 computeAlarm(mSuspendAlarmNotification );
901 908
902} 909}
903 910
904void CalendarView::startAlarm( QString mess , QString filename) 911void CalendarView::startAlarm( QString mess , QString filename)
905{ 912{
906 913
907 topLevelWidget()->showNormal(); 914 topLevelWidget()->showNormal();
908 topLevelWidget()->setActiveWindow(); 915 topLevelWidget()->setActiveWindow();
909 topLevelWidget()->raise(); 916 topLevelWidget()->raise();
910 917
911 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 918 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
912 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 919 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
913 920
914} 921}
915 922
916void CalendarView::checkNextTimerAlarm() 923void CalendarView::checkNextTimerAlarm()
917{ 924{
918 mCalendar->checkAlarmForIncidence( 0, true ); 925 mCalendar->checkAlarmForIncidence( 0, true );
919} 926}
920 927
921void CalendarView::computeAlarm( QString msg ) 928void CalendarView::computeAlarm( QString msg )
922{ 929{
923 930
924 QString mess = msg; 931 QString mess = msg;
925 QString mAlarmMessage = mess.mid( 9 ); 932 QString mAlarmMessage = mess.mid( 9 );
926 QString filename = MainWindow::resourcePath(); 933 QString filename = MainWindow::resourcePath();
927 filename += "koalarm.wav"; 934 filename += "koalarm.wav";
928 QString tempfilename; 935 QString tempfilename;
929 if ( mess.left( 13 ) == "suspend_alarm") { 936 if ( mess.left( 13 ) == "suspend_alarm") {
930 bool error = false; 937 bool error = false;
931 int len = mess.mid( 13 ).find("+++"); 938 int len = mess.mid( 13 ).find("+++");
932 if ( len < 2 ) 939 if ( len < 2 )
933 error = true; 940 error = true;
934 else { 941 else {
935 tempfilename = mess.mid( 13, len ); 942 tempfilename = mess.mid( 13, len );
936 if ( !QFile::exists( tempfilename ) ) 943 if ( !QFile::exists( tempfilename ) )
937 error = true; 944 error = true;
938 } 945 }
939 if ( ! error ) { 946 if ( ! error ) {
940 filename = tempfilename; 947 filename = tempfilename;
941 } 948 }
942 mAlarmMessage = mess.mid( 13+len+3 ); 949 mAlarmMessage = mess.mid( 13+len+3 );
943 //qDebug("suspend file %s ",tempfilename.latin1() ); 950 //qDebug("suspend file %s ",tempfilename.latin1() );
944 startAlarm( mAlarmMessage, filename); 951 startAlarm( mAlarmMessage, filename);
945 return; 952 return;
946 } 953 }
947 if ( mess.left( 11 ) == "timer_alarm") { 954 if ( mess.left( 11 ) == "timer_alarm") {
948 //mTimerTime = 0; 955 //mTimerTime = 0;
949 startAlarm( mess.mid( 11 ), filename ); 956 startAlarm( mess.mid( 11 ), filename );
950 return; 957 return;
951 } 958 }
952 if ( mess.left( 10 ) == "proc_alarm") { 959 if ( mess.left( 10 ) == "proc_alarm") {
953 bool error = false; 960 bool error = false;
954 int len = mess.mid( 10 ).find("+++"); 961 int len = mess.mid( 10 ).find("+++");
955 if ( len < 2 ) 962 if ( len < 2 )
956 error = true; 963 error = true;
957 else { 964 else {
958 tempfilename = mess.mid( 10, len ); 965 tempfilename = mess.mid( 10, len );
959 if ( !QFile::exists( tempfilename ) ) 966 if ( !QFile::exists( tempfilename ) )
960 error = true; 967 error = true;
961 } 968 }
962 if ( error ) { 969 if ( error ) {
963 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 970 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
964 mAlarmMessage += mess.mid( 10+len+3+9 ); 971 mAlarmMessage += mess.mid( 10+len+3+9 );
965 } else { 972 } else {
966 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 973 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
967 //qDebug("-----system command %s ",tempfilename.latin1() ); 974 //qDebug("-----system command %s ",tempfilename.latin1() );
968#ifndef _WIN32_ 975#ifndef _WIN32_
969 if ( vfork () == 0 ) { 976 if ( vfork () == 0 ) {
970 execl ( tempfilename.latin1(), 0 ); 977 execl ( tempfilename.latin1(), 0 );
971 return; 978 return;
972 } 979 }
973#else 980#else
974 QProcess* p = new QProcess(); 981 QProcess* p = new QProcess();
975 p->addArgument( tempfilename.latin1() ); 982 p->addArgument( tempfilename.latin1() );
976 p->start(); 983 p->start();
977 return; 984 return;
978#endif 985#endif
979 986
980 return; 987 return;
981 } 988 }
982 989
983 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 990 //qDebug("+++++++system command %s ",tempfilename.latin1() );
984 } 991 }
985 if ( mess.left( 11 ) == "audio_alarm") { 992 if ( mess.left( 11 ) == "audio_alarm") {
986 bool error = false; 993 bool error = false;
987 int len = mess.mid( 11 ).find("+++"); 994 int len = mess.mid( 11 ).find("+++");
988 if ( len < 2 ) 995 if ( len < 2 )
989 error = true; 996 error = true;
990 else { 997 else {
991 tempfilename = mess.mid( 11, len ); 998 tempfilename = mess.mid( 11, len );
992 if ( !QFile::exists( tempfilename ) ) 999 if ( !QFile::exists( tempfilename ) )
993 error = true; 1000 error = true;
994 } 1001 }
995 if ( ! error ) { 1002 if ( ! error ) {
996 filename = tempfilename; 1003 filename = tempfilename;
997 } 1004 }
998 mAlarmMessage = mess.mid( 11+len+3+9 ); 1005 mAlarmMessage = mess.mid( 11+len+3+9 );
999 //qDebug("audio file command %s ",tempfilename.latin1() ); 1006 //qDebug("audio file command %s ",tempfilename.latin1() );
1000 } 1007 }
1001 if ( mess.left( 9 ) == "cal_alarm") { 1008 if ( mess.left( 9 ) == "cal_alarm") {
1002 mAlarmMessage = mess.mid( 9 ) ; 1009 mAlarmMessage = mess.mid( 9 ) ;
1003 } 1010 }
1004 1011
1005 startAlarm( mAlarmMessage, filename ); 1012 startAlarm( mAlarmMessage, filename );
1006 1013
1007 1014
1008} 1015}
1009 1016
1010void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1017void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1011{ 1018{
1012 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1019 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1013 1020
1014 mSuspendAlarmNotification = noti; 1021 mSuspendAlarmNotification = noti;
1015 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1022 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1016 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1023 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1017 mSuspendTimer->start( ms , true ); 1024 mSuspendTimer->start( ms , true );
1018 1025
1019} 1026}
1020 1027
1021void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1028void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1022{ 1029{
1023 mNextAlarmDateTime = qdt; 1030 mNextAlarmDateTime = qdt;
1024 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1031 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1025 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1032 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1026#ifndef DESKTOP_VERSION 1033#ifndef DESKTOP_VERSION
1027 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1034 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1028#endif 1035#endif
1029 return; 1036 return;
1030 } 1037 }
1031 int maxSec; 1038 int maxSec;
1032 //maxSec = 5; //testing only 1039 //maxSec = 5; //testing only
1033 maxSec = 86400+3600; // one day+1hour 1040 maxSec = 86400+3600; // one day+1hour
1034 mAlarmNotification = noti; 1041 mAlarmNotification = noti;
1035 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1042 int sec = QDateTime::currentDateTime().secsTo( qdt );
1036 if ( sec > maxSec ) { 1043 if ( sec > maxSec ) {
1037 mRecheckAlarmTimer->start( maxSec * 1000 ); 1044 mRecheckAlarmTimer->start( maxSec * 1000 );
1038 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1045 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1039 return; 1046 return;
1040 } else { 1047 } else {
1041 mRecheckAlarmTimer->stop(); 1048 mRecheckAlarmTimer->stop();
1042 } 1049 }
1043 //qDebug("Alarm timer started with secs: %d ", sec); 1050 //qDebug("Alarm timer started with secs: %d ", sec);
1044 mAlarmTimer->start( sec *1000 , true ); 1051 mAlarmTimer->start( sec *1000 , true );
1045 1052
1046} 1053}
1047// called by mRecheckAlarmTimer to get next alarm 1054// called by mRecheckAlarmTimer to get next alarm
1048// we need this, because a QTimer has only a max range of 25 days 1055// we need this, because a QTimer has only a max range of 25 days
1049void CalendarView::recheckTimerAlarm() 1056void CalendarView::recheckTimerAlarm()
1050{ 1057{
1051 mAlarmTimer->stop(); 1058 mAlarmTimer->stop();
1052 mRecheckAlarmTimer->stop(); 1059 mRecheckAlarmTimer->stop();
1053 mCalendar->checkAlarmForIncidence( 0, true ); 1060 mCalendar->checkAlarmForIncidence( 0, true );
1054} 1061}
1055#ifndef DESKTOP_VERSION 1062#ifndef DESKTOP_VERSION
1056void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1063void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1057#else 1064#else
1058void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1065void CalendarView::removeAlarm(const QDateTime &, const QString & )
1059#endif 1066#endif
1060{ 1067{
1061 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1068 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1062 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1069 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1063#ifndef DESKTOP_VERSION 1070#ifndef DESKTOP_VERSION
1064 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1071 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1065#endif 1072#endif
1066 return; 1073 return;
1067 } 1074 }
1068 mAlarmTimer->stop(); 1075 mAlarmTimer->stop();
1069} 1076}
1070void CalendarView::selectWeekNum ( int num ) 1077void CalendarView::selectWeekNum ( int num )
1071{ 1078{
1072 dateNavigator()->blockSignals( true ); 1079 dateNavigator()->blockSignals( true );
1073 dateNavigator()->selectWeek( num ); 1080 dateNavigator()->selectWeek( num );
1074 dateNavigator()->blockSignals( false ); 1081 dateNavigator()->blockSignals( false );
1075 mViewManager->showWeekView(); 1082 mViewManager->showWeekView();
1076} 1083}
1077KOViewManager *CalendarView::viewManager() 1084KOViewManager *CalendarView::viewManager()
1078{ 1085{
1079 return mViewManager; 1086 return mViewManager;
1080} 1087}
1081 1088
1082KODialogManager *CalendarView::dialogManager() 1089KODialogManager *CalendarView::dialogManager()
1083{ 1090{
1084 return mDialogManager; 1091 return mDialogManager;
1085} 1092}
1086 1093
1087QDate CalendarView::startDate() 1094QDate CalendarView::startDate()
1088{ 1095{
1089 DateList dates = mNavigator->selectedDates(); 1096 DateList dates = mNavigator->selectedDates();
1090 1097
1091 return dates.first(); 1098 return dates.first();
1092} 1099}
1093 1100
1094QDate CalendarView::endDate() 1101QDate CalendarView::endDate()
1095{ 1102{
1096 DateList dates = mNavigator->selectedDates(); 1103 DateList dates = mNavigator->selectedDates();
1097 1104
1098 return dates.last(); 1105 return dates.last();
1099} 1106}
1100 1107
1101 1108
1102void CalendarView::createPrinter() 1109void CalendarView::createPrinter()
1103{ 1110{
1104#ifndef KORG_NOPRINTER 1111#ifndef KORG_NOPRINTER
1105 if (!mCalPrinter) { 1112 if (!mCalPrinter) {
1106 mCalPrinter = new CalPrinter(this, mCalendar); 1113 mCalPrinter = new CalPrinter(this, mCalendar);
1107 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1114 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1108 } 1115 }
1109#endif 1116#endif
1110} 1117}
1111 1118
1112 1119
1113//KOPrefs::instance()->mWriteBackFile 1120//KOPrefs::instance()->mWriteBackFile
1114//KOPrefs::instance()->mWriteBackExistingOnly 1121//KOPrefs::instance()->mWriteBackExistingOnly
1115 1122
1116// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1123// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1117// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1124// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1118// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1125// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1119// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1126// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1120// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1127// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1121// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1128// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1122 1129
1123int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1130int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1124{ 1131{
1125 1132
1126 // 0 equal 1133 // 0 equal
1127 // 1 take local 1134 // 1 take local
1128 // 2 take remote 1135 // 2 take remote
1129 // 3 cancel 1136 // 3 cancel
1130 QDateTime lastSync = mLastCalendarSync; 1137 QDateTime lastSync = mLastCalendarSync;
1131 QDateTime localMod = local->lastModified(); 1138 QDateTime localMod = local->lastModified();
1132 QDateTime remoteMod = remote->lastModified(); 1139 QDateTime remoteMod = remote->lastModified();
1133 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1140 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1134 bool remCh, locCh; 1141 bool remCh, locCh;
1135 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1142 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1136 //if ( remCh ) 1143 //if ( remCh )
1137 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1144 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1138 locCh = ( localMod > mLastCalendarSync ); 1145 locCh = ( localMod > mLastCalendarSync );
1139 if ( !remCh && ! locCh ) { 1146 if ( !remCh && ! locCh ) {
1140 //qDebug("both not changed "); 1147 //qDebug("both not changed ");
1141 lastSync = localMod.addDays(1); 1148 lastSync = localMod.addDays(1);
1142 if ( mode <= SYNC_PREF_ASK ) 1149 if ( mode <= SYNC_PREF_ASK )
1143 return 0; 1150 return 0;
1144 } else { 1151 } else {
1145 if ( locCh ) { 1152 if ( locCh ) {
1146 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1153 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1147 lastSync = localMod.addDays( -1 ); 1154 lastSync = localMod.addDays( -1 );
1148 if ( !remCh ) 1155 if ( !remCh )
1149 remoteMod = ( lastSync.addDays( -1 ) ); 1156 remoteMod = ( lastSync.addDays( -1 ) );
1150 } else { 1157 } else {
1151 //qDebug(" not loc changed "); 1158 //qDebug(" not loc changed ");
1152 lastSync = localMod.addDays( 1 ); 1159 lastSync = localMod.addDays( 1 );
1153 if ( remCh ) 1160 if ( remCh )
1154 remoteMod =( lastSync.addDays( 1 ) ); 1161 remoteMod =( lastSync.addDays( 1 ) );
1155 1162
1156 } 1163 }
1157 } 1164 }
1158 full = true; 1165 full = true;
1159 if ( mode < SYNC_PREF_ASK ) 1166 if ( mode < SYNC_PREF_ASK )
1160 mode = SYNC_PREF_ASK; 1167 mode = SYNC_PREF_ASK;
1161 } else { 1168 } else {
1162 if ( localMod == remoteMod ) 1169 if ( localMod == remoteMod )
1163 // if ( local->revision() == remote->revision() ) 1170 // if ( local->revision() == remote->revision() )
1164 return 0; 1171 return 0;
1165 1172
1166 } 1173 }
1167 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1174 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1168 1175
1169 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1176 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1170 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1177 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1171 //full = true; //debug only 1178 //full = true; //debug only
1172 if ( full ) { 1179 if ( full ) {
1173 bool equ = false; 1180 bool equ = false;
1174 if ( local->typeID() == eventID ) { 1181 if ( local->typeID() == eventID ) {
1175 equ = (*((Event*) local) == *((Event*) remote)); 1182 equ = (*((Event*) local) == *((Event*) remote));
1176 } 1183 }
1177 else if ( local->typeID() == todoID ) 1184 else if ( local->typeID() == todoID )
1178 equ = (*((Todo*) local) == (*(Todo*) remote)); 1185 equ = (*((Todo*) local) == (*(Todo*) remote));
1179 else if ( local->typeID() == journalID ) 1186 else if ( local->typeID() == journalID )
1180 equ = (*((Journal*) local) == *((Journal*) remote)); 1187 equ = (*((Journal*) local) == *((Journal*) remote));
1181 if ( equ ) { 1188 if ( equ ) {
1182 //qDebug("equal "); 1189 //qDebug("equal ");
1183 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1190 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1184 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1191 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1185 } 1192 }
1186 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1193 if ( mode < SYNC_PREF_FORCE_LOCAL )
1187 return 0; 1194 return 0;
1188 1195
1189 }//else //debug only 1196 }//else //debug only
1190 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1197 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1191 } 1198 }
1192 int result; 1199 int result;
1193 bool localIsNew; 1200 bool localIsNew;
1194 //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() ); 1201 //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() );
1195 1202
1196 1203
1197 // ************************************************ 1204 // ************************************************
1198 // ************************************************ 1205 // ************************************************
1199 // ************************************************ 1206 // ************************************************
1200 // We may have that lastSync > remoteMod AND lastSync > localMod 1207 // We may have that lastSync > remoteMod AND lastSync > localMod
1201 // BUT remoteMod != localMod 1208 // BUT remoteMod != localMod
1202 1209
1203 1210
1204 if ( full && mode < SYNC_PREF_NEWEST ) 1211 if ( full && mode < SYNC_PREF_NEWEST )
1205 mode = SYNC_PREF_ASK; 1212 mode = SYNC_PREF_ASK;
1206 1213
1207 switch( mode ) { 1214 switch( mode ) {
1208 case SYNC_PREF_LOCAL: 1215 case SYNC_PREF_LOCAL:
1209 if ( lastSync > remoteMod ) 1216 if ( lastSync > remoteMod )
1210 return 1; 1217 return 1;
1211 if ( lastSync > localMod ) 1218 if ( lastSync > localMod )
1212 return 2; 1219 return 2;
1213 return 1; 1220 return 1;
1214 break; 1221 break;
1215 case SYNC_PREF_REMOTE: 1222 case SYNC_PREF_REMOTE:
1216 if ( lastSync > localMod ) 1223 if ( lastSync > localMod )
1217 return 2; 1224 return 2;
1218 if ( lastSync > remoteMod ) 1225 if ( lastSync > remoteMod )
1219 return 1; 1226 return 1;
1220 return 2; 1227 return 2;
1221 break; 1228 break;
1222 case SYNC_PREF_NEWEST: 1229 case SYNC_PREF_NEWEST:
1223 if ( localMod >= remoteMod ) 1230 if ( localMod >= remoteMod )
1224 return 1; 1231 return 1;
1225 else 1232 else
1226 return 2; 1233 return 2;
1227 break; 1234 break;
1228 case SYNC_PREF_ASK: 1235 case SYNC_PREF_ASK:
1229 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1236 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1230 if ( lastSync > remoteMod && lastSync > localMod) 1237 if ( lastSync > remoteMod && lastSync > localMod)
1231 return 0; 1238 return 0;
1232 if ( lastSync > remoteMod ) 1239 if ( lastSync > remoteMod )
1233 return 1; 1240 return 1;
1234 if ( lastSync > localMod ) 1241 if ( lastSync > localMod )
1235 return 2; 1242 return 2;
1236 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1243 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1237 localIsNew = localMod >= remoteMod; 1244 localIsNew = localMod >= remoteMod;
1238 if ( localIsNew ) 1245 if ( localIsNew )
1239 getEventViewerDialog()->setColorMode( 1 ); 1246 getEventViewerDialog()->setColorMode( 1 );
1240 else 1247 else
1241 getEventViewerDialog()->setColorMode( 2 ); 1248 getEventViewerDialog()->setColorMode( 2 );
1242 getEventViewerDialog()->setIncidence(local); 1249 getEventViewerDialog()->setIncidence(local);
1243 if ( localIsNew ) 1250 if ( localIsNew )
1244 getEventViewerDialog()->setColorMode( 2 ); 1251 getEventViewerDialog()->setColorMode( 2 );
1245 else 1252 else
1246 getEventViewerDialog()->setColorMode( 1 ); 1253 getEventViewerDialog()->setColorMode( 1 );
1247 getEventViewerDialog()->addIncidence(remote); 1254 getEventViewerDialog()->addIncidence(remote);
1248 getEventViewerDialog()->setColorMode( 0 ); 1255 getEventViewerDialog()->setColorMode( 0 );
1249 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1256 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1250 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1257 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1251 getEventViewerDialog()->showMe(); 1258 getEventViewerDialog()->showMe();
1252 result = getEventViewerDialog()->executeS( localIsNew ); 1259 result = getEventViewerDialog()->executeS( localIsNew );
1253 return result; 1260 return result;
1254 1261
1255 break; 1262 break;
1256 case SYNC_PREF_FORCE_LOCAL: 1263 case SYNC_PREF_FORCE_LOCAL:
1257 return 1; 1264 return 1;
1258 break; 1265 break;
1259 case SYNC_PREF_FORCE_REMOTE: 1266 case SYNC_PREF_FORCE_REMOTE:
1260 return 2; 1267 return 2;
1261 break; 1268 break;
1262 1269
1263 default: 1270 default:
1264 // SYNC_PREF_TAKE_BOTH not implemented 1271 // SYNC_PREF_TAKE_BOTH not implemented
1265 break; 1272 break;
1266 } 1273 }
1267 return 0; 1274 return 0;
1268} 1275}
1269Event* CalendarView::getLastSyncEvent() 1276Event* CalendarView::getLastSyncEvent()
1270{ 1277{
1271 Event* lse; 1278 Event* lse;
1272 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1279 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1273 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1280 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1274 if (!lse) { 1281 if (!lse) {
1275 lse = new Event(); 1282 lse = new Event();
1276 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1283 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1277 QString sum = ""; 1284 QString sum = "";
1278 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1285 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1279 sum = "E: "; 1286 sum = "E: ";
1280 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1287 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1281 lse->setDtStart( mLastCalendarSync ); 1288 lse->setDtStart( mLastCalendarSync );
1282 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1289 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1283 lse->setCategories( i18n("SyncEvent") ); 1290 lse->setCategories( i18n("SyncEvent") );
1284 lse->setReadOnly( true ); 1291 lse->setReadOnly( true );
1285 mCalendar->addEvent( lse ); 1292 mCalendar->addEvent( lse );
1286 } 1293 }
1287 1294
1288 return lse; 1295 return lse;
1289 1296
1290} 1297}
1291 1298
1292// we check, if the to delete event has a id for a profile 1299// we check, if the to delete event has a id for a profile
1293// if yes, we set this id in the profile to delete 1300// if yes, we set this id in the profile to delete
1294void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1301void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1295{ 1302{
1296 if ( lastSync.count() == 0 ) { 1303 if ( lastSync.count() == 0 ) {
1297 //qDebug(" lastSync.count() == 0"); 1304 //qDebug(" lastSync.count() == 0");
1298 return; 1305 return;
1299 } 1306 }
1300 if ( toDelete->typeID() == journalID ) 1307 if ( toDelete->typeID() == journalID )
1301 return; 1308 return;
1302 1309
1303 Event* eve = lastSync.first(); 1310 Event* eve = lastSync.first();
1304 1311
1305 while ( eve ) { 1312 while ( eve ) {
1306 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1313 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1307 if ( !id.isEmpty() ) { 1314 if ( !id.isEmpty() ) {
1308 QString des = eve->description(); 1315 QString des = eve->description();
1309 QString pref = "e"; 1316 QString pref = "e";
1310 if ( toDelete->typeID() == todoID ) 1317 if ( toDelete->typeID() == todoID )
1311 pref = "t"; 1318 pref = "t";
1312 des += pref+ id + ","; 1319 des += pref+ id + ",";
1313 eve->setReadOnly( false ); 1320 eve->setReadOnly( false );
1314 eve->setDescription( des ); 1321 eve->setDescription( des );
1315 //qDebug("setdes %s ", des.latin1()); 1322 //qDebug("setdes %s ", des.latin1());
1316 eve->setReadOnly( true ); 1323 eve->setReadOnly( true );
1317 } 1324 }
1318 eve = lastSync.next(); 1325 eve = lastSync.next();
1319 } 1326 }
1320 1327
1321} 1328}
1322void CalendarView::checkExternalId( Incidence * inc ) 1329void CalendarView::checkExternalId( Incidence * inc )
1323{ 1330{
1324 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1331 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1325 checkExternSyncEvent( lastSync, inc ); 1332 checkExternSyncEvent( lastSync, inc );
1326 1333
1327} 1334}
1328bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1335bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1329{ 1336{
1330 bool syncOK = true; 1337 bool syncOK = true;
1331 int addedEvent = 0; 1338 int addedEvent = 0;
1332 int addedEventR = 0; 1339 int addedEventR = 0;
1333 int deletedEventR = 0; 1340 int deletedEventR = 0;
1334 int deletedEventL = 0; 1341 int deletedEventL = 0;
1335 int changedLocal = 0; 1342 int changedLocal = 0;
1336 int changedRemote = 0; 1343 int changedRemote = 0;
1337 int filteredIN = 0; 1344 int filteredIN = 0;
1338 int filteredOUT = 0; 1345 int filteredOUT = 0;
1339 //QPtrList<Event> el = local->rawEvents(); 1346 //QPtrList<Event> el = local->rawEvents();
1340 Event* eventR; 1347 Event* eventR;
1341 QString uid; 1348 QString uid;
1342 int take; 1349 int take;
1343 Event* eventRSync; 1350 Event* eventRSync;
1344 Event* eventLSync; 1351 Event* eventLSync;
1345 clearAllViews(); 1352 clearAllViews();
1346 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1353 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1347 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1354 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1348 bool fullDateRange = false; 1355 bool fullDateRange = false;
1349 local->resetTempSyncStat(); 1356 local->resetTempSyncStat();
1350 mLastCalendarSync = QDateTime::currentDateTime(); 1357 mLastCalendarSync = QDateTime::currentDateTime();
1351 if ( mSyncManager->syncWithDesktop() ) { 1358 if ( mSyncManager->syncWithDesktop() ) {
1352 remote->resetPilotStat(1); 1359 remote->resetPilotStat(1);
1353 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1360 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1354 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1361 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1355 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1362 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1356 } else { 1363 } else {
1357 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1364 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1358 } 1365 }
1359 } 1366 }
1360 QDateTime modifiedCalendar = mLastCalendarSync; 1367 QDateTime modifiedCalendar = mLastCalendarSync;
1361 eventLSync = getLastSyncEvent(); 1368 eventLSync = getLastSyncEvent();
1362 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1369 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1363 if ( eventR ) { 1370 if ( eventR ) {
1364 qDebug("last-syncEvent on remote found "); 1371 qDebug("last-syncEvent on remote found ");
1365 eventRSync = (Event*) eventR->clone(); 1372 eventRSync = (Event*) eventR->clone();
1366 remote->deleteEvent(eventR ); 1373 remote->deleteEvent(eventR );
1367 1374
1368 } else { 1375 } else {
1369 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1376 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1370 eventRSync = (Event*)eventLSync->clone(); 1377 eventRSync = (Event*)eventLSync->clone();
1371 } else { 1378 } else {
1372 fullDateRange = true; 1379 fullDateRange = true;
1373 eventRSync = new Event(); 1380 eventRSync = new Event();
1374 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1381 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1375 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1382 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1376 eventRSync->setDtStart( mLastCalendarSync ); 1383 eventRSync->setDtStart( mLastCalendarSync );
1377 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1384 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1378 eventRSync->setCategories( i18n("SyncEvent") ); 1385 eventRSync->setCategories( i18n("SyncEvent") );
1379 } 1386 }
1380 } 1387 }
1381 if ( eventLSync->dtStart() == mLastCalendarSync ) 1388 if ( eventLSync->dtStart() == mLastCalendarSync )
1382 fullDateRange = true; 1389 fullDateRange = true;
1383 1390
1384 if ( ! fullDateRange ) { 1391 if ( ! fullDateRange ) {
1385 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1392 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1386 1393
1387 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1394 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1388 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1395 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1389 fullDateRange = true; 1396 fullDateRange = true;
1390 } 1397 }
1391 } 1398 }
1392 if ( mSyncManager->syncWithDesktop() ) { 1399 if ( mSyncManager->syncWithDesktop() ) {
1393 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1400 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1394 } 1401 }
1395 if ( fullDateRange ) 1402 if ( fullDateRange )
1396 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1403 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1397 else 1404 else
1398 mLastCalendarSync = eventLSync->dtStart(); 1405 mLastCalendarSync = eventLSync->dtStart();
1399 // for resyncing if own file has changed 1406 // for resyncing if own file has changed
1400 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1407 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1401 mLastCalendarSync = loadedFileVersion; 1408 mLastCalendarSync = loadedFileVersion;
1402 //qDebug("setting mLastCalendarSync "); 1409 //qDebug("setting mLastCalendarSync ");
1403 } 1410 }
1404 //qDebug("*************************** "); 1411 //qDebug("*************************** ");
1405 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1412 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1406 QPtrList<Incidence> er = remote->rawIncidences(); 1413 QPtrList<Incidence> er = remote->rawIncidences();
1407 Incidence* inR = er.first(); 1414 Incidence* inR = er.first();
1408 Incidence* inL; 1415 Incidence* inL;
1409 QProgressBar bar( er.count(),0 ); 1416 QProgressBar bar( er.count(),0 );
1410 bar.setCaption (i18n("Syncing - close to abort!") ); 1417 bar.setCaption (i18n("Syncing - close to abort!") );
1411 1418
1412 // ************** setting up filter ************* 1419 // ************** setting up filter *************
1413 CalFilter *filterIN = 0; 1420 CalFilter *filterIN = 0;
1414 CalFilter *filterOUT = 0; 1421 CalFilter *filterOUT = 0;
1415 CalFilter *filter = mFilters.first(); 1422 CalFilter *filter = mFilters.first();
1416 while(filter) { 1423 while(filter) {
1417 if ( filter->name() == mSyncManager->mFilterInCal ) 1424 if ( filter->name() == mSyncManager->mFilterInCal )
1418 filterIN = filter; 1425 filterIN = filter;
1419 if ( filter->name() == mSyncManager->mFilterOutCal ) 1426 if ( filter->name() == mSyncManager->mFilterOutCal )
1420 filterOUT = filter; 1427 filterOUT = filter;
1421 filter = mFilters.next(); 1428 filter = mFilters.next();
1422 } 1429 }
1423 int w = 300; 1430 int w = 300;
1424 if ( QApplication::desktop()->width() < 320 ) 1431 if ( QApplication::desktop()->width() < 320 )
1425 w = 220; 1432 w = 220;
1426 int h = bar.sizeHint().height() ; 1433 int h = bar.sizeHint().height() ;
1427 int dw = QApplication::desktop()->width(); 1434 int dw = QApplication::desktop()->width();
1428 int dh = QApplication::desktop()->height(); 1435 int dh = QApplication::desktop()->height();
1429 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1436 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1430 bar.show(); 1437 bar.show();
1431 int modulo = (er.count()/10)+1; 1438 int modulo = (er.count()/10)+1;
1432 int incCounter = 0; 1439 int incCounter = 0;
1433 while ( inR ) { 1440 while ( inR ) {
1434 if ( ! bar.isVisible() ) 1441 if ( ! bar.isVisible() )
1435 return false; 1442 return false;
1436 if ( incCounter % modulo == 0 ) 1443 if ( incCounter % modulo == 0 )
1437 bar.setProgress( incCounter ); 1444 bar.setProgress( incCounter );
1438 ++incCounter; 1445 ++incCounter;
1439 uid = inR->uid(); 1446 uid = inR->uid();
1440 bool skipIncidence = false; 1447 bool skipIncidence = false;
1441 if ( uid.left(15) == QString("last-syncEvent-") ) 1448 if ( uid.left(15) == QString("last-syncEvent-") )
1442 skipIncidence = true; 1449 skipIncidence = true;
1443 QString idS; 1450 QString idS;
1444 qApp->processEvents(); 1451 qApp->processEvents();
1445 if ( !skipIncidence ) { 1452 if ( !skipIncidence ) {
1446 inL = local->incidenceForUid( uid , false ); 1453 inL = local->incidenceForUid( uid , false );
1447 if ( inL ) { // maybe conflict - same uid in both calendars 1454 if ( inL ) { // maybe conflict - same uid in both calendars
1448 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1455 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1449 //qDebug("take %d %s ", take, inL->summary().latin1()); 1456 //qDebug("take %d %s ", take, inL->summary().latin1());
1450 if ( take == 3 ) 1457 if ( take == 3 )
1451 return false; 1458 return false;
1452 if ( take == 1 ) {// take local ********************** 1459 if ( take == 1 ) {// take local **********************
1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1460 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1454 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1461 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1455 else 1462 else
1456 idS = inR->IDStr(); 1463 idS = inR->IDStr();
1457 int calID = inR->calID(); 1464 int calID = inR->calID();
1458 remote->deleteIncidence( inR ); 1465 remote->deleteIncidence( inR );
1459 inR = inL->clone(); 1466 inR = inL->clone();
1460 inR->setCalID( calID ); 1467 inR->setCalID( calID );
1461 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1468 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1462 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1469 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1463 inR->setIDStr( idS ); 1470 inR->setIDStr( idS );
1464 remote->addIncidence( inR ); 1471 remote->addIncidence( inR );
1465 if ( mSyncManager->syncWithDesktop() ) 1472 if ( mSyncManager->syncWithDesktop() )
1466 inR->setPilotId( 2 ); 1473 inR->setPilotId( 2 );
1467 ++changedRemote; 1474 ++changedRemote;
1468 } else {// take remote ********************** 1475 } else {// take remote **********************
1469 if ( !inL->isReadOnly() ) { 1476 if ( !inL->isReadOnly() ) {
1470 idS = inL->IDStr(); 1477 idS = inL->IDStr();
1471 int pid = inL->pilotId(); 1478 int pid = inL->pilotId();
1472 int calID = inL->calID(); 1479 int calID = inL->calID();
1473 local->deleteIncidence( inL ); 1480 local->deleteIncidence( inL );
1474 inL = inR->clone(); 1481 inL = inR->clone();
1475 inL->setCalID( calID ); 1482 inL->setCalID( calID );
1476 if ( mSyncManager->syncWithDesktop() ) 1483 if ( mSyncManager->syncWithDesktop() )
1477 inL->setPilotId( pid ); 1484 inL->setPilotId( pid );
1478 inL->setIDStr( idS ); 1485 inL->setIDStr( idS );
1479 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1486 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1480 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1487 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1481 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1488 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1482 } 1489 }
1483 local->addIncidence( inL ); 1490 local->addIncidence( inL );
1484 ++changedLocal; 1491 ++changedLocal;
1485 } 1492 }
1486 } 1493 }
1487 } 1494 }
1488 } else { // no conflict ********** add or delete remote 1495 } else { // no conflict ********** add or delete remote
1489 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1496 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1490 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1497 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1491 QString des = eventLSync->description(); 1498 QString des = eventLSync->description();
1492 QString pref = "e"; 1499 QString pref = "e";
1493 if ( inR->typeID() == todoID ) 1500 if ( inR->typeID() == todoID )
1494 pref = "t"; 1501 pref = "t";
1495 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1502 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1496 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1503 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1497 //remote->deleteIncidence( inR ); 1504 //remote->deleteIncidence( inR );
1498 ++deletedEventR; 1505 ++deletedEventR;
1499 } else { 1506 } else {
1500 inR->setLastModified( modifiedCalendar ); 1507 inR->setLastModified( modifiedCalendar );
1501 inL = inR->clone(); 1508 inL = inR->clone();
1502 inL->setIDStr( ":" ); 1509 inL->setIDStr( ":" );
1503 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1510 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1504 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1511 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1505 1512
1506 inL->setCalID( 0 );// add to default cal 1513 inL->setCalID( 0 );// add to default cal
1507 local->addIncidence( inL ); 1514 local->addIncidence( inL );
1508 ++addedEvent; 1515 ++addedEvent;
1509 1516
1510 } 1517 }
1511 } else { 1518 } else {
1512 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1519 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1513 inR->setLastModified( modifiedCalendar ); 1520 inR->setLastModified( modifiedCalendar );
1514 inL = inR->clone(); 1521 inL = inR->clone();
1515 inL->setIDStr( ":" ); 1522 inL->setIDStr( ":" );
1516 inL->setCalID( 0 );// add to default cal 1523 inL->setCalID( 0 );// add to default cal
1517 local->addIncidence( inL ); 1524 local->addIncidence( inL );
1518 ++addedEvent; 1525 ++addedEvent;
1519 1526
1520 } else { 1527 } else {
1521 checkExternSyncEvent(eventRSyncSharp, inR); 1528 checkExternSyncEvent(eventRSyncSharp, inR);
1522 remote->deleteIncidence( inR ); 1529 remote->deleteIncidence( inR );
1523 ++deletedEventR; 1530 ++deletedEventR;
1524 } 1531 }
1525 } 1532 }
1526 } else { 1533 } else {
1527 ++filteredIN; 1534 ++filteredIN;
1528 } 1535 }
1529 } 1536 }
1530 } 1537 }
1531 inR = er.next(); 1538 inR = er.next();
1532 } 1539 }
1533 QPtrList<Incidence> el = local->rawIncidences(); 1540 QPtrList<Incidence> el = local->rawIncidences();
1534 inL = el.first(); 1541 inL = el.first();
1535 modulo = (el.count()/10)+1; 1542 modulo = (el.count()/10)+1;
1536 bar.setCaption (i18n("Add / remove events") ); 1543 bar.setCaption (i18n("Add / remove events") );
1537 bar.setTotalSteps ( el.count() ) ; 1544 bar.setTotalSteps ( el.count() ) ;
1538 bar.show(); 1545 bar.show();
1539 incCounter = 0; 1546 incCounter = 0;
1540 1547
1541 while ( inL ) { 1548 while ( inL ) {
1542 1549
1543 qApp->processEvents(); 1550 qApp->processEvents();
1544 if ( ! bar.isVisible() ) 1551 if ( ! bar.isVisible() )
1545 return false; 1552 return false;
1546 if ( incCounter % modulo == 0 ) 1553 if ( incCounter % modulo == 0 )
1547 bar.setProgress( incCounter ); 1554 bar.setProgress( incCounter );
1548 ++incCounter; 1555 ++incCounter;
1549 uid = inL->uid(); 1556 uid = inL->uid();
1550 bool skipIncidence = false; 1557 bool skipIncidence = false;
1551 if ( uid.left(15) == QString("last-syncEvent-") ) 1558 if ( uid.left(15) == QString("last-syncEvent-") )
1552 skipIncidence = true; 1559 skipIncidence = true;
1553 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1560 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1554 skipIncidence = true; 1561 skipIncidence = true;
1555 if ( !skipIncidence ) { 1562 if ( !skipIncidence ) {
1556 inR = remote->incidenceForUid( uid , true ); 1563 inR = remote->incidenceForUid( uid , true );
1557 if ( ! inR ) { 1564 if ( ! inR ) {
1558 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1565 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1559 // no conflict ********** add or delete local 1566 // no conflict ********** add or delete local
1560 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1567 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1561 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1568 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1562 checkExternSyncEvent(eventLSyncSharp, inL); 1569 checkExternSyncEvent(eventLSyncSharp, inL);
1563 local->deleteIncidence( inL ); 1570 local->deleteIncidence( inL );
1564 ++deletedEventL; 1571 ++deletedEventL;
1565 } else { 1572 } else {
1566 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1573 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1567 inL->removeID(mCurrentSyncDevice ); 1574 inL->removeID(mCurrentSyncDevice );
1568 ++addedEventR; 1575 ++addedEventR;
1569 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1576 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1570 inL->setLastModified( modifiedCalendar ); 1577 inL->setLastModified( modifiedCalendar );
1571 inR = inL->clone(); 1578 inR = inL->clone();
1572 inR->setIDStr( ":" ); 1579 inR->setIDStr( ":" );
1573 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1580 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1574 inR->setCalID( 0 );// add to default cal 1581 inR->setCalID( 0 );// add to default cal
1575 remote->addIncidence( inR ); 1582 remote->addIncidence( inR );
1576 } 1583 }
1577 } 1584 }
1578 } else { 1585 } else {
1579 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1586 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1580 checkExternSyncEvent(eventLSyncSharp, inL); 1587 checkExternSyncEvent(eventLSyncSharp, inL);
1581 local->deleteIncidence( inL ); 1588 local->deleteIncidence( inL );
1582 ++deletedEventL; 1589 ++deletedEventL;
1583 } else { 1590 } else {
1584 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1591 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1585 ++addedEventR; 1592 ++addedEventR;
1586 inL->setLastModified( modifiedCalendar ); 1593 inL->setLastModified( modifiedCalendar );
1587 inR = inL->clone(); 1594 inR = inL->clone();
1588 inR->setIDStr( ":" ); 1595 inR->setIDStr( ":" );
1589 inR->setCalID( 0 );// add to default cal 1596 inR->setCalID( 0 );// add to default cal
1590 remote->addIncidence( inR ); 1597 remote->addIncidence( inR );
1591 } 1598 }
1592 } 1599 }
1593 } 1600 }
1594 } else { 1601 } else {
1595 ++filteredOUT; 1602 ++filteredOUT;
1596 } 1603 }
1597 } 1604 }
1598 } 1605 }
1599 inL = el.next(); 1606 inL = el.next();
1600 } 1607 }
1601 int delFut = 0; 1608 int delFut = 0;
1602 int remRem = 0; 1609 int remRem = 0;
1603 if ( mSyncManager->mWriteBackInFuture ) { 1610 if ( mSyncManager->mWriteBackInFuture ) {
1604 er = remote->rawIncidences(); 1611 er = remote->rawIncidences();
1605 remRem = er.count(); 1612 remRem = er.count();
1606 inR = er.first(); 1613 inR = er.first();
1607 QDateTime dt; 1614 QDateTime dt;
1608 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1615 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1609 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1616 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1610 while ( inR ) { 1617 while ( inR ) {
1611 if ( inR->typeID() == todoID ) { 1618 if ( inR->typeID() == todoID ) {
1612 Todo * t = (Todo*)inR; 1619 Todo * t = (Todo*)inR;
1613 if ( t->hasDueDate() ) 1620 if ( t->hasDueDate() )
1614 dt = t->dtDue(); 1621 dt = t->dtDue();
1615 else 1622 else
1616 dt = cur.addSecs( 62 ); 1623 dt = cur.addSecs( 62 );
1617 } 1624 }
1618 else if (inR->typeID() == eventID ) { 1625 else if (inR->typeID() == eventID ) {
1619 bool ok; 1626 bool ok;
1620 dt = inR->getNextOccurence( cur, &ok ); 1627 dt = inR->getNextOccurence( cur, &ok );
1621 if ( !ok ) 1628 if ( !ok )
1622 dt = cur.addSecs( -62 ); 1629 dt = cur.addSecs( -62 );
1623 } 1630 }
1624 else 1631 else
1625 dt = inR->dtStart(); 1632 dt = inR->dtStart();
1626 if ( dt < cur || dt > end ) { 1633 if ( dt < cur || dt > end ) {
1627 remote->deleteIncidence( inR ); 1634 remote->deleteIncidence( inR );
1628 ++delFut; 1635 ++delFut;
1629 } 1636 }
1630 inR = er.next(); 1637 inR = er.next();
1631 } 1638 }
1632 } 1639 }
1633 bar.hide(); 1640 bar.hide();
1634 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1641 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1635 eventLSync->setReadOnly( false ); 1642 eventLSync->setReadOnly( false );
1636 eventLSync->setDtStart( mLastCalendarSync ); 1643 eventLSync->setDtStart( mLastCalendarSync );
1637 eventRSync->setDtStart( mLastCalendarSync ); 1644 eventRSync->setDtStart( mLastCalendarSync );
1638 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1645 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1639 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1646 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1640 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1647 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1641 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1648 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1642 eventLSync->setReadOnly( true ); 1649 eventLSync->setReadOnly( true );
1643 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1650 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1644 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1651 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1645 remote->addEvent( eventRSync ); 1652 remote->addEvent( eventRSync );
1646 else 1653 else
1647 delete eventRSync; 1654 delete eventRSync;
1648 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1655 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1649 QString mes; 1656 QString mes;
1650 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 ); 1657 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 );
1651 QString delmess; 1658 QString delmess;
1652 if ( delFut ) { 1659 if ( delFut ) {
1653 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); 1660 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);
1654 mes += delmess; 1661 mes += delmess;
1655 } 1662 }
1656 mes = i18n("Local calendar changed!\n") +mes; 1663 mes = i18n("Local calendar changed!\n") +mes;
1657 mCalendar->checkAlarmForIncidence( 0, true ); 1664 mCalendar->checkAlarmForIncidence( 0, true );
1658 qDebug( mes ); 1665 qDebug( mes );
1659 if ( mSyncManager->mShowSyncSummary ) { 1666 if ( mSyncManager->mShowSyncSummary ) {
1660 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1667 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1661 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1668 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1662 qDebug("KO: WB cancelled "); 1669 qDebug("KO: WB cancelled ");
1663 mSyncManager->mWriteBackFile = false; 1670 mSyncManager->mWriteBackFile = false;
1664 return syncOK; 1671 return syncOK;
1665 } 1672 }
1666 } 1673 }
1667 return syncOK; 1674 return syncOK;
1668} 1675}
1669 1676
1670void CalendarView::setSyncDevice( QString s ) 1677void CalendarView::setSyncDevice( QString s )
1671{ 1678{
1672 mCurrentSyncDevice= s; 1679 mCurrentSyncDevice= s;
1673} 1680}
1674void CalendarView::setSyncName( QString s ) 1681void CalendarView::setSyncName( QString s )
1675{ 1682{
1676 mCurrentSyncName= s; 1683 mCurrentSyncName= s;
1677} 1684}
1678bool CalendarView::syncCalendar(QString filename, int mode) 1685bool CalendarView::syncCalendar(QString filename, int mode)
1679{ 1686{
1680 //qDebug("syncCalendar %s ", filename.latin1()); 1687 //qDebug("syncCalendar %s ", filename.latin1());
1681 mGlobalSyncMode = SYNC_MODE_NORMAL; 1688 mGlobalSyncMode = SYNC_MODE_NORMAL;
1682 CalendarLocal* calendar = new CalendarLocal(); 1689 CalendarLocal* calendar = new CalendarLocal();
1683 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1690 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1684 FileStorage* storage = new FileStorage( calendar ); 1691 FileStorage* storage = new FileStorage( calendar );
1685 bool syncOK = false; 1692 bool syncOK = false;
1686 storage->setFileName( filename ); 1693 storage->setFileName( filename );
1687 // qDebug("loading ... "); 1694 // qDebug("loading ... ");
1688 if ( storage->load() ) { 1695 if ( storage->load() ) {
1689 getEventViewerDialog()->setSyncMode( true ); 1696 getEventViewerDialog()->setSyncMode( true );
1690 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1697 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1691 getEventViewerDialog()->setSyncMode( false ); 1698 getEventViewerDialog()->setSyncMode( false );
1692 if ( syncOK ) { 1699 if ( syncOK ) {
1693 if ( mSyncManager->mWriteBackFile ) 1700 if ( mSyncManager->mWriteBackFile )
1694 { 1701 {
1695 storage->setSaveFormat( new ICalFormat() ); 1702 storage->setSaveFormat( new ICalFormat() );
1696 storage->save(); 1703 storage->save();
1697 } 1704 }
1698 } 1705 }
1699 setModified( true ); 1706 setModified( true );
1700 } 1707 }
1701 delete storage; 1708 delete storage;
1702 delete calendar; 1709 delete calendar;
1703 if ( syncOK ) 1710 if ( syncOK )
1704 updateView(); 1711 updateView();
1705 return syncOK; 1712 return syncOK;
1706} 1713}
1707 1714
1708void CalendarView::syncExternal( int mode ) 1715void CalendarView::syncExternal( int mode )
1709{ 1716{
1710 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1717 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1711 1718
1712 qApp->processEvents(); 1719 qApp->processEvents();
1713 CalendarLocal* calendar = new CalendarLocal(); 1720 CalendarLocal* calendar = new CalendarLocal();
1714 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1721 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1715 bool syncOK = false; 1722 bool syncOK = false;
1716 bool loadSuccess = false; 1723 bool loadSuccess = false;
1717 PhoneFormat* phoneFormat = 0; 1724 PhoneFormat* phoneFormat = 0;
1718 emit tempDisableBR(true); 1725 emit tempDisableBR(true);
1719#ifndef DESKTOP_VERSION 1726#ifndef DESKTOP_VERSION
1720 SharpFormat* sharpFormat = 0; 1727 SharpFormat* sharpFormat = 0;
1721 if ( mode == 0 ) { // sharp 1728 if ( mode == 0 ) { // sharp
1722 sharpFormat = new SharpFormat () ; 1729 sharpFormat = new SharpFormat () ;
1723 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1730 loadSuccess = sharpFormat->load( calendar, mCalendar );
1724 1731
1725 } else 1732 } else
1726#endif 1733#endif
1727 if ( mode == 1 ) { // phone 1734 if ( mode == 1 ) { // phone
1728 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1735 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1729 mSyncManager->mPhoneDevice, 1736 mSyncManager->mPhoneDevice,
1730 mSyncManager->mPhoneConnection, 1737 mSyncManager->mPhoneConnection,
1731 mSyncManager->mPhoneModel); 1738 mSyncManager->mPhoneModel);
1732 loadSuccess = phoneFormat->load( calendar,mCalendar); 1739 loadSuccess = phoneFormat->load( calendar,mCalendar);
1733 1740
1734 } else { 1741 } else {
1735 emit tempDisableBR(false); 1742 emit tempDisableBR(false);
1736 return; 1743 return;
1737 } 1744 }
1738 if ( loadSuccess ) { 1745 if ( loadSuccess ) {
1739 getEventViewerDialog()->setSyncMode( true ); 1746 getEventViewerDialog()->setSyncMode( true );
1740 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1747 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1741 getEventViewerDialog()->setSyncMode( false ); 1748 getEventViewerDialog()->setSyncMode( false );
1742 qApp->processEvents(); 1749 qApp->processEvents();
1743 if ( syncOK ) { 1750 if ( syncOK ) {
1744 if ( mSyncManager->mWriteBackFile ) 1751 if ( mSyncManager->mWriteBackFile )
1745 { 1752 {
1746 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1753 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1747 Incidence* inc = iL.first(); 1754 Incidence* inc = iL.first();
1748 if ( phoneFormat ) { 1755 if ( phoneFormat ) {
1749 while ( inc ) { 1756 while ( inc ) {
1750 inc->removeID(mCurrentSyncDevice); 1757 inc->removeID(mCurrentSyncDevice);
1751 inc = iL.next(); 1758 inc = iL.next();
1752 } 1759 }
1753 } 1760 }
1754#ifndef DESKTOP_VERSION 1761#ifndef DESKTOP_VERSION
1755 if ( sharpFormat ) 1762 if ( sharpFormat )
1756 sharpFormat->save(calendar); 1763 sharpFormat->save(calendar);
1757#endif 1764#endif
1758 if ( phoneFormat ) 1765 if ( phoneFormat )
1759 phoneFormat->save(calendar); 1766 phoneFormat->save(calendar);
1760 iL = calendar->rawIncidences(); 1767 iL = calendar->rawIncidences();
1761 inc = iL.first(); 1768 inc = iL.first();
1762 Incidence* loc; 1769 Incidence* loc;
1763 while ( inc ) { 1770 while ( inc ) {
1764 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1771 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1765 loc = mCalendar->incidence(inc->uid() ); 1772 loc = mCalendar->incidence(inc->uid() );
1766 if ( loc ) { 1773 if ( loc ) {
1767 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1774 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1768 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1775 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1769 } 1776 }
1770 } 1777 }
1771 inc = iL.next(); 1778 inc = iL.next();
1772 } 1779 }
1773 Incidence* lse = getLastSyncEvent(); 1780 Incidence* lse = getLastSyncEvent();
1774 if ( lse ) { 1781 if ( lse ) {
1775 lse->setReadOnly( false ); 1782 lse->setReadOnly( false );
1776 lse->setDescription( "" ); 1783 lse->setDescription( "" );
1777 lse->setReadOnly( true ); 1784 lse->setReadOnly( true );
1778 } 1785 }
1779 } 1786 }
1780 } else { 1787 } else {
1781 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1788 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1782 } 1789 }
1783 setModified( true ); 1790 setModified( true );
1784 } else { 1791 } else {
1785 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1792 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1786 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1793 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1787 question, i18n("Ok")) ; 1794 question, i18n("Ok")) ;
1788 1795
1789 } 1796 }
1790 delete calendar; 1797 delete calendar;
1791 updateView(); 1798 updateView();
1792 emit tempDisableBR(false); 1799 emit tempDisableBR(false);
1793 return ;//syncOK; 1800 return ;//syncOK;
1794 1801
1795} 1802}
1796 1803
1797bool CalendarView::importBday() 1804bool CalendarView::importBday()
1798{ 1805{
1799#ifndef KORG_NOKABC 1806#ifndef KORG_NOKABC
1800 1807
1801#ifdef DESKTOP_VERSION 1808#ifdef DESKTOP_VERSION
1802 int curCal = mCalendar->defaultCalendar(); 1809 int curCal = mCalendar->defaultCalendar();
1803 int bd = mCalEditView->getBirtdayID(); 1810 int bd = mCalEditView->getBirtdayID();
1804 if ( bd == 0 ) 1811 if ( bd == 0 )
1805 return false; 1812 return false;
1806 mCalendar->setDefaultCalendar( bd ); 1813 mCalendar->setDefaultCalendar( bd );
1807 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1814 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1808 KABC::AddressBook::Iterator it; 1815 KABC::AddressBook::Iterator it;
1809 int count = 0; 1816 int count = 0;
1810 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1817 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1811 ++count; 1818 ++count;
1812 } 1819 }
1813 QProgressBar bar(count,0 ); 1820 QProgressBar bar(count,0 );
1814 int w = 300; 1821 int w = 300;
1815 if ( QApplication::desktop()->width() < 320 ) 1822 if ( QApplication::desktop()->width() < 320 )
1816 w = 220; 1823 w = 220;
1817 int h = bar.sizeHint().height() ; 1824 int h = bar.sizeHint().height() ;
1818 int dw = QApplication::desktop()->width(); 1825 int dw = QApplication::desktop()->width();
1819 int dh = QApplication::desktop()->height(); 1826 int dh = QApplication::desktop()->height();
1820 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1827 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1821 bar.show(); 1828 bar.show();
1822 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1829 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1823 qApp->processEvents(); 1830 qApp->processEvents();
1824 count = 0; 1831 count = 0;
1825 int addCount = 0; 1832 int addCount = 0;
1826 KCal::Attendee* a = 0; 1833 KCal::Attendee* a = 0;
1827 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1834 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1828 if ( ! bar.isVisible() ) 1835 if ( ! bar.isVisible() )
1829 return false; 1836 return false;
1830 bar.setProgress( count++ ); 1837 bar.setProgress( count++ );
1831 qApp->processEvents(); 1838 qApp->processEvents();
1832 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1839 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1833 if ( (*it).birthday().date().isValid() ){ 1840 if ( (*it).birthday().date().isValid() ){
1834 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1841 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1835 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1842 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1836 ++addCount; 1843 ++addCount;
1837 } 1844 }
1838 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1845 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1839 if ( anni.isValid() ){ 1846 if ( anni.isValid() ){
1840 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1847 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1841 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1848 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1842 ++addCount; 1849 ++addCount;
1843 } 1850 }
1844 } 1851 }
1845 mCalendar->setDefaultCalendar( curCal ); 1852 mCalendar->setDefaultCalendar( curCal );
1846 updateView(); 1853 updateView();
1847 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1854 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1848#else //DESKTOP_VERSION 1855#else //DESKTOP_VERSION
1849 1856
1850 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1857 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1851 // the result should now arrive through method insertBirthdays 1858 // the result should now arrive through method insertBirthdays
1852 1859
1853#endif //DESKTOP_VERSION 1860#endif //DESKTOP_VERSION
1854 1861
1855#endif //KORG_NOKABC 1862#endif //KORG_NOKABC
1856 1863
1857 1864
1858 return true; 1865 return true;
1859} 1866}
1860 1867
1861// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1868// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1862void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1869void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1863 const QStringList& anniversaryList, const QStringList& realNameList, 1870 const QStringList& anniversaryList, const QStringList& realNameList,
1864 const QStringList& emailList, const QStringList& assembledNameList, 1871 const QStringList& emailList, const QStringList& assembledNameList,
1865 const QStringList& uidList) 1872 const QStringList& uidList)
1866{ 1873{
1867 1874
1868 //qDebug("KO::CalendarView::insertBirthdays"); 1875 //qDebug("KO::CalendarView::insertBirthdays");
1869 if (uid == this->name()) 1876 if (uid == this->name())
1870 { 1877 {
1871 int curCal = mCalendar->defaultCalendar(); 1878 int curCal = mCalendar->defaultCalendar();
1872 int bd = mCalEditView->getBirtdayID(); 1879 int bd = mCalEditView->getBirtdayID();
1873 if ( bd == 0 ) 1880 if ( bd == 0 )
1874 return; 1881 return;
1875 mCalendar->setDefaultCalendar( bd ); 1882 mCalendar->setDefaultCalendar( bd );
1876 1883
1877 1884
1878 int count = birthdayList.count(); 1885 int count = birthdayList.count();
1879 int addCount = 0; 1886 int addCount = 0;
1880 KCal::Attendee* a = 0; 1887 KCal::Attendee* a = 0;
1881 1888
1882 //qDebug("CalView 1 %i", count); 1889 //qDebug("CalView 1 %i", count);
1883 1890
1884 QProgressBar bar(count,0 ); 1891 QProgressBar bar(count,0 );
1885 int w = 300; 1892 int w = 300;
1886 if ( QApplication::desktop()->width() < 320 ) 1893 if ( QApplication::desktop()->width() < 320 )
1887 w = 220; 1894 w = 220;
1888 int h = bar.sizeHint().height() ; 1895 int h = bar.sizeHint().height() ;
1889 int dw = QApplication::desktop()->width(); 1896 int dw = QApplication::desktop()->width();
1890 int dh = QApplication::desktop()->height(); 1897 int dh = QApplication::desktop()->height();
1891 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1898 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1892 bar.show(); 1899 bar.show();
1893 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1900 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1894 qApp->processEvents(); 1901 qApp->processEvents();
1895 1902
1896 QDate birthday; 1903 QDate birthday;
1897 QDate anniversary; 1904 QDate anniversary;
1898 QString realName; 1905 QString realName;
1899 QString email; 1906 QString email;
1900 QString assembledName; 1907 QString assembledName;
1901 QString uid; 1908 QString uid;
1902 bool ok = true; 1909 bool ok = true;
1903 for ( int i = 0; i < count; i++) 1910 for ( int i = 0; i < count; i++)
1904 { 1911 {
1905 if ( ! bar.isVisible() ) 1912 if ( ! bar.isVisible() )
1906 return; 1913 return;
1907 bar.setProgress( i ); 1914 bar.setProgress( i );
1908 qApp->processEvents(); 1915 qApp->processEvents();
1909 1916
1910 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1917 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1911 if (!ok) { 1918 if (!ok) {
1912 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1919 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1913 } 1920 }
1914 1921
1915 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1922 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1916 if (!ok) { 1923 if (!ok) {
1917 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1924 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1918 } 1925 }
1919 realName = realNameList[i]; 1926 realName = realNameList[i];
1920 email = emailList[i]; 1927 email = emailList[i];
1921 assembledName = assembledNameList[i]; 1928 assembledName = assembledNameList[i];
1922 uid = uidList[i]; 1929 uid = uidList[i];
1923 //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() ); 1930 //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() );
1924 1931
1925 if ( birthday.isValid() ){ 1932 if ( birthday.isValid() ){
1926 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1933 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1927 KCal::Attendee::ReqParticipant,uid) ; 1934 KCal::Attendee::ReqParticipant,uid) ;
1928 if ( addAnniversary( birthday, assembledName, a, true ) ) 1935 if ( addAnniversary( birthday, assembledName, a, true ) )
1929 ++addCount; 1936 ++addCount;
1930 } 1937 }
1931 1938
1932 if ( anniversary.isValid() ){ 1939 if ( anniversary.isValid() ){
1933 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1940 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1934 KCal::Attendee::ReqParticipant,uid) ; 1941 KCal::Attendee::ReqParticipant,uid) ;
1935 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1942 if ( addAnniversary( anniversary, assembledName, a, false ) )
1936 ++addCount; 1943 ++addCount;
1937 } 1944 }
1938 } 1945 }
1939 1946
1940 mCalendar->setDefaultCalendar( curCal ); 1947 mCalendar->setDefaultCalendar( curCal );
1941 updateView(); 1948 updateView();
1942 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1949 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1943 1950
1944 } 1951 }
1945 1952
1946} 1953}
1947 1954
1948 1955
1949 1956
1950bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1957bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1951{ 1958{
1952 //qDebug("addAnni "); 1959 //qDebug("addAnni ");
1953 Event * ev = new Event(); 1960 Event * ev = new Event();
1954 ev->setOrganizer(KOPrefs::instance()->email()); 1961 ev->setOrganizer(KOPrefs::instance()->email());
1955 if ( a ) { 1962 if ( a ) {
1956 ev->addAttendee( a ); 1963 ev->addAttendee( a );
1957 } 1964 }
1958 QString kind; 1965 QString kind;
1959 if ( birthday ) { 1966 if ( birthday ) {
1960 kind = i18n( "Birthday" ); 1967 kind = i18n( "Birthday" );
1961 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1968 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1962 } 1969 }
1963 else { 1970 else {
1964 kind = i18n( "Anniversary" ); 1971 kind = i18n( "Anniversary" );
1965 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1972 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1966 } 1973 }
1967 ev->setCategories( kind ); 1974 ev->setCategories( kind );
1968 ev->setDtStart( QDateTime(date) ); 1975 ev->setDtStart( QDateTime(date) );
1969 ev->setDtEnd( QDateTime(date) ); 1976 ev->setDtEnd( QDateTime(date) );
1970 ev->setFloats( true ); 1977 ev->setFloats( true );
1971 Recurrence * rec = ev->recurrence(); 1978 Recurrence * rec = ev->recurrence();
1972 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1979 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1973 rec->addYearlyNum( date.month() ); 1980 rec->addYearlyNum( date.month() );
1974 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1981 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1975 delete ev; 1982 delete ev;
1976 return false; 1983 return false;
1977 } 1984 }
1978 return true; 1985 return true;
1979 1986
1980} 1987}
1981bool CalendarView::importQtopia( const QString &categories, 1988bool CalendarView::importQtopia( const QString &categories,
1982 const QString &datebook, 1989 const QString &datebook,
1983 const QString &todolist ) 1990 const QString &todolist )
1984{ 1991{
1985 1992
1986 QtopiaFormat qtopiaFormat; 1993 QtopiaFormat qtopiaFormat;
1987 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1994 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1988 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1995 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1989 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1996 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1990 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1997 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1991 1998
1992 updateView(); 1999 updateView();
1993 return true; 2000 return true;
1994 2001
1995#if 0 2002#if 0
1996 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2003 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1997 mCurrentSyncDevice = "qtopia-XML"; 2004 mCurrentSyncDevice = "qtopia-XML";
1998 if ( mSyncManager->mAskForPreferences ) 2005 if ( mSyncManager->mAskForPreferences )
1999 edit_sync_options(); 2006 edit_sync_options();
2000 qApp->processEvents(); 2007 qApp->processEvents();
2001 CalendarLocal* calendar = new CalendarLocal(); 2008 CalendarLocal* calendar = new CalendarLocal();
2002 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2009 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2003 bool syncOK = false; 2010 bool syncOK = false;
2004 QtopiaFormat qtopiaFormat; 2011 QtopiaFormat qtopiaFormat;
2005 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2012 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2006 bool loadOk = true; 2013 bool loadOk = true;
2007 if ( !categories.isEmpty() ) 2014 if ( !categories.isEmpty() )
2008 loadOk = qtopiaFormat.load( calendar, categories ); 2015 loadOk = qtopiaFormat.load( calendar, categories );
2009 if ( loadOk && !datebook.isEmpty() ) 2016 if ( loadOk && !datebook.isEmpty() )
2010 loadOk = qtopiaFormat.load( calendar, datebook ); 2017 loadOk = qtopiaFormat.load( calendar, datebook );
2011 if ( loadOk && !todolist.isEmpty() ) 2018 if ( loadOk && !todolist.isEmpty() )
2012 loadOk = qtopiaFormat.load( calendar, todolist ); 2019 loadOk = qtopiaFormat.load( calendar, todolist );
2013 2020
2014 if ( loadOk ) { 2021 if ( loadOk ) {
2015 getEventViewerDialog()->setSyncMode( true ); 2022 getEventViewerDialog()->setSyncMode( true );
2016 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2023 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2017 getEventViewerDialog()->setSyncMode( false ); 2024 getEventViewerDialog()->setSyncMode( false );
2018 qApp->processEvents(); 2025 qApp->processEvents();
2019 if ( syncOK ) { 2026 if ( syncOK ) {
2020 if ( mSyncManager->mWriteBackFile ) 2027 if ( mSyncManager->mWriteBackFile )
2021 { 2028 {
2022 // write back XML file 2029 // write back XML file
2023 2030
2024 } 2031 }
2025 setModified( true ); 2032 setModified( true );
2026 } 2033 }
2027 } else { 2034 } else {
2028 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2035 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2029 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2036 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2030 question, i18n("Ok")) ; 2037 question, i18n("Ok")) ;
2031 } 2038 }
2032 delete calendar; 2039 delete calendar;
2033 updateView(); 2040 updateView();
2034 return syncOK; 2041 return syncOK;
2035 2042
2036 2043
2037#endif 2044#endif
2038 2045
2039} 2046}
2040 2047
2041void CalendarView::setSyncEventsReadOnly() 2048void CalendarView::setSyncEventsReadOnly()
2042{ 2049{
2043 mCalendar->setSyncEventsReadOnly(); 2050 mCalendar->setSyncEventsReadOnly();
2044} 2051}
2045 2052
2046bool CalendarView::loadCalendars() 2053bool CalendarView::loadCalendars()
2047{ 2054{
2048 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2055 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2049 KopiCalendarFile * cal = calendars.first(); 2056 KopiCalendarFile * cal = calendars.first();
2050 mCalendar->setDefaultCalendar( 1 ); 2057 mCalendar->setDefaultCalendar( 1 );
2051 openCalendar( MainWindow::defaultFileName(), false ); 2058 openCalendar( MainWindow::defaultFileName(), false );
2052 cal = calendars.next(); 2059 cal = calendars.next();
2053 while ( cal ) { 2060 while ( cal ) {
2054 addCalendar( cal ); 2061 addCalendar( cal );
2055 cal = calendars.next(); 2062 cal = calendars.next();
2056 } 2063 }
2057 restoreCalendarSettings(); 2064 restoreCalendarSettings();
2058 return true; 2065 return true;
2059} 2066}
2060bool CalendarView::restoreCalendarSettings() 2067bool CalendarView::restoreCalendarSettings()
2061{ 2068{
2062 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2069 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2063 KopiCalendarFile * cal = calendars.first(); 2070 KopiCalendarFile * cal = calendars.first();
2064 while ( cal ) { 2071 while ( cal ) {
2065 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2072 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2066 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2073 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2067 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2074 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2068 if ( cal->isStandard ) 2075 if ( cal->isStandard )
2069 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2076 mCalendar->setDefaultCalendar( cal->mCalNumber );
2070 cal = calendars.next(); 2077 cal = calendars.next();
2071 } 2078 }
2072 setSyncEventsReadOnly(); 2079 setSyncEventsReadOnly();
2073 mCalendar->reInitAlarmSettings(); 2080 mCalendar->reInitAlarmSettings();
2074 updateUnmanagedViews(); 2081 updateUnmanagedViews();
2075 updateView(); 2082 updateView();
2076 return true; 2083 return true;
2077} 2084}
2078void CalendarView::addCalendarId( int id ) 2085void CalendarView::addCalendarId( int id )
2079{ 2086{
2080 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2087 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2081 if ( cal ) 2088 if ( cal )
2082 addCalendar( cal ); 2089 addCalendar( cal );
2083} 2090}
2084bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2091bool CalendarView::addCalendar( KopiCalendarFile * cal )
2085{ 2092{
2086 cal->mErrorOnLoad = false; 2093 cal->mErrorOnLoad = false;
2087 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2094 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2088 cal->mLoadDt = QDateTime::currentDateTime(); 2095 cal->mLoadDt = QDateTime::currentDateTime();
2089 return true; 2096 return true;
2090 } 2097 }
2091 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2098 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2092 cal->mErrorOnLoad = true; 2099 cal->mErrorOnLoad = true;
2093 return false; 2100 return false;
2094} 2101}
2095bool CalendarView::openCalendar(QString filename, bool merge) 2102bool CalendarView::openCalendar(QString filename, bool merge)
2096{ 2103{
2097 2104
2098 if (filename.isEmpty()) { 2105 if (filename.isEmpty()) {
2099 return false; 2106 return false;
2100 } 2107 }
2101 2108
2102 if (!QFile::exists(filename)) { 2109 if (!QFile::exists(filename)) {
2103 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2110 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2104 return false; 2111 return false;
2105 } 2112 }
2106 2113
2107 globalFlagBlockAgenda = 1; 2114 globalFlagBlockAgenda = 1;
2108 clearAllViews(); 2115 clearAllViews();
2109 if (!merge) { 2116 if (!merge) {
2110 mViewManager->setDocumentId( filename ); 2117 mViewManager->setDocumentId( filename );
2111 mCalendar->close(); 2118 mCalendar->close();
2112 } 2119 }
2113 mStorage->setFileName( filename ); 2120 mStorage->setFileName( filename );
2114 2121
2115 if ( mStorage->load() ) { 2122 if ( mStorage->load() ) {
2116 if ( merge ) ;//setModified( true ); 2123 if ( merge ) ;//setModified( true );
2117 else { 2124 else {
2118 //setModified( true ); 2125 //setModified( true );
2119 mViewManager->setDocumentId( filename ); 2126 mViewManager->setDocumentId( filename );
2120 mDialogManager->setDocumentId( filename ); 2127 mDialogManager->setDocumentId( filename );
2121 mTodoList->setDocumentId( filename ); 2128 mTodoList->setDocumentId( filename );
2122 } 2129 }
2123 globalFlagBlockAgenda = 2; 2130 globalFlagBlockAgenda = 2;
2124 // if ( getLastSyncEvent() ) 2131 // if ( getLastSyncEvent() )
2125 // getLastSyncEvent()->setReadOnly( true ); 2132 // getLastSyncEvent()->setReadOnly( true );
2126 mCalendar->reInitAlarmSettings(); 2133 mCalendar->reInitAlarmSettings();
2127 setSyncEventsReadOnly(); 2134 setSyncEventsReadOnly();
2128 updateUnmanagedViews(); 2135 updateUnmanagedViews();
2129 updateView(); 2136 updateView();
2130 if ( filename != MainWindow::defaultFileName() ) { 2137 if ( filename != MainWindow::defaultFileName() ) {
2131 saveCalendar( MainWindow::defaultFileName() ); 2138 saveCalendar( MainWindow::defaultFileName() );
2132 } else { 2139 } else {
2133 QFileInfo finf ( MainWindow::defaultFileName()); 2140 QFileInfo finf ( MainWindow::defaultFileName());
2134 if ( finf.exists() ) { 2141 if ( finf.exists() ) {
2135 setLoadedFileVersion( finf.lastModified () ); 2142 setLoadedFileVersion( finf.lastModified () );
2136 } 2143 }
2137 } 2144 }
2138 return true; 2145 return true;
2139 } else { 2146 } else {
2140 // while failing to load, the calendar object could 2147 // while failing to load, the calendar object could
2141 // have become partially populated. Clear it out. 2148 // have become partially populated. Clear it out.
2142 if ( !merge ) { 2149 if ( !merge ) {
2143 mCalendar->close(); 2150 mCalendar->close();
2144 mViewManager->setDocumentId( filename ); 2151 mViewManager->setDocumentId( filename );
2145 mDialogManager->setDocumentId( filename ); 2152 mDialogManager->setDocumentId( filename );
2146 mTodoList->setDocumentId( filename ); 2153 mTodoList->setDocumentId( filename );
2147 } 2154 }
2148 2155
2149 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2156 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2150 2157
2151 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2158 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2152 globalFlagBlockAgenda = 2; 2159 globalFlagBlockAgenda = 2;
2153 mCalendar->reInitAlarmSettings(); 2160 mCalendar->reInitAlarmSettings();
2154 setSyncEventsReadOnly(); 2161 setSyncEventsReadOnly();
2155 updateUnmanagedViews(); 2162 updateUnmanagedViews();
2156 updateView(); 2163 updateView();
2157 } 2164 }
2158 return false; 2165 return false;
2159} 2166}
2160void CalendarView::mergeFile( QString fn ) 2167void CalendarView::mergeFile( QString fn )
2161{ 2168{
2162 clearAllViews(); 2169 clearAllViews();
2163 mCalendar->mergeCalendarFile( fn ); 2170 mCalendar->mergeCalendarFile( fn );
2164 mCalendar->reInitAlarmSettings(); 2171 mCalendar->reInitAlarmSettings();
2165 setSyncEventsReadOnly(); 2172 setSyncEventsReadOnly();
2166 updateUnmanagedViews(); 2173 updateUnmanagedViews();
2167 updateView(); 2174 updateView();
2168} 2175}
2169void CalendarView::showOpenError() 2176void CalendarView::showOpenError()
2170{ 2177{
2171 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2178 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2172} 2179}
2173void CalendarView::setLoadedFileVersion(QDateTime dt) 2180void CalendarView::setLoadedFileVersion(QDateTime dt)
2174{ 2181{
2175 loadedFileVersion = dt; 2182 loadedFileVersion = dt;
2176} 2183}
2177bool CalendarView::checkFileChanged(QString fn) 2184bool CalendarView::checkFileChanged(QString fn)
2178{ 2185{
2179 QFileInfo finf ( fn ); 2186 QFileInfo finf ( fn );
2180 if ( !finf.exists() ) 2187 if ( !finf.exists() )
2181 return true; 2188 return true;
2182 QDateTime dt = finf.lastModified (); 2189 QDateTime dt = finf.lastModified ();
2183 if ( dt <= loadedFileVersion ) 2190 if ( dt <= loadedFileVersion )
2184 return false; 2191 return false;
2185 return true; 2192 return true;
2186 2193
2187} 2194}
2188void CalendarView::watchSavedFile() 2195void CalendarView::watchSavedFile()
2189{ 2196{
2190 QFileInfo finf ( MainWindow::defaultFileName()); 2197 QFileInfo finf ( MainWindow::defaultFileName());
2191 if ( !finf.exists() ) 2198 if ( !finf.exists() )
2192 return; 2199 return;
2193 QDateTime dt = finf.lastModified (); 2200 QDateTime dt = finf.lastModified ();
2194 if ( dt < loadedFileVersion ) { 2201 if ( dt < loadedFileVersion ) {
2195 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2202 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2196 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2203 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2197 return; 2204 return;
2198 } 2205 }
2199 loadedFileVersion = dt; 2206 loadedFileVersion = dt;
2200} 2207}
2201bool CalendarView::checkAllFileVersions() 2208bool CalendarView::checkAllFileVersions()
2202{ 2209{
2203 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2210 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2204 KopiCalendarFile * cal = calendars.first(); 2211 KopiCalendarFile * cal = calendars.first();
2205 mCalendar->setDefaultCalendar( 1 ); 2212 mCalendar->setDefaultCalendar( 1 );
2206 mCalendar->setDefaultCalendarEnabledOnly(); 2213 mCalendar->setDefaultCalendarEnabledOnly();
2207 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2214 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2208 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2215 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2209 restoreCalendarSettings(); 2216 restoreCalendarSettings();
2210 return false; 2217 return false;
2211 } 2218 }
2212 } 2219 }
2213 cal = calendars.next(); 2220 cal = calendars.next();
2214 QDateTime storeTemp = loadedFileVersion; 2221 QDateTime storeTemp = loadedFileVersion;
2215 while ( cal ) { 2222 while ( cal ) {
2216 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2223 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2217 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2224 mCalendar->setDefaultCalendar( cal->mCalNumber );
2218 mCalendar->setDefaultCalendarEnabledOnly(); 2225 mCalendar->setDefaultCalendarEnabledOnly();
2219 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2226 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2220 if ( !checkFileVersion(cal->mFileName )) { 2227 if ( !checkFileVersion(cal->mFileName )) {
2221 loadedFileVersion = storeTemp; 2228 loadedFileVersion = storeTemp;
2222 restoreCalendarSettings(); 2229 restoreCalendarSettings();
2223 return false; 2230 return false;
2224 } 2231 }
2225 } 2232 }
2226 cal = calendars.next(); 2233 cal = calendars.next();
2227 } 2234 }
2228 loadedFileVersion = storeTemp; 2235 loadedFileVersion = storeTemp;
2229 return true; 2236 return true;
2230} 2237}
2231bool CalendarView::checkFileVersion(QString fn) 2238bool CalendarView::checkFileVersion(QString fn)
2232{ 2239{
2233 QFileInfo finf ( fn ); 2240 QFileInfo finf ( fn );
2234 if ( !finf.exists() ) 2241 if ( !finf.exists() )
2235 return true; 2242 return true;
2236 QDateTime dt = finf.lastModified (); 2243 QDateTime dt = finf.lastModified ();
2237 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2244 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2238 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2245 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2239 if ( dt <= loadedFileVersion ) 2246 if ( dt <= loadedFileVersion )
2240 return true; 2247 return true;
2241 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2248 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2242 i18n("KO/Pi Warning"),i18n("Overwrite"), 2249 i18n("KO/Pi Warning"),i18n("Overwrite"),
2243 i18n("Sync+save")); 2250 i18n("Sync+save"));
2244 2251
2245 if ( km == KMessageBox::Cancel ) 2252 if ( km == KMessageBox::Cancel )
2246 return false; 2253 return false;
2247 if ( km == KMessageBox::Yes ) 2254 if ( km == KMessageBox::Yes )
2248 return true; 2255 return true;
2249 2256
2250 setSyncDevice("deleteaftersync" ); 2257 setSyncDevice("deleteaftersync" );
2251 mSyncManager->mAskForPreferences = true; 2258 mSyncManager->mAskForPreferences = true;
2252 mSyncManager->mSyncAlgoPrefs = 3; 2259 mSyncManager->mSyncAlgoPrefs = 3;
2253 mSyncManager->mWriteBackFile = false; 2260 mSyncManager->mWriteBackFile = false;
2254 mSyncManager->mWriteBackExistingOnly = false; 2261 mSyncManager->mWriteBackExistingOnly = false;
2255 mSyncManager->mShowSyncSummary = false; 2262 mSyncManager->mShowSyncSummary = false;
2256 syncCalendar( fn, 3 ); 2263 syncCalendar( fn, 3 );
2257 Event * e = getLastSyncEvent(); 2264 Event * e = getLastSyncEvent();
2258 if ( e ) 2265 if ( e )
2259 mCalendar->deleteEvent( e ); 2266 mCalendar->deleteEvent( e );
2260 return true; 2267 return true;
2261} 2268}
2262bool CalendarView::saveCalendars() 2269bool CalendarView::saveCalendars()
2263{ 2270{
2264 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2271 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2265 KopiCalendarFile * cal = calendars.first(); 2272 KopiCalendarFile * cal = calendars.first();
2266 mCalendar->setDefaultCalendar( 1 ); 2273 mCalendar->setDefaultCalendar( 1 );
2267 mCalendar->setDefaultCalendarEnabledOnly(); 2274 mCalendar->setDefaultCalendarEnabledOnly();
2268 saveCalendar( MainWindow::defaultFileName() ); 2275 saveCalendar( MainWindow::defaultFileName() );
2269 cal = calendars.next(); 2276 cal = calendars.next();
2270 while ( cal ) { 2277 while ( cal ) {
2271 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2278 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2272 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2279 mCalendar->setDefaultCalendar( cal->mCalNumber );
2273 mCalendar->setDefaultCalendarEnabledOnly(); 2280 mCalendar->setDefaultCalendarEnabledOnly();
2274 if ( saveCalendar( cal->mFileName ) ) 2281 if ( saveCalendar( cal->mFileName ) )
2275 cal->mLoadDt = QDateTime::currentDateTime(); 2282 cal->mLoadDt = QDateTime::currentDateTime();
2276 } 2283 }
2277 cal = calendars.next(); 2284 cal = calendars.next();
2278 } 2285 }
2279 restoreCalendarSettings(); 2286 restoreCalendarSettings();
2280 return true; 2287 return true;
2281} 2288}
2282bool CalendarView::saveCalendar( QString filename ) 2289bool CalendarView::saveCalendar( QString filename )
2283{ 2290{
2284 2291
2285 // Store back all unsaved data into calendar object 2292 // Store back all unsaved data into calendar object
2286 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2293 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2287 if ( mViewManager->currentView() ) 2294 if ( mViewManager->currentView() )
2288 mViewManager->currentView()->flushView(); 2295 mViewManager->currentView()->flushView();
2289 2296
2290 2297
2291 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2298 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2292 mStorage->setSaveFormat( new ICalFormat() ); 2299 mStorage->setSaveFormat( new ICalFormat() );
2293 mStorage->setFileName( filename ); 2300 mStorage->setFileName( filename );
2294 bool success; 2301 bool success;
2295 success = mStorage->save(); 2302 success = mStorage->save();
2296 if ( !success ) { 2303 if ( !success ) {
2297 return false; 2304 return false;
2298 } 2305 }
2299 if ( filename == MainWindow::defaultFileName() ) { 2306 if ( filename == MainWindow::defaultFileName() ) {
2300 setLoadedFileVersion( lfv ); 2307 setLoadedFileVersion( lfv );
2301 watchSavedFile(); 2308 watchSavedFile();
2302 } 2309 }
2303 return true; 2310 return true;
2304} 2311}
2305 2312
2306void CalendarView::closeCalendar() 2313void CalendarView::closeCalendar()
2307{ 2314{
2308 2315
2309 // child windows no longer valid 2316 // child windows no longer valid
2310 clearAllViews(); 2317 clearAllViews();
2311 emit closingDown(); 2318 emit closingDown();
2312 2319
2313 mCalendar->close(); 2320 mCalendar->close();
2314 setModified(false); 2321 setModified(false);
2315 updateView(); 2322 updateView();
2316} 2323}
2317 2324
2318void CalendarView::archiveCalendar() 2325void CalendarView::archiveCalendar()
2319{ 2326{
2320 mDialogManager->showArchiveDialog(); 2327 mDialogManager->showArchiveDialog();
2321} 2328}
2322 2329
2323 2330
2324void CalendarView::readSettings() 2331void CalendarView::readSettings()
2325{ 2332{
2326 2333
2327 2334
2328 // mViewManager->showAgendaView(); 2335 // mViewManager->showAgendaView();
2329 QString str; 2336 QString str;
2330 //qDebug("CalendarView::readSettings() "); 2337 //qDebug("CalendarView::readSettings() ");
2331 // read settings from the KConfig, supplying reasonable 2338 // read settings from the KConfig, supplying reasonable
2332 // defaults where none are to be found 2339 // defaults where none are to be found
2333 KConfig *config = KOGlobals::config(); 2340 KConfig *config = KOGlobals::config();
2334#ifndef KORG_NOSPLITTER 2341#ifndef KORG_NOSPLITTER
2335 config->setGroup("KOrganizer Geometry"); 2342 config->setGroup("KOrganizer Geometry");
2336 2343
2337 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2344 QValueList<int> sizes = config->readIntListEntry("Separator1");
2338 if (sizes.count() != 2) { 2345 if (sizes.count() != 2) {
2339 sizes << mDateNavigator->minimumSizeHint().width(); 2346 sizes << mDateNavigator->minimumSizeHint().width();
2340 sizes << 300; 2347 sizes << 300;
2341 } 2348 }
2342 mPanner->setSizes(sizes); 2349 mPanner->setSizes(sizes);
2343 2350
2344 sizes = config->readIntListEntry("Separator2"); 2351 sizes = config->readIntListEntry("Separator2");
2345 if ( ( mResourceView && sizes.count() == 4 ) || 2352 if ( ( mResourceView && sizes.count() == 4 ) ||
2346 ( !mResourceView && sizes.count() == 3 ) ) { 2353 ( !mResourceView && sizes.count() == 3 ) ) {
2347 mLeftSplitter->setSizes(sizes); 2354 mLeftSplitter->setSizes(sizes);
2348 } 2355 }
2349#endif 2356#endif
2350 globalFlagBlockAgenda = 1; 2357 globalFlagBlockAgenda = 1;
2351 mViewManager->showAgendaView(); 2358 mViewManager->showAgendaView();
2352 //mViewManager->readSettings( config ); 2359 //mViewManager->readSettings( config );
2353 mTodoList->restoreLayout(config,QString("Todo Layout")); 2360 mTodoList->restoreLayout(config,QString("Todo Layout"));
2354 readFilterSettings(config); 2361 readFilterSettings(config);
2355 2362
2356#ifdef DESKTOP_VERSION 2363#ifdef DESKTOP_VERSION
2357 config->setGroup("WidgetLayout"); 2364 config->setGroup("WidgetLayout");
2358 QStringList list; 2365 QStringList list;
2359 list = config->readListEntry("MainLayout"); 2366 list = config->readListEntry("MainLayout");
2360 int x,y,w,h; 2367 int x,y,w,h;
2361 if ( ! list.isEmpty() ) { 2368 if ( ! list.isEmpty() ) {
2362 x = list[0].toInt(); 2369 x = list[0].toInt();
2363 y = list[1].toInt(); 2370 y = list[1].toInt();
2364 w = list[2].toInt(); 2371 w = list[2].toInt();
2365 h = list[3].toInt(); 2372 h = list[3].toInt();
2366 KApplication::testCoords( &x,&y,&w,&h ); 2373 KApplication::testCoords( &x,&y,&w,&h );
2367 topLevelWidget()->setGeometry(x,y,w,h); 2374 topLevelWidget()->setGeometry(x,y,w,h);
2368 2375
2369 } else { 2376 } else {
2370 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2377 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2371 } 2378 }
2372 list = config->readListEntry("EditEventLayout"); 2379 list = config->readListEntry("EditEventLayout");
2373 if ( ! list.isEmpty() ) { 2380 if ( ! list.isEmpty() ) {
2374 x = list[0].toInt(); 2381 x = list[0].toInt();
2375 y = list[1].toInt(); 2382 y = list[1].toInt();
2376 w = list[2].toInt(); 2383 w = list[2].toInt();
2377 h = list[3].toInt(); 2384 h = list[3].toInt();
2378 KApplication::testCoords( &x,&y,&w,&h ); 2385 KApplication::testCoords( &x,&y,&w,&h );
2379 mEventEditor->setGeometry(x,y,w,h); 2386 mEventEditor->setGeometry(x,y,w,h);
2380 2387
2381 } 2388 }
2382 list = config->readListEntry("EditTodoLayout"); 2389 list = config->readListEntry("EditTodoLayout");
2383 if ( ! list.isEmpty() ) { 2390 if ( ! list.isEmpty() ) {
2384 x = list[0].toInt(); 2391 x = list[0].toInt();
2385 y = list[1].toInt(); 2392 y = list[1].toInt();
2386 w = list[2].toInt(); 2393 w = list[2].toInt();
2387 h = list[3].toInt(); 2394 h = list[3].toInt();
2388 KApplication::testCoords( &x,&y,&w,&h ); 2395 KApplication::testCoords( &x,&y,&w,&h );
2389 mTodoEditor->setGeometry(x,y,w,h); 2396 mTodoEditor->setGeometry(x,y,w,h);
2390 2397
2391 } 2398 }
2392 list = config->readListEntry("ViewerLayout"); 2399 list = config->readListEntry("ViewerLayout");
2393 if ( ! list.isEmpty() ) { 2400 if ( ! list.isEmpty() ) {
2394 x = list[0].toInt(); 2401 x = list[0].toInt();
2395 y = list[1].toInt(); 2402 y = list[1].toInt();
2396 w = list[2].toInt(); 2403 w = list[2].toInt();
2397 h = list[3].toInt(); 2404 h = list[3].toInt();
2398 KApplication::testCoords( &x,&y,&w,&h ); 2405 KApplication::testCoords( &x,&y,&w,&h );
2399 getEventViewerDialog()->setGeometry(x,y,w,h); 2406 getEventViewerDialog()->setGeometry(x,y,w,h);
2400 } 2407 }
2401#endif 2408#endif
2402 config->setGroup( "Views" ); 2409 config->setGroup( "Views" );
2403 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2410 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2404 2411
2405 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2412 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2406 2413
2407 int resetval = 0; 2414 int resetval = 0;
2408 int maxVal = 0; 2415 int maxVal = 0;
2409 if (sizes.count() != 3) { 2416 if (sizes.count() != 3) {
2410 if ( KOPrefs::instance()->mVerticalScreen ) { 2417 if ( KOPrefs::instance()->mVerticalScreen ) {
2411 resetval = mDateNavigator->sizeHint().width()+2; 2418 resetval = mDateNavigator->sizeHint().width()+2;
2412 } else { 2419 } else {
2413 resetval = mDateNavigator->sizeHint().height()+2; 2420 resetval = mDateNavigator->sizeHint().height()+2;
2414 } 2421 }
2415 } 2422 }
2416 if ( resetval ) { 2423 if ( resetval ) {
2417 sizes.clear(); 2424 sizes.clear();
2418 if ( KOPrefs::instance()->mVerticalScreen ) { 2425 if ( KOPrefs::instance()->mVerticalScreen ) {
2419 maxVal = QApplication::desktop()->width() -10; 2426 maxVal = QApplication::desktop()->width() -10;
2420 } else { 2427 } else {
2421 maxVal = QApplication::desktop()->height()-10; 2428 maxVal = QApplication::desktop()->height()-10;
2422 } 2429 }
2423 sizes << resetval; 2430 sizes << resetval;
2424 if ( maxVal < resetval + resetval) 2431 if ( maxVal < resetval + resetval)
2425 resetval = maxVal - resetval; 2432 resetval = maxVal - resetval;
2426 sizes << resetval; 2433 sizes << resetval;
2427 sizes << 100; 2434 sizes << 100;
2428 } 2435 }
2429 mLeftFrame->setSizes(sizes); 2436 mLeftFrame->setSizes(sizes);
2430 sizes = config->readIntListEntry("Main Splitter Frame"); 2437 sizes = config->readIntListEntry("Main Splitter Frame");
2431 resetval = 0; 2438 resetval = 0;
2432 maxVal = 0; 2439 maxVal = 0;
2433 if (sizes.count() != 2) { 2440 if (sizes.count() != 2) {
2434 if ( !KOPrefs::instance()->mVerticalScreen ) { 2441 if ( !KOPrefs::instance()->mVerticalScreen ) {
2435 resetval = mDateNavigator->sizeHint().width()+2; 2442 resetval = mDateNavigator->sizeHint().width()+2;
2436 } else { 2443 } else {
2437 resetval = mDateNavigator->sizeHint().height()+2; 2444 resetval = mDateNavigator->sizeHint().height()+2;
2438 } 2445 }
2439 } 2446 }
2440 if ( resetval ) { 2447 if ( resetval ) {
2441 sizes.clear(); 2448 sizes.clear();
2442 if ( !KOPrefs::instance()->mVerticalScreen ) { 2449 if ( !KOPrefs::instance()->mVerticalScreen ) {
2443 maxVal = QApplication::desktop()->width() -10; 2450 maxVal = QApplication::desktop()->width() -10;
2444 } else { 2451 } else {
2445 maxVal = QApplication::desktop()->height()-10; 2452 maxVal = QApplication::desktop()->height()-10;
2446 } 2453 }
2447 sizes << resetval; 2454 sizes << resetval;
2448 if ( maxVal < resetval + resetval) 2455 if ( maxVal < resetval + resetval)
2449 resetval = maxVal - resetval; 2456 resetval = maxVal - resetval;
2450 sizes << resetval; 2457 sizes << resetval;
2451 } 2458 }
2452 mMainFrame->setSizes(sizes); 2459 mMainFrame->setSizes(sizes);
2453 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2460 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2454 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2461 else if ( dateCount == 7 ) mNavigator->selectWeek();
2455 else mNavigator->selectDates( dateCount ); 2462 else mNavigator->selectDates( dateCount );
2456 // mViewManager->readSettings( config ); 2463 // mViewManager->readSettings( config );
2457 updateConfig(); 2464 updateConfig();
2458 globalFlagBlockAgenda = 2; 2465 globalFlagBlockAgenda = 2;
2459 mViewManager->readSettings( config ); 2466 mViewManager->readSettings( config );
2460 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2467 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2461} 2468}
2462 2469
2463void CalendarView::checkSuspendAlarm() 2470void CalendarView::checkSuspendAlarm()
2464{ 2471{
2465 if ( mSuspendTimer->isActive() ) { 2472 if ( mSuspendTimer->isActive() ) {
2466 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2473 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2467 } 2474 }
2468} 2475}
2469void CalendarView::writeSettings() 2476void CalendarView::writeSettings()
2470{ 2477{
2471 // kdDebug() << "CalendarView::writeSettings" << endl; 2478 // kdDebug() << "CalendarView::writeSettings" << endl;
2472 2479
2473 KConfig *config = KOGlobals::config(); 2480 KConfig *config = KOGlobals::config();
2474 2481
2475 mViewManager->writeSettings( config ); 2482 mViewManager->writeSettings( config );
2476 mTodoList->saveLayout(config,QString("Todo Layout")); 2483 mTodoList->saveLayout(config,QString("Todo Layout"));
2477 mDialogManager->writeSettings( config ); 2484 mDialogManager->writeSettings( config );
2478 //KOPrefs::instance()->usrWriteConfig(); 2485 //KOPrefs::instance()->usrWriteConfig();
2479 KOPrefs::instance()->writeConfig(); 2486 KOPrefs::instance()->writeConfig();
2480 2487
2481 writeFilterSettings(config); 2488 writeFilterSettings(config);
2482 config->setGroup( "AppRun" ); 2489 config->setGroup( "AppRun" );
2483 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2490 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2484 int days = dt.daysTo( QDate::currentDate() ); 2491 int days = dt.daysTo( QDate::currentDate() );
2485 dt = dt.addDays( days ); 2492 dt = dt.addDays( days );
2486 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2493 int secs = dt.secsTo( QDateTime::currentDateTime() );
2487 config->writeEntry( "LatestProgramStopDays", days ); 2494 config->writeEntry( "LatestProgramStopDays", days );
2488 config->writeEntry( "LatestProgramStopSecs", secs ); 2495 config->writeEntry( "LatestProgramStopSecs", secs );
2489 //qDebug("KO: Writing stop time: %d ", secs); 2496 //qDebug("KO: Writing stop time: %d ", secs);
2490 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2497 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2491 //QDateTime latest = dt.addSecs ( secs ); 2498 //QDateTime latest = dt.addSecs ( secs );
2492 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2499 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2493 config->setGroup( "Views" ); 2500 config->setGroup( "Views" );
2494 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2501 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2495 2502
2496#if 0 2503#if 0
2497 qDebug("********************* "); 2504 qDebug("********************* ");
2498 qDebug("Testcode secsto "); 2505 qDebug("Testcode secsto ");
2499 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2506 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2500 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2507 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2501 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2508 int secsto = dt_nodaylight.secsTo( dt_daylight );
2502 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2509 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2503 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2510 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2504 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2511 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2505 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2512 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2506 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2513 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2507 qDebug("********************* testcode end"); 2514 qDebug("********************* testcode end");
2508 2515
2509#endif 2516#endif
2510 2517
2511 QValueList<int> listINT = mLeftFrame->sizes(); 2518 QValueList<int> listINT = mLeftFrame->sizes();
2512 config->writeEntry("Left Splitter Frame",listINT); 2519 config->writeEntry("Left Splitter Frame",listINT);
2513 QValueList<int> listINT2 = mMainFrame->sizes(); 2520 QValueList<int> listINT2 = mMainFrame->sizes();
2514 config->writeEntry("Main Splitter Frame",listINT2); 2521 config->writeEntry("Main Splitter Frame",listINT2);
2515#ifdef DESKTOP_VERSION 2522#ifdef DESKTOP_VERSION
2516 config->setGroup("WidgetLayout"); 2523 config->setGroup("WidgetLayout");
2517 QStringList list ;//= config->readListEntry("MainLayout"); 2524 QStringList list ;//= config->readListEntry("MainLayout");
2518 int x,y,w,h; 2525 int x,y,w,h;
2519 QWidget* wid; 2526 QWidget* wid;
2520 wid = topLevelWidget(); 2527 wid = topLevelWidget();
2521 x = wid->geometry().x(); 2528 x = wid->geometry().x();
2522 y = wid->geometry().y(); 2529 y = wid->geometry().y();
2523 w = wid->width(); 2530 w = wid->width();
2524 h = wid->height(); 2531 h = wid->height();
2525 list.clear(); 2532 list.clear();
2526 list << QString::number( x ); 2533 list << QString::number( x );
2527 list << QString::number( y ); 2534 list << QString::number( y );
2528 list << QString::number( w ); 2535 list << QString::number( w );
2529 list << QString::number( h ); 2536 list << QString::number( h );
2530 config->writeEntry("MainLayout",list ); 2537 config->writeEntry("MainLayout",list );
2531 2538
2532 wid = mEventEditor; 2539 wid = mEventEditor;
2533 x = wid->geometry().x(); 2540 x = wid->geometry().x();
2534 y = wid->geometry().y(); 2541 y = wid->geometry().y();
2535 w = wid->width(); 2542 w = wid->width();
2536 h = wid->height(); 2543 h = wid->height();
2537 list.clear(); 2544 list.clear();
2538 list << QString::number( x ); 2545 list << QString::number( x );
2539 list << QString::number( y ); 2546 list << QString::number( y );
2540 list << QString::number( w ); 2547 list << QString::number( w );
2541 list << QString::number( h ); 2548 list << QString::number( h );
2542 config->writeEntry("EditEventLayout",list ); 2549 config->writeEntry("EditEventLayout",list );
2543 2550
2544 wid = mTodoEditor; 2551 wid = mTodoEditor;
2545 x = wid->geometry().x(); 2552 x = wid->geometry().x();
2546 y = wid->geometry().y(); 2553 y = wid->geometry().y();
2547 w = wid->width(); 2554 w = wid->width();
2548 h = wid->height(); 2555 h = wid->height();
2549 list.clear(); 2556 list.clear();
2550 list << QString::number( x ); 2557 list << QString::number( x );
2551 list << QString::number( y ); 2558 list << QString::number( y );
2552 list << QString::number( w ); 2559 list << QString::number( w );
2553 list << QString::number( h ); 2560 list << QString::number( h );
2554 config->writeEntry("EditTodoLayout",list ); 2561 config->writeEntry("EditTodoLayout",list );
2555 wid = getEventViewerDialog(); 2562 wid = getEventViewerDialog();
2556 x = wid->geometry().x(); 2563 x = wid->geometry().x();
2557 y = wid->geometry().y(); 2564 y = wid->geometry().y();
2558 w = wid->width(); 2565 w = wid->width();
2559 h = wid->height(); 2566 h = wid->height();
2560 list.clear(); 2567 list.clear();
2561 list << QString::number( x ); 2568 list << QString::number( x );
2562 list << QString::number( y ); 2569 list << QString::number( y );
2563 list << QString::number( w ); 2570 list << QString::number( w );
2564 list << QString::number( h ); 2571 list << QString::number( h );
2565 config->writeEntry("ViewerLayout",list ); 2572 config->writeEntry("ViewerLayout",list );
2566 wid = mDialogManager->getSearchDialog(); 2573 wid = mDialogManager->getSearchDialog();
2567 if ( wid ) { 2574 if ( wid ) {
2568 x = wid->geometry().x(); 2575 x = wid->geometry().x();
2569 y = wid->geometry().y(); 2576 y = wid->geometry().y();
2570 w = wid->width(); 2577 w = wid->width();
2571 h = wid->height(); 2578 h = wid->height();
2572 list.clear(); 2579 list.clear();
2573 list << QString::number( x ); 2580 list << QString::number( x );
2574 list << QString::number( y ); 2581 list << QString::number( y );
2575 list << QString::number( w ); 2582 list << QString::number( w );
2576 list << QString::number( h ); 2583 list << QString::number( h );
2577 config->writeEntry("SearchLayout",list ); 2584 config->writeEntry("SearchLayout",list );
2578 } 2585 }
2579#endif 2586#endif
2580 2587
2581 2588
2582 config->sync(); 2589 config->sync();
2583} 2590}
2584 2591
2585void CalendarView::readFilterSettings(KConfig *config) 2592void CalendarView::readFilterSettings(KConfig *config)
2586{ 2593{
2587 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2594 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2588 2595
2589 mFilters.clear(); 2596 mFilters.clear();
2590 2597
2591 config->setGroup("General"); 2598 config->setGroup("General");
2592 QStringList filterList = config->readListEntry("CalendarFilters"); 2599 QStringList filterList = config->readListEntry("CalendarFilters");
2593 2600
2594 QStringList::ConstIterator it = filterList.begin(); 2601 QStringList::ConstIterator it = filterList.begin();
2595 QStringList::ConstIterator end = filterList.end(); 2602 QStringList::ConstIterator end = filterList.end();
2596 while(it != end) { 2603 while(it != end) {
2597 // kdDebug() << " filter: " << (*it) << endl; 2604 // kdDebug() << " filter: " << (*it) << endl;
2598 2605
2599 CalFilter *filter; 2606 CalFilter *filter;
2600 filter = new CalFilter(*it); 2607 filter = new CalFilter(*it);
2601 config->setGroup("Filter_" + (*it).utf8()); 2608 config->setGroup("Filter_" + (*it).utf8());
2602 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2609 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2603 filter->setCriteria(config->readNumEntry("Criteria",0)); 2610 filter->setCriteria(config->readNumEntry("Criteria",0));
2604 filter->setCategoryList(config->readListEntry("CategoryList")); 2611 filter->setCategoryList(config->readListEntry("CategoryList"));
2605 mFilters.append(filter); 2612 mFilters.append(filter);
2606 2613
2607 ++it; 2614 ++it;
2608 } 2615 }
2609 2616
2610 if (mFilters.count() == 0) { 2617 if (mFilters.count() == 0) {
2611 CalFilter *filter = new CalFilter(i18n("Default")); 2618 CalFilter *filter = new CalFilter(i18n("Default"));
2612 mFilters.append(filter); 2619 mFilters.append(filter);
2613 } 2620 }
2614 mFilterView->updateFilters(); 2621 mFilterView->updateFilters();
2615 config->setGroup("FilterView"); 2622 config->setGroup("FilterView");
2616 2623
2617 mFilterView->blockSignals(true); 2624 mFilterView->blockSignals(true);
2618 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2625 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2619 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2626 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2620 mFilterView->blockSignals(false); 2627 mFilterView->blockSignals(false);
2621 // We do it manually to avoid it being done twice by the above calls 2628 // We do it manually to avoid it being done twice by the above calls
2622 updateFilter(); 2629 updateFilter();
2623} 2630}
2624 2631
2625void CalendarView::writeFilterSettings(KConfig *config) 2632void CalendarView::writeFilterSettings(KConfig *config)
2626{ 2633{
2627 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2634 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2628 2635
2629 QStringList filterList; 2636 QStringList filterList;
2630 2637
2631 CalFilter *filter = mFilters.first(); 2638 CalFilter *filter = mFilters.first();
2632 while(filter) { 2639 while(filter) {
2633 // kdDebug() << " fn: " << filter->name() << endl; 2640 // kdDebug() << " fn: " << filter->name() << endl;
2634 filterList << filter->name(); 2641 filterList << filter->name();
2635 config->setGroup("Filter_" + filter->name().utf8()); 2642 config->setGroup("Filter_" + filter->name().utf8());
2636 config->writeEntry("Criteria",filter->criteria()); 2643 config->writeEntry("Criteria",filter->criteria());
2637 config->writeEntry("CategoryList",filter->categoryList()); 2644 config->writeEntry("CategoryList",filter->categoryList());
2638 filter = mFilters.next(); 2645 filter = mFilters.next();
2639 } 2646 }
2640 config->setGroup("General"); 2647 config->setGroup("General");
2641 config->writeEntry("CalendarFilters",filterList); 2648 config->writeEntry("CalendarFilters",filterList);
2642 2649
2643 config->setGroup("FilterView"); 2650 config->setGroup("FilterView");
2644 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2651 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2645 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2652 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2646} 2653}
2647 2654
2648 2655
2649void CalendarView::goToday() 2656void CalendarView::goToday()
2650{ 2657{
2651 if ( mViewManager->currentView()->isMonthView() ) 2658 if ( mViewManager->currentView()->isMonthView() )
2652 mNavigator->selectTodayMonth(); 2659 mNavigator->selectTodayMonth();
2653 else 2660 else
2654 mNavigator->selectToday(); 2661 mNavigator->selectToday();
2655} 2662}
2656 2663
2657void CalendarView::goNext() 2664void CalendarView::goNext()
2658{ 2665{
2659 mNavigator->selectNext(); 2666 mNavigator->selectNext();
2660} 2667}
2661 2668
2662void CalendarView::goPrevious() 2669void CalendarView::goPrevious()
2663{ 2670{
2664 mNavigator->selectPrevious(); 2671 mNavigator->selectPrevious();
2665} 2672}
2666void CalendarView::goNextMonth() 2673void CalendarView::goNextMonth()
2667{ 2674{
2668 mNavigator->selectNextMonth(); 2675 mNavigator->selectNextMonth();
2669} 2676}
2670 2677
2671void CalendarView::goPreviousMonth() 2678void CalendarView::goPreviousMonth()
2672{ 2679{
2673 mNavigator->selectPreviousMonth(); 2680 mNavigator->selectPreviousMonth();
2674} 2681}
2675 2682
2676void CalendarView::updateConfig() 2683void CalendarView::updateConfig()
2677{ 2684{
2678 if ( KOPrefs::instance()->mUseAppColors ) 2685 if ( KOPrefs::instance()->mUseAppColors )
2679 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2686 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2680 emit configChanged(); 2687 emit configChanged();
2681 mTodoList->updateConfig(); 2688 mTodoList->updateConfig();
2682 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2689 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2683 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2690 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2684 // To make the "fill window" configurations work 2691 // To make the "fill window" configurations work
2685 //mViewManager->raiseCurrentView(); 2692 //mViewManager->raiseCurrentView();
2686} 2693}
2687 2694
2688 2695
2689void CalendarView::eventChanged(Event *event) 2696void CalendarView::eventChanged(Event *event)
2690{ 2697{
2691 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2698 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2692 //updateUnmanagedViews(); 2699 //updateUnmanagedViews();
2693} 2700}
2694 2701
2695void CalendarView::eventAdded(Event *event) 2702void CalendarView::eventAdded(Event *event)
2696{ 2703{
2697 changeEventDisplay(event,KOGlobals::EVENTADDED); 2704 changeEventDisplay(event,KOGlobals::EVENTADDED);
2698} 2705}
2699 2706
2700void CalendarView::eventToBeDeleted(Event *) 2707void CalendarView::eventToBeDeleted(Event *)
2701{ 2708{
2702 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2709 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2703} 2710}
2704 2711
2705void CalendarView::eventDeleted() 2712void CalendarView::eventDeleted()
2706{ 2713{
2707 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2714 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2708} 2715}
2709void CalendarView::changeTodoDisplay(Todo *which, int action) 2716void CalendarView::changeTodoDisplay(Todo *which, int action)
2710{ 2717{
2711 changeIncidenceDisplay((Incidence *)which, action); 2718 changeIncidenceDisplay((Incidence *)which, action);
2712 mDateNavigator->updateView(); //LR 2719 mDateNavigator->updateView(); //LR
2713 //mDialogManager->updateSearchDialog(); 2720 //mDialogManager->updateSearchDialog();
2714 2721
2715 if (which) { 2722 if (which) {
2716 mViewManager->updateWNview(); 2723 mViewManager->updateWNview();
2717 //mTodoList->updateView(); 2724 //mTodoList->updateView();
2718 } 2725 }
2719 2726
2720} 2727}
2721 2728
2722void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2729void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2723{ 2730{
2724 updateUnmanagedViews(); 2731 updateUnmanagedViews();
2725 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2732 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2726 if ( action == KOGlobals::EVENTDELETED ) { //delete 2733 if ( action == KOGlobals::EVENTDELETED ) { //delete
2727 mCalendar->checkAlarmForIncidence( 0, true ); 2734 mCalendar->checkAlarmForIncidence( 0, true );
2728 if ( mEventViewerDialog ) 2735 if ( mEventViewerDialog )
2729 mEventViewerDialog->hide(); 2736 mEventViewerDialog->hide();
2730 } 2737 }
2731 else 2738 else
2732 mCalendar->checkAlarmForIncidence( which , false ); 2739 mCalendar->checkAlarmForIncidence( which , false );
2733} 2740}
2734 2741
2735// most of the changeEventDisplays() right now just call the view's 2742// most of the changeEventDisplays() right now just call the view's
2736// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2743// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2737void CalendarView::changeEventDisplay(Event *which, int action) 2744void CalendarView::changeEventDisplay(Event *which, int action)
2738{ 2745{
2739 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2746 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2740 changeIncidenceDisplay((Incidence *)which, action); 2747 changeIncidenceDisplay((Incidence *)which, action);
2741 static bool clearallviews = false; 2748 static bool clearallviews = false;
2742 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2749 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2743 if ( clearallviews ) { 2750 if ( clearallviews ) {
2744 clearAllViews(); 2751 clearAllViews();
2745 clearallviews = false; 2752 clearallviews = false;
2746 } 2753 }
2747 return; 2754 return;
2748 } 2755 }
2749 clearallviews = true; 2756 clearallviews = true;
2750 mDateNavigator->updateView(); 2757 mDateNavigator->updateView();
2751 //mDialogManager->updateSearchDialog(); 2758 //mDialogManager->updateSearchDialog();
2752 if (which) { 2759 if (which) {
2753 // If there is an event view visible update the display 2760 // If there is an event view visible update the display
2754 mViewManager->currentView()->changeEventDisplay(which,action); 2761 mViewManager->currentView()->changeEventDisplay(which,action);
2755 // TODO: check, if update needed 2762 // TODO: check, if update needed
2756 // if (which->getTodoStatus()) { 2763 // if (which->getTodoStatus()) {
2757 mTodoList->updateView(); 2764 mTodoList->updateView();
2758 if ( action != KOGlobals::EVENTDELETED ) { 2765 if ( action != KOGlobals::EVENTDELETED ) {
2759 mConflictingEvent = which ; 2766 mConflictingEvent = which ;
2760 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); 2767 QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) );
2761 } 2768 }
2762 // } 2769 // }
2763 } else { 2770 } else {
2764 mViewManager->currentView()->updateView(); 2771 mViewManager->currentView()->updateView();
2765 } 2772 }
2766} 2773}
2767void CalendarView::checkConflictForEvent() 2774void CalendarView::checkConflictForEvent()
2768{ 2775{
2769 2776
2770 if (!KOPrefs::instance()->mConfirm) 2777 if (!KOPrefs::instance()->mConfirm)
2771 return; 2778 return;
2772 if ( ! mConflictingEvent ) return; 2779 if ( ! mConflictingEvent ) return;
2773 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 2780 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
2774 QPtrList<Event> testlist = mCalendar->events(); 2781 QPtrList<Event> testlist = mCalendar->events();
2775 Event * test = testlist.first(); 2782 Event * test = testlist.first();
2776 QDateTime conflict; 2783 QDateTime conflict;
2777 QDateTime retVal; 2784 QDateTime retVal;
2778 bool found = false; 2785 bool found = false;
2779 Event * cE = 0; 2786 Event * cE = 0;
2780 QDateTime current = QDateTime::currentDateTime(); 2787 QDateTime current = QDateTime::currentDateTime();
2781 while ( test ) { 2788 while ( test ) {
2782 qApp->processEvents(); 2789 qApp->processEvents();
2783 if ( !test->doesFloat() ) { 2790 if ( !test->doesFloat() ) {
2784 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 2791 if ( mConflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
2785 if ( ! found ) { 2792 if ( ! found ) {
2786 conflict = retVal; 2793 conflict = retVal;
2787 cE = test; 2794 cE = test;
2788 } else { 2795 } else {
2789 if ( retVal < conflict ) { 2796 if ( retVal < conflict ) {
2790 conflict = retVal; 2797 conflict = retVal;
2791 cE = test; 2798 cE = test;
2792 } 2799 }
2793 } 2800 }
2794 found = true; 2801 found = true;
2795 } 2802 }
2796 } 2803 }
2797 test = testlist.next(); 2804 test = testlist.next();
2798 } 2805 }
2799 if ( found ) { 2806 if ( found ) {
2800 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 2807 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
2801 qApp->processEvents(); 2808 qApp->processEvents();
2802 int km = KMessageBox::warningContinueCancel(this,mess, 2809 int km = KMessageBox::warningContinueCancel(this,mess,
2803 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); 2810 i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!"));
2804 if ( km != KMessageBox::Continue ) 2811 if ( km != KMessageBox::Continue )
2805 return; 2812 return;
2806 2813
2807 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 2814 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
2808 mViewManager->showDayView(); 2815 mViewManager->showDayView();
2809 mNavigator->slotDaySelect( conflict.date() ); 2816 mNavigator->slotDaySelect( conflict.date() );
2810 int hour = conflict.time().hour(); 2817 int hour = conflict.time().hour();
2811 mViewManager->agendaView()->setStartHour( hour ); 2818 mViewManager->agendaView()->setStartHour( hour );
2812 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 2819 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
2813 } else 2820 } else
2814 topLevelWidget()->setCaption( i18n("No conflict found") ); 2821 topLevelWidget()->setCaption( i18n("No conflict found") );
2815 mConflictingEvent = 0; 2822 mConflictingEvent = 0;
2816 return; 2823 return;
2817 2824
2818} 2825}
2819 2826
2820void CalendarView::updateTodoViews() 2827void CalendarView::updateTodoViews()
2821{ 2828{
2822 mTodoList->updateView(); 2829 mTodoList->updateView();
2823 mViewManager->currentView()->updateView(); 2830 mViewManager->currentView()->updateView();
2824 2831
2825} 2832}
2826 2833
2827 2834
2828 2835
2829void CalendarView::clearAllViews() 2836void CalendarView::clearAllViews()
2830{ 2837{
2831 mTodoList->clearList(); 2838 mTodoList->clearList();
2832 mViewManager->clearAllViews(); 2839 mViewManager->clearAllViews();
2833 SearchDialog * sd = mDialogManager->getSearchDialog(); 2840 SearchDialog * sd = mDialogManager->getSearchDialog();
2834 if ( sd ) { 2841 if ( sd ) {
2835 KOListView* kol = sd->listview(); 2842 KOListView* kol = sd->listview();
2836 if ( kol ) 2843 if ( kol )
2837 kol->clearList(); 2844 kol->clearList();
2838 } 2845 }
2839} 2846}
2840void CalendarView::updateView() 2847void CalendarView::updateView()
2841{ 2848{
2842 static bool clearallviews = false; 2849 static bool clearallviews = false;
2843 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2850 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2844 if ( clearallviews ) { 2851 if ( clearallviews ) {
2845 clearAllViews(); 2852 clearAllViews();
2846 clearallviews = false; 2853 clearallviews = false;
2847 } 2854 }
2848 return; 2855 return;
2849 } 2856 }
2850 clearallviews = true; 2857 clearallviews = true;
2851 DateList tmpList = mNavigator->selectedDates(); 2858 DateList tmpList = mNavigator->selectedDates();
2852 2859
2853 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2860 if ( KOPrefs::instance()->mHideNonStartedTodos )
2854 mTodoList->updateView(); 2861 mTodoList->updateView();
2855 // We assume that the navigator only selects consecutive days. 2862 // We assume that the navigator only selects consecutive days.
2856 updateView( tmpList.first(), tmpList.last() ); 2863 updateView( tmpList.first(), tmpList.last() );
2857} 2864}
2858 2865
2859void CalendarView::updateUnmanagedViews() 2866void CalendarView::updateUnmanagedViews()
2860{ 2867{
2861 mDateNavigator->updateDayMatrix(); 2868 mDateNavigator->updateDayMatrix();
2862} 2869}
2863 2870
2864int CalendarView::msgItemDelete(const QString name) 2871int CalendarView::msgItemDelete(const QString name)
2865{ 2872{
2866 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2873 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2867 i18n("This item will be\npermanently deleted."), 2874 i18n("This item will be\npermanently deleted."),
2868 i18n("KO/Pi Confirmation"),i18n("Delete")); 2875 i18n("KO/Pi Confirmation"),i18n("Delete"));
2869} 2876}
2870 2877
2871 2878
2872void CalendarView::edit_cut() 2879void CalendarView::edit_cut()
2873{ 2880{
2874 Event *anEvent=0; 2881 Event *anEvent=0;
2875 2882
2876 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2883 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2877 2884
2878 if (mViewManager->currentView()->isEventView()) { 2885 if (mViewManager->currentView()->isEventView()) {
2879 if ( incidence && incidence->typeID() == eventID ) { 2886 if ( incidence && incidence->typeID() == eventID ) {
2880 anEvent = static_cast<Event *>(incidence); 2887 anEvent = static_cast<Event *>(incidence);
2881 } 2888 }
2882 } 2889 }
2883 2890
2884 if (!anEvent) { 2891 if (!anEvent) {
2885 KNotifyClient::beep(); 2892 KNotifyClient::beep();
2886 return; 2893 return;
2887 } 2894 }
2888 DndFactory factory( mCalendar ); 2895 DndFactory factory( mCalendar );
2889 factory.cutIncidence(anEvent); 2896 factory.cutIncidence(anEvent);
2890 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2897 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2891} 2898}
2892 2899
2893void CalendarView::edit_copy() 2900void CalendarView::edit_copy()
2894{ 2901{
2895 Event *anEvent=0; 2902 Event *anEvent=0;
2896 2903
2897 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2904 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2898 2905
2899 if (mViewManager->currentView()->isEventView()) { 2906 if (mViewManager->currentView()->isEventView()) {
2900 if ( incidence && incidence->typeID() == eventID ) { 2907 if ( incidence && incidence->typeID() == eventID ) {
2901 anEvent = static_cast<Event *>(incidence); 2908 anEvent = static_cast<Event *>(incidence);
2902 } 2909 }
2903 } 2910 }
2904 2911
2905 if (!anEvent) { 2912 if (!anEvent) {
2906 KNotifyClient::beep(); 2913 KNotifyClient::beep();
2907 return; 2914 return;
2908 } 2915 }
2909 DndFactory factory( mCalendar ); 2916 DndFactory factory( mCalendar );
2910 factory.copyIncidence(anEvent); 2917 factory.copyIncidence(anEvent);
2911} 2918}
2912 2919
2913void CalendarView::edit_paste() 2920void CalendarView::edit_paste()
2914{ 2921{
2915 QDate date = mNavigator->selectedDates().first(); 2922 QDate date = mNavigator->selectedDates().first();
2916 2923
2917 DndFactory factory( mCalendar ); 2924 DndFactory factory( mCalendar );
2918 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2925 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2919 2926
2920 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2927 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2921} 2928}
2922void CalendarView::edit_global_options() 2929void CalendarView::edit_global_options()
2923{ 2930{
2924 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2931 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2925 emit save(); 2932 emit save();
2926 emit saveStopTimer(); 2933 emit saveStopTimer();
2927 mDialogManager->showGlobalOptionsDialog(); 2934 mDialogManager->showGlobalOptionsDialog();
2928 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2935 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2929 emit saveStopTimer(); 2936 emit saveStopTimer();
2930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2937 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2931 i18n("Timezone settings"),i18n("Reload"))) { 2938 i18n("Timezone settings"),i18n("Reload"))) {
2932 qDebug("KO: TZ reload cancelled "); 2939 qDebug("KO: TZ reload cancelled ");
2933 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2940 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2934 return; 2941 return;
2935 } 2942 }
2936 qDebug("KO: Timezone change "); 2943 qDebug("KO: Timezone change ");
2937 loadCalendars(); 2944 loadCalendars();
2938 setModified(true); 2945 setModified(true);
2939 } 2946 }
2940 else 2947 else
2941 qDebug("KO: No tz change "); 2948 qDebug("KO: No tz change ");
2942} 2949}
2943void CalendarView::edit_options() 2950void CalendarView::edit_options()
2944{ 2951{
2945 mDialogManager->showOptionsDialog(); 2952 mDialogManager->showOptionsDialog();
2946} 2953}
2947 2954
2948 2955
2949void CalendarView::slotSelectPickerDate( QDate d) 2956void CalendarView::slotSelectPickerDate( QDate d)
2950{ 2957{
2951 mDateFrame->hide(); 2958 mDateFrame->hide();
2952 if ( mDatePickerMode == 1 ) { 2959 if ( mDatePickerMode == 1 ) {
2953 mNavigator->slotDaySelect( d ); 2960 mNavigator->slotDaySelect( d );
2954 } else if ( mDatePickerMode == 2 ) { 2961 } else if ( mDatePickerMode == 2 ) {
2955 if ( mMoveIncidence->typeID() == todoID ) { 2962 if ( mMoveIncidence->typeID() == todoID ) {
2956 Todo * to = (Todo *) mMoveIncidence; 2963 Todo * to = (Todo *) mMoveIncidence;
2957 QTime tim; 2964 QTime tim;
2958 int len = 0; 2965 int len = 0;
2959 if ( to->hasStartDate() && to->hasDueDate() ) 2966 if ( to->hasStartDate() && to->hasDueDate() )
2960 len = to->dtStart().secsTo( to->dtDue()); 2967 len = to->dtStart().secsTo( to->dtDue());
2961 if ( to->hasDueDate() ) 2968 if ( to->hasDueDate() )
2962 tim = to->dtDue().time(); 2969 tim = to->dtDue().time();
2963 else { 2970 else {
2964 tim = QTime ( 0,0,0 ); 2971 tim = QTime ( 0,0,0 );
2965 to->setFloats( true ); 2972 to->setFloats( true );
2966 to->setHasDueDate( true ); 2973 to->setHasDueDate( true );
2967 } 2974 }
2968 QDateTime dt ( d,tim ); 2975 QDateTime dt ( d,tim );
2969 to->setDtDue( dt ); 2976 to->setDtDue( dt );
2970 2977
2971 if ( to->hasStartDate() ) { 2978 if ( to->hasStartDate() ) {
2972 if ( len>0 ) 2979 if ( len>0 )
2973 to->setDtStart(to->dtDue().addSecs( -len )); 2980 to->setDtStart(to->dtDue().addSecs( -len ));
2974 else 2981 else
2975 if (to->dtStart() > to->dtDue() ) 2982 if (to->dtStart() > to->dtDue() )
2976 to->setDtStart(to->dtDue().addDays( -3 )); 2983 to->setDtStart(to->dtDue().addDays( -3 ));
2977 } 2984 }
2978 2985
2979 todoChanged( to ); 2986 todoChanged( to );
2980 } else if ( mMoveIncidence->typeID() == eventID ) { 2987 } else if ( mMoveIncidence->typeID() == eventID ) {
2981 if ( mMoveIncidence->doesRecur() ) { 2988 if ( mMoveIncidence->doesRecur() ) {
2982#if 0 2989#if 0
2983 // PENDING implement this 2990 // PENDING implement this
2984 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2991 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2985 mCalendar()->addIncidence( newInc ); 2992 mCalendar()->addIncidence( newInc );
2986 if ( mMoveIncidence->typeID() == todoID ) 2993 if ( mMoveIncidence->typeID() == todoID )
2987 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2994 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2988 else 2995 else
2989 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2996 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2990 mMoveIncidence = newInc; 2997 mMoveIncidence = newInc;
2991 2998
2992#endif 2999#endif
2993 } 3000 }
2994 QTime tim = mMoveIncidence->dtStart().time(); 3001 QTime tim = mMoveIncidence->dtStart().time();
2995 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3002 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2996 QDateTime dt ( d,tim ); 3003 QDateTime dt ( d,tim );
2997 mMoveIncidence->setDtStart( dt ); 3004 mMoveIncidence->setDtStart( dt );
2998 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3005 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2999 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3006 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3000 } else if ( mMoveIncidence->typeID() == journalID ) { 3007 } else if ( mMoveIncidence->typeID() == journalID ) {
3001 QTime tim = mMoveIncidence->dtStart().time(); 3008 QTime tim = mMoveIncidence->dtStart().time();
3002 QDateTime dt ( d,tim ); 3009 QDateTime dt ( d,tim );
3003 mMoveIncidence->setDtStart( dt ); 3010 mMoveIncidence->setDtStart( dt );
3004 updateView(); 3011 updateView();
3005 } 3012 }
3006 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3013 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3007 } 3014 }
3008} 3015}
3009 3016
3010void CalendarView::removeCategories() 3017void CalendarView::removeCategories()
3011{ 3018{
3012 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3019 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3013 QStringList catList = KOPrefs::instance()->mCustomCategories; 3020 QStringList catList = KOPrefs::instance()->mCustomCategories;
3014 QStringList catIncList; 3021 QStringList catIncList;
3015 QStringList newCatList; 3022 QStringList newCatList;
3016 Incidence* inc = incList.first(); 3023 Incidence* inc = incList.first();
3017 uint i; 3024 uint i;
3018 while ( inc ) { 3025 while ( inc ) {
3019 newCatList.clear(); 3026 newCatList.clear();
3020 catIncList = inc->categories() ; 3027 catIncList = inc->categories() ;
3021 for( i = 0; i< catIncList.count(); ++i ) { 3028 for( i = 0; i< catIncList.count(); ++i ) {
3022 if ( catList.contains (catIncList[i])) 3029 if ( catList.contains (catIncList[i]))
3023 newCatList.append( catIncList[i] ); 3030 newCatList.append( catIncList[i] );
3024 } 3031 }
3025 newCatList.sort(); 3032 newCatList.sort();
3026 inc->setCategories( newCatList.join(",") ); 3033 inc->setCategories( newCatList.join(",") );
3027 inc = incList.next(); 3034 inc = incList.next();
3028 } 3035 }
3029} 3036}
3030 3037
3031int CalendarView::addCategories() 3038int CalendarView::addCategories()
3032{ 3039{
3033 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3040 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3034 QStringList catList = KOPrefs::instance()->mCustomCategories; 3041 QStringList catList = KOPrefs::instance()->mCustomCategories;
3035 QStringList catIncList; 3042 QStringList catIncList;
3036 Incidence* inc = incList.first(); 3043 Incidence* inc = incList.first();
3037 uint i; 3044 uint i;
3038 int count = 0; 3045 int count = 0;
3039 while ( inc ) { 3046 while ( inc ) {
3040 catIncList = inc->categories() ; 3047 catIncList = inc->categories() ;
3041 for( i = 0; i< catIncList.count(); ++i ) { 3048 for( i = 0; i< catIncList.count(); ++i ) {
3042 if ( !catList.contains (catIncList[i])) { 3049 if ( !catList.contains (catIncList[i])) {
3043 catList.append( catIncList[i] ); 3050 catList.append( catIncList[i] );
3044 //qDebug("add cat %s ", catIncList[i].latin1()); 3051 //qDebug("add cat %s ", catIncList[i].latin1());
3045 ++count; 3052 ++count;
3046 } 3053 }
3047 } 3054 }
3048 inc = incList.next(); 3055 inc = incList.next();
3049 } 3056 }
3050 catList.sort(); 3057 catList.sort();
3051 KOPrefs::instance()->mCustomCategories = catList; 3058 KOPrefs::instance()->mCustomCategories = catList;
3052 return count; 3059 return count;
3053} 3060}
3054 3061
3055void CalendarView::editCategories() 3062void CalendarView::editCategories()
3056{ 3063{
3057 qDebug("CalendarView::editCategories() "); 3064 qDebug("CalendarView::editCategories() ");
3058 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3065 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3059 ced.exec(); 3066 ced.exec();
3060} 3067}
3061void CalendarView::manageCategories() 3068void CalendarView::manageCategories()
3062{ 3069{
3063 KOCatPrefs* cp = new KOCatPrefs(); 3070 KOCatPrefs* cp = new KOCatPrefs();
3064 cp->show(); 3071 cp->show();
3065 int w =cp->sizeHint().width() ; 3072 int w =cp->sizeHint().width() ;
3066 int h = cp->sizeHint().height() ; 3073 int h = cp->sizeHint().height() ;
3067 int dw = QApplication::desktop()->width(); 3074 int dw = QApplication::desktop()->width();
3068 int dh = QApplication::desktop()->height(); 3075 int dh = QApplication::desktop()->height();
3069 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3076 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3070 if ( !cp->exec() ) { 3077 if ( !cp->exec() ) {
3071 delete cp; 3078 delete cp;
3072 return; 3079 return;
3073 } 3080 }
3074 int count = 0; 3081 int count = 0;
3075 if ( cp->addCat() ) { 3082 if ( cp->addCat() ) {
3076 count = addCategories(); 3083 count = addCategories();
3077 if ( count ) { 3084 if ( count ) {
3078 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3085 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3079 writeSettings(); 3086 writeSettings();
3080 } else 3087 } else
3081 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3088 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3082 } else { 3089 } else {
3083 removeCategories(); 3090 removeCategories();
3084 updateView(); 3091 updateView();
3085 } 3092 }
3086 delete cp; 3093 delete cp;
3087} 3094}
3088 3095
3089void CalendarView::beamIncidence(Incidence * Inc) 3096void CalendarView::beamIncidence(Incidence * Inc)
3090{ 3097{
3091 QPtrList<Incidence> delSel ; 3098 QPtrList<Incidence> delSel ;
3092 delSel.append(Inc); 3099 delSel.append(Inc);
3093 beamIncidenceList( delSel ); 3100 beamIncidenceList( delSel );
3094} 3101}
3095void CalendarView::beamCalendar() 3102void CalendarView::beamCalendar()
3096{ 3103{
3097 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3104 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3098 //qDebug("beamCalendar() "); 3105 //qDebug("beamCalendar() ");
3099 beamIncidenceList( delSel ); 3106 beamIncidenceList( delSel );
3100} 3107}
3101void CalendarView::beamFilteredCalendar() 3108void CalendarView::beamFilteredCalendar()
3102{ 3109{
3103 QPtrList<Incidence> delSel = mCalendar->incidences(); 3110 QPtrList<Incidence> delSel = mCalendar->incidences();
3104 //qDebug("beamFilteredCalendar() "); 3111 //qDebug("beamFilteredCalendar() ");
3105 beamIncidenceList( delSel ); 3112 beamIncidenceList( delSel );
3106} 3113}
3107void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3114void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3108{ 3115{
3109 3116
3110 KOBeamPrefs beamDialog; 3117 KOBeamPrefs beamDialog;
3111 if ( beamDialog.exec () == QDialog::Rejected ) 3118 if ( beamDialog.exec () == QDialog::Rejected )
3112 return; 3119 return;
3113#ifdef DESKTOP_VERSION 3120#ifdef DESKTOP_VERSION
3114 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3121 QString fn = locateLocal( "tmp", "kopibeamfile" );
3115#else 3122#else
3116 QString fn = "/tmp/kopibeamfile"; 3123 QString fn = "/tmp/kopibeamfile";
3117#endif 3124#endif
3118 QString mes; 3125 QString mes;
3119 bool createbup = true; 3126 bool createbup = true;
3120 if ( createbup ) { 3127 if ( createbup ) {
3121 QString description = "\n"; 3128 QString description = "\n";
3122 CalendarLocal* cal = new CalendarLocal(); 3129 CalendarLocal* cal = new CalendarLocal();
3123 if ( beamDialog.beamLocal() ) 3130 if ( beamDialog.beamLocal() )
3124 cal->setLocalTime(); 3131 cal->setLocalTime();
3125 else 3132 else
3126 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3133 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3127 Incidence *incidence = delSel.first(); 3134 Incidence *incidence = delSel.first();
3128 bool addText = false; 3135 bool addText = false;
3129 if ( delSel.count() < 10 ) 3136 if ( delSel.count() < 10 )
3130 addText = true; 3137 addText = true;
3131 else { 3138 else {
3132 description.sprintf(i18n(" %d items?"),delSel.count() ); 3139 description.sprintf(i18n(" %d items?"),delSel.count() );
3133 } 3140 }
3134 while ( incidence ) { 3141 while ( incidence ) {
3135 Incidence *in = incidence->clone(); 3142 Incidence *in = incidence->clone();
3136 if ( ! in->summary().isEmpty() ) { 3143 if ( ! in->summary().isEmpty() ) {
3137 in->setDescription(""); 3144 in->setDescription("");
3138 } else { 3145 } else {
3139 in->setSummary( in->description().left(20)); 3146 in->setSummary( in->description().left(20));
3140 in->setDescription(""); 3147 in->setDescription("");
3141 } 3148 }
3142 if ( addText ) 3149 if ( addText )
3143 description += in->summary() + "\n"; 3150 description += in->summary() + "\n";
3144 cal->addIncidence( in ); 3151 cal->addIncidence( in );
3145 incidence = delSel.next(); 3152 incidence = delSel.next();
3146 } 3153 }
3147 if ( beamDialog.beamVcal() ) { 3154 if ( beamDialog.beamVcal() ) {
3148 fn += ".vcs"; 3155 fn += ".vcs";
3149 FileStorage storage( cal, fn, new VCalFormat ); 3156 FileStorage storage( cal, fn, new VCalFormat );
3150 storage.save(); 3157 storage.save();
3151 } else { 3158 } else {
3152 fn += ".ics"; 3159 fn += ".ics";
3153 FileStorage storage( cal, fn, new ICalFormat( ) ); 3160 FileStorage storage( cal, fn, new ICalFormat( ) );
3154 storage.save(); 3161 storage.save();
3155 } 3162 }
3156 delete cal; 3163 delete cal;
3157 mes = i18n("KO/Pi: Ready for beaming"); 3164 mes = i18n("KO/Pi: Ready for beaming");
3158 topLevelWidget()->setCaption(mes); 3165 topLevelWidget()->setCaption(mes);
3159 KApplication::convert2latin1( fn ); 3166 KApplication::convert2latin1( fn );
3160#ifndef DESKTOP_VERSION 3167#ifndef DESKTOP_VERSION
3161 Ir *ir = new Ir( this ); 3168 Ir *ir = new Ir( this );
3162 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3169 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3163 ir->send( fn, description, "text/x-vCalendar" ); 3170 ir->send( fn, description, "text/x-vCalendar" );
3164#endif 3171#endif
3165 } 3172 }
3166} 3173}
3167 3174
3168#ifndef DESKTOP_VERSION 3175#ifndef DESKTOP_VERSION
3169void CalendarView::beamDone( Ir *ir ) 3176void CalendarView::beamDone( Ir *ir )
3170{ 3177{
3171 delete ir; 3178 delete ir;
3172 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3179 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3173 topLevelWidget()->raise(); 3180 topLevelWidget()->raise();
3174} 3181}
3175#else 3182#else
3176void CalendarView::beamDone( Ir *){;} 3183void CalendarView::beamDone( Ir *){;}
3177#endif 3184#endif
3178void CalendarView::moveIncidence(Incidence * inc ) 3185void CalendarView::moveIncidence(Incidence * inc )
3179{ 3186{
3180 if ( !inc ) return; 3187 if ( !inc ) return;
3181 showDatePickerPopup(); 3188 showDatePickerPopup();
3182 mDatePickerMode = 2; 3189 mDatePickerMode = 2;
3183 mMoveIncidence = inc ; 3190 mMoveIncidence = inc ;
3184 QDate da; 3191 QDate da;
3185 if ( mMoveIncidence->typeID() == todoID ) { 3192 if ( mMoveIncidence->typeID() == todoID ) {
3186 Todo * to = (Todo *) mMoveIncidence; 3193 Todo * to = (Todo *) mMoveIncidence;
3187 if ( to->hasDueDate() ) 3194 if ( to->hasDueDate() )
3188 da = to->dtDue().date(); 3195 da = to->dtDue().date();
3189 else 3196 else
3190 da = QDate::currentDate(); 3197 da = QDate::currentDate();
3191 } else { 3198 } else {
3192 da = mMoveIncidence->dtStart().date(); 3199 da = mMoveIncidence->dtStart().date();
3193 } 3200 }
3194 //PENDING set date for recurring incidence to date of recurrence 3201 //PENDING set date for recurring incidence to date of recurrence
3195 //mMoveIncidenceOldDate; 3202 //mMoveIncidenceOldDate;
3196 mDatePicker->setDate( da ); 3203 mDatePicker->setDate( da );
3197} 3204}
3198void CalendarView::showDatePickerPopup() 3205void CalendarView::showDatePickerPopup()
3199{ 3206{
3200 if ( mDateFrame->isVisible() ) 3207 if ( mDateFrame->isVisible() )
3201 mDateFrame->hide(); 3208 mDateFrame->hide();
3202 else { 3209 else {
3203 int offX = 0, offY = 0; 3210 int offX = 0, offY = 0;
3204#ifdef DESKTOP_VERSION 3211#ifdef DESKTOP_VERSION
3205 int w =mDatePicker->sizeHint().width() ; 3212 int w =mDatePicker->sizeHint().width() ;
3206 int h = mDatePicker->sizeHint().height() ; 3213 int h = mDatePicker->sizeHint().height() ;
3207 int dw = topLevelWidget()->width(); 3214 int dw = topLevelWidget()->width();
3208 int dh = topLevelWidget()->height(); 3215 int dh = topLevelWidget()->height();
3209 offX = topLevelWidget()->x(); 3216 offX = topLevelWidget()->x();
3210 offY = topLevelWidget()->y(); 3217 offY = topLevelWidget()->y();
3211#else 3218#else
3212 int w =mDatePicker->sizeHint().width() ; 3219 int w =mDatePicker->sizeHint().width() ;
3213 int h = mDatePicker->sizeHint().height() ; 3220 int h = mDatePicker->sizeHint().height() ;
3214 int dw = QApplication::desktop()->width(); 3221 int dw = QApplication::desktop()->width();
3215 int dh = QApplication::desktop()->height(); 3222 int dh = QApplication::desktop()->height();
3216#endif 3223#endif
3217 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3224 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3218 mDateFrame->show(); 3225 mDateFrame->show();
3219 } 3226 }
3220} 3227}
3221void CalendarView::showDatePicker( ) 3228void CalendarView::showDatePicker( )
3222{ 3229{
3223 showDatePickerPopup(); 3230 showDatePickerPopup();
3224 mDatePickerMode = 1; 3231 mDatePickerMode = 1;
3225 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3232 mDatePicker->setDate( mNavigator->selectedDates().first() );
3226} 3233}
3227 3234
3228void CalendarView::showEventEditor() 3235void CalendarView::showEventEditor()
3229{ 3236{
3230#ifdef DESKTOP_VERSION 3237#ifdef DESKTOP_VERSION
3231 int x,y,w,h; 3238 int x,y,w,h;
3232 x = mEventEditor->geometry().x(); 3239 x = mEventEditor->geometry().x();
3233 y = mEventEditor->geometry().y(); 3240 y = mEventEditor->geometry().y();
3234 w = mEventEditor->width(); 3241 w = mEventEditor->width();
3235 h = mEventEditor->height(); 3242 h = mEventEditor->height();
3236 mEventEditor->show(); 3243 mEventEditor->show();
3237 mEventEditor->setGeometry(x,y,w,h); 3244 mEventEditor->setGeometry(x,y,w,h);
3238#else 3245#else
3239 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3246 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3240 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3247 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3241 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3248 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3242 qApp->processEvents(); 3249 qApp->processEvents();
3243 delete mEventEditor; 3250 delete mEventEditor;
3244 mEventEditor = mDialogManager->getEventEditor(); 3251 mEventEditor = mDialogManager->getEventEditor();
3245 topLevelWidget()->setCaption( i18n("") ); 3252 topLevelWidget()->setCaption( i18n("") );
3246 } 3253 }
3247 mEventEditor->showMaximized(); 3254 mEventEditor->showMaximized();
3248#endif 3255#endif
3249} 3256}
3250void CalendarView::showTodoEditor() 3257void CalendarView::showTodoEditor()
3251{ 3258{
3252#ifdef DESKTOP_VERSION 3259#ifdef DESKTOP_VERSION
3253 int x,y,w,h; 3260 int x,y,w,h;
3254 x = mTodoEditor->geometry().x(); 3261 x = mTodoEditor->geometry().x();
3255 y = mTodoEditor->geometry().y(); 3262 y = mTodoEditor->geometry().y();
3256 w = mTodoEditor->width(); 3263 w = mTodoEditor->width();
3257 h = mTodoEditor->height(); 3264 h = mTodoEditor->height();
3258 mTodoEditor->show(); 3265 mTodoEditor->show();
3259 mTodoEditor->setGeometry(x,y,w,h); 3266 mTodoEditor->setGeometry(x,y,w,h);
3260#else 3267#else
3261 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3268 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3262 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3269 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3263 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3270 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3264 qApp->processEvents(); 3271 qApp->processEvents();
3265 delete mTodoEditor; 3272 delete mTodoEditor;
3266 mTodoEditor = mDialogManager->getTodoEditor(); 3273 mTodoEditor = mDialogManager->getTodoEditor();
3267 topLevelWidget()->setCaption( i18n("") ); 3274 topLevelWidget()->setCaption( i18n("") );
3268 } 3275 }
3269 mTodoEditor->showMaximized(); 3276 mTodoEditor->showMaximized();
3270#endif 3277#endif
3271} 3278}
3272 3279
3273void CalendarView::cloneIncidence() 3280void CalendarView::cloneIncidence()
3274{ 3281{
3275 Incidence *incidence = currentSelection(); 3282 Incidence *incidence = currentSelection();
3276 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3283 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3277 if ( incidence ) { 3284 if ( incidence ) {
3278 cloneIncidence(incidence); 3285 cloneIncidence(incidence);
3279 } 3286 }
3280} 3287}
3281void CalendarView::moveIncidence() 3288void CalendarView::moveIncidence()
3282{ 3289{
3283 Incidence *incidence = currentSelection(); 3290 Incidence *incidence = currentSelection();
3284 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3291 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3285 if ( incidence ) { 3292 if ( incidence ) {
3286 moveIncidence(incidence); 3293 moveIncidence(incidence);
3287 } 3294 }
3288} 3295}
3289void CalendarView::beamIncidence() 3296void CalendarView::beamIncidence()
3290{ 3297{
3291 Incidence *incidence = currentSelection(); 3298 Incidence *incidence = currentSelection();
3292 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3299 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3293 if ( incidence ) { 3300 if ( incidence ) {
3294 beamIncidence(incidence); 3301 beamIncidence(incidence);
3295 } 3302 }
3296} 3303}
3297void CalendarView::toggleCancelIncidence() 3304void CalendarView::toggleCancelIncidence()
3298{ 3305{
3299 Incidence *incidence = currentSelection(); 3306 Incidence *incidence = currentSelection();
3300 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3307 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3301 if ( incidence ) { 3308 if ( incidence ) {
3302 cancelIncidence(incidence); 3309 cancelIncidence(incidence);
3303 } 3310 }
3304} 3311}
3305 3312
3306 3313
3307void CalendarView::cancelIncidence(Incidence * inc ) 3314void CalendarView::cancelIncidence(Incidence * inc )
3308{ 3315{
3309 inc->setCancelled( ! inc->cancelled() ); 3316 inc->setCancelled( ! inc->cancelled() );
3310 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3317 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3311 updateView(); 3318 updateView();
3312} 3319}
3313void CalendarView::cloneIncidence(Incidence * orgInc ) 3320void CalendarView::cloneIncidence(Incidence * orgInc )
3314{ 3321{
3315 Incidence * newInc = orgInc->clone(); 3322 Incidence * newInc = orgInc->clone();
3316 newInc->recreate(); 3323 newInc->recreate();
3317 3324
3318 if ( newInc->typeID() == todoID ) { 3325 if ( newInc->typeID() == todoID ) {
3319 Todo* t = (Todo*) newInc; 3326 Todo* t = (Todo*) newInc;
3320 bool cloneSub = false; 3327 bool cloneSub = false;
3321 if ( orgInc->relations().count() ) { 3328 if ( orgInc->relations().count() ) {
3322 int result = KMessageBox::warningYesNoCancel(this, 3329 int result = KMessageBox::warningYesNoCancel(this,
3323 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), 3330 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
3324 i18n("Todo has subtodos"), 3331 i18n("Todo has subtodos"),
3325 i18n("Yes"), 3332 i18n("Yes"),
3326 i18n("No")); 3333 i18n("No"));
3327 3334
3328 if ( result == KMessageBox::Cancel ) { 3335 if ( result == KMessageBox::Cancel ) {
3329 delete t; 3336 delete t;
3330 return; 3337 return;
3331 } 3338 }
3332 if (result == KMessageBox::Yes) cloneSub = true; 3339 if (result == KMessageBox::Yes) cloneSub = true;
3333 } 3340 }
3334 showTodoEditor(); 3341 showTodoEditor();
3335 mTodoEditor->editTodo( t ); 3342 mTodoEditor->editTodo( t );
3336 if ( mTodoEditor->exec() ) { 3343 if ( mTodoEditor->exec() ) {
3337 if ( cloneSub ) { 3344 if ( cloneSub ) {
3338 orgInc->cloneRelations( t ); 3345 orgInc->cloneRelations( t );
3339 mCalendar->addIncidenceBranch( t ); 3346 mCalendar->addIncidenceBranch( t );
3340 updateView(); 3347 updateView();
3341 3348
3342 } else { 3349 } else {
3343 mCalendar->addTodo( t ); 3350 mCalendar->addTodo( t );
3344 updateView(); 3351 updateView();
3345 } 3352 }
3346 } else { 3353 } else {
3347 delete t; 3354 delete t;
3348 } 3355 }
3349 } 3356 }
3350 else if ( newInc->typeID() == eventID ) { 3357 else if ( newInc->typeID() == eventID ) {
3351 Event* e = (Event*) newInc; 3358 Event* e = (Event*) newInc;
3352 showEventEditor(); 3359 showEventEditor();
3353 mEventEditor->editEvent( e ); 3360 mEventEditor->editEvent( e );
3354 if ( mEventEditor->exec() ) { 3361 if ( mEventEditor->exec() ) {
3355 mCalendar->addEvent( e ); 3362 mCalendar->addEvent( e );
3356 updateView(); 3363 updateView();
3357 } else { 3364 } else {
3358 delete e; 3365 delete e;
3359 } 3366 }
3360 } if ( newInc->typeID() == journalID ) { 3367 } if ( newInc->typeID() == journalID ) {
3361 mCalendar->addJournal( (Journal*) newInc ); 3368 mCalendar->addJournal( (Journal*) newInc );
3362 editJournal( (Journal*) newInc ); 3369 editJournal( (Journal*) newInc );
3363 } 3370 }
3364 setActiveWindow(); 3371 setActiveWindow();
3365} 3372}
3366 3373
3367void CalendarView::newEvent() 3374void CalendarView::newEvent()
3368{ 3375{
3369 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3376 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3370 KOAgendaView *aView = mViewManager->agendaView(); 3377 KOAgendaView *aView = mViewManager->agendaView();
3371 if (aView) { 3378 if (aView) {
3372 if (aView->selectionStart().isValid()) { 3379 if (aView->selectionStart().isValid()) {
3373 if (aView->selectedIsAllDay()) { 3380 if (aView->selectedIsAllDay()) {
3374 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3381 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3375 } else { 3382 } else {
3376 newEvent(aView->selectionStart(),aView->selectionEnd()); 3383 newEvent(aView->selectionStart(),aView->selectionEnd());
3377 } 3384 }
3378 return; 3385 return;
3379 } 3386 }
3380 } 3387 }
3381 3388
3382 QDate date = mNavigator->selectedDates().first(); 3389 QDate date = mNavigator->selectedDates().first();
3383#if 0 3390#if 0
3384 QDateTime current = QDateTime::currentDateTime(); 3391 QDateTime current = QDateTime::currentDateTime();
3385 if ( date <= current.date() ) { 3392 if ( date <= current.date() ) {
3386 int hour = current.time().hour() +1; 3393 int hour = current.time().hour() +1;
3387 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3394 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3388 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3395 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3389 } else 3396 } else
3390#endif 3397#endif
3391 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3398 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3392 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3399 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3393 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3400 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3394} 3401}
3395 3402
3396void CalendarView::newEvent(QDateTime fh) 3403void CalendarView::newEvent(QDateTime fh)
3397{ 3404{
3398 newEvent(fh, 3405 newEvent(fh,
3399 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3406 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3400} 3407}
3401 3408
3402void CalendarView::newEvent(QDate dt) 3409void CalendarView::newEvent(QDate dt)
3403{ 3410{
3404 newEvent(QDateTime(dt, QTime(0,0,0)), 3411 newEvent(QDateTime(dt, QTime(0,0,0)),
3405 QDateTime(dt, QTime(0,0,0)), true); 3412 QDateTime(dt, QTime(0,0,0)), true);
3406} 3413}
3407void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3414void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3408{ 3415{
3409 newEvent(fromHint, toHint, false); 3416 newEvent(fromHint, toHint, false);
3410} 3417}
3411void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3418void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3412{ 3419{
3413 3420
3414 showEventEditor(); 3421 showEventEditor();
3415 mEventEditor->newEvent(fromHint,toHint,allDay); 3422 mEventEditor->newEvent(fromHint,toHint,allDay);
3416 if ( mFilterView->filtersEnabled() ) { 3423 if ( mFilterView->filtersEnabled() ) {
3417 CalFilter *filter = mFilterView->selectedFilter(); 3424 CalFilter *filter = mFilterView->selectedFilter();
3418 if (filter && filter->showCategories()) { 3425 if (filter && filter->showCategories()) {
3419 mEventEditor->setCategories(filter->categoryList().join(",") ); 3426 mEventEditor->setCategories(filter->categoryList().join(",") );
3420 } 3427 }
3421 if ( filter ) 3428 if ( filter )
3422 mEventEditor->setSecrecy( filter->getSecrecy() ); 3429 mEventEditor->setSecrecy( filter->getSecrecy() );
3423 } 3430 }
3424 mEventEditor->exec(); 3431 mEventEditor->exec();
3425 setActiveWindow(); 3432 setActiveWindow();
3426} 3433}
3427void CalendarView::todoAdded(Todo * t) 3434void CalendarView::todoAdded(Todo * t)
3428{ 3435{
3429 3436
3430 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3437 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3431 updateTodoViews(); 3438 updateTodoViews();
3432} 3439}
3433void CalendarView::todoChanged(Todo * t) 3440void CalendarView::todoChanged(Todo * t)
3434{ 3441{
3435 emit todoModified( t, 4 ); 3442 emit todoModified( t, 4 );
3436 // updateTodoViews(); 3443 // updateTodoViews();
3437} 3444}
3438void CalendarView::todoToBeDeleted(Todo *) 3445void CalendarView::todoToBeDeleted(Todo *)
3439{ 3446{
3440 //qDebug("todoToBeDeleted(Todo *) "); 3447 //qDebug("todoToBeDeleted(Todo *) ");
3441 updateTodoViews(); 3448 updateTodoViews();
3442} 3449}
3443void CalendarView::todoDeleted() 3450void CalendarView::todoDeleted()
3444{ 3451{
3445 //qDebug(" todoDeleted()"); 3452 //qDebug(" todoDeleted()");
3446 updateTodoViews(); 3453 updateTodoViews();
3447} 3454}
3448 3455
3449 3456
3450void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3457void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3451{ 3458{
3452 showTodoEditor(); 3459 showTodoEditor();
3453 mTodoEditor->newTodo(dt,0,allday); 3460 mTodoEditor->newTodo(dt,0,allday);
3454 if ( mFilterView->filtersEnabled() ) { 3461 if ( mFilterView->filtersEnabled() ) {
3455 CalFilter *filter = mFilterView->selectedFilter(); 3462 CalFilter *filter = mFilterView->selectedFilter();
3456 if (filter && filter->showCategories()) { 3463 if (filter && filter->showCategories()) {
3457 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3464 mTodoEditor->setCategories(filter->categoryList().join(",") );
3458 } 3465 }
3459 if ( filter ) 3466 if ( filter )
3460 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3467 mTodoEditor->setSecrecy( filter->getSecrecy() );
3461 } 3468 }
3462 mTodoEditor->exec(); 3469 mTodoEditor->exec();
3463 setActiveWindow(); 3470 setActiveWindow();
3464} 3471}
3465 3472
3466void CalendarView::newTodo() 3473void CalendarView::newTodo()
3467{ 3474{
3468 newTodoDateTime( QDateTime(),true ); 3475 newTodoDateTime( QDateTime(),true );
3469} 3476}
3470 3477
3471void CalendarView::newSubTodo() 3478void CalendarView::newSubTodo()
3472{ 3479{
3473 Todo *todo = selectedTodo(); 3480 Todo *todo = selectedTodo();
3474 if ( todo ) newSubTodo( todo ); 3481 if ( todo ) newSubTodo( todo );
3475} 3482}
3476 3483
3477void CalendarView::newSubTodo(Todo *parentEvent) 3484void CalendarView::newSubTodo(Todo *parentEvent)
3478{ 3485{
3479 3486
3480 showTodoEditor(); 3487 showTodoEditor();
3481 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3488 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3482 mTodoEditor->exec(); 3489 mTodoEditor->exec();
3483 setActiveWindow(); 3490 setActiveWindow();
3484} 3491}
3485 3492
3486void CalendarView::newFloatingEvent() 3493void CalendarView::newFloatingEvent()
3487{ 3494{
3488 DateList tmpList = mNavigator->selectedDates(); 3495 DateList tmpList = mNavigator->selectedDates();
3489 QDate date = tmpList.first(); 3496 QDate date = tmpList.first();
3490 3497
3491 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3498 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3492 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3499 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3493} 3500}
3494 3501
3495 3502
3496void CalendarView::editEvent( Event *event ) 3503void CalendarView::editEvent( Event *event )
3497{ 3504{
3498 3505
3499 if ( !event ) return; 3506 if ( !event ) return;
3500 if ( event->isReadOnly() ) { 3507 if ( event->isReadOnly() ) {
3501 showEvent( event ); 3508 showEvent( event );
3502 return; 3509 return;
3503 } 3510 }
3504 showEventEditor(); 3511 showEventEditor();
3505 mEventEditor->editEvent( event , mFlagEditDescription); 3512 mEventEditor->editEvent( event , mFlagEditDescription);
3506 mEventEditor->exec(); 3513 mEventEditor->exec();
3507 setActiveWindow(); 3514 setActiveWindow();
3508 3515
3509} 3516}
3510void CalendarView::editJournal( Journal *jour ) 3517void CalendarView::editJournal( Journal *jour )
3511{ 3518{
3512 if ( !jour ) return; 3519 if ( !jour ) return;
3513 mDialogManager->hideSearchDialog(); 3520 mDialogManager->hideSearchDialog();
3514 mViewManager->showJournalView(); 3521 mViewManager->showJournalView();
3515 mNavigator->slotDaySelect( jour->dtStart().date() ); 3522 mNavigator->slotDaySelect( jour->dtStart().date() );
3516} 3523}
3517void CalendarView::editTodo( Todo *todo ) 3524void CalendarView::editTodo( Todo *todo )
3518{ 3525{
3519 if ( !todo ) return; 3526 if ( !todo ) return;
3520 3527
3521 if ( todo->isReadOnly() ) { 3528 if ( todo->isReadOnly() ) {
3522 showTodo( todo ); 3529 showTodo( todo );
3523 return; 3530 return;
3524 } 3531 }
3525 showTodoEditor(); 3532 showTodoEditor();
3526 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3533 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3527 mTodoEditor->exec(); 3534 mTodoEditor->exec();
3528 setActiveWindow(); 3535 setActiveWindow();
3529 3536
3530} 3537}
3531 3538
3532KOEventViewerDialog* CalendarView::getEventViewerDialog() 3539KOEventViewerDialog* CalendarView::getEventViewerDialog()
3533{ 3540{
3534 if ( !mEventViewerDialog ) { 3541 if ( !mEventViewerDialog ) {
3535 mEventViewerDialog = new KOEventViewerDialog(0); 3542 mEventViewerDialog = new KOEventViewerDialog(0);
3536 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3543 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3537 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3544 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3538 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3545 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3539 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3546 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3540 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3547 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3541 viewManager(), SLOT( showAgendaView( bool ) ) ); 3548 viewManager(), SLOT( showAgendaView( bool ) ) );
3542 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3549 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3543 this, SLOT( slotViewerClosed() ) ); 3550 this, SLOT( slotViewerClosed() ) );
3544 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3551 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3545 this, SLOT( todoChanged(Todo *) ) ); 3552 this, SLOT( todoChanged(Todo *) ) );
3546 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3553 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3547 mEventViewerDialog->resize( 640, 480 ); 3554 mEventViewerDialog->resize( 640, 480 );
3548 3555
3549 } 3556 }
3550 return mEventViewerDialog; 3557 return mEventViewerDialog;
3551} 3558}
3552void CalendarView::showEvent(Event *event) 3559void CalendarView::showEvent(Event *event)
3553{ 3560{
3554 getEventViewerDialog()->setEvent(event); 3561 getEventViewerDialog()->setEvent(event);
3555 getEventViewerDialog()->showMe(); 3562 getEventViewerDialog()->showMe();
3556} 3563}
3557 3564
3558void CalendarView::showTodo(Todo *event) 3565void CalendarView::showTodo(Todo *event)
3559{ 3566{
3560 getEventViewerDialog()->setTodo(event); 3567 getEventViewerDialog()->setTodo(event);
3561 getEventViewerDialog()->showMe(); 3568 getEventViewerDialog()->showMe();
3562} 3569}
3563void CalendarView::showJournal( Journal *jour ) 3570void CalendarView::showJournal( Journal *jour )
3564{ 3571{
3565 getEventViewerDialog()->setJournal(jour); 3572 getEventViewerDialog()->setJournal(jour);
3566 getEventViewerDialog()->showMe(); 3573 getEventViewerDialog()->showMe();
3567 3574
3568} 3575}
3569// void CalendarView::todoModified (Todo *event, int changed) 3576// void CalendarView::todoModified (Todo *event, int changed)
3570// { 3577// {
3571// // if (mDialogList.find (event) != mDialogList.end ()) { 3578// // if (mDialogList.find (event) != mDialogList.end ()) {
3572// // kdDebug() << "Todo modified and open" << endl; 3579// // kdDebug() << "Todo modified and open" << endl;
3573// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3580// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3574// // temp->modified (changed); 3581// // temp->modified (changed);
3575 3582
3576// // } 3583// // }
3577 3584
3578// mViewManager->updateView(); 3585// mViewManager->updateView();
3579// } 3586// }
3580 3587
3581void CalendarView::appointment_show() 3588void CalendarView::appointment_show()
3582{ 3589{
3583 Event *anEvent = 0; 3590 Event *anEvent = 0;
3584 3591
3585 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3592 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3586 3593
3587 if (mViewManager->currentView()->isEventView()) { 3594 if (mViewManager->currentView()->isEventView()) {
3588 if ( incidence && incidence->typeID() == eventID ) { 3595 if ( incidence && incidence->typeID() == eventID ) {
3589 anEvent = static_cast<Event *>(incidence); 3596 anEvent = static_cast<Event *>(incidence);
3590 } 3597 }
3591 } 3598 }
3592 3599
3593 if (!anEvent) { 3600 if (!anEvent) {
3594 KNotifyClient::beep(); 3601 KNotifyClient::beep();
3595 return; 3602 return;
3596 } 3603 }
3597 3604
3598 showEvent(anEvent); 3605 showEvent(anEvent);
3599} 3606}
3600 3607
3601void CalendarView::appointment_edit() 3608void CalendarView::appointment_edit()
3602{ 3609{
3603 Event *anEvent = 0; 3610 Event *anEvent = 0;
3604 3611
3605 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3612 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3606 3613
3607 if (mViewManager->currentView()->isEventView()) { 3614 if (mViewManager->currentView()->isEventView()) {
3608 if ( incidence && incidence->typeID() == eventID ) { 3615 if ( incidence && incidence->typeID() == eventID ) {
3609 anEvent = static_cast<Event *>(incidence); 3616 anEvent = static_cast<Event *>(incidence);
3610 } 3617 }
3611 } 3618 }
3612 3619
3613 if (!anEvent) { 3620 if (!anEvent) {
3614 KNotifyClient::beep(); 3621 KNotifyClient::beep();
3615 return; 3622 return;
3616 } 3623 }
3617 3624
3618 editEvent(anEvent); 3625 editEvent(anEvent);
3619} 3626}
3620 3627
3621void CalendarView::appointment_delete() 3628void CalendarView::appointment_delete()
3622{ 3629{
3623 Event *anEvent = 0; 3630 Event *anEvent = 0;
3624 3631
3625 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3632 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3626 3633
3627 if (mViewManager->currentView()->isEventView()) { 3634 if (mViewManager->currentView()->isEventView()) {
3628 if ( incidence && incidence->typeID() == eventID ) { 3635 if ( incidence && incidence->typeID() == eventID ) {
3629 anEvent = static_cast<Event *>(incidence); 3636 anEvent = static_cast<Event *>(incidence);
3630 } 3637 }
3631 } 3638 }
3632 3639
3633 if (!anEvent) { 3640 if (!anEvent) {
3634 KNotifyClient::beep(); 3641 KNotifyClient::beep();
3635 return; 3642 return;
3636 } 3643 }
3637 3644
3638 deleteEvent(anEvent); 3645 deleteEvent(anEvent);
3639} 3646}
3640 3647
3641void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3648void CalendarView::todo_resub( Todo * parent, Todo * sub )
3642{ 3649{
3643 if (!sub) return; 3650 if (!sub) return;
3644 if ( sub->relatedTo() == parent ) 3651 if ( sub->relatedTo() == parent )
3645 return; 3652 return;
3646 sub->setRelatedTo(parent); 3653 sub->setRelatedTo(parent);
3647 sub->updated(); 3654 sub->updated();
3648 setModified(true); 3655 setModified(true);
3649 updateView(); 3656 updateView();
3650} 3657}
3651void CalendarView::todo_unsub(Todo *anTodo ) 3658void CalendarView::todo_unsub(Todo *anTodo )
3652{ 3659{
3653 todo_resub( 0, anTodo ); 3660 todo_resub( 0, anTodo );
3654} 3661}
3655 3662
3656void CalendarView::deleteTodo(Todo *todo) 3663void CalendarView::deleteTodo(Todo *todo)
3657{ 3664{
3658 if (!todo) { 3665 if (!todo) {
3659 KNotifyClient::beep(); 3666 KNotifyClient::beep();
3660 return; 3667 return;
3661 } 3668 }
3662 if (KOPrefs::instance()->mConfirm) { 3669 if (KOPrefs::instance()->mConfirm) {
3663 QString text = KGlobal::formatMessage ( todo->summary(),0 ); 3670 QString text = KGlobal::formatMessage ( todo->summary(),0 );
3664 if (!todo->relations().isEmpty()) { 3671 if (!todo->relations().isEmpty()) {
3665 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3672 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3666 3673
3667 } 3674 }
3668 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { 3675 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
3669 case KMessageBox::Continue: // OK 3676 case KMessageBox::Continue: // OK
3670 bool deleteT = false; 3677 bool deleteT = false;
3671 if (!todo->relations().isEmpty()) { 3678 if (!todo->relations().isEmpty()) {
3672 deleteT = removeCompletedSubTodos( todo ); 3679 deleteT = removeCompletedSubTodos( todo );
3673 } 3680 }
3674 // deleteT == true: todo already deleted in removeCompletedSubTodos 3681 // deleteT == true: todo already deleted in removeCompletedSubTodos
3675 if ( !deleteT ) { 3682 if ( !deleteT ) {
3676 checkExternalId( todo ); 3683 checkExternalId( todo );
3677 calendar()->deleteTodo(todo); 3684 calendar()->deleteTodo(todo);
3678 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3685 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3679 updateView(); 3686 updateView();
3680 } 3687 }
3681 break; 3688 break;
3682 } // switch 3689 } // switch
3683 } else { 3690 } else {
3684 checkExternalId( todo ); 3691 checkExternalId( todo );
3685 mCalendar->deleteTodo(todo); 3692 mCalendar->deleteTodo(todo);
3686 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3693 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3687 updateView(); 3694 updateView();
3688 } 3695 }
3689 3696
3690 emit updateSearchDialog(); 3697 emit updateSearchDialog();
3691} 3698}
3692void CalendarView::deleteJournal(Journal *jour) 3699void CalendarView::deleteJournal(Journal *jour)
3693{ 3700{
3694 if (!jour) { 3701 if (!jour) {
3695 KNotifyClient::beep(); 3702 KNotifyClient::beep();
3696 return; 3703 return;
3697 } 3704 }
3698 if (KOPrefs::instance()->mConfirm) { 3705 if (KOPrefs::instance()->mConfirm) {
3699 3706
3700 QString des; 3707 QString des;
3701 if ( !jour->summary().isEmpty() ) { 3708 if ( !jour->summary().isEmpty() ) {
3702 des = jour->summary(); 3709 des = jour->summary();
3703 } else { 3710 } else {
3704 des = jour->description().left(30); 3711 des = jour->description().left(30);
3705 des = des.simplifyWhiteSpace (); 3712 des = des.simplifyWhiteSpace ();
3706 des.replace (QRegExp ("\\n"),"" ); 3713 des.replace (QRegExp ("\\n"),"" );
3707 des.replace (QRegExp ("\\r"),"" ); 3714 des.replace (QRegExp ("\\r"),"" );
3708 } 3715 }
3709 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { 3716 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
3710 case KMessageBox::Continue: // OK 3717 case KMessageBox::Continue: // OK
3711 calendar()->deleteJournal(jour); 3718 calendar()->deleteJournal(jour);
3712 updateView(); 3719 updateView();
3713 break; 3720 break;
3714 } // switch 3721 } // switch
3715 } else { 3722 } else {
3716 calendar()->deleteJournal(jour);; 3723 calendar()->deleteJournal(jour);;
3717 updateView(); 3724 updateView();
3718 } 3725 }
3719 emit updateSearchDialog(); 3726 emit updateSearchDialog();
3720} 3727}
3721 3728
3722void CalendarView::deleteEvent(Event *anEvent) 3729void CalendarView::deleteEvent(Event *anEvent)
3723{ 3730{
3724 if (!anEvent) { 3731 if (!anEvent) {
3725 KNotifyClient::beep(); 3732 KNotifyClient::beep();
3726 return; 3733 return;
3727 } 3734 }
3728 3735
3729 if (anEvent->recurrence()->doesRecur()) { 3736 if (anEvent->recurrence()->doesRecur()) {
3730 QDate itemDate = mViewManager->currentSelectionDate(); 3737 QDate itemDate = mViewManager->currentSelectionDate();
3731 int km; 3738 int km;
3732 if (!itemDate.isValid()) { 3739 if (!itemDate.isValid()) {
3733 //kdDebug() << "Date Not Valid" << endl; 3740 //kdDebug() << "Date Not Valid" << endl;
3734 if (KOPrefs::instance()->mConfirm) { 3741 if (KOPrefs::instance()->mConfirm) {
3735 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3742 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3736 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3743 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3737 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3744 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3738 if ( km == KMessageBox::Continue ) 3745 if ( km == KMessageBox::Continue )
3739 km = KMessageBox::No; // No = all below 3746 km = KMessageBox::No; // No = all below
3740 } else 3747 } else
3741 km = KMessageBox::No; 3748 km = KMessageBox::No;
3742 } else { 3749 } else {
3743 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3750 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3744 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3751 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3745 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3752 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3746 i18n("KO/Pi Confirmation"),i18n("Current"), 3753 i18n("KO/Pi Confirmation"),i18n("Current"),
3747 i18n("All")); 3754 i18n("All"));
3748 } 3755 }
3749 switch(km) { 3756 switch(km) {
3750 3757
3751 case KMessageBox::No: // Continue // all 3758 case KMessageBox::No: // Continue // all
3752 //qDebug("KMessageBox::No "); 3759 //qDebug("KMessageBox::No ");
3753 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3760 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3754 schedule(Scheduler::Cancel,anEvent); 3761 schedule(Scheduler::Cancel,anEvent);
3755 3762
3756 checkExternalId( anEvent); 3763 checkExternalId( anEvent);
3757 mCalendar->deleteEvent(anEvent); 3764 mCalendar->deleteEvent(anEvent);
3758 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3765 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3759 break; 3766 break;
3760 3767
3761 // Disabled because it does not work 3768 // Disabled because it does not work
3762 //#if 0 3769 //#if 0
3763 case KMessageBox::Yes: // just this one 3770 case KMessageBox::Yes: // just this one
3764 //QDate qd = mNavigator->selectedDates().first(); 3771 //QDate qd = mNavigator->selectedDates().first();
3765 //if (!qd.isValid()) { 3772 //if (!qd.isValid()) {
3766 // kdDebug() << "no date selected, or invalid date" << endl; 3773 // kdDebug() << "no date selected, or invalid date" << endl;
3767 // KNotifyClient::beep(); 3774 // KNotifyClient::beep();
3768 // return; 3775 // return;
3769 //} 3776 //}
3770 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3777 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3771 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3778 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3772 anEvent->addExDate(itemDate); 3779 anEvent->addExDate(itemDate);
3773 int duration = anEvent->recurrence()->duration(); 3780 int duration = anEvent->recurrence()->duration();
3774 if ( duration > 0 ) { 3781 if ( duration > 0 ) {
3775 anEvent->recurrence()->setDuration( duration - 1 ); 3782 anEvent->recurrence()->setDuration( duration - 1 );
3776 } 3783 }
3777 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3784 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3778 } 3785 }
3779 break; 3786 break;
3780 //#endif 3787 //#endif
3781 } // switch 3788 } // switch
3782 } else { 3789 } else {
3783 if (KOPrefs::instance()->mConfirm) { 3790 if (KOPrefs::instance()->mConfirm) {
3784 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 3791 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
3785 i18n("\nAre you sure you want\nto delete this event?"), 3792 i18n("\nAre you sure you want\nto delete this event?"),
3786 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3793 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3787 case KMessageBox::Continue: // OK 3794 case KMessageBox::Continue: // OK
3788 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3795 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3789 schedule(Scheduler::Cancel,anEvent); 3796 schedule(Scheduler::Cancel,anEvent);
3790 checkExternalId( anEvent); 3797 checkExternalId( anEvent);
3791 mCalendar->deleteEvent(anEvent); 3798 mCalendar->deleteEvent(anEvent);
3792 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3799 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3793 break; 3800 break;
3794 } // switch 3801 } // switch
3795 } else { 3802 } else {
3796 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3803 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3797 schedule(Scheduler::Cancel,anEvent); 3804 schedule(Scheduler::Cancel,anEvent);
3798 checkExternalId( anEvent); 3805 checkExternalId( anEvent);
3799 mCalendar->deleteEvent(anEvent); 3806 mCalendar->deleteEvent(anEvent);
3800 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3807 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3801 } 3808 }
3802 } // if-else 3809 } // if-else
3803 emit updateSearchDialog(); 3810 emit updateSearchDialog();
3804} 3811}
3805 3812
3806bool CalendarView::deleteEvent(const QString &uid) 3813bool CalendarView::deleteEvent(const QString &uid)
3807{ 3814{
3808 Event *ev = mCalendar->event(uid); 3815 Event *ev = mCalendar->event(uid);
3809 if (ev) { 3816 if (ev) {
3810 deleteEvent(ev); 3817 deleteEvent(ev);
3811 return true; 3818 return true;
3812 } else { 3819 } else {
3813 return false; 3820 return false;
3814 } 3821 }
3815} 3822}
3816 3823
3817/*****************************************************************************/ 3824/*****************************************************************************/
3818 3825
3819void CalendarView::action_mail() 3826void CalendarView::action_mail()
3820{ 3827{
3821#ifndef KORG_NOMAIL 3828#ifndef KORG_NOMAIL
3822 KOMailClient mailClient; 3829 KOMailClient mailClient;
3823 3830
3824 Incidence *incidence = currentSelection(); 3831 Incidence *incidence = currentSelection();
3825 3832
3826 if (!incidence) { 3833 if (!incidence) {
3827 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3834 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3828 return; 3835 return;
3829 } 3836 }
3830 if(incidence->attendeeCount() == 0 ) { 3837 if(incidence->attendeeCount() == 0 ) {
3831 KMessageBox::sorry(this, 3838 KMessageBox::sorry(this,
3832 i18n("Can't generate mail:\nNo attendees defined.\n")); 3839 i18n("Can't generate mail:\nNo attendees defined.\n"));
3833 return; 3840 return;
3834 } 3841 }
3835 3842
3836 CalendarLocal cal_tmp; 3843 CalendarLocal cal_tmp;
3837 Event *event = 0; 3844 Event *event = 0;
3838 Event *ev = 0; 3845 Event *ev = 0;
3839 if ( incidence && incidence->typeID() == eventID ) { 3846 if ( incidence && incidence->typeID() == eventID ) {
3840 event = static_cast<Event *>(incidence); 3847 event = static_cast<Event *>(incidence);
3841 ev = new Event(*event); 3848 ev = new Event(*event);
3842 cal_tmp.addEvent(ev); 3849 cal_tmp.addEvent(ev);
3843 } 3850 }
3844 ICalFormat mForm(); 3851 ICalFormat mForm();
3845 QString attachment = mForm.toString( &cal_tmp ); 3852 QString attachment = mForm.toString( &cal_tmp );
3846 if (ev) delete(ev); 3853 if (ev) delete(ev);
3847 3854
3848 mailClient.mailAttendees(currentSelection(), attachment); 3855 mailClient.mailAttendees(currentSelection(), attachment);
3849 3856
3850#endif 3857#endif
3851 3858
3852#if 0 3859#if 0
3853 Event *anEvent = 0; 3860 Event *anEvent = 0;
3854 if (mViewManager->currentView()->isEventView()) { 3861 if (mViewManager->currentView()->isEventView()) {
3855 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3862 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3856 } 3863 }
3857 3864
3858 if (!anEvent) { 3865 if (!anEvent) {
3859 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3866 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3860 return; 3867 return;
3861 } 3868 }
3862 if(anEvent->attendeeCount() == 0 ) { 3869 if(anEvent->attendeeCount() == 0 ) {
3863 KMessageBox::sorry(this, 3870 KMessageBox::sorry(this,
3864 i18n("Can't generate mail:\nNo attendees defined.\n")); 3871 i18n("Can't generate mail:\nNo attendees defined.\n"));
3865 return; 3872 return;
3866 } 3873 }
3867 3874
3868 mailobject.emailEvent(anEvent); 3875 mailobject.emailEvent(anEvent);
3869#endif 3876#endif
3870} 3877}
3871 3878
3872 3879
3873void CalendarView::schedule_publish(Incidence *incidence) 3880void CalendarView::schedule_publish(Incidence *incidence)
3874{ 3881{
3875 Event *event = 0; 3882 Event *event = 0;
3876 Todo *todo = 0; 3883 Todo *todo = 0;
3877 3884
3878 if (incidence == 0) { 3885 if (incidence == 0) {
3879 incidence = mViewManager->currentView()->selectedIncidences().first(); 3886 incidence = mViewManager->currentView()->selectedIncidences().first();
3880 if (incidence == 0) { 3887 if (incidence == 0) {
3881 incidence = mTodoList->selectedIncidences().first(); 3888 incidence = mTodoList->selectedIncidences().first();
3882 } 3889 }
3883 } 3890 }
3884 if ( incidence && incidence->typeID() == eventID ) { 3891 if ( incidence && incidence->typeID() == eventID ) {
3885 event = static_cast<Event *>(incidence); 3892 event = static_cast<Event *>(incidence);
3886 } else { 3893 } else {
3887 if ( incidence && incidence->typeID() == todoID ) { 3894 if ( incidence && incidence->typeID() == todoID ) {
3888 todo = static_cast<Todo *>(incidence); 3895 todo = static_cast<Todo *>(incidence);
3889 } 3896 }
3890 } 3897 }
3891 3898
3892 if (!event && !todo) { 3899 if (!event && !todo) {
3893 KMessageBox::sorry(this,i18n("No event selected.")); 3900 KMessageBox::sorry(this,i18n("No event selected."));
3894 return; 3901 return;
3895 } 3902 }
3896 3903
3897 PublishDialog *publishdlg = new PublishDialog(); 3904 PublishDialog *publishdlg = new PublishDialog();
3898 if (incidence->attendeeCount()>0) { 3905 if (incidence->attendeeCount()>0) {
3899 QPtrList<Attendee> attendees = incidence->attendees(); 3906 QPtrList<Attendee> attendees = incidence->attendees();
3900 attendees.first(); 3907 attendees.first();
3901 while ( attendees.current()!=0 ) { 3908 while ( attendees.current()!=0 ) {
3902 publishdlg->addAttendee(attendees.current()); 3909 publishdlg->addAttendee(attendees.current());
3903 attendees.next(); 3910 attendees.next();
3904 } 3911 }
3905 } 3912 }
3906 bool send = true; 3913 bool send = true;
3907 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3914 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3908 if ( publishdlg->exec() != QDialog::Accepted ) 3915 if ( publishdlg->exec() != QDialog::Accepted )
3909 send = false; 3916 send = false;
3910 } 3917 }
3911 if ( send ) { 3918 if ( send ) {
3912 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3919 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3913 if ( event ) { 3920 if ( event ) {
3914 Event *ev = new Event(*event); 3921 Event *ev = new Event(*event);
3915 ev->registerObserver(0); 3922 ev->registerObserver(0);
3916 ev->clearAttendees(); 3923 ev->clearAttendees();
3917 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3924 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3918 delete(ev); 3925 delete(ev);
3919 } 3926 }
3920 } else { 3927 } else {
3921 if ( todo ) { 3928 if ( todo ) {
3922 Todo *ev = new Todo(*todo); 3929 Todo *ev = new Todo(*todo);
3923 ev->registerObserver(0); 3930 ev->registerObserver(0);
3924 ev->clearAttendees(); 3931 ev->clearAttendees();
3925 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3932 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3926 delete(ev); 3933 delete(ev);
3927 } 3934 }
3928 } 3935 }
3929 } 3936 }
3930 } 3937 }
3931 delete publishdlg; 3938 delete publishdlg;
3932} 3939}
3933 3940
3934void CalendarView::schedule_request(Incidence *incidence) 3941void CalendarView::schedule_request(Incidence *incidence)
3935{ 3942{
3936 schedule(Scheduler::Request,incidence); 3943 schedule(Scheduler::Request,incidence);
3937} 3944}
3938 3945
3939void CalendarView::schedule_refresh(Incidence *incidence) 3946void CalendarView::schedule_refresh(Incidence *incidence)
3940{ 3947{
3941 schedule(Scheduler::Refresh,incidence); 3948 schedule(Scheduler::Refresh,incidence);
3942} 3949}
3943 3950
3944void CalendarView::schedule_cancel(Incidence *incidence) 3951void CalendarView::schedule_cancel(Incidence *incidence)
3945{ 3952{
3946 schedule(Scheduler::Cancel,incidence); 3953 schedule(Scheduler::Cancel,incidence);
3947} 3954}
3948 3955
3949void CalendarView::schedule_add(Incidence *incidence) 3956void CalendarView::schedule_add(Incidence *incidence)
3950{ 3957{
3951 schedule(Scheduler::Add,incidence); 3958 schedule(Scheduler::Add,incidence);
3952} 3959}
3953 3960
3954void CalendarView::schedule_reply(Incidence *incidence) 3961void CalendarView::schedule_reply(Incidence *incidence)
3955{ 3962{
3956 schedule(Scheduler::Reply,incidence); 3963 schedule(Scheduler::Reply,incidence);
3957} 3964}
3958 3965
3959void CalendarView::schedule_counter(Incidence *incidence) 3966void CalendarView::schedule_counter(Incidence *incidence)
3960{ 3967{
3961 schedule(Scheduler::Counter,incidence); 3968 schedule(Scheduler::Counter,incidence);
3962} 3969}
3963 3970
3964void CalendarView::schedule_declinecounter(Incidence *incidence) 3971void CalendarView::schedule_declinecounter(Incidence *incidence)
3965{ 3972{
3966 schedule(Scheduler::Declinecounter,incidence); 3973 schedule(Scheduler::Declinecounter,incidence);
3967} 3974}
3968 3975
3969void CalendarView::schedule_publish_freebusy(int daysToPublish) 3976void CalendarView::schedule_publish_freebusy(int daysToPublish)
3970{ 3977{
3971 QDateTime start = QDateTime::currentDateTime(); 3978 QDateTime start = QDateTime::currentDateTime();
3972 QDateTime end = start.addDays(daysToPublish); 3979 QDateTime end = start.addDays(daysToPublish);
3973 3980
3974 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3981 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3975 freebusy->setOrganizer(KOPrefs::instance()->email()); 3982 freebusy->setOrganizer(KOPrefs::instance()->email());
3976 3983
3977 3984
3978 PublishDialog *publishdlg = new PublishDialog(); 3985 PublishDialog *publishdlg = new PublishDialog();
3979 if ( publishdlg->exec() == QDialog::Accepted ) { 3986 if ( publishdlg->exec() == QDialog::Accepted ) {
3980 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3987 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3981 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3988 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3982 delete(freebusy); 3989 delete(freebusy);
3983 } 3990 }
3984 } 3991 }
3985 delete publishdlg; 3992 delete publishdlg;
3986} 3993}
3987 3994
3988void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3995void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3989{ 3996{
3990 Event *event = 0; 3997 Event *event = 0;
3991 Todo *todo = 0; 3998 Todo *todo = 0;
3992 3999
3993 if (incidence == 0) { 4000 if (incidence == 0) {
3994 incidence = mViewManager->currentView()->selectedIncidences().first(); 4001 incidence = mViewManager->currentView()->selectedIncidences().first();
3995 if (incidence == 0) { 4002 if (incidence == 0) {
3996 incidence = mTodoList->selectedIncidences().first(); 4003 incidence = mTodoList->selectedIncidences().first();
3997 } 4004 }
3998 } 4005 }
3999 if ( incidence && incidence->typeID() == eventID ) { 4006 if ( incidence && incidence->typeID() == eventID ) {
4000 event = static_cast<Event *>(incidence); 4007 event = static_cast<Event *>(incidence);
4001 } 4008 }
4002 if ( incidence && incidence->typeID() == todoID ) { 4009 if ( incidence && incidence->typeID() == todoID ) {
4003 todo = static_cast<Todo *>(incidence); 4010 todo = static_cast<Todo *>(incidence);
4004 } 4011 }
4005 4012
4006 if (!event && !todo) { 4013 if (!event && !todo) {
4007 KMessageBox::sorry(this,i18n("No event selected.")); 4014 KMessageBox::sorry(this,i18n("No event selected."));
4008 return; 4015 return;
4009 } 4016 }
4010 4017
4011 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 4018 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
4012 KMessageBox::sorry(this,i18n("The event has no attendees.")); 4019 KMessageBox::sorry(this,i18n("The event has no attendees."));
4013 return; 4020 return;
4014 } 4021 }
4015 4022
4016 Event *ev = 0; 4023 Event *ev = 0;
4017 if (event) ev = new Event(*event); 4024 if (event) ev = new Event(*event);
4018 Todo *to = 0; 4025 Todo *to = 0;
4019 if (todo) to = new Todo(*todo); 4026 if (todo) to = new Todo(*todo);
4020 4027
4021 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4028 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4022 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4029 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4023 if (!me) { 4030 if (!me) {
4024 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4031 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4025 return; 4032 return;
4026 } 4033 }
4027 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4034 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4028 StatusDialog *statdlg = new StatusDialog(this); 4035 StatusDialog *statdlg = new StatusDialog(this);
4029 if (!statdlg->exec()==QDialog::Accepted) return; 4036 if (!statdlg->exec()==QDialog::Accepted) return;
4030 me->setStatus( statdlg->status() ); 4037 me->setStatus( statdlg->status() );
4031 delete(statdlg); 4038 delete(statdlg);
4032 } 4039 }
4033 Attendee *menew = new Attendee(*me); 4040 Attendee *menew = new Attendee(*me);
4034 if (ev) { 4041 if (ev) {
4035 ev->clearAttendees(); 4042 ev->clearAttendees();
4036 ev->addAttendee(menew,false); 4043 ev->addAttendee(menew,false);
4037 } else { 4044 } else {
4038 if (to) { 4045 if (to) {
4039 todo->clearAttendees(); 4046 todo->clearAttendees();
4040 todo->addAttendee(menew,false); 4047 todo->addAttendee(menew,false);
4041 } 4048 }
4042 } 4049 }
4043 } 4050 }
4044 4051
4045 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4052 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4046 if (ev) { 4053 if (ev) {
4047 if ( !dlg->addMessage(ev,method) ) delete(ev); 4054 if ( !dlg->addMessage(ev,method) ) delete(ev);
4048 } else { 4055 } else {
4049 if (to) { 4056 if (to) {
4050 if ( !dlg->addMessage(to,method) ) delete(to); 4057 if ( !dlg->addMessage(to,method) ) delete(to);
4051 } 4058 }
4052 } 4059 }
4053} 4060}
4054 4061
4055void CalendarView::openAddressbook() 4062void CalendarView::openAddressbook()
4056{ 4063{
4057 KRun::runCommand("kaddressbook"); 4064 KRun::runCommand("kaddressbook");
4058} 4065}
4059 4066
4060void CalendarView::setModified(bool modified) 4067void CalendarView::setModified(bool modified)
4061{ 4068{
4062 if ( modified ) 4069 if ( modified )
4063 emit signalmodified(); 4070 emit signalmodified();
4064 if (mModified != modified) { 4071 if (mModified != modified) {
4065 mModified = modified; 4072 mModified = modified;
4066 emit modifiedChanged(mModified); 4073 emit modifiedChanged(mModified);
4067 } 4074 }
4068} 4075}
4069 4076
4070bool CalendarView::isReadOnly() 4077bool CalendarView::isReadOnly()
4071{ 4078{
4072 return mReadOnly; 4079 return mReadOnly;
4073} 4080}
4074 4081
4075void CalendarView::setReadOnly(bool readOnly) 4082void CalendarView::setReadOnly(bool readOnly)
4076{ 4083{
4077 if (mReadOnly != readOnly) { 4084 if (mReadOnly != readOnly) {
4078 mReadOnly = readOnly; 4085 mReadOnly = readOnly;
4079 emit readOnlyChanged(mReadOnly); 4086 emit readOnlyChanged(mReadOnly);
4080 } 4087 }
4081} 4088}
4082 4089
4083bool CalendarView::isModified() 4090bool CalendarView::isModified()
4084{ 4091{
4085 return mModified; 4092 return mModified;
4086} 4093}
4087void CalendarView::slotprintSelInc() 4094void CalendarView::slotprintSelInc()
4088{ 4095{
4089 if ( currentSelection() == 0 ) { 4096 if ( currentSelection() == 0 ) {
4090 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4097 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4091 return; 4098 return;
4092 } 4099 }
4093 showIncidence(); 4100 showIncidence();
4094 getEventViewerDialog()->print(); 4101 getEventViewerDialog()->print();
4095 4102
4096} 4103}
4097void CalendarView::printSetup() 4104void CalendarView::printSetup()
4098{ 4105{
4099#ifndef KORG_NOPRINTER 4106#ifndef KORG_NOPRINTER
4100 createPrinter(); 4107 createPrinter();
4101 4108
4102 mCalPrinter->setupPrinter(); 4109 mCalPrinter->setupPrinter();
4103#endif 4110#endif
4104} 4111}
4105 4112
4106void CalendarView::print() 4113void CalendarView::print()
4107{ 4114{
4108#ifndef KORG_NOPRINTER 4115#ifndef KORG_NOPRINTER
4109 createPrinter(); 4116 createPrinter();
4110 4117
4111 DateList tmpDateList = mNavigator->selectedDates(); 4118 DateList tmpDateList = mNavigator->selectedDates();
4112 mCalPrinter->print(CalPrinter::Month, 4119 mCalPrinter->print(CalPrinter::Month,
4113 tmpDateList.first(), tmpDateList.last()); 4120 tmpDateList.first(), tmpDateList.last());
4114#endif 4121#endif
4115} 4122}
4116 4123
4117void CalendarView::printPreview() 4124void CalendarView::printPreview()
4118{ 4125{
4119#ifndef KORG_NOPRINTER 4126#ifndef KORG_NOPRINTER
4120 kdDebug() << "CalendarView::printPreview()" << endl; 4127 kdDebug() << "CalendarView::printPreview()" << endl;
4121 4128
4122 createPrinter(); 4129 createPrinter();
4123 4130
4124 DateList tmpDateList = mNavigator->selectedDates(); 4131 DateList tmpDateList = mNavigator->selectedDates();
4125 4132
4126 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 4133 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
4127 tmpDateList.last()); 4134 tmpDateList.last());
4128#endif 4135#endif
4129} 4136}
4130 4137
4131void CalendarView::exportICalendar() 4138void CalendarView::exportICalendar()
4132{ 4139{
4133 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 4140 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
4134 4141
4135 // Force correct extension 4142 // Force correct extension
4136 if (filename.right(4) != ".ics") filename += ".ics"; 4143 if (filename.right(4) != ".ics") filename += ".ics";
4137 4144
4138 FileStorage storage( mCalendar, filename, new ICalFormat() ); 4145 FileStorage storage( mCalendar, filename, new ICalFormat() );
4139 storage.save(); 4146 storage.save();
4140} 4147}
4141 4148
4142bool CalendarView::exportVCalendar( QString filename ) 4149bool CalendarView::exportVCalendar( QString filename )
4143{ 4150{
4144 if (mCalendar->journals().count() > 0) { 4151 if (mCalendar->journals().count() > 0) {
4145 int result = KMessageBox::warningContinueCancel(this, 4152 int result = KMessageBox::warningContinueCancel(this,
4146 i18n("The journal entries can not be\nexported to a vCalendar file."), 4153 i18n("The journal entries can not be\nexported to a vCalendar file."),
4147 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 4154 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
4148 true); 4155 true);
4149 if (result != KMessageBox::Continue) return false; 4156 if (result != KMessageBox::Continue) return false;
4150 } 4157 }
4151 4158
4152 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 4159 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
4153 4160
4154 // Force correct extension 4161 // Force correct extension
4155 if (filename.right(4) != ".vcs") filename += ".vcs"; 4162 if (filename.right(4) != ".vcs") filename += ".vcs";
4156 4163
4157 FileStorage storage( mCalendar, filename, new VCalFormat ); 4164 FileStorage storage( mCalendar, filename, new VCalFormat );
4158 return storage.save(); 4165 return storage.save();
4159 4166
4160} 4167}
4161 4168
4162void CalendarView::eventUpdated(Incidence *) 4169void CalendarView::eventUpdated(Incidence *)
4163{ 4170{
4164 setModified(); 4171 setModified();
4165 // Don't call updateView here. The code, which has caused the update of the 4172 // Don't call updateView here. The code, which has caused the update of the
4166 // event is responsible for updating the view. 4173 // event is responsible for updating the view.
4167 // updateView(); 4174 // updateView();
4168} 4175}
4169 4176
4170void CalendarView::adaptNavigationUnits() 4177void CalendarView::adaptNavigationUnits()
4171{ 4178{
4172 if (mViewManager->currentView()->isEventView()) { 4179 if (mViewManager->currentView()->isEventView()) {
4173 int days = mViewManager->currentView()->currentDateCount(); 4180 int days = mViewManager->currentView()->currentDateCount();
4174 if (days == 1) { 4181 if (days == 1) {
4175 emit changeNavStringPrev(i18n("&Previous Day")); 4182 emit changeNavStringPrev(i18n("&Previous Day"));
4176 emit changeNavStringNext(i18n("&Next Day")); 4183 emit changeNavStringNext(i18n("&Next Day"));
4177 } else { 4184 } else {
4178 emit changeNavStringPrev(i18n("&Previous Week")); 4185 emit changeNavStringPrev(i18n("&Previous Week"));
4179 emit changeNavStringNext(i18n("&Next Week")); 4186 emit changeNavStringNext(i18n("&Next Week"));
4180 } 4187 }
4181 } 4188 }
4182} 4189}
4183 4190
4184void CalendarView::processMainViewSelection( Incidence *incidence ) 4191void CalendarView::processMainViewSelection( Incidence *incidence )
4185{ 4192{
4186 if ( incidence ) mTodoList->clearSelection(); 4193 if ( incidence ) mTodoList->clearSelection();
4187 processIncidenceSelection( incidence ); 4194 processIncidenceSelection( incidence );
4188} 4195}
4189 4196
4190void CalendarView::processTodoListSelection( Incidence *incidence ) 4197void CalendarView::processTodoListSelection( Incidence *incidence )
4191{ 4198{
4192 if ( incidence && mViewManager->currentView() ) { 4199 if ( incidence && mViewManager->currentView() ) {
4193 mViewManager->currentView()->clearSelection(); 4200 mViewManager->currentView()->clearSelection();
4194 } 4201 }
4195 processIncidenceSelection( incidence ); 4202 processIncidenceSelection( incidence );
4196} 4203}
4197 4204
4198void CalendarView::processIncidenceSelection( Incidence *incidence ) 4205void CalendarView::processIncidenceSelection( Incidence *incidence )
4199{ 4206{
4200 emit incidenceSelected( incidence ); 4207 emit incidenceSelected( incidence );
4201 if ( incidence == mSelectedIncidence ) return; 4208 if ( incidence == mSelectedIncidence ) return;
4202 mSelectedIncidence = incidence; 4209 mSelectedIncidence = incidence;
4203 4210
4204 if ( incidence && incidence->typeID() == eventID ) { 4211 if ( incidence && incidence->typeID() == eventID ) {
4205 Event *event = static_cast<Event *>( incidence ); 4212 Event *event = static_cast<Event *>( incidence );
4206 if ( event->organizer() == KOPrefs::instance()->email() ) { 4213 if ( event->organizer() == KOPrefs::instance()->email() ) {
4207 emit organizerEventsSelected( true ); 4214 emit organizerEventsSelected( true );
4208 } else { 4215 } else {
4209 emit organizerEventsSelected(false); 4216 emit organizerEventsSelected(false);
4210 } 4217 }
4211 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4218 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4212 KOPrefs::instance()->email() ) ) { 4219 KOPrefs::instance()->email() ) ) {
4213 emit groupEventsSelected( true ); 4220 emit groupEventsSelected( true );
4214 } else { 4221 } else {
4215 emit groupEventsSelected(false); 4222 emit groupEventsSelected(false);
4216 } 4223 }
4217 return; 4224 return;
4218 } else { 4225 } else {
4219 if ( incidence && incidence->typeID() == todoID ) { 4226 if ( incidence && incidence->typeID() == todoID ) {
4220 emit todoSelected( true ); 4227 emit todoSelected( true );
4221 Todo *event = static_cast<Todo *>( incidence ); 4228 Todo *event = static_cast<Todo *>( incidence );
4222 if ( event->organizer() == KOPrefs::instance()->email() ) { 4229 if ( event->organizer() == KOPrefs::instance()->email() ) {
4223 emit organizerEventsSelected( true ); 4230 emit organizerEventsSelected( true );
4224 } else { 4231 } else {
4225 emit organizerEventsSelected(false); 4232 emit organizerEventsSelected(false);
4226 } 4233 }
4227 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4234 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4228 KOPrefs::instance()->email() ) ) { 4235 KOPrefs::instance()->email() ) ) {
4229 emit groupEventsSelected( true ); 4236 emit groupEventsSelected( true );
4230 } else { 4237 } else {
4231 emit groupEventsSelected(false); 4238 emit groupEventsSelected(false);
4232 } 4239 }
4233 return; 4240 return;
4234 } else { 4241 } else {
4235 emit todoSelected( false ); 4242 emit todoSelected( false );
4236 emit organizerEventsSelected(false); 4243 emit organizerEventsSelected(false);
4237 emit groupEventsSelected(false); 4244 emit groupEventsSelected(false);
4238 } 4245 }
4239 return; 4246 return;
4240 } 4247 }
4241 4248
4242 /* if ( incidence && incidence->typeID() == todoID ) { 4249 /* if ( incidence && incidence->typeID() == todoID ) {
4243 emit todoSelected( true ); 4250 emit todoSelected( true );
4244 } else { 4251 } else {
4245 emit todoSelected( false ); 4252 emit todoSelected( false );
4246 }*/ 4253 }*/
4247} 4254}
4248 4255
4249 4256
4250void CalendarView::checkClipboard() 4257void CalendarView::checkClipboard()
4251{ 4258{
4252#ifndef KORG_NODND 4259#ifndef KORG_NODND
4253 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4260 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4254 emit pasteEnabled(true); 4261 emit pasteEnabled(true);
4255 } else { 4262 } else {
4256 emit pasteEnabled(false); 4263 emit pasteEnabled(false);
4257 } 4264 }
4258#endif 4265#endif
4259} 4266}
4260 4267
4261void CalendarView::showDates(const DateList &selectedDates) 4268void CalendarView::showDates(const DateList &selectedDates)
4262{ 4269{
4263 // kdDebug() << "CalendarView::selectDates()" << endl; 4270 // kdDebug() << "CalendarView::selectDates()" << endl;
4264 4271
4265 4272
4266 if ( !mBlockShowDates ) { 4273 if ( !mBlockShowDates ) {
4267 if ( mViewManager->currentView() ) { 4274 if ( mViewManager->currentView() ) {
4268 updateView( selectedDates.first(), selectedDates.last() ); 4275 updateView( selectedDates.first(), selectedDates.last() );
4269 } else { 4276 } else {
4270 mViewManager->showAgendaView(); 4277 mViewManager->showAgendaView();
4271 } 4278 }
4272 } 4279 }
4273 4280
4274 QDate date = selectedDates.first(); 4281 QDate date = selectedDates.first();
4275 if ( ! date.isValid() ) { 4282 if ( ! date.isValid() ) {
4276 topLevelWidget()->setCaption(""); 4283 topLevelWidget()->setCaption("");
4277 return; 4284 return;
4278 } 4285 }
4279 4286
4280 QString selDates; 4287 QString selDates;
4281 selDates = KGlobal::locale()->formatDate( date, true); 4288 selDates = KGlobal::locale()->formatDate( date, true);
4282 if (selectedDates.first() < selectedDates.last() ) 4289 if (selectedDates.first() < selectedDates.last() )
4283 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4290 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4284 else { 4291 else {
4285 QString addString; 4292 QString addString;
4286 if ( date == QDateTime::currentDateTime().date() ) 4293 if ( date == QDateTime::currentDateTime().date() )
4287 addString = i18n("Today"); 4294 addString = i18n("Today");
4288 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4295 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4289 addString = i18n("Tomorrow"); 4296 addString = i18n("Tomorrow");
4290 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4297 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4291 addString = i18n("Yesterday"); 4298 addString = i18n("Yesterday");
4292 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4299 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4293 addString = i18n("Day before yesterday"); 4300 addString = i18n("Day before yesterday");
4294 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4301 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4295 addString = i18n("Day after tomorrow"); 4302 addString = i18n("Day after tomorrow");
4296 if ( !addString.isEmpty() ) { 4303 if ( !addString.isEmpty() ) {
4297 topLevelWidget()->setCaption( addString+", " + selDates ); 4304 topLevelWidget()->setCaption( addString+", " + selDates );
4298 return; 4305 return;
4299 } 4306 }
4300 } 4307 }
4301 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4308 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4302 4309
4303} 4310}
4304 4311
4305QPtrList<CalFilter> CalendarView::filters() 4312QPtrList<CalFilter> CalendarView::filters()
4306{ 4313{
4307 return mFilters; 4314 return mFilters;
4308 4315
4309} 4316}
4310void CalendarView::editFilters() 4317void CalendarView::editFilters()
4311{ 4318{
4312 // kdDebug() << "CalendarView::editFilters()" << endl; 4319 // kdDebug() << "CalendarView::editFilters()" << endl;
4313 4320
4314 CalFilter *filter = mFilters.first(); 4321 CalFilter *filter = mFilters.first();
4315 while(filter) { 4322 while(filter) {
4316 filter = mFilters.next(); 4323 filter = mFilters.next();
4317 } 4324 }
4318 4325
4319 mDialogManager->showFilterEditDialog(&mFilters); 4326 mDialogManager->showFilterEditDialog(&mFilters);
4320 updateFilter(); 4327 updateFilter();
4321} 4328}
4322void CalendarView::toggleFilter() 4329void CalendarView::toggleFilter()
4323{ 4330{
4324 if ( mLeftFrame->isHidden() ) { 4331 if ( mLeftFrame->isHidden() ) {
4325 toggleExpand(); 4332 toggleExpand();
4326 showFilter( true ); 4333 showFilter( true );
4327 } else 4334 } else
4328 showFilter(! mCalEditView->isVisible()); 4335 showFilter(! mCalEditView->isVisible());
4329} 4336}
4330 4337
4331KOFilterView *CalendarView::filterView() 4338KOFilterView *CalendarView::filterView()
4332{ 4339{
4333 return mFilterView; 4340 return mFilterView;
4334} 4341}
4335void CalendarView::selectFilter( int fil ) 4342void CalendarView::selectFilter( int fil )
4336{ 4343{
4337 mFilterView->setSelectedFilter( fil ); 4344 mFilterView->setSelectedFilter( fil );
4338 updateUnmanagedViews(); 4345 updateUnmanagedViews();
4339} 4346}
4340void CalendarView::showFilter(bool visible) 4347void CalendarView::showFilter(bool visible)
4341{ 4348{
4342#if 1 4349#if 1
4343 if (visible) { 4350 if (visible) {
4344 mCalEditView->readConfig(); 4351 mCalEditView->readConfig();
4345 mCalEditView->show(); 4352 mCalEditView->show();
4346 QValueList<int> sizes; 4353 QValueList<int> sizes;
4347 sizes = mLeftFrame->sizes(); 4354 sizes = mLeftFrame->sizes();
4348 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4355 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4349 sizes.clear(); 4356 sizes.clear();
4350 sizes << 100; 4357 sizes << 100;
4351 sizes << 0; 4358 sizes << 0;
4352 sizes << 0; 4359 sizes << 0;
4353 sizes << 100; 4360 sizes << 100;
4354 mLeftFrame->setSizes(sizes); 4361 mLeftFrame->setSizes(sizes);
4355 } 4362 }
4356#if 0 4363#if 0
4357 sizes = mLeftFrame->sizes(); 4364 sizes = mLeftFrame->sizes();
4358 int ccc = 0; 4365 int ccc = 0;
4359 while ( ccc < sizes.count()) { 4366 while ( ccc < sizes.count()) {
4360 qDebug("size %d %d ", ccc, sizes[ccc]); 4367 qDebug("size %d %d ", ccc, sizes[ccc]);
4361 ++ccc; 4368 ++ccc;
4362 } 4369 }
4363#endif 4370#endif
4364 4371
4365 } 4372 }
4366 else { 4373 else {
4367 mCalEditView->hide(); 4374 mCalEditView->hide();
4368 } 4375 }
4369#else 4376#else
4370 if (visible) mFilterView->show(); 4377 if (visible) mFilterView->show();
4371 else mFilterView->hide(); 4378 else mFilterView->hide();
4372#endif 4379#endif
4373} 4380}
4374void CalendarView::toggleFilerEnabled( ) 4381void CalendarView::toggleFilerEnabled( )
4375{ 4382{
4376 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4383 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4377 if ( !mFilterView->filtersEnabled() ) 4384 if ( !mFilterView->filtersEnabled() )
4378 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4385 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4379 updateUnmanagedViews(); 4386 updateUnmanagedViews();
4380 4387
4381} 4388}
4382void CalendarView::updateFilter() 4389void CalendarView::updateFilter()
4383{ 4390{
4384 CalFilter *filter = mFilterView->selectedFilter(); 4391 CalFilter *filter = mFilterView->selectedFilter();
4385 if (filter) { 4392 if (filter) {
4386 QString mess; 4393 QString mess;
4387 if (mFilterView->filtersEnabled()) { 4394 if (mFilterView->filtersEnabled()) {
4388 mess = i18n("Filter selected: ")+filter->name(); 4395 mess = i18n("Filter selected: ")+filter->name();
4389 filter->setEnabled(true); 4396 filter->setEnabled(true);
4390 } 4397 }
4391 else filter->setEnabled(false); 4398 else filter->setEnabled(false);
4392 mCalendar->setFilter(filter); 4399 mCalendar->setFilter(filter);
4393 updateView(); 4400 updateView();
4394 if ( !mess.isEmpty() ) 4401 if ( !mess.isEmpty() )
4395 topLevelWidget()->setCaption( mess ); 4402 topLevelWidget()->setCaption( mess );
4396 4403
4397 } 4404 }
4398 emit filtersUpdated(); 4405 emit filtersUpdated();
4399} 4406}
4400 4407
4401void CalendarView::filterEdited() 4408void CalendarView::filterEdited()
4402{ 4409{
4403 mFilterView->updateFilters(); 4410 mFilterView->updateFilters();
4404 updateFilter(); 4411 updateFilter();
4405 writeSettings(); 4412 writeSettings();
4406} 4413}
4407 4414
4408 4415
4409void CalendarView::takeOverEvent() 4416void CalendarView::takeOverEvent()
4410{ 4417{
4411 Incidence *incidence = currentSelection(); 4418 Incidence *incidence = currentSelection();
4412 4419
4413 if (!incidence) return; 4420 if (!incidence) return;
4414 4421
4415 incidence->setOrganizer(KOPrefs::instance()->email()); 4422 incidence->setOrganizer(KOPrefs::instance()->email());
4416 incidence->recreate(); 4423 incidence->recreate();
4417 incidence->setReadOnly(false); 4424 incidence->setReadOnly(false);
4418 4425
4419 updateView(); 4426 updateView();
4420} 4427}
4421 4428
4422void CalendarView::takeOverCalendar() 4429void CalendarView::takeOverCalendar()
4423{ 4430{
4424 // TODO: Create Calendar::allIncidences() function and use it here 4431 // TODO: Create Calendar::allIncidences() function and use it here
4425 4432
4426 clearAllViews(); 4433 clearAllViews();
4427 QPtrList<Event> events = mCalendar->events(); 4434 QPtrList<Event> events = mCalendar->events();
4428 for(uint i=0; i<events.count(); ++i) { 4435 for(uint i=0; i<events.count(); ++i) {
4429 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4436 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4430 events.at(i)->recreate(); 4437 events.at(i)->recreate();
4431 events.at(i)->setReadOnly(false); 4438 events.at(i)->setReadOnly(false);
4432 } 4439 }
4433 4440
4434 QPtrList<Todo> todos = mCalendar->todos(); 4441 QPtrList<Todo> todos = mCalendar->todos();
4435 for(uint i=0; i<todos.count(); ++i) { 4442 for(uint i=0; i<todos.count(); ++i) {
4436 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4443 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4437 todos.at(i)->recreate(); 4444 todos.at(i)->recreate();
4438 todos.at(i)->setReadOnly(false); 4445 todos.at(i)->setReadOnly(false);
4439 } 4446 }
4440 4447
4441 QPtrList<Journal> journals = mCalendar->journals(); 4448 QPtrList<Journal> journals = mCalendar->journals();
4442 for(uint i=0; i<journals.count(); ++i) { 4449 for(uint i=0; i<journals.count(); ++i) {
4443 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4450 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4444 journals.at(i)->recreate(); 4451 journals.at(i)->recreate();
4445 journals.at(i)->setReadOnly(false); 4452 journals.at(i)->setReadOnly(false);
4446 } 4453 }
4447 4454
4448 updateView(); 4455 updateView();
4449} 4456}
4450 4457
4451void CalendarView::showIntro() 4458void CalendarView::showIntro()
4452{ 4459{
4453 kdDebug() << "To be implemented." << endl; 4460 kdDebug() << "To be implemented." << endl;
4454} 4461}
4455 4462
4456QWidgetStack *CalendarView::viewStack() 4463QWidgetStack *CalendarView::viewStack()
4457{ 4464{
4458 return mRightFrame; 4465 return mRightFrame;
4459} 4466}
4460 4467
4461QWidget *CalendarView::leftFrame() 4468QWidget *CalendarView::leftFrame()
4462{ 4469{
4463 return ( QWidget *)mLeftFrame; 4470 return ( QWidget *)mLeftFrame;
4464} 4471}
4465 4472
4466DateNavigator *CalendarView::dateNavigator() 4473DateNavigator *CalendarView::dateNavigator()
4467{ 4474{
4468 return mNavigator; 4475 return mNavigator;
4469} 4476}
4470 4477
4471KDateNavigator* CalendarView::dateNavigatorWidget() 4478KDateNavigator* CalendarView::dateNavigatorWidget()
4472{ 4479{
4473 return mDateNavigator->navigatorView(); 4480 return mDateNavigator->navigatorView();
4474} 4481}
4475void CalendarView::toggleDateNavigatorWidget() 4482void CalendarView::toggleDateNavigatorWidget()
4476{ 4483{
4477 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4484 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4478 4485
4479 if (!KOPrefs::instance()->mShowDateNavigator ) 4486 if (!KOPrefs::instance()->mShowDateNavigator )
4480 mDateNavigator->hide(); 4487 mDateNavigator->hide();
4481 else 4488 else
4482 mDateNavigator->show(); 4489 mDateNavigator->show();
4483} 4490}
4484void CalendarView::addView(KOrg::BaseView *view) 4491void CalendarView::addView(KOrg::BaseView *view)
4485{ 4492{
4486 mViewManager->addView(view); 4493 mViewManager->addView(view);
4487} 4494}
4488 4495
4489void CalendarView::showView(KOrg::BaseView *view) 4496void CalendarView::showView(KOrg::BaseView *view)
4490{ 4497{
4491 mViewManager->showView(view, mLeftFrame->isVisible()); 4498 mViewManager->showView(view, mLeftFrame->isVisible());
4492} 4499}
4493 4500
4494Incidence *CalendarView::currentSelection() 4501Incidence *CalendarView::currentSelection()
4495{ 4502{
4496 return mViewManager->currentSelection(); 4503 return mViewManager->currentSelection();
4497} 4504}
4498void CalendarView::toggleAllDaySize() 4505void CalendarView::toggleAllDaySize()
4499{ 4506{
4500 /* 4507 /*
4501 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4508 if ( KOPrefs::instance()->mAllDaySize > 47 )
4502 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4509 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4503 else 4510 else
4504 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4511 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4505 */ 4512 */
4506 viewManager()->agendaView()->toggleAllDay(); 4513 viewManager()->agendaView()->toggleAllDay();
4507} 4514}
4508void CalendarView::toggleExpand() 4515void CalendarView::toggleExpand()
4509{ 4516{
4510 // if ( mLeftFrame->isHidden() ) { 4517 // if ( mLeftFrame->isHidden() ) {
4511 // mLeftFrame->show(); 4518 // mLeftFrame->show();
4512 // emit calendarViewExpanded( false ); 4519 // emit calendarViewExpanded( false );
4513 // } else { 4520 // } else {
4514 // mLeftFrame->hide(); 4521 // mLeftFrame->hide();
4515 // emit calendarViewExpanded( true ); 4522 // emit calendarViewExpanded( true );
4516 // } 4523 // }
4517 //qDebug(" CalendarView::toggleExpand()"); 4524 //qDebug(" CalendarView::toggleExpand()");
4518 globalFlagBlockAgenda = 1; 4525 globalFlagBlockAgenda = 1;
4519 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4526 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4520 globalFlagBlockAgenda = 5; 4527 globalFlagBlockAgenda = 5;
4521 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4528 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4522 //mViewManager->showView( 0, true ); 4529 //mViewManager->showView( 0, true );
4523} 4530}
4524 4531
4525void CalendarView::calendarModified( bool modified, Calendar * ) 4532void CalendarView::calendarModified( bool modified, Calendar * )
4526{ 4533{
4527 setModified( modified ); 4534 setModified( modified );
4528} 4535}
4529 4536
4530Todo *CalendarView::selectedTodo() 4537Todo *CalendarView::selectedTodo()
4531{ 4538{
4532 Incidence *incidence = currentSelection(); 4539 Incidence *incidence = currentSelection();
4533 if ( incidence && incidence->typeID() == todoID ) { 4540 if ( incidence && incidence->typeID() == todoID ) {
4534 return static_cast<Todo *>( incidence ); 4541 return static_cast<Todo *>( incidence );
4535 } 4542 }
4536 4543
4537 incidence = mTodoList->selectedIncidences().first(); 4544 incidence = mTodoList->selectedIncidences().first();
4538 if ( incidence && incidence->typeID() == todoID ) { 4545 if ( incidence && incidence->typeID() == todoID ) {
4539 return static_cast<Todo *>( incidence ); 4546 return static_cast<Todo *>( incidence );
4540 } 4547 }
4541 4548
4542 return 0; 4549 return 0;
4543} 4550}
4544 4551
4545void CalendarView::showIncidence() 4552void CalendarView::showIncidence()
4546{ 4553{
4547 mViewerCallerIsSearchDialog = false; 4554 mViewerCallerIsSearchDialog = false;
4548 Incidence *incidence = currentSelection(); 4555 Incidence *incidence = currentSelection();
4549 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4556 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4550 if ( incidence ) { 4557 if ( incidence ) {
4551 ShowIncidenceVisitor v; 4558 ShowIncidenceVisitor v;
4552 v.act( incidence, this ); 4559 v.act( incidence, this );
4553 } 4560 }
4554} 4561}
4555void CalendarView::editIncidenceDescription() 4562void CalendarView::editIncidenceDescription()
4556{ 4563{
4557 mFlagEditDescription = true; 4564 mFlagEditDescription = true;
4558 editIncidence(); 4565 editIncidence();
4559 mFlagEditDescription = false; 4566 mFlagEditDescription = false;
4560} 4567}
4561void CalendarView::editIncidence() 4568void CalendarView::editIncidence()
4562{ 4569{
4563 // qDebug("editIncidence() "); 4570 // qDebug("editIncidence() ");
4564 Incidence *incidence = currentSelection(); 4571 Incidence *incidence = currentSelection();
4565 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4572 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4566 if ( incidence ) { 4573 if ( incidence ) {
4567 EditIncidenceVisitor v; 4574 EditIncidenceVisitor v;
4568 v.act( incidence, this ); 4575 v.act( incidence, this );
4569 } 4576 }
4570} 4577}
4571 4578
4572void CalendarView::deleteIncidence() 4579void CalendarView::deleteIncidence()
4573{ 4580{
4574 Incidence *incidence = currentSelection(); 4581 Incidence *incidence = currentSelection();
4575 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4582 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4576 if ( incidence ) { 4583 if ( incidence ) {
4577 deleteIncidence(incidence); 4584 deleteIncidence(incidence);
4578 } 4585 }
4579} 4586}
4580void CalendarView::showIncidence(QString uid) 4587void CalendarView::showIncidence(QString uid)
4581{ 4588{
4582 Incidence *inc = mCalendar->incidence( uid ); 4589 Incidence *inc = mCalendar->incidence( uid );
4583 if ( inc ) 4590 if ( inc )
4584 showIncidence( inc ); 4591 showIncidence( inc );
4585} 4592}
4586void CalendarView::showIncidence(Incidence *incidence) 4593void CalendarView::showIncidence(Incidence *incidence)
4587{ 4594{
4588 mViewerCallerIsSearchDialog = false; 4595 mViewerCallerIsSearchDialog = false;
4589 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4596 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4590 if ( sender() && mDialogManager->getSearchDialog() ) { 4597 if ( sender() && mDialogManager->getSearchDialog() ) {
4591 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4598 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4592 mViewerCallerIsSearchDialog = true; 4599 mViewerCallerIsSearchDialog = true;
4593 } 4600 }
4594 } 4601 }
4595 if ( incidence ) { 4602 if ( incidence ) {
4596 ShowIncidenceVisitor v; 4603 ShowIncidenceVisitor v;
4597 v.act( incidence, this ); 4604 v.act( incidence, this );
4598 } 4605 }
4599} 4606}
4600 4607
4601void CalendarView::editIncidence(Incidence *incidence) 4608void CalendarView::editIncidence(Incidence *incidence)
4602{ 4609{
4603 if ( incidence ) { 4610 if ( incidence ) {
4604 4611
4605 EditIncidenceVisitor v; 4612 EditIncidenceVisitor v;
4606 v.act( incidence, this ); 4613 v.act( incidence, this );
4607 4614
4608 } 4615 }
4609} 4616}
4610 4617
4611void CalendarView::deleteIncidence(Incidence *incidence) 4618void CalendarView::deleteIncidence(Incidence *incidence)
4612{ 4619{
4613 //qDebug(" CalendarView::deleteIncidence "); 4620 //qDebug(" CalendarView::deleteIncidence ");
4614 if ( incidence == 0 ) { 4621 if ( incidence == 0 ) {
4615 updateView(); 4622 updateView();
4616 emit updateSearchDialog(); 4623 emit updateSearchDialog();
4617 return; 4624 return;
4618 } 4625 }
4619 if ( incidence ) { 4626 if ( incidence ) {
4620 DeleteIncidenceVisitor v; 4627 DeleteIncidenceVisitor v;
4621 v.act( incidence, this ); 4628 v.act( incidence, this );
4622 } 4629 }
4623} 4630}
4624 4631
4625 4632
4626void CalendarView::lookForOutgoingMessages() 4633void CalendarView::lookForOutgoingMessages()
4627{ 4634{
4628 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4635 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4629 ogd->loadMessages(); 4636 ogd->loadMessages();
4630} 4637}
4631 4638
4632void CalendarView::lookForIncomingMessages() 4639void CalendarView::lookForIncomingMessages()
4633{ 4640{
4634 IncomingDialog *icd = mDialogManager->incomingDialog(); 4641 IncomingDialog *icd = mDialogManager->incomingDialog();
4635 icd->retrieve(); 4642 icd->retrieve();
4636} 4643}
4637 4644
4638bool CalendarView::removeCompletedSubTodos( Todo* t ) 4645bool CalendarView::removeCompletedSubTodos( Todo* t )
4639{ 4646{
4640 bool deleteTodo = true; 4647 bool deleteTodo = true;
4641 QPtrList<Incidence> subTodos; 4648 QPtrList<Incidence> subTodos;
4642 Incidence *aTodo; 4649 Incidence *aTodo;
4643 subTodos = t->relations(); 4650 subTodos = t->relations();
4644 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4651 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4645 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4652 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4646 deleteTodo = false; 4653 deleteTodo = false;
4647 } 4654 }
4648 if ( deleteTodo ) { 4655 if ( deleteTodo ) {
4649 if ( t->isCompleted() && !t->doesRecur()) { 4656 if ( t->isCompleted() && !t->doesRecur()) {
4650 checkExternalId( t ); 4657 checkExternalId( t );
4651 mCalendar->deleteTodo( t ); 4658 mCalendar->deleteTodo( t );
4652 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4659 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4653 } 4660 }
4654 else 4661 else
4655 deleteTodo = false; 4662 deleteTodo = false;
4656 } 4663 }
4657 return deleteTodo; 4664 return deleteTodo;
4658 4665
4659} 4666}
4660void CalendarView::purgeCompleted() 4667void CalendarView::purgeCompleted()
4661{ 4668{
4662 int result = KMessageBox::warningContinueCancel(this, 4669 int result = KMessageBox::warningContinueCancel(this,
4663 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4670 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4664 4671
4665 if (result == KMessageBox::Continue) { 4672 if (result == KMessageBox::Continue) {
4666 4673
4667 QPtrList<Todo> todoCal; 4674 QPtrList<Todo> todoCal;
4668 QPtrList<Todo> rootTodos; 4675 QPtrList<Todo> rootTodos;
4669 //QPtrList<Incidence> rel; 4676 //QPtrList<Incidence> rel;
4670 Todo *aTodo; 4677 Todo *aTodo;
4671 todoCal = calendar()->todos(); 4678 todoCal = calendar()->todos();
4672 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4679 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4673 if ( !aTodo->relatedTo() ) 4680 if ( !aTodo->relatedTo() )
4674 rootTodos.append( aTodo ); 4681 rootTodos.append( aTodo );
4675 } 4682 }
4676 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4683 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4677 removeCompletedSubTodos( aTodo ); 4684 removeCompletedSubTodos( aTodo );
4678 } 4685 }
4679 4686
4680 updateView(); 4687 updateView();
4681 } 4688 }
4682} 4689}
4683 4690
4684void CalendarView::slotCalendarChanged() 4691void CalendarView::slotCalendarChanged()
4685{ 4692{
4686 ; 4693 ;
4687} 4694}
4688 4695
4689void CalendarView::keyPressEvent ( QKeyEvent *e) 4696void CalendarView::keyPressEvent ( QKeyEvent *e)
4690{ 4697{
4691 //qDebug("CalendarView::keyPressEvent "); 4698 //qDebug("CalendarView::keyPressEvent ");
4692 e->ignore(); 4699 e->ignore();
4693} 4700}
4694 4701
4695 4702
4696bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4703bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4697{ 4704{
4698 4705
4699 if ( manager != mSyncManager) 4706 if ( manager != mSyncManager)
4700 qDebug("KO: Internal error-1. SyncManager mismatch "); 4707 qDebug("KO: Internal error-1. SyncManager mismatch ");
4701 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4708 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4702 qDebug("KO: SyncKDE request detected!"); 4709 qDebug("KO: SyncKDE request detected!");
4703 } 4710 }
4704 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4711 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4705 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4712 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4706 return syncCalendar( filename, mode ); 4713 return syncCalendar( filename, mode );
4707} 4714}
4708bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4715bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4709{ 4716{
4710 //mSyncManager = manager; 4717 //mSyncManager = manager;
4711 if ( manager != mSyncManager) 4718 if ( manager != mSyncManager)
4712 qDebug("KO: Internal error-2. SyncManager mismatch "); 4719 qDebug("KO: Internal error-2. SyncManager mismatch ");
4713 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4720 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4714 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4721 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4715 if ( resource == "sharp" ) 4722 if ( resource == "sharp" )
4716 syncExternal( 0 ); 4723 syncExternal( 0 );
4717 if ( resource == "phone" ) 4724 if ( resource == "phone" )
4718 syncExternal( 1 ); 4725 syncExternal( 1 );
4719 // pending setmodified 4726 // pending setmodified
4720 return true; 4727 return true;
4721} 4728}
4722void CalendarView::setSyncManager(KSyncManager* manager) 4729void CalendarView::setSyncManager(KSyncManager* manager)
4723{ 4730{
4724 mSyncManager = manager; 4731 mSyncManager = manager;
4725} 4732}
4726 4733
4727void CalendarView::removeSyncInfo( QString syncProfile) 4734void CalendarView::removeSyncInfo( QString syncProfile)
4728{ 4735{
4729 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4736 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4730 mCalendar->removeSyncInfo( syncProfile ); 4737 mCalendar->removeSyncInfo( syncProfile );
4731 4738
4732} 4739}
4733 4740
4734void CalendarView::undo_delete() 4741void CalendarView::undo_delete()
4735{ 4742{
4736 //qDebug("undo_delete() "); 4743 //qDebug("undo_delete() ");
4737 Incidence* undo = mCalendar->undoIncidence(); 4744 Incidence* undo = mCalendar->undoIncidence();
4738 if ( !undo ) { 4745 if ( !undo ) {
4739 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4746 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4740 i18n("KO/Pi")); 4747 i18n("KO/Pi"));
4741 return; 4748 return;
4742 } 4749 }
4743 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 4750 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
4744 i18n("\nAre you sure you want\nto restore this?"), 4751 i18n("\nAre you sure you want\nto restore this?"),
4745 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4752 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4746 mCalendar->undoDeleteIncidence(); 4753 mCalendar->undoDeleteIncidence();
4747 updateView(); 4754 updateView();
4748 } 4755 }
4749} 4756}
4750 4757
4751void CalendarView::slotViewerClosed() 4758void CalendarView::slotViewerClosed()
4752{ 4759{
4753 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4760 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4754} 4761}
4755 4762
4756void CalendarView::resetFocus() 4763void CalendarView::resetFocus()
4757{ 4764{
4758 if ( mViewerCallerIsSearchDialog ) { 4765 if ( mViewerCallerIsSearchDialog ) {
4759 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4766 if ( mDialogManager->getSearchDialog()->isVisible() ){
4760 mDialogManager->getSearchDialog()->raise(); 4767 mDialogManager->getSearchDialog()->raise();
4761 mDialogManager->getSearchDialog()->setActiveWindow(); 4768 mDialogManager->getSearchDialog()->setActiveWindow();
4762 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4769 mDialogManager->getSearchDialog()->listview()->resetFocus();
4763 } else 4770 } else
4764 mViewerCallerIsSearchDialog = false; 4771 mViewerCallerIsSearchDialog = false;
4765 } 4772 }
4766 if ( !mViewerCallerIsSearchDialog ) { 4773 if ( !mViewerCallerIsSearchDialog ) {
4767 //mViewManager->currentView()->setFocus(); 4774 //mViewManager->currentView()->setFocus();
4768 //qDebug("sssssssssssssssset focus "); 4775 //qDebug("sssssssssssssssset focus ");
4769 topLevelWidget()->raise(); 4776 topLevelWidget()->raise();
4770 setActiveWindow(); 4777 setActiveWindow();
4771 //setFocus(); 4778 //setFocus();
4772 } 4779 }
4773 mViewerCallerIsSearchDialog = false; 4780 mViewerCallerIsSearchDialog = false;
4774} 4781}
4775 4782
4776void CalendarView::showNextAlarms() 4783void CalendarView::showNextAlarms()
4777{ 4784{
4778 QString message; 4785 QString message;
4779 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4786 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4780 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4787 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4781 QString sum = mCalendar->nextSummary(); 4788 QString sum = mCalendar->nextSummary();
4782 QDateTime nextA = mNextAlarmDateTime; 4789 QDateTime nextA = mNextAlarmDateTime;
4783 QDateTime cur = QDateTime::currentDateTime(); 4790 QDateTime cur = QDateTime::currentDateTime();
4784 int secs = cur.secsTo( nextA ); 4791 int secs = cur.secsTo( nextA );
4785 int min = secs /60; 4792 int min = secs /60;
4786 int hours = min /60; 4793 int hours = min /60;
4787 min = min % 60; 4794 min = min % 60;
4788 int days = hours /24; 4795 int days = hours /24;
4789 hours = hours % 24; 4796 hours = hours % 24;
4790 4797
4791 //message = i18n("The next alarm is in:\n"); 4798 //message = i18n("The next alarm is in:\n");
4792 if ( days > 1 ) 4799 if ( days > 1 )
4793 message += i18n("%1 days\n").arg( days ); 4800 message += i18n("%1 days\n").arg( days );
4794 else if ( days == 1 ) 4801 else if ( days == 1 )
4795 message += i18n("1 day\n"); 4802 message += i18n("1 day\n");
4796 if ( hours > 1 ) 4803 if ( hours > 1 )
4797 message += i18n("%1 hours\n").arg( hours ); 4804 message += i18n("%1 hours\n").arg( hours );
4798 else if ( hours == 1 ) 4805 else if ( hours == 1 )
4799 message += i18n("1 hour\n"); 4806 message += i18n("1 hour\n");
4800 if ( min > 1 ) 4807 if ( min > 1 )
4801 message += i18n("%1 minutes\n").arg( min ); 4808 message += i18n("%1 minutes\n").arg( min );
4802 else if ( min == 1 ) 4809 else if ( min == 1 )
4803 message += i18n("1 minute\n"); 4810 message += i18n("1 minute\n");
4804 if ( message.isEmpty() ) 4811 if ( message.isEmpty() )
4805 message = i18n("The next alarm is in\nless than one minute!"); 4812 message = i18n("The next alarm is in\nless than one minute!");
4806 else 4813 else
4807 message = i18n("The next alarm is in:\n") + message; 4814 message = i18n("The next alarm is in:\n") + message;
4808 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4815 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4809 } else { 4816 } else {
4810 message = i18n("There is no next alarm."); 4817 message = i18n("There is no next alarm.");
4811 4818
4812 } 4819 }
4813#ifdef DESKTOP_VERSION 4820#ifdef DESKTOP_VERSION
4814 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4821 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4815 message += i18n("\nThe internal alarm notification is disabled!\n"); 4822 message += i18n("\nThe internal alarm notification is disabled!\n");
4816 message += i18n("Enable it in the settings menu, TAB alarm."); 4823 message += i18n("Enable it in the settings menu, TAB alarm.");
4817 } 4824 }
4818 4825
4819#endif 4826#endif
4820 KMessageBox::information( this, message); 4827 KMessageBox::information( this, message);
4821} 4828}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 799c297..456c2d7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,667 +1,668 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#include <qscrollbar.h> 33#include <qscrollbar.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qtopia/ir.h> 35#include <qtopia/ir.h>
36#else 36#else
37#define Ir char 37#define Ir char
38#endif 38#endif
39#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
40#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
44 44
45#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
46 46
47#include <ksyncmanager.h> 47#include <ksyncmanager.h>
48//#include <koprefs.h> 48//#include <koprefs.h>
49 49
50class QWidgetStack; 50class QWidgetStack;
51class QSplitter; 51class QSplitter;
52class KopiCalendarFile; 52class KopiCalendarFile;
53class CalPrinter; 53class CalPrinter;
54class KOFilterView; 54class KOFilterView;
55class KOCalEditView; 55class KOCalEditView;
56class KOViewManager; 56class KOViewManager;
57class KODialogManager; 57class KODialogManager;
58class KOTodoView; 58class KOTodoView;
59class KDateNavigator; 59class KDateNavigator;
60class DateNavigatorContainer; 60class DateNavigatorContainer;
61class DateNavigator; 61class DateNavigator;
62class KOIncidenceEditor; 62class KOIncidenceEditor;
63class KDatePicker; 63class KDatePicker;
64class ResourceView; 64class ResourceView;
65class KOEventEditor; 65class KOEventEditor;
66class KOTodoEditor ; 66class KOTodoEditor ;
67class KOEventViewerDialog; 67class KOEventViewerDialog;
68class KOBeamPrefs; 68class KOBeamPrefs;
69class KSyncProfile; 69class KSyncProfile;
70class AlarmDialog; 70class AlarmDialog;
71class KCal::Attendee; 71class KCal::Attendee;
72 72
73namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
74 74
75using namespace KCal; 75using namespace KCal;
76 76
77/** 77/**
78 This is the main calendar widget. It provides the different vies on t he 78 This is the main calendar widget. It provides the different vies on t he
79 calendar data as well as the date navigator. It also handles synchronisation 79 calendar data as well as the date navigator. It also handles synchronisation
80 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
81 event editor, search dialog etc. 81 event editor, search dialog etc.
82 82
83 @short main calendar view widget 83 @short main calendar view widget
84 @author Cornelius Schumacher 84 @author Cornelius Schumacher
85*/ 85*/
86 86
87#include <qtextbrowser.h> 87#include <qtextbrowser.h>
88#include <qtextcodec.h> 88#include <qtextcodec.h>
89 89
90class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
91 Q_OBJECT 91 Q_OBJECT
92 public: 92 public:
93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
94 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
95 void setSource(const QString & n); 95 void setSource(const QString & n);
96 96
97 private: 97 private:
98 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
99 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
100 signals: 100 signals:
101 void showIncidence( QString uid); 101 void showIncidence( QString uid);
102}; 102};
103 103
104 104
105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 public: 108 public:
109 /** 109 /**
110 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
111 111
112 @param calendar calendar document 112 @param calendar calendar document
113 @param parent parent window 113 @param parent parent window
114 @param name Qt internal widget object name 114 @param name Qt internal widget object name
115 */ 115 */
116 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
119 const char *name = 0 ); 119 const char *name = 0 );
120 virtual ~CalendarView(); 120 virtual ~CalendarView();
121 121
122 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
123 123
124 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
125 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
126 126
127 QDate startDate(); 127 QDate startDate();
128 QDate endDate(); 128 QDate endDate();
129 129
130 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
131 QWidget *leftFrame(); 131 QWidget *leftFrame();
132 132
133 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
134 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
135 135
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 142
143 signals: 143 signals:
144 void save (); 144 void save ();
145 void saveStopTimer (); 145 void saveStopTimer ();
146 void tempDisableBR(bool); 146 void tempDisableBR(bool);
147 /** This todo has been modified */ 147 /** This todo has been modified */
148 void todoModified(Todo *, int); 148 void todoModified(Todo *, int);
149 149
150 /** when change is made to options dialog, the topwidget will catch this 150 /** when change is made to options dialog, the topwidget will catch this
151 * and emit this signal which notifies all widgets which have registered 151 * and emit this signal which notifies all widgets which have registered
152 * for notification to update their settings. */ 152 * for notification to update their settings. */
153 void configChanged(); 153 void configChanged();
154 /** emitted when the topwidget is closing down, so that any attached 154 /** emitted when the topwidget is closing down, so that any attached
155 child windows can also close. */ 155 child windows can also close. */
156 void closingDown(); 156 void closingDown();
157 /** emitted right before we die */ 157 /** emitted right before we die */
158 void closed(QWidget *); 158 void closed(QWidget *);
159 159
160 /** Emitted when state of modified flag changes */ 160 /** Emitted when state of modified flag changes */
161 void modifiedChanged(bool); 161 void modifiedChanged(bool);
162 void signalmodified(); 162 void signalmodified();
163 163
164 /** Emitted when state of read-only flag changes */ 164 /** Emitted when state of read-only flag changes */
165 void readOnlyChanged(bool); 165 void readOnlyChanged(bool);
166 166
167 /** Emitted when the unit of navigation changes */ 167 /** Emitted when the unit of navigation changes */
168 void changeNavStringPrev(const QString &); 168 void changeNavStringPrev(const QString &);
169 void changeNavStringNext(const QString &); 169 void changeNavStringNext(const QString &);
170 170
171 /** Emitted when state of events selection has changed and user is organizer*/ 171 /** Emitted when state of events selection has changed and user is organizer*/
172 void organizerEventsSelected(bool); 172 void organizerEventsSelected(bool);
173 /** Emitted when state of events selection has changed and user is attendee*/ 173 /** Emitted when state of events selection has changed and user is attendee*/
174 void groupEventsSelected(bool); 174 void groupEventsSelected(bool);
175 /** 175 /**
176 Emitted when an incidence gets selected. If the selection is cleared the 176 Emitted when an incidence gets selected. If the selection is cleared the
177 signal is emitted with 0 as argument. 177 signal is emitted with 0 as argument.
178 */ 178 */
179 void incidenceSelected( Incidence * ); 179 void incidenceSelected( Incidence * );
180 /** Emitted, when a todoitem is selected or deselected. */ 180 /** Emitted, when a todoitem is selected or deselected. */
181 void todoSelected( bool ); 181 void todoSelected( bool );
182 182
183 /** 183 /**
184 Emitted, when clipboard content changes. Parameter indicates if paste 184 Emitted, when clipboard content changes. Parameter indicates if paste
185 is possible or not. 185 is possible or not.
186 */ 186 */
187 void pasteEnabled(bool); 187 void pasteEnabled(bool);
188 188
189 /** Emitted, when the number of incoming messages has changed. */ 189 /** Emitted, when the number of incoming messages has changed. */
190 void numIncomingChanged(int); 190 void numIncomingChanged(int);
191 191
192 /** Emitted, when the number of outgoing messages has changed. */ 192 /** Emitted, when the number of outgoing messages has changed. */
193 void numOutgoingChanged(int); 193 void numOutgoingChanged(int);
194 194
195 /** Send status message, which can e.g. be displayed in the status bar. */ 195 /** Send status message, which can e.g. be displayed in the status bar. */
196 void statusMessage(const QString &); 196 void statusMessage(const QString &);
197 197
198 void calendarViewExpanded( bool ); 198 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 199 void updateSearchDialog();
200 void filtersUpdated(); 200 void filtersUpdated();
201 201
202 202
203 public slots: 203 public slots:
204 void slotResetFocus();
204 void nextConflict( bool all, bool allday ); 205 void nextConflict( bool all, bool allday );
205 void conflictAll(); 206 void conflictAll();
206 void conflictAllday(); 207 void conflictAllday();
207 void conflictNotAll(); 208 void conflictNotAll();
208 void setCalReadOnly( int id, bool readO ); 209 void setCalReadOnly( int id, bool readO );
209 void checkAlarms(); 210 void checkAlarms();
210 void checkFiles(); 211 void checkFiles();
211 void slotprintSelInc(); 212 void slotprintSelInc();
212 void showNextAlarms(); 213 void showNextAlarms();
213 void showOpenError(); 214 void showOpenError();
214 void watchSavedFile(); 215 void watchSavedFile();
215 void recheckTimerAlarm(); 216 void recheckTimerAlarm();
216 void checkNextTimerAlarm(); 217 void checkNextTimerAlarm();
217 void addAlarm(const QDateTime &qdt, const QString &noti ); 218 void addAlarm(const QDateTime &qdt, const QString &noti );
218 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
219 void removeAlarm(const QDateTime &qdt, const QString &noti ); 220 void removeAlarm(const QDateTime &qdt, const QString &noti );
220 221
221 /** options dialog made a changed to the configuration. we catch this 222 /** options dialog made a changed to the configuration. we catch this
222 * and notify all widgets which need to update their configuration. */ 223 * and notify all widgets which need to update their configuration. */
223 void updateConfig(); 224 void updateConfig();
224 225
225 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 226 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
226 const QStringList& anniversaryList, const QStringList& realNameList, 227 const QStringList& anniversaryList, const QStringList& realNameList,
227 const QStringList& emailList, const QStringList& assembledNameList, 228 const QStringList& emailList, const QStringList& assembledNameList,
228 const QStringList& uidList); 229 const QStringList& uidList);
229 230
230 /** 231 /**
231 Load calendar from file \a filename. If \a merge is true, load 232 Load calendar from file \a filename. If \a merge is true, load
232 calendar into existing one, if it is false, clear calendar, before 233 calendar into existing one, if it is false, clear calendar, before
233 loading. Return true, if calendar could be successfully loaded. 234 loading. Return true, if calendar could be successfully loaded.
234 */ 235 */
235 bool openCalendar(QString filename, bool merge=false); 236 bool openCalendar(QString filename, bool merge=false);
236 bool loadCalendars(); 237 bool loadCalendars();
237 bool saveCalendars(); 238 bool saveCalendars();
238 bool restoreCalendarSettings(); 239 bool restoreCalendarSettings();
239 bool addCalendar( KopiCalendarFile * ); 240 bool addCalendar( KopiCalendarFile * );
240 void addCalendarId( int id ); 241 void addCalendarId( int id );
241 bool syncCalendar(QString filename,int mode = 0 ); 242 bool syncCalendar(QString filename,int mode = 0 );
242 243
243 /** 244 /**
244 Save calendar data to file. Return true if calendar could be 245 Save calendar data to file. Return true if calendar could be
245 successfully saved. 246 successfully saved.
246 */ 247 */
247 bool saveCalendar(QString filename); 248 bool saveCalendar(QString filename);
248 249
249 /** 250 /**
250 Close calendar. Clear calendar data and reset views to display an empty 251 Close calendar. Clear calendar data and reset views to display an empty
251 calendar. 252 calendar.
252 */ 253 */
253 void closeCalendar(); 254 void closeCalendar();
254 255
255 /** Archive old events of calendar */ 256 /** Archive old events of calendar */
256 void archiveCalendar(); 257 void archiveCalendar();
257 258
258 void showIncidence(); 259 void showIncidence();
259 void editIncidence(); 260 void editIncidence();
260 void editIncidenceDescription(); 261 void editIncidenceDescription();
261 void deleteIncidence(); 262 void deleteIncidence();
262 void cloneIncidence(); 263 void cloneIncidence();
263 void moveIncidence(); 264 void moveIncidence();
264 void beamIncidence(); 265 void beamIncidence();
265 void toggleCancelIncidence(); 266 void toggleCancelIncidence();
266 267
267 /** create an editeventwin with supplied date/time, and if bool is true, 268 /** create an editeventwin with supplied date/time, and if bool is true,
268 * make the event take all day. */ 269 * make the event take all day. */
269 void newEvent(QDateTime, QDateTime, bool allDay ); 270 void newEvent(QDateTime, QDateTime, bool allDay );
270 void newEvent(QDateTime, QDateTime); 271 void newEvent(QDateTime, QDateTime);
271 void newEvent(QDateTime fh); 272 void newEvent(QDateTime fh);
272 void newEvent(QDate dt); 273 void newEvent(QDate dt);
273 /** create new event without having a date hint. Takes current date as 274 /** create new event without having a date hint. Takes current date as
274 default hint. */ 275 default hint. */
275 void newEvent(); 276 void newEvent();
276 void newFloatingEvent(); 277 void newFloatingEvent();
277 278
278 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
279 void showIncidence(Incidence *); 280 void showIncidence(Incidence *);
280 void showIncidence(QString uid); 281 void showIncidence(QString uid);
281 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
282 void editIncidence(Incidence *); 283 void editIncidence(Incidence *);
283 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
284 void deleteIncidence(Incidence *); 285 void deleteIncidence(Incidence *);
285 void cloneIncidence(Incidence *); 286 void cloneIncidence(Incidence *);
286 void cancelIncidence(Incidence *); 287 void cancelIncidence(Incidence *);
287 /** Create an editor for the supplied event. */ 288 /** Create an editor for the supplied event. */
288 void editEvent(Event *); 289 void editEvent(Event *);
289 /** Delete the supplied event. */ 290 /** Delete the supplied event. */
290 void deleteEvent(Event *); 291 void deleteEvent(Event *);
291 /** Delete the event with the given unique ID. Returns false, if event wasn't 292 /** Delete the event with the given unique ID. Returns false, if event wasn't
292 found. */ 293 found. */
293 bool deleteEvent(const QString &uid); 294 bool deleteEvent(const QString &uid);
294 /** Create a read-only viewer dialog for the supplied event. */ 295 /** Create a read-only viewer dialog for the supplied event. */
295 void showEvent(Event *); 296 void showEvent(Event *);
296 297
297 void editJournal(Journal *); 298 void editJournal(Journal *);
298 void showJournal(Journal *); 299 void showJournal(Journal *);
299 void deleteJournal(Journal *); 300 void deleteJournal(Journal *);
300 /** Create an editor dialog for a todo */ 301 /** Create an editor dialog for a todo */
301 void editTodo(Todo *); 302 void editTodo(Todo *);
302 /** Create a read-only viewer dialog for the supplied todo */ 303 /** Create a read-only viewer dialog for the supplied todo */
303 void showTodo(Todo *); 304 void showTodo(Todo *);
304 /** create new todo */ 305 /** create new todo */
305 void newTodo(); 306 void newTodo();
306 void newTodoDateTime(QDateTime, bool allday); 307 void newTodoDateTime(QDateTime, bool allday);
307 /** create new todo with a parent todo */ 308 /** create new todo with a parent todo */
308 void newSubTodo(); 309 void newSubTodo();
309 /** create new todo with a parent todo */ 310 /** create new todo with a parent todo */
310 void newSubTodo(Todo *); 311 void newSubTodo(Todo *);
311 /** Delete todo */ 312 /** Delete todo */
312 void deleteTodo(Todo *); 313 void deleteTodo(Todo *);
313 314
314 315
315 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
316 * emitted as result. */ 317 * emitted as result. */
317 void checkClipboard(); 318 void checkClipboard();
318 319
319 /** using the KConfig associated with the kapp variable, read in the 320 /** using the KConfig associated with the kapp variable, read in the
320 * settings from the config file. 321 * settings from the config file.
321 */ 322 */
322 void readSettings(); 323 void readSettings();
323 324
324 /** write current state to config file. */ 325 /** write current state to config file. */
325 void writeSettings(); 326 void writeSettings();
326 327
327 /** read settings for calendar filters */ 328 /** read settings for calendar filters */
328 void readFilterSettings(KConfig *config); 329 void readFilterSettings(KConfig *config);
329 330
330 /** write settings for calendar filters */ 331 /** write settings for calendar filters */
331 void writeFilterSettings(KConfig *config); 332 void writeFilterSettings(KConfig *config);
332 333
333 /** passes on the message that an event has changed to the currently 334 /** passes on the message that an event has changed to the currently
334 * activated view so that it can make appropriate display changes. */ 335 * activated view so that it can make appropriate display changes. */
335 void changeEventDisplay(Event *, int); 336 void changeEventDisplay(Event *, int);
336 void changeIncidenceDisplay(Incidence *, int); 337 void changeIncidenceDisplay(Incidence *, int);
337 void changeTodoDisplay(Todo *, int); 338 void changeTodoDisplay(Todo *, int);
338 339
339 void eventAdded(Event *); 340 void eventAdded(Event *);
340 void eventChanged(Event *); 341 void eventChanged(Event *);
341 void eventToBeDeleted(Event *); 342 void eventToBeDeleted(Event *);
342 void eventDeleted(); 343 void eventDeleted();
343 344
344 void todoAdded(Todo *); 345 void todoAdded(Todo *);
345 void todoChanged(Todo *); 346 void todoChanged(Todo *);
346 void todoToBeDeleted(Todo *); 347 void todoToBeDeleted(Todo *);
347 void todoDeleted(); 348 void todoDeleted();
348 349
349 void updateView(const QDate &start, const QDate &end); 350 void updateView(const QDate &start, const QDate &end);
350 void updateView(); 351 void updateView();
351 void clearAllViews(); 352 void clearAllViews();
352 353
353 /** Full update of visible todo views */ 354 /** Full update of visible todo views */
354 void updateTodoViews(); 355 void updateTodoViews();
355 356
356 void updateUnmanagedViews(); 357 void updateUnmanagedViews();
357 358
358 /** cut the current appointment to the clipboard */ 359 /** cut the current appointment to the clipboard */
359 void edit_cut(); 360 void edit_cut();
360 361
361 /** copy the current appointment(s) to the clipboard */ 362 /** copy the current appointment(s) to the clipboard */
362 void edit_copy(); 363 void edit_copy();
363 364
364 /** paste the current vobject(s) in the clipboard buffer into calendar */ 365 /** paste the current vobject(s) in the clipboard buffer into calendar */
365 void edit_paste(); 366 void edit_paste();
366 367
367 /** edit viewing and configuration options. */ 368 /** edit viewing and configuration options. */
368 void edit_options(); 369 void edit_options();
369 void edit_global_options(); 370 void edit_global_options();
370 /** 371 /**
371 Functions for printing, previewing a print, and setting up printing 372 Functions for printing, previewing a print, and setting up printing
372 parameters. 373 parameters.
373 */ 374 */
374 void print(); 375 void print();
375 void printSetup(); 376 void printSetup();
376 void printPreview(); 377 void printPreview();
377 378
378 /** Export as iCalendar file */ 379 /** Export as iCalendar file */
379 void exportICalendar(); 380 void exportICalendar();
380 381
381 /** Export as vCalendar file */ 382 /** Export as vCalendar file */
382 bool exportVCalendar( QString fn); 383 bool exportVCalendar( QString fn);
383 384
384 /** pop up a dialog to show an existing appointment. */ 385 /** pop up a dialog to show an existing appointment. */
385 void appointment_show(); 386 void appointment_show();
386 /** 387 /**
387 * pop up an Appointment Dialog to edit an existing appointment.Get 388 * pop up an Appointment Dialog to edit an existing appointment.Get
388 * information on the appointment from the list of unique IDs that is 389 * information on the appointment from the list of unique IDs that is
389 * currently in the View, called currIds. 390 * currently in the View, called currIds.
390 */ 391 */
391 void appointment_edit(); 392 void appointment_edit();
392 /** 393 /**
393 * pop up dialog confirming deletion of currently selected event in the 394 * pop up dialog confirming deletion of currently selected event in the
394 * View. 395 * View.
395 */ 396 */
396 void appointment_delete(); 397 void appointment_delete();
397 398
398 /** mails the currently selected event to a particular user as a vCalendar 399 /** mails the currently selected event to a particular user as a vCalendar
399 attachment. */ 400 attachment. */
400 void action_mail(); 401 void action_mail();
401 402
402 /* frees a subtodo from it's relation */ 403 /* frees a subtodo from it's relation */
403 void todo_unsub( Todo * ); 404 void todo_unsub( Todo * );
404 void todo_resub( Todo * parent, Todo * sub ); 405 void todo_resub( Todo * parent, Todo * sub );
405 406
406 /** Take ownership of selected event. */ 407 /** Take ownership of selected event. */
407 void takeOverEvent(); 408 void takeOverEvent();
408 409
409 /** Take ownership of all events in calendar. */ 410 /** Take ownership of all events in calendar. */
410 void takeOverCalendar(); 411 void takeOverCalendar();
411 412
412 /** query whether or not the calendar is "dirty". */ 413 /** query whether or not the calendar is "dirty". */
413 bool isModified(); 414 bool isModified();
414 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 415 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
415 void setModified(bool modified=true); 416 void setModified(bool modified=true);
416 417
417 /** query if the calendar is read-only. */ 418 /** query if the calendar is read-only. */
418 bool isReadOnly(); 419 bool isReadOnly();
419 /** set state of calendar to read-only */ 420 /** set state of calendar to read-only */
420 void setReadOnly(bool readOnly=true); 421 void setReadOnly(bool readOnly=true);
421 422
422 void eventUpdated(Incidence *); 423 void eventUpdated(Incidence *);
423 424
424 /* iTIP scheduling actions */ 425 /* iTIP scheduling actions */
425 void schedule_publish(Incidence *incidence = 0); 426 void schedule_publish(Incidence *incidence = 0);
426 void schedule_request(Incidence *incidence = 0); 427 void schedule_request(Incidence *incidence = 0);
427 void schedule_refresh(Incidence *incidence = 0); 428 void schedule_refresh(Incidence *incidence = 0);
428 void schedule_cancel(Incidence *incidence = 0); 429 void schedule_cancel(Incidence *incidence = 0);
429 void schedule_add(Incidence *incidence = 0); 430 void schedule_add(Incidence *incidence = 0);
430 void schedule_reply(Incidence *incidence = 0); 431 void schedule_reply(Incidence *incidence = 0);
431 void schedule_counter(Incidence *incidence = 0); 432 void schedule_counter(Incidence *incidence = 0);
432 void schedule_declinecounter(Incidence *incidence = 0); 433 void schedule_declinecounter(Incidence *incidence = 0);
433 void schedule_publish_freebusy(int daysToPublish = 30); 434 void schedule_publish_freebusy(int daysToPublish = 30);
434 435
435 void openAddressbook(); 436 void openAddressbook();
436 437
437 void editFilters(); 438 void editFilters();
438 void toggleFilerEnabled(); 439 void toggleFilerEnabled();
439 QPtrList<CalFilter> filters(); 440 QPtrList<CalFilter> filters();
440 void toggleFilter(); 441 void toggleFilter();
441 void showFilter(bool visible); 442 void showFilter(bool visible);
442 void updateFilter(); 443 void updateFilter();
443 void filterEdited(); 444 void filterEdited();
444 void selectFilter( int ); 445 void selectFilter( int );
445 KOFilterView *filterView(); 446 KOFilterView *filterView();
446 447
447 void showIntro(); 448 void showIntro();
448 449
449 /** Move the curdatepient view date to today */ 450 /** Move the curdatepient view date to today */
450 void goToday(); 451 void goToday();
451 452
452 /** Move to the next date(s) in the current view */ 453 /** Move to the next date(s) in the current view */
453 void goNext(); 454 void goNext();
454 455
455 /** Move to the previous date(s) in the current view */ 456 /** Move to the previous date(s) in the current view */
456 void goPrevious(); 457 void goPrevious();
457 /** Move to the next date(s) in the current view */ 458 /** Move to the next date(s) in the current view */
458 void goNextMonth(); 459 void goNextMonth();
459 460
460 /** Move to the previous date(s) in the current view */ 461 /** Move to the previous date(s) in the current view */
461 void goPreviousMonth(); 462 void goPreviousMonth();
462 463
463 void toggleExpand(); 464 void toggleExpand();
464 void toggleDateNavigatorWidget(); 465 void toggleDateNavigatorWidget();
465 void toggleAllDaySize(); 466 void toggleAllDaySize();
466 467
467 /** Look for new messages in the inbox */ 468 /** Look for new messages in the inbox */
468 void lookForIncomingMessages(); 469 void lookForIncomingMessages();
469 /** Look for new messages in the outbox */ 470 /** Look for new messages in the outbox */
470 void lookForOutgoingMessages(); 471 void lookForOutgoingMessages();
471 472
472 void processMainViewSelection( Incidence * ); 473 void processMainViewSelection( Incidence * );
473 void processTodoListSelection( Incidence * ); 474 void processTodoListSelection( Incidence * );
474 475
475 void processIncidenceSelection( Incidence * ); 476 void processIncidenceSelection( Incidence * );
476 477
477 void purgeCompleted(); 478 void purgeCompleted();
478 bool removeCompletedSubTodos( Todo* ); 479 bool removeCompletedSubTodos( Todo* );
479 void slotCalendarChanged(); 480 void slotCalendarChanged();
480 bool importBday(); 481 bool importBday();
481 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 482 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
482 bool importQtopia( const QString &categoriesFile, 483 bool importQtopia( const QString &categoriesFile,
483 const QString &datebookFile, 484 const QString &datebookFile,
484 const QString &tasklistFile ); 485 const QString &tasklistFile );
485 void syncExternal( int mode ); 486 void syncExternal( int mode );
486 void slotSelectPickerDate( QDate ) ; 487 void slotSelectPickerDate( QDate ) ;
487 void showDatePicker() ; 488 void showDatePicker() ;
488 void showDatePickerPopup() ; 489 void showDatePickerPopup() ;
489 void moveIncidence(Incidence *) ; 490 void moveIncidence(Incidence *) ;
490 void beamIncidence(Incidence *) ; 491 void beamIncidence(Incidence *) ;
491 void beamCalendar() ; 492 void beamCalendar() ;
492 void beamFilteredCalendar() ; 493 void beamFilteredCalendar() ;
493 void beamIncidenceList(QPtrList<Incidence>) ; 494 void beamIncidenceList(QPtrList<Incidence>) ;
494 void manageCategories(); 495 void manageCategories();
495 void editCategories(); 496 void editCategories();
496 int addCategories(); 497 int addCategories();
497 void removeCategories(); 498 void removeCategories();
498 void setSyncDevice( QString ); 499 void setSyncDevice( QString );
499 void setSyncName( QString ); 500 void setSyncName( QString );
500 void showDay( QDate ); 501 void showDay( QDate );
501 void undo_delete(); 502 void undo_delete();
502 protected slots: 503 protected slots:
503 void resetFocus(); 504 void resetFocus();
504 void scrollBarValue(int); 505 void scrollBarValue(int);
505 void slotViewerClosed(); 506 void slotViewerClosed();
506 void timerAlarm(); 507 void timerAlarm();
507 void suspendAlarm(); 508 void suspendAlarm();
508 void beamDone( Ir *ir ); 509 void beamDone( Ir *ir );
509 /** Select a view or adapt the current view to display the specified dates. */ 510 /** Select a view or adapt the current view to display the specified dates. */
510 void showDates( const KCal::DateList & ); 511 void showDates( const KCal::DateList & );
511 void selectWeekNum ( int ); 512 void selectWeekNum ( int );
512 void checkConflictForEvent(); 513 void checkConflictForEvent();
513 514
514 public: 515 public:
515 // show a standard warning 516 // show a standard warning
516 // returns KMsgBox::yesNoCancel() 517 // returns KMsgBox::yesNoCancel()
517 int msgCalModified(); 518 int msgCalModified();
518 virtual bool sync(KSyncManager* manager, QString filename, int mode); 519 virtual bool sync(KSyncManager* manager, QString filename, int mode);
519 520
520 virtual bool syncExternal(KSyncManager* manager, QString resource); 521 virtual bool syncExternal(KSyncManager* manager, QString resource);
521 virtual void removeSyncInfo( QString syncProfile); 522 virtual void removeSyncInfo( QString syncProfile);
522 void setSyncManager(KSyncManager* manager); 523 void setSyncManager(KSyncManager* manager);
523 void setLoadedFileVersion(QDateTime); 524 void setLoadedFileVersion(QDateTime);
524 bool checkFileVersion(QString fn); 525 bool checkFileVersion(QString fn);
525 bool checkAllFileVersions(); 526 bool checkAllFileVersions();
526 bool checkFileChanged(QString fn); 527 bool checkFileChanged(QString fn);
527 Event* getLastSyncEvent(); 528 Event* getLastSyncEvent();
528 /** Adapt navigation units correpsonding to step size of navigation of the 529 /** Adapt navigation units correpsonding to step size of navigation of the
529 * current view. 530 * current view.
530 */ 531 */
531 void adaptNavigationUnits(); 532 void adaptNavigationUnits();
532 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 533 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
533 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 534 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
534 //Attendee* getYourAttendee(Event *event); 535 //Attendee* getYourAttendee(Event *event);
535 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 536 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
536 void setScrollBarStep(int val ); 537 void setScrollBarStep(int val );
537 538
538 protected: 539 protected:
539 Event *mConflictingEvent; 540 Event *mConflictingEvent;
540 void schedule(Scheduler::Method, Incidence *incidence = 0); 541 void schedule(Scheduler::Method, Incidence *incidence = 0);
541 542
542 // returns KMsgBox::OKCandel() 543 // returns KMsgBox::OKCandel()
543 int msgItemDelete(const QString name); 544 int msgItemDelete(const QString name);
544 void showEventEditor(); 545 void showEventEditor();
545 void showTodoEditor(); 546 void showTodoEditor();
546 Todo *selectedTodo(); 547 Todo *selectedTodo();
547 private: 548 private:
548#ifdef DESKTOP_VERSION 549#ifdef DESKTOP_VERSION
549 QScrollBar * mDateScrollBar; 550 QScrollBar * mDateScrollBar;
550#endif 551#endif
551 QDateTime mNextAlarmDateTime; 552 QDateTime mNextAlarmDateTime;
552 bool mViewerCallerIsSearchDialog; 553 bool mViewerCallerIsSearchDialog;
553 bool mBlockShowDates; 554 bool mBlockShowDates;
554 KSyncManager* mSyncManager; 555 KSyncManager* mSyncManager;
555 AlarmDialog * mAlarmDialog; 556 AlarmDialog * mAlarmDialog;
556 QString mAlarmNotification; 557 QString mAlarmNotification;
557 QString mSuspendAlarmNotification; 558 QString mSuspendAlarmNotification;
558 QTimer* mSuspendTimer; 559 QTimer* mSuspendTimer;
559 QTimer* mAlarmTimer; 560 QTimer* mAlarmTimer;
560 QTimer* mRecheckAlarmTimer; 561 QTimer* mRecheckAlarmTimer;
561 void computeAlarm( QString ); 562 void computeAlarm( QString );
562 void startAlarm( QString, QString ); 563 void startAlarm( QString, QString );
563 void setSyncEventsReadOnly(); 564 void setSyncEventsReadOnly();
564 565
565 QDateTime loadedFileVersion; 566 QDateTime loadedFileVersion;
566 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 567 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
567 void checkExternalId( Incidence * inc ); 568 void checkExternalId( Incidence * inc );
568 int mGlobalSyncMode; 569 int mGlobalSyncMode;
569 QString mCurrentSyncDevice; 570 QString mCurrentSyncDevice;
570 QString mCurrentSyncName; 571 QString mCurrentSyncName;
571 void init(); 572 void init();
572 int mDatePickerMode; 573 int mDatePickerMode;
573 bool mFlagEditDescription; 574 bool mFlagEditDescription;
574 QDateTime mLastCalendarSync; 575 QDateTime mLastCalendarSync;
575 void createPrinter(); 576 void createPrinter();
576 577
577 void calendarModified( bool, Calendar * ); 578 void calendarModified( bool, Calendar * );
578 579
579 CalPrinter *mCalPrinter; 580 CalPrinter *mCalPrinter;
580 581
581 QSplitter *mPanner; 582 QSplitter *mPanner;
582 QSplitter *mLeftSplitter; 583 QSplitter *mLeftSplitter;
583 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 584 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
584 QWidgetStack *mRightFrame; 585 QWidgetStack *mRightFrame;
585 586
586 KDatePicker* mDatePicker; 587 KDatePicker* mDatePicker;
587 QVBox* mDateFrame; 588 QVBox* mDateFrame;
588 589
589 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 590 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
590 591
591 KOFilterView *mFilterView; 592 KOFilterView *mFilterView;
592 KOCalEditView *mCalEditView; 593 KOCalEditView *mCalEditView;
593 594
594 ResourceView *mResourceView; 595 ResourceView *mResourceView;
595 596
596 // calendar object for this viewing instance 597 // calendar object for this viewing instance
597 Calendar *mCalendar; 598 Calendar *mCalendar;
598 599
599 CalendarResourceManager *mResourceManager; 600 CalendarResourceManager *mResourceManager;
600 601
601 FileStorage *mStorage; 602 FileStorage *mStorage;
602 603
603 DateNavigator *mNavigator; 604 DateNavigator *mNavigator;
604 605
605 KOViewManager *mViewManager; 606 KOViewManager *mViewManager;
606 KODialogManager *mDialogManager; 607 KODialogManager *mDialogManager;
607 608
608 // Calendar filters 609 // Calendar filters
609 QPtrList<CalFilter> mFilters; 610 QPtrList<CalFilter> mFilters;
610 611
611 // various housekeeping variables. 612 // various housekeeping variables.
612 bool mModified; // flag indicating if calendar is modified 613 bool mModified; // flag indicating if calendar is modified
613 bool mReadOnly; // flag indicating if calendar is read-only 614 bool mReadOnly; // flag indicating if calendar is read-only
614 QDate mSaveSingleDate; 615 QDate mSaveSingleDate;
615 616
616 Incidence *mSelectedIncidence; 617 Incidence *mSelectedIncidence;
617 Incidence *mMoveIncidence; 618 Incidence *mMoveIncidence;
618 QDate mMoveIncidenceOldDate; 619 QDate mMoveIncidenceOldDate;
619 KOTodoView *mTodoList; 620 KOTodoView *mTodoList;
620 KOEventEditor * mEventEditor; 621 KOEventEditor * mEventEditor;
621 KOTodoEditor * mTodoEditor; 622 KOTodoEditor * mTodoEditor;
622 KOEventViewerDialog * mEventViewerDialog; 623 KOEventViewerDialog * mEventViewerDialog;
623 void keyPressEvent ( QKeyEvent *e) ; 624 void keyPressEvent ( QKeyEvent *e) ;
624 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 625 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
625}; 626};
626 627
627 628
628class CalendarViewVisitor : public Incidence::Visitor 629class CalendarViewVisitor : public Incidence::Visitor
629{ 630{
630 public: 631 public:
631 CalendarViewVisitor() : mView( 0 ) {} 632 CalendarViewVisitor() : mView( 0 ) {}
632 633
633 bool act( Incidence *incidence, CalendarView *view ) 634 bool act( Incidence *incidence, CalendarView *view )
634 { 635 {
635 mView = view; 636 mView = view;
636 return incidence->accept( *this ); 637 return incidence->accept( *this );
637 } 638 }
638 639
639 protected: 640 protected:
640 CalendarView *mView; 641 CalendarView *mView;
641}; 642};
642 643
643class ShowIncidenceVisitor : public CalendarViewVisitor 644class ShowIncidenceVisitor : public CalendarViewVisitor
644{ 645{
645 protected: 646 protected:
646 bool visit( Event *event ) { mView->showEvent( event ); return true; } 647 bool visit( Event *event ) { mView->showEvent( event ); return true; }
647 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 648 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
648 bool visit( Journal * j ) { mView->showJournal( j );return true; } 649 bool visit( Journal * j ) { mView->showJournal( j );return true; }
649}; 650};
650 651
651class EditIncidenceVisitor : public CalendarViewVisitor 652class EditIncidenceVisitor : public CalendarViewVisitor
652{ 653{
653 protected: 654 protected:
654 bool visit( Event *event ) { mView->editEvent( event ); return true; } 655 bool visit( Event *event ) { mView->editEvent( event ); return true; }
655 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 656 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
656 bool visit( Journal *j ) { mView->editJournal( j); return true; } 657 bool visit( Journal *j ) { mView->editJournal( j); return true; }
657}; 658};
658 659
659class DeleteIncidenceVisitor : public CalendarViewVisitor 660class DeleteIncidenceVisitor : public CalendarViewVisitor
660{ 661{
661 protected: 662 protected:
662 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 663 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
663 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 664 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
664 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 665 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
665}; 666};
666 667
667#endif 668#endif
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 779f12e..0dd5ef5 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1,2265 +1,2268 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 Marcus Bains line. 5 Marcus Bains line.
6 Copyright (c) 2001 Ali Rahimi 6 Copyright (c) 2001 Ali Rahimi
7 7
8 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 (at your option) any later version.
12 12
13 This program is distributed in the hope that it will be useful, 13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 GNU General Public License for more details.
17 17
18 You should have received a copy of the GNU General Public License 18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 21
22 As a special exception, permission is given to link this program 22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable, 23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution. 24 without including the source code for Qt in the source distribution.
25*/ 25*/
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#define protected public 28#define protected public
29#include <qwidget.h> 29#include <qwidget.h>
30#undef protected 30#undef protected
31#endif 31#endif
32#include <qintdict.h> 32#include <qintdict.h>
33#include <qdatetime.h> 33#include <qdatetime.h>
34#include <qapplication.h> 34#include <qapplication.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <qcursor.h> 36#include <qcursor.h>
37#include <qpainter.h> 37#include <qpainter.h>
38 38
39#include <kdebug.h> 39#include <kdebug.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kglobal.h> 42#include <kglobal.h>
43 43
44#include "koagendaitem.h" 44#include "koagendaitem.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "koglobals.h" 46#include "koglobals.h"
47 47
48#include "koagenda.h" 48#include "koagenda.h"
49 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63 63
64//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
66 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
67{ 67{
68 setLineWidth(0); 68 setLineWidth(0);
69 setMargin(0); 69 setMargin(0);
70 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
71 minutes = new QTimer(this); 71 minutes = new QTimer(this);
72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
73 minutes->start(0, true); 73 minutes->start(0, true);
74 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
76 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
77 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
78 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
79 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
80 80
81 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
82 82
83 oldToday = -1; 83 oldToday = -1;
84} 84}
85 85
86MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
87{ 87{
88 //delete minutes; 88 //delete minutes;
89} 89}
90 90
91int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
92{ 92{
93 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
94 94
95 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
96 DateList::ConstIterator it; 96 DateList::ConstIterator it;
97 int col = 0; 97 int col = 0;
98 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
99 if((*it) == currentDate) 99 if((*it) == currentDate)
100 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
101 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
102 ++col; 102 ++col;
103 } 103 }
104 104
105 return -1; 105 return -1;
106} 106}
107void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
108{ 108{
109 updateLocation(); 109 updateLocation();
110} 110}
111void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
112{ 112{
113 113
114 QTime tim = QTime::currentTime(); 114 QTime tim = QTime::currentTime();
115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); 115 //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1());
116 if((tim.hour() == 0) && (oldTime.hour()==23)) 116 if((tim.hour() == 0) && (oldTime.hour()==23))
117 recalculate = true; 117 recalculate = true;
118 118
119 int mins = tim.hour()*60 + tim.minute(); 119 int mins = tim.hour()*60 + tim.minute();
120 int minutesPerCell = 24 * 60 / agenda->rows(); 120 int minutesPerCell = 24 * 60 / agenda->rows();
121 int y = mins*agenda->gridSpacingY()/minutesPerCell; 121 int y = mins*agenda->gridSpacingY()/minutesPerCell;
122 int today = recalculate ? todayColumn() : oldToday; 122 int today = recalculate ? todayColumn() : oldToday;
123 int x = agenda->gridSpacingX()*today; 123 int x = agenda->gridSpacingX()*today;
124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); 124 bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled);
125 125
126 oldTime = tim; 126 oldTime = tim;
127 oldToday = today; 127 oldToday = today;
128 128
129 if(disabled || (today<0)) { 129 if(disabled || (today<0)) {
130 hide(); mTimeBox->hide(); 130 hide(); mTimeBox->hide();
131 return; 131 return;
132 } else { 132 } else {
133 show(); mTimeBox->show(); 133 show(); mTimeBox->show();
134 } 134 }
135 135
136 if(recalculate) 136 if(recalculate)
137 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
138 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
139 raise(); 139 raise();
140 140
141 if(recalculate) 141 if(recalculate)
142 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
144 144
145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
146 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
147 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
148 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
149 // narrower than the other columns. 149 // narrower than the other columns.
150 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
151 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
153 y-mTimeBox->height()); 153 y-mTimeBox->height());
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 int secs = QTime::currentTime().second(); 156 int secs = QTime::currentTime().second();
157 minutes->start( (60 - secs +1)*1000 ,true); 157 minutes->start( (60 - secs +1)*1000 ,true);
158} 158}
159 159
160 160
161//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
162 162
163 163
164/* 164/*
165 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
166*/ 166*/
167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
168 const char *name,WFlags f) : 168 const char *name,WFlags f) :
169 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
170{ 170{
171 171
172 mAllAgendaPopup = 0; 172 mAllAgendaPopup = 0;
173 mColumns = columns; 173 mColumns = columns;
174 mRows = rows; 174 mRows = rows;
175 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
176 mAllDayMode = false; 176 mAllDayMode = false;
177#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
179#endif 179#endif
180 mHolidayMask = 0; 180 mHolidayMask = 0;
181 init(); 181 init();
182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); 182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
183} 183}
184 184
185/* 185/*
186 Create an agenda widget with columns columns and one row. This is used for 186 Create an agenda widget with columns columns and one row. This is used for
187 all-day events. 187 all-day events.
188*/ 188*/
189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
190 QScrollView(parent,name,f) 190 QScrollView(parent,name,f)
191{ 191{
192 mAllAgendaPopup = 0; 192 mAllAgendaPopup = 0;
193 blockResize = false; 193 blockResize = false;
194 mColumns = columns; 194 mColumns = columns;
195 mRows = 1; 195 mRows = 1;
196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
197 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 197 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
198 mAllDayMode = true; 198 mAllDayMode = true;
199#ifndef DESKTOP_VERSION 199#ifndef DESKTOP_VERSION
200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
201#endif 201#endif
202 mHolidayMask = 0; 202 mHolidayMask = 0;
203 init(); 203 init();
204} 204}
205 205
206 206
207KOAgenda::~KOAgenda() 207KOAgenda::~KOAgenda()
208{ 208{
209 if(mMarcusBains) delete mMarcusBains; 209 if(mMarcusBains) delete mMarcusBains;
210 210
211} 211}
212 212
213Incidence *KOAgenda::selectedIncidence() const 213Incidence *KOAgenda::selectedIncidence() const
214{ 214{
215 return (mSelectedItem ? mSelectedItem->incidence() : 0); 215 return (mSelectedItem ? mSelectedItem->incidence() : 0);
216} 216}
217 217
218 218
219QDate KOAgenda::selectedIncidenceDate() const 219QDate KOAgenda::selectedIncidenceDate() const
220{ 220{
221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
222} 222}
223 223
224 224
225void KOAgenda::init() 225void KOAgenda::init()
226{ 226{
227 mPopupTimer = new QTimer(this); 227 mPopupTimer = new QTimer(this);
228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
229 229
230 mNewItemPopup = new QPopupMenu( this ); 230 mNewItemPopup = new QPopupMenu( this );
231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 231 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
232 QString pathString = ""; 232 QString pathString = "";
233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 233 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
234 if ( QApplication::desktop()->width() < 480 ) 234 if ( QApplication::desktop()->width() < 480 )
235 pathString += "icons16/"; 235 pathString += "icons16/";
236 } else 236 } else
237 pathString += "iconsmini/"; 237 pathString += "iconsmini/";
238 238
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
241 mNewItemPopup->insertSeparator ( ); 241 mNewItemPopup->insertSeparator ( );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 245 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); 246 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 247 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
248#ifndef _WIN32_ 248#ifndef _WIN32_
249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 249 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
250 viewport()->setWFlags ( wflags); 250 viewport()->setWFlags ( wflags);
251#endif 251#endif
252 mGridSpacingX = 80; 252 mGridSpacingX = 80;
253 mResizeBorderWidth = 8; 253 mResizeBorderWidth = 8;
254 mScrollBorderWidth = 8; 254 mScrollBorderWidth = 8;
255 mScrollDelay = 30; 255 mScrollDelay = 30;
256 mScrollOffset = 10; 256 mScrollOffset = 10;
257 mPaintPixmap.resize( 20,20); 257 mPaintPixmap.resize( 20,20);
258 //enableClipper(true); 258 //enableClipper(true);
259 259
260 // Grab key strokes for keyboard navigation of agenda. Seems to have no 260 // Grab key strokes for keyboard navigation of agenda. Seems to have no
261 // effect. Has to be fixed. 261 // effect. Has to be fixed.
262 setFocusPolicy(WheelFocus); 262 setFocusPolicy(WheelFocus);
263 263
264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 264 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 265 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 266 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
267 267
268 mStartCellX = 0; 268 mStartCellX = 0;
269 mStartCellY = 0; 269 mStartCellY = 0;
270 mCurrentCellX = 0; 270 mCurrentCellX = 0;
271 mCurrentCellY = 0; 271 mCurrentCellY = 0;
272 272
273 mSelectionCellX = 0; 273 mSelectionCellX = 0;
274 mSelectionYTop = 0; 274 mSelectionYTop = 0;
275 mSelectionHeight = 0; 275 mSelectionHeight = 0;
276 276
277 mOldLowerScrollValue = -1; 277 mOldLowerScrollValue = -1;
278 mOldUpperScrollValue = -1; 278 mOldUpperScrollValue = -1;
279 279
280 mClickedItem = 0; 280 mClickedItem = 0;
281 281
282 mActionItem = 0; 282 mActionItem = 0;
283 mActionType = NOP; 283 mActionType = NOP;
284 mItemMoved = false; 284 mItemMoved = false;
285 285
286 mSelectedItem = 0; 286 mSelectedItem = 0;
287 287
288 // mItems.setAutoDelete(true); 288 // mItems.setAutoDelete(true);
289 289
290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
291 291
292 viewport()->update(); 292 viewport()->update();
293 293
294 setMinimumSize(30, 1); 294 setMinimumSize(30, 1);
295// setMaximumHeight(mGridSpacingY * mRows + 5); 295// setMaximumHeight(mGridSpacingY * mRows + 5);
296 296
297 // Disable horizontal scrollbar. This is a hack. The geometry should be 297 // Disable horizontal scrollbar. This is a hack. The geometry should be
298 // controlled in a way that the contents horizontally always fits. Then it is 298 // controlled in a way that the contents horizontally always fits. Then it is
299 // not necessary to turn off the scrollbar. 299 // not necessary to turn off the scrollbar.
300 setHScrollBarMode(AlwaysOff); 300 setHScrollBarMode(AlwaysOff);
301 if ( ! mAllDayMode ) 301 if ( ! mAllDayMode )
302 setVScrollBarMode(AlwaysOn); 302 setVScrollBarMode(AlwaysOn);
303 else 303 else
304 setVScrollBarMode(AlwaysOff); 304 setVScrollBarMode(AlwaysOff);
305 305
306 setStartHour(KOPrefs::instance()->mDayBegins); 306 setStartHour(KOPrefs::instance()->mDayBegins);
307 307
308 calculateWorkingHours(); 308 calculateWorkingHours();
309 309
310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
311 SLOT(checkScrollBoundaries(int))); 311 SLOT(checkScrollBoundaries(int)));
312 312
313 // Create the Marcus Bains line. 313 // Create the Marcus Bains line.
314 if(mAllDayMode) 314 if(mAllDayMode)
315 mMarcusBains = 0; 315 mMarcusBains = 0;
316 else { 316 else {
317 mMarcusBains = new MarcusBains(this); 317 mMarcusBains = new MarcusBains(this);
318 addChild(mMarcusBains); 318 addChild(mMarcusBains);
319 } 319 }
320 mPopupKind = 0; 320 mPopupKind = 0;
321 mPopupItem = 0; 321 mPopupItem = 0;
322 mInvalidPixmap = false; 322 mInvalidPixmap = false;
323 323
324} 324}
325 325
326void KOAgenda::shrinkPixmap() 326void KOAgenda::shrinkPixmap()
327{ 327{
328 mPaintPixmap.resize( 20,20); 328 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true; 329 mInvalidPixmap = true;
330} 330}
331void KOAgenda::slotContentMove(int,int) 331void KOAgenda::slotContentMove(int,int)
332{ 332{
333 emit sendPing(); 333 emit sendPing();
334 if ( mActionType == NOP ) 334 if ( mActionType == NOP )
335 slotClearSelection(); 335 slotClearSelection();
336 if ( mSelectedItem && !mActionItem ) { 336 if ( mSelectedItem && !mActionItem ) {
337 deselectItem(); 337 deselectItem();
338 emit incidenceSelected( 0 ); 338 emit incidenceSelected( 0 );
339 } 339 }
340} 340}
341void KOAgenda::clear() 341void KOAgenda::clear()
342{ 342{
343 KOAgendaItem *item; 343 KOAgendaItem *item;
344 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 344 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
345 mUnusedItems.append( item ); 345 mUnusedItems.append( item );
346 //item->hide(); 346 //item->hide();
347 } 347 }
348 mItems.clear(); 348 mItems.clear();
349 mSelectedItem = 0; 349 mSelectedItem = 0;
350 clearSelection(); 350 clearSelection();
351} 351}
352 352
353void KOAgenda::clearSelection() 353void KOAgenda::clearSelection()
354{ 354{
355 mSelectionCellX = 0; 355 mSelectionCellX = 0;
356 mSelectionYTop = 0; 356 mSelectionYTop = 0;
357 mSelectionHeight = 0; 357 mSelectionHeight = 0;
358} 358}
359 359
360void KOAgenda::marcus_bains() 360void KOAgenda::marcus_bains()
361{ 361{
362 if(mMarcusBains) mMarcusBains->updateLocation(true); 362 if(mMarcusBains) mMarcusBains->updateLocation(true);
363} 363}
364 364
365 365
366void KOAgenda::changeColumns(int columns) 366void KOAgenda::changeColumns(int columns)
367{ 367{
368 if (columns == 0) { 368 if (columns == 0) {
369 qDebug("KOAgenda::changeColumns() called with argument 0 "); 369 qDebug("KOAgenda::changeColumns() called with argument 0 ");
370 return; 370 return;
371 } 371 }
372 clear(); 372 clear();
373 mColumns = columns; 373 mColumns = columns;
374 computeSizes(); 374 computeSizes();
375} 375}
376 376
377/* 377/*
378 This is the eventFilter function, which gets all events from the KOAgendaItems 378 This is the eventFilter function, which gets all events from the KOAgendaItems
379 contained in the agenda. It has to handle moving and resizing for all items. 379 contained in the agenda. It has to handle moving and resizing for all items.
380*/ 380*/
381bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 381bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
382{ 382{
383 // kdDebug() << "KOAgenda::eventFilter" << endl; 383 // kdDebug() << "KOAgenda::eventFilter" << endl;
384 switch(event->type()) { 384 switch(event->type()) {
385 case QEvent::MouseButtonPress: 385 case QEvent::MouseButtonPress:
386 case QEvent::MouseButtonDblClick: 386 case QEvent::MouseButtonDblClick:
387 case QEvent::MouseButtonRelease: 387 case QEvent::MouseButtonRelease:
388 case QEvent::MouseMove: 388 case QEvent::MouseMove:
389 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); 389 return eventFilter_mouse(object, static_cast<QMouseEvent *>(event));
390 390
391 case (QEvent::Leave): 391 case (QEvent::Leave):
392 if (!mActionItem) 392 if (!mActionItem)
393 setCursor(arrowCursor); 393 setCursor(arrowCursor);
394 return true; 394 return true;
395 395
396 default: 396 default:
397 return QScrollView::eventFilter(object,event); 397 return QScrollView::eventFilter(object,event);
398 } 398 }
399} 399}
400void KOAgenda::popupMenu() 400void KOAgenda::popupMenu()
401{ 401{
402 mPopupTimer->stop(); 402 mPopupTimer->stop();
403 if ( mPopupKind == 1 || mPopupKind == 3 ) { 403 if ( mPopupKind == 1 || mPopupKind == 3 ) {
404 if (mActionItem ) { 404 if (mActionItem ) {
405 endItemAction(); 405 endItemAction();
406 } 406 }
407 mLeftMouseDown = false; // no more leftMouse computation 407 mLeftMouseDown = false; // no more leftMouse computation
408 if (mPopupItem) { 408 if (mPopupItem) {
409 //mClickedItem = mPopupItem; 409 //mClickedItem = mPopupItem;
410 selectItem(mPopupItem); 410 selectItem(mPopupItem);
411 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) 411 if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 )
412 mAllAgendaPopup->installEventFilter( this ); 412 mAllAgendaPopup->installEventFilter( this );
413 emit showIncidencePopupSignal(mPopupItem->incidence()); 413 emit showIncidencePopupSignal(mPopupItem->incidence());
414 414
415 } 415 }
416 } else if ( mPopupKind == 2 || mPopupKind == 4 ) { 416 } else if ( mPopupKind == 2 || mPopupKind == 4 ) {
417 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action 417 if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action
418 endSelectAction( false ); // do not emit new event signal 418 endSelectAction( false ); // do not emit new event signal
419 mLeftMouseDown = false; // no more leftMouse computation 419 mLeftMouseDown = false; // no more leftMouse computation
420 } 420 }
421 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) 421 if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 )
422 mNewItemPopup->installEventFilter( this ); 422 mNewItemPopup->installEventFilter( this );
423 mNewItemPopup->popup( mPopupPos); 423 mNewItemPopup->popup( mPopupPos);
424 424
425 } 425 }
426 mLeftMouseDown = false; 426 mLeftMouseDown = false;
427 mPopupItem = 0; 427 mPopupItem = 0;
428 mPopupKind = 0; 428 mPopupKind = 0;
429} 429}
430void KOAgenda::categoryChanged(Incidence * inc) 430void KOAgenda::categoryChanged(Incidence * inc)
431{ 431{
432 KOAgendaItem *item; 432 KOAgendaItem *item;
433 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 433 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
434 if ( item->incidence() == inc ) { 434 if ( item->incidence() == inc ) {
435 item->initColor (); 435 item->initColor ();
436 item->updateItem(); 436 item->updateItem();
437 } 437 }
438 } 438 }
439} 439}
440bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) 440bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
441{ 441{
442 442
443 if ( mInvalidPixmap ) { 443 if ( mInvalidPixmap ) {
444 mInvalidPixmap = false; 444 mInvalidPixmap = false;
445 qDebug("KO: Upsizing Pixmaps "); 445 qDebug("KO: Upsizing Pixmaps ");
446 computeSizes(); 446 computeSizes();
447 emit updateViewSignal(); 447 emit updateViewSignal();
448 return true; 448 return true;
449 } 449 }
450 emit sendPing(); 450 emit sendPing();
451 static int startX = 0; 451 static int startX = 0;
452 static int startY = 0; 452 static int startY = 0;
453 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); 453 int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 );
454 static bool blockMoving = true; 454 static bool blockMoving = true;
455 455
456 //qDebug("KOAgenda::eventFilter_mous "); 456 //qDebug("KOAgenda::eventFilter_mous ");
457 if ( object == mNewItemPopup ) { 457 if ( object == mNewItemPopup ) {
458 //qDebug("mNewItemPopup "); 458 //qDebug("mNewItemPopup ");
459 if ( me->type() == QEvent::MouseButtonRelease ) { 459 if ( me->type() == QEvent::MouseButtonRelease ) {
460 mNewItemPopup->removeEventFilter( this ); 460 mNewItemPopup->removeEventFilter( this );
461 int dX = me->globalPos().x() - mPopupPos.x();; 461 int dX = me->globalPos().x() - mPopupPos.x();;
462 if ( dX < 0 ) 462 if ( dX < 0 )
463 dX = -dX; 463 dX = -dX;
464 int dY = me->globalPos().y() - mPopupPos.y(); 464 int dY = me->globalPos().y() - mPopupPos.y();
465 if ( dY < 0 ) 465 if ( dY < 0 )
466 dY = -dY; 466 dY = -dY;
467 if ( dX > blockmoveDist || dY > blockmoveDist ) { 467 if ( dX > blockmoveDist || dY > blockmoveDist ) {
468 mNewItemPopup->hide(); 468 mNewItemPopup->hide();
469 } 469 }
470 } 470 }
471 return true; 471 return true;
472 } 472 }
473 if ( object == mAllAgendaPopup ) { 473 if ( object == mAllAgendaPopup ) {
474 //qDebug(" mAllAgendaPopup "); 474 //qDebug(" mAllAgendaPopup ");
475 if ( me->type() == QEvent::MouseButtonRelease ) { 475 if ( me->type() == QEvent::MouseButtonRelease ) {
476 mAllAgendaPopup->removeEventFilter( this ); 476 mAllAgendaPopup->removeEventFilter( this );
477 int dX = me->globalPos().x() - mPopupPos.x();; 477 int dX = me->globalPos().x() - mPopupPos.x();;
478 if ( dX < 0 ) 478 if ( dX < 0 )
479 dX = -dX; 479 dX = -dX;
480 int dY = me->globalPos().y() - mPopupPos.y(); 480 int dY = me->globalPos().y() - mPopupPos.y();
481 if ( dY < 0 ) 481 if ( dY < 0 )
482 dY = -dY; 482 dY = -dY;
483 if ( dX > blockmoveDist || dY > blockmoveDist ) { 483 if ( dX > blockmoveDist || dY > blockmoveDist ) {
484 mAllAgendaPopup->hide(); 484 mAllAgendaPopup->hide();
485 } 485 }
486 } 486 }
487 return true; 487 return true;
488 } 488 }
489 QPoint viewportPos; 489 QPoint viewportPos;
490 if (object != viewport()) { 490 if (object != viewport()) {
491 blockmoveDist = blockmoveDist*2; 491 blockmoveDist = blockmoveDist*2;
492 viewportPos = ((QWidget *)object)->mapToParent(me->pos()); 492 viewportPos = ((QWidget *)object)->mapToParent(me->pos());
493 } else { 493 } else {
494 viewportPos = me->pos(); 494 viewportPos = me->pos();
495 } 495 }
496 bool objIsNotViewport = (object != viewport()); 496 bool objIsNotViewport = (object != viewport());
497 bool leftButt = false; 497 bool leftButt = false;
498#ifdef DESKTOP_VERSION 498#ifdef DESKTOP_VERSION
499 leftButt = (me->button() == LeftButton); 499 leftButt = (me->button() == LeftButton);
500#endif 500#endif
501 switch (me->type()) { 501 switch (me->type()) {
502 case QEvent::MouseButtonPress: 502 case QEvent::MouseButtonPress:
503 if (me->button() == LeftButton) { 503 if (me->button() == LeftButton) {
504 mPopupTimer->start( 600 ); 504 mPopupTimer->start( 600 );
505 mLeftMouseDown = true; 505 mLeftMouseDown = true;
506 } 506 }
507 blockMoving = true; 507 blockMoving = true;
508 startX = viewportPos.x(); 508 startX = viewportPos.x();
509 startY = viewportPos.y(); 509 startY = viewportPos.y();
510 mPopupPos = me->globalPos(); 510 mPopupPos = me->globalPos();
511 if ( objIsNotViewport && !leftButt ) { 511 if ( objIsNotViewport && !leftButt ) {
512 KOAgendaItem * tempItem = (KOAgendaItem *)object; 512 KOAgendaItem * tempItem = (KOAgendaItem *)object;
513 if (mAllDayMode) { 513 if (mAllDayMode) {
514 if ( tempItem->height() > 10 ) { 514 if ( tempItem->height() > 10 ) {
515 int minV = tempItem->height()/4; 515 int minV = tempItem->height()/4;
516 if ( minV > (blockmoveDist/2)-2 ) { 516 if ( minV > (blockmoveDist/2)-2 ) {
517 if ( minV > blockmoveDist ) 517 if ( minV > blockmoveDist )
518 minV = blockmoveDist; 518 minV = blockmoveDist;
519 else 519 else
520 minV = (blockmoveDist/2); 520 minV = (blockmoveDist/2);
521 } 521 }
522 bool border = false; 522 bool border = false;
523 int diff = tempItem->y() - viewportPos.y(); 523 int diff = tempItem->y() - viewportPos.y();
524 if ( diff < 0 ) 524 if ( diff < 0 )
525 diff *= -1; 525 diff *= -1;
526 if ( diff < minV ) { 526 if ( diff < minV ) {
527 border = true; 527 border = true;
528 objIsNotViewport = false; 528 objIsNotViewport = false;
529 } 529 }
530 if ( ! border ) { 530 if ( ! border ) {
531 diff = tempItem->y() + tempItem->height()- viewportPos.y(); 531 diff = tempItem->y() + tempItem->height()- viewportPos.y();
532 if ( diff < 0 ) 532 if ( diff < 0 )
533 diff *= -1; 533 diff *= -1;
534 if ( diff < minV ) { 534 if ( diff < minV ) {
535 border = true; 535 border = true;
536 objIsNotViewport = false; 536 objIsNotViewport = false;
537 } 537 }
538 } 538 }
539 } 539 }
540 } else { // not allday 540 } else { // not allday
541 if ( tempItem->width() > 10 ) { 541 if ( tempItem->width() > 10 ) {
542 int minH = tempItem->width()/4; 542 int minH = tempItem->width()/4;
543 if ( minH > (blockmoveDist/2)-2 ) { 543 if ( minH > (blockmoveDist/2)-2 ) {
544 if ( minH > blockmoveDist ) 544 if ( minH > blockmoveDist )
545 minH = blockmoveDist; 545 minH = blockmoveDist;
546 else 546 else
547 minH = (blockmoveDist/2); 547 minH = (blockmoveDist/2);
548 } 548 }
549 bool border = false; 549 bool border = false;
550 int diff = tempItem->x() - viewportPos.x(); 550 int diff = tempItem->x() - viewportPos.x();
551 if ( diff < 0 ) 551 if ( diff < 0 )
552 diff *= -1; 552 diff *= -1;
553 if ( diff < minH ) { 553 if ( diff < minH ) {
554 border = true; 554 border = true;
555 objIsNotViewport = false; 555 objIsNotViewport = false;
556 } 556 }
557 if ( ! border ) { 557 if ( ! border ) {
558 diff = tempItem->x() + tempItem->width() - viewportPos.x(); 558 diff = tempItem->x() + tempItem->width() - viewportPos.x();
559 if ( diff < 0 ) 559 if ( diff < 0 )
560 diff *= -1; 560 diff *= -1;
561 if ( diff < minH ) { 561 if ( diff < minH ) {
562 border = true; 562 border = true;
563 objIsNotViewport = false; 563 objIsNotViewport = false;
564 } 564 }
565 } 565 }
566 } 566 }
567 } 567 }
568 } 568 }
569 if ( objIsNotViewport ) { 569 if ( objIsNotViewport ) {
570 mPopupItem = (KOAgendaItem *)object; 570 mPopupItem = (KOAgendaItem *)object;
571 mPopupKind = 1; 571 mPopupKind = 1;
572 if (me->button() == RightButton) { 572 if (me->button() == RightButton) {
573 mPopupKind = 3; 573 mPopupKind = 3;
574 popupMenu(); 574 popupMenu();
575 } else if (me->button() == LeftButton) { 575 } else if (me->button() == LeftButton) {
576 mActionItem = (KOAgendaItem *)object; 576 mActionItem = (KOAgendaItem *)object;
577 if (mActionItem) { 577 if (mActionItem) {
578 emit signalClearSelection(); 578 emit signalClearSelection();
579 slotClearSelection(); 579 slotClearSelection();
580 selectItem(mActionItem); 580 selectItem(mActionItem);
581 Incidence *incidence = mActionItem->incidence(); 581 Incidence *incidence = mActionItem->incidence();
582 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) { 582 if ( incidence->isReadOnly() /*|| incidence->recurrence()->doesRecur() */) {
583 mActionItem = 0; 583 mActionItem = 0;
584 } else { 584 } else {
585 startItemAction(viewportPos); 585 startItemAction(viewportPos);
586 } 586 }
587 } 587 }
588 } 588 }
589 } else { // ---------- viewport() 589 } else { // ---------- viewport()
590 mPopupItem = 0; 590 mPopupItem = 0;
591 mPopupKind = 2; 591 mPopupKind = 2;
592 selectItem(0); 592 selectItem(0);
593 mActionItem = 0; 593 mActionItem = 0;
594 if (me->button() == RightButton) { 594 if (me->button() == RightButton) {
595 int x,y; 595 int x,y;
596 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 596 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
597 int gx,gy; 597 int gx,gy;
598 contentsToGrid(x,y,gx,gy); 598 contentsToGrid(x,y,gx,gy);
599 mCurrentCellX = gx; 599 mCurrentCellX = gx;
600 mCurrentCellY = gy; 600 mCurrentCellY = gy;
601 mStartCellX = gx; 601 mStartCellX = gx;
602 mStartCellY = gy; 602 mStartCellY = gy;
603 mPopupKind = 4; 603 mPopupKind = 4;
604 popupMenu(); 604 popupMenu();
605 } else if (me->button() == LeftButton) { 605 } else if (me->button() == LeftButton) {
606 setCursor(arrowCursor); 606 setCursor(arrowCursor);
607 startSelectAction(viewportPos); 607 startSelectAction(viewportPos);
608 } 608 }
609 } 609 }
610 break; 610 break;
611 611
612 case QEvent::MouseButtonRelease: 612 case QEvent::MouseButtonRelease:
613 if (me->button() == LeftButton ) { 613 if (me->button() == LeftButton ) {
614 mPopupTimer->stop(); 614 mPopupTimer->stop();
615 } 615 }
616 if (object != viewport()) { 616 if (object != viewport()) {
617 if (me->button() == LeftButton && mLeftMouseDown) { 617 if (me->button() == LeftButton && mLeftMouseDown) {
618 if (mActionItem) { 618 if (mActionItem) {
619 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 619 QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos));
620 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); 620 //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 );
621 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 621 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
622 mScrollUpTimer.stop(); 622 mScrollUpTimer.stop();
623 mScrollDownTimer.stop(); 623 mScrollDownTimer.stop();
624 mActionItem->resetMove(); 624 mActionItem->resetMove();
625 placeSubCells( mActionItem ); 625 placeSubCells( mActionItem );
626 // emit startDragSignal( mActionItem->incidence() ); 626 // emit startDragSignal( mActionItem->incidence() );
627 setCursor( arrowCursor ); 627 setCursor( arrowCursor );
628 mActionItem = 0; 628 mActionItem = 0;
629 mActionType = NOP; 629 mActionType = NOP;
630 mItemMoved = 0; 630 mItemMoved = 0;
631 mLeftMouseDown = false; 631 mLeftMouseDown = false;
632 return true; 632 return true;
633 } 633 }
634 endItemAction(); 634 endItemAction();
635 } 635 }
636 } 636 }
637 637
638 } else { // ---------- viewport() 638 } else { // ---------- viewport()
639 if (me->button() == LeftButton && mLeftMouseDown ) { //left click 639 if (me->button() == LeftButton && mLeftMouseDown ) { //left click
640 endSelectAction( true ); // emit new event signal 640 endSelectAction( true ); // emit new event signal
641 } 641 }
642 } 642 }
643 if (me->button() == LeftButton) 643 if (me->button() == LeftButton)
644 mLeftMouseDown = false; 644 mLeftMouseDown = false;
645 645
646 break; 646 break;
647 647
648 case QEvent::MouseMove: 648 case QEvent::MouseMove:
649 //qDebug("mm "); 649 //qDebug("mm ");
650 if ( !mLeftMouseDown ) 650 if ( !mLeftMouseDown )
651 return false; 651 return false;
652 if ( blockMoving ) { 652 if ( blockMoving ) {
653 int dX, dY; 653 int dX, dY;
654 dX = startX - viewportPos.x(); 654 dX = startX - viewportPos.x();
655 if ( dX < 0 ) 655 if ( dX < 0 )
656 dX = -dX; 656 dX = -dX;
657 dY = viewportPos.y() - startY; 657 dY = viewportPos.y() - startY;
658 if ( dY < 0 ) 658 if ( dY < 0 )
659 dY = -dY; 659 dY = -dY;
660 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 660 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
661 if ( dX > blockmoveDist || dY > blockmoveDist ) { 661 if ( dX > blockmoveDist || dY > blockmoveDist ) {
662 blockMoving = false; 662 blockMoving = false;
663 } 663 }
664 } 664 }
665 if ( ! blockMoving ) 665 if ( ! blockMoving )
666 mPopupTimer->stop(); 666 mPopupTimer->stop();
667 if (object != viewport()) { 667 if (object != viewport()) {
668 KOAgendaItem *moveItem = (KOAgendaItem *)object; 668 KOAgendaItem *moveItem = (KOAgendaItem *)object;
669 if (!moveItem->incidence()->isReadOnly() ) { 669 if (!moveItem->incidence()->isReadOnly() ) {
670 if (!mActionItem) 670 if (!mActionItem)
671 setNoActionCursor(moveItem,viewportPos); 671 setNoActionCursor(moveItem,viewportPos);
672 else { 672 else {
673 if ( !blockMoving ) 673 if ( !blockMoving )
674 performItemAction(viewportPos); 674 performItemAction(viewportPos);
675 } 675 }
676 } 676 }
677 } else { // ---------- viewport() 677 } else { // ---------- viewport()
678 mPopupPos = viewport()->mapToGlobal( me->pos() ); 678 mPopupPos = viewport()->mapToGlobal( me->pos() );
679 if ( mActionType == SELECT ) { 679 if ( mActionType == SELECT ) {
680 performSelectAction( viewportPos ); 680 performSelectAction( viewportPos );
681 } 681 }
682 } 682 }
683 break; 683 break;
684 684
685 case QEvent::MouseButtonDblClick: 685 case QEvent::MouseButtonDblClick:
686 mPopupTimer->stop(); 686 mPopupTimer->stop();
687 if (object == viewport()) { 687 if (object == viewport()) {
688 selectItem(0); 688 selectItem(0);
689 int x,y; 689 int x,y;
690 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 690 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
691 int gx,gy; 691 int gx,gy;
692 contentsToGrid(x,y,gx,gy); 692 contentsToGrid(x,y,gx,gy);
693 emit newEventSignal(gx,gy); 693 emit newEventSignal(gx,gy);
694 } else { 694 } else {
695 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 695 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
696 selectItem(doubleClickedItem); 696 selectItem(doubleClickedItem);
697 if ( KOPrefs::instance()->mEditOnDoubleClick ) 697 if ( KOPrefs::instance()->mEditOnDoubleClick )
698 emit editIncidenceSignal(doubleClickedItem->incidence()); 698 emit editIncidenceSignal(doubleClickedItem->incidence());
699 else 699 else
700 emit showIncidenceSignal(doubleClickedItem->incidence()); 700 emit showIncidenceSignal(doubleClickedItem->incidence());
701 } 701 }
702 break; 702 break;
703 703
704 default: 704 default:
705 break; 705 break;
706 } 706 }
707 return true; 707 return true;
708 708
709} 709}
710 710
711void KOAgenda::newItem( int item ) 711void KOAgenda::newItem( int item )
712{ 712{
713 if ( item == 1 ) { //new event 713 if ( item == 1 ) { //new event
714 newEventSignal(mStartCellX ,mStartCellY ); 714 newEventSignal(mStartCellX ,mStartCellY );
715 } else 715 } else
716 if ( item == 2 ) { //new event 716 if ( item == 2 ) { //new event
717 newTodoSignal(mStartCellX ,mStartCellY ); 717 newTodoSignal(mStartCellX ,mStartCellY );
718 } else 718 } else
719 { 719 {
720 emit showDateView( item, mStartCellX ); 720 emit showDateView( item, mStartCellX );
721 // 3Day view 721 // 3Day view
722 // 4Week view 722 // 4Week view
723 // 5Month view 723 // 5Month view
724 // 6Journal view 724 // 6Journal view
725 } 725 }
726} 726}
727void KOAgenda::slotClearSelection() 727void KOAgenda::slotClearSelection()
728{ 728{
729 if (mSelectionHeight) { 729 if (mSelectionHeight) {
730 int selectionX = mSelectionCellX * mGridSpacingX; 730 int selectionX = mSelectionCellX * mGridSpacingX;
731 int top = mSelectionYTop - 2 *mGridSpacingY; 731 int top = mSelectionYTop - 2 *mGridSpacingY;
732 int hei = mSelectionHeight + 4 *mGridSpacingY; 732 int hei = mSelectionHeight + 4 *mGridSpacingY;
733 clearSelection(); 733 clearSelection();
734 repaintContents( selectionX, top, 734 repaintContents( selectionX, top,
735 mGridSpacingX, hei ,false ); 735 mGridSpacingX, hei ,false );
736 } 736 }
737 737
738} 738}
739void KOAgenda::startSelectAction(QPoint viewportPos) 739void KOAgenda::startSelectAction(QPoint viewportPos)
740{ 740{
741 741
742 emit signalClearSelection(); 742 emit signalClearSelection();
743 slotClearSelection(); 743 slotClearSelection();
744 744
745 mActionType = SELECT; 745 mActionType = SELECT;
746 746
747 int x,y; 747 int x,y;
748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 748 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
749 int gx,gy; 749 int gx,gy;
750 contentsToGrid(x,y,gx,gy); 750 contentsToGrid(x,y,gx,gy);
751 751
752 mStartCellX = gx; 752 mStartCellX = gx;
753 mStartCellY = gy; 753 mStartCellY = gy;
754 mCurrentCellX = gx; 754 mCurrentCellX = gx;
755 mCurrentCellY = gy; 755 mCurrentCellY = gy;
756 756
757 // Store new selection 757 // Store new selection
758 mSelectionCellX = gx; 758 mSelectionCellX = gx;
759 mSelectionYTop = gy * mGridSpacingY; 759 mSelectionYTop = gy * mGridSpacingY;
760 mSelectionHeight = mGridSpacingY; 760 mSelectionHeight = mGridSpacingY;
761 761
762 // Paint new selection 762 // Paint new selection
763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop, 763 repaintContents( mSelectionCellX * mGridSpacingX+1, mSelectionYTop,
764 mGridSpacingX-1, mSelectionHeight ); 764 mGridSpacingX-1, mSelectionHeight );
765} 765}
766 766
767void KOAgenda::performSelectAction(QPoint viewportPos) 767void KOAgenda::performSelectAction(QPoint viewportPos)
768{ 768{
769 int x,y; 769 int x,y;
770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 770 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
771 int gx,gy; 771 int gx,gy;
772 contentsToGrid(x,y,gx,gy); 772 contentsToGrid(x,y,gx,gy);
773 773
774 QPoint clipperPos = clipper()-> 774 QPoint clipperPos = clipper()->
775 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 775 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
776 776
777 // Scroll if cursor was moved to upper or lower end of agenda. 777 // Scroll if cursor was moved to upper or lower end of agenda.
778 if (clipperPos.y() < mScrollBorderWidth) { 778 if (clipperPos.y() < mScrollBorderWidth) {
779 mScrollUpTimer.start(mScrollDelay); 779 mScrollUpTimer.start(mScrollDelay);
780 } else if (visibleHeight() - clipperPos.y() < 780 } else if (visibleHeight() - clipperPos.y() <
781 mScrollBorderWidth) { 781 mScrollBorderWidth) {
782 mScrollDownTimer.start(mScrollDelay); 782 mScrollDownTimer.start(mScrollDelay);
783 } else { 783 } else {
784 mScrollUpTimer.stop(); 784 mScrollUpTimer.stop();
785 mScrollDownTimer.stop(); 785 mScrollDownTimer.stop();
786 } 786 }
787 787
788 if ( gy > mCurrentCellY ) { 788 if ( gy > mCurrentCellY ) {
789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 789 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
790 790
791 791
792 repaintContents( (KOGlobals::self()->reverseLayout() ? 792 repaintContents( (KOGlobals::self()->reverseLayout() ?
793 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 793 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
794 mGridSpacingX, mSelectionYTop, 794 mGridSpacingX, mSelectionYTop,
795 mGridSpacingX, mSelectionHeight , false); 795 mGridSpacingX, mSelectionHeight , false);
796 796
797 mCurrentCellY = gy; 797 mCurrentCellY = gy;
798 } else if ( gy < mCurrentCellY ) { 798 } else if ( gy < mCurrentCellY ) {
799 if ( gy >= mStartCellY ) { 799 if ( gy >= mStartCellY ) {
800 int selectionHeight = mSelectionHeight; 800 int selectionHeight = mSelectionHeight;
801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 801 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
802 802
803 repaintContents( (KOGlobals::self()->reverseLayout() ? 803 repaintContents( (KOGlobals::self()->reverseLayout() ?
804 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 804 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
805 mGridSpacingX, mSelectionYTop, 805 mGridSpacingX, mSelectionYTop,
806 mGridSpacingX, selectionHeight,false ); 806 mGridSpacingX, selectionHeight,false );
807 807
808 mCurrentCellY = gy; 808 mCurrentCellY = gy;
809 } else { 809 } else {
810 } 810 }
811 } 811 }
812} 812}
813 813
814void KOAgenda::endSelectAction( bool emitNewEvent ) 814void KOAgenda::endSelectAction( bool emitNewEvent )
815{ 815{
816 mActionType = NOP; 816 mActionType = NOP;
817 mScrollUpTimer.stop(); 817 mScrollUpTimer.stop();
818 mScrollDownTimer.stop(); 818 mScrollDownTimer.stop();
819 819
820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 820 emit newTimeSpanSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) { 821 if ( emitNewEvent && mStartCellY < mCurrentCellY ) {
822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY); 822 emit newEventSignal(mStartCellX,mStartCellY,mCurrentCellX,mCurrentCellY);
823 } 823 }
824} 824}
825 825
826void KOAgenda::startItemAction(QPoint viewportPos) 826void KOAgenda::startItemAction(QPoint viewportPos)
827{ 827{
828 int x,y; 828 int x,y;
829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 829 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
830 int gx,gy; 830 int gx,gy;
831 contentsToGrid(x,y,gx,gy); 831 contentsToGrid(x,y,gx,gy);
832 832
833 mStartCellX = gx; 833 mStartCellX = gx;
834 mStartCellY = gy; 834 mStartCellY = gy;
835 mCurrentCellX = gx; 835 mCurrentCellX = gx;
836 mCurrentCellY = gy; 836 mCurrentCellY = gy;
837 837
838 if (mAllDayMode) { 838 if (mAllDayMode) {
839 int gridDistanceX = (x - gx * mGridSpacingX); 839 int gridDistanceX = (x - gx * mGridSpacingX);
840 if (gridDistanceX < mResizeBorderWidth && 840 if (gridDistanceX < mResizeBorderWidth &&
841 mActionItem->cellX() == mCurrentCellX) { 841 mActionItem->cellX() == mCurrentCellX) {
842 mActionType = RESIZELEFT; 842 mActionType = RESIZELEFT;
843 setCursor(sizeHorCursor); 843 setCursor(sizeHorCursor);
844 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 844 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
845 mActionItem->cellXWidth() == mCurrentCellX) { 845 mActionItem->cellXWidth() == mCurrentCellX) {
846 mActionType = RESIZERIGHT; 846 mActionType = RESIZERIGHT;
847 setCursor(sizeHorCursor); 847 setCursor(sizeHorCursor);
848 } else { 848 } else {
849 mActionType = MOVE; 849 mActionType = MOVE;
850 mActionItem->startMove(); 850 mActionItem->startMove();
851 setCursor(sizeAllCursor); 851 setCursor(sizeAllCursor);
852 } 852 }
853 } else { 853 } else {
854 int gridDistanceY = (y - gy * mGridSpacingY); 854 int gridDistanceY = (y - gy * mGridSpacingY);
855 bool allowResize = ( mActionItem->incidence()->typeID() != todoID ); 855 bool allowResize = ( mActionItem->incidence()->typeID() != todoID );
856 if (allowResize && gridDistanceY < mResizeBorderWidth && 856 if (allowResize && gridDistanceY < mResizeBorderWidth &&
857 mActionItem->cellYTop() == mCurrentCellY && 857 mActionItem->cellYTop() == mCurrentCellY &&
858 !mActionItem->firstMultiItem()) { 858 !mActionItem->firstMultiItem()) {
859 mActionType = RESIZETOP; 859 mActionType = RESIZETOP;
860 setCursor(sizeVerCursor); 860 setCursor(sizeVerCursor);
861 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 861 } else if (allowResize &&(mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
862 mActionItem->cellYBottom() == mCurrentCellY && 862 mActionItem->cellYBottom() == mCurrentCellY &&
863 !mActionItem->lastMultiItem()) { 863 !mActionItem->lastMultiItem()) {
864 mActionType = RESIZEBOTTOM; 864 mActionType = RESIZEBOTTOM;
865 setCursor(sizeVerCursor); 865 setCursor(sizeVerCursor);
866 } else { 866 } else {
867 mActionType = MOVE; 867 mActionType = MOVE;
868 mActionItem->startMove(); 868 mActionItem->startMove();
869 setCursor(sizeAllCursor); 869 setCursor(sizeAllCursor);
870 } 870 }
871 } 871 }
872} 872}
873 873
874void KOAgenda::performItemAction(QPoint viewportPos) 874void KOAgenda::performItemAction(QPoint viewportPos)
875{ 875{
876// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 876// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
877// QPoint point = viewport()->mapToGlobal(viewportPos); 877// QPoint point = viewport()->mapToGlobal(viewportPos);
878// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 878// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
879// point = clipper()->mapFromGlobal(point); 879// point = clipper()->mapFromGlobal(point);
880// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 880// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
881// kdDebug() << "visible height: " << visibleHeight() << endl; 881// kdDebug() << "visible height: " << visibleHeight() << endl;
882 int x,y; 882 int x,y;
883 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 883 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
884// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 884// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
885 int gx,gy; 885 int gx,gy;
886 contentsToGrid(x,y,gx,gy); 886 contentsToGrid(x,y,gx,gy);
887 QPoint clipperPos = clipper()-> 887 QPoint clipperPos = clipper()->
888 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 888 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
889 889
890 // Cursor left active agenda area. 890 // Cursor left active agenda area.
891 // This starts a drag. 891 // This starts a drag.
892 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/ 892 if ( /*clipperPos.y() < 0 || clipperPos.y() > visibleHeight() ||*/
893 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) { 893 clipperPos.x() < 0 || clipperPos.x() > visibleWidth() ) {
894 if ( mActionType == MOVE ) { 894 if ( mActionType == MOVE ) {
895 mScrollUpTimer.stop(); 895 mScrollUpTimer.stop();
896 mScrollDownTimer.stop(); 896 mScrollDownTimer.stop();
897 mActionItem->resetMove(); 897 mActionItem->resetMove();
898 placeSubCells( mActionItem ); 898 placeSubCells( mActionItem );
899 // emit startDragSignal( mActionItem->incidence() ); 899 // emit startDragSignal( mActionItem->incidence() );
900 setCursor( arrowCursor ); 900 setCursor( arrowCursor );
901 mActionItem = 0; 901 mActionItem = 0;
902 mActionType = NOP; 902 mActionType = NOP;
903 mItemMoved = 0; 903 mItemMoved = 0;
904 return; 904 return;
905 } 905 }
906 } else { 906 } else {
907 switch ( mActionType ) { 907 switch ( mActionType ) {
908 case MOVE: 908 case MOVE:
909 setCursor( sizeAllCursor ); 909 setCursor( sizeAllCursor );
910 break; 910 break;
911 case RESIZETOP: 911 case RESIZETOP:
912 case RESIZEBOTTOM: 912 case RESIZEBOTTOM:
913 setCursor( sizeVerCursor ); 913 setCursor( sizeVerCursor );
914 break; 914 break;
915 case RESIZELEFT: 915 case RESIZELEFT:
916 case RESIZERIGHT: 916 case RESIZERIGHT:
917 setCursor( sizeHorCursor ); 917 setCursor( sizeHorCursor );
918 break; 918 break;
919 default: 919 default:
920 setCursor( arrowCursor ); 920 setCursor( arrowCursor );
921 } 921 }
922 } 922 }
923 923
924 // Scroll if item was moved to upper or lower end of agenda. 924 // Scroll if item was moved to upper or lower end of agenda.
925 if (clipperPos.y() < mScrollBorderWidth) { 925 if (clipperPos.y() < mScrollBorderWidth) {
926 mScrollUpTimer.start(mScrollDelay); 926 mScrollUpTimer.start(mScrollDelay);
927 } else if (visibleHeight() - clipperPos.y() < 927 } else if (visibleHeight() - clipperPos.y() <
928 mScrollBorderWidth) { 928 mScrollBorderWidth) {
929 mScrollDownTimer.start(mScrollDelay); 929 mScrollDownTimer.start(mScrollDelay);
930 } else { 930 } else {
931 mScrollUpTimer.stop(); 931 mScrollUpTimer.stop();
932 mScrollDownTimer.stop(); 932 mScrollDownTimer.stop();
933 } 933 }
934 934
935 // Move or resize item if necessary 935 // Move or resize item if necessary
936 if (mCurrentCellX != gx || mCurrentCellY != gy) { 936 if (mCurrentCellX != gx || mCurrentCellY != gy) {
937 mItemMoved = true; 937 mItemMoved = true;
938 mActionItem->raise(); 938 mActionItem->raise();
939 if (mActionType == MOVE) { 939 if (mActionType == MOVE) {
940 // Move all items belonging to a multi item 940 // Move all items belonging to a multi item
941 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 941 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 942 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
943 if (!moveItem) moveItem = mActionItem; 943 if (!moveItem) moveItem = mActionItem;
944 while (moveItem) { 944 while (moveItem) {
945 int dy; 945 int dy;
946 if (isMultiItem) dy = 0; 946 if (isMultiItem) dy = 0;
947 else dy = gy - mCurrentCellY; 947 else dy = gy - mCurrentCellY;
948 moveItem->moveRelative(gx - mCurrentCellX,dy); 948 moveItem->moveRelative(gx - mCurrentCellX,dy);
949 int x,y; 949 int x,y;
950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 950 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 951 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
952 mGridSpacingY * moveItem->cellHeight()); 952 mGridSpacingY * moveItem->cellHeight());
953 moveItem->raise(); 953 moveItem->raise();
954 moveChild(moveItem,x,y); 954 moveChild(moveItem,x,y);
955 moveItem = moveItem->nextMultiItem(); 955 moveItem = moveItem->nextMultiItem();
956 } 956 }
957 } else if (mActionType == RESIZETOP) { 957 } else if (mActionType == RESIZETOP) {
958 if (mCurrentCellY <= mActionItem->cellYBottom()) { 958 if (mCurrentCellY <= mActionItem->cellYBottom()) {
959 mActionItem->expandTop(gy - mCurrentCellY); 959 mActionItem->expandTop(gy - mCurrentCellY);
960 mActionItem->resize(mActionItem->width(), 960 mActionItem->resize(mActionItem->width(),
961 mGridSpacingY * mActionItem->cellHeight()); 961 mGridSpacingY * mActionItem->cellHeight());
962 int x,y; 962 int x,y;
963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 963 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
964 //moveChild(mActionItem,childX(mActionItem),y); 964 //moveChild(mActionItem,childX(mActionItem),y);
965 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 965 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
966 } 966 }
967 } else if (mActionType == RESIZEBOTTOM) { 967 } else if (mActionType == RESIZEBOTTOM) {
968 if (mCurrentCellY >= mActionItem->cellYTop()) { 968 if (mCurrentCellY >= mActionItem->cellYTop()) {
969 mActionItem->expandBottom(gy - mCurrentCellY); 969 mActionItem->expandBottom(gy - mCurrentCellY);
970 mActionItem->resize(mActionItem->width(), 970 mActionItem->resize(mActionItem->width(),
971 mGridSpacingY * mActionItem->cellHeight()); 971 mGridSpacingY * mActionItem->cellHeight());
972 } 972 }
973 } else if (mActionType == RESIZELEFT) { 973 } else if (mActionType == RESIZELEFT) {
974 if (mCurrentCellX <= mActionItem->cellXWidth()) { 974 if (mCurrentCellX <= mActionItem->cellXWidth()) {
975 mActionItem->expandLeft(gx - mCurrentCellX); 975 mActionItem->expandLeft(gx - mCurrentCellX);
976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 976 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
977 mActionItem->height()); 977 mActionItem->height());
978 int x,y; 978 int x,y;
979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 979 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
980 moveChild(mActionItem,x,childY(mActionItem)); 980 moveChild(mActionItem,x,childY(mActionItem));
981 } 981 }
982 } else if (mActionType == RESIZERIGHT) { 982 } else if (mActionType == RESIZERIGHT) {
983 if (mCurrentCellX >= mActionItem->cellX()) { 983 if (mCurrentCellX >= mActionItem->cellX()) {
984 mActionItem->expandRight(gx - mCurrentCellX); 984 mActionItem->expandRight(gx - mCurrentCellX);
985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 985 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
986 mActionItem->height()); 986 mActionItem->height());
987 } 987 }
988 } 988 }
989 mCurrentCellX = gx; 989 mCurrentCellX = gx;
990 mCurrentCellY = gy; 990 mCurrentCellY = gy;
991 } 991 }
992} 992}
993 993
994void KOAgenda::endItemAction() 994void KOAgenda::endItemAction()
995{ 995{
996 996
997 if ( mItemMoved ) { 997 if ( mItemMoved ) {
998 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 998 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
999 if ( !placeItem ) { 999 if ( !placeItem ) {
1000 placeItem = mActionItem; 1000 placeItem = mActionItem;
1001 } 1001 }
1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) { 1002 if ( placeItem->incidence()->recurrence()->doesRecur() ) {
1003 Incidence* oldInc = placeItem->incidence(); 1003 Incidence* oldInc = placeItem->incidence();
1004 placeItem->recreateIncidence(); 1004 placeItem->recreateIncidence();
1005 emit addToCalSignal(placeItem->incidence(), oldInc ); 1005 emit addToCalSignal(placeItem->incidence(), oldInc );
1006 } 1006 }
1007 int type = mActionType; 1007 int type = mActionType;
1008 if ( mAllDayMode ) 1008 if ( mAllDayMode )
1009 type = -1; 1009 type = -1;
1010 KOAgendaItem *modifiedItem = placeItem; 1010 KOAgendaItem *modifiedItem = placeItem;
1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */); 1011 //emit itemModified( placeItem, mActionType /*KOGlobals::EVENTEDITED */);
1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems(); 1012 QPtrList<KOAgendaItem> oldconflictItems ;//= placeItem->conflictItems();
1013 KOAgendaItem *item; 1013 KOAgendaItem *item;
1014 1014
1015 if ( placeItem->incidence()->typeID() == todoID ) { 1015 if ( placeItem->incidence()->typeID() == todoID ) {
1016 mSelectedItem = 0; 1016 mSelectedItem = 0;
1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth()); 1017 //qDebug("todo %d %d %d ", mCurrentCellX, modifiedItem->cellX() ,modifiedItem->cellXWidth());
1018 modifiedItem->mLastMoveXPos = mCurrentCellX; 1018 modifiedItem->mLastMoveXPos = mCurrentCellX;
1019 emit itemModified( modifiedItem, mActionType ); 1019 emit itemModified( modifiedItem, mActionType );
1020 } 1020 }
1021 else { 1021 else {
1022 1022
1023 1023
1024 globalFlagBlockAgendaItemPaint = 1; 1024 globalFlagBlockAgendaItemPaint = 1;
1025 for ( item=oldconflictItems.first(); item != 0; 1025 for ( item=oldconflictItems.first(); item != 0;
1026 item=oldconflictItems.next() ) { 1026 item=oldconflictItems.next() ) {
1027 placeSubCells(item); 1027 placeSubCells(item);
1028 } 1028 }
1029 while ( placeItem ) { 1029 while ( placeItem ) {
1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1030 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1031 oldconflictItems = placeItem->conflictItems(); 1031 oldconflictItems = placeItem->conflictItems();
1032 for ( item=oldconflictItems.first(); item != 0; 1032 for ( item=oldconflictItems.first(); item != 0;
1033 item=oldconflictItems.next() ) { 1033 item=oldconflictItems.next() ) {
1034 placeSubCells(item); 1034 placeSubCells(item);
1035 } 1035 }
1036 placeSubCells( placeItem ); 1036 placeSubCells( placeItem );
1037 placeItem = placeItem->nextMultiItem(); 1037 placeItem = placeItem->nextMultiItem();
1038 } 1038 }
1039 globalFlagBlockAgendaItemPaint = 0; 1039 globalFlagBlockAgendaItemPaint = 0;
1040 for ( item=oldconflictItems.first(); item != 0; 1040 for ( item=oldconflictItems.first(); item != 0;
1041 item=oldconflictItems.next() ) { 1041 item=oldconflictItems.next() ) {
1042 globalFlagBlockAgendaItemUpdate = 0; 1042 globalFlagBlockAgendaItemUpdate = 0;
1043 item->repaintMe(); 1043 item->repaintMe();
1044 globalFlagBlockAgendaItemUpdate = 1; 1044 globalFlagBlockAgendaItemUpdate = 1;
1045 item->repaint( false ); 1045 item->repaint( false );
1046 } 1046 }
1047 placeItem = modifiedItem; 1047 placeItem = modifiedItem;
1048 1048
1049 while ( placeItem ) { 1049 while ( placeItem ) {
1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1()); 1050 //qDebug("placeItem %s ", placeItem->incidence()->summary().latin1());
1051 globalFlagBlockAgendaItemUpdate = 0; 1051 globalFlagBlockAgendaItemUpdate = 0;
1052 placeItem->repaintMe(); 1052 placeItem->repaintMe();
1053 globalFlagBlockAgendaItemUpdate = 1; 1053 globalFlagBlockAgendaItemUpdate = 1;
1054 placeItem->repaint(false); 1054 placeItem->repaint(false);
1055 placeItem = placeItem->nextMultiItem(); 1055 placeItem = placeItem->nextMultiItem();
1056 } 1056 }
1057 emit itemModified( modifiedItem, mActionType ); 1057 emit itemModified( modifiedItem, mActionType );
1058 1058
1059 1059
1060 placeItem = modifiedItem; 1060 placeItem = modifiedItem;
1061 while ( placeItem ) { 1061 while ( placeItem ) {
1062 oldconflictItems = placeItem->conflictItems(); 1062 oldconflictItems = placeItem->conflictItems();
1063 for ( item=oldconflictItems.first(); item != 0; 1063 for ( item=oldconflictItems.first(); item != 0;
1064 item=oldconflictItems.next() ) { 1064 item=oldconflictItems.next() ) {
1065 placeSubCells(item); 1065 placeSubCells(item);
1066 } 1066 }
1067 placeSubCells( placeItem ); 1067 placeSubCells( placeItem );
1068 placeItem = placeItem->nextMultiItem(); 1068 placeItem = placeItem->nextMultiItem();
1069 1069
1070 } 1070 }
1071 placeItem = modifiedItem; 1071 placeItem = modifiedItem;
1072 while ( placeItem ) { 1072 while ( placeItem ) {
1073 oldconflictItems = placeItem->conflictItems(); 1073 oldconflictItems = placeItem->conflictItems();
1074 for ( item=oldconflictItems.first(); item != 0; 1074 for ( item=oldconflictItems.first(); item != 0;
1075 item=oldconflictItems.next() ) { 1075 item=oldconflictItems.next() ) {
1076 globalFlagBlockAgendaItemUpdate = 0; 1076 globalFlagBlockAgendaItemUpdate = 0;
1077 item->repaintMe(); 1077 item->repaintMe();
1078 globalFlagBlockAgendaItemUpdate = 1; 1078 globalFlagBlockAgendaItemUpdate = 1;
1079 item->repaint(false); 1079 item->repaint(false);
1080 } 1080 }
1081 placeItem = placeItem->nextMultiItem(); 1081 placeItem = placeItem->nextMultiItem();
1082 } 1082 }
1083 /* 1083 /*
1084 1084
1085 oldconflictItems = modifiedItem->conflictItems(); 1085 oldconflictItems = modifiedItem->conflictItems();
1086 for ( item=oldconflictItems.first(); item != 0; 1086 for ( item=oldconflictItems.first(); item != 0;
1087 item=oldconflictItems.next() ) { 1087 item=oldconflictItems.next() ) {
1088 globalFlagBlockAgendaItemUpdate = 0; 1088 globalFlagBlockAgendaItemUpdate = 0;
1089 item->paintMe(false); 1089 item->paintMe(false);
1090 globalFlagBlockAgendaItemUpdate = 1; 1090 globalFlagBlockAgendaItemUpdate = 1;
1091 item->repaint(false); 1091 item->repaint(false);
1092 } 1092 }
1093 */ 1093 */
1094 1094
1095 1095
1096 } 1096 }
1097 1097
1098 } 1098 }
1099 if ( mActionItem ) 1099 if ( mActionItem )
1100 emit incidenceSelected( mActionItem->incidence() ); 1100 emit incidenceSelected( mActionItem->incidence() );
1101 mScrollUpTimer.stop(); 1101 mScrollUpTimer.stop();
1102 mScrollDownTimer.stop(); 1102 mScrollDownTimer.stop();
1103 setCursor( arrowCursor ); 1103 setCursor( arrowCursor );
1104 mActionItem = 0; 1104 mActionItem = 0;
1105 mActionType = NOP; 1105 mActionType = NOP;
1106 mItemMoved = 0; 1106 mItemMoved = 0;
1107 1107
1108} 1108}
1109 1109
1110void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos) 1110void KOAgenda::setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos)
1111{ 1111{
1112// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl; 1112// kdDebug() << "viewportPos: " << viewportPos.x() << "," << viewportPos.y() << endl;
1113// QPoint point = viewport()->mapToGlobal(viewportPos); 1113// QPoint point = viewport()->mapToGlobal(viewportPos);
1114// kdDebug() << "Global: " << point.x() << "," << point.y() << endl; 1114// kdDebug() << "Global: " << point.x() << "," << point.y() << endl;
1115// point = clipper()->mapFromGlobal(point); 1115// point = clipper()->mapFromGlobal(point);
1116// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl; 1116// kdDebug() << "clipper: " << point.x() << "," << point.y() << endl;
1117 1117
1118 int x,y; 1118 int x,y;
1119 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 1119 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
1120// kdDebug() << "contents: " << x << "," << y << "\n" << endl; 1120// kdDebug() << "contents: " << x << "," << y << "\n" << endl;
1121 int gx,gy; 1121 int gx,gy;
1122 contentsToGrid(x,y,gx,gy); 1122 contentsToGrid(x,y,gx,gy);
1123 1123
1124 // Change cursor to resize cursor if appropriate 1124 // Change cursor to resize cursor if appropriate
1125 if (mAllDayMode) { 1125 if (mAllDayMode) {
1126 int gridDistanceX = (x - gx * mGridSpacingX); 1126 int gridDistanceX = (x - gx * mGridSpacingX);
1127 if (gridDistanceX < mResizeBorderWidth && 1127 if (gridDistanceX < mResizeBorderWidth &&
1128 moveItem->cellX() == gx) { 1128 moveItem->cellX() == gx) {
1129 setCursor(sizeHorCursor); 1129 setCursor(sizeHorCursor);
1130 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth && 1130 } else if ((mGridSpacingX - gridDistanceX) < mResizeBorderWidth &&
1131 moveItem->cellXWidth() == gx) { 1131 moveItem->cellXWidth() == gx) {
1132 setCursor(sizeHorCursor); 1132 setCursor(sizeHorCursor);
1133 } else { 1133 } else {
1134 setCursor(arrowCursor); 1134 setCursor(arrowCursor);
1135 } 1135 }
1136 } else { 1136 } else {
1137 int gridDistanceY = (y - gy * mGridSpacingY); 1137 int gridDistanceY = (y - gy * mGridSpacingY);
1138 if (gridDistanceY < mResizeBorderWidth && 1138 if (gridDistanceY < mResizeBorderWidth &&
1139 moveItem->cellYTop() == gy && 1139 moveItem->cellYTop() == gy &&
1140 !moveItem->firstMultiItem()) { 1140 !moveItem->firstMultiItem()) {
1141 setCursor(sizeVerCursor); 1141 setCursor(sizeVerCursor);
1142 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth && 1142 } else if ((mGridSpacingY - gridDistanceY) < mResizeBorderWidth &&
1143 moveItem->cellYBottom() == gy && 1143 moveItem->cellYBottom() == gy &&
1144 !moveItem->lastMultiItem()) { 1144 !moveItem->lastMultiItem()) {
1145 setCursor(sizeVerCursor); 1145 setCursor(sizeVerCursor);
1146 } else { 1146 } else {
1147 setCursor(arrowCursor); 1147 setCursor(arrowCursor);
1148 } 1148 }
1149 } 1149 }
1150} 1150}
1151 1151
1152 1152
1153/* 1153/*
1154 Place item in cell and take care that multiple items using the same cell do 1154 Place item in cell and take care that multiple items using the same cell do
1155 not overlap. This method is not yet optimal. It doesn´t use the maximum space 1155 not overlap. This method is not yet optimal. It doesn´t use the maximum space
1156 it can get in all cases. 1156 it can get in all cases.
1157 At the moment the method has a bug: When an item is placed only the sub cell 1157 At the moment the method has a bug: When an item is placed only the sub cell
1158 widths of the items are changed, which are within the Y region the item to 1158 widths of the items are changed, which are within the Y region the item to
1159 place spans. When the sub cell width change of one of this items affects a 1159 place spans. When the sub cell width change of one of this items affects a
1160 cell, where other items are, which do not overlap in Y with the item to place, 1160 cell, where other items are, which do not overlap in Y with the item to place,
1161 the display gets corrupted, although the corruption looks quite nice. 1161 the display gets corrupted, although the corruption looks quite nice.
1162*/ 1162*/
1163void KOAgenda::placeSubCells(KOAgendaItem *placeItem) 1163void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1164{ 1164{
1165 1165
1166 QPtrList<KOAgendaItem> conflictItems; 1166 QPtrList<KOAgendaItem> conflictItems;
1167 int maxSubCells = 0; 1167 int maxSubCells = 0;
1168 QIntDict<KOAgendaItem> subCellDict(7); 1168 QIntDict<KOAgendaItem> subCellDict(7);
1169 1169
1170 KOAgendaItem *item; 1170 KOAgendaItem *item;
1171 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1171 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1172 if (item != placeItem) { 1172 if (item != placeItem) {
1173 if (placeItem->cellX() <= item->cellXWidth() && 1173 if (placeItem->cellX() <= item->cellXWidth() &&
1174 placeItem->cellXWidth() >= item->cellX()) { 1174 placeItem->cellXWidth() >= item->cellX()) {
1175 if ((placeItem->cellYTop() <= item->cellYBottom()) && 1175 if ((placeItem->cellYTop() <= item->cellYBottom()) &&
1176 (placeItem->cellYBottom() >= item->cellYTop())) { 1176 (placeItem->cellYBottom() >= item->cellYTop())) {
1177 conflictItems.append(item); 1177 conflictItems.append(item);
1178 if (item->subCells() > maxSubCells) 1178 if (item->subCells() > maxSubCells)
1179 maxSubCells = item->subCells(); 1179 maxSubCells = item->subCells();
1180 subCellDict.insert(item->subCell(),item); 1180 subCellDict.insert(item->subCell(),item);
1181 } 1181 }
1182 } 1182 }
1183 } 1183 }
1184 } 1184 }
1185 1185
1186 if (conflictItems.count() > 0) { 1186 if (conflictItems.count() > 0) {
1187 // Look for unused sub cell and insert item 1187 // Look for unused sub cell and insert item
1188 int i; 1188 int i;
1189 for(i=0;i<maxSubCells;++i) { 1189 for(i=0;i<maxSubCells;++i) {
1190 if (!subCellDict.find(i)) { 1190 if (!subCellDict.find(i)) {
1191 placeItem->setSubCell(i); 1191 placeItem->setSubCell(i);
1192 break; 1192 break;
1193 } 1193 }
1194 } 1194 }
1195 if (i == maxSubCells) { 1195 if (i == maxSubCells) {
1196 placeItem->setSubCell(maxSubCells); 1196 placeItem->setSubCell(maxSubCells);
1197 maxSubCells++; // add new item to number of sub cells 1197 maxSubCells++; // add new item to number of sub cells
1198 } 1198 }
1199 1199
1200 // Prepare for sub cell geometry adjustment 1200 // Prepare for sub cell geometry adjustment
1201 int newSubCellWidth; 1201 int newSubCellWidth;
1202 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; 1202 if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells;
1203 else newSubCellWidth = mGridSpacingX / maxSubCells; 1203 else newSubCellWidth = mGridSpacingX / maxSubCells;
1204 conflictItems.append(placeItem); 1204 conflictItems.append(placeItem);
1205 1205
1206 1206
1207 // Adjust sub cell geometry of all direct conflict items 1207 // Adjust sub cell geometry of all direct conflict items
1208 for ( item=conflictItems.first(); item != 0; 1208 for ( item=conflictItems.first(); item != 0;
1209 item=conflictItems.next() ) { 1209 item=conflictItems.next() ) {
1210 item->setSubCells(maxSubCells); 1210 item->setSubCells(maxSubCells);
1211 if (mAllDayMode) { 1211 if (mAllDayMode) {
1212 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1212 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1213 } else { 1213 } else {
1214 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1214 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1215 } 1215 }
1216 int x,y; 1216 int x,y;
1217 gridToContents(item->cellX(),item->cellYTop(),x,y); 1217 gridToContents(item->cellX(),item->cellYTop(),x,y);
1218 if (mAllDayMode) { 1218 if (mAllDayMode) {
1219 y += item->subCell() * newSubCellWidth; 1219 y += item->subCell() * newSubCellWidth;
1220 } else { 1220 } else {
1221 x += item->subCell() * newSubCellWidth; 1221 x += item->subCell() * newSubCellWidth;
1222 } 1222 }
1223 moveChild(item,x,y); 1223 moveChild(item,x,y);
1224 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); 1224 // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y);
1225 //item->updateItem(); 1225 //item->updateItem();
1226 } 1226 }
1227 // Adjust sub cell geometry of all conflict items of all conflict items 1227 // Adjust sub cell geometry of all conflict items of all conflict items
1228 for ( item=conflictItems.first(); item != 0; 1228 for ( item=conflictItems.first(); item != 0;
1229 item=conflictItems.next() ) { 1229 item=conflictItems.next() ) {
1230 if ( placeItem != item ) { 1230 if ( placeItem != item ) {
1231 KOAgendaItem *item2; 1231 KOAgendaItem *item2;
1232 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1232 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1233 for ( item2=conflictItems2.first(); item2 != 0; 1233 for ( item2=conflictItems2.first(); item2 != 0;
1234 item2=conflictItems2.next() ) { 1234 item2=conflictItems2.next() ) {
1235 if ( item2->subCells() != maxSubCells) { 1235 if ( item2->subCells() != maxSubCells) {
1236 item2->setSubCells(maxSubCells); 1236 item2->setSubCells(maxSubCells);
1237 if (mAllDayMode) { 1237 if (mAllDayMode) {
1238 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1238 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1239 } else { 1239 } else {
1240 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1240 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1241 } 1241 }
1242 int x,y; 1242 int x,y;
1243 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1243 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1244 if (mAllDayMode) { 1244 if (mAllDayMode) {
1245 y += item2->subCell() * newSubCellWidth; 1245 y += item2->subCell() * newSubCellWidth;
1246 } else { 1246 } else {
1247 x += item2->subCell() * newSubCellWidth; 1247 x += item2->subCell() * newSubCellWidth;
1248 } 1248 }
1249 moveChild(item2,x,y); 1249 moveChild(item2,x,y);
1250 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1250 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1251 } 1251 }
1252 } 1252 }
1253 } 1253 }
1254 } 1254 }
1255 } else { 1255 } else {
1256 placeItem->setSubCell(0); 1256 placeItem->setSubCell(0);
1257 placeItem->setSubCells(1); 1257 placeItem->setSubCells(1);
1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1259 else placeItem->resize(mGridSpacingX,placeItem->height()); 1259 else placeItem->resize(mGridSpacingX,placeItem->height());
1260 int x,y; 1260 int x,y;
1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1262 moveChild(placeItem,x,y); 1262 moveChild(placeItem,x,y);
1263 } 1263 }
1264 placeItem->setConflictItems(conflictItems); 1264 placeItem->setConflictItems(conflictItems);
1265 // for ( item=conflictItems.first(); item != 0; 1265 // for ( item=conflictItems.first(); item != 0;
1266// item=conflictItems.next() ) { 1266// item=conflictItems.next() ) {
1267// //item->updateItem(); 1267// //item->updateItem();
1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1269// } 1269// }
1270// placeItem->updateItem(); 1270// placeItem->updateItem();
1271} 1271}
1272 1272
1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1274{ 1274{
1275 if ( globalFlagBlockAgenda ) 1275 if ( globalFlagBlockAgenda )
1276 return; 1276 return;
1277 1277
1278 if ( mInvalidPixmap ) { 1278 if ( mInvalidPixmap ) {
1279 mInvalidPixmap = false; 1279 mInvalidPixmap = false;
1280 qDebug("KO: Upsizing Pixmaps "); 1280 qDebug("KO: Upsizing Pixmaps ");
1281 computeSizes(); 1281 computeSizes();
1282 emit updateViewSignal(); 1282 emit updateViewSignal();
1283 return; 1283 return;
1284 } 1284 }
1285 if ( ! mAllDayMode ) { 1285 if ( ! mAllDayMode ) {
1286 // currently not working for 1286 // currently not working for
1287 1287
1288 //qDebug("KOAgenda::drawContents "); 1288 //qDebug("KOAgenda::drawContents ");
1289#if 0 1289#if 0
1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1291 qDebug("WAU "); 1291 qDebug("WAU ");
1292 drawContentsToPainter(); 1292 drawContentsToPainter();
1293 } 1293 }
1294#endif 1294#endif
1295 QPaintDevice* pd = p->device(); 1295 QPaintDevice* pd = p->device();
1296 p->end(); 1296 p->end();
1297 int vx, vy; 1297 int vx, vy;
1298 int selectionX = KOGlobals::self()->reverseLayout() ? 1298 int selectionX = KOGlobals::self()->reverseLayout() ?
1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1300 mSelectionCellX * mGridSpacingX; 1300 mSelectionCellX * mGridSpacingX;
1301 contentsToViewport ( cx, cy, vx,vy); 1301 contentsToViewport ( cx, cy, vx,vy);
1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1303 1303
1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1307 1307
1308 int vxSel, vySel; 1308 int vxSel, vySel;
1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1310 int off = mSelectionHeight; 1310 int off = mSelectionHeight;
1311 if ( vySel < 0 ) 1311 if ( vySel < 0 )
1312 off += vySel; 1312 off += vySel;
1313 //qDebug("OFF %d %d %d", off,vySel, vy ); 1313 //qDebug("OFF %d %d %d", off,vySel, vy );
1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1315 } else { 1315 } else {
1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1317 } 1317 }
1318 } 1318 }
1319 if ( mSelectionHeight > 0 ) { 1319 if ( mSelectionHeight > 0 ) {
1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1325 int hei = mSelectionHeight; 1325 int hei = mSelectionHeight;
1326 int offset = 0; 1326 int offset = 0;
1327 while ( hei > 0 ) { 1327 while ( hei > 0 ) {
1328 int p_hei = 5; 1328 int p_hei = 5;
1329 if ( hei < 5 ) p_hei = hei; 1329 if ( hei < 5 ) p_hei = hei;
1330 hei -= 5; 1330 hei -= 5;
1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1332 offset += 5; 1332 offset += 5;
1333 } 1333 }
1334 } 1334 }
1335 } 1335 }
1336 p->begin( pd ); 1336 p->begin( pd );
1337 } else { 1337 } else {
1338#if 0 1338#if 0
1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); 1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1341 qDebug("WAUWAU "); 1341 qDebug("WAUWAU ");
1342 drawContentsToPainter(); 1342 drawContentsToPainter();
1343 } 1343 }
1344#endif 1344#endif
1345 QPaintDevice* pd = p->device(); 1345 QPaintDevice* pd = p->device();
1346 p->end(); 1346 p->end();
1347 int vx, vy; 1347 int vx, vy;
1348 int selectionX = KOGlobals::self()->reverseLayout() ? 1348 int selectionX = KOGlobals::self()->reverseLayout() ?
1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1350 mSelectionCellX * mGridSpacingX; 1350 mSelectionCellX * mGridSpacingX;
1351 contentsToViewport ( cx, cy, vx,vy); 1351 contentsToViewport ( cx, cy, vx,vy);
1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1355 1355
1356 if ( mSelectionHeight > 0 ) { 1356 if ( mSelectionHeight > 0 ) {
1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1362 int hei = mSelectionHeight; 1362 int hei = mSelectionHeight;
1363 int offset = 0; 1363 int offset = 0;
1364 while ( hei > 0 ) { 1364 while ( hei > 0 ) {
1365 int p_hei = 5; 1365 int p_hei = 5;
1366 if ( hei < 5 ) p_hei = hei; 1366 if ( hei < 5 ) p_hei = hei;
1367 hei -= 5; 1367 hei -= 5;
1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1369 offset += 5; 1369 offset += 5;
1370 } 1370 }
1371 } 1371 }
1372 } 1372 }
1373 p->begin( pd ); 1373 p->begin( pd );
1374 } 1374 }
1375 1375
1376} 1376}
1377 1377
1378void KOAgenda::finishUpdate() 1378void KOAgenda::finishUpdate()
1379{ 1379{
1380 1380
1381 KOAgendaItem *item; 1381 KOAgendaItem *item;
1382 globalFlagBlockAgendaItemPaint = 1; 1382 globalFlagBlockAgendaItemPaint = 1;
1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1385 if ( !item->checkLayout() ) { 1385 if ( !item->checkLayout() ) {
1386 //qDebug(" conflictitem found "); 1386 //qDebug(" conflictitem found ");
1387 int newSubCellWidth; 1387 int newSubCellWidth;
1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1389 else newSubCellWidth = mGridSpacingX / item->subCells(); 1389 else newSubCellWidth = mGridSpacingX / item->subCells();
1390 1390
1391 if (mAllDayMode) { 1391 if (mAllDayMode) {
1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1393 } else { 1393 } else {
1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1395 } 1395 }
1396 int x,y; 1396 int x,y;
1397 gridToContents(item->cellX(),item->cellYTop(),x,y); 1397 gridToContents(item->cellX(),item->cellYTop(),x,y);
1398 if (mAllDayMode) { 1398 if (mAllDayMode) {
1399 y += item->subCell() * newSubCellWidth; 1399 y += item->subCell() * newSubCellWidth;
1400 } else { 1400 } else {
1401 x += item->subCell() * newSubCellWidth; 1401 x += item->subCell() * newSubCellWidth;
1402 } 1402 }
1403 moveChild(item,x,y); 1403 moveChild(item,x,y);
1404 } 1404 }
1405 } 1405 }
1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1407 if ( !item->isVisible() ) 1407 if ( !item->isVisible() )
1408 item->show(); 1408 item->show();
1409 1409
1410 } 1410 }
1411 globalFlagBlockAgendaItemUpdate = 0; 1411 globalFlagBlockAgendaItemUpdate = 0;
1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1413 item->repaintMe( ); 1413 item->repaintMe( );
1414 } 1414 }
1415 globalFlagBlockAgendaItemUpdate = 1; 1415 globalFlagBlockAgendaItemUpdate = 1;
1416 qApp->processEvents(); 1416 qApp->processEvents();
1417 globalFlagBlockAgendaItemPaint = 0; 1417 globalFlagBlockAgendaItemPaint = 0;
1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1419 item->repaint( false ); 1419 item->repaint( false );
1420 } 1420 }
1421 marcus_bains(); 1421 marcus_bains();
1422} 1422}
1423 1423
1424/* 1424/*
1425 Draw grid in the background of the agenda. 1425 Draw grid in the background of the agenda.
1426*/ 1426*/
1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1428{ 1428{
1429 1429
1430 1430
1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1432 return; 1432 return;
1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1434 return; 1434 return;
1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1436 if ( ch < 1 ) 1436 if ( ch < 1 )
1437 ch = 1; 1437 ch = 1;
1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1439 mPaintPixmap.resize( contentsWidth()+42, ch ); 1439 mPaintPixmap.resize( contentsWidth()+42, ch );
1440 } 1440 }
1441 mCurPixWid = contentsWidth(); 1441 mCurPixWid = contentsWidth();
1442 mCurPixHei = ch; 1442 mCurPixHei = ch;
1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1446 } 1446 }
1447 mPixPainter.begin( &mPaintPixmap) ; 1447 mPixPainter.begin( &mPaintPixmap) ;
1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1449 QPainter * p ; 1449 QPainter * p ;
1450 if (paint == 0) { 1450 if (paint == 0) {
1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1452 p = &mPixPainter; 1452 p = &mPixPainter;
1453 } 1453 }
1454 else 1454 else
1455 p = paint ; 1455 p = paint ;
1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1457 1457
1458 //--cx;++cw; 1458 //--cx;++cw;
1459 int lGridSpacingY = mGridSpacingY*2; 1459 int lGridSpacingY = mGridSpacingY*2;
1460 int selDay; 1460 int selDay;
1461 QDate curDate = QDate::currentDate(); 1461 QDate curDate = QDate::currentDate();
1462 if ( !backgroundOnly ) { 1462 if ( !backgroundOnly ) {
1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1464 { 1464 {
1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1466 int x1 = cx; 1466 int x1 = cx;
1467 int y1 = 0; 1467 int y1 = 0;
1468 if (y1 < cy) y1 = cy; 1468 if (y1 < cy) y1 = cy;
1469 int x2 = cx+cw-1; 1469 int x2 = cx+cw-1;
1470 int y2 = contentsHeight(); 1470 int y2 = contentsHeight();
1471 if (y2 > cy+ch-1) y2=cy+ch-1; 1471 if (y2 > cy+ch-1) y2=cy+ch-1;
1472 if (x2 >= x1 && y2 >= y1) { 1472 if (x2 >= x1 && y2 >= y1) {
1473 int gxStart = selDay; 1473 int gxStart = selDay;
1474 int gxEnd = gxStart ; 1474 int gxEnd = gxStart ;
1475 int xStart = KOGlobals::self()->reverseLayout() ? 1475 int xStart = KOGlobals::self()->reverseLayout() ?
1476 (mColumns - 1 - gxStart)*mGridSpacingX : 1476 (mColumns - 1 - gxStart)*mGridSpacingX :
1477 gxStart*mGridSpacingX; 1477 gxStart*mGridSpacingX;
1478 if (xStart < x1) xStart = x1; 1478 if (xStart < x1) xStart = x1;
1479 int xEnd = KOGlobals::self()->reverseLayout() ? 1479 int xEnd = KOGlobals::self()->reverseLayout() ?
1480 (mColumns - gxStart)*mGridSpacingX-1 : 1480 (mColumns - gxStart)*mGridSpacingX-1 :
1481 (gxStart+1)*mGridSpacingX-1; 1481 (gxStart+1)*mGridSpacingX-1;
1482 if (xEnd > x2) xEnd = x2; 1482 if (xEnd > x2) xEnd = x2;
1483 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1483 if ( KOPrefs::instance()->mUseHighlightLightColor )
1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1485 KOPrefs::instance()->mAgendaBgColor.light()); 1485 KOPrefs::instance()->mAgendaBgColor.light());
1486 else 1486 else
1487 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1487 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1488 KOPrefs::instance()->mAgendaBgColor.dark()); 1488 KOPrefs::instance()->mAgendaBgColor.dark());
1489 1489
1490 } 1490 }
1491 } 1491 }
1492 } 1492 }
1493 } 1493 }
1494 // Highlight working hours 1494 // Highlight working hours
1495 1495
1496 if ( !backgroundOnly ) 1496 if ( !backgroundOnly )
1497 if (mWorkingHoursEnable) { 1497 if (mWorkingHoursEnable) {
1498 int x1 = cx; 1498 int x1 = cx;
1499 int y1 = mWorkingHoursYTop; 1499 int y1 = mWorkingHoursYTop;
1500 if (y1 < cy) y1 = cy; 1500 if (y1 < cy) y1 = cy;
1501 int x2 = cx+cw-1; 1501 int x2 = cx+cw-1;
1502 // int x2 = mGridSpacingX * 5 - 1; 1502 // int x2 = mGridSpacingX * 5 - 1;
1503 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1503 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1504 int y2 = mWorkingHoursYBottom; 1504 int y2 = mWorkingHoursYBottom;
1505 if (y2 > cy+ch-1) y2=cy+ch-1; 1505 if (y2 > cy+ch-1) y2=cy+ch-1;
1506 1506
1507 if (x2 >= x1 && y2 >= y1) { 1507 if (x2 >= x1 && y2 >= y1) {
1508 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1508 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1509 int gxStart = x1/mGridSpacingX; 1509 int gxStart = x1/mGridSpacingX;
1510 int gxEnd = x2/mGridSpacingX; 1510 int gxEnd = x2/mGridSpacingX;
1511 while(gxStart <= gxEnd) { 1511 while(gxStart <= gxEnd) {
1512 if (gxStart < int(mHolidayMask->count()) && 1512 if (gxStart < int(mHolidayMask->count()) &&
1513 !mHolidayMask->at(gxStart)) { 1513 !mHolidayMask->at(gxStart)) {
1514 int xStart = KOGlobals::self()->reverseLayout() ? 1514 int xStart = KOGlobals::self()->reverseLayout() ?
1515 (mColumns - 1 - gxStart)*mGridSpacingX : 1515 (mColumns - 1 - gxStart)*mGridSpacingX :
1516 gxStart*mGridSpacingX; 1516 gxStart*mGridSpacingX;
1517 if (xStart < x1) xStart = x1; 1517 if (xStart < x1) xStart = x1;
1518 int xEnd = KOGlobals::self()->reverseLayout() ? 1518 int xEnd = KOGlobals::self()->reverseLayout() ?
1519 (mColumns - gxStart)*mGridSpacingX-1 : 1519 (mColumns - gxStart)*mGridSpacingX-1 :
1520 (gxStart+1)*mGridSpacingX-1; 1520 (gxStart+1)*mGridSpacingX-1;
1521 if (xEnd > x2) xEnd = x2; 1521 if (xEnd > x2) xEnd = x2;
1522 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { 1522 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
1523 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1523 if ( KOPrefs::instance()->mUseHighlightLightColor )
1524 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1524 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1525 KOPrefs::instance()->mWorkingHoursColor.light()); 1525 KOPrefs::instance()->mWorkingHoursColor.light());
1526 else 1526 else
1527 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1527 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1528 KOPrefs::instance()->mWorkingHoursColor.dark()); 1528 KOPrefs::instance()->mWorkingHoursColor.dark());
1529 } else { 1529 } else {
1530 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1530 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1531 KOPrefs::instance()->mWorkingHoursColor); 1531 KOPrefs::instance()->mWorkingHoursColor);
1532 } 1532 }
1533 } 1533 }
1534 ++gxStart; 1534 ++gxStart;
1535 } 1535 }
1536 } 1536 }
1537 } 1537 }
1538 /* 1538 /*
1539 int selectionX = KOGlobals::self()->reverseLayout() ? 1539 int selectionX = KOGlobals::self()->reverseLayout() ?
1540 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1540 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1541 mSelectionCellX * mGridSpacingX; 1541 mSelectionCellX * mGridSpacingX;
1542 1542
1543 // Draw selection 1543 // Draw selection
1544 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1544 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1545 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1545 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1546 // TODO: paint only part within cx,cy,cw,ch 1546 // TODO: paint only part within cx,cy,cw,ch
1547 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1547 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1548 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1548 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1549 } 1549 }
1550 */ 1550 */
1551 // Draw vertical lines of grid 1551 // Draw vertical lines of grid
1552 1552
1553 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1553 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1554 if ( mGridSpacingX > 0 ) { 1554 if ( mGridSpacingX > 0 ) {
1555 while (x < cx + cw) { 1555 while (x < cx + cw) {
1556 p->drawLine(x,cy,x,cy+ch); 1556 p->drawLine(x,cy,x,cy+ch);
1557 x+=mGridSpacingX; 1557 x+=mGridSpacingX;
1558 } 1558 }
1559 } 1559 }
1560 // Draw horizontal lines of grid 1560 // Draw horizontal lines of grid
1561 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1561 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1562 if ( lGridSpacingY > 0 ) { 1562 if ( lGridSpacingY > 0 ) {
1563 while (y < cy + ch) { 1563 while (y < cy + ch) {
1564 p->setPen( SolidLine ); 1564 p->setPen( SolidLine );
1565 p->drawLine(cx,y,cx+cw,y); 1565 p->drawLine(cx,y,cx+cw,y);
1566 y+=lGridSpacingY; 1566 y+=lGridSpacingY;
1567 p->setPen( DotLine ); 1567 p->setPen( DotLine );
1568 p->drawLine(cx,y,cx+cw,y); 1568 p->drawLine(cx,y,cx+cw,y);
1569 y+=lGridSpacingY; 1569 y+=lGridSpacingY;
1570 } 1570 }
1571 p->setPen( SolidLine ); 1571 p->setPen( SolidLine );
1572 } 1572 }
1573 mPixPainter.end() ; 1573 mPixPainter.end() ;
1574} 1574}
1575 1575
1576/* 1576/*
1577 Convert srcollview contents coordinates to agenda grid coordinates. 1577 Convert srcollview contents coordinates to agenda grid coordinates.
1578*/ 1578*/
1579void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1579void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1580{ 1580{
1581 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1581 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1582 x/mGridSpacingX; 1582 x/mGridSpacingX;
1583 gy = y/mGridSpacingY; 1583 gy = y/mGridSpacingY;
1584} 1584}
1585 1585
1586/* 1586/*
1587 Convert agenda grid coordinates to scrollview contents coordinates. 1587 Convert agenda grid coordinates to scrollview contents coordinates.
1588*/ 1588*/
1589void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1589void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1590{ 1590{
1591 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1591 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1592 gx*mGridSpacingX; 1592 gx*mGridSpacingX;
1593 y = gy*mGridSpacingY; 1593 y = gy*mGridSpacingY;
1594} 1594}
1595 1595
1596 1596
1597/* 1597/*
1598 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1598 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1599 the grid. 1599 the grid.
1600*/ 1600*/
1601int KOAgenda::timeToY(const QTime &time) 1601int KOAgenda::timeToY(const QTime &time)
1602{ 1602{
1603 int minutesPerCell = 24 * 60 / mRows; 1603 int minutesPerCell = 24 * 60 / mRows;
1604 int timeMinutes = time.hour() * 60 + time.minute(); 1604 int timeMinutes = time.hour() * 60 + time.minute();
1605 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1605 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1606 return Y; 1606 return Y;
1607} 1607}
1608 1608
1609 1609
1610/* 1610/*
1611 Return time corresponding to cell y coordinate. Coordinates are rounded to 1611 Return time corresponding to cell y coordinate. Coordinates are rounded to
1612 fit into the grid. 1612 fit into the grid.
1613*/ 1613*/
1614QTime KOAgenda::gyToTime(int gy) 1614QTime KOAgenda::gyToTime(int gy)
1615{ 1615{
1616 1616
1617 int secondsPerCell = 24 * 60 * 60/ mRows; 1617 int secondsPerCell = 24 * 60 * 60/ mRows;
1618 1618
1619 int timeSeconds = secondsPerCell * gy; 1619 int timeSeconds = secondsPerCell * gy;
1620 1620
1621 QTime time( 0, 0, 0 ); 1621 QTime time( 0, 0, 0 );
1622 if ( timeSeconds < 24 * 60 * 60 ) { 1622 if ( timeSeconds < 24 * 60 * 60 ) {
1623 time = time.addSecs(timeSeconds); 1623 time = time.addSecs(timeSeconds);
1624 } else { 1624 } else {
1625 time.setHMS( 23, 59, 59 ); 1625 time.setHMS( 23, 59, 59 );
1626 } 1626 }
1627 1627
1628 return time; 1628 return time;
1629} 1629}
1630 1630
1631void KOAgenda::setStartHour(int startHour) 1631void KOAgenda::setStartHour(int startHour)
1632{ 1632{
1633 int startCell = startHour * mRows / 24; 1633 int startCell = startHour * mRows / 24;
1634 setContentsPos(0,startCell * gridSpacingY()); 1634 setContentsPos(0,startCell * gridSpacingY());
1635} 1635}
1636QTime KOAgenda::getEndTime() 1636QTime KOAgenda::getEndTime()
1637{ 1637{
1638 return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0); 1638 int tim = (contentsY ()+viewport()->height())*24/contentsHeight ();
1639 if ( tim > 23 )
1640 return QTime ( 23,59,59);
1641 return QTime ( tim,0,0);
1639} 1642}
1640void KOAgenda::hideUnused() 1643void KOAgenda::hideUnused()
1641{ 1644{
1642 // experimental only 1645 // experimental only
1643 // return; 1646 // return;
1644 KOAgendaItem *item; 1647 KOAgendaItem *item;
1645 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1648 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1646 item->hide(); 1649 item->hide();
1647 } 1650 }
1648} 1651}
1649 1652
1650 1653
1651KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1654KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1652{ 1655{
1653 1656
1654 KOAgendaItem *fi; 1657 KOAgendaItem *fi;
1655 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1658 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1656 if ( fi->incidence() == event ) { 1659 if ( fi->incidence() == event ) {
1657 mUnusedItems.remove(); 1660 mUnusedItems.remove();
1658 fi->init( event, qd ); 1661 fi->init( event, qd );
1659 return fi; 1662 return fi;
1660 } 1663 }
1661 } 1664 }
1662 fi=mUnusedItems.first(); 1665 fi=mUnusedItems.first();
1663 if ( fi ) { 1666 if ( fi ) {
1664 mUnusedItems.remove(); 1667 mUnusedItems.remove();
1665 fi->init( event, qd ); 1668 fi->init( event, qd );
1666 return fi; 1669 return fi;
1667 } 1670 }
1668 // qDebug("new KOAgendaItem "); 1671 // qDebug("new KOAgendaItem ");
1669 1672
1670 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1673 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1671 agendaItem->installEventFilter(this); 1674 agendaItem->installEventFilter(this);
1672 addChild(agendaItem,0,0); 1675 addChild(agendaItem,0,0);
1673 return agendaItem; 1676 return agendaItem;
1674} 1677}
1675KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1678KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1676{ 1679{
1677 KOAgendaItem *item; 1680 KOAgendaItem *item;
1678 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1681 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1679 if ( item->incidence() == todo ) { 1682 if ( item->incidence() == todo ) {
1680 mItems.remove(); 1683 mItems.remove();
1681 return item; 1684 return item;
1682 } 1685 }
1683 } 1686 }
1684 return 0; 1687 return 0;
1685} 1688}
1686 1689
1687 1690
1688void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1691void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1689{ 1692{
1690 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1693 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1691 KOAgendaItem *item; 1694 KOAgendaItem *item;
1692 item = getItemForTodo ( todo ); 1695 item = getItemForTodo ( todo );
1693 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1696 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1694 if ( item ) { 1697 if ( item ) {
1695 blockSignals( true ); 1698 blockSignals( true );
1696 //qDebug("item found "); 1699 //qDebug("item found ");
1697 item->hide(); 1700 item->hide();
1698 item->setCellX(-2, -1 ); 1701 item->setCellX(-2, -1 );
1699 item->select(false); 1702 item->select(false);
1700 mUnusedItems.append( item ); 1703 mUnusedItems.append( item );
1701 mItems.remove( item ); 1704 mItems.remove( item );
1702 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1705 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1703 KOAgendaItem *itemit; 1706 KOAgendaItem *itemit;
1704 //globalFlagBlockAgendaItemPaint = 1; 1707 //globalFlagBlockAgendaItemPaint = 1;
1705 for ( itemit=oldconflictItems.first(); itemit != 0; 1708 for ( itemit=oldconflictItems.first(); itemit != 0;
1706 itemit=oldconflictItems.next() ) { 1709 itemit=oldconflictItems.next() ) {
1707 if ( itemit != item ) 1710 if ( itemit != item )
1708 placeSubCells(itemit); 1711 placeSubCells(itemit);
1709 } 1712 }
1710 qApp->processEvents(); 1713 qApp->processEvents();
1711 //globalFlagBlockAgendaItemPaint = 0; 1714 //globalFlagBlockAgendaItemPaint = 0;
1712 for ( itemit=oldconflictItems.first(); itemit != 0; 1715 for ( itemit=oldconflictItems.first(); itemit != 0;
1713 itemit=oldconflictItems.next() ) { 1716 itemit=oldconflictItems.next() ) {
1714 globalFlagBlockAgendaItemUpdate = 0; 1717 globalFlagBlockAgendaItemUpdate = 0;
1715 if ( itemit != item ) 1718 if ( itemit != item )
1716 itemit->repaintMe(); 1719 itemit->repaintMe();
1717 globalFlagBlockAgendaItemUpdate = 1; 1720 globalFlagBlockAgendaItemUpdate = 1;
1718 //qDebug("sigleshot "); 1721 //qDebug("sigleshot ");
1719 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1722 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1720 //itemit->repaint( false ); repaintItem() 1723 //itemit->repaint( false ); repaintItem()
1721 } 1724 }
1722 blockSignals( false ); 1725 blockSignals( false );
1723 } 1726 }
1724 if ( remove ) { 1727 if ( remove ) {
1725 //qDebug("remove****************************************** "); 1728 //qDebug("remove****************************************** ");
1726 return; 1729 return;
1727 } 1730 }
1728 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1731 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1729 return; 1732 return;
1730 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1733 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1731 QDate currentDate = QDate::currentDate(); 1734 QDate currentDate = QDate::currentDate();
1732 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1735 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1733 QDateTime dt; 1736 QDateTime dt;
1734 if ( todo->hasCompletedDate() ) 1737 if ( todo->hasCompletedDate() )
1735 dt = todo->completed(); 1738 dt = todo->completed();
1736 else 1739 else
1737 dt = todo->dtDue(); 1740 dt = todo->dtDue();
1738 if ( overdue ) { 1741 if ( overdue ) {
1739 days += todo->dtDue().date().daysTo( currentDate ); 1742 days += todo->dtDue().date().daysTo( currentDate );
1740 } 1743 }
1741 else 1744 else
1742 currentDate = dt.date(); 1745 currentDate = dt.date();
1743 1746
1744 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1747 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1745 if ( ! mAllDayMode ) return; 1748 if ( ! mAllDayMode ) return;
1746 // aldayagenda 1749 // aldayagenda
1747 globalFlagBlockAgendaItemPaint = 1; 1750 globalFlagBlockAgendaItemPaint = 1;
1748 item = insertAllDayItem(todo, currentDate,days, days); 1751 item = insertAllDayItem(todo, currentDate,days, days);
1749 item->show(); 1752 item->show();
1750 1753
1751 } 1754 }
1752 else { 1755 else {
1753 if ( mAllDayMode ) return; 1756 if ( mAllDayMode ) return;
1754 // mAgenda 1757 // mAgenda
1755 globalFlagBlockAgendaItemPaint = 1; 1758 globalFlagBlockAgendaItemPaint = 1;
1756 int endY = timeToY(dt.time()) - 1; 1759 int endY = timeToY(dt.time()) - 1;
1757 int hi = 12/KOPrefs::instance()->mHourSize; 1760 int hi = 12/KOPrefs::instance()->mHourSize;
1758 int startY = endY - 1-hi; 1761 int startY = endY - 1-hi;
1759 item = insertItem(todo,currentDate,days,startY,endY); 1762 item = insertItem(todo,currentDate,days,startY,endY);
1760 item->show(); 1763 item->show();
1761 } 1764 }
1762 qApp->processEvents(); 1765 qApp->processEvents();
1763 globalFlagBlockAgendaItemPaint = 0; 1766 globalFlagBlockAgendaItemPaint = 0;
1764 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1767 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1765 KOAgendaItem *itemit; 1768 KOAgendaItem *itemit;
1766 for ( itemit=oldconflictItems.first(); itemit != 0; 1769 for ( itemit=oldconflictItems.first(); itemit != 0;
1767 itemit=oldconflictItems.next() ) { 1770 itemit=oldconflictItems.next() ) {
1768 globalFlagBlockAgendaItemUpdate = 0; 1771 globalFlagBlockAgendaItemUpdate = 0;
1769 itemit->repaintMe(); 1772 itemit->repaintMe();
1770 globalFlagBlockAgendaItemUpdate = 1; 1773 globalFlagBlockAgendaItemUpdate = 1;
1771 itemit->repaint(); 1774 itemit->repaint();
1772 } 1775 }
1773 globalFlagBlockAgendaItemUpdate = 0; 1776 globalFlagBlockAgendaItemUpdate = 0;
1774 item->repaintMe(); 1777 item->repaintMe();
1775 globalFlagBlockAgendaItemUpdate = 1; 1778 globalFlagBlockAgendaItemUpdate = 1;
1776 item->repaint(); 1779 item->repaint();
1777} 1780}
1778/* 1781/*
1779 Insert KOAgendaItem into agenda. 1782 Insert KOAgendaItem into agenda.
1780*/ 1783*/
1781KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1784KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1782{ 1785{
1783 if (mAllDayMode) { 1786 if (mAllDayMode) {
1784 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1787 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1785 return 0; 1788 return 0;
1786 } 1789 }
1787 1790
1788 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1791 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1789 //agendaItem->setFrameStyle(WinPanel|Raised); 1792 //agendaItem->setFrameStyle(WinPanel|Raised);
1790 1793
1791 int YSize = YBottom - YTop + 1; 1794 int YSize = YBottom - YTop + 1;
1792 if (YSize < 0) { 1795 if (YSize < 0) {
1793 YSize = 1; 1796 YSize = 1;
1794 } 1797 }
1795 int iheight = mGridSpacingY * YSize; 1798 int iheight = mGridSpacingY * YSize;
1796 1799
1797 agendaItem->resize(mGridSpacingX,iheight ); 1800 agendaItem->resize(mGridSpacingX,iheight );
1798 agendaItem->setCellXY(X,YTop,YBottom); 1801 agendaItem->setCellXY(X,YTop,YBottom);
1799 agendaItem->setCellXWidth(X); 1802 agendaItem->setCellXWidth(X);
1800 1803
1801 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1804 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1802 mItems.append(agendaItem); 1805 mItems.append(agendaItem);
1803 1806
1804 placeSubCells(agendaItem); 1807 placeSubCells(agendaItem);
1805 1808
1806 //agendaItem->show(); 1809 //agendaItem->show();
1807 1810
1808 1811
1809 return agendaItem; 1812 return agendaItem;
1810} 1813}
1811 1814
1812 1815
1813/* 1816/*
1814 Insert all-day KOAgendaItem into agenda. 1817 Insert all-day KOAgendaItem into agenda.
1815*/ 1818*/
1816KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1819KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1817{ 1820{
1818 if (!mAllDayMode) { 1821 if (!mAllDayMode) {
1819 return 0; 1822 return 0;
1820 } 1823 }
1821 1824
1822 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1825 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1823 1826
1824 agendaItem->setCellXY(XBegin,0,0); 1827 agendaItem->setCellXY(XBegin,0,0);
1825 agendaItem->setCellXWidth(XEnd); 1828 agendaItem->setCellXWidth(XEnd);
1826 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1829 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1827 1830
1828 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1831 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1829 mItems.append(agendaItem); 1832 mItems.append(agendaItem);
1830 1833
1831 placeSubCells(agendaItem); 1834 placeSubCells(agendaItem);
1832 1835
1833 //agendaItem->show(); 1836 //agendaItem->show();
1834 1837
1835 return agendaItem; 1838 return agendaItem;
1836} 1839}
1837 1840
1838 1841
1839void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1842void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1840 int YTop,int YBottom) 1843 int YTop,int YBottom)
1841{ 1844{
1842 if (mAllDayMode) { 1845 if (mAllDayMode) {
1843 ; 1846 ;
1844 return; 1847 return;
1845 } 1848 }
1846 1849
1847 int cellX,cellYTop,cellYBottom; 1850 int cellX,cellYTop,cellYBottom;
1848 QString newtext; 1851 QString newtext;
1849 int width = XEnd - XBegin + 1; 1852 int width = XEnd - XBegin + 1;
1850 int count = 0; 1853 int count = 0;
1851 KOAgendaItem *current = 0; 1854 KOAgendaItem *current = 0;
1852 QPtrList<KOAgendaItem> multiItems; 1855 QPtrList<KOAgendaItem> multiItems;
1853 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1856 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1854 if (cellX == XBegin) cellYTop = YTop; 1857 if (cellX == XBegin) cellYTop = YTop;
1855 else cellYTop = 0; 1858 else cellYTop = 0;
1856 if (cellX == XEnd) cellYBottom = YBottom; 1859 if (cellX == XEnd) cellYBottom = YBottom;
1857 else cellYBottom = rows() - 1; 1860 else cellYBottom = rows() - 1;
1858 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1861 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1859 newtext.append(event->summary()); 1862 newtext.append(event->summary());
1860 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1863 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1861 current->setText(newtext); 1864 current->setText(newtext);
1862 multiItems.append(current); 1865 multiItems.append(current);
1863 } 1866 }
1864 1867
1865 KOAgendaItem *next = 0; 1868 KOAgendaItem *next = 0;
1866 KOAgendaItem *last = multiItems.last(); 1869 KOAgendaItem *last = multiItems.last();
1867 KOAgendaItem *first = multiItems.first(); 1870 KOAgendaItem *first = multiItems.first();
1868 KOAgendaItem *setFirst,*setLast; 1871 KOAgendaItem *setFirst,*setLast;
1869 current = first; 1872 current = first;
1870 while (current) { 1873 while (current) {
1871 next = multiItems.next(); 1874 next = multiItems.next();
1872 if (current == first) setFirst = 0; 1875 if (current == first) setFirst = 0;
1873 else setFirst = first; 1876 else setFirst = first;
1874 if (current == last) setLast = 0; 1877 if (current == last) setLast = 0;
1875 else setLast = last; 1878 else setLast = last;
1876 1879
1877 current->setMultiItem(setFirst,next,setLast); 1880 current->setMultiItem(setFirst,next,setLast);
1878 current = next; 1881 current = next;
1879 } 1882 }
1880} 1883}
1881 1884
1882 1885
1883//QSizePolicy KOAgenda::sizePolicy() const 1886//QSizePolicy KOAgenda::sizePolicy() const
1884//{ 1887//{
1885 // Thought this would make the all-day event agenda minimum size and the 1888 // Thought this would make the all-day event agenda minimum size and the
1886 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1889 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1887 // don´t seem to think that an Expanding widget needs more space than a 1890 // don´t seem to think that an Expanding widget needs more space than a
1888 // Preferred one. 1891 // Preferred one.
1889 // But it doesn´t hurt, so it stays. 1892 // But it doesn´t hurt, so it stays.
1890// if (mAllDayMode) { 1893// if (mAllDayMode) {
1891// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1894// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1892// } else { 1895// } else {
1893// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1896// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1894// } 1897// }
1895//} 1898//}
1896void KOAgenda::finishResize ( ) 1899void KOAgenda::finishResize ( )
1897{ 1900{
1898 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1901 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1899 if ( globalFlagBlockAgenda == 0 ) { 1902 if ( globalFlagBlockAgenda == 0 ) {
1900 finishUpdate(); 1903 finishUpdate();
1901 //qDebug("finishUpdate() called "); 1904 //qDebug("finishUpdate() called ");
1902 } 1905 }
1903} 1906}
1904/* 1907/*
1905 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1908 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1906*/ 1909*/
1907void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1910void KOAgenda::resizeEvent ( QResizeEvent *ev )
1908{ 1911{
1909 mSelectionHeight = 0; 1912 mSelectionHeight = 0;
1910 mResizeTimer.start( 150 , true ); 1913 mResizeTimer.start( 150 , true );
1911 computeSizes(); 1914 computeSizes();
1912 return; 1915 return;
1913 1916
1914} 1917}
1915void KOAgenda::computeSizes() 1918void KOAgenda::computeSizes()
1916{ 1919{
1917 if ( globalFlagBlockStartup ) 1920 if ( globalFlagBlockStartup )
1918 return; 1921 return;
1919 int frameOffset = frameWidth() * 2 +1; 1922 int frameOffset = frameWidth() * 2 +1;
1920 if (mAllDayMode) { 1923 if (mAllDayMode) {
1921 mGridSpacingX = (width()-frameOffset) / mColumns; 1924 mGridSpacingX = (width()-frameOffset) / mColumns;
1922 mGridSpacingY = height() - 2 * frameWidth() - 1; 1925 mGridSpacingY = height() - 2 * frameWidth() - 1;
1923 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1926 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1924 // mGridSpacingY = height(); 1927 // mGridSpacingY = height();
1925 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1928 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1926 1929
1927 KOAgendaItem *item; 1930 KOAgendaItem *item;
1928 int subCellWidth; 1931 int subCellWidth;
1929 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1932 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1930 subCellWidth = mGridSpacingY / item->subCells(); 1933 subCellWidth = mGridSpacingY / item->subCells();
1931 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1934 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1932 moveChild(item,KOGlobals::self()->reverseLayout() ? 1935 moveChild(item,KOGlobals::self()->reverseLayout() ?
1933 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1936 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1934 item->cellX() * mGridSpacingX, 1937 item->cellX() * mGridSpacingX,
1935 item->subCell() * subCellWidth); 1938 item->subCell() * subCellWidth);
1936 } 1939 }
1937 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1940 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1938 } else { 1941 } else {
1939 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1942 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1940 if (height() > mGridSpacingY * mRows + 1 ) { 1943 if (height() > mGridSpacingY * mRows + 1 ) {
1941 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1944 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1942 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1945 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1943 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1946 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1944 emit resizedSignal(); 1947 emit resizedSignal();
1945 } else 1948 } else
1946 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1949 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1947 KOAgendaItem *item; 1950 KOAgendaItem *item;
1948 int subCellWidth; 1951 int subCellWidth;
1949 1952
1950 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1953 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1951 subCellWidth = mGridSpacingX / item->subCells(); 1954 subCellWidth = mGridSpacingX / item->subCells();
1952 item->resize(subCellWidth,item->height()); 1955 item->resize(subCellWidth,item->height());
1953 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1956 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1954 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1957 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1955 item->cellX() * mGridSpacingX) + 1958 item->cellX() * mGridSpacingX) +
1956 item->subCell() * subCellWidth,childY(item)); 1959 item->subCell() * subCellWidth,childY(item));
1957 } 1960 }
1958 } 1961 }
1959 int cw = contentsWidth(); 1962 int cw = contentsWidth();
1960 int ch = contentsHeight(); 1963 int ch = contentsHeight();
1961 if ( mAllDayMode ) { 1964 if ( mAllDayMode ) {
1962 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1965 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1963 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1966 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1964 //qDebug("paintPixAll->resize "); 1967 //qDebug("paintPixAll->resize ");
1965 paintPixAll->resize( cw, ch ); 1968 paintPixAll->resize( cw, ch );
1966 } 1969 }
1967 } else { 1970 } else {
1968 QPixmap* paintPix = KOAgendaItem::paintPix(); 1971 QPixmap* paintPix = KOAgendaItem::paintPix();
1969 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1972 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1970 //qDebug("paintPix->resize "); 1973 //qDebug("paintPix->resize ");
1971 paintPix->resize( cw , ch ); 1974 paintPix->resize( cw , ch );
1972 } 1975 }
1973 } 1976 }
1974 1977
1975 checkScrollBoundaries(); 1978 checkScrollBoundaries();
1976 drawContentsToPainter(); 1979 drawContentsToPainter();
1977 viewport()->repaint(false); 1980 viewport()->repaint(false);
1978} 1981}
1979 1982
1980void KOAgenda::scrollUp() 1983void KOAgenda::scrollUp()
1981{ 1984{
1982 scrollBy(0,-mScrollOffset); 1985 scrollBy(0,-mScrollOffset);
1983} 1986}
1984 1987
1985 1988
1986void KOAgenda::scrollDown() 1989void KOAgenda::scrollDown()
1987{ 1990{
1988 scrollBy(0,mScrollOffset); 1991 scrollBy(0,mScrollOffset);
1989} 1992}
1990 1993
1991void KOAgenda::popupAlarm() 1994void KOAgenda::popupAlarm()
1992{ 1995{
1993 if (!mClickedItem) { 1996 if (!mClickedItem) {
1994 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1997 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1995 return; 1998 return;
1996 } 1999 }
1997 // TODO: deal correctly with multiple alarms 2000 // TODO: deal correctly with multiple alarms
1998 Alarm* alarm; 2001 Alarm* alarm;
1999 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 2002 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
2000 for(alarm=list.first();alarm;alarm=list.next()) { 2003 for(alarm=list.first();alarm;alarm=list.next()) {
2001 alarm->toggleAlarm(); 2004 alarm->toggleAlarm();
2002 } 2005 }
2003 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2006 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2004 mClickedItem->paintMe( true ); 2007 mClickedItem->paintMe( true );
2005 mClickedItem->repaint( false ); 2008 mClickedItem->repaint( false );
2006} 2009}
2007 2010
2008/* 2011/*
2009 Calculates the minimum width 2012 Calculates the minimum width
2010*/ 2013*/
2011int KOAgenda::minimumWidth() const 2014int KOAgenda::minimumWidth() const
2012{ 2015{
2013 // TODO:: develop a way to dynamically determine the minimum width 2016 // TODO:: develop a way to dynamically determine the minimum width
2014 int min = 100; 2017 int min = 100;
2015 2018
2016 return min; 2019 return min;
2017} 2020}
2018 2021
2019void KOAgenda::updateConfig() 2022void KOAgenda::updateConfig()
2020{ 2023{
2021 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2024 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
2022 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2025 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
2023 if ( mAllDayMode ) { 2026 if ( mAllDayMode ) {
2024 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize; 2027 mGridSpacingY = height() - 1 ;// KOPrefs::instance()->mAllDaySize;
2025 //mGridSpacingY = KOPrefs::instance()->mAllDaySize; 2028 //mGridSpacingY = KOPrefs::instance()->mAllDaySize;
2026 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 ); 2029 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY+1 );
2027 // setMaximumHeight( mGridSpacingY+1 ); 2030 // setMaximumHeight( mGridSpacingY+1 );
2028 viewport()->repaint( false ); 2031 viewport()->repaint( false );
2029 //setFixedHeight( mGridSpacingY+1 ); 2032 //setFixedHeight( mGridSpacingY+1 );
2030 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize); 2033 //qDebug("KOPrefs:aaaaa:instance()->mAllDaySize %d ", KOPrefs::instance()->mAllDaySize);
2031 } 2034 }
2032 else { 2035 else {
2033 mGridSpacingY = KOPrefs::instance()->mHourSize; 2036 mGridSpacingY = KOPrefs::instance()->mHourSize;
2034 calculateWorkingHours(); 2037 calculateWorkingHours();
2035 } 2038 }
2036} 2039}
2037 2040
2038void KOAgenda::checkScrollBoundaries() 2041void KOAgenda::checkScrollBoundaries()
2039{ 2042{
2040 // Invalidate old values to force update 2043 // Invalidate old values to force update
2041 mOldLowerScrollValue = -1; 2044 mOldLowerScrollValue = -1;
2042 mOldUpperScrollValue = -1; 2045 mOldUpperScrollValue = -1;
2043 2046
2044 checkScrollBoundaries(verticalScrollBar()->value()); 2047 checkScrollBoundaries(verticalScrollBar()->value());
2045} 2048}
2046 2049
2047void KOAgenda::checkScrollBoundaries(int v) 2050void KOAgenda::checkScrollBoundaries(int v)
2048{ 2051{
2049 if ( mGridSpacingY == 0 ) 2052 if ( mGridSpacingY == 0 )
2050 return; 2053 return;
2051 int yMin = v/mGridSpacingY; 2054 int yMin = v/mGridSpacingY;
2052 int yMax = (v+visibleHeight())/mGridSpacingY; 2055 int yMax = (v+visibleHeight())/mGridSpacingY;
2053 2056
2054// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl; 2057// kdDebug() << "--- yMin: " << yMin << " yMax: " << yMax << endl;
2055 2058
2056 if (yMin != mOldLowerScrollValue) { 2059 if (yMin != mOldLowerScrollValue) {
2057 mOldLowerScrollValue = yMin; 2060 mOldLowerScrollValue = yMin;
2058 emit lowerYChanged(yMin); 2061 emit lowerYChanged(yMin);
2059 } 2062 }
2060 if (yMax != mOldUpperScrollValue) { 2063 if (yMax != mOldUpperScrollValue) {
2061 mOldUpperScrollValue = yMax; 2064 mOldUpperScrollValue = yMax;
2062 emit upperYChanged(yMax); 2065 emit upperYChanged(yMax);
2063 } 2066 }
2064} 2067}
2065 2068
2066void KOAgenda::deselectItem() 2069void KOAgenda::deselectItem()
2067{ 2070{
2068 if (mSelectedItem.isNull()) return; 2071 if (mSelectedItem.isNull()) return;
2069 mSelectedItem->select(false); 2072 mSelectedItem->select(false);
2070 mSelectedItem = 0; 2073 mSelectedItem = 0;
2071} 2074}
2072 2075
2073void KOAgenda::selectItem(KOAgendaItem *item) 2076void KOAgenda::selectItem(KOAgendaItem *item)
2074{ 2077{
2075 if ((KOAgendaItem *)mSelectedItem == item) return; 2078 if ((KOAgendaItem *)mSelectedItem == item) return;
2076 deselectItem(); 2079 deselectItem();
2077 if (item == 0) { 2080 if (item == 0) {
2078 emit incidenceSelected( 0 ); 2081 emit incidenceSelected( 0 );
2079 return; 2082 return;
2080 } 2083 }
2081 mSelectedItem = item; 2084 mSelectedItem = item;
2082 mSelectedItem->select(); 2085 mSelectedItem->select();
2083 emit incidenceSelected( mSelectedItem->incidence() ); 2086 emit incidenceSelected( mSelectedItem->incidence() );
2084} 2087}
2085 2088
2086// This function seems never be called. 2089// This function seems never be called.
2087void KOAgenda::keyPressEvent( QKeyEvent *kev ) 2090void KOAgenda::keyPressEvent( QKeyEvent *kev )
2088{ 2091{
2089 switch(kev->key()) { 2092 switch(kev->key()) {
2090 case Key_PageDown: 2093 case Key_PageDown:
2091 verticalScrollBar()->addPage(); 2094 verticalScrollBar()->addPage();
2092 break; 2095 break;
2093 case Key_PageUp: 2096 case Key_PageUp:
2094 verticalScrollBar()->subtractPage(); 2097 verticalScrollBar()->subtractPage();
2095 break; 2098 break;
2096 case Key_Down: 2099 case Key_Down:
2097 verticalScrollBar()->addLine(); 2100 verticalScrollBar()->addLine();
2098 break; 2101 break;
2099 case Key_Up: 2102 case Key_Up:
2100 verticalScrollBar()->subtractLine(); 2103 verticalScrollBar()->subtractLine();
2101 break; 2104 break;
2102 default: 2105 default:
2103 ; 2106 ;
2104 } 2107 }
2105} 2108}
2106 2109
2107void KOAgenda::calculateWorkingHours() 2110void KOAgenda::calculateWorkingHours()
2108{ 2111{
2109// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours; 2112// mWorkingHoursEnable = KOPrefs::instance()->mEnableWorkingHours;
2110 mWorkingHoursEnable = !mAllDayMode; 2113 mWorkingHoursEnable = !mAllDayMode;
2111 2114
2112 mWorkingHoursYTop = mGridSpacingY * 2115 mWorkingHoursYTop = mGridSpacingY *
2113 KOPrefs::instance()->mWorkingHoursStart * 4; 2116 KOPrefs::instance()->mWorkingHoursStart * 4;
2114 mWorkingHoursYBottom = mGridSpacingY * 2117 mWorkingHoursYBottom = mGridSpacingY *
2115 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1; 2118 KOPrefs::instance()->mWorkingHoursEnd * 4 - 1;
2116} 2119}
2117 2120
2118 2121
2119DateList KOAgenda::dateList() const 2122DateList KOAgenda::dateList() const
2120{ 2123{
2121 return mSelectedDates; 2124 return mSelectedDates;
2122} 2125}
2123 2126
2124void KOAgenda::setDateList(const DateList &selectedDates) 2127void KOAgenda::setDateList(const DateList &selectedDates)
2125{ 2128{
2126 mSelectedDates = selectedDates; 2129 mSelectedDates = selectedDates;
2127} 2130}
2128 2131
2129void KOAgenda::setHolidayMask(QMemArray<bool> *mask) 2132void KOAgenda::setHolidayMask(QMemArray<bool> *mask)
2130{ 2133{
2131 mHolidayMask = mask; 2134 mHolidayMask = mask;
2132 2135
2133/* 2136/*
2134 kdDebug() << "HolidayMask: "; 2137 kdDebug() << "HolidayMask: ";
2135 for(uint i=0;i<mask->count();++i) { 2138 for(uint i=0;i<mask->count();++i) {
2136 kdDebug() << (mask->at(i) ? "*" : "o"); 2139 kdDebug() << (mask->at(i) ? "*" : "o");
2137 } 2140 }
2138 kdDebug() << endl; 2141 kdDebug() << endl;
2139*/ 2142*/
2140} 2143}
2141 2144
2142void KOAgenda::contentsMousePressEvent ( QMouseEvent *event ) 2145void KOAgenda::contentsMousePressEvent ( QMouseEvent *event )
2143{ 2146{
2144 2147
2145 QScrollView::contentsMousePressEvent(event); 2148 QScrollView::contentsMousePressEvent(event);
2146} 2149}
2147 2150
2148void KOAgenda::storePosition() 2151void KOAgenda::storePosition()
2149{ 2152{
2150 //mContentPosition 2153 //mContentPosition
2151 int max = mGridSpacingY*4*24; 2154 int max = mGridSpacingY*4*24;
2152 if ( contentsY() < 5 && max > viewport()->height()*3/2 ) 2155 if ( contentsY() < 5 && max > viewport()->height()*3/2 )
2153 mContentPosition = 0; 2156 mContentPosition = 0;
2154 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2) 2157 else if ( contentsY() + viewport()->height() > max - 5 && max > viewport()->height()*3/2)
2155 mContentPosition = -1.0; 2158 mContentPosition = -1.0;
2156 else 2159 else
2157 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2))); 2160 mContentPosition = ((float) max)/ ((float)(contentsY()+ ( viewport()->height()/2)));
2158 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height()); 2161 //qDebug("mContentPosition %f %d %d %d",mContentPosition , max, contentsY() ,viewport()->height());
2159 2162
2160} 2163}
2161void KOAgenda::restorePosition() 2164void KOAgenda::restorePosition()
2162{ 2165{
2163 int posY; 2166 int posY;
2164 int max = mGridSpacingY*4*24; 2167 int max = mGridSpacingY*4*24;
2165 if ( mContentPosition < 0 ) 2168 if ( mContentPosition < 0 )
2166 posY = max-viewport()->height(); 2169 posY = max-viewport()->height();
2167 else 2170 else
2168 if ( mContentPosition == 0 ) 2171 if ( mContentPosition == 0 )
2169 posY = 0; 2172 posY = 0;
2170 else 2173 else
2171 posY = (max/mContentPosition)-(viewport()->height()/2); 2174 posY = (max/mContentPosition)-(viewport()->height()/2);
2172 setContentsPos (0, posY ); 2175 setContentsPos (0, posY );
2173 //qDebug("posY %d hei %d", posY, max); 2176 //qDebug("posY %d hei %d", posY, max);
2174 2177
2175} 2178}
2176void KOAgenda::moveChild( QWidget *w, int x , int y ) 2179void KOAgenda::moveChild( QWidget *w, int x , int y )
2177{ 2180{
2178 ++x; 2181 ++x;
2179 QScrollView::moveChild( w, x , y ); 2182 QScrollView::moveChild( w, x , y );
2180} 2183}
2181#include <qmessagebox.h> 2184#include <qmessagebox.h>
2182#ifdef DESKTOP_VERSION 2185#ifdef DESKTOP_VERSION
2183#include <qprinter.h> 2186#include <qprinter.h>
2184#include <qpainter.h> 2187#include <qpainter.h>
2185#include <qpaintdevicemetrics.h> 2188#include <qpaintdevicemetrics.h>
2186 2189
2187#endif 2190#endif
2188void KOAgenda::printSelection() 2191void KOAgenda::printSelection()
2189{ 2192{
2190#ifdef DESKTOP_VERSION 2193#ifdef DESKTOP_VERSION
2191 if ( mStartCellY == mCurrentCellY ) { 2194 if ( mStartCellY == mCurrentCellY ) {
2192 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2195 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2193 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "), 2196 i18n("Nothing selected!\n\nThis prints the full width of the Agenda view as you see it!\n\nTo determine the vertical range of the printing, please select\na vertical range (with the left mouse button down) in one column. "),
2194 i18n("OK"), 0, 0, 2197 i18n("OK"), 0, 0,
2195 0, 1 ); 2198 0, 1 );
2196 return; 2199 return;
2197 } 2200 }
2198 2201
2199 float dx, dy; 2202 float dx, dy;
2200 int x,y,w,h; 2203 int x,y,w,h;
2201 x= 0; 2204 x= 0;
2202 w= contentsWidth()+2; 2205 w= contentsWidth()+2;
2203 // h= contentsHeight(); 2206 // h= contentsHeight();
2204 y = mGridSpacingY*mStartCellY; 2207 y = mGridSpacingY*mStartCellY;
2205 h = mGridSpacingY*(mCurrentCellY+1)-y+2; 2208 h = mGridSpacingY*(mCurrentCellY+1)-y+2;
2206 2209
2207 //return; 2210 //return;
2208 QPrinter* printer = new QPrinter(); 2211 QPrinter* printer = new QPrinter();
2209 if ( !printer->setup()) { 2212 if ( !printer->setup()) {
2210 delete printer; 2213 delete printer;
2211 return; 2214 return;
2212 } 2215 }
2213 QPainter p( printer ); 2216 QPainter p( printer );
2214 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer ); 2217 QPaintDeviceMetrics m = QPaintDeviceMetrics ( printer );
2215 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() ); 2218 QString date = i18n("Date range: ")+KGlobal::locale()->formatDate( mSelectedDates.first() )+" - "+KGlobal::locale()->formatDate( mSelectedDates.last() );
2216 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true ); 2219 //date += " --- printing time: " + KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), true );
2217 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height(); 2220 int hei = p.boundingRect(0,0, 5, 5, Qt::AlignLeft, date ).height();
2218 // p.drawText( 0, 0, date ); 2221 // p.drawText( 0, 0, date );
2219 int offset = m.width()/8; 2222 int offset = m.width()/8;
2220 // compute the scale 2223 // compute the scale
2221 dx = ((float) m.width()-offset) / (float)w; 2224 dx = ((float) m.width()-offset) / (float)w;
2222 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h; 2225 dy = (float)(m.height() - ( 2 * hei )-offset ) / (float)h;
2223 float scale; 2226 float scale;
2224 // scale to fit the width or height of the paper 2227 // scale to fit the width or height of the paper
2225 if ( dx < dy ) 2228 if ( dx < dy )
2226 scale = dx; 2229 scale = dx;
2227 else 2230 else
2228 scale = dy; 2231 scale = dy;
2229 // set the scale 2232 // set the scale
2230 p.drawText( offset* scale, offset* scale*3/4, date ); 2233 p.drawText( offset* scale, offset* scale*3/4, date );
2231 2234
2232 int selDay; 2235 int selDay;
2233 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count())); 2236 float widOffset = ((float) m.width()-offset) / ((float)(mSelectedDates.count()));
2234 float startX = 1; 2237 float startX = 1;
2235 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 2238 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
2236 { 2239 {
2237 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true ); 2240 QString text = KGlobal::locale()->formatDate( mSelectedDates[selDay],true );
2238 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) ); 2241 p.setClipRect(offset* scale+startX , 0, widOffset-4, offset* scale+(2*hei* scale) );
2239 p.drawText( offset* scale+startX, (offset+hei)* scale, text ); 2242 p.drawText( offset* scale+startX, (offset+hei)* scale, text );
2240 startX += widOffset; 2243 startX += widOffset;
2241 2244
2242 } 2245 }
2243 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale)); 2246 p.translate( offset* scale,offset* scale+ (-y * scale)+(2*hei* scale));
2244 p.scale( scale, scale ); 2247 p.scale( scale, scale );
2245 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale ); 2248 p.setClipRect( offset* scale, offset* scale+(2*hei* scale), w*scale, h*scale );
2246 // now printing with y offset: 2 hei 2249 // now printing with y offset: 2 hei
2247 // p.translate( 0, -y*scale); 2250 // p.translate( 0, -y*scale);
2248 2251
2249 drawContentsToPainter(&p, true ); 2252 drawContentsToPainter(&p, true );
2250 globalFlagBlockAgendaItemUpdate = false; 2253 globalFlagBlockAgendaItemUpdate = false;
2251 KOAgendaItem *item; 2254 KOAgendaItem *item;
2252 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 2255 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
2253 item->select(false); 2256 item->select(false);
2254 item->paintMe( false, &p ); 2257 item->paintMe( false, &p );
2255 } 2258 }
2256 globalFlagBlockAgendaItemUpdate = true; 2259 globalFlagBlockAgendaItemUpdate = true;
2257 p.end(); 2260 p.end();
2258 delete printer; 2261 delete printer;
2259#else 2262#else
2260 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2263 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2261 i18n("Not supported \non PDA!\n"), 2264 i18n("Not supported \non PDA!\n"),
2262 i18n("OK"), 0, 0, 2265 i18n("OK"), 0, 0,
2263 0, 1 ); 2266 0, 1 );
2264#endif 2267#endif
2265} 2268}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 4bedb61..21d5a35 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2636 +1,2634 @@
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>
25#include <qpe/qpetoolbar.h> 24#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 25#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 27#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 29#include <unistd.h> // for sleep
31#else 30#else
32#include <qmenubar.h>
33#include <qtoolbar.h> 31#include <qtoolbar.h>
34#include <qapplication.h> 32#include <qapplication.h>
35//#include <resource.h> 33//#include <resource.h>
36 34
37#endif 35#endif
38#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 37#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 38#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 39#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 40#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 41#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 42#include <libkdepim/kpimglobalprefs.h>
45 43
46#include "calendarview.h" 44#include "calendarview.h"
47#include "koviewmanager.h" 45#include "koviewmanager.h"
48#include "datenavigator.h" 46#include "datenavigator.h"
49#include "koagendaview.h" 47#include "koagendaview.h"
50#include "kojournalview.h" 48#include "kojournalview.h"
51#include "koagenda.h" 49#include "koagenda.h"
52#include "kodialogmanager.h" 50#include "kodialogmanager.h"
53#include "kdialogbase.h" 51#include "kdialogbase.h"
54#include "kapplication.h" 52#include "kapplication.h"
55#include "kofilterview.h" 53#include "kofilterview.h"
56#include "kstandarddirs.h" 54#include "kstandarddirs.h"
57#include "koprefs.h" 55#include "koprefs.h"
58#include "kfiledialog.h" 56#include "kfiledialog.h"
59#include "koglobals.h" 57#include "koglobals.h"
60#include "kglobal.h" 58#include "kglobal.h"
61#include "ktoolbar.h" 59#include "ktoolbar.h"
62#include "klocale.h" 60#include "klocale.h"
63#include "kconfig.h" 61#include "kconfig.h"
64#include "externalapphandler.h" 62#include "externalapphandler.h"
65#include <kglobalsettings.h> 63#include <kglobalsettings.h>
66 64
67using namespace KCal; 65using namespace KCal;
68#ifndef _WIN32_ 66#ifndef _WIN32_
69#include <unistd.h> 67#include <unistd.h>
70#else 68#else
71#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
72#include "koimportoldialog.h" 70#include "koimportoldialog.h"
73#endif 71#endif
74#endif 72#endif
75#include "mainwindow.h" 73#include "mainwindow.h"
76 74
77 75
78class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
79{ 77{
80 public: 78 public:
81 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
82 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
83 { 81 {
84 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
85 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
86 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
87 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
88 QLabel *lab; 86 QLabel *lab;
89 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
90 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
91 QHBox* temphb; 89 QHBox* temphb;
92 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
93 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
94 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
95 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
96 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
97 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
98 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
99 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
100 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
101 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
102 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
103 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
104 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
105 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
106 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
107 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
108 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
109 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
110 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
111 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
112 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
113 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
114 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
115 lay->addWidget( ok ); 113 lay->addWidget( ok );
116 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
117 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
118 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
119 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
120 resize( 220, 240 ); 118 resize( 220, 240 );
121 qApp->processEvents(); 119 qApp->processEvents();
122 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
123 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
124 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
125 } 123 }
126 124
127public: 125public:
128 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
129 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
130 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
131}; 129};
132 130
133QPixmap* sgListViewCompletedPix[6]; 131QPixmap* sgListViewCompletedPix[6];
134QPixmap* sgListViewJournalPix; 132QPixmap* sgListViewJournalPix;
135 133
136 134
137int globalFlagBlockStartup; 135int globalFlagBlockStartup;
138MainWindow::MainWindow( QWidget *parent, const char *name ) : 136MainWindow::MainWindow( QWidget *parent, const char *name ) :
139 QMainWindow( parent, name ) 137 QMainWindow( parent, name )
140{ 138{
141 sgListViewCompletedPix[5] = &listviewPix; 139 sgListViewCompletedPix[5] = &listviewPix;
142 sgListViewCompletedPix[0] = &listviewPix0; 140 sgListViewCompletedPix[0] = &listviewPix0;
143 sgListViewCompletedPix[1] = &listviewPix20; 141 sgListViewCompletedPix[1] = &listviewPix20;
144 sgListViewCompletedPix[2] = &listviewPix40; 142 sgListViewCompletedPix[2] = &listviewPix40;
145 sgListViewCompletedPix[3] = &listviewPix60; 143 sgListViewCompletedPix[3] = &listviewPix60;
146 sgListViewCompletedPix[4] = &listviewPix80; 144 sgListViewCompletedPix[4] = &listviewPix80;
147 //int size = 12; 145 //int size = 12;
148 { 146 {
149 sgListViewCompletedPix[5]->resize( 11, 11 ); 147 sgListViewCompletedPix[5]->resize( 11, 11 );
150 sgListViewCompletedPix[5]->fill( Qt::white ); 148 sgListViewCompletedPix[5]->fill( Qt::white );
151 QPainter p ( sgListViewCompletedPix[5] ); 149 QPainter p ( sgListViewCompletedPix[5] );
152 p.drawRect( 0,0,11,11); 150 p.drawRect( 0,0,11,11);
153 p.drawLine ( 2, 5, 4 , 7 ) ; 151 p.drawLine ( 2, 5, 4 , 7 ) ;
154 p.drawLine ( 4 , 7 , 8, 3) ; 152 p.drawLine ( 4 , 7 , 8, 3) ;
155 int iii = 0; 153 int iii = 0;
156 for ( iii = 0; iii < 5; ++iii ) { 154 for ( iii = 0; iii < 5; ++iii ) {
157 sgListViewCompletedPix[iii]->resize( 11, 11 ); 155 sgListViewCompletedPix[iii]->resize( 11, 11 );
158 sgListViewCompletedPix[iii]->fill( Qt::white ); 156 sgListViewCompletedPix[iii]->fill( Qt::white );
159 QPainter p ( sgListViewCompletedPix[iii] ); 157 QPainter p ( sgListViewCompletedPix[iii] );
160 p.drawRect( 0,0,11,11); 158 p.drawRect( 0,0,11,11);
161 if ( iii ) 159 if ( iii )
162 p.fillRect( 1,1,iii*2,9,Qt::gray ); 160 p.fillRect( 1,1,iii*2,9,Qt::gray );
163 } 161 }
164 sgListViewJournalPix = &journalPix; 162 sgListViewJournalPix = &journalPix;
165 sgListViewJournalPix->resize( 11, 11 ); 163 sgListViewJournalPix->resize( 11, 11 );
166 sgListViewJournalPix->fill( Qt::white ); 164 sgListViewJournalPix->fill( Qt::white );
167 { 165 {
168 QPainter p ( sgListViewJournalPix ); 166 QPainter p ( sgListViewJournalPix );
169 p.drawRect( 0,0,11,11); 167 p.drawRect( 0,0,11,11);
170 p.drawLine( 2,3,5,3); 168 p.drawLine( 2,3,5,3);
171 p.drawLine( 2,5,8,5); 169 p.drawLine( 2,5,8,5);
172 p.drawLine( 2,7,6,7); 170 p.drawLine( 2,7,6,7);
173 } 171 }
174 } 172 }
175 mClosed = false; 173 mClosed = false;
176 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 174 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
177 QString confFile = locateLocal("config","korganizerrc"); 175 QString confFile = locateLocal("config","korganizerrc");
178 QFileInfo finf ( confFile ); 176 QFileInfo finf ( confFile );
179 bool showWarning = !finf.exists(); 177 bool showWarning = !finf.exists();
180 setIcon(SmallIcon( "ko24" ) ); 178 setIcon(SmallIcon( "ko24" ) );
181 mBlockAtStartup = true; 179 mBlockAtStartup = true;
182 mFlagKeyPressed = false; 180 mFlagKeyPressed = false;
183 setCaption("KO/Pi"); 181 setCaption("KO/Pi");
184 KOPrefs *p = KOPrefs::instance(); 182 KOPrefs *p = KOPrefs::instance();
185 //KPimGlobalPrefs::instance()->setGlobalConfig(); 183 //KPimGlobalPrefs::instance()->setGlobalConfig();
186 p->mCurrentDisplayedView = 0; 184 p->mCurrentDisplayedView = 0;
187 if ( p->mHourSize > 22 ) 185 if ( p->mHourSize > 22 )
188 p->mHourSize = 22; 186 p->mHourSize = 22;
189 QMainWindow::ToolBarDock tbd; 187 QMainWindow::ToolBarDock tbd;
190 if ( p->mToolBarHor ) { 188 if ( p->mToolBarHor ) {
191 if ( p->mToolBarUp ) 189 if ( p->mToolBarUp )
192 tbd = Bottom; 190 tbd = Bottom;
193 else 191 else
194 tbd = Top; 192 tbd = Top;
195 } 193 }
196 else { 194 else {
197 if ( p->mToolBarUp ) 195 if ( p->mToolBarUp )
198 tbd = Right; 196 tbd = Right;
199 else 197 else
200 tbd = Left; 198 tbd = Left;
201 } 199 }
202 if ( KOPrefs::instance()->mUseAppColors ) 200 if ( KOPrefs::instance()->mUseAppColors )
203 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 201 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
204 globalFlagBlockStartup = 1; 202 globalFlagBlockStartup = 1;
205 iconToolBar = new QPEToolBar( this ); 203 iconToolBar = new QPEToolBar( this );
206 addToolBar (iconToolBar , tbd ); 204 addToolBar (iconToolBar , tbd );
207 205
208#ifdef DESKTOP_VERSION 206#ifdef DESKTOP_VERSION
209 if ( KOPrefs::instance()->mShowIconFilter ) 207 if ( KOPrefs::instance()->mShowIconFilter )
210#else 208#else
211 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 209 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
212#endif 210#endif
213 211
214{ 212{
215 if ( p->mToolBarHorF ) { 213 if ( p->mToolBarHorF ) {
216 if ( p->mToolBarUpF ) 214 if ( p->mToolBarUpF )
217 tbd = Bottom; 215 tbd = Bottom;
218 else 216 else
219 tbd = Top; 217 tbd = Top;
220 } 218 }
221 else { 219 else {
222 if ( p->mToolBarUpF ) 220 if ( p->mToolBarUpF )
223 tbd = Right; 221 tbd = Right;
224 else 222 else
225 tbd = Left; 223 tbd = Left;
226 } 224 }
227 filterToolBar = new QPEToolBar ( this ); 225 filterToolBar = new QPEToolBar ( this );
228 filterMenubar = new QMenuBar( 0 ); 226 filterMenubar = new KMenuBar( 0 );
229 QFontMetrics fm ( filterMenubar->font() ); 227 QFontMetrics fm ( filterMenubar->font() );
230 228
231 filterPopupMenu = new QPopupMenu( this ); 229 filterPopupMenu = new QPopupMenu( this );
232 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 230 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
233 QString addTest = "A"; 231 QString addTest = "A";
234 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 232 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
235#ifdef DESKTOP_VERSION 233#ifdef DESKTOP_VERSION
236 addTest = "AAABBBCCCx"; 234 addTest = "AAABBBCCCx";
237#else 235#else
238 addTest = "AAx"; 236 addTest = "AAx";
239#endif 237#endif
240 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 238 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
241 addToolBar (filterToolBar , tbd ); 239 addToolBar (filterToolBar , tbd );
242 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 240 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
243 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 241 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
244 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 242 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
245 filterToolBar->hide(); 243 filterToolBar->hide();
246 } else { 244 } else {
247 filterToolBar = 0; 245 filterToolBar = 0;
248 filterMenubar = 0; 246 filterMenubar = 0;
249 filterPopupMenu = 0; 247 filterPopupMenu = 0;
250 } 248 }
251 if ( p->mShowIconOnetoolbar ) { 249 if ( p->mShowIconOnetoolbar ) {
252 viewToolBar = iconToolBar ; 250 viewToolBar = iconToolBar ;
253 navigatorToolBar = iconToolBar ; 251 navigatorToolBar = iconToolBar ;
254 } else { 252 } else {
255#ifndef DESKTOP_VERSION 253#ifndef DESKTOP_VERSION
256 setToolBarsMovable( false ); 254 setToolBarsMovable( false );
257#endif 255#endif
258 if ( p->mToolBarHorV ) { 256 if ( p->mToolBarHorV ) {
259 if ( p->mToolBarUpV ) 257 if ( p->mToolBarUpV )
260 tbd = Bottom; 258 tbd = Bottom;
261 else 259 else
262 tbd = Top; 260 tbd = Top;
263 } 261 }
264 else { 262 else {
265 if ( p->mToolBarUpV ) 263 if ( p->mToolBarUpV )
266 tbd = Right; 264 tbd = Right;
267 else 265 else
268 tbd = Left; 266 tbd = Left;
269 } 267 }
270 viewToolBar = new QPEToolBar( this ); 268 viewToolBar = new QPEToolBar( this );
271 addToolBar (viewToolBar , tbd ); 269 addToolBar (viewToolBar , tbd );
272 if ( p->mToolBarHorN ) { 270 if ( p->mToolBarHorN ) {
273 if ( p->mToolBarUpN ) 271 if ( p->mToolBarUpN )
274 tbd = Bottom; 272 tbd = Bottom;
275 else 273 else
276 tbd = Top; 274 tbd = Top;
277 } 275 }
278 else { 276 else {
279 if ( p->mToolBarUpN ) 277 if ( p->mToolBarUpN )
280 tbd = Right; 278 tbd = Right;
281 else 279 else
282 tbd = Left; 280 tbd = Left;
283 } 281 }
284 navigatorToolBar = new QPEToolBar( this ); 282 navigatorToolBar = new QPEToolBar( this );
285 addToolBar (navigatorToolBar , tbd ); 283 addToolBar (navigatorToolBar , tbd );
286 } 284 }
287 285
288 286
289 287
290 mCalendarModifiedFlag = false; 288 mCalendarModifiedFlag = false;
291 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 289 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
292 splash->setAlignment ( AlignCenter ); 290 splash->setAlignment ( AlignCenter );
293 setCentralWidget( splash ); 291 setCentralWidget( splash );
294#ifndef DESKTOP_VERSION 292#ifndef DESKTOP_VERSION
295 showMaximized(); 293 showMaximized();
296#endif 294#endif
297 295
298 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 296 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
299 setDefaultPreferences(); 297 setDefaultPreferences();
300 mCalendar = new CalendarLocal(); 298 mCalendar = new CalendarLocal();
301 mView = new CalendarView( mCalendar, this,"mCalendar " ); 299 mView = new CalendarView( mCalendar, this,"mCalendar " );
302 mView->hide(); 300 mView->hide();
303 //mView->resize(splash->size() ); 301 //mView->resize(splash->size() );
304 initActions(); 302 initActions();
305 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 303 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
306 mSyncManager->setBlockSave(false); 304 mSyncManager->setBlockSave(false);
307 mView->setSyncManager(mSyncManager); 305 mView->setSyncManager(mSyncManager);
308#ifndef DESKTOP_VERSION 306#ifndef DESKTOP_VERSION
309 iconToolBar->show(); 307 iconToolBar->show();
310 qApp->processEvents(); 308 qApp->processEvents();
311#endif 309#endif
312 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 310 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
313 int vh = height() ; 311 int vh = height() ;
314 int vw = width(); 312 int vw = width();
315 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 313 //qDebug("Toolbar hei %d ",iconToolBar->height() );
316 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 314 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
317 vh -= iconToolBar->height(); 315 vh -= iconToolBar->height();
318 } else { 316 } else {
319 vw -= iconToolBar->height(); 317 vw -= iconToolBar->height();
320 } 318 }
321 //mView->setMaximumSize( splash->size() ); 319 //mView->setMaximumSize( splash->size() );
322 //mView->resize( splash->size() ); 320 //mView->resize( splash->size() );
323 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 321 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
324 mView->readSettings(); 322 mView->readSettings();
325 bool newFile = false; 323 bool newFile = false;
326 if( !QFile::exists( defaultFileName() ) ) { 324 if( !QFile::exists( defaultFileName() ) ) {
327 QFileInfo finfo ( defaultFileName() ); 325 QFileInfo finfo ( defaultFileName() );
328 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 326 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
329 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 327 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
330 finfo.setFile( oldFile ); 328 finfo.setFile( oldFile );
331 if (finfo.exists() ) { 329 if (finfo.exists() ) {
332 KMessageBox::information( this, message); 330 KMessageBox::information( this, message);
333 mView->openCalendar( oldFile ); 331 mView->openCalendar( oldFile );
334 qApp->processEvents(); 332 qApp->processEvents();
335 } else { 333 } else {
336 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 334 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
337 finfo.setFile( oldFile ); 335 finfo.setFile( oldFile );
338 if (finfo.exists() ) { 336 if (finfo.exists() ) {
339 KMessageBox::information( this, message); 337 KMessageBox::information( this, message);
340 mView->openCalendar( oldFile ); 338 mView->openCalendar( oldFile );
341 qApp->processEvents(); 339 qApp->processEvents();
342 } 340 }
343 } 341 }
344 mView->saveCalendar( defaultFileName() ); 342 mView->saveCalendar( defaultFileName() );
345 newFile = true; 343 newFile = true;
346 } 344 }
347 345
348 QTime neededSaveTime = QDateTime::currentDateTime().time(); 346 QTime neededSaveTime = QDateTime::currentDateTime().time();
349 mView->loadCalendars(); 347 mView->loadCalendars();
350 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 348 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
351 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 349 qDebug("KO: Calendar loading time: %d ms",msNeeded );
352 350
353 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 351 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
354 KOPrefs::instance()->setAllDefaults(); 352 KOPrefs::instance()->setAllDefaults();
355 } 353 }
356 processIncidenceSelection( 0 ); 354 processIncidenceSelection( 0 );
357 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 355 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
358 SLOT( processIncidenceSelection( Incidence * ) ) ); 356 SLOT( processIncidenceSelection( Incidence * ) ) );
359 connect( mView, SIGNAL( modifiedChanged( bool ) ), 357 connect( mView, SIGNAL( modifiedChanged( bool ) ),
360 SLOT( slotModifiedChanged( bool ) ) ); 358 SLOT( slotModifiedChanged( bool ) ) );
361 359
362 360
363 connect( mView, SIGNAL( tempDisableBR(bool) ), 361 connect( mView, SIGNAL( tempDisableBR(bool) ),
364 SLOT( disableBR(bool) ) ); 362 SLOT( disableBR(bool) ) );
365 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 363 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
366 mView->setModified( false ); 364 mView->setModified( false );
367 mBlockAtStartup = false; 365 mBlockAtStartup = false;
368 mView->setModified( false ); 366 mView->setModified( false );
369 setCentralWidget( mView ); 367 setCentralWidget( mView );
370 globalFlagBlockStartup = 0; 368 globalFlagBlockStartup = 0;
371 mView->show(); 369 mView->show();
372 delete splash; 370 delete splash;
373 if ( newFile ) 371 if ( newFile )
374 mView->updateConfig(); 372 mView->updateConfig();
375 // qApp->processEvents(); 373 // qApp->processEvents();
376 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 374 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
377 //fillSyncMenu(); 375 //fillSyncMenu();
378 376
379 377
380 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 378 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
381 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 379 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
382 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 380 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
383 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 381 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
384 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 382 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
385 mSyncManager->setDefaultFileName( sentSyncFile()); 383 mSyncManager->setDefaultFileName( sentSyncFile());
386 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 384 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
387 mSyncManager->fillSyncMenu(); 385 mSyncManager->fillSyncMenu();
388 386
389 387
390 388
391 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 389 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
392 if ( showWarning ) { 390 if ( showWarning ) {
393 KMessageBox::information( this, 391 KMessageBox::information( this,
394 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 392 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
395 qApp->processEvents(); 393 qApp->processEvents();
396 mView->dialogManager()->showSyncOptions(); 394 mView->dialogManager()->showSyncOptions();
397 } 395 }
398 396
399 //US listen for result adressed from Ka/Pi 397 //US listen for result adressed from Ka/Pi
400#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
401 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 399 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
402#endif 400#endif
403#ifndef DESKTOP_VERSION 401#ifndef DESKTOP_VERSION
404 infrared = 0; 402 infrared = 0;
405#endif 403#endif
406 updateFilterToolbar(); 404 updateFilterToolbar();
407 updateWeek( mView->startDate() ); 405 updateWeek( mView->startDate() );
408 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 406 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
409 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 407 SLOT( updateWeekNum( const KCal::DateList & ) ) );
410 mBRdisabled = false; 408 mBRdisabled = false;
411 //toggleBeamReceive(); 409 //toggleBeamReceive();
412 410
413 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() )); 411 QTimer::singleShot( 1000, mView, SLOT ( checkFiles() ));
414} 412}
415MainWindow::~MainWindow() 413MainWindow::~MainWindow()
416{ 414{
417 //qDebug("MainWindow::~MainWindow() "); 415 //qDebug("MainWindow::~MainWindow() ");
418 //save toolbar location 416 //save toolbar location
419 delete mCalendar; 417 delete mCalendar;
420 delete mSyncManager; 418 delete mSyncManager;
421#ifndef DESKTOP_VERSION 419#ifndef DESKTOP_VERSION
422 if ( infrared ) 420 if ( infrared )
423 delete infrared; 421 delete infrared;
424#endif 422#endif
425 423
426 424
427} 425}
428 426
429void MainWindow::disableBR(bool b) 427void MainWindow::disableBR(bool b)
430{ 428{
431#ifndef DESKTOP_VERSION 429#ifndef DESKTOP_VERSION
432 if ( b ) { 430 if ( b ) {
433 if ( infrared ) { 431 if ( infrared ) {
434 toggleBeamReceive(); 432 toggleBeamReceive();
435 mBRdisabled = true; 433 mBRdisabled = true;
436 } 434 }
437 mBRdisabled = true; 435 mBRdisabled = true;
438 } else { 436 } else {
439 if ( mBRdisabled ) { 437 if ( mBRdisabled ) {
440 mBRdisabled = false; 438 mBRdisabled = false;
441 //makes no sense,because other cal ap is probably running 439 //makes no sense,because other cal ap is probably running
442 // toggleBeamReceive(); 440 // toggleBeamReceive();
443 } 441 }
444 } 442 }
445#endif 443#endif
446 444
447} 445}
448bool MainWindow::beamReceiveEnabled() 446bool MainWindow::beamReceiveEnabled()
449{ 447{
450#ifndef DESKTOP_VERSION 448#ifndef DESKTOP_VERSION
451 return ( infrared != 0 ); 449 return ( infrared != 0 );
452#endif 450#endif
453 return false; 451 return false;
454} 452}
455 453
456void MainWindow::toggleBeamReceive() 454void MainWindow::toggleBeamReceive()
457{ 455{
458 if ( mBRdisabled ) 456 if ( mBRdisabled )
459 return; 457 return;
460#ifndef DESKTOP_VERSION 458#ifndef DESKTOP_VERSION
461 if ( infrared ) { 459 if ( infrared ) {
462 qDebug("KO: Disable BeamReceive "); 460 qDebug("KO: Disable BeamReceive ");
463 delete infrared; 461 delete infrared;
464 infrared = 0; 462 infrared = 0;
465 brAction->setOn(false); 463 brAction->setOn(false);
466 return; 464 return;
467 } 465 }
468 qDebug("KO: Enable BeamReceive "); 466 qDebug("KO: Enable BeamReceive ");
469 brAction->setOn(true); 467 brAction->setOn(true);
470 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 468 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
471 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 469 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
472#endif 470#endif
473} 471}
474void MainWindow::showMaximized () 472void MainWindow::showMaximized ()
475{ 473{
476#ifndef DESKTOP_VERSION 474#ifndef DESKTOP_VERSION
477 if ( ! globalFlagBlockStartup ) 475 if ( ! globalFlagBlockStartup )
478 if ( mClosed ) 476 if ( mClosed )
479 mView->goToday(); 477 mView->goToday();
480#endif 478#endif
481 QWidget::showMaximized () ; 479 QWidget::showMaximized () ;
482 mClosed = false; 480 mClosed = false;
483} 481}
484void MainWindow::closeEvent( QCloseEvent* ce ) 482void MainWindow::closeEvent( QCloseEvent* ce )
485{ 483{
486 484
487 485
488 486
489 if ( ! KOPrefs::instance()->mAskForQuit ) { 487 if ( ! KOPrefs::instance()->mAskForQuit ) {
490 saveOnClose(); 488 saveOnClose();
491 mClosed = true; 489 mClosed = true;
492 ce->accept(); 490 ce->accept();
493 return; 491 return;
494 492
495 } 493 }
496 494
497 switch( QMessageBox::information( this, "KO/Pi", 495 switch( QMessageBox::information( this, "KO/Pi",
498 i18n("Do you really want\nto close KO/Pi?"), 496 i18n("Do you really want\nto close KO/Pi?"),
499 i18n("Close"), i18n("No"), 497 i18n("Close"), i18n("No"),
500 0, 0 ) ) { 498 0, 0 ) ) {
501 case 0: 499 case 0:
502 saveOnClose(); 500 saveOnClose();
503 mClosed = true; 501 mClosed = true;
504 ce->accept(); 502 ce->accept();
505 break; 503 break;
506 case 1: 504 case 1:
507 ce->ignore(); 505 ce->ignore();
508 break; 506 break;
509 case 2: 507 case 2:
510 508
511 default: 509 default:
512 break; 510 break;
513 } 511 }
514 512
515 513
516} 514}
517 515
518void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 516void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
519{ 517{
520 QDataStream stream( data, IO_ReadOnly ); 518 QDataStream stream( data, IO_ReadOnly );
521 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 519 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
522 //QString datamess; 520 //QString datamess;
523 //qDebug("message "); 521 //qDebug("message ");
524 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 522 qDebug("KO: QCOP message received: %s ", cmsg.data() );
525 523
526 if ( cmsg == "setDocument(QString)" ) { 524 if ( cmsg == "setDocument(QString)" ) {
527 QDataStream stream( data, IO_ReadOnly ); 525 QDataStream stream( data, IO_ReadOnly );
528 QString fileName; 526 QString fileName;
529 stream >> fileName; 527 stream >> fileName;
530 //qDebug("filename %s ", fileName.latin1()); 528 //qDebug("filename %s ", fileName.latin1());
531 showMaximized(); 529 showMaximized();
532 raise(); 530 raise();
533 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 531 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
534 mSyncManager->slotSyncMenu( 1002 ); 532 mSyncManager->slotSyncMenu( 1002 );
535 return; 533 return;
536 } 534 }
537 535
538 if ( cmsg == "-writeFile" ) { 536 if ( cmsg == "-writeFile" ) {
539 // I made from the "-writeFile" an "-writeAlarm" 537 // I made from the "-writeFile" an "-writeAlarm"
540 mView->viewManager()->showWhatsNextView(); 538 mView->viewManager()->showWhatsNextView();
541 mCalendar->checkAlarmForIncidence( 0, true); 539 mCalendar->checkAlarmForIncidence( 0, true);
542 showMaximized(); 540 showMaximized();
543 raise(); 541 raise();
544 return; 542 return;
545 543
546 } 544 }
547 if ( cmsg == "-writeFileSilent" ) { 545 if ( cmsg == "-writeFileSilent" ) {
548 // I made from the "-writeFile" an "-writeAlarm" 546 // I made from the "-writeFile" an "-writeAlarm"
549 // mView->viewManager()->showWhatsNextView(); 547 // mView->viewManager()->showWhatsNextView();
550 mCalendar->checkAlarmForIncidence( 0, true); 548 mCalendar->checkAlarmForIncidence( 0, true);
551 //showMaximized(); 549 //showMaximized();
552 //raise(); 550 //raise();
553 hide(); 551 hide();
554 return; 552 return;
555 } 553 }
556 if ( cmsg == "-newCountdown" ) { 554 if ( cmsg == "-newCountdown" ) {
557 qDebug("newCountdown "); 555 qDebug("newCountdown ");
558 556
559 } 557 }
560 QString msg ; 558 QString msg ;
561 QString allmsg = cmsg; 559 QString allmsg = cmsg;
562 while ( allmsg.length() > 0 ) { 560 while ( allmsg.length() > 0 ) {
563 int nextC = allmsg.find( "-", 1 ); 561 int nextC = allmsg.find( "-", 1 );
564 if ( nextC == -1 ) { 562 if ( nextC == -1 ) {
565 msg = allmsg; 563 msg = allmsg;
566 allmsg = ""; 564 allmsg = "";
567 } else{ 565 } else{
568 msg = allmsg.left( nextC ); 566 msg = allmsg.left( nextC );
569 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 567 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
570 } 568 }
571 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 569 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
572 if ( msg == "-newEvent" ) { 570 if ( msg == "-newEvent" ) {
573 QTimer::singleShot( 0, mView, SLOT ( newEvent())); 571 QTimer::singleShot( 0, mView, SLOT ( newEvent()));
574 } 572 }
575 if ( msg == "-newTodo" ) { 573 if ( msg == "-newTodo" ) {
576 QTimer::singleShot( 0, mView, SLOT ( newTodo())); 574 QTimer::singleShot( 0, mView, SLOT ( newTodo()));
577 } 575 }
578 if ( msg == "-showWN" ) { 576 if ( msg == "-showWN" ) {
579 mView->viewManager()->showWhatsNextView(); 577 mView->viewManager()->showWhatsNextView();
580 } 578 }
581 if ( msg == "-showTodo" ) { 579 if ( msg == "-showTodo" ) {
582 mView->viewManager()->showTodoView(); 580 mView->viewManager()->showTodoView();
583 } 581 }
584 if ( msg == "-showList" ) { 582 if ( msg == "-showList" ) {
585 mView->viewManager()->showListView(); 583 mView->viewManager()->showListView();
586 } 584 }
587 else if ( msg == "-showDay" ) { 585 else if ( msg == "-showDay" ) {
588 mView->viewManager()->showDayView(); 586 mView->viewManager()->showDayView();
589 } 587 }
590 else if ( msg == "-showWWeek" ) { 588 else if ( msg == "-showWWeek" ) {
591 mView->viewManager()->showWorkWeekView(); 589 mView->viewManager()->showWorkWeekView();
592 } 590 }
593 else if ( msg == "-ringSync" ) { 591 else if ( msg == "-ringSync" ) {
594 QTimer::singleShot( 0, this, SLOT (startMultiSync())); 592 QTimer::singleShot( 0, this, SLOT (startMultiSync()));
595 } 593 }
596 else if ( msg == "-showWeek" ) { 594 else if ( msg == "-showWeek" ) {
597 mView->viewManager()->showWeekView(); 595 mView->viewManager()->showWeekView();
598 } 596 }
599 else if ( msg == "-showTodo" ) { 597 else if ( msg == "-showTodo" ) {
600 mView->viewManager()->showTodoView(); 598 mView->viewManager()->showTodoView();
601 } 599 }
602 else if ( msg == "-showJournal" ) { 600 else if ( msg == "-showJournal" ) {
603 mView->dateNavigator()->selectDates( 1 ); 601 mView->dateNavigator()->selectDates( 1 );
604 mView->dateNavigator()->selectToday(); 602 mView->dateNavigator()->selectToday();
605 mView->viewManager()->showJournalView(); 603 mView->viewManager()->showJournalView();
606 } 604 }
607 else if ( msg == "-showKO" ) { 605 else if ( msg == "-showKO" ) {
608 mView->viewManager()->showNextXView(); 606 mView->viewManager()->showNextXView();
609 } 607 }
610 else if ( msg == "-showWNext" ) { 608 else if ( msg == "-showWNext" ) {
611 mView->viewManager()->showWhatsNextView(); 609 mView->viewManager()->showWhatsNextView();
612 } 610 }
613 else if ( msg == "nextView()" ) { 611 else if ( msg == "nextView()" ) {
614 mView->viewManager()->showNextView(); 612 mView->viewManager()->showNextView();
615 } 613 }
616 else if ( msg == "-showNextXView" ) { 614 else if ( msg == "-showNextXView" ) {
617 mView->viewManager()->showNextXView(); 615 mView->viewManager()->showNextXView();
618 } 616 }
619 617
620 618
621 } 619 }
622 620
623 showMaximized(); 621 showMaximized();
624 raise(); 622 raise();
625} 623}
626void MainWindow::startMultiSync() 624void MainWindow::startMultiSync()
627{ 625{
628 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 626 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
629 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"), 627 if ( QMessageBox::information( this, i18n("KDE-Pim Sync"),
630 question, 628 question,
631 i18n("Yes"), i18n("No"), 629 i18n("Yes"), i18n("No"),
632 0, 0 ) != 0 ) { 630 0, 0 ) != 0 ) {
633 setCaption(i18n("Aborted! Nothing synced!")); 631 setCaption(i18n("Aborted! Nothing synced!"));
634 return; 632 return;
635 } 633 }
636 mSyncManager->multiSync( false ); 634 mSyncManager->multiSync( false );
637#ifndef DESKTOP_VERSION 635#ifndef DESKTOP_VERSION
638 QCopEnvelope e("QPE/Application/kapi", "doRingSync"); 636 QCopEnvelope e("QPE/Application/kapi", "doRingSync");
639#endif 637#endif
640} 638}
641QPixmap MainWindow::loadPixmap( QString name ) 639QPixmap MainWindow::loadPixmap( QString name )
642{ 640{
643 return SmallIcon( name ); 641 return SmallIcon( name );
644 642
645} 643}
646void MainWindow::setUsesBigPixmaps ( bool b ) 644void MainWindow::setUsesBigPixmaps ( bool b )
647{ 645{
648 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 646 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
649 if ( b ) 647 if ( b )
650 qDebug("KO: BigPixmaps are not supported "); 648 qDebug("KO: BigPixmaps are not supported ");
651} 649}
652void MainWindow::initActions() 650void MainWindow::initActions()
653{ 651{
654 //KOPrefs::instance()->mShowFullMenu 652 //KOPrefs::instance()->mShowFullMenu
655 iconToolBar->clear(); 653 iconToolBar->clear();
656 KOPrefs *p = KOPrefs::instance(); 654 KOPrefs *p = KOPrefs::instance();
657 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 655 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
658 656
659 QPopupMenu *viewMenu = new QPopupMenu( this ); 657 QPopupMenu *viewMenu = new QPopupMenu( this );
660 QPopupMenu *actionMenu = new QPopupMenu( this ); 658 QPopupMenu *actionMenu = new QPopupMenu( this );
661 mCurrentItemMenu = new QPopupMenu ( this ); 659 mCurrentItemMenu = new QPopupMenu ( this );
662 QPopupMenu *nextConflictMenu = new QPopupMenu ( this ); 660 QPopupMenu *nextConflictMenu = new QPopupMenu ( this );
663 QPopupMenu *importMenu = new QPopupMenu( this ); 661 QPopupMenu *importMenu = new QPopupMenu( this );
664 QPopupMenu *importMenu_X = new QPopupMenu( this ); 662 QPopupMenu *importMenu_X = new QPopupMenu( this );
665 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 663 QPopupMenu *exportMenu_X = new QPopupMenu( this );
666 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 664 QPopupMenu *beamMenu_X = new QPopupMenu( this );
667 selectFilterMenu = new QPopupMenu( this ); 665 selectFilterMenu = new QPopupMenu( this );
668 selectFilterMenu->setCheckable( true ); 666 selectFilterMenu->setCheckable( true );
669 syncMenu = new QPopupMenu( this ); 667 syncMenu = new QPopupMenu( this );
670 configureAgendaMenu = new QPopupMenu( this ); 668 configureAgendaMenu = new QPopupMenu( this );
671 configureToolBarMenu = new QPopupMenu( this ); 669 configureToolBarMenu = new QPopupMenu( this );
672 QPopupMenu *helpMenu = new QPopupMenu( this ); 670 QPopupMenu *helpMenu = new QPopupMenu( this );
673 QIconSet icon; 671 QIconSet icon;
674 int pixWid = 22, pixHei = 22; 672 int pixWid = 22, pixHei = 22;
675 QString pathString = ""; 673 QString pathString = "";
676 if ( !p->mToolBarMiniIcons ) { 674 if ( !p->mToolBarMiniIcons ) {
677 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 675 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
678 pathString += "icons16/"; 676 pathString += "icons16/";
679 pixWid = 18; pixHei = 16; 677 pixWid = 18; pixHei = 16;
680 } 678 }
681 } else { 679 } else {
682 pathString += "iconsmini/"; 680 pathString += "iconsmini/";
683 pixWid = 18; pixHei = 16; 681 pixWid = 18; pixHei = 16;
684 } 682 }
683 KMenuBar *menuBar1;
685 if ( KOPrefs::instance()->mShowFullMenu ) { 684 if ( KOPrefs::instance()->mShowFullMenu ) {
686 QMenuBar *menuBar1; 685 menuBar1 = new KMenuBar( this );//menuBar();
687 menuBar1 = menuBar();
688 menuBar1->insertItem( i18n("File"), importMenu ); 686 menuBar1->insertItem( i18n("File"), importMenu );
689 menuBar1->insertItem( i18n("View"), viewMenu ); 687 menuBar1->insertItem( i18n("View"), viewMenu );
690 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu ); 688 menuBar1->insertItem( i18n("Edit"), mCurrentItemMenu );
691 menuBar1->insertItem( i18n("Action"), actionMenu ); 689 menuBar1->insertItem( i18n("Action"), actionMenu );
692#ifdef DESKTOP_VERSION 690#ifdef DESKTOP_VERSION
693 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 691 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
694 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 692 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
695#else 693#else
696 menuBar1->insertItem( i18n("Sync"), syncMenu ); 694 menuBar1->insertItem( i18n("Sync"), syncMenu );
697 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 695 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
698#endif 696#endif
699 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 697 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
700 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 698 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
701 menuBar1->insertItem( i18n("Help"), helpMenu ); 699 menuBar1->insertItem( i18n("Help"), helpMenu );
702 } else { 700 } else {
703 QPEMenuBar *menuBar1; 701 menuBar1 = new KMenuBar( iconToolBar );
704 menuBar1 = new QPEMenuBar( iconToolBar );
705 QPopupMenu *menuBar = new QPopupMenu( this ); 702 QPopupMenu *menuBar = new QPopupMenu( this );
706 icon = loadPixmap( pathString + "z_menu" ); 703 icon = loadPixmap( pathString + "z_menu" );
707 menuBar1->insertItem( icon.pixmap(), menuBar); 704 menuBar1->insertItem( icon.pixmap(), menuBar);
708 //menuBar1->insertItem( i18n("ME"), menuBar); 705 //menuBar1->insertItem( i18n("ME"), menuBar);
709 menuBar->insertItem( i18n("File"), importMenu ); 706 menuBar->insertItem( i18n("File"), importMenu );
710 menuBar->insertItem( i18n("View"), viewMenu ); 707 menuBar->insertItem( i18n("View"), viewMenu );
711 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu ); 708 menuBar->insertItem( i18n("Edit"), mCurrentItemMenu );
712 menuBar->insertItem( i18n("Action"), actionMenu ); 709 menuBar->insertItem( i18n("Action"), actionMenu );
713 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 710 menuBar->insertItem( i18n("Synchronize"), syncMenu );
714 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 711 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
715 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 712 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
716 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 713 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
717 menuBar->insertItem( i18n("Help"), helpMenu ); 714 menuBar->insertItem( i18n("Help"), helpMenu );
718 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 715 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
719 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 716 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
720 } 717 }
718 connect ( menuBar1, SIGNAL( lostFocus () ), mView, SLOT ( slotResetFocus() ) );
721 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 719 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
722 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 720 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
723 721
724 722
725 mWeekBgColor = iconToolBar->backgroundColor(); 723 mWeekBgColor = iconToolBar->backgroundColor();
726 mWeekPixmap.resize( pixWid , pixHei ); 724 mWeekPixmap.resize( pixWid , pixHei );
727 mWeekPixmap.fill( mWeekBgColor ); 725 mWeekPixmap.fill( mWeekBgColor );
728 icon = mWeekPixmap; 726 icon = mWeekPixmap;
729 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 727 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
730 if ( p-> mShowIconWeekNum ) 728 if ( p-> mShowIconWeekNum )
731 mWeekAction->addTo( iconToolBar ); 729 mWeekAction->addTo( iconToolBar );
732 mWeekFont = font(); 730 mWeekFont = font();
733 731
734 int fontPoint = mWeekFont.pointSize(); 732 int fontPoint = mWeekFont.pointSize();
735 QFontMetrics f( mWeekFont ); 733 QFontMetrics f( mWeekFont );
736 int fontWid = f.width( "30" ); 734 int fontWid = f.width( "30" );
737 while ( fontWid > pixWid ) { 735 while ( fontWid > pixWid ) {
738 --fontPoint; 736 --fontPoint;
739 mWeekFont.setPointSize( fontPoint ); 737 mWeekFont.setPointSize( fontPoint );
740 QFontMetrics f( mWeekFont ); 738 QFontMetrics f( mWeekFont );
741 fontWid = f.width( "30" ); 739 fontWid = f.width( "30" );
742 //qDebug("dec-- "); 740 //qDebug("dec-- ");
743 } 741 }
744 742
745 connect( mWeekAction, SIGNAL( activated() ), 743 connect( mWeekAction, SIGNAL( activated() ),
746 this, SLOT( weekAction() ) ); 744 this, SLOT( weekAction() ) );
747 745
748 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 746 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
749 if ( p->mShowIconFilterview ) { 747 if ( p->mShowIconFilterview ) {
750 icon = loadPixmap( pathString + "filter" ); 748 icon = loadPixmap( pathString + "filter" );
751 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 749 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
752 connect( actionFilterMenuTB, SIGNAL( activated() ), 750 connect( actionFilterMenuTB, SIGNAL( activated() ),
753 this, SLOT( fillFilterMenuTB() ) ); 751 this, SLOT( fillFilterMenuTB() ) );
754 actionFilterMenuTB->addTo( iconToolBar ); 752 actionFilterMenuTB->addTo( iconToolBar );
755 selectFilterMenuTB = new QPopupMenu( this ); 753 selectFilterMenuTB = new QPopupMenu( this );
756 selectFilterMenuTB->setCheckable( true ); 754 selectFilterMenuTB->setCheckable( true );
757 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 755 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
758 } 756 }
759 757
760 //#endif 758 //#endif
761 // ****************** 759 // ******************
762 QAction *action; 760 QAction *action;
763 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 761 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
764 configureToolBarMenu->setCheckable( true ); 762 configureToolBarMenu->setCheckable( true );
765 763
766 764
767 configureAgendaMenu->setCheckable( true ); 765 configureAgendaMenu->setCheckable( true );
768 int iii ; 766 int iii ;
769 for ( iii = 1;iii<= 10 ;++iii ){ 767 for ( iii = 1;iii<= 10 ;++iii ){
770 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 768 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
771 } 769 }
772 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 770 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
773 771
774 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 772 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
775 this, SLOT( showConfigureAgenda( ) ) ); 773 this, SLOT( showConfigureAgenda( ) ) );
776 icon = loadPixmap( pathString + "today" ); 774 icon = loadPixmap( pathString + "today" );
777 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 775 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
778 today_action->addTo( actionMenu ); 776 today_action->addTo( actionMenu );
779 connect( today_action, SIGNAL( activated() ), 777 connect( today_action, SIGNAL( activated() ),
780 mView, SLOT( goToday() ) ); 778 mView, SLOT( goToday() ) );
781 779
782 icon = loadPixmap( pathString + "picker" ); 780 icon = loadPixmap( pathString + "picker" );
783 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this ); 781 QAction* dPickerAction = new QAction( i18n("Select Date..."), icon, i18n("Select Date..."), 0, this );
784 dPickerAction->addTo( actionMenu ); 782 dPickerAction->addTo( actionMenu );
785 connect( dPickerAction, SIGNAL( activated() ), 783 connect( dPickerAction, SIGNAL( activated() ),
786 mView, SLOT( showDatePicker() ) ); 784 mView, SLOT( showDatePicker() ) );
787 785
788 icon = loadPixmap( pathString + "search" ); 786 icon = loadPixmap( pathString + "search" );
789 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 787 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
790 search_action->addTo( actionMenu ); 788 search_action->addTo( actionMenu );
791 connect( search_action, SIGNAL( activated() ), 789 connect( search_action, SIGNAL( activated() ),
792 mView->dialogManager(), SLOT( showSearchDialog() ) ); 790 mView->dialogManager(), SLOT( showSearchDialog() ) );
793 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu ); 791 actionMenu->insertItem( i18n("Show next conflict for"), nextConflictMenu );
794 792
795 action = new QAction( "Undo Delete", i18n("All events"), 0, this ); 793 action = new QAction( "Undo Delete", i18n("All events"), 0, this );
796 action->addTo( nextConflictMenu ); 794 action->addTo( nextConflictMenu );
797 connect( action, SIGNAL( activated() ), 795 connect( action, SIGNAL( activated() ),
798 mView, SLOT( conflictAll() ) ); 796 mView, SLOT( conflictAll() ) );
799 797
800 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this ); 798 action = new QAction( "Undo Delete", i18n("Allday events"), 0, this );
801 action->addTo( nextConflictMenu ); 799 action->addTo( nextConflictMenu );
802 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
803 mView, SLOT( conflictAllday() ) ); 801 mView, SLOT( conflictAllday() ) );
804 802
805 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this ); 803 action = new QAction( "Undo Delete", i18n("Events with time"), 0, this );
806 action->addTo( nextConflictMenu ); 804 action->addTo( nextConflictMenu );
807 connect( action, SIGNAL( activated() ), 805 connect( action, SIGNAL( activated() ),
808 mView, SLOT( conflictNotAll() ) ); 806 mView, SLOT( conflictNotAll() ) );
809 807
810 actionMenu->insertSeparator(); 808 actionMenu->insertSeparator();
811 809
812 icon = loadPixmap( pathString + "newevent" ); 810 icon = loadPixmap( pathString + "newevent" );
813 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 811 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
814 ne_action->addTo( mCurrentItemMenu ); 812 ne_action->addTo( mCurrentItemMenu );
815 connect( ne_action, SIGNAL( activated() ), 813 connect( ne_action, SIGNAL( activated() ),
816 mView, SLOT( newEvent() ) ); 814 mView, SLOT( newEvent() ) );
817 icon = loadPixmap( pathString + "newtodo" ); 815 icon = loadPixmap( pathString + "newtodo" );
818 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 816 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
819 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 817 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
820 nt_action->addTo( mCurrentItemMenu ); 818 nt_action->addTo( mCurrentItemMenu );
821 connect( nt_action, SIGNAL( activated() ), 819 connect( nt_action, SIGNAL( activated() ),
822 mView, SLOT( newTodo() ) ); 820 mView, SLOT( newTodo() ) );
823 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 821 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
824 this ); 822 this );
825 mNewSubTodoAction->addTo( mCurrentItemMenu ); 823 mNewSubTodoAction->addTo( mCurrentItemMenu );
826 connect( mNewSubTodoAction, SIGNAL( activated() ), 824 connect( mNewSubTodoAction, SIGNAL( activated() ),
827 mView, SLOT( newSubTodo() ) ); 825 mView, SLOT( newSubTodo() ) );
828 826
829 mCurrentItemMenu->insertSeparator(); 827 mCurrentItemMenu->insertSeparator();
830 icon = loadPixmap( pathString + "newevent" ); 828 icon = loadPixmap( pathString + "newevent" );
831 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 829 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
832 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 830 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
833 configureToolBarMenu->insertSeparator(); 831 configureToolBarMenu->insertSeparator();
834 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 832 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
835 configureToolBarMenu->insertSeparator(); 833 configureToolBarMenu->insertSeparator();
836 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 834 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
837 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 835 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
838 836
839 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu); 837 //actionMenu->insertItem ( i18n("Selected Item"), mCurrentItemMenu);
840 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this ); 838 mShowAction = new QAction( "show_incidence", i18n("Show"), 0, this );
841 mShowAction->addTo( mCurrentItemMenu ); 839 mShowAction->addTo( mCurrentItemMenu );
842 connect( mShowAction, SIGNAL( activated() ), 840 connect( mShowAction, SIGNAL( activated() ),
843 mView, SLOT( showIncidence() ) ); 841 mView, SLOT( showIncidence() ) );
844 842
845 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 843 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
846 mEditAction->addTo( mCurrentItemMenu ); 844 mEditAction->addTo( mCurrentItemMenu );
847 connect( mEditAction, SIGNAL( activated() ), 845 connect( mEditAction, SIGNAL( activated() ),
848 mView, SLOT( editIncidence() ) ); 846 mView, SLOT( editIncidence() ) );
849 847
850 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 848 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
851 mDeleteAction->addTo( mCurrentItemMenu ); 849 mDeleteAction->addTo( mCurrentItemMenu );
852 connect( mDeleteAction, SIGNAL( activated() ), 850 connect( mDeleteAction, SIGNAL( activated() ),
853 mView, SLOT( deleteIncidence() ) ); 851 mView, SLOT( deleteIncidence() ) );
854 852
855 853
856 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 854 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
857 mCloneAction->addTo( mCurrentItemMenu ); 855 mCloneAction->addTo( mCurrentItemMenu );
858 connect( mCloneAction, SIGNAL( activated() ), 856 connect( mCloneAction, SIGNAL( activated() ),
859 mView, SLOT( cloneIncidence() ) ); 857 mView, SLOT( cloneIncidence() ) );
860 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 858 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
861 mMoveAction->addTo( mCurrentItemMenu ); 859 mMoveAction->addTo( mCurrentItemMenu );
862 connect( mMoveAction, SIGNAL( activated() ), 860 connect( mMoveAction, SIGNAL( activated() ),
863 mView, SLOT( moveIncidence() ) ); 861 mView, SLOT( moveIncidence() ) );
864#ifndef DESKTOP_VERSION 862#ifndef DESKTOP_VERSION
865 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 863 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
866 mBeamAction->addTo(mCurrentItemMenu ); 864 mBeamAction->addTo(mCurrentItemMenu );
867 connect( mBeamAction, SIGNAL( activated() ), 865 connect( mBeamAction, SIGNAL( activated() ),
868 mView, SLOT( beamIncidence() ) ); 866 mView, SLOT( beamIncidence() ) );
869#endif 867#endif
870 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 868 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
871 mCancelAction->addTo( mCurrentItemMenu ); 869 mCancelAction->addTo( mCurrentItemMenu );
872 connect( mCancelAction, SIGNAL( activated() ), 870 connect( mCancelAction, SIGNAL( activated() ),
873 mView, SLOT( toggleCancelIncidence() ) ); 871 mView, SLOT( toggleCancelIncidence() ) );
874 872
875 873
876 mCurrentItemMenu->insertSeparator(); 874 mCurrentItemMenu->insertSeparator();
877 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 875 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
878 action->addTo( mCurrentItemMenu ); 876 action->addTo( mCurrentItemMenu );
879 connect( action, SIGNAL( activated() ), 877 connect( action, SIGNAL( activated() ),
880 mView, SLOT( undo_delete() ) ); 878 mView, SLOT( undo_delete() ) );
881 879
882 // *********************** 880 // ***********************
883 if ( KOPrefs::instance()->mVerticalScreen ) { 881 if ( KOPrefs::instance()->mVerticalScreen ) {
884 icon = SmallIcon( "1updownarrow" ); 882 icon = SmallIcon( "1updownarrow" );
885 } else { 883 } else {
886 icon = SmallIcon("1leftrightarrow" ); 884 icon = SmallIcon("1leftrightarrow" );
887 } 885 }
888 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 886 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
889 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 887 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
890 FSaction->addTo( viewMenu ); 888 FSaction->addTo( viewMenu );
891 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 889 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
892 890
893 891
894 icon = loadPixmap( pathString + "filter" ); 892 icon = loadPixmap( pathString + "filter" );
895 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 893 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
896 icon = loadPixmap( pathString + "configure" ); 894 icon = loadPixmap( pathString + "configure" );
897 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 895 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
898 action->addTo( viewMenu ); 896 action->addTo( viewMenu );
899 connect( action, SIGNAL( activated() ), 897 connect( action, SIGNAL( activated() ),
900 mView, SLOT( toggleFilter() ) ); 898 mView, SLOT( toggleFilter() ) );
901 mToggleFilter = action; 899 mToggleFilter = action;
902 icon = loadPixmap( pathString + "navi" ); 900 icon = loadPixmap( pathString + "navi" );
903 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 901 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
904 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 902 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
905 action->addTo( viewMenu ); 903 action->addTo( viewMenu );
906 connect( action, SIGNAL( activated() ), 904 connect( action, SIGNAL( activated() ),
907 mView, SLOT( toggleDateNavigatorWidget() ) ); 905 mView, SLOT( toggleDateNavigatorWidget() ) );
908 mToggleNav = action ; 906 mToggleNav = action ;
909 icon = loadPixmap( pathString + "allday" ); 907 icon = loadPixmap( pathString + "allday" );
910 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 908 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
911 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 909 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
912 action->addTo( viewMenu ); 910 action->addTo( viewMenu );
913 connect( action, SIGNAL( activated() ), 911 connect( action, SIGNAL( activated() ),
914 mView, SLOT( toggleAllDaySize() ) ); 912 mView, SLOT( toggleAllDaySize() ) );
915 mToggleAllday = action; 913 mToggleAllday = action;
916 914
917 915
918 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 916 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
919 mToggleNav, SLOT( setEnabled ( bool ) ) ); 917 mToggleNav, SLOT( setEnabled ( bool ) ) );
920 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 918 //connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
921 // mToggleFilter, SLOT( setEnabled ( bool ) ) ); 919 // mToggleFilter, SLOT( setEnabled ( bool ) ) );
922 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 920 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
923 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 921 mToggleAllday, SLOT( setEnabled ( bool ) ) );
924 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 922 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
925 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 923 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
926 924
927 925
928 dPickerAction->addTo( iconToolBar ); 926 dPickerAction->addTo( iconToolBar );
929 viewMenu->insertSeparator(); 927 viewMenu->insertSeparator();
930 928
931 if ( p-> mShowIconToggleFull ) 929 if ( p-> mShowIconToggleFull )
932 FSaction->addTo( iconToolBar ); 930 FSaction->addTo( iconToolBar );
933 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 931 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
934 932
935 //******************** 933 //********************
936 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 934 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
937 935
938 936
939 icon = loadPixmap( pathString + "whatsnext" ); 937 icon = loadPixmap( pathString + "whatsnext" );
940 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 938 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
941 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 939 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
942 whatsnext_action->addTo( viewMenu ); 940 whatsnext_action->addTo( viewMenu );
943 connect( whatsnext_action, SIGNAL( activated() ), 941 connect( whatsnext_action, SIGNAL( activated() ),
944 mView->viewManager(), SLOT( showWhatsNextView() ) ); 942 mView->viewManager(), SLOT( showWhatsNextView() ) );
945 943
946 icon = loadPixmap( pathString + "xdays" ); 944 icon = loadPixmap( pathString + "xdays" );
947 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 945 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
948 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 946 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
949 xdays_action->addTo( viewMenu ); 947 xdays_action->addTo( viewMenu );
950 connect( xdays_action, SIGNAL( activated() ), 948 connect( xdays_action, SIGNAL( activated() ),
951 mView->viewManager(), SLOT( showNextXView() ) ); 949 mView->viewManager(), SLOT( showNextXView() ) );
952 950
953 951
954 icon = loadPixmap( pathString + "journal" ); 952 icon = loadPixmap( pathString + "journal" );
955 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 953 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
956 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 954 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
957 viewjournal_action->addTo( viewMenu ); 955 viewjournal_action->addTo( viewMenu );
958 connect( viewjournal_action, SIGNAL( activated() ), 956 connect( viewjournal_action, SIGNAL( activated() ),
959 mView->viewManager(), SLOT( showJournalView() ) ); 957 mView->viewManager(), SLOT( showJournalView() ) );
960 958
961 959
962 icon = loadPixmap( pathString + "day" ); 960 icon = loadPixmap( pathString + "day" );
963 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 961 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
964 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 962 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
965 day1_action->addTo( viewMenu ); 963 day1_action->addTo( viewMenu );
966 // action->addTo( toolBar ); 964 // action->addTo( toolBar );
967 connect( day1_action, SIGNAL( activated() ), 965 connect( day1_action, SIGNAL( activated() ),
968 mView->viewManager(), SLOT( showDayView() ) ); 966 mView->viewManager(), SLOT( showDayView() ) );
969 967
970 icon = loadPixmap( pathString + "workweek" ); 968 icon = loadPixmap( pathString + "workweek" );
971 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 969 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
972 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 970 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
973 day5_action->addTo( viewMenu ); 971 day5_action->addTo( viewMenu );
974 connect( day5_action, SIGNAL( activated() ), 972 connect( day5_action, SIGNAL( activated() ),
975 mView->viewManager(), SLOT( showWorkWeekView() ) ); 973 mView->viewManager(), SLOT( showWorkWeekView() ) );
976 974
977 icon = loadPixmap( pathString + "week" ); 975 icon = loadPixmap( pathString + "week" );
978 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 976 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
979 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 977 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
980 day7_action->addTo( viewMenu ); 978 day7_action->addTo( viewMenu );
981 connect( day7_action, SIGNAL( activated() ), 979 connect( day7_action, SIGNAL( activated() ),
982 mView->viewManager(), SLOT( showWeekView() ) ); 980 mView->viewManager(), SLOT( showWeekView() ) );
983 981
984 icon = loadPixmap( pathString + "workweek2" ); 982 icon = loadPixmap( pathString + "workweek2" );
985 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 983 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
986 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 984 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
987 day6_action->addTo( viewMenu ); 985 day6_action->addTo( viewMenu );
988 connect( day6_action, SIGNAL( activated() ), 986 connect( day6_action, SIGNAL( activated() ),
989 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 987 mView->viewManager(), SLOT( showMonthViewWeek() ) );
990 988
991 icon = loadPixmap( pathString + "month" ); 989 icon = loadPixmap( pathString + "month" );
992 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 990 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
993 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 991 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
994 month_action->addTo( viewMenu ); 992 month_action->addTo( viewMenu );
995 connect( month_action, SIGNAL( activated() ), 993 connect( month_action, SIGNAL( activated() ),
996 mView->viewManager(), SLOT( showMonthView() ) ); 994 mView->viewManager(), SLOT( showMonthView() ) );
997 995
998 icon = loadPixmap( pathString + "list" ); 996 icon = loadPixmap( pathString + "list" );
999 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 997 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
1000 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 998 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
1001 showlist_action->addTo( viewMenu ); 999 showlist_action->addTo( viewMenu );
1002 connect( showlist_action, SIGNAL( activated() ), 1000 connect( showlist_action, SIGNAL( activated() ),
1003 mView->viewManager(), SLOT( showListView() ) ); 1001 mView->viewManager(), SLOT( showListView() ) );
1004 1002
1005 icon = loadPixmap( pathString + "todo" ); 1003 icon = loadPixmap( pathString + "todo" );
1006 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 1004 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
1007 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 1005 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
1008 todoview_action->addTo( viewMenu ); 1006 todoview_action->addTo( viewMenu );
1009 connect( todoview_action, SIGNAL( activated() ), 1007 connect( todoview_action, SIGNAL( activated() ),
1010 mView->viewManager(), SLOT( showTodoView() ) ); 1008 mView->viewManager(), SLOT( showTodoView() ) );
1011 1009
1012 1010
1013 1011
1014#if 0 1012#if 0
1015 action = new QAction( "view_timespan", "Time Span", 0, this ); 1013 action = new QAction( "view_timespan", "Time Span", 0, this );
1016 action->addTo( viewMenu ); 1014 action->addTo( viewMenu );
1017 connect( action, SIGNAL( activated() ), 1015 connect( action, SIGNAL( activated() ),
1018 mView->viewManager(), SLOT( showTimeSpanView() ) ); 1016 mView->viewManager(), SLOT( showTimeSpanView() ) );
1019#endif 1017#endif
1020 1018
1021 1019
1022 1020
1023 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0, 1021 action = new QAction( "purge_completed", i18n("Purge Completed..."), 0,
1024 this ); 1022 this );
1025 action->addTo( actionMenu ); 1023 action->addTo( actionMenu );
1026 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 1024 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
1027 1025
1028 1026
1029 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 1027 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
1030 1028
1031 1029
1032 1030
1033 actionMenu->insertSeparator(); 1031 actionMenu->insertSeparator();
1034 action = new QAction( "manage cat", i18n("Edit category list..."), 0, 1032 action = new QAction( "manage cat", i18n("Edit category list..."), 0,
1035 this ); 1033 this );
1036 action->addTo( actionMenu ); 1034 action->addTo( actionMenu );
1037 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) ); 1035 connect( action, SIGNAL( activated() ), mView, SLOT( editCategories() ) );
1038 1036
1039 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1037 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1040 this ); 1038 this );
1041 action->addTo( actionMenu ); 1039 action->addTo( actionMenu );
1042 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1040 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1043 1041
1044 1042
1045 actionMenu->insertSeparator(); 1043 actionMenu->insertSeparator();
1046 icon = loadPixmap( pathString + "configure" ); 1044 icon = loadPixmap( pathString + "configure" );
1047 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 1045 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
1048 action->addTo( actionMenu ); 1046 action->addTo( actionMenu );
1049 connect( action, SIGNAL( activated() ), 1047 connect( action, SIGNAL( activated() ),
1050 mView, SLOT( edit_options() ) ); 1048 mView, SLOT( edit_options() ) );
1051 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this ); 1049 action = new QAction( i18n("Configure"),icon, i18n("Configure Calendar Files..."), 0, this );
1052 action->addTo( actionMenu ); 1050 action->addTo( actionMenu );
1053 connect( action, SIGNAL( activated() ), 1051 connect( action, SIGNAL( activated() ),
1054 this, SLOT( calHint() ) ); 1052 this, SLOT( calHint() ) );
1055 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 1053 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
1056 action->addTo( actionMenu ); 1054 action->addTo( actionMenu );
1057 connect( action, SIGNAL( activated() ), 1055 connect( action, SIGNAL( activated() ),
1058 mView, SLOT( edit_global_options() ) ); 1056 mView, SLOT( edit_global_options() ) );
1059 if ( KOPrefs::instance()->mShowFullMenu ) { 1057 if ( KOPrefs::instance()->mShowFullMenu ) {
1060 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 1058 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
1061 1059
1062 } 1060 }
1063 // actionMenu->insertSeparator(); 1061 // actionMenu->insertSeparator();
1064 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 1062 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
1065 this ); 1063 this );
1066 action->addTo( importMenu_X ); 1064 action->addTo( importMenu_X );
1067 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 1065 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
1068 action = new QAction( "import_quick", i18n("Import last file"), 0, 1066 action = new QAction( "import_quick", i18n("Import last file"), 0,
1069 this ); 1067 this );
1070 action->addTo( importMenu_X ); 1068 action->addTo( importMenu_X );
1071 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 1069 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
1072 importMenu_X->insertSeparator(); 1070 importMenu_X->insertSeparator();
1073 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 1071 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
1074 this ); 1072 this );
1075 action->addTo( importMenu_X ); 1073 action->addTo( importMenu_X );
1076 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 1074 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
1077 //#ifndef DESKTOP_VERSION 1075 //#ifndef DESKTOP_VERSION
1078 importMenu_X->insertSeparator(); 1076 importMenu_X->insertSeparator();
1079 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 1077 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
1080 this ); 1078 this );
1081 action->addTo( importMenu_X ); 1079 action->addTo( importMenu_X );
1082 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 1080 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
1083 //#else 1081 //#else
1084#ifdef _OL_IMPORT_ 1082#ifdef _OL_IMPORT_
1085 importMenu_X->insertSeparator(); 1083 importMenu_X->insertSeparator();
1086 action = new QAction( "import_ol", i18n("Import from OL"), 0, 1084 action = new QAction( "import_ol", i18n("Import from OL"), 0,
1087 this ); 1085 this );
1088 action->addTo( importMenu_X ); 1086 action->addTo( importMenu_X );
1089 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1087 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1090#endif 1088#endif
1091 //#endif 1089 //#endif
1092 1090
1093 //importMenu->insertSeparator(); 1091 //importMenu->insertSeparator();
1094#if 0 1092#if 0
1095 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1093 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1096 this ); 1094 this );
1097 action->addTo( importMenu ); 1095 action->addTo( importMenu );
1098 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1096 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1099#endif 1097#endif
1100 action = new QAction( "save_cal", i18n("Save Backup..."), 0, 1098 action = new QAction( "save_cal", i18n("Save Backup..."), 0,
1101 this ); 1099 this );
1102 action->addTo( importMenu ); 1100 action->addTo( importMenu );
1103 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1101 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1104 importMenu->insertSeparator(); 1102 importMenu->insertSeparator();
1105 importMenu->insertItem( i18n("Import"), importMenu_X ); 1103 importMenu->insertItem( i18n("Import"), importMenu_X );
1106 //importMenu->insertSeparator(); 1104 //importMenu->insertSeparator();
1107 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1105 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1108 this ); 1106 this );
1109 action->addTo( exportMenu_X ); 1107 action->addTo( exportMenu_X );
1110 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1108 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1111 1109
1112 1110
1113 //LR 1111 //LR
1114 QPopupMenu *ex2phone = new QPopupMenu( this ); 1112 QPopupMenu *ex2phone = new QPopupMenu( this );
1115 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1113 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1116 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1114 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1117 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1115 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1118 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1116 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1119 1117
1120 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1118 importMenu->insertItem( i18n("Export"), exportMenu_X );
1121 mPrintSelAction = 0; 1119 mPrintSelAction = 0;
1122#ifndef DESKTOP_VERSION 1120#ifndef DESKTOP_VERSION
1123 //importMenu->insertSeparator(); 1121 //importMenu->insertSeparator();
1124 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1122 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1125 this ); 1123 this );
1126 brAction->addTo( beamMenu_X ); 1124 brAction->addTo( beamMenu_X );
1127 brAction->setToggleAction (true ) ; 1125 brAction->setToggleAction (true ) ;
1128 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1126 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1129 1127
1130 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1128 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1131 this ); 1129 this );
1132 action->addTo( beamMenu_X ); 1130 action->addTo( beamMenu_X );
1133 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1131 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1134 1132
1135 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1133 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1136 this ); 1134 this );
1137 action->addTo( beamMenu_X ); 1135 action->addTo( beamMenu_X );
1138 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1136 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1139 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1137 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1140#else 1138#else
1141 //importMenu->insertSeparator(); 1139 //importMenu->insertSeparator();
1142 icon = loadPixmap( pathString + "print" ); 1140 icon = loadPixmap( pathString + "print" );
1143 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1141 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1144 action->addTo( beamMenu_X ); 1142 action->addTo( beamMenu_X );
1145 connect( action, SIGNAL( activated() ), 1143 connect( action, SIGNAL( activated() ),
1146 this, SLOT( printCal() ) ); 1144 this, SLOT( printCal() ) );
1147 1145
1148 icon = loadPixmap( pathString + "week" ); 1146 icon = loadPixmap( pathString + "week" );
1149 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1147 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1150 action->addTo( beamMenu_X ); 1148 action->addTo( beamMenu_X );
1151 connect( action, SIGNAL( activated() ), 1149 connect( action, SIGNAL( activated() ),
1152 this, SLOT( printSel() ) ); 1150 this, SLOT( printSel() ) );
1153 icon = loadPixmap( pathString + "whatsnext" ); 1151 icon = loadPixmap( pathString + "whatsnext" );
1154 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1152 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1155 action->addTo( beamMenu_X ); 1153 action->addTo( beamMenu_X );
1156 connect( action, SIGNAL( activated() ), 1154 connect( action, SIGNAL( activated() ),
1157 mView->viewManager(), SLOT( slotprintWNV() ) ); 1155 mView->viewManager(), SLOT( slotprintWNV() ) );
1158 1156
1159 1157
1160 icon = loadPixmap( pathString + "list" ); 1158 icon = loadPixmap( pathString + "list" );
1161 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1159 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1162 action->addTo( beamMenu_X ); 1160 action->addTo( beamMenu_X );
1163 connect( action, SIGNAL( activated() ), 1161 connect( action, SIGNAL( activated() ),
1164 this, SLOT( printListView() ) ); 1162 this, SLOT( printListView() ) );
1165 1163
1166 icon = loadPixmap( pathString + "newevent" ); 1164 icon = loadPixmap( pathString + "newevent" );
1167 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1165 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1168 action->addTo( beamMenu_X ); 1166 action->addTo( beamMenu_X );
1169 connect( action, SIGNAL( activated() ), 1167 connect( action, SIGNAL( activated() ),
1170 mView, SLOT( slotprintSelInc() ) ); 1168 mView, SLOT( slotprintSelInc() ) );
1171 mPrintSelAction = action; 1169 mPrintSelAction = action;
1172 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1170 importMenu->insertItem( i18n("Print"), beamMenu_X );
1173#endif 1171#endif
1174 1172
1175 importMenu->insertSeparator(); 1173 importMenu->insertSeparator();
1176 action = new QAction( "beam all", i18n("Save"), 0, 1174 action = new QAction( "beam all", i18n("Save"), 0,
1177 this ); 1175 this );
1178 action->addTo( importMenu ); 1176 action->addTo( importMenu );
1179 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1177 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1180 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1178 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1181 this ); 1179 this );
1182 action->addTo( importMenu ); 1180 action->addTo( importMenu );
1183 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1181 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1184 1182
1185 //menuBar->insertItem( "Configure",configureMenu ); 1183 //menuBar->insertItem( "Configure",configureMenu );
1186 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1184 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1187 icon = loadPixmap( "korganizer/korganizer" ); 1185 icon = loadPixmap( "korganizer/korganizer" );
1188 1186
1189 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1187 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1190 action->addTo( helpMenu ); 1188 action->addTo( helpMenu );
1191 connect( action, SIGNAL( activated() ), 1189 connect( action, SIGNAL( activated() ),
1192 SLOT( whatsNew() ) ); 1190 SLOT( whatsNew() ) );
1193 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1191 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1194 action->addTo( helpMenu ); 1192 action->addTo( helpMenu );
1195 connect( action, SIGNAL( activated() ), 1193 connect( action, SIGNAL( activated() ),
1196 SLOT( features() ) ); 1194 SLOT( features() ) );
1197 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1195 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1198 action->addTo( helpMenu ); 1196 action->addTo( helpMenu );
1199 connect( action, SIGNAL( activated() ), 1197 connect( action, SIGNAL( activated() ),
1200 SLOT( keyBindings() ) ); 1198 SLOT( keyBindings() ) );
1201 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1199 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1202 action->addTo( helpMenu ); 1200 action->addTo( helpMenu );
1203 connect( action, SIGNAL( activated() ), 1201 connect( action, SIGNAL( activated() ),
1204 SLOT( storagehowto() ) ); 1202 SLOT( storagehowto() ) );
1205 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1203 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1206 action->addTo( helpMenu ); 1204 action->addTo( helpMenu );
1207 connect( action, SIGNAL( activated() ), 1205 connect( action, SIGNAL( activated() ),
1208 SLOT( timetrackinghowto() ) ); 1206 SLOT( timetrackinghowto() ) );
1209 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1207 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1210 action->addTo( helpMenu ); 1208 action->addTo( helpMenu );
1211 connect( action, SIGNAL( activated() ), 1209 connect( action, SIGNAL( activated() ),
1212 SLOT( synchowto() ) ); 1210 SLOT( synchowto() ) );
1213 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1211 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1214 action->addTo( helpMenu ); 1212 action->addTo( helpMenu );
1215 connect( action, SIGNAL( activated() ), 1213 connect( action, SIGNAL( activated() ),
1216 SLOT( kdesynchowto() ) ); 1214 SLOT( kdesynchowto() ) );
1217 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1215 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1218 action->addTo( helpMenu ); 1216 action->addTo( helpMenu );
1219 connect( action, SIGNAL( activated() ), 1217 connect( action, SIGNAL( activated() ),
1220 SLOT( multisynchowto() ) ); 1218 SLOT( multisynchowto() ) );
1221 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1219 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1222 action->addTo( helpMenu ); 1220 action->addTo( helpMenu );
1223 connect( action, SIGNAL( activated() ), 1221 connect( action, SIGNAL( activated() ),
1224 SLOT( aboutAutoSaving() ) ); 1222 SLOT( aboutAutoSaving() ) );
1225 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1223 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1226 action->addTo( helpMenu ); 1224 action->addTo( helpMenu );
1227 connect( action, SIGNAL( activated() ), 1225 connect( action, SIGNAL( activated() ),
1228 SLOT( aboutKnownBugs() ) ); 1226 SLOT( aboutKnownBugs() ) );
1229 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1227 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1230 action->addTo( helpMenu ); 1228 action->addTo( helpMenu );
1231 connect( action, SIGNAL( activated() ), 1229 connect( action, SIGNAL( activated() ),
1232 SLOT( usertrans() ) ); 1230 SLOT( usertrans() ) );
1233 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1231 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1234 action->addTo( helpMenu ); 1232 action->addTo( helpMenu );
1235 connect( action, SIGNAL( activated() ), 1233 connect( action, SIGNAL( activated() ),
1236 SLOT( faq() ) ); 1234 SLOT( faq() ) );
1237 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1235 action = new QAction( "licence", i18n("Licence..."), 0, this );
1238 action->addTo( helpMenu ); 1236 action->addTo( helpMenu );
1239 connect( action, SIGNAL( activated() ), 1237 connect( action, SIGNAL( activated() ),
1240 SLOT( licence() ) ); 1238 SLOT( licence() ) );
1241 action = new QAction( "about", i18n("About..."), 0, this ); 1239 action = new QAction( "about", i18n("About..."), 0, this );
1242 action->addTo( helpMenu ); 1240 action->addTo( helpMenu );
1243 connect( action, SIGNAL( activated() ), 1241 connect( action, SIGNAL( activated() ),
1244 SLOT( about() ) ); 1242 SLOT( about() ) );
1245 //menuBar->insertSeparator(); 1243 //menuBar->insertSeparator();
1246 1244
1247 // ****************************************************** 1245 // ******************************************************
1248 // menubar icons 1246 // menubar icons
1249 1247
1250 1248
1251 1249
1252 //menuBar->insertItem( iconToolBar ); 1250 //menuBar->insertItem( iconToolBar );
1253 //xdays_action 1251 //xdays_action
1254 if (p-> mShowIconNewEvent) 1252 if (p-> mShowIconNewEvent)
1255 ne_action->addTo( iconToolBar ); 1253 ne_action->addTo( iconToolBar );
1256 if (p->mShowIconNewTodo ) 1254 if (p->mShowIconNewTodo )
1257 nt_action->addTo( iconToolBar ); 1255 nt_action->addTo( iconToolBar );
1258 if (p-> mShowIconSearch) 1256 if (p-> mShowIconSearch)
1259 search_action->addTo( iconToolBar ); 1257 search_action->addTo( iconToolBar );
1260 if (p-> mShowIconWhatsThis) 1258 if (p-> mShowIconWhatsThis)
1261 QWhatsThis::whatsThisButton ( iconToolBar ); 1259 QWhatsThis::whatsThisButton ( iconToolBar );
1262 if (p-> mShowIconNext) 1260 if (p-> mShowIconNext)
1263 whatsnext_action->addTo( viewToolBar ); 1261 whatsnext_action->addTo( viewToolBar );
1264 if (p-> mShowIconNextDays) 1262 if (p-> mShowIconNextDays)
1265 xdays_action->addTo( viewToolBar ); 1263 xdays_action->addTo( viewToolBar );
1266 if (p-> mShowIconJournal) 1264 if (p-> mShowIconJournal)
1267 viewjournal_action->addTo( viewToolBar ); 1265 viewjournal_action->addTo( viewToolBar );
1268 if (p-> mShowIconDay1) 1266 if (p-> mShowIconDay1)
1269 day1_action->addTo( viewToolBar ); 1267 day1_action->addTo( viewToolBar );
1270 if (p-> mShowIconDay5) 1268 if (p-> mShowIconDay5)
1271 day5_action->addTo( viewToolBar ); 1269 day5_action->addTo( viewToolBar );
1272 if (p-> mShowIconDay7) 1270 if (p-> mShowIconDay7)
1273 day7_action->addTo( viewToolBar ); 1271 day7_action->addTo( viewToolBar );
1274 if (p-> mShowIconDay6) 1272 if (p-> mShowIconDay6)
1275 day6_action->addTo( viewToolBar ); 1273 day6_action->addTo( viewToolBar );
1276 if (p-> mShowIconMonth) 1274 if (p-> mShowIconMonth)
1277 month_action->addTo( viewToolBar ); 1275 month_action->addTo( viewToolBar );
1278 if (p-> mShowIconList) 1276 if (p-> mShowIconList)
1279 showlist_action->addTo( viewToolBar ); 1277 showlist_action->addTo( viewToolBar );
1280 if (p-> mShowIconTodoview) 1278 if (p-> mShowIconTodoview)
1281 todoview_action->addTo( viewToolBar ); 1279 todoview_action->addTo( viewToolBar );
1282 1280
1283 icon = loadPixmap( pathString + "2leftarrowB" ); 1281 icon = loadPixmap( pathString + "2leftarrowB" );
1284 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1282 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1285 if (p-> mShowIconBackFast) { 1283 if (p-> mShowIconBackFast) {
1286 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1284 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1287 connect( action, SIGNAL( activated() ), 1285 connect( action, SIGNAL( activated() ),
1288 mView, SLOT( goPreviousMonth() ) ); 1286 mView, SLOT( goPreviousMonth() ) );
1289 action->addTo( navigatorToolBar ); 1287 action->addTo( navigatorToolBar );
1290 } 1288 }
1291 icon = loadPixmap( pathString + "1leftarrowB" ); 1289 icon = loadPixmap( pathString + "1leftarrowB" );
1292 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1290 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1293 if (p-> mShowIconBack) { 1291 if (p-> mShowIconBack) {
1294 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1292 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1295 connect( action, SIGNAL( activated() ), 1293 connect( action, SIGNAL( activated() ),
1296 mView, SLOT( goPrevious() ) ); 1294 mView, SLOT( goPrevious() ) );
1297 action->addTo( navigatorToolBar ); 1295 action->addTo( navigatorToolBar );
1298 } 1296 }
1299 icon = loadPixmap( pathString + "today" ); 1297 icon = loadPixmap( pathString + "today" );
1300 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1298 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1301 if (p-> mShowIconToday) 1299 if (p-> mShowIconToday)
1302 today_action->addTo( navigatorToolBar ); 1300 today_action->addTo( navigatorToolBar );
1303 icon = loadPixmap( pathString + "1rightarrowB" ); 1301 icon = loadPixmap( pathString + "1rightarrowB" );
1304 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1302 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1305 if (p-> mShowIconForward) { 1303 if (p-> mShowIconForward) {
1306 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1304 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1307 connect( action, SIGNAL( activated() ), 1305 connect( action, SIGNAL( activated() ),
1308 mView, SLOT( goNext() ) ); 1306 mView, SLOT( goNext() ) );
1309 action->addTo( navigatorToolBar ); 1307 action->addTo( navigatorToolBar );
1310 } 1308 }
1311 icon = loadPixmap( pathString + "2rightarrowB" ); 1309 icon = loadPixmap( pathString + "2rightarrowB" );
1312 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1310 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1313 if (p-> mShowIconForwardFast) { 1311 if (p-> mShowIconForwardFast) {
1314 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1312 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1315 connect( action, SIGNAL( activated() ), 1313 connect( action, SIGNAL( activated() ),
1316 mView, SLOT( goNextMonth() ) ); 1314 mView, SLOT( goNextMonth() ) );
1317 action->addTo( navigatorToolBar ); 1315 action->addTo( navigatorToolBar );
1318 } 1316 }
1319 1317
1320 1318
1321 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1319 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1322 1320
1323 1321
1324 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1322 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1325 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1323 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1326 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1324 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1327 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1325 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1328 1326
1329 if (p-> mShowIconNewEvent) 1327 if (p-> mShowIconNewEvent)
1330 configureToolBarMenu->setItemChecked( 10, true ); 1328 configureToolBarMenu->setItemChecked( 10, true );
1331 if (p->mShowIconNewTodo ) 1329 if (p->mShowIconNewTodo )
1332 configureToolBarMenu->setItemChecked( 20, true ); 1330 configureToolBarMenu->setItemChecked( 20, true );
1333 if (p-> mShowIconSearch) 1331 if (p-> mShowIconSearch)
1334 configureToolBarMenu->setItemChecked( 120, true ); 1332 configureToolBarMenu->setItemChecked( 120, true );
1335 if (p-> mShowIconList) 1333 if (p-> mShowIconList)
1336 configureToolBarMenu->setItemChecked( 30, true ); 1334 configureToolBarMenu->setItemChecked( 30, true );
1337 if (p-> mShowIconDay1) 1335 if (p-> mShowIconDay1)
1338 configureToolBarMenu->setItemChecked( 40, true ); 1336 configureToolBarMenu->setItemChecked( 40, true );
1339 if (p-> mShowIconDay5) 1337 if (p-> mShowIconDay5)
1340 configureToolBarMenu->setItemChecked( 50, true ); 1338 configureToolBarMenu->setItemChecked( 50, true );
1341 if (p-> mShowIconDay6) 1339 if (p-> mShowIconDay6)
1342 configureToolBarMenu->setItemChecked( 75, true ); 1340 configureToolBarMenu->setItemChecked( 75, true );
1343 if (p-> mShowIconDay7) 1341 if (p-> mShowIconDay7)
1344 configureToolBarMenu->setItemChecked( 60, true ); 1342 configureToolBarMenu->setItemChecked( 60, true );
1345 if (p-> mShowIconMonth) 1343 if (p-> mShowIconMonth)
1346 configureToolBarMenu->setItemChecked( 70, true ); 1344 configureToolBarMenu->setItemChecked( 70, true );
1347 if (p-> mShowIconTodoview) 1345 if (p-> mShowIconTodoview)
1348 configureToolBarMenu->setItemChecked( 80, true ); 1346 configureToolBarMenu->setItemChecked( 80, true );
1349 if (p-> mShowIconBackFast) 1347 if (p-> mShowIconBackFast)
1350 configureToolBarMenu->setItemChecked( 200, true ); 1348 configureToolBarMenu->setItemChecked( 200, true );
1351 if (p-> mShowIconBack) 1349 if (p-> mShowIconBack)
1352 configureToolBarMenu->setItemChecked( 210, true ); 1350 configureToolBarMenu->setItemChecked( 210, true );
1353 if (p-> mShowIconToday) 1351 if (p-> mShowIconToday)
1354 configureToolBarMenu->setItemChecked( 130, true ); 1352 configureToolBarMenu->setItemChecked( 130, true );
1355 if (p-> mShowIconForward) 1353 if (p-> mShowIconForward)
1356 configureToolBarMenu->setItemChecked( 220, true ); 1354 configureToolBarMenu->setItemChecked( 220, true );
1357 if (p-> mShowIconForwardFast) 1355 if (p-> mShowIconForwardFast)
1358 configureToolBarMenu->setItemChecked( 230, true ); 1356 configureToolBarMenu->setItemChecked( 230, true );
1359 if (p-> mShowIconNextDays) 1357 if (p-> mShowIconNextDays)
1360 configureToolBarMenu->setItemChecked( 100, true ); 1358 configureToolBarMenu->setItemChecked( 100, true );
1361 if (p-> mShowIconNext) 1359 if (p-> mShowIconNext)
1362 configureToolBarMenu->setItemChecked( 110, true ); 1360 configureToolBarMenu->setItemChecked( 110, true );
1363 if (p-> mShowIconJournal) 1361 if (p-> mShowIconJournal)
1364 configureToolBarMenu->setItemChecked( 90, true ); 1362 configureToolBarMenu->setItemChecked( 90, true );
1365 if (p-> mShowIconWhatsThis) 1363 if (p-> mShowIconWhatsThis)
1366 configureToolBarMenu->setItemChecked( 300, true ); 1364 configureToolBarMenu->setItemChecked( 300, true );
1367 if (p-> mShowIconWeekNum) 1365 if (p-> mShowIconWeekNum)
1368 configureToolBarMenu->setItemChecked( 400, true ); 1366 configureToolBarMenu->setItemChecked( 400, true );
1369 if (!p-> mShowIconStretch) { 1367 if (!p-> mShowIconStretch) {
1370 QLabel* dummy = new QLabel( iconToolBar ); 1368 QLabel* dummy = new QLabel( iconToolBar );
1371 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1369 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1372 dummy->setMinimumWidth( 0 ); 1370 dummy->setMinimumWidth( 0 );
1373 iconToolBar->setStretchableWidget ( dummy ) ; 1371 iconToolBar->setStretchableWidget ( dummy ) ;
1374 } 1372 }
1375 else { 1373 else {
1376 iconToolBar->setHorizontalStretchable (true ); 1374 iconToolBar->setHorizontalStretchable (true );
1377 viewToolBar->setHorizontalStretchable (true ); 1375 viewToolBar->setHorizontalStretchable (true );
1378 navigatorToolBar->setHorizontalStretchable (true ); 1376 navigatorToolBar->setHorizontalStretchable (true );
1379 iconToolBar->setVerticalStretchable (true ); 1377 iconToolBar->setVerticalStretchable (true );
1380 viewToolBar->setVerticalStretchable (true ); 1378 viewToolBar->setVerticalStretchable (true );
1381 navigatorToolBar->setVerticalStretchable (true ); 1379 navigatorToolBar->setVerticalStretchable (true );
1382 configureToolBarMenu->setItemChecked( 5, true ); 1380 configureToolBarMenu->setItemChecked( 5, true );
1383 } 1381 }
1384 if (p-> mShowIconFilter) 1382 if (p-> mShowIconFilter)
1385 configureToolBarMenu->setItemChecked( 7, true ); 1383 configureToolBarMenu->setItemChecked( 7, true );
1386 if (p-> mShowIconOnetoolbar) 1384 if (p-> mShowIconOnetoolbar)
1387 configureToolBarMenu->setItemChecked( 6, true ); 1385 configureToolBarMenu->setItemChecked( 6, true );
1388 1386
1389 1387
1390 if ( filterMenubar ) { 1388 if ( filterMenubar ) {
1391 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1389 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1392 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) ); 1390 connect( mView, SIGNAL( filtersUpdated() ), SLOT( updateFilterToolbar() ) );
1393 } 1391 }
1394 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1392 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1395 configureAgenda( p->mHourSize ); 1393 configureAgenda( p->mHourSize );
1396 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1394 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1397} 1395}
1398void MainWindow::calHint() 1396void MainWindow::calHint()
1399{ 1397{
1400 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>."); 1398 QString message = i18n("You can use and display <b>more than one</b> calendar file in KO/Pi. A calendar file is called a <b>resource</b>. To add a calendar or change calendar settings please use menu: <b>View -> Toggle Resource View</b>.");
1401 1399
1402 KMessageBox::information( this, message); 1400 KMessageBox::information( this, message);
1403} 1401}
1404void MainWindow::exportToPhone( int mode ) 1402void MainWindow::exportToPhone( int mode )
1405{ 1403{
1406 1404
1407 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1405 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1408 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1406 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1409 KOex2phonePrefs ex2phone; 1407 KOex2phonePrefs ex2phone;
1410 1408
1411 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1409 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1412 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1410 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1413 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1411 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1414 if ( mode == 1 ) 1412 if ( mode == 1 )
1415 ex2phone.setCaption(i18n("Export complete calendar")); 1413 ex2phone.setCaption(i18n("Export complete calendar"));
1416 if ( mode == 2 ) 1414 if ( mode == 2 )
1417 ex2phone.setCaption(i18n("Export filtered calendar")); 1415 ex2phone.setCaption(i18n("Export filtered calendar"));
1418 1416
1419 if ( !ex2phone.exec() ) { 1417 if ( !ex2phone.exec() ) {
1420 return; 1418 return;
1421 } 1419 }
1422 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1420 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1423 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1421 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1424 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1422 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1425 1423
1426 int inFuture = 0; 1424 int inFuture = 0;
1427 if ( ex2phone.mWriteBackFuture->isChecked() ) 1425 if ( ex2phone.mWriteBackFuture->isChecked() )
1428 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1426 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1429 QPtrList<Incidence> delSel; 1427 QPtrList<Incidence> delSel;
1430 if ( mode == 1 ) 1428 if ( mode == 1 )
1431 delSel = mCalendar->rawIncidences(); 1429 delSel = mCalendar->rawIncidences();
1432 if ( mode == 2 ) 1430 if ( mode == 2 )
1433 delSel = mCalendar->incidences(); 1431 delSel = mCalendar->incidences();
1434 CalendarLocal* cal = new CalendarLocal(); 1432 CalendarLocal* cal = new CalendarLocal();
1435 cal->setLocalTime(); 1433 cal->setLocalTime();
1436 Incidence *incidence = delSel.first(); 1434 Incidence *incidence = delSel.first();
1437 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1435 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1438 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1436 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1439 while ( incidence ) { 1437 while ( incidence ) {
1440 if ( incidence->typeID() != journalID ) { 1438 if ( incidence->typeID() != journalID ) {
1441 bool add = true; 1439 bool add = true;
1442 if ( inFuture ) { 1440 if ( inFuture ) {
1443 QDateTime dt; 1441 QDateTime dt;
1444 if ( incidence->typeID() == todoID ) { 1442 if ( incidence->typeID() == todoID ) {
1445 Todo * t = (Todo*)incidence; 1443 Todo * t = (Todo*)incidence;
1446 if ( t->hasDueDate() ) 1444 if ( t->hasDueDate() )
1447 dt = t->dtDue(); 1445 dt = t->dtDue();
1448 else 1446 else
1449 dt = cur.addSecs( 62 ); 1447 dt = cur.addSecs( 62 );
1450 } 1448 }
1451 else { 1449 else {
1452 bool ok; 1450 bool ok;
1453 dt = incidence->getNextOccurence( cur, &ok ); 1451 dt = incidence->getNextOccurence( cur, &ok );
1454 if ( !ok ) 1452 if ( !ok )
1455 dt = cur.addSecs( -62 ); 1453 dt = cur.addSecs( -62 );
1456 } 1454 }
1457 if ( dt < cur || dt > end ) { 1455 if ( dt < cur || dt > end ) {
1458 add = false; 1456 add = false;
1459 } 1457 }
1460 } 1458 }
1461 if ( add ) { 1459 if ( add ) {
1462 Incidence *in = incidence->clone(); 1460 Incidence *in = incidence->clone();
1463 cal->addIncidence( in ); 1461 cal->addIncidence( in );
1464 } 1462 }
1465 } 1463 }
1466 incidence = delSel.next(); 1464 incidence = delSel.next();
1467 } 1465 }
1468 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1466 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1469 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1467 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1470 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1468 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1471 1469
1472 setCaption( i18n("Writing to phone...")); 1470 setCaption( i18n("Writing to phone..."));
1473 if ( PhoneFormat::writeToPhone( cal ) ) 1471 if ( PhoneFormat::writeToPhone( cal ) )
1474 setCaption( i18n("Export to phone successful!")); 1472 setCaption( i18n("Export to phone successful!"));
1475 else 1473 else
1476 setCaption( i18n("Error exporting to phone!")); 1474 setCaption( i18n("Error exporting to phone!"));
1477 delete cal; 1475 delete cal;
1478} 1476}
1479 1477
1480 1478
1481void MainWindow::setDefaultPreferences() 1479void MainWindow::setDefaultPreferences()
1482{ 1480{
1483 KOPrefs *p = KOPrefs::instance(); 1481 KOPrefs *p = KOPrefs::instance();
1484 1482
1485 p->mCompactDialogs = true; 1483 p->mCompactDialogs = true;
1486 p->mConfirm = true; 1484 p->mConfirm = true;
1487 // p->mEnableQuickTodo = false; 1485 // p->mEnableQuickTodo = false;
1488 1486
1489} 1487}
1490 1488
1491QString MainWindow::resourcePath() 1489QString MainWindow::resourcePath()
1492{ 1490{
1493 return KGlobal::iconLoader()->iconPath(); 1491 return KGlobal::iconLoader()->iconPath();
1494} 1492}
1495 1493
1496void MainWindow::displayText( QString text ,QString cap ) 1494void MainWindow::displayText( QString text ,QString cap )
1497{ 1495{
1498 QDialog dia( this, "name", true ); ; 1496 QDialog dia( this, "name", true ); ;
1499 dia.setCaption( cap ); 1497 dia.setCaption( cap );
1500 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1498 QVBoxLayout* lay = new QVBoxLayout( &dia );
1501 lay->setSpacing( 3 ); 1499 lay->setSpacing( 3 );
1502 lay->setMargin( 3 ); 1500 lay->setMargin( 3 );
1503 QTextBrowser tb ( &dia ); 1501 QTextBrowser tb ( &dia );
1504 lay->addWidget( &tb ); 1502 lay->addWidget( &tb );
1505 tb.setText( text ); 1503 tb.setText( text );
1506#ifdef DESKTOP_VERSION 1504#ifdef DESKTOP_VERSION
1507 dia.resize( 640, 480); 1505 dia.resize( 640, 480);
1508#else 1506#else
1509 dia.showMaximized(); 1507 dia.showMaximized();
1510#endif 1508#endif
1511 dia.exec(); 1509 dia.exec();
1512} 1510}
1513 1511
1514void MainWindow::features() 1512void MainWindow::features()
1515{ 1513{
1516 1514
1517 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1515 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1518} 1516}
1519 1517
1520void MainWindow::usertrans() 1518void MainWindow::usertrans()
1521{ 1519{
1522 1520
1523 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1521 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1524} 1522}
1525 1523
1526void MainWindow::storagehowto() 1524void MainWindow::storagehowto()
1527{ 1525{
1528 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1526 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1529} 1527}
1530void MainWindow::timetrackinghowto() 1528void MainWindow::timetrackinghowto()
1531{ 1529{
1532 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1530 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1533} 1531}
1534void MainWindow::kdesynchowto() 1532void MainWindow::kdesynchowto()
1535{ 1533{
1536 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1534 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1537} 1535}
1538void MainWindow::multisynchowto() 1536void MainWindow::multisynchowto()
1539{ 1537{
1540 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1538 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1541} 1539}
1542void MainWindow::synchowto() 1540void MainWindow::synchowto()
1543{ 1541{
1544 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1542 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1545} 1543}
1546void MainWindow::faq() 1544void MainWindow::faq()
1547{ 1545{
1548 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1546 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1549 1547
1550} 1548}
1551void MainWindow::whatsNew() 1549void MainWindow::whatsNew()
1552{ 1550{
1553 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1551 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1554 1552
1555} 1553}
1556void MainWindow::licence() 1554void MainWindow::licence()
1557{ 1555{
1558 KApplication::showLicence(); 1556 KApplication::showLicence();
1559 1557
1560} 1558}
1561void MainWindow::about() 1559void MainWindow::about()
1562{ 1560{
1563 QString version; 1561 QString version;
1564#include <../version> 1562#include <../version>
1565 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1563 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1566 i18n("KOrganizer/Platform-independent\n") + 1564 i18n("KOrganizer/Platform-independent\n") +
1567 "(KO/Pi) " + version + " - " + 1565 "(KO/Pi) " + version + " - " +
1568 1566
1569#ifdef DESKTOP_VERSION 1567#ifdef DESKTOP_VERSION
1570 i18n("Desktop Edition\n") + 1568 i18n("Desktop Edition\n") +
1571#else 1569#else
1572 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1570 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1573#endif 1571#endif
1574 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!") ); 1572 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!") );
1575} 1573}
1576void MainWindow::keyBindings() 1574void MainWindow::keyBindings()
1577{ 1575{
1578 QString cap = i18n("KO/Pi Keys + Colors"); 1576 QString cap = i18n("KO/Pi Keys + Colors");
1579 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1577 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1580 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1578 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1581 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1579 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1582 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1580 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1583 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1581 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1584 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1582 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1585 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1583 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1586 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1584 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1587 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1585 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1588 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1586 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1589 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+ 1587 i18n("<p><b>Q</b>: Show next date with conflicting events\n ")+
1590 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1588 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1591 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1589 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1592 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1590 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1593 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1591 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1594 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1592 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1595 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1593 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1596 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1594 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1597 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1595 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1598 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1596 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1599 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1597 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1600 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1598 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1601 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1599 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1602 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1600 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1603 i18n("<p><h3>In agenda view:</h3></p>\n") + 1601 i18n("<p><h3>In agenda view:</h3></p>\n") +
1604 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1602 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1605 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1603 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1606 i18n("<p><h3>In todo view:</h3></p>\n") + 1604 i18n("<p><h3>In todo view:</h3></p>\n") +
1607 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1605 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1608 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1606 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1609 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1607 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1610 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1608 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1611 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1609 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1612 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1610 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1613 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1611 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1614 i18n("<p><h3>In list view:</h3></p>\n") + 1612 i18n("<p><h3>In list view:</h3></p>\n") +
1615 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1613 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1616 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1614 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1617 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1615 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1618 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1616 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1619 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1617 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1620 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1618 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1621 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1619 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1622 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1620 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1623 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1621 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1624 i18n("<p><b>E</b>: Edit item</p>\n") + 1622 i18n("<p><b>E</b>: Edit item</p>\n") +
1625 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1623 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1626 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1624 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1627 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1625 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1628 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1626 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1629 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1627 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1630 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1628 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1631 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1629 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1632 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1630 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1633 i18n("<p><b>White</b>: Item readonly</p>\n"); 1631 i18n("<p><b>White</b>: Item readonly</p>\n");
1634 displayText( text, cap); 1632 displayText( text, cap);
1635} 1633}
1636void MainWindow::aboutAutoSaving() 1634void MainWindow::aboutAutoSaving()
1637{ 1635{
1638 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"); 1636 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");
1639 1637
1640 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1638 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1641 1639
1642} 1640}
1643void MainWindow::aboutKnownBugs() 1641void MainWindow::aboutKnownBugs()
1644{ 1642{
1645 QMessageBox* msg; 1643 QMessageBox* msg;
1646 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1644 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1647 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")+ 1645 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")+
1648 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1646 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1649 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1647 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1650 i18n("\nor report them in the bugtracker on\n") + 1648 i18n("\nor report them in the bugtracker on\n") +
1651 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1649 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1652 QMessageBox::NoIcon, 1650 QMessageBox::NoIcon,
1653 QMessageBox::Ok, 1651 QMessageBox::Ok,
1654 QMessageBox::NoButton, 1652 QMessageBox::NoButton,
1655 QMessageBox::NoButton); 1653 QMessageBox::NoButton);
1656 msg->exec(); 1654 msg->exec();
1657 delete msg; 1655 delete msg;
1658 1656
1659} 1657}
1660 1658
1661QString MainWindow::defaultFileName() 1659QString MainWindow::defaultFileName()
1662{ 1660{
1663 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1661 return locateLocal( "data", "korganizer/mycalendar.ics" );
1664} 1662}
1665QString MainWindow::syncFileName() 1663QString MainWindow::syncFileName()
1666{ 1664{
1667#ifdef DESKTOP_VERSION 1665#ifdef DESKTOP_VERSION
1668 return locateLocal( "tmp", "synccalendar.ics" ); 1666 return locateLocal( "tmp", "synccalendar.ics" );
1669#else 1667#else
1670 return QString( "/tmp/synccalendar.ics" ); 1668 return QString( "/tmp/synccalendar.ics" );
1671#endif 1669#endif
1672} 1670}
1673#include "koglobals.h" 1671#include "koglobals.h"
1674#include <kcalendarsystem.h> 1672#include <kcalendarsystem.h>
1675void MainWindow::updateWeek(QDate seda) 1673void MainWindow::updateWeek(QDate seda)
1676{ 1674{
1677 int weekNum = KGlobal::locale()->weekNum ( seda ); 1675 int weekNum = KGlobal::locale()->weekNum ( seda );
1678 mWeekPixmap.fill( mWeekBgColor ); 1676 mWeekPixmap.fill( mWeekBgColor );
1679 QPainter p ( &mWeekPixmap ); 1677 QPainter p ( &mWeekPixmap );
1680 p.setFont( mWeekFont ); 1678 p.setFont( mWeekFont );
1681 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1679 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1682 p.end(); 1680 p.end();
1683 QIconSet icon3 ( mWeekPixmap ); 1681 QIconSet icon3 ( mWeekPixmap );
1684 mWeekAction->setIconSet ( icon3 ); 1682 mWeekAction->setIconSet ( icon3 );
1685 1683
1686} 1684}
1687void MainWindow::updateWeekNum(const DateList &selectedDates) 1685void MainWindow::updateWeekNum(const DateList &selectedDates)
1688{ 1686{
1689 updateWeek( selectedDates.first() ); 1687 updateWeek( selectedDates.first() );
1690} 1688}
1691void MainWindow::processIncidenceSelection( Incidence *incidence ) 1689void MainWindow::processIncidenceSelection( Incidence *incidence )
1692{ 1690{
1693 if ( !incidence ) { 1691 if ( !incidence ) {
1694 mShowAction->setMenuText( i18n("Show") ); 1692 mShowAction->setMenuText( i18n("Show") );
1695 enableIncidenceActions( false ); 1693 enableIncidenceActions( false );
1696 mNewSubTodoAction->setEnabled( false ); 1694 mNewSubTodoAction->setEnabled( false );
1697 setCaptionToDates(); 1695 setCaptionToDates();
1698 return; 1696 return;
1699 } 1697 }
1700 QString startString = ""; 1698 QString startString = "";
1701 if ( incidence->typeID() != todoID ) { 1699 if ( incidence->typeID() != todoID ) {
1702 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1700 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1703 if ( incidence->doesFloat() ) { 1701 if ( incidence->doesFloat() ) {
1704 startString += ": "+incidence->dtStartDateStr( true ); 1702 startString += ": "+incidence->dtStartDateStr( true );
1705 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1703 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1706 } else { 1704 } else {
1707 startString = ": "+incidence->dtStartStr(true); 1705 startString = ": "+incidence->dtStartStr(true);
1708 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1706 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1709 } 1707 }
1710 } else { 1708 } else {
1711 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1709 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1712 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1710 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1713 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1711 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1714 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1712 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1715 bool ok; 1713 bool ok;
1716 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1714 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1717 if ( ok ) { 1715 if ( ok ) {
1718 int years = noc.date().year() - incidence->dtStart().date().year(); 1716 int years = noc.date().year() - incidence->dtStart().date().year();
1719 startString += i18n(" (%1 y.)"). arg( years ); 1717 startString += i18n(" (%1 y.)"). arg( years );
1720 } 1718 }
1721 } 1719 }
1722 else 1720 else
1723 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1721 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1724 } 1722 }
1725 } 1723 }
1726 else { 1724 else {
1727 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 ) 1725 if ( (( KCal::Todo*)incidence)->percentComplete() == 100 )
1728 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) ); 1726 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+i18n("completed on %1").arg( (( KCal::Todo*)incidence)->completedStr(true) );
1729 else 1727 else
1730 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1728 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1731 } 1729 }
1732 if ( !incidence->location().isEmpty() ) 1730 if ( !incidence->location().isEmpty() )
1733 startString += " (" +incidence->location()+")"; 1731 startString += " (" +incidence->location()+")";
1734 setCaption( incidence->summary()+startString); 1732 setCaption( incidence->summary()+startString);
1735 enableIncidenceActions( true ); 1733 enableIncidenceActions( true );
1736 if ( incidence->typeID() == eventID ) { 1734 if ( incidence->typeID() == eventID ) {
1737 mShowAction->setMenuText( i18n("Show Event") ); 1735 mShowAction->setMenuText( i18n("Show Event") );
1738 mNewSubTodoAction->setEnabled( false ); 1736 mNewSubTodoAction->setEnabled( false );
1739 } else if ( incidence->typeID() == todoID ) { 1737 } else if ( incidence->typeID() == todoID ) {
1740 mShowAction->setMenuText( i18n("Show Todo") ); 1738 mShowAction->setMenuText( i18n("Show Todo") );
1741 mNewSubTodoAction->setEnabled( true ); 1739 mNewSubTodoAction->setEnabled( true );
1742 } else { 1740 } else {
1743 mShowAction->setMenuText( i18n("Show") ); 1741 mShowAction->setMenuText( i18n("Show") );
1744 mNewSubTodoAction->setEnabled( false ); 1742 mNewSubTodoAction->setEnabled( false );
1745 } 1743 }
1746 static QPixmap jP = SmallIcon( "journal" ); 1744 static QPixmap jP = SmallIcon( "journal" );
1747 static QPixmap eP = SmallIcon( "newevent" ); 1745 static QPixmap eP = SmallIcon( "newevent" );
1748 static QPixmap tP = SmallIcon( "newtodo" ); 1746 static QPixmap tP = SmallIcon( "newtodo" );
1749#ifdef DESKTOP_VERSION 1747#ifdef DESKTOP_VERSION
1750 QIconSet icon; 1748 QIconSet icon;
1751 if ( incidence->typeID() == todoID ) 1749 if ( incidence->typeID() == todoID )
1752 icon = QIconSet ( tP ); 1750 icon = QIconSet ( tP );
1753 else if ( incidence->typeID() == eventID ) 1751 else if ( incidence->typeID() == eventID )
1754 icon = QIconSet ( eP ); 1752 icon = QIconSet ( eP );
1755 else if ( incidence->typeID() == journalID ) 1753 else if ( incidence->typeID() == journalID )
1756 icon = QIconSet ( jP ); 1754 icon = QIconSet ( jP );
1757 mPrintSelAction->setIconSet ( icon ); 1755 mPrintSelAction->setIconSet ( icon );
1758#endif 1756#endif
1759} 1757}
1760 1758
1761void MainWindow::enableIncidenceActions( bool enabled ) 1759void MainWindow::enableIncidenceActions( bool enabled )
1762{ 1760{
1763 mShowAction->setEnabled( enabled ); 1761 mShowAction->setEnabled( enabled );
1764 mEditAction->setEnabled( enabled ); 1762 mEditAction->setEnabled( enabled );
1765 mDeleteAction->setEnabled( enabled ); 1763 mDeleteAction->setEnabled( enabled );
1766 1764
1767 mCloneAction->setEnabled( enabled ); 1765 mCloneAction->setEnabled( enabled );
1768 mMoveAction->setEnabled( enabled ); 1766 mMoveAction->setEnabled( enabled );
1769#ifndef DESKTOP_VERSION 1767#ifndef DESKTOP_VERSION
1770 mBeamAction->setEnabled( enabled ); 1768 mBeamAction->setEnabled( enabled );
1771#else 1769#else
1772 mPrintSelAction->setEnabled( enabled ); 1770 mPrintSelAction->setEnabled( enabled );
1773#endif 1771#endif
1774 mCancelAction->setEnabled( enabled ); 1772 mCancelAction->setEnabled( enabled );
1775} 1773}
1776 1774
1777void MainWindow::importOL() 1775void MainWindow::importOL()
1778{ 1776{
1779#ifdef _OL_IMPORT_ 1777#ifdef _OL_IMPORT_
1780 mView->clearAllViews(); 1778 mView->clearAllViews();
1781 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1779 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1782 id->exec(); 1780 id->exec();
1783 delete id; 1781 delete id;
1784 mView->calendar()->checkAlarmForIncidence( 0, true ); 1782 mView->calendar()->checkAlarmForIncidence( 0, true );
1785 mView->updateView(); 1783 mView->updateView();
1786#endif 1784#endif
1787} 1785}
1788void MainWindow::importBday() 1786void MainWindow::importBday()
1789{ 1787{
1790 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"), 1788 int result = QMessageBox::warning( this, i18n("KO/Pi import information!"),
1791 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1789 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1792 i18n("Import!"), i18n("Cancel"), 0, 1790 i18n("Import!"), i18n("Cancel"), 0,
1793 0, 1 ); 1791 0, 1 );
1794 if ( result == 0 ) { 1792 if ( result == 0 ) {
1795 mView->importBday(); 1793 mView->importBday();
1796 1794
1797 } 1795 }
1798 1796
1799 1797
1800} 1798}
1801void MainWindow::importQtopia() 1799void MainWindow::importQtopia()
1802{ 1800{
1803 //#ifndef DESKTOP_VERSION 1801 //#ifndef DESKTOP_VERSION
1804 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"); 1802 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");
1805#ifdef DESKTOP_VERSION 1803#ifdef DESKTOP_VERSION
1806 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"); 1804 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");
1807#endif 1805#endif
1808 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1806 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1809 i18n("Import!"), i18n("Cancel"), 0, 1807 i18n("Import!"), i18n("Cancel"), 0,
1810 0, 1 ); 1808 0, 1 );
1811 if ( result == 0 ) { 1809 if ( result == 0 ) {
1812#ifndef DESKTOP_VERSION 1810#ifndef DESKTOP_VERSION
1813 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1811 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1814 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1812 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1815 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1813 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1816#else 1814#else
1817 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1815 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1818 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1816 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1819 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1817 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1820#endif 1818#endif
1821 mView->importQtopia( categories, datebook, todolist ); 1819 mView->importQtopia( categories, datebook, todolist );
1822 } 1820 }
1823 mView->calendar()->reInitAlarmSettings(); 1821 mView->calendar()->reInitAlarmSettings();
1824#if 0 1822#if 0
1825 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1823 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1826 i18n("Not supported \non desktop!\n"), 1824 i18n("Not supported \non desktop!\n"),
1827 i18n("Ok"), i18n("Cancel"), 0, 1825 i18n("Ok"), i18n("Cancel"), 0,
1828 0, 1 ); 1826 0, 1 );
1829 1827
1830#endif 1828#endif
1831} 1829}
1832 1830
1833void MainWindow::saveOnClose() 1831void MainWindow::saveOnClose()
1834{ 1832{
1835 KOPrefs *p = KOPrefs::instance(); 1833 KOPrefs *p = KOPrefs::instance();
1836 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1834 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1837 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1835 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1838 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1836 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1839 if ( filterToolBar ) { 1837 if ( filterToolBar ) {
1840 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1838 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1841 } 1839 }
1842#ifdef DESKTOP_VERSION 1840#ifdef DESKTOP_VERSION
1843 1841
1844 QPoint myP; 1842 QPoint myP;
1845 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1843 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1846 if ( p->mToolBarHor ) 1844 if ( p->mToolBarHor )
1847 p->mToolBarUp = myP.y() > height()/2; 1845 p->mToolBarUp = myP.y() > height()/2;
1848 else 1846 else
1849 p->mToolBarUp = myP.x() > width()/2; 1847 p->mToolBarUp = myP.x() > width()/2;
1850 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1848 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1851 if ( p->mToolBarHorV ) 1849 if ( p->mToolBarHorV )
1852 p->mToolBarUpV = myP.y() > height()/2; 1850 p->mToolBarUpV = myP.y() > height()/2;
1853 else 1851 else
1854 p->mToolBarUpV = myP.x() > width()/2 ; 1852 p->mToolBarUpV = myP.x() > width()/2 ;
1855 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1853 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1856 if ( p->mToolBarHorN ) 1854 if ( p->mToolBarHorN )
1857 p->mToolBarUpN = myP.y() > height()/2; 1855 p->mToolBarUpN = myP.y() > height()/2;
1858 else 1856 else
1859 p->mToolBarUpN = myP.x() > width()/2 ; 1857 p->mToolBarUpN = myP.x() > width()/2 ;
1860 if ( filterToolBar ) { 1858 if ( filterToolBar ) {
1861 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1859 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1862 if ( p->mToolBarHorF ) 1860 if ( p->mToolBarHorF )
1863 p->mToolBarUpF = myP.y() > height()/2; 1861 p->mToolBarUpF = myP.y() > height()/2;
1864 else 1862 else
1865 p->mToolBarUpF = myP.x() > width()/2 ; 1863 p->mToolBarUpF = myP.x() > width()/2 ;
1866 } 1864 }
1867#else 1865#else
1868 if ( p->mToolBarHor ) 1866 if ( p->mToolBarHor )
1869 p->mToolBarUp = iconToolBar->y() > height()/2; 1867 p->mToolBarUp = iconToolBar->y() > height()/2;
1870 else 1868 else
1871 p->mToolBarUp = iconToolBar->x() > width()/2; 1869 p->mToolBarUp = iconToolBar->x() > width()/2;
1872 if ( p->mToolBarHorV ) 1870 if ( p->mToolBarHorV )
1873 p->mToolBarUpV = viewToolBar->y() > height()/2; 1871 p->mToolBarUpV = viewToolBar->y() > height()/2;
1874 else 1872 else
1875 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1873 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1876 1874
1877 if ( p->mToolBarHorN ) 1875 if ( p->mToolBarHorN )
1878 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1876 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1879 else 1877 else
1880 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1878 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1881 if ( filterToolBar ) { 1879 if ( filterToolBar ) {
1882 if ( p->mToolBarHorF ) 1880 if ( p->mToolBarHorF )
1883 p->mToolBarUpF = filterToolBar->y() > height()/2; 1881 p->mToolBarUpF = filterToolBar->y() > height()/2;
1884 else 1882 else
1885 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1883 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1886 } 1884 }
1887#endif 1885#endif
1888 save(); 1886 save();
1889 mView->writeSettings(); 1887 mView->writeSettings();
1890 mView->checkSuspendAlarm(); 1888 mView->checkSuspendAlarm();
1891} 1889}
1892void MainWindow::slotModifiedChanged( bool ) 1890void MainWindow::slotModifiedChanged( bool )
1893{ 1891{
1894 if ( mBlockAtStartup ) 1892 if ( mBlockAtStartup )
1895 return; 1893 return;
1896 1894
1897 int msec; 1895 int msec;
1898 // we store the changes after 1 minute, 1896 // we store the changes after 1 minute,
1899 // and for safety reasons after 10 minutes again 1897 // and for safety reasons after 10 minutes again
1900 if ( !mSyncManager->blockSave() ) 1898 if ( !mSyncManager->blockSave() )
1901 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1899 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1902 else 1900 else
1903 msec = 1000 * 600; 1901 msec = 1000 * 600;
1904 mSaveTimer.start( msec, true ); // 1 minute 1902 mSaveTimer.start( msec, true ); // 1 minute
1905 qDebug("KO: Saving File in %d secs!", msec/1000); 1903 qDebug("KO: Saving File in %d secs!", msec/1000);
1906 mCalendarModifiedFlag = true; 1904 mCalendarModifiedFlag = true;
1907} 1905}
1908void MainWindow::saveStopTimer() 1906void MainWindow::saveStopTimer()
1909{ 1907{
1910 mSaveTimer.stop(); 1908 mSaveTimer.stop();
1911} 1909}
1912void MainWindow::backupAllFiles() 1910void MainWindow::backupAllFiles()
1913{ 1911{
1914 QDate reference ( 2000,1,1); 1912 QDate reference ( 2000,1,1);
1915 int daysTo = reference.daysTo ( QDate::currentDate() ); 1913 int daysTo = reference.daysTo ( QDate::currentDate() );
1916 setCaption(i18n("Creating backup ... please wait ..." )); 1914 setCaption(i18n("Creating backup ... please wait ..." ));
1917 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1915 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1918 // we need the file path, the backup dir and the number of bups as param 1916 // we need the file path, the backup dir and the number of bups as param
1919 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1917 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1920 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1918 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1921 bupDir = KGlobalSettings::backupDataDir(); 1919 bupDir = KGlobalSettings::backupDataDir();
1922 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1920 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1923 if ( retval == 0 ) { 1921 if ( retval == 0 ) {
1924 setCaption(i18n("Backup cancelled" )); 1922 setCaption(i18n("Backup cancelled" ));
1925 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1923 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1926 // retval == 0 : backup skipped for today, try again tomorrow 1924 // retval == 0 : backup skipped for today, try again tomorrow
1927 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1925 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1928 } else if ( retval == 1 ){ 1926 } else if ( retval == 1 ){
1929 qDebug("KO: Backup created."); 1927 qDebug("KO: Backup created.");
1930 // backup ok 1928 // backup ok
1931 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1929 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1932 KopiCalendarFile * cal = calendars.first(); 1930 KopiCalendarFile * cal = calendars.first();
1933 cal = calendars.next(); 1931 cal = calendars.next();
1934 while ( cal ) { 1932 while ( cal ) {
1935 if ( !cal->mErrorOnLoad ) { 1933 if ( !cal->mErrorOnLoad ) {
1936 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1934 KApplication::createBackup( cal->mFileName, bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1937 } 1935 }
1938 cal = calendars.next(); 1936 cal = calendars.next();
1939 } 1937 }
1940 KOPrefs::instance()->mLastBackupDate = daysTo; 1938 KOPrefs::instance()->mLastBackupDate = daysTo;
1941 setCaption(i18n("Backup succesfully finished" )); 1939 setCaption(i18n("Backup succesfully finished" ));
1942 } else if ( retval == 2 ){ 1940 } else if ( retval == 2 ){
1943 setCaption(i18n("Backup globally disabled" )); 1941 setCaption(i18n("Backup globally disabled" ));
1944 qDebug("KO: Backup globally cancelled."); 1942 qDebug("KO: Backup globally cancelled.");
1945 // backup globally cancelled 1943 // backup globally cancelled
1946 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1944 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1947 } 1945 }
1948 // retval == 3: do nothing, try again later 1946 // retval == 3: do nothing, try again later
1949} 1947}
1950void MainWindow::save() 1948void MainWindow::save()
1951{ 1949{
1952 1950
1953 if ( mView->viewManager()->journalView() ) 1951 if ( mView->viewManager()->journalView() )
1954 mView->viewManager()->journalView()->checkModified(); 1952 mView->viewManager()->journalView()->checkModified();
1955 if ( !mCalendarModifiedFlag ) { 1953 if ( !mCalendarModifiedFlag ) {
1956 qDebug("KO: Calendar not modified. Nothing saved."); 1954 qDebug("KO: Calendar not modified. Nothing saved.");
1957 return; 1955 return;
1958 } 1956 }
1959 if ( mSyncManager->blockSave() ) 1957 if ( mSyncManager->blockSave() )
1960 return; 1958 return;
1961 mSyncManager->setBlockSave(true); 1959 mSyncManager->setBlockSave(true);
1962 if ( mView->checkAllFileVersions() ) { 1960 if ( mView->checkAllFileVersions() ) {
1963 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1961 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1964 QDate reference ( 2000,1,1); 1962 QDate reference ( 2000,1,1);
1965 int daysTo = reference.daysTo ( QDate::currentDate() ); 1963 int daysTo = reference.daysTo ( QDate::currentDate() );
1966 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1964 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1967 backupAllFiles(); 1965 backupAllFiles();
1968 } 1966 }
1969 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1967 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1970 } 1968 }
1971 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1969 QTime neededSaveTime = QDateTime::currentDateTime().time();
1972 if ( !isMinimized () ) 1970 if ( !isMinimized () )
1973 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1971 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1974 qDebug("KO: Start saving data to file!"); 1972 qDebug("KO: Start saving data to file!");
1975 mView->saveCalendars(); 1973 mView->saveCalendars();
1976 mCalendarModifiedFlag = false; 1974 mCalendarModifiedFlag = false;
1977 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1975 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1978 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1976 qDebug("KO: Needed %d ms for saving.",msNeeded );
1979 QString savemes; 1977 QString savemes;
1980 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1978 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1981 if ( !isMinimized () ) 1979 if ( !isMinimized () )
1982 setCaption(savemes); 1980 setCaption(savemes);
1983 else 1981 else
1984 qDebug(savemes); 1982 qDebug(savemes);
1985 } else 1983 } else
1986 setCaption(i18n("Saving cancelled!")); 1984 setCaption(i18n("Saving cancelled!"));
1987 mSyncManager->setBlockSave( false ); 1985 mSyncManager->setBlockSave( false );
1988} 1986}
1989 1987
1990void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1988void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1991{ 1989{
1992 if ( !e->isAutoRepeat() ) { 1990 if ( !e->isAutoRepeat() ) {
1993 mFlagKeyPressed = false; 1991 mFlagKeyPressed = false;
1994 } 1992 }
1995} 1993}
1996void MainWindow::keyPressEvent ( QKeyEvent * e ) 1994void MainWindow::keyPressEvent ( QKeyEvent * e )
1997{ 1995{
1998 qApp->processEvents(); 1996 qApp->processEvents();
1999 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1997 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
2000 e->ignore(); 1998 e->ignore();
2001 // qDebug(" ignore %d",e->isAutoRepeat() ); 1999 // qDebug(" ignore %d",e->isAutoRepeat() );
2002 return; 2000 return;
2003 } 2001 }
2004 if (! e->isAutoRepeat() ) 2002 if (! e->isAutoRepeat() )
2005 mFlagKeyPressed = true; 2003 mFlagKeyPressed = true;
2006 KOPrefs *p = KOPrefs::instance(); 2004 KOPrefs *p = KOPrefs::instance();
2007 bool showSelectedDates = false; 2005 bool showSelectedDates = false;
2008 int size; 2006 int size;
2009 int pro = 0; 2007 int pro = 0;
2010 //qDebug("MainWindow::keyPressEvent "); 2008 //qDebug("MainWindow::keyPressEvent ");
2011 switch ( e->key() ) { 2009 switch ( e->key() ) {
2012 case Qt::Key_Right: 2010 case Qt::Key_Right:
2013 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2011 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2014 mView->goNextMonth(); 2012 mView->goNextMonth();
2015 else 2013 else
2016 mView->goNext(); 2014 mView->goNext();
2017 showSelectedDates = true; 2015 showSelectedDates = true;
2018 break; 2016 break;
2019 case Qt::Key_Left: 2017 case Qt::Key_Left:
2020 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2018 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2021 mView->goPreviousMonth(); 2019 mView->goPreviousMonth();
2022 else 2020 else
2023 mView->goPrevious(); 2021 mView->goPrevious();
2024 showSelectedDates = true; 2022 showSelectedDates = true;
2025 break; 2023 break;
2026 case Qt::Key_Down: 2024 case Qt::Key_Down:
2027 mView->viewManager()->agendaView()->scrollOneHourDown(); 2025 mView->viewManager()->agendaView()->scrollOneHourDown();
2028 break; 2026 break;
2029 case Qt::Key_Up: 2027 case Qt::Key_Up:
2030 mView->viewManager()->agendaView()->scrollOneHourUp(); 2028 mView->viewManager()->agendaView()->scrollOneHourUp();
2031 break; 2029 break;
2032 case Qt::Key_K: 2030 case Qt::Key_K:
2033 mView->viewManager()->showMonthViewWeek(); 2031 mView->viewManager()->showMonthViewWeek();
2034 break; 2032 break;
2035 case Qt::Key_I: 2033 case Qt::Key_I:
2036 mView->showIncidence(); 2034 mView->showIncidence();
2037 break; 2035 break;
2038 case Qt::Key_Delete: 2036 case Qt::Key_Delete:
2039 case Qt::Key_Backspace: 2037 case Qt::Key_Backspace:
2040 mView->deleteIncidence(); 2038 mView->deleteIncidence();
2041 break; 2039 break;
2042 case Qt::Key_D: 2040 case Qt::Key_D:
2043 mView->viewManager()->showDayView(); 2041 mView->viewManager()->showDayView();
2044 showSelectedDates = true; 2042 showSelectedDates = true;
2045 break; 2043 break;
2046 case Qt::Key_O: 2044 case Qt::Key_O:
2047 mView->toggleFilerEnabled( ); 2045 mView->toggleFilerEnabled( );
2048 break; 2046 break;
2049 case Qt::Key_0: 2047 case Qt::Key_0:
2050 case Qt::Key_1: 2048 case Qt::Key_1:
2051 case Qt::Key_2: 2049 case Qt::Key_2:
2052 case Qt::Key_3: 2050 case Qt::Key_3:
2053 case Qt::Key_4: 2051 case Qt::Key_4:
2054 case Qt::Key_5: 2052 case Qt::Key_5:
2055 case Qt::Key_6: 2053 case Qt::Key_6:
2056 case Qt::Key_7: 2054 case Qt::Key_7:
2057 case Qt::Key_8: 2055 case Qt::Key_8:
2058 case Qt::Key_9: 2056 case Qt::Key_9:
2059 pro = e->key()-48; 2057 pro = e->key()-48;
2060 if ( pro == 0 ) 2058 if ( pro == 0 )
2061 pro = 10; 2059 pro = 10;
2062 if ( e->state() == Qt::ControlButton) 2060 if ( e->state() == Qt::ControlButton)
2063 pro += 10; 2061 pro += 10;
2064 break; 2062 break;
2065 case Qt::Key_M: 2063 case Qt::Key_M:
2066 mView->viewManager()->showMonthView(); 2064 mView->viewManager()->showMonthView();
2067 showSelectedDates = true; 2065 showSelectedDates = true;
2068 break; 2066 break;
2069 case Qt::Key_Insert: 2067 case Qt::Key_Insert:
2070 mView->newEvent(); 2068 mView->newEvent();
2071 break; 2069 break;
2072 case Qt::Key_S : 2070 case Qt::Key_S :
2073 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 2071 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
2074 mView->newSubTodo(); 2072 mView->newSubTodo();
2075 else 2073 else
2076 mView->dialogManager()->showSearchDialog(); 2074 mView->dialogManager()->showSearchDialog();
2077 break; 2075 break;
2078 case Qt::Key_Y : 2076 case Qt::Key_Y :
2079 case Qt::Key_Z : 2077 case Qt::Key_Z :
2080 mView->viewManager()->showWorkWeekView(); 2078 mView->viewManager()->showWorkWeekView();
2081 showSelectedDates = true; 2079 showSelectedDates = true;
2082 break; 2080 break;
2083 case Qt::Key_U : 2081 case Qt::Key_U :
2084 mView->viewManager()->showWeekView(); 2082 mView->viewManager()->showWeekView();
2085 showSelectedDates = true; 2083 showSelectedDates = true;
2086 break; 2084 break;
2087 case Qt::Key_H : 2085 case Qt::Key_H :
2088 keyBindings(); 2086 keyBindings();
2089 break; 2087 break;
2090 case Qt::Key_W: 2088 case Qt::Key_W:
2091 mView->viewManager()->showWhatsNextView(); 2089 mView->viewManager()->showWhatsNextView();
2092 break; 2090 break;
2093 case Qt::Key_L: 2091 case Qt::Key_L:
2094 mView->viewManager()->showListView(); 2092 mView->viewManager()->showListView();
2095 break; 2093 break;
2096 case Qt::Key_N: 2094 case Qt::Key_N:
2097 mView->viewManager()->showNextView(); 2095 mView->viewManager()->showNextView();
2098 break; 2096 break;
2099 case Qt::Key_V: 2097 case Qt::Key_V:
2100 mView->viewManager()->showTodoView(); 2098 mView->viewManager()->showTodoView();
2101 break; 2099 break;
2102 case Qt::Key_C: 2100 case Qt::Key_C:
2103 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 2101 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
2104 break; 2102 break;
2105 case Qt::Key_P: 2103 case Qt::Key_P:
2106 mView->showDatePicker( ); 2104 mView->showDatePicker( );
2107 break; 2105 break;
2108 case Qt::Key_F: 2106 case Qt::Key_F:
2109 mView->editFilters(); 2107 mView->editFilters();
2110 break; 2108 break;
2111 case Qt::Key_R: 2109 case Qt::Key_R:
2112 mView->toggleFilter(); 2110 mView->toggleFilter();
2113 break; 2111 break;
2114 case Qt::Key_X: 2112 case Qt::Key_X:
2115 if ( e->state() == Qt::ControlButton ) 2113 if ( e->state() == Qt::ControlButton )
2116 mView->toggleDateNavigatorWidget(); 2114 mView->toggleDateNavigatorWidget();
2117 else { 2115 else {
2118 mView->viewManager()->showNextXView(); 2116 mView->viewManager()->showNextXView();
2119 showSelectedDates = true; 2117 showSelectedDates = true;
2120 } 2118 }
2121 break; 2119 break;
2122 case Qt::Key_Space: 2120 case Qt::Key_Space:
2123 mView->toggleExpand(); 2121 mView->toggleExpand();
2124 break; 2122 break;
2125 case Qt::Key_A: 2123 case Qt::Key_A:
2126 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2124 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2127 mView->showNextAlarms(); 2125 mView->showNextAlarms();
2128 else 2126 else
2129 mView->toggleAllDaySize(); 2127 mView->toggleAllDaySize();
2130 break; 2128 break;
2131 case Qt::Key_T: 2129 case Qt::Key_T:
2132 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2130 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2133 mView->newTodo(); 2131 mView->newTodo();
2134 else { 2132 else {
2135 mView->goToday(); 2133 mView->goToday();
2136 showSelectedDates = true; 2134 showSelectedDates = true;
2137 } 2135 }
2138 break; 2136 break;
2139 case Qt::Key_Q: 2137 case Qt::Key_Q:
2140 if ( e->state() == Qt::ControlButton ) 2138 if ( e->state() == Qt::ControlButton )
2141 mView->conflictNotAll(); 2139 mView->conflictNotAll();
2142 else if ( e->state() == Qt::ShiftButton ) 2140 else if ( e->state() == Qt::ShiftButton )
2143 mView->conflictAllday(); 2141 mView->conflictAllday();
2144 else 2142 else
2145 mView->conflictAll(); 2143 mView->conflictAll();
2146 break; 2144 break;
2147 case Qt::Key_J: 2145 case Qt::Key_J:
2148 mView->viewManager()->showJournalView(); 2146 mView->viewManager()->showJournalView();
2149 break; 2147 break;
2150 case Qt::Key_B: 2148 case Qt::Key_B:
2151 mView->editIncidenceDescription();; 2149 mView->editIncidenceDescription();;
2152 break; 2150 break;
2153 // case Qt::Key_Return: 2151 // case Qt::Key_Return:
2154 case Qt::Key_E: 2152 case Qt::Key_E:
2155 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2153 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2156 mView->newEvent(); 2154 mView->newEvent();
2157 else 2155 else
2158 mView->editIncidence(); 2156 mView->editIncidence();
2159 break; 2157 break;
2160 case Qt::Key_Plus: 2158 case Qt::Key_Plus:
2161 size = p->mHourSize +2; 2159 size = p->mHourSize +2;
2162 if ( size <= 22 ) 2160 if ( size <= 22 )
2163 configureAgenda( size ); 2161 configureAgenda( size );
2164 break; 2162 break;
2165 case Qt::Key_Minus: 2163 case Qt::Key_Minus:
2166 size = p->mHourSize - 2; 2164 size = p->mHourSize - 2;
2167 if ( size >= 4 ) 2165 if ( size >= 4 )
2168 configureAgenda( size ); 2166 configureAgenda( size );
2169 break; 2167 break;
2170 2168
2171 2169
2172 default: 2170 default:
2173 e->ignore(); 2171 e->ignore();
2174 } 2172 }
2175 if ( pro > 0 ) { 2173 if ( pro > 0 ) {
2176 selectFilter( pro+1 ); 2174 selectFilter( pro+1 );
2177 } 2175 }
2178 if ( showSelectedDates ) { 2176 if ( showSelectedDates ) {
2179 ;// setCaptionToDates(); 2177 ;// setCaptionToDates();
2180 } 2178 }
2181 2179
2182} 2180}
2183void MainWindow::fillFilterMenuTB() 2181void MainWindow::fillFilterMenuTB()
2184{ 2182{
2185 selectFilterMenuTB->clear(); 2183 selectFilterMenuTB->clear();
2186 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2184 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2187 selectFilterMenuTB->insertSeparator(); 2185 selectFilterMenuTB->insertSeparator();
2188 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2186 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2189 2187
2190 selectFilterMenuTB->insertSeparator(); 2188 selectFilterMenuTB->insertSeparator();
2191 QPtrList<CalFilter> fili = mView->filters(); 2189 QPtrList<CalFilter> fili = mView->filters();
2192 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2190 CalFilter *curfilter = mView->filterView()->selectedFilter();
2193 CalFilter *filter = fili.first(); 2191 CalFilter *filter = fili.first();
2194 int iii = 2; 2192 int iii = 2;
2195 bool checkitem = mView->filterView()->filtersEnabled(); 2193 bool checkitem = mView->filterView()->filtersEnabled();
2196 while(filter) { 2194 while(filter) {
2197 selectFilterMenuTB->insertItem( filter->name(), iii ); 2195 selectFilterMenuTB->insertItem( filter->name(), iii );
2198 if ( filter == curfilter) 2196 if ( filter == curfilter)
2199 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2197 selectFilterMenuTB->setItemChecked( iii, checkitem );
2200 filter = fili.next(); 2198 filter = fili.next();
2201 ++iii; 2199 ++iii;
2202 } 2200 }
2203 if ( !checkitem ) 2201 if ( !checkitem )
2204 selectFilterMenuTB->setItemChecked( 1, true ); 2202 selectFilterMenuTB->setItemChecked( 1, true );
2205 2203
2206 int x = 0; 2204 int x = 0;
2207 int y = iconToolBar->height(); 2205 int y = iconToolBar->height();
2208 int dX = 0; 2206 int dX = 0;
2209 int dY = 0; 2207 int dY = 0;
2210 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2208 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2211 if ( iconToolBar->y() > height()/2 ) { 2209 if ( iconToolBar->y() > height()/2 ) {
2212 dY = selectFilterMenuTB->sizeHint().height()+8; 2210 dY = selectFilterMenuTB->sizeHint().height()+8;
2213 y = 0; 2211 y = 0;
2214 } 2212 }
2215 } else { 2213 } else {
2216 if ( iconToolBar->x() > width()/2 ) { // right side 2214 if ( iconToolBar->x() > width()/2 ) { // right side
2217 x=0; 2215 x=0;
2218 dX= selectFilterMenuTB->sizeHint().width()+8; 2216 dX= selectFilterMenuTB->sizeHint().width()+8;
2219 y = 0; 2217 y = 0;
2220 } else { 2218 } else {
2221 x= iconToolBar->width(); 2219 x= iconToolBar->width();
2222 y = 0; 2220 y = 0;
2223 } 2221 }
2224 } 2222 }
2225 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2223 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2226 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2224 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2227} 2225}
2228void MainWindow::fillFilterMenu() 2226void MainWindow::fillFilterMenu()
2229{ 2227{
2230 selectFilterMenu->clear(); 2228 selectFilterMenu->clear();
2231 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2229 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2232 selectFilterMenu->insertSeparator(); 2230 selectFilterMenu->insertSeparator();
2233 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2231 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2234 2232
2235 selectFilterMenu->insertSeparator(); 2233 selectFilterMenu->insertSeparator();
2236 QPtrList<CalFilter> fili = mView->filters(); 2234 QPtrList<CalFilter> fili = mView->filters();
2237 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2235 CalFilter *curfilter = mView->filterView()->selectedFilter();
2238 CalFilter *filter = fili.first(); 2236 CalFilter *filter = fili.first();
2239 int iii = 2; 2237 int iii = 2;
2240 bool checkitem = mView->filterView()->filtersEnabled(); 2238 bool checkitem = mView->filterView()->filtersEnabled();
2241 while(filter) { 2239 while(filter) {
2242 selectFilterMenu->insertItem( filter->name(), iii ); 2240 selectFilterMenu->insertItem( filter->name(), iii );
2243 if ( filter == curfilter) 2241 if ( filter == curfilter)
2244 selectFilterMenu->setItemChecked( iii, checkitem ); 2242 selectFilterMenu->setItemChecked( iii, checkitem );
2245 filter = fili.next(); 2243 filter = fili.next();
2246 ++iii; 2244 ++iii;
2247 } 2245 }
2248 if ( !checkitem ) 2246 if ( !checkitem )
2249 selectFilterMenu->setItemChecked( 1, true ); 2247 selectFilterMenu->setItemChecked( 1, true );
2250} 2248}
2251void MainWindow::fillFilterMenuPopup() 2249void MainWindow::fillFilterMenuPopup()
2252{ 2250{
2253 filterPopupMenu->clear(); 2251 filterPopupMenu->clear();
2254 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2252 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2255 2253
2256 filterPopupMenu->insertSeparator(); 2254 filterPopupMenu->insertSeparator();
2257 QPtrList<CalFilter> fili = mView->filters(); 2255 QPtrList<CalFilter> fili = mView->filters();
2258 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2256 CalFilter *curfilter = mView->filterView()->selectedFilter();
2259 CalFilter *filter = fili.first(); 2257 CalFilter *filter = fili.first();
2260 int iii = 1; 2258 int iii = 1;
2261 bool checkitem = mView->filterView()->filtersEnabled(); 2259 bool checkitem = mView->filterView()->filtersEnabled();
2262 while(filter) { 2260 while(filter) {
2263 filterPopupMenu->insertItem( filter->name(), iii ); 2261 filterPopupMenu->insertItem( filter->name(), iii );
2264 if ( filter == curfilter) 2262 if ( filter == curfilter)
2265 filterPopupMenu->setItemChecked( iii, checkitem ); 2263 filterPopupMenu->setItemChecked( iii, checkitem );
2266 filter = fili.next(); 2264 filter = fili.next();
2267 ++iii; 2265 ++iii;
2268 } 2266 }
2269 if ( !checkitem ) 2267 if ( !checkitem )
2270 filterPopupMenu->setItemChecked( 0, true ); 2268 filterPopupMenu->setItemChecked( 0, true );
2271} 2269}
2272void MainWindow::selectFilter( int fil ) 2270void MainWindow::selectFilter( int fil )
2273{ 2271{
2274 2272
2275 if ( fil == 0 ) { 2273 if ( fil == 0 ) {
2276 mView->editFilters( ); 2274 mView->editFilters( );
2277 } else if ( fil == 1 ){ 2275 } else if ( fil == 1 ){
2278 if ( mView->filterView()->filtersEnabled() ) 2276 if ( mView->filterView()->filtersEnabled() )
2279 mView->toggleFilerEnabled( ); 2277 mView->toggleFilerEnabled( );
2280 } else { 2278 } else {
2281 if ( !mView->filterView()->filtersEnabled() ) { 2279 if ( !mView->filterView()->filtersEnabled() ) {
2282 mView->filterView()->blockSignals( true ); 2280 mView->filterView()->blockSignals( true );
2283 mView->toggleFilerEnabled( ); 2281 mView->toggleFilerEnabled( );
2284 mView->filterView()->blockSignals( false ); 2282 mView->filterView()->blockSignals( false );
2285 } 2283 }
2286 mView->selectFilter( fil-2 ); 2284 mView->selectFilter( fil-2 );
2287 } 2285 }
2288} 2286}
2289void MainWindow::updateFilterToolbar() 2287void MainWindow::updateFilterToolbar()
2290{ 2288{
2291 if ( filterMenubar ) { 2289 if ( filterMenubar ) {
2292 if ( !mView->filterView()->filtersEnabled() ) { 2290 if ( !mView->filterView()->filtersEnabled() ) {
2293 filterMenubar->changeItem( 0, i18n("No Filter") ); 2291 filterMenubar->changeItem( 0, i18n("No Filter") );
2294 } else { 2292 } else {
2295 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2293 CalFilter *curfilter = mView->filterView()->selectedFilter();
2296 if ( curfilter ) { 2294 if ( curfilter ) {
2297 filterMenubar->changeItem( 0, curfilter->name() ); 2295 filterMenubar->changeItem( 0, curfilter->name() );
2298 } 2296 }
2299 } 2297 }
2300 } 2298 }
2301} 2299}
2302void MainWindow::selectFilterPopup( int fil ) 2300void MainWindow::selectFilterPopup( int fil )
2303{ 2301{
2304 selectFilter( fil + 1 ); 2302 selectFilter( fil + 1 );
2305 2303
2306} 2304}
2307void MainWindow::configureToolBar( int item ) 2305void MainWindow::configureToolBar( int item )
2308{ 2306{
2309 2307
2310 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2308 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2311 KOPrefs *p = KOPrefs::instance(); 2309 KOPrefs *p = KOPrefs::instance();
2312 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2310 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2313 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2311 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2314 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2312 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2315 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2313 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2316 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2314 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2317 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2315 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2318 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2316 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2319 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2317 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2320 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2318 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2321 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2319 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2322 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2320 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2323 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2321 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2324 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2322 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2325 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2323 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2326 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2324 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2327 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2325 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2328 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2326 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2329 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2327 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2330 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2328 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2331 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2329 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2332 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2330 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2333 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2331 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2334 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2332 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2335 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2333 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2336 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2334 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2337 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2335 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2338 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2336 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2339 // initActions(); 2337 // initActions();
2340 setCaption ( i18n("Toolbar changes needs a restart!") ); 2338 setCaption ( i18n("Toolbar changes needs a restart!") );
2341} 2339}
2342void MainWindow::setCaption ( const QString & c ) 2340void MainWindow::setCaption ( const QString & c )
2343{ 2341{
2344 QString cap = c; 2342 QString cap = c;
2345 cap.replace( QRegExp("\n"), " " ); 2343 cap.replace( QRegExp("\n"), " " );
2346 cap = cap.stripWhiteSpace(); 2344 cap = cap.stripWhiteSpace();
2347 if ( cap.isEmpty() ) 2345 if ( cap.isEmpty() )
2348 cap = "KO/Pi"; 2346 cap = "KO/Pi";
2349 QWidget::setCaption( cap ); 2347 QWidget::setCaption( cap );
2350} 2348}
2351void MainWindow::setCaptionToDates() 2349void MainWindow::setCaptionToDates()
2352{ 2350{
2353 QString selDates; 2351 QString selDates;
2354 QDate date = mView->startDate(); 2352 QDate date = mView->startDate();
2355 if ( ! date.isValid() ) { 2353 if ( ! date.isValid() ) {
2356 setCaption(""); 2354 setCaption("");
2357 return; 2355 return;
2358 } 2356 }
2359 selDates = KGlobal::locale()->formatDate( date, true); 2357 selDates = KGlobal::locale()->formatDate( date, true);
2360 if (mView->startDate() < mView->endDate() ) 2358 if (mView->startDate() < mView->endDate() )
2361 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2359 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2362 else { 2360 else {
2363 QString addString; 2361 QString addString;
2364 if ( date == QDateTime::currentDateTime().date() ) 2362 if ( date == QDateTime::currentDateTime().date() )
2365 addString = i18n("Today"); 2363 addString = i18n("Today");
2366 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2364 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2367 addString = i18n("Tomorrow"); 2365 addString = i18n("Tomorrow");
2368 if ( !addString.isEmpty() ) 2366 if ( !addString.isEmpty() )
2369 selDates = addString+", "+selDates ; 2367 selDates = addString+", "+selDates ;
2370 } 2368 }
2371 setCaption( i18n("Dates: ") + selDates ); 2369 setCaption( i18n("Dates: ") + selDates );
2372 2370
2373} 2371}
2374void MainWindow::showConfigureAgenda( ) 2372void MainWindow::showConfigureAgenda( )
2375{ 2373{
2376 int iii; 2374 int iii;
2377 for ( iii = 1;iii<= 10 ;++iii ){ 2375 for ( iii = 1;iii<= 10 ;++iii ){
2378 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2376 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2379 } 2377 }
2380 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2378 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2381} 2379}
2382void MainWindow::configureAgenda( int item ) 2380void MainWindow::configureAgenda( int item )
2383{ 2381{
2384 if ( KOPrefs::instance()->mHourSize == item ) 2382 if ( KOPrefs::instance()->mHourSize == item )
2385 return; 2383 return;
2386 KOPrefs::instance()->mHourSize=item; 2384 KOPrefs::instance()->mHourSize=item;
2387 mView->viewManager()->agendaView()->updateConfig(); 2385 mView->viewManager()->agendaView()->updateConfig();
2388} 2386}
2389 2387
2390void MainWindow::saveCalendar() 2388void MainWindow::saveCalendar()
2391{ 2389{
2392 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 2390 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
2393 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 2391 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
2394 bupDir = KGlobalSettings::backupDataDir(); 2392 bupDir = KGlobalSettings::backupDataDir();
2395 bupDir = KGlobal::formatMessage ( bupDir, 0 ); 2393 bupDir = KGlobal::formatMessage ( bupDir, 0 );
2396 QString bupHint; 2394 QString bupHint;
2397 if ( !KPimGlobalPrefs::instance()->mBackupEnabled ) 2395 if ( !KPimGlobalPrefs::instance()->mBackupEnabled )
2398 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)"); 2396 bupHint = i18n("(Hint: You can enable automatic backup in the global settings!)");
2399 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return; 2397 if ( KMessageBox::warningContinueCancel( this, i18n("This will <b>backup all calendar files</b> to the directory %1 %2").arg(bupDir).arg(bupHint),i18n("Information") ) != KMessageBox::Continue ) return;
2400 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled; 2398 bool enabled = KPimGlobalPrefs::instance()->mBackupEnabled;
2401 KPimGlobalPrefs::instance()->mBackupEnabled = false; 2399 KPimGlobalPrefs::instance()->mBackupEnabled = false;
2402 save(); 2400 save();
2403 KPimGlobalPrefs::instance()->mBackupEnabled = enabled; 2401 KPimGlobalPrefs::instance()->mBackupEnabled = enabled;
2404 backupAllFiles(); 2402 backupAllFiles();
2405} 2403}
2406void MainWindow::loadCalendar() 2404void MainWindow::loadCalendar()
2407{ 2405{
2408 2406
2409 2407
2410#if 0 2408#if 0
2411 QString fn = KOPrefs::instance()->mLastLoadFile; 2409 QString fn = KOPrefs::instance()->mLastLoadFile;
2412 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2410 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2413 2411
2414 if ( fn == "" ) 2412 if ( fn == "" )
2415 return; 2413 return;
2416 QFileInfo info; 2414 QFileInfo info;
2417 info.setFile( fn ); 2415 info.setFile( fn );
2418 QString mess; 2416 QString mess;
2419 bool loadbup = true; 2417 bool loadbup = true;
2420 if ( info. exists() ) { 2418 if ( info. exists() ) {
2421 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2419 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2422 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2420 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2423 mess, 2421 mess,
2424 i18n("Load!"), i18n("Cancel"), 0, 2422 i18n("Load!"), i18n("Cancel"), 0,
2425 0, 1 ); 2423 0, 1 );
2426 if ( result != 0 ) { 2424 if ( result != 0 ) {
2427 loadbup = false; 2425 loadbup = false;
2428 } 2426 }
2429 } else { 2427 } else {
2430 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2428 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2431 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2429 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2432 0, 1 ); 2430 0, 1 );
2433 2431
2434 return; 2432 return;
2435 } 2433 }
2436 if ( loadbup ) { 2434 if ( loadbup ) {
2437 mView->openCalendar( fn ); 2435 mView->openCalendar( fn );
2438 KOPrefs::instance()->mLastLoadFile = fn; 2436 KOPrefs::instance()->mLastLoadFile = fn;
2439 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2437 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2440 setCaption(mess); 2438 setCaption(mess);
2441 } 2439 }
2442#endif 2440#endif
2443 2441
2444} 2442}
2445void MainWindow::quickImportIcal() 2443void MainWindow::quickImportIcal()
2446{ 2444{
2447 importFile( KOPrefs::instance()->mLastImportFile, false ); 2445 importFile( KOPrefs::instance()->mLastImportFile, false );
2448} 2446}
2449void MainWindow::importFile( QString fn, bool quick ) 2447void MainWindow::importFile( QString fn, bool quick )
2450{ 2448{
2451 QFileInfo info; 2449 QFileInfo info;
2452 info.setFile( fn ); 2450 info.setFile( fn );
2453 QString mess; 2451 QString mess;
2454 if ( !info. exists() ) { 2452 if ( !info. exists() ) {
2455 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2453 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2456 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2454 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2457 mess ); 2455 mess );
2458 return; 2456 return;
2459 } 2457 }
2460 int result = 0; 2458 int result = 0;
2461 if ( !quick ) { 2459 if ( !quick ) {
2462 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 )); 2460 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 ));
2463 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2461 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2464 mess, 2462 mess,
2465 "Import", "Cancel", 0, 2463 "Import", "Cancel", 0,
2466 0, 1 ); 2464 0, 1 );
2467 } 2465 }
2468 if ( result == 0 ) { 2466 if ( result == 0 ) {
2469 if ( mView->openCalendar( fn, true )) { 2467 if ( mView->openCalendar( fn, true )) {
2470 KOPrefs::instance()->mLastImportFile = fn; 2468 KOPrefs::instance()->mLastImportFile = fn;
2471 setCaption(i18n("Imported file successfully")); 2469 setCaption(i18n("Imported file successfully"));
2472 } else { 2470 } else {
2473 setCaption(i18n("Error importing file")); 2471 setCaption(i18n("Error importing file"));
2474 } 2472 }
2475 } 2473 }
2476} 2474}
2477 2475
2478void MainWindow::importIcal() 2476void MainWindow::importIcal()
2479{ 2477{
2480 2478
2481 QString fn =KOPrefs::instance()->mLastImportFile; 2479 QString fn =KOPrefs::instance()->mLastImportFile;
2482 2480
2483 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2481 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2484 if ( fn == "" ) 2482 if ( fn == "" )
2485 return; 2483 return;
2486 importFile( fn, true ); 2484 importFile( fn, true );
2487 2485
2488} 2486}
2489 2487
2490void MainWindow::exportVCalendar() 2488void MainWindow::exportVCalendar()
2491{ 2489{
2492 QString fn = KOPrefs::instance()->mLastVcalFile; 2490 QString fn = KOPrefs::instance()->mLastVcalFile;
2493 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2491 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2494 if ( fn == "" ) 2492 if ( fn == "" )
2495 return; 2493 return;
2496 QFileInfo info; 2494 QFileInfo info;
2497 info.setFile( fn ); 2495 info.setFile( fn );
2498 QString mes; 2496 QString mes;
2499 bool createbup = true; 2497 bool createbup = true;
2500 if ( info. exists() ) { 2498 if ( info. exists() ) {
2501 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2499 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2502 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2500 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2503 i18n("Overwrite!"), i18n("Cancel"), 0, 2501 i18n("Overwrite!"), i18n("Cancel"), 0,
2504 0, 1 ); 2502 0, 1 );
2505 if ( result != 0 ) { 2503 if ( result != 0 ) {
2506 createbup = false; 2504 createbup = false;
2507 } 2505 }
2508 } 2506 }
2509 if ( createbup ) { 2507 if ( createbup ) {
2510 if ( mView->exportVCalendar( fn ) ) { 2508 if ( mView->exportVCalendar( fn ) ) {
2511 KOPrefs::instance()->mLastVcalFile = fn; 2509 KOPrefs::instance()->mLastVcalFile = fn;
2512 if ( fn.length() > 20 ) 2510 if ( fn.length() > 20 )
2513 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2511 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2514 else 2512 else
2515 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2513 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2516 setCaption(mes); 2514 setCaption(mes);
2517 } 2515 }
2518 } 2516 }
2519 2517
2520} 2518}
2521QString MainWindow::sentSyncFile() 2519QString MainWindow::sentSyncFile()
2522{ 2520{
2523#ifdef DESKTOP_VERSION 2521#ifdef DESKTOP_VERSION
2524 return locateLocal( "tmp", "copysynccal.ics" ); 2522 return locateLocal( "tmp", "copysynccal.ics" );
2525#else 2523#else
2526 return QString( "/tmp/copysynccal.ics" ); 2524 return QString( "/tmp/copysynccal.ics" );
2527#endif 2525#endif
2528} 2526}
2529 2527
2530void MainWindow::syncFileRequest() 2528void MainWindow::syncFileRequest()
2531{ 2529{
2532 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2530 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2533 mSyncManager->slotSyncMenu( 999 ); 2531 mSyncManager->slotSyncMenu( 999 );
2534 } 2532 }
2535 2533
2536 setCaption(i18n("Saving Data to temp file ..." )); 2534 setCaption(i18n("Saving Data to temp file ..." ));
2537 mView->saveCalendar( sentSyncFile() ); 2535 mView->saveCalendar( sentSyncFile() );
2538 setCaption(i18n("Data saved to temp file!" )); 2536 setCaption(i18n("Data saved to temp file!" ));
2539 2537
2540} 2538}
2541void MainWindow::getFile( bool success ) 2539void MainWindow::getFile( bool success )
2542{ 2540{
2543 if ( ! success ) { 2541 if ( ! success ) {
2544 setCaption( i18n("Error receiving file. Nothing changed!") ); 2542 setCaption( i18n("Error receiving file. Nothing changed!") );
2545 return; 2543 return;
2546 } 2544 }
2547 mView->mergeFile( sentSyncFile() ); 2545 mView->mergeFile( sentSyncFile() );
2548 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2546 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2549 mSyncManager->slotSyncMenu( 999 ); 2547 mSyncManager->slotSyncMenu( 999 );
2550 } 2548 }
2551 setCaption( i18n("Pi-Sync successful!") ); 2549 setCaption( i18n("Pi-Sync successful!") );
2552} 2550}
2553void MainWindow::printListView() 2551void MainWindow::printListView()
2554{ 2552{
2555 2553
2556 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2554 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2557 2555
2558 KMessageBox::information( this, message); 2556 KMessageBox::information( this, message);
2559} 2557}
2560void MainWindow::printSel( ) 2558void MainWindow::printSel( )
2561{ 2559{
2562 mView->viewManager()->agendaView()->agenda()->printSelection(); 2560 mView->viewManager()->agendaView()->agenda()->printSelection();
2563} 2561}
2564 2562
2565void MainWindow::printCal() 2563void MainWindow::printCal()
2566{ 2564{
2567 mView->print();//mCp->showDialog(); 2565 mView->print();//mCp->showDialog();
2568} 2566}
2569 2567
2570 2568
2571#include "libkdepim/kdatepicker.h" 2569#include "libkdepim/kdatepicker.h"
2572#include <kdatetbl.h> 2570#include <kdatetbl.h>
2573 2571
2574void MainWindow::weekAction() 2572void MainWindow::weekAction()
2575{ 2573{
2576 int month; 2574 int month;
2577 KPopupFrame* popup = new KPopupFrame(this); 2575 KPopupFrame* popup = new KPopupFrame(this);
2578 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2576 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2579 // ----- 2577 // -----
2580 picker->resize(picker->sizeHint()); 2578 picker->resize(picker->sizeHint());
2581 popup->setMainWidget(picker); 2579 popup->setMainWidget(picker);
2582 picker->setFocus(); 2580 picker->setFocus();
2583 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2581 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2584 int x = 0; 2582 int x = 0;
2585 int y = iconToolBar->height(); 2583 int y = iconToolBar->height();
2586 int dX = 0; 2584 int dX = 0;
2587 int dY = 0; 2585 int dY = 0;
2588 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2586 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2589 if ( iconToolBar->y() > height()/2 ) { 2587 if ( iconToolBar->y() > height()/2 ) {
2590 dY = picker->sizeHint().height()+8; 2588 dY = picker->sizeHint().height()+8;
2591 y = 0; 2589 y = 0;
2592 } 2590 }
2593 } else { 2591 } else {
2594 if ( iconToolBar->x() > width()/2 ) { // right side 2592 if ( iconToolBar->x() > width()/2 ) { // right side
2595 x=0; 2593 x=0;
2596 dX= picker->sizeHint().width()+8; 2594 dX= picker->sizeHint().width()+8;
2597 y = 0; 2595 y = 0;
2598 } else { 2596 } else {
2599 x= iconToolBar->width(); 2597 x= iconToolBar->width();
2600 y = 0; 2598 y = 0;
2601 } 2599 }
2602 } 2600 }
2603 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2601 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2604 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2602 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2605 { 2603 {
2606 month = picker->getResult(); 2604 month = picker->getResult();
2607 emit selectWeek ( month ); 2605 emit selectWeek ( month );
2608 //qDebug("weekSelected %d ", month); 2606 //qDebug("weekSelected %d ", month);
2609 } 2607 }
2610 delete popup; 2608 delete popup;
2611} 2609}
2612 2610
2613void MainWindow::hideEvent ( QHideEvent * ) 2611void MainWindow::hideEvent ( QHideEvent * )
2614{ 2612{
2615 QString message; 2613 QString message;
2616 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2614 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2617 if ( nextA.isValid() ) { 2615 if ( nextA.isValid() ) {
2618 QString sum = mCalendar->nextSummary(); 2616 QString sum = mCalendar->nextSummary();
2619 2617
2620 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)); 2618 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));
2621 setCaption( message ); 2619 setCaption( message );
2622 } 2620 }
2623} 2621}
2624 2622
2625void MainWindow::resizeEvent( QResizeEvent* e) 2623void MainWindow::resizeEvent( QResizeEvent* e)
2626{ 2624{
2627#ifndef DESKTOP_VERSION 2625#ifndef DESKTOP_VERSION
2628 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2626 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2629 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2627 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2630 filterToolBar->hide(); 2628 filterToolBar->hide();
2631 else 2629 else
2632 filterToolBar->show(); 2630 filterToolBar->show();
2633 } 2631 }
2634#endif 2632#endif
2635 QMainWindow::resizeEvent( e); 2633 QMainWindow::resizeEvent( e);
2636} 2634}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d648f14..e2de3ba 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,174 +1,173 @@
1#ifndef KORGE_MAINWINDOW_H 1#ifndef KORGE_MAINWINDOW_H
2#define KORGE_MAINWINDOW_H 2#define KORGE_MAINWINDOW_H
3 3
4#include <qmainwindow.h> 4#include <qmainwindow.h>
5#include <qtimer.h> 5#include <qtimer.h>
6#include <qdict.h> 6#include <qdict.h>
7#include <qfile.h> 7#include <qfile.h>
8#include <qmenubar.h> 8#include <qmenubar.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qregexp.h> 10#include <qregexp.h>
11 11
12#include <libkcal/incidence.h> 12#include <libkcal/incidence.h>
13#include <ksyncmanager.h> 13#include <ksyncmanager.h>
14#include <kpopupmenu.h>
14#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
15#include <qcopchannel_qws.h> 16#include <qcopchannel_qws.h>
16#endif 17#endif
17class QAction; 18class QAction;
18class CalendarView; 19class CalendarView;
19class KSyncProfile; 20class KSyncProfile;
20#ifdef DESKTOP_VERSION 21#ifdef DESKTOP_VERSION
21 22
22#define QPEToolBar QToolBar 23#define QPEToolBar QToolBar
23#define QPEMenuBar QMenuBar
24#endif 24#endif
25class QPEToolBar; 25class QPEToolBar;
26class QPEMenuBar;
27 26
28 27
29namespace KCal { 28namespace KCal {
30class CalendarLocal; 29class CalendarLocal;
31} 30}
32 31
33using namespace KCal; 32using namespace KCal;
34 33
35class MainWindow : public QMainWindow 34class MainWindow : public QMainWindow
36{ 35{
37 Q_OBJECT 36 Q_OBJECT
38 public: 37 public:
39 MainWindow( QWidget *parent = 0, const char *name = 0 ); 38 MainWindow( QWidget *parent = 0, const char *name = 0 );
40 ~MainWindow(); 39 ~MainWindow();
41 bool beamReceiveEnabled(); 40 bool beamReceiveEnabled();
42 static QString defaultFileName(); 41 static QString defaultFileName();
43 static QString syncFileName(); 42 static QString syncFileName();
44 static QString resourcePath(); 43 static QString resourcePath();
45 public slots: 44 public slots:
46 void setUsesBigPixmaps ( bool ); 45 void setUsesBigPixmaps ( bool );
47 void setCaption ( const QString & ); 46 void setCaption ( const QString & );
48 void updateWeekNum(const KCal::DateList &); 47 void updateWeekNum(const KCal::DateList &);
49 void updateWeek(QDate); 48 void updateWeek(QDate);
50 void updateFilterToolbar(); 49 void updateFilterToolbar();
51 virtual void showMaximized (); 50 virtual void showMaximized ();
52 void configureAgenda( int ); 51 void configureAgenda( int );
53 void recieve( const QCString& msg, const QByteArray& data ); 52 void recieve( const QCString& msg, const QByteArray& data );
54 protected slots: 53 protected slots:
55 void calHint(); 54 void calHint();
56 void startMultiSync(); 55 void startMultiSync();
57 void setCaptionToDates(); 56 void setCaptionToDates();
58 void weekAction(); 57 void weekAction();
59 void about(); 58 void about();
60 void licence(); 59 void licence();
61 void faq(); 60 void faq();
62 void usertrans(); 61 void usertrans();
63 void features(); 62 void features();
64 void synchowto(); 63 void synchowto();
65 void storagehowto(); 64 void storagehowto();
66 void timetrackinghowto(); 65 void timetrackinghowto();
67 void kdesynchowto(); 66 void kdesynchowto();
68 void multisynchowto(); 67 void multisynchowto();
69 void whatsNew(); 68 void whatsNew();
70 void keyBindings(); 69 void keyBindings();
71 void aboutAutoSaving();; 70 void aboutAutoSaving();;
72 void aboutKnownBugs(); 71 void aboutKnownBugs();
73 72
74 void processIncidenceSelection( Incidence * ); 73 void processIncidenceSelection( Incidence * );
75 74
76 void importQtopia(); 75 void importQtopia();
77 void importBday(); 76 void importBday();
78 void importOL(); 77 void importOL();
79 void importIcal(); 78 void importIcal();
80 void importFile( QString, bool ); 79 void importFile( QString, bool );
81 void quickImportIcal(); 80 void quickImportIcal();
82 81
83 void slotModifiedChanged( bool ); 82 void slotModifiedChanged( bool );
84 83
85 void save(); 84 void save();
86 void backupAllFiles(); 85 void backupAllFiles();
87 void saveStopTimer(); 86 void saveStopTimer();
88 void configureToolBar( int ); 87 void configureToolBar( int );
89 void printSel(); 88 void printSel();
90 void printCal(); 89 void printCal();
91 void printListView(); 90 void printListView();
92 void saveCalendar(); 91 void saveCalendar();
93 void loadCalendar(); 92 void loadCalendar();
94 void exportVCalendar(); 93 void exportVCalendar();
95 void fillFilterMenu(); 94 void fillFilterMenu();
96 void fillFilterMenuTB(); 95 void fillFilterMenuTB();
97 void selectFilter( int ); 96 void selectFilter( int );
98 void fillFilterMenuPopup(); 97 void fillFilterMenuPopup();
99 void selectFilterPopup( int ); 98 void selectFilterPopup( int );
100 void exportToPhone( int ); 99 void exportToPhone( int );
101 void toggleBeamReceive(); 100 void toggleBeamReceive();
102 void disableBR(bool); 101 void disableBR(bool);
103 signals: 102 signals:
104 void selectWeek ( int ); 103 void selectWeek ( int );
105 private slots: 104 private slots:
106 void showConfigureAgenda(); 105 void showConfigureAgenda();
107 void getFile( bool ); 106 void getFile( bool );
108 void syncFileRequest(); 107 void syncFileRequest();
109 108
110 protected: 109 protected:
111 void hideEvent ( QHideEvent * ); 110 void hideEvent ( QHideEvent * );
112 QString sentSyncFile(); 111 QString sentSyncFile();
113 void displayText( QString, QString); 112 void displayText( QString, QString);
114 void enableIncidenceActions( bool ); 113 void enableIncidenceActions( bool );
115 114
116 private: 115 private:
117 bool mBRdisabled; 116 bool mBRdisabled;
118#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
119 QCopChannel* infrared; 118 QCopChannel* infrared;
120#endif 119#endif
121 QAction* brAction; 120 QAction* brAction;
122 KSyncManager* mSyncManager; 121 KSyncManager* mSyncManager;
123 bool mClosed; 122 bool mClosed;
124 void saveOnClose(); 123 void saveOnClose();
125 bool mFlagKeyPressed; 124 bool mFlagKeyPressed;
126 bool mBlockAtStartup; 125 bool mBlockAtStartup;
127 QPEToolBar *iconToolBar; 126 QPEToolBar *iconToolBar;
128 QPEToolBar *viewToolBar; 127 QPEToolBar *viewToolBar;
129 QPEToolBar *navigatorToolBar; 128 QPEToolBar *navigatorToolBar;
130 QPEToolBar *filterToolBar; 129 QPEToolBar *filterToolBar;
131 QMenuBar *filterMenubar; 130 KMenuBar *filterMenubar;
132 QPopupMenu * filterPopupMenu; 131 QPopupMenu * filterPopupMenu;
133 QPopupMenu * mCurrentItemMenu; 132 QPopupMenu * mCurrentItemMenu;
134 void initActions(); 133 void initActions();
135 void setDefaultPreferences(); 134 void setDefaultPreferences();
136 void resizeEvent( QResizeEvent* e); 135 void resizeEvent( QResizeEvent* e);
137 void keyPressEvent ( QKeyEvent * ) ; 136 void keyPressEvent ( QKeyEvent * ) ;
138 void keyReleaseEvent ( QKeyEvent * ) ; 137 void keyReleaseEvent ( QKeyEvent * ) ;
139 QPopupMenu *configureToolBarMenu; 138 QPopupMenu *configureToolBarMenu;
140 QPopupMenu *selectFilterMenu; 139 QPopupMenu *selectFilterMenu;
141 QPopupMenu *selectFilterMenuTB; 140 QPopupMenu *selectFilterMenuTB;
142 QPopupMenu *configureAgendaMenu, *syncMenu; 141 QPopupMenu *configureAgendaMenu, *syncMenu;
143 CalendarLocal *mCalendar; 142 CalendarLocal *mCalendar;
144 CalendarView *mView; 143 CalendarView *mView;
145 QAction *mNewSubTodoAction; 144 QAction *mNewSubTodoAction;
146 QAction *mWeekAction; 145 QAction *mWeekAction;
147 QFont mWeekFont; 146 QFont mWeekFont;
148 QPixmap mWeekPixmap; 147 QPixmap mWeekPixmap;
149 QColor mWeekBgColor; 148 QColor mWeekBgColor;
150 149
151 QAction *mShowAction; 150 QAction *mShowAction;
152 QAction *mEditAction; 151 QAction *mEditAction;
153 QAction *mDeleteAction; 152 QAction *mDeleteAction;
154 QAction *mCloneAction; 153 QAction *mCloneAction;
155 QAction *mMoveAction; 154 QAction *mMoveAction;
156 QAction *mBeamAction; 155 QAction *mBeamAction;
157 QAction *mCancelAction; 156 QAction *mCancelAction;
158 QAction *mPrintSelAction; 157 QAction *mPrintSelAction;
159 158
160 QAction *mToggleNav; 159 QAction *mToggleNav;
161 QAction *mToggleFilter; 160 QAction *mToggleFilter;
162 QAction *mToggleAllday; 161 QAction *mToggleAllday;
163 QAction *actionFilterMenuTB; 162 QAction *actionFilterMenuTB;
164 163
165 void closeEvent( QCloseEvent* ce ); 164 void closeEvent( QCloseEvent* ce );
166 QTimer mSaveTimer; 165 QTimer mSaveTimer;
167 //bool mBlockSaveFlag; 166 //bool mBlockSaveFlag;
168 bool mCalendarModifiedFlag; 167 bool mCalendarModifiedFlag;
169 QPixmap loadPixmap( QString ); 168 QPixmap loadPixmap( QString );
170 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix; 169 QPixmap listviewPix, listviewPix0, listviewPix20, listviewPix40, listviewPix60, listviewPix80, journalPix;
171}; 170};
172 171
173 172
174#endif 173#endif
diff --git a/microkde/kdeui/kbuttonbox.cpp b/microkde/kdeui/kbuttonbox.cpp
index 16206e8..83d622a 100644
--- a/microkde/kdeui/kbuttonbox.cpp
+++ b/microkde/kdeui/kbuttonbox.cpp
@@ -1,300 +1,300 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com) 2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* 20/*
21 * KButtonBox class 21 * KButtonBox class
22 * 22 *
23 * A container widget for buttons. Uses Qt layout control to place the 23 * A container widget for buttons. Uses Qt layout control to place the
24 * buttons, can handle both vertical and horizontal button placement. 24 * buttons, can handle both vertical and horizontal button placement.
25* 25*
26 * HISTORY 26 * HISTORY
27 * 27 *
28 * 03/08/2000 Mario Weilguni <mweilguni@kde.org> 28 * 03/08/2000 Mario Weilguni <mweilguni@kde.org>
29 * Removed all those long outdated Motif stuff 29 * Removed all those long outdated Motif stuff
30 * Improved and clarified some if conditions (easier to understand) 30 * Improved and clarified some if conditions (easier to understand)
31 * 31 *
32 * 11/13/98 Reginald Stadlbauer <reggie@kde.org> 32 * 11/13/98 Reginald Stadlbauer <reggie@kde.org>
33 * Now in Qt 1.4x motif default buttons have no extra width/height anymore. 33 * Now in Qt 1.4x motif default buttons have no extra width/height anymore.
34 * So the KButtonBox doesn't add this width/height to default buttons anymore 34 * So the KButtonBox doesn't add this width/height to default buttons anymore
35 * which makes the buttons look better. 35 * which makes the buttons look better.
36 * 36 *
37 * 01/17/98 Mario Weilguni <mweilguni@sime.com> 37 * 01/17/98 Mario Weilguni <mweilguni@sime.com>
38 * Fixed a bug in sizeHint() 38 * Fixed a bug in sizeHint()
39 * Improved the handling of Motif default buttons 39 * Improved the handling of Motif default buttons
40 * 40 *
41 * 01/09/98 Mario Weilguni <mweilguni@sime.com> 41 * 01/09/98 Mario Weilguni <mweilguni@sime.com>
42 * The last button was to far right away from the right/bottom border. 42 * The last button was to far right away from the right/bottom border.
43 * Fixed this. Removed old code. Buttons get now a minimum width. 43 * Fixed this. Removed old code. Buttons get now a minimum width.
44 * Programmer may now override minimum width and height of a button. 44 * Programmer may now override minimum width and height of a button.
45 * 45 *
46 */ 46 */
47 47
48//US #include "kbuttonbox.moc" 48//US #include "kbuttonbox.moc"
49 49
50#include <kbuttonbox.h> 50#include <kbuttonbox.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qptrlist.h> 52#include <qptrlist.h>
53#include <assert.h> 53#include <assert.h>
54 54
55#define minButtonWidth 50 55#define minButtonWidth 50
56 56
57class KButtonBox::Item { 57class KButtonBox::Item {
58public: 58public:
59 QPushButton *button; 59 QPushButton *button;
60 bool noexpand; 60 bool noexpand;
61 unsigned short stretch; 61 unsigned short stretch;
62 unsigned short actual_size; 62 unsigned short actual_size;
63}; 63};
64 64
65template class QPtrList<KButtonBox::Item>; 65template class QPtrList<KButtonBox::Item>;
66 66
67class KButtonBoxPrivate { 67class KButtonBoxPrivate {
68public: 68public:
69 unsigned short border; 69 unsigned short border;
70 unsigned short autoborder; 70 unsigned short autoborder;
71 unsigned short orientation; 71 unsigned short orientation;
72 bool activated; 72 bool activated;
73 QPtrList<KButtonBox::Item> buttons; 73 QPtrList<KButtonBox::Item> buttons;
74}; 74};
75 75
76KButtonBox::KButtonBox(QWidget *parent, Orientation _orientation, 76KButtonBox::KButtonBox(QWidget *parent, Orientation _orientation,
77 int border, int autoborder) 77 int border, int autoborder)
78 : QWidget(parent) 78 : QWidget(parent)
79{ 79{
80 data = new KButtonBoxPrivate; 80 data = new KButtonBoxPrivate;
81 assert(data != 0); 81 assert(data != 0);
82 82
83 data->orientation = _orientation; 83 data->orientation = _orientation;
84 data->border = border; 84 data->border = border;
85 data->autoborder = autoborder < 0 ? border : autoborder; 85 data->autoborder = autoborder < 0 ? border : autoborder;
86 data->buttons.setAutoDelete(TRUE); 86 data->buttons.setAutoDelete(TRUE);
87} 87}
88 88
89KButtonBox::~KButtonBox() { 89KButtonBox::~KButtonBox() {
90 delete data; 90 delete data;
91} 91}
92 92
93QPushButton *KButtonBox::addButton(const QString& text, bool noexpand) { 93QPushButton *KButtonBox::addButton(const QString& text, bool noexpand) {
94 Item *item = new Item; 94 Item *item = new Item;
95 95
96 item->button = new QPushButton(text, this); 96 item->button = new QPushButton(text, this);
97 item->noexpand = noexpand; 97 item->noexpand = noexpand;
98 data->buttons.append(item); 98 data->buttons.append(item);
99 item->button->adjustSize(); 99 item->button->adjustSize();
100 100
101 return item->button; 101 return item->button;
102} 102}
103 103
104 QPushButton * 104 QPushButton *
105KButtonBox::addButton( 105KButtonBox::addButton(
106 const QString & text, 106 const QString & text,
107 QObject * receiver, 107 QObject * receiver,
108 const char * slot, 108 const char * slot,
109 bool noexpand 109 bool noexpand
110) 110)
111{ 111{
112 QPushButton * pb = addButton(text, noexpand); 112 QPushButton * pb = addButton(text, noexpand);
113 113
114 if ((0 != receiver) && (0 != slot)) 114 if ((0 != receiver) && (0 != slot))
115 QObject::connect(pb, SIGNAL(clicked()), receiver, slot); 115 QObject::connect(pb, SIGNAL(clicked()), receiver, slot);
116 116
117 return pb; 117 return pb;
118} 118}
119 119
120 120
121void KButtonBox::addStretch(int scale) { 121void KButtonBox::addStretch(int scale) {
122 if(scale > 0) { 122 if(scale > 0) {
123 Item *item = new Item; 123 Item *item = new Item;
124 item->button = 0; 124 item->button = 0;
125 item->noexpand = FALSE; 125 item->noexpand = FALSE;
126 item->stretch = scale; 126 item->stretch = scale;
127 data->buttons.append(item); 127 data->buttons.append(item);
128 } 128 }
129} 129}
130 130
131void KButtonBox::layout() { 131void KButtonBox::layout() {
132 // resize all buttons 132 // resize all buttons
133 QSize bs = bestButtonSize(); 133 QSize bs = bestButtonSize();
134 134
135 for(unsigned int i = 0; i < data->buttons.count(); i++) { 135 for(unsigned int i = 0; i < data->buttons.count(); i++) {
136 Item *item = data->buttons.at(i); 136 Item *item = data->buttons.at(i);
137 QPushButton *b = item->button; 137 QPushButton *b = item->button;
138 if(b != 0) { 138 if(b != 0) {
139 if(item->noexpand) 139 if(item->noexpand)
140 b->setFixedSize(buttonSizeHint(b)); 140 b->setFixedSize(buttonSizeHint(b));
141 else 141 else
142 b->setFixedSize(bs); 142 b->setFixedSize(bs);
143 } 143 }
144 } 144 }
145 145
146 setMinimumSize(sizeHint()); 146 setMinimumSize(sizeHint());
147} 147}
148 148
149void KButtonBox::placeButtons() { 149void KButtonBox::placeButtons() {
150 unsigned int i; 150 unsigned int i;
151 151
152 if(data->orientation == Horizontal) { 152 if(data->orientation == Horizontal) {
153 // calculate free size and stretches 153 // calculate free size and stretches
154 int fs = width() - 2 * data->border; 154 int fs = width() - 2 * data->border;
155 int stretch = 0; 155 int stretch = 0;
156 for(i = 0; i < data->buttons.count(); i++) { 156 for(i = 0; i < data->buttons.count(); i++) {
157 Item *item = data->buttons.at(i); 157 Item *item = data->buttons.at(i);
158 if(item->button != 0) { 158 if(item->button != 0) {
159 fs -= item->button->width(); 159 fs -= item->button->width();
160 160
161 // Last button? 161 // Last button?
162 if(i != data->buttons.count() - 1) 162 if(i != data->buttons.count() - 1)
163 fs -= data->autoborder; 163 fs -= data->autoborder;
164 } else 164 } else
165 stretch +=item->stretch; 165 stretch +=item->stretch;
166 } 166 }
167 167
168 // distribute buttons 168 // distribute buttons
169 int x_pos = data->border; 169 int x_pos = data->border;
170 for(i = 0; i < data->buttons.count(); i++) { 170 for(i = 0; i < data->buttons.count(); i++) {
171 Item *item = data->buttons.at(i); 171 Item *item = data->buttons.at(i);
172 if(item->button != 0) { 172 if(item->button != 0) {
173 QPushButton *b = item->button; 173 QPushButton *b = item->button;
174 b->move(x_pos, (height() - b->height()) / 2); 174 b->move(x_pos, (height() - b->height()) / 2);
175 175
176 x_pos += b->width() + data->autoborder; 176 x_pos += b->width() + data->autoborder;
177 } else 177 } else
178 x_pos += (int)((((double)fs) * item->stretch) / stretch); 178 x_pos += (int)((((double)fs) * item->stretch) / stretch);
179 } 179 }
180 } else { // VERTICAL 180 } else { // VERTICAL
181 // calcualte free size and stretches 181 // calcualte free size and stretches
182 int fs = height() - 2 * data->border; 182 int fs = height() - 2 * data->border;
183 int stretch = 0; 183 int stretch = 0;
184 for(i = 0; i < data->buttons.count(); i++) { 184 for(i = 0; i < data->buttons.count(); i++) {
185 Item *item = data->buttons.at(i); 185 Item *item = data->buttons.at(i);
186 if(item->button != 0) 186 if(item->button != 0)
187 fs -= item->button->height() + data->autoborder; 187 fs -= item->button->height() + data->autoborder;
188 else 188 else
189 stretch +=item->stretch; 189 stretch +=item->stretch;
190 } 190 }
191 191
192 // distribute buttons 192 // distribute buttons
193 int y_pos = data->border; 193 int y_pos = data->border;
194 for(i = 0; i < data->buttons.count(); i++) { 194 for(i = 0; i < data->buttons.count(); i++) {
195 Item *item = data->buttons.at(i); 195 Item *item = data->buttons.at(i);
196 if(item->button != 0) { 196 if(item->button != 0) {
197 QPushButton *b = item->button; 197 QPushButton *b = item->button;
198 b->move((width() - b->width()) / 2, y_pos); 198 b->move((width() - b->width()) / 2, y_pos);
199 199
200 y_pos += b->height() + data->autoborder; 200 y_pos += b->height() + data->autoborder;
201 } else 201 } else
202 y_pos += (int)((((double)fs) * item->stretch) / stretch); 202 y_pos += (int)((((double)fs) * item->stretch) / stretch);
203 } 203 }
204 } 204 }
205} 205}
206 206
207void KButtonBox::resizeEvent(QResizeEvent *) { 207void KButtonBox::resizeEvent(QResizeEvent *) {
208 placeButtons(); 208 placeButtons();
209} 209}
210 210
211QSize KButtonBox::bestButtonSize() const { 211QSize KButtonBox::bestButtonSize() const {
212 QSize s(0, 0); 212 QSize s(0, 0);
213 unsigned int i; 213 unsigned int i;
214 214
215 // calculate optimal size 215 // calculate optimal size
216 for(i = 0; i < data->buttons.count(); i++) { 216 for(i = 0; i < data->buttons.count(); i++) {
217 KButtonBox *that = (KButtonBox*)this; // to remove the const ;( 217 KButtonBox *that = (KButtonBox*)this; // to remove the const ;(
218 Item *item = that->data->buttons.at(i); 218 Item *item = that->data->buttons.at(i);
219 QPushButton *b = item->button; 219 QPushButton *b = item->button;
220 220
221 if(b != 0 && !item->noexpand) { 221 if(b != 0 && !item->noexpand) {
222 QSize bs = buttonSizeHint(b); 222 QSize bs = buttonSizeHint(b);
223 223
224 if(bs.width() > s.width()) 224 if(bs.width() > s.width())
225 s.setWidth(bs.width()); 225 s.setWidth(bs.width());
226 if(bs.height() > s.height()) 226 if(bs.height() > s.height())
227 s.setHeight(bs.height()); 227 s.setHeight(bs.height());
228 } 228 }
229 } 229 }
230 230
231 return s; 231 return s;
232} 232}
233 233
234QSize KButtonBox::sizeHint() const { 234QSize KButtonBox::sizeHint() const {
235 unsigned int i, dw; 235 unsigned int i, dw;
236 236
237 if(data->buttons.count() == 0) 237 if(data->buttons.count() == 0)
238 return QSize(0, 0); 238 return QSize(0, 0);
239 else { 239 else {
240 dw = 2 * data->border; 240 dw = 2 * data->border;
241 241
242 QSize bs = bestButtonSize(); 242 QSize bs = bestButtonSize();
243 for(i = 0; i < data->buttons.count(); i++) { 243 for(i = 0; i < data->buttons.count(); i++) {
244 KButtonBox *that = (KButtonBox*)this; 244 KButtonBox *that = (KButtonBox*)this;
245 Item *item = that->data->buttons.at(i); 245 Item *item = that->data->buttons.at(i);
246 QPushButton *b = item->button; 246 QPushButton *b = item->button;
247 if(b != 0) { 247 if(b != 0) {
248 QSize s; 248 QSize s;
249 if(item->noexpand) 249 if(item->noexpand)
250 s = that->buttonSizeHint(b); 250 s = that->buttonSizeHint(b);
251 else 251 else
252 s = bs; 252 s = bs;
253 253
254 if(data->orientation == Horizontal) 254 if(data->orientation == Horizontal)
255 dw += s.width(); 255 dw += s.width();
256 else 256 else
257 dw += s.height(); 257 dw += s.height();
258 258
259 if( i != data->buttons.count() - 1 ) 259 if( i != data->buttons.count() - 1 )
260 dw += data->autoborder; 260 dw += data->autoborder;
261 } 261 }
262 } 262 }
263 263
264 if(data->orientation == Horizontal) 264 if(data->orientation == Horizontal)
265 return QSize(dw, bs.height() + 2 * data->border); 265 return QSize(dw, bs.height() + 2 * data->border);
266 else 266 else
267 return QSize(bs.width() + 2 * data->border, dw); 267 return QSize(bs.width() + 2 * data->border, dw);
268 } 268 }
269} 269}
270 270
271QSizePolicy KButtonBox::sizePolicy() const 271QSizePolicy KButtonBox::sizePolicy() const
272{ 272{
273 return data->orientation == Horizontal? 273 return data->orientation == Horizontal?
274 QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) : 274 QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) :
275 QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ); 275 QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
276} 276}
277 277
278/* 278/*
279 * Returns the best size for a button. If a button is less than 279 * Returns the best size for a button. If a button is less than
280 * minButtonWidth pixels wide, return minButtonWidth pixels 280 * minButtonWidth pixels wide, return minButtonWidth pixels
281 * as minimum width 281 * as minimum width
282 */ 282 */
283QSize KButtonBox::buttonSizeHint(QPushButton *b) const { 283QSize KButtonBox::buttonSizeHint(QPushButton *b) const {
284 QSize s = b->sizeHint(); 284 QSize s = b->sizeHint();
285 QSize ms = b->minimumSize(); 285 QSize ms = b->minimumSize();
286 if(s.width() < minButtonWidth) 286 if(s.width() < minButtonWidth)
287 s.setWidth(minButtonWidth); 287 s.setWidth(minButtonWidth);
288 288
289 // allows the programmer to override the settings 289 // allows the programmer to override the settings
290 if(ms.width() > s.width()) 290 if(ms.width() > s.width())
291 s.setWidth(ms.width()); 291 s.setWidth(ms.width());
292 if(ms.height() > s.height()) 292 if(ms.height() > s.height())
293 s.setHeight(ms.height()); 293 s.setHeight(ms.height());
294 294
295 return s; 295 return s;
296} 296}
297 297
298void KButtonBox::virtual_hook( int, void* ) 298void KButtonBox::virtual_hook( int, void* )
299{ /*BASE::virtual_hook( id, data );*/ } 299{ /*BASE::virtual_hook( id, data );*/ }
300 300
diff --git a/microkde/kdeui/kpopupmenu.cpp b/microkde/kdeui/kpopupmenu.cpp
new file mode 100644
index 0000000..96d2a87
--- a/dev/null
+++ b/microkde/kdeui/kpopupmenu.cpp
@@ -0,0 +1,19 @@
1
2#include <kpopupmenu.h>
3#include <qtimer.h>
4
5
6KPopupMenu::KPopupMenu ( QWidget * parent, const char * name )
7 : QPopupMenu ( parent, name ) {;}
8
9
10
11KMenuBar::KMenuBar ( QWidget * parent, const char * name )
12 : QPEMenuBar ( parent, name ) {}
13
14void KMenuBar::focusOutEvent ( QFocusEvent * e)
15{
16 QPEMenuBar::focusOutEvent( e );
17 QTimer::singleShot( 100, this, SIGNAL ( lostFocus() ) );
18
19}
diff --git a/microkde/kdeui/kpopupmenu.h b/microkde/kdeui/kpopupmenu.h
index 1352429..f16ce77 100644
--- a/microkde/kdeui/kpopupmenu.h
+++ b/microkde/kdeui/kpopupmenu.h
@@ -1,14 +1,32 @@
1#ifndef KPOPUPMENU_H 1#ifndef KPOPUPMENU_H
2#define KPOPUPMENU_H 2#define KPOPUPMENU_H
3 3
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#ifdef DESKTOP_VERSION
6#include <qmenubar.h>
7#define QPEMenuBar QMenubar
8#else
9#include <qpe/qpemenubar.h>
10#endif
5 11
6class KPopupMenu : public QPopupMenu 12class KPopupMenu : public QPopupMenu
7{ 13{
14Q_OBJECT
8 public: 15 public:
9 KPopupMenu ( QWidget * parent=0, const char * name=0 ) 16 KPopupMenu ( QWidget * parent=0, const char * name=0 );
10 : QPopupMenu ( parent, name ) {} 17
18};
11 19
20
21class KMenuBar : public QPEMenuBar
22{
23Q_OBJECT
24 public:
25 KMenuBar ( QWidget * parent=0, const char * name=0 );
26 signals:
27 void lostFocus();
28 protected:
29 void focusOutEvent ( QFocusEvent * e);
12}; 30};
13 31
14#endif 32#endif
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 44e5f9d..7120bdd 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -1,178 +1,180 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3include( ../variables.pri ) 3include( ../variables.pri )
4#INCLUDEPATH += $(QTDIR)/include . 4#INCLUDEPATH += $(QTDIR)/include .
5#DEPENDPATH += $(QTDIR)/include 5#DEPENDPATH += $(QTDIR)/include
6INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio 6INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio
7#LIBS += -lqtcompat 7#LIBS += -lqtcompat
8 8
9 TARGET = microkde 9 TARGET = microkde
10DESTDIR= ../bin 10DESTDIR= ../bin
11DEFINES += DESKTOP_VERSION KDE_QT_ONLY 11DEFINES += DESKTOP_VERSION KDE_QT_ONLY
12unix : { 12unix : {
13staticlib: { 13staticlib: {
14INCLUDEPATH += ../kabc/plugins 14INCLUDEPATH += ../kabc/plugins
15DEFINES += STATIC_RESOURCES 15DEFINES += STATIC_RESOURCES
16} 16}
17 17
18 18
19OBJECTS_DIR = obj/unix 19OBJECTS_DIR = obj/unix
20MOC_DIR = moc/unix 20MOC_DIR = moc/unix
21} 21}
22win32: { 22win32: {
23DEFINES += _WIN32_ 23DEFINES += _WIN32_
24OBJECTS_DIR = obj/win 24OBJECTS_DIR = obj/win
25MOC_DIR = moc/win 25MOC_DIR = moc/win
26} 26}
27 27
28 28
29 29
30HEADERS = \ 30HEADERS = \
31qlayoutengine_p.h \ 31qlayoutengine_p.h \
32KDGanttMinimizeSplitter.h \ 32KDGanttMinimizeSplitter.h \
33 kapplication.h \ 33 kapplication.h \
34 kaudioplayer.h \ 34 kaudioplayer.h \
35 kcalendarsystem.h \ 35 kcalendarsystem.h \
36 kcalendarsystemgregorian.h \ 36 kcalendarsystemgregorian.h \
37 kcolorbutton.h \ 37 kcolorbutton.h \
38 kcombobox.h \ 38 kcombobox.h \
39 kconfig.h \ 39 kconfig.h \
40 kdatetbl.h \ 40 kdatetbl.h \
41 kdebug.h \ 41 kdebug.h \
42 kdialog.h \ 42 kdialog.h \
43 kdialogbase.h \ 43 kdialogbase.h \
44 keditlistbox.h \ 44 keditlistbox.h \
45 kemailsettings.h \ 45 kemailsettings.h \
46 kfiledialog.h \ 46 kfiledialog.h \
47 kfontdialog.h \ 47 kfontdialog.h \
48 kglobal.h \ 48 kglobal.h \
49 kglobalsettings.h \ 49 kglobalsettings.h \
50 kiconloader.h \ 50 kiconloader.h \
51 klineedit.h \ 51 klineedit.h \
52 klineeditdlg.h \ 52 klineeditdlg.h \
53 kmessagebox.h \ 53 kmessagebox.h \
54 knotifyclient.h \ 54 knotifyclient.h \
55 kprinter.h \ 55 kprinter.h \
56 kprocess.h \ 56 kprocess.h \
57 krestrictedline.h \ 57 krestrictedline.h \
58 krun.h \ 58 krun.h \
59 ksimpleconfig.h \ 59 ksimpleconfig.h \
60 kstaticdeleter.h \ 60 kstaticdeleter.h \
61 ksystemtray.h \ 61 ksystemtray.h \
62 ktempfile.h \ 62 ktempfile.h \
63 ktextedit.h \ 63 ktextedit.h \
64 kunload.h \ 64 kunload.h \
65 kurl.h \ 65 kurl.h \
66 kdeui/kguiitem.h \ 66 kdeui/kguiitem.h \
67 kdeui/kcmodule.h \ 67 kdeui/kcmodule.h \
68 kdeui/kbuttonbox.h \ 68 kdeui/kbuttonbox.h \
69 kdeui/klistbox.h \ 69 kdeui/klistbox.h \
70 kdeui/klistview.h \ 70 kdeui/klistview.h \
71 kdeui/kjanuswidget.h \ 71 kdeui/kjanuswidget.h \
72 kdeui/kseparator.h \ 72 kdeui/kseparator.h \
73 kdeui/knuminput.h \ 73 kdeui/knuminput.h \
74 kdeui/knumvalidator.h \ 74 kdeui/knumvalidator.h \
75 kdeui/ksqueezedtextlabel.h \ 75 kdeui/ksqueezedtextlabel.h \
76 kio/job.h \ 76 kio/job.h \
77 kio/kio/kdirwatch.h \ 77 kio/kio/kdirwatch.h \
78 kio/kio/kdirwatch_p.h \ 78 kio/kio/kdirwatch_p.h \
79 kio/kfile/kurlrequester.h \ 79 kio/kfile/kurlrequester.h \
80 kresources/resource.h \ 80 kresources/resource.h \
81 kresources/factory.h \ 81 kresources/factory.h \
82 kresources/managerimpl.h \ 82 kresources/managerimpl.h \
83 kresources/manager.h \ 83 kresources/manager.h \
84 kresources/selectdialog.h \ 84 kresources/selectdialog.h \
85 kresources/configpage.h \ 85 kresources/configpage.h \
86 kresources/configwidget.h \ 86 kresources/configwidget.h \
87 kresources/configdialog.h \ 87 kresources/configdialog.h \
88 kresources/kcmkresources.h \ 88 kresources/kcmkresources.h \
89 kdecore/kmdcodec.h \ 89 kdecore/kmdcodec.h \
90 kdecore/kconfigbase.h \ 90 kdecore/kconfigbase.h \
91 kdecore/klocale.h \ 91 kdecore/klocale.h \
92 kdecore/kcatalogue.h \ 92 kdecore/kcatalogue.h \
93 kdecore/ksharedptr.h \ 93 kdecore/ksharedptr.h \
94 kdecore/kshell.h \ 94 kdecore/kshell.h \
95 kdecore/kstandarddirs.h \ 95 kdecore/kstandarddirs.h \
96 kdecore/kstringhandler.h \ 96 kdecore/kstringhandler.h \
97 kdecore/kshortcut.h \ 97 kdecore/kshortcut.h \
98 kutils/kcmultidialog.h \ 98 kutils/kcmultidialog.h \
99 kdeui/kxmlguiclient.h \ 99 kdeui/kxmlguiclient.h \
100 kdeui/kstdaction.h \ 100 kdeui/kstdaction.h \
101 kdeui/kmainwindow.h \ 101 kdeui/kmainwindow.h \
102 kdeui/ktoolbar.h \ 102 kdeui/ktoolbar.h \
103 kdeui/ktoolbarbutton.h \ 103 kdeui/ktoolbarbutton.h \
104 kdeui/ktoolbarhandler.h \ 104 kdeui/ktoolbarhandler.h \
105 kdeui/kaction.h \ 105 kdeui/kaction.h \
106 kdeui/kpopupmenu.h \
106 kdeui/kactionclasses.h \ 107 kdeui/kactionclasses.h \
107 kdeui/kactioncollection.h \ 108 kdeui/kactioncollection.h \
108 kdecore/kprefs.h \ 109 kdecore/kprefs.h \
109 kdecore/klibloader.h \ 110 kdecore/klibloader.h \
110 kidmanager.h 111 kidmanager.h
111 112
112 113
113# kdecore/klibloader.h \ 114# kdecore/klibloader.h \
114 115
115 116
116SOURCES = \ 117SOURCES = \
117KDGanttMinimizeSplitter.cpp \ 118KDGanttMinimizeSplitter.cpp \
118 kapplication.cpp \ 119 kapplication.cpp \
119 kcalendarsystem.cpp \ 120 kcalendarsystem.cpp \
120 kcalendarsystemgregorian.cpp \ 121 kcalendarsystemgregorian.cpp \
121 kcolorbutton.cpp \ 122 kcolorbutton.cpp \
122 kconfig.cpp \ 123 kconfig.cpp \
123 kdatetbl.cpp \ 124 kdatetbl.cpp \
124 kdialog.cpp \ 125 kdialog.cpp \
125 kdialogbase.cpp \ 126 kdialogbase.cpp \
126 keditlistbox.cpp \ 127 keditlistbox.cpp \
127 kemailsettings.cpp \ 128 kemailsettings.cpp \
128 kfontdialog.cpp \ 129 kfontdialog.cpp \
129 kfiledialog.cpp \ 130 kfiledialog.cpp \
130 kglobal.cpp \ 131 kglobal.cpp \
131 kglobalsettings.cpp \ 132 kglobalsettings.cpp \
132 kiconloader.cpp \ 133 kiconloader.cpp \
133 kmessagebox.cpp \ 134 kmessagebox.cpp \
134 ktextedit.cpp \ 135 ktextedit.cpp \
135 kprocess.cpp \ 136 kprocess.cpp \
136 krun.cpp \ 137 krun.cpp \
137 ksystemtray.cpp \ 138 ksystemtray.cpp \
138 ktempfile.cpp \ 139 ktempfile.cpp \
139 kurl.cpp \ 140 kurl.cpp \
140 kdecore/kcatalogue.cpp \ 141 kdecore/kcatalogue.cpp \
141 kdecore/klocale.cpp \ 142 kdecore/klocale.cpp \
142 kdecore/kmdcodec.cpp \ 143 kdecore/kmdcodec.cpp \
143 kdecore/kshell.cpp \ 144 kdecore/kshell.cpp \
144 kdecore/kstandarddirs.cpp \ 145 kdecore/kstandarddirs.cpp \
145 kdecore/kstringhandler.cpp \ 146 kdecore/kstringhandler.cpp \
146 kdeui/kbuttonbox.cpp \ 147 kdeui/kbuttonbox.cpp \
147 kdeui/kcmodule.cpp \ 148 kdeui/kcmodule.cpp \
148 kdeui/kguiitem.cpp \ 149 kdeui/kguiitem.cpp \
149 kdeui/kjanuswidget.cpp \ 150 kdeui/kjanuswidget.cpp \
150 kdeui/klistbox.cpp \ 151 kdeui/klistbox.cpp \
151 kdeui/klistview.cpp \ 152 kdeui/klistview.cpp \
152 kdeui/knuminput.cpp \ 153 kdeui/knuminput.cpp \
153 kdeui/knumvalidator.cpp \ 154 kdeui/knumvalidator.cpp \
154 kdeui/kseparator.cpp \ 155 kdeui/kseparator.cpp \
155 kdeui/ksqueezedtextlabel.cpp \ 156 kdeui/ksqueezedtextlabel.cpp \
156 kio/kio/kdirwatch.cpp \ 157 kio/kio/kdirwatch.cpp \
157 kio/kfile/kurlrequester.cpp \ 158 kio/kfile/kurlrequester.cpp \
158 kresources/configpage.cpp \ 159 kresources/configpage.cpp \
159 kresources/configdialog.cpp \ 160 kresources/configdialog.cpp \
160 kresources/configwidget.cpp \ 161 kresources/configwidget.cpp \
161 kresources/factory.cpp \ 162 kresources/factory.cpp \
162 kresources/kcmkresources.cpp \ 163 kresources/kcmkresources.cpp \
163 kresources/managerimpl.cpp \ 164 kresources/managerimpl.cpp \
164 kresources/resource.cpp \ 165 kresources/resource.cpp \
165 kresources/selectdialog.cpp \ 166 kresources/selectdialog.cpp \
166 kutils/kcmultidialog.cpp \ 167 kutils/kcmultidialog.cpp \
167 kdeui/kaction.cpp \ 168 kdeui/kaction.cpp \
169 kdeui/kpopupmenu.cpp \
168 kdeui/kactionclasses.cpp \ 170 kdeui/kactionclasses.cpp \
169 kdeui/kactioncollection.cpp \ 171 kdeui/kactioncollection.cpp \
170 kdeui/kmainwindow.cpp \ 172 kdeui/kmainwindow.cpp \
171 kdeui/ktoolbar.cpp \ 173 kdeui/ktoolbar.cpp \
172 kdeui/ktoolbarbutton.cpp \ 174 kdeui/ktoolbarbutton.cpp \
173 kdeui/ktoolbarhandler.cpp \ 175 kdeui/ktoolbarhandler.cpp \
174 kdeui/kstdaction.cpp \ 176 kdeui/kstdaction.cpp \
175 kdeui/kxmlguiclient.cpp \ 177 kdeui/kxmlguiclient.cpp \
176 kdecore/kprefs.cpp \ 178 kdecore/kprefs.cpp \
177 kdecore/klibloader.cpp \ 179 kdecore/klibloader.cpp \
178 kidmanager.cpp 180 kidmanager.cpp
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro
index 335fcd0..8fe2bd5 100644
--- a/microkde/microkdeE.pro
+++ b/microkde/microkdeE.pro
@@ -1,172 +1,174 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3INCLUDEPATH += . .. $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/kabc kdecore kdeui kio/kfile kio/kio $(QPEDIR)/include 3INCLUDEPATH += . .. $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/kabc kdecore kdeui kio/kfile kio/kio $(QPEDIR)/include
4 4
5DEPENDPATH += $(QPEDIR)/include 5DEPENDPATH += $(QPEDIR)/include
6LIBS += -lmicroqtcompat -L$(QPEDIR)/lib 6LIBS += -lmicroqtcompat -L$(QPEDIR)/lib
7 7
8DEFINES += KDE_QT_ONLY 8DEFINES += KDE_QT_ONLY
9 9
10 TARGET = microkde 10 TARGET = microkde
11OBJECTS_DIR = obj/$(PLATFORM) 11OBJECTS_DIR = obj/$(PLATFORM)
12MOC_DIR = moc/$(PLATFORM) 12MOC_DIR = moc/$(PLATFORM)
13DESTDIR=$(QPEDIR)/lib 13DESTDIR=$(QPEDIR)/lib
14 14
15 15
16INTERFACES = \ 16INTERFACES = \
17 17
18HEADERS = \ 18HEADERS = \
19qlayoutengine_p.h fncolordialog.h\ 19qlayoutengine_p.h fncolordialog.h\
20KDGanttMinimizeSplitter.h \ 20KDGanttMinimizeSplitter.h \
21 kapplication.h \ 21 kapplication.h \
22 kaudioplayer.h \ 22 kaudioplayer.h \
23 kcalendarsystem.h \ 23 kcalendarsystem.h \
24 kcalendarsystemgregorian.h \ 24 kcalendarsystemgregorian.h \
25 kcolorbutton.h \ 25 kcolorbutton.h \
26 kcolordialog.h \ 26 kcolordialog.h \
27 kcombobox.h \ 27 kcombobox.h \
28 kconfig.h \ 28 kconfig.h \
29 kdatetbl.h \ 29 kdatetbl.h \
30 kdebug.h \ 30 kdebug.h \
31 kdialog.h \ 31 kdialog.h \
32 kdialogbase.h \ 32 kdialogbase.h \
33 keditlistbox.h \ 33 keditlistbox.h \
34 kemailsettings.h \ 34 kemailsettings.h \
35 kfiledialog.h \ 35 kfiledialog.h \
36 kfontdialog.h \ 36 kfontdialog.h \
37 kglobal.h \ 37 kglobal.h \
38 kglobalsettings.h \ 38 kglobalsettings.h \
39 kiconloader.h \ 39 kiconloader.h \
40 klineedit.h \ 40 klineedit.h \
41 klineeditdlg.h \ 41 klineeditdlg.h \
42 kmessagebox.h \ 42 kmessagebox.h \
43 knotifyclient.h \ 43 knotifyclient.h \
44 kprinter.h \ 44 kprinter.h \
45 kprocess.h \ 45 kprocess.h \
46 krestrictedline.h \ 46 krestrictedline.h \
47 krun.h \ 47 krun.h \
48 ksimpleconfig.h \ 48 ksimpleconfig.h \
49 kstaticdeleter.h \ 49 kstaticdeleter.h \
50 ksystemtray.h \ 50 ksystemtray.h \
51 ktempfile.h \ 51 ktempfile.h \
52 ktextedit.h \ 52 ktextedit.h \
53 kunload.h \ 53 kunload.h \
54 kurl.h \ 54 kurl.h \
55 ofileselector_p.h \ 55 ofileselector_p.h \
56 ofontselector.h \ 56 ofontselector.h \
57 kdeui/kguiitem.h \ 57 kdeui/kguiitem.h \
58 kdeui/kaction.h \ 58 kdeui/kaction.h \
59 kdeui/kpopupmenu.h \
59 kdeui/kactionclasses.h \ 60 kdeui/kactionclasses.h \
60 kdeui/kactioncollection.h \ 61 kdeui/kactioncollection.h \
61 kdeui/kcmodule.h \ 62 kdeui/kcmodule.h \
62 kdeui/kstdaction.h \ 63 kdeui/kstdaction.h \
63 kdeui/kbuttonbox.h \ 64 kdeui/kbuttonbox.h \
64 kdeui/klistbox.h \ 65 kdeui/klistbox.h \
65 kdeui/klistview.h \ 66 kdeui/klistview.h \
66 kdeui/kjanuswidget.h \ 67 kdeui/kjanuswidget.h \
67 kdeui/kseparator.h \ 68 kdeui/kseparator.h \
68 kdeui/kmainwindow.h \ 69 kdeui/kmainwindow.h \
69 kdeui/knuminput.h \ 70 kdeui/knuminput.h \
70 kdeui/knumvalidator.h \ 71 kdeui/knumvalidator.h \
71 kdeui/ksqueezedtextlabel.h \ 72 kdeui/ksqueezedtextlabel.h \
72 kdeui/ktoolbar.h \ 73 kdeui/ktoolbar.h \
73 kdeui/ktoolbarbutton.h \ 74 kdeui/ktoolbarbutton.h \
74 kdeui/ktoolbarhandler.h \ 75 kdeui/ktoolbarhandler.h \
75 kdeui/kxmlguiclient.h \ 76 kdeui/kxmlguiclient.h \
76 kio/job.h \ 77 kio/job.h \
77 kio/kio/kdirwatch.h \ 78 kio/kio/kdirwatch.h \
78 kio/kio/kdirwatch_p.h \ 79 kio/kio/kdirwatch_p.h \
79 kio/kfile/kurlrequester.h \ 80 kio/kfile/kurlrequester.h \
80 kresources/resource.h \ 81 kresources/resource.h \
81 kresources/factory.h \ 82 kresources/factory.h \
82 kresources/managerimpl.h \ 83 kresources/managerimpl.h \
83 kresources/manager.h \ 84 kresources/manager.h \
84 kresources/selectdialog.h \ 85 kresources/selectdialog.h \
85 kresources/configpage.h \ 86 kresources/configpage.h \
86 kresources/configwidget.h \ 87 kresources/configwidget.h \
87 kresources/configdialog.h \ 88 kresources/configdialog.h \
88 kresources/kcmkresources.h \ 89 kresources/kcmkresources.h \
89 kdecore/kmdcodec.h \ 90 kdecore/kmdcodec.h \
90 kdecore/kconfigbase.h \ 91 kdecore/kconfigbase.h \
91 kdecore/klocale.h \ 92 kdecore/klocale.h \
92 kdecore/klibloader.h \ 93 kdecore/klibloader.h \
93 kdecore/kcatalogue.h \ 94 kdecore/kcatalogue.h \
94 kdecore/kprefs.h \ 95 kdecore/kprefs.h \
95 kdecore/ksharedptr.h \ 96 kdecore/ksharedptr.h \
96 kdecore/kshell.h \ 97 kdecore/kshell.h \
97 kdecore/kstandarddirs.h \ 98 kdecore/kstandarddirs.h \
98 kdecore/kstringhandler.h \ 99 kdecore/kstringhandler.h \
99 kdecore/kshortcut.h \ 100 kdecore/kshortcut.h \
100 kutils/kcmultidialog.h \ 101 kutils/kcmultidialog.h \
101 kidmanager.h 102 kidmanager.h
102 103
103 104
104 105
105 106
106SOURCES = \ 107SOURCES = \
107KDGanttMinimizeSplitter.cpp fncolordialog.cpp \ 108KDGanttMinimizeSplitter.cpp fncolordialog.cpp \
108 kapplication.cpp \ 109 kapplication.cpp \
109 kcalendarsystem.cpp \ 110 kcalendarsystem.cpp \
110 kcalendarsystemgregorian.cpp \ 111 kcalendarsystemgregorian.cpp \
111 kcolorbutton.cpp \ 112 kcolorbutton.cpp \
112 kcolordialog.cpp \ 113 kcolordialog.cpp \
113 kconfig.cpp \ 114 kconfig.cpp \
114 kdatetbl.cpp \ 115 kdatetbl.cpp \
115 kdialog.cpp \ 116 kdialog.cpp \
116 kdialogbase.cpp \ 117 kdialogbase.cpp \
117 keditlistbox.cpp \ 118 keditlistbox.cpp \
118 kemailsettings.cpp \ 119 kemailsettings.cpp \
119 kfontdialog.cpp \ 120 kfontdialog.cpp \
120 kfiledialog.cpp \ 121 kfiledialog.cpp \
121 kglobal.cpp \ 122 kglobal.cpp \
122 kglobalsettings.cpp \ 123 kglobalsettings.cpp \
123 kiconloader.cpp \ 124 kiconloader.cpp \
124 kmessagebox.cpp \ 125 kmessagebox.cpp \
125 kprocess.cpp \ 126 kprocess.cpp \
126 krun.cpp \ 127 krun.cpp \
127 ksystemtray.cpp \ 128 ksystemtray.cpp \
128 ktempfile.cpp \ 129 ktempfile.cpp \
129 kurl.cpp \ 130 kurl.cpp \
130 ktextedit.cpp \ 131 ktextedit.cpp \
131 ofileselector_p.cpp \ 132 ofileselector_p.cpp \
132 ofontselector.cpp \ 133 ofontselector.cpp \
133 kdecore/kcatalogue.cpp \ 134 kdecore/kcatalogue.cpp \
134 kdecore/klibloader.cpp \ 135 kdecore/klibloader.cpp \
135 kdecore/klocale.cpp \ 136 kdecore/klocale.cpp \
136 kdecore/kmdcodec.cpp \ 137 kdecore/kmdcodec.cpp \
137 kdecore/kprefs.cpp \ 138 kdecore/kprefs.cpp \
138 kdecore/kshell.cpp \ 139 kdecore/kshell.cpp \
139 kdecore/kstandarddirs.cpp \ 140 kdecore/kstandarddirs.cpp \
140 kdecore/kstringhandler.cpp \ 141 kdecore/kstringhandler.cpp \
141 kdeui/kaction.cpp \ 142 kdeui/kaction.cpp \
143 kdeui/kpopupmenu.cpp \
142 kdeui/kactionclasses.cpp \ 144 kdeui/kactionclasses.cpp \
143 kdeui/kactioncollection.cpp \ 145 kdeui/kactioncollection.cpp \
144 kdeui/kbuttonbox.cpp \ 146 kdeui/kbuttonbox.cpp \
145 kdeui/kcmodule.cpp \ 147 kdeui/kcmodule.cpp \
146 kdeui/kguiitem.cpp \ 148 kdeui/kguiitem.cpp \
147 kdeui/kjanuswidget.cpp \ 149 kdeui/kjanuswidget.cpp \
148 kdeui/klistbox.cpp \ 150 kdeui/klistbox.cpp \
149 kdeui/klistview.cpp \ 151 kdeui/klistview.cpp \
150 kdeui/kmainwindow.cpp \ 152 kdeui/kmainwindow.cpp \
151 kdeui/knuminput.cpp \ 153 kdeui/knuminput.cpp \
152 kdeui/knumvalidator.cpp \ 154 kdeui/knumvalidator.cpp \
153 kdeui/kseparator.cpp \ 155 kdeui/kseparator.cpp \
154 kdeui/kstdaction.cpp \ 156 kdeui/kstdaction.cpp \
155 kdeui/ksqueezedtextlabel.cpp \ 157 kdeui/ksqueezedtextlabel.cpp \
156 kdeui/ktoolbar.cpp \ 158 kdeui/ktoolbar.cpp \
157 kdeui/ktoolbarbutton.cpp \ 159 kdeui/ktoolbarbutton.cpp \
158 kdeui/ktoolbarhandler.cpp \ 160 kdeui/ktoolbarhandler.cpp \
159 kdeui/kxmlguiclient.cpp \ 161 kdeui/kxmlguiclient.cpp \
160 kio/kfile/kurlrequester.cpp \ 162 kio/kfile/kurlrequester.cpp \
161 kio/kio/kdirwatch.cpp \ 163 kio/kio/kdirwatch.cpp \
162 kresources/configpage.cpp \ 164 kresources/configpage.cpp \
163 kresources/configdialog.cpp \ 165 kresources/configdialog.cpp \
164 kresources/configwidget.cpp \ 166 kresources/configwidget.cpp \
165 kresources/factory.cpp \ 167 kresources/factory.cpp \
166 kresources/kcmkresources.cpp \ 168 kresources/kcmkresources.cpp \
167 kresources/managerimpl.cpp \ 169 kresources/managerimpl.cpp \
168 kresources/resource.cpp \ 170 kresources/resource.cpp \
169 kresources/selectdialog.cpp \ 171 kresources/selectdialog.cpp \
170 kutils/kcmultidialog.cpp \ 172 kutils/kcmultidialog.cpp \
171 kidmanager.cpp 173 kidmanager.cpp
172 174