summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-16 10:26:46 (UTC)
committer zautrix <zautrix>2005-01-16 10:26:46 (UTC)
commit5138d4edea4189100ddc8bf6bd82bccbdcaebf95 (patch) (unidiff)
treec4ec0d0552d06065a1e9f8eb12c44fcbfdd19f4a
parent62ff81d5d292ddf3c6032b48f27a6daedf6a6cb0 (diff)
downloadkdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.zip
kdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.tar.gz
kdepimpi-5138d4edea4189100ddc8bf6bd82bccbdcaebf95.tar.bz2
filter setings changed
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp11
-rw-r--r--korganizer/filteredit_base.cpp73
-rw-r--r--korganizer/filteredit_base.h18
-rw-r--r--korganizer/filteredit_base.ui123
-rw-r--r--korganizer/korganizer.pro4
-rw-r--r--libkcal/calfilter.h2
-rw-r--r--libkdepim/ksyncmanager.cpp10
-rw-r--r--libkdepim/ksyncmanager.h4
8 files changed, 170 insertions, 75 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 378c7d4..8258c74 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3849 +1,3860 @@
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#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 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 ); 186 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 );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 269 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 271
272#ifdef KORG_NORESOURCEVIEW 272#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 273 mResourceView = 0;
274#else 274#else
275 if ( mResourceManager ) { 275 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 277 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 278 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 279 SLOT( updateView() ) );
280 } else { 280 } else {
281 mResourceView = 0; 281 mResourceView = 0;
282 } 282 }
283#endif 283#endif
284 QWidget *rightBox = new QWidget( mPanner ); 284 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 286
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 288 rightLayout->addWidget( mNavigatorBar );
289 289
290 mRightFrame = new QWidgetStack( rightBox ); 290 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 291 rightLayout->addWidget( mRightFrame, 1 );
292 292
293 mLeftFrame = mLeftSplitter; 293 mLeftFrame = mLeftSplitter;
294#else 294#else
295 QWidget *mainBox = new QWidget( this ); 295 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 296 QWidget *leftFrame = new QWidget( mainBox );
297 297
298 QBoxLayout * mainBoxLayout; 298 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 299 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 300 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 301 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 302 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 303 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 304 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 305 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 306 }
307 topLayout->addWidget( mainBox ); 307 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 308 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 310 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 311 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 312 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 315 mTodoList->setNavigator( mNavigator );
316 316
317 if ( QApplication::desktop()->width() < 480 ) { 317 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 318 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 319 leftFrameLayout->addWidget(mTodoList, 2 );
320 320
321 } else { 321 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 322 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 323 leftFrameLayout->addWidget(mFilterView );
324 } 324 }
325 mFilterView->hide(); 325 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 326 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 327 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 330 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 331 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
333 333
334 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 338 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 341 }
342 342
343 //qDebug("Calendarview Size %d %d ", width(), height()); 343 //qDebug("Calendarview Size %d %d ", width(), height());
344#endif 344#endif
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 SLOT( showDates( const KCal::DateList & ) ) ); 347 SLOT( showDates( const KCal::DateList & ) ) );
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 351 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
352 mNavigator, SLOT( selectPreviousYear() ) ); 352 mNavigator, SLOT( selectPreviousYear() ) );
353 connect( mNavigatorBar, SIGNAL( goNextYear() ), 353 connect( mNavigatorBar, SIGNAL( goNextYear() ),
354 mNavigator, SLOT( selectNextYear() ) ); 354 mNavigator, SLOT( selectNextYear() ) );
355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
356 mNavigator, SLOT( selectPreviousMonth() ) ); 356 mNavigator, SLOT( selectPreviousMonth() ) );
357 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 357 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
358 mNavigator, SLOT( selectNextMonth() ) ); 358 mNavigator, SLOT( selectNextMonth() ) );
359 359
360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
362 362
363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
364 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 364 mNavigator, SLOT( selectWeek( const QDate & ) ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevYear() ), 366 connect( mDateNavigator, SIGNAL( goPrevYear() ),
367 mNavigator, SLOT( selectPreviousYear() ) ); 367 mNavigator, SLOT( selectPreviousYear() ) );
368 connect( mDateNavigator, SIGNAL( goNextYear() ), 368 connect( mDateNavigator, SIGNAL( goNextYear() ),
369 mNavigator, SLOT( selectNextYear() ) ); 369 mNavigator, SLOT( selectNextYear() ) );
370 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 370 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
371 mNavigator, SLOT( selectPreviousMonth() ) ); 371 mNavigator, SLOT( selectPreviousMonth() ) );
372 connect( mDateNavigator, SIGNAL( goNextMonth() ), 372 connect( mDateNavigator, SIGNAL( goNextMonth() ),
373 mNavigator, SLOT( selectNextMonth() ) ); 373 mNavigator, SLOT( selectNextMonth() ) );
374 374
375 connect( mDateNavigator, SIGNAL( goPrevious() ), 375 connect( mDateNavigator, SIGNAL( goPrevious() ),
376 mNavigator, SLOT( selectPrevious() ) ); 376 mNavigator, SLOT( selectPrevious() ) );
377 connect( mDateNavigator, SIGNAL( goNext() ), 377 connect( mDateNavigator, SIGNAL( goNext() ),
378 mNavigator, SLOT( selectNext() ) ); 378 mNavigator, SLOT( selectNext() ) );
379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 383
384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
386 386
387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
388 SLOT( eventAdded( Event *) ) ); 388 SLOT( eventAdded( Event *) ) );
389 389
390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
391 391
392 connect( this, SIGNAL( configChanged() ), 392 connect( this, SIGNAL( configChanged() ),
393 mDateNavigator, SLOT( updateConfig() ) ); 393 mDateNavigator, SLOT( updateConfig() ) );
394 394
395 connect( mTodoList, SIGNAL( newTodoSignal() ), 395 connect( mTodoList, SIGNAL( newTodoSignal() ),
396 SLOT( newTodo() ) ); 396 SLOT( newTodo() ) );
397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
398 SLOT( newSubTodo( Todo * ) ) ); 398 SLOT( newSubTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
400 SLOT( editTodo( Todo * ) ) ); 400 SLOT( editTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
402 SLOT( showTodo( Todo *) ) ); 402 SLOT( showTodo( Todo *) ) );
403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
404 SLOT( deleteTodo( Todo *) ) ); 404 SLOT( deleteTodo( Todo *) ) );
405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
407 SLOT( purgeCompleted() ) ); 407 SLOT( purgeCompleted() ) );
408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
409 SIGNAL( todoModified( Todo *, int ) ) ); 409 SIGNAL( todoModified( Todo *, int ) ) );
410 410
411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
412 this, SLOT ( cloneIncidence( Incidence * ) ) ); 412 this, SLOT ( cloneIncidence( Incidence * ) ) );
413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
414 this, SLOT (cancelIncidence( Incidence * ) ) ); 414 this, SLOT (cancelIncidence( Incidence * ) ) );
415 415
416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
417 this, SLOT ( moveIncidence( Incidence * ) ) ); 417 this, SLOT ( moveIncidence( Incidence * ) ) );
418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
419 this, SLOT ( beamIncidence( Incidence * ) ) ); 419 this, SLOT ( beamIncidence( Incidence * ) ) );
420 420
421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
422 this, SLOT ( todo_unsub( Todo * ) ) ); 422 this, SLOT ( todo_unsub( Todo * ) ) );
423 423
424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
425 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 425 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
427 SLOT( updateTodo( Todo *, int ) ) ); 427 SLOT( updateTodo( Todo *, int ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), this, 428 connect( this, SIGNAL( todoModified( Todo *, int )), this,
429 SLOT( changeTodoDisplay( Todo *, int ) ) ); 429 SLOT( changeTodoDisplay( Todo *, int ) ) );
430 430
431 431
432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
436 436
437 437
438 438
439 439
440 440
441 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 441 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
442 SLOT(checkClipboard())); 442 SLOT(checkClipboard()));
443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
444 SLOT( processTodoListSelection( Incidence * ) ) ); 444 SLOT( processTodoListSelection( Incidence * ) ) );
445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
446 446
447 // kdDebug() << "CalendarView::CalendarView() done" << endl; 447 // kdDebug() << "CalendarView::CalendarView() done" << endl;
448 448
449 mDateFrame = new QVBox(0,0,WType_Popup); 449 mDateFrame = new QVBox(0,0,WType_Popup);
450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
452 mDateFrame->setLineWidth(3); 452 mDateFrame->setLineWidth(3);
453 mDateFrame->hide(); 453 mDateFrame->hide();
454 mDateFrame->setCaption( i18n( "Pick a date to display")); 454 mDateFrame->setCaption( i18n( "Pick a date to display"));
455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
456 456
457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
458 458
459 mEventEditor = mDialogManager->getEventEditor(); 459 mEventEditor = mDialogManager->getEventEditor();
460 mTodoEditor = mDialogManager->getTodoEditor(); 460 mTodoEditor = mDialogManager->getTodoEditor();
461 461
462 mFlagEditDescription = false; 462 mFlagEditDescription = false;
463 463
464 mSuspendTimer = new QTimer( this ); 464 mSuspendTimer = new QTimer( this );
465 mAlarmTimer = new QTimer( this ); 465 mAlarmTimer = new QTimer( this );
466 mRecheckAlarmTimer = new QTimer( this ); 466 mRecheckAlarmTimer = new QTimer( this );
467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
470 mAlarmDialog = new AlarmDialog( this ); 470 mAlarmDialog = new AlarmDialog( this );
471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
472 mAlarmDialog->setServerNotification( false ); 472 mAlarmDialog->setServerNotification( false );
473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
474 474
475 475
476#ifndef DESKTOP_VERSION 476#ifndef DESKTOP_VERSION
477//US listen for arriving address resultsets 477//US listen for arriving address resultsets
478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
480#endif 480#endif
481 481
482} 482}
483 483
484 484
485CalendarView::~CalendarView() 485CalendarView::~CalendarView()
486{ 486{
487 // kdDebug() << "~CalendarView()" << endl; 487 // kdDebug() << "~CalendarView()" << endl;
488 //qDebug("CalendarView::~CalendarView() "); 488 //qDebug("CalendarView::~CalendarView() ");
489 delete mDialogManager; 489 delete mDialogManager;
490 delete mViewManager; 490 delete mViewManager;
491 delete mStorage; 491 delete mStorage;
492 delete mDateFrame ; 492 delete mDateFrame ;
493 delete beamDialog; 493 delete beamDialog;
494 //kdDebug() << "~CalendarView() done" << endl; 494 //kdDebug() << "~CalendarView() done" << endl;
495} 495}
496 496
497void CalendarView::showDay( QDate d ) 497void CalendarView::showDay( QDate d )
498{ 498{
499 dateNavigator()->selectDate( d ); 499 dateNavigator()->selectDate( d );
500 mViewManager->showWeekView(); 500 mViewManager->showWeekView();
501 dateNavigator()->selectDate( d ); 501 dateNavigator()->selectDate( d );
502} 502}
503void CalendarView::timerAlarm() 503void CalendarView::timerAlarm()
504{ 504{
505 //qDebug("CalendarView::timerAlarm() "); 505 //qDebug("CalendarView::timerAlarm() ");
506 computeAlarm(mAlarmNotification ); 506 computeAlarm(mAlarmNotification );
507} 507}
508 508
509void CalendarView::suspendAlarm() 509void CalendarView::suspendAlarm()
510{ 510{
511 //qDebug(" CalendarView::suspendAlarm() "); 511 //qDebug(" CalendarView::suspendAlarm() ");
512 computeAlarm(mSuspendAlarmNotification ); 512 computeAlarm(mSuspendAlarmNotification );
513 513
514} 514}
515 515
516void CalendarView::startAlarm( QString mess , QString filename) 516void CalendarView::startAlarm( QString mess , QString filename)
517{ 517{
518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
520 520
521} 521}
522 522
523void CalendarView::checkNextTimerAlarm() 523void CalendarView::checkNextTimerAlarm()
524{ 524{
525 mCalendar->checkAlarmForIncidence( 0, true ); 525 mCalendar->checkAlarmForIncidence( 0, true );
526} 526}
527 527
528void CalendarView::computeAlarm( QString msg ) 528void CalendarView::computeAlarm( QString msg )
529{ 529{
530 530
531 QString mess = msg; 531 QString mess = msg;
532 QString mAlarmMessage = mess.mid( 9 ); 532 QString mAlarmMessage = mess.mid( 9 );
533 QString filename = MainWindow::resourcePath(); 533 QString filename = MainWindow::resourcePath();
534 filename += "koalarm.wav"; 534 filename += "koalarm.wav";
535 QString tempfilename; 535 QString tempfilename;
536 if ( mess.left( 13 ) == "suspend_alarm") { 536 if ( mess.left( 13 ) == "suspend_alarm") {
537 bool error = false; 537 bool error = false;
538 int len = mess.mid( 13 ).find("+++"); 538 int len = mess.mid( 13 ).find("+++");
539 if ( len < 2 ) 539 if ( len < 2 )
540 error = true; 540 error = true;
541 else { 541 else {
542 tempfilename = mess.mid( 13, len ); 542 tempfilename = mess.mid( 13, len );
543 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
544 error = true; 544 error = true;
545 } 545 }
546 if ( ! error ) { 546 if ( ! error ) {
547 filename = tempfilename; 547 filename = tempfilename;
548 } 548 }
549 mAlarmMessage = mess.mid( 13+len+3 ); 549 mAlarmMessage = mess.mid( 13+len+3 );
550 //qDebug("suspend file %s ",tempfilename.latin1() ); 550 //qDebug("suspend file %s ",tempfilename.latin1() );
551 startAlarm( mAlarmMessage, filename); 551 startAlarm( mAlarmMessage, filename);
552 return; 552 return;
553 } 553 }
554 if ( mess.left( 11 ) == "timer_alarm") { 554 if ( mess.left( 11 ) == "timer_alarm") {
555 //mTimerTime = 0; 555 //mTimerTime = 0;
556 startAlarm( mess.mid( 11 ), filename ); 556 startAlarm( mess.mid( 11 ), filename );
557 return; 557 return;
558 } 558 }
559 if ( mess.left( 10 ) == "proc_alarm") { 559 if ( mess.left( 10 ) == "proc_alarm") {
560 bool error = false; 560 bool error = false;
561 int len = mess.mid( 10 ).find("+++"); 561 int len = mess.mid( 10 ).find("+++");
562 if ( len < 2 ) 562 if ( len < 2 )
563 error = true; 563 error = true;
564 else { 564 else {
565 tempfilename = mess.mid( 10, len ); 565 tempfilename = mess.mid( 10, len );
566 if ( !QFile::exists( tempfilename ) ) 566 if ( !QFile::exists( tempfilename ) )
567 error = true; 567 error = true;
568 } 568 }
569 if ( error ) { 569 if ( error ) {
570 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 570 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
571 mAlarmMessage += mess.mid( 10+len+3+9 ); 571 mAlarmMessage += mess.mid( 10+len+3+9 );
572 } else { 572 } else {
573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
574 //qDebug("-----system command %s ",tempfilename.latin1() ); 574 //qDebug("-----system command %s ",tempfilename.latin1() );
575#ifndef _WIN32_ 575#ifndef _WIN32_
576 if ( vfork () == 0 ) { 576 if ( vfork () == 0 ) {
577 execl ( tempfilename.latin1(), 0 ); 577 execl ( tempfilename.latin1(), 0 );
578 return; 578 return;
579 } 579 }
580#else 580#else
581 QProcess* p = new QProcess(); 581 QProcess* p = new QProcess();
582 p->addArgument( tempfilename.latin1() ); 582 p->addArgument( tempfilename.latin1() );
583 p->start(); 583 p->start();
584 return; 584 return;
585#endif 585#endif
586 586
587 return; 587 return;
588 } 588 }
589 589
590 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 590 //qDebug("+++++++system command %s ",tempfilename.latin1() );
591 } 591 }
592 if ( mess.left( 11 ) == "audio_alarm") { 592 if ( mess.left( 11 ) == "audio_alarm") {
593 bool error = false; 593 bool error = false;
594 int len = mess.mid( 11 ).find("+++"); 594 int len = mess.mid( 11 ).find("+++");
595 if ( len < 2 ) 595 if ( len < 2 )
596 error = true; 596 error = true;
597 else { 597 else {
598 tempfilename = mess.mid( 11, len ); 598 tempfilename = mess.mid( 11, len );
599 if ( !QFile::exists( tempfilename ) ) 599 if ( !QFile::exists( tempfilename ) )
600 error = true; 600 error = true;
601 } 601 }
602 if ( ! error ) { 602 if ( ! error ) {
603 filename = tempfilename; 603 filename = tempfilename;
604 } 604 }
605 mAlarmMessage = mess.mid( 11+len+3+9 ); 605 mAlarmMessage = mess.mid( 11+len+3+9 );
606 //qDebug("audio file command %s ",tempfilename.latin1() ); 606 //qDebug("audio file command %s ",tempfilename.latin1() );
607 } 607 }
608 if ( mess.left( 9 ) == "cal_alarm") { 608 if ( mess.left( 9 ) == "cal_alarm") {
609 mAlarmMessage = mess.mid( 9 ) ; 609 mAlarmMessage = mess.mid( 9 ) ;
610 } 610 }
611 611
612 startAlarm( mAlarmMessage, filename ); 612 startAlarm( mAlarmMessage, filename );
613 613
614 614
615} 615}
616 616
617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 620
621 mSuspendAlarmNotification = noti; 621 mSuspendAlarmNotification = noti;
622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
624 mSuspendTimer->start( ms , true ); 624 mSuspendTimer->start( ms , true );
625 625
626} 626}
627 627
628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
629{ 629{
630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
632#ifndef DESKTOP_VERSION 632#ifndef DESKTOP_VERSION
633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
634#endif 634#endif
635 return; 635 return;
636 } 636 }
637 int maxSec; 637 int maxSec;
638 //maxSec = 5; //testing only 638 //maxSec = 5; //testing only
639 maxSec = 86400+3600; // one day+1hour 639 maxSec = 86400+3600; // one day+1hour
640 mAlarmNotification = noti; 640 mAlarmNotification = noti;
641 int sec = QDateTime::currentDateTime().secsTo( qdt ); 641 int sec = QDateTime::currentDateTime().secsTo( qdt );
642 if ( sec > maxSec ) { 642 if ( sec > maxSec ) {
643 mRecheckAlarmTimer->start( maxSec * 1000 ); 643 mRecheckAlarmTimer->start( maxSec * 1000 );
644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
645 return; 645 return;
646 } else { 646 } else {
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 } 648 }
649 //qDebug("Alarm timer started with secs: %d ", sec); 649 //qDebug("Alarm timer started with secs: %d ", sec);
650 mAlarmTimer->start( sec *1000 , true ); 650 mAlarmTimer->start( sec *1000 , true );
651 651
652} 652}
653// called by mRecheckAlarmTimer to get next alarm 653// called by mRecheckAlarmTimer to get next alarm
654// we need this, because a QTimer has only a max range of 25 days 654// we need this, because a QTimer has only a max range of 25 days
655void CalendarView::recheckTimerAlarm() 655void CalendarView::recheckTimerAlarm()
656{ 656{
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658 mRecheckAlarmTimer->stop(); 658 mRecheckAlarmTimer->stop();
659 mCalendar->checkAlarmForIncidence( 0, true ); 659 mCalendar->checkAlarmForIncidence( 0, true );
660} 660}
661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
662{ 662{
663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
667#endif 667#endif
668 return; 668 return;
669 } 669 }
670 mAlarmTimer->stop(); 670 mAlarmTimer->stop();
671} 671}
672void CalendarView::selectWeekNum ( int num ) 672void CalendarView::selectWeekNum ( int num )
673{ 673{
674 dateNavigator()->selectWeek( num ); 674 dateNavigator()->selectWeek( num );
675 mViewManager->showWeekView(); 675 mViewManager->showWeekView();
676} 676}
677KOViewManager *CalendarView::viewManager() 677KOViewManager *CalendarView::viewManager()
678{ 678{
679 return mViewManager; 679 return mViewManager;
680} 680}
681 681
682KODialogManager *CalendarView::dialogManager() 682KODialogManager *CalendarView::dialogManager()
683{ 683{
684 return mDialogManager; 684 return mDialogManager;
685} 685}
686 686
687QDate CalendarView::startDate() 687QDate CalendarView::startDate()
688{ 688{
689 DateList dates = mNavigator->selectedDates(); 689 DateList dates = mNavigator->selectedDates();
690 690
691 return dates.first(); 691 return dates.first();
692} 692}
693 693
694QDate CalendarView::endDate() 694QDate CalendarView::endDate()
695{ 695{
696 DateList dates = mNavigator->selectedDates(); 696 DateList dates = mNavigator->selectedDates();
697 697
698 return dates.last(); 698 return dates.last();
699} 699}
700 700
701 701
702void CalendarView::createPrinter() 702void CalendarView::createPrinter()
703{ 703{
704#ifndef KORG_NOPRINTER 704#ifndef KORG_NOPRINTER
705 if (!mCalPrinter) { 705 if (!mCalPrinter) {
706 mCalPrinter = new CalPrinter(this, mCalendar); 706 mCalPrinter = new CalPrinter(this, mCalendar);
707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
708 } 708 }
709#endif 709#endif
710} 710}
711 711
712 712
713//KOPrefs::instance()->mWriteBackFile 713//KOPrefs::instance()->mWriteBackFile
714//KOPrefs::instance()->mWriteBackExistingOnly 714//KOPrefs::instance()->mWriteBackExistingOnly
715 715
716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
722 722
723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
724{ 724{
725 725
726 // 0 equal 726 // 0 equal
727 // 1 take local 727 // 1 take local
728 // 2 take remote 728 // 2 take remote
729 // 3 cancel 729 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 730 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 731 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 732 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 734 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 736 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 738 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 739 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 740 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 741 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 742 if ( mode <= SYNC_PREF_ASK )
743 return 0; 743 return 0;
744 } else { 744 } else {
745 if ( locCh ) { 745 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 747 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 748 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 749 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 750 } else {
751 //qDebug(" not loc changed "); 751 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 752 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 753 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 754 remoteMod =( lastSync.addDays( 1 ) );
755 755
756 } 756 }
757 } 757 }
758 full = true; 758 full = true;
759 if ( mode < SYNC_PREF_ASK ) 759 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 760 mode = SYNC_PREF_ASK;
761 } else { 761 } else {
762 if ( localMod == remoteMod ) 762 if ( localMod == remoteMod )
763 // if ( local->revision() == remote->revision() ) 763 // if ( local->revision() == remote->revision() )
764 return 0; 764 return 0;
765 765
766 } 766 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 768
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 771 //full = true; //debug only
772 if ( full ) { 772 if ( full ) {
773 bool equ = false; 773 bool equ = false;
774 if ( local->type() == "Event" ) { 774 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 775 equ = (*((Event*) local) == *((Event*) remote));
776 } 776 }
777 else if ( local->type() =="Todo" ) 777 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 778 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 779 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 780 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 781 if ( equ ) {
782 //qDebug("equal "); 782 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 785 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 786 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 787 return 0;
788 788
789 }//else //debug only 789 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 791 }
792 int result; 792 int result;
793 bool localIsNew; 793 bool localIsNew;
794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
795 795
796 if ( full && mode < SYNC_PREF_NEWEST ) 796 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 797 mode = SYNC_PREF_ASK;
798 798
799 switch( mode ) { 799 switch( mode ) {
800 case SYNC_PREF_LOCAL: 800 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 801 if ( lastSync > remoteMod )
802 return 1; 802 return 1;
803 if ( lastSync > localMod ) 803 if ( lastSync > localMod )
804 return 2; 804 return 2;
805 return 1; 805 return 1;
806 break; 806 break;
807 case SYNC_PREF_REMOTE: 807 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 808 if ( lastSync > remoteMod )
809 return 1; 809 return 1;
810 if ( lastSync > localMod ) 810 if ( lastSync > localMod )
811 return 2; 811 return 2;
812 return 2; 812 return 2;
813 break; 813 break;
814 case SYNC_PREF_NEWEST: 814 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 815 if ( localMod > remoteMod )
816 return 1; 816 return 1;
817 else 817 else
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_ASK: 820 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 822 if ( lastSync > remoteMod )
823 return 1; 823 return 1;
824 if ( lastSync > localMod ) 824 if ( lastSync > localMod )
825 return 2; 825 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 827 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 828 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
830 else 830 else
831 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 832 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 833 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 834 getEventViewerDialog()->setColorMode( 2 );
835 else 835 else
836 getEventViewerDialog()->setColorMode( 1 ); 836 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 837 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 838 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 841 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 842 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 843 return result;
844 844
845 break; 845 break;
846 case SYNC_PREF_FORCE_LOCAL: 846 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 847 return 1;
848 break; 848 break;
849 case SYNC_PREF_FORCE_REMOTE: 849 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 850 return 2;
851 break; 851 break;
852 852
853 default: 853 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 854 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 855 break;
856 } 856 }
857 return 0; 857 return 0;
858} 858}
859Event* CalendarView::getLastSyncEvent() 859Event* CalendarView::getLastSyncEvent()
860{ 860{
861 Event* lse; 861 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 864 if (!lse) {
865 lse = new Event(); 865 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 867 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 869 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 871 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 873 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 874 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 875 mCalendar->addEvent( lse );
876 } 876 }
877 877
878 return lse; 878 return lse;
879 879
880} 880}
881 881
882// we check, if the to delete event has a id for a profile 882// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 883// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 885{
886 if ( lastSync.count() == 0 ) { 886 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 887 //qDebug(" lastSync.count() == 0");
888 return; 888 return;
889 } 889 }
890 if ( toDelete->type() == "Journal" ) 890 if ( toDelete->type() == "Journal" )
891 return; 891 return;
892 892
893 Event* eve = lastSync.first(); 893 Event* eve = lastSync.first();
894 894
895 while ( eve ) { 895 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 897 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 898 QString des = eve->description();
899 QString pref = "e"; 899 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 900 if ( toDelete->type() == "Todo" )
901 pref = "t"; 901 pref = "t";
902 des += pref+ id + ","; 902 des += pref+ id + ",";
903 eve->setReadOnly( false ); 903 eve->setReadOnly( false );
904 eve->setDescription( des ); 904 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 905 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 906 eve->setReadOnly( true );
907 } 907 }
908 eve = lastSync.next(); 908 eve = lastSync.next();
909 } 909 }
910 910
911} 911}
912void CalendarView::checkExternalId( Incidence * inc ) 912void CalendarView::checkExternalId( Incidence * inc )
913{ 913{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 915 checkExternSyncEvent( lastSync, inc );
916 916
917} 917}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 919{
920 bool syncOK = true; 920 bool syncOK = true;
921 int addedEvent = 0; 921 int addedEvent = 0;
922 int addedEventR = 0; 922 int addedEventR = 0;
923 int deletedEventR = 0; 923 int deletedEventR = 0;
924 int deletedEventL = 0; 924 int deletedEventL = 0;
925 int changedLocal = 0; 925 int changedLocal = 0;
926 int changedRemote = 0; 926 int changedRemote = 0;
927 //QPtrList<Event> el = local->rawEvents(); 927 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 928 Event* eventR;
929 QString uid; 929 QString uid;
930 int take; 930 int take;
931 Event* eventL; 931 Event* eventL;
932 Event* eventRSync; 932 Event* eventRSync;
933 Event* eventLSync; 933 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 936 bool fullDateRange = false;
937 local->resetTempSyncStat(); 937 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 938 mLastCalendarSync = QDateTime::currentDateTime();
939 if ( mSyncManager->syncWithDesktop() ) { 939 if ( mSyncManager->syncWithDesktop() ) {
940 remote->resetPilotStat(1); 940 remote->resetPilotStat(1);
941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
944 } else { 944 } else {
945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
946 } 946 }
947 } 947 }
948 QDateTime modifiedCalendar = mLastCalendarSync; 948 QDateTime modifiedCalendar = mLastCalendarSync;
949 eventLSync = getLastSyncEvent(); 949 eventLSync = getLastSyncEvent();
950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
951 if ( eventR ) { 951 if ( eventR ) {
952 eventRSync = (Event*) eventR->clone(); 952 eventRSync = (Event*) eventR->clone();
953 remote->deleteEvent(eventR ); 953 remote->deleteEvent(eventR );
954 954
955 } else { 955 } else {
956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
957 eventRSync = (Event*)eventLSync->clone(); 957 eventRSync = (Event*)eventLSync->clone();
958 } else { 958 } else {
959 fullDateRange = true; 959 fullDateRange = true;
960 eventRSync = new Event(); 960 eventRSync = new Event();
961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync ); 963 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") ); 965 eventRSync->setCategories( i18n("SyncEvent") );
966 } 966 }
967 } 967 }
968 if ( eventLSync->dtStart() == mLastCalendarSync ) 968 if ( eventLSync->dtStart() == mLastCalendarSync )
969 fullDateRange = true; 969 fullDateRange = true;
970 970
971 if ( ! fullDateRange ) { 971 if ( ! fullDateRange ) {
972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
973 973
974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
976 fullDateRange = true; 976 fullDateRange = true;
977 } 977 }
978 } 978 }
979 if ( mSyncManager->syncWithDesktop() ) { 979 if ( mSyncManager->syncWithDesktop() ) {
980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
981 } 981 }
982 if ( fullDateRange ) 982 if ( fullDateRange )
983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
984 else 984 else
985 mLastCalendarSync = eventLSync->dtStart(); 985 mLastCalendarSync = eventLSync->dtStart();
986 // for resyncing if own file has changed 986 // for resyncing if own file has changed
987 if ( mCurrentSyncDevice == "deleteaftersync" ) { 987 if ( mCurrentSyncDevice == "deleteaftersync" ) {
988 mLastCalendarSync = loadedFileVersion; 988 mLastCalendarSync = loadedFileVersion;
989 //qDebug("setting mLastCalendarSync "); 989 //qDebug("setting mLastCalendarSync ");
990 } 990 }
991 //qDebug("*************************** "); 991 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
993 QPtrList<Incidence> er = remote->rawIncidences(); 993 QPtrList<Incidence> er = remote->rawIncidences();
994 Incidence* inR = er.first(); 994 Incidence* inR = er.first();
995 Incidence* inL; 995 Incidence* inL;
996 QProgressBar bar( er.count(),0 ); 996 QProgressBar bar( er.count(),0 );
997 bar.setCaption (i18n("Syncing - close to abort!") ); 997 bar.setCaption (i18n("Syncing - close to abort!") );
998 998
999 // ************** setting up filter *************
1000 CalFilter *filterIN = 0;
1001 CalFilter *filterOUT = 0;
1002 CalFilter *filter = mFilters.first();
1003 while(filter) {
1004 if ( filter->name() == mSyncManager->mFilterInCal )
1005 filterIN = filter;
1006 if ( filter->name() == mSyncManager->mFilterOutCal )
1007 filterOUT = filter;
1008 filter = mFilters.next();
1009 }
999 int w = 300; 1010 int w = 300;
1000 if ( QApplication::desktop()->width() < 320 ) 1011 if ( QApplication::desktop()->width() < 320 )
1001 w = 220; 1012 w = 220;
1002 int h = bar.sizeHint().height() ; 1013 int h = bar.sizeHint().height() ;
1003 int dw = QApplication::desktop()->width(); 1014 int dw = QApplication::desktop()->width();
1004 int dh = QApplication::desktop()->height(); 1015 int dh = QApplication::desktop()->height();
1005 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1016 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1006 bar.show(); 1017 bar.show();
1007 int modulo = (er.count()/10)+1; 1018 int modulo = (er.count()/10)+1;
1008 int incCounter = 0; 1019 int incCounter = 0;
1009 while ( inR ) { 1020 while ( inR ) {
1010 if ( ! bar.isVisible() ) 1021 if ( ! bar.isVisible() )
1011 return false; 1022 return false;
1012 if ( incCounter % modulo == 0 ) 1023 if ( incCounter % modulo == 0 )
1013 bar.setProgress( incCounter ); 1024 bar.setProgress( incCounter );
1014 ++incCounter; 1025 ++incCounter;
1015 uid = inR->uid(); 1026 uid = inR->uid();
1016 bool skipIncidence = false; 1027 bool skipIncidence = false;
1017 if ( uid.left(15) == QString("last-syncEvent-") ) 1028 if ( uid.left(15) == QString("last-syncEvent-") )
1018 skipIncidence = true; 1029 skipIncidence = true;
1019 QString idS; 1030 QString idS;
1020 qApp->processEvents(); 1031 qApp->processEvents();
1021 if ( !skipIncidence ) { 1032 if ( !skipIncidence ) {
1022 inL = local->incidence( uid ); 1033 inL = local->incidence( uid );
1023 if ( inL ) { // maybe conflict - same uid in both calendars 1034 if ( inL ) { // maybe conflict - same uid in both calendars
1024 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1035 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1025 //qDebug("take %d %s ", take, inL->summary().latin1()); 1036 //qDebug("take %d %s ", take, inL->summary().latin1());
1026 if ( take == 3 ) 1037 if ( take == 3 )
1027 return false; 1038 return false;
1028 if ( take == 1 ) {// take local ********************** 1039 if ( take == 1 ) {// take local **********************
1029 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1030 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1031 else 1042 else
1032 idS = inR->IDStr(); 1043 idS = inR->IDStr();
1033 remote->deleteIncidence( inR ); 1044 remote->deleteIncidence( inR );
1034 inR = inL->clone(); 1045 inR = inL->clone();
1035 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1046 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1036 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1047 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1037 inR->setIDStr( idS ); 1048 inR->setIDStr( idS );
1038 remote->addIncidence( inR ); 1049 remote->addIncidence( inR );
1039 if ( mSyncManager->syncWithDesktop() ) 1050 if ( mSyncManager->syncWithDesktop() )
1040 inR->setPilotId( 2 ); 1051 inR->setPilotId( 2 );
1041 ++changedRemote; 1052 ++changedRemote;
1042 } else {// take remote ********************** 1053 } else {// take remote **********************
1043 idS = inL->IDStr(); 1054 idS = inL->IDStr();
1044 int pid = inL->pilotId(); 1055 int pid = inL->pilotId();
1045 local->deleteIncidence( inL ); 1056 local->deleteIncidence( inL );
1046 inL = inR->clone(); 1057 inL = inR->clone();
1047 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1048 inL->setPilotId( pid ); 1059 inL->setPilotId( pid );
1049 inL->setIDStr( idS ); 1060 inL->setIDStr( idS );
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1051 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1052 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1053 } 1064 }
1054 local->addIncidence( inL ); 1065 local->addIncidence( inL );
1055 ++changedLocal; 1066 ++changedLocal;
1056 } 1067 }
1057 } 1068 }
1058 } else { // no conflict ********** add or delete remote 1069 } else { // no conflict ********** add or delete remote
1059 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1070 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1060 QString des = eventLSync->description(); 1071 QString des = eventLSync->description();
1061 QString pref = "e"; 1072 QString pref = "e";
1062 if ( inR->type() == "Todo" ) 1073 if ( inR->type() == "Todo" )
1063 pref = "t"; 1074 pref = "t";
1064 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1075 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1065 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1076 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1066 //remote->deleteIncidence( inR ); 1077 //remote->deleteIncidence( inR );
1067 ++deletedEventR; 1078 ++deletedEventR;
1068 } else { 1079 } else {
1069 inR->setLastModified( modifiedCalendar ); 1080 inR->setLastModified( modifiedCalendar );
1070 inL = inR->clone(); 1081 inL = inR->clone();
1071 inL->setIDStr( ":" ); 1082 inL->setIDStr( ":" );
1072 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1083 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1073 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1084 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1074 local->addIncidence( inL ); 1085 local->addIncidence( inL );
1075 ++addedEvent; 1086 ++addedEvent;
1076 } 1087 }
1077 } else { 1088 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1089 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1090 inR->setLastModified( modifiedCalendar );
1080 inL = inR->clone(); 1091 inL = inR->clone();
1081 inL->setIDStr( ":" ); 1092 inL->setIDStr( ":" );
1082 local->addIncidence( inL ); 1093 local->addIncidence( inL );
1083 ++addedEvent; 1094 ++addedEvent;
1084 } else { 1095 } else {
1085 checkExternSyncEvent(eventRSyncSharp, inR); 1096 checkExternSyncEvent(eventRSyncSharp, inR);
1086 remote->deleteIncidence( inR ); 1097 remote->deleteIncidence( inR );
1087 ++deletedEventR; 1098 ++deletedEventR;
1088 } 1099 }
1089 } 1100 }
1090 } 1101 }
1091 } 1102 }
1092 inR = er.next(); 1103 inR = er.next();
1093 } 1104 }
1094 QPtrList<Incidence> el = local->rawIncidences(); 1105 QPtrList<Incidence> el = local->rawIncidences();
1095 inL = el.first(); 1106 inL = el.first();
1096 modulo = (el.count()/10)+1; 1107 modulo = (el.count()/10)+1;
1097 bar.setCaption (i18n("Add / remove events") ); 1108 bar.setCaption (i18n("Add / remove events") );
1098 bar.setTotalSteps ( el.count() ) ; 1109 bar.setTotalSteps ( el.count() ) ;
1099 bar.show(); 1110 bar.show();
1100 incCounter = 0; 1111 incCounter = 0;
1101 1112
1102 while ( inL ) { 1113 while ( inL ) {
1103 1114
1104 qApp->processEvents(); 1115 qApp->processEvents();
1105 if ( ! bar.isVisible() ) 1116 if ( ! bar.isVisible() )
1106 return false; 1117 return false;
1107 if ( incCounter % modulo == 0 ) 1118 if ( incCounter % modulo == 0 )
1108 bar.setProgress( incCounter ); 1119 bar.setProgress( incCounter );
1109 ++incCounter; 1120 ++incCounter;
1110 uid = inL->uid(); 1121 uid = inL->uid();
1111 bool skipIncidence = false; 1122 bool skipIncidence = false;
1112 if ( uid.left(15) == QString("last-syncEvent-") ) 1123 if ( uid.left(15) == QString("last-syncEvent-") )
1113 skipIncidence = true; 1124 skipIncidence = true;
1114 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1125 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1115 skipIncidence = true; 1126 skipIncidence = true;
1116 if ( !skipIncidence ) { 1127 if ( !skipIncidence ) {
1117 inR = remote->incidence( uid ); 1128 inR = remote->incidence( uid );
1118 if ( ! inR ) { // no conflict ********** add or delete local 1129 if ( ! inR ) { // no conflict ********** add or delete local
1119 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1130 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1120 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1131 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1121 checkExternSyncEvent(eventLSyncSharp, inL); 1132 checkExternSyncEvent(eventLSyncSharp, inL);
1122 local->deleteIncidence( inL ); 1133 local->deleteIncidence( inL );
1123 ++deletedEventL; 1134 ++deletedEventL;
1124 } else { 1135 } else {
1125 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1136 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1126 inL->removeID(mCurrentSyncDevice ); 1137 inL->removeID(mCurrentSyncDevice );
1127 ++addedEventR; 1138 ++addedEventR;
1128 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1139 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1129 inL->setLastModified( modifiedCalendar ); 1140 inL->setLastModified( modifiedCalendar );
1130 inR = inL->clone(); 1141 inR = inL->clone();
1131 inR->setIDStr( ":" ); 1142 inR->setIDStr( ":" );
1132 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1143 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1133 remote->addIncidence( inR ); 1144 remote->addIncidence( inR );
1134 } 1145 }
1135 } 1146 }
1136 } else { 1147 } else {
1137 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1148 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1138 checkExternSyncEvent(eventLSyncSharp, inL); 1149 checkExternSyncEvent(eventLSyncSharp, inL);
1139 local->deleteIncidence( inL ); 1150 local->deleteIncidence( inL );
1140 ++deletedEventL; 1151 ++deletedEventL;
1141 } else { 1152 } else {
1142 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1153 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1143 ++addedEventR; 1154 ++addedEventR;
1144 inL->setLastModified( modifiedCalendar ); 1155 inL->setLastModified( modifiedCalendar );
1145 inR = inL->clone(); 1156 inR = inL->clone();
1146 inR->setIDStr( ":" ); 1157 inR->setIDStr( ":" );
1147 remote->addIncidence( inR ); 1158 remote->addIncidence( inR );
1148 } 1159 }
1149 } 1160 }
1150 } 1161 }
1151 } 1162 }
1152 } 1163 }
1153 inL = el.next(); 1164 inL = el.next();
1154 } 1165 }
1155 int delFut = 0; 1166 int delFut = 0;
1156 int remRem = 0; 1167 int remRem = 0;
1157 if ( mSyncManager->mWriteBackInFuture ) { 1168 if ( mSyncManager->mWriteBackInFuture ) {
1158 er = remote->rawIncidences(); 1169 er = remote->rawIncidences();
1159 remRem = er.count(); 1170 remRem = er.count();
1160 inR = er.first(); 1171 inR = er.first();
1161 QDateTime dt; 1172 QDateTime dt;
1162 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1173 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1163 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1174 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1164 while ( inR ) { 1175 while ( inR ) {
1165 if ( inR->type() == "Todo" ) { 1176 if ( inR->type() == "Todo" ) {
1166 Todo * t = (Todo*)inR; 1177 Todo * t = (Todo*)inR;
1167 if ( t->hasDueDate() ) 1178 if ( t->hasDueDate() )
1168 dt = t->dtDue(); 1179 dt = t->dtDue();
1169 else 1180 else
1170 dt = cur.addSecs( 62 ); 1181 dt = cur.addSecs( 62 );
1171 } 1182 }
1172 else if (inR->type() == "Event" ) { 1183 else if (inR->type() == "Event" ) {
1173 bool ok; 1184 bool ok;
1174 dt = inR->getNextOccurence( cur, &ok ); 1185 dt = inR->getNextOccurence( cur, &ok );
1175 if ( !ok ) 1186 if ( !ok )
1176 dt = cur.addSecs( -62 ); 1187 dt = cur.addSecs( -62 );
1177 } 1188 }
1178 else 1189 else
1179 dt = inR->dtStart(); 1190 dt = inR->dtStart();
1180 if ( dt < cur || dt > end ) { 1191 if ( dt < cur || dt > end ) {
1181 remote->deleteIncidence( inR ); 1192 remote->deleteIncidence( inR );
1182 ++delFut; 1193 ++delFut;
1183 } 1194 }
1184 inR = er.next(); 1195 inR = er.next();
1185 } 1196 }
1186 } 1197 }
1187 bar.hide(); 1198 bar.hide();
1188 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1199 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1189 eventLSync->setReadOnly( false ); 1200 eventLSync->setReadOnly( false );
1190 eventLSync->setDtStart( mLastCalendarSync ); 1201 eventLSync->setDtStart( mLastCalendarSync );
1191 eventRSync->setDtStart( mLastCalendarSync ); 1202 eventRSync->setDtStart( mLastCalendarSync );
1192 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1203 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1193 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1204 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1194 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1205 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1195 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1206 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1196 eventLSync->setReadOnly( true ); 1207 eventLSync->setReadOnly( true );
1197 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1208 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1198 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1209 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1199 remote->addEvent( eventRSync ); 1210 remote->addEvent( eventRSync );
1200 else 1211 else
1201 delete eventRSync; 1212 delete eventRSync;
1202 QString mes; 1213 QString mes;
1203 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 ); 1214 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 );
1204 QString delmess; 1215 QString delmess;
1205 if ( delFut ) { 1216 if ( delFut ) {
1206 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1217 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1207 mes += delmess; 1218 mes += delmess;
1208 } 1219 }
1209 mes = i18n("Local calendar changed!\n") +mes; 1220 mes = i18n("Local calendar changed!\n") +mes;
1210 mCalendar->checkAlarmForIncidence( 0, true ); 1221 mCalendar->checkAlarmForIncidence( 0, true );
1211 qDebug( mes ); 1222 qDebug( mes );
1212 if ( mSyncManager->mShowSyncSummary ) { 1223 if ( mSyncManager->mShowSyncSummary ) {
1213 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1224 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1214 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1225 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1215 qDebug("cancelled "); 1226 qDebug("cancelled ");
1216 return false; 1227 return false;
1217 } 1228 }
1218 } 1229 }
1219 return syncOK; 1230 return syncOK;
1220} 1231}
1221 1232
1222void CalendarView::setSyncDevice( QString s ) 1233void CalendarView::setSyncDevice( QString s )
1223{ 1234{
1224 mCurrentSyncDevice= s; 1235 mCurrentSyncDevice= s;
1225} 1236}
1226void CalendarView::setSyncName( QString s ) 1237void CalendarView::setSyncName( QString s )
1227{ 1238{
1228 mCurrentSyncName= s; 1239 mCurrentSyncName= s;
1229} 1240}
1230bool CalendarView::syncCalendar(QString filename, int mode) 1241bool CalendarView::syncCalendar(QString filename, int mode)
1231{ 1242{
1232 //qDebug("syncCalendar %s ", filename.latin1()); 1243 //qDebug("syncCalendar %s ", filename.latin1());
1233 mGlobalSyncMode = SYNC_MODE_NORMAL; 1244 mGlobalSyncMode = SYNC_MODE_NORMAL;
1234 CalendarLocal* calendar = new CalendarLocal(); 1245 CalendarLocal* calendar = new CalendarLocal();
1235 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1246 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1236 FileStorage* storage = new FileStorage( calendar ); 1247 FileStorage* storage = new FileStorage( calendar );
1237 bool syncOK = false; 1248 bool syncOK = false;
1238 storage->setFileName( filename ); 1249 storage->setFileName( filename );
1239 // qDebug("loading ... "); 1250 // qDebug("loading ... ");
1240 if ( storage->load() ) { 1251 if ( storage->load() ) {
1241 getEventViewerDialog()->setSyncMode( true ); 1252 getEventViewerDialog()->setSyncMode( true );
1242 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1253 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1243 getEventViewerDialog()->setSyncMode( false ); 1254 getEventViewerDialog()->setSyncMode( false );
1244 if ( syncOK ) { 1255 if ( syncOK ) {
1245 if ( mSyncManager->mWriteBackFile ) 1256 if ( mSyncManager->mWriteBackFile )
1246 { 1257 {
1247 storage->setSaveFormat( new ICalFormat() ); 1258 storage->setSaveFormat( new ICalFormat() );
1248 storage->save(); 1259 storage->save();
1249 } 1260 }
1250 } 1261 }
1251 setModified( true ); 1262 setModified( true );
1252 } 1263 }
1253 delete storage; 1264 delete storage;
1254 delete calendar; 1265 delete calendar;
1255 if ( syncOK ) 1266 if ( syncOK )
1256 updateView(); 1267 updateView();
1257 return syncOK; 1268 return syncOK;
1258} 1269}
1259 1270
1260void CalendarView::syncExternal( int mode ) 1271void CalendarView::syncExternal( int mode )
1261{ 1272{
1262 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1273 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1263 1274
1264 qApp->processEvents(); 1275 qApp->processEvents();
1265 CalendarLocal* calendar = new CalendarLocal(); 1276 CalendarLocal* calendar = new CalendarLocal();
1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1277 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1267 bool syncOK = false; 1278 bool syncOK = false;
1268 bool loadSuccess = false; 1279 bool loadSuccess = false;
1269 PhoneFormat* phoneFormat = 0; 1280 PhoneFormat* phoneFormat = 0;
1270 emit tempDisableBR(true); 1281 emit tempDisableBR(true);
1271#ifndef DESKTOP_VERSION 1282#ifndef DESKTOP_VERSION
1272 SharpFormat* sharpFormat = 0; 1283 SharpFormat* sharpFormat = 0;
1273 if ( mode == 0 ) { // sharp 1284 if ( mode == 0 ) { // sharp
1274 sharpFormat = new SharpFormat () ; 1285 sharpFormat = new SharpFormat () ;
1275 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1286 loadSuccess = sharpFormat->load( calendar, mCalendar );
1276 1287
1277 } else 1288 } else
1278#endif 1289#endif
1279 if ( mode == 1 ) { // phone 1290 if ( mode == 1 ) { // phone
1280 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1291 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1281 mSyncManager->mPhoneDevice, 1292 mSyncManager->mPhoneDevice,
1282 mSyncManager->mPhoneConnection, 1293 mSyncManager->mPhoneConnection,
1283 mSyncManager->mPhoneModel); 1294 mSyncManager->mPhoneModel);
1284 loadSuccess = phoneFormat->load( calendar,mCalendar); 1295 loadSuccess = phoneFormat->load( calendar,mCalendar);
1285 1296
1286 } else { 1297 } else {
1287 emit tempDisableBR(false); 1298 emit tempDisableBR(false);
1288 return; 1299 return;
1289 } 1300 }
1290 if ( loadSuccess ) { 1301 if ( loadSuccess ) {
1291 getEventViewerDialog()->setSyncMode( true ); 1302 getEventViewerDialog()->setSyncMode( true );
1292 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1303 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1293 getEventViewerDialog()->setSyncMode( false ); 1304 getEventViewerDialog()->setSyncMode( false );
1294 qApp->processEvents(); 1305 qApp->processEvents();
1295 if ( syncOK ) { 1306 if ( syncOK ) {
1296 if ( mSyncManager->mWriteBackFile ) 1307 if ( mSyncManager->mWriteBackFile )
1297 { 1308 {
1298 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1309 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1299 Incidence* inc = iL.first(); 1310 Incidence* inc = iL.first();
1300 if ( phoneFormat ) { 1311 if ( phoneFormat ) {
1301 while ( inc ) { 1312 while ( inc ) {
1302 inc->removeID(mCurrentSyncDevice); 1313 inc->removeID(mCurrentSyncDevice);
1303 inc = iL.next(); 1314 inc = iL.next();
1304 } 1315 }
1305 } 1316 }
1306#ifndef DESKTOP_VERSION 1317#ifndef DESKTOP_VERSION
1307 if ( sharpFormat ) 1318 if ( sharpFormat )
1308 sharpFormat->save(calendar); 1319 sharpFormat->save(calendar);
1309#endif 1320#endif
1310 if ( phoneFormat ) 1321 if ( phoneFormat )
1311 phoneFormat->save(calendar); 1322 phoneFormat->save(calendar);
1312 iL = calendar->rawIncidences(); 1323 iL = calendar->rawIncidences();
1313 inc = iL.first(); 1324 inc = iL.first();
1314 Incidence* loc; 1325 Incidence* loc;
1315 while ( inc ) { 1326 while ( inc ) {
1316 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1327 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1317 loc = mCalendar->incidence(inc->uid() ); 1328 loc = mCalendar->incidence(inc->uid() );
1318 if ( loc ) { 1329 if ( loc ) {
1319 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1330 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1320 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1331 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1321 } 1332 }
1322 } 1333 }
1323 inc = iL.next(); 1334 inc = iL.next();
1324 } 1335 }
1325 Incidence* lse = getLastSyncEvent(); 1336 Incidence* lse = getLastSyncEvent();
1326 if ( lse ) { 1337 if ( lse ) {
1327 lse->setReadOnly( false ); 1338 lse->setReadOnly( false );
1328 lse->setDescription( "" ); 1339 lse->setDescription( "" );
1329 lse->setReadOnly( true ); 1340 lse->setReadOnly( true );
1330 } 1341 }
1331 } 1342 }
1332 } else { 1343 } else {
1333 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1344 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1334 } 1345 }
1335 setModified( true ); 1346 setModified( true );
1336 } else { 1347 } else {
1337 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1348 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1338 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1349 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1339 question, i18n("Ok")) ; 1350 question, i18n("Ok")) ;
1340 1351
1341 } 1352 }
1342 delete calendar; 1353 delete calendar;
1343 updateView(); 1354 updateView();
1344 emit tempDisableBR(false); 1355 emit tempDisableBR(false);
1345 return ;//syncOK; 1356 return ;//syncOK;
1346 1357
1347} 1358}
1348 1359
1349bool CalendarView::importBday() 1360bool CalendarView::importBday()
1350{ 1361{
1351#ifndef KORG_NOKABC 1362#ifndef KORG_NOKABC
1352 1363
1353#ifdef DESKTOP_VERSION 1364#ifdef DESKTOP_VERSION
1354 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1365 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1355 KABC::AddressBook::Iterator it; 1366 KABC::AddressBook::Iterator it;
1356 int count = 0; 1367 int count = 0;
1357 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1368 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1358 ++count; 1369 ++count;
1359 } 1370 }
1360 QProgressBar bar(count,0 ); 1371 QProgressBar bar(count,0 );
1361 int w = 300; 1372 int w = 300;
1362 if ( QApplication::desktop()->width() < 320 ) 1373 if ( QApplication::desktop()->width() < 320 )
1363 w = 220; 1374 w = 220;
1364 int h = bar.sizeHint().height() ; 1375 int h = bar.sizeHint().height() ;
1365 int dw = QApplication::desktop()->width(); 1376 int dw = QApplication::desktop()->width();
1366 int dh = QApplication::desktop()->height(); 1377 int dh = QApplication::desktop()->height();
1367 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1378 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1368 bar.show(); 1379 bar.show();
1369 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1380 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1370 qApp->processEvents(); 1381 qApp->processEvents();
1371 count = 0; 1382 count = 0;
1372 int addCount = 0; 1383 int addCount = 0;
1373 KCal::Attendee* a = 0; 1384 KCal::Attendee* a = 0;
1374 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1385 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1375 if ( ! bar.isVisible() ) 1386 if ( ! bar.isVisible() )
1376 return false; 1387 return false;
1377 bar.setProgress( count++ ); 1388 bar.setProgress( count++ );
1378 qApp->processEvents(); 1389 qApp->processEvents();
1379 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1390 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1380 if ( (*it).birthday().date().isValid() ){ 1391 if ( (*it).birthday().date().isValid() ){
1381 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1392 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1382 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1393 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1383 ++addCount; 1394 ++addCount;
1384 } 1395 }
1385 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1396 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1386 if ( anni.isValid() ){ 1397 if ( anni.isValid() ){
1387 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1398 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1388 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1399 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1389 ++addCount; 1400 ++addCount;
1390 } 1401 }
1391 } 1402 }
1392 updateView(); 1403 updateView();
1393 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1404 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1394#else //DESKTOP_VERSION 1405#else //DESKTOP_VERSION
1395 1406
1396 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1407 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1397 // the result should now arrive through method insertBirthdays 1408 // the result should now arrive through method insertBirthdays
1398 1409
1399#endif //DESKTOP_VERSION 1410#endif //DESKTOP_VERSION
1400 1411
1401#endif //KORG_NOKABC 1412#endif //KORG_NOKABC
1402 1413
1403 1414
1404 return true; 1415 return true;
1405} 1416}
1406 1417
1407// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1418// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1408void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1419void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1409 const QStringList& anniversaryList, const QStringList& realNameList, 1420 const QStringList& anniversaryList, const QStringList& realNameList,
1410 const QStringList& emailList, const QStringList& assembledNameList, 1421 const QStringList& emailList, const QStringList& assembledNameList,
1411 const QStringList& uidList) 1422 const QStringList& uidList)
1412{ 1423{
1413 qDebug("CalendarView::insertBirthdays"); 1424 qDebug("CalendarView::insertBirthdays");
1414 if (uid == this->name()) 1425 if (uid == this->name())
1415 { 1426 {
1416 int count = birthdayList.count(); 1427 int count = birthdayList.count();
1417 int addCount = 0; 1428 int addCount = 0;
1418 KCal::Attendee* a = 0; 1429 KCal::Attendee* a = 0;
1419 1430
1420 qDebug("CalView 1 %i", count); 1431 qDebug("CalView 1 %i", count);
1421 1432
1422 QProgressBar bar(count,0 ); 1433 QProgressBar bar(count,0 );
1423 int w = 300; 1434 int w = 300;
1424 if ( QApplication::desktop()->width() < 320 ) 1435 if ( QApplication::desktop()->width() < 320 )
1425 w = 220; 1436 w = 220;
1426 int h = bar.sizeHint().height() ; 1437 int h = bar.sizeHint().height() ;
1427 int dw = QApplication::desktop()->width(); 1438 int dw = QApplication::desktop()->width();
1428 int dh = QApplication::desktop()->height(); 1439 int dh = QApplication::desktop()->height();
1429 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1440 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1430 bar.show(); 1441 bar.show();
1431 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1442 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1432 qApp->processEvents(); 1443 qApp->processEvents();
1433 1444
1434 QDate birthday; 1445 QDate birthday;
1435 QDate anniversary; 1446 QDate anniversary;
1436 QString realName; 1447 QString realName;
1437 QString email; 1448 QString email;
1438 QString assembledName; 1449 QString assembledName;
1439 QString uid; 1450 QString uid;
1440 bool ok = true; 1451 bool ok = true;
1441 for ( int i = 0; i < count; i++) 1452 for ( int i = 0; i < count; i++)
1442 { 1453 {
1443 if ( ! bar.isVisible() ) 1454 if ( ! bar.isVisible() )
1444 return; 1455 return;
1445 bar.setProgress( i ); 1456 bar.setProgress( i );
1446 qApp->processEvents(); 1457 qApp->processEvents();
1447 1458
1448 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1459 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1449 if (!ok) { 1460 if (!ok) {
1450 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1461 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1451 } 1462 }
1452 1463
1453 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1464 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1454 if (!ok) { 1465 if (!ok) {
1455 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1466 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1456 } 1467 }
1457 realName = realNameList[i]; 1468 realName = realNameList[i];
1458 email = emailList[i]; 1469 email = emailList[i];
1459 assembledName = assembledNameList[i]; 1470 assembledName = assembledNameList[i];
1460 uid = uidList[i]; 1471 uid = uidList[i];
1461 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1472 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1462 1473
1463 if ( birthday.isValid() ){ 1474 if ( birthday.isValid() ){
1464 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1475 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1465 KCal::Attendee::ReqParticipant,uid) ; 1476 KCal::Attendee::ReqParticipant,uid) ;
1466 if ( addAnniversary( birthday, assembledName, a, true ) ) 1477 if ( addAnniversary( birthday, assembledName, a, true ) )
1467 ++addCount; 1478 ++addCount;
1468 } 1479 }
1469 1480
1470 if ( anniversary.isValid() ){ 1481 if ( anniversary.isValid() ){
1471 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1482 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1472 KCal::Attendee::ReqParticipant,uid) ; 1483 KCal::Attendee::ReqParticipant,uid) ;
1473 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1484 if ( addAnniversary( anniversary, assembledName, a, false ) )
1474 ++addCount; 1485 ++addCount;
1475 } 1486 }
1476 } 1487 }
1477 1488
1478 updateView(); 1489 updateView();
1479 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1490 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1480 1491
1481 } 1492 }
1482 1493
1483} 1494}
1484 1495
1485 1496
1486 1497
1487bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1498bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1488{ 1499{
1489 //qDebug("addAnni "); 1500 //qDebug("addAnni ");
1490 Event * ev = new Event(); 1501 Event * ev = new Event();
1491 if ( a ) { 1502 if ( a ) {
1492 ev->addAttendee( a ); 1503 ev->addAttendee( a );
1493 } 1504 }
1494 QString kind; 1505 QString kind;
1495 if ( birthday ) 1506 if ( birthday )
1496 kind = i18n( "Birthday" ); 1507 kind = i18n( "Birthday" );
1497 else 1508 else
1498 kind = i18n( "Anniversary" ); 1509 kind = i18n( "Anniversary" );
1499 ev->setSummary( name + " - " + kind ); 1510 ev->setSummary( name + " - " + kind );
1500 ev->setOrganizer(a->email()); 1511 ev->setOrganizer(a->email());
1501 ev->setCategories( kind ); 1512 ev->setCategories( kind );
1502 ev->setDtStart( QDateTime(date) ); 1513 ev->setDtStart( QDateTime(date) );
1503 ev->setDtEnd( QDateTime(date) ); 1514 ev->setDtEnd( QDateTime(date) );
1504 ev->setFloats( true ); 1515 ev->setFloats( true );
1505 Recurrence * rec = ev->recurrence(); 1516 Recurrence * rec = ev->recurrence();
1506 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1517 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1507 rec->addYearlyNum( date.month() ); 1518 rec->addYearlyNum( date.month() );
1508 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1519 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1509 delete ev; 1520 delete ev;
1510 return false; 1521 return false;
1511 } 1522 }
1512 return true; 1523 return true;
1513 1524
1514} 1525}
1515bool CalendarView::importQtopia( const QString &categories, 1526bool CalendarView::importQtopia( const QString &categories,
1516 const QString &datebook, 1527 const QString &datebook,
1517 const QString &todolist ) 1528 const QString &todolist )
1518{ 1529{
1519 1530
1520 QtopiaFormat qtopiaFormat; 1531 QtopiaFormat qtopiaFormat;
1521 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1532 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1522 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1533 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1523 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1534 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1524 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1535 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1525 1536
1526 updateView(); 1537 updateView();
1527 return true; 1538 return true;
1528 1539
1529#if 0 1540#if 0
1530 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1541 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1531 mCurrentSyncDevice = "qtopia-XML"; 1542 mCurrentSyncDevice = "qtopia-XML";
1532 if ( mSyncManager->mAskForPreferences ) 1543 if ( mSyncManager->mAskForPreferences )
1533 edit_sync_options(); 1544 edit_sync_options();
1534 qApp->processEvents(); 1545 qApp->processEvents();
1535 CalendarLocal* calendar = new CalendarLocal(); 1546 CalendarLocal* calendar = new CalendarLocal();
1536 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1547 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1537 bool syncOK = false; 1548 bool syncOK = false;
1538 QtopiaFormat qtopiaFormat; 1549 QtopiaFormat qtopiaFormat;
1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1550 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1540 bool loadOk = true; 1551 bool loadOk = true;
1541 if ( !categories.isEmpty() ) 1552 if ( !categories.isEmpty() )
1542 loadOk = qtopiaFormat.load( calendar, categories ); 1553 loadOk = qtopiaFormat.load( calendar, categories );
1543 if ( loadOk && !datebook.isEmpty() ) 1554 if ( loadOk && !datebook.isEmpty() )
1544 loadOk = qtopiaFormat.load( calendar, datebook ); 1555 loadOk = qtopiaFormat.load( calendar, datebook );
1545 if ( loadOk && !todolist.isEmpty() ) 1556 if ( loadOk && !todolist.isEmpty() )
1546 loadOk = qtopiaFormat.load( calendar, todolist ); 1557 loadOk = qtopiaFormat.load( calendar, todolist );
1547 1558
1548 if ( loadOk ) { 1559 if ( loadOk ) {
1549 getEventViewerDialog()->setSyncMode( true ); 1560 getEventViewerDialog()->setSyncMode( true );
1550 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1561 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1551 getEventViewerDialog()->setSyncMode( false ); 1562 getEventViewerDialog()->setSyncMode( false );
1552 qApp->processEvents(); 1563 qApp->processEvents();
1553 if ( syncOK ) { 1564 if ( syncOK ) {
1554 if ( mSyncManager->mWriteBackFile ) 1565 if ( mSyncManager->mWriteBackFile )
1555 { 1566 {
1556 // write back XML file 1567 // write back XML file
1557 1568
1558 } 1569 }
1559 setModified( true ); 1570 setModified( true );
1560 } 1571 }
1561 } else { 1572 } else {
1562 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1573 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1563 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1574 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1564 question, i18n("Ok")) ; 1575 question, i18n("Ok")) ;
1565 } 1576 }
1566 delete calendar; 1577 delete calendar;
1567 updateView(); 1578 updateView();
1568 return syncOK; 1579 return syncOK;
1569 1580
1570 1581
1571#endif 1582#endif
1572 1583
1573} 1584}
1574 1585
1575void CalendarView::setSyncEventsReadOnly() 1586void CalendarView::setSyncEventsReadOnly()
1576{ 1587{
1577 Event * ev; 1588 Event * ev;
1578 QPtrList<Event> eL = mCalendar->rawEvents(); 1589 QPtrList<Event> eL = mCalendar->rawEvents();
1579 ev = eL.first(); 1590 ev = eL.first();
1580 while ( ev ) { 1591 while ( ev ) {
1581 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1592 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1582 ev->setReadOnly( true ); 1593 ev->setReadOnly( true );
1583 ev = eL.next(); 1594 ev = eL.next();
1584 } 1595 }
1585} 1596}
1586bool CalendarView::openCalendar(QString filename, bool merge) 1597bool CalendarView::openCalendar(QString filename, bool merge)
1587{ 1598{
1588 1599
1589 if (filename.isEmpty()) { 1600 if (filename.isEmpty()) {
1590 return false; 1601 return false;
1591 } 1602 }
1592 1603
1593 if (!QFile::exists(filename)) { 1604 if (!QFile::exists(filename)) {
1594 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1605 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1595 return false; 1606 return false;
1596 } 1607 }
1597 1608
1598 globalFlagBlockAgenda = 1; 1609 globalFlagBlockAgenda = 1;
1599 if (!merge) mCalendar->close(); 1610 if (!merge) mCalendar->close();
1600 1611
1601 mStorage->setFileName( filename ); 1612 mStorage->setFileName( filename );
1602 1613
1603 if ( mStorage->load() ) { 1614 if ( mStorage->load() ) {
1604 if ( merge ) ;//setModified( true ); 1615 if ( merge ) ;//setModified( true );
1605 else { 1616 else {
1606 //setModified( true ); 1617 //setModified( true );
1607 mViewManager->setDocumentId( filename ); 1618 mViewManager->setDocumentId( filename );
1608 mDialogManager->setDocumentId( filename ); 1619 mDialogManager->setDocumentId( filename );
1609 mTodoList->setDocumentId( filename ); 1620 mTodoList->setDocumentId( filename );
1610 } 1621 }
1611 globalFlagBlockAgenda = 2; 1622 globalFlagBlockAgenda = 2;
1612 // if ( getLastSyncEvent() ) 1623 // if ( getLastSyncEvent() )
1613 // getLastSyncEvent()->setReadOnly( true ); 1624 // getLastSyncEvent()->setReadOnly( true );
1614 mCalendar->reInitAlarmSettings(); 1625 mCalendar->reInitAlarmSettings();
1615 setSyncEventsReadOnly(); 1626 setSyncEventsReadOnly();
1616 updateUnmanagedViews(); 1627 updateUnmanagedViews();
1617 updateView(); 1628 updateView();
1618 if ( filename != MainWindow::defaultFileName() ) { 1629 if ( filename != MainWindow::defaultFileName() ) {
1619 saveCalendar( MainWindow::defaultFileName() ); 1630 saveCalendar( MainWindow::defaultFileName() );
1620 } else { 1631 } else {
1621 QFileInfo finf ( MainWindow::defaultFileName()); 1632 QFileInfo finf ( MainWindow::defaultFileName());
1622 if ( finf.exists() ) { 1633 if ( finf.exists() ) {
1623 setLoadedFileVersion( finf.lastModified () ); 1634 setLoadedFileVersion( finf.lastModified () );
1624 } 1635 }
1625 } 1636 }
1626 return true; 1637 return true;
1627 } else { 1638 } else {
1628 // while failing to load, the calendar object could 1639 // while failing to load, the calendar object could
1629 // have become partially populated. Clear it out. 1640 // have become partially populated. Clear it out.
1630 if ( !merge ) { 1641 if ( !merge ) {
1631 mCalendar->close(); 1642 mCalendar->close();
1632 mViewManager->setDocumentId( filename ); 1643 mViewManager->setDocumentId( filename );
1633 mDialogManager->setDocumentId( filename ); 1644 mDialogManager->setDocumentId( filename );
1634 mTodoList->setDocumentId( filename ); 1645 mTodoList->setDocumentId( filename );
1635 } 1646 }
1636 1647
1637 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1648 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1638 1649
1639 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1650 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1640 globalFlagBlockAgenda = 2; 1651 globalFlagBlockAgenda = 2;
1641 mCalendar->reInitAlarmSettings(); 1652 mCalendar->reInitAlarmSettings();
1642 setSyncEventsReadOnly(); 1653 setSyncEventsReadOnly();
1643 updateUnmanagedViews(); 1654 updateUnmanagedViews();
1644 updateView(); 1655 updateView();
1645 } 1656 }
1646 return false; 1657 return false;
1647} 1658}
1648void CalendarView::showOpenError() 1659void CalendarView::showOpenError()
1649{ 1660{
1650 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1661 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1651} 1662}
1652void CalendarView::setLoadedFileVersion(QDateTime dt) 1663void CalendarView::setLoadedFileVersion(QDateTime dt)
1653{ 1664{
1654 loadedFileVersion = dt; 1665 loadedFileVersion = dt;
1655} 1666}
1656bool CalendarView::checkFileChanged(QString fn) 1667bool CalendarView::checkFileChanged(QString fn)
1657{ 1668{
1658 QFileInfo finf ( fn ); 1669 QFileInfo finf ( fn );
1659 if ( !finf.exists() ) 1670 if ( !finf.exists() )
1660 return true; 1671 return true;
1661 QDateTime dt = finf.lastModified (); 1672 QDateTime dt = finf.lastModified ();
1662 if ( dt <= loadedFileVersion ) 1673 if ( dt <= loadedFileVersion )
1663 return false; 1674 return false;
1664 return true; 1675 return true;
1665 1676
1666} 1677}
1667void CalendarView::watchSavedFile() 1678void CalendarView::watchSavedFile()
1668{ 1679{
1669 QFileInfo finf ( MainWindow::defaultFileName()); 1680 QFileInfo finf ( MainWindow::defaultFileName());
1670 if ( !finf.exists() ) 1681 if ( !finf.exists() )
1671 return; 1682 return;
1672 QDateTime dt = finf.lastModified (); 1683 QDateTime dt = finf.lastModified ();
1673 if ( dt < loadedFileVersion ) { 1684 if ( dt < loadedFileVersion ) {
1674 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1685 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1675 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1686 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1676 return; 1687 return;
1677 } 1688 }
1678 loadedFileVersion = dt; 1689 loadedFileVersion = dt;
1679} 1690}
1680 1691
1681bool CalendarView::checkFileVersion(QString fn) 1692bool CalendarView::checkFileVersion(QString fn)
1682{ 1693{
1683 QFileInfo finf ( fn ); 1694 QFileInfo finf ( fn );
1684 if ( !finf.exists() ) 1695 if ( !finf.exists() )
1685 return true; 1696 return true;
1686 QDateTime dt = finf.lastModified (); 1697 QDateTime dt = finf.lastModified ();
1687 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1698 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1688 //qDebug("file on disk version %s",dt.toString().latin1()); 1699 //qDebug("file on disk version %s",dt.toString().latin1());
1689 if ( dt <= loadedFileVersion ) 1700 if ( dt <= loadedFileVersion )
1690 return true; 1701 return true;
1691 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1702 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1692 i18n("KO/Pi Warning"),i18n("Overwrite"), 1703 i18n("KO/Pi Warning"),i18n("Overwrite"),
1693 i18n("Sync+save")); 1704 i18n("Sync+save"));
1694 1705
1695 if ( km == KMessageBox::Cancel ) 1706 if ( km == KMessageBox::Cancel )
1696 return false; 1707 return false;
1697 if ( km == KMessageBox::Yes ) 1708 if ( km == KMessageBox::Yes )
1698 return true; 1709 return true;
1699 1710
1700 setSyncDevice("deleteaftersync" ); 1711 setSyncDevice("deleteaftersync" );
1701 mSyncManager->mAskForPreferences = true; 1712 mSyncManager->mAskForPreferences = true;
1702 mSyncManager->mSyncAlgoPrefs = 3; 1713 mSyncManager->mSyncAlgoPrefs = 3;
1703 mSyncManager->mWriteBackFile = false; 1714 mSyncManager->mWriteBackFile = false;
1704 mSyncManager->mWriteBackExistingOnly = false; 1715 mSyncManager->mWriteBackExistingOnly = false;
1705 mSyncManager->mShowSyncSummary = false; 1716 mSyncManager->mShowSyncSummary = false;
1706 syncCalendar( fn, 3 ); 1717 syncCalendar( fn, 3 );
1707 Event * e = getLastSyncEvent(); 1718 Event * e = getLastSyncEvent();
1708 mCalendar->deleteEvent ( e ); 1719 mCalendar->deleteEvent ( e );
1709 updateView(); 1720 updateView();
1710 return true; 1721 return true;
1711} 1722}
1712 1723
1713bool CalendarView::saveCalendar( QString filename ) 1724bool CalendarView::saveCalendar( QString filename )
1714{ 1725{
1715 1726
1716 // Store back all unsaved data into calendar object 1727 // Store back all unsaved data into calendar object
1717 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1728 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1718 if ( mViewManager->currentView() ) 1729 if ( mViewManager->currentView() )
1719 mViewManager->currentView()->flushView(); 1730 mViewManager->currentView()->flushView();
1720 1731
1721 1732
1722 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1733 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1723 mStorage->setSaveFormat( new ICalFormat() ); 1734 mStorage->setSaveFormat( new ICalFormat() );
1724 mStorage->setFileName( filename ); 1735 mStorage->setFileName( filename );
1725 bool success; 1736 bool success;
1726 success = mStorage->save(); 1737 success = mStorage->save();
1727 if ( !success ) { 1738 if ( !success ) {
1728 return false; 1739 return false;
1729 } 1740 }
1730 if ( filename == MainWindow::defaultFileName() ) { 1741 if ( filename == MainWindow::defaultFileName() ) {
1731 setLoadedFileVersion( lfv ); 1742 setLoadedFileVersion( lfv );
1732 watchSavedFile(); 1743 watchSavedFile();
1733 } 1744 }
1734 return true; 1745 return true;
1735} 1746}
1736 1747
1737void CalendarView::closeCalendar() 1748void CalendarView::closeCalendar()
1738{ 1749{
1739 1750
1740 // child windows no longer valid 1751 // child windows no longer valid
1741 emit closingDown(); 1752 emit closingDown();
1742 1753
1743 mCalendar->close(); 1754 mCalendar->close();
1744 setModified(false); 1755 setModified(false);
1745 updateView(); 1756 updateView();
1746} 1757}
1747 1758
1748void CalendarView::archiveCalendar() 1759void CalendarView::archiveCalendar()
1749{ 1760{
1750 mDialogManager->showArchiveDialog(); 1761 mDialogManager->showArchiveDialog();
1751} 1762}
1752 1763
1753 1764
1754void CalendarView::readSettings() 1765void CalendarView::readSettings()
1755{ 1766{
1756 1767
1757 1768
1758 // mViewManager->showAgendaView(); 1769 // mViewManager->showAgendaView();
1759 QString str; 1770 QString str;
1760 //qDebug("CalendarView::readSettings() "); 1771 //qDebug("CalendarView::readSettings() ");
1761 // read settings from the KConfig, supplying reasonable 1772 // read settings from the KConfig, supplying reasonable
1762 // defaults where none are to be found 1773 // defaults where none are to be found
1763 KConfig *config = KOGlobals::config(); 1774 KConfig *config = KOGlobals::config();
1764#ifndef KORG_NOSPLITTER 1775#ifndef KORG_NOSPLITTER
1765 config->setGroup("KOrganizer Geometry"); 1776 config->setGroup("KOrganizer Geometry");
1766 1777
1767 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1778 QValueList<int> sizes = config->readIntListEntry("Separator1");
1768 if (sizes.count() != 2) { 1779 if (sizes.count() != 2) {
1769 sizes << mDateNavigator->minimumSizeHint().width(); 1780 sizes << mDateNavigator->minimumSizeHint().width();
1770 sizes << 300; 1781 sizes << 300;
1771 } 1782 }
1772 mPanner->setSizes(sizes); 1783 mPanner->setSizes(sizes);
1773 1784
1774 sizes = config->readIntListEntry("Separator2"); 1785 sizes = config->readIntListEntry("Separator2");
1775 if ( ( mResourceView && sizes.count() == 4 ) || 1786 if ( ( mResourceView && sizes.count() == 4 ) ||
1776 ( !mResourceView && sizes.count() == 3 ) ) { 1787 ( !mResourceView && sizes.count() == 3 ) ) {
1777 mLeftSplitter->setSizes(sizes); 1788 mLeftSplitter->setSizes(sizes);
1778 } 1789 }
1779#endif 1790#endif
1780 globalFlagBlockAgenda = 1; 1791 globalFlagBlockAgenda = 1;
1781 mViewManager->showAgendaView(); 1792 mViewManager->showAgendaView();
1782 //mViewManager->readSettings( config ); 1793 //mViewManager->readSettings( config );
1783 mTodoList->restoreLayout(config,QString("Todo Layout")); 1794 mTodoList->restoreLayout(config,QString("Todo Layout"));
1784 readFilterSettings(config); 1795 readFilterSettings(config);
1785 config->setGroup( "Views" ); 1796 config->setGroup( "Views" );
1786 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1797 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1787 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1798 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1788 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1799 else if ( dateCount == 7 ) mNavigator->selectWeek();
1789 else mNavigator->selectDates( dateCount ); 1800 else mNavigator->selectDates( dateCount );
1790 // mViewManager->readSettings( config ); 1801 // mViewManager->readSettings( config );
1791 updateConfig(); 1802 updateConfig();
1792 globalFlagBlockAgenda = 2; 1803 globalFlagBlockAgenda = 2;
1793 mViewManager->readSettings( config ); 1804 mViewManager->readSettings( config );
1794#ifdef DESKTOP_VERSION 1805#ifdef DESKTOP_VERSION
1795 config->setGroup("WidgetLayout"); 1806 config->setGroup("WidgetLayout");
1796 QStringList list; 1807 QStringList list;
1797 list = config->readListEntry("MainLayout"); 1808 list = config->readListEntry("MainLayout");
1798 int x,y,w,h; 1809 int x,y,w,h;
1799 if ( ! list.isEmpty() ) { 1810 if ( ! list.isEmpty() ) {
1800 x = list[0].toInt(); 1811 x = list[0].toInt();
1801 y = list[1].toInt(); 1812 y = list[1].toInt();
1802 w = list[2].toInt(); 1813 w = list[2].toInt();
1803 h = list[3].toInt(); 1814 h = list[3].toInt();
1804 topLevelWidget()->setGeometry(x,y,w,h); 1815 topLevelWidget()->setGeometry(x,y,w,h);
1805 1816
1806 } else { 1817 } else {
1807 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1818 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1808 } 1819 }
1809 list = config->readListEntry("EditEventLayout"); 1820 list = config->readListEntry("EditEventLayout");
1810 if ( ! list.isEmpty() ) { 1821 if ( ! list.isEmpty() ) {
1811 x = list[0].toInt(); 1822 x = list[0].toInt();
1812 y = list[1].toInt(); 1823 y = list[1].toInt();
1813 w = list[2].toInt(); 1824 w = list[2].toInt();
1814 h = list[3].toInt(); 1825 h = list[3].toInt();
1815 mEventEditor->setGeometry(x,y,w,h); 1826 mEventEditor->setGeometry(x,y,w,h);
1816 1827
1817 } 1828 }
1818 list = config->readListEntry("EditTodoLayout"); 1829 list = config->readListEntry("EditTodoLayout");
1819 if ( ! list.isEmpty() ) { 1830 if ( ! list.isEmpty() ) {
1820 x = list[0].toInt(); 1831 x = list[0].toInt();
1821 y = list[1].toInt(); 1832 y = list[1].toInt();
1822 w = list[2].toInt(); 1833 w = list[2].toInt();
1823 h = list[3].toInt(); 1834 h = list[3].toInt();
1824 mTodoEditor->setGeometry(x,y,w,h); 1835 mTodoEditor->setGeometry(x,y,w,h);
1825 1836
1826 } 1837 }
1827 list = config->readListEntry("ViewerLayout"); 1838 list = config->readListEntry("ViewerLayout");
1828 if ( ! list.isEmpty() ) { 1839 if ( ! list.isEmpty() ) {
1829 x = list[0].toInt(); 1840 x = list[0].toInt();
1830 y = list[1].toInt(); 1841 y = list[1].toInt();
1831 w = list[2].toInt(); 1842 w = list[2].toInt();
1832 h = list[3].toInt(); 1843 h = list[3].toInt();
1833 getEventViewerDialog()->setGeometry(x,y,w,h); 1844 getEventViewerDialog()->setGeometry(x,y,w,h);
1834 } 1845 }
1835#endif 1846#endif
1836 1847
1837} 1848}
1838 1849
1839 1850
1840void CalendarView::writeSettings() 1851void CalendarView::writeSettings()
1841{ 1852{
1842 // kdDebug() << "CalendarView::writeSettings" << endl; 1853 // kdDebug() << "CalendarView::writeSettings" << endl;
1843 1854
1844 KConfig *config = KOGlobals::config(); 1855 KConfig *config = KOGlobals::config();
1845 1856
1846#ifndef KORG_NOSPLITTER 1857#ifndef KORG_NOSPLITTER
1847 config->setGroup("KOrganizer Geometry"); 1858 config->setGroup("KOrganizer Geometry");
1848 1859
1849 QValueList<int> list = mPanner->sizes(); 1860 QValueList<int> list = mPanner->sizes();
1850 config->writeEntry("Separator1",list); 1861 config->writeEntry("Separator1",list);
1851 1862
1852 list = mLeftSplitter->sizes(); 1863 list = mLeftSplitter->sizes();
1853 config->writeEntry("Separator2",list); 1864 config->writeEntry("Separator2",list);
1854#endif 1865#endif
1855 1866
1856 mViewManager->writeSettings( config ); 1867 mViewManager->writeSettings( config );
1857 mTodoList->saveLayout(config,QString("Todo Layout")); 1868 mTodoList->saveLayout(config,QString("Todo Layout"));
1858 mDialogManager->writeSettings( config ); 1869 mDialogManager->writeSettings( config );
1859 //KOPrefs::instance()->usrWriteConfig(); 1870 //KOPrefs::instance()->usrWriteConfig();
1860 KOPrefs::instance()->writeConfig(); 1871 KOPrefs::instance()->writeConfig();
1861 1872
1862 writeFilterSettings(config); 1873 writeFilterSettings(config);
1863 1874
1864 config->setGroup( "Views" ); 1875 config->setGroup( "Views" );
1865 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1876 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1866 1877
1867#ifdef DESKTOP_VERSION 1878#ifdef DESKTOP_VERSION
1868 config->setGroup("WidgetLayout"); 1879 config->setGroup("WidgetLayout");
1869 QStringList list ;//= config->readListEntry("MainLayout"); 1880 QStringList list ;//= config->readListEntry("MainLayout");
1870 int x,y,w,h; 1881 int x,y,w,h;
1871 QWidget* wid; 1882 QWidget* wid;
1872 wid = topLevelWidget(); 1883 wid = topLevelWidget();
1873 x = wid->geometry().x(); 1884 x = wid->geometry().x();
1874 y = wid->geometry().y(); 1885 y = wid->geometry().y();
1875 w = wid->width(); 1886 w = wid->width();
1876 h = wid->height(); 1887 h = wid->height();
1877 list.clear(); 1888 list.clear();
1878 list << QString::number( x ); 1889 list << QString::number( x );
1879 list << QString::number( y ); 1890 list << QString::number( y );
1880 list << QString::number( w ); 1891 list << QString::number( w );
1881 list << QString::number( h ); 1892 list << QString::number( h );
1882 config->writeEntry("MainLayout",list ); 1893 config->writeEntry("MainLayout",list );
1883 1894
1884 wid = mEventEditor; 1895 wid = mEventEditor;
1885 x = wid->geometry().x(); 1896 x = wid->geometry().x();
1886 y = wid->geometry().y(); 1897 y = wid->geometry().y();
1887 w = wid->width(); 1898 w = wid->width();
1888 h = wid->height(); 1899 h = wid->height();
1889 list.clear(); 1900 list.clear();
1890 list << QString::number( x ); 1901 list << QString::number( x );
1891 list << QString::number( y ); 1902 list << QString::number( y );
1892 list << QString::number( w ); 1903 list << QString::number( w );
1893 list << QString::number( h ); 1904 list << QString::number( h );
1894 config->writeEntry("EditEventLayout",list ); 1905 config->writeEntry("EditEventLayout",list );
1895 1906
1896 wid = mTodoEditor; 1907 wid = mTodoEditor;
1897 x = wid->geometry().x(); 1908 x = wid->geometry().x();
1898 y = wid->geometry().y(); 1909 y = wid->geometry().y();
1899 w = wid->width(); 1910 w = wid->width();
1900 h = wid->height(); 1911 h = wid->height();
1901 list.clear(); 1912 list.clear();
1902 list << QString::number( x ); 1913 list << QString::number( x );
1903 list << QString::number( y ); 1914 list << QString::number( y );
1904 list << QString::number( w ); 1915 list << QString::number( w );
1905 list << QString::number( h ); 1916 list << QString::number( h );
1906 config->writeEntry("EditTodoLayout",list ); 1917 config->writeEntry("EditTodoLayout",list );
1907 wid = getEventViewerDialog(); 1918 wid = getEventViewerDialog();
1908 x = wid->geometry().x(); 1919 x = wid->geometry().x();
1909 y = wid->geometry().y(); 1920 y = wid->geometry().y();
1910 w = wid->width(); 1921 w = wid->width();
1911 h = wid->height(); 1922 h = wid->height();
1912 list.clear(); 1923 list.clear();
1913 list << QString::number( x ); 1924 list << QString::number( x );
1914 list << QString::number( y ); 1925 list << QString::number( y );
1915 list << QString::number( w ); 1926 list << QString::number( w );
1916 list << QString::number( h ); 1927 list << QString::number( h );
1917 config->writeEntry("ViewerLayout",list ); 1928 config->writeEntry("ViewerLayout",list );
1918 wid = mDialogManager->getSearchDialog(); 1929 wid = mDialogManager->getSearchDialog();
1919 if ( wid ) { 1930 if ( wid ) {
1920 x = wid->geometry().x(); 1931 x = wid->geometry().x();
1921 y = wid->geometry().y(); 1932 y = wid->geometry().y();
1922 w = wid->width(); 1933 w = wid->width();
1923 h = wid->height(); 1934 h = wid->height();
1924 list.clear(); 1935 list.clear();
1925 list << QString::number( x ); 1936 list << QString::number( x );
1926 list << QString::number( y ); 1937 list << QString::number( y );
1927 list << QString::number( w ); 1938 list << QString::number( w );
1928 list << QString::number( h ); 1939 list << QString::number( h );
1929 config->writeEntry("SearchLayout",list ); 1940 config->writeEntry("SearchLayout",list );
1930 } 1941 }
1931#endif 1942#endif
1932 1943
1933 1944
1934 config->sync(); 1945 config->sync();
1935} 1946}
1936 1947
1937void CalendarView::readFilterSettings(KConfig *config) 1948void CalendarView::readFilterSettings(KConfig *config)
1938{ 1949{
1939 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1950 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1940 1951
1941 mFilters.clear(); 1952 mFilters.clear();
1942 1953
1943 config->setGroup("General"); 1954 config->setGroup("General");
1944 QStringList filterList = config->readListEntry("CalendarFilters"); 1955 QStringList filterList = config->readListEntry("CalendarFilters");
1945 1956
1946 QStringList::ConstIterator it = filterList.begin(); 1957 QStringList::ConstIterator it = filterList.begin();
1947 QStringList::ConstIterator end = filterList.end(); 1958 QStringList::ConstIterator end = filterList.end();
1948 while(it != end) { 1959 while(it != end) {
1949 // kdDebug() << " filter: " << (*it) << endl; 1960 // kdDebug() << " filter: " << (*it) << endl;
1950 1961
1951 CalFilter *filter; 1962 CalFilter *filter;
1952 filter = new CalFilter(*it); 1963 filter = new CalFilter(*it);
1953 config->setGroup("Filter_" + (*it)); 1964 config->setGroup("Filter_" + (*it));
1954 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1965 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1955 filter->setCriteria(config->readNumEntry("Criteria",0)); 1966 filter->setCriteria(config->readNumEntry("Criteria",0));
1956 filter->setCategoryList(config->readListEntry("CategoryList")); 1967 filter->setCategoryList(config->readListEntry("CategoryList"));
1957 mFilters.append(filter); 1968 mFilters.append(filter);
1958 1969
1959 ++it; 1970 ++it;
1960 } 1971 }
1961 1972
1962 if (mFilters.count() == 0) { 1973 if (mFilters.count() == 0) {
1963 CalFilter *filter = new CalFilter(i18n("Default")); 1974 CalFilter *filter = new CalFilter(i18n("Default"));
1964 mFilters.append(filter); 1975 mFilters.append(filter);
1965 } 1976 }
1966 mFilterView->updateFilters(); 1977 mFilterView->updateFilters();
1967 config->setGroup("FilterView"); 1978 config->setGroup("FilterView");
1968 1979
1969 mFilterView->blockSignals(true); 1980 mFilterView->blockSignals(true);
1970 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1981 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1971 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1982 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1972 mFilterView->blockSignals(false); 1983 mFilterView->blockSignals(false);
1973 // We do it manually to avoid it being done twice by the above calls 1984 // We do it manually to avoid it being done twice by the above calls
1974 updateFilter(); 1985 updateFilter();
1975} 1986}
1976 1987
1977void CalendarView::writeFilterSettings(KConfig *config) 1988void CalendarView::writeFilterSettings(KConfig *config)
1978{ 1989{
1979 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1990 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1980 1991
1981 QStringList filterList; 1992 QStringList filterList;
1982 1993
1983 CalFilter *filter = mFilters.first(); 1994 CalFilter *filter = mFilters.first();
1984 while(filter) { 1995 while(filter) {
1985 // kdDebug() << " fn: " << filter->name() << endl; 1996 // kdDebug() << " fn: " << filter->name() << endl;
1986 filterList << filter->name(); 1997 filterList << filter->name();
1987 config->setGroup("Filter_" + filter->name()); 1998 config->setGroup("Filter_" + filter->name());
1988 config->writeEntry("Criteria",filter->criteria()); 1999 config->writeEntry("Criteria",filter->criteria());
1989 config->writeEntry("CategoryList",filter->categoryList()); 2000 config->writeEntry("CategoryList",filter->categoryList());
1990 filter = mFilters.next(); 2001 filter = mFilters.next();
1991 } 2002 }
1992 config->setGroup("General"); 2003 config->setGroup("General");
1993 config->writeEntry("CalendarFilters",filterList); 2004 config->writeEntry("CalendarFilters",filterList);
1994 2005
1995 config->setGroup("FilterView"); 2006 config->setGroup("FilterView");
1996 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2007 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1997 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2008 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1998} 2009}
1999 2010
2000 2011
2001void CalendarView::goToday() 2012void CalendarView::goToday()
2002{ 2013{
2003 if ( mViewManager->currentView()->isMonthView() ) 2014 if ( mViewManager->currentView()->isMonthView() )
2004 mNavigator->selectTodayMonth(); 2015 mNavigator->selectTodayMonth();
2005 else 2016 else
2006 mNavigator->selectToday(); 2017 mNavigator->selectToday();
2007} 2018}
2008 2019
2009void CalendarView::goNext() 2020void CalendarView::goNext()
2010{ 2021{
2011 mNavigator->selectNext(); 2022 mNavigator->selectNext();
2012} 2023}
2013 2024
2014void CalendarView::goPrevious() 2025void CalendarView::goPrevious()
2015{ 2026{
2016 mNavigator->selectPrevious(); 2027 mNavigator->selectPrevious();
2017} 2028}
2018void CalendarView::goNextMonth() 2029void CalendarView::goNextMonth()
2019{ 2030{
2020 mNavigator->selectNextMonth(); 2031 mNavigator->selectNextMonth();
2021} 2032}
2022 2033
2023void CalendarView::goPreviousMonth() 2034void CalendarView::goPreviousMonth()
2024{ 2035{
2025 mNavigator->selectPreviousMonth(); 2036 mNavigator->selectPreviousMonth();
2026} 2037}
2027void CalendarView::writeLocale() 2038void CalendarView::writeLocale()
2028{ 2039{
2029 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2040 //KPimGlobalPrefs::instance()->setGlobalConfig();
2030#if 0 2041#if 0
2031 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2042 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2032 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2043 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2033 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2044 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2034 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2045 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2035 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2046 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2036 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2047 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2037 dummy = KOPrefs::instance()->mUserDateFormatShort; 2048 dummy = KOPrefs::instance()->mUserDateFormatShort;
2038 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2049 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2039 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2050 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2040 KOPrefs::instance()->mDaylightsavingStart, 2051 KOPrefs::instance()->mDaylightsavingStart,
2041 KOPrefs::instance()->mDaylightsavingEnd ); 2052 KOPrefs::instance()->mDaylightsavingEnd );
2042 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2053 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2043#endif 2054#endif
2044} 2055}
2045void CalendarView::updateConfig() 2056void CalendarView::updateConfig()
2046{ 2057{
2047 writeLocale(); 2058 writeLocale();
2048 if ( KOPrefs::instance()->mUseAppColors ) 2059 if ( KOPrefs::instance()->mUseAppColors )
2049 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2060 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2050 emit configChanged(); 2061 emit configChanged();
2051 mTodoList->updateConfig(); 2062 mTodoList->updateConfig();
2052 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2063 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2053 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2064 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2054 // To make the "fill window" configurations work 2065 // To make the "fill window" configurations work
2055 //mViewManager->raiseCurrentView(); 2066 //mViewManager->raiseCurrentView();
2056} 2067}
2057 2068
2058 2069
2059void CalendarView::eventChanged(Event *event) 2070void CalendarView::eventChanged(Event *event)
2060{ 2071{
2061 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2072 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2062 //updateUnmanagedViews(); 2073 //updateUnmanagedViews();
2063} 2074}
2064 2075
2065void CalendarView::eventAdded(Event *event) 2076void CalendarView::eventAdded(Event *event)
2066{ 2077{
2067 changeEventDisplay(event,KOGlobals::EVENTADDED); 2078 changeEventDisplay(event,KOGlobals::EVENTADDED);
2068} 2079}
2069 2080
2070void CalendarView::eventToBeDeleted(Event *) 2081void CalendarView::eventToBeDeleted(Event *)
2071{ 2082{
2072 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2083 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2073} 2084}
2074 2085
2075void CalendarView::eventDeleted() 2086void CalendarView::eventDeleted()
2076{ 2087{
2077 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2088 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2078} 2089}
2079void CalendarView::changeTodoDisplay(Todo *which, int action) 2090void CalendarView::changeTodoDisplay(Todo *which, int action)
2080{ 2091{
2081 changeIncidenceDisplay((Incidence *)which, action); 2092 changeIncidenceDisplay((Incidence *)which, action);
2082 mDateNavigator->updateView(); //LR 2093 mDateNavigator->updateView(); //LR
2083 //mDialogManager->updateSearchDialog(); 2094 //mDialogManager->updateSearchDialog();
2084 2095
2085 if (which) { 2096 if (which) {
2086 mViewManager->updateWNview(); 2097 mViewManager->updateWNview();
2087 //mTodoList->updateView(); 2098 //mTodoList->updateView();
2088 } 2099 }
2089 2100
2090} 2101}
2091 2102
2092void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2103void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2093{ 2104{
2094 updateUnmanagedViews(); 2105 updateUnmanagedViews();
2095 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2106 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2096 if ( action == KOGlobals::EVENTDELETED ) { //delete 2107 if ( action == KOGlobals::EVENTDELETED ) { //delete
2097 mCalendar->checkAlarmForIncidence( 0, true ); 2108 mCalendar->checkAlarmForIncidence( 0, true );
2098 if ( mEventViewerDialog ) 2109 if ( mEventViewerDialog )
2099 mEventViewerDialog->hide(); 2110 mEventViewerDialog->hide();
2100 } 2111 }
2101 else 2112 else
2102 mCalendar->checkAlarmForIncidence( which , false ); 2113 mCalendar->checkAlarmForIncidence( which , false );
2103} 2114}
2104 2115
2105// most of the changeEventDisplays() right now just call the view's 2116// most of the changeEventDisplays() right now just call the view's
2106// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2117// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2107void CalendarView::changeEventDisplay(Event *which, int action) 2118void CalendarView::changeEventDisplay(Event *which, int action)
2108{ 2119{
2109 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2120 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2110 changeIncidenceDisplay((Incidence *)which, action); 2121 changeIncidenceDisplay((Incidence *)which, action);
2111 mDateNavigator->updateView(); 2122 mDateNavigator->updateView();
2112 //mDialogManager->updateSearchDialog(); 2123 //mDialogManager->updateSearchDialog();
2113 2124
2114 if (which) { 2125 if (which) {
2115 // If there is an event view visible update the display 2126 // If there is an event view visible update the display
2116 mViewManager->currentView()->changeEventDisplay(which,action); 2127 mViewManager->currentView()->changeEventDisplay(which,action);
2117 // TODO: check, if update needed 2128 // TODO: check, if update needed
2118 // if (which->getTodoStatus()) { 2129 // if (which->getTodoStatus()) {
2119 mTodoList->updateView(); 2130 mTodoList->updateView();
2120 // } 2131 // }
2121 } else { 2132 } else {
2122 mViewManager->currentView()->updateView(); 2133 mViewManager->currentView()->updateView();
2123 } 2134 }
2124} 2135}
2125 2136
2126 2137
2127void CalendarView::updateTodoViews() 2138void CalendarView::updateTodoViews()
2128{ 2139{
2129 2140
2130 mTodoList->updateView(); 2141 mTodoList->updateView();
2131 mViewManager->currentView()->updateView(); 2142 mViewManager->currentView()->updateView();
2132 2143
2133} 2144}
2134 2145
2135 2146
2136void CalendarView::updateView(const QDate &start, const QDate &end) 2147void CalendarView::updateView(const QDate &start, const QDate &end)
2137{ 2148{
2138 mTodoList->updateView(); 2149 mTodoList->updateView();
2139 mViewManager->updateView(start, end); 2150 mViewManager->updateView(start, end);
2140 //mDateNavigator->updateView(); 2151 //mDateNavigator->updateView();
2141} 2152}
2142 2153
2143void CalendarView::updateView() 2154void CalendarView::updateView()
2144{ 2155{
2145 DateList tmpList = mNavigator->selectedDates(); 2156 DateList tmpList = mNavigator->selectedDates();
2146 2157
2147 // We assume that the navigator only selects consecutive days. 2158 // We assume that the navigator only selects consecutive days.
2148 updateView( tmpList.first(), tmpList.last() ); 2159 updateView( tmpList.first(), tmpList.last() );
2149 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2160 if ( KOPrefs::instance()->mHideNonStartedTodos )
2150 mTodoList->updateView(); 2161 mTodoList->updateView();
2151} 2162}
2152 2163
2153void CalendarView::updateUnmanagedViews() 2164void CalendarView::updateUnmanagedViews()
2154{ 2165{
2155 mDateNavigator->updateDayMatrix(); 2166 mDateNavigator->updateDayMatrix();
2156} 2167}
2157 2168
2158int CalendarView::msgItemDelete() 2169int CalendarView::msgItemDelete()
2159{ 2170{
2160 return KMessageBox::warningContinueCancel(this, 2171 return KMessageBox::warningContinueCancel(this,
2161 i18n("This item will be\npermanently deleted."), 2172 i18n("This item will be\npermanently deleted."),
2162 i18n("KO/Pi Confirmation"),i18n("Delete")); 2173 i18n("KO/Pi Confirmation"),i18n("Delete"));
2163} 2174}
2164 2175
2165 2176
2166void CalendarView::edit_cut() 2177void CalendarView::edit_cut()
2167{ 2178{
2168 Event *anEvent=0; 2179 Event *anEvent=0;
2169 2180
2170 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2181 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2171 2182
2172 if (mViewManager->currentView()->isEventView()) { 2183 if (mViewManager->currentView()->isEventView()) {
2173 if ( incidence && incidence->type() == "Event" ) { 2184 if ( incidence && incidence->type() == "Event" ) {
2174 anEvent = static_cast<Event *>(incidence); 2185 anEvent = static_cast<Event *>(incidence);
2175 } 2186 }
2176 } 2187 }
2177 2188
2178 if (!anEvent) { 2189 if (!anEvent) {
2179 KNotifyClient::beep(); 2190 KNotifyClient::beep();
2180 return; 2191 return;
2181 } 2192 }
2182 DndFactory factory( mCalendar ); 2193 DndFactory factory( mCalendar );
2183 factory.cutEvent(anEvent); 2194 factory.cutEvent(anEvent);
2184 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2195 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2185} 2196}
2186 2197
2187void CalendarView::edit_copy() 2198void CalendarView::edit_copy()
2188{ 2199{
2189 Event *anEvent=0; 2200 Event *anEvent=0;
2190 2201
2191 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2202 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2192 2203
2193 if (mViewManager->currentView()->isEventView()) { 2204 if (mViewManager->currentView()->isEventView()) {
2194 if ( incidence && incidence->type() == "Event" ) { 2205 if ( incidence && incidence->type() == "Event" ) {
2195 anEvent = static_cast<Event *>(incidence); 2206 anEvent = static_cast<Event *>(incidence);
2196 } 2207 }
2197 } 2208 }
2198 2209
2199 if (!anEvent) { 2210 if (!anEvent) {
2200 KNotifyClient::beep(); 2211 KNotifyClient::beep();
2201 return; 2212 return;
2202 } 2213 }
2203 DndFactory factory( mCalendar ); 2214 DndFactory factory( mCalendar );
2204 factory.copyEvent(anEvent); 2215 factory.copyEvent(anEvent);
2205} 2216}
2206 2217
2207void CalendarView::edit_paste() 2218void CalendarView::edit_paste()
2208{ 2219{
2209 QDate date = mNavigator->selectedDates().first(); 2220 QDate date = mNavigator->selectedDates().first();
2210 2221
2211 DndFactory factory( mCalendar ); 2222 DndFactory factory( mCalendar );
2212 Event *pastedEvent = factory.pasteEvent( date ); 2223 Event *pastedEvent = factory.pasteEvent( date );
2213 2224
2214 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2225 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2215} 2226}
2216 2227
2217void CalendarView::edit_options() 2228void CalendarView::edit_options()
2218{ 2229{
2219 mDialogManager->showOptionsDialog(); 2230 mDialogManager->showOptionsDialog();
2220 //writeSettings(); 2231 //writeSettings();
2221} 2232}
2222 2233
2223 2234
2224void CalendarView::slotSelectPickerDate( QDate d) 2235void CalendarView::slotSelectPickerDate( QDate d)
2225{ 2236{
2226 mDateFrame->hide(); 2237 mDateFrame->hide();
2227 if ( mDatePickerMode == 1 ) { 2238 if ( mDatePickerMode == 1 ) {
2228 mNavigator->slotDaySelect( d ); 2239 mNavigator->slotDaySelect( d );
2229 } else if ( mDatePickerMode == 2 ) { 2240 } else if ( mDatePickerMode == 2 ) {
2230 if ( mMoveIncidence->type() == "Todo" ) { 2241 if ( mMoveIncidence->type() == "Todo" ) {
2231 Todo * to = (Todo *) mMoveIncidence; 2242 Todo * to = (Todo *) mMoveIncidence;
2232 QTime tim; 2243 QTime tim;
2233 if ( to->hasDueDate() ) 2244 if ( to->hasDueDate() )
2234 tim = to->dtDue().time(); 2245 tim = to->dtDue().time();
2235 else { 2246 else {
2236 tim = QTime ( 0,0,0 ); 2247 tim = QTime ( 0,0,0 );
2237 to->setFloats( true ); 2248 to->setFloats( true );
2238 to->setHasDueDate( true ); 2249 to->setHasDueDate( true );
2239 } 2250 }
2240 QDateTime dt ( d,tim ); 2251 QDateTime dt ( d,tim );
2241 to->setDtDue( dt ); 2252 to->setDtDue( dt );
2242 todoChanged( to ); 2253 todoChanged( to );
2243 } else { 2254 } else {
2244 if ( mMoveIncidence->doesRecur() ) { 2255 if ( mMoveIncidence->doesRecur() ) {
2245#if 0 2256#if 0
2246 // PENDING implement this 2257 // PENDING implement this
2247 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2258 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2248 mCalendar()->addIncidence( newInc ); 2259 mCalendar()->addIncidence( newInc );
2249 if ( mMoveIncidence->type() == "Todo" ) 2260 if ( mMoveIncidence->type() == "Todo" )
2250 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2261 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2251 else 2262 else
2252 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2263 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2253 mMoveIncidence = newInc; 2264 mMoveIncidence = newInc;
2254 2265
2255#endif 2266#endif
2256 } 2267 }
2257 QTime tim = mMoveIncidence->dtStart().time(); 2268 QTime tim = mMoveIncidence->dtStart().time();
2258 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2269 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2259 QDateTime dt ( d,tim ); 2270 QDateTime dt ( d,tim );
2260 mMoveIncidence->setDtStart( dt ); 2271 mMoveIncidence->setDtStart( dt );
2261 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2272 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2262 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2273 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2263 } 2274 }
2264 2275
2265 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2276 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2266 } 2277 }
2267} 2278}
2268 2279
2269void CalendarView::removeCategories() 2280void CalendarView::removeCategories()
2270{ 2281{
2271 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2282 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2272 QStringList catList = KOPrefs::instance()->mCustomCategories; 2283 QStringList catList = KOPrefs::instance()->mCustomCategories;
2273 QStringList catIncList; 2284 QStringList catIncList;
2274 QStringList newCatList; 2285 QStringList newCatList;
2275 Incidence* inc = incList.first(); 2286 Incidence* inc = incList.first();
2276 int i; 2287 int i;
2277 int count = 0; 2288 int count = 0;
2278 while ( inc ) { 2289 while ( inc ) {
2279 newCatList.clear(); 2290 newCatList.clear();
2280 catIncList = inc->categories() ; 2291 catIncList = inc->categories() ;
2281 for( i = 0; i< catIncList.count(); ++i ) { 2292 for( i = 0; i< catIncList.count(); ++i ) {
2282 if ( catList.contains (catIncList[i])) 2293 if ( catList.contains (catIncList[i]))
2283 newCatList.append( catIncList[i] ); 2294 newCatList.append( catIncList[i] );
2284 } 2295 }
2285 newCatList.sort(); 2296 newCatList.sort();
2286 inc->setCategories( newCatList.join(",") ); 2297 inc->setCategories( newCatList.join(",") );
2287 inc = incList.next(); 2298 inc = incList.next();
2288 } 2299 }
2289} 2300}
2290 2301
2291int CalendarView::addCategories() 2302int CalendarView::addCategories()
2292{ 2303{
2293 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2304 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2294 QStringList catList = KOPrefs::instance()->mCustomCategories; 2305 QStringList catList = KOPrefs::instance()->mCustomCategories;
2295 QStringList catIncList; 2306 QStringList catIncList;
2296 Incidence* inc = incList.first(); 2307 Incidence* inc = incList.first();
2297 int i; 2308 int i;
2298 int count = 0; 2309 int count = 0;
2299 while ( inc ) { 2310 while ( inc ) {
2300 catIncList = inc->categories() ; 2311 catIncList = inc->categories() ;
2301 for( i = 0; i< catIncList.count(); ++i ) { 2312 for( i = 0; i< catIncList.count(); ++i ) {
2302 if ( !catList.contains (catIncList[i])) { 2313 if ( !catList.contains (catIncList[i])) {
2303 catList.append( catIncList[i] ); 2314 catList.append( catIncList[i] );
2304 //qDebug("add cat %s ", catIncList[i].latin1()); 2315 //qDebug("add cat %s ", catIncList[i].latin1());
2305 ++count; 2316 ++count;
2306 } 2317 }
2307 } 2318 }
2308 inc = incList.next(); 2319 inc = incList.next();
2309 } 2320 }
2310 catList.sort(); 2321 catList.sort();
2311 KOPrefs::instance()->mCustomCategories = catList; 2322 KOPrefs::instance()->mCustomCategories = catList;
2312 return count; 2323 return count;
2313} 2324}
2314 2325
2315void CalendarView::manageCategories() 2326void CalendarView::manageCategories()
2316{ 2327{
2317 KOCatPrefs* cp = new KOCatPrefs(); 2328 KOCatPrefs* cp = new KOCatPrefs();
2318 cp->show(); 2329 cp->show();
2319 int w =cp->sizeHint().width() ; 2330 int w =cp->sizeHint().width() ;
2320 int h = cp->sizeHint().height() ; 2331 int h = cp->sizeHint().height() ;
2321 int dw = QApplication::desktop()->width(); 2332 int dw = QApplication::desktop()->width();
2322 int dh = QApplication::desktop()->height(); 2333 int dh = QApplication::desktop()->height();
2323 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2334 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2324 if ( !cp->exec() ) { 2335 if ( !cp->exec() ) {
2325 delete cp; 2336 delete cp;
2326 return; 2337 return;
2327 } 2338 }
2328 int count = 0; 2339 int count = 0;
2329 if ( cp->addCat() ) { 2340 if ( cp->addCat() ) {
2330 count = addCategories(); 2341 count = addCategories();
2331 if ( count ) { 2342 if ( count ) {
2332 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2343 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2333 writeSettings(); 2344 writeSettings();
2334 } else 2345 } else
2335 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2346 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2336 } else { 2347 } else {
2337 removeCategories(); 2348 removeCategories();
2338 updateView(); 2349 updateView();
2339 } 2350 }
2340 delete cp; 2351 delete cp;
2341} 2352}
2342 2353
2343void CalendarView::beamIncidence(Incidence * Inc) 2354void CalendarView::beamIncidence(Incidence * Inc)
2344{ 2355{
2345 QPtrList<Incidence> delSel ; 2356 QPtrList<Incidence> delSel ;
2346 delSel.append(Inc); 2357 delSel.append(Inc);
2347 beamIncidenceList( delSel ); 2358 beamIncidenceList( delSel );
2348} 2359}
2349void CalendarView::beamCalendar() 2360void CalendarView::beamCalendar()
2350{ 2361{
2351 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2362 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2352 //qDebug("beamCalendar() "); 2363 //qDebug("beamCalendar() ");
2353 beamIncidenceList( delSel ); 2364 beamIncidenceList( delSel );
2354} 2365}
2355void CalendarView::beamFilteredCalendar() 2366void CalendarView::beamFilteredCalendar()
2356{ 2367{
2357 QPtrList<Incidence> delSel = mCalendar->incidences(); 2368 QPtrList<Incidence> delSel = mCalendar->incidences();
2358 //qDebug("beamFilteredCalendar() "); 2369 //qDebug("beamFilteredCalendar() ");
2359 beamIncidenceList( delSel ); 2370 beamIncidenceList( delSel );
2360} 2371}
2361void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2372void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2362{ 2373{
2363 if ( beamDialog->exec () == QDialog::Rejected ) 2374 if ( beamDialog->exec () == QDialog::Rejected )
2364 return; 2375 return;
2365#ifdef DESKTOP_VERSION 2376#ifdef DESKTOP_VERSION
2366 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2377 QString fn = locateLocal( "tmp", "kopibeamfile" );
2367#else 2378#else
2368 QString fn = "/tmp/kopibeamfile"; 2379 QString fn = "/tmp/kopibeamfile";
2369#endif 2380#endif
2370 QString mes; 2381 QString mes;
2371 bool createbup = true; 2382 bool createbup = true;
2372 if ( createbup ) { 2383 if ( createbup ) {
2373 QString description = "\n"; 2384 QString description = "\n";
2374 CalendarLocal* cal = new CalendarLocal(); 2385 CalendarLocal* cal = new CalendarLocal();
2375 if ( beamDialog->beamLocal() ) 2386 if ( beamDialog->beamLocal() )
2376 cal->setLocalTime(); 2387 cal->setLocalTime();
2377 else 2388 else
2378 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2389 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2379 Incidence *incidence = delSel.first(); 2390 Incidence *incidence = delSel.first();
2380 bool addText = false; 2391 bool addText = false;
2381 if ( delSel.count() < 10 ) 2392 if ( delSel.count() < 10 )
2382 addText = true; 2393 addText = true;
2383 else { 2394 else {
2384 description.sprintf(i18n(" %d items?"),delSel.count() ); 2395 description.sprintf(i18n(" %d items?"),delSel.count() );
2385 } 2396 }
2386 while ( incidence ) { 2397 while ( incidence ) {
2387 Incidence *in = incidence->clone(); 2398 Incidence *in = incidence->clone();
2388 if ( ! in->summary().isEmpty() ) { 2399 if ( ! in->summary().isEmpty() ) {
2389 in->setDescription(""); 2400 in->setDescription("");
2390 } else { 2401 } else {
2391 in->setSummary( in->description().left(20)); 2402 in->setSummary( in->description().left(20));
2392 in->setDescription(""); 2403 in->setDescription("");
2393 } 2404 }
2394 if ( addText ) 2405 if ( addText )
2395 description += in->summary() + "\n"; 2406 description += in->summary() + "\n";
2396 cal->addIncidence( in ); 2407 cal->addIncidence( in );
2397 incidence = delSel.next(); 2408 incidence = delSel.next();
2398 } 2409 }
2399 if ( beamDialog->beamVcal() ) { 2410 if ( beamDialog->beamVcal() ) {
2400 fn += ".vcs"; 2411 fn += ".vcs";
2401 FileStorage storage( cal, fn, new VCalFormat ); 2412 FileStorage storage( cal, fn, new VCalFormat );
2402 storage.save(); 2413 storage.save();
2403 } else { 2414 } else {
2404 fn += ".ics"; 2415 fn += ".ics";
2405 FileStorage storage( cal, fn, new ICalFormat( ) ); 2416 FileStorage storage( cal, fn, new ICalFormat( ) );
2406 storage.save(); 2417 storage.save();
2407 } 2418 }
2408 delete cal; 2419 delete cal;
2409 mes = i18n("KO/Pi: Ready for beaming"); 2420 mes = i18n("KO/Pi: Ready for beaming");
2410 topLevelWidget()->setCaption(mes); 2421 topLevelWidget()->setCaption(mes);
2411 KApplication::convert2latin1( fn ); 2422 KApplication::convert2latin1( fn );
2412#ifndef DESKTOP_VERSION 2423#ifndef DESKTOP_VERSION
2413 Ir *ir = new Ir( this ); 2424 Ir *ir = new Ir( this );
2414 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2425 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2415 ir->send( fn, description, "text/x-vCalendar" ); 2426 ir->send( fn, description, "text/x-vCalendar" );
2416#endif 2427#endif
2417 } 2428 }
2418} 2429}
2419void CalendarView::beamDone( Ir *ir ) 2430void CalendarView::beamDone( Ir *ir )
2420{ 2431{
2421#ifndef DESKTOP_VERSION 2432#ifndef DESKTOP_VERSION
2422 delete ir; 2433 delete ir;
2423#endif 2434#endif
2424 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2435 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2425 topLevelWidget()->raise(); 2436 topLevelWidget()->raise();
2426} 2437}
2427 2438
2428void CalendarView::moveIncidence(Incidence * inc ) 2439void CalendarView::moveIncidence(Incidence * inc )
2429{ 2440{
2430 if ( !inc ) return; 2441 if ( !inc ) return;
2431 // qDebug("showDatePickerForIncidence( ) "); 2442 // qDebug("showDatePickerForIncidence( ) ");
2432 if ( mDateFrame->isVisible() ) 2443 if ( mDateFrame->isVisible() )
2433 mDateFrame->hide(); 2444 mDateFrame->hide();
2434 else { 2445 else {
2435 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2446 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2436 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2447 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2437 int dw = QApplication::desktop()->width(); 2448 int dw = QApplication::desktop()->width();
2438 int dh = QApplication::desktop()->height(); 2449 int dh = QApplication::desktop()->height();
2439 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2450 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2440 mDateFrame->show(); 2451 mDateFrame->show();
2441 } 2452 }
2442 mDatePickerMode = 2; 2453 mDatePickerMode = 2;
2443 mMoveIncidence = inc ; 2454 mMoveIncidence = inc ;
2444 QDate da; 2455 QDate da;
2445 if ( mMoveIncidence->type() == "Todo" ) { 2456 if ( mMoveIncidence->type() == "Todo" ) {
2446 Todo * to = (Todo *) mMoveIncidence; 2457 Todo * to = (Todo *) mMoveIncidence;
2447 if ( to->hasDueDate() ) 2458 if ( to->hasDueDate() )
2448 da = to->dtDue().date(); 2459 da = to->dtDue().date();
2449 else 2460 else
2450 da = QDate::currentDate(); 2461 da = QDate::currentDate();
2451 } else { 2462 } else {
2452 da = mMoveIncidence->dtStart().date(); 2463 da = mMoveIncidence->dtStart().date();
2453 } 2464 }
2454 //PENDING set date for recurring incidence to date of recurrence 2465 //PENDING set date for recurring incidence to date of recurrence
2455 //mMoveIncidenceOldDate; 2466 //mMoveIncidenceOldDate;
2456 mDatePicker->setDate( da ); 2467 mDatePicker->setDate( da );
2457} 2468}
2458void CalendarView::showDatePicker( ) 2469void CalendarView::showDatePicker( )
2459{ 2470{
2460 //qDebug("CalendarView::showDatePicker( ) "); 2471 //qDebug("CalendarView::showDatePicker( ) ");
2461 if ( mDateFrame->isVisible() ) 2472 if ( mDateFrame->isVisible() )
2462 mDateFrame->hide(); 2473 mDateFrame->hide();
2463 else { 2474 else {
2464 int w =mDatePicker->sizeHint().width() ; 2475 int w =mDatePicker->sizeHint().width() ;
2465 int h = mDatePicker->sizeHint().height() ; 2476 int h = mDatePicker->sizeHint().height() ;
2466 int dw = QApplication::desktop()->width(); 2477 int dw = QApplication::desktop()->width();
2467 int dh = QApplication::desktop()->height(); 2478 int dh = QApplication::desktop()->height();
2468 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2479 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2469 mDateFrame->show(); 2480 mDateFrame->show();
2470 } 2481 }
2471 mDatePickerMode = 1; 2482 mDatePickerMode = 1;
2472 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2483 mDatePicker->setDate( mNavigator->selectedDates().first() );
2473} 2484}
2474 2485
2475void CalendarView::showEventEditor() 2486void CalendarView::showEventEditor()
2476{ 2487{
2477#ifdef DESKTOP_VERSION 2488#ifdef DESKTOP_VERSION
2478 mEventEditor->show(); 2489 mEventEditor->show();
2479#else 2490#else
2480 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2491 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2481 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2492 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2482 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2493 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2483 delete mEventEditor; 2494 delete mEventEditor;
2484 mEventEditor = mDialogManager->getEventEditor(); 2495 mEventEditor = mDialogManager->getEventEditor();
2485 } 2496 }
2486 mEventEditor->showMaximized(); 2497 mEventEditor->showMaximized();
2487#endif 2498#endif
2488} 2499}
2489void CalendarView::showTodoEditor() 2500void CalendarView::showTodoEditor()
2490{ 2501{
2491#ifdef DESKTOP_VERSION 2502#ifdef DESKTOP_VERSION
2492 mTodoEditor->show(); 2503 mTodoEditor->show();
2493#else 2504#else
2494 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2505 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2495 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2506 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2496 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2507 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2497 delete mTodoEditor; 2508 delete mTodoEditor;
2498 mTodoEditor = mDialogManager->getTodoEditor(); 2509 mTodoEditor = mDialogManager->getTodoEditor();
2499 } 2510 }
2500 mTodoEditor->showMaximized(); 2511 mTodoEditor->showMaximized();
2501#endif 2512#endif
2502} 2513}
2503 2514
2504void CalendarView::cloneIncidence() 2515void CalendarView::cloneIncidence()
2505{ 2516{
2506 Incidence *incidence = currentSelection(); 2517 Incidence *incidence = currentSelection();
2507 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2518 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2508 if ( incidence ) { 2519 if ( incidence ) {
2509 cloneIncidence(incidence); 2520 cloneIncidence(incidence);
2510 } 2521 }
2511} 2522}
2512void CalendarView::moveIncidence() 2523void CalendarView::moveIncidence()
2513{ 2524{
2514 Incidence *incidence = currentSelection(); 2525 Incidence *incidence = currentSelection();
2515 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2526 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2516 if ( incidence ) { 2527 if ( incidence ) {
2517 moveIncidence(incidence); 2528 moveIncidence(incidence);
2518 } 2529 }
2519} 2530}
2520void CalendarView::beamIncidence() 2531void CalendarView::beamIncidence()
2521{ 2532{
2522 Incidence *incidence = currentSelection(); 2533 Incidence *incidence = currentSelection();
2523 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2534 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2524 if ( incidence ) { 2535 if ( incidence ) {
2525 beamIncidence(incidence); 2536 beamIncidence(incidence);
2526 } 2537 }
2527} 2538}
2528void CalendarView::toggleCancelIncidence() 2539void CalendarView::toggleCancelIncidence()
2529{ 2540{
2530 Incidence *incidence = currentSelection(); 2541 Incidence *incidence = currentSelection();
2531 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2542 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2532 if ( incidence ) { 2543 if ( incidence ) {
2533 cancelIncidence(incidence); 2544 cancelIncidence(incidence);
2534 } 2545 }
2535} 2546}
2536 2547
2537 2548
2538void CalendarView::cancelIncidence(Incidence * inc ) 2549void CalendarView::cancelIncidence(Incidence * inc )
2539{ 2550{
2540 inc->setCancelled( ! inc->cancelled() ); 2551 inc->setCancelled( ! inc->cancelled() );
2541 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2552 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2542 updateView(); 2553 updateView();
2543} 2554}
2544void CalendarView::cloneIncidence(Incidence * orgInc ) 2555void CalendarView::cloneIncidence(Incidence * orgInc )
2545{ 2556{
2546 Incidence * newInc = orgInc->clone(); 2557 Incidence * newInc = orgInc->clone();
2547 newInc->recreate(); 2558 newInc->recreate();
2548 2559
2549 if ( newInc->type() == "Todo" ) { 2560 if ( newInc->type() == "Todo" ) {
2550 Todo* t = (Todo*) newInc; 2561 Todo* t = (Todo*) newInc;
2551 showTodoEditor(); 2562 showTodoEditor();
2552 mTodoEditor->editTodo( t ); 2563 mTodoEditor->editTodo( t );
2553 if ( mTodoEditor->exec() ) { 2564 if ( mTodoEditor->exec() ) {
2554 mCalendar->addTodo( t ); 2565 mCalendar->addTodo( t );
2555 updateView(); 2566 updateView();
2556 } else { 2567 } else {
2557 delete t; 2568 delete t;
2558 } 2569 }
2559 } 2570 }
2560 else { 2571 else {
2561 Event* e = (Event*) newInc; 2572 Event* e = (Event*) newInc;
2562 showEventEditor(); 2573 showEventEditor();
2563 mEventEditor->editEvent( e ); 2574 mEventEditor->editEvent( e );
2564 if ( mEventEditor->exec() ) { 2575 if ( mEventEditor->exec() ) {
2565 mCalendar->addEvent( e ); 2576 mCalendar->addEvent( e );
2566 updateView(); 2577 updateView();
2567 } else { 2578 } else {
2568 delete e; 2579 delete e;
2569 } 2580 }
2570 } 2581 }
2571} 2582}
2572 2583
2573void CalendarView::newEvent() 2584void CalendarView::newEvent()
2574{ 2585{
2575 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2586 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2576 KOAgendaView *aView = mViewManager->agendaView(); 2587 KOAgendaView *aView = mViewManager->agendaView();
2577 if (aView) { 2588 if (aView) {
2578 if (aView->selectionStart().isValid()) { 2589 if (aView->selectionStart().isValid()) {
2579 if (aView->selectedIsAllDay()) { 2590 if (aView->selectedIsAllDay()) {
2580 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2591 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2581 } else { 2592 } else {
2582 newEvent(aView->selectionStart(),aView->selectionEnd()); 2593 newEvent(aView->selectionStart(),aView->selectionEnd());
2583 } 2594 }
2584 return; 2595 return;
2585 } 2596 }
2586 } 2597 }
2587 2598
2588 QDate date = mNavigator->selectedDates().first(); 2599 QDate date = mNavigator->selectedDates().first();
2589 QDateTime current = QDateTime::currentDateTime(); 2600 QDateTime current = QDateTime::currentDateTime();
2590 if ( date <= current.date() ) { 2601 if ( date <= current.date() ) {
2591 int hour = current.time().hour() +1; 2602 int hour = current.time().hour() +1;
2592 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2603 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2593 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2604 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2594 } else 2605 } else
2595 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2606 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2596 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2607 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2597 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2608 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2598} 2609}
2599 2610
2600void CalendarView::newEvent(QDateTime fh) 2611void CalendarView::newEvent(QDateTime fh)
2601{ 2612{
2602 newEvent(fh, 2613 newEvent(fh,
2603 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2614 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2604} 2615}
2605 2616
2606void CalendarView::newEvent(QDate dt) 2617void CalendarView::newEvent(QDate dt)
2607{ 2618{
2608 newEvent(QDateTime(dt, QTime(0,0,0)), 2619 newEvent(QDateTime(dt, QTime(0,0,0)),
2609 QDateTime(dt, QTime(0,0,0)), true); 2620 QDateTime(dt, QTime(0,0,0)), true);
2610} 2621}
2611 2622
2612void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2623void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2613{ 2624{
2614 2625
2615 showEventEditor(); 2626 showEventEditor();
2616 mEventEditor->newEvent(fromHint,toHint,allDay); 2627 mEventEditor->newEvent(fromHint,toHint,allDay);
2617 if ( mFilterView->filtersEnabled() ) { 2628 if ( mFilterView->filtersEnabled() ) {
2618 CalFilter *filter = mFilterView->selectedFilter(); 2629 CalFilter *filter = mFilterView->selectedFilter();
2619 if (filter && filter->showCategories()) { 2630 if (filter && filter->showCategories()) {
2620 mEventEditor->setCategories(filter->categoryList().join(",") ); 2631 mEventEditor->setCategories(filter->categoryList().join(",") );
2621 } 2632 }
2622 if ( filter ) 2633 if ( filter )
2623 mEventEditor->setSecrecy( filter->getSecrecy() ); 2634 mEventEditor->setSecrecy( filter->getSecrecy() );
2624 } 2635 }
2625} 2636}
2626void CalendarView::todoAdded(Todo * t) 2637void CalendarView::todoAdded(Todo * t)
2627{ 2638{
2628 2639
2629 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2640 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2630 updateTodoViews(); 2641 updateTodoViews();
2631} 2642}
2632void CalendarView::todoChanged(Todo * t) 2643void CalendarView::todoChanged(Todo * t)
2633{ 2644{
2634 emit todoModified( t, 4 ); 2645 emit todoModified( t, 4 );
2635 // updateTodoViews(); 2646 // updateTodoViews();
2636} 2647}
2637void CalendarView::todoToBeDeleted(Todo *) 2648void CalendarView::todoToBeDeleted(Todo *)
2638{ 2649{
2639 //qDebug("todoToBeDeleted(Todo *) "); 2650 //qDebug("todoToBeDeleted(Todo *) ");
2640 updateTodoViews(); 2651 updateTodoViews();
2641} 2652}
2642void CalendarView::todoDeleted() 2653void CalendarView::todoDeleted()
2643{ 2654{
2644 //qDebug(" todoDeleted()"); 2655 //qDebug(" todoDeleted()");
2645 updateTodoViews(); 2656 updateTodoViews();
2646} 2657}
2647 2658
2648 2659
2649 2660
2650void CalendarView::newTodo() 2661void CalendarView::newTodo()
2651{ 2662{
2652 2663
2653 showTodoEditor(); 2664 showTodoEditor();
2654 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2665 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2655 if ( mFilterView->filtersEnabled() ) { 2666 if ( mFilterView->filtersEnabled() ) {
2656 CalFilter *filter = mFilterView->selectedFilter(); 2667 CalFilter *filter = mFilterView->selectedFilter();
2657 if (filter && filter->showCategories()) { 2668 if (filter && filter->showCategories()) {
2658 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2669 mTodoEditor->setCategories(filter->categoryList().join(",") );
2659 } 2670 }
2660 if ( filter ) 2671 if ( filter )
2661 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2672 mTodoEditor->setSecrecy( filter->getSecrecy() );
2662 } 2673 }
2663} 2674}
2664 2675
2665void CalendarView::newSubTodo() 2676void CalendarView::newSubTodo()
2666{ 2677{
2667 Todo *todo = selectedTodo(); 2678 Todo *todo = selectedTodo();
2668 if ( todo ) newSubTodo( todo ); 2679 if ( todo ) newSubTodo( todo );
2669} 2680}
2670 2681
2671void CalendarView::newSubTodo(Todo *parentEvent) 2682void CalendarView::newSubTodo(Todo *parentEvent)
2672{ 2683{
2673 2684
2674 showTodoEditor(); 2685 showTodoEditor();
2675 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2676} 2687}
2677 2688
2678void CalendarView::newFloatingEvent() 2689void CalendarView::newFloatingEvent()
2679{ 2690{
2680 DateList tmpList = mNavigator->selectedDates(); 2691 DateList tmpList = mNavigator->selectedDates();
2681 QDate date = tmpList.first(); 2692 QDate date = tmpList.first();
2682 2693
2683 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2694 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2684 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2695 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2685} 2696}
2686 2697
2687 2698
2688void CalendarView::editEvent( Event *event ) 2699void CalendarView::editEvent( Event *event )
2689{ 2700{
2690 2701
2691 if ( !event ) return; 2702 if ( !event ) return;
2692 if ( event->isReadOnly() ) { 2703 if ( event->isReadOnly() ) {
2693 showEvent( event ); 2704 showEvent( event );
2694 return; 2705 return;
2695 } 2706 }
2696 showEventEditor(); 2707 showEventEditor();
2697 mEventEditor->editEvent( event , mFlagEditDescription); 2708 mEventEditor->editEvent( event , mFlagEditDescription);
2698} 2709}
2699void CalendarView::editJournal( Journal *jour ) 2710void CalendarView::editJournal( Journal *jour )
2700{ 2711{
2701 if ( !jour ) return; 2712 if ( !jour ) return;
2702 mDialogManager->hideSearchDialog(); 2713 mDialogManager->hideSearchDialog();
2703 mViewManager->showJournalView(); 2714 mViewManager->showJournalView();
2704 mNavigator->slotDaySelect( jour->dtStart().date() ); 2715 mNavigator->slotDaySelect( jour->dtStart().date() );
2705} 2716}
2706void CalendarView::editTodo( Todo *todo ) 2717void CalendarView::editTodo( Todo *todo )
2707{ 2718{
2708 if ( !todo ) return; 2719 if ( !todo ) return;
2709 2720
2710 if ( todo->isReadOnly() ) { 2721 if ( todo->isReadOnly() ) {
2711 showTodo( todo ); 2722 showTodo( todo );
2712 return; 2723 return;
2713 } 2724 }
2714 showTodoEditor(); 2725 showTodoEditor();
2715 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2726 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2716 2727
2717} 2728}
2718 2729
2719KOEventViewerDialog* CalendarView::getEventViewerDialog() 2730KOEventViewerDialog* CalendarView::getEventViewerDialog()
2720{ 2731{
2721 if ( !mEventViewerDialog ) { 2732 if ( !mEventViewerDialog ) {
2722 mEventViewerDialog = new KOEventViewerDialog(this); 2733 mEventViewerDialog = new KOEventViewerDialog(this);
2723 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2734 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2724 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2735 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2725 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2736 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2726 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2737 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2727 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2738 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2728 viewManager(), SLOT( showAgendaView( bool ) ) ); 2739 viewManager(), SLOT( showAgendaView( bool ) ) );
2729 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2740 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2730 this, SLOT( todoChanged(Todo *) ) ); 2741 this, SLOT( todoChanged(Todo *) ) );
2731 mEventViewerDialog->resize( 640, 480 ); 2742 mEventViewerDialog->resize( 640, 480 );
2732 2743
2733 } 2744 }
2734 return mEventViewerDialog; 2745 return mEventViewerDialog;
2735} 2746}
2736void CalendarView::showEvent(Event *event) 2747void CalendarView::showEvent(Event *event)
2737{ 2748{
2738 getEventViewerDialog()->setEvent(event); 2749 getEventViewerDialog()->setEvent(event);
2739 getEventViewerDialog()->showMe(); 2750 getEventViewerDialog()->showMe();
2740} 2751}
2741 2752
2742void CalendarView::showTodo(Todo *event) 2753void CalendarView::showTodo(Todo *event)
2743{ 2754{
2744 getEventViewerDialog()->setTodo(event); 2755 getEventViewerDialog()->setTodo(event);
2745 getEventViewerDialog()->showMe(); 2756 getEventViewerDialog()->showMe();
2746} 2757}
2747void CalendarView::showJournal( Journal *jour ) 2758void CalendarView::showJournal( Journal *jour )
2748{ 2759{
2749 getEventViewerDialog()->setJournal(jour); 2760 getEventViewerDialog()->setJournal(jour);
2750 getEventViewerDialog()->showMe(); 2761 getEventViewerDialog()->showMe();
2751 2762
2752} 2763}
2753// void CalendarView::todoModified (Todo *event, int changed) 2764// void CalendarView::todoModified (Todo *event, int changed)
2754// { 2765// {
2755// // if (mDialogList.find (event) != mDialogList.end ()) { 2766// // if (mDialogList.find (event) != mDialogList.end ()) {
2756// // kdDebug() << "Todo modified and open" << endl; 2767// // kdDebug() << "Todo modified and open" << endl;
2757// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2768// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2758// // temp->modified (changed); 2769// // temp->modified (changed);
2759 2770
2760// // } 2771// // }
2761 2772
2762// mViewManager->updateView(); 2773// mViewManager->updateView();
2763// } 2774// }
2764 2775
2765void CalendarView::appointment_show() 2776void CalendarView::appointment_show()
2766{ 2777{
2767 Event *anEvent = 0; 2778 Event *anEvent = 0;
2768 2779
2769 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2780 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2770 2781
2771 if (mViewManager->currentView()->isEventView()) { 2782 if (mViewManager->currentView()->isEventView()) {
2772 if ( incidence && incidence->type() == "Event" ) { 2783 if ( incidence && incidence->type() == "Event" ) {
2773 anEvent = static_cast<Event *>(incidence); 2784 anEvent = static_cast<Event *>(incidence);
2774 } 2785 }
2775 } 2786 }
2776 2787
2777 if (!anEvent) { 2788 if (!anEvent) {
2778 KNotifyClient::beep(); 2789 KNotifyClient::beep();
2779 return; 2790 return;
2780 } 2791 }
2781 2792
2782 showEvent(anEvent); 2793 showEvent(anEvent);
2783} 2794}
2784 2795
2785void CalendarView::appointment_edit() 2796void CalendarView::appointment_edit()
2786{ 2797{
2787 Event *anEvent = 0; 2798 Event *anEvent = 0;
2788 2799
2789 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2800 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2790 2801
2791 if (mViewManager->currentView()->isEventView()) { 2802 if (mViewManager->currentView()->isEventView()) {
2792 if ( incidence && incidence->type() == "Event" ) { 2803 if ( incidence && incidence->type() == "Event" ) {
2793 anEvent = static_cast<Event *>(incidence); 2804 anEvent = static_cast<Event *>(incidence);
2794 } 2805 }
2795 } 2806 }
2796 2807
2797 if (!anEvent) { 2808 if (!anEvent) {
2798 KNotifyClient::beep(); 2809 KNotifyClient::beep();
2799 return; 2810 return;
2800 } 2811 }
2801 2812
2802 editEvent(anEvent); 2813 editEvent(anEvent);
2803} 2814}
2804 2815
2805void CalendarView::appointment_delete() 2816void CalendarView::appointment_delete()
2806{ 2817{
2807 Event *anEvent = 0; 2818 Event *anEvent = 0;
2808 2819
2809 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2820 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2810 2821
2811 if (mViewManager->currentView()->isEventView()) { 2822 if (mViewManager->currentView()->isEventView()) {
2812 if ( incidence && incidence->type() == "Event" ) { 2823 if ( incidence && incidence->type() == "Event" ) {
2813 anEvent = static_cast<Event *>(incidence); 2824 anEvent = static_cast<Event *>(incidence);
2814 } 2825 }
2815 } 2826 }
2816 2827
2817 if (!anEvent) { 2828 if (!anEvent) {
2818 KNotifyClient::beep(); 2829 KNotifyClient::beep();
2819 return; 2830 return;
2820 } 2831 }
2821 2832
2822 deleteEvent(anEvent); 2833 deleteEvent(anEvent);
2823} 2834}
2824 2835
2825void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2836void CalendarView::todo_resub( Todo * parent, Todo * sub )
2826{ 2837{
2827 if (!sub) return; 2838 if (!sub) return;
2828 if (!parent) return; 2839 if (!parent) return;
2829 if ( sub->relatedTo() ) 2840 if ( sub->relatedTo() )
2830 sub->relatedTo()->removeRelation(sub); 2841 sub->relatedTo()->removeRelation(sub);
2831 sub->setRelatedTo(parent); 2842 sub->setRelatedTo(parent);
2832 sub->setRelatedToUid(parent->uid()); 2843 sub->setRelatedToUid(parent->uid());
2833 parent->addRelation(sub); 2844 parent->addRelation(sub);
2834 sub->updated(); 2845 sub->updated();
2835 parent->updated(); 2846 parent->updated();
2836 setModified(true); 2847 setModified(true);
2837 updateView(); 2848 updateView();
2838} 2849}
2839void CalendarView::todo_unsub(Todo *anTodo ) 2850void CalendarView::todo_unsub(Todo *anTodo )
2840{ 2851{
2841 // Todo *anTodo = selectedTodo(); 2852 // Todo *anTodo = selectedTodo();
2842 if (!anTodo) return; 2853 if (!anTodo) return;
2843 if (!anTodo->relatedTo()) return; 2854 if (!anTodo->relatedTo()) return;
2844 anTodo->relatedTo()->removeRelation(anTodo); 2855 anTodo->relatedTo()->removeRelation(anTodo);
2845 anTodo->setRelatedTo(0); 2856 anTodo->setRelatedTo(0);
2846 anTodo->updated(); 2857 anTodo->updated();
2847 anTodo->setRelatedToUid(""); 2858 anTodo->setRelatedToUid("");
2848 setModified(true); 2859 setModified(true);
2849 updateView(); 2860 updateView();
2850} 2861}
2851 2862
2852void CalendarView::deleteTodo(Todo *todo) 2863void CalendarView::deleteTodo(Todo *todo)
2853{ 2864{
2854 if (!todo) { 2865 if (!todo) {
2855 KNotifyClient::beep(); 2866 KNotifyClient::beep();
2856 return; 2867 return;
2857 } 2868 }
2858 if (KOPrefs::instance()->mConfirm) { 2869 if (KOPrefs::instance()->mConfirm) {
2859 switch (msgItemDelete()) { 2870 switch (msgItemDelete()) {
2860 case KMessageBox::Continue: // OK 2871 case KMessageBox::Continue: // OK
2861 if (!todo->relations().isEmpty()) { 2872 if (!todo->relations().isEmpty()) {
2862 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2873 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2863 i18n("Delete To-Do")); 2874 i18n("Delete To-Do"));
2864 } else { 2875 } else {
2865 checkExternalId( todo ); 2876 checkExternalId( todo );
2866 calendar()->deleteTodo(todo); 2877 calendar()->deleteTodo(todo);
2867 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2878 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2868 updateView(); 2879 updateView();
2869 } 2880 }
2870 break; 2881 break;
2871 } // switch 2882 } // switch
2872 } else { 2883 } else {
2873 if (!todo->relations().isEmpty()) { 2884 if (!todo->relations().isEmpty()) {
2874 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2885 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2875 i18n("Delete To-Do")); 2886 i18n("Delete To-Do"));
2876 } else { 2887 } else {
2877 checkExternalId( todo ); 2888 checkExternalId( todo );
2878 mCalendar->deleteTodo(todo); 2889 mCalendar->deleteTodo(todo);
2879 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2890 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2880 updateView(); 2891 updateView();
2881 } 2892 }
2882 } 2893 }
2883 emit updateSearchDialog(); 2894 emit updateSearchDialog();
2884} 2895}
2885void CalendarView::deleteJournal(Journal *jour) 2896void CalendarView::deleteJournal(Journal *jour)
2886{ 2897{
2887 if (!jour) { 2898 if (!jour) {
2888 KNotifyClient::beep(); 2899 KNotifyClient::beep();
2889 return; 2900 return;
2890 } 2901 }
2891 if (KOPrefs::instance()->mConfirm) { 2902 if (KOPrefs::instance()->mConfirm) {
2892 switch (msgItemDelete()) { 2903 switch (msgItemDelete()) {
2893 case KMessageBox::Continue: // OK 2904 case KMessageBox::Continue: // OK
2894 calendar()->deleteJournal(jour); 2905 calendar()->deleteJournal(jour);
2895 updateView(); 2906 updateView();
2896 break; 2907 break;
2897 } // switch 2908 } // switch
2898 } else { 2909 } else {
2899 calendar()->deleteJournal(jour);; 2910 calendar()->deleteJournal(jour);;
2900 updateView(); 2911 updateView();
2901 } 2912 }
2902 emit updateSearchDialog(); 2913 emit updateSearchDialog();
2903} 2914}
2904 2915
2905void CalendarView::deleteEvent(Event *anEvent) 2916void CalendarView::deleteEvent(Event *anEvent)
2906{ 2917{
2907 if (!anEvent) { 2918 if (!anEvent) {
2908 KNotifyClient::beep(); 2919 KNotifyClient::beep();
2909 return; 2920 return;
2910 } 2921 }
2911 2922
2912 if (anEvent->recurrence()->doesRecur()) { 2923 if (anEvent->recurrence()->doesRecur()) {
2913 QDate itemDate = mViewManager->currentSelectionDate(); 2924 QDate itemDate = mViewManager->currentSelectionDate();
2914 int km; 2925 int km;
2915 if (!itemDate.isValid()) { 2926 if (!itemDate.isValid()) {
2916 //kdDebug() << "Date Not Valid" << endl; 2927 //kdDebug() << "Date Not Valid" << endl;
2917 if (KOPrefs::instance()->mConfirm) { 2928 if (KOPrefs::instance()->mConfirm) {
2918 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2929 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2919 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2930 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2920 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2931 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2921 if ( km == KMessageBox::Continue ) 2932 if ( km == KMessageBox::Continue )
2922 km = KMessageBox::No; // No = all below 2933 km = KMessageBox::No; // No = all below
2923 } else 2934 } else
2924 km = KMessageBox::No; 2935 km = KMessageBox::No;
2925 } else { 2936 } else {
2926 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2937 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2927 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2938 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2928 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2939 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2929 i18n("KO/Pi Confirmation"),i18n("Current"), 2940 i18n("KO/Pi Confirmation"),i18n("Current"),
2930 i18n("All")); 2941 i18n("All"));
2931 } 2942 }
2932 switch(km) { 2943 switch(km) {
2933 2944
2934 case KMessageBox::No: // Continue // all 2945 case KMessageBox::No: // Continue // all
2935 //qDebug("KMessageBox::No "); 2946 //qDebug("KMessageBox::No ");
2936 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2947 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2937 schedule(Scheduler::Cancel,anEvent); 2948 schedule(Scheduler::Cancel,anEvent);
2938 2949
2939 checkExternalId( anEvent); 2950 checkExternalId( anEvent);
2940 mCalendar->deleteEvent(anEvent); 2951 mCalendar->deleteEvent(anEvent);
2941 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2952 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2942 break; 2953 break;
2943 2954
2944 // Disabled because it does not work 2955 // Disabled because it does not work
2945 //#if 0 2956 //#if 0
2946 case KMessageBox::Yes: // just this one 2957 case KMessageBox::Yes: // just this one
2947 //QDate qd = mNavigator->selectedDates().first(); 2958 //QDate qd = mNavigator->selectedDates().first();
2948 //if (!qd.isValid()) { 2959 //if (!qd.isValid()) {
2949 // kdDebug() << "no date selected, or invalid date" << endl; 2960 // kdDebug() << "no date selected, or invalid date" << endl;
2950 // KNotifyClient::beep(); 2961 // KNotifyClient::beep();
2951 // return; 2962 // return;
2952 //} 2963 //}
2953 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2964 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2954 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2965 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2955 anEvent->addExDate(itemDate); 2966 anEvent->addExDate(itemDate);
2956 int duration = anEvent->recurrence()->duration(); 2967 int duration = anEvent->recurrence()->duration();
2957 if ( duration > 0 ) { 2968 if ( duration > 0 ) {
2958 anEvent->recurrence()->setDuration( duration - 1 ); 2969 anEvent->recurrence()->setDuration( duration - 1 );
2959 } 2970 }
2960 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2971 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2961 } 2972 }
2962 break; 2973 break;
2963 //#endif 2974 //#endif
2964 } // switch 2975 } // switch
2965 } else { 2976 } else {
2966 if (KOPrefs::instance()->mConfirm) { 2977 if (KOPrefs::instance()->mConfirm) {
2967 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2978 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2968 i18n("\nAre you sure you want\nto delete this event?"), 2979 i18n("\nAre you sure you want\nto delete this event?"),
2969 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2980 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2970 case KMessageBox::Continue: // OK 2981 case KMessageBox::Continue: // OK
2971 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2982 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2972 schedule(Scheduler::Cancel,anEvent); 2983 schedule(Scheduler::Cancel,anEvent);
2973 checkExternalId( anEvent); 2984 checkExternalId( anEvent);
2974 mCalendar->deleteEvent(anEvent); 2985 mCalendar->deleteEvent(anEvent);
2975 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2986 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2976 break; 2987 break;
2977 } // switch 2988 } // switch
2978 } else { 2989 } else {
2979 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2990 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2980 schedule(Scheduler::Cancel,anEvent); 2991 schedule(Scheduler::Cancel,anEvent);
2981 checkExternalId( anEvent); 2992 checkExternalId( anEvent);
2982 mCalendar->deleteEvent(anEvent); 2993 mCalendar->deleteEvent(anEvent);
2983 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2994 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2984 } 2995 }
2985 } // if-else 2996 } // if-else
2986 emit updateSearchDialog(); 2997 emit updateSearchDialog();
2987} 2998}
2988 2999
2989bool CalendarView::deleteEvent(const QString &uid) 3000bool CalendarView::deleteEvent(const QString &uid)
2990{ 3001{
2991 Event *ev = mCalendar->event(uid); 3002 Event *ev = mCalendar->event(uid);
2992 if (ev) { 3003 if (ev) {
2993 deleteEvent(ev); 3004 deleteEvent(ev);
2994 return true; 3005 return true;
2995 } else { 3006 } else {
2996 return false; 3007 return false;
2997 } 3008 }
2998} 3009}
2999 3010
3000/*****************************************************************************/ 3011/*****************************************************************************/
3001 3012
3002void CalendarView::action_mail() 3013void CalendarView::action_mail()
3003{ 3014{
3004#ifndef KORG_NOMAIL 3015#ifndef KORG_NOMAIL
3005 KOMailClient mailClient; 3016 KOMailClient mailClient;
3006 3017
3007 Incidence *incidence = currentSelection(); 3018 Incidence *incidence = currentSelection();
3008 3019
3009 if (!incidence) { 3020 if (!incidence) {
3010 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3021 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3011 return; 3022 return;
3012 } 3023 }
3013 if(incidence->attendeeCount() == 0 ) { 3024 if(incidence->attendeeCount() == 0 ) {
3014 KMessageBox::sorry(this, 3025 KMessageBox::sorry(this,
3015 i18n("Can't generate mail:\nNo attendees defined.\n")); 3026 i18n("Can't generate mail:\nNo attendees defined.\n"));
3016 return; 3027 return;
3017 } 3028 }
3018 3029
3019 CalendarLocal cal_tmp; 3030 CalendarLocal cal_tmp;
3020 Event *event = 0; 3031 Event *event = 0;
3021 Event *ev = 0; 3032 Event *ev = 0;
3022 if ( incidence && incidence->type() == "Event" ) { 3033 if ( incidence && incidence->type() == "Event" ) {
3023 event = static_cast<Event *>(incidence); 3034 event = static_cast<Event *>(incidence);
3024 ev = new Event(*event); 3035 ev = new Event(*event);
3025 cal_tmp.addEvent(ev); 3036 cal_tmp.addEvent(ev);
3026 } 3037 }
3027 ICalFormat mForm(); 3038 ICalFormat mForm();
3028 QString attachment = mForm.toString( &cal_tmp ); 3039 QString attachment = mForm.toString( &cal_tmp );
3029 if (ev) delete(ev); 3040 if (ev) delete(ev);
3030 3041
3031 mailClient.mailAttendees(currentSelection(), attachment); 3042 mailClient.mailAttendees(currentSelection(), attachment);
3032 3043
3033#endif 3044#endif
3034 3045
3035#if 0 3046#if 0
3036 Event *anEvent = 0; 3047 Event *anEvent = 0;
3037 if (mViewManager->currentView()->isEventView()) { 3048 if (mViewManager->currentView()->isEventView()) {
3038 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3049 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3039 } 3050 }
3040 3051
3041 if (!anEvent) { 3052 if (!anEvent) {
3042 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3053 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3043 return; 3054 return;
3044 } 3055 }
3045 if(anEvent->attendeeCount() == 0 ) { 3056 if(anEvent->attendeeCount() == 0 ) {
3046 KMessageBox::sorry(this, 3057 KMessageBox::sorry(this,
3047 i18n("Can't generate mail:\nNo attendees defined.\n")); 3058 i18n("Can't generate mail:\nNo attendees defined.\n"));
3048 return; 3059 return;
3049 } 3060 }
3050 3061
3051 mailobject.emailEvent(anEvent); 3062 mailobject.emailEvent(anEvent);
3052#endif 3063#endif
3053} 3064}
3054 3065
3055 3066
3056void CalendarView::schedule_publish(Incidence *incidence) 3067void CalendarView::schedule_publish(Incidence *incidence)
3057{ 3068{
3058 Event *event = 0; 3069 Event *event = 0;
3059 Todo *todo = 0; 3070 Todo *todo = 0;
3060 3071
3061 if (incidence == 0) { 3072 if (incidence == 0) {
3062 incidence = mViewManager->currentView()->selectedIncidences().first(); 3073 incidence = mViewManager->currentView()->selectedIncidences().first();
3063 if (incidence == 0) { 3074 if (incidence == 0) {
3064 incidence = mTodoList->selectedIncidences().first(); 3075 incidence = mTodoList->selectedIncidences().first();
3065 } 3076 }
3066 } 3077 }
3067 if ( incidence && incidence->type() == "Event" ) { 3078 if ( incidence && incidence->type() == "Event" ) {
3068 event = static_cast<Event *>(incidence); 3079 event = static_cast<Event *>(incidence);
3069 } else { 3080 } else {
3070 if ( incidence && incidence->type() == "Todo" ) { 3081 if ( incidence && incidence->type() == "Todo" ) {
3071 todo = static_cast<Todo *>(incidence); 3082 todo = static_cast<Todo *>(incidence);
3072 } 3083 }
3073 } 3084 }
3074 3085
3075 if (!event && !todo) { 3086 if (!event && !todo) {
3076 KMessageBox::sorry(this,i18n("No event selected.")); 3087 KMessageBox::sorry(this,i18n("No event selected."));
3077 return; 3088 return;
3078 } 3089 }
3079 3090
3080 PublishDialog *publishdlg = new PublishDialog(); 3091 PublishDialog *publishdlg = new PublishDialog();
3081 if (incidence->attendeeCount()>0) { 3092 if (incidence->attendeeCount()>0) {
3082 QPtrList<Attendee> attendees = incidence->attendees(); 3093 QPtrList<Attendee> attendees = incidence->attendees();
3083 attendees.first(); 3094 attendees.first();
3084 while ( attendees.current()!=0 ) { 3095 while ( attendees.current()!=0 ) {
3085 publishdlg->addAttendee(attendees.current()); 3096 publishdlg->addAttendee(attendees.current());
3086 attendees.next(); 3097 attendees.next();
3087 } 3098 }
3088 } 3099 }
3089 bool send = true; 3100 bool send = true;
3090 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3101 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3091 if ( publishdlg->exec() != QDialog::Accepted ) 3102 if ( publishdlg->exec() != QDialog::Accepted )
3092 send = false; 3103 send = false;
3093 } 3104 }
3094 if ( send ) { 3105 if ( send ) {
3095 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3106 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3096 if ( event ) { 3107 if ( event ) {
3097 Event *ev = new Event(*event); 3108 Event *ev = new Event(*event);
3098 ev->registerObserver(0); 3109 ev->registerObserver(0);
3099 ev->clearAttendees(); 3110 ev->clearAttendees();
3100 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3111 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3101 delete(ev); 3112 delete(ev);
3102 } 3113 }
3103 } else { 3114 } else {
3104 if ( todo ) { 3115 if ( todo ) {
3105 Todo *ev = new Todo(*todo); 3116 Todo *ev = new Todo(*todo);
3106 ev->registerObserver(0); 3117 ev->registerObserver(0);
3107 ev->clearAttendees(); 3118 ev->clearAttendees();
3108 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3119 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3109 delete(ev); 3120 delete(ev);
3110 } 3121 }
3111 } 3122 }
3112 } 3123 }
3113 } 3124 }
3114 delete publishdlg; 3125 delete publishdlg;
3115} 3126}
3116 3127
3117void CalendarView::schedule_request(Incidence *incidence) 3128void CalendarView::schedule_request(Incidence *incidence)
3118{ 3129{
3119 schedule(Scheduler::Request,incidence); 3130 schedule(Scheduler::Request,incidence);
3120} 3131}
3121 3132
3122void CalendarView::schedule_refresh(Incidence *incidence) 3133void CalendarView::schedule_refresh(Incidence *incidence)
3123{ 3134{
3124 schedule(Scheduler::Refresh,incidence); 3135 schedule(Scheduler::Refresh,incidence);
3125} 3136}
3126 3137
3127void CalendarView::schedule_cancel(Incidence *incidence) 3138void CalendarView::schedule_cancel(Incidence *incidence)
3128{ 3139{
3129 schedule(Scheduler::Cancel,incidence); 3140 schedule(Scheduler::Cancel,incidence);
3130} 3141}
3131 3142
3132void CalendarView::schedule_add(Incidence *incidence) 3143void CalendarView::schedule_add(Incidence *incidence)
3133{ 3144{
3134 schedule(Scheduler::Add,incidence); 3145 schedule(Scheduler::Add,incidence);
3135} 3146}
3136 3147
3137void CalendarView::schedule_reply(Incidence *incidence) 3148void CalendarView::schedule_reply(Incidence *incidence)
3138{ 3149{
3139 schedule(Scheduler::Reply,incidence); 3150 schedule(Scheduler::Reply,incidence);
3140} 3151}
3141 3152
3142void CalendarView::schedule_counter(Incidence *incidence) 3153void CalendarView::schedule_counter(Incidence *incidence)
3143{ 3154{
3144 schedule(Scheduler::Counter,incidence); 3155 schedule(Scheduler::Counter,incidence);
3145} 3156}
3146 3157
3147void CalendarView::schedule_declinecounter(Incidence *incidence) 3158void CalendarView::schedule_declinecounter(Incidence *incidence)
3148{ 3159{
3149 schedule(Scheduler::Declinecounter,incidence); 3160 schedule(Scheduler::Declinecounter,incidence);
3150} 3161}
3151 3162
3152void CalendarView::schedule_publish_freebusy(int daysToPublish) 3163void CalendarView::schedule_publish_freebusy(int daysToPublish)
3153{ 3164{
3154 QDateTime start = QDateTime::currentDateTime(); 3165 QDateTime start = QDateTime::currentDateTime();
3155 QDateTime end = start.addDays(daysToPublish); 3166 QDateTime end = start.addDays(daysToPublish);
3156 3167
3157 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3168 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3158 freebusy->setOrganizer(KOPrefs::instance()->email()); 3169 freebusy->setOrganizer(KOPrefs::instance()->email());
3159 3170
3160 3171
3161 PublishDialog *publishdlg = new PublishDialog(); 3172 PublishDialog *publishdlg = new PublishDialog();
3162 if ( publishdlg->exec() == QDialog::Accepted ) { 3173 if ( publishdlg->exec() == QDialog::Accepted ) {
3163 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3174 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3164 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3175 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3165 delete(freebusy); 3176 delete(freebusy);
3166 } 3177 }
3167 } 3178 }
3168 delete publishdlg; 3179 delete publishdlg;
3169} 3180}
3170 3181
3171void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3182void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3172{ 3183{
3173 Event *event = 0; 3184 Event *event = 0;
3174 Todo *todo = 0; 3185 Todo *todo = 0;
3175 3186
3176 if (incidence == 0) { 3187 if (incidence == 0) {
3177 incidence = mViewManager->currentView()->selectedIncidences().first(); 3188 incidence = mViewManager->currentView()->selectedIncidences().first();
3178 if (incidence == 0) { 3189 if (incidence == 0) {
3179 incidence = mTodoList->selectedIncidences().first(); 3190 incidence = mTodoList->selectedIncidences().first();
3180 } 3191 }
3181 } 3192 }
3182 if ( incidence && incidence->type() == "Event" ) { 3193 if ( incidence && incidence->type() == "Event" ) {
3183 event = static_cast<Event *>(incidence); 3194 event = static_cast<Event *>(incidence);
3184 } 3195 }
3185 if ( incidence && incidence->type() == "Todo" ) { 3196 if ( incidence && incidence->type() == "Todo" ) {
3186 todo = static_cast<Todo *>(incidence); 3197 todo = static_cast<Todo *>(incidence);
3187 } 3198 }
3188 3199
3189 if (!event && !todo) { 3200 if (!event && !todo) {
3190 KMessageBox::sorry(this,i18n("No event selected.")); 3201 KMessageBox::sorry(this,i18n("No event selected."));
3191 return; 3202 return;
3192 } 3203 }
3193 3204
3194 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3205 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3195 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3206 KMessageBox::sorry(this,i18n("The event has no attendees."));
3196 return; 3207 return;
3197 } 3208 }
3198 3209
3199 Event *ev = 0; 3210 Event *ev = 0;
3200 if (event) ev = new Event(*event); 3211 if (event) ev = new Event(*event);
3201 Todo *to = 0; 3212 Todo *to = 0;
3202 if (todo) to = new Todo(*todo); 3213 if (todo) to = new Todo(*todo);
3203 3214
3204 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3215 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3205 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3216 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3206 if (!me) { 3217 if (!me) {
3207 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3218 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3208 return; 3219 return;
3209 } 3220 }
3210 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3221 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3211 StatusDialog *statdlg = new StatusDialog(this); 3222 StatusDialog *statdlg = new StatusDialog(this);
3212 if (!statdlg->exec()==QDialog::Accepted) return; 3223 if (!statdlg->exec()==QDialog::Accepted) return;
3213 me->setStatus( statdlg->status() ); 3224 me->setStatus( statdlg->status() );
3214 delete(statdlg); 3225 delete(statdlg);
3215 } 3226 }
3216 Attendee *menew = new Attendee(*me); 3227 Attendee *menew = new Attendee(*me);
3217 if (ev) { 3228 if (ev) {
3218 ev->clearAttendees(); 3229 ev->clearAttendees();
3219 ev->addAttendee(menew,false); 3230 ev->addAttendee(menew,false);
3220 } else { 3231 } else {
3221 if (to) { 3232 if (to) {
3222 todo->clearAttendees(); 3233 todo->clearAttendees();
3223 todo->addAttendee(menew,false); 3234 todo->addAttendee(menew,false);
3224 } 3235 }
3225 } 3236 }
3226 } 3237 }
3227 3238
3228 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3239 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3229 if (ev) { 3240 if (ev) {
3230 if ( !dlg->addMessage(ev,method) ) delete(ev); 3241 if ( !dlg->addMessage(ev,method) ) delete(ev);
3231 } else { 3242 } else {
3232 if (to) { 3243 if (to) {
3233 if ( !dlg->addMessage(to,method) ) delete(to); 3244 if ( !dlg->addMessage(to,method) ) delete(to);
3234 } 3245 }
3235 } 3246 }
3236} 3247}
3237 3248
3238void CalendarView::openAddressbook() 3249void CalendarView::openAddressbook()
3239{ 3250{
3240 KRun::runCommand("kaddressbook"); 3251 KRun::runCommand("kaddressbook");
3241} 3252}
3242 3253
3243void CalendarView::setModified(bool modified) 3254void CalendarView::setModified(bool modified)
3244{ 3255{
3245 if ( modified ) 3256 if ( modified )
3246 emit signalmodified(); 3257 emit signalmodified();
3247 if (mModified != modified) { 3258 if (mModified != modified) {
3248 mModified = modified; 3259 mModified = modified;
3249 emit modifiedChanged(mModified); 3260 emit modifiedChanged(mModified);
3250 } 3261 }
3251} 3262}
3252 3263
3253bool CalendarView::isReadOnly() 3264bool CalendarView::isReadOnly()
3254{ 3265{
3255 return mReadOnly; 3266 return mReadOnly;
3256} 3267}
3257 3268
3258void CalendarView::setReadOnly(bool readOnly) 3269void CalendarView::setReadOnly(bool readOnly)
3259{ 3270{
3260 if (mReadOnly != readOnly) { 3271 if (mReadOnly != readOnly) {
3261 mReadOnly = readOnly; 3272 mReadOnly = readOnly;
3262 emit readOnlyChanged(mReadOnly); 3273 emit readOnlyChanged(mReadOnly);
3263 } 3274 }
3264} 3275}
3265 3276
3266bool CalendarView::isModified() 3277bool CalendarView::isModified()
3267{ 3278{
3268 return mModified; 3279 return mModified;
3269} 3280}
3270 3281
3271void CalendarView::printSetup() 3282void CalendarView::printSetup()
3272{ 3283{
3273#ifndef KORG_NOPRINTER 3284#ifndef KORG_NOPRINTER
3274 createPrinter(); 3285 createPrinter();
3275 3286
3276 mCalPrinter->setupPrinter(); 3287 mCalPrinter->setupPrinter();
3277#endif 3288#endif
3278} 3289}
3279 3290
3280void CalendarView::print() 3291void CalendarView::print()
3281{ 3292{
3282#ifndef KORG_NOPRINTER 3293#ifndef KORG_NOPRINTER
3283 createPrinter(); 3294 createPrinter();
3284 3295
3285 DateList tmpDateList = mNavigator->selectedDates(); 3296 DateList tmpDateList = mNavigator->selectedDates();
3286 mCalPrinter->print(CalPrinter::Month, 3297 mCalPrinter->print(CalPrinter::Month,
3287 tmpDateList.first(), tmpDateList.last()); 3298 tmpDateList.first(), tmpDateList.last());
3288#endif 3299#endif
3289} 3300}
3290 3301
3291void CalendarView::printPreview() 3302void CalendarView::printPreview()
3292{ 3303{
3293#ifndef KORG_NOPRINTER 3304#ifndef KORG_NOPRINTER
3294 kdDebug() << "CalendarView::printPreview()" << endl; 3305 kdDebug() << "CalendarView::printPreview()" << endl;
3295 3306
3296 createPrinter(); 3307 createPrinter();
3297 3308
3298 DateList tmpDateList = mNavigator->selectedDates(); 3309 DateList tmpDateList = mNavigator->selectedDates();
3299 3310
3300 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3311 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3301 tmpDateList.last()); 3312 tmpDateList.last());
3302#endif 3313#endif
3303} 3314}
3304 3315
3305void CalendarView::exportICalendar() 3316void CalendarView::exportICalendar()
3306{ 3317{
3307 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3318 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3308 3319
3309 // Force correct extension 3320 // Force correct extension
3310 if (filename.right(4) != ".ics") filename += ".ics"; 3321 if (filename.right(4) != ".ics") filename += ".ics";
3311 3322
3312 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3323 FileStorage storage( mCalendar, filename, new ICalFormat() );
3313 storage.save(); 3324 storage.save();
3314} 3325}
3315 3326
3316bool CalendarView::exportVCalendar( QString filename ) 3327bool CalendarView::exportVCalendar( QString filename )
3317{ 3328{
3318 if (mCalendar->journals().count() > 0) { 3329 if (mCalendar->journals().count() > 0) {
3319 int result = KMessageBox::warningContinueCancel(this, 3330 int result = KMessageBox::warningContinueCancel(this,
3320 i18n("The journal entries can not be\nexported to a vCalendar file."), 3331 i18n("The journal entries can not be\nexported to a vCalendar file."),
3321 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3332 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3322 true); 3333 true);
3323 if (result != KMessageBox::Continue) return false; 3334 if (result != KMessageBox::Continue) return false;
3324 } 3335 }
3325 3336
3326 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3337 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3327 3338
3328 // Force correct extension 3339 // Force correct extension
3329 if (filename.right(4) != ".vcs") filename += ".vcs"; 3340 if (filename.right(4) != ".vcs") filename += ".vcs";
3330 3341
3331 FileStorage storage( mCalendar, filename, new VCalFormat ); 3342 FileStorage storage( mCalendar, filename, new VCalFormat );
3332 return storage.save(); 3343 return storage.save();
3333 3344
3334} 3345}
3335 3346
3336void CalendarView::eventUpdated(Incidence *) 3347void CalendarView::eventUpdated(Incidence *)
3337{ 3348{
3338 setModified(); 3349 setModified();
3339 // Don't call updateView here. The code, which has caused the update of the 3350 // Don't call updateView here. The code, which has caused the update of the
3340 // event is responsible for updating the view. 3351 // event is responsible for updating the view.
3341 // updateView(); 3352 // updateView();
3342} 3353}
3343 3354
3344void CalendarView::adaptNavigationUnits() 3355void CalendarView::adaptNavigationUnits()
3345{ 3356{
3346 if (mViewManager->currentView()->isEventView()) { 3357 if (mViewManager->currentView()->isEventView()) {
3347 int days = mViewManager->currentView()->currentDateCount(); 3358 int days = mViewManager->currentView()->currentDateCount();
3348 if (days == 1) { 3359 if (days == 1) {
3349 emit changeNavStringPrev(i18n("&Previous Day")); 3360 emit changeNavStringPrev(i18n("&Previous Day"));
3350 emit changeNavStringNext(i18n("&Next Day")); 3361 emit changeNavStringNext(i18n("&Next Day"));
3351 } else { 3362 } else {
3352 emit changeNavStringPrev(i18n("&Previous Week")); 3363 emit changeNavStringPrev(i18n("&Previous Week"));
3353 emit changeNavStringNext(i18n("&Next Week")); 3364 emit changeNavStringNext(i18n("&Next Week"));
3354 } 3365 }
3355 } 3366 }
3356} 3367}
3357 3368
3358void CalendarView::processMainViewSelection( Incidence *incidence ) 3369void CalendarView::processMainViewSelection( Incidence *incidence )
3359{ 3370{
3360 if ( incidence ) mTodoList->clearSelection(); 3371 if ( incidence ) mTodoList->clearSelection();
3361 processIncidenceSelection( incidence ); 3372 processIncidenceSelection( incidence );
3362} 3373}
3363 3374
3364void CalendarView::processTodoListSelection( Incidence *incidence ) 3375void CalendarView::processTodoListSelection( Incidence *incidence )
3365{ 3376{
3366 if ( incidence && mViewManager->currentView() ) { 3377 if ( incidence && mViewManager->currentView() ) {
3367 mViewManager->currentView()->clearSelection(); 3378 mViewManager->currentView()->clearSelection();
3368 } 3379 }
3369 processIncidenceSelection( incidence ); 3380 processIncidenceSelection( incidence );
3370} 3381}
3371 3382
3372void CalendarView::processIncidenceSelection( Incidence *incidence ) 3383void CalendarView::processIncidenceSelection( Incidence *incidence )
3373{ 3384{
3374 if ( incidence == mSelectedIncidence ) return; 3385 if ( incidence == mSelectedIncidence ) return;
3375 3386
3376 mSelectedIncidence = incidence; 3387 mSelectedIncidence = incidence;
3377 3388
3378 emit incidenceSelected( mSelectedIncidence ); 3389 emit incidenceSelected( mSelectedIncidence );
3379 3390
3380 if ( incidence && incidence->type() == "Event" ) { 3391 if ( incidence && incidence->type() == "Event" ) {
3381 Event *event = static_cast<Event *>( incidence ); 3392 Event *event = static_cast<Event *>( incidence );
3382 if ( event->organizer() == KOPrefs::instance()->email() ) { 3393 if ( event->organizer() == KOPrefs::instance()->email() ) {
3383 emit organizerEventsSelected( true ); 3394 emit organizerEventsSelected( true );
3384 } else { 3395 } else {
3385 emit organizerEventsSelected(false); 3396 emit organizerEventsSelected(false);
3386 } 3397 }
3387 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3398 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3388 KOPrefs::instance()->email() ) ) { 3399 KOPrefs::instance()->email() ) ) {
3389 emit groupEventsSelected( true ); 3400 emit groupEventsSelected( true );
3390 } else { 3401 } else {
3391 emit groupEventsSelected(false); 3402 emit groupEventsSelected(false);
3392 } 3403 }
3393 return; 3404 return;
3394 } else { 3405 } else {
3395 if ( incidence && incidence->type() == "Todo" ) { 3406 if ( incidence && incidence->type() == "Todo" ) {
3396 emit todoSelected( true ); 3407 emit todoSelected( true );
3397 Todo *event = static_cast<Todo *>( incidence ); 3408 Todo *event = static_cast<Todo *>( incidence );
3398 if ( event->organizer() == KOPrefs::instance()->email() ) { 3409 if ( event->organizer() == KOPrefs::instance()->email() ) {
3399 emit organizerEventsSelected( true ); 3410 emit organizerEventsSelected( true );
3400 } else { 3411 } else {
3401 emit organizerEventsSelected(false); 3412 emit organizerEventsSelected(false);
3402 } 3413 }
3403 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3414 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3404 KOPrefs::instance()->email() ) ) { 3415 KOPrefs::instance()->email() ) ) {
3405 emit groupEventsSelected( true ); 3416 emit groupEventsSelected( true );
3406 } else { 3417 } else {
3407 emit groupEventsSelected(false); 3418 emit groupEventsSelected(false);
3408 } 3419 }
3409 return; 3420 return;
3410 } else { 3421 } else {
3411 emit todoSelected( false ); 3422 emit todoSelected( false );
3412 emit organizerEventsSelected(false); 3423 emit organizerEventsSelected(false);
3413 emit groupEventsSelected(false); 3424 emit groupEventsSelected(false);
3414 } 3425 }
3415 return; 3426 return;
3416 } 3427 }
3417 3428
3418 /* if ( incidence && incidence->type() == "Todo" ) { 3429 /* if ( incidence && incidence->type() == "Todo" ) {
3419 emit todoSelected( true ); 3430 emit todoSelected( true );
3420 } else { 3431 } else {
3421 emit todoSelected( false ); 3432 emit todoSelected( false );
3422 }*/ 3433 }*/
3423} 3434}
3424 3435
3425 3436
3426void CalendarView::checkClipboard() 3437void CalendarView::checkClipboard()
3427{ 3438{
3428#ifndef KORG_NODND 3439#ifndef KORG_NODND
3429 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3440 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3430 emit pasteEnabled(true); 3441 emit pasteEnabled(true);
3431 } else { 3442 } else {
3432 emit pasteEnabled(false); 3443 emit pasteEnabled(false);
3433 } 3444 }
3434#endif 3445#endif
3435} 3446}
3436 3447
3437void CalendarView::showDates(const DateList &selectedDates) 3448void CalendarView::showDates(const DateList &selectedDates)
3438{ 3449{
3439 // kdDebug() << "CalendarView::selectDates()" << endl; 3450 // kdDebug() << "CalendarView::selectDates()" << endl;
3440 3451
3441 if ( mViewManager->currentView() ) { 3452 if ( mViewManager->currentView() ) {
3442 updateView( selectedDates.first(), selectedDates.last() ); 3453 updateView( selectedDates.first(), selectedDates.last() );
3443 } else { 3454 } else {
3444 mViewManager->showAgendaView(); 3455 mViewManager->showAgendaView();
3445 } 3456 }
3446 3457
3447 QString selDates; 3458 QString selDates;
3448 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3459 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3449 if (selectedDates.first() < selectedDates.last() ) 3460 if (selectedDates.first() < selectedDates.last() )
3450 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3461 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3451 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3462 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3452 3463
3453} 3464}
3454 3465
3455QPtrList<CalFilter> CalendarView::filters() 3466QPtrList<CalFilter> CalendarView::filters()
3456{ 3467{
3457 return mFilters; 3468 return mFilters;
3458 3469
3459} 3470}
3460void CalendarView::editFilters() 3471void CalendarView::editFilters()
3461{ 3472{
3462 // kdDebug() << "CalendarView::editFilters()" << endl; 3473 // kdDebug() << "CalendarView::editFilters()" << endl;
3463 3474
3464 CalFilter *filter = mFilters.first(); 3475 CalFilter *filter = mFilters.first();
3465 while(filter) { 3476 while(filter) {
3466 kdDebug() << " Filter: " << filter->name() << endl; 3477 kdDebug() << " Filter: " << filter->name() << endl;
3467 filter = mFilters.next(); 3478 filter = mFilters.next();
3468 } 3479 }
3469 3480
3470 mDialogManager->showFilterEditDialog(&mFilters); 3481 mDialogManager->showFilterEditDialog(&mFilters);
3471} 3482}
3472void CalendarView::toggleFilter() 3483void CalendarView::toggleFilter()
3473{ 3484{
3474 showFilter(! mFilterView->isVisible()); 3485 showFilter(! mFilterView->isVisible());
3475} 3486}
3476 3487
3477KOFilterView *CalendarView::filterView() 3488KOFilterView *CalendarView::filterView()
3478{ 3489{
3479 return mFilterView; 3490 return mFilterView;
3480} 3491}
3481void CalendarView::selectFilter( int fil ) 3492void CalendarView::selectFilter( int fil )
3482{ 3493{
3483 mFilterView->setSelectedFilter( fil ); 3494 mFilterView->setSelectedFilter( fil );
3484} 3495}
3485void CalendarView::showFilter(bool visible) 3496void CalendarView::showFilter(bool visible)
3486{ 3497{
3487 if (visible) mFilterView->show(); 3498 if (visible) mFilterView->show();
3488 else mFilterView->hide(); 3499 else mFilterView->hide();
3489} 3500}
3490void CalendarView::toggleFilerEnabled( ) 3501void CalendarView::toggleFilerEnabled( )
3491{ 3502{
3492 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3503 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3493 if ( !mFilterView->filtersEnabled() ) 3504 if ( !mFilterView->filtersEnabled() )
3494 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3505 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3495 3506
3496} 3507}
3497void CalendarView::updateFilter() 3508void CalendarView::updateFilter()
3498{ 3509{
3499 CalFilter *filter = mFilterView->selectedFilter(); 3510 CalFilter *filter = mFilterView->selectedFilter();
3500 if (filter) { 3511 if (filter) {
3501 if (mFilterView->filtersEnabled()) { 3512 if (mFilterView->filtersEnabled()) {
3502 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3513 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3503 filter->setEnabled(true); 3514 filter->setEnabled(true);
3504 } 3515 }
3505 else filter->setEnabled(false); 3516 else filter->setEnabled(false);
3506 mCalendar->setFilter(filter); 3517 mCalendar->setFilter(filter);
3507 updateView(); 3518 updateView();
3508 } 3519 }
3509} 3520}
3510 3521
3511void CalendarView::filterEdited() 3522void CalendarView::filterEdited()
3512{ 3523{
3513 mFilterView->updateFilters(); 3524 mFilterView->updateFilters();
3514 updateFilter(); 3525 updateFilter();
3515 writeSettings(); 3526 writeSettings();
3516} 3527}
3517 3528
3518 3529
3519void CalendarView::takeOverEvent() 3530void CalendarView::takeOverEvent()
3520{ 3531{
3521 Incidence *incidence = currentSelection(); 3532 Incidence *incidence = currentSelection();
3522 3533
3523 if (!incidence) return; 3534 if (!incidence) return;
3524 3535
3525 incidence->setOrganizer(KOPrefs::instance()->email()); 3536 incidence->setOrganizer(KOPrefs::instance()->email());
3526 incidence->recreate(); 3537 incidence->recreate();
3527 incidence->setReadOnly(false); 3538 incidence->setReadOnly(false);
3528 3539
3529 updateView(); 3540 updateView();
3530} 3541}
3531 3542
3532void CalendarView::takeOverCalendar() 3543void CalendarView::takeOverCalendar()
3533{ 3544{
3534 // TODO: Create Calendar::allIncidences() function and use it here 3545 // TODO: Create Calendar::allIncidences() function and use it here
3535 3546
3536 QPtrList<Event> events = mCalendar->events(); 3547 QPtrList<Event> events = mCalendar->events();
3537 for(uint i=0; i<events.count(); ++i) { 3548 for(uint i=0; i<events.count(); ++i) {
3538 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3549 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3539 events.at(i)->recreate(); 3550 events.at(i)->recreate();
3540 events.at(i)->setReadOnly(false); 3551 events.at(i)->setReadOnly(false);
3541 } 3552 }
3542 3553
3543 QPtrList<Todo> todos = mCalendar->todos(); 3554 QPtrList<Todo> todos = mCalendar->todos();
3544 for(uint i=0; i<todos.count(); ++i) { 3555 for(uint i=0; i<todos.count(); ++i) {
3545 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3556 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3546 todos.at(i)->recreate(); 3557 todos.at(i)->recreate();
3547 todos.at(i)->setReadOnly(false); 3558 todos.at(i)->setReadOnly(false);
3548 } 3559 }
3549 3560
3550 QPtrList<Journal> journals = mCalendar->journals(); 3561 QPtrList<Journal> journals = mCalendar->journals();
3551 for(uint i=0; i<journals.count(); ++i) { 3562 for(uint i=0; i<journals.count(); ++i) {
3552 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3563 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3553 journals.at(i)->recreate(); 3564 journals.at(i)->recreate();
3554 journals.at(i)->setReadOnly(false); 3565 journals.at(i)->setReadOnly(false);
3555 } 3566 }
3556 3567
3557 updateView(); 3568 updateView();
3558} 3569}
3559 3570
3560void CalendarView::showIntro() 3571void CalendarView::showIntro()
3561{ 3572{
3562 kdDebug() << "To be implemented." << endl; 3573 kdDebug() << "To be implemented." << endl;
3563} 3574}
3564 3575
3565QWidgetStack *CalendarView::viewStack() 3576QWidgetStack *CalendarView::viewStack()
3566{ 3577{
3567 return mRightFrame; 3578 return mRightFrame;
3568} 3579}
3569 3580
3570QWidget *CalendarView::leftFrame() 3581QWidget *CalendarView::leftFrame()
3571{ 3582{
3572 return mLeftFrame; 3583 return mLeftFrame;
3573} 3584}
3574 3585
3575DateNavigator *CalendarView::dateNavigator() 3586DateNavigator *CalendarView::dateNavigator()
3576{ 3587{
3577 return mNavigator; 3588 return mNavigator;
3578} 3589}
3579 3590
3580KDateNavigator* CalendarView::dateNavigatorWidget() 3591KDateNavigator* CalendarView::dateNavigatorWidget()
3581{ 3592{
3582 return mDateNavigator; 3593 return mDateNavigator;
3583} 3594}
3584void CalendarView::toggleDateNavigatorWidget() 3595void CalendarView::toggleDateNavigatorWidget()
3585{ 3596{
3586 if (mDateNavigator->isVisible()) 3597 if (mDateNavigator->isVisible())
3587 mDateNavigator->hide(); 3598 mDateNavigator->hide();
3588 else 3599 else
3589 mDateNavigator->show(); 3600 mDateNavigator->show();
3590} 3601}
3591void CalendarView::addView(KOrg::BaseView *view) 3602void CalendarView::addView(KOrg::BaseView *view)
3592{ 3603{
3593 mViewManager->addView(view); 3604 mViewManager->addView(view);
3594} 3605}
3595 3606
3596void CalendarView::showView(KOrg::BaseView *view) 3607void CalendarView::showView(KOrg::BaseView *view)
3597{ 3608{
3598 mViewManager->showView(view, mLeftFrame->isVisible()); 3609 mViewManager->showView(view, mLeftFrame->isVisible());
3599} 3610}
3600 3611
3601Incidence *CalendarView::currentSelection() 3612Incidence *CalendarView::currentSelection()
3602{ 3613{
3603 return mViewManager->currentSelection(); 3614 return mViewManager->currentSelection();
3604} 3615}
3605void CalendarView::toggleAllDaySize() 3616void CalendarView::toggleAllDaySize()
3606{ 3617{
3607 /* 3618 /*
3608 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3619 if ( KOPrefs::instance()->mAllDaySize > 47 )
3609 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3620 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3610 else 3621 else
3611 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3622 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3612 */ 3623 */
3613 viewManager()->agendaView()->toggleAllDay(); 3624 viewManager()->agendaView()->toggleAllDay();
3614} 3625}
3615void CalendarView::toggleExpand() 3626void CalendarView::toggleExpand()
3616{ 3627{
3617 // if ( mLeftFrame->isHidden() ) { 3628 // if ( mLeftFrame->isHidden() ) {
3618 // mLeftFrame->show(); 3629 // mLeftFrame->show();
3619 // emit calendarViewExpanded( false ); 3630 // emit calendarViewExpanded( false );
3620 // } else { 3631 // } else {
3621 // mLeftFrame->hide(); 3632 // mLeftFrame->hide();
3622 // emit calendarViewExpanded( true ); 3633 // emit calendarViewExpanded( true );
3623 // } 3634 // }
3624 3635
3625 globalFlagBlockAgenda = 1; 3636 globalFlagBlockAgenda = 1;
3626 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3637 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3627 globalFlagBlockAgenda = 5; 3638 globalFlagBlockAgenda = 5;
3628 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3639 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3629 //mViewManager->showView( 0, true ); 3640 //mViewManager->showView( 0, true );
3630} 3641}
3631 3642
3632void CalendarView::calendarModified( bool modified, Calendar * ) 3643void CalendarView::calendarModified( bool modified, Calendar * )
3633{ 3644{
3634 setModified( modified ); 3645 setModified( modified );
3635} 3646}
3636 3647
3637Todo *CalendarView::selectedTodo() 3648Todo *CalendarView::selectedTodo()
3638{ 3649{
3639 Incidence *incidence = currentSelection(); 3650 Incidence *incidence = currentSelection();
3640 if ( incidence && incidence->type() == "Todo" ) { 3651 if ( incidence && incidence->type() == "Todo" ) {
3641 return static_cast<Todo *>( incidence ); 3652 return static_cast<Todo *>( incidence );
3642 } 3653 }
3643 3654
3644 incidence = mTodoList->selectedIncidences().first(); 3655 incidence = mTodoList->selectedIncidences().first();
3645 if ( incidence && incidence->type() == "Todo" ) { 3656 if ( incidence && incidence->type() == "Todo" ) {
3646 return static_cast<Todo *>( incidence ); 3657 return static_cast<Todo *>( incidence );
3647 } 3658 }
3648 3659
3649 return 0; 3660 return 0;
3650} 3661}
3651 3662
3652void CalendarView::dialogClosing(Incidence *in) 3663void CalendarView::dialogClosing(Incidence *in)
3653{ 3664{
3654 // mDialogList.remove(in); 3665 // mDialogList.remove(in);
3655} 3666}
3656 3667
3657void CalendarView::showIncidence() 3668void CalendarView::showIncidence()
3658{ 3669{
3659 Incidence *incidence = currentSelection(); 3670 Incidence *incidence = currentSelection();
3660 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3661 if ( incidence ) { 3672 if ( incidence ) {
3662 ShowIncidenceVisitor v; 3673 ShowIncidenceVisitor v;
3663 v.act( incidence, this ); 3674 v.act( incidence, this );
3664 } 3675 }
3665} 3676}
3666void CalendarView::editIncidenceDescription() 3677void CalendarView::editIncidenceDescription()
3667{ 3678{
3668 mFlagEditDescription = true; 3679 mFlagEditDescription = true;
3669 editIncidence(); 3680 editIncidence();
3670 mFlagEditDescription = false; 3681 mFlagEditDescription = false;
3671} 3682}
3672void CalendarView::editIncidence() 3683void CalendarView::editIncidence()
3673{ 3684{
3674 // qDebug("editIncidence() "); 3685 // qDebug("editIncidence() ");
3675 Incidence *incidence = currentSelection(); 3686 Incidence *incidence = currentSelection();
3676 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3677 if ( incidence ) { 3688 if ( incidence ) {
3678 EditIncidenceVisitor v; 3689 EditIncidenceVisitor v;
3679 v.act( incidence, this ); 3690 v.act( incidence, this );
3680 } 3691 }
3681} 3692}
3682 3693
3683void CalendarView::deleteIncidence() 3694void CalendarView::deleteIncidence()
3684{ 3695{
3685 Incidence *incidence = currentSelection(); 3696 Incidence *incidence = currentSelection();
3686 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3697 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3687 if ( incidence ) { 3698 if ( incidence ) {
3688 deleteIncidence(incidence); 3699 deleteIncidence(incidence);
3689 } 3700 }
3690} 3701}
3691 3702
3692void CalendarView::showIncidence(Incidence *incidence) 3703void CalendarView::showIncidence(Incidence *incidence)
3693{ 3704{
3694 if ( incidence ) { 3705 if ( incidence ) {
3695 ShowIncidenceVisitor v; 3706 ShowIncidenceVisitor v;
3696 v.act( incidence, this ); 3707 v.act( incidence, this );
3697 } 3708 }
3698} 3709}
3699 3710
3700void CalendarView::editIncidence(Incidence *incidence) 3711void CalendarView::editIncidence(Incidence *incidence)
3701{ 3712{
3702 if ( incidence ) { 3713 if ( incidence ) {
3703 3714
3704 EditIncidenceVisitor v; 3715 EditIncidenceVisitor v;
3705 v.act( incidence, this ); 3716 v.act( incidence, this );
3706 3717
3707 } 3718 }
3708} 3719}
3709 3720
3710void CalendarView::deleteIncidence(Incidence *incidence) 3721void CalendarView::deleteIncidence(Incidence *incidence)
3711{ 3722{
3712 //qDebug(" CalendarView::deleteIncidence "); 3723 //qDebug(" CalendarView::deleteIncidence ");
3713 if ( incidence ) { 3724 if ( incidence ) {
3714 DeleteIncidenceVisitor v; 3725 DeleteIncidenceVisitor v;
3715 v.act( incidence, this ); 3726 v.act( incidence, this );
3716 } 3727 }
3717} 3728}
3718 3729
3719 3730
3720void CalendarView::lookForOutgoingMessages() 3731void CalendarView::lookForOutgoingMessages()
3721{ 3732{
3722 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3733 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3723 ogd->loadMessages(); 3734 ogd->loadMessages();
3724} 3735}
3725 3736
3726void CalendarView::lookForIncomingMessages() 3737void CalendarView::lookForIncomingMessages()
3727{ 3738{
3728 IncomingDialog *icd = mDialogManager->incomingDialog(); 3739 IncomingDialog *icd = mDialogManager->incomingDialog();
3729 icd->retrieve(); 3740 icd->retrieve();
3730} 3741}
3731 3742
3732bool CalendarView::removeCompletedSubTodos( Todo* t ) 3743bool CalendarView::removeCompletedSubTodos( Todo* t )
3733{ 3744{
3734 bool deleteTodo = true; 3745 bool deleteTodo = true;
3735 QPtrList<Incidence> subTodos; 3746 QPtrList<Incidence> subTodos;
3736 Incidence *aTodo; 3747 Incidence *aTodo;
3737 subTodos = t->relations(); 3748 subTodos = t->relations();
3738 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3749 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3739 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3750 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3740 deleteTodo = false; 3751 deleteTodo = false;
3741 } 3752 }
3742 if ( deleteTodo ) { 3753 if ( deleteTodo ) {
3743 if ( t->isCompleted() ) { 3754 if ( t->isCompleted() ) {
3744 checkExternalId( t ); 3755 checkExternalId( t );
3745 mCalendar->deleteTodo( t ); 3756 mCalendar->deleteTodo( t );
3746 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3757 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3747 } 3758 }
3748 else 3759 else
3749 deleteTodo = false; 3760 deleteTodo = false;
3750 } 3761 }
3751 return deleteTodo; 3762 return deleteTodo;
3752 3763
3753} 3764}
3754void CalendarView::purgeCompleted() 3765void CalendarView::purgeCompleted()
3755{ 3766{
3756 int result = KMessageBox::warningContinueCancel(this, 3767 int result = KMessageBox::warningContinueCancel(this,
3757 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3768 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3758 3769
3759 if (result == KMessageBox::Continue) { 3770 if (result == KMessageBox::Continue) {
3760 3771
3761 QPtrList<Todo> todoCal; 3772 QPtrList<Todo> todoCal;
3762 QPtrList<Todo> rootTodos; 3773 QPtrList<Todo> rootTodos;
3763 //QPtrList<Incidence> rel; 3774 //QPtrList<Incidence> rel;
3764 Todo *aTodo;//, *rTodo; 3775 Todo *aTodo;//, *rTodo;
3765 Incidence *rIncidence; 3776 Incidence *rIncidence;
3766 bool childDelete = false; 3777 bool childDelete = false;
3767 bool deletedOne = true; 3778 bool deletedOne = true;
3768 todoCal = calendar()->todos(); 3779 todoCal = calendar()->todos();
3769 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3780 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3770 if ( !aTodo->relatedTo() ) 3781 if ( !aTodo->relatedTo() )
3771 rootTodos.append( aTodo ); 3782 rootTodos.append( aTodo );
3772 } 3783 }
3773 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3784 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3774 removeCompletedSubTodos( aTodo ); 3785 removeCompletedSubTodos( aTodo );
3775 } 3786 }
3776 3787
3777 updateView(); 3788 updateView();
3778 } 3789 }
3779} 3790}
3780 3791
3781void CalendarView::slotCalendarChanged() 3792void CalendarView::slotCalendarChanged()
3782{ 3793{
3783 ; 3794 ;
3784} 3795}
3785 3796
3786NavigatorBar *CalendarView::navigatorBar() 3797NavigatorBar *CalendarView::navigatorBar()
3787{ 3798{
3788 return mNavigatorBar; 3799 return mNavigatorBar;
3789} 3800}
3790 3801
3791 3802
3792 3803
3793void CalendarView::keyPressEvent ( QKeyEvent *e) 3804void CalendarView::keyPressEvent ( QKeyEvent *e)
3794{ 3805{
3795 //qDebug(" alendarView::keyPressEvent "); 3806 //qDebug(" alendarView::keyPressEvent ");
3796 e->ignore(); 3807 e->ignore();
3797} 3808}
3798 3809
3799 3810
3800bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3811bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3801{ 3812{
3802 // mSyncManager = manager; 3813 // mSyncManager = manager;
3803 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3814 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3804 qDebug("SyncKDE request detected!"); 3815 qDebug("SyncKDE request detected!");
3805 } 3816 }
3806 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3817 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3807 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3818 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3808 return syncCalendar( filename, mode ); 3819 return syncCalendar( filename, mode );
3809} 3820}
3810bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3821bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3811{ 3822{
3812 //mSyncManager = manager; 3823 //mSyncManager = manager;
3813 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3824 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3814 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3825 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3815 if ( resource == "sharp" ) 3826 if ( resource == "sharp" )
3816 syncExternal( 0 ); 3827 syncExternal( 0 );
3817 if ( resource == "phone" ) 3828 if ( resource == "phone" )
3818 syncExternal( 1 ); 3829 syncExternal( 1 );
3819 // pending setmodified 3830 // pending setmodified
3820 return true; 3831 return true;
3821} 3832}
3822void CalendarView::setSyncManager(KSyncManager* manager) 3833void CalendarView::setSyncManager(KSyncManager* manager)
3823{ 3834{
3824 mSyncManager = manager; 3835 mSyncManager = manager;
3825} 3836}
3826 3837
3827void CalendarView::removeSyncInfo( QString syncProfile) 3838void CalendarView::removeSyncInfo( QString syncProfile)
3828{ 3839{
3829 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3840 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3830 mCalendar->removeSyncInfo( syncProfile ); 3841 mCalendar->removeSyncInfo( syncProfile );
3831 3842
3832} 3843}
3833 3844
3834void CalendarView::undo_delete() 3845void CalendarView::undo_delete()
3835{ 3846{
3836 //qDebug("undo_delete() "); 3847 //qDebug("undo_delete() ");
3837 Incidence* undo = mCalendar->undoIncidence(); 3848 Incidence* undo = mCalendar->undoIncidence();
3838 if ( !undo ) { 3849 if ( !undo ) {
3839 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3850 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3840 i18n("KO/Pi")); 3851 i18n("KO/Pi"));
3841 return; 3852 return;
3842 } 3853 }
3843 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3854 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3844 i18n("\nAre you sure you want\nto restore this?"), 3855 i18n("\nAre you sure you want\nto restore this?"),
3845 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3856 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3846 mCalendar->undoDeleteIncidence(); 3857 mCalendar->undoDeleteIncidence();
3847 updateView(); 3858 updateView();
3848 } 3859 }
3849} 3860}
diff --git a/korganizer/filteredit_base.cpp b/korganizer/filteredit_base.cpp
index 21a0954..e724da4 100644
--- a/korganizer/filteredit_base.cpp
+++ b/korganizer/filteredit_base.cpp
@@ -1,128 +1,145 @@
1/**************************************************************************** 1/****************************************************************************
2** Form implementation generated from reading ui file 'filteredit_base.ui' 2** Form implementation generated from reading ui file 'filteredit_base.ui'
3** 3**
4** Created: Di Mai 4 15:30:31 2004 4** Created: So Jan 16 11:23:21 2005
5** by: The User Interface Compiler ($Id$) 5** by: The User Interface Compiler ($Id$)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#include "filteredit_base.h" 10#include "filteredit_base.h"
11 11
12#include <qvariant.h> 12#include <qvariant.h>
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qframe.h> 14#include <qframe.h>
15#include <qbuttongroup.h> 15#include <qbuttongroup.h>
16#include <qradiobutton.h> 16#include <qradiobutton.h>
17#include <qlistbox.h> 17#include <qlistbox.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qcheckbox.h> 19#include <qcheckbox.h>
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtooltip.h> 21#include <qtooltip.h>
22#include <qwhatsthis.h> 22#include <qwhatsthis.h>
23#include "filteredit_base.ui.h"
23 24
24/* 25/*
25 * Constructs a FilterEdit_base as a child of 'parent', with the 26 * Constructs a FilterEdit_base as a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'. 27 * name 'name' and widget flags set to 'f'.
27 */ 28 */
28FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl ) 29FilterEdit_base::FilterEdit_base( QWidget* parent, const char* name, WFlags fl )
29 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
30{ 31{
31 if ( !name ) 32 if ( !name )
32 setName( "FilterEdit_base" ); 33 setName( "FilterEdit_base" );
33 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout"); 34 FilterEdit_baseLayout = new QVBoxLayout( this, 0, 0, "FilterEdit_baseLayout");
34 35
35 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" ); 36 mCriteriaFrame = new QFrame( this, "mCriteriaFrame" );
36 mCriteriaFrame->setFrameShape( QFrame::StyledPanel ); 37 mCriteriaFrame->setFrameShape( QFrame::StyledPanel );
37 mCriteriaFrame->setFrameShadow( QFrame::Raised ); 38 mCriteriaFrame->setFrameShadow( QFrame::Raised );
38 mCriteriaFrameLayout = new QGridLayout( mCriteriaFrame, 1, 1, 3, 2, "mCriteriaFrameLayout"); 39 mCriteriaFrameLayout = new QVBoxLayout( mCriteriaFrame, 3, 2, "mCriteriaFrameLayout");
39 40
40 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" ); 41 ButtonGroup1 = new QButtonGroup( mCriteriaFrame, "ButtonGroup1" );
41 ButtonGroup1->setColumnLayout(0, Qt::Vertical ); 42 ButtonGroup1->setColumnLayout(0, Qt::Vertical );
42 ButtonGroup1->layout()->setSpacing( 6 ); 43 ButtonGroup1->layout()->setSpacing( 6 );
43 ButtonGroup1->layout()->setMargin( 11 ); 44 ButtonGroup1->layout()->setMargin( 6 );
44 ButtonGroup1Layout = new QVBoxLayout( ButtonGroup1->layout() ); 45 ButtonGroup1Layout = new QGridLayout( ButtonGroup1->layout() );
45 ButtonGroup1Layout->setAlignment( Qt::AlignTop ); 46 ButtonGroup1Layout->setAlignment( Qt::AlignTop );
46 47
48 layout4 = new QHBoxLayout( 0, 0, 6, "layout4");
49
47 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" ); 50 mCatShowCheck = new QRadioButton( ButtonGroup1, "mCatShowCheck" );
48 ButtonGroup1Layout->addWidget( mCatShowCheck ); 51 layout4->addWidget( mCatShowCheck );
49 52
50 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" ); 53 mCatHideCheck = new QRadioButton( ButtonGroup1, "mCatHideCheck" );
51 ButtonGroup1Layout->addWidget( mCatHideCheck ); 54 layout4->addWidget( mCatHideCheck );
52
53 mCatList = new QListBox( ButtonGroup1, "mCatList" );
54 ButtonGroup1Layout->addWidget( mCatList );
55 55
56 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" ); 56 mCatEditButton = new QPushButton( ButtonGroup1, "mCatEditButton" );
57 ButtonGroup1Layout->addWidget( mCatEditButton ); 57 layout4->addWidget( mCatEditButton );
58 58
59 mCriteriaFrameLayout->addWidget( ButtonGroup1, 0, 0 ); 59 ButtonGroup1Layout->addLayout( layout4, 0, 0 );
60 60
61 layout1 = new QHBoxLayout( 0, 0, 0, "layout1"); 61 mCatList = new QListBox( ButtonGroup1, "mCatList" );
62
63 ButtonGroup1Layout->addWidget( mCatList, 1, 0 );
64 mCriteriaFrameLayout->addWidget( ButtonGroup1 );
65
66 layout7 = new QHBoxLayout( 0, 0, 6, "layout7");
62 67
63 textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" ); 68 textLabel1 = new QLabel( mCriteriaFrame, "textLabel1" );
64 layout1->addWidget( textLabel1 ); 69 layout7->addWidget( textLabel1 );
65 70
66 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" ); 71 mRecurringCheck = new QCheckBox( mCriteriaFrame, "mRecurringCheck" );
67 layout1->addWidget( mRecurringCheck ); 72 layout7->addWidget( mRecurringCheck );
68 73
69 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" ); 74 mCompletedCheck = new QCheckBox( mCriteriaFrame, "mCompletedCheck" );
70 layout1->addWidget( mCompletedCheck ); 75 layout7->addWidget( mCompletedCheck );
76 mCriteriaFrameLayout->addLayout( layout7 );
77
78 layout9 = new QHBoxLayout( 0, 0, 6, "layout9");
71 79
72 mCriteriaFrameLayout->addLayout( layout1, 1, 0 ); 80 textLabel1_2 = new QLabel( mCriteriaFrame, "textLabel1_2" );
81 layout9->addWidget( textLabel1_2 );
82
83 mEventCheck = new QCheckBox( mCriteriaFrame, "mEventCheck" );
84 layout9->addWidget( mEventCheck );
85
86 mTodoCheck = new QCheckBox( mCriteriaFrame, "mTodoCheck" );
87 layout9->addWidget( mTodoCheck );
88
89 mJournalCheck = new QCheckBox( mCriteriaFrame, "mJournalCheck" );
90 layout9->addWidget( mJournalCheck );
91 mCriteriaFrameLayout->addLayout( layout9 );
73 92
74 layout2 = new QHBoxLayout( 0, 0, 0, "layout2"); 93 layout2 = new QHBoxLayout( 0, 0, 0, "layout2");
75 94
76 textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" ); 95 textLabel2 = new QLabel( mCriteriaFrame, "textLabel2" );
77 layout2->addWidget( textLabel2 ); 96 layout2->addWidget( textLabel2 );
78 97
79 mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" ); 98 mPublicCheck = new QCheckBox( mCriteriaFrame, "mPublicCheck" );
80 layout2->addWidget( mPublicCheck ); 99 layout2->addWidget( mPublicCheck );
81 100
82 mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" ); 101 mPrivateCheck = new QCheckBox( mCriteriaFrame, "mPrivateCheck" );
83 layout2->addWidget( mPrivateCheck ); 102 layout2->addWidget( mPrivateCheck );
84 103
85 mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" ); 104 mConfidentialCheck = new QCheckBox( mCriteriaFrame, "mConfidentialCheck" );
86 mConfidentialCheck->setChecked( FALSE ); 105 mConfidentialCheck->setChecked( FALSE );
87 layout2->addWidget( mConfidentialCheck ); 106 layout2->addWidget( mConfidentialCheck );
88 107 mCriteriaFrameLayout->addLayout( layout2 );
89 mCriteriaFrameLayout->addLayout( layout2, 2, 0 );
90 FilterEdit_baseLayout->addWidget( mCriteriaFrame ); 108 FilterEdit_baseLayout->addWidget( mCriteriaFrame );
91 languageChange(); 109 languageChange();
92 resize( QSize(284, 241).expandedTo(minimumSizeHint()) ); 110 resize( QSize(351, 275).expandedTo(minimumSizeHint()) );
93 clearWState( WState_Polished ); 111 clearWState( WState_Polished );
94} 112}
95 113
96/* 114/*
97 * Destroys the object and frees any allocated resources 115 * Destroys the object and frees any allocated resources
98 */ 116 */
99FilterEdit_base::~FilterEdit_base() 117FilterEdit_base::~FilterEdit_base()
100{ 118{
101 // no need to delete child widgets, Qt does it all for us 119 // no need to delete child widgets, Qt does it all for us
102} 120}
103 121
104/* 122/*
105 * Sets the strings of the subwidgets using the current 123 * Sets the strings of the subwidgets using the current
106 * language. 124 * language.
107 */ 125 */
108void FilterEdit_base::languageChange() 126void FilterEdit_base::languageChange()
109{ 127{
110 setCaption( tr( "FilterEditor" ) ); 128 setCaption( tr( "FilterEditor" ) );
111 ButtonGroup1->setTitle( tr( "Categories" ) ); 129 ButtonGroup1->setTitle( tr( "Categories" ) );
112 mCatShowCheck->setText( tr( "Show only selected" ) ); 130 mCatShowCheck->setText( tr( "Include" ) );
113 mCatHideCheck->setText( tr( "Show all but selected" ) ); 131 mCatHideCheck->setText( tr( "Exclude" ) );
114 mCatEditButton->setText( tr( "Edit Selection..." ) ); 132 mCatEditButton->setText( tr( "Edit Selection..." ) );
115 textLabel1->setText( tr( "Hide" ) ); 133 textLabel1->setText( tr( "Exclude" ) );
116 mRecurringCheck->setText( tr( "recurring events" ) ); 134 mRecurringCheck->setText( tr( "recurring events" ) );
117 mCompletedCheck->setText( tr( "completed to-dos" ) ); 135 mCompletedCheck->setText( tr( "completed to-dos" ) );
118 textLabel2->setText( tr( "Show" ) ); 136 textLabel1_2->setText( tr( "Exclude" ) );
137 mEventCheck->setText( tr( "events" ) );
138 mTodoCheck->setText( tr( "todos" ) );
139 mJournalCheck->setText( tr( "journals" ) );
140 textLabel2->setText( tr( "Include" ) );
119 mPublicCheck->setText( tr( "public" ) ); 141 mPublicCheck->setText( tr( "public" ) );
120 mPrivateCheck->setText( tr( "private" ) ); 142 mPrivateCheck->setText( tr( "private" ) );
121 mConfidentialCheck->setText( tr( "confidential" ) ); 143 mConfidentialCheck->setText( tr( "confidential" ) );
122} 144}
123 145
124void FilterEdit_base::updateFilter()
125{
126 qWarning( "FilterEdit_base::updateFilter(): Not implemented yet" );
127}
128
diff --git a/korganizer/filteredit_base.h b/korganizer/filteredit_base.h
index 664598a..0c2988a 100644
--- a/korganizer/filteredit_base.h
+++ b/korganizer/filteredit_base.h
@@ -1,66 +1,72 @@
1/**************************************************************************** 1/****************************************************************************
2** Form interface generated from reading ui file 'filteredit_base.ui' 2** Form interface generated from reading ui file 'filteredit_base.ui'
3** 3**
4** Created: Di Mai 4 15:24:50 2004 4** Created: So Jan 16 11:23:21 2005
5** by: The User Interface Compiler ($Id$) 5** by: The User Interface Compiler ($Id$)
6** 6**
7** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
8****************************************************************************/ 8****************************************************************************/
9 9
10#ifndef FILTEREDIT_BASE_H 10#ifndef FILTEREDIT_BASE_H
11#define FILTEREDIT_BASE_H 11#define FILTEREDIT_BASE_H
12 12
13#include <qvariant.h> 13#include <qvariant.h>
14#include <qwidget.h> 14#include <qwidget.h>
15 15
16class QVBoxLayout; 16class QVBoxLayout;
17class QHBoxLayout; 17class QHBoxLayout;
18class QGridLayout; 18class QGridLayout;
19class QSpacerItem; 19class QSpacerItem;
20class QFrame; 20class QFrame;
21class QButtonGroup; 21class QButtonGroup;
22class QRadioButton; 22class QRadioButton;
23class QPushButton;
23class QListBox; 24class QListBox;
24class QListBoxItem; 25class QListBoxItem;
25class QPushButton;
26class QLabel; 26class QLabel;
27class QCheckBox; 27class QCheckBox;
28 28
29class FilterEdit_base : public QWidget 29class FilterEdit_base : public QWidget
30{ 30{
31 Q_OBJECT 31 Q_OBJECT
32 32
33public: 33public:
34 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 34 FilterEdit_base( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
35 ~FilterEdit_base(); 35 ~FilterEdit_base();
36 36
37 QFrame* mCriteriaFrame; 37 QFrame* mCriteriaFrame;
38 QButtonGroup* ButtonGroup1; 38 QButtonGroup* ButtonGroup1;
39 QRadioButton* mCatShowCheck; 39 QRadioButton* mCatShowCheck;
40 QRadioButton* mCatHideCheck; 40 QRadioButton* mCatHideCheck;
41 QListBox* mCatList;
42 QPushButton* mCatEditButton; 41 QPushButton* mCatEditButton;
42 QListBox* mCatList;
43 QLabel* textLabel1; 43 QLabel* textLabel1;
44 QCheckBox* mRecurringCheck; 44 QCheckBox* mRecurringCheck;
45 QCheckBox* mCompletedCheck; 45 QCheckBox* mCompletedCheck;
46 QLabel* textLabel1_2;
47 QCheckBox* mEventCheck;
48 QCheckBox* mTodoCheck;
49 QCheckBox* mJournalCheck;
46 QLabel* textLabel2; 50 QLabel* textLabel2;
47 QCheckBox* mPublicCheck; 51 QCheckBox* mPublicCheck;
48 QCheckBox* mPrivateCheck; 52 QCheckBox* mPrivateCheck;
49 QCheckBox* mConfidentialCheck; 53 QCheckBox* mConfidentialCheck;
50 54
51public slots: 55public slots:
52 virtual void updateFilter(); 56 virtual void updateFilter();
53 57
54protected: 58protected:
55 QVBoxLayout* FilterEdit_baseLayout; 59 QVBoxLayout* FilterEdit_baseLayout;
56 QGridLayout* mCriteriaFrameLayout; 60 QVBoxLayout* mCriteriaFrameLayout;
57 QVBoxLayout* ButtonGroup1Layout; 61 QGridLayout* ButtonGroup1Layout;
58 QHBoxLayout* layout1; 62 QHBoxLayout* layout4;
63 QHBoxLayout* layout7;
64 QHBoxLayout* layout9;
59 QHBoxLayout* layout2; 65 QHBoxLayout* layout2;
60 66
61protected slots: 67protected slots:
62 virtual void languageChange(); 68 virtual void languageChange();
63 69
64}; 70};
65 71
66#endif // FILTEREDIT_BASE_H 72#endif // FILTEREDIT_BASE_H
diff --git a/korganizer/filteredit_base.ui b/korganizer/filteredit_base.ui
index b7cbb59..2436f57 100644
--- a/korganizer/filteredit_base.ui
+++ b/korganizer/filteredit_base.ui
@@ -1,201 +1,250 @@
1<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> 1<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
2<class>FilterEdit_base</class> 2<class>FilterEdit_base</class>
3<widget class="QWidget"> 3<widget class="QWidget">
4 <property name="name"> 4 <property name="name">
5 <cstring>FilterEdit_base</cstring> 5 <cstring>FilterEdit_base</cstring>
6 </property> 6 </property>
7 <property name="geometry"> 7 <property name="geometry">
8 <rect> 8 <rect>
9 <x>0</x> 9 <x>0</x>
10 <y>0</y> 10 <y>0</y>
11 <width>284</width> 11 <width>351</width>
12 <height>241</height> 12 <height>275</height>
13 </rect> 13 </rect>
14 </property> 14 </property>
15 <property name="caption"> 15 <property name="caption">
16 <string>FilterEditor</string> 16 <string>FilterEditor</string>
17 </property> 17 </property>
18 <property name="layoutMargin" stdset="0"> 18 <property name="layoutMargin" stdset="0">
19 </property> 19 </property>
20 <property name="layoutSpacing" stdset="0"> 20 <property name="layoutSpacing" stdset="0">
21 </property> 21 </property>
22 <vbox> 22 <vbox>
23 <property name="name"> 23 <property name="name">
24 <cstring>unnamed</cstring> 24 <cstring>unnamed</cstring>
25 </property> 25 </property>
26 <property name="margin"> 26 <property name="margin">
27 <number>0</number> 27 <number>0</number>
28 </property> 28 </property>
29 <property name="spacing"> 29 <property name="spacing">
30 <number>0</number> 30 <number>0</number>
31 </property> 31 </property>
32 <widget class="QFrame"> 32 <widget class="QFrame">
33 <property name="name"> 33 <property name="name">
34 <cstring>mCriteriaFrame</cstring> 34 <cstring>mCriteriaFrame</cstring>
35 </property> 35 </property>
36 <property name="frameShape"> 36 <property name="frameShape">
37 <enum>StyledPanel</enum> 37 <enum>StyledPanel</enum>
38 </property> 38 </property>
39 <property name="frameShadow"> 39 <property name="frameShadow">
40 <enum>Raised</enum> 40 <enum>Raised</enum>
41 </property> 41 </property>
42 <property name="layoutMargin" stdset="0"> 42 <property name="layoutMargin" stdset="0">
43 </property> 43 </property>
44 <grid> 44 <vbox>
45 <property name="name"> 45 <property name="name">
46 <cstring>unnamed</cstring> 46 <cstring>unnamed</cstring>
47 </property> 47 </property>
48 <property name="margin"> 48 <property name="margin">
49 <number>3</number> 49 <number>3</number>
50 </property> 50 </property>
51 <property name="spacing"> 51 <property name="spacing">
52 <number>2</number> 52 <number>2</number>
53 </property> 53 </property>
54 <widget class="QButtonGroup" row="0" column="0"> 54 <widget class="QButtonGroup">
55 <property name="name"> 55 <property name="name">
56 <cstring>ButtonGroup1</cstring> 56 <cstring>ButtonGroup1</cstring>
57 </property> 57 </property>
58 <property name="title"> 58 <property name="title">
59 <string>Categories</string> 59 <string>Categories</string>
60 </property> 60 </property>
61 <vbox> 61 <grid>
62 <property name="name"> 62 <property name="name">
63 <cstring>unnamed</cstring> 63 <cstring>unnamed</cstring>
64 </property> 64 </property>
65 <property name="margin"> 65 <property name="margin">
66 <number>11</number> 66 <number>6</number>
67 </property> 67 </property>
68 <property name="spacing"> 68 <property name="spacing">
69 <number>6</number> 69 <number>6</number>
70 </property> 70 </property>
71 <widget class="QRadioButton"> 71 <widget class="QLayoutWidget" row="0" column="0">
72 <property name="name"> 72 <property name="name">
73 <cstring>mCatShowCheck</cstring> 73 <cstring>layout4</cstring>
74 </property> 74 </property>
75 <property name="text"> 75 <hbox>
76 <string>Show only selected</string> 76 <property name="name">
77 <cstring>unnamed</cstring>
78 </property>
79 <widget class="QRadioButton">
80 <property name="name">
81 <cstring>mCatShowCheck</cstring>
82 </property>
83 <property name="text">
84 <string>Include</string>
85 </property>
86 </widget>
87 <widget class="QRadioButton">
88 <property name="name">
89 <cstring>mCatHideCheck</cstring>
90 </property>
91 <property name="text">
92 <string>Exclude</string>
93 </property>
94 </widget>
95 <widget class="QPushButton">
96 <property name="name">
97 <cstring>mCatEditButton</cstring>
98 </property>
99 <property name="text">
100 <string>Edit Selection...</string>
101 </property>
102 </widget>
103 </hbox>
104 </widget>
105 <widget class="QListBox" row="1" column="0">
106 <property name="name">
107 <cstring>mCatList</cstring>
77 </property> 108 </property>
78 </widget> 109 </widget>
79 <widget class="QRadioButton"> 110 </grid>
111 </widget>
112 <widget class="QLayoutWidget">
113 <property name="name">
114 <cstring>layout7</cstring>
115 </property>
116 <hbox>
117 <property name="name">
118 <cstring>unnamed</cstring>
119 </property>
120 <widget class="QLabel">
80 <property name="name"> 121 <property name="name">
81 <cstring>mCatHideCheck</cstring> 122 <cstring>textLabel1</cstring>
82 </property> 123 </property>
83 <property name="text"> 124 <property name="text">
84 <string>Show all but selected</string> 125 <string>Exclude</string>
85 </property> 126 </property>
86 </widget> 127 </widget>
87 <widget class="QListBox"> 128 <widget class="QCheckBox">
88 <property name="name"> 129 <property name="name">
89 <cstring>mCatList</cstring> 130 <cstring>mRecurringCheck</cstring>
131 </property>
132 <property name="text">
133 <string>recurring events</string>
90 </property> 134 </property>
91 </widget> 135 </widget>
92 <widget class="QPushButton"> 136 <widget class="QCheckBox">
93 <property name="name"> 137 <property name="name">
94 <cstring>mCatEditButton</cstring> 138 <cstring>mCompletedCheck</cstring>
95 </property> 139 </property>
96 <property name="text"> 140 <property name="text">
97 <string>Edit Selection...</string> 141 <string>completed to-dos</string>
98 </property> 142 </property>
99 </widget> 143 </widget>
100 </vbox> 144 </hbox>
101 </widget> 145 </widget>
102 <widget class="QLayoutWidget" row="1" column="0"> 146 <widget class="QLayoutWidget">
103 <property name="name"> 147 <property name="name">
104 <cstring>layout1</cstring> 148 <cstring>layout9</cstring>
105 </property> 149 </property>
106 <hbox> 150 <hbox>
107 <property name="name"> 151 <property name="name">
108 <cstring>unnamed</cstring> 152 <cstring>unnamed</cstring>
109 </property> 153 </property>
110 <property name="margin">
111 <number>0</number>
112 </property>
113 <property name="spacing">
114 <number>0</number>
115 </property>
116 <widget class="QLabel"> 154 <widget class="QLabel">
117 <property name="name"> 155 <property name="name">
118 <cstring>textLabel1</cstring> 156 <cstring>textLabel1_2</cstring>
119 </property> 157 </property>
120 <property name="text"> 158 <property name="text">
121 <string>Hide</string> 159 <string>Exclude</string>
122 </property> 160 </property>
123 </widget> 161 </widget>
124 <widget class="QCheckBox"> 162 <widget class="QCheckBox">
125 <property name="name"> 163 <property name="name">
126 <cstring>mRecurringCheck</cstring> 164 <cstring>mEventCheck</cstring>
127 </property> 165 </property>
128 <property name="text"> 166 <property name="text">
129 <string>recurring events</string> 167 <string>events</string>
130 </property> 168 </property>
131 </widget> 169 </widget>
132 <widget class="QCheckBox"> 170 <widget class="QCheckBox">
133 <property name="name"> 171 <property name="name">
134 <cstring>mCompletedCheck</cstring> 172 <cstring>mTodoCheck</cstring>
135 </property> 173 </property>
136 <property name="text"> 174 <property name="text">
137 <string>completed to-dos</string> 175 <string>todos</string>
176 </property>
177 </widget>
178 <widget class="QCheckBox">
179 <property name="name">
180 <cstring>mJournalCheck</cstring>
181 </property>
182 <property name="text">
183 <string>journals</string>
138 </property> 184 </property>
139 </widget> 185 </widget>
140 </hbox> 186 </hbox>
141 </widget> 187 </widget>
142 <widget class="QLayoutWidget" row="2" column="0"> 188 <widget class="QLayoutWidget">
143 <property name="name"> 189 <property name="name">
144 <cstring>layout2</cstring> 190 <cstring>layout2</cstring>
145 </property> 191 </property>
146 <hbox> 192 <hbox>
147 <property name="name"> 193 <property name="name">
148 <cstring>unnamed</cstring> 194 <cstring>unnamed</cstring>
149 </property> 195 </property>
150 <property name="margin"> 196 <property name="margin">
151 <number>0</number> 197 <number>0</number>
152 </property> 198 </property>
153 <property name="spacing"> 199 <property name="spacing">
154 <number>0</number> 200 <number>0</number>
155 </property> 201 </property>
156 <widget class="QLabel"> 202 <widget class="QLabel">
157 <property name="name"> 203 <property name="name">
158 <cstring>textLabel2</cstring> 204 <cstring>textLabel2</cstring>
159 </property> 205 </property>
160 <property name="text"> 206 <property name="text">
161 <string>Show</string> 207 <string>Include</string>
162 </property> 208 </property>
163 </widget> 209 </widget>
164 <widget class="QCheckBox"> 210 <widget class="QCheckBox">
165 <property name="name"> 211 <property name="name">
166 <cstring>mPublicCheck</cstring> 212 <cstring>mPublicCheck</cstring>
167 </property> 213 </property>
168 <property name="text"> 214 <property name="text">
169 <string>public</string> 215 <string>public</string>
170 </property> 216 </property>
171 </widget> 217 </widget>
172 <widget class="QCheckBox"> 218 <widget class="QCheckBox">
173 <property name="name"> 219 <property name="name">
174 <cstring>mPrivateCheck</cstring> 220 <cstring>mPrivateCheck</cstring>
175 </property> 221 </property>
176 <property name="text"> 222 <property name="text">
177 <string>private</string> 223 <string>private</string>
178 </property> 224 </property>
179 </widget> 225 </widget>
180 <widget class="QCheckBox"> 226 <widget class="QCheckBox">
181 <property name="name"> 227 <property name="name">
182 <cstring>mConfidentialCheck</cstring> 228 <cstring>mConfidentialCheck</cstring>
183 </property> 229 </property>
184 <property name="text"> 230 <property name="text">
185 <string>confidential</string> 231 <string>confidential</string>
186 </property> 232 </property>
187 <property name="checked"> 233 <property name="checked">
188 <bool>false</bool> 234 <bool>false</bool>
189 </property> 235 </property>
190 </widget> 236 </widget>
191 </hbox> 237 </hbox>
192 </widget> 238 </widget>
193 </grid> 239 </vbox>
194 </widget> 240 </widget>
195 </vbox> 241 </vbox>
196</widget> 242</widget>
243<includes>
244 <include location="local" impldecl="in implementation">filteredit_base.ui.h</include>
245</includes>
197<slots> 246<slots>
198 <slot>updateFilter()</slot> 247 <slot>updateFilter()</slot>
199</slots> 248</slots>
200<layoutdefaults spacing="6" margin="11"/> 249<layoutdefaults spacing="6" margin="11"/>
201</UI> 250</UI>
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro
index 2816c6e..628d84e 100644
--- a/korganizer/korganizer.pro
+++ b/korganizer/korganizer.pro
@@ -1,193 +1,193 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3 TARGET = kopi 3 TARGET = kopi
4OBJECTS_DIR = _obj/ 4OBJECTS_DIR = _obj/
5MOC_DIR = _moc 5MOC_DIR = _moc
6DESTDIR= ../bin 6DESTDIR= ../bin
7 7
8include( ../variables.pri ) 8include( ../variables.pri )
9 9
10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim 10INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim
11#../qtcompat 11#../qtcompat
12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL 12DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL
13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER 13DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER
14#KORG_NOPRINTER KORG_NOKABC 14#KORG_NOPRINTER KORG_NOKABC
15DEFINES += KORG_NOLVALTERNATION 15DEFINES += KORG_NOLVALTERNATION
16DEFINES += DESKTOP_VERSION 16DEFINES += DESKTOP_VERSION
17unix : { 17unix : {
18LIBS += ../bin/libmicrokdepim.so 18LIBS += ../bin/libmicrokdepim.so
19LIBS += ../bin/libmicrokcal.so 19LIBS += ../bin/libmicrokcal.so
20LIBS += ../bin/libmicrokde.so 20LIBS += ../bin/libmicrokde.so
21LIBS += ../bin/libmicrokabc.so 21LIBS += ../bin/libmicrokabc.so
22#LIBS += -lbluetooth 22#LIBS += -lbluetooth
23#LIBS += -lsdp 23#LIBS += -lsdp
24 24
25#LIBS += -lldap 25#LIBS += -lldap
26OBJECTS_DIR = obj/unix 26OBJECTS_DIR = obj/unix
27MOC_DIR = moc/unix 27MOC_DIR = moc/unix
28} 28}
29win32: { 29win32: {
30RC_FILE = winicons.rc 30RC_FILE = winicons.rc
31DEFINES += _WIN32_ 31DEFINES += _WIN32_
32LIBS += ../bin/microkdepim.lib 32LIBS += ../bin/microkdepim.lib
33LIBS += ../bin/microkcal.lib 33LIBS += ../bin/microkcal.lib
34LIBS += ../bin/microkde.lib 34LIBS += ../bin/microkde.lib
35LIBS += ../bin/microkabc.lib 35LIBS += ../bin/microkabc.lib
36LIBS += ../libical/lib/ical.lib 36LIBS += ../libical/lib/ical.lib
37LIBS += ../libical/lib/icalss.lib 37LIBS += ../libical/lib/icalss.lib
38#LIBS += atls.lib 38#LIBS += atls.lib
39LIBS += mfc71u.lib 39LIBS += mfc71u.lib
40QMAKE_LINK += /NODEFAULTLIB:LIBC 40QMAKE_LINK += /NODEFAULTLIB:LIBC
41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT 41#QMAKE_LINK += /NODEFAULTLIB:MSVCRT
42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib 42#QMAKE_LINK += /NODEFAULTLIB:uafxcw.lib
43OBJECTS_DIR = obj/win 43OBJECTS_DIR = obj/win
44MOC_DIR = moc/win 44MOC_DIR = moc/win
45} 45}
46 46
47 47
48INTERFACES = kofilterview_base.ui 48INTERFACES = kofilterview_base.ui
49# filteredit_base.ui 49# filteredit_base.ui
50 50
51# kdateedit.h \ 51# kdateedit.h \
52 52
53HEADERS = \ 53HEADERS = \
54 filteredit_base.h \ 54 filteredit_base.h \
55 alarmclient.h \ 55 alarmclient.h \
56 calendarview.h \ 56 calendarview.h \
57 customlistviewitem.h \ 57 customlistviewitem.h \
58 datenavigator.h \ 58 datenavigator.h \
59 docprefs.h \ 59 docprefs.h \
60 filtereditdialog.h \ 60 filtereditdialog.h \
61 incomingdialog.h \ 61 incomingdialog.h \
62 incomingdialog_base.h \ 62 incomingdialog_base.h \
63 interfaces/korganizer/baseview.h \ 63 interfaces/korganizer/baseview.h \
64 interfaces/korganizer/calendarviewbase.h \ 64 interfaces/korganizer/calendarviewbase.h \
65 journalentry.h \ 65 journalentry.h \
66 kdatenavigator.h \ 66 kdatenavigator.h \
67 koagenda.h \ 67 koagenda.h \
68 koagendaitem.h \ 68 koagendaitem.h \
69 koagendaview.h \ 69 koagendaview.h \
70 kocounterdialog.h \ 70 kocounterdialog.h \
71 kodaymatrix.h \ 71 kodaymatrix.h \
72 kodialogmanager.h \ 72 kodialogmanager.h \
73 koeditordetails.h \ 73 koeditordetails.h \
74 koeditorgeneral.h \ 74 koeditorgeneral.h \
75 koeditorgeneralevent.h \ 75 koeditorgeneralevent.h \
76 koeditorgeneraltodo.h \ 76 koeditorgeneraltodo.h \
77 koeditorrecurrence.h \ 77 koeditorrecurrence.h \
78 koeventeditor.h \ 78 koeventeditor.h \
79 koeventpopupmenu.h \ 79 koeventpopupmenu.h \
80 koeventview.h \ 80 koeventview.h \
81 koeventviewer.h \ 81 koeventviewer.h \
82 koeventviewerdialog.h \ 82 koeventviewerdialog.h \
83 kofilterview.h \ 83 kofilterview.h \
84 koglobals.h \ 84 koglobals.h \
85 koincidenceeditor.h \ 85 koincidenceeditor.h \
86 kojournalview.h \ 86 kojournalview.h \
87 kolistview.h \ 87 kolistview.h \
88 kolocationbox.h \ 88 kolocationbox.h \
89 komonthview.h \ 89 komonthview.h \
90 koprefs.h \ 90 koprefs.h \
91 koprefsdialog.h \ 91 koprefsdialog.h \
92 kotimespanview.h \ 92 kotimespanview.h \
93 kotodoeditor.h \ 93 kotodoeditor.h \
94 kotodoview.h \ 94 kotodoview.h \
95 kotodoviewitem.h \ 95 kotodoviewitem.h \
96 koviewmanager.h \ 96 koviewmanager.h \
97 kowhatsnextview.h \ 97 kowhatsnextview.h \
98 ktimeedit.h \ 98 ktimeedit.h \
99 lineview.h \ 99 lineview.h \
100 mainwindow.h \ 100 mainwindow.h \
101 navigatorbar.h \ 101 navigatorbar.h \
102 outgoingdialog.h \ 102 outgoingdialog.h \
103 outgoingdialog_base.h \ 103 outgoingdialog_base.h \
104 publishdialog.h \ 104 publishdialog.h \
105 publishdialog_base.h \ 105 publishdialog_base.h \
106 savetemplatedialog.h \ 106 savetemplatedialog.h \
107 searchdialog.h \ 107 searchdialog.h \
108 simplealarmclient.h \ 108 simplealarmclient.h \
109 statusdialog.h \ 109 statusdialog.h \
110 timeline.h \ 110 timeline.h \
111 timespanview.h \ 111 timespanview.h \
112 version.h \ 112 version.h \
113 ../kalarmd/alarmdialog.h \ 113 ../kalarmd/alarmdialog.h \
114 114
115 115
116SOURCES = \ 116SOURCES = \
117filteredit_base.cpp \ 117filteredit_base.cpp \
118 calendarview.cpp \ 118 calendarview.cpp \
119 datenavigator.cpp \ 119 datenavigator.cpp \
120 docprefs.cpp \ 120 docprefs.cpp \
121 filtereditdialog.cpp \ 121 filtereditdialog.cpp \
122 incomingdialog.cpp \ 122 incomingdialog.cpp \
123 incomingdialog_base.cpp \ 123 incomingdialog_base.cpp \
124 journalentry.cpp \ 124 journalentry.cpp \
125 kdatenavigator.cpp \ 125 kdatenavigator.cpp \
126 koagenda.cpp \ 126 koagenda.cpp \
127 koagendaitem.cpp \ 127 koagendaitem.cpp \
128 koagendaview.cpp \ 128 koagendaview.cpp \
129 kocounterdialog.cpp \ 129 kocounterdialog.cpp \
130 kodaymatrix.cpp \ 130 kodaymatrix.cpp \
131 kodialogmanager.cpp \ 131 kodialogmanager.cpp \
132 koeditordetails.cpp \ 132 koeditordetails.cpp \
133 koeditorgeneral.cpp \ 133 koeditorgeneral.cpp \
134 koeditorgeneralevent.cpp \ 134 koeditorgeneralevent.cpp \
135 koeditorgeneraltodo.cpp \ 135 koeditorgeneraltodo.cpp \
136 koeditorrecurrence.cpp \ 136 koeditorrecurrence.cpp \
137 koeventeditor.cpp \ 137 koeventeditor.cpp \
138 koeventpopupmenu.cpp \ 138 koeventpopupmenu.cpp \
139 koeventview.cpp \ 139 koeventview.cpp \
140 koeventviewer.cpp \ 140 koeventviewer.cpp \
141 koeventviewerdialog.cpp \ 141 koeventviewerdialog.cpp \
142 kofilterview.cpp \ 142 kofilterview.cpp \
143 koglobals.cpp \ 143 koglobals.cpp \
144 koincidenceeditor.cpp \ 144 koincidenceeditor.cpp \
145 kojournalview.cpp \ 145 kojournalview.cpp \
146 kolistview.cpp \ 146 kolistview.cpp \
147 kolocationbox.cpp \ 147 kolocationbox.cpp \
148 komonthview.cpp \ 148 komonthview.cpp \
149 koprefs.cpp \ 149 koprefs.cpp \
150 koprefsdialog.cpp \ 150 koprefsdialog.cpp \
151 kotimespanview.cpp \ 151 kotimespanview.cpp \
152 kotodoeditor.cpp \ 152 kotodoeditor.cpp \
153 kotodoview.cpp \ 153 kotodoview.cpp \
154 kotodoviewitem.cpp \ 154 kotodoviewitem.cpp \
155 koviewmanager.cpp \ 155 koviewmanager.cpp \
156 kowhatsnextview.cpp \ 156 kowhatsnextview.cpp \
157 ktimeedit.cpp \ 157 ktimeedit.cpp \
158 lineview.cpp \ 158 lineview.cpp \
159 main.cpp \ 159 main.cpp \
160 mainwindow.cpp \ 160 mainwindow.cpp \
161 navigatorbar.cpp \ 161 navigatorbar.cpp \
162 outgoingdialog.cpp \ 162 outgoingdialog.cpp \
163 outgoingdialog_base.cpp \ 163 outgoingdialog_base.cpp \
164 publishdialog.cpp \ 164 publishdialog.cpp \
165 publishdialog_base.cpp \ 165 publishdialog_base.cpp \
166 savetemplatedialog.cpp \ 166 savetemplatedialog.cpp \
167 searchdialog.cpp \ 167 searchdialog.cpp \
168 simplealarmclient.cpp \ 168 simplealarmclient.cpp \
169 statusdialog.cpp \ 169 statusdialog.cpp \
170 timeline.cpp \ 170 timeline.cpp \
171 timespanview.cpp \ 171 timespanview.cpp \
172 ../kalarmd/alarmdialog.cpp 172 ../kalarmd/alarmdialog.cpp
173 173
174HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h 174HEADERS += calprintbase.h calprinter.h calprintplugins.h cellitem.h
175INTERFACES += calprintdayconfig_base.ui \ 175INTERFACES += calprintdayconfig_base.ui \
176 calprintmonthconfig_base.ui \ 176 calprintmonthconfig_base.ui \
177 calprinttodoconfig_base.ui \ 177 calprinttodoconfig_base.ui \
178 calprintweekconfig_base.ui 178 calprintweekconfig_base.ui
179SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp 179SOURCES += calprintbase.cpp calprinter.cpp calprintplugins.cpp cellitem.cpp
180 180
181 181
182 182
183win32: { 183win32: {
184HEADERS += ../outport/msoutl9.h \ 184HEADERS += ../outport/msoutl9.h \
185 koimportoldialog.h 185 koimportoldialog.h
186 186
187 187
188SOURCES += ../outport/msoutl9.cpp \ 188SOURCES += ../outport/msoutl9.cpp \
189 koimportoldialog.cpp 189 koimportoldialog.cpp
190 190
191 191
192} 192}
193 193
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index d6d4717..5ad0064 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -1,128 +1,128 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
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#ifndef _CALFILTER_H 21#ifndef _CALFILTER_H
22#define _CALFILTER_H 22#define _CALFILTER_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include "event.h" 27#include "event.h"
28#include "todo.h" 28#include "todo.h"
29 29
30namespace KCal { 30namespace KCal {
31 31
32/** 32/**
33 Filter for calendar objects. 33 Filter for calendar objects.
34*/ 34*/
35class CalFilter { 35class CalFilter {
36 public: 36 public:
37 /** Construct filter. */ 37 /** Construct filter. */
38 CalFilter(); 38 CalFilter();
39 /** Construct filter with name */ 39 /** Construct filter with name */
40 CalFilter(const QString &name); 40 CalFilter(const QString &name);
41 /** Destruct filter. */ 41 /** Destruct filter. */
42 ~CalFilter(); 42 ~CalFilter();
43 43
44 /** 44 /**
45 Set name of filter. 45 Set name of filter.
46 */ 46 */
47 void setName(const QString &name) { mName = name; } 47 void setName(const QString &name) { mName = name; }
48 /** 48 /**
49 Return name of filter. 49 Return name of filter.
50 */ 50 */
51 QString name() const { return mName; } 51 QString name() const { return mName; }
52 52
53 /** 53 /**
54 Apply filter to eventlist, all events not matching filter criterias are 54 Apply filter to eventlist, all events not matching filter criterias are
55 removed from the list. 55 removed from the list.
56 */ 56 */
57 void apply(QPtrList<Event> *eventlist); 57 void apply(QPtrList<Event> *eventlist);
58 58
59 /** 59 /**
60 Apply filter to todolist, all todos not matching filter criterias are 60 Apply filter to todolist, all todos not matching filter criterias are
61 removed from the list. 61 removed from the list.
62 */ 62 */
63 void apply(QPtrList<Todo> *todolist); 63 void apply(QPtrList<Todo> *todolist);
64 64
65 /** 65 /**
66 Apply filter criteria on the specified event. Return true, if event passes 66 Apply filter criteria on the specified event. Return true, if event passes
67 criteria, otherwise return false. 67 criteria, otherwise return false.
68 */ 68 */
69 bool filterEvent(Event *); 69 bool filterEvent(Event *);
70 70
71 /** 71 /**
72 Apply filter criteria on the specified todo. Return true, if event passes 72 Apply filter criteria on the specified todo. Return true, if event passes
73 criteria, otherwise return false. 73 criteria, otherwise return false.
74 */ 74 */
75 bool filterTodo(Todo *); 75 bool filterTodo(Todo *);
76 76
77 /** 77 /**
78 Apply filter criteria on the specified incidence. Return true, if event passes 78 Apply filter criteria on the specified incidence. Return true, if event passes
79 criteria, otherwise return false. 79 criteria, otherwise return false.
80 */ 80 */
81 bool filterIncidence(Incidence *); 81 bool filterIncidence(Incidence *);
82 82
83 /** 83 /**
84 Enable or disable filter. 84 Enable or disable filter.
85 */ 85 */
86 void setEnabled(bool); 86 void setEnabled(bool);
87 /** 87 /**
88 Return wheter the filter is enabled or not. 88 Return wheter the filter is enabled or not.
89 */ 89 */
90 bool isEnabled(); 90 bool isEnabled();
91 bool showCategories(); 91 bool showCategories();
92 int getSecrecy(); 92 int getSecrecy();
93 /** 93 /**
94 Set list of categories, which is used for showing/hiding categories of 94 Set list of categories, which is used for showing/hiding categories of
95 events. 95 events.
96 See related functions. 96 See related functions.
97 */ 97 */
98 void setCategoryList(const QStringList &); 98 void setCategoryList(const QStringList &);
99 /** 99 /**
100 Return category list, used for showing/hiding categories of events. 100 Return category list, used for showing/hiding categories of events.
101 See related functions. 101 See related functions.
102 */ 102 */
103 QStringList categoryList(); 103 QStringList categoryList();
104 104
105 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32 }; 105 enum { HideRecurring = 1, HideCompleted = 2, ShowCategories = 4 ,ShowPublic = 8, ShowPrivate = 16, ShowConfidential = 32, HideEvents = 64, HideTodos = 128, HideJournals = 256 };
106 106
107 /** 107 /**
108 Set criteria, which have to be fulfilled by events passing the filter. 108 Set criteria, which have to be fulfilled by events passing the filter.
109 */ 109 */
110 void setCriteria(int); 110 void setCriteria(int);
111 /** 111 /**
112 Get inclusive filter criteria. 112 Get inclusive filter criteria.
113 */ 113 */
114 int criteria(); 114 int criteria();
115 115
116 private: 116 private:
117 QString mName; 117 QString mName;
118 118
119 int mCriteria; 119 int mCriteria;
120 120
121 bool mEnabled; 121 bool mEnabled;
122 122
123 QStringList mCategoryList; 123 QStringList mCategoryList;
124}; 124};
125 125
126} 126}
127 127
128#endif /* _CALFILTER_H */ 128#endif /* _CALFILTER_H */
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index 33b4a65..6c1f444 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1476 +1,1484 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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 "ksyncmanager.h" 23#include "ksyncmanager.h"
24 24
25#include <stdlib.h> 25#include <stdlib.h>
26 26
27#ifndef _WIN32_ 27#ifndef _WIN32_
28#include <unistd.h> 28#include <unistd.h>
29#endif 29#endif
30 30
31 31
32#include "ksyncprofile.h" 32#include "ksyncprofile.h"
33#include "ksyncprefsdialog.h" 33#include "ksyncprefsdialog.h"
34#include "kpimprefs.h" 34#include "kpimprefs.h"
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#include <qprogressbar.h> 38#include <qprogressbar.h>
39#include <qpopupmenu.h> 39#include <qpopupmenu.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#include <qbuttongroup.h> 42#include <qbuttongroup.h>
43#include <qtimer.h> 43#include <qtimer.h>
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qlineedit.h> 46#include <qlineedit.h>
47#include <qdialog.h> 47#include <qdialog.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qtextcodec.h> 49#include <qtextcodec.h>
50#include <qlabel.h> 50#include <qlabel.h>
51#include <qcheckbox.h> 51#include <qcheckbox.h>
52 52
53#include <klocale.h> 53#include <klocale.h>
54#include <kglobal.h> 54#include <kglobal.h>
55#include <kconfig.h> 55#include <kconfig.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57 57
58QDateTime KSyncManager::mRequestedSyncEvent; 58QDateTime KSyncManager::mRequestedSyncEvent;
59 59
60 60
61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 61KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu) 62 : QObject(), mParent(parent), mImplementation(implementation), mTargetApp(ta), mPrefs(prefs ),mSyncMenu(syncmenu)
63{ 63{
64 mServerSocket = 0; 64 mServerSocket = 0;
65 bar = new QProgressBar ( 1, 0 ); 65 bar = new QProgressBar ( 1, 0 );
66 bar->setCaption (""); 66 bar->setCaption ("");
67 mWriteBackInPast = 2; 67 mWriteBackInPast = 2;
68 int w = 300; 68 int w = 300;
69 if ( QApplication::desktop()->width() < 320 ) 69 if ( QApplication::desktop()->width() < 320 )
70 w = 220; 70 w = 220;
71 int h = bar->sizeHint().height() ; 71 int h = bar->sizeHint().height() ;
72 int dw = QApplication::desktop()->width(); 72 int dw = QApplication::desktop()->width();
73 int dh = QApplication::desktop()->height(); 73 int dh = QApplication::desktop()->height();
74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 74 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
75 if ( mPrefs->mPassiveSyncAutoStart ) 75 if ( mPrefs->mPassiveSyncAutoStart )
76 enableQuick( false ); 76 enableQuick( false );
77 77
78} 78}
79 79
80KSyncManager::~KSyncManager() 80KSyncManager::~KSyncManager()
81{ 81{
82 delete bar; 82 delete bar;
83} 83}
84 84
85 85
86void KSyncManager::fillSyncMenu() 86void KSyncManager::fillSyncMenu()
87{ 87{
88 if ( mSyncMenu->count() ) 88 if ( mSyncMenu->count() )
89 mSyncMenu->clear(); 89 mSyncMenu->clear();
90 90
91 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 91 mSyncMenu->insertItem( i18n("Configure..."), 0 );
92 mSyncMenu->insertSeparator(); 92 mSyncMenu->insertSeparator();
93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 93 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 94 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
95 clearMenu->insertItem( i18n("For all profiles"), 1 ); 95 clearMenu->insertItem( i18n("For all profiles"), 1 );
96 clearMenu->insertSeparator(); 96 clearMenu->insertSeparator();
97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 97 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
98 mSyncMenu->insertSeparator(); 98 mSyncMenu->insertSeparator();
99 if ( mServerSocket == 0 ) { 99 if ( mServerSocket == 0 ) {
100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 100 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
101 } else { 101 } else {
102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 102 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
103 } 103 }
104 mSyncMenu->insertSeparator(); 104 mSyncMenu->insertSeparator();
105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 105 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
106 mSyncMenu->insertSeparator(); 106 mSyncMenu->insertSeparator();
107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 107 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
108 config.setGroup("General"); 108 config.setGroup("General");
109 QStringList prof = config.readListEntry("SyncProfileNames"); 109 QStringList prof = config.readListEntry("SyncProfileNames");
110 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 110 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
111 if ( prof.count() < 2 ) { 111 if ( prof.count() < 2 ) {
112 prof.clear(); 112 prof.clear();
113 QString externalName; 113 QString externalName;
114#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
115#ifdef _WIN32_ 115#ifdef _WIN32_
116 externalName = "OutLook(not_implemented)"; 116 externalName = "OutLook(not_implemented)";
117#else 117#else
118 externalName = "KDE_Desktop"; 118 externalName = "KDE_Desktop";
119#endif 119#endif
120#else 120#else
121 externalName = "Sharp_DTM"; 121 externalName = "Sharp_DTM";
122#endif 122#endif
123 prof << externalName; 123 prof << externalName;
124 prof << i18n("Local_file"); 124 prof << i18n("Local_file");
125 prof << i18n("Last_file"); 125 prof << i18n("Last_file");
126 KSyncProfile* temp = new KSyncProfile (); 126 KSyncProfile* temp = new KSyncProfile ();
127 temp->setName( prof[0] ); 127 temp->setName( prof[0] );
128 temp->writeConfig(&config); 128 temp->writeConfig(&config);
129 temp->setName( prof[1] ); 129 temp->setName( prof[1] );
130 temp->writeConfig(&config); 130 temp->writeConfig(&config);
131 temp->setName( prof[2] ); 131 temp->setName( prof[2] );
132 temp->writeConfig(&config); 132 temp->writeConfig(&config);
133 config.setGroup("General"); 133 config.setGroup("General");
134 config.writeEntry("SyncProfileNames",prof); 134 config.writeEntry("SyncProfileNames",prof);
135 config.writeEntry("ExternSyncProfiles",externalName); 135 config.writeEntry("ExternSyncProfiles",externalName);
136 config.sync(); 136 config.sync();
137 delete temp; 137 delete temp;
138 } 138 }
139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 139 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
140 mSyncProfileNames = prof; 140 mSyncProfileNames = prof;
141 unsigned int i; 141 unsigned int i;
142 for ( i = 0; i < prof.count(); ++i ) { 142 for ( i = 0; i < prof.count(); ++i ) {
143 mSyncMenu->insertItem( prof[i], 1000+i ); 143 mSyncMenu->insertItem( prof[i], 1000+i );
144 clearMenu->insertItem( prof[i], 1000+i ); 144 clearMenu->insertItem( prof[i], 1000+i );
145 if ( i == 2 ) 145 if ( i == 2 )
146 mSyncMenu->insertSeparator(); 146 mSyncMenu->insertSeparator();
147 } 147 }
148 QDir app_dir; 148 QDir app_dir;
149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 149 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
150 if ( mTargetApp == PWMPI) { 150 if ( mTargetApp == PWMPI) {
151 mSyncMenu->removeItem( 1000 ); 151 mSyncMenu->removeItem( 1000 );
152 clearMenu->removeItem( 1000 ); 152 clearMenu->removeItem( 1000 );
153 } 153 }
154#ifndef DESKTOP_VERSION 154#ifndef DESKTOP_VERSION
155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 155 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
156 mSyncMenu->removeItem( 1000 ); 156 mSyncMenu->removeItem( 1000 );
157 clearMenu->removeItem( 1000 ); 157 clearMenu->removeItem( 1000 );
158 } 158 }
159#endif 159#endif
160 mSyncMenu->removeItem( 1002 ); 160 mSyncMenu->removeItem( 1002 );
161 clearMenu->removeItem( 1002 ); 161 clearMenu->removeItem( 1002 );
162} 162}
163void KSyncManager::slotClearMenu( int action ) 163void KSyncManager::slotClearMenu( int action )
164{ 164{
165 QString syncDevice; 165 QString syncDevice;
166 if ( action > 999 ) { 166 if ( action > 999 ) {
167 syncDevice = mSyncProfileNames[action - 1000] ; 167 syncDevice = mSyncProfileNames[action - 1000] ;
168 } 168 }
169 169
170 170
171 171
172 int result = 0; 172 int result = 0;
173 QString sd; 173 QString sd;
174 if ( syncDevice.isEmpty() ) 174 if ( syncDevice.isEmpty() )
175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 175 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
176 else 176 else
177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 177 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
178 178
179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 179 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
180 0, 1 ); 180 0, 1 );
181 if ( result ) 181 if ( result )
182 return; 182 return;
183 mImplementation->removeSyncInfo( syncDevice ); 183 mImplementation->removeSyncInfo( syncDevice );
184} 184}
185void KSyncManager::slotSyncMenu( int action ) 185void KSyncManager::slotSyncMenu( int action )
186{ 186{
187 qDebug("syncaction %d ", action); 187 qDebug("syncaction %d ", action);
188 if ( action == 5000 ) 188 if ( action == 5000 )
189 return; 189 return;
190 mSyncWithDesktop = false; 190 mSyncWithDesktop = false;
191 if ( action == 0 ) { 191 if ( action == 0 ) {
192 192
193 // seems to be a Qt2 event handling bug 193 // seems to be a Qt2 event handling bug
194 // syncmenu.clear causes a segfault at first time 194 // syncmenu.clear causes a segfault at first time
195 // when we call it after the main event loop, it is ok 195 // when we call it after the main event loop, it is ok
196 // same behaviour when calling OM/Pi via QCOP for the first time 196 // same behaviour when calling OM/Pi via QCOP for the first time
197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 197 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
198 //confSync(); 198 //confSync();
199 199
200 return; 200 return;
201 } 201 }
202 if ( action == 1 ) { 202 if ( action == 1 ) {
203 multiSync( true ); 203 multiSync( true );
204 return; 204 return;
205 } 205 }
206 if ( action == 2 ) { 206 if ( action == 2 ) {
207 enableQuick(); 207 enableQuick();
208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 208 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
209 return; 209 return;
210 } 210 }
211 if ( action == 3 ) { 211 if ( action == 3 ) {
212 delete mServerSocket; 212 delete mServerSocket;
213 mServerSocket = 0; 213 mServerSocket = 0;
214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 214 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
215 return; 215 return;
216 } 216 }
217 217
218 if (blockSave()) 218 if (blockSave())
219 return; 219 return;
220 220
221 setBlockSave(true); 221 setBlockSave(true);
222 bool silent = false; 222 bool silent = false;
223 if ( action == 999 ) { 223 if ( action == 999 ) {
224 //special mode for silent syncing 224 //special mode for silent syncing
225 action = 1000; 225 action = 1000;
226 silent = true; 226 silent = true;
227 } 227 }
228 228
229 mCurrentSyncProfile = action - 1000 ; 229 mCurrentSyncProfile = action - 1000 ;
230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 230 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
231 mCurrentSyncName = mLocalMachineName ; 231 mCurrentSyncName = mLocalMachineName ;
232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 232 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
233 KSyncProfile* temp = new KSyncProfile (); 233 KSyncProfile* temp = new KSyncProfile ();
234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 234 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
235 temp->readConfig(&config); 235 temp->readConfig(&config);
236 if (silent) { 236 if (silent) {
237 mAskForPreferences = false; 237 mAskForPreferences = false;
238 mShowSyncSummary = false; 238 mShowSyncSummary = false;
239 mWriteBackFile = true; 239 mWriteBackFile = true;
240 mSyncAlgoPrefs = 2;// take newest 240 mSyncAlgoPrefs = 2;// take newest
241 } 241 }
242 else { 242 else {
243 mAskForPreferences = temp->getAskForPreferences(); 243 mAskForPreferences = temp->getAskForPreferences();
244 mShowSyncSummary = temp->getShowSummaryAfterSync(); 244 mShowSyncSummary = temp->getShowSummaryAfterSync();
245 mWriteBackFile = temp->getWriteBackFile(); 245 mWriteBackFile = temp->getWriteBackFile();
246 mSyncAlgoPrefs = temp->getSyncPrefs(); 246 mSyncAlgoPrefs = temp->getSyncPrefs();
247 } 247 }
248 mWriteBackExistingOnly = temp->getWriteBackExisting(); 248 mWriteBackExistingOnly = temp->getWriteBackExisting();
249 mIsKapiFile = temp->getIsKapiFile(); 249 mIsKapiFile = temp->getIsKapiFile();
250 mWriteBackInFuture = 0; 250 mWriteBackInFuture = 0;
251 if ( temp->getWriteBackFuture() ) { 251 if ( temp->getWriteBackFuture() ) {
252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 252 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
253 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 253 mWriteBackInPast = temp->getWriteBackPastWeeks( );
254 } 254 }
255 255 mFilterInCal = temp->getFilterInCal();
256 mFilterOutCal = temp->getFilterOutCal();
257 mFilterInAB = temp->getFilterInAB();
258 mFilterOutAB = temp->getFilterOutAB();
259
256 if ( action == 1000 ) { 260 if ( action == 1000 ) {
257 mIsKapiFile = false; 261 mIsKapiFile = false;
258#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
259 syncKDE(); 263 syncKDE();
260#else 264#else
261 syncSharp(); 265 syncSharp();
262#endif 266#endif
263 267
264 } else if ( action == 1001 ) { 268 } else if ( action == 1001 ) {
265 syncLocalFile(); 269 syncLocalFile();
266 270
267 } else if ( action == 1002 ) { 271 } else if ( action == 1002 ) {
268 mWriteBackFile = false; 272 mWriteBackFile = false;
269 mAskForPreferences = false; 273 mAskForPreferences = false;
270 mShowSyncSummary = false; 274 mShowSyncSummary = false;
271 mSyncAlgoPrefs = 3; 275 mSyncAlgoPrefs = 3;
272 quickSyncLocalFile(); 276 quickSyncLocalFile();
273 277
274 } else if ( action >= 1003 ) { 278 } else if ( action >= 1003 ) {
275 if ( temp->getIsLocalFileSync() ) { 279 if ( temp->getIsLocalFileSync() ) {
276 switch(mTargetApp) 280 switch(mTargetApp)
277 { 281 {
278 case (KAPI): 282 case (KAPI):
279 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 283 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
280 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
281 break; 285 break;
282 case (KOPI): 286 case (KOPI):
283 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 287 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
284 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
285 break; 289 break;
286 case (PWMPI): 290 case (PWMPI):
287 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 291 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
288 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 292 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
289 break; 293 break;
290 default: 294 default:
291 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 295 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
292 break; 296 break;
293 297
294 } 298 }
295 } else { 299 } else {
296 if ( temp->getIsPhoneSync() ) { 300 if ( temp->getIsPhoneSync() ) {
297 mPhoneDevice = temp->getPhoneDevice( ) ; 301 mPhoneDevice = temp->getPhoneDevice( ) ;
298 mPhoneConnection = temp->getPhoneConnection( ); 302 mPhoneConnection = temp->getPhoneConnection( );
299 mPhoneModel = temp->getPhoneModel( ); 303 mPhoneModel = temp->getPhoneModel( );
300 syncPhone(); 304 syncPhone();
301 } else if ( temp->getIsPiSync() ) { 305 } else if ( temp->getIsPiSync() ) {
302 if ( mTargetApp == KAPI ) { 306 if ( mTargetApp == KAPI ) {
303 mPassWordPiSync = temp->getRemotePwAB(); 307 mPassWordPiSync = temp->getRemotePwAB();
304 mActiveSyncPort = temp->getRemotePortAB(); 308 mActiveSyncPort = temp->getRemotePortAB();
305 mActiveSyncIP = temp->getRemoteIPAB(); 309 mActiveSyncIP = temp->getRemoteIPAB();
306 } else if ( mTargetApp == KOPI ) { 310 } else if ( mTargetApp == KOPI ) {
307 mPassWordPiSync = temp->getRemotePw(); 311 mPassWordPiSync = temp->getRemotePw();
308 mActiveSyncPort = temp->getRemotePort(); 312 mActiveSyncPort = temp->getRemotePort();
309 mActiveSyncIP = temp->getRemoteIP(); 313 mActiveSyncIP = temp->getRemoteIP();
310 } else { 314 } else {
311 mPassWordPiSync = temp->getRemotePwPWM(); 315 mPassWordPiSync = temp->getRemotePwPWM();
312 mActiveSyncPort = temp->getRemotePortPWM(); 316 mActiveSyncPort = temp->getRemotePortPWM();
313 mActiveSyncIP = temp->getRemoteIPPWM(); 317 mActiveSyncIP = temp->getRemoteIPPWM();
314 } 318 }
315 syncPi(); 319 syncPi();
316 while ( !mPisyncFinished ) { 320 while ( !mPisyncFinished ) {
317 //qDebug("waiting "); 321 //qDebug("waiting ");
318 qApp->processEvents(); 322 qApp->processEvents();
319 } 323 }
320 } else 324 } else
321 syncRemote( temp ); 325 syncRemote( temp );
322 326
323 } 327 }
324 } 328 }
325 delete temp; 329 delete temp;
326 setBlockSave(false); 330 setBlockSave(false);
327} 331}
328 332
329void KSyncManager::enableQuick( bool ask ) 333void KSyncManager::enableQuick( bool ask )
330{ 334{
331 bool autoStart; 335 bool autoStart;
332 bool changed = false; 336 bool changed = false;
333 if ( ask ) { 337 if ( ask ) {
334 QDialog dia ( 0, "input-dialog", true ); 338 QDialog dia ( 0, "input-dialog", true );
335 QLineEdit lab ( &dia ); 339 QLineEdit lab ( &dia );
336 QVBoxLayout lay( &dia ); 340 QVBoxLayout lay( &dia );
337 lab.setText( mPrefs->mPassiveSyncPort ); 341 lab.setText( mPrefs->mPassiveSyncPort );
338 lay.setMargin(7); 342 lay.setMargin(7);
339 lay.setSpacing(7); 343 lay.setSpacing(7);
340 int po = 9197+mTargetApp; 344 int po = 9197+mTargetApp;
341 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia ); 345 QLabel label ( i18n("Port number (Default: %1)").arg(po), &dia );
342 lay.addWidget( &label); 346 lay.addWidget( &label);
343 lay.addWidget( &lab); 347 lay.addWidget( &lab);
344 348
345 QLineEdit lepw ( &dia ); 349 QLineEdit lepw ( &dia );
346 lepw.setText( mPrefs->mPassiveSyncPw ); 350 lepw.setText( mPrefs->mPassiveSyncPw );
347 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 351 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
348 lay.addWidget( &label2); 352 lay.addWidget( &label2);
349 lay.addWidget( &lepw); 353 lay.addWidget( &lepw);
350 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 354 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
351 lay.addWidget( &autostart); 355 lay.addWidget( &autostart);
352 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 356 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
353#ifdef DESKTOP_VERSION 357#ifdef DESKTOP_VERSION
354#ifdef _WIN32_ 358#ifdef _WIN32_
355 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 359 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
356 syncdesktop.hide();// not implemented! 360 syncdesktop.hide();// not implemented!
357#else 361#else
358 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 362 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
359#endif 363#endif
360 lay.addWidget( &syncdesktop); 364 lay.addWidget( &syncdesktop);
361#else 365#else
362 mPrefs->mPassiveSyncWithDesktop = false; 366 mPrefs->mPassiveSyncWithDesktop = false;
363 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 367 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
364 syncdesktop.hide(); 368 syncdesktop.hide();
365#endif 369#endif
366 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 370 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
367 371
368 dia.setFixedSize( 230,120 ); 372 dia.setFixedSize( 230,120 );
369 dia.setCaption( i18n("Enter port for Pi-Sync") ); 373 dia.setCaption( i18n("Enter port for Pi-Sync") );
370 QPushButton pb ( "OK", &dia); 374 QPushButton pb ( "OK", &dia);
371 lay.addWidget( &pb ); 375 lay.addWidget( &pb );
372 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 376 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
373 dia.show(); 377 dia.show();
374 if ( ! dia.exec() ) 378 if ( ! dia.exec() )
375 return; 379 return;
376 dia.hide(); 380 dia.hide();
377 qApp->processEvents(); 381 qApp->processEvents();
378 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 382 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
379 changed = true; 383 changed = true;
380 mPrefs->mPassiveSyncPw = lepw.text(); 384 mPrefs->mPassiveSyncPw = lepw.text();
381 } 385 }
382 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 386 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
383 mPrefs->mPassiveSyncPort = lab.text(); 387 mPrefs->mPassiveSyncPort = lab.text();
384 changed = true; 388 changed = true;
385 } 389 }
386 autoStart = autostart.isChecked(); 390 autoStart = autostart.isChecked();
387 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 391 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
388 changed = true; 392 changed = true;
389 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 393 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
390 } 394 }
391 } 395 }
392 else 396 else
393 autoStart = mPrefs->mPassiveSyncAutoStart; 397 autoStart = mPrefs->mPassiveSyncAutoStart;
394 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 398 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
395 changed = true; 399 changed = true;
396 bool ok; 400 bool ok;
397 mPrefs->mPassiveSyncAutoStart = false; 401 mPrefs->mPassiveSyncAutoStart = false;
398 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok); 402 Q_UINT16 port = mPrefs->mPassiveSyncPort.toUInt(&ok);
399 if ( ! ok ) { 403 if ( ! ok ) {
400 KMessageBox::information( 0, i18n("No valid port")); 404 KMessageBox::information( 0, i18n("No valid port"));
401 return; 405 return;
402 } 406 }
403 //qDebug("port %d ", port); 407 //qDebug("port %d ", port);
404 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 408 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
405 mServerSocket->setFileName( defaultFileName() );//bbb 409 mServerSocket->setFileName( defaultFileName() );//bbb
406 //qDebug("connected "); 410 //qDebug("connected ");
407 if ( !mServerSocket->ok() ) { 411 if ( !mServerSocket->ok() ) {
408 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!")); 412 KMessageBox::information( 0, i18n("Failed to bind or\nlisten to the port!"));
409 delete mServerSocket; 413 delete mServerSocket;
410 mServerSocket = 0; 414 mServerSocket = 0;
411 return; 415 return;
412 } 416 }
413 mPrefs->mPassiveSyncAutoStart = autoStart; 417 mPrefs->mPassiveSyncAutoStart = autoStart;
414 if ( changed ) { 418 if ( changed ) {
415 mPrefs->writeConfig(); 419 mPrefs->writeConfig();
416 } 420 }
417 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 421 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
418 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 422 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
419} 423}
420 424
421void KSyncManager::syncLocalFile() 425void KSyncManager::syncLocalFile()
422{ 426{
423 427
424 QString fn =mPrefs->mLastSyncedLocalFile; 428 QString fn =mPrefs->mLastSyncedLocalFile;
425 QString ext; 429 QString ext;
426 430
427 switch(mTargetApp) 431 switch(mTargetApp)
428 { 432 {
429 case (KAPI): 433 case (KAPI):
430 ext = "(*.vcf)"; 434 ext = "(*.vcf)";
431 break; 435 break;
432 case (KOPI): 436 case (KOPI):
433 ext = "(*.ics/*.vcs)"; 437 ext = "(*.ics/*.vcs)";
434 break; 438 break;
435 case (PWMPI): 439 case (PWMPI):
436 ext = "(*.pwm)"; 440 ext = "(*.pwm)";
437 break; 441 break;
438 default: 442 default:
439 qDebug("KSyncManager::syncLocalFile: invalid apptype selected"); 443 qDebug("KSyncManager::syncLocalFile: invalid apptype selected");
440 break; 444 break;
441 445
442 } 446 }
443 447
444 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 448 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
445 if ( fn == "" ) 449 if ( fn == "" )
446 return; 450 return;
447 if ( syncWithFile( fn, false ) ) { 451 if ( syncWithFile( fn, false ) ) {
448 qDebug("syncLocalFile() successful "); 452 qDebug("syncLocalFile() successful ");
449 } 453 }
450 454
451} 455}
452 456
453bool KSyncManager::syncWithFile( QString fn , bool quick ) 457bool KSyncManager::syncWithFile( QString fn , bool quick )
454{ 458{
455 bool ret = false; 459 bool ret = false;
456 QFileInfo info; 460 QFileInfo info;
457 info.setFile( fn ); 461 info.setFile( fn );
458 QString mess; 462 QString mess;
459 bool loadbup = true; 463 bool loadbup = true;
460 if ( !info. exists() ) { 464 if ( !info. exists() ) {
461 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 465 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
462 int result = QMessageBox::warning( mParent, i18n("Warning!"), 466 int result = QMessageBox::warning( mParent, i18n("Warning!"),
463 mess ); 467 mess );
464 return ret; 468 return ret;
465 } 469 }
466 int result = 0; 470 int result = 0;
467 if ( !quick ) { 471 if ( !quick ) {
468 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 472 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
469 result = QMessageBox::warning( mParent, i18n("Warning!"), 473 result = QMessageBox::warning( mParent, i18n("Warning!"),
470 mess, 474 mess,
471 i18n("Sync"), i18n("Cancel"), 0, 475 i18n("Sync"), i18n("Cancel"), 0,
472 0, 1 ); 476 0, 1 );
473 if ( result ) 477 if ( result )
474 return false; 478 return false;
475 } 479 }
476 if ( mAskForPreferences ) 480 if ( mAskForPreferences )
477 if ( !edit_sync_options()) { 481 if ( !edit_sync_options()) {
478 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 482 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
479 return false; 483 return false;
480 } 484 }
481 if ( result == 0 ) { 485 if ( result == 0 ) {
482 //qDebug("Now sycing ... "); 486 //qDebug("Now sycing ... ");
483 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 487 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) )
484 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 488 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
485 else 489 else
486 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 490 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
487 if ( ! quick ) 491 if ( ! quick )
488 mPrefs->mLastSyncedLocalFile = fn; 492 mPrefs->mLastSyncedLocalFile = fn;
489 } 493 }
490 return ret; 494 return ret;
491} 495}
492 496
493void KSyncManager::quickSyncLocalFile() 497void KSyncManager::quickSyncLocalFile()
494{ 498{
495 499
496 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 500 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
497 qDebug("quick syncLocalFile() successful "); 501 qDebug("quick syncLocalFile() successful ");
498 502
499 } 503 }
500} 504}
501 505
502void KSyncManager::multiSync( bool askforPrefs ) 506void KSyncManager::multiSync( bool askforPrefs )
503{ 507{
504 if (blockSave()) 508 if (blockSave())
505 return; 509 return;
506 setBlockSave(true); 510 setBlockSave(true);
507 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 511 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
508 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 512 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
509 question, 513 question,
510 i18n("Yes"), i18n("No"), 514 i18n("Yes"), i18n("No"),
511 0, 0 ) != 0 ) { 515 0, 0 ) != 0 ) {
512 setBlockSave(false); 516 setBlockSave(false);
513 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 517 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
514 return; 518 return;
515 } 519 }
516 mCurrentSyncDevice = i18n("Multiple profiles") ; 520 mCurrentSyncDevice = i18n("Multiple profiles") ;
517 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 521 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
518 if ( askforPrefs ) { 522 if ( askforPrefs ) {
519 if ( !edit_sync_options()) { 523 if ( !edit_sync_options()) {
520 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 524 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
521 return; 525 return;
522 } 526 }
523 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 527 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
524 } 528 }
525 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 529 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
526 qApp->processEvents(); 530 qApp->processEvents();
527 int num = ringSync() ; 531 int num = ringSync() ;
528 if ( num > 1 ) 532 if ( num > 1 )
529 ringSync(); 533 ringSync();
530 setBlockSave(false); 534 setBlockSave(false);
531 if ( num ) 535 if ( num )
532 emit save(); 536 emit save();
533 if ( num ) 537 if ( num )
534 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 538 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
535 else 539 else
536 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 540 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
537 return; 541 return;
538} 542}
539 543
540int KSyncManager::ringSync() 544int KSyncManager::ringSync()
541{ 545{
542 546
543 int syncedProfiles = 0; 547 int syncedProfiles = 0;
544 unsigned int i; 548 unsigned int i;
545 QTime timer; 549 QTime timer;
546 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 550 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
547 QStringList syncProfileNames = mSyncProfileNames; 551 QStringList syncProfileNames = mSyncProfileNames;
548 KSyncProfile* temp = new KSyncProfile (); 552 KSyncProfile* temp = new KSyncProfile ();
549 mAskForPreferences = false; 553 mAskForPreferences = false;
550 for ( i = 0; i < syncProfileNames.count(); ++i ) { 554 for ( i = 0; i < syncProfileNames.count(); ++i ) {
551 mCurrentSyncProfile = i; 555 mCurrentSyncProfile = i;
552 temp->setName(syncProfileNames[mCurrentSyncProfile]); 556 temp->setName(syncProfileNames[mCurrentSyncProfile]);
553 temp->readConfig(&config); 557 temp->readConfig(&config);
554 558
555 bool includeInRingSync; 559 bool includeInRingSync;
556 switch(mTargetApp) 560 switch(mTargetApp)
557 { 561 {
558 case (KAPI): 562 case (KAPI):
559 includeInRingSync = temp->getIncludeInRingSyncAB(); 563 includeInRingSync = temp->getIncludeInRingSyncAB();
560 break; 564 break;
561 case (KOPI): 565 case (KOPI):
562 includeInRingSync = temp->getIncludeInRingSync(); 566 includeInRingSync = temp->getIncludeInRingSync();
563 break; 567 break;
564 case (PWMPI): 568 case (PWMPI):
565 includeInRingSync = temp->getIncludeInRingSyncPWM(); 569 includeInRingSync = temp->getIncludeInRingSyncPWM();
566 break; 570 break;
567 default: 571 default:
568 qDebug("KSyncManager::ringSync: invalid apptype selected"); 572 qDebug("KSyncManager::ringSync: invalid apptype selected");
569 break; 573 break;
570 574
571 } 575 }
572 576
573 577
574 if ( includeInRingSync && ( i < 1 || i > 2 )) { 578 if ( includeInRingSync && ( i < 1 || i > 2 )) {
575 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 579 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
576 ++syncedProfiles; 580 ++syncedProfiles;
577 mSyncWithDesktop = false; 581 mSyncWithDesktop = false;
578 // mAskForPreferences = temp->getAskForPreferences(); 582 // mAskForPreferences = temp->getAskForPreferences();
579 mWriteBackFile = temp->getWriteBackFile(); 583 mWriteBackFile = temp->getWriteBackFile();
580 mWriteBackExistingOnly = temp->getWriteBackExisting(); 584 mWriteBackExistingOnly = temp->getWriteBackExisting();
581 mIsKapiFile = temp->getIsKapiFile(); 585 mIsKapiFile = temp->getIsKapiFile();
582 mWriteBackInFuture = 0; 586 mWriteBackInFuture = 0;
583 if ( temp->getWriteBackFuture() ) { 587 if ( temp->getWriteBackFuture() ) {
584 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 588 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
585 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 589 mWriteBackInPast = temp->getWriteBackPastWeeks( );
586 } 590 }
591 mFilterInCal = temp->getFilterInCal();
592 mFilterOutCal = temp->getFilterOutCal();
593 mFilterInAB = temp->getFilterInAB();
594 mFilterOutAB = temp->getFilterOutAB();
587 mShowSyncSummary = false; 595 mShowSyncSummary = false;
588 mCurrentSyncDevice = syncProfileNames[i] ; 596 mCurrentSyncDevice = syncProfileNames[i] ;
589 mCurrentSyncName = mLocalMachineName; 597 mCurrentSyncName = mLocalMachineName;
590 if ( i == 0 ) { 598 if ( i == 0 ) {
591 mIsKapiFile = false; 599 mIsKapiFile = false;
592#ifdef DESKTOP_VERSION 600#ifdef DESKTOP_VERSION
593 syncKDE(); 601 syncKDE();
594#else 602#else
595 syncSharp(); 603 syncSharp();
596#endif 604#endif
597 } else { 605 } else {
598 if ( temp->getIsLocalFileSync() ) { 606 if ( temp->getIsLocalFileSync() ) {
599 switch(mTargetApp) 607 switch(mTargetApp)
600 { 608 {
601 case (KAPI): 609 case (KAPI):
602 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 610 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
603 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
604 break; 612 break;
605 case (KOPI): 613 case (KOPI):
606 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 614 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
607 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 615 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
608 break; 616 break;
609 case (PWMPI): 617 case (PWMPI):
610 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 618 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
611 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 619 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
612 break; 620 break;
613 default: 621 default:
614 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 622 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
615 break; 623 break;
616 } 624 }
617 } else { 625 } else {
618 if ( temp->getIsPhoneSync() ) { 626 if ( temp->getIsPhoneSync() ) {
619 mPhoneDevice = temp->getPhoneDevice( ) ; 627 mPhoneDevice = temp->getPhoneDevice( ) ;
620 mPhoneConnection = temp->getPhoneConnection( ); 628 mPhoneConnection = temp->getPhoneConnection( );
621 mPhoneModel = temp->getPhoneModel( ); 629 mPhoneModel = temp->getPhoneModel( );
622 syncPhone(); 630 syncPhone();
623 } else if ( temp->getIsPiSync() ) { 631 } else if ( temp->getIsPiSync() ) {
624 if ( mTargetApp == KAPI ) { 632 if ( mTargetApp == KAPI ) {
625 mPassWordPiSync = temp->getRemotePwAB(); 633 mPassWordPiSync = temp->getRemotePwAB();
626 mActiveSyncPort = temp->getRemotePortAB(); 634 mActiveSyncPort = temp->getRemotePortAB();
627 mActiveSyncIP = temp->getRemoteIPAB(); 635 mActiveSyncIP = temp->getRemoteIPAB();
628 } else if ( mTargetApp == KOPI ) { 636 } else if ( mTargetApp == KOPI ) {
629 mPassWordPiSync = temp->getRemotePw(); 637 mPassWordPiSync = temp->getRemotePw();
630 mActiveSyncPort = temp->getRemotePort(); 638 mActiveSyncPort = temp->getRemotePort();
631 mActiveSyncIP = temp->getRemoteIP(); 639 mActiveSyncIP = temp->getRemoteIP();
632 } else { 640 } else {
633 mPassWordPiSync = temp->getRemotePwPWM(); 641 mPassWordPiSync = temp->getRemotePwPWM();
634 mActiveSyncPort = temp->getRemotePortPWM(); 642 mActiveSyncPort = temp->getRemotePortPWM();
635 mActiveSyncIP = temp->getRemoteIPPWM(); 643 mActiveSyncIP = temp->getRemoteIPPWM();
636 } 644 }
637 syncPi(); 645 syncPi();
638 while ( !mPisyncFinished ) { 646 while ( !mPisyncFinished ) {
639 //qDebug("waiting "); 647 //qDebug("waiting ");
640 qApp->processEvents(); 648 qApp->processEvents();
641 } 649 }
642 timer.start(); 650 timer.start();
643 while ( timer.elapsed () < 2000 ) { 651 while ( timer.elapsed () < 2000 ) {
644 qApp->processEvents(); 652 qApp->processEvents();
645 } 653 }
646 } else 654 } else
647 syncRemote( temp, false ); 655 syncRemote( temp, false );
648 656
649 } 657 }
650 } 658 }
651 timer.start(); 659 timer.start();
652 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 660 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
653 while ( timer.elapsed () < 2000 ) { 661 while ( timer.elapsed () < 2000 ) {
654 qApp->processEvents(); 662 qApp->processEvents();
655#ifndef _WIN32_ 663#ifndef _WIN32_
656 sleep (1); 664 sleep (1);
657#endif 665#endif
658 } 666 }
659 667
660 } 668 }
661 669
662 } 670 }
663 delete temp; 671 delete temp;
664 return syncedProfiles; 672 return syncedProfiles;
665} 673}
666 674
667void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 675void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
668{ 676{
669 QString question; 677 QString question;
670 if ( ask ) { 678 if ( ask ) {
671 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 679 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
672 if ( QMessageBox::information( mParent, i18n("Sync"), 680 if ( QMessageBox::information( mParent, i18n("Sync"),
673 question, 681 question,
674 i18n("Yes"), i18n("No"), 682 i18n("Yes"), i18n("No"),
675 0, 0 ) != 0 ) 683 0, 0 ) != 0 )
676 return; 684 return;
677 } 685 }
678 686
679 QString preCommand; 687 QString preCommand;
680 QString localTempFile; 688 QString localTempFile;
681 QString postCommand; 689 QString postCommand;
682 690
683 switch(mTargetApp) 691 switch(mTargetApp)
684 { 692 {
685 case (KAPI): 693 case (KAPI):
686 preCommand = prof->getPreSyncCommandAB(); 694 preCommand = prof->getPreSyncCommandAB();
687 postCommand = prof->getPostSyncCommandAB(); 695 postCommand = prof->getPostSyncCommandAB();
688 localTempFile = prof->getLocalTempFileAB(); 696 localTempFile = prof->getLocalTempFileAB();
689 break; 697 break;
690 case (KOPI): 698 case (KOPI):
691 preCommand = prof->getPreSyncCommand(); 699 preCommand = prof->getPreSyncCommand();
692 postCommand = prof->getPostSyncCommand(); 700 postCommand = prof->getPostSyncCommand();
693 localTempFile = prof->getLocalTempFile(); 701 localTempFile = prof->getLocalTempFile();
694 break; 702 break;
695 case (PWMPI): 703 case (PWMPI):
696 preCommand = prof->getPreSyncCommandPWM(); 704 preCommand = prof->getPreSyncCommandPWM();
697 postCommand = prof->getPostSyncCommandPWM(); 705 postCommand = prof->getPostSyncCommandPWM();
698 localTempFile = prof->getLocalTempFilePWM(); 706 localTempFile = prof->getLocalTempFilePWM();
699 break; 707 break;
700 default: 708 default:
701 qDebug("KSyncManager::syncRemote: invalid apptype selected"); 709 qDebug("KSyncManager::syncRemote: invalid apptype selected");
702 break; 710 break;
703 } 711 }
704 712
705 713
706 int fi; 714 int fi;
707 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 715 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
708 QString pwd = getPassword(); 716 QString pwd = getPassword();
709 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 717 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
710 718
711 } 719 }
712 int maxlen = 30; 720 int maxlen = 30;
713 if ( QApplication::desktop()->width() > 320 ) 721 if ( QApplication::desktop()->width() > 320 )
714 maxlen += 25; 722 maxlen += 25;
715 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 723 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
716 int fileSize = 0; 724 int fileSize = 0;
717 int result = system ( preCommand ); 725 int result = system ( preCommand );
718 // 0 : okay 726 // 0 : okay
719 // 256: no such file or dir 727 // 256: no such file or dir
720 // 728 //
721 qDebug("Sync: Remote copy result(0 = okay): %d ",result ); 729 qDebug("Sync: Remote copy result(0 = okay): %d ",result );
722 if ( result != 0 ) { 730 if ( result != 0 ) {
723 unsigned int len = maxlen; 731 unsigned int len = maxlen;
724 while ( len < preCommand.length() ) { 732 while ( len < preCommand.length() ) {
725 preCommand.insert( len , "\n" ); 733 preCommand.insert( len , "\n" );
726 len += maxlen +2; 734 len += maxlen +2;
727 } 735 }
728 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 (preCommand) ; 736 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 (preCommand) ;
729 QMessageBox::information( mParent, i18n("Sync - ERROR"), 737 QMessageBox::information( mParent, i18n("Sync - ERROR"),
730 question, 738 question,
731 i18n("Okay!")) ; 739 i18n("Okay!")) ;
732 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 740 mParent->topLevelWidget()->setCaption ("KDE-Pim");
733 return; 741 return;
734 } 742 }
735 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 743 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
736 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 744 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
737 745
738 if ( syncWithFile( localTempFile, true ) ) { 746 if ( syncWithFile( localTempFile, true ) ) {
739 747
740 if ( mWriteBackFile ) { 748 if ( mWriteBackFile ) {
741 int fi; 749 int fi;
742 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 750 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
743 QString pwd = getPassword(); 751 QString pwd = getPassword();
744 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 752 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
745 753
746 } 754 }
747 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 755 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
748 result = system ( postCommand ); 756 result = system ( postCommand );
749 qDebug("Sync:Writing back file result: %d ", result); 757 qDebug("Sync:Writing back file result: %d ", result);
750 if ( result != 0 ) { 758 if ( result != 0 ) {
751 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 759 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
752 return; 760 return;
753 } else { 761 } else {
754 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 762 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
755 } 763 }
756 } 764 }
757 } 765 }
758 return; 766 return;
759} 767}
760bool KSyncManager::edit_pisync_options() 768bool KSyncManager::edit_pisync_options()
761{ 769{
762 QDialog dia( mParent, "dia", true ); 770 QDialog dia( mParent, "dia", true );
763 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 771 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
764 QVBoxLayout lay ( &dia ); 772 QVBoxLayout lay ( &dia );
765 lay.setSpacing( 5 ); 773 lay.setSpacing( 5 );
766 lay.setMargin( 3 ); 774 lay.setMargin( 3 );
767 QLabel lab1 ( i18n("Password for remote access:"), &dia); 775 QLabel lab1 ( i18n("Password for remote access:"), &dia);
768 lay.addWidget( &lab1 ); 776 lay.addWidget( &lab1 );
769 QLineEdit le1 (&dia ); 777 QLineEdit le1 (&dia );
770 lay.addWidget( &le1 ); 778 lay.addWidget( &le1 );
771 QLabel lab2 ( i18n("Remote IP address:"), &dia); 779 QLabel lab2 ( i18n("Remote IP address:"), &dia);
772 lay.addWidget( &lab2 ); 780 lay.addWidget( &lab2 );
773 QLineEdit le2 (&dia ); 781 QLineEdit le2 (&dia );
774 lay.addWidget( &le2 ); 782 lay.addWidget( &le2 );
775 QLabel lab3 ( i18n("Remote port number:"), &dia); 783 QLabel lab3 ( i18n("Remote port number:"), &dia);
776 lay.addWidget( &lab3 ); 784 lay.addWidget( &lab3 );
777 QLineEdit le3 (&dia ); 785 QLineEdit le3 (&dia );
778 lay.addWidget( &le3 ); 786 lay.addWidget( &le3 );
779 QPushButton pb ( "OK", &dia); 787 QPushButton pb ( "OK", &dia);
780 lay.addWidget( &pb ); 788 lay.addWidget( &pb );
781 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 789 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
782 le1.setText( mPassWordPiSync ); 790 le1.setText( mPassWordPiSync );
783 le2.setText( mActiveSyncIP ); 791 le2.setText( mActiveSyncIP );
784 le3.setText( mActiveSyncPort ); 792 le3.setText( mActiveSyncPort );
785 if ( dia.exec() ) { 793 if ( dia.exec() ) {
786 mPassWordPiSync = le1.text(); 794 mPassWordPiSync = le1.text();
787 mActiveSyncPort = le3.text(); 795 mActiveSyncPort = le3.text();
788 mActiveSyncIP = le2.text(); 796 mActiveSyncIP = le2.text();
789 return true; 797 return true;
790 } 798 }
791 return false; 799 return false;
792} 800}
793bool KSyncManager::edit_sync_options() 801bool KSyncManager::edit_sync_options()
794{ 802{
795 803
796 QDialog dia( mParent, "dia", true ); 804 QDialog dia( mParent, "dia", true );
797 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 805 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
798 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 806 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
799 QVBoxLayout lay ( &dia ); 807 QVBoxLayout lay ( &dia );
800 lay.setSpacing( 2 ); 808 lay.setSpacing( 2 );
801 lay.setMargin( 3 ); 809 lay.setMargin( 3 );
802 lay.addWidget(&gr); 810 lay.addWidget(&gr);
803 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 811 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
804 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 812 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
805 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 813 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
806 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 814 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
807 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 815 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
808 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 816 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
809 //QRadioButton both( i18n("Take both on conflict"), &gr ); 817 //QRadioButton both( i18n("Take both on conflict"), &gr );
810 QPushButton pb ( "OK", &dia); 818 QPushButton pb ( "OK", &dia);
811 lay.addWidget( &pb ); 819 lay.addWidget( &pb );
812 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 820 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
813 switch ( mSyncAlgoPrefs ) { 821 switch ( mSyncAlgoPrefs ) {
814 case 0: 822 case 0:
815 loc.setChecked( true); 823 loc.setChecked( true);
816 break; 824 break;
817 case 1: 825 case 1:
818 rem.setChecked( true ); 826 rem.setChecked( true );
819 break; 827 break;
820 case 2: 828 case 2:
821 newest.setChecked( true); 829 newest.setChecked( true);
822 break; 830 break;
823 case 3: 831 case 3:
824 ask.setChecked( true); 832 ask.setChecked( true);
825 break; 833 break;
826 case 4: 834 case 4:
827 f_loc.setChecked( true); 835 f_loc.setChecked( true);
828 break; 836 break;
829 case 5: 837 case 5:
830 f_rem.setChecked( true); 838 f_rem.setChecked( true);
831 break; 839 break;
832 case 6: 840 case 6:
833 // both.setChecked( true); 841 // both.setChecked( true);
834 break; 842 break;
835 default: 843 default:
836 break; 844 break;
837 } 845 }
838 if ( dia.exec() ) { 846 if ( dia.exec() ) {
839 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 847 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
840 return true; 848 return true;
841 } 849 }
842 return false; 850 return false;
843} 851}
844 852
845QString KSyncManager::getPassword( ) 853QString KSyncManager::getPassword( )
846{ 854{
847 QString retfile = ""; 855 QString retfile = "";
848 QDialog dia ( mParent, "input-dialog", true ); 856 QDialog dia ( mParent, "input-dialog", true );
849 QLineEdit lab ( &dia ); 857 QLineEdit lab ( &dia );
850 lab.setEchoMode( QLineEdit::Password ); 858 lab.setEchoMode( QLineEdit::Password );
851 QVBoxLayout lay( &dia ); 859 QVBoxLayout lay( &dia );
852 lay.setMargin(7); 860 lay.setMargin(7);
853 lay.setSpacing(7); 861 lay.setSpacing(7);
854 lay.addWidget( &lab); 862 lay.addWidget( &lab);
855 dia.setFixedSize( 230,50 ); 863 dia.setFixedSize( 230,50 );
856 dia.setCaption( i18n("Enter password") ); 864 dia.setCaption( i18n("Enter password") );
857 QPushButton pb ( "OK", &dia); 865 QPushButton pb ( "OK", &dia);
858 lay.addWidget( &pb ); 866 lay.addWidget( &pb );
859 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 867 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
860 dia.show(); 868 dia.show();
861 int res = dia.exec(); 869 int res = dia.exec();
862 if ( res ) 870 if ( res )
863 retfile = lab.text(); 871 retfile = lab.text();
864 dia.hide(); 872 dia.hide();
865 qApp->processEvents(); 873 qApp->processEvents();
866 return retfile; 874 return retfile;
867 875
868} 876}
869 877
870 878
871void KSyncManager::confSync() 879void KSyncManager::confSync()
872{ 880{
873 static KSyncPrefsDialog* sp = 0; 881 static KSyncPrefsDialog* sp = 0;
874 if ( ! sp ) { 882 if ( ! sp ) {
875 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 883 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
876 } 884 }
877 sp->usrReadConfig(); 885 sp->usrReadConfig();
878#ifndef DESKTOP_VERSION 886#ifndef DESKTOP_VERSION
879 sp->showMaximized(); 887 sp->showMaximized();
880#else 888#else
881 sp->show(); 889 sp->show();
882#endif 890#endif
883 sp->exec(); 891 sp->exec();
884 QStringList oldSyncProfileNames = mSyncProfileNames; 892 QStringList oldSyncProfileNames = mSyncProfileNames;
885 mSyncProfileNames = sp->getSyncProfileNames(); 893 mSyncProfileNames = sp->getSyncProfileNames();
886 mLocalMachineName = sp->getLocalMachineName (); 894 mLocalMachineName = sp->getLocalMachineName ();
887 int ii; 895 int ii;
888 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 896 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
889 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 897 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
890 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 898 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
891 } 899 }
892 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 900 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
893} 901}
894void KSyncManager::syncKDE() 902void KSyncManager::syncKDE()
895{ 903{
896 mSyncWithDesktop = true; 904 mSyncWithDesktop = true;
897 emit save(); 905 emit save();
898 switch(mTargetApp) 906 switch(mTargetApp)
899 { 907 {
900 case (KAPI): 908 case (KAPI):
901 { 909 {
902#ifdef DESKTOP_VERSION 910#ifdef DESKTOP_VERSION
903 QString command = qApp->applicationDirPath () + "/kdeabdump"; 911 QString command = qApp->applicationDirPath () + "/kdeabdump";
904#else 912#else
905 QString command = "kdeabdump"; 913 QString command = "kdeabdump";
906#endif 914#endif
907 if ( ! QFile::exists ( command ) ) 915 if ( ! QFile::exists ( command ) )
908 command = "kdeabdump"; 916 command = "kdeabdump";
909 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 917 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
910 system ( command.latin1()); 918 system ( command.latin1());
911 if ( syncWithFile( fileName,true ) ) { 919 if ( syncWithFile( fileName,true ) ) {
912 if ( mWriteBackFile ) { 920 if ( mWriteBackFile ) {
913 command += " --read"; 921 command += " --read";
914 system ( command.latin1()); 922 system ( command.latin1());
915 } 923 }
916 } 924 }
917 925
918 } 926 }
919 break; 927 break;
920 case (KOPI): 928 case (KOPI):
921 { 929 {
922#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
923 QString command = qApp->applicationDirPath () + "/kdecaldump"; 931 QString command = qApp->applicationDirPath () + "/kdecaldump";
924#else 932#else
925 QString command = "kdecaldump"; 933 QString command = "kdecaldump";
926#endif 934#endif
927 if ( ! QFile::exists ( command ) ) 935 if ( ! QFile::exists ( command ) )
928 command = "kdecaldump"; 936 command = "kdecaldump";
929 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 937 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
930 system ( command.latin1()); 938 system ( command.latin1());
931 if ( syncWithFile( fileName,true ) ) { 939 if ( syncWithFile( fileName,true ) ) {
932 if ( mWriteBackFile ) { 940 if ( mWriteBackFile ) {
933 command += " --read"; 941 command += " --read";
934 system ( command.latin1()); 942 system ( command.latin1());
935 } 943 }
936 } 944 }
937 945
938 } 946 }
939 break; 947 break;
940 case (PWMPI): 948 case (PWMPI):
941 949
942 break; 950 break;
943 default: 951 default:
944 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected"); 952 qDebug("KSyncManager::slotSyncMenu: invalid apptype selected");
945 break; 953 break;
946 954
947 } 955 }
948} 956}
949 957
950void KSyncManager::syncSharp() 958void KSyncManager::syncSharp()
951{ 959{
952 960
953 if ( ! syncExternalApplication("sharp") ) 961 if ( ! syncExternalApplication("sharp") )
954 qDebug("ERROR sync sharp "); 962 qDebug("ERROR sync sharp ");
955} 963}
956 964
957bool KSyncManager::syncExternalApplication(QString resource) 965bool KSyncManager::syncExternalApplication(QString resource)
958{ 966{
959 967
960 emit save(); 968 emit save();
961 969
962 if ( mAskForPreferences ) 970 if ( mAskForPreferences )
963 if ( !edit_sync_options()) { 971 if ( !edit_sync_options()) {
964 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 972 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
965 return false; 973 return false;
966 } 974 }
967 975
968 qDebug("Sync extern %s", resource.latin1()); 976 qDebug("Sync extern %s", resource.latin1());
969 977
970 bool syncOK = mImplementation->syncExternal(this, resource); 978 bool syncOK = mImplementation->syncExternal(this, resource);
971 979
972 return syncOK; 980 return syncOK;
973 981
974} 982}
975 983
976void KSyncManager::syncPhone() 984void KSyncManager::syncPhone()
977{ 985{
978 986
979 syncExternalApplication("phone"); 987 syncExternalApplication("phone");
980 988
981} 989}
982 990
983void KSyncManager::showProgressBar(int percentage, QString caption, int total) 991void KSyncManager::showProgressBar(int percentage, QString caption, int total)
984{ 992{
985 if (!bar->isVisible()) 993 if (!bar->isVisible())
986 { 994 {
987 bar->setCaption (caption); 995 bar->setCaption (caption);
988 bar->setTotalSteps ( total ) ; 996 bar->setTotalSteps ( total ) ;
989 997
990 bar->show(); 998 bar->show();
991 } 999 }
992 1000
993 bar->setProgress( percentage ); 1001 bar->setProgress( percentage );
994} 1002}
995 1003
996void KSyncManager::hideProgressBar() 1004void KSyncManager::hideProgressBar()
997{ 1005{
998 bar->hide(); 1006 bar->hide();
999} 1007}
1000 1008
1001bool KSyncManager::isProgressBarCanceled() 1009bool KSyncManager::isProgressBarCanceled()
1002{ 1010{
1003 return !bar->isVisible(); 1011 return !bar->isVisible();
1004} 1012}
1005 1013
1006QString KSyncManager::syncFileName() 1014QString KSyncManager::syncFileName()
1007{ 1015{
1008 1016
1009 QString fn = "tempfile"; 1017 QString fn = "tempfile";
1010 switch(mTargetApp) 1018 switch(mTargetApp)
1011 { 1019 {
1012 case (KAPI): 1020 case (KAPI):
1013 fn = "tempsyncab.vcf"; 1021 fn = "tempsyncab.vcf";
1014 break; 1022 break;
1015 case (KOPI): 1023 case (KOPI):
1016 fn = "tempsynccal.ics"; 1024 fn = "tempsynccal.ics";
1017 break; 1025 break;
1018 case (PWMPI): 1026 case (PWMPI):
1019 fn = "tempsyncpw.pwm"; 1027 fn = "tempsyncpw.pwm";
1020 break; 1028 break;
1021 default: 1029 default:
1022 break; 1030 break;
1023 } 1031 }
1024#ifdef _WIN32_ 1032#ifdef _WIN32_
1025 return locateLocal( "tmp", fn ); 1033 return locateLocal( "tmp", fn );
1026#else 1034#else
1027 return (QString( "/tmp/" )+ fn ); 1035 return (QString( "/tmp/" )+ fn );
1028#endif 1036#endif
1029} 1037}
1030 1038
1031void KSyncManager::syncPi() 1039void KSyncManager::syncPi()
1032{ 1040{
1033 mIsKapiFile = true; 1041 mIsKapiFile = true;
1034 mPisyncFinished = false; 1042 mPisyncFinished = false;
1035 qApp->processEvents(); 1043 qApp->processEvents();
1036 if ( mAskForPreferences ) 1044 if ( mAskForPreferences )
1037 if ( !edit_pisync_options()) { 1045 if ( !edit_pisync_options()) {
1038 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1046 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1039 return; 1047 return;
1040 } 1048 }
1041 bool ok; 1049 bool ok;
1042 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1050 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1043 if ( ! ok ) { 1051 if ( ! ok ) {
1044 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1052 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1045 return; 1053 return;
1046 } 1054 }
1047 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this ); 1055 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this );
1048 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1056 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1049 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") ); 1057 mParent->topLevelWidget()->setCaption( i18n("Sending request for remote file ...") );
1050 commandSocket->readFile( syncFileName() ); 1058 commandSocket->readFile( syncFileName() );
1051} 1059}
1052 1060
1053void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1061void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1054{ 1062{
1055 //enum { success, errorW, errorR, quiet }; 1063 //enum { success, errorW, errorR, quiet };
1056 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) { 1064 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) {
1057 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1065 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1058 delete s; 1066 delete s;
1059 if ( state == KCommandSocket::errorR ) { 1067 if ( state == KCommandSocket::errorR ) {
1060 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1068 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1061 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1069 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1062 commandSocket->sendStop(); 1070 commandSocket->sendStop();
1063 } 1071 }
1064 mPisyncFinished = true; 1072 mPisyncFinished = true;
1065 return; 1073 return;
1066 1074
1067 } else if ( state == KCommandSocket::errorW ) { 1075 } else if ( state == KCommandSocket::errorW ) {
1068 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1076 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1069 mPisyncFinished = true; 1077 mPisyncFinished = true;
1070 1078
1071 } else if ( state == KCommandSocket::successR ) { 1079 } else if ( state == KCommandSocket::successR ) {
1072 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1080 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1073 1081
1074 } else if ( state == KCommandSocket::successW ) { 1082 } else if ( state == KCommandSocket::successW ) {
1075 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1083 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1076 mPisyncFinished = true; 1084 mPisyncFinished = true;
1077 } 1085 }
1078 1086
1079 delete s; 1087 delete s;
1080} 1088}
1081 1089
1082void KSyncManager::readFileFromSocket() 1090void KSyncManager::readFileFromSocket()
1083{ 1091{
1084 QString fileName = syncFileName(); 1092 QString fileName = syncFileName();
1085 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1093 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1086 if ( ! syncWithFile( fileName , true ) ) { 1094 if ( ! syncWithFile( fileName , true ) ) {
1087 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1095 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1088 mPisyncFinished = true; 1096 mPisyncFinished = true;
1089 return; 1097 return;
1090 } 1098 }
1091 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this ); 1099 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this );
1092 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1100 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1093 if ( mWriteBackFile ) 1101 if ( mWriteBackFile )
1094 commandSocket->writeFile( fileName ); 1102 commandSocket->writeFile( fileName );
1095 else { 1103 else {
1096 commandSocket->sendStop(); 1104 commandSocket->sendStop();
1097 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1105 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1098 mPisyncFinished = true; 1106 mPisyncFinished = true;
1099 } 1107 }
1100} 1108}
1101 1109
1102KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1110KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1103{ 1111{
1104 mPassWord = pw; 1112 mPassWord = pw;
1105 mSocket = 0; 1113 mSocket = 0;
1106 mSyncActionDialog = 0; 1114 mSyncActionDialog = 0;
1107 blockRC = false; 1115 blockRC = false;
1108}; 1116};
1109 1117
1110void KServerSocket::newConnection ( int socket ) 1118void KServerSocket::newConnection ( int socket )
1111{ 1119{
1112 // qDebug("KServerSocket:New connection %d ", socket); 1120 // qDebug("KServerSocket:New connection %d ", socket);
1113 if ( mSocket ) { 1121 if ( mSocket ) {
1114 qDebug("KServerSocket::newConnection Socket deleted! "); 1122 qDebug("KServerSocket::newConnection Socket deleted! ");
1115 delete mSocket; 1123 delete mSocket;
1116 mSocket = 0; 1124 mSocket = 0;
1117 } 1125 }
1118 mSocket = new QSocket( this ); 1126 mSocket = new QSocket( this );
1119 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1127 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1120 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1128 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1121 mSocket->setSocket( socket ); 1129 mSocket->setSocket( socket );
1122} 1130}
1123 1131
1124void KServerSocket::discardClient() 1132void KServerSocket::discardClient()
1125{ 1133{
1126 //qDebug(" KServerSocket::discardClient()"); 1134 //qDebug(" KServerSocket::discardClient()");
1127 if ( mSocket ) { 1135 if ( mSocket ) {
1128 delete mSocket; 1136 delete mSocket;
1129 mSocket = 0; 1137 mSocket = 0;
1130 } 1138 }
1131 //emit endConnect(); 1139 //emit endConnect();
1132} 1140}
1133void KServerSocket::readClient() 1141void KServerSocket::readClient()
1134{ 1142{
1135 if ( blockRC ) 1143 if ( blockRC )
1136 return; 1144 return;
1137 if ( mSocket == 0 ) { 1145 if ( mSocket == 0 ) {
1138 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 1146 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
1139 return; 1147 return;
1140 } 1148 }
1141 //qDebug("KServerSocket::readClient()"); 1149 //qDebug("KServerSocket::readClient()");
1142 if ( mSocket->canReadLine() ) { 1150 if ( mSocket->canReadLine() ) {
1143 QString line = mSocket->readLine(); 1151 QString line = mSocket->readLine();
1144 //qDebug("KServerSocket readline: %s ", line.latin1()); 1152 //qDebug("KServerSocket readline: %s ", line.latin1());
1145 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1153 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1146 if ( tokens[0] == "GET" ) { 1154 if ( tokens[0] == "GET" ) {
1147 if ( tokens[1] == mPassWord ) { 1155 if ( tokens[1] == mPassWord ) {
1148 //emit sendFile( mSocket ); 1156 //emit sendFile( mSocket );
1149 bool ok = false; 1157 bool ok = false;
1150 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1158 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1151 if ( ok ) { 1159 if ( ok ) {
1152 KSyncManager::mRequestedSyncEvent = dt; 1160 KSyncManager::mRequestedSyncEvent = dt;
1153 } 1161 }
1154 else 1162 else
1155 KSyncManager::mRequestedSyncEvent = QDateTime(); 1163 KSyncManager::mRequestedSyncEvent = QDateTime();
1156 send_file(); 1164 send_file();
1157 } 1165 }
1158 else { 1166 else {
1159 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password")); 1167 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"));
1160 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1168 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1161 } 1169 }
1162 } 1170 }
1163 if ( tokens[0] == "PUT" ) { 1171 if ( tokens[0] == "PUT" ) {
1164 if ( tokens[1] == mPassWord ) { 1172 if ( tokens[1] == mPassWord ) {
1165 //emit getFile( mSocket ); 1173 //emit getFile( mSocket );
1166 blockRC = true; 1174 blockRC = true;
1167 get_file(); 1175 get_file();
1168 } 1176 }
1169 else { 1177 else {
1170 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password")); 1178 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"));
1171 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 1179 //qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
1172 } 1180 }
1173 } 1181 }
1174 if ( tokens[0] == "STOP" ) { 1182 if ( tokens[0] == "STOP" ) {
1175 //emit endConnect(); 1183 //emit endConnect();
1176 end_connect(); 1184 end_connect();
1177 } 1185 }
1178 } 1186 }
1179} 1187}
1180void KServerSocket::end_connect() 1188void KServerSocket::end_connect()
1181{ 1189{
1182 delete mSyncActionDialog; 1190 delete mSyncActionDialog;
1183 mSyncActionDialog = 0; 1191 mSyncActionDialog = 0;
1184} 1192}
1185void KServerSocket::send_file() 1193void KServerSocket::send_file()
1186{ 1194{
1187 //qDebug("MainWindow::sendFile(QSocket* s) "); 1195 //qDebug("MainWindow::sendFile(QSocket* s) ");
1188 if ( mSyncActionDialog ) 1196 if ( mSyncActionDialog )
1189 delete mSyncActionDialog; 1197 delete mSyncActionDialog;
1190 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1198 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1191 mSyncActionDialog->setCaption(i18n("Received sync request")); 1199 mSyncActionDialog->setCaption(i18n("Received sync request"));
1192 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1200 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1193 label->setAlignment ( Qt::AlignHCenter ); 1201 label->setAlignment ( Qt::AlignHCenter );
1194 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1202 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1195 lay->addWidget( label); 1203 lay->addWidget( label);
1196 lay->setMargin(7); 1204 lay->setMargin(7);
1197 lay->setSpacing(7); 1205 lay->setSpacing(7);
1198 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1206 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1199 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1207 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1200 if ( secs < 0 ) 1208 if ( secs < 0 )
1201 secs = secs * (-1); 1209 secs = secs * (-1);
1202 if ( secs > 30 ) 1210 if ( secs > 30 )
1203 //if ( true ) 1211 //if ( true )
1204 { 1212 {
1205 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1213 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1206 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1214 QLabel* label = new QLabel( warning, mSyncActionDialog );
1207 label->setAlignment ( Qt::AlignHCenter ); 1215 label->setAlignment ( Qt::AlignHCenter );
1208 lay->addWidget( label); 1216 lay->addWidget( label);
1209 if ( secs > 180 ) 1217 if ( secs > 180 )
1210 { 1218 {
1211 if ( secs > 300 ) { 1219 if ( secs > 300 ) {
1212 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1220 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\n of more than 5 minutes.\nPlease adjust your clocks.\n<b>You may get wrong syncing results!<\b>\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1213 qDebug("cancelled "); 1221 qDebug("cancelled ");
1214 return ; 1222 return ;
1215 } 1223 }
1216 } 1224 }
1217 QFont f = label->font(); 1225 QFont f = label->font();
1218 f.setPointSize ( f.pointSize() *2 ); 1226 f.setPointSize ( f.pointSize() *2 );
1219 f. setBold (true ); 1227 f. setBold (true );
1220 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1228 QLabel* label = new QLabel( warning, mSyncActionDialog );
1221 label->setFont( f ); 1229 label->setFont( f );
1222 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1230 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1223 label->setText( warning ); 1231 label->setText( warning );
1224 label->setAlignment ( Qt::AlignHCenter ); 1232 label->setAlignment ( Qt::AlignHCenter );
1225 lay->addWidget( label); 1233 lay->addWidget( label);
1226 mSyncActionDialog->setFixedSize( 230, 300); 1234 mSyncActionDialog->setFixedSize( 230, 300);
1227 } else { 1235 } else {
1228 mSyncActionDialog->setFixedSize( 230, 200); 1236 mSyncActionDialog->setFixedSize( 230, 200);
1229 } 1237 }
1230 } else { 1238 } else {
1231 mSyncActionDialog->setFixedSize( 230, 120); 1239 mSyncActionDialog->setFixedSize( 230, 120);
1232 } 1240 }
1233 } else 1241 } else
1234 mSyncActionDialog->setFixedSize( 230, 120); 1242 mSyncActionDialog->setFixedSize( 230, 120);
1235 mSyncActionDialog->show(); 1243 mSyncActionDialog->show();
1236 mSyncActionDialog->raise(); 1244 mSyncActionDialog->raise();
1237 emit request_file(); 1245 emit request_file();
1238 qApp->processEvents(); 1246 qApp->processEvents();
1239 QString fileName = mFileName; 1247 QString fileName = mFileName;
1240 QFile file( fileName ); 1248 QFile file( fileName );
1241 if (!file.open( IO_ReadOnly ) ) { 1249 if (!file.open( IO_ReadOnly ) ) {
1242 delete mSyncActionDialog; 1250 delete mSyncActionDialog;
1243 mSyncActionDialog = 0; 1251 mSyncActionDialog = 0;
1244 qDebug("KSS::error open sync file: %s ", fileName.latin1()); 1252 qDebug("KSS::error open sync file: %s ", fileName.latin1());
1245 mSocket->close(); 1253 mSocket->close();
1246 if ( mSocket->state() == QSocket::Idle ) 1254 if ( mSocket->state() == QSocket::Idle )
1247 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1255 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1248 return ; 1256 return ;
1249 1257
1250 } 1258 }
1251 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1259 mSyncActionDialog->setCaption( i18n("Sending file...") );
1252 QTextStream ts( &file ); 1260 QTextStream ts( &file );
1253 ts.setEncoding( QTextStream::Latin1 ); 1261 ts.setEncoding( QTextStream::Latin1 );
1254 1262
1255 QTextStream os( mSocket ); 1263 QTextStream os( mSocket );
1256 os.setEncoding( QTextStream::Latin1 ); 1264 os.setEncoding( QTextStream::Latin1 );
1257 while ( ! ts.atEnd() ) { 1265 while ( ! ts.atEnd() ) {
1258 os << ts.readLine() << "\r\n"; 1266 os << ts.readLine() << "\r\n";
1259 } 1267 }
1260 //os << ts.read(); 1268 //os << ts.read();
1261 file.close(); 1269 file.close();
1262 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1270 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1263 mSocket->close(); 1271 mSocket->close();
1264 if ( mSocket->state() == QSocket::Idle ) 1272 if ( mSocket->state() == QSocket::Idle )
1265 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1273 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1266} 1274}
1267void KServerSocket::get_file() 1275void KServerSocket::get_file()
1268{ 1276{
1269 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1277 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1270 1278
1271 piTime.start(); 1279 piTime.start();
1272 piFileString = ""; 1280 piFileString = "";
1273 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1281 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1274} 1282}
1275 1283
1276 1284
1277void KServerSocket::readBackFileFromSocket() 1285void KServerSocket::readBackFileFromSocket()
1278{ 1286{
1279 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1287 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1280 while ( mSocket->canReadLine () ) { 1288 while ( mSocket->canReadLine () ) {
1281 piTime.restart(); 1289 piTime.restart();
1282 QString line = mSocket->readLine (); 1290 QString line = mSocket->readLine ();
1283 piFileString += line; 1291 piFileString += line;
1284 //qDebug("readline: %s ", line.latin1()); 1292 //qDebug("readline: %s ", line.latin1());
1285 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1293 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1286 1294
1287 } 1295 }
1288 if ( piTime.elapsed () < 3000 ) { 1296 if ( piTime.elapsed () < 3000 ) {
1289 // wait for more 1297 // wait for more
1290 //qDebug("waitformore "); 1298 //qDebug("waitformore ");
1291 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1299 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1292 return; 1300 return;
1293 } 1301 }
1294 QString fileName = mFileName; 1302 QString fileName = mFileName;
1295 QFile file ( fileName ); 1303 QFile file ( fileName );
1296 if (!file.open( IO_WriteOnly ) ) { 1304 if (!file.open( IO_WriteOnly ) ) {
1297 delete mSyncActionDialog; 1305 delete mSyncActionDialog;
1298 mSyncActionDialog = 0; 1306 mSyncActionDialog = 0;
1299 qDebug("KSS:Error open read back file "); 1307 qDebug("KSS:Error open read back file ");
1300 piFileString = ""; 1308 piFileString = "";
1301 emit file_received( false ); 1309 emit file_received( false );
1302 blockRC = false; 1310 blockRC = false;
1303 return ; 1311 return ;
1304 1312
1305 } 1313 }
1306 1314
1307 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1315 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1308 QTextStream ts ( &file ); 1316 QTextStream ts ( &file );
1309 ts.setEncoding( QTextStream::Latin1 ); 1317 ts.setEncoding( QTextStream::Latin1 );
1310 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1318 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1311 ts << piFileString; 1319 ts << piFileString;
1312 mSocket->close(); 1320 mSocket->close();
1313 if ( mSocket->state() == QSocket::Idle ) 1321 if ( mSocket->state() == QSocket::Idle )
1314 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1322 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1315 file.close(); 1323 file.close();
1316 piFileString = ""; 1324 piFileString = "";
1317 emit file_received( true ); 1325 emit file_received( true );
1318 delete mSyncActionDialog; 1326 delete mSyncActionDialog;
1319 mSyncActionDialog = 0; 1327 mSyncActionDialog = 0;
1320 blockRC = false; 1328 blockRC = false;
1321 1329
1322} 1330}
1323 1331
1324KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 1332KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
1325{ 1333{
1326 mPassWord = password; 1334 mPassWord = password;
1327 mSocket = 0; 1335 mSocket = 0;
1328 mPort = port; 1336 mPort = port;
1329 mHost = host; 1337 mHost = host;
1330 1338
1331 mRetVal = quiet; 1339 mRetVal = quiet;
1332 mTimerSocket = new QTimer ( this ); 1340 mTimerSocket = new QTimer ( this );
1333 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 1341 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
1334} 1342}
1335void KCommandSocket::readFile( QString fn ) 1343void KCommandSocket::readFile( QString fn )
1336{ 1344{
1337 if ( !mSocket ) { 1345 if ( !mSocket ) {
1338 mSocket = new QSocket( this ); 1346 mSocket = new QSocket( this );
1339 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1347 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1340 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1348 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1341 } 1349 }
1342 mFileString = ""; 1350 mFileString = "";
1343 mFileName = fn; 1351 mFileName = fn;
1344 mFirst = true; 1352 mFirst = true;
1345 mSocket->connectToHost( mHost, mPort ); 1353 mSocket->connectToHost( mHost, mPort );
1346 QTextStream os( mSocket ); 1354 QTextStream os( mSocket );
1347 os.setEncoding( QTextStream::Latin1 ); 1355 os.setEncoding( QTextStream::Latin1 );
1348 1356
1349 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1357 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1350 os << "GET " << mPassWord << curDt <<"\r\n"; 1358 os << "GET " << mPassWord << curDt <<"\r\n";
1351 mTimerSocket->start( 300000 ); 1359 mTimerSocket->start( 300000 );
1352} 1360}
1353 1361
1354void KCommandSocket::writeFile( QString fileName ) 1362void KCommandSocket::writeFile( QString fileName )
1355{ 1363{
1356 if ( !mSocket ) { 1364 if ( !mSocket ) {
1357 mSocket = new QSocket( this ); 1365 mSocket = new QSocket( this );
1358 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1366 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1359 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1367 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1360 } 1368 }
1361 mFileName = fileName ; 1369 mFileName = fileName ;
1362 mSocket->connectToHost( mHost, mPort ); 1370 mSocket->connectToHost( mHost, mPort );
1363} 1371}
1364void KCommandSocket::writeFileToSocket() 1372void KCommandSocket::writeFileToSocket()
1365{ 1373{
1366 QFile file2( mFileName ); 1374 QFile file2( mFileName );
1367 if (!file2.open( IO_ReadOnly ) ) { 1375 if (!file2.open( IO_ReadOnly ) ) {
1368 mRetVal= errorW; 1376 mRetVal= errorW;
1369 mSocket->close(); 1377 mSocket->close();
1370 if ( mSocket->state() == QSocket::Idle ) 1378 if ( mSocket->state() == QSocket::Idle )
1371 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1379 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1372 return ; 1380 return ;
1373 } 1381 }
1374 QTextStream ts2( &file2 ); 1382 QTextStream ts2( &file2 );
1375 ts2.setEncoding( QTextStream::Latin1 ); 1383 ts2.setEncoding( QTextStream::Latin1 );
1376 QTextStream os2( mSocket ); 1384 QTextStream os2( mSocket );
1377 os2.setEncoding( QTextStream::Latin1 ); 1385 os2.setEncoding( QTextStream::Latin1 );
1378 os2 << "PUT " << mPassWord << "\r\n";; 1386 os2 << "PUT " << mPassWord << "\r\n";;
1379 while ( ! ts2.atEnd() ) { 1387 while ( ! ts2.atEnd() ) {
1380 os2 << ts2.readLine() << "\r\n"; 1388 os2 << ts2.readLine() << "\r\n";
1381 } 1389 }
1382 mRetVal= successW; 1390 mRetVal= successW;
1383 file2.close(); 1391 file2.close();
1384 mSocket->close(); 1392 mSocket->close();
1385 if ( mSocket->state() == QSocket::Idle ) 1393 if ( mSocket->state() == QSocket::Idle )
1386 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1394 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1387} 1395}
1388void KCommandSocket::sendStop() 1396void KCommandSocket::sendStop()
1389{ 1397{
1390 if ( !mSocket ) { 1398 if ( !mSocket ) {
1391 mSocket = new QSocket( this ); 1399 mSocket = new QSocket( this );
1392 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1400 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1393 } 1401 }
1394 mSocket->connectToHost( mHost, mPort ); 1402 mSocket->connectToHost( mHost, mPort );
1395 QTextStream os2( mSocket ); 1403 QTextStream os2( mSocket );
1396 os2.setEncoding( QTextStream::Latin1 ); 1404 os2.setEncoding( QTextStream::Latin1 );
1397 os2 << "STOP\r\n"; 1405 os2 << "STOP\r\n";
1398 mSocket->close(); 1406 mSocket->close();
1399 if ( mSocket->state() == QSocket::Idle ) 1407 if ( mSocket->state() == QSocket::Idle )
1400 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1408 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1401} 1409}
1402 1410
1403void KCommandSocket::startReadFileFromSocket() 1411void KCommandSocket::startReadFileFromSocket()
1404{ 1412{
1405 if ( ! mFirst ) 1413 if ( ! mFirst )
1406 return; 1414 return;
1407 mFirst = false; 1415 mFirst = false;
1408 mTimerSocket->stop(); 1416 mTimerSocket->stop();
1409 mFileString = ""; 1417 mFileString = "";
1410 mTime.start(); 1418 mTime.start();
1411 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1419 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1412 1420
1413} 1421}
1414void KCommandSocket::readFileFromSocket() 1422void KCommandSocket::readFileFromSocket()
1415{ 1423{
1416 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1424 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1417 while ( mSocket->canReadLine () ) { 1425 while ( mSocket->canReadLine () ) {
1418 mTime.restart(); 1426 mTime.restart();
1419 QString line = mSocket->readLine (); 1427 QString line = mSocket->readLine ();
1420 mFileString += line; 1428 mFileString += line;
1421 //qDebug("readline: %s ", line.latin1()); 1429 //qDebug("readline: %s ", line.latin1());
1422 } 1430 }
1423 if ( mTime.elapsed () < 3000 ) { 1431 if ( mTime.elapsed () < 3000 ) {
1424 // wait for more 1432 // wait for more
1425 //qDebug("waitformore "); 1433 //qDebug("waitformore ");
1426 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1434 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1427 return; 1435 return;
1428 } 1436 }
1429 QString fileName = mFileName; 1437 QString fileName = mFileName;
1430 QFile file ( fileName ); 1438 QFile file ( fileName );
1431 if (!file.open( IO_WriteOnly ) ) { 1439 if (!file.open( IO_WriteOnly ) ) {
1432 mFileString = ""; 1440 mFileString = "";
1433 mRetVal = errorR; 1441 mRetVal = errorR;
1434 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1442 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1435 deleteSocket(); 1443 deleteSocket();
1436 return ; 1444 return ;
1437 1445
1438 } 1446 }
1439 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1447 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1440 QTextStream ts ( &file ); 1448 QTextStream ts ( &file );
1441 ts.setEncoding( QTextStream::Latin1 ); 1449 ts.setEncoding( QTextStream::Latin1 );
1442 ts << mFileString; 1450 ts << mFileString;
1443 file.close(); 1451 file.close();
1444 mFileString = ""; 1452 mFileString = "";
1445 mRetVal = successR; 1453 mRetVal = successR;
1446 mSocket->close(); 1454 mSocket->close();
1447 // if state is not idle, deleteSocket(); is called via 1455 // if state is not idle, deleteSocket(); is called via
1448 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1456 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1449 if ( mSocket->state() == QSocket::Idle ) 1457 if ( mSocket->state() == QSocket::Idle )
1450 deleteSocket(); 1458 deleteSocket();
1451} 1459}
1452 1460
1453void KCommandSocket::deleteSocket() 1461void KCommandSocket::deleteSocket()
1454{ 1462{
1455 //qDebug("KCommandSocket::deleteSocket() "); 1463 //qDebug("KCommandSocket::deleteSocket() ");
1456 if ( mTimerSocket->isActive () ) { 1464 if ( mTimerSocket->isActive () ) {
1457 mTimerSocket->stop(); 1465 mTimerSocket->stop();
1458 mRetVal = errorTO; 1466 mRetVal = errorTO;
1459 qDebug("Connection to remote host timed out"); 1467 qDebug("Connection to remote host timed out");
1460 if ( mSocket ) { 1468 if ( mSocket ) {
1461 mSocket->close(); 1469 mSocket->close();
1462 //if ( mSocket->state() == QSocket::Idle ) 1470 //if ( mSocket->state() == QSocket::Idle )
1463 // deleteSocket(); 1471 // deleteSocket();
1464 delete mSocket; 1472 delete mSocket;
1465 mSocket = 0; 1473 mSocket = 0;
1466 } 1474 }
1467 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 1475 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host? "));
1468 emit commandFinished( this, mRetVal ); 1476 emit commandFinished( this, mRetVal );
1469 return; 1477 return;
1470 } 1478 }
1471 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1479 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1472 if ( mSocket) 1480 if ( mSocket)
1473 delete mSocket; 1481 delete mSocket;
1474 mSocket = 0; 1482 mSocket = 0;
1475 emit commandFinished( this, mRetVal ); 1483 emit commandFinished( this, mRetVal );
1476} 1484}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index 2d0a4ab..6d89950 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,217 +1,221 @@
1/* 1/*
2 This file is part of KDE-Pim/Pi. 2 This file is part of KDE-Pim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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 $Id$ 20 $Id$
21*/ 21*/
22#ifndef _KSYNCMANAGER_H 22#ifndef _KSYNCMANAGER_H
23#define _KSYNCMANAGER_H 23#define _KSYNCMANAGER_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qsocket.h> 27#include <qsocket.h>
28#include <qdatetime.h> 28#include <qdatetime.h>
29#include <qserversocket.h> 29#include <qserversocket.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31#include <qregexp.h> 31#include <qregexp.h>
32 32
33class QPopupMenu; 33class QPopupMenu;
34class KSyncProfile; 34class KSyncProfile;
35class KPimPrefs; 35class KPimPrefs;
36class QWidget; 36class QWidget;
37class KSyncManager; 37class KSyncManager;
38class KSyncInterface; 38class KSyncInterface;
39class QProgressBar; 39class QProgressBar;
40 40
41 41
42class KServerSocket : public QServerSocket 42class KServerSocket : public QServerSocket
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46 public: 46 public:
47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 47 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
48 48
49 void newConnection ( int socket ) ; 49 void newConnection ( int socket ) ;
50 void setFileName( QString fn ) {mFileName = fn;}; 50 void setFileName( QString fn ) {mFileName = fn;};
51 signals: 51 signals:
52 void file_received( bool ); 52 void file_received( bool );
53 void request_file(); 53 void request_file();
54 void saveFile(); 54 void saveFile();
55 void endConnect(); 55 void endConnect();
56 private slots: 56 private slots:
57 void discardClient(); 57 void discardClient();
58 void readClient(); 58 void readClient();
59 void readBackFileFromSocket(); 59 void readBackFileFromSocket();
60 private : 60 private :
61 bool blockRC; 61 bool blockRC;
62 void send_file(); 62 void send_file();
63 void get_file(); 63 void get_file();
64 void end_connect(); 64 void end_connect();
65 QDialog* mSyncActionDialog; 65 QDialog* mSyncActionDialog;
66 QSocket* mSocket; 66 QSocket* mSocket;
67 QString mPassWord; 67 QString mPassWord;
68 QString mFileName; 68 QString mFileName;
69 QTime piTime; 69 QTime piTime;
70 QString piFileString; 70 QString piFileString;
71}; 71};
72 72
73class KCommandSocket : public QObject 73class KCommandSocket : public QObject
74{ 74{
75 Q_OBJECT 75 Q_OBJECT
76 public: 76 public:
77 enum state { successR, errorR, successW, errorW, errorTO, quiet }; 77 enum state { successR, errorR, successW, errorW, errorTO, quiet };
78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); 78 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 );
79 void readFile( QString ); 79 void readFile( QString );
80 void writeFile( QString ); 80 void writeFile( QString );
81 void sendStop(); 81 void sendStop();
82 82
83 signals: 83 signals:
84 void commandFinished( KCommandSocket*, int ); 84 void commandFinished( KCommandSocket*, int );
85 private slots: 85 private slots:
86 void startReadFileFromSocket(); 86 void startReadFileFromSocket();
87 void readFileFromSocket(); 87 void readFileFromSocket();
88 void deleteSocket(); 88 void deleteSocket();
89 void writeFileToSocket(); 89 void writeFileToSocket();
90 private : 90 private :
91 QSocket* mSocket; 91 QSocket* mSocket;
92 QString mPassWord; 92 QString mPassWord;
93 Q_UINT16 mPort; 93 Q_UINT16 mPort;
94 QString mHost; 94 QString mHost;
95 QString mFileName; 95 QString mFileName;
96 QTimer* mTimerSocket; 96 QTimer* mTimerSocket;
97 int mRetVal; 97 int mRetVal;
98 QTime mTime; 98 QTime mTime;
99 QString mFileString; 99 QString mFileString;
100 bool mFirst; 100 bool mFirst;
101}; 101};
102 102
103 103
104class KSyncManager : public QObject 104class KSyncManager : public QObject
105{ 105{
106 Q_OBJECT 106 Q_OBJECT
107 107
108 public: 108 public:
109 enum TargetApp { 109 enum TargetApp {
110 KOPI = 0, 110 KOPI = 0,
111 KAPI = 1, 111 KAPI = 1,
112 PWMPI = 2 }; 112 PWMPI = 2 };
113 113
114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 114 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
115 ~KSyncManager() ; 115 ~KSyncManager() ;
116 116
117 void multiSync( bool askforPrefs ); 117 void multiSync( bool askforPrefs );
118 bool blockSave() { return mBlockSaveFlag; } 118 bool blockSave() { return mBlockSaveFlag; }
119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 119 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
120 void setDefaultFileName( QString s) { mDefFileName = s ;} 120 void setDefaultFileName( QString s) { mDefFileName = s ;}
121 QString defaultFileName() { return mDefFileName ;} 121 QString defaultFileName() { return mDefFileName ;}
122 QString syncFileName(); 122 QString syncFileName();
123 void enableQuick( bool ask = true); 123 void enableQuick( bool ask = true);
124 124
125 bool syncWithDesktop () { return mSyncWithDesktop;} 125 bool syncWithDesktop () { return mSyncWithDesktop;}
126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 126 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
127 QString getCurrentSyncName() { return mCurrentSyncName; } 127 QString getCurrentSyncName() { return mCurrentSyncName; }
128 128
129 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 129 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
130 void hideProgressBar(); 130 void hideProgressBar();
131 bool isProgressBarCanceled(); 131 bool isProgressBarCanceled();
132 132
133 // sync stuff 133 // sync stuff
134 QString mLocalMachineName; 134 QString mLocalMachineName;
135 QStringList mExternSyncProfiles; 135 QStringList mExternSyncProfiles;
136 QStringList mSyncProfileNames; 136 QStringList mSyncProfileNames;
137 bool mAskForPreferences; 137 bool mAskForPreferences;
138 bool mShowSyncSummary; 138 bool mShowSyncSummary;
139 bool mIsKapiFile; 139 bool mIsKapiFile;
140 bool mWriteBackExistingOnly; 140 bool mWriteBackExistingOnly;
141 int mSyncAlgoPrefs; 141 int mSyncAlgoPrefs;
142 bool mWriteBackFile; 142 bool mWriteBackFile;
143 int mWriteBackInFuture; 143 int mWriteBackInFuture;
144 int mWriteBackInPast; 144 int mWriteBackInPast;
145 QString mPhoneDevice; 145 QString mPhoneDevice;
146 QString mPhoneConnection; 146 QString mPhoneConnection;
147 QString mPhoneModel; 147 QString mPhoneModel;
148 QString mPassWordPiSync; 148 QString mPassWordPiSync;
149 QString mActiveSyncPort; 149 QString mActiveSyncPort;
150 QString mActiveSyncIP ; 150 QString mActiveSyncIP ;
151 QString mFilterInCal;
152 QString mFilterOutCal;
153 QString mFilterInAB;
154 QString mFilterOutAB;
151 static QDateTime mRequestedSyncEvent; 155 static QDateTime mRequestedSyncEvent;
152 156
153 signals: 157 signals:
154 void save(); 158 void save();
155 void request_file(); 159 void request_file();
156 void getFile( bool ); 160 void getFile( bool );
157 161
158 public slots: 162 public slots:
159 void slotSyncMenu( int ); 163 void slotSyncMenu( int );
160 void slotClearMenu( int action ); 164 void slotClearMenu( int action );
161 void deleteCommandSocket(KCommandSocket*s, int state); 165 void deleteCommandSocket(KCommandSocket*s, int state);
162 void readFileFromSocket(); 166 void readFileFromSocket();
163 void fillSyncMenu(); 167 void fillSyncMenu();
164 168
165 private: 169 private:
166 void syncPi(); 170 void syncPi();
167 KServerSocket * mServerSocket; 171 KServerSocket * mServerSocket;
168 KPimPrefs* mPrefs; 172 KPimPrefs* mPrefs;
169 QString mDefFileName; 173 QString mDefFileName;
170 QString mCurrentSyncDevice; 174 QString mCurrentSyncDevice;
171 QString mCurrentSyncName; 175 QString mCurrentSyncName;
172 void quickSyncLocalFile(); 176 void quickSyncLocalFile();
173 bool syncWithFile( QString fn , bool quick ); 177 bool syncWithFile( QString fn , bool quick );
174 void syncLocalFile(); 178 void syncLocalFile();
175 void syncPhone(); 179 void syncPhone();
176 void syncSharp(); 180 void syncSharp();
177 void syncKDE(); 181 void syncKDE();
178 bool syncExternalApplication(QString); 182 bool syncExternalApplication(QString);
179 int mCurrentSyncProfile ; 183 int mCurrentSyncProfile ;
180 void syncRemote( KSyncProfile* prof, bool ask = true); 184 void syncRemote( KSyncProfile* prof, bool ask = true);
181 bool edit_sync_options(); 185 bool edit_sync_options();
182 bool edit_pisync_options(); 186 bool edit_pisync_options();
183 int ringSync(); 187 int ringSync();
184 QString getPassword( ); 188 QString getPassword( );
185 bool mPisyncFinished; 189 bool mPisyncFinished;
186 bool mBlockSaveFlag; 190 bool mBlockSaveFlag;
187 QWidget* mParent; 191 QWidget* mParent;
188 KSyncInterface* mImplementation; 192 KSyncInterface* mImplementation;
189 TargetApp mTargetApp; 193 TargetApp mTargetApp;
190 QPopupMenu* mSyncMenu; 194 QPopupMenu* mSyncMenu;
191 QProgressBar* bar; 195 QProgressBar* bar;
192 bool mSyncWithDesktop; 196 bool mSyncWithDesktop;
193 197
194private slots: 198private slots:
195 void confSync(); 199 void confSync();
196 200
197 201
198}; 202};
199 203
200 204
201class KSyncInterface 205class KSyncInterface
202{ 206{
203 public : 207 public :
204 virtual void removeSyncInfo( QString syncProfile) = 0; 208 virtual void removeSyncInfo( QString syncProfile) = 0;
205 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 209 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0;
206 virtual bool syncExternal(KSyncManager* manager, QString resource) 210 virtual bool syncExternal(KSyncManager* manager, QString resource)
207 { 211 {
208 // empty implementation, because some syncable applications do not 212 // empty implementation, because some syncable applications do not
209 // have an external(sharpdtm) syncmode, like pwmanager. 213 // have an external(sharpdtm) syncmode, like pwmanager.
210 return false; 214 return false;
211 } 215 }
212 216
213 217
214}; 218};
215 219
216 220
217#endif 221#endif