summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-07 16:10:09 (UTC)
committer zautrix <zautrix>2004-08-07 16:10:09 (UTC)
commitef8a09ce74ad3f0a51484d03fdf009bd5b3677bf (patch) (unidiff)
tree7ff6c37e8ad6b7f1dbd672d28de6fcea916caf8f
parenta9a774e19c02f03de948b6064804b913abd4f08b (diff)
downloadkdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.zip
kdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.tar.gz
kdepimpi-ef8a09ce74ad3f0a51484d03fdf009bd5b3677bf.tar.bz2
Fix of the syncprofiles
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/resource.cpp4
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/koprefs.h3
-rw-r--r--korganizer/mainwindow.cpp16
-rw-r--r--korganizer/mainwindow.h1
-rw-r--r--libkdepim/ksyncprofile.cpp15
-rw-r--r--libkdepim/ksyncprofile.h5
8 files changed, 32 insertions, 17 deletions
diff --git a/kabc/resource.cpp b/kabc/resource.cpp
index d39fd6a..7b91239 100644
--- a/kabc/resource.cpp
+++ b/kabc/resource.cpp
@@ -1,144 +1,144 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22Enhanced Version of the file for platform independent KDE tools. 22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk 23Copyright (c) 2004 Ulf Schenk
24 24
25$Id$ 25$Id$
26*/ 26*/
27 27
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include <ksyncprofile.h> 30#include <ksyncprofile.h>
31 31
32#include "resource.h" 32#include "resource.h"
33 33
34using namespace KABC; 34using namespace KABC;
35 35
36Resource::Resource( const KConfig *config, bool syncable ) 36Resource::Resource( const KConfig *config, bool syncable )
37 : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 ) 37 : KRES::Resource( config ), mAddressBook( 0 ), mSyncProfile( 0 )
38{ 38{
39 if(syncable == true) { 39 if(syncable == true) {
40 mSyncProfile = new KSyncProfile( identifier() ); 40 mSyncProfile = new KSyncProfile( );
41 mSyncProfile->setName(resourceName()); 41 mSyncProfile->setName("pending" /*resourceName()*/);
42 mSyncProfile->readConfig( (KConfig *)config ); 42 mSyncProfile->readConfig( (KConfig *)config );
43 } 43 }
44} 44}
45 45
46Resource::~Resource() 46Resource::~Resource()
47{ 47{
48 if (mSyncProfile != 0) { 48 if (mSyncProfile != 0) {
49 delete mSyncProfile; 49 delete mSyncProfile;
50 } 50 }
51} 51}
52 52
53void Resource::writeConfig( KConfig *config ) 53void Resource::writeConfig( KConfig *config )
54{ 54{
55 KRES::Resource::writeConfig( config ); 55 KRES::Resource::writeConfig( config );
56 56
57 if(mSyncProfile != 0) 57 if(mSyncProfile != 0)
58 mSyncProfile->writeConfig( config ); 58 mSyncProfile->writeConfig( config );
59} 59}
60 60
61 61
62void Resource::setAddressBook( AddressBook *ab ) 62void Resource::setAddressBook( AddressBook *ab )
63{ 63{
64 mAddressBook = ab; 64 mAddressBook = ab;
65} 65}
66 66
67AddressBook *Resource::addressBook() 67AddressBook *Resource::addressBook()
68{ 68{
69 return mAddressBook; 69 return mAddressBook;
70} 70}
71 71
72bool Resource::doOpen() 72bool Resource::doOpen()
73{ 73{
74 return true; 74 return true;
75} 75}
76 76
77void Resource::doClose() 77void Resource::doClose()
78{ 78{
79} 79}
80 80
81Ticket *Resource::requestSaveTicket() 81Ticket *Resource::requestSaveTicket()
82{ 82{
83 return 0; 83 return 0;
84} 84}
85 85
86bool Resource::load() 86bool Resource::load()
87{ 87{
88 return true; 88 return true;
89} 89}
90 90
91bool Resource::save( Ticket * ) 91bool Resource::save( Ticket * )
92{ 92{
93 return false; 93 return false;
94} 94}
95 95
96Ticket *Resource::createTicket( Resource *resource ) 96Ticket *Resource::createTicket( Resource *resource )
97{ 97{
98 return new Ticket( resource ); 98 return new Ticket( resource );
99} 99}
100 100
101void Resource::removeAddressee( const Addressee& ) 101void Resource::removeAddressee( const Addressee& )
102{ 102{
103 // do nothing 103 // do nothing
104} 104}
105 105
106void Resource::cleanUp() 106void Resource::cleanUp()
107{ 107{
108 // do nothing 108 // do nothing
109} 109}
110 110
111bool Resource::isSyncable() const 111bool Resource::isSyncable() const
112{ 112{
113 return (mSyncProfile != 0); 113 return (mSyncProfile != 0);
114} 114}
115 115
116KSyncProfile* Resource::getSyncProfile() 116KSyncProfile* Resource::getSyncProfile()
117{ 117{
118 return mSyncProfile; 118 return mSyncProfile;
119} 119}
120 120
121 121
122QString Resource::fileName() const 122QString Resource::fileName() const
123{ 123{
124 return mFileName; 124 return mFileName;
125} 125}
126 126
127void Resource::setFileName( const QString &fileName ) 127void Resource::setFileName( const QString &fileName )
128{ 128{
129 mFileName = fileName; 129 mFileName = fileName;
130} 130}
131 131
132/** 132/**
133 * Set the name of resource.You can override this method, 133 * Set the name of resource.You can override this method,
134 * but also remember to call Resource::setResourceName(). 134 * but also remember to call Resource::setResourceName().
135 */ 135 */
136void Resource::setResourceName( const QString &name ) 136void Resource::setResourceName( const QString &name )
137{ 137{
138 KRES::Resource::setResourceName(name); 138 KRES::Resource::setResourceName(name);
139 if(mSyncProfile != 0) { 139 if(mSyncProfile != 0) {
140 mSyncProfile->setName( name ); 140 mSyncProfile->setName( name );
141 } 141 }
142 142
143} 143}
144 144
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index f859b90..689618d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3510 +1,3514 @@
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 (preston.brown@yale.edu) 8 Preston Brown (preston.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 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132 132
133 133
134class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
135{ 135{
136 public: 136 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
139 { 139 {
140 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 145 lay->addWidget( format );
146 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 151 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 154 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 156 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 158 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 161 resize( 200, 200 );
162 } 162 }
163 163
164 bool beamVcal() { return vcal->isChecked(); } 164 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 165 bool beamLocal() { return local->isChecked(); }
166private: 166private:
167 QRadioButton* vcal, *ical, *local, *tz; 167 QRadioButton* vcal, *ical, *local, *tz;
168}; 168};
169class KOCatPrefs : public QDialog 169class KOCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 185 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201 201
202 202
203CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 206 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
208{ 208{
209 209
210 mEventEditor = 0; 210 mEventEditor = 0;
211 mTodoEditor = 0; 211 mTodoEditor = 0;
212 212
213 init(); 213 init();
214} 214}
215 215
216CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 219 mCalendar( calendar ),
220 mResourceManager( 0 ) 220 mResourceManager( 0 )
221{ 221{
222 222
223 mEventEditor = 0; 223 mEventEditor = 0;
224 mTodoEditor = 0; 224 mTodoEditor = 0;
225 init();} 225 init();}
226 226
227void CalendarView::init() 227void CalendarView::init()
228{ 228{
229 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 230 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
232 writeLocale(); 232 writeLocale();
233 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
236 mModified = false; 236 mModified = false;
237 mReadOnly = false; 237 mReadOnly = false;
238 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
239 mCalPrinter = 0; 239 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
241 241
242 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
244 244
245 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 247
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 250 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
253 253
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 257
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 263
264#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 265 mResourceView = 0;
266#else 266#else
267 if ( mResourceManager ) { 267 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 269 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
272 } else { 272 } else {
273 mResourceView = 0; 273 mResourceView = 0;
274 } 274 }
275#endif 275#endif
276 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
278 278
279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
280 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
281 281
282 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
283 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
284 284
285 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
286#else 286#else
287 QWidget *mainBox = new QWidget( this ); 287 QWidget *mainBox = new QWidget( this );
288 QWidget *leftFrame = new QWidget( mainBox ); 288 QWidget *leftFrame = new QWidget( mainBox );
289 289
290 QBoxLayout * mainBoxLayout; 290 QBoxLayout * mainBoxLayout;
291 QBoxLayout * leftFrameLayout; 291 QBoxLayout * leftFrameLayout;
292 if ( KOPrefs::instance()->mVerticalScreen ) { 292 if ( KOPrefs::instance()->mVerticalScreen ) {
293 mainBoxLayout = new QVBoxLayout(mainBox); 293 mainBoxLayout = new QVBoxLayout(mainBox);
294 leftFrameLayout = new QHBoxLayout(leftFrame ); 294 leftFrameLayout = new QHBoxLayout(leftFrame );
295 } else { 295 } else {
296 mainBoxLayout = new QHBoxLayout(mainBox); 296 mainBoxLayout = new QHBoxLayout(mainBox);
297 leftFrameLayout = new QVBoxLayout(leftFrame ); 297 leftFrameLayout = new QVBoxLayout(leftFrame );
298 } 298 }
299 topLayout->addWidget( mainBox ); 299 topLayout->addWidget( mainBox );
300 mainBoxLayout->addWidget (leftFrame); 300 mainBoxLayout->addWidget (leftFrame);
301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
302 "CalendarView::DateNavigator", QDate::currentDate()); 302 "CalendarView::DateNavigator", QDate::currentDate());
303 // mDateNavigator->blockSignals( true ); 303 // mDateNavigator->blockSignals( true );
304 leftFrameLayout->addWidget( mDateNavigator ); 304 leftFrameLayout->addWidget( mDateNavigator );
305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
307 307
308 if ( QApplication::desktop()->width() < 480 ) { 308 if ( QApplication::desktop()->width() < 480 ) {
309 leftFrameLayout->addWidget(mFilterView); 309 leftFrameLayout->addWidget(mFilterView);
310 leftFrameLayout->addWidget(mTodoList, 2 ); 310 leftFrameLayout->addWidget(mTodoList, 2 );
311 311
312 } else { 312 } else {
313 leftFrameLayout->addWidget(mTodoList,2 ); 313 leftFrameLayout->addWidget(mTodoList,2 );
314 leftFrameLayout->addWidget(mFilterView ); 314 leftFrameLayout->addWidget(mFilterView );
315 } 315 }
316 mFilterView->hide(); 316 mFilterView->hide();
317 QWidget *rightBox = new QWidget( mainBox ); 317 QWidget *rightBox = new QWidget( mainBox );
318 mainBoxLayout->addWidget ( rightBox, 10 ); 318 mainBoxLayout->addWidget ( rightBox, 10 );
319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
321 mRightFrame = new QWidgetStack( rightBox ); 321 mRightFrame = new QWidgetStack( rightBox );
322 rightLayout->addWidget( mNavigatorBar ); 322 rightLayout->addWidget( mNavigatorBar );
323 rightLayout->addWidget( mRightFrame, 10 ); 323 rightLayout->addWidget( mRightFrame, 10 );
324 324
325 mLeftFrame = leftFrame; 325 mLeftFrame = leftFrame;
326 if ( KOPrefs::instance()->mVerticalScreen ) { 326 if ( KOPrefs::instance()->mVerticalScreen ) {
327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
329 } else { 329 } else {
330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
332 } 332 }
333 333
334 //qDebug("Calendarview Size %d %d ", width(), height()); 334 //qDebug("Calendarview Size %d %d ", width(), height());
335#endif 335#endif
336 336
337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
338 SLOT( showDates( const KCal::DateList & ) ) ); 338 SLOT( showDates( const KCal::DateList & ) ) );
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
341 341
342 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 342 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
343 mNavigator, SLOT( selectPreviousYear() ) ); 343 mNavigator, SLOT( selectPreviousYear() ) );
344 connect( mNavigatorBar, SIGNAL( goNextYear() ), 344 connect( mNavigatorBar, SIGNAL( goNextYear() ),
345 mNavigator, SLOT( selectNextYear() ) ); 345 mNavigator, SLOT( selectNextYear() ) );
346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
347 mNavigator, SLOT( selectPreviousMonth() ) ); 347 mNavigator, SLOT( selectPreviousMonth() ) );
348 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 348 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
349 mNavigator, SLOT( selectNextMonth() ) ); 349 mNavigator, SLOT( selectNextMonth() ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
353 353
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 374
375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
379 SLOT( eventAdded( Event *) ) ); 379 SLOT( eventAdded( Event *) ) );
380 380
381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
382 382
383 connect( this, SIGNAL( configChanged() ), 383 connect( this, SIGNAL( configChanged() ),
384 mDateNavigator, SLOT( updateConfig() ) ); 384 mDateNavigator, SLOT( updateConfig() ) );
385 385
386 connect( mTodoList, SIGNAL( newTodoSignal() ), 386 connect( mTodoList, SIGNAL( newTodoSignal() ),
387 SLOT( newTodo() ) ); 387 SLOT( newTodo() ) );
388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
389 SLOT( newSubTodo( Todo * ) ) ); 389 SLOT( newSubTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
391 SLOT( editTodo( Todo * ) ) ); 391 SLOT( editTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
393 SLOT( showTodo( Todo *) ) ); 393 SLOT( showTodo( Todo *) ) );
394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
395 SLOT( deleteTodo( Todo *) ) ); 395 SLOT( deleteTodo( Todo *) ) );
396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
398 SLOT( purgeCompleted() ) ); 398 SLOT( purgeCompleted() ) );
399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
400 SIGNAL( todoModified( Todo *, int ) ) ); 400 SIGNAL( todoModified( Todo *, int ) ) );
401 401
402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
403 this, SLOT ( cloneIncidence( Incidence * ) ) ); 403 this, SLOT ( cloneIncidence( Incidence * ) ) );
404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
405 this, SLOT (cancelIncidence( Incidence * ) ) ); 405 this, SLOT (cancelIncidence( Incidence * ) ) );
406 406
407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
408 this, SLOT ( moveIncidence( Incidence * ) ) ); 408 this, SLOT ( moveIncidence( Incidence * ) ) );
409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
410 this, SLOT ( beamIncidence( Incidence * ) ) ); 410 this, SLOT ( beamIncidence( Incidence * ) ) );
411 411
412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
413 this, SLOT ( todo_unsub( Todo * ) ) ); 413 this, SLOT ( todo_unsub( Todo * ) ) );
414 414
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 419
420 420
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 425
426 426
427 427
428 428
429 429
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 435
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 494
495} 495}
496 496
497void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
498{ 498{
499 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
500} 500}
501 501
502void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
503{ 503{
504 504
505 QString mess = msg; 505 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
509 QString tempfilename; 509 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 511 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 513 if ( len < 2 )
514 error = true; 514 error = true;
515 else { 515 else {
516 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
518 error = true; 518 error = true;
519 } 519 }
520 if ( ! error ) { 520 if ( ! error ) {
521 filename = tempfilename; 521 filename = tempfilename;
522 } 522 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 529 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
531 return; 531 return;
532 } 532 }
533 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 534 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 536 if ( len < 2 )
537 error = true; 537 error = true;
538 else { 538 else {
539 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
541 error = true; 541 error = true;
542 } 542 }
543 if ( error ) { 543 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 546 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 549#ifndef _WIN32_
550 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
552 return; 552 return;
553 } 553 }
554#else 554#else
555 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
557 p->start(); 557 p->start();
558 return; 558 return;
559#endif 559#endif
560 560
561 return; 561 return;
562 } 562 }
563 563
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 565 }
566 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 567 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 569 if ( len < 2 )
570 error = true; 570 error = true;
571 else { 571 else {
572 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
574 error = true; 574 error = true;
575 } 575 }
576 if ( ! error ) { 576 if ( ! error ) {
577 filename = tempfilename; 577 filename = tempfilename;
578 } 578 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 581 }
582 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
584 } 584 }
585 585
586 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
587 587
588 588
589} 589}
590 590
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 592{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 594
595 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
599 599
600} 600}
601 601
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 603{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 608#endif
609 return; 609 return;
610 } 610 }
611 int maxSec; 611 int maxSec;
612 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 614 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 619 return;
620 } else { 620 } else {
621 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
622 } 622 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
625 625
626} 626}
627// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 628// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
630{ 630{
631 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
634} 634}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 636{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 641#endif
642 return; 642 return;
643 } 643 }
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645} 645}
646void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
647{ 647{
648 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
650} 650}
651KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
652{ 652{
653 return mViewManager; 653 return mViewManager;
654} 654}
655 655
656KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
657{ 657{
658 return mDialogManager; 658 return mDialogManager;
659} 659}
660 660
661QDate CalendarView::startDate() 661QDate CalendarView::startDate()
662{ 662{
663 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
664 664
665 return dates.first(); 665 return dates.first();
666} 666}
667 667
668QDate CalendarView::endDate() 668QDate CalendarView::endDate()
669{ 669{
670 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
671 671
672 return dates.last(); 672 return dates.last();
673} 673}
674 674
675 675
676void CalendarView::createPrinter() 676void CalendarView::createPrinter()
677{ 677{
678#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 679 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 682 }
683#endif 683#endif
684} 684}
685 685
686void CalendarView::confSync() 686void CalendarView::confSync()
687{ 687{
688 static KSyncPrefsDialog* sp = 0; 688 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 689 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 691 }
692 sp->usrReadConfig(); 692 sp->usrReadConfig();
693#ifndef DESKTOP_VERSION 693#ifndef DESKTOP_VERSION
694 sp->showMaximized(); 694 sp->showMaximized();
695#else 695#else
696 sp->show(); 696 sp->show();
697#endif 697#endif
698 sp->exec(); 698 sp->exec();
699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 //void setZaurusId(int id); 717 //void setZaurusId(int id);
718 // int zaurusId() const; 718 // int zaurusId() const;
719 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
720 // int zaurusUid() const; 720 // int zaurusUid() const;
721 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
722 // int zaurusStat() const; 722 // int zaurusStat() const;
723 // 0 equal 723 // 0 equal
724 // 1 take local 724 // 1 take local
725 // 2 take remote 725 // 2 take remote
726 // 3 cancel 726 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 729 bool remCh, locCh;
730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 734 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
736 } else { 736 } else {
737 if ( locCh ) { 737 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 740 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 742 } else {
743 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
744 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
745 if ( remCh ) 745 if ( remCh )
746 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
747 747
748 } 748 }
749 } 749 }
750 full = true; 750 full = true;
751 if ( mode < SYNC_PREF_ASK ) 751 if ( mode < SYNC_PREF_ASK )
752 mode = SYNC_PREF_ASK; 752 mode = SYNC_PREF_ASK;
753 } else { 753 } else {
754 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
755 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
756 return 0; 756 return 0;
757 757
758 } 758 }
759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
760 760
761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
763 //full = true; //debug only 763 //full = true; //debug only
764 if ( full ) { 764 if ( full ) {
765 bool equ = false; 765 bool equ = false;
766 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
767 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
768 } 768 }
769 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
770 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
771 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
772 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
773 if ( equ ) { 773 if ( equ ) {
774 //qDebug("equal "); 774 //qDebug("equal ");
775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
776 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 776 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
777 } 777 }
778 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
779 return 0; 779 return 0;
780 780
781 }//else //debug only 781 }//else //debug only
782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
783 } 783 }
784 int result; 784 int result;
785 bool localIsNew; 785 bool localIsNew;
786 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
787 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
788 788
789 switch( mode ) { 789 switch( mode ) {
790 case SYNC_PREF_LOCAL: 790 case SYNC_PREF_LOCAL:
791 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
792 return 1; 792 return 1;
793 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
794 return 2; 794 return 2;
795 return 1; 795 return 1;
796 break; 796 break;
797 case SYNC_PREF_REMOTE: 797 case SYNC_PREF_REMOTE:
798 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
799 return 1; 799 return 1;
800 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
801 return 2; 801 return 2;
802 return 2; 802 return 2;
803 break; 803 break;
804 case SYNC_PREF_NEWEST: 804 case SYNC_PREF_NEWEST:
805 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
806 return 1; 806 return 1;
807 else 807 else
808 return 2; 808 return 2;
809 break; 809 break;
810 case SYNC_PREF_ASK: 810 case SYNC_PREF_ASK:
811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
812 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
813 return 1; 813 return 1;
814 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
815 return 2; 815 return 2;
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
817 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
818 if ( localIsNew ) 818 if ( localIsNew )
819 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
820 else 820 else
821 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
822 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
823 if ( localIsNew ) 823 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
825 else 825 else
826 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
827 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
828 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
831 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
832 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
833 return result; 833 return result;
834 834
835 break; 835 break;
836 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
837 return 1; 837 return 1;
838 break; 838 break;
839 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
840 return 2; 840 return 2;
841 break; 841 break;
842 842
843 default: 843 default:
844 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
845 break; 845 break;
846 } 846 }
847 return 0; 847 return 0;
848} 848}
849Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
850{ 850{
851 Event* lse; 851 Event* lse;
852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
853 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
854 if (!lse) { 854 if (!lse) {
855 lse = new Event(); 855 lse = new Event();
856 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
857 QString sum = ""; 857 QString sum = "";
858 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 858 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
859 sum = "E: "; 859 sum = "E: ";
860 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 860 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
861 lse->setDtStart( mLastCalendarSync ); 861 lse->setDtStart( mLastCalendarSync );
862 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 862 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
863 lse->setCategories( i18n("SyncEvent") ); 863 lse->setCategories( i18n("SyncEvent") );
864 lse->setReadOnly( true ); 864 lse->setReadOnly( true );
865 mCalendar->addEvent( lse ); 865 mCalendar->addEvent( lse );
866 } 866 }
867 867
868 return lse; 868 return lse;
869 869
870} 870}
871// probaly useless 871// probaly useless
872void CalendarView::setupExternSyncProfiles() 872void CalendarView::setupExternSyncProfiles()
873{ 873{
874 Event* lse; 874 Event* lse;
875 mExternLastSyncEvent.clear(); 875 mExternLastSyncEvent.clear();
876 int i; 876 int i;
877 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 877 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
878 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 878 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
879 if ( lse ) 879 if ( lse )
880 mExternLastSyncEvent.append( lse ); 880 mExternLastSyncEvent.append( lse );
881 else 881 else
882 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 882 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
883 } 883 }
884 884
885} 885}
886// we check, if the to delete event has a id for a profile 886// we check, if the to delete event has a id for a profile
887// if yes, we set this id in the profile to delete 887// if yes, we set this id in the profile to delete
888void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 888void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
889{ 889{
890 if ( lastSync.count() == 0 ) { 890 if ( lastSync.count() == 0 ) {
891 //qDebug(" lastSync.count() == 0"); 891 //qDebug(" lastSync.count() == 0");
892 return; 892 return;
893 } 893 }
894 if ( toDelete->type() == "Journal" ) 894 if ( toDelete->type() == "Journal" )
895 return; 895 return;
896 896
897 Event* eve = lastSync.first(); 897 Event* eve = lastSync.first();
898 898
899 while ( eve ) { 899 while ( eve ) {
900 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 900 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
901 if ( !id.isEmpty() ) { 901 if ( !id.isEmpty() ) {
902 QString des = eve->description(); 902 QString des = eve->description();
903 QString pref = "e"; 903 QString pref = "e";
904 if ( toDelete->type() == "Todo" ) 904 if ( toDelete->type() == "Todo" )
905 pref = "t"; 905 pref = "t";
906 des += pref+ id + ","; 906 des += pref+ id + ",";
907 eve->setReadOnly( false ); 907 eve->setReadOnly( false );
908 eve->setDescription( des ); 908 eve->setDescription( des );
909 //qDebug("setdes %s ", des.latin1()); 909 //qDebug("setdes %s ", des.latin1());
910 eve->setReadOnly( true ); 910 eve->setReadOnly( true );
911 } 911 }
912 eve = lastSync.next(); 912 eve = lastSync.next();
913 } 913 }
914 914
915} 915}
916void CalendarView::checkExternalId( Incidence * inc ) 916void CalendarView::checkExternalId( Incidence * inc )
917{ 917{
918 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 918 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
919 checkExternSyncEvent( lastSync, inc ); 919 checkExternSyncEvent( lastSync, inc );
920 920
921} 921}
922bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 922bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
923{ 923{
924 bool syncOK = true; 924 bool syncOK = true;
925 int addedEvent = 0; 925 int addedEvent = 0;
926 int addedEventR = 0; 926 int addedEventR = 0;
927 int deletedEventR = 0; 927 int deletedEventR = 0;
928 int deletedEventL = 0; 928 int deletedEventL = 0;
929 int changedLocal = 0; 929 int changedLocal = 0;
930 int changedRemote = 0; 930 int changedRemote = 0;
931 //QPtrList<Event> el = local->rawEvents(); 931 //QPtrList<Event> el = local->rawEvents();
932 Event* eventR; 932 Event* eventR;
933 QString uid; 933 QString uid;
934 int take; 934 int take;
935 Event* eventL; 935 Event* eventL;
936 Event* eventRSync; 936 Event* eventRSync;
937 Event* eventLSync; 937 Event* eventLSync;
938 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 938 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
939 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 939 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
940 bool fullDateRange = false; 940 bool fullDateRange = false;
941 mLastCalendarSync = QDateTime::currentDateTime(); 941 mLastCalendarSync = QDateTime::currentDateTime();
942 QDateTime modifiedCalendar = mLastCalendarSync;; 942 QDateTime modifiedCalendar = mLastCalendarSync;;
943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
944 if ( eventR ) { 944 if ( eventR ) {
945 eventRSync = (Event*) eventR->clone(); 945 eventRSync = (Event*) eventR->clone();
946 remote->deleteEvent(eventR ); 946 remote->deleteEvent(eventR );
947 947
948 } else { 948 } else {
949 fullDateRange = true; 949 fullDateRange = true;
950 eventRSync = new Event(); 950 eventRSync = new Event();
951 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 951 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
952 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 952 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
953 eventRSync->setDtStart( mLastCalendarSync ); 953 eventRSync->setDtStart( mLastCalendarSync );
954 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 954 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
955 eventRSync->setCategories( i18n("SyncEvent") ); 955 eventRSync->setCategories( i18n("SyncEvent") );
956 } 956 }
957 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
958 if ( eventLSync->dtStart() == mLastCalendarSync ) 958 if ( eventLSync->dtStart() == mLastCalendarSync )
959 fullDateRange = true; 959 fullDateRange = true;
960 960
961 if ( ! fullDateRange ) { 961 if ( ! fullDateRange ) {
962 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 962 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
963 963
964 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 964 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
965 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 965 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
966 fullDateRange = true; 966 fullDateRange = true;
967 } 967 }
968 } 968 }
969 if ( fullDateRange ) 969 if ( fullDateRange )
970 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 970 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
971 else 971 else
972 mLastCalendarSync = eventLSync->dtStart(); 972 mLastCalendarSync = eventLSync->dtStart();
973 // for resyncing if own file has changed 973 // for resyncing if own file has changed
974 if ( mCurrentSyncDevice == "deleteaftersync" ) { 974 if ( mCurrentSyncDevice == "deleteaftersync" ) {
975 mLastCalendarSync = loadedFileVersion; 975 mLastCalendarSync = loadedFileVersion;
976 qDebug("setting mLastCalendarSync "); 976 qDebug("setting mLastCalendarSync ");
977 } 977 }
978 //qDebug("*************************** "); 978 //qDebug("*************************** ");
979 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 979 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
980 QPtrList<Incidence> er = remote->rawIncidences(); 980 QPtrList<Incidence> er = remote->rawIncidences();
981 Incidence* inR = er.first(); 981 Incidence* inR = er.first();
982 Incidence* inL; 982 Incidence* inL;
983 QProgressBar bar( er.count(),0 ); 983 QProgressBar bar( er.count(),0 );
984 bar.setCaption (i18n("Syncing - close to abort!") ); 984 bar.setCaption (i18n("Syncing - close to abort!") );
985 985
986 int w = 300; 986 int w = 300;
987 if ( QApplication::desktop()->width() < 320 ) 987 if ( QApplication::desktop()->width() < 320 )
988 w = 220; 988 w = 220;
989 int h = bar.sizeHint().height() ; 989 int h = bar.sizeHint().height() ;
990 int dw = QApplication::desktop()->width(); 990 int dw = QApplication::desktop()->width();
991 int dh = QApplication::desktop()->height(); 991 int dh = QApplication::desktop()->height();
992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
993 bar.show(); 993 bar.show();
994 int modulo = (er.count()/10)+1; 994 int modulo = (er.count()/10)+1;
995 int incCounter = 0; 995 int incCounter = 0;
996 while ( inR ) { 996 while ( inR ) {
997 if ( ! bar.isVisible() ) 997 if ( ! bar.isVisible() )
998 return false; 998 return false;
999 if ( incCounter % modulo == 0 ) 999 if ( incCounter % modulo == 0 )
1000 bar.setProgress( incCounter ); 1000 bar.setProgress( incCounter );
1001 ++incCounter; 1001 ++incCounter;
1002 uid = inR->uid(); 1002 uid = inR->uid();
1003 bool skipIncidence = false; 1003 bool skipIncidence = false;
1004 if ( uid.left(15) == QString("last-syncEvent-") ) 1004 if ( uid.left(15) == QString("last-syncEvent-") )
1005 skipIncidence = true; 1005 skipIncidence = true;
1006 1006
1007 qApp->processEvents(); 1007 qApp->processEvents();
1008 if ( !skipIncidence ) { 1008 if ( !skipIncidence ) {
1009 inL = local->incidence( uid ); 1009 inL = local->incidence( uid );
1010 if ( inL ) { // maybe conflict - same uid in both calendars 1010 if ( inL ) { // maybe conflict - same uid in both calendars
1011 int maxrev = inL->revision(); 1011 int maxrev = inL->revision();
1012 if ( maxrev < inR->revision() ) 1012 if ( maxrev < inR->revision() )
1013 maxrev = inR->revision(); 1013 maxrev = inR->revision();
1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1015 //qDebug("take %d %s ", take, inL->summary().latin1()); 1015 //qDebug("take %d %s ", take, inL->summary().latin1());
1016 if ( take == 3 ) 1016 if ( take == 3 )
1017 return false; 1017 return false;
1018 if ( take == 1 ) {// take local 1018 if ( take == 1 ) {// take local
1019 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1019 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1020 remote->deleteIncidence( inR ); 1020 remote->deleteIncidence( inR );
1021 if ( inL->revision() < maxrev ) 1021 if ( inL->revision() < maxrev )
1022 inL->setRevision( maxrev ); 1022 inL->setRevision( maxrev );
1023 remote->addIncidence( inL->clone() ); 1023 remote->addIncidence( inL->clone() );
1024 ++changedRemote; 1024 ++changedRemote;
1025 } else { 1025 } else {
1026 if ( inR->revision() < maxrev ) 1026 if ( inR->revision() < maxrev )
1027 inR->setRevision( maxrev ); 1027 inR->setRevision( maxrev );
1028 local->deleteIncidence( inL ); 1028 local->deleteIncidence( inL );
1029 local->addIncidence( inR->clone() ); 1029 local->addIncidence( inR->clone() );
1030 ++changedLocal; 1030 ++changedLocal;
1031 } 1031 }
1032 } 1032 }
1033 } else { // no conflict 1033 } else { // no conflict
1034 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1034 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1035 QString des = eventLSync->description(); 1035 QString des = eventLSync->description();
1036 QString pref = "e"; 1036 QString pref = "e";
1037 if ( inR->type() == "Todo" ) 1037 if ( inR->type() == "Todo" )
1038 pref = "t"; 1038 pref = "t";
1039 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1039 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1040 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1040 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1041 //remote->deleteIncidence( inR ); 1041 //remote->deleteIncidence( inR );
1042 ++deletedEventR; 1042 ++deletedEventR;
1043 } else { 1043 } else {
1044 inR->setLastModified( modifiedCalendar ); 1044 inR->setLastModified( modifiedCalendar );
1045 local->addIncidence( inR->clone() ); 1045 local->addIncidence( inR->clone() );
1046 ++addedEvent; 1046 ++addedEvent;
1047 } 1047 }
1048 } else { 1048 } else {
1049 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1049 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1050 inR->setLastModified( modifiedCalendar ); 1050 inR->setLastModified( modifiedCalendar );
1051 local->addIncidence( inR->clone() ); 1051 local->addIncidence( inR->clone() );
1052 ++addedEvent; 1052 ++addedEvent;
1053 } else { 1053 } else {
1054 checkExternSyncEvent(eventRSyncSharp, inR); 1054 checkExternSyncEvent(eventRSyncSharp, inR);
1055 remote->deleteIncidence( inR ); 1055 remote->deleteIncidence( inR );
1056 ++deletedEventR; 1056 ++deletedEventR;
1057 } 1057 }
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 inR = er.next(); 1061 inR = er.next();
1062 } 1062 }
1063 QPtrList<Incidence> el = local->rawIncidences(); 1063 QPtrList<Incidence> el = local->rawIncidences();
1064 inL = el.first(); 1064 inL = el.first();
1065 modulo = (el.count()/10)+1; 1065 modulo = (el.count()/10)+1;
1066 bar.setCaption (i18n("Add / remove events") ); 1066 bar.setCaption (i18n("Add / remove events") );
1067 bar.setTotalSteps ( el.count() ) ; 1067 bar.setTotalSteps ( el.count() ) ;
1068 bar.show(); 1068 bar.show();
1069 incCounter = 0; 1069 incCounter = 0;
1070 1070
1071 while ( inL ) { 1071 while ( inL ) {
1072 1072
1073 qApp->processEvents(); 1073 qApp->processEvents();
1074 if ( ! bar.isVisible() ) 1074 if ( ! bar.isVisible() )
1075 return false; 1075 return false;
1076 if ( incCounter % modulo == 0 ) 1076 if ( incCounter % modulo == 0 )
1077 bar.setProgress( incCounter ); 1077 bar.setProgress( incCounter );
1078 ++incCounter; 1078 ++incCounter;
1079 uid = inL->uid(); 1079 uid = inL->uid();
1080 bool skipIncidence = false; 1080 bool skipIncidence = false;
1081 if ( uid.left(15) == QString("last-syncEvent-") ) 1081 if ( uid.left(15) == QString("last-syncEvent-") )
1082 skipIncidence = true; 1082 skipIncidence = true;
1083 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1083 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1084 skipIncidence = true; 1084 skipIncidence = true;
1085 if ( !skipIncidence ) { 1085 if ( !skipIncidence ) {
1086 inR = remote->incidence( uid ); 1086 inR = remote->incidence( uid );
1087 if ( ! inR ) { 1087 if ( ! inR ) {
1088 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1088 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1089 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1089 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1090 local->deleteIncidence( inL ); 1090 local->deleteIncidence( inL );
1091 ++deletedEventL; 1091 ++deletedEventL;
1092 } else { 1092 } else {
1093 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1093 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1094 inL->removeID(mCurrentSyncDevice ); 1094 inL->removeID(mCurrentSyncDevice );
1095 ++addedEventR; 1095 ++addedEventR;
1096 inL->setLastModified( modifiedCalendar ); 1096 inL->setLastModified( modifiedCalendar );
1097 remote->addIncidence( inL->clone() ); 1097 remote->addIncidence( inL->clone() );
1098 } 1098 }
1099 } 1099 }
1100 } else { 1100 } else {
1101 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1101 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1102 checkExternSyncEvent(eventLSyncSharp, inL); 1102 checkExternSyncEvent(eventLSyncSharp, inL);
1103 local->deleteIncidence( inL ); 1103 local->deleteIncidence( inL );
1104 ++deletedEventL; 1104 ++deletedEventL;
1105 } else { 1105 } else {
1106 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1106 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1107 ++addedEventR; 1107 ++addedEventR;
1108 inL->setLastModified( modifiedCalendar ); 1108 inL->setLastModified( modifiedCalendar );
1109 remote->addIncidence( inL->clone() ); 1109 remote->addIncidence( inL->clone() );
1110 } 1110 }
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 inL = el.next(); 1115 inL = el.next();
1116 } 1116 }
1117 1117
1118 bar.hide(); 1118 bar.hide();
1119 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1119 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1120 eventLSync->setReadOnly( false ); 1120 eventLSync->setReadOnly( false );
1121 eventLSync->setDtStart( mLastCalendarSync ); 1121 eventLSync->setDtStart( mLastCalendarSync );
1122 eventRSync->setDtStart( mLastCalendarSync ); 1122 eventRSync->setDtStart( mLastCalendarSync );
1123 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1123 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1124 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1125 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1126 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1126 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1127 eventLSync->setReadOnly( true ); 1127 eventLSync->setReadOnly( true );
1128 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1128 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1129 remote->addEvent( eventRSync ); 1129 remote->addEvent( eventRSync );
1130 QString mes; 1130 QString mes;
1131 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1131 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1132 if ( KOPrefs::instance()->mShowSyncSummary ) { 1132 if ( KOPrefs::instance()->mShowSyncSummary ) {
1133 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1133 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1134 } 1134 }
1135 qDebug( mes ); 1135 qDebug( mes );
1136 mCalendar->checkAlarmForIncidence( 0, true ); 1136 mCalendar->checkAlarmForIncidence( 0, true );
1137 return syncOK; 1137 return syncOK;
1138} 1138}
1139 1139
1140void CalendarView::setSyncDevice( QString s ) 1140void CalendarView::setSyncDevice( QString s )
1141{ 1141{
1142 mCurrentSyncDevice= s; 1142 mCurrentSyncDevice= s;
1143} 1143}
1144void CalendarView::setSyncName( QString s ) 1144void CalendarView::setSyncName( QString s )
1145{ 1145{
1146 mCurrentSyncName= s; 1146 mCurrentSyncName= s;
1147} 1147}
1148bool CalendarView::syncCalendar(QString filename, int mode) 1148bool CalendarView::syncCalendar(QString filename, int mode)
1149{ 1149{
1150 mGlobalSyncMode = SYNC_MODE_NORMAL; 1150 mGlobalSyncMode = SYNC_MODE_NORMAL;
1151 CalendarLocal* calendar = new CalendarLocal(); 1151 CalendarLocal* calendar = new CalendarLocal();
1152 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1152 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1153 FileStorage* storage = new FileStorage( calendar ); 1153 FileStorage* storage = new FileStorage( calendar );
1154 bool syncOK = false; 1154 bool syncOK = false;
1155 storage->setFileName( filename ); 1155 storage->setFileName( filename );
1156 // qDebug("loading ... "); 1156 // qDebug("loading ... ");
1157 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1157 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1158 getEventViewerDialog()->setSyncMode( true ); 1158 getEventViewerDialog()->setSyncMode( true );
1159 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1159 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1160 getEventViewerDialog()->setSyncMode( false ); 1160 getEventViewerDialog()->setSyncMode( false );
1161 if ( syncOK ) { 1161 if ( syncOK ) {
1162 if ( KOPrefs::instance()->mWriteBackFile ) 1162 if ( KOPrefs::instance()->mWriteBackFile )
1163 { 1163 {
1164 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1164 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1165 storage->save(); 1165 storage->save();
1166 } 1166 }
1167 } 1167 }
1168 setModified( true ); 1168 setModified( true );
1169 } 1169 }
1170 delete storage; 1170 delete storage;
1171 delete calendar; 1171 delete calendar;
1172 if ( syncOK ) 1172 if ( syncOK )
1173 updateView(); 1173 updateView();
1174 return syncOK; 1174 return syncOK;
1175} 1175}
1176void CalendarView::syncPhone()
1177{
1178 qDebug("CalendarView::syncPhone() ");
1179}
1176void CalendarView::syncSharp() 1180void CalendarView::syncSharp()
1177{ 1181{
1178#ifndef DESKTOP_VERSION 1182#ifndef DESKTOP_VERSION
1179 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1180 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1181 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1182 edit_sync_options(); 1186 edit_sync_options();
1183 qApp->processEvents(); 1187 qApp->processEvents();
1184 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1185 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1186 bool syncOK = false; 1190 bool syncOK = false;
1187 SharpFormat sharpFormat; 1191 SharpFormat sharpFormat;
1188 if ( sharpFormat.load( calendar, mCalendar ) ) { 1192 if ( sharpFormat.load( calendar, mCalendar ) ) {
1189 getEventViewerDialog()->setSyncMode( true ); 1193 getEventViewerDialog()->setSyncMode( true );
1190 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1194 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1191 getEventViewerDialog()->setSyncMode( false ); 1195 getEventViewerDialog()->setSyncMode( false );
1192 qApp->processEvents(); 1196 qApp->processEvents();
1193 if ( syncOK ) { 1197 if ( syncOK ) {
1194 if ( KOPrefs::instance()->mWriteBackFile ) 1198 if ( KOPrefs::instance()->mWriteBackFile )
1195 { 1199 {
1196 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1200 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1197 Incidence* inc = iL.first(); 1201 Incidence* inc = iL.first();
1198 /* obsolete 1202 /* obsolete
1199 while ( inc ) { 1203 while ( inc ) {
1200 inc->setZaurusStat( inc->revision () ); 1204 inc->setZaurusStat( inc->revision () );
1201 inc = iL.next(); 1205 inc = iL.next();
1202 } 1206 }
1203 */ 1207 */
1204 // pending: clean last sync event description 1208 // pending: clean last sync event description
1205 sharpFormat.save(calendar); 1209 sharpFormat.save(calendar);
1206 iL = calendar->rawIncidences(); 1210 iL = calendar->rawIncidences();
1207 inc = iL.first(); 1211 inc = iL.first();
1208 Incidence* loc; 1212 Incidence* loc;
1209 while ( inc ) { 1213 while ( inc ) {
1210 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1214 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1211 loc = mCalendar->incidence(inc->uid() ); 1215 loc = mCalendar->incidence(inc->uid() );
1212 if ( loc ) { 1216 if ( loc ) {
1213 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1217 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1214 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1218 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1215 } 1219 }
1216 } 1220 }
1217 inc = iL.next(); 1221 inc = iL.next();
1218 } 1222 }
1219 Incidence* lse = getLastSyncEvent(); 1223 Incidence* lse = getLastSyncEvent();
1220 if ( lse ) { 1224 if ( lse ) {
1221 lse->setReadOnly( false ); 1225 lse->setReadOnly( false );
1222 lse->setDescription( "" ); 1226 lse->setDescription( "" );
1223 lse->setReadOnly( true ); 1227 lse->setReadOnly( true );
1224 } 1228 }
1225 } 1229 }
1226 } 1230 }
1227 setModified( true ); 1231 setModified( true );
1228 } else { 1232 } else {
1229 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1233 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1230 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1234 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1231 question, i18n("Ok")) ; 1235 question, i18n("Ok")) ;
1232 1236
1233 } 1237 }
1234 delete calendar; 1238 delete calendar;
1235 updateView(); 1239 updateView();
1236 return ;//syncOK; 1240 return ;//syncOK;
1237#endif 1241#endif
1238} 1242}
1239 1243
1240 1244
1241#include <kabc/stdaddressbook.h> 1245#include <kabc/stdaddressbook.h>
1242bool CalendarView::importBday() 1246bool CalendarView::importBday()
1243{ 1247{
1244 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1248 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1245 KABC::AddressBook::Iterator it; 1249 KABC::AddressBook::Iterator it;
1246 int count = 0; 1250 int count = 0;
1247 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1251 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1248 ++count; 1252 ++count;
1249 } 1253 }
1250 QProgressBar bar(count,0 ); 1254 QProgressBar bar(count,0 );
1251 int w = 300; 1255 int w = 300;
1252 if ( QApplication::desktop()->width() < 320 ) 1256 if ( QApplication::desktop()->width() < 320 )
1253 w = 220; 1257 w = 220;
1254 int h = bar.sizeHint().height() ; 1258 int h = bar.sizeHint().height() ;
1255 int dw = QApplication::desktop()->width(); 1259 int dw = QApplication::desktop()->width();
1256 int dh = QApplication::desktop()->height(); 1260 int dh = QApplication::desktop()->height();
1257 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1261 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1258 bar.show(); 1262 bar.show();
1259 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1263 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1260 qApp->processEvents(); 1264 qApp->processEvents();
1261 count = 0; 1265 count = 0;
1262 int addCount = 0; 1266 int addCount = 0;
1263 KCal::Attendee* a = 0; 1267 KCal::Attendee* a = 0;
1264 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1268 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1265 if ( ! bar.isVisible() ) 1269 if ( ! bar.isVisible() )
1266 return false; 1270 return false;
1267 bar.setProgress( count++ ); 1271 bar.setProgress( count++ );
1268 qApp->processEvents(); 1272 qApp->processEvents();
1269 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1273 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1270 if ( (*it).birthday().date().isValid() ){ 1274 if ( (*it).birthday().date().isValid() ){
1271 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1275 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1272 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1276 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1273 ++addCount; 1277 ++addCount;
1274 } 1278 }
1275 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1279 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1276 if ( anni.isValid() ){ 1280 if ( anni.isValid() ){
1277 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1281 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1278 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1282 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1279 ++addCount; 1283 ++addCount;
1280 } 1284 }
1281 } 1285 }
1282 updateView(); 1286 updateView();
1283 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1287 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1284 return true; 1288 return true;
1285} 1289}
1286 1290
1287bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1291bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1288{ 1292{
1289 //qDebug("addAnni "); 1293 //qDebug("addAnni ");
1290 Event * ev = new Event(); 1294 Event * ev = new Event();
1291 if ( a ) { 1295 if ( a ) {
1292 ev->addAttendee( a ); 1296 ev->addAttendee( a );
1293 } 1297 }
1294 QString kind; 1298 QString kind;
1295 if ( birthday ) 1299 if ( birthday )
1296 kind = i18n( "Birthday" ); 1300 kind = i18n( "Birthday" );
1297 else 1301 else
1298 kind = i18n( "Anniversary" ); 1302 kind = i18n( "Anniversary" );
1299 ev->setSummary( name + " - " + kind ); 1303 ev->setSummary( name + " - " + kind );
1300 ev->setOrganizer( "nobody@nowhere" ); 1304 ev->setOrganizer( "nobody@nowhere" );
1301 ev->setCategories( kind ); 1305 ev->setCategories( kind );
1302 ev->setDtStart( QDateTime(date) ); 1306 ev->setDtStart( QDateTime(date) );
1303 ev->setDtEnd( QDateTime(date) ); 1307 ev->setDtEnd( QDateTime(date) );
1304 ev->setFloats( true ); 1308 ev->setFloats( true );
1305 Recurrence * rec = ev->recurrence(); 1309 Recurrence * rec = ev->recurrence();
1306 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1310 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1307 rec->addYearlyNum( date.month() ); 1311 rec->addYearlyNum( date.month() );
1308 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1312 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1309 delete ev; 1313 delete ev;
1310 return false; 1314 return false;
1311 } 1315 }
1312 return true; 1316 return true;
1313 1317
1314} 1318}
1315bool CalendarView::importQtopia( const QString &categories, 1319bool CalendarView::importQtopia( const QString &categories,
1316 const QString &datebook, 1320 const QString &datebook,
1317 const QString &todolist ) 1321 const QString &todolist )
1318{ 1322{
1319 1323
1320 QtopiaFormat qtopiaFormat; 1324 QtopiaFormat qtopiaFormat;
1321 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1325 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1322 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1326 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1323 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1327 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1324 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1328 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1325 1329
1326 updateView(); 1330 updateView();
1327 return true; 1331 return true;
1328 1332
1329#if 0 1333#if 0
1330 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1334 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1331 mCurrentSyncDevice = "qtopia-XML"; 1335 mCurrentSyncDevice = "qtopia-XML";
1332 if ( KOPrefs::instance()->mAskForPreferences ) 1336 if ( KOPrefs::instance()->mAskForPreferences )
1333 edit_sync_options(); 1337 edit_sync_options();
1334 qApp->processEvents(); 1338 qApp->processEvents();
1335 CalendarLocal* calendar = new CalendarLocal(); 1339 CalendarLocal* calendar = new CalendarLocal();
1336 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1340 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1337 bool syncOK = false; 1341 bool syncOK = false;
1338 QtopiaFormat qtopiaFormat; 1342 QtopiaFormat qtopiaFormat;
1339 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1343 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1340 bool loadOk = true; 1344 bool loadOk = true;
1341 if ( !categories.isEmpty() ) 1345 if ( !categories.isEmpty() )
1342 loadOk = qtopiaFormat.load( calendar, categories ); 1346 loadOk = qtopiaFormat.load( calendar, categories );
1343 if ( loadOk && !datebook.isEmpty() ) 1347 if ( loadOk && !datebook.isEmpty() )
1344 loadOk = qtopiaFormat.load( calendar, datebook ); 1348 loadOk = qtopiaFormat.load( calendar, datebook );
1345 if ( loadOk && !todolist.isEmpty() ) 1349 if ( loadOk && !todolist.isEmpty() )
1346 loadOk = qtopiaFormat.load( calendar, todolist ); 1350 loadOk = qtopiaFormat.load( calendar, todolist );
1347 1351
1348 if ( loadOk ) { 1352 if ( loadOk ) {
1349 getEventViewerDialog()->setSyncMode( true ); 1353 getEventViewerDialog()->setSyncMode( true );
1350 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1354 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1351 getEventViewerDialog()->setSyncMode( false ); 1355 getEventViewerDialog()->setSyncMode( false );
1352 qApp->processEvents(); 1356 qApp->processEvents();
1353 if ( syncOK ) { 1357 if ( syncOK ) {
1354 if ( KOPrefs::instance()->mWriteBackFile ) 1358 if ( KOPrefs::instance()->mWriteBackFile )
1355 { 1359 {
1356 // write back XML file 1360 // write back XML file
1357 1361
1358 } 1362 }
1359 setModified( true ); 1363 setModified( true );
1360 } 1364 }
1361 } else { 1365 } else {
1362 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1366 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1363 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1367 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1364 question, i18n("Ok")) ; 1368 question, i18n("Ok")) ;
1365 } 1369 }
1366 delete calendar; 1370 delete calendar;
1367 updateView(); 1371 updateView();
1368 return syncOK; 1372 return syncOK;
1369 1373
1370 1374
1371#endif 1375#endif
1372 1376
1373} 1377}
1374 1378
1375void CalendarView::setSyncEventsReadOnly() 1379void CalendarView::setSyncEventsReadOnly()
1376{ 1380{
1377 Event * ev; 1381 Event * ev;
1378 QPtrList<Event> eL = mCalendar->rawEvents(); 1382 QPtrList<Event> eL = mCalendar->rawEvents();
1379 ev = eL.first(); 1383 ev = eL.first();
1380 while ( ev ) { 1384 while ( ev ) {
1381 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1385 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1382 ev->setReadOnly( true ); 1386 ev->setReadOnly( true );
1383 ev = eL.next(); 1387 ev = eL.next();
1384 } 1388 }
1385} 1389}
1386bool CalendarView::openCalendar(QString filename, bool merge) 1390bool CalendarView::openCalendar(QString filename, bool merge)
1387{ 1391{
1388 1392
1389 if (filename.isEmpty()) { 1393 if (filename.isEmpty()) {
1390 return false; 1394 return false;
1391 } 1395 }
1392 1396
1393 if (!QFile::exists(filename)) { 1397 if (!QFile::exists(filename)) {
1394 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1398 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1395 return false; 1399 return false;
1396 } 1400 }
1397 1401
1398 globalFlagBlockAgenda = 1; 1402 globalFlagBlockAgenda = 1;
1399 if (!merge) mCalendar->close(); 1403 if (!merge) mCalendar->close();
1400 1404
1401 mStorage->setFileName( filename ); 1405 mStorage->setFileName( filename );
1402 1406
1403 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1407 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1404 if ( merge ) ;//setModified( true ); 1408 if ( merge ) ;//setModified( true );
1405 else { 1409 else {
1406 //setModified( true ); 1410 //setModified( true );
1407 mViewManager->setDocumentId( filename ); 1411 mViewManager->setDocumentId( filename );
1408 mDialogManager->setDocumentId( filename ); 1412 mDialogManager->setDocumentId( filename );
1409 mTodoList->setDocumentId( filename ); 1413 mTodoList->setDocumentId( filename );
1410 } 1414 }
1411 globalFlagBlockAgenda = 2; 1415 globalFlagBlockAgenda = 2;
1412 // if ( getLastSyncEvent() ) 1416 // if ( getLastSyncEvent() )
1413 // getLastSyncEvent()->setReadOnly( true ); 1417 // getLastSyncEvent()->setReadOnly( true );
1414 mCalendar->reInitAlarmSettings(); 1418 mCalendar->reInitAlarmSettings();
1415 setSyncEventsReadOnly(); 1419 setSyncEventsReadOnly();
1416 updateUnmanagedViews(); 1420 updateUnmanagedViews();
1417 updateView(); 1421 updateView();
1418 if ( filename != MainWindow::defaultFileName() ) 1422 if ( filename != MainWindow::defaultFileName() )
1419 saveCalendar( MainWindow::defaultFileName() ); 1423 saveCalendar( MainWindow::defaultFileName() );
1420 loadedFileVersion = QDateTime::currentDateTime(); 1424 loadedFileVersion = QDateTime::currentDateTime();
1421 return true; 1425 return true;
1422 } else { 1426 } else {
1423 // while failing to load, the calendar object could 1427 // while failing to load, the calendar object could
1424 // have become partially populated. Clear it out. 1428 // have become partially populated. Clear it out.
1425 if ( !merge ) mCalendar->close(); 1429 if ( !merge ) mCalendar->close();
1426 1430
1427 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1431 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1428 1432
1429 globalFlagBlockAgenda = 2; 1433 globalFlagBlockAgenda = 2;
1430 updateView(); 1434 updateView();
1431 } 1435 }
1432 return false; 1436 return false;
1433} 1437}
1434void CalendarView::setLoadedFileVersion(QDateTime dt) 1438void CalendarView::setLoadedFileVersion(QDateTime dt)
1435{ 1439{
1436 loadedFileVersion = dt; 1440 loadedFileVersion = dt;
1437} 1441}
1438bool CalendarView::checkFileChanged(QString fn) 1442bool CalendarView::checkFileChanged(QString fn)
1439{ 1443{
1440 QFileInfo finf ( fn ); 1444 QFileInfo finf ( fn );
1441 if ( !finf.exists() ) 1445 if ( !finf.exists() )
1442 return true; 1446 return true;
1443 QDateTime dt = finf.lastModified (); 1447 QDateTime dt = finf.lastModified ();
1444 if ( dt <= loadedFileVersion ) 1448 if ( dt <= loadedFileVersion )
1445 return false; 1449 return false;
1446 return true; 1450 return true;
1447 1451
1448} 1452}
1449bool CalendarView::checkFileVersion(QString fn) 1453bool CalendarView::checkFileVersion(QString fn)
1450{ 1454{
1451 QFileInfo finf ( fn ); 1455 QFileInfo finf ( fn );
1452 if ( !finf.exists() ) 1456 if ( !finf.exists() )
1453 return true; 1457 return true;
1454 QDateTime dt = finf.lastModified (); 1458 QDateTime dt = finf.lastModified ();
1455 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1459 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1456 //qDebug("file on disk version %s",dt.toString().latin1()); 1460 //qDebug("file on disk version %s",dt.toString().latin1());
1457 if ( dt <= loadedFileVersion ) 1461 if ( dt <= loadedFileVersion )
1458 return true; 1462 return true;
1459 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1463 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1460 i18n("KO/Pi Warning"),i18n("Overwrite"), 1464 i18n("KO/Pi Warning"),i18n("Overwrite"),
1461 i18n("Sync+save")); 1465 i18n("Sync+save"));
1462 1466
1463 if ( km == KMessageBox::Cancel ) 1467 if ( km == KMessageBox::Cancel )
1464 return false; 1468 return false;
1465 if ( km == KMessageBox::Yes ) 1469 if ( km == KMessageBox::Yes )
1466 return true; 1470 return true;
1467 1471
1468 setSyncDevice("deleteaftersync" ); 1472 setSyncDevice("deleteaftersync" );
1469 KOPrefs::instance()->mAskForPreferences = true; 1473 KOPrefs::instance()->mAskForPreferences = true;
1470 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1474 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1471 KOPrefs::instance()->mWriteBackFile = false; 1475 KOPrefs::instance()->mWriteBackFile = false;
1472 KOPrefs::instance()->mWriteBackExistingOnly = false; 1476 KOPrefs::instance()->mWriteBackExistingOnly = false;
1473 KOPrefs::instance()->mShowSyncSummary = false; 1477 KOPrefs::instance()->mShowSyncSummary = false;
1474 syncCalendar( fn, 3 ); 1478 syncCalendar( fn, 3 );
1475 Event * e = getLastSyncEvent(); 1479 Event * e = getLastSyncEvent();
1476 mCalendar->deleteEvent ( e ); 1480 mCalendar->deleteEvent ( e );
1477 updateView(); 1481 updateView();
1478 return true; 1482 return true;
1479} 1483}
1480 1484
1481bool CalendarView::saveCalendar( QString filename ) 1485bool CalendarView::saveCalendar( QString filename )
1482{ 1486{
1483 1487
1484 // Store back all unsaved data into calendar object 1488 // Store back all unsaved data into calendar object
1485 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1489 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1486 if ( mViewManager->currentView() ) 1490 if ( mViewManager->currentView() )
1487 mViewManager->currentView()->flushView(); 1491 mViewManager->currentView()->flushView();
1488 1492
1489 //mStorage->setFileName( filename ); 1493 //mStorage->setFileName( filename );
1490 1494
1491 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1495 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1492 mStorage->setFileName( filename ); 1496 mStorage->setFileName( filename );
1493 bool success; 1497 bool success;
1494 success = mStorage->save(); 1498 success = mStorage->save();
1495 if ( !success ) { 1499 if ( !success ) {
1496 return false; 1500 return false;
1497 } 1501 }
1498 1502
1499 return true; 1503 return true;
1500} 1504}
1501 1505
1502void CalendarView::closeCalendar() 1506void CalendarView::closeCalendar()
1503{ 1507{
1504 1508
1505 // child windows no longer valid 1509 // child windows no longer valid
1506 emit closingDown(); 1510 emit closingDown();
1507 1511
1508 mCalendar->close(); 1512 mCalendar->close();
1509 setModified(false); 1513 setModified(false);
1510 updateView(); 1514 updateView();
1511} 1515}
1512 1516
1513void CalendarView::archiveCalendar() 1517void CalendarView::archiveCalendar()
1514{ 1518{
1515 mDialogManager->showArchiveDialog(); 1519 mDialogManager->showArchiveDialog();
1516} 1520}
1517 1521
1518 1522
1519void CalendarView::readSettings() 1523void CalendarView::readSettings()
1520{ 1524{
1521 1525
1522 1526
1523 // mViewManager->showAgendaView(); 1527 // mViewManager->showAgendaView();
1524 QString str; 1528 QString str;
1525 //qDebug("CalendarView::readSettings() "); 1529 //qDebug("CalendarView::readSettings() ");
1526 // read settings from the KConfig, supplying reasonable 1530 // read settings from the KConfig, supplying reasonable
1527 // defaults where none are to be found 1531 // defaults where none are to be found
1528 KConfig *config = KOGlobals::config(); 1532 KConfig *config = KOGlobals::config();
1529#ifndef KORG_NOSPLITTER 1533#ifndef KORG_NOSPLITTER
1530 config->setGroup("KOrganizer Geometry"); 1534 config->setGroup("KOrganizer Geometry");
1531 1535
1532 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1536 QValueList<int> sizes = config->readIntListEntry("Separator1");
1533 if (sizes.count() != 2) { 1537 if (sizes.count() != 2) {
1534 sizes << mDateNavigator->minimumSizeHint().width(); 1538 sizes << mDateNavigator->minimumSizeHint().width();
1535 sizes << 300; 1539 sizes << 300;
1536 } 1540 }
1537 mPanner->setSizes(sizes); 1541 mPanner->setSizes(sizes);
1538 1542
1539 sizes = config->readIntListEntry("Separator2"); 1543 sizes = config->readIntListEntry("Separator2");
1540 if ( ( mResourceView && sizes.count() == 4 ) || 1544 if ( ( mResourceView && sizes.count() == 4 ) ||
1541 ( !mResourceView && sizes.count() == 3 ) ) { 1545 ( !mResourceView && sizes.count() == 3 ) ) {
1542 mLeftSplitter->setSizes(sizes); 1546 mLeftSplitter->setSizes(sizes);
1543 } 1547 }
1544#endif 1548#endif
1545 globalFlagBlockAgenda = 1; 1549 globalFlagBlockAgenda = 1;
1546 mViewManager->showAgendaView(); 1550 mViewManager->showAgendaView();
1547 //mViewManager->readSettings( config ); 1551 //mViewManager->readSettings( config );
1548 mTodoList->restoreLayout(config,QString("Todo Layout")); 1552 mTodoList->restoreLayout(config,QString("Todo Layout"));
1549 readFilterSettings(config); 1553 readFilterSettings(config);
1550 config->setGroup( "Views" ); 1554 config->setGroup( "Views" );
1551 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1555 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1552 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1556 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1553 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1557 else if ( dateCount == 7 ) mNavigator->selectWeek();
1554 else mNavigator->selectDates( dateCount ); 1558 else mNavigator->selectDates( dateCount );
1555 // mViewManager->readSettings( config ); 1559 // mViewManager->readSettings( config );
1556 updateConfig(); 1560 updateConfig();
1557 globalFlagBlockAgenda = 2; 1561 globalFlagBlockAgenda = 2;
1558 mViewManager->readSettings( config ); 1562 mViewManager->readSettings( config );
1559#ifdef DESKTOP_VERSION 1563#ifdef DESKTOP_VERSION
1560 config->setGroup("WidgetLayout"); 1564 config->setGroup("WidgetLayout");
1561 QStringList list; 1565 QStringList list;
1562 list = config->readListEntry("MainLayout"); 1566 list = config->readListEntry("MainLayout");
1563 int x,y,w,h; 1567 int x,y,w,h;
1564 if ( ! list.isEmpty() ) { 1568 if ( ! list.isEmpty() ) {
1565 x = list[0].toInt(); 1569 x = list[0].toInt();
1566 y = list[1].toInt(); 1570 y = list[1].toInt();
1567 w = list[2].toInt(); 1571 w = list[2].toInt();
1568 h = list[3].toInt(); 1572 h = list[3].toInt();
1569 topLevelWidget()->setGeometry(x,y,w,h); 1573 topLevelWidget()->setGeometry(x,y,w,h);
1570 1574
1571 } else { 1575 } else {
1572 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1576 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1573 } 1577 }
1574 list = config->readListEntry("EditEventLayout"); 1578 list = config->readListEntry("EditEventLayout");
1575 if ( ! list.isEmpty() ) { 1579 if ( ! list.isEmpty() ) {
1576 x = list[0].toInt(); 1580 x = list[0].toInt();
1577 y = list[1].toInt(); 1581 y = list[1].toInt();
1578 w = list[2].toInt(); 1582 w = list[2].toInt();
1579 h = list[3].toInt(); 1583 h = list[3].toInt();
1580 mEventEditor->setGeometry(x,y,w,h); 1584 mEventEditor->setGeometry(x,y,w,h);
1581 1585
1582 } 1586 }
1583 list = config->readListEntry("EditTodoLayout"); 1587 list = config->readListEntry("EditTodoLayout");
1584 if ( ! list.isEmpty() ) { 1588 if ( ! list.isEmpty() ) {
1585 x = list[0].toInt(); 1589 x = list[0].toInt();
1586 y = list[1].toInt(); 1590 y = list[1].toInt();
1587 w = list[2].toInt(); 1591 w = list[2].toInt();
1588 h = list[3].toInt(); 1592 h = list[3].toInt();
1589 mTodoEditor->setGeometry(x,y,w,h); 1593 mTodoEditor->setGeometry(x,y,w,h);
1590 1594
1591 } 1595 }
1592 list = config->readListEntry("ViewerLayout"); 1596 list = config->readListEntry("ViewerLayout");
1593 if ( ! list.isEmpty() ) { 1597 if ( ! list.isEmpty() ) {
1594 x = list[0].toInt(); 1598 x = list[0].toInt();
1595 y = list[1].toInt(); 1599 y = list[1].toInt();
1596 w = list[2].toInt(); 1600 w = list[2].toInt();
1597 h = list[3].toInt(); 1601 h = list[3].toInt();
1598 getEventViewerDialog()->setGeometry(x,y,w,h); 1602 getEventViewerDialog()->setGeometry(x,y,w,h);
1599 } 1603 }
1600#endif 1604#endif
1601 1605
1602} 1606}
1603 1607
1604 1608
1605void CalendarView::writeSettings() 1609void CalendarView::writeSettings()
1606{ 1610{
1607 // kdDebug() << "CalendarView::writeSettings" << endl; 1611 // kdDebug() << "CalendarView::writeSettings" << endl;
1608 1612
1609 KConfig *config = KOGlobals::config(); 1613 KConfig *config = KOGlobals::config();
1610 1614
1611#ifndef KORG_NOSPLITTER 1615#ifndef KORG_NOSPLITTER
1612 config->setGroup("KOrganizer Geometry"); 1616 config->setGroup("KOrganizer Geometry");
1613 1617
1614 QValueList<int> list = mPanner->sizes(); 1618 QValueList<int> list = mPanner->sizes();
1615 config->writeEntry("Separator1",list); 1619 config->writeEntry("Separator1",list);
1616 1620
1617 list = mLeftSplitter->sizes(); 1621 list = mLeftSplitter->sizes();
1618 config->writeEntry("Separator2",list); 1622 config->writeEntry("Separator2",list);
1619#endif 1623#endif
1620 1624
1621 mViewManager->writeSettings( config ); 1625 mViewManager->writeSettings( config );
1622 mTodoList->saveLayout(config,QString("Todo Layout")); 1626 mTodoList->saveLayout(config,QString("Todo Layout"));
1623 mDialogManager->writeSettings( config ); 1627 mDialogManager->writeSettings( config );
1624 //KOPrefs::instance()->usrWriteConfig(); 1628 //KOPrefs::instance()->usrWriteConfig();
1625 KOPrefs::instance()->writeConfig(); 1629 KOPrefs::instance()->writeConfig();
1626 1630
1627 writeFilterSettings(config); 1631 writeFilterSettings(config);
1628 1632
1629 config->setGroup( "Views" ); 1633 config->setGroup( "Views" );
1630 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1634 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1631 1635
1632#ifdef DESKTOP_VERSION 1636#ifdef DESKTOP_VERSION
1633 config->setGroup("WidgetLayout"); 1637 config->setGroup("WidgetLayout");
1634 QStringList list ;//= config->readListEntry("MainLayout"); 1638 QStringList list ;//= config->readListEntry("MainLayout");
1635 int x,y,w,h; 1639 int x,y,w,h;
1636 QWidget* wid; 1640 QWidget* wid;
1637 wid = topLevelWidget(); 1641 wid = topLevelWidget();
1638 x = wid->geometry().x(); 1642 x = wid->geometry().x();
1639 y = wid->geometry().y(); 1643 y = wid->geometry().y();
1640 w = wid->width(); 1644 w = wid->width();
1641 h = wid->height(); 1645 h = wid->height();
1642 list.clear(); 1646 list.clear();
1643 list << QString::number( x ); 1647 list << QString::number( x );
1644 list << QString::number( y ); 1648 list << QString::number( y );
1645 list << QString::number( w ); 1649 list << QString::number( w );
1646 list << QString::number( h ); 1650 list << QString::number( h );
1647 config->writeEntry("MainLayout",list ); 1651 config->writeEntry("MainLayout",list );
1648 1652
1649 wid = mEventEditor; 1653 wid = mEventEditor;
1650 x = wid->geometry().x(); 1654 x = wid->geometry().x();
1651 y = wid->geometry().y(); 1655 y = wid->geometry().y();
1652 w = wid->width(); 1656 w = wid->width();
1653 h = wid->height(); 1657 h = wid->height();
1654 list.clear(); 1658 list.clear();
1655 list << QString::number( x ); 1659 list << QString::number( x );
1656 list << QString::number( y ); 1660 list << QString::number( y );
1657 list << QString::number( w ); 1661 list << QString::number( w );
1658 list << QString::number( h ); 1662 list << QString::number( h );
1659 config->writeEntry("EditEventLayout",list ); 1663 config->writeEntry("EditEventLayout",list );
1660 1664
1661 wid = mTodoEditor; 1665 wid = mTodoEditor;
1662 x = wid->geometry().x(); 1666 x = wid->geometry().x();
1663 y = wid->geometry().y(); 1667 y = wid->geometry().y();
1664 w = wid->width(); 1668 w = wid->width();
1665 h = wid->height(); 1669 h = wid->height();
1666 list.clear(); 1670 list.clear();
1667 list << QString::number( x ); 1671 list << QString::number( x );
1668 list << QString::number( y ); 1672 list << QString::number( y );
1669 list << QString::number( w ); 1673 list << QString::number( w );
1670 list << QString::number( h ); 1674 list << QString::number( h );
1671 config->writeEntry("EditTodoLayout",list ); 1675 config->writeEntry("EditTodoLayout",list );
1672 wid = getEventViewerDialog(); 1676 wid = getEventViewerDialog();
1673 x = wid->geometry().x(); 1677 x = wid->geometry().x();
1674 y = wid->geometry().y(); 1678 y = wid->geometry().y();
1675 w = wid->width(); 1679 w = wid->width();
1676 h = wid->height(); 1680 h = wid->height();
1677 list.clear(); 1681 list.clear();
1678 list << QString::number( x ); 1682 list << QString::number( x );
1679 list << QString::number( y ); 1683 list << QString::number( y );
1680 list << QString::number( w ); 1684 list << QString::number( w );
1681 list << QString::number( h ); 1685 list << QString::number( h );
1682 config->writeEntry("ViewerLayout",list ); 1686 config->writeEntry("ViewerLayout",list );
1683 wid = mDialogManager->getSearchDialog(); 1687 wid = mDialogManager->getSearchDialog();
1684 if ( wid ) { 1688 if ( wid ) {
1685 x = wid->geometry().x(); 1689 x = wid->geometry().x();
1686 y = wid->geometry().y(); 1690 y = wid->geometry().y();
1687 w = wid->width(); 1691 w = wid->width();
1688 h = wid->height(); 1692 h = wid->height();
1689 list.clear(); 1693 list.clear();
1690 list << QString::number( x ); 1694 list << QString::number( x );
1691 list << QString::number( y ); 1695 list << QString::number( y );
1692 list << QString::number( w ); 1696 list << QString::number( w );
1693 list << QString::number( h ); 1697 list << QString::number( h );
1694 config->writeEntry("SearchLayout",list ); 1698 config->writeEntry("SearchLayout",list );
1695 } 1699 }
1696#endif 1700#endif
1697 1701
1698 1702
1699 config->sync(); 1703 config->sync();
1700} 1704}
1701 1705
1702void CalendarView::readFilterSettings(KConfig *config) 1706void CalendarView::readFilterSettings(KConfig *config)
1703{ 1707{
1704 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1708 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1705 1709
1706 mFilters.clear(); 1710 mFilters.clear();
1707 1711
1708 config->setGroup("General"); 1712 config->setGroup("General");
1709 QStringList filterList = config->readListEntry("CalendarFilters"); 1713 QStringList filterList = config->readListEntry("CalendarFilters");
1710 1714
1711 QStringList::ConstIterator it = filterList.begin(); 1715 QStringList::ConstIterator it = filterList.begin();
1712 QStringList::ConstIterator end = filterList.end(); 1716 QStringList::ConstIterator end = filterList.end();
1713 while(it != end) { 1717 while(it != end) {
1714 // kdDebug() << " filter: " << (*it) << endl; 1718 // kdDebug() << " filter: " << (*it) << endl;
1715 1719
1716 CalFilter *filter; 1720 CalFilter *filter;
1717 filter = new CalFilter(*it); 1721 filter = new CalFilter(*it);
1718 config->setGroup("Filter_" + (*it)); 1722 config->setGroup("Filter_" + (*it));
1719 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1723 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1720 filter->setCriteria(config->readNumEntry("Criteria",0)); 1724 filter->setCriteria(config->readNumEntry("Criteria",0));
1721 filter->setCategoryList(config->readListEntry("CategoryList")); 1725 filter->setCategoryList(config->readListEntry("CategoryList"));
1722 mFilters.append(filter); 1726 mFilters.append(filter);
1723 1727
1724 ++it; 1728 ++it;
1725 } 1729 }
1726 1730
1727 if (mFilters.count() == 0) { 1731 if (mFilters.count() == 0) {
1728 CalFilter *filter = new CalFilter(i18n("Default")); 1732 CalFilter *filter = new CalFilter(i18n("Default"));
1729 mFilters.append(filter); 1733 mFilters.append(filter);
1730 } 1734 }
1731 mFilterView->updateFilters(); 1735 mFilterView->updateFilters();
1732 config->setGroup("FilterView"); 1736 config->setGroup("FilterView");
1733 1737
1734 mFilterView->blockSignals(true); 1738 mFilterView->blockSignals(true);
1735 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1739 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1736 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1740 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1737 mFilterView->blockSignals(false); 1741 mFilterView->blockSignals(false);
1738 // We do it manually to avoid it being done twice by the above calls 1742 // We do it manually to avoid it being done twice by the above calls
1739 updateFilter(); 1743 updateFilter();
1740} 1744}
1741 1745
1742void CalendarView::writeFilterSettings(KConfig *config) 1746void CalendarView::writeFilterSettings(KConfig *config)
1743{ 1747{
1744 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1748 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1745 1749
1746 QStringList filterList; 1750 QStringList filterList;
1747 1751
1748 CalFilter *filter = mFilters.first(); 1752 CalFilter *filter = mFilters.first();
1749 while(filter) { 1753 while(filter) {
1750 // kdDebug() << " fn: " << filter->name() << endl; 1754 // kdDebug() << " fn: " << filter->name() << endl;
1751 filterList << filter->name(); 1755 filterList << filter->name();
1752 config->setGroup("Filter_" + filter->name()); 1756 config->setGroup("Filter_" + filter->name());
1753 config->writeEntry("Criteria",filter->criteria()); 1757 config->writeEntry("Criteria",filter->criteria());
1754 config->writeEntry("CategoryList",filter->categoryList()); 1758 config->writeEntry("CategoryList",filter->categoryList());
1755 filter = mFilters.next(); 1759 filter = mFilters.next();
1756 } 1760 }
1757 config->setGroup("General"); 1761 config->setGroup("General");
1758 config->writeEntry("CalendarFilters",filterList); 1762 config->writeEntry("CalendarFilters",filterList);
1759 1763
1760 config->setGroup("FilterView"); 1764 config->setGroup("FilterView");
1761 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1765 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1762 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1766 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1763} 1767}
1764 1768
1765 1769
1766void CalendarView::goToday() 1770void CalendarView::goToday()
1767{ 1771{
1768 mNavigator->selectToday(); 1772 mNavigator->selectToday();
1769} 1773}
1770 1774
1771void CalendarView::goNext() 1775void CalendarView::goNext()
1772{ 1776{
1773 mNavigator->selectNext(); 1777 mNavigator->selectNext();
1774} 1778}
1775 1779
1776void CalendarView::goPrevious() 1780void CalendarView::goPrevious()
1777{ 1781{
1778 mNavigator->selectPrevious(); 1782 mNavigator->selectPrevious();
1779} 1783}
1780void CalendarView::goNextMonth() 1784void CalendarView::goNextMonth()
1781{ 1785{
1782 mNavigator->selectNextMonth(); 1786 mNavigator->selectNextMonth();
1783} 1787}
1784 1788
1785void CalendarView::goPreviousMonth() 1789void CalendarView::goPreviousMonth()
1786{ 1790{
1787 mNavigator->selectPreviousMonth(); 1791 mNavigator->selectPreviousMonth();
1788} 1792}
1789void CalendarView::writeLocale() 1793void CalendarView::writeLocale()
1790{ 1794{
1791 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1795 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1792 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1796 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1793 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1797 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1794 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1798 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1795 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1799 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1796 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1800 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1797 dummy = KOPrefs::instance()->mUserDateFormatShort; 1801 dummy = KOPrefs::instance()->mUserDateFormatShort;
1798 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1802 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1799 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1803 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1800 KOPrefs::instance()->mDaylightsavingStart, 1804 KOPrefs::instance()->mDaylightsavingStart,
1801 KOPrefs::instance()->mDaylightsavingEnd ); 1805 KOPrefs::instance()->mDaylightsavingEnd );
1802 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1806 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1803} 1807}
1804void CalendarView::updateConfig() 1808void CalendarView::updateConfig()
1805{ 1809{
1806 writeLocale(); 1810 writeLocale();
1807 if ( KOPrefs::instance()->mUseAppColors ) 1811 if ( KOPrefs::instance()->mUseAppColors )
1808 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1812 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1809 emit configChanged(); 1813 emit configChanged();
1810 mTodoList->updateConfig(); 1814 mTodoList->updateConfig();
1811 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1815 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1812 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1816 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1813 // To make the "fill window" configurations work 1817 // To make the "fill window" configurations work
1814 //mViewManager->raiseCurrentView(); 1818 //mViewManager->raiseCurrentView();
1815} 1819}
1816 1820
1817 1821
1818void CalendarView::eventChanged(Event *event) 1822void CalendarView::eventChanged(Event *event)
1819{ 1823{
1820 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1824 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1821 //updateUnmanagedViews(); 1825 //updateUnmanagedViews();
1822} 1826}
1823 1827
1824void CalendarView::eventAdded(Event *event) 1828void CalendarView::eventAdded(Event *event)
1825{ 1829{
1826 changeEventDisplay(event,KOGlobals::EVENTADDED); 1830 changeEventDisplay(event,KOGlobals::EVENTADDED);
1827} 1831}
1828 1832
1829void CalendarView::eventToBeDeleted(Event *) 1833void CalendarView::eventToBeDeleted(Event *)
1830{ 1834{
1831 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1835 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1832} 1836}
1833 1837
1834void CalendarView::eventDeleted() 1838void CalendarView::eventDeleted()
1835{ 1839{
1836 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1840 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1837} 1841}
1838void CalendarView::changeTodoDisplay(Todo *which, int action) 1842void CalendarView::changeTodoDisplay(Todo *which, int action)
1839{ 1843{
1840 changeIncidenceDisplay((Incidence *)which, action); 1844 changeIncidenceDisplay((Incidence *)which, action);
1841} 1845}
1842 1846
1843void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1847void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1844{ 1848{
1845 updateUnmanagedViews(); 1849 updateUnmanagedViews();
1846 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1850 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1847 if ( action == KOGlobals::EVENTDELETED ) { //delete 1851 if ( action == KOGlobals::EVENTDELETED ) { //delete
1848 mCalendar->checkAlarmForIncidence( 0, true ); 1852 mCalendar->checkAlarmForIncidence( 0, true );
1849 if ( mEventViewerDialog ) 1853 if ( mEventViewerDialog )
1850 mEventViewerDialog->hide(); 1854 mEventViewerDialog->hide();
1851 } 1855 }
1852 else 1856 else
1853 mCalendar->checkAlarmForIncidence( which , false ); 1857 mCalendar->checkAlarmForIncidence( which , false );
1854} 1858}
1855 1859
1856// most of the changeEventDisplays() right now just call the view's 1860// most of the changeEventDisplays() right now just call the view's
1857// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1861// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1858void CalendarView::changeEventDisplay(Event *which, int action) 1862void CalendarView::changeEventDisplay(Event *which, int action)
1859{ 1863{
1860 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1864 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1861 changeIncidenceDisplay((Incidence *)which, action); 1865 changeIncidenceDisplay((Incidence *)which, action);
1862 mDateNavigator->updateView(); 1866 mDateNavigator->updateView();
1863 //mDialogManager->updateSearchDialog(); 1867 //mDialogManager->updateSearchDialog();
1864 1868
1865 if (which) { 1869 if (which) {
1866 // If there is an event view visible update the display 1870 // If there is an event view visible update the display
1867 mViewManager->currentView()->changeEventDisplay(which,action); 1871 mViewManager->currentView()->changeEventDisplay(which,action);
1868 // TODO: check, if update needed 1872 // TODO: check, if update needed
1869 // if (which->getTodoStatus()) { 1873 // if (which->getTodoStatus()) {
1870 mTodoList->updateView(); 1874 mTodoList->updateView();
1871 // } 1875 // }
1872 } else { 1876 } else {
1873 mViewManager->currentView()->updateView(); 1877 mViewManager->currentView()->updateView();
1874 } 1878 }
1875} 1879}
1876 1880
1877 1881
1878void CalendarView::updateTodoViews() 1882void CalendarView::updateTodoViews()
1879{ 1883{
1880 1884
1881 mTodoList->updateView(); 1885 mTodoList->updateView();
1882 mViewManager->currentView()->updateView(); 1886 mViewManager->currentView()->updateView();
1883 1887
1884} 1888}
1885 1889
1886 1890
1887void CalendarView::updateView(const QDate &start, const QDate &end) 1891void CalendarView::updateView(const QDate &start, const QDate &end)
1888{ 1892{
1889 mTodoList->updateView(); 1893 mTodoList->updateView();
1890 mViewManager->updateView(start, end); 1894 mViewManager->updateView(start, end);
1891 //mDateNavigator->updateView(); 1895 //mDateNavigator->updateView();
1892} 1896}
1893 1897
1894void CalendarView::updateView() 1898void CalendarView::updateView()
1895{ 1899{
1896 DateList tmpList = mNavigator->selectedDates(); 1900 DateList tmpList = mNavigator->selectedDates();
1897 1901
1898 // We assume that the navigator only selects consecutive days. 1902 // We assume that the navigator only selects consecutive days.
1899 updateView( tmpList.first(), tmpList.last() ); 1903 updateView( tmpList.first(), tmpList.last() );
1900} 1904}
1901 1905
1902void CalendarView::updateUnmanagedViews() 1906void CalendarView::updateUnmanagedViews()
1903{ 1907{
1904 mDateNavigator->updateDayMatrix(); 1908 mDateNavigator->updateDayMatrix();
1905} 1909}
1906 1910
1907int CalendarView::msgItemDelete() 1911int CalendarView::msgItemDelete()
1908{ 1912{
1909 return KMessageBox::warningContinueCancel(this, 1913 return KMessageBox::warningContinueCancel(this,
1910 i18n("This item will be\npermanently deleted."), 1914 i18n("This item will be\npermanently deleted."),
1911 i18n("KO/Pi Confirmation"),i18n("Delete")); 1915 i18n("KO/Pi Confirmation"),i18n("Delete"));
1912} 1916}
1913 1917
1914 1918
1915void CalendarView::edit_cut() 1919void CalendarView::edit_cut()
1916{ 1920{
1917 Event *anEvent=0; 1921 Event *anEvent=0;
1918 1922
1919 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1923 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1920 1924
1921 if (mViewManager->currentView()->isEventView()) { 1925 if (mViewManager->currentView()->isEventView()) {
1922 if ( incidence && incidence->type() == "Event" ) { 1926 if ( incidence && incidence->type() == "Event" ) {
1923 anEvent = static_cast<Event *>(incidence); 1927 anEvent = static_cast<Event *>(incidence);
1924 } 1928 }
1925 } 1929 }
1926 1930
1927 if (!anEvent) { 1931 if (!anEvent) {
1928 KNotifyClient::beep(); 1932 KNotifyClient::beep();
1929 return; 1933 return;
1930 } 1934 }
1931 DndFactory factory( mCalendar ); 1935 DndFactory factory( mCalendar );
1932 factory.cutEvent(anEvent); 1936 factory.cutEvent(anEvent);
1933 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1937 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1934} 1938}
1935 1939
1936void CalendarView::edit_copy() 1940void CalendarView::edit_copy()
1937{ 1941{
1938 Event *anEvent=0; 1942 Event *anEvent=0;
1939 1943
1940 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1944 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1941 1945
1942 if (mViewManager->currentView()->isEventView()) { 1946 if (mViewManager->currentView()->isEventView()) {
1943 if ( incidence && incidence->type() == "Event" ) { 1947 if ( incidence && incidence->type() == "Event" ) {
1944 anEvent = static_cast<Event *>(incidence); 1948 anEvent = static_cast<Event *>(incidence);
1945 } 1949 }
1946 } 1950 }
1947 1951
1948 if (!anEvent) { 1952 if (!anEvent) {
1949 KNotifyClient::beep(); 1953 KNotifyClient::beep();
1950 return; 1954 return;
1951 } 1955 }
1952 DndFactory factory( mCalendar ); 1956 DndFactory factory( mCalendar );
1953 factory.copyEvent(anEvent); 1957 factory.copyEvent(anEvent);
1954} 1958}
1955 1959
1956void CalendarView::edit_paste() 1960void CalendarView::edit_paste()
1957{ 1961{
1958 QDate date = mNavigator->selectedDates().first(); 1962 QDate date = mNavigator->selectedDates().first();
1959 1963
1960 DndFactory factory( mCalendar ); 1964 DndFactory factory( mCalendar );
1961 Event *pastedEvent = factory.pasteEvent( date ); 1965 Event *pastedEvent = factory.pasteEvent( date );
1962 1966
1963 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1967 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1964} 1968}
1965 1969
1966void CalendarView::edit_options() 1970void CalendarView::edit_options()
1967{ 1971{
1968 mDialogManager->showOptionsDialog(); 1972 mDialogManager->showOptionsDialog();
1969 //writeSettings(); 1973 //writeSettings();
1970} 1974}
1971void CalendarView::edit_sync_options() 1975void CalendarView::edit_sync_options()
1972{ 1976{
1973 //mDialogManager->showSyncOptions(); 1977 //mDialogManager->showSyncOptions();
1974 //KOPrefs::instance()->mSyncAlgoPrefs 1978 //KOPrefs::instance()->mSyncAlgoPrefs
1975 QDialog dia( this, "dia", true ); 1979 QDialog dia( this, "dia", true );
1976 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1980 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1977 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1981 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1978 QVBoxLayout lay ( &dia ); 1982 QVBoxLayout lay ( &dia );
1979 lay.setSpacing( 2 ); 1983 lay.setSpacing( 2 );
1980 lay.setMargin( 3 ); 1984 lay.setMargin( 3 );
1981 lay.addWidget(&gr); 1985 lay.addWidget(&gr);
1982 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1986 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1983 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1987 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1984 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1988 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1985 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1989 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1986 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1990 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1987 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1991 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1988 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1992 //QRadioButton both( i18n("Take both on conflict"), &gr );
1989 QPushButton pb ( "OK", &dia); 1993 QPushButton pb ( "OK", &dia);
1990 lay.addWidget( &pb ); 1994 lay.addWidget( &pb );
1991 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1995 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1992 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1996 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1993 case 0: 1997 case 0:
1994 loc.setChecked( true); 1998 loc.setChecked( true);
1995 break; 1999 break;
1996 case 1: 2000 case 1:
1997 rem.setChecked( true ); 2001 rem.setChecked( true );
1998 break; 2002 break;
1999 case 2: 2003 case 2:
2000 newest.setChecked( true); 2004 newest.setChecked( true);
2001 break; 2005 break;
2002 case 3: 2006 case 3:
2003 ask.setChecked( true); 2007 ask.setChecked( true);
2004 break; 2008 break;
2005 case 4: 2009 case 4:
2006 f_loc.setChecked( true); 2010 f_loc.setChecked( true);
2007 break; 2011 break;
2008 case 5: 2012 case 5:
2009 f_rem.setChecked( true); 2013 f_rem.setChecked( true);
2010 break; 2014 break;
2011 case 6: 2015 case 6:
2012 // both.setChecked( true); 2016 // both.setChecked( true);
2013 break; 2017 break;
2014 default: 2018 default:
2015 break; 2019 break;
2016 } 2020 }
2017 if ( dia.exec() ) { 2021 if ( dia.exec() ) {
2018 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2022 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2019 } 2023 }
2020 2024
2021} 2025}
2022 2026
2023void CalendarView::slotSelectPickerDate( QDate d) 2027void CalendarView::slotSelectPickerDate( QDate d)
2024{ 2028{
2025 mDateFrame->hide(); 2029 mDateFrame->hide();
2026 if ( mDatePickerMode == 1 ) { 2030 if ( mDatePickerMode == 1 ) {
2027 mNavigator->slotDaySelect( d ); 2031 mNavigator->slotDaySelect( d );
2028 } else if ( mDatePickerMode == 2 ) { 2032 } else if ( mDatePickerMode == 2 ) {
2029 if ( mMoveIncidence->type() == "Todo" ) { 2033 if ( mMoveIncidence->type() == "Todo" ) {
2030 Todo * to = (Todo *) mMoveIncidence; 2034 Todo * to = (Todo *) mMoveIncidence;
2031 QTime tim; 2035 QTime tim;
2032 if ( to->hasDueDate() ) 2036 if ( to->hasDueDate() )
2033 tim = to->dtDue().time(); 2037 tim = to->dtDue().time();
2034 else { 2038 else {
2035 tim = QTime ( 0,0,0 ); 2039 tim = QTime ( 0,0,0 );
2036 to->setFloats( true ); 2040 to->setFloats( true );
2037 to->setHasDueDate( true ); 2041 to->setHasDueDate( true );
2038 } 2042 }
2039 QDateTime dt ( d,tim ); 2043 QDateTime dt ( d,tim );
2040 to->setDtDue( dt ); 2044 to->setDtDue( dt );
2041 todoChanged( to ); 2045 todoChanged( to );
2042 } else { 2046 } else {
2043 QTime tim = mMoveIncidence->dtStart().time(); 2047 QTime tim = mMoveIncidence->dtStart().time();
2044 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2048 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2045 QDateTime dt ( d,tim ); 2049 QDateTime dt ( d,tim );
2046 mMoveIncidence->setDtStart( dt ); 2050 mMoveIncidence->setDtStart( dt );
2047 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2051 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2048 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2052 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2049 } 2053 }
2050 2054
2051 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2055 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2052 } 2056 }
2053} 2057}
2054 2058
2055void CalendarView::removeCategories() 2059void CalendarView::removeCategories()
2056{ 2060{
2057 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2061 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2058 QStringList catList = KOPrefs::instance()->mCustomCategories; 2062 QStringList catList = KOPrefs::instance()->mCustomCategories;
2059 QStringList catIncList; 2063 QStringList catIncList;
2060 QStringList newCatList; 2064 QStringList newCatList;
2061 Incidence* inc = incList.first(); 2065 Incidence* inc = incList.first();
2062 int i; 2066 int i;
2063 int count = 0; 2067 int count = 0;
2064 while ( inc ) { 2068 while ( inc ) {
2065 newCatList.clear(); 2069 newCatList.clear();
2066 catIncList = inc->categories() ; 2070 catIncList = inc->categories() ;
2067 for( i = 0; i< catIncList.count(); ++i ) { 2071 for( i = 0; i< catIncList.count(); ++i ) {
2068 if ( catList.contains (catIncList[i])) 2072 if ( catList.contains (catIncList[i]))
2069 newCatList.append( catIncList[i] ); 2073 newCatList.append( catIncList[i] );
2070 } 2074 }
2071 newCatList.sort(); 2075 newCatList.sort();
2072 inc->setCategories( newCatList.join(",") ); 2076 inc->setCategories( newCatList.join(",") );
2073 inc = incList.next(); 2077 inc = incList.next();
2074 } 2078 }
2075} 2079}
2076 2080
2077int CalendarView::addCategories() 2081int CalendarView::addCategories()
2078{ 2082{
2079 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2083 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2080 QStringList catList = KOPrefs::instance()->mCustomCategories; 2084 QStringList catList = KOPrefs::instance()->mCustomCategories;
2081 QStringList catIncList; 2085 QStringList catIncList;
2082 Incidence* inc = incList.first(); 2086 Incidence* inc = incList.first();
2083 int i; 2087 int i;
2084 int count = 0; 2088 int count = 0;
2085 while ( inc ) { 2089 while ( inc ) {
2086 catIncList = inc->categories() ; 2090 catIncList = inc->categories() ;
2087 for( i = 0; i< catIncList.count(); ++i ) { 2091 for( i = 0; i< catIncList.count(); ++i ) {
2088 if ( !catList.contains (catIncList[i])) { 2092 if ( !catList.contains (catIncList[i])) {
2089 catList.append( catIncList[i] ); 2093 catList.append( catIncList[i] );
2090 //qDebug("add cat %s ", catIncList[i].latin1()); 2094 //qDebug("add cat %s ", catIncList[i].latin1());
2091 ++count; 2095 ++count;
2092 } 2096 }
2093 } 2097 }
2094 inc = incList.next(); 2098 inc = incList.next();
2095 } 2099 }
2096 catList.sort(); 2100 catList.sort();
2097 KOPrefs::instance()->mCustomCategories = catList; 2101 KOPrefs::instance()->mCustomCategories = catList;
2098 return count; 2102 return count;
2099} 2103}
2100 2104
2101void CalendarView::manageCategories() 2105void CalendarView::manageCategories()
2102{ 2106{
2103 KOCatPrefs* cp = new KOCatPrefs(); 2107 KOCatPrefs* cp = new KOCatPrefs();
2104 cp->show(); 2108 cp->show();
2105 int w =cp->sizeHint().width() ; 2109 int w =cp->sizeHint().width() ;
2106 int h = cp->sizeHint().height() ; 2110 int h = cp->sizeHint().height() ;
2107 int dw = QApplication::desktop()->width(); 2111 int dw = QApplication::desktop()->width();
2108 int dh = QApplication::desktop()->height(); 2112 int dh = QApplication::desktop()->height();
2109 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2113 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2110 if ( !cp->exec() ) { 2114 if ( !cp->exec() ) {
2111 delete cp; 2115 delete cp;
2112 return; 2116 return;
2113 } 2117 }
2114 int count = 0; 2118 int count = 0;
2115 if ( cp->addCat() ) { 2119 if ( cp->addCat() ) {
2116 count = addCategories(); 2120 count = addCategories();
2117 if ( count ) { 2121 if ( count ) {
2118 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2122 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2119 writeSettings(); 2123 writeSettings();
2120 } 2124 }
2121 } else { 2125 } else {
2122 removeCategories(); 2126 removeCategories();
2123 updateView(); 2127 updateView();
2124 } 2128 }
2125 delete cp; 2129 delete cp;
2126} 2130}
2127 2131
2128void CalendarView::beamIncidence(Incidence * Inc) 2132void CalendarView::beamIncidence(Incidence * Inc)
2129{ 2133{
2130 QPtrList<Incidence> delSel ; 2134 QPtrList<Incidence> delSel ;
2131 delSel.append(Inc); 2135 delSel.append(Inc);
2132 beamIncidenceList( delSel ); 2136 beamIncidenceList( delSel );
2133} 2137}
2134void CalendarView::beamCalendar() 2138void CalendarView::beamCalendar()
2135{ 2139{
2136 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2140 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2137 //qDebug("beamCalendar() "); 2141 //qDebug("beamCalendar() ");
2138 beamIncidenceList( delSel ); 2142 beamIncidenceList( delSel );
2139} 2143}
2140void CalendarView::beamFilteredCalendar() 2144void CalendarView::beamFilteredCalendar()
2141{ 2145{
2142 QPtrList<Incidence> delSel = mCalendar->incidences(); 2146 QPtrList<Incidence> delSel = mCalendar->incidences();
2143 //qDebug("beamFilteredCalendar() "); 2147 //qDebug("beamFilteredCalendar() ");
2144 beamIncidenceList( delSel ); 2148 beamIncidenceList( delSel );
2145} 2149}
2146void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2150void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2147{ 2151{
2148 if ( beamDialog->exec () == QDialog::Rejected ) 2152 if ( beamDialog->exec () == QDialog::Rejected )
2149 return; 2153 return;
2150 2154
2151 QString fn = "/tmp/kopibeamfile"; 2155 QString fn = "/tmp/kopibeamfile";
2152 QString mes; 2156 QString mes;
2153 bool createbup = true; 2157 bool createbup = true;
2154 if ( createbup ) { 2158 if ( createbup ) {
2155 QString description = "\n"; 2159 QString description = "\n";
2156 CalendarLocal* cal = new CalendarLocal(); 2160 CalendarLocal* cal = new CalendarLocal();
2157 if ( beamDialog->beamLocal() ) 2161 if ( beamDialog->beamLocal() )
2158 cal->setLocalTime(); 2162 cal->setLocalTime();
2159 else 2163 else
2160 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2164 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2161 Incidence *incidence = delSel.first(); 2165 Incidence *incidence = delSel.first();
2162 bool addText = false; 2166 bool addText = false;
2163 if ( delSel.count() < 10 ) 2167 if ( delSel.count() < 10 )
2164 addText = true; 2168 addText = true;
2165 else { 2169 else {
2166 description.sprintf(i18n(" %d items?"),delSel.count() ); 2170 description.sprintf(i18n(" %d items?"),delSel.count() );
2167 } 2171 }
2168 while ( incidence ) { 2172 while ( incidence ) {
2169 Incidence *in = incidence->clone(); 2173 Incidence *in = incidence->clone();
2170 if ( addText ) 2174 if ( addText )
2171 description += in->summary() + "\n"; 2175 description += in->summary() + "\n";
2172 cal->addIncidence( in ); 2176 cal->addIncidence( in );
2173 incidence = delSel.next(); 2177 incidence = delSel.next();
2174 } 2178 }
2175 if ( beamDialog->beamVcal() ) { 2179 if ( beamDialog->beamVcal() ) {
2176 fn += ".vcs"; 2180 fn += ".vcs";
2177 FileStorage storage( cal, fn, new VCalFormat ); 2181 FileStorage storage( cal, fn, new VCalFormat );
2178 storage.save(); 2182 storage.save();
2179 } else { 2183 } else {
2180 fn += ".ics"; 2184 fn += ".ics";
2181 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2185 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2182 storage.save(); 2186 storage.save();
2183 } 2187 }
2184 delete cal; 2188 delete cal;
2185 mes = i18n("KO/Pi: Ready for beaming"); 2189 mes = i18n("KO/Pi: Ready for beaming");
2186 setCaption(mes); 2190 setCaption(mes);
2187 2191
2188#ifndef DESKTOP_VERSION 2192#ifndef DESKTOP_VERSION
2189 Ir *ir = new Ir( this ); 2193 Ir *ir = new Ir( this );
2190 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2194 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2191 ir->send( fn, description, "text/x-vCalendar" ); 2195 ir->send( fn, description, "text/x-vCalendar" );
2192#endif 2196#endif
2193 } 2197 }
2194} 2198}
2195void CalendarView::beamDone( Ir *ir ) 2199void CalendarView::beamDone( Ir *ir )
2196{ 2200{
2197#ifndef DESKTOP_VERSION 2201#ifndef DESKTOP_VERSION
2198 delete ir; 2202 delete ir;
2199#endif 2203#endif
2200} 2204}
2201 2205
2202void CalendarView::moveIncidence(Incidence * inc ) 2206void CalendarView::moveIncidence(Incidence * inc )
2203{ 2207{
2204 if ( !inc ) return; 2208 if ( !inc ) return;
2205 // qDebug("showDatePickerForIncidence( ) "); 2209 // qDebug("showDatePickerForIncidence( ) ");
2206 if ( mDateFrame->isVisible() ) 2210 if ( mDateFrame->isVisible() )
2207 mDateFrame->hide(); 2211 mDateFrame->hide();
2208 else { 2212 else {
2209 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2213 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2210 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2214 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2211 int dw = QApplication::desktop()->width(); 2215 int dw = QApplication::desktop()->width();
2212 int dh = QApplication::desktop()->height(); 2216 int dh = QApplication::desktop()->height();
2213 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2217 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2214 mDateFrame->show(); 2218 mDateFrame->show();
2215 } 2219 }
2216 mDatePickerMode = 2; 2220 mDatePickerMode = 2;
2217 mMoveIncidence = inc ; 2221 mMoveIncidence = inc ;
2218 QDate da; 2222 QDate da;
2219 if ( mMoveIncidence->type() == "Todo" ) { 2223 if ( mMoveIncidence->type() == "Todo" ) {
2220 Todo * to = (Todo *) mMoveIncidence; 2224 Todo * to = (Todo *) mMoveIncidence;
2221 if ( to->hasDueDate() ) 2225 if ( to->hasDueDate() )
2222 da = to->dtDue().date(); 2226 da = to->dtDue().date();
2223 else 2227 else
2224 da = QDate::currentDate(); 2228 da = QDate::currentDate();
2225 } else { 2229 } else {
2226 da = mMoveIncidence->dtStart().date(); 2230 da = mMoveIncidence->dtStart().date();
2227 } 2231 }
2228 mDatePicker->setDate( da ); 2232 mDatePicker->setDate( da );
2229} 2233}
2230void CalendarView::showDatePicker( ) 2234void CalendarView::showDatePicker( )
2231{ 2235{
2232 //qDebug("CalendarView::showDatePicker( ) "); 2236 //qDebug("CalendarView::showDatePicker( ) ");
2233 if ( mDateFrame->isVisible() ) 2237 if ( mDateFrame->isVisible() )
2234 mDateFrame->hide(); 2238 mDateFrame->hide();
2235 else { 2239 else {
2236 int w =mDatePicker->sizeHint().width() ; 2240 int w =mDatePicker->sizeHint().width() ;
2237 int h = mDatePicker->sizeHint().height() ; 2241 int h = mDatePicker->sizeHint().height() ;
2238 int dw = QApplication::desktop()->width(); 2242 int dw = QApplication::desktop()->width();
2239 int dh = QApplication::desktop()->height(); 2243 int dh = QApplication::desktop()->height();
2240 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2244 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2241 mDateFrame->show(); 2245 mDateFrame->show();
2242 } 2246 }
2243 mDatePickerMode = 1; 2247 mDatePickerMode = 1;
2244 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2248 mDatePicker->setDate( mNavigator->selectedDates().first() );
2245} 2249}
2246 2250
2247void CalendarView::showEventEditor() 2251void CalendarView::showEventEditor()
2248{ 2252{
2249#ifdef DESKTOP_VERSION 2253#ifdef DESKTOP_VERSION
2250 mEventEditor->show(); 2254 mEventEditor->show();
2251#else 2255#else
2252 mEventEditor->showMaximized(); 2256 mEventEditor->showMaximized();
2253#endif 2257#endif
2254} 2258}
2255void CalendarView::showTodoEditor() 2259void CalendarView::showTodoEditor()
2256{ 2260{
2257#ifdef DESKTOP_VERSION 2261#ifdef DESKTOP_VERSION
2258 mTodoEditor->show(); 2262 mTodoEditor->show();
2259#else 2263#else
2260 mTodoEditor->showMaximized(); 2264 mTodoEditor->showMaximized();
2261#endif 2265#endif
2262} 2266}
2263void CalendarView::cancelIncidence(Incidence * inc ) 2267void CalendarView::cancelIncidence(Incidence * inc )
2264{ 2268{
2265 inc->setCancelled( ! inc->cancelled() ); 2269 inc->setCancelled( ! inc->cancelled() );
2266 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2270 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2267 updateView(); 2271 updateView();
2268} 2272}
2269void CalendarView::cloneIncidence(Incidence * orgInc ) 2273void CalendarView::cloneIncidence(Incidence * orgInc )
2270{ 2274{
2271 Incidence * newInc = orgInc->clone(); 2275 Incidence * newInc = orgInc->clone();
2272 newInc->recreate(); 2276 newInc->recreate();
2273 2277
2274 if ( newInc->type() == "Todo" ) { 2278 if ( newInc->type() == "Todo" ) {
2275 Todo* t = (Todo*) newInc; 2279 Todo* t = (Todo*) newInc;
2276 mTodoEditor->editTodo( t ); 2280 mTodoEditor->editTodo( t );
2277 showTodoEditor(); 2281 showTodoEditor();
2278 if ( mTodoEditor->exec() ) { 2282 if ( mTodoEditor->exec() ) {
2279 mCalendar->addTodo( t ); 2283 mCalendar->addTodo( t );
2280 updateView(); 2284 updateView();
2281 } else { 2285 } else {
2282 delete t; 2286 delete t;
2283 } 2287 }
2284 } 2288 }
2285 else { 2289 else {
2286 Event* e = (Event*) newInc; 2290 Event* e = (Event*) newInc;
2287 mEventEditor->editEvent( e ); 2291 mEventEditor->editEvent( e );
2288 showEventEditor(); 2292 showEventEditor();
2289 if ( mEventEditor->exec() ) { 2293 if ( mEventEditor->exec() ) {
2290 mCalendar->addEvent( e ); 2294 mCalendar->addEvent( e );
2291 updateView(); 2295 updateView();
2292 } else { 2296 } else {
2293 delete e; 2297 delete e;
2294 } 2298 }
2295 } 2299 }
2296} 2300}
2297 2301
2298void CalendarView::newEvent() 2302void CalendarView::newEvent()
2299{ 2303{
2300 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2304 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2301 KOAgendaView *aView = mViewManager->agendaView(); 2305 KOAgendaView *aView = mViewManager->agendaView();
2302 if (aView) { 2306 if (aView) {
2303 if (aView->selectionStart().isValid()) { 2307 if (aView->selectionStart().isValid()) {
2304 if (aView->selectedIsAllDay()) { 2308 if (aView->selectedIsAllDay()) {
2305 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2309 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2306 } else { 2310 } else {
2307 newEvent(aView->selectionStart(),aView->selectionEnd()); 2311 newEvent(aView->selectionStart(),aView->selectionEnd());
2308 } 2312 }
2309 return; 2313 return;
2310 } 2314 }
2311 } 2315 }
2312 2316
2313 QDate date = mNavigator->selectedDates().first(); 2317 QDate date = mNavigator->selectedDates().first();
2314 QDateTime current = QDateTime::currentDateTime(); 2318 QDateTime current = QDateTime::currentDateTime();
2315 if ( date <= current.date() ) { 2319 if ( date <= current.date() ) {
2316 int hour = current.time().hour() +1; 2320 int hour = current.time().hour() +1;
2317 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2321 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2318 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2322 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2319 } else 2323 } else
2320 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2324 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2321 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2325 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2322 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2326 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2323} 2327}
2324 2328
2325void CalendarView::newEvent(QDateTime fh) 2329void CalendarView::newEvent(QDateTime fh)
2326{ 2330{
2327 newEvent(fh, 2331 newEvent(fh,
2328 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2332 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2329} 2333}
2330 2334
2331void CalendarView::newEvent(QDate dt) 2335void CalendarView::newEvent(QDate dt)
2332{ 2336{
2333 newEvent(QDateTime(dt, QTime(0,0,0)), 2337 newEvent(QDateTime(dt, QTime(0,0,0)),
2334 QDateTime(dt, QTime(0,0,0)), true); 2338 QDateTime(dt, QTime(0,0,0)), true);
2335} 2339}
2336 2340
2337void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2341void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2338{ 2342{
2339 2343
2340 mEventEditor->newEvent(fromHint,toHint,allDay); 2344 mEventEditor->newEvent(fromHint,toHint,allDay);
2341 if ( mFilterView->filtersEnabled() ) { 2345 if ( mFilterView->filtersEnabled() ) {
2342 CalFilter *filter = mFilterView->selectedFilter(); 2346 CalFilter *filter = mFilterView->selectedFilter();
2343 if (filter && filter->showCategories()) { 2347 if (filter && filter->showCategories()) {
2344 mEventEditor->setCategories(filter->categoryList().join(",") ); 2348 mEventEditor->setCategories(filter->categoryList().join(",") );
2345 } 2349 }
2346 if ( filter ) 2350 if ( filter )
2347 mEventEditor->setSecrecy( filter->getSecrecy() ); 2351 mEventEditor->setSecrecy( filter->getSecrecy() );
2348 } 2352 }
2349 showEventEditor(); 2353 showEventEditor();
2350} 2354}
2351void CalendarView::todoAdded(Todo * t) 2355void CalendarView::todoAdded(Todo * t)
2352{ 2356{
2353 2357
2354 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2358 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2355 updateTodoViews(); 2359 updateTodoViews();
2356} 2360}
2357void CalendarView::todoChanged(Todo * t) 2361void CalendarView::todoChanged(Todo * t)
2358{ 2362{
2359 emit todoModified( t, 4 ); 2363 emit todoModified( t, 4 );
2360 // updateTodoViews(); 2364 // updateTodoViews();
2361} 2365}
2362void CalendarView::todoToBeDeleted(Todo *) 2366void CalendarView::todoToBeDeleted(Todo *)
2363{ 2367{
2364 //qDebug("todoToBeDeleted(Todo *) "); 2368 //qDebug("todoToBeDeleted(Todo *) ");
2365 updateTodoViews(); 2369 updateTodoViews();
2366} 2370}
2367void CalendarView::todoDeleted() 2371void CalendarView::todoDeleted()
2368{ 2372{
2369 //qDebug(" todoDeleted()"); 2373 //qDebug(" todoDeleted()");
2370 updateTodoViews(); 2374 updateTodoViews();
2371} 2375}
2372 2376
2373 2377
2374 2378
2375void CalendarView::newTodo() 2379void CalendarView::newTodo()
2376{ 2380{
2377 2381
2378 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2382 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2379 if ( mFilterView->filtersEnabled() ) { 2383 if ( mFilterView->filtersEnabled() ) {
2380 CalFilter *filter = mFilterView->selectedFilter(); 2384 CalFilter *filter = mFilterView->selectedFilter();
2381 if (filter && filter->showCategories()) { 2385 if (filter && filter->showCategories()) {
2382 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2386 mTodoEditor->setCategories(filter->categoryList().join(",") );
2383 } 2387 }
2384 if ( filter ) 2388 if ( filter )
2385 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2389 mTodoEditor->setSecrecy( filter->getSecrecy() );
2386 } 2390 }
2387 showTodoEditor(); 2391 showTodoEditor();
2388} 2392}
2389 2393
2390void CalendarView::newSubTodo() 2394void CalendarView::newSubTodo()
2391{ 2395{
2392 Todo *todo = selectedTodo(); 2396 Todo *todo = selectedTodo();
2393 if ( todo ) newSubTodo( todo ); 2397 if ( todo ) newSubTodo( todo );
2394} 2398}
2395 2399
2396void CalendarView::newSubTodo(Todo *parentEvent) 2400void CalendarView::newSubTodo(Todo *parentEvent)
2397{ 2401{
2398 2402
2399 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2403 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2400 showTodoEditor(); 2404 showTodoEditor();
2401} 2405}
2402 2406
2403void CalendarView::newFloatingEvent() 2407void CalendarView::newFloatingEvent()
2404{ 2408{
2405 DateList tmpList = mNavigator->selectedDates(); 2409 DateList tmpList = mNavigator->selectedDates();
2406 QDate date = tmpList.first(); 2410 QDate date = tmpList.first();
2407 2411
2408 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2412 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2409 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2413 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2410} 2414}
2411 2415
2412 2416
2413void CalendarView::editEvent( Event *event ) 2417void CalendarView::editEvent( Event *event )
2414{ 2418{
2415 2419
2416 if ( !event ) return; 2420 if ( !event ) return;
2417 if ( event->isReadOnly() ) { 2421 if ( event->isReadOnly() ) {
2418 showEvent( event ); 2422 showEvent( event );
2419 return; 2423 return;
2420 } 2424 }
2421 mEventEditor->editEvent( event , mFlagEditDescription); 2425 mEventEditor->editEvent( event , mFlagEditDescription);
2422 showEventEditor(); 2426 showEventEditor();
2423} 2427}
2424void CalendarView::editJournal( Journal *jour ) 2428void CalendarView::editJournal( Journal *jour )
2425{ 2429{
2426 if ( !jour ) return; 2430 if ( !jour ) return;
2427 mDialogManager->hideSearchDialog(); 2431 mDialogManager->hideSearchDialog();
2428 mViewManager->showJournalView(); 2432 mViewManager->showJournalView();
2429 mNavigator->slotDaySelect( jour->dtStart().date() ); 2433 mNavigator->slotDaySelect( jour->dtStart().date() );
2430} 2434}
2431void CalendarView::editTodo( Todo *todo ) 2435void CalendarView::editTodo( Todo *todo )
2432{ 2436{
2433 if ( !todo ) return; 2437 if ( !todo ) return;
2434 2438
2435 if ( todo->isReadOnly() ) { 2439 if ( todo->isReadOnly() ) {
2436 showTodo( todo ); 2440 showTodo( todo );
2437 return; 2441 return;
2438 } 2442 }
2439 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2443 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2440 showTodoEditor(); 2444 showTodoEditor();
2441 2445
2442} 2446}
2443 2447
2444KOEventViewerDialog* CalendarView::getEventViewerDialog() 2448KOEventViewerDialog* CalendarView::getEventViewerDialog()
2445{ 2449{
2446 if ( !mEventViewerDialog ) { 2450 if ( !mEventViewerDialog ) {
2447 mEventViewerDialog = new KOEventViewerDialog(this); 2451 mEventViewerDialog = new KOEventViewerDialog(this);
2448 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2452 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2449 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2453 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2450 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2454 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2451 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2455 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2452 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2456 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2453 viewManager(), SLOT( showAgendaView( bool ) ) ); 2457 viewManager(), SLOT( showAgendaView( bool ) ) );
2454 mEventViewerDialog->resize( 640, 480 ); 2458 mEventViewerDialog->resize( 640, 480 );
2455 2459
2456 } 2460 }
2457 return mEventViewerDialog; 2461 return mEventViewerDialog;
2458} 2462}
2459void CalendarView::showEvent(Event *event) 2463void CalendarView::showEvent(Event *event)
2460{ 2464{
2461 getEventViewerDialog()->setEvent(event); 2465 getEventViewerDialog()->setEvent(event);
2462 getEventViewerDialog()->showMe(); 2466 getEventViewerDialog()->showMe();
2463} 2467}
2464 2468
2465void CalendarView::showTodo(Todo *event) 2469void CalendarView::showTodo(Todo *event)
2466{ 2470{
2467 getEventViewerDialog()->setTodo(event); 2471 getEventViewerDialog()->setTodo(event);
2468 getEventViewerDialog()->showMe(); 2472 getEventViewerDialog()->showMe();
2469} 2473}
2470void CalendarView::showJournal( Journal *jour ) 2474void CalendarView::showJournal( Journal *jour )
2471{ 2475{
2472 getEventViewerDialog()->setJournal(jour); 2476 getEventViewerDialog()->setJournal(jour);
2473 getEventViewerDialog()->showMe(); 2477 getEventViewerDialog()->showMe();
2474 2478
2475} 2479}
2476// void CalendarView::todoModified (Todo *event, int changed) 2480// void CalendarView::todoModified (Todo *event, int changed)
2477// { 2481// {
2478// // if (mDialogList.find (event) != mDialogList.end ()) { 2482// // if (mDialogList.find (event) != mDialogList.end ()) {
2479// // kdDebug() << "Todo modified and open" << endl; 2483// // kdDebug() << "Todo modified and open" << endl;
2480// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2484// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2481// // temp->modified (changed); 2485// // temp->modified (changed);
2482 2486
2483// // } 2487// // }
2484 2488
2485// mViewManager->updateView(); 2489// mViewManager->updateView();
2486// } 2490// }
2487 2491
2488void CalendarView::appointment_show() 2492void CalendarView::appointment_show()
2489{ 2493{
2490 Event *anEvent = 0; 2494 Event *anEvent = 0;
2491 2495
2492 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2496 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2493 2497
2494 if (mViewManager->currentView()->isEventView()) { 2498 if (mViewManager->currentView()->isEventView()) {
2495 if ( incidence && incidence->type() == "Event" ) { 2499 if ( incidence && incidence->type() == "Event" ) {
2496 anEvent = static_cast<Event *>(incidence); 2500 anEvent = static_cast<Event *>(incidence);
2497 } 2501 }
2498 } 2502 }
2499 2503
2500 if (!anEvent) { 2504 if (!anEvent) {
2501 KNotifyClient::beep(); 2505 KNotifyClient::beep();
2502 return; 2506 return;
2503 } 2507 }
2504 2508
2505 showEvent(anEvent); 2509 showEvent(anEvent);
2506} 2510}
2507 2511
2508void CalendarView::appointment_edit() 2512void CalendarView::appointment_edit()
2509{ 2513{
2510 Event *anEvent = 0; 2514 Event *anEvent = 0;
2511 2515
2512 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2516 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2513 2517
2514 if (mViewManager->currentView()->isEventView()) { 2518 if (mViewManager->currentView()->isEventView()) {
2515 if ( incidence && incidence->type() == "Event" ) { 2519 if ( incidence && incidence->type() == "Event" ) {
2516 anEvent = static_cast<Event *>(incidence); 2520 anEvent = static_cast<Event *>(incidence);
2517 } 2521 }
2518 } 2522 }
2519 2523
2520 if (!anEvent) { 2524 if (!anEvent) {
2521 KNotifyClient::beep(); 2525 KNotifyClient::beep();
2522 return; 2526 return;
2523 } 2527 }
2524 2528
2525 editEvent(anEvent); 2529 editEvent(anEvent);
2526} 2530}
2527 2531
2528void CalendarView::appointment_delete() 2532void CalendarView::appointment_delete()
2529{ 2533{
2530 Event *anEvent = 0; 2534 Event *anEvent = 0;
2531 2535
2532 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2536 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2533 2537
2534 if (mViewManager->currentView()->isEventView()) { 2538 if (mViewManager->currentView()->isEventView()) {
2535 if ( incidence && incidence->type() == "Event" ) { 2539 if ( incidence && incidence->type() == "Event" ) {
2536 anEvent = static_cast<Event *>(incidence); 2540 anEvent = static_cast<Event *>(incidence);
2537 } 2541 }
2538 } 2542 }
2539 2543
2540 if (!anEvent) { 2544 if (!anEvent) {
2541 KNotifyClient::beep(); 2545 KNotifyClient::beep();
2542 return; 2546 return;
2543 } 2547 }
2544 2548
2545 deleteEvent(anEvent); 2549 deleteEvent(anEvent);
2546} 2550}
2547 2551
2548void CalendarView::todo_unsub(Todo *anTodo ) 2552void CalendarView::todo_unsub(Todo *anTodo )
2549{ 2553{
2550 // Todo *anTodo = selectedTodo(); 2554 // Todo *anTodo = selectedTodo();
2551 if (!anTodo) return; 2555 if (!anTodo) return;
2552 if (!anTodo->relatedTo()) return; 2556 if (!anTodo->relatedTo()) return;
2553 anTodo->relatedTo()->removeRelation(anTodo); 2557 anTodo->relatedTo()->removeRelation(anTodo);
2554 anTodo->setRelatedTo(0); 2558 anTodo->setRelatedTo(0);
2555 anTodo->updated(); 2559 anTodo->updated();
2556 anTodo->setRelatedToUid(""); 2560 anTodo->setRelatedToUid("");
2557 setModified(true); 2561 setModified(true);
2558 updateView(); 2562 updateView();
2559} 2563}
2560 2564
2561void CalendarView::deleteTodo(Todo *todo) 2565void CalendarView::deleteTodo(Todo *todo)
2562{ 2566{
2563 if (!todo) { 2567 if (!todo) {
2564 KNotifyClient::beep(); 2568 KNotifyClient::beep();
2565 return; 2569 return;
2566 } 2570 }
2567 if (KOPrefs::instance()->mConfirm) { 2571 if (KOPrefs::instance()->mConfirm) {
2568 switch (msgItemDelete()) { 2572 switch (msgItemDelete()) {
2569 case KMessageBox::Continue: // OK 2573 case KMessageBox::Continue: // OK
2570 if (!todo->relations().isEmpty()) { 2574 if (!todo->relations().isEmpty()) {
2571 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2575 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2572 i18n("Delete To-Do")); 2576 i18n("Delete To-Do"));
2573 } else { 2577 } else {
2574 checkExternalId( todo ); 2578 checkExternalId( todo );
2575 calendar()->deleteTodo(todo); 2579 calendar()->deleteTodo(todo);
2576 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2580 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2577 updateView(); 2581 updateView();
2578 } 2582 }
2579 break; 2583 break;
2580 } // switch 2584 } // switch
2581 } else { 2585 } else {
2582 if (!todo->relations().isEmpty()) { 2586 if (!todo->relations().isEmpty()) {
2583 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2587 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2584 i18n("Delete To-Do")); 2588 i18n("Delete To-Do"));
2585 } else { 2589 } else {
2586 checkExternalId( todo ); 2590 checkExternalId( todo );
2587 mCalendar->deleteTodo(todo); 2591 mCalendar->deleteTodo(todo);
2588 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2592 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2589 updateView(); 2593 updateView();
2590 } 2594 }
2591 } 2595 }
2592 emit updateSearchDialog(); 2596 emit updateSearchDialog();
2593} 2597}
2594void CalendarView::deleteJournal(Journal *jour) 2598void CalendarView::deleteJournal(Journal *jour)
2595{ 2599{
2596 if (!jour) { 2600 if (!jour) {
2597 KNotifyClient::beep(); 2601 KNotifyClient::beep();
2598 return; 2602 return;
2599 } 2603 }
2600 if (KOPrefs::instance()->mConfirm) { 2604 if (KOPrefs::instance()->mConfirm) {
2601 switch (msgItemDelete()) { 2605 switch (msgItemDelete()) {
2602 case KMessageBox::Continue: // OK 2606 case KMessageBox::Continue: // OK
2603 calendar()->deleteJournal(jour); 2607 calendar()->deleteJournal(jour);
2604 updateView(); 2608 updateView();
2605 break; 2609 break;
2606 } // switch 2610 } // switch
2607 } else { 2611 } else {
2608 calendar()->deleteJournal(jour);; 2612 calendar()->deleteJournal(jour);;
2609 updateView(); 2613 updateView();
2610 } 2614 }
2611 emit updateSearchDialog(); 2615 emit updateSearchDialog();
2612} 2616}
2613 2617
2614void CalendarView::deleteEvent(Event *anEvent) 2618void CalendarView::deleteEvent(Event *anEvent)
2615{ 2619{
2616 if (!anEvent) { 2620 if (!anEvent) {
2617 KNotifyClient::beep(); 2621 KNotifyClient::beep();
2618 return; 2622 return;
2619 } 2623 }
2620 2624
2621 if (anEvent->recurrence()->doesRecur()) { 2625 if (anEvent->recurrence()->doesRecur()) {
2622 QDate itemDate = mViewManager->currentSelectionDate(); 2626 QDate itemDate = mViewManager->currentSelectionDate();
2623 int km; 2627 int km;
2624 if (!itemDate.isValid()) { 2628 if (!itemDate.isValid()) {
2625 //kdDebug() << "Date Not Valid" << endl; 2629 //kdDebug() << "Date Not Valid" << endl;
2626 if (KOPrefs::instance()->mConfirm) { 2630 if (KOPrefs::instance()->mConfirm) {
2627 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2631 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2628 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2632 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2629 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2633 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2630 if ( km == KMessageBox::Continue ) 2634 if ( km == KMessageBox::Continue )
2631 km = KMessageBox::No; // No = all below 2635 km = KMessageBox::No; // No = all below
2632 } else 2636 } else
2633 km = KMessageBox::No; 2637 km = KMessageBox::No;
2634 } else { 2638 } else {
2635 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2639 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2636 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2640 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2637 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2641 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2638 i18n("KO/Pi Confirmation"),i18n("Current"), 2642 i18n("KO/Pi Confirmation"),i18n("Current"),
2639 i18n("All")); 2643 i18n("All"));
2640 } 2644 }
2641 switch(km) { 2645 switch(km) {
2642 2646
2643 case KMessageBox::No: // Continue // all 2647 case KMessageBox::No: // Continue // all
2644 //qDebug("KMessageBox::No "); 2648 //qDebug("KMessageBox::No ");
2645 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2649 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2646 schedule(Scheduler::Cancel,anEvent); 2650 schedule(Scheduler::Cancel,anEvent);
2647 2651
2648 checkExternalId( anEvent); 2652 checkExternalId( anEvent);
2649 mCalendar->deleteEvent(anEvent); 2653 mCalendar->deleteEvent(anEvent);
2650 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2654 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2651 break; 2655 break;
2652 2656
2653 // Disabled because it does not work 2657 // Disabled because it does not work
2654 //#if 0 2658 //#if 0
2655 case KMessageBox::Yes: // just this one 2659 case KMessageBox::Yes: // just this one
2656 //QDate qd = mNavigator->selectedDates().first(); 2660 //QDate qd = mNavigator->selectedDates().first();
2657 //if (!qd.isValid()) { 2661 //if (!qd.isValid()) {
2658 // kdDebug() << "no date selected, or invalid date" << endl; 2662 // kdDebug() << "no date selected, or invalid date" << endl;
2659 // KNotifyClient::beep(); 2663 // KNotifyClient::beep();
2660 // return; 2664 // return;
2661 //} 2665 //}
2662 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2666 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2663 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2667 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2664 anEvent->addExDate(itemDate); 2668 anEvent->addExDate(itemDate);
2665 int duration = anEvent->recurrence()->duration(); 2669 int duration = anEvent->recurrence()->duration();
2666 if ( duration > 0 ) { 2670 if ( duration > 0 ) {
2667 anEvent->recurrence()->setDuration( duration - 1 ); 2671 anEvent->recurrence()->setDuration( duration - 1 );
2668 } 2672 }
2669 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2673 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2670 } 2674 }
2671 break; 2675 break;
2672 //#endif 2676 //#endif
2673 } // switch 2677 } // switch
2674 } else { 2678 } else {
2675 if (KOPrefs::instance()->mConfirm) { 2679 if (KOPrefs::instance()->mConfirm) {
2676 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2680 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2677 i18n("\nAre you sure you want\nto delete this event?"), 2681 i18n("\nAre you sure you want\nto delete this event?"),
2678 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2682 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2679 case KMessageBox::Continue: // OK 2683 case KMessageBox::Continue: // OK
2680 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2684 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2681 schedule(Scheduler::Cancel,anEvent); 2685 schedule(Scheduler::Cancel,anEvent);
2682 checkExternalId( anEvent); 2686 checkExternalId( anEvent);
2683 mCalendar->deleteEvent(anEvent); 2687 mCalendar->deleteEvent(anEvent);
2684 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2688 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2685 break; 2689 break;
2686 } // switch 2690 } // switch
2687 } else { 2691 } else {
2688 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2692 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2689 schedule(Scheduler::Cancel,anEvent); 2693 schedule(Scheduler::Cancel,anEvent);
2690 checkExternalId( anEvent); 2694 checkExternalId( anEvent);
2691 mCalendar->deleteEvent(anEvent); 2695 mCalendar->deleteEvent(anEvent);
2692 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2696 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2693 } 2697 }
2694 } // if-else 2698 } // if-else
2695 emit updateSearchDialog(); 2699 emit updateSearchDialog();
2696} 2700}
2697 2701
2698bool CalendarView::deleteEvent(const QString &uid) 2702bool CalendarView::deleteEvent(const QString &uid)
2699{ 2703{
2700 Event *ev = mCalendar->event(uid); 2704 Event *ev = mCalendar->event(uid);
2701 if (ev) { 2705 if (ev) {
2702 deleteEvent(ev); 2706 deleteEvent(ev);
2703 return true; 2707 return true;
2704 } else { 2708 } else {
2705 return false; 2709 return false;
2706 } 2710 }
2707} 2711}
2708 2712
2709/*****************************************************************************/ 2713/*****************************************************************************/
2710 2714
2711void CalendarView::action_mail() 2715void CalendarView::action_mail()
2712{ 2716{
2713#ifndef KORG_NOMAIL 2717#ifndef KORG_NOMAIL
2714 KOMailClient mailClient; 2718 KOMailClient mailClient;
2715 2719
2716 Incidence *incidence = currentSelection(); 2720 Incidence *incidence = currentSelection();
2717 2721
2718 if (!incidence) { 2722 if (!incidence) {
2719 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2723 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2720 return; 2724 return;
2721 } 2725 }
2722 if(incidence->attendeeCount() == 0 ) { 2726 if(incidence->attendeeCount() == 0 ) {
2723 KMessageBox::sorry(this, 2727 KMessageBox::sorry(this,
2724 i18n("Can't generate mail:\nNo attendees defined.\n")); 2728 i18n("Can't generate mail:\nNo attendees defined.\n"));
2725 return; 2729 return;
2726 } 2730 }
2727 2731
2728 CalendarLocal cal_tmp; 2732 CalendarLocal cal_tmp;
2729 Event *event = 0; 2733 Event *event = 0;
2730 Event *ev = 0; 2734 Event *ev = 0;
2731 if ( incidence && incidence->type() == "Event" ) { 2735 if ( incidence && incidence->type() == "Event" ) {
2732 event = static_cast<Event *>(incidence); 2736 event = static_cast<Event *>(incidence);
2733 ev = new Event(*event); 2737 ev = new Event(*event);
2734 cal_tmp.addEvent(ev); 2738 cal_tmp.addEvent(ev);
2735 } 2739 }
2736 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2740 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2737 QString attachment = mForm.toString( &cal_tmp ); 2741 QString attachment = mForm.toString( &cal_tmp );
2738 if (ev) delete(ev); 2742 if (ev) delete(ev);
2739 2743
2740 mailClient.mailAttendees(currentSelection(), attachment); 2744 mailClient.mailAttendees(currentSelection(), attachment);
2741 2745
2742#endif 2746#endif
2743 2747
2744#if 0 2748#if 0
2745 Event *anEvent = 0; 2749 Event *anEvent = 0;
2746 if (mViewManager->currentView()->isEventView()) { 2750 if (mViewManager->currentView()->isEventView()) {
2747 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2751 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2748 } 2752 }
2749 2753
2750 if (!anEvent) { 2754 if (!anEvent) {
2751 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2755 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2752 return; 2756 return;
2753 } 2757 }
2754 if(anEvent->attendeeCount() == 0 ) { 2758 if(anEvent->attendeeCount() == 0 ) {
2755 KMessageBox::sorry(this, 2759 KMessageBox::sorry(this,
2756 i18n("Can't generate mail:\nNo attendees defined.\n")); 2760 i18n("Can't generate mail:\nNo attendees defined.\n"));
2757 return; 2761 return;
2758 } 2762 }
2759 2763
2760 mailobject.emailEvent(anEvent); 2764 mailobject.emailEvent(anEvent);
2761#endif 2765#endif
2762} 2766}
2763 2767
2764 2768
2765void CalendarView::schedule_publish(Incidence *incidence) 2769void CalendarView::schedule_publish(Incidence *incidence)
2766{ 2770{
2767 Event *event = 0; 2771 Event *event = 0;
2768 Todo *todo = 0; 2772 Todo *todo = 0;
2769 2773
2770 if (incidence == 0) { 2774 if (incidence == 0) {
2771 incidence = mViewManager->currentView()->selectedIncidences().first(); 2775 incidence = mViewManager->currentView()->selectedIncidences().first();
2772 if (incidence == 0) { 2776 if (incidence == 0) {
2773 incidence = mTodoList->selectedIncidences().first(); 2777 incidence = mTodoList->selectedIncidences().first();
2774 } 2778 }
2775 } 2779 }
2776 if ( incidence && incidence->type() == "Event" ) { 2780 if ( incidence && incidence->type() == "Event" ) {
2777 event = static_cast<Event *>(incidence); 2781 event = static_cast<Event *>(incidence);
2778 } else { 2782 } else {
2779 if ( incidence && incidence->type() == "Todo" ) { 2783 if ( incidence && incidence->type() == "Todo" ) {
2780 todo = static_cast<Todo *>(incidence); 2784 todo = static_cast<Todo *>(incidence);
2781 } 2785 }
2782 } 2786 }
2783 2787
2784 if (!event && !todo) { 2788 if (!event && !todo) {
2785 KMessageBox::sorry(this,i18n("No event selected.")); 2789 KMessageBox::sorry(this,i18n("No event selected."));
2786 return; 2790 return;
2787 } 2791 }
2788 2792
2789 PublishDialog *publishdlg = new PublishDialog(); 2793 PublishDialog *publishdlg = new PublishDialog();
2790 if (incidence->attendeeCount()>0) { 2794 if (incidence->attendeeCount()>0) {
2791 QPtrList<Attendee> attendees = incidence->attendees(); 2795 QPtrList<Attendee> attendees = incidence->attendees();
2792 attendees.first(); 2796 attendees.first();
2793 while ( attendees.current()!=0 ) { 2797 while ( attendees.current()!=0 ) {
2794 publishdlg->addAttendee(attendees.current()); 2798 publishdlg->addAttendee(attendees.current());
2795 attendees.next(); 2799 attendees.next();
2796 } 2800 }
2797 } 2801 }
2798 bool send = true; 2802 bool send = true;
2799 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2803 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2800 if ( publishdlg->exec() != QDialog::Accepted ) 2804 if ( publishdlg->exec() != QDialog::Accepted )
2801 send = false; 2805 send = false;
2802 } 2806 }
2803 if ( send ) { 2807 if ( send ) {
2804 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2808 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2805 if ( event ) { 2809 if ( event ) {
2806 Event *ev = new Event(*event); 2810 Event *ev = new Event(*event);
2807 ev->registerObserver(0); 2811 ev->registerObserver(0);
2808 ev->clearAttendees(); 2812 ev->clearAttendees();
2809 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2813 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2810 delete(ev); 2814 delete(ev);
2811 } 2815 }
2812 } else { 2816 } else {
2813 if ( todo ) { 2817 if ( todo ) {
2814 Todo *ev = new Todo(*todo); 2818 Todo *ev = new Todo(*todo);
2815 ev->registerObserver(0); 2819 ev->registerObserver(0);
2816 ev->clearAttendees(); 2820 ev->clearAttendees();
2817 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2821 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2818 delete(ev); 2822 delete(ev);
2819 } 2823 }
2820 } 2824 }
2821 } 2825 }
2822 } 2826 }
2823 delete publishdlg; 2827 delete publishdlg;
2824} 2828}
2825 2829
2826void CalendarView::schedule_request(Incidence *incidence) 2830void CalendarView::schedule_request(Incidence *incidence)
2827{ 2831{
2828 schedule(Scheduler::Request,incidence); 2832 schedule(Scheduler::Request,incidence);
2829} 2833}
2830 2834
2831void CalendarView::schedule_refresh(Incidence *incidence) 2835void CalendarView::schedule_refresh(Incidence *incidence)
2832{ 2836{
2833 schedule(Scheduler::Refresh,incidence); 2837 schedule(Scheduler::Refresh,incidence);
2834} 2838}
2835 2839
2836void CalendarView::schedule_cancel(Incidence *incidence) 2840void CalendarView::schedule_cancel(Incidence *incidence)
2837{ 2841{
2838 schedule(Scheduler::Cancel,incidence); 2842 schedule(Scheduler::Cancel,incidence);
2839} 2843}
2840 2844
2841void CalendarView::schedule_add(Incidence *incidence) 2845void CalendarView::schedule_add(Incidence *incidence)
2842{ 2846{
2843 schedule(Scheduler::Add,incidence); 2847 schedule(Scheduler::Add,incidence);
2844} 2848}
2845 2849
2846void CalendarView::schedule_reply(Incidence *incidence) 2850void CalendarView::schedule_reply(Incidence *incidence)
2847{ 2851{
2848 schedule(Scheduler::Reply,incidence); 2852 schedule(Scheduler::Reply,incidence);
2849} 2853}
2850 2854
2851void CalendarView::schedule_counter(Incidence *incidence) 2855void CalendarView::schedule_counter(Incidence *incidence)
2852{ 2856{
2853 schedule(Scheduler::Counter,incidence); 2857 schedule(Scheduler::Counter,incidence);
2854} 2858}
2855 2859
2856void CalendarView::schedule_declinecounter(Incidence *incidence) 2860void CalendarView::schedule_declinecounter(Incidence *incidence)
2857{ 2861{
2858 schedule(Scheduler::Declinecounter,incidence); 2862 schedule(Scheduler::Declinecounter,incidence);
2859} 2863}
2860 2864
2861void CalendarView::schedule_publish_freebusy(int daysToPublish) 2865void CalendarView::schedule_publish_freebusy(int daysToPublish)
2862{ 2866{
2863 QDateTime start = QDateTime::currentDateTime(); 2867 QDateTime start = QDateTime::currentDateTime();
2864 QDateTime end = start.addDays(daysToPublish); 2868 QDateTime end = start.addDays(daysToPublish);
2865 2869
2866 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2870 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2867 freebusy->setOrganizer(KOPrefs::instance()->email()); 2871 freebusy->setOrganizer(KOPrefs::instance()->email());
2868 2872
2869 2873
2870 PublishDialog *publishdlg = new PublishDialog(); 2874 PublishDialog *publishdlg = new PublishDialog();
2871 if ( publishdlg->exec() == QDialog::Accepted ) { 2875 if ( publishdlg->exec() == QDialog::Accepted ) {
2872 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2876 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2873 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2877 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2874 delete(freebusy); 2878 delete(freebusy);
2875 } 2879 }
2876 } 2880 }
2877 delete publishdlg; 2881 delete publishdlg;
2878} 2882}
2879 2883
2880void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2884void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2881{ 2885{
2882 Event *event = 0; 2886 Event *event = 0;
2883 Todo *todo = 0; 2887 Todo *todo = 0;
2884 2888
2885 if (incidence == 0) { 2889 if (incidence == 0) {
2886 incidence = mViewManager->currentView()->selectedIncidences().first(); 2890 incidence = mViewManager->currentView()->selectedIncidences().first();
2887 if (incidence == 0) { 2891 if (incidence == 0) {
2888 incidence = mTodoList->selectedIncidences().first(); 2892 incidence = mTodoList->selectedIncidences().first();
2889 } 2893 }
2890 } 2894 }
2891 if ( incidence && incidence->type() == "Event" ) { 2895 if ( incidence && incidence->type() == "Event" ) {
2892 event = static_cast<Event *>(incidence); 2896 event = static_cast<Event *>(incidence);
2893 } 2897 }
2894 if ( incidence && incidence->type() == "Todo" ) { 2898 if ( incidence && incidence->type() == "Todo" ) {
2895 todo = static_cast<Todo *>(incidence); 2899 todo = static_cast<Todo *>(incidence);
2896 } 2900 }
2897 2901
2898 if (!event && !todo) { 2902 if (!event && !todo) {
2899 KMessageBox::sorry(this,i18n("No event selected.")); 2903 KMessageBox::sorry(this,i18n("No event selected."));
2900 return; 2904 return;
2901 } 2905 }
2902 2906
2903 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2907 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2904 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2908 KMessageBox::sorry(this,i18n("The event has no attendees."));
2905 return; 2909 return;
2906 } 2910 }
2907 2911
2908 Event *ev = 0; 2912 Event *ev = 0;
2909 if (event) ev = new Event(*event); 2913 if (event) ev = new Event(*event);
2910 Todo *to = 0; 2914 Todo *to = 0;
2911 if (todo) to = new Todo(*todo); 2915 if (todo) to = new Todo(*todo);
2912 2916
2913 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2917 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2914 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2918 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2915 if (!me) { 2919 if (!me) {
2916 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2920 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2917 return; 2921 return;
2918 } 2922 }
2919 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2923 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2920 StatusDialog *statdlg = new StatusDialog(this); 2924 StatusDialog *statdlg = new StatusDialog(this);
2921 if (!statdlg->exec()==QDialog::Accepted) return; 2925 if (!statdlg->exec()==QDialog::Accepted) return;
2922 me->setStatus( statdlg->status() ); 2926 me->setStatus( statdlg->status() );
2923 delete(statdlg); 2927 delete(statdlg);
2924 } 2928 }
2925 Attendee *menew = new Attendee(*me); 2929 Attendee *menew = new Attendee(*me);
2926 if (ev) { 2930 if (ev) {
2927 ev->clearAttendees(); 2931 ev->clearAttendees();
2928 ev->addAttendee(menew,false); 2932 ev->addAttendee(menew,false);
2929 } else { 2933 } else {
2930 if (to) { 2934 if (to) {
2931 todo->clearAttendees(); 2935 todo->clearAttendees();
2932 todo->addAttendee(menew,false); 2936 todo->addAttendee(menew,false);
2933 } 2937 }
2934 } 2938 }
2935 } 2939 }
2936 2940
2937 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2941 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2938 if (ev) { 2942 if (ev) {
2939 if ( !dlg->addMessage(ev,method) ) delete(ev); 2943 if ( !dlg->addMessage(ev,method) ) delete(ev);
2940 } else { 2944 } else {
2941 if (to) { 2945 if (to) {
2942 if ( !dlg->addMessage(to,method) ) delete(to); 2946 if ( !dlg->addMessage(to,method) ) delete(to);
2943 } 2947 }
2944 } 2948 }
2945} 2949}
2946 2950
2947void CalendarView::openAddressbook() 2951void CalendarView::openAddressbook()
2948{ 2952{
2949 KRun::runCommand("kaddressbook"); 2953 KRun::runCommand("kaddressbook");
2950} 2954}
2951 2955
2952void CalendarView::setModified(bool modified) 2956void CalendarView::setModified(bool modified)
2953{ 2957{
2954 if ( modified ) 2958 if ( modified )
2955 emit signalmodified(); 2959 emit signalmodified();
2956 if (mModified != modified) { 2960 if (mModified != modified) {
2957 mModified = modified; 2961 mModified = modified;
2958 emit modifiedChanged(mModified); 2962 emit modifiedChanged(mModified);
2959 } 2963 }
2960} 2964}
2961 2965
2962bool CalendarView::isReadOnly() 2966bool CalendarView::isReadOnly()
2963{ 2967{
2964 return mReadOnly; 2968 return mReadOnly;
2965} 2969}
2966 2970
2967void CalendarView::setReadOnly(bool readOnly) 2971void CalendarView::setReadOnly(bool readOnly)
2968{ 2972{
2969 if (mReadOnly != readOnly) { 2973 if (mReadOnly != readOnly) {
2970 mReadOnly = readOnly; 2974 mReadOnly = readOnly;
2971 emit readOnlyChanged(mReadOnly); 2975 emit readOnlyChanged(mReadOnly);
2972 } 2976 }
2973} 2977}
2974 2978
2975bool CalendarView::isModified() 2979bool CalendarView::isModified()
2976{ 2980{
2977 return mModified; 2981 return mModified;
2978} 2982}
2979 2983
2980void CalendarView::printSetup() 2984void CalendarView::printSetup()
2981{ 2985{
2982#ifndef KORG_NOPRINTER 2986#ifndef KORG_NOPRINTER
2983 createPrinter(); 2987 createPrinter();
2984 2988
2985 mCalPrinter->setupPrinter(); 2989 mCalPrinter->setupPrinter();
2986#endif 2990#endif
2987} 2991}
2988 2992
2989void CalendarView::print() 2993void CalendarView::print()
2990{ 2994{
2991#ifndef KORG_NOPRINTER 2995#ifndef KORG_NOPRINTER
2992 createPrinter(); 2996 createPrinter();
2993 2997
2994 DateList tmpDateList = mNavigator->selectedDates(); 2998 DateList tmpDateList = mNavigator->selectedDates();
2995 mCalPrinter->print(CalPrinter::Month, 2999 mCalPrinter->print(CalPrinter::Month,
2996 tmpDateList.first(), tmpDateList.last()); 3000 tmpDateList.first(), tmpDateList.last());
2997#endif 3001#endif
2998} 3002}
2999 3003
3000void CalendarView::printPreview() 3004void CalendarView::printPreview()
3001{ 3005{
3002#ifndef KORG_NOPRINTER 3006#ifndef KORG_NOPRINTER
3003 kdDebug() << "CalendarView::printPreview()" << endl; 3007 kdDebug() << "CalendarView::printPreview()" << endl;
3004 3008
3005 createPrinter(); 3009 createPrinter();
3006 3010
3007 DateList tmpDateList = mNavigator->selectedDates(); 3011 DateList tmpDateList = mNavigator->selectedDates();
3008 3012
3009 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3013 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3010 tmpDateList.last()); 3014 tmpDateList.last());
3011#endif 3015#endif
3012} 3016}
3013 3017
3014void CalendarView::exportICalendar() 3018void CalendarView::exportICalendar()
3015{ 3019{
3016 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3020 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3017 3021
3018 // Force correct extension 3022 // Force correct extension
3019 if (filename.right(4) != ".ics") filename += ".ics"; 3023 if (filename.right(4) != ".ics") filename += ".ics";
3020 3024
3021 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3025 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3022 storage.save(); 3026 storage.save();
3023} 3027}
3024 3028
3025bool CalendarView::exportVCalendar( QString filename ) 3029bool CalendarView::exportVCalendar( QString filename )
3026{ 3030{
3027 if (mCalendar->journals().count() > 0) { 3031 if (mCalendar->journals().count() > 0) {
3028 int result = KMessageBox::warningContinueCancel(this, 3032 int result = KMessageBox::warningContinueCancel(this,
3029 i18n("The journal entries can not be\nexported to a vCalendar file."), 3033 i18n("The journal entries can not be\nexported to a vCalendar file."),
3030 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3034 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3031 true); 3035 true);
3032 if (result != KMessageBox::Continue) return false; 3036 if (result != KMessageBox::Continue) return false;
3033 } 3037 }
3034 3038
3035 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3039 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3036 3040
3037 // Force correct extension 3041 // Force correct extension
3038 if (filename.right(4) != ".vcs") filename += ".vcs"; 3042 if (filename.right(4) != ".vcs") filename += ".vcs";
3039 3043
3040 FileStorage storage( mCalendar, filename, new VCalFormat ); 3044 FileStorage storage( mCalendar, filename, new VCalFormat );
3041 return storage.save(); 3045 return storage.save();
3042 3046
3043} 3047}
3044 3048
3045void CalendarView::eventUpdated(Incidence *) 3049void CalendarView::eventUpdated(Incidence *)
3046{ 3050{
3047 setModified(); 3051 setModified();
3048 // Don't call updateView here. The code, which has caused the update of the 3052 // Don't call updateView here. The code, which has caused the update of the
3049 // event is responsible for updating the view. 3053 // event is responsible for updating the view.
3050 // updateView(); 3054 // updateView();
3051} 3055}
3052 3056
3053void CalendarView::adaptNavigationUnits() 3057void CalendarView::adaptNavigationUnits()
3054{ 3058{
3055 if (mViewManager->currentView()->isEventView()) { 3059 if (mViewManager->currentView()->isEventView()) {
3056 int days = mViewManager->currentView()->currentDateCount(); 3060 int days = mViewManager->currentView()->currentDateCount();
3057 if (days == 1) { 3061 if (days == 1) {
3058 emit changeNavStringPrev(i18n("&Previous Day")); 3062 emit changeNavStringPrev(i18n("&Previous Day"));
3059 emit changeNavStringNext(i18n("&Next Day")); 3063 emit changeNavStringNext(i18n("&Next Day"));
3060 } else { 3064 } else {
3061 emit changeNavStringPrev(i18n("&Previous Week")); 3065 emit changeNavStringPrev(i18n("&Previous Week"));
3062 emit changeNavStringNext(i18n("&Next Week")); 3066 emit changeNavStringNext(i18n("&Next Week"));
3063 } 3067 }
3064 } 3068 }
3065} 3069}
3066 3070
3067void CalendarView::processMainViewSelection( Incidence *incidence ) 3071void CalendarView::processMainViewSelection( Incidence *incidence )
3068{ 3072{
3069 if ( incidence ) mTodoList->clearSelection(); 3073 if ( incidence ) mTodoList->clearSelection();
3070 processIncidenceSelection( incidence ); 3074 processIncidenceSelection( incidence );
3071} 3075}
3072 3076
3073void CalendarView::processTodoListSelection( Incidence *incidence ) 3077void CalendarView::processTodoListSelection( Incidence *incidence )
3074{ 3078{
3075 if ( incidence && mViewManager->currentView() ) { 3079 if ( incidence && mViewManager->currentView() ) {
3076 mViewManager->currentView()->clearSelection(); 3080 mViewManager->currentView()->clearSelection();
3077 } 3081 }
3078 processIncidenceSelection( incidence ); 3082 processIncidenceSelection( incidence );
3079} 3083}
3080 3084
3081void CalendarView::processIncidenceSelection( Incidence *incidence ) 3085void CalendarView::processIncidenceSelection( Incidence *incidence )
3082{ 3086{
3083 if ( incidence == mSelectedIncidence ) return; 3087 if ( incidence == mSelectedIncidence ) return;
3084 3088
3085 mSelectedIncidence = incidence; 3089 mSelectedIncidence = incidence;
3086 3090
3087 emit incidenceSelected( mSelectedIncidence ); 3091 emit incidenceSelected( mSelectedIncidence );
3088 3092
3089 if ( incidence && incidence->type() == "Event" ) { 3093 if ( incidence && incidence->type() == "Event" ) {
3090 Event *event = static_cast<Event *>( incidence ); 3094 Event *event = static_cast<Event *>( incidence );
3091 if ( event->organizer() == KOPrefs::instance()->email() ) { 3095 if ( event->organizer() == KOPrefs::instance()->email() ) {
3092 emit organizerEventsSelected( true ); 3096 emit organizerEventsSelected( true );
3093 } else { 3097 } else {
3094 emit organizerEventsSelected(false); 3098 emit organizerEventsSelected(false);
3095 } 3099 }
3096 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3100 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3097 KOPrefs::instance()->email() ) ) { 3101 KOPrefs::instance()->email() ) ) {
3098 emit groupEventsSelected( true ); 3102 emit groupEventsSelected( true );
3099 } else { 3103 } else {
3100 emit groupEventsSelected(false); 3104 emit groupEventsSelected(false);
3101 } 3105 }
3102 return; 3106 return;
3103 } else { 3107 } else {
3104 if ( incidence && incidence->type() == "Todo" ) { 3108 if ( incidence && incidence->type() == "Todo" ) {
3105 emit todoSelected( true ); 3109 emit todoSelected( true );
3106 Todo *event = static_cast<Todo *>( incidence ); 3110 Todo *event = static_cast<Todo *>( incidence );
3107 if ( event->organizer() == KOPrefs::instance()->email() ) { 3111 if ( event->organizer() == KOPrefs::instance()->email() ) {
3108 emit organizerEventsSelected( true ); 3112 emit organizerEventsSelected( true );
3109 } else { 3113 } else {
3110 emit organizerEventsSelected(false); 3114 emit organizerEventsSelected(false);
3111 } 3115 }
3112 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3116 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3113 KOPrefs::instance()->email() ) ) { 3117 KOPrefs::instance()->email() ) ) {
3114 emit groupEventsSelected( true ); 3118 emit groupEventsSelected( true );
3115 } else { 3119 } else {
3116 emit groupEventsSelected(false); 3120 emit groupEventsSelected(false);
3117 } 3121 }
3118 return; 3122 return;
3119 } else { 3123 } else {
3120 emit todoSelected( false ); 3124 emit todoSelected( false );
3121 emit organizerEventsSelected(false); 3125 emit organizerEventsSelected(false);
3122 emit groupEventsSelected(false); 3126 emit groupEventsSelected(false);
3123 } 3127 }
3124 return; 3128 return;
3125 } 3129 }
3126 3130
3127 /* if ( incidence && incidence->type() == "Todo" ) { 3131 /* if ( incidence && incidence->type() == "Todo" ) {
3128 emit todoSelected( true ); 3132 emit todoSelected( true );
3129 } else { 3133 } else {
3130 emit todoSelected( false ); 3134 emit todoSelected( false );
3131 }*/ 3135 }*/
3132} 3136}
3133 3137
3134 3138
3135void CalendarView::checkClipboard() 3139void CalendarView::checkClipboard()
3136{ 3140{
3137#ifndef KORG_NODND 3141#ifndef KORG_NODND
3138 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3142 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3139 emit pasteEnabled(true); 3143 emit pasteEnabled(true);
3140 } else { 3144 } else {
3141 emit pasteEnabled(false); 3145 emit pasteEnabled(false);
3142 } 3146 }
3143#endif 3147#endif
3144} 3148}
3145 3149
3146void CalendarView::showDates(const DateList &selectedDates) 3150void CalendarView::showDates(const DateList &selectedDates)
3147{ 3151{
3148 // kdDebug() << "CalendarView::selectDates()" << endl; 3152 // kdDebug() << "CalendarView::selectDates()" << endl;
3149 3153
3150 if ( mViewManager->currentView() ) { 3154 if ( mViewManager->currentView() ) {
3151 updateView( selectedDates.first(), selectedDates.last() ); 3155 updateView( selectedDates.first(), selectedDates.last() );
3152 } else { 3156 } else {
3153 mViewManager->showAgendaView(); 3157 mViewManager->showAgendaView();
3154 } 3158 }
3155 3159
3156 QString selDates; 3160 QString selDates;
3157 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3161 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3158 if (selectedDates.first() < selectedDates.last() ) 3162 if (selectedDates.first() < selectedDates.last() )
3159 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3163 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3160 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3164 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3161 3165
3162} 3166}
3163 3167
3164QPtrList<CalFilter> CalendarView::filters() 3168QPtrList<CalFilter> CalendarView::filters()
3165{ 3169{
3166 return mFilters; 3170 return mFilters;
3167 3171
3168} 3172}
3169void CalendarView::editFilters() 3173void CalendarView::editFilters()
3170{ 3174{
3171 // kdDebug() << "CalendarView::editFilters()" << endl; 3175 // kdDebug() << "CalendarView::editFilters()" << endl;
3172 3176
3173 CalFilter *filter = mFilters.first(); 3177 CalFilter *filter = mFilters.first();
3174 while(filter) { 3178 while(filter) {
3175 kdDebug() << " Filter: " << filter->name() << endl; 3179 kdDebug() << " Filter: " << filter->name() << endl;
3176 filter = mFilters.next(); 3180 filter = mFilters.next();
3177 } 3181 }
3178 3182
3179 mDialogManager->showFilterEditDialog(&mFilters); 3183 mDialogManager->showFilterEditDialog(&mFilters);
3180} 3184}
3181void CalendarView::toggleFilter() 3185void CalendarView::toggleFilter()
3182{ 3186{
3183 showFilter(! mFilterView->isVisible()); 3187 showFilter(! mFilterView->isVisible());
3184} 3188}
3185 3189
3186KOFilterView *CalendarView::filterView() 3190KOFilterView *CalendarView::filterView()
3187{ 3191{
3188 return mFilterView; 3192 return mFilterView;
3189} 3193}
3190void CalendarView::selectFilter( int fil ) 3194void CalendarView::selectFilter( int fil )
3191{ 3195{
3192 mFilterView->setSelectedFilter( fil ); 3196 mFilterView->setSelectedFilter( fil );
3193} 3197}
3194void CalendarView::showFilter(bool visible) 3198void CalendarView::showFilter(bool visible)
3195{ 3199{
3196 if (visible) mFilterView->show(); 3200 if (visible) mFilterView->show();
3197 else mFilterView->hide(); 3201 else mFilterView->hide();
3198} 3202}
3199void CalendarView::toggleFilerEnabled( ) 3203void CalendarView::toggleFilerEnabled( )
3200{ 3204{
3201 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3205 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3202 if ( !mFilterView->filtersEnabled() ) 3206 if ( !mFilterView->filtersEnabled() )
3203 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3207 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3204 3208
3205} 3209}
3206void CalendarView::updateFilter() 3210void CalendarView::updateFilter()
3207{ 3211{
3208 CalFilter *filter = mFilterView->selectedFilter(); 3212 CalFilter *filter = mFilterView->selectedFilter();
3209 if (filter) { 3213 if (filter) {
3210 if (mFilterView->filtersEnabled()) { 3214 if (mFilterView->filtersEnabled()) {
3211 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3215 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3212 filter->setEnabled(true); 3216 filter->setEnabled(true);
3213 } 3217 }
3214 else filter->setEnabled(false); 3218 else filter->setEnabled(false);
3215 mCalendar->setFilter(filter); 3219 mCalendar->setFilter(filter);
3216 updateView(); 3220 updateView();
3217 } 3221 }
3218} 3222}
3219 3223
3220void CalendarView::filterEdited() 3224void CalendarView::filterEdited()
3221{ 3225{
3222 mFilterView->updateFilters(); 3226 mFilterView->updateFilters();
3223 updateFilter(); 3227 updateFilter();
3224 writeSettings(); 3228 writeSettings();
3225} 3229}
3226 3230
3227 3231
3228void CalendarView::takeOverEvent() 3232void CalendarView::takeOverEvent()
3229{ 3233{
3230 Incidence *incidence = currentSelection(); 3234 Incidence *incidence = currentSelection();
3231 3235
3232 if (!incidence) return; 3236 if (!incidence) return;
3233 3237
3234 incidence->setOrganizer(KOPrefs::instance()->email()); 3238 incidence->setOrganizer(KOPrefs::instance()->email());
3235 incidence->recreate(); 3239 incidence->recreate();
3236 incidence->setReadOnly(false); 3240 incidence->setReadOnly(false);
3237 3241
3238 updateView(); 3242 updateView();
3239} 3243}
3240 3244
3241void CalendarView::takeOverCalendar() 3245void CalendarView::takeOverCalendar()
3242{ 3246{
3243 // TODO: Create Calendar::allIncidences() function and use it here 3247 // TODO: Create Calendar::allIncidences() function and use it here
3244 3248
3245 QPtrList<Event> events = mCalendar->events(); 3249 QPtrList<Event> events = mCalendar->events();
3246 for(uint i=0; i<events.count(); ++i) { 3250 for(uint i=0; i<events.count(); ++i) {
3247 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3251 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3248 events.at(i)->recreate(); 3252 events.at(i)->recreate();
3249 events.at(i)->setReadOnly(false); 3253 events.at(i)->setReadOnly(false);
3250 } 3254 }
3251 3255
3252 QPtrList<Todo> todos = mCalendar->todos(); 3256 QPtrList<Todo> todos = mCalendar->todos();
3253 for(uint i=0; i<todos.count(); ++i) { 3257 for(uint i=0; i<todos.count(); ++i) {
3254 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3258 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3255 todos.at(i)->recreate(); 3259 todos.at(i)->recreate();
3256 todos.at(i)->setReadOnly(false); 3260 todos.at(i)->setReadOnly(false);
3257 } 3261 }
3258 3262
3259 QPtrList<Journal> journals = mCalendar->journals(); 3263 QPtrList<Journal> journals = mCalendar->journals();
3260 for(uint i=0; i<journals.count(); ++i) { 3264 for(uint i=0; i<journals.count(); ++i) {
3261 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3265 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3262 journals.at(i)->recreate(); 3266 journals.at(i)->recreate();
3263 journals.at(i)->setReadOnly(false); 3267 journals.at(i)->setReadOnly(false);
3264 } 3268 }
3265 3269
3266 updateView(); 3270 updateView();
3267} 3271}
3268 3272
3269void CalendarView::showIntro() 3273void CalendarView::showIntro()
3270{ 3274{
3271 kdDebug() << "To be implemented." << endl; 3275 kdDebug() << "To be implemented." << endl;
3272} 3276}
3273 3277
3274QWidgetStack *CalendarView::viewStack() 3278QWidgetStack *CalendarView::viewStack()
3275{ 3279{
3276 return mRightFrame; 3280 return mRightFrame;
3277} 3281}
3278 3282
3279QWidget *CalendarView::leftFrame() 3283QWidget *CalendarView::leftFrame()
3280{ 3284{
3281 return mLeftFrame; 3285 return mLeftFrame;
3282} 3286}
3283 3287
3284DateNavigator *CalendarView::dateNavigator() 3288DateNavigator *CalendarView::dateNavigator()
3285{ 3289{
3286 return mNavigator; 3290 return mNavigator;
3287} 3291}
3288 3292
3289KDateNavigator* CalendarView::dateNavigatorWidget() 3293KDateNavigator* CalendarView::dateNavigatorWidget()
3290{ 3294{
3291 return mDateNavigator; 3295 return mDateNavigator;
3292} 3296}
3293void CalendarView::toggleDateNavigatorWidget() 3297void CalendarView::toggleDateNavigatorWidget()
3294{ 3298{
3295 if (mDateNavigator->isVisible()) 3299 if (mDateNavigator->isVisible())
3296 mDateNavigator->hide(); 3300 mDateNavigator->hide();
3297 else 3301 else
3298 mDateNavigator->show(); 3302 mDateNavigator->show();
3299} 3303}
3300void CalendarView::addView(KOrg::BaseView *view) 3304void CalendarView::addView(KOrg::BaseView *view)
3301{ 3305{
3302 mViewManager->addView(view); 3306 mViewManager->addView(view);
3303} 3307}
3304 3308
3305void CalendarView::showView(KOrg::BaseView *view) 3309void CalendarView::showView(KOrg::BaseView *view)
3306{ 3310{
3307 mViewManager->showView(view, mLeftFrame->isVisible()); 3311 mViewManager->showView(view, mLeftFrame->isVisible());
3308} 3312}
3309 3313
3310Incidence *CalendarView::currentSelection() 3314Incidence *CalendarView::currentSelection()
3311{ 3315{
3312 return mViewManager->currentSelection(); 3316 return mViewManager->currentSelection();
3313} 3317}
3314void CalendarView::toggleAllDaySize() 3318void CalendarView::toggleAllDaySize()
3315{ 3319{
3316 /* 3320 /*
3317 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3321 if ( KOPrefs::instance()->mAllDaySize > 47 )
3318 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3322 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3319 else 3323 else
3320 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3324 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3321 */ 3325 */
3322 viewManager()->agendaView()->toggleAllDay(); 3326 viewManager()->agendaView()->toggleAllDay();
3323} 3327}
3324void CalendarView::toggleExpand() 3328void CalendarView::toggleExpand()
3325{ 3329{
3326 // if ( mLeftFrame->isHidden() ) { 3330 // if ( mLeftFrame->isHidden() ) {
3327 // mLeftFrame->show(); 3331 // mLeftFrame->show();
3328 // emit calendarViewExpanded( false ); 3332 // emit calendarViewExpanded( false );
3329 // } else { 3333 // } else {
3330 // mLeftFrame->hide(); 3334 // mLeftFrame->hide();
3331 // emit calendarViewExpanded( true ); 3335 // emit calendarViewExpanded( true );
3332 // } 3336 // }
3333 3337
3334 globalFlagBlockAgenda = 1; 3338 globalFlagBlockAgenda = 1;
3335 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3339 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3336 globalFlagBlockAgenda = 5; 3340 globalFlagBlockAgenda = 5;
3337 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3341 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3338 //mViewManager->showView( 0, true ); 3342 //mViewManager->showView( 0, true );
3339} 3343}
3340 3344
3341void CalendarView::calendarModified( bool modified, Calendar * ) 3345void CalendarView::calendarModified( bool modified, Calendar * )
3342{ 3346{
3343 setModified( modified ); 3347 setModified( modified );
3344} 3348}
3345 3349
3346Todo *CalendarView::selectedTodo() 3350Todo *CalendarView::selectedTodo()
3347{ 3351{
3348 Incidence *incidence = currentSelection(); 3352 Incidence *incidence = currentSelection();
3349 if ( incidence && incidence->type() == "Todo" ) { 3353 if ( incidence && incidence->type() == "Todo" ) {
3350 return static_cast<Todo *>( incidence ); 3354 return static_cast<Todo *>( incidence );
3351 } 3355 }
3352 3356
3353 incidence = mTodoList->selectedIncidences().first(); 3357 incidence = mTodoList->selectedIncidences().first();
3354 if ( incidence && incidence->type() == "Todo" ) { 3358 if ( incidence && incidence->type() == "Todo" ) {
3355 return static_cast<Todo *>( incidence ); 3359 return static_cast<Todo *>( incidence );
3356 } 3360 }
3357 3361
3358 return 0; 3362 return 0;
3359} 3363}
3360 3364
3361void CalendarView::dialogClosing(Incidence *in) 3365void CalendarView::dialogClosing(Incidence *in)
3362{ 3366{
3363 // mDialogList.remove(in); 3367 // mDialogList.remove(in);
3364} 3368}
3365 3369
3366void CalendarView::showIncidence() 3370void CalendarView::showIncidence()
3367{ 3371{
3368 Incidence *incidence = currentSelection(); 3372 Incidence *incidence = currentSelection();
3369 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3373 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3370 if ( incidence ) { 3374 if ( incidence ) {
3371 ShowIncidenceVisitor v; 3375 ShowIncidenceVisitor v;
3372 v.act( incidence, this ); 3376 v.act( incidence, this );
3373 } 3377 }
3374} 3378}
3375void CalendarView::editIncidenceDescription() 3379void CalendarView::editIncidenceDescription()
3376{ 3380{
3377 mFlagEditDescription = true; 3381 mFlagEditDescription = true;
3378 editIncidence(); 3382 editIncidence();
3379 mFlagEditDescription = false; 3383 mFlagEditDescription = false;
3380} 3384}
3381void CalendarView::editIncidence() 3385void CalendarView::editIncidence()
3382{ 3386{
3383 // qDebug("editIncidence() "); 3387 // qDebug("editIncidence() ");
3384 Incidence *incidence = currentSelection(); 3388 Incidence *incidence = currentSelection();
3385 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3389 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3386 if ( incidence ) { 3390 if ( incidence ) {
3387 EditIncidenceVisitor v; 3391 EditIncidenceVisitor v;
3388 v.act( incidence, this ); 3392 v.act( incidence, this );
3389 } 3393 }
3390} 3394}
3391 3395
3392void CalendarView::deleteIncidence() 3396void CalendarView::deleteIncidence()
3393{ 3397{
3394 Incidence *incidence = currentSelection(); 3398 Incidence *incidence = currentSelection();
3395 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3399 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3396 if ( incidence ) { 3400 if ( incidence ) {
3397 deleteIncidence(incidence); 3401 deleteIncidence(incidence);
3398 } 3402 }
3399} 3403}
3400 3404
3401void CalendarView::showIncidence(Incidence *incidence) 3405void CalendarView::showIncidence(Incidence *incidence)
3402{ 3406{
3403 if ( incidence ) { 3407 if ( incidence ) {
3404 ShowIncidenceVisitor v; 3408 ShowIncidenceVisitor v;
3405 v.act( incidence, this ); 3409 v.act( incidence, this );
3406 } 3410 }
3407} 3411}
3408 3412
3409void CalendarView::editIncidence(Incidence *incidence) 3413void CalendarView::editIncidence(Incidence *incidence)
3410{ 3414{
3411 if ( incidence ) { 3415 if ( incidence ) {
3412 3416
3413 EditIncidenceVisitor v; 3417 EditIncidenceVisitor v;
3414 v.act( incidence, this ); 3418 v.act( incidence, this );
3415 3419
3416 } 3420 }
3417} 3421}
3418 3422
3419void CalendarView::deleteIncidence(Incidence *incidence) 3423void CalendarView::deleteIncidence(Incidence *incidence)
3420{ 3424{
3421 //qDebug(" CalendarView::deleteIncidence "); 3425 //qDebug(" CalendarView::deleteIncidence ");
3422 if ( incidence ) { 3426 if ( incidence ) {
3423 DeleteIncidenceVisitor v; 3427 DeleteIncidenceVisitor v;
3424 v.act( incidence, this ); 3428 v.act( incidence, this );
3425 } 3429 }
3426} 3430}
3427 3431
3428 3432
3429void CalendarView::lookForOutgoingMessages() 3433void CalendarView::lookForOutgoingMessages()
3430{ 3434{
3431 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3435 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3432 ogd->loadMessages(); 3436 ogd->loadMessages();
3433} 3437}
3434 3438
3435void CalendarView::lookForIncomingMessages() 3439void CalendarView::lookForIncomingMessages()
3436{ 3440{
3437 IncomingDialog *icd = mDialogManager->incomingDialog(); 3441 IncomingDialog *icd = mDialogManager->incomingDialog();
3438 icd->retrieve(); 3442 icd->retrieve();
3439} 3443}
3440 3444
3441bool CalendarView::removeCompletedSubTodos( Todo* t ) 3445bool CalendarView::removeCompletedSubTodos( Todo* t )
3442{ 3446{
3443 bool deleteTodo = true; 3447 bool deleteTodo = true;
3444 QPtrList<Incidence> subTodos; 3448 QPtrList<Incidence> subTodos;
3445 Incidence *aTodo; 3449 Incidence *aTodo;
3446 subTodos = t->relations(); 3450 subTodos = t->relations();
3447 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3451 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3448 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3452 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3449 deleteTodo = false; 3453 deleteTodo = false;
3450 } 3454 }
3451 if ( deleteTodo ) { 3455 if ( deleteTodo ) {
3452 if ( t->isCompleted() ) { 3456 if ( t->isCompleted() ) {
3453 checkExternalId( t ); 3457 checkExternalId( t );
3454 mCalendar->deleteTodo( t ); 3458 mCalendar->deleteTodo( t );
3455 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3459 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3456 } 3460 }
3457 else 3461 else
3458 deleteTodo = false; 3462 deleteTodo = false;
3459 } 3463 }
3460 return deleteTodo; 3464 return deleteTodo;
3461 3465
3462} 3466}
3463void CalendarView::purgeCompleted() 3467void CalendarView::purgeCompleted()
3464{ 3468{
3465 int result = KMessageBox::warningContinueCancel(this, 3469 int result = KMessageBox::warningContinueCancel(this,
3466 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3470 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3467 3471
3468 if (result == KMessageBox::Continue) { 3472 if (result == KMessageBox::Continue) {
3469 3473
3470 QPtrList<Todo> todoCal; 3474 QPtrList<Todo> todoCal;
3471 QPtrList<Todo> rootTodos; 3475 QPtrList<Todo> rootTodos;
3472 //QPtrList<Incidence> rel; 3476 //QPtrList<Incidence> rel;
3473 Todo *aTodo;//, *rTodo; 3477 Todo *aTodo;//, *rTodo;
3474 Incidence *rIncidence; 3478 Incidence *rIncidence;
3475 bool childDelete = false; 3479 bool childDelete = false;
3476 bool deletedOne = true; 3480 bool deletedOne = true;
3477 todoCal = calendar()->todos(); 3481 todoCal = calendar()->todos();
3478 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3482 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3479 if ( !aTodo->relatedTo() ) 3483 if ( !aTodo->relatedTo() )
3480 rootTodos.append( aTodo ); 3484 rootTodos.append( aTodo );
3481 } 3485 }
3482 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3486 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3483 removeCompletedSubTodos( aTodo ); 3487 removeCompletedSubTodos( aTodo );
3484 } 3488 }
3485 3489
3486 updateView(); 3490 updateView();
3487 } 3491 }
3488} 3492}
3489 3493
3490void CalendarView::slotCalendarChanged() 3494void CalendarView::slotCalendarChanged()
3491{ 3495{
3492 ; 3496 ;
3493} 3497}
3494 3498
3495NavigatorBar *CalendarView::navigatorBar() 3499NavigatorBar *CalendarView::navigatorBar()
3496{ 3500{
3497 return mNavigatorBar; 3501 return mNavigatorBar;
3498} 3502}
3499 3503
3500 3504
3501 3505
3502void CalendarView::keyPressEvent ( QKeyEvent *e) 3506void CalendarView::keyPressEvent ( QKeyEvent *e)
3503{ 3507{
3504 //qDebug(" alendarView::keyPressEvent "); 3508 //qDebug(" alendarView::keyPressEvent ");
3505 e->ignore(); 3509 e->ignore();
3506} 3510}
3507 3511
3508//#include "calendarview.moc" 3512//#include "calendarview.moc"
3509 3513
3510//#include "calendarviewbase.moc" 3514//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index d564473..b2838db 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,588 +1,589 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45class QWidgetStack; 45class QWidgetStack;
46class QSplitter; 46class QSplitter;
47 47
48class CalPrinter; 48class CalPrinter;
49class KOFilterView; 49class KOFilterView;
50class KOViewManager; 50class KOViewManager;
51class KODialogManager; 51class KODialogManager;
52class KOTodoView; 52class KOTodoView;
53class KDateNavigator; 53class KDateNavigator;
54class DateNavigator; 54class DateNavigator;
55class KOIncidenceEditor; 55class KOIncidenceEditor;
56class KDatePicker; 56class KDatePicker;
57class ResourceView; 57class ResourceView;
58class NavigatorBar; 58class NavigatorBar;
59class KOEventEditor; 59class KOEventEditor;
60class KOTodoEditor ; 60class KOTodoEditor ;
61class KOEventViewerDialog; 61class KOEventViewerDialog;
62class KOBeamPrefs; 62class KOBeamPrefs;
63class KSyncProfile; 63class KSyncProfile;
64class AlarmDialog; 64class AlarmDialog;
65class KCal::Attendee; 65class KCal::Attendee;
66 66
67namespace KCal { class FileStorage; } 67namespace KCal { class FileStorage; }
68 68
69using namespace KCal; 69using namespace KCal;
70 70
71/** 71/**
72 This is the main calendar widget. It provides the different vies on t he 72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 75 event editor, search dialog etc.
76 76
77 @short main calendar view widget 77 @short main calendar view widget
78 @author Cornelius Schumacher 78 @author Cornelius Schumacher
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 void setupExternSyncProfiles(); 116 void setupExternSyncProfiles();
117 117
118 signals: 118 signals:
119 /** This todo has been modified */ 119 /** This todo has been modified */
120 void todoModified(Todo *, int); 120 void todoModified(Todo *, int);
121 121
122 /** when change is made to options dialog, the topwidget will catch this 122 /** when change is made to options dialog, the topwidget will catch this
123 * and emit this signal which notifies all widgets which have registered 123 * and emit this signal which notifies all widgets which have registered
124 * for notification to update their settings. */ 124 * for notification to update their settings. */
125 void configChanged(); 125 void configChanged();
126 /** emitted when the topwidget is closing down, so that any attached 126 /** emitted when the topwidget is closing down, so that any attached
127 child windows can also close. */ 127 child windows can also close. */
128 void closingDown(); 128 void closingDown();
129 /** emitted right before we die */ 129 /** emitted right before we die */
130 void closed(QWidget *); 130 void closed(QWidget *);
131 131
132 /** Emitted when state of modified flag changes */ 132 /** Emitted when state of modified flag changes */
133 void modifiedChanged(bool); 133 void modifiedChanged(bool);
134 void signalmodified(); 134 void signalmodified();
135 135
136 /** Emitted when state of read-only flag changes */ 136 /** Emitted when state of read-only flag changes */
137 void readOnlyChanged(bool); 137 void readOnlyChanged(bool);
138 138
139 /** Emitted when the unit of navigation changes */ 139 /** Emitted when the unit of navigation changes */
140 void changeNavStringPrev(const QString &); 140 void changeNavStringPrev(const QString &);
141 void changeNavStringNext(const QString &); 141 void changeNavStringNext(const QString &);
142 142
143 /** Emitted when state of events selection has changed and user is organizer*/ 143 /** Emitted when state of events selection has changed and user is organizer*/
144 void organizerEventsSelected(bool); 144 void organizerEventsSelected(bool);
145 /** Emitted when state of events selection has changed and user is attendee*/ 145 /** Emitted when state of events selection has changed and user is attendee*/
146 void groupEventsSelected(bool); 146 void groupEventsSelected(bool);
147 /** 147 /**
148 Emitted when an incidence gets selected. If the selection is cleared the 148 Emitted when an incidence gets selected. If the selection is cleared the
149 signal is emitted with 0 as argument. 149 signal is emitted with 0 as argument.
150 */ 150 */
151 void incidenceSelected( Incidence * ); 151 void incidenceSelected( Incidence * );
152 /** Emitted, when a todoitem is selected or deselected. */ 152 /** Emitted, when a todoitem is selected or deselected. */
153 void todoSelected( bool ); 153 void todoSelected( bool );
154 154
155 /** 155 /**
156 Emitted, when clipboard content changes. Parameter indicates if paste 156 Emitted, when clipboard content changes. Parameter indicates if paste
157 is possible or not. 157 is possible or not.
158 */ 158 */
159 void pasteEnabled(bool); 159 void pasteEnabled(bool);
160 160
161 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 162 void numIncomingChanged(int);
163 163
164 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
166 166
167 /** Send status message, which can e.g. be displayed in the status bar. */ 167 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 168 void statusMessage(const QString &);
169 169
170 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 171 void updateSearchDialog();
172 172
173 173
174 public slots: 174 public slots:
175 void recheckTimerAlarm(); 175 void recheckTimerAlarm();
176 void checkNextTimerAlarm(); 176 void checkNextTimerAlarm();
177 void addAlarm(const QDateTime &qdt, const QString &noti ); 177 void addAlarm(const QDateTime &qdt, const QString &noti );
178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
179 void removeAlarm(const QDateTime &qdt, const QString &noti ); 179 void removeAlarm(const QDateTime &qdt, const QString &noti );
180 180
181 /** options dialog made a changed to the configuration. we catch this 181 /** options dialog made a changed to the configuration. we catch this
182 * and notify all widgets which need to update their configuration. */ 182 * and notify all widgets which need to update their configuration. */
183 void updateConfig(); 183 void updateConfig();
184 184
185 /** 185 /**
186 Load calendar from file \a filename. If \a merge is true, load 186 Load calendar from file \a filename. If \a merge is true, load
187 calendar into existing one, if it is false, clear calendar, before 187 calendar into existing one, if it is false, clear calendar, before
188 loading. Return true, if calendar could be successfully loaded. 188 loading. Return true, if calendar could be successfully loaded.
189 */ 189 */
190 bool openCalendar(QString filename, bool merge=false); 190 bool openCalendar(QString filename, bool merge=false);
191 bool syncCalendar(QString filename,int mode = 0 ); 191 bool syncCalendar(QString filename,int mode = 0 );
192 192
193 /** 193 /**
194 Save calendar data to file. Return true if calendar could be 194 Save calendar data to file. Return true if calendar could be
195 successfully saved. 195 successfully saved.
196 */ 196 */
197 bool saveCalendar(QString filename); 197 bool saveCalendar(QString filename);
198 198
199 /** 199 /**
200 Close calendar. Clear calendar data and reset views to display an empty 200 Close calendar. Clear calendar data and reset views to display an empty
201 calendar. 201 calendar.
202 */ 202 */
203 void closeCalendar(); 203 void closeCalendar();
204 204
205 /** Archive old events of calendar */ 205 /** Archive old events of calendar */
206 void archiveCalendar(); 206 void archiveCalendar();
207 207
208 void showIncidence(); 208 void showIncidence();
209 void editIncidence(); 209 void editIncidence();
210 void editIncidenceDescription(); 210 void editIncidenceDescription();
211 void deleteIncidence(); 211 void deleteIncidence();
212 212
213 /** create an editeventwin with supplied date/time, and if bool is true, 213 /** create an editeventwin with supplied date/time, and if bool is true,
214 * make the event take all day. */ 214 * make the event take all day. */
215 void newEvent(QDateTime, QDateTime, bool allDay = false); 215 void newEvent(QDateTime, QDateTime, bool allDay = false);
216 void newEvent(QDateTime fh); 216 void newEvent(QDateTime fh);
217 void newEvent(QDate dt); 217 void newEvent(QDate dt);
218 /** create new event without having a date hint. Takes current date as 218 /** create new event without having a date hint. Takes current date as
219 default hint. */ 219 default hint. */
220 void newEvent(); 220 void newEvent();
221 void newFloatingEvent(); 221 void newFloatingEvent();
222 222
223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
224 void showIncidence(Incidence *); 224 void showIncidence(Incidence *);
225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
226 void editIncidence(Incidence *); 226 void editIncidence(Incidence *);
227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
228 void deleteIncidence(Incidence *); 228 void deleteIncidence(Incidence *);
229 void cloneIncidence(Incidence *); 229 void cloneIncidence(Incidence *);
230 void cancelIncidence(Incidence *); 230 void cancelIncidence(Incidence *);
231 /** Create an editor for the supplied event. */ 231 /** Create an editor for the supplied event. */
232 void editEvent(Event *); 232 void editEvent(Event *);
233 /** Delete the supplied event. */ 233 /** Delete the supplied event. */
234 void deleteEvent(Event *); 234 void deleteEvent(Event *);
235 /** Delete the event with the given unique ID. Returns false, if event wasn't 235 /** Delete the event with the given unique ID. Returns false, if event wasn't
236 found. */ 236 found. */
237 bool deleteEvent(const QString &uid); 237 bool deleteEvent(const QString &uid);
238 /** Create a read-only viewer dialog for the supplied event. */ 238 /** Create a read-only viewer dialog for the supplied event. */
239 void showEvent(Event *); 239 void showEvent(Event *);
240 240
241 void editJournal(Journal *); 241 void editJournal(Journal *);
242 void showJournal(Journal *); 242 void showJournal(Journal *);
243 void deleteJournal(Journal *); 243 void deleteJournal(Journal *);
244 /** Create an editor dialog for a todo */ 244 /** Create an editor dialog for a todo */
245 void editTodo(Todo *); 245 void editTodo(Todo *);
246 /** Create a read-only viewer dialog for the supplied todo */ 246 /** Create a read-only viewer dialog for the supplied todo */
247 void showTodo(Todo *); 247 void showTodo(Todo *);
248 /** create new todo */ 248 /** create new todo */
249 void newTodo(); 249 void newTodo();
250 /** create new todo with a parent todo */ 250 /** create new todo with a parent todo */
251 void newSubTodo(); 251 void newSubTodo();
252 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
253 void newSubTodo(Todo *); 253 void newSubTodo(Todo *);
254 /** Delete todo */ 254 /** Delete todo */
255 void deleteTodo(Todo *); 255 void deleteTodo(Todo *);
256 256
257 257
258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
259 * emitted as result. */ 259 * emitted as result. */
260 void checkClipboard(); 260 void checkClipboard();
261 261
262 /** using the KConfig associated with the kapp variable, read in the 262 /** using the KConfig associated with the kapp variable, read in the
263 * settings from the config file. 263 * settings from the config file.
264 */ 264 */
265 void readSettings(); 265 void readSettings();
266 266
267 /** write current state to config file. */ 267 /** write current state to config file. */
268 void writeSettings(); 268 void writeSettings();
269 269
270 /** read settings for calendar filters */ 270 /** read settings for calendar filters */
271 void readFilterSettings(KConfig *config); 271 void readFilterSettings(KConfig *config);
272 272
273 /** write settings for calendar filters */ 273 /** write settings for calendar filters */
274 void writeFilterSettings(KConfig *config); 274 void writeFilterSettings(KConfig *config);
275 275
276 /** passes on the message that an event has changed to the currently 276 /** passes on the message that an event has changed to the currently
277 * activated view so that it can make appropriate display changes. */ 277 * activated view so that it can make appropriate display changes. */
278 void changeEventDisplay(Event *, int); 278 void changeEventDisplay(Event *, int);
279 void changeIncidenceDisplay(Incidence *, int); 279 void changeIncidenceDisplay(Incidence *, int);
280 void changeTodoDisplay(Todo *, int); 280 void changeTodoDisplay(Todo *, int);
281 281
282 void eventAdded(Event *); 282 void eventAdded(Event *);
283 void eventChanged(Event *); 283 void eventChanged(Event *);
284 void eventToBeDeleted(Event *); 284 void eventToBeDeleted(Event *);
285 void eventDeleted(); 285 void eventDeleted();
286 286
287 void todoAdded(Todo *); 287 void todoAdded(Todo *);
288 void todoChanged(Todo *); 288 void todoChanged(Todo *);
289 void todoToBeDeleted(Todo *); 289 void todoToBeDeleted(Todo *);
290 void todoDeleted(); 290 void todoDeleted();
291 291
292 void updateView(const QDate &start, const QDate &end); 292 void updateView(const QDate &start, const QDate &end);
293 void updateView(); 293 void updateView();
294 294
295 /** Full update of visible todo views */ 295 /** Full update of visible todo views */
296 void updateTodoViews(); 296 void updateTodoViews();
297 297
298 void updateUnmanagedViews(); 298 void updateUnmanagedViews();
299 299
300 /** cut the current appointment to the clipboard */ 300 /** cut the current appointment to the clipboard */
301 void edit_cut(); 301 void edit_cut();
302 302
303 /** copy the current appointment(s) to the clipboard */ 303 /** copy the current appointment(s) to the clipboard */
304 void edit_copy(); 304 void edit_copy();
305 305
306 /** paste the current vobject(s) in the clipboard buffer into calendar */ 306 /** paste the current vobject(s) in the clipboard buffer into calendar */
307 void edit_paste(); 307 void edit_paste();
308 308
309 /** edit viewing and configuration options. */ 309 /** edit viewing and configuration options. */
310 void edit_options(); 310 void edit_options();
311 void edit_sync_options(); 311 void edit_sync_options();
312 /** 312 /**
313 Functions for printing, previewing a print, and setting up printing 313 Functions for printing, previewing a print, and setting up printing
314 parameters. 314 parameters.
315 */ 315 */
316 void print(); 316 void print();
317 void printSetup(); 317 void printSetup();
318 void printPreview(); 318 void printPreview();
319 319
320 /** Export as iCalendar file */ 320 /** Export as iCalendar file */
321 void exportICalendar(); 321 void exportICalendar();
322 322
323 /** Export as vCalendar file */ 323 /** Export as vCalendar file */
324 bool exportVCalendar( QString fn); 324 bool exportVCalendar( QString fn);
325 325
326 /** pop up a dialog to show an existing appointment. */ 326 /** pop up a dialog to show an existing appointment. */
327 void appointment_show(); 327 void appointment_show();
328 /** 328 /**
329 * pop up an Appointment Dialog to edit an existing appointment.Get 329 * pop up an Appointment Dialog to edit an existing appointment.Get
330 * information on the appointment from the list of unique IDs that is 330 * information on the appointment from the list of unique IDs that is
331 * currently in the View, called currIds. 331 * currently in the View, called currIds.
332 */ 332 */
333 void appointment_edit(); 333 void appointment_edit();
334 /** 334 /**
335 * pop up dialog confirming deletion of currently selected event in the 335 * pop up dialog confirming deletion of currently selected event in the
336 * View. 336 * View.
337 */ 337 */
338 void appointment_delete(); 338 void appointment_delete();
339 339
340 /** mails the currently selected event to a particular user as a vCalendar 340 /** mails the currently selected event to a particular user as a vCalendar
341 attachment. */ 341 attachment. */
342 void action_mail(); 342 void action_mail();
343 343
344 /* frees a subtodo from it's relation */ 344 /* frees a subtodo from it's relation */
345 void todo_unsub( Todo * ); 345 void todo_unsub( Todo * );
346 346
347 /** Take ownership of selected event. */ 347 /** Take ownership of selected event. */
348 void takeOverEvent(); 348 void takeOverEvent();
349 349
350 /** Take ownership of all events in calendar. */ 350 /** Take ownership of all events in calendar. */
351 void takeOverCalendar(); 351 void takeOverCalendar();
352 352
353 /** query whether or not the calendar is "dirty". */ 353 /** query whether or not the calendar is "dirty". */
354 bool isModified(); 354 bool isModified();
355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
356 void setModified(bool modified=true); 356 void setModified(bool modified=true);
357 357
358 /** query if the calendar is read-only. */ 358 /** query if the calendar is read-only. */
359 bool isReadOnly(); 359 bool isReadOnly();
360 /** set state of calendar to read-only */ 360 /** set state of calendar to read-only */
361 void setReadOnly(bool readOnly=true); 361 void setReadOnly(bool readOnly=true);
362 362
363 void eventUpdated(Incidence *); 363 void eventUpdated(Incidence *);
364 364
365 /* iTIP scheduling actions */ 365 /* iTIP scheduling actions */
366 void schedule_publish(Incidence *incidence = 0); 366 void schedule_publish(Incidence *incidence = 0);
367 void schedule_request(Incidence *incidence = 0); 367 void schedule_request(Incidence *incidence = 0);
368 void schedule_refresh(Incidence *incidence = 0); 368 void schedule_refresh(Incidence *incidence = 0);
369 void schedule_cancel(Incidence *incidence = 0); 369 void schedule_cancel(Incidence *incidence = 0);
370 void schedule_add(Incidence *incidence = 0); 370 void schedule_add(Incidence *incidence = 0);
371 void schedule_reply(Incidence *incidence = 0); 371 void schedule_reply(Incidence *incidence = 0);
372 void schedule_counter(Incidence *incidence = 0); 372 void schedule_counter(Incidence *incidence = 0);
373 void schedule_declinecounter(Incidence *incidence = 0); 373 void schedule_declinecounter(Incidence *incidence = 0);
374 void schedule_publish_freebusy(int daysToPublish = 30); 374 void schedule_publish_freebusy(int daysToPublish = 30);
375 375
376 void openAddressbook(); 376 void openAddressbook();
377 377
378 void editFilters(); 378 void editFilters();
379 void toggleFilerEnabled(); 379 void toggleFilerEnabled();
380 QPtrList<CalFilter> filters(); 380 QPtrList<CalFilter> filters();
381 void toggleFilter(); 381 void toggleFilter();
382 void showFilter(bool visible); 382 void showFilter(bool visible);
383 void updateFilter(); 383 void updateFilter();
384 void filterEdited(); 384 void filterEdited();
385 void selectFilter( int ); 385 void selectFilter( int );
386 KOFilterView *filterView(); 386 KOFilterView *filterView();
387 387
388 void showIntro(); 388 void showIntro();
389 389
390 /** Move the curdatepient view date to today */ 390 /** Move the curdatepient view date to today */
391 void goToday(); 391 void goToday();
392 392
393 /** Move to the next date(s) in the current view */ 393 /** Move to the next date(s) in the current view */
394 void goNext(); 394 void goNext();
395 395
396 /** Move to the previous date(s) in the current view */ 396 /** Move to the previous date(s) in the current view */
397 void goPrevious(); 397 void goPrevious();
398 /** Move to the next date(s) in the current view */ 398 /** Move to the next date(s) in the current view */
399 void goNextMonth(); 399 void goNextMonth();
400 400
401 /** Move to the previous date(s) in the current view */ 401 /** Move to the previous date(s) in the current view */
402 void goPreviousMonth(); 402 void goPreviousMonth();
403 403
404 void toggleExpand(); 404 void toggleExpand();
405 void toggleDateNavigatorWidget(); 405 void toggleDateNavigatorWidget();
406 void toggleAllDaySize(); 406 void toggleAllDaySize();
407 void dialogClosing(Incidence *); 407 void dialogClosing(Incidence *);
408 408
409 /** Look for new messages in the inbox */ 409 /** Look for new messages in the inbox */
410 void lookForIncomingMessages(); 410 void lookForIncomingMessages();
411 /** Look for new messages in the outbox */ 411 /** Look for new messages in the outbox */
412 void lookForOutgoingMessages(); 412 void lookForOutgoingMessages();
413 413
414 void processMainViewSelection( Incidence * ); 414 void processMainViewSelection( Incidence * );
415 void processTodoListSelection( Incidence * ); 415 void processTodoListSelection( Incidence * );
416 416
417 void processIncidenceSelection( Incidence * ); 417 void processIncidenceSelection( Incidence * );
418 418
419 void purgeCompleted(); 419 void purgeCompleted();
420 bool removeCompletedSubTodos( Todo* ); 420 bool removeCompletedSubTodos( Todo* );
421 void slotCalendarChanged(); 421 void slotCalendarChanged();
422 bool importBday(); 422 bool importBday();
423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
424 bool importQtopia( const QString &categoriesFile, 424 bool importQtopia( const QString &categoriesFile,
425 const QString &datebookFile, 425 const QString &datebookFile,
426 const QString &tasklistFile ); 426 const QString &tasklistFile );
427 void syncSharp( ); 427 void syncSharp( );
428 void syncPhone( );
428 void slotSelectPickerDate( QDate ) ; 429 void slotSelectPickerDate( QDate ) ;
429 void showDatePicker( ) ; 430 void showDatePicker( ) ;
430 void moveIncidence(Incidence *) ; 431 void moveIncidence(Incidence *) ;
431 void beamIncidence(Incidence *) ; 432 void beamIncidence(Incidence *) ;
432 void beamCalendar() ; 433 void beamCalendar() ;
433 void beamFilteredCalendar() ; 434 void beamFilteredCalendar() ;
434 void beamIncidenceList(QPtrList<Incidence>) ; 435 void beamIncidenceList(QPtrList<Incidence>) ;
435 void manageCategories(); 436 void manageCategories();
436 int addCategories(); 437 int addCategories();
437 void removeCategories(); 438 void removeCategories();
438 void setSyncDevice( QString ); 439 void setSyncDevice( QString );
439 void setSyncName( QString ); 440 void setSyncName( QString );
440 protected slots: 441 protected slots:
441 void timerAlarm(); 442 void timerAlarm();
442 void suspendAlarm(); 443 void suspendAlarm();
443 void beamDone( Ir *ir ); 444 void beamDone( Ir *ir );
444 /** Select a view or adapt the current view to display the specified dates. */ 445 /** Select a view or adapt the current view to display the specified dates. */
445 void showDates( const KCal::DateList & ); 446 void showDates( const KCal::DateList & );
446 void selectWeekNum ( int ); 447 void selectWeekNum ( int );
447 448
448 public: 449 public:
449 // show a standard warning 450 // show a standard warning
450 // returns KMsgBox::yesNoCancel() 451 // returns KMsgBox::yesNoCancel()
451 int msgCalModified(); 452 int msgCalModified();
452 void confSync(); 453 void confSync();
453 void setLoadedFileVersion(QDateTime); 454 void setLoadedFileVersion(QDateTime);
454 bool checkFileVersion(QString fn); 455 bool checkFileVersion(QString fn);
455 bool checkFileChanged(QString fn); 456 bool checkFileChanged(QString fn);
456 Event* getLastSyncEvent(); 457 Event* getLastSyncEvent();
457 /** Adapt navigation units correpsonding to step size of navigation of the 458 /** Adapt navigation units correpsonding to step size of navigation of the
458 * current view. 459 * current view.
459 */ 460 */
460 void adaptNavigationUnits(); 461 void adaptNavigationUnits();
461 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 462 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
462 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 463 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
463 //Attendee* getYourAttendee(Event *event); 464 //Attendee* getYourAttendee(Event *event);
464 protected: 465 protected:
465 void schedule(Scheduler::Method, Incidence *incidence = 0); 466 void schedule(Scheduler::Method, Incidence *incidence = 0);
466 467
467 // returns KMsgBox::OKCandel() 468 // returns KMsgBox::OKCandel()
468 int msgItemDelete(); 469 int msgItemDelete();
469 void showEventEditor(); 470 void showEventEditor();
470 void showTodoEditor(); 471 void showTodoEditor();
471 void writeLocale(); 472 void writeLocale();
472 Todo *selectedTodo(); 473 Todo *selectedTodo();
473 474
474 private: 475 private:
475 AlarmDialog * mAlarmDialog; 476 AlarmDialog * mAlarmDialog;
476 QString mAlarmNotification; 477 QString mAlarmNotification;
477 QString mSuspendAlarmNotification; 478 QString mSuspendAlarmNotification;
478 QTimer* mSuspendTimer; 479 QTimer* mSuspendTimer;
479 QTimer* mAlarmTimer; 480 QTimer* mAlarmTimer;
480 QTimer* mRecheckAlarmTimer; 481 QTimer* mRecheckAlarmTimer;
481 void computeAlarm( QString ); 482 void computeAlarm( QString );
482 void startAlarm( QString, QString ); 483 void startAlarm( QString, QString );
483 void setSyncEventsReadOnly(); 484 void setSyncEventsReadOnly();
484 485
485 QDateTime loadedFileVersion; 486 QDateTime loadedFileVersion;
486 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 487 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
487 void checkExternalId( Incidence * inc ); 488 void checkExternalId( Incidence * inc );
488 int mGlobalSyncMode; 489 int mGlobalSyncMode;
489 QString mCurrentSyncDevice; 490 QString mCurrentSyncDevice;
490 QString mCurrentSyncName; 491 QString mCurrentSyncName;
491 KOBeamPrefs* beamDialog; 492 KOBeamPrefs* beamDialog;
492 void init(); 493 void init();
493 int mDatePickerMode; 494 int mDatePickerMode;
494 bool mFlagEditDescription; 495 bool mFlagEditDescription;
495 QDateTime mLastCalendarSync; 496 QDateTime mLastCalendarSync;
496 void createPrinter(); 497 void createPrinter();
497 498
498 void calendarModified( bool, Calendar * ); 499 void calendarModified( bool, Calendar * );
499 500
500 CalPrinter *mCalPrinter; 501 CalPrinter *mCalPrinter;
501 502
502 QSplitter *mPanner; 503 QSplitter *mPanner;
503 QSplitter *mLeftSplitter; 504 QSplitter *mLeftSplitter;
504 QWidget *mLeftFrame; 505 QWidget *mLeftFrame;
505 QWidgetStack *mRightFrame; 506 QWidgetStack *mRightFrame;
506 507
507 KDatePicker* mDatePicker; 508 KDatePicker* mDatePicker;
508 QVBox* mDateFrame; 509 QVBox* mDateFrame;
509 NavigatorBar *mNavigatorBar; 510 NavigatorBar *mNavigatorBar;
510 511
511 KDateNavigator *mDateNavigator; // widget showing small month view. 512 KDateNavigator *mDateNavigator; // widget showing small month view.
512 513
513 KOFilterView *mFilterView; 514 KOFilterView *mFilterView;
514 515
515 ResourceView *mResourceView; 516 ResourceView *mResourceView;
516 517
517 // calendar object for this viewing instance 518 // calendar object for this viewing instance
518 Calendar *mCalendar; 519 Calendar *mCalendar;
519 520
520 CalendarResourceManager *mResourceManager; 521 CalendarResourceManager *mResourceManager;
521 522
522 FileStorage *mStorage; 523 FileStorage *mStorage;
523 524
524 DateNavigator *mNavigator; 525 DateNavigator *mNavigator;
525 526
526 KOViewManager *mViewManager; 527 KOViewManager *mViewManager;
527 KODialogManager *mDialogManager; 528 KODialogManager *mDialogManager;
528 529
529 // Calendar filters 530 // Calendar filters
530 QPtrList<CalFilter> mFilters; 531 QPtrList<CalFilter> mFilters;
531 532
532 // various housekeeping variables. 533 // various housekeeping variables.
533 bool mModified; // flag indicating if calendar is modified 534 bool mModified; // flag indicating if calendar is modified
534 bool mReadOnly; // flag indicating if calendar is read-only 535 bool mReadOnly; // flag indicating if calendar is read-only
535 QDate mSaveSingleDate; 536 QDate mSaveSingleDate;
536 537
537 Incidence *mSelectedIncidence; 538 Incidence *mSelectedIncidence;
538 Incidence *mMoveIncidence; 539 Incidence *mMoveIncidence;
539 QPtrList<Event> mExternLastSyncEvent; 540 QPtrList<Event> mExternLastSyncEvent;
540 KOTodoView *mTodoList; 541 KOTodoView *mTodoList;
541 KOEventEditor * mEventEditor; 542 KOEventEditor * mEventEditor;
542 KOTodoEditor * mTodoEditor; 543 KOTodoEditor * mTodoEditor;
543 KOEventViewerDialog * mEventViewerDialog; 544 KOEventViewerDialog * mEventViewerDialog;
544 void keyPressEvent ( QKeyEvent *e) ; 545 void keyPressEvent ( QKeyEvent *e) ;
545 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 546 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
546}; 547};
547 548
548 549
549class CalendarViewVisitor : public Incidence::Visitor 550class CalendarViewVisitor : public Incidence::Visitor
550{ 551{
551 public: 552 public:
552 CalendarViewVisitor() : mView( 0 ) {} 553 CalendarViewVisitor() : mView( 0 ) {}
553 554
554 bool act( Incidence *incidence, CalendarView *view ) 555 bool act( Incidence *incidence, CalendarView *view )
555 { 556 {
556 mView = view; 557 mView = view;
557 return incidence->accept( *this ); 558 return incidence->accept( *this );
558 } 559 }
559 560
560 protected: 561 protected:
561 CalendarView *mView; 562 CalendarView *mView;
562}; 563};
563 564
564class ShowIncidenceVisitor : public CalendarViewVisitor 565class ShowIncidenceVisitor : public CalendarViewVisitor
565{ 566{
566 protected: 567 protected:
567 bool visit( Event *event ) { mView->showEvent( event ); return true; } 568 bool visit( Event *event ) { mView->showEvent( event ); return true; }
568 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 569 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
569 bool visit( Journal * j ) { mView->showJournal( j );return true; } 570 bool visit( Journal * j ) { mView->showJournal( j );return true; }
570}; 571};
571 572
572class EditIncidenceVisitor : public CalendarViewVisitor 573class EditIncidenceVisitor : public CalendarViewVisitor
573{ 574{
574 protected: 575 protected:
575 bool visit( Event *event ) { mView->editEvent( event ); return true; } 576 bool visit( Event *event ) { mView->editEvent( event ); return true; }
576 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 577 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
577 bool visit( Journal *j ) { mView->editJournal( j); return true; } 578 bool visit( Journal *j ) { mView->editJournal( j); return true; }
578}; 579};
579 580
580class DeleteIncidenceVisitor : public CalendarViewVisitor 581class DeleteIncidenceVisitor : public CalendarViewVisitor
581{ 582{
582 protected: 583 protected:
583 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 584 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
584 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 585 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
585 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 586 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
586}; 587};
587 588
588#endif 589#endif
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 424fa98..446fe2e 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,300 +1,303 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h> 26#include <qdict.h>
27 27
28#include <libkdepim/kpimprefs.h> 28#include <libkdepim/kpimprefs.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35class KOPrefs : public KPimPrefs 35class KOPrefs : public KPimPrefs
36{ 36{
37 public: 37 public:
38 enum { FormatVCalendar, FormatICalendar }; 38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 43 enum { standardDestination, askDestination };
44 44
45 virtual ~KOPrefs(); 45 virtual ~KOPrefs();
46 46
47 /** Get instance of KOPrefs. It is made sure that there is only one 47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 48 instance. */
49 static KOPrefs *instance(); 49 static KOPrefs *instance();
50 50
51 /** Set preferences to default values */ 51 /** Set preferences to default values */
52 void usrSetDefaults(); 52 void usrSetDefaults();
53 53
54 /** Read preferences from config file */ 54 /** Read preferences from config file */
55 void usrReadConfig(); 55 void usrReadConfig();
56 56
57 /** Write preferences to config file */ 57 /** Write preferences to config file */
58 void usrWriteConfig(); 58 void usrWriteConfig();
59 void setCategoryDefaults(); 59 void setCategoryDefaults();
60 60
61 protected: 61 protected:
62 void setTimeZoneIdDefault(); 62 void setTimeZoneIdDefault();
63 63
64 /** Fill empty mail fields with default values. */ 64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults(); 65 void fillMailDefaults();
66 66
67 private: 67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs 68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */ 69 object. */
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict; 73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 74 QStringList getDefaultList();
75 public: 75 public:
76 // preferences data 76 // preferences data
77 KConfig* getConfig(); 77 KConfig* getConfig();
78 void setFullName(const QString &); 78 void setFullName(const QString &);
79 QString fullName(); 79 QString fullName();
80 void setEmail(const QString &); 80 void setEmail(const QString &);
81 QString email(); 81 QString email();
82 82
83 QString mAdditional; 83 QString mAdditional;
84 84
85 bool mEmailControlCenter; 85 bool mEmailControlCenter;
86 86
87 bool mBcc; 87 bool mBcc;
88 bool mAutoSave; 88 bool mAutoSave;
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 QString mTimeZoneId; 99 QString mTimeZoneId;
100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
101 //int mTimeZoneOffset; // e.g. -240 min 101 //int mTimeZoneOffset; // e.g. -240 min
102 bool mUseDaylightsaving; 102 bool mUseDaylightsaving;
103 int mDaylightsavingStart; 103 int mDaylightsavingStart;
104 int mDaylightsavingEnd; 104 int mDaylightsavingEnd;
105 int mStartTime; 105 int mStartTime;
106 int mDefaultDuration; 106 int mDefaultDuration;
107 int mAlarmTime; 107 int mAlarmTime;
108 int mDaylightSavings; 108 int mDaylightSavings;
109 109
110 int mWorkingHoursStart; 110 int mWorkingHoursStart;
111 int mWorkingHoursEnd; 111 int mWorkingHoursEnd;
112 bool mExcludeHolidays; 112 bool mExcludeHolidays;
113 bool mExcludeSaturdays; 113 bool mExcludeSaturdays;
114 bool mMarcusBainsShowSeconds; 114 bool mMarcusBainsShowSeconds;
115 115
116 QFont mTimeBarFont; 116 QFont mTimeBarFont;
117 QFont mMonthViewFont; 117 QFont mMonthViewFont;
118 QFont mAgendaViewFont; 118 QFont mAgendaViewFont;
119 QFont mMarcusBainsFont; 119 QFont mMarcusBainsFont;
120 QFont mTimeLabelsFont; 120 QFont mTimeLabelsFont;
121 QFont mTodoViewFont; 121 QFont mTodoViewFont;
122 QFont mListViewFont; 122 QFont mListViewFont;
123 QFont mDateNavigatorFont; 123 QFont mDateNavigatorFont;
124 QFont mEditBoxFont; 124 QFont mEditBoxFont;
125 QFont mJornalViewFont; 125 QFont mJornalViewFont;
126 QFont mWhatsNextFont; 126 QFont mWhatsNextFont;
127 QFont mEventViewFont; 127 QFont mEventViewFont;
128 128
129 129
130 130
131 131
132 QColor mHolidayColor; 132 QColor mHolidayColor;
133 QColor mHighlightColor; 133 QColor mHighlightColor;
134 QColor mEventColor; 134 QColor mEventColor;
135 QColor mAgendaBgColor; 135 QColor mAgendaBgColor;
136 QColor mWorkingHoursColor; 136 QColor mWorkingHoursColor;
137 QColor mTodoDueTodayColor; 137 QColor mTodoDueTodayColor;
138 QColor mTodoOverdueColor; 138 QColor mTodoOverdueColor;
139 QColor mMonthViewEvenColor; 139 QColor mMonthViewEvenColor;
140 QColor mMonthViewOddColor; 140 QColor mMonthViewOddColor;
141 QColor mMonthViewHolidayColor; 141 QColor mMonthViewHolidayColor;
142 bool mMonthViewUsesDayColors; 142 bool mMonthViewUsesDayColors;
143 bool mMonthViewSatSunTog; 143 bool mMonthViewSatSunTog;
144 QColor mAppColor1; 144 QColor mAppColor1;
145 QColor mAppColor2; 145 QColor mAppColor2;
146 bool mUseAppColors; 146 bool mUseAppColors;
147 147
148 int mDayBegins; 148 int mDayBegins;
149 int mHourSize; 149 int mHourSize;
150 int mAllDaySize; 150 int mAllDaySize;
151 bool mShowFullMenu; 151 bool mShowFullMenu;
152 bool mDailyRecur; 152 bool mDailyRecur;
153 bool mWeeklyRecur; 153 bool mWeeklyRecur;
154 bool mMonthDailyRecur; 154 bool mMonthDailyRecur;
155 bool mMonthWeeklyRecur; 155 bool mMonthWeeklyRecur;
156 bool mMonthShowIcons; 156 bool mMonthShowIcons;
157 bool mMonthShowShort; 157 bool mMonthShowShort;
158 bool mEnableToolTips; 158 bool mEnableToolTips;
159 bool mEnableMonthScroll; 159 bool mEnableMonthScroll;
160 bool mFullViewMonth; 160 bool mFullViewMonth;
161 bool mMonthViewUsesCategoryColor; 161 bool mMonthViewUsesCategoryColor;
162 bool mFullViewTodo; 162 bool mFullViewTodo;
163 bool mShowCompletedTodo; 163 bool mShowCompletedTodo;
164 bool mMarcusBainsEnabled; 164 bool mMarcusBainsEnabled;
165 int mNextXDays; 165 int mNextXDays;
166 int mWhatsNextDays; 166 int mWhatsNextDays;
167 int mWhatsNextPrios; 167 int mWhatsNextPrios;
168 bool mEnableQuickTodo; 168 bool mEnableQuickTodo;
169 bool mLanguageChanged; 169 bool mLanguageChanged;
170 170
171 bool mCompactDialogs; 171 bool mCompactDialogs;
172 bool mVerticalScreen; 172 bool mVerticalScreen;
173 173
174 bool mShowIconNewTodo; 174 bool mShowIconNewTodo;
175 bool mShowIconNewEvent; 175 bool mShowIconNewEvent;
176 bool mShowIconSearch; 176 bool mShowIconSearch;
177 bool mShowIconList; 177 bool mShowIconList;
178 bool mShowIconDay1; 178 bool mShowIconDay1;
179 bool mShowIconDay5; 179 bool mShowIconDay5;
180 bool mShowIconDay7; 180 bool mShowIconDay7;
181 bool mShowIconMonth; 181 bool mShowIconMonth;
182 bool mShowIconTodoview; 182 bool mShowIconTodoview;
183 bool mShowIconBackFast; 183 bool mShowIconBackFast;
184 bool mShowIconBack; 184 bool mShowIconBack;
185 bool mShowIconToday; 185 bool mShowIconToday;
186 bool mShowIconForward; 186 bool mShowIconForward;
187 bool mShowIconForwardFast; 187 bool mShowIconForwardFast;
188 bool mShowIconWhatsThis; 188 bool mShowIconWhatsThis;
189 bool mShowIconNextDays; 189 bool mShowIconNextDays;
190 bool mShowIconNext; 190 bool mShowIconNext;
191 bool mShowIconJournal; 191 bool mShowIconJournal;
192 192
193 bool mShowIconStretch; 193 bool mShowIconStretch;
194 194
195 bool mToolBarHor; 195 bool mToolBarHor;
196 bool mToolBarUp; 196 bool mToolBarUp;
197 bool mToolBarMiniIcons; 197 bool mToolBarMiniIcons;
198 198
199 bool mAskForQuit; 199 bool mAskForQuit;
200 bool mUsePassWd; 200 bool mUsePassWd;
201 bool mWriteBackFile; 201 bool mWriteBackFile;
202 bool mAskForPreferences; 202 bool mAskForPreferences;
203 bool mShowSyncSummary; 203 bool mShowSyncSummary;
204 bool mShowSyncEvents; 204 bool mShowSyncEvents;
205 bool mShowTodoInAgenda; 205 bool mShowTodoInAgenda;
206 bool mWriteBackExistingOnly; 206 bool mWriteBackExistingOnly;
207 207
208 QString mRemoteIP; 208 QString mRemoteIP;
209 QString mRemoteUser; 209 QString mRemoteUser;
210 QString mRemotePassWd; 210 QString mRemotePassWd;
211 QString mRemoteFile; 211 QString mRemoteFile;
212 QString mLocalTempFile; 212 QString mLocalTempFile;
213 QString mPhoneDevice;
214 QString mPhoneConnection;
215 QString mPhoneModel;
213 216
214 int mLastSyncTime; 217 int mLastSyncTime;
215 int mSyncAlgoPrefs; 218 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 219 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 220 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles; 221 QStringList mExternSyncProfiles;
219 QString mLocalMachineName; 222 QString mLocalMachineName;
220 void setCategoryColor(QString cat,const QColor & color); 223 void setCategoryColor(QString cat,const QColor & color);
221 QColor *categoryColor(QString cat); 224 QColor *categoryColor(QString cat);
222 225
223 QString mArchiveFile; 226 QString mArchiveFile;
224 QString mHtmlExportFile; 227 QString mHtmlExportFile;
225 bool mHtmlWithSave; 228 bool mHtmlWithSave;
226 229
227 QStringList mSelectedPlugins; 230 QStringList mSelectedPlugins;
228 231
229 QString mLastImportFile; 232 QString mLastImportFile;
230 QString mLastVcalFile; 233 QString mLastVcalFile;
231 QString mLastSaveFile; 234 QString mLastSaveFile;
232 QString mLastLoadFile; 235 QString mLastLoadFile;
233 QString mLastSyncedLocalFile; 236 QString mLastSyncedLocalFile;
234 237
235 238
236 QString mDefaultAlarmFile; 239 QString mDefaultAlarmFile;
237 int mIMIPScheduler; 240 int mIMIPScheduler;
238 int mIMIPSend; 241 int mIMIPSend;
239 QStringList mAdditionalMails; 242 QStringList mAdditionalMails;
240 int mIMIPAutoRefresh; 243 int mIMIPAutoRefresh;
241 int mIMIPAutoInsertReply; 244 int mIMIPAutoInsertReply;
242 int mIMIPAutoInsertRequest; 245 int mIMIPAutoInsertRequest;
243 int mIMIPAutoFreeBusy; 246 int mIMIPAutoFreeBusy;
244 int mIMIPAutoFreeBusyReply; 247 int mIMIPAutoFreeBusyReply;
245 248
246 QStringList mTodoTemplates; 249 QStringList mTodoTemplates;
247 QStringList mEventTemplates; 250 QStringList mEventTemplates;
248 251
249 int mDestination; 252 int mDestination;
250 253
251 254
252 bool mEditOnDoubleClick; 255 bool mEditOnDoubleClick;
253 bool mViewChangeHoldFullscreen; 256 bool mViewChangeHoldFullscreen;
254 bool mViewChangeHoldNonFullscreen; 257 bool mViewChangeHoldNonFullscreen;
255 bool mCenterOnCurrentTime; 258 bool mCenterOnCurrentTime;
256 bool mSetTimeToDayStartAt; 259 bool mSetTimeToDayStartAt;
257 bool mHighlightCurrentDay; 260 bool mHighlightCurrentDay;
258 bool mUseHighlightLightColor; 261 bool mUseHighlightLightColor;
259 bool mListViewMonthTimespan; 262 bool mListViewMonthTimespan;
260 bool mWNViewShowsParents; 263 bool mWNViewShowsParents;
261 bool mWNViewShowLocation; 264 bool mWNViewShowLocation;
262 bool mTodoViewShowsPercentage; 265 bool mTodoViewShowsPercentage;
263 bool mTodoViewUsesCatColors; 266 bool mTodoViewUsesCatColors;
264 bool mTodoViewUsesSmallFont; 267 bool mTodoViewUsesSmallFont;
265 bool mTodoViewUsesForegroundColor; 268 bool mTodoViewUsesForegroundColor;
266 bool mMonthViewUsesForegroundColor; 269 bool mMonthViewUsesForegroundColor;
267 270
268 bool mHightlightDateTimeEdit; 271 bool mHightlightDateTimeEdit;
269 int mPreferredLanguage; 272 int mPreferredLanguage;
270 bool mUseQuicksave; 273 bool mUseQuicksave;
271 int mPreferredTime; 274 int mPreferredTime;
272 int mPreferredDate; 275 int mPreferredDate;
273 bool mWeekStartsOnSunday; 276 bool mWeekStartsOnSunday;
274 bool mShortDateInViewer; 277 bool mShortDateInViewer;
275 QString mUserDateFormatLong; 278 QString mUserDateFormatLong;
276 QString mUserDateFormatShort; 279 QString mUserDateFormatShort;
277 280
278 QStringList mLocationDefaults; 281 QStringList mLocationDefaults;
279 QStringList mEventSummaryUser; 282 QStringList mEventSummaryUser;
280 QStringList mTodoSummaryUser; 283 QStringList mTodoSummaryUser;
281 284
282 bool mUseInternalAlarmNotification; 285 bool mUseInternalAlarmNotification;
283 int mAlarmPlayBeeps; 286 int mAlarmPlayBeeps;
284 int mAlarmSuspendTime; 287 int mAlarmSuspendTime;
285 int mAlarmSuspendCount; 288 int mAlarmSuspendCount;
286 int mAlarmBeepInterval; 289 int mAlarmBeepInterval;
287 290
288 private: 291 private:
289 QDict<QColor> mCategoryColors; 292 QDict<QColor> mCategoryColors;
290 QColor mDefaultCategoryColor; 293 QColor mDefaultCategoryColor;
291 294
292 QFont mDefaultTimeBarFont; 295 QFont mDefaultTimeBarFont;
293 QFont mDefaultViewFont; 296 QFont mDefaultViewFont;
294 QFont mDefaultMonthViewFont; 297 QFont mDefaultMonthViewFont;
295 298
296 QString mName; 299 QString mName;
297 QString mEmail; 300 QString mEmail;
298}; 301};
299 302
300#endif 303#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index c3c4c26..062c95f 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2049 +1,2063 @@
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 <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qwmatrix.h> 14#include <qwmatrix.h>
15#include <qtextbrowser.h> 15#include <qtextbrowser.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION 17#ifndef DESKTOP_VERSION
18#include <qpe/global.h> 18#include <qpe/global.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h> 23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h> 24#include <qtopia/qcopenvelope_qws.h>
25#else 25#else
26#include <qmenubar.h> 26#include <qmenubar.h>
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qapplication.h> 28#include <qapplication.h>
29//#include <resource.h> 29//#include <resource.h>
30 30
31#endif 31#endif
32#include <libkcal/calendarlocal.h> 32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h> 33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h> 34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h> 35#include <libkdepim/kincidenceformatter.h>
36 36
37#include "calendarview.h" 37#include "calendarview.h"
38#include "koviewmanager.h" 38#include "koviewmanager.h"
39#include "datenavigator.h" 39#include "datenavigator.h"
40#include "koagendaview.h" 40#include "koagendaview.h"
41#include "koagenda.h" 41#include "koagenda.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kdialogbase.h" 43#include "kdialogbase.h"
44#include "kapplication.h" 44#include "kapplication.h"
45#include "kofilterview.h" 45#include "kofilterview.h"
46#include "kstandarddirs.h" 46#include "kstandarddirs.h"
47#include "koprefs.h" 47#include "koprefs.h"
48#include "kfiledialog.h" 48#include "kfiledialog.h"
49#include "koglobals.h" 49#include "koglobals.h"
50#include "kglobal.h" 50#include "kglobal.h"
51#include "klocale.h" 51#include "klocale.h"
52#include "kconfig.h" 52#include "kconfig.h"
53#include "simplealarmclient.h" 53#include "simplealarmclient.h"
54using namespace KCal; 54using namespace KCal;
55#ifndef _WIN32_ 55#ifndef _WIN32_
56#include <unistd.h> 56#include <unistd.h>
57#else 57#else
58#include "koimportoldialog.h" 58#include "koimportoldialog.h"
59#endif 59#endif
60#include "mainwindow.h" 60#include "mainwindow.h"
61 61
62int globalFlagBlockStartup; 62int globalFlagBlockStartup;
63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
64 QMainWindow( parent, name ) 64 QMainWindow( parent, name )
65{ 65{
66 66
67#ifdef DESKTOP_VERSION 67#ifdef DESKTOP_VERSION
68 setFont( QFont("Arial"), 14 ); 68 setFont( QFont("Arial"), 14 );
69#endif 69#endif
70 70
71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
72 QString confFile = locateLocal("config","korganizerrc"); 72 QString confFile = locateLocal("config","korganizerrc");
73 QFileInfo finf ( confFile ); 73 QFileInfo finf ( confFile );
74 bool showWarning = !finf.exists(); 74 bool showWarning = !finf.exists();
75 setIcon(SmallIcon( "ko24" ) ); 75 setIcon(SmallIcon( "ko24" ) );
76 mBlockAtStartup = true; 76 mBlockAtStartup = true;
77 mFlagKeyPressed = false; 77 mFlagKeyPressed = false;
78 setCaption("KOrganizer/Pi"); 78 setCaption("KOrganizer/Pi");
79 KOPrefs *p = KOPrefs::instance(); 79 KOPrefs *p = KOPrefs::instance();
80 // if ( QApplication::desktop()->height() > 480 ) { 80 // if ( QApplication::desktop()->height() > 480 ) {
81// if ( p->mHourSize == 4 ) 81// if ( p->mHourSize == 4 )
82// p->mHourSize = 6; 82// p->mHourSize = 6;
83// } 83// }
84 if ( p->mHourSize > 18 ) 84 if ( p->mHourSize > 18 )
85 p->mHourSize = 18; 85 p->mHourSize = 18;
86 QMainWindow::ToolBarDock tbd; 86 QMainWindow::ToolBarDock tbd;
87 if ( p->mToolBarHor ) { 87 if ( p->mToolBarHor ) {
88 if ( p->mToolBarUp ) 88 if ( p->mToolBarUp )
89 tbd = Bottom; 89 tbd = Bottom;
90 else 90 else
91 tbd = Top; 91 tbd = Top;
92 } 92 }
93 else { 93 else {
94 if ( p->mToolBarUp ) 94 if ( p->mToolBarUp )
95 tbd = Right; 95 tbd = Right;
96 else 96 else
97 tbd = Left; 97 tbd = Left;
98 } 98 }
99 if ( KOPrefs::instance()->mUseAppColors ) 99 if ( KOPrefs::instance()->mUseAppColors )
100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
101 globalFlagBlockStartup = 1; 101 globalFlagBlockStartup = 1;
102 iconToolBar = new QPEToolBar( this ); 102 iconToolBar = new QPEToolBar( this );
103 addToolBar (iconToolBar , tbd ); 103 addToolBar (iconToolBar , tbd );
104 mBlockSaveFlag = false; 104 mBlockSaveFlag = false;
105 mCalendarModifiedFlag = false; 105 mCalendarModifiedFlag = false;
106 106
107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
108 splash->setAlignment ( AlignCenter ); 108 splash->setAlignment ( AlignCenter );
109 setCentralWidget( splash ); 109 setCentralWidget( splash );
110#ifndef DESKTOP_VERSION 110#ifndef DESKTOP_VERSION
111 showMaximized(); 111 showMaximized();
112#endif 112#endif
113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
114 setDefaultPreferences(); 114 setDefaultPreferences();
115 mCalendar = new CalendarLocal(); 115 mCalendar = new CalendarLocal();
116 mView = new CalendarView( mCalendar, this,"mCalendar " ); 116 mView = new CalendarView( mCalendar, this,"mCalendar " );
117 mView->hide(); 117 mView->hide();
118 //mView->resize(splash->size() ); 118 //mView->resize(splash->size() );
119 initActions(); 119 initActions();
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 iconToolBar->show(); 121 iconToolBar->show();
122 qApp->processEvents(); 122 qApp->processEvents();
123#endif 123#endif
124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
125 int vh = height() ; 125 int vh = height() ;
126 int vw = width(); 126 int vw = width();
127 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 127 //qDebug("Toolbar hei %d ",iconToolBar->height() );
128 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 128 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
129 vh -= iconToolBar->height(); 129 vh -= iconToolBar->height();
130 } else { 130 } else {
131 vw -= iconToolBar->height(); 131 vw -= iconToolBar->height();
132 } 132 }
133 //mView->setMaximumSize( splash->size() ); 133 //mView->setMaximumSize( splash->size() );
134 //mView->resize( splash->size() ); 134 //mView->resize( splash->size() );
135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
136 mView->readSettings(); 136 mView->readSettings();
137 bool oldOpened = false; 137 bool oldOpened = false;
138 bool newFile = false; 138 bool newFile = false;
139 if( !QFile::exists( defaultFileName() ) ) { 139 if( !QFile::exists( defaultFileName() ) ) {
140 QFileInfo finfo ( defaultFileName() ); 140 QFileInfo finfo ( defaultFileName() );
141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
142 qDebug("oldfile %s ", oldFile.latin1()); 142 qDebug("oldfile %s ", oldFile.latin1());
143 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"; 143 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";
144 finfo.setFile( oldFile ); 144 finfo.setFile( oldFile );
145 if (finfo.exists() ) { 145 if (finfo.exists() ) {
146 KMessageBox::information( this, message); 146 KMessageBox::information( this, message);
147 mView->openCalendar( oldFile ); 147 mView->openCalendar( oldFile );
148 qApp->processEvents(); 148 qApp->processEvents();
149 } else { 149 } else {
150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
151 finfo.setFile( oldFile ); 151 finfo.setFile( oldFile );
152 if (finfo.exists() ) { 152 if (finfo.exists() ) {
153 KMessageBox::information( this, message); 153 KMessageBox::information( this, message);
154 mView->openCalendar( oldFile ); 154 mView->openCalendar( oldFile );
155 qApp->processEvents(); 155 qApp->processEvents();
156 } 156 }
157 } 157 }
158 mView->saveCalendar( defaultFileName() ); 158 mView->saveCalendar( defaultFileName() );
159 newFile = true; 159 newFile = true;
160 } 160 }
161 161
162 QTime neededSaveTime = QDateTime::currentDateTime().time(); 162 QTime neededSaveTime = QDateTime::currentDateTime().time();
163 if ( ! oldOpened ) 163 if ( ! oldOpened )
164 mView->openCalendar( defaultFileName() ); 164 mView->openCalendar( defaultFileName() );
165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
166 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 166 qDebug("KO: Calendar loading time: %d ms",msNeeded );
167 167
168 if ( KOPrefs::instance()->mLanguageChanged ) { 168 if ( KOPrefs::instance()->mLanguageChanged ) {
169 KOPrefs::instance()->setCategoryDefaults(); 169 KOPrefs::instance()->setCategoryDefaults();
170 int count = mView->addCategories(); 170 int count = mView->addCategories();
171 KOPrefs::instance()->mLanguageChanged = false; 171 KOPrefs::instance()->mLanguageChanged = false;
172 } 172 }
173 processIncidenceSelection( 0 ); 173 processIncidenceSelection( 0 );
174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
175 SLOT( processIncidenceSelection( Incidence * ) ) ); 175 SLOT( processIncidenceSelection( Incidence * ) ) );
176 connect( mView, SIGNAL( modifiedChanged( bool ) ), 176 connect( mView, SIGNAL( modifiedChanged( bool ) ),
177 SLOT( slotModifiedChanged( bool ) ) ); 177 SLOT( slotModifiedChanged( bool ) ) );
178 178
179 179
180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
181 mView->setModified( false ); 181 mView->setModified( false );
182 mBlockAtStartup = false; 182 mBlockAtStartup = false;
183 mView->setModified( false ); 183 mView->setModified( false );
184 setCentralWidget( mView ); 184 setCentralWidget( mView );
185 globalFlagBlockStartup = 0; 185 globalFlagBlockStartup = 0;
186 mView->show(); 186 mView->show();
187 delete splash; 187 delete splash;
188 if ( newFile ) 188 if ( newFile )
189 mView->updateConfig(); 189 mView->updateConfig();
190 // qApp->processEvents(); 190 // qApp->processEvents();
191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
192 fillSyncMenu(); 192 fillSyncMenu();
193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
194 if ( showWarning ) { 194 if ( showWarning ) {
195 KMessageBox::information( this, 195 KMessageBox::information( this,
196 "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"); 196 "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");
197 qApp->processEvents(); 197 qApp->processEvents();
198 mView->dialogManager()->showSyncOptions(); 198 mView->dialogManager()->showSyncOptions();
199 } 199 }
200} 200}
201MainWindow::~MainWindow() 201MainWindow::~MainWindow()
202{ 202{
203 //qDebug("MainWindow::~MainWindow() "); 203 //qDebug("MainWindow::~MainWindow() ");
204 //save toolbar location 204 //save toolbar location
205 205
206 delete mCalendar; 206 delete mCalendar;
207 delete KOPrefs::instance(); 207 delete KOPrefs::instance();
208 delete KIncidenceFormatter::instance(); 208 delete KIncidenceFormatter::instance();
209 209
210 210
211} 211}
212void MainWindow::closeEvent( QCloseEvent* ce ) 212void MainWindow::closeEvent( QCloseEvent* ce )
213{ 213{
214 214
215 215
216 216
217 if ( ! KOPrefs::instance()->mAskForQuit ) { 217 if ( ! KOPrefs::instance()->mAskForQuit ) {
218 saveOnClose(); 218 saveOnClose();
219 ce->accept(); 219 ce->accept();
220 return; 220 return;
221 221
222 } 222 }
223 223
224 switch( QMessageBox::information( this, "KO/Pi", 224 switch( QMessageBox::information( this, "KO/Pi",
225 i18n("Do you really want\nto close KO/Pi?"), 225 i18n("Do you really want\nto close KO/Pi?"),
226 i18n("Close"), i18n("No"), 226 i18n("Close"), i18n("No"),
227 0, 0 ) ) { 227 0, 0 ) ) {
228 case 0: 228 case 0:
229 saveOnClose(); 229 saveOnClose();
230 ce->accept(); 230 ce->accept();
231 break; 231 break;
232 case 1: 232 case 1:
233 ce->ignore(); 233 ce->ignore();
234 break; 234 break;
235 case 2: 235 case 2:
236 236
237 default: 237 default:
238 break; 238 break;
239 } 239 }
240 240
241 241
242} 242}
243 243
244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
245{ 245{
246 QDataStream stream( data, IO_ReadOnly ); 246 QDataStream stream( data, IO_ReadOnly );
247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
248 //QString datamess; 248 //QString datamess;
249 //qDebug("message "); 249 //qDebug("message ");
250 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 250 qDebug("KO: QCOP message received: %s ", cmsg.data() );
251 if ( cmsg == "-writeFile" ) { 251 if ( cmsg == "-writeFile" ) {
252 // I made from the "-writeFile" an "-writeAlarm" 252 // I made from the "-writeFile" an "-writeAlarm"
253 mView->viewManager()->showWhatsNextView(); 253 mView->viewManager()->showWhatsNextView();
254 mCalendar->checkAlarmForIncidence( 0, true); 254 mCalendar->checkAlarmForIncidence( 0, true);
255 showMaximized(); 255 showMaximized();
256 raise(); 256 raise();
257 return; 257 return;
258 258
259 } 259 }
260 if ( cmsg == "-writeFileSilent" ) { 260 if ( cmsg == "-writeFileSilent" ) {
261 // I made from the "-writeFile" an "-writeAlarm" 261 // I made from the "-writeFile" an "-writeAlarm"
262 // mView->viewManager()->showWhatsNextView(); 262 // mView->viewManager()->showWhatsNextView();
263 mCalendar->checkAlarmForIncidence( 0, true); 263 mCalendar->checkAlarmForIncidence( 0, true);
264 //showMaximized(); 264 //showMaximized();
265 //raise(); 265 //raise();
266 hide(); 266 hide();
267 return; 267 return;
268 } 268 }
269 if ( cmsg == "-newCountdown" ) { 269 if ( cmsg == "-newCountdown" ) {
270 qDebug("newCountdown "); 270 qDebug("newCountdown ");
271 271
272 } 272 }
273 QString msg ; 273 QString msg ;
274 QString allmsg = cmsg; 274 QString allmsg = cmsg;
275 while ( allmsg.length() > 0 ) { 275 while ( allmsg.length() > 0 ) {
276 int nextC = allmsg.find( "-", 1 ); 276 int nextC = allmsg.find( "-", 1 );
277 if ( nextC == -1 ) { 277 if ( nextC == -1 ) {
278 msg = allmsg; 278 msg = allmsg;
279 allmsg = ""; 279 allmsg = "";
280 } else{ 280 } else{
281 msg = allmsg.left( nextC ); 281 msg = allmsg.left( nextC );
282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
283 } 283 }
284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
285 if ( msg == "-newEvent" ) { 285 if ( msg == "-newEvent" ) {
286 mView->newEvent(); 286 mView->newEvent();
287 } 287 }
288 if ( msg == "-newTodo" ) { 288 if ( msg == "-newTodo" ) {
289 mView->newTodo(); 289 mView->newTodo();
290 290
291 } 291 }
292 if ( msg == "-showWN" ) { 292 if ( msg == "-showWN" ) {
293 mView->viewManager()->showWhatsNextView(); 293 mView->viewManager()->showWhatsNextView();
294 } 294 }
295 if ( msg == "-showTodo" ) { 295 if ( msg == "-showTodo" ) {
296 mView->viewManager()->showTodoView(); 296 mView->viewManager()->showTodoView();
297 } 297 }
298 if ( msg == "-showList" ) { 298 if ( msg == "-showList" ) {
299 mView->viewManager()->showListView(); 299 mView->viewManager()->showListView();
300 } 300 }
301 else if ( msg == "-showDay" ) { 301 else if ( msg == "-showDay" ) {
302 mView->viewManager()->showDayView(); 302 mView->viewManager()->showDayView();
303 } 303 }
304 else if ( msg == "-showWWeek" ) { 304 else if ( msg == "-showWWeek" ) {
305 mView->viewManager()->showWorkWeekView(); 305 mView->viewManager()->showWorkWeekView();
306 } 306 }
307 else if ( msg == "-ringSync" ) { 307 else if ( msg == "-ringSync" ) {
308 multiSync( false ); 308 multiSync( false );
309 } 309 }
310 else if ( msg == "-showWeek" ) { 310 else if ( msg == "-showWeek" ) {
311 mView->viewManager()->showWeekView(); 311 mView->viewManager()->showWeekView();
312 } 312 }
313 else if ( msg == "-showTodo" ) { 313 else if ( msg == "-showTodo" ) {
314 mView->viewManager()->showTodoView(); 314 mView->viewManager()->showTodoView();
315 } 315 }
316 else if ( msg == "-showJournal" ) { 316 else if ( msg == "-showJournal" ) {
317 mView->dateNavigator()->selectDates( 1 ); 317 mView->dateNavigator()->selectDates( 1 );
318 mView->dateNavigator()->selectToday(); 318 mView->dateNavigator()->selectToday();
319 mView->viewManager()->showJournalView(); 319 mView->viewManager()->showJournalView();
320 } 320 }
321 else if ( msg == "-showKO" ) { 321 else if ( msg == "-showKO" ) {
322 mView->viewManager()->showNextXView(); 322 mView->viewManager()->showNextXView();
323 } 323 }
324 else if ( msg == "-showWNext" || msg == "nextView()" ) { 324 else if ( msg == "-showWNext" || msg == "nextView()" ) {
325 mView->viewManager()->showWhatsNextView(); 325 mView->viewManager()->showWhatsNextView();
326 } 326 }
327 else if ( msg == "-showNextXView" ) { 327 else if ( msg == "-showNextXView" ) {
328 mView->viewManager()->showNextXView(); 328 mView->viewManager()->showNextXView();
329 } 329 }
330 330
331 331
332 } 332 }
333 333
334 showMaximized(); 334 showMaximized();
335 raise(); 335 raise();
336} 336}
337 337
338QPixmap MainWindow::loadPixmap( QString name ) 338QPixmap MainWindow::loadPixmap( QString name )
339{ 339{
340 return SmallIcon( name ); 340 return SmallIcon( name );
341 341
342} 342}
343void MainWindow::initActions() 343void MainWindow::initActions()
344{ 344{
345 //KOPrefs::instance()->mShowFullMenu 345 //KOPrefs::instance()->mShowFullMenu
346 iconToolBar->clear(); 346 iconToolBar->clear();
347 KOPrefs *p = KOPrefs::instance(); 347 KOPrefs *p = KOPrefs::instance();
348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
349 349
350 QPopupMenu *viewMenu = new QPopupMenu( this ); 350 QPopupMenu *viewMenu = new QPopupMenu( this );
351 QPopupMenu *actionMenu = new QPopupMenu( this ); 351 QPopupMenu *actionMenu = new QPopupMenu( this );
352 QPopupMenu *importMenu = new QPopupMenu( this ); 352 QPopupMenu *importMenu = new QPopupMenu( this );
353 selectFilterMenu = new QPopupMenu( this ); 353 selectFilterMenu = new QPopupMenu( this );
354 selectFilterMenu->setCheckable( true ); 354 selectFilterMenu->setCheckable( true );
355 syncMenu = new QPopupMenu( this ); 355 syncMenu = new QPopupMenu( this );
356 configureAgendaMenu = new QPopupMenu( this ); 356 configureAgendaMenu = new QPopupMenu( this );
357 configureToolBarMenu = new QPopupMenu( this ); 357 configureToolBarMenu = new QPopupMenu( this );
358 QPopupMenu *helpMenu = new QPopupMenu( this ); 358 QPopupMenu *helpMenu = new QPopupMenu( this );
359 if ( KOPrefs::instance()->mShowFullMenu ) { 359 if ( KOPrefs::instance()->mShowFullMenu ) {
360 QMenuBar *menuBar1; 360 QMenuBar *menuBar1;
361 menuBar1 = menuBar(); 361 menuBar1 = menuBar();
362 menuBar1->insertItem( i18n("File"), importMenu ); 362 menuBar1->insertItem( i18n("File"), importMenu );
363 menuBar1->insertItem( i18n("View"), viewMenu ); 363 menuBar1->insertItem( i18n("View"), viewMenu );
364 menuBar1->insertItem( i18n("Actions"), actionMenu ); 364 menuBar1->insertItem( i18n("Actions"), actionMenu );
365 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 365 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
369 menuBar1->insertItem( i18n("Help"), helpMenu ); 369 menuBar1->insertItem( i18n("Help"), helpMenu );
370 } else { 370 } else {
371 QPEMenuBar *menuBar1; 371 QPEMenuBar *menuBar1;
372 menuBar1 = new QPEMenuBar( iconToolBar ); 372 menuBar1 = new QPEMenuBar( iconToolBar );
373 QPopupMenu *menuBar = new QPopupMenu( this ); 373 QPopupMenu *menuBar = new QPopupMenu( this );
374 menuBar1->insertItem( i18n("ME"), menuBar); 374 menuBar1->insertItem( i18n("ME"), menuBar);
375 menuBar->insertItem( i18n("File"), importMenu ); 375 menuBar->insertItem( i18n("File"), importMenu );
376 menuBar->insertItem( i18n("View"), viewMenu ); 376 menuBar->insertItem( i18n("View"), viewMenu );
377 menuBar->insertItem( i18n("Actions"), actionMenu ); 377 menuBar->insertItem( i18n("Actions"), actionMenu );
378 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 378 menuBar->insertItem( i18n("Synchronize"), syncMenu );
379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
381 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 381 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
382 menuBar->insertItem( i18n("Help"), helpMenu ); 382 menuBar->insertItem( i18n("Help"), helpMenu );
383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
384 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 384 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
385 } 385 }
386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
389 389
390 // ****************** 390 // ******************
391 QAction *action; 391 QAction *action;
392 QIconSet icon; 392 QIconSet icon;
393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
394 configureToolBarMenu->setCheckable( true ); 394 configureToolBarMenu->setCheckable( true );
395 395
396 QString pathString = ""; 396 QString pathString = "";
397 if ( !p->mToolBarMiniIcons ) { 397 if ( !p->mToolBarMiniIcons ) {
398 if ( QApplication::desktop()->width() < 480 ) 398 if ( QApplication::desktop()->width() < 480 )
399 pathString += "icons16/"; 399 pathString += "icons16/";
400 } else 400 } else
401 pathString += "iconsmini/"; 401 pathString += "iconsmini/";
402 configureAgendaMenu->setCheckable( true ); 402 configureAgendaMenu->setCheckable( true );
403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
404 configureAgendaMenu->insertSeparator(); 404 configureAgendaMenu->insertSeparator();
405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
406 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 406 configureAgendaMenu->insertItem(i18n("Small"), 6 );
407 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 407 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
408 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 408 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
409 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 409 configureAgendaMenu->insertItem(i18n("Large"), 12 );
410 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 410 configureAgendaMenu->insertItem(i18n("Big"), 14 );
411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
414 414
415 icon = loadPixmap( pathString + "configure" ); 415 icon = loadPixmap( pathString + "configure" );
416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
417 action->addTo( actionMenu ); 417 action->addTo( actionMenu );
418 connect( action, SIGNAL( activated() ), 418 connect( action, SIGNAL( activated() ),
419 mView, SLOT( edit_options() ) ); 419 mView, SLOT( edit_options() ) );
420 actionMenu->insertSeparator(); 420 actionMenu->insertSeparator();
421 icon = loadPixmap( pathString + "newevent" ); 421 icon = loadPixmap( pathString + "newevent" );
422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
423 configureToolBarMenu->insertSeparator(); 423 configureToolBarMenu->insertSeparator();
424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
426 ne_action->addTo( actionMenu ); 426 ne_action->addTo( actionMenu );
427 connect( ne_action, SIGNAL( activated() ), 427 connect( ne_action, SIGNAL( activated() ),
428 mView, SLOT( newEvent() ) ); 428 mView, SLOT( newEvent() ) );
429 icon = loadPixmap( pathString + "newtodo" ); 429 icon = loadPixmap( pathString + "newtodo" );
430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
432 nt_action->addTo( actionMenu ); 432 nt_action->addTo( actionMenu );
433 connect( nt_action, SIGNAL( activated() ), 433 connect( nt_action, SIGNAL( activated() ),
434 mView, SLOT( newTodo() ) ); 434 mView, SLOT( newTodo() ) );
435 icon = loadPixmap( pathString + "navi" ); 435 icon = loadPixmap( pathString + "navi" );
436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
437 action->addTo( viewMenu ); 437 action->addTo( viewMenu );
438 connect( action, SIGNAL( activated() ), 438 connect( action, SIGNAL( activated() ),
439 mView, SLOT( toggleDateNavigatorWidget() ) ); 439 mView, SLOT( toggleDateNavigatorWidget() ) );
440 icon = loadPixmap( pathString + "filter" ); 440 icon = loadPixmap( pathString + "filter" );
441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( toggleFilter() ) ); 444 mView, SLOT( toggleFilter() ) );
445 445
446 446
447 viewMenu->insertSeparator(); 447 viewMenu->insertSeparator();
448 icon = loadPixmap( pathString + "picker" ); 448 icon = loadPixmap( pathString + "picker" );
449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
450 action->addTo( viewMenu ); 450 action->addTo( viewMenu );
451 connect( action, SIGNAL( activated() ), 451 connect( action, SIGNAL( activated() ),
452 mView, SLOT( showDatePicker() ) ); 452 mView, SLOT( showDatePicker() ) );
453 action->addTo( iconToolBar ); 453 action->addTo( iconToolBar );
454 viewMenu->insertSeparator(); 454 viewMenu->insertSeparator();
455 icon = loadPixmap( pathString + "list" ); 455 icon = loadPixmap( pathString + "list" );
456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
458 showlist_action->addTo( viewMenu ); 458 showlist_action->addTo( viewMenu );
459 connect( showlist_action, SIGNAL( activated() ), 459 connect( showlist_action, SIGNAL( activated() ),
460 mView->viewManager(), SLOT( showListView() ) ); 460 mView->viewManager(), SLOT( showListView() ) );
461 461
462 462
463 icon = loadPixmap( pathString + "day" ); 463 icon = loadPixmap( pathString + "day" );
464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
466 day1_action->addTo( viewMenu ); 466 day1_action->addTo( viewMenu );
467 // action->addTo( toolBar ); 467 // action->addTo( toolBar );
468 connect( day1_action, SIGNAL( activated() ), 468 connect( day1_action, SIGNAL( activated() ),
469 mView->viewManager(), SLOT( showDayView() ) ); 469 mView->viewManager(), SLOT( showDayView() ) );
470 470
471 icon = loadPixmap( pathString + "workweek" ); 471 icon = loadPixmap( pathString + "workweek" );
472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
474 day5_action->addTo( viewMenu ); 474 day5_action->addTo( viewMenu );
475 connect( day5_action, SIGNAL( activated() ), 475 connect( day5_action, SIGNAL( activated() ),
476 mView->viewManager(), SLOT( showWorkWeekView() ) ); 476 mView->viewManager(), SLOT( showWorkWeekView() ) );
477 477
478 icon = loadPixmap( pathString + "week" ); 478 icon = loadPixmap( pathString + "week" );
479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
481 day7_action->addTo( viewMenu ); 481 day7_action->addTo( viewMenu );
482 connect( day7_action, SIGNAL( activated() ), 482 connect( day7_action, SIGNAL( activated() ),
483 mView->viewManager(), SLOT( showWeekView() ) ); 483 mView->viewManager(), SLOT( showWeekView() ) );
484 484
485 icon = loadPixmap( pathString + "month" ); 485 icon = loadPixmap( pathString + "month" );
486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
488 month_action->addTo( viewMenu ); 488 month_action->addTo( viewMenu );
489 connect( month_action, SIGNAL( activated() ), 489 connect( month_action, SIGNAL( activated() ),
490 mView->viewManager(), SLOT( showMonthView() ) ); 490 mView->viewManager(), SLOT( showMonthView() ) );
491 491
492 icon = loadPixmap( pathString + "todo" ); 492 icon = loadPixmap( pathString + "todo" );
493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
495 todoview_action->addTo( viewMenu ); 495 todoview_action->addTo( viewMenu );
496 connect( todoview_action, SIGNAL( activated() ), 496 connect( todoview_action, SIGNAL( activated() ),
497 mView->viewManager(), SLOT( showTodoView() ) ); 497 mView->viewManager(), SLOT( showTodoView() ) );
498 498
499 icon = loadPixmap( pathString + "journal" ); 499 icon = loadPixmap( pathString + "journal" );
500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
502 viewjournal_action->addTo( viewMenu ); 502 viewjournal_action->addTo( viewMenu );
503 connect( viewjournal_action, SIGNAL( activated() ), 503 connect( viewjournal_action, SIGNAL( activated() ),
504 mView->viewManager(), SLOT( showJournalView() ) ); 504 mView->viewManager(), SLOT( showJournalView() ) );
505 505
506 icon = loadPixmap( pathString + "xdays" ); 506 icon = loadPixmap( pathString + "xdays" );
507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
509 xdays_action->addTo( viewMenu ); 509 xdays_action->addTo( viewMenu );
510 connect( xdays_action, SIGNAL( activated() ), 510 connect( xdays_action, SIGNAL( activated() ),
511 mView->viewManager(), SLOT( showNextXView() ) ); 511 mView->viewManager(), SLOT( showNextXView() ) );
512 512
513 icon = loadPixmap( pathString + "whatsnext" ); 513 icon = loadPixmap( pathString + "whatsnext" );
514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
516 whatsnext_action->addTo( viewMenu ); 516 whatsnext_action->addTo( viewMenu );
517 connect( whatsnext_action, SIGNAL( activated() ), 517 connect( whatsnext_action, SIGNAL( activated() ),
518 mView->viewManager(), SLOT( showWhatsNextView() ) ); 518 mView->viewManager(), SLOT( showWhatsNextView() ) );
519 519
520#if 0 520#if 0
521 action = new QAction( "view_timespan", "Time Span", 0, this ); 521 action = new QAction( "view_timespan", "Time Span", 0, this );
522 action->addTo( viewMenu ); 522 action->addTo( viewMenu );
523 connect( action, SIGNAL( activated() ), 523 connect( action, SIGNAL( activated() ),
524 mView->viewManager(), SLOT( showTimeSpanView() ) ); 524 mView->viewManager(), SLOT( showTimeSpanView() ) );
525#endif 525#endif
526 526
527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
528 this ); 528 this );
529 mNewSubTodoAction->addTo( actionMenu ); 529 mNewSubTodoAction->addTo( actionMenu );
530 connect( mNewSubTodoAction, SIGNAL( activated() ), 530 connect( mNewSubTodoAction, SIGNAL( activated() ),
531 mView, SLOT( newSubTodo() ) ); 531 mView, SLOT( newSubTodo() ) );
532 532
533 actionMenu->insertSeparator(); 533 actionMenu->insertSeparator();
534 534
535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
536 mShowAction->addTo( actionMenu ); 536 mShowAction->addTo( actionMenu );
537 connect( mShowAction, SIGNAL( activated() ), 537 connect( mShowAction, SIGNAL( activated() ),
538 mView, SLOT( showIncidence() ) ); 538 mView, SLOT( showIncidence() ) );
539 539
540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
541 mEditAction->addTo( actionMenu ); 541 mEditAction->addTo( actionMenu );
542 connect( mEditAction, SIGNAL( activated() ), 542 connect( mEditAction, SIGNAL( activated() ),
543 mView, SLOT( editIncidence() ) ); 543 mView, SLOT( editIncidence() ) );
544 544
545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
546 mDeleteAction->addTo( actionMenu ); 546 mDeleteAction->addTo( actionMenu );
547 connect( mDeleteAction, SIGNAL( activated() ), 547 connect( mDeleteAction, SIGNAL( activated() ),
548 mView, SLOT( deleteIncidence() ) ); 548 mView, SLOT( deleteIncidence() ) );
549 549
550 actionMenu->insertSeparator(); 550 actionMenu->insertSeparator();
551 551
552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
553 this ); 553 this );
554 action->addTo( actionMenu ); 554 action->addTo( actionMenu );
555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
556 556
557 icon = loadPixmap( pathString + "search" ); 557 icon = loadPixmap( pathString + "search" );
558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
560 search_action->addTo( actionMenu ); 560 search_action->addTo( actionMenu );
561 connect( search_action, SIGNAL( activated() ), 561 connect( search_action, SIGNAL( activated() ),
562 mView->dialogManager(), SLOT( showSearchDialog() ) ); 562 mView->dialogManager(), SLOT( showSearchDialog() ) );
563 563
564 icon = loadPixmap( pathString + "today" ); 564 icon = loadPixmap( pathString + "today" );
565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
567 today_action->addTo( actionMenu ); 567 today_action->addTo( actionMenu );
568 connect( today_action, SIGNAL( activated() ), 568 connect( today_action, SIGNAL( activated() ),
569 mView, SLOT( goToday() ) ); 569 mView, SLOT( goToday() ) );
570 570
571 if ( KOPrefs::instance()->mShowFullMenu ) { 571 if ( KOPrefs::instance()->mShowFullMenu ) {
572 actionMenu->insertSeparator(); 572 actionMenu->insertSeparator();
573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
574 574
575 } 575 }
576 // actionMenu->insertSeparator(); 576 // actionMenu->insertSeparator();
577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
578 this ); 578 this );
579 action->addTo( importMenu ); 579 action->addTo( importMenu );
580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
581 action = new QAction( "import_quick", i18n("Import last file"), 0, 581 action = new QAction( "import_quick", i18n("Import last file"), 0,
582 this ); 582 this );
583 action->addTo( importMenu ); 583 action->addTo( importMenu );
584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
585 importMenu->insertSeparator(); 585 importMenu->insertSeparator();
586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
587 this ); 587 this );
588 action->addTo( importMenu ); 588 action->addTo( importMenu );
589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
590#ifndef DESKTOP_VERSION 590#ifndef DESKTOP_VERSION
591 importMenu->insertSeparator(); 591 importMenu->insertSeparator();
592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
593 this ); 593 this );
594 action->addTo( importMenu ); 594 action->addTo( importMenu );
595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
596#else 596#else
597#ifdef _WIN32_ 597#ifdef _WIN32_
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "import_ol", i18n("Import from OL"), 0, 599 action = new QAction( "import_ol", i18n("Import from OL"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
603#endif 603#endif
604#endif 604#endif
605 605
606 importMenu->insertSeparator(); 606 importMenu->insertSeparator();
607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
608 this ); 608 this );
609 action->addTo( importMenu ); 609 action->addTo( importMenu );
610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
611 611
612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
613 this ); 613 this );
614 action->addTo( importMenu ); 614 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
616 616
617 importMenu->insertSeparator(); 617 importMenu->insertSeparator();
618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
619 this ); 619 this );
620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
621 importMenu->insertSeparator(); 621 importMenu->insertSeparator();
622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
623 this ); 623 this );
624 action->addTo( importMenu ); 624 action->addTo( importMenu );
625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
626#ifndef DESKTOP_VERSION 626#ifndef DESKTOP_VERSION
627 importMenu->insertSeparator(); 627 importMenu->insertSeparator();
628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
629 this ); 629 this );
630 action->addTo( importMenu ); 630 action->addTo( importMenu );
631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
632 632
633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
634 this ); 634 this );
635 action->addTo( importMenu ); 635 action->addTo( importMenu );
636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
637#else 637#else
638 importMenu->insertSeparator(); 638 importMenu->insertSeparator();
639 icon = loadPixmap( pathString + "print" ); 639 icon = loadPixmap( pathString + "print" );
640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
641 action->addTo( importMenu ); 641 action->addTo( importMenu );
642 connect( action, SIGNAL( activated() ), 642 connect( action, SIGNAL( activated() ),
643 this, SLOT( printCal() ) ); 643 this, SLOT( printCal() ) );
644 644
645 icon = loadPixmap( pathString + "print" ); 645 icon = loadPixmap( pathString + "print" );
646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
647 action->addTo( importMenu ); 647 action->addTo( importMenu );
648 connect( action, SIGNAL( activated() ), 648 connect( action, SIGNAL( activated() ),
649 this, SLOT( printSel() ) ); 649 this, SLOT( printSel() ) );
650#endif 650#endif
651 importMenu->insertSeparator(); 651 importMenu->insertSeparator();
652 action = new QAction( "beam all", i18n("Save"), 0, 652 action = new QAction( "beam all", i18n("Save"), 0,
653 this ); 653 this );
654 action->addTo( importMenu ); 654 action->addTo( importMenu );
655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
656 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 656 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
657 this ); 657 this );
658 action->addTo( importMenu ); 658 action->addTo( importMenu );
659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
660 660
661 //menuBar->insertItem( "Configure",configureMenu ); 661 //menuBar->insertItem( "Configure",configureMenu );
662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
663 icon = loadPixmap( "korganizer/korganizer" ); 663 icon = loadPixmap( "korganizer/korganizer" );
664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( keyBindings() ) ); 667 SLOT( keyBindings() ) );
668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( features() ) ); 671 SLOT( features() ) );
672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( aboutAutoSaving() ) ); 675 SLOT( aboutAutoSaving() ) );
676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( aboutKnownBugs() ) ); 679 SLOT( aboutKnownBugs() ) );
680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( usertrans() ) ); 683 SLOT( usertrans() ) );
684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( synchowto() ) ); 687 SLOT( synchowto() ) );
688 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 688 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
689 action->addTo( helpMenu ); 689 action->addTo( helpMenu );
690 connect( action, SIGNAL( activated() ), 690 connect( action, SIGNAL( activated() ),
691 SLOT( whatsNew() ) ); 691 SLOT( whatsNew() ) );
692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
693 action->addTo( helpMenu ); 693 action->addTo( helpMenu );
694 connect( action, SIGNAL( activated() ), 694 connect( action, SIGNAL( activated() ),
695 SLOT( faq() ) ); 695 SLOT( faq() ) );
696 696
697 697
698 action = new QAction( "about", i18n("About..."), 0, this ); 698 action = new QAction( "about", i18n("About..."), 0, this );
699 action->addTo( helpMenu ); 699 action->addTo( helpMenu );
700 connect( action, SIGNAL( activated() ), 700 connect( action, SIGNAL( activated() ),
701 SLOT( about() ) ); 701 SLOT( about() ) );
702 action = new QAction( "licence", i18n("Licence..."), 0, this ); 702 action = new QAction( "licence", i18n("Licence..."), 0, this );
703 action->addTo( helpMenu ); 703 action->addTo( helpMenu );
704 connect( action, SIGNAL( activated() ), 704 connect( action, SIGNAL( activated() ),
705 SLOT( licence() ) ); 705 SLOT( licence() ) );
706 //menuBar->insertSeparator(); 706 //menuBar->insertSeparator();
707 707
708 // ****************************************************** 708 // ******************************************************
709 // menubar icons 709 // menubar icons
710 710
711 711
712 iconToolBar->setHorizontalStretchable (true ); 712 iconToolBar->setHorizontalStretchable (true );
713 //menuBar->insertItem( iconToolBar ); 713 //menuBar->insertItem( iconToolBar );
714 //xdays_action 714 //xdays_action
715 if (p-> mShowIconNewEvent) 715 if (p-> mShowIconNewEvent)
716 ne_action->addTo( iconToolBar ); 716 ne_action->addTo( iconToolBar );
717 if (p->mShowIconNewTodo ) 717 if (p->mShowIconNewTodo )
718 nt_action->addTo( iconToolBar ); 718 nt_action->addTo( iconToolBar );
719 if (p-> mShowIconSearch) 719 if (p-> mShowIconSearch)
720 search_action->addTo( iconToolBar ); 720 search_action->addTo( iconToolBar );
721 if (p-> mShowIconNext) 721 if (p-> mShowIconNext)
722 whatsnext_action->addTo( iconToolBar ); 722 whatsnext_action->addTo( iconToolBar );
723 if (p-> mShowIconNextDays) 723 if (p-> mShowIconNextDays)
724 xdays_action->addTo( iconToolBar ); 724 xdays_action->addTo( iconToolBar );
725 if (p-> mShowIconList) 725 if (p-> mShowIconList)
726 showlist_action->addTo( iconToolBar ); 726 showlist_action->addTo( iconToolBar );
727 if (p-> mShowIconDay1) 727 if (p-> mShowIconDay1)
728 day1_action->addTo( iconToolBar ); 728 day1_action->addTo( iconToolBar );
729 if (p-> mShowIconDay5) 729 if (p-> mShowIconDay5)
730 day5_action->addTo( iconToolBar ); 730 day5_action->addTo( iconToolBar );
731 if (p-> mShowIconDay7) 731 if (p-> mShowIconDay7)
732 day7_action->addTo( iconToolBar ); 732 day7_action->addTo( iconToolBar );
733 if (p-> mShowIconMonth) 733 if (p-> mShowIconMonth)
734 month_action->addTo( iconToolBar ); 734 month_action->addTo( iconToolBar );
735 if (p-> mShowIconTodoview) 735 if (p-> mShowIconTodoview)
736 todoview_action->addTo( iconToolBar ); 736 todoview_action->addTo( iconToolBar );
737 if (p-> mShowIconJournal) 737 if (p-> mShowIconJournal)
738 viewjournal_action->addTo( iconToolBar ); 738 viewjournal_action->addTo( iconToolBar );
739 icon = loadPixmap( pathString + "2leftarrowB" ); 739 icon = loadPixmap( pathString + "2leftarrowB" );
740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
741 if (p-> mShowIconBackFast) { 741 if (p-> mShowIconBackFast) {
742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
743 connect( action, SIGNAL( activated() ), 743 connect( action, SIGNAL( activated() ),
744 mView, SLOT( goPreviousMonth() ) ); 744 mView, SLOT( goPreviousMonth() ) );
745 action->addTo( iconToolBar ); 745 action->addTo( iconToolBar );
746 } 746 }
747 icon = loadPixmap( pathString + "1leftarrowB" ); 747 icon = loadPixmap( pathString + "1leftarrowB" );
748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
749 if (p-> mShowIconBack) { 749 if (p-> mShowIconBack) {
750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
751 connect( action, SIGNAL( activated() ), 751 connect( action, SIGNAL( activated() ),
752 mView, SLOT( goPrevious() ) ); 752 mView, SLOT( goPrevious() ) );
753 action->addTo( iconToolBar ); 753 action->addTo( iconToolBar );
754 } 754 }
755 if (p-> mShowIconToday) 755 if (p-> mShowIconToday)
756 today_action->addTo( iconToolBar ); 756 today_action->addTo( iconToolBar );
757 icon = loadPixmap( pathString + "1rightarrowB" ); 757 icon = loadPixmap( pathString + "1rightarrowB" );
758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
759 if (p-> mShowIconForward) { 759 if (p-> mShowIconForward) {
760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
761 connect( action, SIGNAL( activated() ), 761 connect( action, SIGNAL( activated() ),
762 mView, SLOT( goNext() ) ); 762 mView, SLOT( goNext() ) );
763 action->addTo( iconToolBar ); 763 action->addTo( iconToolBar );
764 } 764 }
765 icon = loadPixmap( pathString + "2rightarrowB" ); 765 icon = loadPixmap( pathString + "2rightarrowB" );
766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
767 if (p-> mShowIconForwardFast) { 767 if (p-> mShowIconForwardFast) {
768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
769 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
770 mView, SLOT( goNextMonth() ) ); 770 mView, SLOT( goNextMonth() ) );
771 action->addTo( iconToolBar ); 771 action->addTo( iconToolBar );
772 } 772 }
773 773
774 774
775 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 775 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
776 776
777 if (p-> mShowIconNewEvent) 777 if (p-> mShowIconNewEvent)
778 configureToolBarMenu->setItemChecked( 10, true ); 778 configureToolBarMenu->setItemChecked( 10, true );
779 if (p->mShowIconNewTodo ) 779 if (p->mShowIconNewTodo )
780 configureToolBarMenu->setItemChecked( 20, true ); 780 configureToolBarMenu->setItemChecked( 20, true );
781 if (p-> mShowIconSearch) 781 if (p-> mShowIconSearch)
782 configureToolBarMenu->setItemChecked( 120, true ); 782 configureToolBarMenu->setItemChecked( 120, true );
783 if (p-> mShowIconList) 783 if (p-> mShowIconList)
784 configureToolBarMenu->setItemChecked( 30, true ); 784 configureToolBarMenu->setItemChecked( 30, true );
785 if (p-> mShowIconDay1) 785 if (p-> mShowIconDay1)
786 configureToolBarMenu->setItemChecked( 40, true ); 786 configureToolBarMenu->setItemChecked( 40, true );
787 if (p-> mShowIconDay5) 787 if (p-> mShowIconDay5)
788 configureToolBarMenu->setItemChecked( 50, true ); 788 configureToolBarMenu->setItemChecked( 50, true );
789 if (p-> mShowIconDay7) 789 if (p-> mShowIconDay7)
790 configureToolBarMenu->setItemChecked( 60, true ); 790 configureToolBarMenu->setItemChecked( 60, true );
791 if (p-> mShowIconMonth) 791 if (p-> mShowIconMonth)
792 configureToolBarMenu->setItemChecked( 70, true ); 792 configureToolBarMenu->setItemChecked( 70, true );
793 if (p-> mShowIconTodoview) 793 if (p-> mShowIconTodoview)
794 configureToolBarMenu->setItemChecked( 80, true ); 794 configureToolBarMenu->setItemChecked( 80, true );
795 if (p-> mShowIconBackFast) 795 if (p-> mShowIconBackFast)
796 configureToolBarMenu->setItemChecked( 200, true ); 796 configureToolBarMenu->setItemChecked( 200, true );
797 if (p-> mShowIconBack) 797 if (p-> mShowIconBack)
798 configureToolBarMenu->setItemChecked( 210, true ); 798 configureToolBarMenu->setItemChecked( 210, true );
799 if (p-> mShowIconToday) 799 if (p-> mShowIconToday)
800 configureToolBarMenu->setItemChecked( 130, true ); 800 configureToolBarMenu->setItemChecked( 130, true );
801 if (p-> mShowIconForward) 801 if (p-> mShowIconForward)
802 configureToolBarMenu->setItemChecked( 220, true ); 802 configureToolBarMenu->setItemChecked( 220, true );
803 if (p-> mShowIconForwardFast) 803 if (p-> mShowIconForwardFast)
804 configureToolBarMenu->setItemChecked( 230, true ); 804 configureToolBarMenu->setItemChecked( 230, true );
805 if (p-> mShowIconNextDays) 805 if (p-> mShowIconNextDays)
806 configureToolBarMenu->setItemChecked( 100, true ); 806 configureToolBarMenu->setItemChecked( 100, true );
807 if (p-> mShowIconNext) 807 if (p-> mShowIconNext)
808 configureToolBarMenu->setItemChecked( 110, true ); 808 configureToolBarMenu->setItemChecked( 110, true );
809 if (p-> mShowIconJournal) 809 if (p-> mShowIconJournal)
810 configureToolBarMenu->setItemChecked( 90, true ); 810 configureToolBarMenu->setItemChecked( 90, true );
811 if (p-> mShowIconWhatsThis) 811 if (p-> mShowIconWhatsThis)
812 configureToolBarMenu->setItemChecked( 300, true ); 812 configureToolBarMenu->setItemChecked( 300, true );
813 813
814 QLabel* dummy = new QLabel( iconToolBar ); 814 QLabel* dummy = new QLabel( iconToolBar );
815 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 815 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
816 if (!p-> mShowIconStretch) 816 if (!p-> mShowIconStretch)
817 iconToolBar->setStretchableWidget ( dummy ) ; 817 iconToolBar->setStretchableWidget ( dummy ) ;
818 else 818 else
819 configureToolBarMenu->setItemChecked( 5, true ); 819 configureToolBarMenu->setItemChecked( 5, true );
820 if (p-> mShowIconWhatsThis) 820 if (p-> mShowIconWhatsThis)
821 QWhatsThis::whatsThisButton ( iconToolBar ); 821 QWhatsThis::whatsThisButton ( iconToolBar );
822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
823 configureAgenda( p->mHourSize ); 823 configureAgenda( p->mHourSize );
824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
825} 825}
826void MainWindow::fillSyncMenu() 826void MainWindow::fillSyncMenu()
827{ 827{
828 syncMenu->clear(); 828 syncMenu->clear();
829 syncMenu->insertItem( i18n("Configure..."), 0 ); 829 syncMenu->insertItem( i18n("Configure..."), 0 );
830 syncMenu->insertSeparator(); 830 syncMenu->insertSeparator();
831 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 831 syncMenu->insertItem( i18n("Multiple sync"), 1 );
832 syncMenu->insertSeparator(); 832 syncMenu->insertSeparator();
833 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 833 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
834 config.setGroup("General"); 834 config.setGroup("General");
835 QStringList prof = config.readListEntry("SyncProfileNames"); 835 QStringList prof = config.readListEntry("SyncProfileNames");
836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
837 if ( prof.count() < 3 ) { 837 if ( prof.count() < 3 ) {
838 prof.clear(); 838 prof.clear();
839 prof << i18n("Sharp_DTM"); 839 prof << i18n("Sharp_DTM");
840 prof << i18n("Local_file"); 840 prof << i18n("Local_file");
841 prof << i18n("Last_file"); 841 prof << i18n("Last_file");
842 KSyncProfile* temp = new KSyncProfile (); 842 KSyncProfile* temp = new KSyncProfile ();
843 temp->setName( prof[0] ); 843 temp->setName( prof[0] );
844 temp->writeConfig(&config); 844 temp->writeConfig(&config);
845 temp->setName( prof[1] ); 845 temp->setName( prof[1] );
846 temp->writeConfig(&config); 846 temp->writeConfig(&config);
847 temp->setName( prof[2] ); 847 temp->setName( prof[2] );
848 temp->writeConfig(&config); 848 temp->writeConfig(&config);
849 config.setGroup("General"); 849 config.setGroup("General");
850 config.writeEntry("SyncProfileNames",prof); 850 config.writeEntry("SyncProfileNames",prof);
851 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 851 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
852 config.sync(); 852 config.sync();
853 delete temp; 853 delete temp;
854 } 854 }
855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
856 KOPrefs::instance()->mSyncProfileNames = prof; 856 KOPrefs::instance()->mSyncProfileNames = prof;
857 int i; 857 int i;
858 for ( i = 0; i < prof.count(); ++i ) { 858 for ( i = 0; i < prof.count(); ++i ) {
859 859
860 syncMenu->insertItem( prof[i], 1000+i ); 860 syncMenu->insertItem( prof[i], 1000+i );
861 if ( i == 2 ) 861 if ( i == 2 )
862 syncMenu->insertSeparator(); 862 syncMenu->insertSeparator();
863 } 863 }
864 QDir app_dir; 864 QDir app_dir;
865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
866 syncMenu->setItemEnabled( false , 1000 ); 866 syncMenu->setItemEnabled( false , 1000 );
867 } 867 }
868 mView->setupExternSyncProfiles(); 868 mView->setupExternSyncProfiles();
869} 869}
870 870
871int MainWindow::ringSync() 871int MainWindow::ringSync()
872{ 872{
873 int syncedProfiles = 0; 873 int syncedProfiles = 0;
874 int i; 874 int i;
875 QTime timer; 875 QTime timer;
876 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 876 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
878 KSyncProfile* temp = new KSyncProfile (); 878 KSyncProfile* temp = new KSyncProfile ();
879 KOPrefs::instance()->mAskForPreferences = false; 879 KOPrefs::instance()->mAskForPreferences = false;
880 for ( i = 0; i < syncProfileNames.count(); ++i ) { 880 for ( i = 0; i < syncProfileNames.count(); ++i ) {
881 mCurrentSyncProfile = i; 881 mCurrentSyncProfile = i;
882 temp->setName(syncProfileNames[mCurrentSyncProfile]); 882 temp->setName(syncProfileNames[mCurrentSyncProfile]);
883 temp->readConfig(&config); 883 temp->readConfig(&config);
884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
886 ++syncedProfiles; 886 ++syncedProfiles;
887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
890 KOPrefs::instance()->mShowSyncSummary = false; 890 KOPrefs::instance()->mShowSyncSummary = false;
891 mView->setSyncDevice(syncProfileNames[i] ); 891 mView->setSyncDevice(syncProfileNames[i] );
892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
893 if ( i == 0 ) { 893 if ( i == 0 ) {
894 syncSharp(); 894 syncSharp();
895 } else { 895 } else {
896 if ( temp->getIsLocalFileSync() ) { 896 if ( temp->getIsLocalFileSync() ) {
897 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 897 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
899 } else { 899 } else {
900 syncRemote( temp, false ); 900 if ( temp->getIsPhoneSync() ) {
901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
904 syncPhone();
905 } else
906 syncRemote( temp, false );
901 907
902 } 908 }
903 } 909 }
904 timer.start(); 910 timer.start();
905 setCaption(i18n("Multiple sync in progress ... please wait!") ); 911 setCaption(i18n("Multiple sync in progress ... please wait!") );
906 while ( timer.elapsed () < 2000 ) { 912 while ( timer.elapsed () < 2000 ) {
907 qApp->processEvents(); 913 qApp->processEvents();
908#ifndef _WIN32_ 914#ifndef _WIN32_
909 sleep (1); 915 sleep (1);
910#endif 916#endif
911 } 917 }
912 918
913 } 919 }
914 920
915 } 921 }
916 delete temp; 922 delete temp;
917 return syncedProfiles; 923 return syncedProfiles;
918} 924}
919 925
920void MainWindow::multiSync( bool askforPrefs ) 926void MainWindow::multiSync( bool askforPrefs )
921{ 927{
922 if (mBlockSaveFlag) 928 if (mBlockSaveFlag)
923 return; 929 return;
924 mBlockSaveFlag = true; 930 mBlockSaveFlag = true;
925 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
926 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
927 question, 933 question,
928 i18n("Yes"), i18n("No"), 934 i18n("Yes"), i18n("No"),
929 0, 0 ) != 0 ) { 935 0, 0 ) != 0 ) {
930 mBlockSaveFlag = false; 936 mBlockSaveFlag = false;
931 setCaption(i18n("Aborted! Nothing synced!")); 937 setCaption(i18n("Aborted! Nothing synced!"));
932 return; 938 return;
933 } 939 }
934 mView->setSyncDevice(i18n("Multiple profiles") ); 940 mView->setSyncDevice(i18n("Multiple profiles") );
935 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
936 if ( askforPrefs ) { 942 if ( askforPrefs ) {
937 mView->edit_sync_options(); 943 mView->edit_sync_options();
938 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
939 } 945 }
940 setCaption(i18n("Multiple sync started.") ); 946 setCaption(i18n("Multiple sync started.") );
941 qApp->processEvents(); 947 qApp->processEvents();
942 int num = ringSync() ; 948 int num = ringSync() ;
943 if ( num > 1 ) 949 if ( num > 1 )
944 ringSync(); 950 ringSync();
945 mBlockSaveFlag = false; 951 mBlockSaveFlag = false;
946 if ( num ) 952 if ( num )
947 save(); 953 save();
948 if ( num ) 954 if ( num )
949 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
950 else 956 else
951 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 957 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
952 return; 958 return;
953} 959}
954void MainWindow::slotSyncMenu( int action ) 960void MainWindow::slotSyncMenu( int action )
955{ 961{
956 //qDebug("syncaction %d ", action); 962 //qDebug("syncaction %d ", action);
957 if ( action == 0 ) { 963 if ( action == 0 ) {
958 964
959 confSync(); 965 confSync();
960 966
961 return; 967 return;
962 } 968 }
963 if ( action == 1 ) { 969 if ( action == 1 ) {
964 multiSync( true ); 970 multiSync( true );
965 return; 971 return;
966 } 972 }
967 973
968 if (mBlockSaveFlag) 974 if (mBlockSaveFlag)
969 return; 975 return;
970 mBlockSaveFlag = true; 976 mBlockSaveFlag = true;
971 mCurrentSyncProfile = action - 1000 ; 977 mCurrentSyncProfile = action - 1000 ;
972 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
973 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
974 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 980 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
975 KSyncProfile* temp = new KSyncProfile (); 981 KSyncProfile* temp = new KSyncProfile ();
976 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
977 temp->readConfig(&config); 983 temp->readConfig(&config);
978 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
979 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
980 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
981 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
982 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
983 if ( action == 1000 ) { 989 if ( action == 1000 ) {
984 syncSharp(); 990 syncSharp();
985 991
986 } else if ( action == 1001 ) { 992 } else if ( action == 1001 ) {
987 syncLocalFile(); 993 syncLocalFile();
988 994
989 } else if ( action == 1002 ) { 995 } else if ( action == 1002 ) {
990 quickSyncLocalFile(); 996 quickSyncLocalFile();
991 997
992 } else if ( action >= 1003 ) { 998 } else if ( action >= 1003 ) {
993 if ( temp->getIsLocalFileSync() ) { 999 if ( temp->getIsLocalFileSync() ) {
994 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
995 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
996 } else { 1002 } else {
997 syncRemote( temp ); 1003 syncRemote( temp );
998 1004
999 } 1005 }
1000 } 1006 }
1001 delete temp; 1007 delete temp;
1002 mBlockSaveFlag = false; 1008 mBlockSaveFlag = false;
1003} 1009}
1004void MainWindow::setDefaultPreferences() 1010void MainWindow::setDefaultPreferences()
1005{ 1011{
1006 KOPrefs *p = KOPrefs::instance(); 1012 KOPrefs *p = KOPrefs::instance();
1007 1013
1008 p->mCompactDialogs = true; 1014 p->mCompactDialogs = true;
1009 p->mConfirm = true; 1015 p->mConfirm = true;
1010 // p->mEnableQuickTodo = false; 1016 // p->mEnableQuickTodo = false;
1011} 1017}
1012 1018
1013QString MainWindow::resourcePath() 1019QString MainWindow::resourcePath()
1014{ 1020{
1015 return KGlobal::iconLoader()->iconPath(); 1021 return KGlobal::iconLoader()->iconPath();
1016} 1022}
1017 1023
1018void MainWindow::displayText( QString text ,QString cap ) 1024void MainWindow::displayText( QString text ,QString cap )
1019{ 1025{
1020 QDialog dia( this, "name", true ); ; 1026 QDialog dia( this, "name", true ); ;
1021 dia.setCaption( cap ); 1027 dia.setCaption( cap );
1022 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1028 QVBoxLayout* lay = new QVBoxLayout( &dia );
1023 lay->setSpacing( 3 ); 1029 lay->setSpacing( 3 );
1024 lay->setMargin( 3 ); 1030 lay->setMargin( 3 );
1025 QTextBrowser tb ( &dia ); 1031 QTextBrowser tb ( &dia );
1026 lay->addWidget( &tb ); 1032 lay->addWidget( &tb );
1027 tb.setText( text ); 1033 tb.setText( text );
1028#ifdef DESKTOP_VERSION 1034#ifdef DESKTOP_VERSION
1029 dia.resize( 640, 480); 1035 dia.resize( 640, 480);
1030#else 1036#else
1031 dia.showMaximized(); 1037 dia.showMaximized();
1032#endif 1038#endif
1033 dia.exec(); 1039 dia.exec();
1034} 1040}
1035void MainWindow::displayFile( QString fn, QString cap ) 1041void MainWindow::displayFile( QString fn, QString cap )
1036{ 1042{
1037 QString fileName = resourcePath() + fn; 1043 QString fileName = resourcePath() + fn;
1038 QString text; 1044 QString text;
1039 QFile file( fileName ); 1045 QFile file( fileName );
1040 if (!file.open( IO_ReadOnly ) ) { 1046 if (!file.open( IO_ReadOnly ) ) {
1041 return ; 1047 return ;
1042 1048
1043 } 1049 }
1044 QTextStream ts( &file ); 1050 QTextStream ts( &file );
1045 text = ts.read(); 1051 text = ts.read();
1046 file.close(); 1052 file.close();
1047 displayText( text, cap); 1053 displayText( text, cap);
1048} 1054}
1049void MainWindow::features() 1055void MainWindow::features()
1050{ 1056{
1051 1057
1052 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1058 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1053} 1059}
1054 1060
1055void MainWindow::usertrans() 1061void MainWindow::usertrans()
1056{ 1062{
1057 1063
1058 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1064 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1059} 1065}
1060void MainWindow::synchowto() 1066void MainWindow::synchowto()
1061{ 1067{
1062 1068
1063 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1069 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1064} 1070}
1065void MainWindow::faq() 1071void MainWindow::faq()
1066{ 1072{
1067 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1073 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1068 1074
1069} 1075}
1070void MainWindow::whatsNew() 1076void MainWindow::whatsNew()
1071{ 1077{
1072 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1078 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1073 1079
1074} 1080}
1075void MainWindow::licence() 1081void MainWindow::licence()
1076{ 1082{
1077 KApplication::showLicence(); 1083 KApplication::showLicence();
1078 1084
1079} 1085}
1080void MainWindow::about() 1086void MainWindow::about()
1081{ 1087{
1082 QString version; 1088 QString version;
1083#include <../version> 1089#include <../version>
1084 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1090 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1085 i18n("KOrganizer/Platform-independent\n") + 1091 i18n("KOrganizer/Platform-independent\n") +
1086 "(KO/Pi) " + version + " - " + 1092 "(KO/Pi) " + version + " - " +
1087 1093
1088#ifdef DESKTOP_VERSION 1094#ifdef DESKTOP_VERSION
1089 i18n("Desktop Edition\n") + 1095 i18n("Desktop Edition\n") +
1090#else 1096#else
1091 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1097 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1092#endif 1098#endif
1093 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1099 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1094} 1100}
1095void MainWindow::keyBindings() 1101void MainWindow::keyBindings()
1096{ 1102{
1097 QString cap = i18n("Key bindings KOrganizer/Pi"); 1103 QString cap = i18n("Key bindings KOrganizer/Pi");
1098 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1104 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1099 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1105 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1100 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1106 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1101 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1107 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1102 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1108 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1103 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1109 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1104 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1110 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1105 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1111 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1106 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1112 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1107 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1113 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1108 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1114 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1109 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1115 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1110 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1116 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1111 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1117 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1112 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1118 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1113 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1119 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1114 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1120 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1115 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1121 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1116 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1122 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1117 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1123 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1118 i18n("<p><h3>In agenda view:</h3></p>\n") + 1124 i18n("<p><h3>In agenda view:</h3></p>\n") +
1119 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1125 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1120 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1126 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1121 i18n("<p><h3>In todo view:</h3></p>\n") + 1127 i18n("<p><h3>In todo view:</h3></p>\n") +
1122 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1128 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1123 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1129 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1124 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1130 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1125 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1131 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1126 i18n("<p><h3>In list view:</h3></p>\n") + 1132 i18n("<p><h3>In list view:</h3></p>\n") +
1127 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1133 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1128 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1134 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1129 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1135 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1130 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1136 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1131 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1137 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1132 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1138 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1133 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1139 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1134 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1140 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1135 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1141 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1136 i18n("<p><b>E</b>: Edit item</p>\n") + 1142 i18n("<p><b>E</b>: Edit item</p>\n") +
1137 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1143 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1138 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1144 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1139 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1145 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1140 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1146 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1141 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1147 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1142 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1148 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1143 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1149 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1144 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1150 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1145 i18n("<p><b>White</b>: Item readonly</p>\n"); 1151 i18n("<p><b>White</b>: Item readonly</p>\n");
1146 displayText( text, cap); 1152 displayText( text, cap);
1147 1153
1148} 1154}
1149void MainWindow::aboutAutoSaving() 1155void MainWindow::aboutAutoSaving()
1150{ 1156{
1151 QMessageBox* msg; 1157 QMessageBox* msg;
1152 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1158 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1153 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) 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"), QMessageBox::NoIcon, 1159 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) 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"), QMessageBox::NoIcon,
1154 QMessageBox::Ok, 1160 QMessageBox::Ok,
1155 QMessageBox::NoButton, 1161 QMessageBox::NoButton,
1156 QMessageBox::NoButton); 1162 QMessageBox::NoButton);
1157 msg->exec(); 1163 msg->exec();
1158 delete msg; 1164 delete msg;
1159 1165
1160 1166
1161} 1167}
1162void MainWindow::aboutKnownBugs() 1168void MainWindow::aboutKnownBugs()
1163{ 1169{
1164 QMessageBox* msg; 1170 QMessageBox* msg;
1165 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1171 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1166 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")+ 1172 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")+
1167 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1173 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1168 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1174 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1169 i18n("\nor report them in the bugtracker on\n") + 1175 i18n("\nor report them in the bugtracker on\n") +
1170 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1176 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1171 QMessageBox::NoIcon, 1177 QMessageBox::NoIcon,
1172 QMessageBox::Ok, 1178 QMessageBox::Ok,
1173 QMessageBox::NoButton, 1179 QMessageBox::NoButton,
1174 QMessageBox::NoButton); 1180 QMessageBox::NoButton);
1175 msg->exec(); 1181 msg->exec();
1176 delete msg; 1182 delete msg;
1177 1183
1178} 1184}
1179 1185
1180QString MainWindow::defaultFileName() 1186QString MainWindow::defaultFileName()
1181{ 1187{
1182 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1188 return locateLocal( "data", "korganizer/mycalendar.ics" );
1183} 1189}
1184 1190
1185void MainWindow::processIncidenceSelection( Incidence *incidence ) 1191void MainWindow::processIncidenceSelection( Incidence *incidence )
1186{ 1192{
1187 if ( !incidence ) { 1193 if ( !incidence ) {
1188 enableIncidenceActions( false ); 1194 enableIncidenceActions( false );
1189 1195
1190 mNewSubTodoAction->setEnabled( false ); 1196 mNewSubTodoAction->setEnabled( false );
1191 setCaptionToDates(); 1197 setCaptionToDates();
1192 return; 1198 return;
1193 1199
1194 } 1200 }
1195 1201
1196 //KGlobal::locale()->formatDateTime(nextA, true); 1202 //KGlobal::locale()->formatDateTime(nextA, true);
1197 QString startString = ""; 1203 QString startString = "";
1198 if ( incidence->type() != "Todo" ) { 1204 if ( incidence->type() != "Todo" ) {
1199 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1205 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1200 if ( incidence->doesFloat() ) { 1206 if ( incidence->doesFloat() ) {
1201 startString += ": "+incidence->dtStartDateStr( true ); 1207 startString += ": "+incidence->dtStartDateStr( true );
1202 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1208 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1203 1209
1204 } else { 1210 } else {
1205 startString = ": "+incidence->dtStartStr(true); 1211 startString = ": "+incidence->dtStartStr(true);
1206 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1212 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1207 1213
1208 } 1214 }
1209 1215
1210 } else { 1216 } else {
1211 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1217 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1212 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1218 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1213 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1219 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1214 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1220 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1215 } 1221 }
1216 1222
1217 } 1223 }
1218 else 1224 else
1219 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1225 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1220 if ( !incidence->location().isEmpty() ) 1226 if ( !incidence->location().isEmpty() )
1221 startString += " (" +incidence->location()+")"; 1227 startString += " (" +incidence->location()+")";
1222 setCaption( incidence->summary()+startString); 1228 setCaption( incidence->summary()+startString);
1223 1229
1224 enableIncidenceActions( true ); 1230 enableIncidenceActions( true );
1225 1231
1226 if ( incidence->type() == "Event" ) { 1232 if ( incidence->type() == "Event" ) {
1227 mShowAction->setText( i18n("Show Event...") ); 1233 mShowAction->setText( i18n("Show Event...") );
1228 mEditAction->setText( i18n("Edit Event...") ); 1234 mEditAction->setText( i18n("Edit Event...") );
1229 mDeleteAction->setText( i18n("Delete Event...") ); 1235 mDeleteAction->setText( i18n("Delete Event...") );
1230 1236
1231 mNewSubTodoAction->setEnabled( false ); 1237 mNewSubTodoAction->setEnabled( false );
1232 } else if ( incidence->type() == "Todo" ) { 1238 } else if ( incidence->type() == "Todo" ) {
1233 mShowAction->setText( i18n("Show Todo...") ); 1239 mShowAction->setText( i18n("Show Todo...") );
1234 mEditAction->setText( i18n("Edit Todo...") ); 1240 mEditAction->setText( i18n("Edit Todo...") );
1235 mDeleteAction->setText( i18n("Delete Todo...") ); 1241 mDeleteAction->setText( i18n("Delete Todo...") );
1236 1242
1237 mNewSubTodoAction->setEnabled( true ); 1243 mNewSubTodoAction->setEnabled( true );
1238 } else { 1244 } else {
1239 mShowAction->setText( i18n("Show...") ); 1245 mShowAction->setText( i18n("Show...") );
1240 mShowAction->setText( i18n("Edit...") ); 1246 mShowAction->setText( i18n("Edit...") );
1241 mShowAction->setText( i18n("Delete...") ); 1247 mShowAction->setText( i18n("Delete...") );
1242 1248
1243 mNewSubTodoAction->setEnabled( false ); 1249 mNewSubTodoAction->setEnabled( false );
1244 } 1250 }
1245} 1251}
1246 1252
1247void MainWindow::enableIncidenceActions( bool enabled ) 1253void MainWindow::enableIncidenceActions( bool enabled )
1248{ 1254{
1249 mShowAction->setEnabled( enabled ); 1255 mShowAction->setEnabled( enabled );
1250 mEditAction->setEnabled( enabled ); 1256 mEditAction->setEnabled( enabled );
1251 mDeleteAction->setEnabled( enabled ); 1257 mDeleteAction->setEnabled( enabled );
1252} 1258}
1253 1259
1254void MainWindow::importOL() 1260void MainWindow::importOL()
1255{ 1261{
1256#ifdef _WIN32_ 1262#ifdef _WIN32_
1257 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1263 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1258 id->exec(); 1264 id->exec();
1259 delete id; 1265 delete id;
1260 mView->updateView(); 1266 mView->updateView();
1261#endif 1267#endif
1262} 1268}
1263void MainWindow::importBday() 1269void MainWindow::importBday()
1264{ 1270{
1265 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1271 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1266 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1272 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1267 i18n("Import!"), i18n("Cancel"), 0, 1273 i18n("Import!"), i18n("Cancel"), 0,
1268 0, 1 ); 1274 0, 1 );
1269 if ( result == 0 ) { 1275 if ( result == 0 ) {
1270 mView->importBday(); 1276 mView->importBday();
1271 1277
1272 } 1278 }
1273 1279
1274 1280
1275} 1281}
1276void MainWindow::importQtopia() 1282void MainWindow::importQtopia()
1277{ 1283{
1278#ifndef DESKTOP_VERSION 1284#ifndef DESKTOP_VERSION
1279 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1285 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1280 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"), 1286 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"),
1281 i18n("Import!"), i18n("Cancel"), 0, 1287 i18n("Import!"), i18n("Cancel"), 0,
1282 0, 1 ); 1288 0, 1 );
1283 if ( result == 0 ) { 1289 if ( result == 0 ) {
1284 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1290 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1285 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1291 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1286 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1292 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1287 mView->importQtopia( categories, datebook, todolist ); 1293 mView->importQtopia( categories, datebook, todolist );
1288 } 1294 }
1289#else 1295#else
1290 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1296 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1291 i18n("Not supported \non desktop!\n"), 1297 i18n("Not supported \non desktop!\n"),
1292 i18n("Ok"), i18n("Cancel"), 0, 1298 i18n("Ok"), i18n("Cancel"), 0,
1293 0, 1 ); 1299 0, 1 );
1294 1300
1295#endif 1301#endif
1296} 1302}
1297 1303
1298void MainWindow::saveOnClose() 1304void MainWindow::saveOnClose()
1299{ 1305{
1300 KOPrefs *p = KOPrefs::instance(); 1306 KOPrefs *p = KOPrefs::instance();
1301 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1307 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1302 p->mToolBarUp = iconToolBar->x() > width()/2 || 1308 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1303 iconToolBar->y() > height()/2; 1309 iconToolBar->y() > height()/2;
1304 mView->writeSettings(); 1310 mView->writeSettings();
1305 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1311 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1306 save(); 1312 save();
1307} 1313}
1308void MainWindow::slotModifiedChanged( bool changed ) 1314void MainWindow::slotModifiedChanged( bool changed )
1309{ 1315{
1310 if ( mBlockAtStartup ) 1316 if ( mBlockAtStartup )
1311 return; 1317 return;
1312 int msec; 1318 int msec;
1313 // we store the changes after 1 minute, 1319 // we store the changes after 1 minute,
1314 // and for safety reasons after 10 minutes again 1320 // and for safety reasons after 10 minutes again
1315 if ( !mBlockSaveFlag ) 1321 if ( !mBlockSaveFlag )
1316 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1322 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1317 else 1323 else
1318 msec = 1000 * 600; 1324 msec = 1000 * 600;
1319 mSaveTimer.start( msec, true ); // 1 minute 1325 mSaveTimer.start( msec, true ); // 1 minute
1320 qDebug("KO: Saving File in %d secs!", msec/1000); 1326 qDebug("KO: Saving File in %d secs!", msec/1000);
1321 mCalendarModifiedFlag = true; 1327 mCalendarModifiedFlag = true;
1322} 1328}
1323#include <qfileinfo.h> 1329#include <qfileinfo.h>
1324void MainWindow::save() 1330void MainWindow::save()
1325{ 1331{
1326 if ( mBlockSaveFlag ) 1332 if ( mBlockSaveFlag )
1327 return; 1333 return;
1328 bool store = mBlockSaveFlag; 1334 bool store = mBlockSaveFlag;
1329 mBlockSaveFlag = true; 1335 mBlockSaveFlag = true;
1330 if ( mView->checkFileVersion( defaultFileName()) ) { 1336 if ( mView->checkFileVersion( defaultFileName()) ) {
1331 1337
1332 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1338 QTime neededSaveTime = QDateTime::currentDateTime().time();
1333 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1339 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1334 qDebug("KO: Start saving data to file!"); 1340 qDebug("KO: Start saving data to file!");
1335 mView->saveCalendar( defaultFileName() ); 1341 mView->saveCalendar( defaultFileName() );
1336 1342
1337 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1343 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1338 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1344 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1339 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1345 qDebug("KO: Needed %d ms for saving.",msNeeded );
1340 QString savemes; 1346 QString savemes;
1341 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1347 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1342 setCaption(savemes); 1348 setCaption(savemes);
1343 } else 1349 } else
1344 setCaption(i18n("Saving cancelled!")); 1350 setCaption(i18n("Saving cancelled!"));
1345 mCalendarModifiedFlag = false; 1351 mCalendarModifiedFlag = false;
1346 mBlockSaveFlag = store; 1352 mBlockSaveFlag = store;
1347} 1353}
1348 1354
1349void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1355void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1350{ 1356{
1351 if ( !e->isAutoRepeat() ) { 1357 if ( !e->isAutoRepeat() ) {
1352 mFlagKeyPressed = false; 1358 mFlagKeyPressed = false;
1353 } 1359 }
1354} 1360}
1355void MainWindow::keyPressEvent ( QKeyEvent * e ) 1361void MainWindow::keyPressEvent ( QKeyEvent * e )
1356{ 1362{
1357 qApp->processEvents(); 1363 qApp->processEvents();
1358 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1364 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1359 e->ignore(); 1365 e->ignore();
1360 // qDebug(" ignore %d",e->isAutoRepeat() ); 1366 // qDebug(" ignore %d",e->isAutoRepeat() );
1361 return; 1367 return;
1362 } 1368 }
1363 if (! e->isAutoRepeat() ) 1369 if (! e->isAutoRepeat() )
1364 mFlagKeyPressed = true; 1370 mFlagKeyPressed = true;
1365 KOPrefs *p = KOPrefs::instance(); 1371 KOPrefs *p = KOPrefs::instance();
1366 bool showSelectedDates = false; 1372 bool showSelectedDates = false;
1367 int size; 1373 int size;
1368 int pro = 0; 1374 int pro = 0;
1369 //qDebug("MainWindow::keyPressEvent "); 1375 //qDebug("MainWindow::keyPressEvent ");
1370 switch ( e->key() ) { 1376 switch ( e->key() ) {
1371 case Qt::Key_Right: 1377 case Qt::Key_Right:
1372 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1378 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1373 mView->goNextMonth(); 1379 mView->goNextMonth();
1374 else 1380 else
1375 mView->goNext(); 1381 mView->goNext();
1376 showSelectedDates = true; 1382 showSelectedDates = true;
1377 break; 1383 break;
1378 case Qt::Key_Left: 1384 case Qt::Key_Left:
1379 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1385 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1380 mView->goPreviousMonth(); 1386 mView->goPreviousMonth();
1381 else 1387 else
1382 mView->goPrevious(); 1388 mView->goPrevious();
1383 showSelectedDates = true; 1389 showSelectedDates = true;
1384 break; 1390 break;
1385 case Qt::Key_Down: 1391 case Qt::Key_Down:
1386 mView->viewManager()->agendaView()->scrollOneHourDown(); 1392 mView->viewManager()->agendaView()->scrollOneHourDown();
1387 break; 1393 break;
1388 case Qt::Key_Up: 1394 case Qt::Key_Up:
1389 mView->viewManager()->agendaView()->scrollOneHourUp(); 1395 mView->viewManager()->agendaView()->scrollOneHourUp();
1390 break; 1396 break;
1391 case Qt::Key_I: 1397 case Qt::Key_I:
1392 mView->showIncidence(); 1398 mView->showIncidence();
1393 break; 1399 break;
1394 case Qt::Key_Delete: 1400 case Qt::Key_Delete:
1395 case Qt::Key_Backspace: 1401 case Qt::Key_Backspace:
1396 mView->deleteIncidence(); 1402 mView->deleteIncidence();
1397 break; 1403 break;
1398 case Qt::Key_D: 1404 case Qt::Key_D:
1399 mView->viewManager()->showDayView(); 1405 mView->viewManager()->showDayView();
1400 showSelectedDates = true; 1406 showSelectedDates = true;
1401 break; 1407 break;
1402 case Qt::Key_O: 1408 case Qt::Key_O:
1403 mView->toggleFilerEnabled( ); 1409 mView->toggleFilerEnabled( );
1404 break; 1410 break;
1405 case Qt::Key_0: 1411 case Qt::Key_0:
1406 case Qt::Key_1: 1412 case Qt::Key_1:
1407 case Qt::Key_2: 1413 case Qt::Key_2:
1408 case Qt::Key_3: 1414 case Qt::Key_3:
1409 case Qt::Key_4: 1415 case Qt::Key_4:
1410 case Qt::Key_5: 1416 case Qt::Key_5:
1411 case Qt::Key_6: 1417 case Qt::Key_6:
1412 case Qt::Key_7: 1418 case Qt::Key_7:
1413 case Qt::Key_8: 1419 case Qt::Key_8:
1414 case Qt::Key_9: 1420 case Qt::Key_9:
1415 pro = e->key()-48; 1421 pro = e->key()-48;
1416 if ( pro == 0 ) 1422 if ( pro == 0 )
1417 pro = 10; 1423 pro = 10;
1418 if ( e->state() == Qt::ControlButton) 1424 if ( e->state() == Qt::ControlButton)
1419 pro += 10; 1425 pro += 10;
1420 break; 1426 break;
1421 case Qt::Key_M: 1427 case Qt::Key_M:
1422 mView->viewManager()->showMonthView(); 1428 mView->viewManager()->showMonthView();
1423 showSelectedDates = true; 1429 showSelectedDates = true;
1424 break; 1430 break;
1425 case Qt::Key_Insert: 1431 case Qt::Key_Insert:
1426 mView->newEvent(); 1432 mView->newEvent();
1427 break; 1433 break;
1428 case Qt::Key_S : 1434 case Qt::Key_S :
1429 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1435 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1430 mView->newSubTodo(); 1436 mView->newSubTodo();
1431 else 1437 else
1432 mView->dialogManager()->showSearchDialog(); 1438 mView->dialogManager()->showSearchDialog();
1433 break; 1439 break;
1434 case Qt::Key_Y : 1440 case Qt::Key_Y :
1435 case Qt::Key_Z : 1441 case Qt::Key_Z :
1436 mView->viewManager()->showWorkWeekView(); 1442 mView->viewManager()->showWorkWeekView();
1437 showSelectedDates = true; 1443 showSelectedDates = true;
1438 break; 1444 break;
1439 case Qt::Key_U : 1445 case Qt::Key_U :
1440 mView->viewManager()->showWeekView(); 1446 mView->viewManager()->showWeekView();
1441 showSelectedDates = true; 1447 showSelectedDates = true;
1442 break; 1448 break;
1443 case Qt::Key_H : 1449 case Qt::Key_H :
1444 keyBindings(); 1450 keyBindings();
1445 break; 1451 break;
1446 case Qt::Key_W: 1452 case Qt::Key_W:
1447 mView->viewManager()->showWhatsNextView(); 1453 mView->viewManager()->showWhatsNextView();
1448 break; 1454 break;
1449 case Qt::Key_L: 1455 case Qt::Key_L:
1450 mView->viewManager()->showListView(); 1456 mView->viewManager()->showListView();
1451 break; 1457 break;
1452 case Qt::Key_N: 1458 case Qt::Key_N:
1453 mView->viewManager()->showNextXView(); 1459 mView->viewManager()->showNextXView();
1454 showSelectedDates = true; 1460 showSelectedDates = true;
1455 break; 1461 break;
1456 case Qt::Key_V: 1462 case Qt::Key_V:
1457 mView->viewManager()->showTodoView(); 1463 mView->viewManager()->showTodoView();
1458 break; 1464 break;
1459 case Qt::Key_C: 1465 case Qt::Key_C:
1460 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1466 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1461 break; 1467 break;
1462 case Qt::Key_P: 1468 case Qt::Key_P:
1463 mView->showDatePicker( ); 1469 mView->showDatePicker( );
1464 break; 1470 break;
1465 case Qt::Key_F: 1471 case Qt::Key_F:
1466 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1472 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1467 mView->editFilters(); 1473 mView->editFilters();
1468 else 1474 else
1469 mView->toggleFilter(); 1475 mView->toggleFilter();
1470 break; 1476 break;
1471 case Qt::Key_X: 1477 case Qt::Key_X:
1472 mView->toggleDateNavigatorWidget(); 1478 mView->toggleDateNavigatorWidget();
1473 break; 1479 break;
1474 case Qt::Key_Space: 1480 case Qt::Key_Space:
1475 mView->toggleExpand(); 1481 mView->toggleExpand();
1476 break; 1482 break;
1477 case Qt::Key_A: 1483 case Qt::Key_A:
1478 mView->toggleAllDaySize(); 1484 mView->toggleAllDaySize();
1479 break; 1485 break;
1480 case Qt::Key_T: 1486 case Qt::Key_T:
1481 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1487 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1482 mView->newTodo(); 1488 mView->newTodo();
1483 else { 1489 else {
1484 mView->goToday(); 1490 mView->goToday();
1485 showSelectedDates = true; 1491 showSelectedDates = true;
1486 } 1492 }
1487 break; 1493 break;
1488 case Qt::Key_J: 1494 case Qt::Key_J:
1489 mView->viewManager()->showJournalView(); 1495 mView->viewManager()->showJournalView();
1490 break; 1496 break;
1491 case Qt::Key_B: 1497 case Qt::Key_B:
1492 mView->editIncidenceDescription();; 1498 mView->editIncidenceDescription();;
1493 break; 1499 break;
1494 // case Qt::Key_Return: 1500 // case Qt::Key_Return:
1495 case Qt::Key_E: 1501 case Qt::Key_E:
1496 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1502 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1497 mView->newEvent(); 1503 mView->newEvent();
1498 else 1504 else
1499 mView->editIncidence(); 1505 mView->editIncidence();
1500 break; 1506 break;
1501 case Qt::Key_Plus: 1507 case Qt::Key_Plus:
1502 size = p->mHourSize +2; 1508 size = p->mHourSize +2;
1503 if ( size <= 18 ) 1509 if ( size <= 18 )
1504 configureAgenda( size ); 1510 configureAgenda( size );
1505 break; 1511 break;
1506 case Qt::Key_Minus: 1512 case Qt::Key_Minus:
1507 size = p->mHourSize - 2; 1513 size = p->mHourSize - 2;
1508 if ( size >= 4 ) 1514 if ( size >= 4 )
1509 configureAgenda( size ); 1515 configureAgenda( size );
1510 break; 1516 break;
1511 1517
1512 1518
1513 default: 1519 default:
1514 e->ignore(); 1520 e->ignore();
1515 } 1521 }
1516 if ( pro > 0 ) { 1522 if ( pro > 0 ) {
1517 mView->selectFilter( pro-1 ); 1523 mView->selectFilter( pro-1 );
1518 } 1524 }
1519 if ( showSelectedDates ) { 1525 if ( showSelectedDates ) {
1520 ;// setCaptionToDates(); 1526 ;// setCaptionToDates();
1521 } 1527 }
1522 1528
1523} 1529}
1524 1530
1525void MainWindow::fillFilterMenu() 1531void MainWindow::fillFilterMenu()
1526{ 1532{
1527 selectFilterMenu->clear(); 1533 selectFilterMenu->clear();
1528 bool disable = false; 1534 bool disable = false;
1529 if ( mView->filterView()->filtersEnabled() ) { 1535 if ( mView->filterView()->filtersEnabled() ) {
1530 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1536 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1531 } 1537 }
1532 else { 1538 else {
1533 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1539 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1534 disable = true; 1540 disable = true;
1535 } 1541 }
1536 selectFilterMenu->insertSeparator(); 1542 selectFilterMenu->insertSeparator();
1537 QPtrList<CalFilter> fili = mView->filters(); 1543 QPtrList<CalFilter> fili = mView->filters();
1538 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1544 CalFilter *curfilter = mView->filterView()->selectedFilter();
1539 CalFilter *filter = fili.first(); 1545 CalFilter *filter = fili.first();
1540 int iii = 1; 1546 int iii = 1;
1541 while(filter) { 1547 while(filter) {
1542 selectFilterMenu->insertItem( filter->name(), iii ); 1548 selectFilterMenu->insertItem( filter->name(), iii );
1543 if ( filter == curfilter) 1549 if ( filter == curfilter)
1544 selectFilterMenu->setItemChecked( iii, true ); 1550 selectFilterMenu->setItemChecked( iii, true );
1545 if ( disable ) 1551 if ( disable )
1546 selectFilterMenu->setItemEnabled( iii, false ); 1552 selectFilterMenu->setItemEnabled( iii, false );
1547 filter = fili.next(); 1553 filter = fili.next();
1548 ++iii; 1554 ++iii;
1549 } 1555 }
1550} 1556}
1551void MainWindow::selectFilter( int fil ) 1557void MainWindow::selectFilter( int fil )
1552{ 1558{
1553 if ( fil == 0 ) { 1559 if ( fil == 0 ) {
1554 mView->toggleFilerEnabled( ); 1560 mView->toggleFilerEnabled( );
1555 } else { 1561 } else {
1556 mView->selectFilter( fil-1 ); 1562 mView->selectFilter( fil-1 );
1557 } 1563 }
1558} 1564}
1559void MainWindow::configureToolBar( int item ) 1565void MainWindow::configureToolBar( int item )
1560{ 1566{
1561 1567
1562 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1568 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1563 KOPrefs *p = KOPrefs::instance(); 1569 KOPrefs *p = KOPrefs::instance();
1564 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1570 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1565 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1571 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1566 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1572 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1567 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1573 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1568 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1574 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1569 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1575 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1570 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1576 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1571 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1577 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1572 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1578 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1573 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1579 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1574 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1580 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1575 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1581 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1576 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1582 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1577 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1583 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1578 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1584 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1579 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1585 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1580 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1586 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1581 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1587 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1582 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1588 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1583 // initActions(); 1589 // initActions();
1584} 1590}
1585 1591
1586void MainWindow::setCaptionToDates() 1592void MainWindow::setCaptionToDates()
1587{ 1593{
1588 QString selDates; 1594 QString selDates;
1589 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1595 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1590 if (mView->startDate() < mView->endDate() ) 1596 if (mView->startDate() < mView->endDate() )
1591 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1597 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1592 setCaption( i18n("Dates: ") + selDates ); 1598 setCaption( i18n("Dates: ") + selDates );
1593 1599
1594} 1600}
1595// parameter item == 0: reinit 1601// parameter item == 0: reinit
1596void MainWindow::configureAgenda( int item ) 1602void MainWindow::configureAgenda( int item )
1597{ 1603{
1598 1604
1599 KOPrefs *p = KOPrefs::instance(); 1605 KOPrefs *p = KOPrefs::instance();
1600 1606
1601 int i; 1607 int i;
1602 if ( item == 1 ) { 1608 if ( item == 1 ) {
1603 mView->toggleAllDaySize(); 1609 mView->toggleAllDaySize();
1604 return; 1610 return;
1605 } 1611 }
1606 // do not allow 4 for widgets higher than 480 1612 // do not allow 4 for widgets higher than 480
1607 // if ( QApplication::desktop()->height() > 480 ) { 1613 // if ( QApplication::desktop()->height() > 480 ) {
1608// if ( item == 4 ) 1614// if ( item == 4 )
1609// item = 6; 1615// item = 6;
1610// } 1616// }
1611 for ( i = 4; i <= 18; i= i+2 ) 1617 for ( i = 4; i <= 18; i= i+2 )
1612 configureAgendaMenu->setItemChecked( i, false ); 1618 configureAgendaMenu->setItemChecked( i, false );
1613 configureAgendaMenu->setItemChecked( item, true ); 1619 configureAgendaMenu->setItemChecked( item, true );
1614 if ( p->mHourSize == item ) 1620 if ( p->mHourSize == item )
1615 return; 1621 return;
1616 p->mHourSize=item; 1622 p->mHourSize=item;
1617 mView->viewManager()->agendaView()->updateConfig(); 1623 mView->viewManager()->agendaView()->updateConfig();
1618} 1624}
1619 1625
1620void MainWindow::saveCalendar() 1626void MainWindow::saveCalendar()
1621{ 1627{
1622 QString fn = KOPrefs::instance()->mLastSaveFile; 1628 QString fn = KOPrefs::instance()->mLastSaveFile;
1623 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1629 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1624 1630
1625 if ( fn == "" ) 1631 if ( fn == "" )
1626 return; 1632 return;
1627 QFileInfo info; 1633 QFileInfo info;
1628 info.setFile( fn ); 1634 info.setFile( fn );
1629 QString mes; 1635 QString mes;
1630 bool createbup = true; 1636 bool createbup = true;
1631 if ( info. exists() ) { 1637 if ( info. exists() ) {
1632 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1638 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1633 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1639 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1634 i18n("Overwrite!"), i18n("Cancel"), 0, 1640 i18n("Overwrite!"), i18n("Cancel"), 0,
1635 0, 1 ); 1641 0, 1 );
1636 if ( result != 0 ) { 1642 if ( result != 0 ) {
1637 createbup = false; 1643 createbup = false;
1638 } 1644 }
1639 } 1645 }
1640 if ( createbup ) { 1646 if ( createbup ) {
1641 mView->saveCalendar( fn ); 1647 mView->saveCalendar( fn );
1642 mes = i18n("KO/Pi:Saved %1").arg(fn); 1648 mes = i18n("KO/Pi:Saved %1").arg(fn);
1643 KOPrefs::instance()->mLastSaveFile = fn; 1649 KOPrefs::instance()->mLastSaveFile = fn;
1644 setCaption(mes); 1650 setCaption(mes);
1645 } 1651 }
1646} 1652}
1647void MainWindow::loadCalendar() 1653void MainWindow::loadCalendar()
1648{ 1654{
1649 1655
1650 QString fn = KOPrefs::instance()->mLastLoadFile; 1656 QString fn = KOPrefs::instance()->mLastLoadFile;
1651 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1657 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1652 1658
1653 if ( fn == "" ) 1659 if ( fn == "" )
1654 return; 1660 return;
1655 QFileInfo info; 1661 QFileInfo info;
1656 info.setFile( fn ); 1662 info.setFile( fn );
1657 QString mess; 1663 QString mess;
1658 bool loadbup = true; 1664 bool loadbup = true;
1659 if ( info. exists() ) { 1665 if ( info. exists() ) {
1660 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1666 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1661 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1667 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1662 mess, 1668 mess,
1663 i18n("Load!"), i18n("Cancel"), 0, 1669 i18n("Load!"), i18n("Cancel"), 0,
1664 0, 1 ); 1670 0, 1 );
1665 if ( result != 0 ) { 1671 if ( result != 0 ) {
1666 loadbup = false; 1672 loadbup = false;
1667 } 1673 }
1668 } else { 1674 } else {
1669 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1675 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1670 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1676 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1671 0, 1 ); 1677 0, 1 );
1672 1678
1673 return; 1679 return;
1674 } 1680 }
1675 if ( loadbup ) { 1681 if ( loadbup ) {
1676 mView->openCalendar( fn ); 1682 mView->openCalendar( fn );
1677 KOPrefs::instance()->mLastLoadFile = fn; 1683 KOPrefs::instance()->mLastLoadFile = fn;
1678 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1684 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1679 setCaption(mess); 1685 setCaption(mess);
1680 } 1686 }
1681 1687
1682} 1688}
1683void MainWindow::quickImportIcal() 1689void MainWindow::quickImportIcal()
1684{ 1690{
1685 importFile( KOPrefs::instance()->mLastImportFile, false ); 1691 importFile( KOPrefs::instance()->mLastImportFile, false );
1686} 1692}
1687void MainWindow::importFile( QString fn, bool quick ) 1693void MainWindow::importFile( QString fn, bool quick )
1688{ 1694{
1689 QFileInfo info; 1695 QFileInfo info;
1690 info.setFile( fn ); 1696 info.setFile( fn );
1691 QString mess; 1697 QString mess;
1692 bool loadbup = true; 1698 bool loadbup = true;
1693 if ( !info. exists() ) { 1699 if ( !info. exists() ) {
1694 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1700 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1695 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1701 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1696 mess ); 1702 mess );
1697 return; 1703 return;
1698 } 1704 }
1699 int result = 0; 1705 int result = 0;
1700 if ( !quick ) { 1706 if ( !quick ) {
1701 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 )); 1707 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 ));
1702 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1708 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1703 mess, 1709 mess,
1704 "Import", "Cancel", 0, 1710 "Import", "Cancel", 0,
1705 0, 1 ); 1711 0, 1 );
1706 } 1712 }
1707 if ( result == 0 ) { 1713 if ( result == 0 ) {
1708 if ( mView->openCalendar( fn, true )) { 1714 if ( mView->openCalendar( fn, true )) {
1709 KOPrefs::instance()->mLastImportFile = fn; 1715 KOPrefs::instance()->mLastImportFile = fn;
1710 setCaption(i18n("Imported file successfully")); 1716 setCaption(i18n("Imported file successfully"));
1711 } else { 1717 } else {
1712 setCaption(i18n("Error importing file")); 1718 setCaption(i18n("Error importing file"));
1713 } 1719 }
1714 } 1720 }
1715} 1721}
1716 1722
1717void MainWindow::importIcal() 1723void MainWindow::importIcal()
1718{ 1724{
1719 1725
1720 QString fn =KOPrefs::instance()->mLastImportFile; 1726 QString fn =KOPrefs::instance()->mLastImportFile;
1721 1727
1722 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1728 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1723 if ( fn == "" ) 1729 if ( fn == "" )
1724 return; 1730 return;
1725 importFile( fn, true ); 1731 importFile( fn, true );
1726 1732
1727} 1733}
1728 1734
1729void MainWindow::exportVCalendar() 1735void MainWindow::exportVCalendar()
1730{ 1736{
1731 QString fn = KOPrefs::instance()->mLastVcalFile; 1737 QString fn = KOPrefs::instance()->mLastVcalFile;
1732 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1738 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1733 if ( fn == "" ) 1739 if ( fn == "" )
1734 return; 1740 return;
1735 QFileInfo info; 1741 QFileInfo info;
1736 info.setFile( fn ); 1742 info.setFile( fn );
1737 QString mes; 1743 QString mes;
1738 bool createbup = true; 1744 bool createbup = true;
1739 if ( info. exists() ) { 1745 if ( info. exists() ) {
1740 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1746 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1741 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1747 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1742 i18n("Overwrite!"), i18n("Cancel"), 0, 1748 i18n("Overwrite!"), i18n("Cancel"), 0,
1743 0, 1 ); 1749 0, 1 );
1744 if ( result != 0 ) { 1750 if ( result != 0 ) {
1745 createbup = false; 1751 createbup = false;
1746 } 1752 }
1747 } 1753 }
1748 if ( createbup ) { 1754 if ( createbup ) {
1749 if ( mView->exportVCalendar( fn ) ) { 1755 if ( mView->exportVCalendar( fn ) ) {
1750 KOPrefs::instance()->mLastVcalFile = fn; 1756 KOPrefs::instance()->mLastVcalFile = fn;
1751 if ( fn.length() > 20 ) 1757 if ( fn.length() > 20 )
1752 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1758 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1753 else 1759 else
1754 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1760 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1755 setCaption(mes); 1761 setCaption(mes);
1756 } 1762 }
1757 } 1763 }
1758 1764
1759} 1765}
1760#include <qpushbutton.h> 1766#include <qpushbutton.h>
1761QString MainWindow::getPassword( ) 1767QString MainWindow::getPassword( )
1762{ 1768{
1763 QString retfile = ""; 1769 QString retfile = "";
1764 QDialog dia ( this, "input-dialog", true ); 1770 QDialog dia ( this, "input-dialog", true );
1765 QLineEdit lab ( &dia ); 1771 QLineEdit lab ( &dia );
1766 lab.setEchoMode( QLineEdit::Password ); 1772 lab.setEchoMode( QLineEdit::Password );
1767 QVBoxLayout lay( &dia ); 1773 QVBoxLayout lay( &dia );
1768 lay.setMargin(7); 1774 lay.setMargin(7);
1769 lay.setSpacing(7); 1775 lay.setSpacing(7);
1770 lay.addWidget( &lab); 1776 lay.addWidget( &lab);
1771 dia.setFixedSize( 230,50 ); 1777 dia.setFixedSize( 230,50 );
1772 dia.setCaption( i18n("Enter password") ); 1778 dia.setCaption( i18n("Enter password") );
1773 QPushButton pb ( "OK", &dia); 1779 QPushButton pb ( "OK", &dia);
1774 lay.addWidget( &pb ); 1780 lay.addWidget( &pb );
1775 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1781 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1776 dia.show(); 1782 dia.show();
1777 int res = dia.exec(); 1783 int res = dia.exec();
1778 if ( res ) 1784 if ( res )
1779 retfile = lab.text(); 1785 retfile = lab.text();
1780 dia.hide(); 1786 dia.hide();
1781 qApp->processEvents(); 1787 qApp->processEvents();
1782 return retfile; 1788 return retfile;
1783 1789
1784} 1790}
1785 1791
1786void MainWindow::syncLocalFile() 1792void MainWindow::syncLocalFile()
1787{ 1793{
1788 1794
1789 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1795 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1790 1796
1791 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1797 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1792 if ( fn == "" ) 1798 if ( fn == "" )
1793 return; 1799 return;
1794 //mView->setSyncDevice("local-file" ); 1800 //mView->setSyncDevice("local-file" );
1795 if ( syncWithFile( fn, false ) ) { 1801 if ( syncWithFile( fn, false ) ) {
1796 // Event* e = mView->getLastSyncEvent(); 1802 // Event* e = mView->getLastSyncEvent();
1797// e->setReadOnly( false ); 1803// e->setReadOnly( false );
1798// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1804// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1799// e->setReadOnly( true ); 1805// e->setReadOnly( true );
1800 } 1806 }
1801 1807
1802} 1808}
1803 1809
1804bool MainWindow::syncWithFile( QString fn , bool quick ) 1810bool MainWindow::syncWithFile( QString fn , bool quick )
1805{ 1811{
1806 bool ret = false; 1812 bool ret = false;
1807 QFileInfo info; 1813 QFileInfo info;
1808 info.setFile( fn ); 1814 info.setFile( fn );
1809 QString mess; 1815 QString mess;
1810 bool loadbup = true; 1816 bool loadbup = true;
1811 if ( !info. exists() ) { 1817 if ( !info. exists() ) {
1812 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1818 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1813 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1819 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1814 mess ); 1820 mess );
1815 return ret; 1821 return ret;
1816 } 1822 }
1817 int result = 0; 1823 int result = 0;
1818 if ( !quick ) { 1824 if ( !quick ) {
1819 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1825 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1820 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1826 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1821 mess, 1827 mess,
1822 i18n("Sync"), i18n("Cancel"), 0, 1828 i18n("Sync"), i18n("Cancel"), 0,
1823 0, 1 ); 1829 0, 1 );
1824 if ( result ) 1830 if ( result )
1825 return false; 1831 return false;
1826 } 1832 }
1827 if ( KOPrefs::instance()->mAskForPreferences ) 1833 if ( KOPrefs::instance()->mAskForPreferences )
1828 mView->edit_sync_options(); 1834 mView->edit_sync_options();
1829 if ( result == 0 ) { 1835 if ( result == 0 ) {
1830 //qDebug("Now sycing ... "); 1836 //qDebug("Now sycing ... ");
1831 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1837 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1832 setCaption( i18n("Synchronization successful") ); 1838 setCaption( i18n("Synchronization successful") );
1833 else 1839 else
1834 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1840 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1835 if ( ! quick ) 1841 if ( ! quick )
1836 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1842 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1837 slotModifiedChanged( true ); 1843 slotModifiedChanged( true );
1838 } 1844 }
1839 return ret; 1845 return ret;
1840} 1846}
1841void MainWindow::quickSyncLocalFile() 1847void MainWindow::quickSyncLocalFile()
1842{ 1848{
1843 //mView->setSyncDevice("local-file" ); 1849 //mView->setSyncDevice("local-file" );
1844 //qDebug("quickSyncLocalFile() "); 1850 //qDebug("quickSyncLocalFile() ");
1845 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1851 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1846 // Event* e = mView->getLastSyncEvent(); 1852 // Event* e = mView->getLastSyncEvent();
1847// e->setReadOnly( false ); 1853// e->setReadOnly( false );
1848// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1854// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1849// e->setReadOnly( true ); 1855// e->setReadOnly( true );
1850 1856
1851 } 1857 }
1852} 1858}
1853 1859
1854void MainWindow::confSync() 1860void MainWindow::confSync()
1855{ 1861{
1856 mView->confSync(); 1862 mView->confSync();
1857 fillSyncMenu(); 1863 fillSyncMenu();
1858 //mView->writeSettings(); 1864 //mView->writeSettings();
1859 1865
1860 1866
1861} 1867}
1862void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1868void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1863{ 1869{
1864 QString question; 1870 QString question;
1865 if ( ask ) { 1871 if ( ask ) {
1866 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1872 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1867 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1873 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1868 question, 1874 question,
1869 i18n("Yes"), i18n("No"), 1875 i18n("Yes"), i18n("No"),
1870 0, 0 ) != 0 ) 1876 0, 0 ) != 0 )
1871 return; 1877 return;
1872 } 1878 }
1873 QString command = prof->getPreSyncCommand(); 1879 QString command = prof->getPreSyncCommand();
1874 int fi; 1880 int fi;
1875 if ( (fi = command.find("$PWD$")) > 0 ) { 1881 if ( (fi = command.find("$PWD$")) > 0 ) {
1876 QString pwd = getPassword(); 1882 QString pwd = getPassword();
1877 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1883 command = command.left( fi )+ pwd + command.mid( fi+5 );
1878 1884
1879 } 1885 }
1880 int maxlen = 30; 1886 int maxlen = 30;
1881 if ( QApplication::desktop()->width() > 320 ) 1887 if ( QApplication::desktop()->width() > 320 )
1882 maxlen += 25; 1888 maxlen += 25;
1883 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1889 setCaption ( i18n( "Copy remote file to local machine..." ) );
1884 int fileSize = 0; 1890 int fileSize = 0;
1885 int result = system ( command ); 1891 int result = system ( command );
1886 // 0 : okay 1892 // 0 : okay
1887 // 256: no such file or dir 1893 // 256: no such file or dir
1888 // 1894 //
1889 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1895 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1890 if ( result != 0 ) { 1896 if ( result != 0 ) {
1891 int len = maxlen; 1897 int len = maxlen;
1892 while ( len < command.length() ) { 1898 while ( len < command.length() ) {
1893 command.insert( len , "\n" ); 1899 command.insert( len , "\n" );
1894 len += maxlen +2; 1900 len += maxlen +2;
1895 } 1901 }
1896 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1902 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1897 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1903 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1898 question, 1904 question,
1899 i18n("Okay!")) ; 1905 i18n("Okay!")) ;
1900 setCaption ("KO/Pi"); 1906 setCaption ("KO/Pi");
1901 return; 1907 return;
1902 } 1908 }
1903 setCaption ( i18n( "Copying succeed." ) ); 1909 setCaption ( i18n( "Copying succeed." ) );
1904 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1910 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1905 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1911 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1906// Event* e = mView->getLastSyncEvent(); 1912// Event* e = mView->getLastSyncEvent();
1907// e->setReadOnly( false ); 1913// e->setReadOnly( false );
1908// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1914// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1909// e->setReadOnly( true ); 1915// e->setReadOnly( true );
1910 if ( KOPrefs::instance()->mWriteBackFile ) { 1916 if ( KOPrefs::instance()->mWriteBackFile ) {
1911 command = prof->getPostSyncCommand(); 1917 command = prof->getPostSyncCommand();
1912 setCaption ( i18n( "Writing back file ..." ) ); 1918 setCaption ( i18n( "Writing back file ..." ) );
1913 result = system ( command ); 1919 result = system ( command );
1914 qDebug("KO: Writing back file result: %d ", result); 1920 qDebug("KO: Writing back file result: %d ", result);
1915 if ( result != 0 ) { 1921 if ( result != 0 ) {
1916 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1922 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1917 return; 1923 return;
1918 } else { 1924 } else {
1919 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1925 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1920 } 1926 }
1921 } 1927 }
1922 } 1928 }
1923 return; 1929 return;
1924} 1930}
1925void MainWindow::syncSSH() 1931void MainWindow::syncSSH()
1926{ 1932{
1927 // not used anymore 1933 // not used anymore
1928 QTime timer; 1934 QTime timer;
1929 timer.start(); 1935 timer.start();
1930 //qDebug("MainWindow::syncssh() "); 1936 //qDebug("MainWindow::syncssh() ");
1931 KOPrefs *p = KOPrefs::instance(); 1937 KOPrefs *p = KOPrefs::instance();
1932 QString localFile = p->mLocalTempFile; 1938 QString localFile = p->mLocalTempFile;
1933 QString remoteIP = p->mRemoteIP; 1939 QString remoteIP = p->mRemoteIP;
1934 QString remoteUser = p->mRemoteUser; 1940 QString remoteUser = p->mRemoteUser;
1935 QString remoteFile = p->mRemoteFile; 1941 QString remoteFile = p->mRemoteFile;
1936 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1942 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1937 remoteUser += ":" + p->mRemotePassWd; 1943 remoteUser += ":" + p->mRemotePassWd;
1938 1944
1939 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1945 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1940 i18n("IP: " ) +remoteIP +"\n" + 1946 i18n("IP: " ) +remoteIP +"\n" +
1941 i18n("User: " ) + remoteUser +"\n" ; 1947 i18n("User: " ) + remoteUser +"\n" ;
1942 int maxlen = 30; 1948 int maxlen = 30;
1943 if ( QApplication::desktop()->width() > 320 ) 1949 if ( QApplication::desktop()->width() > 320 )
1944 maxlen += 25; 1950 maxlen += 25;
1945 if ( remoteFile.length() > maxlen ) 1951 if ( remoteFile.length() > maxlen )
1946 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1952 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1947 else 1953 else
1948 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1954 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1949 if ( localFile.length() > maxlen ) 1955 if ( localFile.length() > maxlen )
1950 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1956 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1951 else 1957 else
1952 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1958 question += i18n("Local temp file:\n " ) + localFile +"\n";
1953 1959
1954 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1960 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1955 question, 1961 question,
1956 i18n("Yes"), i18n("No"), 1962 i18n("Yes"), i18n("No"),
1957 0, 0 ) != 0 ) 1963 0, 0 ) != 0 )
1958 return; 1964 return;
1959 // if ( !p->mUsePassWd ) { 1965 // if ( !p->mUsePassWd ) {
1960 // QString pass = getPassword(); 1966 // QString pass = getPassword();
1961 // if ( pass.length() > 0 ) 1967 // if ( pass.length() > 0 )
1962 // remoteUser += ":" + pass; 1968 // remoteUser += ":" + pass;
1963 // } 1969 // }
1964 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1970 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1965 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1971 setCaption ( i18n( "Copy remote file to local machine..." ) );
1966 int fileSize = 0; 1972 int fileSize = 0;
1967 int result = system ( command ); 1973 int result = system ( command );
1968 // 0 : okay 1974 // 0 : okay
1969 // 256: no such file or dir 1975 // 256: no such file or dir
1970 // 1976 //
1971 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1977 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1972 if ( result != 0 ) { 1978 if ( result != 0 ) {
1973 int len = maxlen; 1979 int len = maxlen;
1974 while ( len < command.length() ) { 1980 while ( len < command.length() ) {
1975 command.insert( len , "\n" ); 1981 command.insert( len , "\n" );
1976 len += maxlen +2; 1982 len += maxlen +2;
1977 } 1983 }
1978 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1984 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1979 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1985 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1980 question, 1986 question,
1981 i18n("Okay!")) ; 1987 i18n("Okay!")) ;
1982 setCaption ("KO/Pi"); 1988 setCaption ("KO/Pi");
1983 return; 1989 return;
1984 } 1990 }
1985 1991
1986 1992
1987 setCaption ( i18n( "Copying succeed." ) ); 1993 setCaption ( i18n( "Copying succeed." ) );
1988 //mView->setSyncDevice("ssh-scp" ); 1994 //mView->setSyncDevice("ssh-scp" );
1989 if ( syncWithFile(localFile , true ) ) { 1995 if ( syncWithFile(localFile , true ) ) {
1990// Event* e = mView->getLastSyncEvent(); 1996// Event* e = mView->getLastSyncEvent();
1991// e->setReadOnly( false ); 1997// e->setReadOnly( false );
1992// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1998// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1993// e->setReadOnly( true ); 1999// e->setReadOnly( true );
1994 if ( KOPrefs::instance()->mWriteBackFile ) { 2000 if ( KOPrefs::instance()->mWriteBackFile ) {
1995 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2001 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
1996 setCaption ( i18n( "Writing back file ..." ) ); 2002 setCaption ( i18n( "Writing back file ..." ) );
1997 result = system ( command ); 2003 result = system ( command );
1998 if ( result != 0 ) { 2004 if ( result != 0 ) {
1999 int len = maxlen; 2005 int len = maxlen;
2000 while ( len < command.length() ) { 2006 while ( len < command.length() ) {
2001 command.insert( len , "\n" ); 2007 command.insert( len , "\n" );
2002 len += maxlen +2; 2008 len += maxlen +2;
2003 } 2009 }
2004 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2010 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2005 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2011 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2006 question, 2012 question,
2007 i18n("Okay!")) ; 2013 i18n("Okay!")) ;
2008 setCaption ("KO/Pi"); 2014 setCaption ("KO/Pi");
2009 return; 2015 return;
2010 } else { 2016 } else {
2011 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2017 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2012 } 2018 }
2013 } 2019 }
2014 } 2020 }
2015 return; 2021 return;
2016#if 0 2022#if 0
2017 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2023 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2018 while ( timer.elapsed() < 5000 ) 2024 while ( timer.elapsed() < 5000 )
2019 qApp->processEvents(); 2025 qApp->processEvents();
2020 2026
2021 qDebug("MainWindow::merging) "); 2027 qDebug("MainWindow::merging) ");
2022 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2028 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2023 while ( mBlockSaveFlag ) 2029 while ( mBlockSaveFlag )
2024 qApp->processEvents(); 2030 qApp->processEvents();
2025 save(); 2031 save();
2026 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2032 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2027#endif 2033#endif
2028 2034
2029} 2035}
2030 2036
2031 2037
2032void MainWindow::syncSharp() 2038void MainWindow::syncSharp()
2033{ 2039{
2034 if ( mCalendarModifiedFlag ) 2040 if ( mCalendarModifiedFlag )
2035 save(); 2041 save();
2036 mView->syncSharp(); 2042 mView->syncSharp();
2037 slotModifiedChanged( true ); 2043 slotModifiedChanged( true );
2038 2044
2039} 2045}
2046void MainWindow::syncPhone()
2047{
2048 if ( mCalendarModifiedFlag )
2049 save();
2050 mView->syncPhone();
2051 slotModifiedChanged( true );
2052
2053}
2040 2054
2041void MainWindow::printSel( ) 2055void MainWindow::printSel( )
2042{ 2056{
2043 mView->viewManager()->agendaView()->agenda()->printSelection(); 2057 mView->viewManager()->agendaView()->agenda()->printSelection();
2044} 2058}
2045 2059
2046void MainWindow::printCal() 2060void MainWindow::printCal()
2047{ 2061{
2048 mView->print();//mCp->showDialog(); 2062 mView->print();//mCp->showDialog();
2049} 2063}
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index fba8c52..1d87db0 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -1,120 +1,121 @@
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 7
8#include <libkcal/incidence.h> 8#include <libkcal/incidence.h>
9#include "simplealarmclient.h" 9#include "simplealarmclient.h"
10 10
11class QAction; 11class QAction;
12class CalendarView; 12class CalendarView;
13class KSyncProfile; 13class KSyncProfile;
14#ifdef DESKTOP_VERSION 14#ifdef DESKTOP_VERSION
15 15
16#define QPEToolBar QToolBar 16#define QPEToolBar QToolBar
17#define QPEMenuBar QMenuBar 17#define QPEMenuBar QMenuBar
18#endif 18#endif
19class QPEToolBar; 19class QPEToolBar;
20 20
21namespace KCal { 21namespace KCal {
22class CalendarLocal; 22class CalendarLocal;
23} 23}
24 24
25using namespace KCal; 25using namespace KCal;
26 26
27class MainWindow : public QMainWindow 27class MainWindow : public QMainWindow
28{ 28{
29 Q_OBJECT 29 Q_OBJECT
30 public: 30 public:
31 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); 31 MainWindow( QWidget *parent = 0, const char *name = 0, QString command = "");
32 ~MainWindow(); 32 ~MainWindow();
33 public slots: 33 public slots:
34 void configureAgenda( int ); 34 void configureAgenda( int );
35 void recieve( const QCString& msg, const QByteArray& data ); 35 void recieve( const QCString& msg, const QByteArray& data );
36 static QString defaultFileName(); 36 static QString defaultFileName();
37 static QString resourcePath(); 37 static QString resourcePath();
38 protected slots: 38 protected slots:
39 void setCaptionToDates(); 39 void setCaptionToDates();
40 int ringSync(); 40 int ringSync();
41 void multiSync( bool askforPrefs = false ); 41 void multiSync( bool askforPrefs = false );
42 void about(); 42 void about();
43 void licence(); 43 void licence();
44 void faq(); 44 void faq();
45 void usertrans(); 45 void usertrans();
46 void features(); 46 void features();
47 void synchowto(); 47 void synchowto();
48 void whatsNew(); 48 void whatsNew();
49 void keyBindings(); 49 void keyBindings();
50 void aboutAutoSaving();; 50 void aboutAutoSaving();;
51 void aboutKnownBugs(); 51 void aboutKnownBugs();
52 52
53 void processIncidenceSelection( Incidence * ); 53 void processIncidenceSelection( Incidence * );
54 54
55 void importQtopia(); 55 void importQtopia();
56 void importBday(); 56 void importBday();
57 void importOL(); 57 void importOL();
58 void importIcal(); 58 void importIcal();
59 void importFile( QString, bool ); 59 void importFile( QString, bool );
60 void quickImportIcal(); 60 void quickImportIcal();
61 61
62 void slotModifiedChanged( bool ); 62 void slotModifiedChanged( bool );
63 63
64 void save(); 64 void save();
65 void configureToolBar( int ); 65 void configureToolBar( int );
66 void printSel(); 66 void printSel();
67 void printCal(); 67 void printCal();
68 void saveCalendar(); 68 void saveCalendar();
69 void loadCalendar(); 69 void loadCalendar();
70 void exportVCalendar(); 70 void exportVCalendar();
71 void fillFilterMenu(); 71 void fillFilterMenu();
72 void selectFilter( int ); 72 void selectFilter( int );
73 73
74 void slotSyncMenu( int ); 74 void slotSyncMenu( int );
75 void syncSSH(); 75 void syncSSH();
76 void confSync(); 76 void confSync();
77 void syncSharp(); 77 void syncSharp();
78 void syncPhone();
78 void syncLocalFile(); 79 void syncLocalFile();
79 bool syncWithFile( QString, bool ); 80 bool syncWithFile( QString, bool );
80 void quickSyncLocalFile(); 81 void quickSyncLocalFile();
81 82
82 83
83 protected: 84 protected:
84 void displayText( QString, QString); 85 void displayText( QString, QString);
85 void displayFile( QString, QString); 86 void displayFile( QString, QString);
86 87
87 void enableIncidenceActions( bool ); 88 void enableIncidenceActions( bool );
88 89
89 private: 90 private:
90 void saveOnClose(); 91 void saveOnClose();
91 int mCurrentSyncProfile; 92 int mCurrentSyncProfile;
92 void syncRemote( KSyncProfile* , bool ask = true); 93 void syncRemote( KSyncProfile* , bool ask = true);
93 void fillSyncMenu(); 94 void fillSyncMenu();
94 bool mFlagKeyPressed; 95 bool mFlagKeyPressed;
95 bool mBlockAtStartup; 96 bool mBlockAtStartup;
96 QPEToolBar *iconToolBar; 97 QPEToolBar *iconToolBar;
97 void initActions(); 98 void initActions();
98 void setDefaultPreferences(); 99 void setDefaultPreferences();
99 void keyPressEvent ( QKeyEvent * ) ; 100 void keyPressEvent ( QKeyEvent * ) ;
100 void keyReleaseEvent ( QKeyEvent * ) ; 101 void keyReleaseEvent ( QKeyEvent * ) ;
101 QPopupMenu *configureToolBarMenu; 102 QPopupMenu *configureToolBarMenu;
102 QPopupMenu *selectFilterMenu; 103 QPopupMenu *selectFilterMenu;
103 QPopupMenu *configureAgendaMenu, *syncMenu; 104 QPopupMenu *configureAgendaMenu, *syncMenu;
104 CalendarLocal *mCalendar; 105 CalendarLocal *mCalendar;
105 CalendarView *mView; 106 CalendarView *mView;
106 QString getPassword(); 107 QString getPassword();
107 QAction *mNewSubTodoAction; 108 QAction *mNewSubTodoAction;
108 109
109 QAction *mShowAction; 110 QAction *mShowAction;
110 QAction *mEditAction; 111 QAction *mEditAction;
111 QAction *mDeleteAction; 112 QAction *mDeleteAction;
112 void closeEvent( QCloseEvent* ce ); 113 void closeEvent( QCloseEvent* ce );
113 SimpleAlarmClient mAlarmClient; 114 SimpleAlarmClient mAlarmClient;
114 QTimer mSaveTimer; 115 QTimer mSaveTimer;
115 bool mBlockSaveFlag; 116 bool mBlockSaveFlag;
116 bool mCalendarModifiedFlag; 117 bool mCalendarModifiedFlag;
117 QPixmap loadPixmap( QString ); 118 QPixmap loadPixmap( QString );
118}; 119};
119 120
120#endif 121#endif
diff --git a/libkdepim/ksyncprofile.cpp b/libkdepim/ksyncprofile.cpp
index 15dc152..e7c35fb 100644
--- a/libkdepim/ksyncprofile.cpp
+++ b/libkdepim/ksyncprofile.cpp
@@ -1,191 +1,186 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include <qcolor.h> 23#include <qcolor.h>
24 24
25#include <kconfig.h> 25#include <kconfig.h>
26#include <kstandarddirs.h> 26#include <kstandarddirs.h>
27#include <kglobal.h> 27#include <kglobal.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "ksyncprofile.h" 30#include "ksyncprofile.h"
31 31
32 32
33KSyncProfile::KSyncProfile( const char * identifier): QObject (0, identifier ) 33KSyncProfile::KSyncProfile(): QObject ()
34{ 34{
35 setIdentifier( identifier );
36
37 if (getIdentifier().isEmpty())
38 setIdentifier( "noID" );
39
40 setDefault(); 35 setDefault();
41} 36}
42KSyncProfile::~KSyncProfile() 37KSyncProfile::~KSyncProfile()
43{ 38{
44 39
45} 40}
46 41
47 42
48KSyncProfile* KSyncProfile::clone() 43KSyncProfile* KSyncProfile::clone()
49{ 44{
50 KSyncProfile* myClone = new KSyncProfile(); 45 KSyncProfile* myClone = new KSyncProfile();
51 myClone->setPreSyncCommand( mPreSyncCommand ); 46 myClone->setPreSyncCommand( mPreSyncCommand );
52 myClone->setPostSyncCommand( mPostSyncCommand ); 47 myClone->setPostSyncCommand( mPostSyncCommand );
53 myClone->setLocalTempFile( mLocalTempFile); 48 myClone->setLocalTempFile( mLocalTempFile);
54 myClone->setRemoteFileName( mRemoteFileName ); 49 myClone->setRemoteFileName( mRemoteFileName );
55 myClone->setPreSyncCommandAB( mPreSyncCommandAB ); 50 myClone->setPreSyncCommandAB( mPreSyncCommandAB );
56 myClone->setPostSyncCommandAB( mPostSyncCommandAB ); 51 myClone->setPostSyncCommandAB( mPostSyncCommandAB );
57 myClone->setLocalTempFileAB( mLocalTempFileAB); 52 myClone->setLocalTempFileAB( mLocalTempFileAB);
58 myClone->setRemoteFileNameAB( mRemoteFileNameAB ); 53 myClone->setRemoteFileNameAB( mRemoteFileNameAB );
59 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync ); 54 myClone->setShowSummaryAfterSync( mShowSummaryAfterSync );
60 myClone->setAskForPreferences( mAskForPreferences); 55 myClone->setAskForPreferences( mAskForPreferences);
61 myClone->setWriteBackExisting(mWriteBackExisting ); 56 myClone->setWriteBackExisting(mWriteBackExisting );
62 myClone->setWriteBackFile( mWriteBackFile); 57 myClone->setWriteBackFile( mWriteBackFile);
63 myClone->setWriteBackFuture( mWriteBackFuture ); 58 myClone->setWriteBackFuture( mWriteBackFuture );
64 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks ); 59 myClone->setWriteBackFutureWeeks( mWriteBackFutureWeeks );
65 myClone->setIncludeInRingSync( mIncludeInRingSync ); 60 myClone->setIncludeInRingSync( mIncludeInRingSync );
66 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB ); 61 myClone->setIncludeInRingSyncAB( mIncludeInRingSyncAB );
67 myClone->setSyncPrefs( mSyncPrefs); 62 myClone->setSyncPrefs( mSyncPrefs);
68 myClone->setIsLocalFileSync( mIsLocalFileSync ); 63 myClone->setIsLocalFileSync( mIsLocalFileSync );
69 myClone->setIsPhoneSync( mIsPhoneSync ); 64 myClone->setIsPhoneSync( mIsPhoneSync );
70 myClone->setName( "noName" ); 65 myClone->setName( "noName" );
71 myClone->setIdentifier( "noID" ); 66 //myClone->setIdentifier( "noID" );
72 return myClone; 67 return myClone;
73} 68}
74 69
75 70
76void KSyncProfile::setDefault() 71void KSyncProfile::setDefault()
77{ 72{
78 mPreSyncCommand = i18n("command for downloading remote file to local device"); 73 mPreSyncCommand = i18n("command for downloading remote file to local device");
79 mPostSyncCommand = i18n("command for uploading local temp file to remote device"); 74 mPostSyncCommand = i18n("command for uploading local temp file to remote device");
80 mLocalTempFile = "/tmp/mycalendar.ics"; 75 mLocalTempFile = "/tmp/mycalendar.ics";
81 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics"; 76 mRemoteFileName = "/home/polo/kdepim/apps/korganizer/localfile.ics";
82 mPreSyncCommandAB = i18n("command for downloading remote file to local device"); 77 mPreSyncCommandAB = i18n("command for downloading remote file to local device");
83 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device"); 78 mPostSyncCommandAB = i18n("command for uploading local temp file to remote device");
84 mLocalTempFileAB = "/tmp/std.vcf"; 79 mLocalTempFileAB = "/tmp/std.vcf";
85 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf"; 80 mRemoteFileNameAB = "/home/polo/kdepim/apps/kabc/localfile.vcf";
86 mShowSummaryAfterSync = true; 81 mShowSummaryAfterSync = true;
87 mAskForPreferences = true; 82 mAskForPreferences = true;
88 mWriteBackExisting = false; 83 mWriteBackExisting = false;
89 mWriteBackFuture = false; 84 mWriteBackFuture = false;
90 mWriteBackFutureWeeks = 12; 85 mWriteBackFutureWeeks = 12;
91 mWriteBackFile = true; 86 mWriteBackFile = true;
92 mIncludeInRingSync = false; 87 mIncludeInRingSync = false;
93 mIncludeInRingSyncAB = false; 88 mIncludeInRingSyncAB = false;
94 mSyncPrefs = SYNC_PREF_ASK; 89 mSyncPrefs = SYNC_PREF_ASK;
95 mIsLocalFileSync = true; 90 mIsLocalFileSync = true;
96 mName = "noName"; 91 mName = "noName";
97 mIsPhoneSync = false; 92 mIsPhoneSync = false;
98 mPhoneDevice = "/dev/ircomm"; 93 mPhoneDevice = "/dev/ircomm";
99 mPhoneConnection = "irda"; 94 mPhoneConnection = "irda";
100 mPhoneModel = "6310i"; 95 mPhoneModel = "6310i";
101} 96}
102void KSyncProfile::readConfig(KConfig *config ) 97void KSyncProfile::readConfig(KConfig *config )
103{ 98{
104 if (config) 99 if (config)
105 { 100 {
106 101
107 config->setGroup("SyncProfile_" + mIdentifier); 102 config->setGroup( mName );
108 103
109 mName = config->readEntry( "Name", mName ); 104 mName = config->readEntry( "Name", mName );
110 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand ); 105 mPreSyncCommand = config->readEntry( "PreSyncCommand",mPreSyncCommand );
111 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand ); 106 mPostSyncCommand = config->readEntry( "PostSyncCommand", mPostSyncCommand );
112 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile ); 107 mLocalTempFile = config->readEntry( "LocalTempFile", mLocalTempFile );
113 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName ); 108 mRemoteFileName = config->readEntry( "RemoteFileName", mRemoteFileName );
114 109
115 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 110 mPreSyncCommandAB = config->readEntry( "PreSyncCommandAB",mPreSyncCommandAB );
116 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 111 mPostSyncCommandAB = config->readEntry( "PostSyncCommandAB", mPostSyncCommandAB );
117 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB ); 112 mLocalTempFileAB = config->readEntry( "LocalTempFileAB", mLocalTempFileAB );
118 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 113 mRemoteFileNameAB = config->readEntry( "RemoteFileNameAB", mRemoteFileNameAB );
119 114
120 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice ); 115 mPhoneDevice = config->readEntry( "PhoneDevice", mPhoneDevice );
121 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection ); 116 mPhoneConnection = config->readEntry( "PhoneConnection", mPhoneConnection );
122 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel ); 117 mPhoneModel = config->readEntry( "PhoneModel", mPhoneModel );
123 118
124 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync ); 119 mIncludeInRingSync = config->readBoolEntry( "IncludeInRingSync",mIncludeInRingSync );
125 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 120 mIncludeInRingSyncAB = config->readBoolEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
126 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 121 mShowSummaryAfterSync = config->readBoolEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
127 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences ); 122 mAskForPreferences = config->readBoolEntry( "AskForPreferences",mAskForPreferences );
128 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting ); 123 mWriteBackExisting = config->readBoolEntry( "WriteBackExisting",mWriteBackExisting );
129 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture ); 124 mWriteBackFuture = config->readBoolEntry( "WriteBackFuture",mWriteBackFuture );
130 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs ); 125 mSyncPrefs = config->readNumEntry( "SyncPrefs", mSyncPrefs );
131 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks ); 126 mWriteBackFutureWeeks = config->readNumEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks );
132 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync ); 127 mIsLocalFileSync= config->readBoolEntry( "IsLocalFileSync", mIsLocalFileSync );
133 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync ); 128 mIsPhoneSync= config->readBoolEntry( "IsPhoneSync", mIsPhoneSync );
134 } 129 }
135 else 130 else
136 { 131 {
137 setDefault(); 132 setDefault();
138 } 133 }
139} 134}
140 135
141void KSyncProfile::deleteConfig(KConfig *config ) 136void KSyncProfile::deleteConfig(KConfig *config )
142{ 137{
143 config->deleteGroup( "SyncProfile_" + mIdentifier ); 138 config->deleteGroup( mName );
144} 139}
145 140
146void KSyncProfile::writeConfig( KConfig * config ) 141void KSyncProfile::writeConfig( KConfig * config )
147{ 142{
148 config->setGroup("SyncProfile_" + mIdentifier); 143 config->setGroup(mName);
149 144
150 config->writeEntry( "Name", mName ); 145 config->writeEntry( "Name", mName );
151 config->writeEntry( "PreSyncCommand",mPreSyncCommand ); 146 config->writeEntry( "PreSyncCommand",mPreSyncCommand );
152 config->writeEntry( "PostSyncCommand", mPostSyncCommand ); 147 config->writeEntry( "PostSyncCommand", mPostSyncCommand );
153 config->writeEntry( "LocalTempFile", mLocalTempFile ); 148 config->writeEntry( "LocalTempFile", mLocalTempFile );
154 config->writeEntry( "RemoteFileName", mRemoteFileName ); 149 config->writeEntry( "RemoteFileName", mRemoteFileName );
155 150
156 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB ); 151 config->writeEntry( "PreSyncCommandAB",mPreSyncCommandAB );
157 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB ); 152 config->writeEntry( "PostSyncCommandAB", mPostSyncCommandAB );
158 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB ); 153 config->writeEntry( "LocalTempFileAB", mLocalTempFileAB );
159 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB ); 154 config->writeEntry( "RemoteFileNameAB", mRemoteFileNameAB );
160 155
161 config->writeEntry( "PhoneDevice", mPhoneDevice ); 156 config->writeEntry( "PhoneDevice", mPhoneDevice );
162 config->writeEntry( "PhoneConnection", mPhoneConnection ); 157 config->writeEntry( "PhoneConnection", mPhoneConnection );
163 config->writeEntry( "PhoneModel", mPhoneModel ); 158 config->writeEntry( "PhoneModel", mPhoneModel );
164 159
165 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync ); 160 config->writeEntry( "IncludeInRingSync",mIncludeInRingSync );
166 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB ); 161 config->writeEntry( "IncludeInRingSyncAB",mIncludeInRingSyncAB );
167 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync ); 162 config->writeEntry( "ShowSummaryAfterSync", mShowSummaryAfterSync );
168 config->writeEntry( "AskForPreferences",mAskForPreferences ); 163 config->writeEntry( "AskForPreferences",mAskForPreferences );
169 config->writeEntry( "WriteBackExisting",mWriteBackExisting ); 164 config->writeEntry( "WriteBackExisting",mWriteBackExisting );
170 config->writeEntry( "WriteBackFuture",mWriteBackFuture ); 165 config->writeEntry( "WriteBackFuture",mWriteBackFuture );
171 config->writeEntry( "SyncPrefs", mSyncPrefs ); 166 config->writeEntry( "SyncPrefs", mSyncPrefs );
172 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks); 167 config->writeEntry( "WriteBackFutureWeeks", mWriteBackFutureWeeks);
173 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync ); 168 config->writeEntry( "IsLocalFileSync", mIsLocalFileSync );
174 config->writeEntry( "IsPhoneSync", mIsPhoneSync ); 169 config->writeEntry( "IsPhoneSync", mIsPhoneSync );
175} 170}
176 171
177/* 172/*
178class KPrefsItemInt : public KPrefsItem { 173class KPrefsItemInt : public KPrefsItem {
179 public: 174 public:
180 KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); 175 KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
181 virtual ~KPrefsItemInt() {} 176 virtual ~KPrefsItemInt() {}
182 177
183 void setDefault(); 178 void setDefault();
184 void readConfig(KConfig *); 179 void readConfig(KConfig *);
185 void writeConfig(KConfig *); 180 void writeConfig(KConfig *);
186 181
187 private: 182 private:
188 int *mReference; 183 int *mReference;
189 int mDefault; 184 int mDefault;
190}; 185};
191*/ 186*/
diff --git a/libkdepim/ksyncprofile.h b/libkdepim/ksyncprofile.h
index 8995def..a0cfb71 100644
--- a/libkdepim/ksyncprofile.h
+++ b/libkdepim/ksyncprofile.h
@@ -1,142 +1,139 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KSYNCPROFILE_H 20#ifndef _KSYNCPROFILE_H
21#define _KSYNCPROFILE_H 21#define _KSYNCPROFILE_H
22 22
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qcolor.h> 24#include <qcolor.h>
25#include <qfont.h> 25#include <qfont.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qobject.h> 27#include <qobject.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <libkcal/syncdefines.h> 30#include <libkcal/syncdefines.h>
31 31
32 32
33 33
34class KConfig; 34class KConfig;
35 35
36/** 36/**
37 @short Class for storing a preferences setting 37 @short Class for storing a preferences setting
38 @author Cornelius Schumacher 38 @author Cornelius Schumacher
39 @see KPref 39 @see KPref
40 40
41 This class represents one preferences setting as used by @ref KPrefs. 41 This class represents one preferences setting as used by @ref KPrefs.
42 Subclasses of KPrefsItem implement storage functions for a certain type of 42 Subclasses of KPrefsItem implement storage functions for a certain type of
43 setting. Normally you don't have to use this class directly. Use the special 43 setting. Normally you don't have to use this class directly. Use the special
44 addItem() functions of KPrefs instead. If you subclass this class you will 44 addItem() functions of KPrefs instead. If you subclass this class you will
45 have to register instances with the function KPrefs::addItem(). 45 have to register instances with the function KPrefs::addItem().
46*/ 46*/
47class KSyncProfile : public QObject { 47class KSyncProfile : public QObject {
48 public: 48 public:
49 KSyncProfile( const char * identifier = 0); 49 KSyncProfile();
50 ~KSyncProfile() ; 50 ~KSyncProfile() ;
51 51
52 KSyncProfile* clone(); 52 KSyncProfile* clone();
53 void setDefault(); 53 void setDefault();
54 void readConfig(KConfig *); 54 void readConfig(KConfig *);
55 void writeConfig(KConfig *); 55 void writeConfig(KConfig *);
56 void deleteConfig(KConfig *); 56 void deleteConfig(KConfig *);
57 57
58 void setIdentifier( const QString& i ) {mIdentifier = i;}
59 QString getIdentifier( ) { return mIdentifier;}
60 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;} 58 void setPreSyncCommand( const QString& n ) {mPreSyncCommand = n;}
61 QString getPreSyncCommand( ) { return mPreSyncCommand; } 59 QString getPreSyncCommand( ) { return mPreSyncCommand; }
62 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;} 60 void setPostSyncCommand( const QString& n ) {mPostSyncCommand = n;}
63 QString getPostSyncCommand( ) { return mPostSyncCommand;} 61 QString getPostSyncCommand( ) { return mPostSyncCommand;}
64 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;} 62 void setLocalTempFile( const QString& n ) { mLocalTempFile= n;}
65 QString getLocalTempFile( ) { return mLocalTempFile;} 63 QString getLocalTempFile( ) { return mLocalTempFile;}
66 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;} 64 void setRemoteFileName( const QString& n ) { mRemoteFileName = n;}
67 QString getRemoteFileName( ) { return mRemoteFileName;} 65 QString getRemoteFileName( ) { return mRemoteFileName;}
68 66
69 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;} 67 void setPreSyncCommandAB( const QString& n ) {mPreSyncCommandAB = n;}
70 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; } 68 QString getPreSyncCommandAB( ) { return mPreSyncCommandAB; }
71 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;} 69 void setPostSyncCommandAB( const QString& n ) {mPostSyncCommandAB = n;}
72 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;} 70 QString getPostSyncCommandAB( ) { return mPostSyncCommandAB;}
73 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;} 71 void setLocalTempFileAB( const QString& n ) { mLocalTempFileAB= n;}
74 QString getLocalTempFileAB( ) { return mLocalTempFileAB;} 72 QString getLocalTempFileAB( ) { return mLocalTempFileAB;}
75 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;} 73 void setRemoteFileNameAB( const QString& n ) { mRemoteFileNameAB = n;}
76 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;} 74 QString getRemoteFileNameAB( ) { return mRemoteFileNameAB;}
77 75
78 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;} 76 void setPhoneDevice( const QString& n ) { mPhoneDevice = n;}
79 QString getPhoneDevice( ) { return mPhoneDevice;} 77 QString getPhoneDevice( ) { return mPhoneDevice;}
80 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;} 78 void setPhoneConnection( const QString& n ) { mPhoneConnection = n;}
81 QString getPhoneConnection( ) { return mPhoneConnection;} 79 QString getPhoneConnection( ) { return mPhoneConnection;}
82 void setPhoneModel( const QString& n ) { mPhoneModel = n;} 80 void setPhoneModel( const QString& n ) { mPhoneModel = n;}
83 QString getPhoneModel( ) { return mPhoneModel;} 81 QString getPhoneModel( ) { return mPhoneModel;}
84 /* 82 /*
85 void set( const QString& n ) { = n;} 83 void set( const QString& n ) { = n;}
86 QString get( ) { return ;} 84 QString get( ) { return ;}
87 */ 85 */
88 86
89 void setName( const QString& n ) {mName = n;} 87 void setName( const QString& n ) {mName = n;}
90 QString getName( ) { return mName;} 88 QString getName( ) { return mName;}
91 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;} 89 void setShowSummaryAfterSync( bool b ) { mShowSummaryAfterSync = b;}
92 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;} 90 bool getShowSummaryAfterSync( ) { return mShowSummaryAfterSync ;}
93 void setAskForPreferences( bool b ) { mAskForPreferences= b;} 91 void setAskForPreferences( bool b ) { mAskForPreferences= b;}
94 bool getAskForPreferences( ) { return mAskForPreferences;} 92 bool getAskForPreferences( ) { return mAskForPreferences;}
95 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;} 93 void setWriteBackExisting( bool b ) { mWriteBackExisting = b;}
96 bool getWriteBackExisting( ) { return mWriteBackExisting;} 94 bool getWriteBackExisting( ) { return mWriteBackExisting;}
97 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;} 95 void setWriteBackFuture( bool b ) { mWriteBackFuture = b;}
98 bool getWriteBackFuture( ) { return mWriteBackFuture;} 96 bool getWriteBackFuture( ) { return mWriteBackFuture;}
99 void setWriteBackFile( bool b ) { mWriteBackFile= b;} 97 void setWriteBackFile( bool b ) { mWriteBackFile= b;}
100 bool getWriteBackFile( ) { return mWriteBackFile;} 98 bool getWriteBackFile( ) { return mWriteBackFile;}
101 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;} 99 void setIncludeInRingSync( bool b ) {mIncludeInRingSync = b;}
102 bool getIncludeInRingSync( ) { return mIncludeInRingSync;} 100 bool getIncludeInRingSync( ) { return mIncludeInRingSync;}
103 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;} 101 void setIncludeInRingSyncAB( bool b ) {mIncludeInRingSyncAB = b;}
104 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;} 102 bool getIncludeInRingSyncAB( ) { return mIncludeInRingSyncAB;}
105 void setSyncPrefs( int n ) { mSyncPrefs= n;} 103 void setSyncPrefs( int n ) { mSyncPrefs= n;}
106 int getSyncPrefs( ) { return mSyncPrefs;} 104 int getSyncPrefs( ) { return mSyncPrefs;}
107 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;} 105 void setWriteBackFutureWeeks( int n ) { mWriteBackFutureWeeks= n;}
108 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;} 106 int getWriteBackFutureWeeks( ) { return mWriteBackFutureWeeks;}
109 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;} 107 void setIsLocalFileSync( bool b ) { mIsLocalFileSync= b;}
110 bool getIsLocalFileSync( ) { return mIsLocalFileSync;} 108 bool getIsLocalFileSync( ) { return mIsLocalFileSync;}
111 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;} 109 void setIsPhoneSync( bool b ) { mIsPhoneSync= b;}
112 bool getIsPhoneSync( ) { return mIsPhoneSync;} 110 bool getIsPhoneSync( ) { return mIsPhoneSync;}
113 private: 111 private:
114 QString mName; 112 QString mName;
115 QString mIdentifier;
116 QString mPreSyncCommand; 113 QString mPreSyncCommand;
117 QString mPostSyncCommand; 114 QString mPostSyncCommand;
118 QString mLocalTempFile; 115 QString mLocalTempFile;
119 QString mRemoteFileName; 116 QString mRemoteFileName;
120 QString mPreSyncCommandAB; 117 QString mPreSyncCommandAB;
121 QString mPostSyncCommandAB; 118 QString mPostSyncCommandAB;
122 QString mLocalTempFileAB; 119 QString mLocalTempFileAB;
123 QString mRemoteFileNameAB; 120 QString mRemoteFileNameAB;
124 121
125 QString mPhoneDevice; 122 QString mPhoneDevice;
126 QString mPhoneConnection; 123 QString mPhoneConnection;
127 QString mPhoneModel; 124 QString mPhoneModel;
128 125
129 bool mIncludeInRingSync; 126 bool mIncludeInRingSync;
130 bool mIncludeInRingSyncAB; 127 bool mIncludeInRingSyncAB;
131 int mSyncPrefs; 128 int mSyncPrefs;
132 bool mWriteBackFile; 129 bool mWriteBackFile;
133 bool mWriteBackExisting; 130 bool mWriteBackExisting;
134 bool mWriteBackFuture; 131 bool mWriteBackFuture;
135 int mWriteBackFutureWeeks; 132 int mWriteBackFutureWeeks;
136 bool mAskForPreferences; 133 bool mAskForPreferences;
137 bool mShowSummaryAfterSync; 134 bool mShowSummaryAfterSync;
138 bool mIsLocalFileSync; 135 bool mIsLocalFileSync;
139 bool mIsPhoneSync; 136 bool mIsPhoneSync;
140}; 137};
141 138
142#endif 139#endif