summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-25 15:49:13 (UTC)
committer zautrix <zautrix>2005-11-25 15:49:13 (UTC)
commit794a5204686ad9bfc16172b01db35f1f3b7683e5 (patch) (unidiff)
tree29da2cb35a4d6a0cd6885436087fe0659b58a9f4
parent90b62d1158d00f162a258541e24aaed4c967480b (diff)
downloadkdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.zip
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.gz
kdepimpi-794a5204686ad9bfc16172b01db35f1f3b7683e5.tar.bz2
sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/kabcore.h2
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/koprefs.cpp10
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--libkdepim/ksyncmanager.cpp51
-rw-r--r--libkdepim/ksyncmanager.h8
-rw-r--r--libkdepim/ksyncprefsdialog.cpp6
9 files changed, 80 insertions, 21 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 033e537..2dea619 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3495 +1,3495 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99#include <kprefsdialog.h> 99#include <kprefsdialog.h>
100 100
101 101
102//#include <qlabel.h> 102//#include <qlabel.h>
103 103
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106#include <qpe/ir.h> 106#include <qpe/ir.h>
107#include <qpe/qpemenubar.h> 107#include <qpe/qpemenubar.h>
108#include <qtopia/qcopenvelope_qws.h> 108#include <qtopia/qcopenvelope_qws.h>
109#else 109#else
110 110
111#include <qmenubar.h> 111#include <qmenubar.h>
112#endif 112#endif
113 113
114#endif // KAB_EMBEDDED 114#endif // KAB_EMBEDDED
115#include "kcmconfigs/kcmkabconfig.h" 115#include "kcmconfigs/kcmkabconfig.h"
116#include "kcmconfigs/kcmkdepimconfig.h" 116#include "kcmconfigs/kcmkdepimconfig.h"
117#include "kpimglobalprefs.h" 117#include "kpimglobalprefs.h"
118#include "externalapphandler.h" 118#include "externalapphandler.h"
119#include "xxportselectdialog.h" 119#include "xxportselectdialog.h"
120 120
121 121
122#include <kresources/selectdialog.h> 122#include <kresources/selectdialog.h>
123#include <kmessagebox.h> 123#include <kmessagebox.h>
124 124
125#include <picture.h> 125#include <picture.h>
126#include <resource.h> 126#include <resource.h>
127 127
128//US#include <qsplitter.h> 128//US#include <qsplitter.h>
129#include <qmap.h> 129#include <qmap.h>
130#include <qdir.h> 130#include <qdir.h>
131#include <qfile.h> 131#include <qfile.h>
132#include <qvbox.h> 132#include <qvbox.h>
133#include <qlayout.h> 133#include <qlayout.h>
134#include <qclipboard.h> 134#include <qclipboard.h>
135#include <qtextstream.h> 135#include <qtextstream.h>
136#include <qradiobutton.h> 136#include <qradiobutton.h>
137#include <qbuttongroup.h> 137#include <qbuttongroup.h>
138 138
139#include <libkdepim/categoryselectdialog.h> 139#include <libkdepim/categoryselectdialog.h>
140#include <libkdepim/categoryeditdialog.h> 140#include <libkdepim/categoryeditdialog.h>
141#include <kabc/vcardconverter.h> 141#include <kabc/vcardconverter.h>
142 142
143 143
144#include "addresseeutil.h" 144#include "addresseeutil.h"
145#include "undocmds.h" 145#include "undocmds.h"
146#include "addresseeeditordialog.h" 146#include "addresseeeditordialog.h"
147#include "viewmanager.h" 147#include "viewmanager.h"
148#include "details/detailsviewcontainer.h" 148#include "details/detailsviewcontainer.h"
149#include "kabprefs.h" 149#include "kabprefs.h"
150#include "xxportmanager.h" 150#include "xxportmanager.h"
151#include "incsearchwidget.h" 151#include "incsearchwidget.h"
152#include "jumpbuttonbar.h" 152#include "jumpbuttonbar.h"
153#include "extensionmanager.h" 153#include "extensionmanager.h"
154#include "addresseeconfig.h" 154#include "addresseeconfig.h"
155#include "nameeditdialog.h" 155#include "nameeditdialog.h"
156#include <kcmultidialog.h> 156#include <kcmultidialog.h>
157 157
158#ifdef _WIN32_ 158#ifdef _WIN32_
159#ifdef _OL_IMPORT_ 159#ifdef _OL_IMPORT_
160#include "kaimportoldialog.h" 160#include "kaimportoldialog.h"
161#endif 161#endif
162#else 162#else
163#include <unistd.h> 163#include <unistd.h>
164#endif 164#endif
165// sync includes 165// sync includes
166#include <libkdepim/ksyncprofile.h> 166#include <libkdepim/ksyncprofile.h>
167#include <libkdepim/ksyncprefsdialog.h> 167#include <libkdepim/ksyncprefsdialog.h>
168 168
169 169
170class KABCatPrefs : public QDialog 170class KABCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from addressees"), format ); 186 new QRadioButton(i18n("Remove from addressees"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202class KABFormatPrefs : public QDialog 202class KABFormatPrefs : public QDialog
203{ 203{
204 public: 204 public:
205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 205 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
206 QDialog( parent, name, true ) 206 QDialog( parent, name, true )
207 { 207 {
208 setCaption( i18n("Set formatted name") ); 208 setCaption( i18n("Set formatted name") );
209 QVBoxLayout* lay = new QVBoxLayout( this ); 209 QVBoxLayout* lay = new QVBoxLayout( this );
210 lay->setSpacing( 3 ); 210 lay->setSpacing( 3 );
211 lay->setMargin( 3 ); 211 lay->setMargin( 3 );
212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 212 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
213 lay->addWidget( lab ); 213 lay->addWidget( lab );
214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 214 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
215 lay->addWidget( format ); 215 lay->addWidget( format );
216 format->setExclusive ( true ) ; 216 format->setExclusive ( true ) ;
217 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 217 simple = new QRadioButton(i18n("Simple: James Bond"), format );
218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 218 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 219 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
220 company = new QRadioButton(i18n("Organization: MI6"), format ); 220 company = new QRadioButton(i18n("Organization: MI6"), format );
221 simple->setChecked( true ); 221 simple->setChecked( true );
222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 222 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
223 lay->addWidget( setCompany ); 223 lay->addWidget( setCompany );
224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 224 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
225 lay->addWidget( ok ); 225 lay->addWidget( ok );
226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 226 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
227 lay->addWidget( cancel ); 227 lay->addWidget( cancel );
228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 228 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 229 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
230 //resize( 200, 200 ); 230 //resize( 200, 200 );
231 231
232 } 232 }
233public: 233public:
234 QRadioButton* simple, *full, *reverse, *company; 234 QRadioButton* simple, *full, *reverse, *company;
235 QCheckBox* setCompany; 235 QCheckBox* setCompany;
236}; 236};
237 237
238 238
239 239
240class KAex2phonePrefs : public QDialog 240class KAex2phonePrefs : public QDialog
241{ 241{
242 public: 242 public:
243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 243 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
244 QDialog( parent, name, true ) 244 QDialog( parent, name, true )
245 { 245 {
246 setCaption( i18n("Export to phone options") ); 246 setCaption( i18n("Export to phone options") );
247 QVBoxLayout* lay = new QVBoxLayout( this ); 247 QVBoxLayout* lay = new QVBoxLayout( this );
248 lay->setSpacing( 3 ); 248 lay->setSpacing( 3 );
249 lay->setMargin( 3 ); 249 lay->setMargin( 3 );
250 QLabel *lab; 250 QLabel *lab;
251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 251 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
252 lab->setAlignment (AlignHCenter ); 252 lab->setAlignment (AlignHCenter );
253 QHBox* temphb; 253 QHBox* temphb;
254 temphb = new QHBox( this ); 254 temphb = new QHBox( this );
255 new QLabel( i18n("I/O device: "), temphb ); 255 new QLabel( i18n("I/O device: "), temphb );
256 mPhoneDevice = new QLineEdit( temphb); 256 mPhoneDevice = new QLineEdit( temphb);
257 lay->addWidget( temphb ); 257 lay->addWidget( temphb );
258 temphb = new QHBox( this ); 258 temphb = new QHBox( this );
259 new QLabel( i18n("Connection: "), temphb ); 259 new QLabel( i18n("Connection: "), temphb );
260 mPhoneConnection = new QLineEdit( temphb); 260 mPhoneConnection = new QLineEdit( temphb);
261 lay->addWidget( temphb ); 261 lay->addWidget( temphb );
262 temphb = new QHBox( this ); 262 temphb = new QHBox( this );
263 new QLabel( i18n("Model(opt.): "), temphb ); 263 new QLabel( i18n("Model(opt.): "), temphb );
264 mPhoneModel = new QLineEdit( temphb); 264 mPhoneModel = new QLineEdit( temphb);
265 lay->addWidget( temphb ); 265 lay->addWidget( temphb );
266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 266 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
267 // lay->addWidget( mWriteToSim ); 267 // lay->addWidget( mWriteToSim );
268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 268 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
269 lab->setAlignment (AlignHCenter); 269 lab->setAlignment (AlignHCenter);
270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 270 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
271 lay->addWidget( ok ); 271 lay->addWidget( ok );
272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 272 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
273 lay->addWidget( cancel ); 273 lay->addWidget( cancel );
274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 274 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 275 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
276 resize( 220, 240 ); 276 resize( 220, 240 );
277 277
278 } 278 }
279 279
280public: 280public:
281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 281 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
282 QCheckBox* mWriteToSim; 282 QCheckBox* mWriteToSim;
283}; 283};
284 284
285 285
286bool pasteWithNewUid = true; 286bool pasteWithNewUid = true;
287 287
288#ifdef KAB_EMBEDDED 288#ifdef KAB_EMBEDDED
289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 289KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 290 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 291 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 292 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
293#else //KAB_EMBEDDED 293#else //KAB_EMBEDDED
294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 294KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 295 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 296 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
297 mReadWrite( readWrite ), mModified( false ) 297 mReadWrite( readWrite ), mModified( false )
298#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
299{ 299{
300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 300 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
301 // syncManager->setBlockSave(false); 301 // syncManager->setBlockSave(false);
302 mIncSearchWidget = 0; 302 mIncSearchWidget = 0;
303 mMiniSplitter = 0; 303 mMiniSplitter = 0;
304 mExtensionBarSplitter = 0; 304 mExtensionBarSplitter = 0;
305 mIsPart = !parent->inherits( "KAddressBookMain" ); 305 mIsPart = !parent->inherits( "KAddressBookMain" );
306 mAddressBook = KABC::StdAddressBook::selfNoLoad(); 306 mAddressBook = KABC::StdAddressBook::selfNoLoad();
307 KABC::StdAddressBook::setAutomaticSave( false ); 307 KABC::StdAddressBook::setAutomaticSave( false );
308 308
309#ifndef KAB_EMBEDDED 309#ifndef KAB_EMBEDDED
310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 310 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
311#endif //KAB_EMBEDDED 311#endif //KAB_EMBEDDED
312 312
313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 313 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
314 SLOT( addressBookChanged() ) ); 314 SLOT( addressBookChanged() ) );
315 315
316#if 0 316#if 0
317 // LR moved to addressbook init method 317 // LR moved to addressbook init method
318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
319 "X-Department", "KADDRESSBOOK" ); 319 "X-Department", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
321 "X-Profession", "KADDRESSBOOK" ); 321 "X-Profession", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 322 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
323 "X-AssistantsName", "KADDRESSBOOK" ); 323 "X-AssistantsName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 324 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
325 "X-ManagersName", "KADDRESSBOOK" ); 325 "X-ManagersName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
327 "X-SpousesName", "KADDRESSBOOK" ); 327 "X-SpousesName", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
329 "X-Office", "KADDRESSBOOK" ); 329 "X-Office", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 330 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
331 "X-IMAddress", "KADDRESSBOOK" ); 331 "X-IMAddress", "KADDRESSBOOK" );
332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 332 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
333 "X-Anniversary", "KADDRESSBOOK" ); 333 "X-Anniversary", "KADDRESSBOOK" );
334 334
335 //US added this field to become compatible with Opie/qtopia addressbook 335 //US added this field to become compatible with Opie/qtopia addressbook
336 // values can be "female" or "male" or "". An empty field represents undefined. 336 // values can be "female" or "male" or "". An empty field represents undefined.
337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
338 "X-Gender", "KADDRESSBOOK" ); 338 "X-Gender", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 339 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
340 "X-Children", "KADDRESSBOOK" ); 340 "X-Children", "KADDRESSBOOK" );
341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 341 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
342 "X-FreeBusyUrl", "KADDRESSBOOK" ); 342 "X-FreeBusyUrl", "KADDRESSBOOK" );
343#endif 343#endif
344 initGUI(); 344 initGUI();
345 345
346 mIncSearchWidget->setFocus(); 346 mIncSearchWidget->setFocus();
347 347
348 348
349 connect( mViewManager, SIGNAL( selected( const QString& ) ), 349 connect( mViewManager, SIGNAL( selected( const QString& ) ),
350 SLOT( setContactSelected( const QString& ) ) ); 350 SLOT( setContactSelected( const QString& ) ) );
351 connect( mViewManager, SIGNAL( executed( const QString& ) ), 351 connect( mViewManager, SIGNAL( executed( const QString& ) ),
352 SLOT( executeContact( const QString& ) ) ); 352 SLOT( executeContact( const QString& ) ) );
353 353
354 connect( mViewManager, SIGNAL( deleteRequest( ) ), 354 connect( mViewManager, SIGNAL( deleteRequest( ) ),
355 SLOT( deleteContacts( ) ) ); 355 SLOT( deleteContacts( ) ) );
356 connect( mViewManager, SIGNAL( modified() ), 356 connect( mViewManager, SIGNAL( modified() ),
357 SLOT( setModified() ) ); 357 SLOT( setModified() ) );
358 358
359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 359 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 360 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
361 361
362 connect( mXXPortManager, SIGNAL( modified() ), 362 connect( mXXPortManager, SIGNAL( modified() ),
363 SLOT( setModified() ) ); 363 SLOT( setModified() ) );
364 364
365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 365 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
366 SLOT( incrementalSearchJump( const QString& ) ) ); 366 SLOT( incrementalSearchJump( const QString& ) ) );
367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 367 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
368 mJumpButtonBar, SLOT( recreateButtons() ) ); 368 mJumpButtonBar, SLOT( recreateButtons() ) );
369 369
370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 370 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
371 SLOT( sendMail( const QString& ) ) ); 371 SLOT( sendMail( const QString& ) ) );
372 372
373 373
374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 376 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 377 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync())); 378 connect( ExternalAppHandler::instance(), SIGNAL (doRingSync()),this, SLOT( doRingSync()));
379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 379 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
380 380
381 381
382#ifndef KAB_EMBEDDED 382#ifndef KAB_EMBEDDED
383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 383 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
384 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 384 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
385 385
386 connect( mDetails, SIGNAL( browse( const QString& ) ), 386 connect( mDetails, SIGNAL( browse( const QString& ) ),
387 SLOT( browse( const QString& ) ) ); 387 SLOT( browse( const QString& ) ) );
388 388
389 389
390 mAddressBookService = new KAddressBookService( this ); 390 mAddressBookService = new KAddressBookService( this );
391 391
392#endif //KAB_EMBEDDED 392#endif //KAB_EMBEDDED
393 393
394 mMessageTimer = new QTimer( this ); 394 mMessageTimer = new QTimer( this );
395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 395 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
396 mEditorDialog = 0; 396 mEditorDialog = 0;
397 createAddresseeEditorDialog( this ); 397 createAddresseeEditorDialog( this );
398 setModified( false ); 398 setModified( false );
399 mBRdisabled = false; 399 mBRdisabled = false;
400#ifndef DESKTOP_VERSION 400#ifndef DESKTOP_VERSION
401 infrared = 0; 401 infrared = 0;
402#endif 402#endif
403 //toggleBeamReceive( ); 403 //toggleBeamReceive( );
404 mMainWindow->toolBar()->show(); 404 mMainWindow->toolBar()->show();
405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 405 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 406 //QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() )); 407 QTimer::singleShot( 100, this, SLOT ( loadDataAfterStart() ));
408} 408}
409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data ) 409void KABCore::receiveStart( const QCString& cmsg, const QByteArray& data )
410{ 410{
411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() ); 411 //qDebug("KO: QCOP start message received: %s ", cmsg.data() );
412 mCStringMess = cmsg; 412 mCStringMess = cmsg;
413 mByteData = data; 413 mByteData = data;
414} 414}
415 415
416void KABCore::loadDataAfterStart() 416void KABCore::loadDataAfterStart()
417{ 417{
418 //qDebug("KABCore::loadDataAfterStart() "); 418 //qDebug("KABCore::loadDataAfterStart() ");
419 ((StdAddressBook*)mAddressBook)->init( true ); 419 ((StdAddressBook*)mAddressBook)->init( true );
420 mViewManager->refreshView(); 420 mViewManager->refreshView();
421 421
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & ))); 423 disconnect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), this, SLOT (receiveStart ( const QCString &, const QByteArray & )));
424 424
425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 425 QObject::connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
426 if ( !mCStringMess.isEmpty() ) 426 if ( !mCStringMess.isEmpty() )
427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData ); 427 ExternalAppHandler::instance()->appMessage( mCStringMess, mByteData );
428#endif 428#endif
429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 429 // QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
430 setCaptionBack(); 430 setCaptionBack();
431} 431}
432void KABCore::updateToolBar() 432void KABCore::updateToolBar()
433{ 433{
434 static int iii = 0; 434 static int iii = 0;
435 ++iii; 435 ++iii;
436 mMainWindow->toolBar()->repaintMe(); 436 mMainWindow->toolBar()->repaintMe();
437 if ( iii < 4 ) 437 if ( iii < 4 )
438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 438 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
439} 439}
440KABCore::~KABCore() 440KABCore::~KABCore()
441{ 441{
442 // save(); 442 // save();
443 //saveSettings(); 443 //saveSettings();
444 //KABPrefs::instance()->writeConfig(); 444 //KABPrefs::instance()->writeConfig();
445 delete AddresseeConfig::instance(); 445 delete AddresseeConfig::instance();
446 mAddressBook = 0; 446 mAddressBook = 0;
447 KABC::StdAddressBook::close(); 447 KABC::StdAddressBook::close();
448 448
449 delete syncManager; 449 delete syncManager;
450#ifndef DESKTOP_VERSION 450#ifndef DESKTOP_VERSION
451 if ( infrared ) 451 if ( infrared )
452 delete infrared; 452 delete infrared;
453#endif 453#endif
454} 454}
455void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 455void KABCore::receive( const QCString& cmsg, const QByteArray& data )
456{ 456{
457 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 457 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
458 if ( cmsg == "setDocument(QString)" ) { 458 if ( cmsg == "setDocument(QString)" ) {
459 QDataStream stream( data, IO_ReadOnly ); 459 QDataStream stream( data, IO_ReadOnly );
460 QString fileName; 460 QString fileName;
461 stream >> fileName; 461 stream >> fileName;
462 recieve( fileName ); 462 recieve( fileName );
463 return; 463 return;
464 } 464 }
465} 465}
466void KABCore::toggleBeamReceive( ) 466void KABCore::toggleBeamReceive( )
467{ 467{
468 if ( mBRdisabled ) 468 if ( mBRdisabled )
469 return; 469 return;
470#ifndef DESKTOP_VERSION 470#ifndef DESKTOP_VERSION
471 if ( infrared ) { 471 if ( infrared ) {
472 qDebug("KA: AB disable BeamReceive "); 472 qDebug("KA: AB disable BeamReceive ");
473 delete infrared; 473 delete infrared;
474 infrared = 0; 474 infrared = 0;
475 mActionBR->setChecked(false); 475 mActionBR->setChecked(false);
476 return; 476 return;
477 } 477 }
478 qDebug("KA: AB enable BeamReceive "); 478 qDebug("KA: AB enable BeamReceive ");
479 mActionBR->setChecked(true); 479 mActionBR->setChecked(true);
480 480
481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 481 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 482 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
483#endif 483#endif
484} 484}
485 485
486 486
487void KABCore::disableBR(bool b) 487void KABCore::disableBR(bool b)
488{ 488{
489#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
490 if ( b ) { 490 if ( b ) {
491 if ( infrared ) { 491 if ( infrared ) {
492 toggleBeamReceive( ); 492 toggleBeamReceive( );
493 } 493 }
494 mBRdisabled = true; 494 mBRdisabled = true;
495 } else { 495 } else {
496 if ( mBRdisabled ) { 496 if ( mBRdisabled ) {
497 mBRdisabled = false; 497 mBRdisabled = false;
498 //toggleBeamReceive( ); 498 //toggleBeamReceive( );
499 } 499 }
500 } 500 }
501#endif 501#endif
502 502
503} 503}
504void KABCore::recieve( QString fn ) 504void KABCore::recieve( QString fn )
505{ 505{
506 //qDebug("KABCore::recieve "); 506 //qDebug("KABCore::recieve ");
507 int count = mAddressBook->importFromFile( fn, true ); 507 int count = mAddressBook->importFromFile( fn, true );
508 if ( count ) 508 if ( count )
509 setModified( true ); 509 setModified( true );
510 mViewManager->refreshView(); 510 mViewManager->refreshView();
511 message(i18n("%1 contact(s) received!").arg( count )); 511 message(i18n("%1 contact(s) received!").arg( count ));
512 topLevelWidget()->showMaximized(); 512 topLevelWidget()->showMaximized();
513 topLevelWidget()->raise(); 513 topLevelWidget()->raise();
514} 514}
515void KABCore::restoreSettings() 515void KABCore::restoreSettings()
516{ 516{
517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 517 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
518 518
519 bool state; 519 bool state;
520 520
521 if (mMultipleViewsAtOnce) 521 if (mMultipleViewsAtOnce)
522 state = KABPrefs::instance()->mDetailsPageVisible; 522 state = KABPrefs::instance()->mDetailsPageVisible;
523 else 523 else
524 state = false; 524 state = false;
525 525
526 mActionDetails->setChecked( state ); 526 mActionDetails->setChecked( state );
527 setDetailsVisible( state ); 527 setDetailsVisible( state );
528 528
529 state = KABPrefs::instance()->mJumpButtonBarVisible; 529 state = KABPrefs::instance()->mJumpButtonBarVisible;
530 530
531 mActionJumpBar->setChecked( state ); 531 mActionJumpBar->setChecked( state );
532 setJumpButtonBarVisible( state ); 532 setJumpButtonBarVisible( state );
533/*US 533/*US
534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
535 if ( splitterSize.count() == 0 ) { 535 if ( splitterSize.count() == 0 ) {
536 splitterSize.append( width() / 2 ); 536 splitterSize.append( width() / 2 );
537 splitterSize.append( width() / 2 ); 537 splitterSize.append( width() / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( splitterSize.count() == 0 ) { 542 if ( splitterSize.count() == 0 ) {
543 splitterSize.append( width() / 2 ); 543 splitterSize.append( width() / 2 );
544 splitterSize.append( width() / 2 ); 544 splitterSize.append( width() / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549*/ 549*/
550 mViewManager->restoreSettings(); 550 mViewManager->restoreSettings();
551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 551 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
552 mExtensionManager->restoreSettings(); 552 mExtensionManager->restoreSettings();
553#ifdef DESKTOP_VERSION 553#ifdef DESKTOP_VERSION
554 int wid = width(); 554 int wid = width();
555 if ( wid < 10 ) 555 if ( wid < 10 )
556 wid = 400; 556 wid = 400;
557#else 557#else
558 int wid = QApplication::desktop()->width(); 558 int wid = QApplication::desktop()->width();
559 if ( wid < 640 ) 559 if ( wid < 640 )
560 wid = QApplication::desktop()->height(); 560 wid = QApplication::desktop()->height();
561#endif 561#endif
562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 562 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
563 if ( true /*splitterSize.count() == 0*/ ) { 563 if ( true /*splitterSize.count() == 0*/ ) {
564 splitterSize.append( wid / 2 ); 564 splitterSize.append( wid / 2 );
565 splitterSize.append( wid / 2 ); 565 splitterSize.append( wid / 2 );
566 } 566 }
567 mMiniSplitter->setSizes( splitterSize ); 567 mMiniSplitter->setSizes( splitterSize );
568 if ( mExtensionBarSplitter ) { 568 if ( mExtensionBarSplitter ) {
569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 569 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
570 if ( true /*splitterSize.count() == 0*/ ) { 570 if ( true /*splitterSize.count() == 0*/ ) {
571 splitterSize.append( wid / 2 ); 571 splitterSize.append( wid / 2 );
572 splitterSize.append( wid / 2 ); 572 splitterSize.append( wid / 2 );
573 } 573 }
574 mExtensionBarSplitter->setSizes( splitterSize ); 574 mExtensionBarSplitter->setSizes( splitterSize );
575 575
576 } 576 }
577#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
578 KConfig *config = KABPrefs::instance()->getConfig(); 578 KConfig *config = KABPrefs::instance()->getConfig();
579 config->setGroup("WidgetLayout"); 579 config->setGroup("WidgetLayout");
580 QStringList list; 580 QStringList list;
581 list = config->readListEntry("MainLayout"); 581 list = config->readListEntry("MainLayout");
582 int x,y,w,h; 582 int x,y,w,h;
583 if ( ! list.isEmpty() ) { 583 if ( ! list.isEmpty() ) {
584 x = list[0].toInt(); 584 x = list[0].toInt();
585 y = list[1].toInt(); 585 y = list[1].toInt();
586 w = list[2].toInt(); 586 w = list[2].toInt();
587 h = list[3].toInt(); 587 h = list[3].toInt();
588 KApplication::testCoords( &x,&y,&w,&h ); 588 KApplication::testCoords( &x,&y,&w,&h );
589 topLevelWidget()->setGeometry(x,y,w,h); 589 topLevelWidget()->setGeometry(x,y,w,h);
590 590
591 } else { 591 } else {
592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
593 } 593 }
594#endif 594#endif
595} 595}
596 596
597void KABCore::saveSettings() 597void KABCore::saveSettings()
598{ 598{
599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 599 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
600 if ( mExtensionBarSplitter ) 600 if ( mExtensionBarSplitter )
601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 601 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 602 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 603 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
604#ifndef KAB_EMBEDDED 604#ifndef KAB_EMBEDDED
605 605
606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 606 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 607 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
608#endif //KAB_EMBEDDED 608#endif //KAB_EMBEDDED
609 mExtensionManager->saveSettings(); 609 mExtensionManager->saveSettings();
610 mViewManager->saveSettings(); 610 mViewManager->saveSettings();
611 611
612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 612 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
613 613
614 KABPrefs::instance()->writeConfig(); 614 KABPrefs::instance()->writeConfig();
615 //qDebug("KA: KABCore::saveSettings() "); 615 //qDebug("KA: KABCore::saveSettings() ");
616} 616}
617 617
618KABC::AddressBook *KABCore::addressBook() const 618KABC::AddressBook *KABCore::addressBook() const
619{ 619{
620 return mAddressBook; 620 return mAddressBook;
621} 621}
622 622
623KConfig *KABCore::config() 623KConfig *KABCore::config()
624{ 624{
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626 return KABPrefs::instance()->config(); 626 return KABPrefs::instance()->config();
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628 return KABPrefs::instance()->getConfig(); 628 return KABPrefs::instance()->getConfig();
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630} 630}
631 631
632KActionCollection *KABCore::actionCollection() const 632KActionCollection *KABCore::actionCollection() const
633{ 633{
634 return mGUIClient->actionCollection(); 634 return mGUIClient->actionCollection();
635} 635}
636 636
637KABC::Field *KABCore::currentSearchField() const 637KABC::Field *KABCore::currentSearchField() const
638{ 638{
639 if (mIncSearchWidget) 639 if (mIncSearchWidget)
640 return mIncSearchWidget->currentField(); 640 return mIncSearchWidget->currentField();
641 else 641 else
642 return 0; 642 return 0;
643} 643}
644 644
645QStringList KABCore::selectedUIDs() const 645QStringList KABCore::selectedUIDs() const
646{ 646{
647 return mViewManager->selectedUids(); 647 return mViewManager->selectedUids();
648} 648}
649 649
650KABC::Resource *KABCore::requestResource( QWidget *parent ) 650KABC::Resource *KABCore::requestResource( QWidget *parent )
651{ 651{
652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 652 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
653 653
654 QPtrList<KRES::Resource> kresResources; 654 QPtrList<KRES::Resource> kresResources;
655 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 655 QPtrListIterator<KABC::Resource> resIt( kabcResources );
656 KABC::Resource *resource; 656 KABC::Resource *resource;
657 while ( ( resource = resIt.current() ) != 0 ) { 657 while ( ( resource = resIt.current() ) != 0 ) {
658 ++resIt; 658 ++resIt;
659 if ( !resource->readOnly() ) { 659 if ( !resource->readOnly() ) {
660 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 660 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
661 if ( res ) 661 if ( res )
662 kresResources.append( res ); 662 kresResources.append( res );
663 } 663 }
664 } 664 }
665 665
666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 666 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
667 return static_cast<KABC::Resource*>( res ); 667 return static_cast<KABC::Resource*>( res );
668} 668}
669 669
670#ifndef KAB_EMBEDDED 670#ifndef KAB_EMBEDDED
671KAboutData *KABCore::createAboutData() 671KAboutData *KABCore::createAboutData()
672#else //KAB_EMBEDDED 672#else //KAB_EMBEDDED
673void KABCore::createAboutData() 673void KABCore::createAboutData()
674#endif //KAB_EMBEDDED 674#endif //KAB_EMBEDDED
675{ 675{
676 676
677 677
678 QString version; 678 QString version;
679#include <../version> 679#include <../version>
680 QMessageBox::about( this, "About KAddressbook/Pi", 680 QMessageBox::about( this, "About KAddressbook/Pi",
681 "KAddressbook/Platform-independent\n" 681 "KAddressbook/Platform-independent\n"
682 "(KA/Pi) " +version + " - " + 682 "(KA/Pi) " +version + " - " +
683#ifdef DESKTOP_VERSION 683#ifdef DESKTOP_VERSION
684 "Desktop Edition\n" 684 "Desktop Edition\n"
685#else 685#else
686 "PDA-Edition\n" 686 "PDA-Edition\n"
687 "for: Zaurus 5500 / 7x0 / 8x0\n" 687 "for: Zaurus 5500 / 7x0 / 8x0\n"
688#endif 688#endif
689 689
690 "(c) 2004 Ulf Schenk\n" 690 "(c) 2004 Ulf Schenk\n"
691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 691 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
692 "(c) 1997-2003, The KDE PIM Team\n" 692 "(c) 1997-2003, The KDE PIM Team\n"
693 "Tobias Koenig Maintainer\n" 693 "Tobias Koenig Maintainer\n"
694 "Don Sanders Original author\n" 694 "Don Sanders Original author\n"
695 "Cornelius Schumacher Co-maintainer\n" 695 "Cornelius Schumacher Co-maintainer\n"
696 "Mike Pilone GUI and framework redesign\n" 696 "Mike Pilone GUI and framework redesign\n"
697 "Greg Stern DCOP interface\n" 697 "Greg Stern DCOP interface\n"
698 "Mark Westcot Contact pinning\n" 698 "Mark Westcot Contact pinning\n"
699 "Michel Boyer de la Giroday LDAP Lookup\n" 699 "Michel Boyer de la Giroday LDAP Lookup\n"
700 "Steffen Hansen LDAP Lookup" 700 "Steffen Hansen LDAP Lookup"
701#ifdef _WIN32_ 701#ifdef _WIN32_
702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 702 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
703#endif 703#endif
704 ); 704 );
705} 705}
706 706
707void KABCore::setContactSelected( const QString &uid ) 707void KABCore::setContactSelected( const QString &uid )
708{ 708{
709 KABC::Addressee addr = mAddressBook->findByUid( uid ); 709 KABC::Addressee addr = mAddressBook->findByUid( uid );
710 if ( !mDetails->isHidden() ) 710 if ( !mDetails->isHidden() )
711 mDetails->setAddressee( addr ); 711 mDetails->setAddressee( addr );
712 712
713 if ( !addr.isEmpty() ) { 713 if ( !addr.isEmpty() ) {
714 emit contactSelected( addr.formattedName() ); 714 emit contactSelected( addr.formattedName() );
715 KABC::Picture pic = addr.photo(); 715 KABC::Picture pic = addr.photo();
716 if ( pic.isIntern() ) { 716 if ( pic.isIntern() ) {
717//US emit contactSelected( pic.data() ); 717//US emit contactSelected( pic.data() );
718//US instead use: 718//US instead use:
719 QPixmap px; 719 QPixmap px;
720 if (pic.data().isNull() != true) 720 if (pic.data().isNull() != true)
721 { 721 {
722 px.convertFromImage(pic.data()); 722 px.convertFromImage(pic.data());
723 } 723 }
724 724
725 emit contactSelected( px ); 725 emit contactSelected( px );
726 } 726 }
727 } 727 }
728 728
729 729
730 mExtensionManager->setSelectionChanged(); 730 mExtensionManager->setSelectionChanged();
731 731
732 // update the actions 732 // update the actions
733 bool selected = !uid.isEmpty(); 733 bool selected = !uid.isEmpty();
734 734
735 if ( mReadWrite ) { 735 if ( mReadWrite ) {
736 mActionCut->setEnabled( selected ); 736 mActionCut->setEnabled( selected );
737 mActionPaste->setEnabled( selected ); 737 mActionPaste->setEnabled( selected );
738 } 738 }
739 739
740 mActionCopy->setEnabled( selected ); 740 mActionCopy->setEnabled( selected );
741 mActionDelete->setEnabled( selected ); 741 mActionDelete->setEnabled( selected );
742 mActionEditAddressee->setEnabled( selected ); 742 mActionEditAddressee->setEnabled( selected );
743 mActionMail->setEnabled( selected ); 743 mActionMail->setEnabled( selected );
744 mActionMailVCard->setEnabled( selected ); 744 mActionMailVCard->setEnabled( selected );
745 //if (mActionBeam) 745 //if (mActionBeam)
746 //mActionBeam->setEnabled( selected ); 746 //mActionBeam->setEnabled( selected );
747 mActionWhoAmI->setEnabled( selected ); 747 mActionWhoAmI->setEnabled( selected );
748} 748}
749 749
750void KABCore::sendMail() 750void KABCore::sendMail()
751{ 751{
752 sendMail( mViewManager->selectedEmails().join( ", " ) ); 752 sendMail( mViewManager->selectedEmails().join( ", " ) );
753} 753}
754 754
755void KABCore::sendMail( const QString& emaillist ) 755void KABCore::sendMail( const QString& emaillist )
756{ 756{
757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 757 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
758 if (emaillist.contains(",") > 0) 758 if (emaillist.contains(",") > 0)
759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 759 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
760 else 760 else
761 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 761 ExternalAppHandler::instance()->mailToOneContact( emaillist );
762} 762}
763 763
764 764
765 765
766void KABCore::mailVCard() 766void KABCore::mailVCard()
767{ 767{
768 QStringList uids = mViewManager->selectedUids(); 768 QStringList uids = mViewManager->selectedUids();
769 if ( !uids.isEmpty() ) 769 if ( !uids.isEmpty() )
770 mailVCard( uids ); 770 mailVCard( uids );
771} 771}
772 772
773void KABCore::mailVCard( const QStringList& uids ) 773void KABCore::mailVCard( const QStringList& uids )
774{ 774{
775 QStringList urls; 775 QStringList urls;
776 776
777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 777// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
778 778
779 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 779 QString dirName = "/tmp/" + KApplication::randomString( 8 );
780 780
781 781
782 782
783 QDir().mkdir( dirName, true ); 783 QDir().mkdir( dirName, true );
784 784
785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 785 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
786 KABC::Addressee a = mAddressBook->findByUid( *it ); 786 KABC::Addressee a = mAddressBook->findByUid( *it );
787 787
788 if ( a.isEmpty() ) 788 if ( a.isEmpty() )
789 continue; 789 continue;
790 790
791 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 791 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
792 792
793 QString fileName = dirName + "/" + name; 793 QString fileName = dirName + "/" + name;
794 794
795 QFile outFile(fileName); 795 QFile outFile(fileName);
796 796
797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 797 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
798 KABC::VCardConverter converter; 798 KABC::VCardConverter converter;
799 QString vcard; 799 QString vcard;
800 800
801 converter.addresseeToVCard( a, vcard ); 801 converter.addresseeToVCard( a, vcard );
802 802
803 QTextStream t( &outFile ); // use a text stream 803 QTextStream t( &outFile ); // use a text stream
804 t.setEncoding( QTextStream::UnicodeUTF8 ); 804 t.setEncoding( QTextStream::UnicodeUTF8 );
805 t << vcard; 805 t << vcard;
806 806
807 outFile.close(); 807 outFile.close();
808 808
809 urls.append( fileName ); 809 urls.append( fileName );
810 } 810 }
811 } 811 }
812 812
813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 813 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
814 814
815 815
816/*US 816/*US
817 kapp->invokeMailer( QString::null, QString::null, QString::null, 817 kapp->invokeMailer( QString::null, QString::null, QString::null,
818 QString::null, // subject 818 QString::null, // subject
819 QString::null, // body 819 QString::null, // body
820 QString::null, 820 QString::null,
821 urls ); // attachments 821 urls ); // attachments
822*/ 822*/
823 823
824} 824}
825 825
826/** 826/**
827 Beams the "WhoAmI contact. 827 Beams the "WhoAmI contact.
828*/ 828*/
829void KABCore::beamMySelf() 829void KABCore::beamMySelf()
830{ 830{
831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 831 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
832 if (!a.isEmpty()) 832 if (!a.isEmpty())
833 { 833 {
834 QStringList uids; 834 QStringList uids;
835 uids << a.uid(); 835 uids << a.uid();
836 836
837 beamVCard(uids); 837 beamVCard(uids);
838 } else { 838 } else {
839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 839 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
840 840
841 841
842 } 842 }
843} 843}
844void KABCore::updateMainWindow() 844void KABCore::updateMainWindow()
845{ 845{
846 mMainWindow->showMaximized(); 846 mMainWindow->showMaximized();
847 //mMainWindow->repaint(); 847 //mMainWindow->repaint();
848} 848}
849void KABCore::resizeEvent(QResizeEvent* e ) 849void KABCore::resizeEvent(QResizeEvent* e )
850{ 850{
851 if ( !mMiniSplitter ) { 851 if ( !mMiniSplitter ) {
852 QWidget::resizeEvent( e ); 852 QWidget::resizeEvent( e );
853 return; 853 return;
854 } 854 }
855#ifndef DESKTOP_VERSION 855#ifndef DESKTOP_VERSION
856 static int desktop_width = 0; 856 static int desktop_width = 0;
857 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() ); 857 //qDebug("KABCore::resizeEvent %d %d ",desktop_width,QApplication::desktop()->width() );
858 if ( desktop_width != QApplication::desktop()->width() ) 858 if ( desktop_width != QApplication::desktop()->width() )
859 if ( QApplication::desktop()->width() >= 480 ) { 859 if ( QApplication::desktop()->width() >= 480 ) {
860 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 860 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
861 //qDebug("640 "); 861 //qDebug("640 ");
862 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 862 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
863 //qDebug("switch V->H "); 863 //qDebug("switch V->H ");
864 mMiniSplitter->setOrientation( Qt::Horizontal); 864 mMiniSplitter->setOrientation( Qt::Horizontal);
865 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 865 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
866 } 866 }
867 if ( QApplication::desktop()->width() <= 640 ) { 867 if ( QApplication::desktop()->width() <= 640 ) {
868 bool shot = mMainWindow->isVisible(); 868 bool shot = mMainWindow->isVisible();
869 mMainWindow->showMinimized(); 869 mMainWindow->showMinimized();
870 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 870 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
871 mViewManager->getFilterAction()->setComboWidth( 150 ); 871 mViewManager->getFilterAction()->setComboWidth( 150 );
872 if ( mIncSearchWidget ) 872 if ( mIncSearchWidget )
873 mIncSearchWidget->setSize(); 873 mIncSearchWidget->setSize();
874 if ( shot ) 874 if ( shot )
875 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 875 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
876 } 876 }
877 877
878 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 878 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
879 //qDebug("480 "); 879 //qDebug("480 ");
880 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 880 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
881 //qDebug("switch H->V "); 881 //qDebug("switch H->V ");
882 mMiniSplitter->setOrientation( Qt::Vertical ); 882 mMiniSplitter->setOrientation( Qt::Vertical );
883 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 883 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
884 } 884 }
885 if ( QApplication::desktop()->width() <= 640 ) { 885 if ( QApplication::desktop()->width() <= 640 ) {
886 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 886 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
887 bool shot = mMainWindow->isVisible(); 887 bool shot = mMainWindow->isVisible();
888 mMainWindow->showMinimized(); 888 mMainWindow->showMinimized();
889 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 889 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
890 if ( mIncSearchWidget ) { 890 if ( mIncSearchWidget ) {
891 mIncSearchWidget->setSize(); 891 mIncSearchWidget->setSize();
892 } 892 }
893 } else { 893 } else {
894 mViewManager->getFilterAction()->setComboWidth( 0 ); 894 mViewManager->getFilterAction()->setComboWidth( 0 );
895 } 895 }
896 if ( shot ) 896 if ( shot )
897 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 897 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
898 } 898 }
899 } 899 }
900 } 900 }
901 desktop_width = QApplication::desktop()->width(); 901 desktop_width = QApplication::desktop()->width();
902#endif 902#endif
903 QWidget::resizeEvent( e ); 903 QWidget::resizeEvent( e );
904 904
905} 905}
906void KABCore::export2phone() 906void KABCore::export2phone()
907{ 907{
908 908
909 QStringList uids; 909 QStringList uids;
910 XXPortSelectDialog dlg( this, false, this ); 910 XXPortSelectDialog dlg( this, false, this );
911 if ( dlg.exec() ) 911 if ( dlg.exec() )
912 uids = dlg.uids(); 912 uids = dlg.uids();
913 else 913 else
914 return; 914 return;
915 if ( uids.isEmpty() ) 915 if ( uids.isEmpty() )
916 return; 916 return;
917 // qDebug("count %d ", uids.count()); 917 // qDebug("count %d ", uids.count());
918 918
919 KAex2phonePrefs ex2phone; 919 KAex2phonePrefs ex2phone;
920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 920 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 921 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 922 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
923 923
924 if ( !ex2phone.exec() ) { 924 if ( !ex2phone.exec() ) {
925 return; 925 return;
926 } 926 }
927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 927 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 928 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 929 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
930 930
931 931
932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 932 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
933 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 933 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
934 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 934 KPimGlobalPrefs::instance()->mEx2PhoneModel );
935 935
936 QString fileName = getPhoneFile(); 936 QString fileName = getPhoneFile();
937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 937 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
938 return; 938 return;
939 939
940 message(i18n("Exporting to phone...")); 940 message(i18n("Exporting to phone..."));
941 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 941 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
942 942
943} 943}
944QString KABCore::getPhoneFile() 944QString KABCore::getPhoneFile()
945{ 945{
946#ifdef DESKTOP_VERSION 946#ifdef DESKTOP_VERSION
947 return locateLocal("tmp", "phonefile.vcf"); 947 return locateLocal("tmp", "phonefile.vcf");
948#else 948#else
949 return "/tmp/phonefile.vcf"; 949 return "/tmp/phonefile.vcf";
950#endif 950#endif
951 951
952} 952}
953void KABCore::writeToPhone( ) 953void KABCore::writeToPhone( )
954{ 954{
955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 955 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
956 message(i18n("Export to phone finished!")); 956 message(i18n("Export to phone finished!"));
957 else 957 else
958 qDebug(i18n("KA: Error exporting to phone")); 958 qDebug(i18n("KA: Error exporting to phone"));
959} 959}
960void KABCore::beamVCard() 960void KABCore::beamVCard()
961{ 961{
962 QStringList uids; 962 QStringList uids;
963 XXPortSelectDialog dlg( this, false, this ); 963 XXPortSelectDialog dlg( this, false, this );
964 if ( dlg.exec() ) 964 if ( dlg.exec() )
965 uids = dlg.uids(); 965 uids = dlg.uids();
966 else 966 else
967 return; 967 return;
968 if ( uids.isEmpty() ) 968 if ( uids.isEmpty() )
969 return; 969 return;
970 beamVCard( uids ); 970 beamVCard( uids );
971} 971}
972 972
973 973
974void KABCore::beamVCard(const QStringList& uids) 974void KABCore::beamVCard(const QStringList& uids)
975{ 975{
976 976
977 // LR: we should use the /tmp dir on the Zaurus, 977 // LR: we should use the /tmp dir on the Zaurus,
978 // because: /tmp = RAM, (HOME)/kdepim = flash memory 978 // because: /tmp = RAM, (HOME)/kdepim = flash memory
979 979
980#ifdef DESKTOP_VERSION 980#ifdef DESKTOP_VERSION
981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 981 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
982#else 982#else
983 QString fileName = "/tmp/kapibeamfile.vcf"; 983 QString fileName = "/tmp/kapibeamfile.vcf";
984#endif 984#endif
985 985
986 KABC::VCardConverter converter; 986 KABC::VCardConverter converter;
987 QString description; 987 QString description;
988 QString datastream; 988 QString datastream;
989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 989 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
990 KABC::Addressee a = mAddressBook->findByUid( *it ); 990 KABC::Addressee a = mAddressBook->findByUid( *it );
991 991
992 if ( a.isEmpty() ) 992 if ( a.isEmpty() )
993 continue; 993 continue;
994 994
995 if (description.isEmpty()) 995 if (description.isEmpty())
996 description = a.formattedName(); 996 description = a.formattedName();
997 997
998 QString vcard; 998 QString vcard;
999 converter.addresseeToVCard( a, vcard ); 999 converter.addresseeToVCard( a, vcard );
1000 int start = 0; 1000 int start = 0;
1001 int next; 1001 int next;
1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 1002 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
1003 int semi = vcard.find(";", next); 1003 int semi = vcard.find(";", next);
1004 int dopp = vcard.find(":", next); 1004 int dopp = vcard.find(":", next);
1005 int sep; 1005 int sep;
1006 if ( semi < dopp && semi >= 0 ) 1006 if ( semi < dopp && semi >= 0 )
1007 sep = semi ; 1007 sep = semi ;
1008 else 1008 else
1009 sep = dopp; 1009 sep = dopp;
1010 datastream +=vcard.mid( start, next - start); 1010 datastream +=vcard.mid( start, next - start);
1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 1011 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
1012 start = sep; 1012 start = sep;
1013 } 1013 }
1014 datastream += vcard.mid( start,vcard.length() ); 1014 datastream += vcard.mid( start,vcard.length() );
1015 } 1015 }
1016#ifndef DESKTOP_VERSION 1016#ifndef DESKTOP_VERSION
1017 QFile outFile(fileName); 1017 QFile outFile(fileName);
1018 if ( outFile.open(IO_WriteOnly) ) { 1018 if ( outFile.open(IO_WriteOnly) ) {
1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 1019 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
1020 QTextStream t( &outFile ); // use a text stream 1020 QTextStream t( &outFile ); // use a text stream
1021 //t.setEncoding( QTextStream::UnicodeUTF8 ); 1021 //t.setEncoding( QTextStream::UnicodeUTF8 );
1022 t.setEncoding( QTextStream::Latin1 ); 1022 t.setEncoding( QTextStream::Latin1 );
1023 t <<datastream.latin1(); 1023 t <<datastream.latin1();
1024 outFile.close(); 1024 outFile.close();
1025 Ir *ir = new Ir( this ); 1025 Ir *ir = new Ir( this );
1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1026 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
1027 ir->send( fileName, description, "text/x-vCard" ); 1027 ir->send( fileName, description, "text/x-vCard" );
1028 } else { 1028 } else {
1029 qDebug("KA: Error open temp beam file "); 1029 qDebug("KA: Error open temp beam file ");
1030 return; 1030 return;
1031 } 1031 }
1032#endif 1032#endif
1033 1033
1034} 1034}
1035 1035
1036void KABCore::beamDone( Ir *ir ) 1036void KABCore::beamDone( Ir *ir )
1037{ 1037{
1038#ifndef DESKTOP_VERSION 1038#ifndef DESKTOP_VERSION
1039 delete ir; 1039 delete ir;
1040#endif 1040#endif
1041 topLevelWidget()->raise(); 1041 topLevelWidget()->raise();
1042 message( i18n("Beaming finished!") ); 1042 message( i18n("Beaming finished!") );
1043} 1043}
1044 1044
1045 1045
1046void KABCore::browse( const QString& url ) 1046void KABCore::browse( const QString& url )
1047{ 1047{
1048#ifndef KAB_EMBEDDED 1048#ifndef KAB_EMBEDDED
1049 kapp->invokeBrowser( url ); 1049 kapp->invokeBrowser( url );
1050#else //KAB_EMBEDDED 1050#else //KAB_EMBEDDED
1051 qDebug("KABCore::browse must be fixed"); 1051 qDebug("KABCore::browse must be fixed");
1052#endif //KAB_EMBEDDED 1052#endif //KAB_EMBEDDED
1053} 1053}
1054 1054
1055void KABCore::selectAllContacts() 1055void KABCore::selectAllContacts()
1056{ 1056{
1057 mViewManager->setSelected( QString::null, true ); 1057 mViewManager->setSelected( QString::null, true );
1058} 1058}
1059 1059
1060void KABCore::deleteContacts() 1060void KABCore::deleteContacts()
1061{ 1061{
1062 QStringList uidList = mViewManager->selectedUids(); 1062 QStringList uidList = mViewManager->selectedUids();
1063 deleteContacts( uidList ); 1063 deleteContacts( uidList );
1064} 1064}
1065 1065
1066void KABCore::deleteContacts( const QStringList &uids ) 1066void KABCore::deleteContacts( const QStringList &uids )
1067{ 1067{
1068 1068
1069 if ( uids.count() > 0 ) { 1069 if ( uids.count() > 0 ) {
1070 1070
1071 if ( KABPrefs::instance()->mAskForDelete ) { 1071 if ( KABPrefs::instance()->mAskForDelete ) {
1072 int count = uids.count(); 1072 int count = uids.count();
1073 if ( count > 5 ) count = 5; 1073 if ( count > 5 ) count = 5;
1074 QString cNames; 1074 QString cNames;
1075 int i; 1075 int i;
1076 for ( i = 0; i < count ; ++i ) { 1076 for ( i = 0; i < count ; ++i ) {
1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n"; 1077 cNames += KGlobal::formatMessage( mAddressBook->findByUid( uids[i] ).realName() ,0) + "\n";
1078 } 1078 }
1079 if ( uids.count() > 5 ) 1079 if ( uids.count() > 5 )
1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 ); 1080 cNames += i18n("...and %1 more\ncontact(s) selected").arg( uids.count() - 5 );
1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ; 1081 QString text = i18n( "Do you really\nwant to delete the\nsetected contact(s)?\n\n" ) + cNames ;
1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes ) 1082 if ( KMessageBox::questionYesNo( this, text ) != KMessageBox::Yes )
1083 return; 1083 return;
1084 } 1084 }
1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1085 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1086 UndoStack::instance()->push( command ); 1086 UndoStack::instance()->push( command );
1087 RedoStack::instance()->clear(); 1087 RedoStack::instance()->clear();
1088 1088
1089 // now if we deleted anything, refresh 1089 // now if we deleted anything, refresh
1090 setContactSelected( QString::null ); 1090 setContactSelected( QString::null );
1091 setModified( true ); 1091 setModified( true );
1092 } 1092 }
1093} 1093}
1094 1094
1095void KABCore::copyContacts() 1095void KABCore::copyContacts()
1096{ 1096{
1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1097 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1098 1098
1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1099 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1100 1100
1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1101 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1102 1102
1103 QClipboard *cb = QApplication::clipboard(); 1103 QClipboard *cb = QApplication::clipboard();
1104 cb->setText( clipText ); 1104 cb->setText( clipText );
1105} 1105}
1106 1106
1107void KABCore::cutContacts() 1107void KABCore::cutContacts()
1108{ 1108{
1109 QStringList uidList = mViewManager->selectedUids(); 1109 QStringList uidList = mViewManager->selectedUids();
1110 1110
1111//US if ( uidList.size() > 0 ) { 1111//US if ( uidList.size() > 0 ) {
1112 if ( uidList.count() > 0 ) { 1112 if ( uidList.count() > 0 ) {
1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1113 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1114 UndoStack::instance()->push( command ); 1114 UndoStack::instance()->push( command );
1115 RedoStack::instance()->clear(); 1115 RedoStack::instance()->clear();
1116 1116
1117 setModified( true ); 1117 setModified( true );
1118 } 1118 }
1119} 1119}
1120 1120
1121void KABCore::pasteContacts() 1121void KABCore::pasteContacts()
1122{ 1122{
1123 QClipboard *cb = QApplication::clipboard(); 1123 QClipboard *cb = QApplication::clipboard();
1124 1124
1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1125 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1126 1126
1127 pasteContacts( list ); 1127 pasteContacts( list );
1128} 1128}
1129 1129
1130void KABCore::pasteContacts( KABC::Addressee::List &list ) 1130void KABCore::pasteContacts( KABC::Addressee::List &list )
1131{ 1131{
1132 KABC::Resource *resource = requestResource( this ); 1132 KABC::Resource *resource = requestResource( this );
1133 KABC::Addressee::List::Iterator it; 1133 KABC::Addressee::List::Iterator it;
1134 for ( it = list.begin(); it != list.end(); ++it ) 1134 for ( it = list.begin(); it != list.end(); ++it )
1135 (*it).setResource( resource ); 1135 (*it).setResource( resource );
1136 1136
1137 PwPasteCommand *command = new PwPasteCommand( this, list ); 1137 PwPasteCommand *command = new PwPasteCommand( this, list );
1138 UndoStack::instance()->push( command ); 1138 UndoStack::instance()->push( command );
1139 RedoStack::instance()->clear(); 1139 RedoStack::instance()->clear();
1140 1140
1141 setModified( true ); 1141 setModified( true );
1142} 1142}
1143 1143
1144void KABCore::setWhoAmI() 1144void KABCore::setWhoAmI()
1145{ 1145{
1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1146 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1147 1147
1148 if ( addrList.count() > 1 ) { 1148 if ( addrList.count() > 1 ) {
1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1149 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1150 return; 1150 return;
1151 } 1151 }
1152 1152
1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1153 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes ) 1154 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].realName() ) ) == KMessageBox::Yes )
1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1155 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1156} 1156}
1157void KABCore::editCategories() 1157void KABCore::editCategories()
1158{ 1158{
1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1159 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1160 dlg.exec(); 1160 dlg.exec();
1161} 1161}
1162void KABCore::setCategories() 1162void KABCore::setCategories()
1163{ 1163{
1164 1164
1165 QStringList uids; 1165 QStringList uids;
1166 XXPortSelectDialog dlgx( this, false, this ); 1166 XXPortSelectDialog dlgx( this, false, this );
1167 if ( dlgx.exec() ) 1167 if ( dlgx.exec() )
1168 uids = dlgx.uids(); 1168 uids = dlgx.uids();
1169 else 1169 else
1170 return; 1170 return;
1171 if ( uids.isEmpty() ) 1171 if ( uids.isEmpty() )
1172 return; 1172 return;
1173 // qDebug("count %d ", uids.count()); 1173 // qDebug("count %d ", uids.count());
1174 1174
1175 1175
1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1176 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1177 if ( !dlg.exec() ) { 1177 if ( !dlg.exec() ) {
1178 message( i18n("Setting categories cancelled") ); 1178 message( i18n("Setting categories cancelled") );
1179 return; 1179 return;
1180 } 1180 }
1181 bool merge = false; 1181 bool merge = false;
1182 QString msg = i18n( "Merge with existing categories?" ); 1182 QString msg = i18n( "Merge with existing categories?" );
1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1183 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1184 merge = true; 1184 merge = true;
1185 1185
1186 message( i18n("Setting categories ... please wait!") ); 1186 message( i18n("Setting categories ... please wait!") );
1187 QStringList categories = dlg.selectedCategories(); 1187 QStringList categories = dlg.selectedCategories();
1188 1188
1189 //QStringList uids = mViewManager->selectedUids(); 1189 //QStringList uids = mViewManager->selectedUids();
1190 QStringList::Iterator it; 1190 QStringList::Iterator it;
1191 for ( it = uids.begin(); it != uids.end(); ++it ) { 1191 for ( it = uids.begin(); it != uids.end(); ++it ) {
1192 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1192 KABC::Addressee addr = mAddressBook->findByUid( *it );
1193 if ( !addr.isEmpty() ) { 1193 if ( !addr.isEmpty() ) {
1194 if ( !merge ) 1194 if ( !merge )
1195 addr.setCategories( categories ); 1195 addr.setCategories( categories );
1196 else { 1196 else {
1197 QStringList addrCategories = addr.categories(); 1197 QStringList addrCategories = addr.categories();
1198 QStringList::Iterator catIt; 1198 QStringList::Iterator catIt;
1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1199 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1200 if ( !addrCategories.contains( *catIt ) ) 1200 if ( !addrCategories.contains( *catIt ) )
1201 addrCategories.append( *catIt ); 1201 addrCategories.append( *catIt );
1202 } 1202 }
1203 addr.setCategories( addrCategories ); 1203 addr.setCategories( addrCategories );
1204 } 1204 }
1205 mAddressBook->insertAddressee( addr ); 1205 mAddressBook->insertAddressee( addr );
1206 } 1206 }
1207 } 1207 }
1208 1208
1209 if ( uids.count() > 0 ) 1209 if ( uids.count() > 0 )
1210 setModified( true ); 1210 setModified( true );
1211 message( i18n("Setting categories completed!") ); 1211 message( i18n("Setting categories completed!") );
1212} 1212}
1213 1213
1214void KABCore::setSearchFields( const KABC::Field::List &fields ) 1214void KABCore::setSearchFields( const KABC::Field::List &fields )
1215{ 1215{
1216 mIncSearchWidget->setFields( fields ); 1216 mIncSearchWidget->setFields( fields );
1217} 1217}
1218 1218
1219void KABCore::incrementalSearch( const QString& text ) 1219void KABCore::incrementalSearch( const QString& text )
1220{ 1220{
1221 QString stext; 1221 QString stext;
1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1222 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1223 stext = "*" + text; 1223 stext = "*" + text;
1224 } else { 1224 } else {
1225 stext = text; 1225 stext = text;
1226 } 1226 }
1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1227 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1228} 1228}
1229void KABCore::incrementalSearchJump( const QString& text ) 1229void KABCore::incrementalSearchJump( const QString& text )
1230{ 1230{
1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1231 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1232} 1232}
1233 1233
1234void KABCore::setModified() 1234void KABCore::setModified()
1235{ 1235{
1236 setModified( true ); 1236 setModified( true );
1237} 1237}
1238 1238
1239void KABCore::setModifiedWOrefresh() 1239void KABCore::setModifiedWOrefresh()
1240{ 1240{
1241 // qDebug("KABCore::setModifiedWOrefresh() "); 1241 // qDebug("KABCore::setModifiedWOrefresh() ");
1242 mModified = true; 1242 mModified = true;
1243 mActionSave->setEnabled( mModified ); 1243 mActionSave->setEnabled( mModified );
1244 1244
1245 1245
1246} 1246}
1247void KABCore::setModified( bool modified ) 1247void KABCore::setModified( bool modified )
1248{ 1248{
1249 mModified = modified; 1249 mModified = modified;
1250 mActionSave->setEnabled( mModified ); 1250 mActionSave->setEnabled( mModified );
1251 1251
1252 if ( modified ) 1252 if ( modified )
1253 mJumpButtonBar->recreateButtons(); 1253 mJumpButtonBar->recreateButtons();
1254 1254
1255 mViewManager->refreshView(); 1255 mViewManager->refreshView();
1256 1256
1257} 1257}
1258 1258
1259bool KABCore::modified() const 1259bool KABCore::modified() const
1260{ 1260{
1261 return mModified; 1261 return mModified;
1262} 1262}
1263 1263
1264void KABCore::contactModified( const KABC::Addressee &addr ) 1264void KABCore::contactModified( const KABC::Addressee &addr )
1265{ 1265{
1266 addrModified( addr ); 1266 addrModified( addr );
1267#if 0 // debug only 1267#if 0 // debug only
1268 KABC::Addressee ad = addr; 1268 KABC::Addressee ad = addr;
1269 ad.computeCsum( "123"); 1269 ad.computeCsum( "123");
1270#endif 1270#endif
1271} 1271}
1272 1272
1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1273void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1274{ 1274{
1275 1275
1276 Command *command = 0; 1276 Command *command = 0;
1277 QString uid; 1277 QString uid;
1278 1278
1279 // check if it exists already 1279 // check if it exists already
1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1280 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1281 if ( origAddr.isEmpty() ) 1281 if ( origAddr.isEmpty() )
1282 command = new PwNewCommand( mAddressBook, addr ); 1282 command = new PwNewCommand( mAddressBook, addr );
1283 else { 1283 else {
1284 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1284 command = new PwEditCommand( mAddressBook, origAddr, addr );
1285 uid = addr.uid(); 1285 uid = addr.uid();
1286 } 1286 }
1287 1287
1288 UndoStack::instance()->push( command ); 1288 UndoStack::instance()->push( command );
1289 RedoStack::instance()->clear(); 1289 RedoStack::instance()->clear();
1290 if ( updateDetails ) 1290 if ( updateDetails )
1291 mDetails->setAddressee( addr ); 1291 mDetails->setAddressee( addr );
1292 setModified( true ); 1292 setModified( true );
1293} 1293}
1294 1294
1295void KABCore::newContact() 1295void KABCore::newContact()
1296{ 1296{
1297 1297
1298 1298
1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1299 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1300 1300
1301 QPtrList<KRES::Resource> kresResources; 1301 QPtrList<KRES::Resource> kresResources;
1302 QPtrListIterator<KABC::Resource> it( kabcResources ); 1302 QPtrListIterator<KABC::Resource> it( kabcResources );
1303 KABC::Resource *resource; 1303 KABC::Resource *resource;
1304 while ( ( resource = it.current() ) != 0 ) { 1304 while ( ( resource = it.current() ) != 0 ) {
1305 ++it; 1305 ++it;
1306 if ( !resource->readOnly() ) { 1306 if ( !resource->readOnly() ) {
1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1307 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1308 if ( res ) 1308 if ( res )
1309 kresResources.append( res ); 1309 kresResources.append( res );
1310 } 1310 }
1311 } 1311 }
1312 1312
1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1313 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1314 resource = static_cast<KABC::Resource*>( res ); 1314 resource = static_cast<KABC::Resource*>( res );
1315 1315
1316 if ( resource ) { 1316 if ( resource ) {
1317 KABC::Addressee addr; 1317 KABC::Addressee addr;
1318 addr.setResource( resource ); 1318 addr.setResource( resource );
1319 mEditorDialog->setAddressee( addr ); 1319 mEditorDialog->setAddressee( addr );
1320 mEditorDialog->setCaption( i18n("Edit new contact")); 1320 mEditorDialog->setCaption( i18n("Edit new contact"));
1321 KApplication::execDialog ( mEditorDialog ); 1321 KApplication::execDialog ( mEditorDialog );
1322 1322
1323 } else 1323 } else
1324 return; 1324 return;
1325 1325
1326 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1326 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1327 1327
1328 1328
1329} 1329}
1330 1330
1331void KABCore::addEmail( QString aStr ) 1331void KABCore::addEmail( QString aStr )
1332{ 1332{
1333#ifndef KAB_EMBEDDED 1333#ifndef KAB_EMBEDDED
1334 QString fullName, email; 1334 QString fullName, email;
1335 1335
1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1336 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1337 1337
1338 // Try to lookup the addressee matching the email address 1338 // Try to lookup the addressee matching the email address
1339 bool found = false; 1339 bool found = false;
1340 QStringList emailList; 1340 QStringList emailList;
1341 KABC::AddressBook::Iterator it; 1341 KABC::AddressBook::Iterator it;
1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1342 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1343 emailList = (*it).emails(); 1343 emailList = (*it).emails();
1344 if ( emailList.contains( email ) > 0 ) { 1344 if ( emailList.contains( email ) > 0 ) {
1345 found = true; 1345 found = true;
1346 (*it).setNameFromString( fullName ); 1346 (*it).setNameFromString( fullName );
1347 editContact( (*it).uid() ); 1347 editContact( (*it).uid() );
1348 } 1348 }
1349 } 1349 }
1350 1350
1351 if ( !found ) { 1351 if ( !found ) {
1352 KABC::Addressee addr; 1352 KABC::Addressee addr;
1353 addr.setNameFromString( fullName ); 1353 addr.setNameFromString( fullName );
1354 addr.insertEmail( email, true ); 1354 addr.insertEmail( email, true );
1355 1355
1356 mAddressBook->insertAddressee( addr ); 1356 mAddressBook->insertAddressee( addr );
1357 mViewManager->refreshView( addr.uid() ); 1357 mViewManager->refreshView( addr.uid() );
1358 editContact( addr.uid() ); 1358 editContact( addr.uid() );
1359 } 1359 }
1360#else //KAB_EMBEDDED 1360#else //KAB_EMBEDDED
1361 qDebug("KABCore::addEmail finsih method"); 1361 qDebug("KABCore::addEmail finsih method");
1362#endif //KAB_EMBEDDED 1362#endif //KAB_EMBEDDED
1363} 1363}
1364 1364
1365void KABCore::importVCard( const KURL &url, bool showPreview ) 1365void KABCore::importVCard( const KURL &url, bool showPreview )
1366{ 1366{
1367 mXXPortManager->importVCard( url, showPreview ); 1367 mXXPortManager->importVCard( url, showPreview );
1368} 1368}
1369void KABCore::importFromOL() 1369void KABCore::importFromOL()
1370{ 1370{
1371#ifdef _OL_IMPORT_ 1371#ifdef _OL_IMPORT_
1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1372 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1373 idgl->exec(); 1373 idgl->exec();
1374 KABC::Addressee::List list = idgl->getAddressList(); 1374 KABC::Addressee::List list = idgl->getAddressList();
1375 if ( list.count() > 0 ) { 1375 if ( list.count() > 0 ) {
1376 KABC::Addressee::List listNew; 1376 KABC::Addressee::List listNew;
1377 KABC::Addressee::List listExisting; 1377 KABC::Addressee::List listExisting;
1378 KABC::Addressee::List::Iterator it; 1378 KABC::Addressee::List::Iterator it;
1379 KABC::AddressBook::Iterator iter; 1379 KABC::AddressBook::Iterator iter;
1380 for ( it = list.begin(); it != list.end(); ++it ) { 1380 for ( it = list.begin(); it != list.end(); ++it ) {
1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1381 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1382 listNew.append( (*it) ); 1382 listNew.append( (*it) );
1383 else 1383 else
1384 listExisting.append( (*it) ); 1384 listExisting.append( (*it) );
1385 } 1385 }
1386 if ( listExisting.count() > 0 ) 1386 if ( listExisting.count() > 0 )
1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1387 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1388 if ( listNew.count() > 0 ) { 1388 if ( listNew.count() > 0 ) {
1389 pasteWithNewUid = false; 1389 pasteWithNewUid = false;
1390 pasteContacts( listNew ); 1390 pasteContacts( listNew );
1391 pasteWithNewUid = true; 1391 pasteWithNewUid = true;
1392 } 1392 }
1393 } 1393 }
1394 delete idgl; 1394 delete idgl;
1395#endif 1395#endif
1396} 1396}
1397 1397
1398void KABCore::importVCard( const QString &vCard, bool showPreview ) 1398void KABCore::importVCard( const QString &vCard, bool showPreview )
1399{ 1399{
1400 mXXPortManager->importVCard( vCard, showPreview ); 1400 mXXPortManager->importVCard( vCard, showPreview );
1401} 1401}
1402 1402
1403//US added a second method without defaultparameter 1403//US added a second method without defaultparameter
1404void KABCore::editContact2() { 1404void KABCore::editContact2() {
1405 editContact( QString::null ); 1405 editContact( QString::null );
1406} 1406}
1407 1407
1408void KABCore::editContact( const QString &uid ) 1408void KABCore::editContact( const QString &uid )
1409{ 1409{
1410 1410
1411 if ( mExtensionManager->isQuickEditVisible() ) 1411 if ( mExtensionManager->isQuickEditVisible() )
1412 return; 1412 return;
1413 1413
1414 // First, locate the contact entry 1414 // First, locate the contact entry
1415 QString localUID = uid; 1415 QString localUID = uid;
1416 if ( localUID.isNull() ) { 1416 if ( localUID.isNull() ) {
1417 QStringList uidList = mViewManager->selectedUids(); 1417 QStringList uidList = mViewManager->selectedUids();
1418 if ( uidList.count() > 0 ) 1418 if ( uidList.count() > 0 )
1419 localUID = *( uidList.at( 0 ) ); 1419 localUID = *( uidList.at( 0 ) );
1420 } 1420 }
1421 1421
1422 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1422 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1423 if ( !addr.isEmpty() ) { 1423 if ( !addr.isEmpty() ) {
1424 mEditorDialog->setAddressee( addr ); 1424 mEditorDialog->setAddressee( addr );
1425 KApplication::execDialog ( mEditorDialog ); 1425 KApplication::execDialog ( mEditorDialog );
1426 } 1426 }
1427} 1427}
1428 1428
1429/** 1429/**
1430 Shows or edits the detail view for the given uid. If the uid is QString::null, 1430 Shows or edits the detail view for the given uid. If the uid is QString::null,
1431 the method will try to find a selected addressee in the view. 1431 the method will try to find a selected addressee in the view.
1432 */ 1432 */
1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1433void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1434{ 1434{
1435 if ( mMultipleViewsAtOnce ) 1435 if ( mMultipleViewsAtOnce )
1436 { 1436 {
1437 editContact( uid ); 1437 editContact( uid );
1438 } 1438 }
1439 else 1439 else
1440 { 1440 {
1441 setDetailsVisible( true ); 1441 setDetailsVisible( true );
1442 mActionDetails->setChecked(true); 1442 mActionDetails->setChecked(true);
1443 } 1443 }
1444 1444
1445} 1445}
1446 1446
1447void KABCore::save() 1447void KABCore::save()
1448{ 1448{
1449 if (syncManager->blockSave()) 1449 if (syncManager->blockSave())
1450 return; 1450 return;
1451 if ( !mModified ) 1451 if ( !mModified )
1452 return; 1452 return;
1453 1453
1454 syncManager->setBlockSave(true); 1454 syncManager->setBlockSave(true);
1455 QString text = i18n( "There was an error while attempting to save\n the " 1455 QString text = i18n( "There was an error while attempting to save\n the "
1456 "address book. Please check that some \nother application is " 1456 "address book. Please check that some \nother application is "
1457 "not using it. " ); 1457 "not using it. " );
1458 message(i18n("Saving ... please wait! "), false); 1458 message(i18n("Saving ... please wait! "), false);
1459 //qApp->processEvents(); 1459 //qApp->processEvents();
1460#ifndef KAB_EMBEDDED 1460#ifndef KAB_EMBEDDED
1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1461 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1462 if ( !b || !b->save() ) { 1462 if ( !b || !b->save() ) {
1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1463 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1464 } 1464 }
1465#else //KAB_EMBEDDED 1465#else //KAB_EMBEDDED
1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1466 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1467 if ( !b || !b->save() ) { 1467 if ( !b || !b->save() ) {
1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1468 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1469 } 1469 }
1470#endif //KAB_EMBEDDED 1470#endif //KAB_EMBEDDED
1471 1471
1472 message(i18n("Addressbook saved!")); 1472 message(i18n("Addressbook saved!"));
1473 setModified( false ); 1473 setModified( false );
1474 syncManager->setBlockSave(false); 1474 syncManager->setBlockSave(false);
1475} 1475}
1476 1476
1477 1477
1478void KABCore::undo() 1478void KABCore::undo()
1479{ 1479{
1480 UndoStack::instance()->undo(); 1480 UndoStack::instance()->undo();
1481 1481
1482 // Refresh the view 1482 // Refresh the view
1483 mViewManager->refreshView(); 1483 mViewManager->refreshView();
1484} 1484}
1485 1485
1486void KABCore::redo() 1486void KABCore::redo()
1487{ 1487{
1488 RedoStack::instance()->redo(); 1488 RedoStack::instance()->redo();
1489 1489
1490 // Refresh the view 1490 // Refresh the view
1491 mViewManager->refreshView(); 1491 mViewManager->refreshView();
1492} 1492}
1493void KABCore::setJumpButtonBar( bool visible ) 1493void KABCore::setJumpButtonBar( bool visible )
1494{ 1494{
1495 setJumpButtonBarVisible(visible ); 1495 setJumpButtonBarVisible(visible );
1496 saveSettings(); 1496 saveSettings();
1497} 1497}
1498void KABCore::setJumpButtonBarVisible( bool visible ) 1498void KABCore::setJumpButtonBarVisible( bool visible )
1499{ 1499{
1500 if (mMultipleViewsAtOnce) 1500 if (mMultipleViewsAtOnce)
1501 { 1501 {
1502 if ( visible ) 1502 if ( visible )
1503 mJumpButtonBar->show(); 1503 mJumpButtonBar->show();
1504 else 1504 else
1505 mJumpButtonBar->hide(); 1505 mJumpButtonBar->hide();
1506 } 1506 }
1507 else 1507 else
1508 { 1508 {
1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1509 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1510 if (mViewManager->isVisible()) 1510 if (mViewManager->isVisible())
1511 { 1511 {
1512 if ( visible ) 1512 if ( visible )
1513 mJumpButtonBar->show(); 1513 mJumpButtonBar->show();
1514 else 1514 else
1515 mJumpButtonBar->hide(); 1515 mJumpButtonBar->hide();
1516 } 1516 }
1517 else 1517 else
1518 { 1518 {
1519 mJumpButtonBar->hide(); 1519 mJumpButtonBar->hide();
1520 } 1520 }
1521 } 1521 }
1522 if ( visible ) { 1522 if ( visible ) {
1523 if ( mIncSearchWidget->currentItem() == 0 ) { 1523 if ( mIncSearchWidget->currentItem() == 0 ) {
1524 message( i18n("Change search field enable jump bar") ); 1524 message( i18n("Change search field enable jump bar") );
1525 } 1525 }
1526 } 1526 }
1527} 1527}
1528 1528
1529 1529
1530void KABCore::setDetailsToState() 1530void KABCore::setDetailsToState()
1531{ 1531{
1532 setDetailsVisible( mActionDetails->isChecked() ); 1532 setDetailsVisible( mActionDetails->isChecked() );
1533} 1533}
1534void KABCore::setDetailsToggle() 1534void KABCore::setDetailsToggle()
1535{ 1535{
1536 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1536 mActionDetails->setChecked( !mActionDetails->isChecked() );
1537 setDetailsToState(); 1537 setDetailsToState();
1538} 1538}
1539 1539
1540 1540
1541 1541
1542void KABCore::setDetailsVisible( bool visible ) 1542void KABCore::setDetailsVisible( bool visible )
1543{ 1543{
1544 if (visible && mDetails->isHidden()) 1544 if (visible && mDetails->isHidden())
1545 { 1545 {
1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1546 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1547 if ( addrList.count() > 0 ) 1547 if ( addrList.count() > 0 )
1548 mDetails->setAddressee( addrList[ 0 ] ); 1548 mDetails->setAddressee( addrList[ 0 ] );
1549 } 1549 }
1550 1550
1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1551 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1552 // the listview and the detailview. We do that by changing the splitbar size. 1552 // the listview and the detailview. We do that by changing the splitbar size.
1553 if (mMultipleViewsAtOnce) 1553 if (mMultipleViewsAtOnce)
1554 { 1554 {
1555 if ( visible ) 1555 if ( visible )
1556 mDetails->show(); 1556 mDetails->show();
1557 else 1557 else
1558 mDetails->hide(); 1558 mDetails->hide();
1559 } 1559 }
1560 else 1560 else
1561 { 1561 {
1562 if ( visible ) { 1562 if ( visible ) {
1563 mViewManager->hide(); 1563 mViewManager->hide();
1564 mDetails->show(); 1564 mDetails->show();
1565 mIncSearchWidget->setFocus(); 1565 mIncSearchWidget->setFocus();
1566 } 1566 }
1567 else { 1567 else {
1568 mViewManager->show(); 1568 mViewManager->show();
1569 mDetails->hide(); 1569 mDetails->hide();
1570 mViewManager->setFocusAV(); 1570 mViewManager->setFocusAV();
1571 } 1571 }
1572 setJumpButtonBarVisible( !visible ); 1572 setJumpButtonBarVisible( !visible );
1573 } 1573 }
1574 1574
1575} 1575}
1576 1576
1577void KABCore::extensionChanged( int id ) 1577void KABCore::extensionChanged( int id )
1578{ 1578{
1579 //change the details view only for non desktop systems 1579 //change the details view only for non desktop systems
1580#ifndef DESKTOP_VERSION 1580#ifndef DESKTOP_VERSION
1581 1581
1582 if (id == 0) 1582 if (id == 0)
1583 { 1583 {
1584 //the user disabled the extension. 1584 //the user disabled the extension.
1585 1585
1586 if (mMultipleViewsAtOnce) 1586 if (mMultipleViewsAtOnce)
1587 { // enable detailsview again 1587 { // enable detailsview again
1588 setDetailsVisible( true ); 1588 setDetailsVisible( true );
1589 mActionDetails->setChecked( true ); 1589 mActionDetails->setChecked( true );
1590 } 1590 }
1591 else 1591 else
1592 { //go back to the listview 1592 { //go back to the listview
1593 setDetailsVisible( false ); 1593 setDetailsVisible( false );
1594 mActionDetails->setChecked( false ); 1594 mActionDetails->setChecked( false );
1595 mActionDetails->setEnabled(true); 1595 mActionDetails->setEnabled(true);
1596 } 1596 }
1597 1597
1598 } 1598 }
1599 else 1599 else
1600 { 1600 {
1601 //the user enabled the extension. 1601 //the user enabled the extension.
1602 setDetailsVisible( false ); 1602 setDetailsVisible( false );
1603 mActionDetails->setChecked( false ); 1603 mActionDetails->setChecked( false );
1604 1604
1605 if (!mMultipleViewsAtOnce) 1605 if (!mMultipleViewsAtOnce)
1606 { 1606 {
1607 mActionDetails->setEnabled(false); 1607 mActionDetails->setEnabled(false);
1608 } 1608 }
1609 1609
1610 mExtensionManager->setSelectionChanged(); 1610 mExtensionManager->setSelectionChanged();
1611 1611
1612 } 1612 }
1613 1613
1614#endif// DESKTOP_VERSION 1614#endif// DESKTOP_VERSION
1615 1615
1616} 1616}
1617 1617
1618 1618
1619void KABCore::extensionModified( const KABC::Addressee::List &list ) 1619void KABCore::extensionModified( const KABC::Addressee::List &list )
1620{ 1620{
1621 1621
1622 if ( list.count() != 0 ) { 1622 if ( list.count() != 0 ) {
1623 KABC::Addressee::List::ConstIterator it; 1623 KABC::Addressee::List::ConstIterator it;
1624 for ( it = list.begin(); it != list.end(); ++it ) 1624 for ( it = list.begin(); it != list.end(); ++it )
1625 mAddressBook->insertAddressee( *it ); 1625 mAddressBook->insertAddressee( *it );
1626 if ( list.count() > 1 ) 1626 if ( list.count() > 1 )
1627 setModified(); 1627 setModified();
1628 else 1628 else
1629 setModifiedWOrefresh(); 1629 setModifiedWOrefresh();
1630 } 1630 }
1631 if ( list.count() == 0 ) 1631 if ( list.count() == 0 )
1632 mViewManager->refreshView(); 1632 mViewManager->refreshView();
1633 else 1633 else
1634 mViewManager->refreshView( list[ 0 ].uid() ); 1634 mViewManager->refreshView( list[ 0 ].uid() );
1635 1635
1636 1636
1637 1637
1638} 1638}
1639 1639
1640QString KABCore::getNameByPhone( const QString &phone ) 1640QString KABCore::getNameByPhone( const QString &phone )
1641{ 1641{
1642#ifndef KAB_EMBEDDED 1642#ifndef KAB_EMBEDDED
1643 QRegExp r( "[/*/-/ ]" ); 1643 QRegExp r( "[/*/-/ ]" );
1644 QString localPhone( phone ); 1644 QString localPhone( phone );
1645 1645
1646 bool found = false; 1646 bool found = false;
1647 QString ownerName = ""; 1647 QString ownerName = "";
1648 KABC::AddressBook::Iterator iter; 1648 KABC::AddressBook::Iterator iter;
1649 KABC::PhoneNumber::List::Iterator phoneIter; 1649 KABC::PhoneNumber::List::Iterator phoneIter;
1650 KABC::PhoneNumber::List phoneList; 1650 KABC::PhoneNumber::List phoneList;
1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1651 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1652 phoneList = (*iter).phoneNumbers(); 1652 phoneList = (*iter).phoneNumbers();
1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1653 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1654 ++phoneIter) { 1654 ++phoneIter) {
1655 // Get rid of separator chars so just the numbers are compared. 1655 // Get rid of separator chars so just the numbers are compared.
1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1656 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1657 ownerName = (*iter).formattedName(); 1657 ownerName = (*iter).formattedName();
1658 found = true; 1658 found = true;
1659 } 1659 }
1660 } 1660 }
1661 } 1661 }
1662 1662
1663 return ownerName; 1663 return ownerName;
1664#else //KAB_EMBEDDED 1664#else //KAB_EMBEDDED
1665 qDebug("KABCore::getNameByPhone finsih method"); 1665 qDebug("KABCore::getNameByPhone finsih method");
1666 return ""; 1666 return "";
1667#endif //KAB_EMBEDDED 1667#endif //KAB_EMBEDDED
1668 1668
1669} 1669}
1670void KABCore::openConfigGlobalDialog() 1670void KABCore::openConfigGlobalDialog()
1671{ 1671{
1672 KPimPrefsGlobalDialog gc ( this ); 1672 KPimPrefsGlobalDialog gc ( this );
1673 gc.exec(); 1673 gc.exec();
1674} 1674}
1675void KABCore::openConfigDialog() 1675void KABCore::openConfigDialog()
1676{ 1676{
1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true); 1677 KDialogBase * ConfigureDialog = new KDialogBase ( KDialogBase::Plain , i18n("Configure KA/Pi"), KDialogBase::Default |KDialogBase::Cancel | KDialogBase::Apply | KDialogBase::Ok, KDialogBase::Ok,0, "name", true, true);
1678 1678
1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" ); 1679 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog , "KCMKabConfig" );
1680 ConfigureDialog->setMainWidget( kabcfg ); 1680 ConfigureDialog->setMainWidget( kabcfg );
1681 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1681 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1682 this, SLOT( configurationChanged() ) ); 1682 this, SLOT( configurationChanged() ) );
1683 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1683 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1684 kabcfg, SLOT( save() ) ); 1684 kabcfg, SLOT( save() ) );
1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1685 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1686 this, SLOT( configurationChanged() ) ); 1686 this, SLOT( configurationChanged() ) );
1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ), 1687 connect( ConfigureDialog, SIGNAL( acceptClicked() ),
1688 kabcfg, SLOT( save() ) ); 1688 kabcfg, SLOT( save() ) );
1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ), 1689 connect( ConfigureDialog, SIGNAL( defaultClicked() ),
1690 kabcfg, SLOT( defaults() ) ); 1690 kabcfg, SLOT( defaults() ) );
1691 saveSettings(); 1691 saveSettings();
1692 kabcfg->load(); 1692 kabcfg->load();
1693#ifndef DESKTOP_VERSION 1693#ifndef DESKTOP_VERSION
1694 if ( QApplication::desktop()->height() <= 480 ) 1694 if ( QApplication::desktop()->height() <= 480 )
1695 ConfigureDialog->hideButtons(); 1695 ConfigureDialog->hideButtons();
1696 ConfigureDialog->showMaximized(); 1696 ConfigureDialog->showMaximized();
1697#endif 1697#endif
1698 if ( ConfigureDialog->exec() ) 1698 if ( ConfigureDialog->exec() )
1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1699 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1700 delete ConfigureDialog; 1700 delete ConfigureDialog;
1701} 1701}
1702 1702
1703void KABCore::openLDAPDialog() 1703void KABCore::openLDAPDialog()
1704{ 1704{
1705#ifndef KAB_EMBEDDED 1705#ifndef KAB_EMBEDDED
1706 if ( !mLdapSearchDialog ) { 1706 if ( !mLdapSearchDialog ) {
1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1707 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1708 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1709 SLOT( refreshView() ) ); 1709 SLOT( refreshView() ) );
1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1710 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1711 SLOT( setModified() ) ); 1711 SLOT( setModified() ) );
1712 } else 1712 } else
1713 mLdapSearchDialog->restoreSettings(); 1713 mLdapSearchDialog->restoreSettings();
1714 1714
1715 if ( mLdapSearchDialog->isOK() ) 1715 if ( mLdapSearchDialog->isOK() )
1716 mLdapSearchDialog->exec(); 1716 mLdapSearchDialog->exec();
1717#else //KAB_EMBEDDED 1717#else //KAB_EMBEDDED
1718 qDebug("KABCore::openLDAPDialog() finsih method"); 1718 qDebug("KABCore::openLDAPDialog() finsih method");
1719#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
1720} 1720}
1721 1721
1722void KABCore::print() 1722void KABCore::print()
1723{ 1723{
1724#ifndef KAB_EMBEDDED 1724#ifndef KAB_EMBEDDED
1725 KPrinter printer; 1725 KPrinter printer;
1726 if ( !printer.setup( this ) ) 1726 if ( !printer.setup( this ) )
1727 return; 1727 return;
1728 1728
1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1729 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1730 mViewManager->selectedUids(), this ); 1730 mViewManager->selectedUids(), this );
1731 1731
1732 wizard.exec(); 1732 wizard.exec();
1733#else //KAB_EMBEDDED 1733#else //KAB_EMBEDDED
1734 qDebug("KABCore::print() finsih method"); 1734 qDebug("KABCore::print() finsih method");
1735#endif //KAB_EMBEDDED 1735#endif //KAB_EMBEDDED
1736 1736
1737} 1737}
1738 1738
1739 1739
1740void KABCore::addGUIClient( KXMLGUIClient *client ) 1740void KABCore::addGUIClient( KXMLGUIClient *client )
1741{ 1741{
1742 if ( mGUIClient ) 1742 if ( mGUIClient )
1743 mGUIClient->insertChildClient( client ); 1743 mGUIClient->insertChildClient( client );
1744 else 1744 else
1745 KMessageBox::error( this, "no KXMLGUICLient"); 1745 KMessageBox::error( this, "no KXMLGUICLient");
1746} 1746}
1747 1747
1748 1748
1749void KABCore::configurationChanged() 1749void KABCore::configurationChanged()
1750{ 1750{
1751 mExtensionManager->reconfigure(); 1751 mExtensionManager->reconfigure();
1752} 1752}
1753 1753
1754void KABCore::addressBookChanged() 1754void KABCore::addressBookChanged()
1755{ 1755{
1756/*US 1756/*US
1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1757 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1758 while ( it.current() ) { 1758 while ( it.current() ) {
1759 if ( it.current()->dirty() ) { 1759 if ( it.current()->dirty() ) {
1760 QString text = i18n( "Data has been changed externally. Unsaved " 1760 QString text = i18n( "Data has been changed externally. Unsaved "
1761 "changes will be lost." ); 1761 "changes will be lost." );
1762 KMessageBox::information( this, text ); 1762 KMessageBox::information( this, text );
1763 } 1763 }
1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1764 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1765 ++it; 1765 ++it;
1766 } 1766 }
1767*/ 1767*/
1768 if (mEditorDialog) 1768 if (mEditorDialog)
1769 { 1769 {
1770 if (mEditorDialog->dirty()) 1770 if (mEditorDialog->dirty())
1771 { 1771 {
1772 QString text = i18n( "Data has been changed externally. Unsaved " 1772 QString text = i18n( "Data has been changed externally. Unsaved "
1773 "changes will be lost." ); 1773 "changes will be lost." );
1774 KMessageBox::information( this, text ); 1774 KMessageBox::information( this, text );
1775 } 1775 }
1776 QString currentuid = mEditorDialog->addressee().uid(); 1776 QString currentuid = mEditorDialog->addressee().uid();
1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1777 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1778 } 1778 }
1779 mViewManager->refreshView(); 1779 mViewManager->refreshView();
1780 1780
1781 1781
1782} 1782}
1783 1783
1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1784AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1785 const char *name ) 1785 const char *name )
1786{ 1786{
1787 1787
1788 if ( mEditorDialog == 0 ) { 1788 if ( mEditorDialog == 0 ) {
1789 mEditorDialog = new AddresseeEditorDialog( this, parent, 1789 mEditorDialog = new AddresseeEditorDialog( this, parent,
1790 name ? name : "editorDialog" ); 1790 name ? name : "editorDialog" );
1791 1791
1792 1792
1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1793 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1794 SLOT( contactModified( const KABC::Addressee& ) ) ); 1794 SLOT( contactModified( const KABC::Addressee& ) ) );
1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1795 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1796 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1796 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1797 } 1797 }
1798 1798
1799 return mEditorDialog; 1799 return mEditorDialog;
1800} 1800}
1801 1801
1802void KABCore::slotEditorDestroyed( const QString &uid ) 1802void KABCore::slotEditorDestroyed( const QString &uid )
1803{ 1803{
1804 //mEditorDict.remove( uid ); 1804 //mEditorDict.remove( uid );
1805} 1805}
1806 1806
1807void KABCore::initGUI() 1807void KABCore::initGUI()
1808{ 1808{
1809#ifndef KAB_EMBEDDED 1809#ifndef KAB_EMBEDDED
1810 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1810 QHBoxLayout *topLayout = new QHBoxLayout( this );
1811 topLayout->setSpacing( KDialogBase::spacingHint() ); 1811 topLayout->setSpacing( KDialogBase::spacingHint() );
1812 1812
1813 mExtensionBarSplitter = new QSplitter( this ); 1813 mExtensionBarSplitter = new QSplitter( this );
1814 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1814 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1815 1815
1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1816 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1817 1817
1818 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1818 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1819 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1819 mIncSearchWidget = new IncSearchWidget( viewSpace );
1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1820 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1821 SLOT( incrementalSearch( const QString& ) ) ); 1821 SLOT( incrementalSearch( const QString& ) ) );
1822 1822
1823 mViewManager = new ViewManager( this, viewSpace ); 1823 mViewManager = new ViewManager( this, viewSpace );
1824 viewSpace->setStretchFactor( mViewManager, 1 ); 1824 viewSpace->setStretchFactor( mViewManager, 1 );
1825 1825
1826 mDetails = new ViewContainer( mDetailsSplitter ); 1826 mDetails = new ViewContainer( mDetailsSplitter );
1827 1827
1828 mJumpButtonBar = new JumpButtonBar( this, this ); 1828 mJumpButtonBar = new JumpButtonBar( this, this );
1829 1829
1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1830 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1831 1831
1832 topLayout->addWidget( mExtensionBarSplitter ); 1832 topLayout->addWidget( mExtensionBarSplitter );
1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1833 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1834 topLayout->addWidget( mJumpButtonBar ); 1834 topLayout->addWidget( mJumpButtonBar );
1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1835 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1836 1836
1837 mXXPortManager = new XXPortManager( this, this ); 1837 mXXPortManager = new XXPortManager( this, this );
1838 1838
1839#else //KAB_EMBEDDED 1839#else //KAB_EMBEDDED
1840 //US initialize viewMenu before settingup viewmanager. 1840 //US initialize viewMenu before settingup viewmanager.
1841 // Viewmanager needs this menu to plugin submenues. 1841 // Viewmanager needs this menu to plugin submenues.
1842 viewMenu = new QPopupMenu( this ); 1842 viewMenu = new QPopupMenu( this );
1843 settingsMenu = new QPopupMenu( this ); 1843 settingsMenu = new QPopupMenu( this );
1844 //filterMenu = new QPopupMenu( this ); 1844 //filterMenu = new QPopupMenu( this );
1845 ImportMenu = new QPopupMenu( this ); 1845 ImportMenu = new QPopupMenu( this );
1846 ExportMenu = new QPopupMenu( this ); 1846 ExportMenu = new QPopupMenu( this );
1847 syncMenu = new QPopupMenu( this ); 1847 syncMenu = new QPopupMenu( this );
1848 changeMenu= new QPopupMenu( this ); 1848 changeMenu= new QPopupMenu( this );
1849 beamMenu= new QPopupMenu( this ); 1849 beamMenu= new QPopupMenu( this );
1850 1850
1851//US since we have no splitter for the embedded system, setup 1851//US since we have no splitter for the embedded system, setup
1852// a layout with two frames. One left and one right. 1852// a layout with two frames. One left and one right.
1853 1853
1854 QBoxLayout *topLayout; 1854 QBoxLayout *topLayout;
1855 1855
1856 // = new QHBoxLayout( this ); 1856 // = new QHBoxLayout( this );
1857// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1857// QBoxLayout *topLayout = (QBoxLayout*)layout();
1858 1858
1859// QWidget *mainBox = new QWidget( this ); 1859// QWidget *mainBox = new QWidget( this );
1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1860// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1861 1861
1862#ifdef DESKTOP_VERSION 1862#ifdef DESKTOP_VERSION
1863 topLayout = new QHBoxLayout( this ); 1863 topLayout = new QHBoxLayout( this );
1864 1864
1865 1865
1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1866 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1867 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1868 1868
1869 topLayout->addWidget(mMiniSplitter ); 1869 topLayout->addWidget(mMiniSplitter );
1870 1870
1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1871 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1872 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1873 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1873 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1874 mDetails = new ViewContainer( mMiniSplitter ); 1874 mDetails = new ViewContainer( mMiniSplitter );
1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1875 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1876#else 1876#else
1877 if ( QApplication::desktop()->width() > 480 ) { 1877 if ( QApplication::desktop()->width() > 480 ) {
1878 topLayout = new QHBoxLayout( this ); 1878 topLayout = new QHBoxLayout( this );
1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1879 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1880 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1881 } else { 1881 } else {
1882 1882
1883 topLayout = new QHBoxLayout( this ); 1883 topLayout = new QHBoxLayout( this );
1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1884 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1885 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1886 } 1886 }
1887 1887
1888 topLayout->addWidget(mMiniSplitter ); 1888 topLayout->addWidget(mMiniSplitter );
1889 mViewManager = new ViewManager( this, mMiniSplitter ); 1889 mViewManager = new ViewManager( this, mMiniSplitter );
1890 mDetails = new ViewContainer( mMiniSplitter ); 1890 mDetails = new ViewContainer( mMiniSplitter );
1891 1891
1892 1892
1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1893 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1894#endif 1894#endif
1895 //eh->hide(); 1895 //eh->hide();
1896 // topLayout->addWidget(mExtensionManager ); 1896 // topLayout->addWidget(mExtensionManager );
1897 1897
1898 1898
1899/*US 1899/*US
1900#ifndef KAB_NOSPLITTER 1900#ifndef KAB_NOSPLITTER
1901 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1901 QHBoxLayout *topLayout = new QHBoxLayout( this );
1902//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1902//US topLayout->setSpacing( KDialogBase::spacingHint() );
1903 topLayout->setSpacing( 10 ); 1903 topLayout->setSpacing( 10 );
1904 1904
1905 mDetailsSplitter = new QSplitter( this ); 1905 mDetailsSplitter = new QSplitter( this );
1906 1906
1907 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1907 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1908 1908
1909 mViewManager = new ViewManager( this, viewSpace ); 1909 mViewManager = new ViewManager( this, viewSpace );
1910 viewSpace->setStretchFactor( mViewManager, 1 ); 1910 viewSpace->setStretchFactor( mViewManager, 1 );
1911 1911
1912 mDetails = new ViewContainer( mDetailsSplitter ); 1912 mDetails = new ViewContainer( mDetailsSplitter );
1913 1913
1914 topLayout->addWidget( mDetailsSplitter ); 1914 topLayout->addWidget( mDetailsSplitter );
1915 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1915 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1916#else //KAB_NOSPLITTER 1916#else //KAB_NOSPLITTER
1917 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1917 QHBoxLayout *topLayout = new QHBoxLayout( this );
1918//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1918//US topLayout->setSpacing( KDialogBase::spacingHint() );
1919 topLayout->setSpacing( 10 ); 1919 topLayout->setSpacing( 10 );
1920 1920
1921// mDetailsSplitter = new QSplitter( this ); 1921// mDetailsSplitter = new QSplitter( this );
1922 1922
1923 QVBox *viewSpace = new QVBox( this ); 1923 QVBox *viewSpace = new QVBox( this );
1924 1924
1925 mViewManager = new ViewManager( this, viewSpace ); 1925 mViewManager = new ViewManager( this, viewSpace );
1926 viewSpace->setStretchFactor( mViewManager, 1 ); 1926 viewSpace->setStretchFactor( mViewManager, 1 );
1927 1927
1928 mDetails = new ViewContainer( this ); 1928 mDetails = new ViewContainer( this );
1929 1929
1930 topLayout->addWidget( viewSpace ); 1930 topLayout->addWidget( viewSpace );
1931// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1931// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1932 topLayout->addWidget( mDetails ); 1932 topLayout->addWidget( mDetails );
1933#endif //KAB_NOSPLITTER 1933#endif //KAB_NOSPLITTER
1934*/ 1934*/
1935 1935
1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1936 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1937 syncManager->setBlockSave(false); 1937 syncManager->setBlockSave(false);
1938 1938
1939 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1939 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1940 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1941 QString sync_file = sentSyncFile(); 1941 QString sync_file = sentSyncFile();
1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1942 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1943 syncManager->setDefaultFileName( sync_file ); 1943 syncManager->setDefaultFileName( sync_file );
1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1944 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1945 1945
1946#endif //KAB_EMBEDDED 1946#endif //KAB_EMBEDDED
1947 initActions(); 1947 initActions();
1948 1948
1949#ifdef KAB_EMBEDDED 1949#ifdef KAB_EMBEDDED
1950 addActionsManually(); 1950 addActionsManually();
1951 //US make sure the export and import menues are initialized before creating the xxPortManager. 1951 //US make sure the export and import menues are initialized before creating the xxPortManager.
1952 mXXPortManager = new XXPortManager( this, this ); 1952 mXXPortManager = new XXPortManager( this, this );
1953 1953
1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1954 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1955 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1956 // mActionQuit->plug ( mMainWindow->toolBar()); 1956 // mActionQuit->plug ( mMainWindow->toolBar());
1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1957 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1958 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1959 // mIncSearchWidget->hide(); 1959 // mIncSearchWidget->hide();
1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1960 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1961 SLOT( incrementalSearch( const QString& ) ) ); 1961 SLOT( incrementalSearch( const QString& ) ) );
1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1962 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1963 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1964 1964
1965 mJumpButtonBar = new JumpButtonBar( this, this ); 1965 mJumpButtonBar = new JumpButtonBar( this, this );
1966 1966
1967 topLayout->addWidget( mJumpButtonBar ); 1967 topLayout->addWidget( mJumpButtonBar );
1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1968//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1969 1969
1970// mMainWindow->getIconToolBar()->raise(); 1970// mMainWindow->getIconToolBar()->raise();
1971 1971
1972#endif //KAB_EMBEDDED 1972#endif //KAB_EMBEDDED
1973 1973
1974} 1974}
1975void KABCore::initActions() 1975void KABCore::initActions()
1976{ 1976{
1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1977//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1978 1978
1979#ifndef KAB_EMBEDDED 1979#ifndef KAB_EMBEDDED
1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1980 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1981 SLOT( clipboardDataChanged() ) ); 1981 SLOT( clipboardDataChanged() ) );
1982#endif //KAB_EMBEDDED 1982#endif //KAB_EMBEDDED
1983 1983
1984 // file menu 1984 // file menu
1985 1985
1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1986 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1987 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1988 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1989 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1990 1990
1991 1991
1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1992 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1993 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1994 1994
1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1995 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1996 SLOT( save() ), actionCollection(), "file_sync" ); 1996 SLOT( save() ), actionCollection(), "file_sync" );
1997 1997
1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1998 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1999 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1999 SLOT( newContact() ), actionCollection(), "file_new_contact" );
2000 2000
2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 2001 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
2002 this, SLOT( mailVCard() ), 2002 this, SLOT( mailVCard() ),
2003 actionCollection(), "file_mail_vcard"); 2003 actionCollection(), "file_mail_vcard");
2004 2004
2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 2005 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
2006 SLOT( export2phone() ), actionCollection(), 2006 SLOT( export2phone() ), actionCollection(),
2007 "kaddressbook_ex2phone" ); 2007 "kaddressbook_ex2phone" );
2008 2008
2009 mActionBeamVCard = 0; 2009 mActionBeamVCard = 0;
2010 mActionBeam = 0; 2010 mActionBeam = 0;
2011 2011
2012#ifndef DESKTOP_VERSION 2012#ifndef DESKTOP_VERSION
2013 if ( Ir::supported() ) { 2013 if ( Ir::supported() ) {
2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 2014 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
2015 SLOT( beamVCard() ), actionCollection(), 2015 SLOT( beamVCard() ), actionCollection(),
2016 "kaddressbook_beam_vcard" ); 2016 "kaddressbook_beam_vcard" );
2017 2017
2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 2018 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
2019 SLOT( beamMySelf() ), actionCollection(), 2019 SLOT( beamMySelf() ), actionCollection(),
2020 "kaddressbook_beam_myself" ); 2020 "kaddressbook_beam_myself" );
2021 } 2021 }
2022#endif 2022#endif
2023 2023
2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 2024 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
2025 this, SLOT( editContact2() ), 2025 this, SLOT( editContact2() ),
2026 actionCollection(), "file_properties" ); 2026 actionCollection(), "file_properties" );
2027 2027
2028#ifdef KAB_EMBEDDED 2028#ifdef KAB_EMBEDDED
2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 2029 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 2030 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
2031 mMainWindow, SLOT( exit() ), 2031 mMainWindow, SLOT( exit() ),
2032 actionCollection(), "quit" ); 2032 actionCollection(), "quit" );
2033#endif //KAB_EMBEDDED 2033#endif //KAB_EMBEDDED
2034 2034
2035 // edit menu 2035 // edit menu
2036 if ( mIsPart ) { 2036 if ( mIsPart ) {
2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 2037 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
2038 SLOT( copyContacts() ), actionCollection(), 2038 SLOT( copyContacts() ), actionCollection(),
2039 "kaddressbook_copy" ); 2039 "kaddressbook_copy" );
2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 2040 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
2041 SLOT( cutContacts() ), actionCollection(), 2041 SLOT( cutContacts() ), actionCollection(),
2042 "kaddressbook_cut" ); 2042 "kaddressbook_cut" );
2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 2043 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
2044 SLOT( pasteContacts() ), actionCollection(), 2044 SLOT( pasteContacts() ), actionCollection(),
2045 "kaddressbook_paste" ); 2045 "kaddressbook_paste" );
2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 2046 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
2047 SLOT( selectAllContacts() ), actionCollection(), 2047 SLOT( selectAllContacts() ), actionCollection(),
2048 "kaddressbook_select_all" ); 2048 "kaddressbook_select_all" );
2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 2049 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
2050 SLOT( undo() ), actionCollection(), 2050 SLOT( undo() ), actionCollection(),
2051 "kaddressbook_undo" ); 2051 "kaddressbook_undo" );
2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2052 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
2053 this, SLOT( redo() ), actionCollection(), 2053 this, SLOT( redo() ), actionCollection(),
2054 "kaddressbook_redo" ); 2054 "kaddressbook_redo" );
2055 } else { 2055 } else {
2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2056 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2057 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2058 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2059 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2060 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2061 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
2062 } 2062 }
2063 2063
2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2064 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
2065 Key_Delete, this, SLOT( deleteContacts() ), 2065 Key_Delete, this, SLOT( deleteContacts() ),
2066 actionCollection(), "edit_delete" ); 2066 actionCollection(), "edit_delete" );
2067 2067
2068 mActionUndo->setEnabled( false ); 2068 mActionUndo->setEnabled( false );
2069 mActionRedo->setEnabled( false ); 2069 mActionRedo->setEnabled( false );
2070 2070
2071 // settings menu 2071 // settings menu
2072#ifdef KAB_EMBEDDED 2072#ifdef KAB_EMBEDDED
2073//US special menuentry to configure the addressbook resources. On KDE 2073//US special menuentry to configure the addressbook resources. On KDE
2074// you do that through the control center !!! 2074// you do that through the control center !!!
2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2075 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
2076 SLOT( configureResources() ), actionCollection(), 2076 SLOT( configureResources() ), actionCollection(),
2077 "kaddressbook_configure_resources" ); 2077 "kaddressbook_configure_resources" );
2078#endif //KAB_EMBEDDED 2078#endif //KAB_EMBEDDED
2079 2079
2080 if ( mIsPart ) { 2080 if ( mIsPart ) {
2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2081 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
2082 SLOT( openConfigDialog() ), actionCollection(), 2082 SLOT( openConfigDialog() ), actionCollection(),
2083 "kaddressbook_configure" ); 2083 "kaddressbook_configure" );
2084 2084
2085 //US not implemented yet 2085 //US not implemented yet
2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2086 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2087 // this, SLOT( configureKeyBindings() ), actionCollection(), 2087 // this, SLOT( configureKeyBindings() ), actionCollection(),
2088 // "kaddressbook_configure_shortcuts" ); 2088 // "kaddressbook_configure_shortcuts" );
2089#ifdef KAB_EMBEDDED 2089#ifdef KAB_EMBEDDED
2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2090 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2091 mActionConfigureToolbars->setEnabled( false ); 2091 mActionConfigureToolbars->setEnabled( false );
2092#endif //KAB_EMBEDDED 2092#endif //KAB_EMBEDDED
2093 2093
2094 } else { 2094 } else {
2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this, 2095 mActionConfigKAddressbook = new KAction( i18n( "&Configure KA/Pi..." ), "configure", 0, this,
2096 SLOT( openConfigDialog() ), actionCollection(), 2096 SLOT( openConfigDialog() ), actionCollection(),
2097 "kaddressbook_configure" ); 2097 "kaddressbook_configure" );
2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this, 2098 mActionConfigGlobal = new KAction( i18n( "Global Settings..." ), "configure", 0, this,
2099 SLOT( openConfigGlobalDialog() ), actionCollection(), 2099 SLOT( openConfigGlobalDialog() ), actionCollection(),
2100 "kaddressbook_configure" ); 2100 "kaddressbook_configure" );
2101 } 2101 }
2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2102 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2103 actionCollection(), "options_show_jump_bar" ); 2103 actionCollection(), "options_show_jump_bar" );
2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2104 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2105 2105
2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2106 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2107 actionCollection(), "options_show_details" ); 2107 actionCollection(), "options_show_details" );
2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2108 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2109 2109
2110 2110
2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2111 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2112 SLOT( toggleBeamReceive() ), actionCollection(), 2112 SLOT( toggleBeamReceive() ), actionCollection(),
2113 "kaddressbook_beam_rec" ); 2113 "kaddressbook_beam_rec" );
2114 2114
2115 2115
2116 // misc 2116 // misc
2117 // only enable LDAP lookup if we can handle the protocol 2117 // only enable LDAP lookup if we can handle the protocol
2118#ifndef KAB_EMBEDDED 2118#ifndef KAB_EMBEDDED
2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2119 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2120 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2121 this, SLOT( openLDAPDialog() ), actionCollection(), 2121 this, SLOT( openLDAPDialog() ), actionCollection(),
2122 "ldap_lookup" ); 2122 "ldap_lookup" );
2123 } 2123 }
2124#else //KAB_EMBEDDED 2124#else //KAB_EMBEDDED
2125 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2125 //qDebug("KABCore::initActions() LDAP has to be implemented");
2126#endif //KAB_EMBEDDED 2126#endif //KAB_EMBEDDED
2127 2127
2128 2128
2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2129 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2130 SLOT( setWhoAmI() ), actionCollection(), 2130 SLOT( setWhoAmI() ), actionCollection(),
2131 "set_personal" ); 2131 "set_personal" );
2132 2132
2133 2133
2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2134 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2135 SLOT( setCategories() ), actionCollection(), 2135 SLOT( setCategories() ), actionCollection(),
2136 "edit_set_categories" ); 2136 "edit_set_categories" );
2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2137 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2138 SLOT( editCategories() ), actionCollection(), 2138 SLOT( editCategories() ), actionCollection(),
2139 "edit__categories" ); 2139 "edit__categories" );
2140 2140
2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2141 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2142 SLOT( removeVoice() ), actionCollection(), 2142 SLOT( removeVoice() ), actionCollection(),
2143 "remove_voice" ); 2143 "remove_voice" );
2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2144 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2145 SLOT( setFormattedName() ), actionCollection(), 2145 SLOT( setFormattedName() ), actionCollection(),
2146 "set_formatted" ); 2146 "set_formatted" );
2147 2147
2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2148 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2149 SLOT( manageCategories() ), actionCollection(), 2149 SLOT( manageCategories() ), actionCollection(),
2150 "remove_voice" ); 2150 "remove_voice" );
2151 2151
2152 2152
2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2153 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2154 SLOT( importFromOL() ), actionCollection(), 2154 SLOT( importFromOL() ), actionCollection(),
2155 "import_OL" ); 2155 "import_OL" );
2156#ifdef KAB_EMBEDDED 2156#ifdef KAB_EMBEDDED
2157 mActionLicence = new KAction( i18n( "Licence" ), 0, 2157 mActionLicence = new KAction( i18n( "Licence" ), 0,
2158 this, SLOT( showLicence() ), actionCollection(), 2158 this, SLOT( showLicence() ), actionCollection(),
2159 "licence_about_data" ); 2159 "licence_about_data" );
2160 mActionFaq = new KAction( i18n( "Faq" ), 0, 2160 mActionFaq = new KAction( i18n( "Faq" ), 0,
2161 this, SLOT( faq() ), actionCollection(), 2161 this, SLOT( faq() ), actionCollection(),
2162 "faq_about_data" ); 2162 "faq_about_data" );
2163 mActionWN = new KAction( i18n( "What's New?" ), 0, 2163 mActionWN = new KAction( i18n( "What's New?" ), 0,
2164 this, SLOT( whatsnew() ), actionCollection(), 2164 this, SLOT( whatsnew() ), actionCollection(),
2165 "wn" ); 2165 "wn" );
2166 2166
2167 2167
2168 2168
2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2169 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2170 this, SLOT( storagehowto() ), actionCollection(), 2170 this, SLOT( storagehowto() ), actionCollection(),
2171 "storage" ); 2171 "storage" );
2172 2172
2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2173 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2174 this, SLOT( synchowto() ), actionCollection(), 2174 this, SLOT( synchowto() ), actionCollection(),
2175 "sync" ); 2175 "sync" );
2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2176 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2177 this, SLOT( kdesynchowto() ), actionCollection(), 2177 this, SLOT( kdesynchowto() ), actionCollection(),
2178 "kdesync" ); 2178 "kdesync" );
2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2179 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2180 this, SLOT( multisynchowto() ), actionCollection(), 2180 this, SLOT( multisynchowto() ), actionCollection(),
2181 "multisync" ); 2181 "multisync" );
2182 2182
2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2183 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2184 this, SLOT( createAboutData() ), actionCollection(), 2184 this, SLOT( createAboutData() ), actionCollection(),
2185 "kaddressbook_about_data" ); 2185 "kaddressbook_about_data" );
2186#endif //KAB_EMBEDDED 2186#endif //KAB_EMBEDDED
2187 2187
2188 clipboardDataChanged(); 2188 clipboardDataChanged();
2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2189 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2190 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2191} 2191}
2192 2192
2193//US we need this function, to plug all actions into the correct menues. 2193//US we need this function, to plug all actions into the correct menues.
2194// KDE uses a XML format to plug the actions, but we work her without this overhead. 2194// KDE uses a XML format to plug the actions, but we work her without this overhead.
2195void KABCore::addActionsManually() 2195void KABCore::addActionsManually()
2196{ 2196{
2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2197//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2198 2198
2199#ifdef KAB_EMBEDDED 2199#ifdef KAB_EMBEDDED
2200 QPopupMenu *fileMenu = new QPopupMenu( this ); 2200 QPopupMenu *fileMenu = new QPopupMenu( this );
2201 QPopupMenu *editMenu = new QPopupMenu( this ); 2201 QPopupMenu *editMenu = new QPopupMenu( this );
2202 QPopupMenu *helpMenu = new QPopupMenu( this ); 2202 QPopupMenu *helpMenu = new QPopupMenu( this );
2203 2203
2204 KToolBar* tb = mMainWindow->toolBar(); 2204 KToolBar* tb = mMainWindow->toolBar();
2205 mMainWindow->setToolBarsMovable (false ); 2205 mMainWindow->setToolBarsMovable (false );
2206#ifndef DESKTOP_VERSION 2206#ifndef DESKTOP_VERSION
2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2207 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2208#endif 2208#endif
2209 QMenuBar* mb = mMainWindow->menuBar(); 2209 QMenuBar* mb = mMainWindow->menuBar();
2210 2210
2211 //US setup menubar. 2211 //US setup menubar.
2212 //Disable the following block if you do not want to have a menubar. 2212 //Disable the following block if you do not want to have a menubar.
2213 mb->insertItem( i18n("&File"), fileMenu ); 2213 mb->insertItem( i18n("&File"), fileMenu );
2214 mb->insertItem( i18n("&Edit"), editMenu ); 2214 mb->insertItem( i18n("&Edit"), editMenu );
2215 mb->insertItem( i18n("&View"), viewMenu ); 2215 mb->insertItem( i18n("&View"), viewMenu );
2216 mb->insertItem( i18n("&Settings"), settingsMenu ); 2216 mb->insertItem( i18n("&Settings"), settingsMenu );
2217#ifdef DESKTOP_VERSION 2217#ifdef DESKTOP_VERSION
2218 mb->insertItem( i18n("Synchronize"), syncMenu ); 2218 mb->insertItem( i18n("Synchronize"), syncMenu );
2219#else 2219#else
2220 mb->insertItem( i18n("Sync"), syncMenu ); 2220 mb->insertItem( i18n("Sync"), syncMenu );
2221#endif 2221#endif
2222 //mb->insertItem( i18n("&Change"), changeMenu ); 2222 //mb->insertItem( i18n("&Change"), changeMenu );
2223 mb->insertItem( i18n("&Help"), helpMenu ); 2223 mb->insertItem( i18n("&Help"), helpMenu );
2224 mIncSearchWidget = new IncSearchWidget( tb ); 2224 mIncSearchWidget = new IncSearchWidget( tb );
2225 // tb->insertWidget(-1, 0, mIncSearchWidget); 2225 // tb->insertWidget(-1, 0, mIncSearchWidget);
2226#ifndef DESKTOP_VERSION 2226#ifndef DESKTOP_VERSION
2227 } else { 2227 } else {
2228 //US setup toolbar 2228 //US setup toolbar
2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2229 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2230 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2230 QPopupMenu *popupBarTB = new QPopupMenu( this );
2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB); 2231 menuBarTB->insertItem( SmallIcon( "z_menu" ) , popupBarTB);
2232 tb->insertWidget(-1, 0, menuBarTB); 2232 tb->insertWidget(-1, 0, menuBarTB);
2233 mIncSearchWidget = new IncSearchWidget( tb ); 2233 mIncSearchWidget = new IncSearchWidget( tb );
2234 tb->enableMoving(false); 2234 tb->enableMoving(false);
2235 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2235 popupBarTB->insertItem( i18n("&File"), fileMenu );
2236 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2236 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2237 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2237 popupBarTB->insertItem( i18n("&View"), viewMenu );
2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2238 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2239 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2240 mViewManager->getFilterAction()->plug ( popupBarTB); 2240 mViewManager->getFilterAction()->plug ( popupBarTB);
2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2241 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2242 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2242 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2243 if (QApplication::desktop()->width() > 320 ) { 2243 if (QApplication::desktop()->width() > 320 ) {
2244 // mViewManager->getFilterAction()->plug ( tb); 2244 // mViewManager->getFilterAction()->plug ( tb);
2245 } 2245 }
2246 } 2246 }
2247#endif 2247#endif
2248 mIncSearchWidget->setSize(); 2248 mIncSearchWidget->setSize();
2249 // mActionQuit->plug ( mMainWindow->toolBar()); 2249 // mActionQuit->plug ( mMainWindow->toolBar());
2250 2250
2251 2251
2252 2252
2253 //US Now connect the actions with the menue entries. 2253 //US Now connect the actions with the menue entries.
2254#ifdef DESKTOP_VERSION 2254#ifdef DESKTOP_VERSION
2255 mActionPrint->plug( fileMenu ); 2255 mActionPrint->plug( fileMenu );
2256 mActionPrintDetails->plug( fileMenu ); 2256 mActionPrintDetails->plug( fileMenu );
2257 fileMenu->insertSeparator(); 2257 fileMenu->insertSeparator();
2258#endif 2258#endif
2259 mActionMail->plug( fileMenu ); 2259 mActionMail->plug( fileMenu );
2260 fileMenu->insertSeparator(); 2260 fileMenu->insertSeparator();
2261 2261
2262 mActionNewContact->plug( editMenu ); 2262 mActionNewContact->plug( editMenu );
2263 mActionNewContact->plug( tb ); 2263 mActionNewContact->plug( tb );
2264 2264
2265 mActionEditAddressee->plug( editMenu ); 2265 mActionEditAddressee->plug( editMenu );
2266 editMenu->insertSeparator(); 2266 editMenu->insertSeparator();
2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2267 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2268 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2269 mActionEditAddressee->plug( tb ); 2269 mActionEditAddressee->plug( tb );
2270 2270
2271 // fileMenu->insertSeparator(); 2271 // fileMenu->insertSeparator();
2272 mActionSave->plug( fileMenu ); 2272 mActionSave->plug( fileMenu );
2273 fileMenu->insertItem( "&Import", ImportMenu ); 2273 fileMenu->insertItem( "&Import", ImportMenu );
2274 fileMenu->insertItem( "&Export", ExportMenu ); 2274 fileMenu->insertItem( "&Export", ExportMenu );
2275 editMenu->insertItem( i18n("&Change"), changeMenu ); 2275 editMenu->insertItem( i18n("&Change"), changeMenu );
2276 editMenu->insertSeparator(); 2276 editMenu->insertSeparator();
2277#ifndef DESKTOP_VERSION 2277#ifndef DESKTOP_VERSION
2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2278 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2279#endif 2279#endif
2280#if 0 2280#if 0
2281 // PENDING fix MailVCard 2281 // PENDING fix MailVCard
2282 fileMenu->insertSeparator(); 2282 fileMenu->insertSeparator();
2283 mActionMailVCard->plug( fileMenu ); 2283 mActionMailVCard->plug( fileMenu );
2284#endif 2284#endif
2285#ifndef DESKTOP_VERSION 2285#ifndef DESKTOP_VERSION
2286 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2286 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2287 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2288 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2289#endif 2289#endif
2290 fileMenu->insertSeparator(); 2290 fileMenu->insertSeparator();
2291 mActionQuit->plug( fileMenu ); 2291 mActionQuit->plug( fileMenu );
2292#ifdef _OL_IMPORT_ 2292#ifdef _OL_IMPORT_
2293 mActionImportOL->plug( ImportMenu ); 2293 mActionImportOL->plug( ImportMenu );
2294#endif 2294#endif
2295 // edit menu 2295 // edit menu
2296 mActionUndo->plug( editMenu ); 2296 mActionUndo->plug( editMenu );
2297 mActionRedo->plug( editMenu ); 2297 mActionRedo->plug( editMenu );
2298 editMenu->insertSeparator(); 2298 editMenu->insertSeparator();
2299 mActionCut->plug( editMenu ); 2299 mActionCut->plug( editMenu );
2300 mActionCopy->plug( editMenu ); 2300 mActionCopy->plug( editMenu );
2301 mActionPaste->plug( editMenu ); 2301 mActionPaste->plug( editMenu );
2302 mActionDelete->plug( editMenu ); 2302 mActionDelete->plug( editMenu );
2303 editMenu->insertSeparator(); 2303 editMenu->insertSeparator();
2304 mActionSelectAll->plug( editMenu ); 2304 mActionSelectAll->plug( editMenu );
2305 2305
2306 mActionSetFormattedName->plug( changeMenu ); 2306 mActionSetFormattedName->plug( changeMenu );
2307 mActionRemoveVoice->plug( changeMenu ); 2307 mActionRemoveVoice->plug( changeMenu );
2308 // settingsmings menu 2308 // settingsmings menu
2309//US special menuentry to configure the addressbook resources. On KDE 2309//US special menuentry to configure the addressbook resources. On KDE
2310// you do that through the control center !!! 2310// you do that through the control center !!!
2311 // settingsMenu->insertSeparator(); 2311 // settingsMenu->insertSeparator();
2312 2312
2313 mActionConfigKAddressbook->plug( settingsMenu, 0 ); 2313 mActionConfigKAddressbook->plug( settingsMenu, 0 );
2314 mActionConfigGlobal->plug( settingsMenu, 1 ); 2314 mActionConfigGlobal->plug( settingsMenu, 1 );
2315 mActionConfigResources->plug( settingsMenu,2 ); 2315 mActionConfigResources->plug( settingsMenu,2 );
2316 settingsMenu->insertSeparator(3); 2316 settingsMenu->insertSeparator(3);
2317 2317
2318 if ( mIsPart ) { 2318 if ( mIsPart ) {
2319 //US not implemented yet 2319 //US not implemented yet
2320 //mActionConfigShortcuts->plug( settingsMenu ); 2320 //mActionConfigShortcuts->plug( settingsMenu );
2321 //mActionConfigureToolbars->plug( settingsMenu ); 2321 //mActionConfigureToolbars->plug( settingsMenu );
2322 2322
2323 } else { 2323 } else {
2324 //US not implemented yet 2324 //US not implemented yet
2325 //mActionKeyBindings->plug( settingsMenu ); 2325 //mActionKeyBindings->plug( settingsMenu );
2326 } 2326 }
2327 2327
2328 mActionEditCategories->plug( settingsMenu ); 2328 mActionEditCategories->plug( settingsMenu );
2329 mActionManageCategories->plug( settingsMenu ); 2329 mActionManageCategories->plug( settingsMenu );
2330 mActionJumpBar->plug( viewMenu,0 ); 2330 mActionJumpBar->plug( viewMenu,0 );
2331 mActionDetails->plug( viewMenu,0 ); 2331 mActionDetails->plug( viewMenu,0 );
2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2332 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2333 mActionDetails->plug( tb ); 2333 mActionDetails->plug( tb );
2334 settingsMenu->insertSeparator(); 2334 settingsMenu->insertSeparator();
2335#ifndef DESKTOP_VERSION 2335#ifndef DESKTOP_VERSION
2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2336 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2337 settingsMenu->insertSeparator(); 2337 settingsMenu->insertSeparator();
2338#endif 2338#endif
2339 2339
2340 mActionWhoAmI->plug( settingsMenu ); 2340 mActionWhoAmI->plug( settingsMenu );
2341 //mActionEditCategories->plug( changeMenu ); 2341 //mActionEditCategories->plug( changeMenu );
2342 mActionCategories->plug( changeMenu ); 2342 mActionCategories->plug( changeMenu );
2343 //mActionManageCategories->plug( changeMenu ); 2343 //mActionManageCategories->plug( changeMenu );
2344 2344
2345 //mActionCategories->plug( settingsMenu ); 2345 //mActionCategories->plug( settingsMenu );
2346 2346
2347 2347
2348 mActionWN->plug( helpMenu ); 2348 mActionWN->plug( helpMenu );
2349 mActionStorageHowto->plug( helpMenu ); 2349 mActionStorageHowto->plug( helpMenu );
2350 mActionSyncHowto->plug( helpMenu ); 2350 mActionSyncHowto->plug( helpMenu );
2351 mActionKdeSyncHowto->plug( helpMenu ); 2351 mActionKdeSyncHowto->plug( helpMenu );
2352 mActionMultiSyncHowto->plug( helpMenu ); 2352 mActionMultiSyncHowto->plug( helpMenu );
2353 mActionFaq->plug( helpMenu ); 2353 mActionFaq->plug( helpMenu );
2354 mActionLicence->plug( helpMenu ); 2354 mActionLicence->plug( helpMenu );
2355 mActionAboutKAddressbook->plug( helpMenu ); 2355 mActionAboutKAddressbook->plug( helpMenu );
2356 2356
2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2357 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2358 2358
2359 mActionSave->plug( tb ); 2359 mActionSave->plug( tb );
2360 mViewManager->getFilterAction()->plug ( tb); 2360 mViewManager->getFilterAction()->plug ( tb);
2361 //LR hide filteraction on started in 480x640 2361 //LR hide filteraction on started in 480x640
2362 if (QApplication::desktop()->width() == 480 ) { 2362 if (QApplication::desktop()->width() == 480 ) {
2363 mViewManager->getFilterAction()->setComboWidth( 0 ); 2363 mViewManager->getFilterAction()->setComboWidth( 0 );
2364 } 2364 }
2365 mActionUndo->plug( tb ); 2365 mActionUndo->plug( tb );
2366 mActionDelete->plug( tb ); 2366 mActionDelete->plug( tb );
2367 mActionRedo->plug( tb ); 2367 mActionRedo->plug( tb );
2368 } else { 2368 } else {
2369 mActionSave->plug( tb ); 2369 mActionSave->plug( tb );
2370 tb->enableMoving(false); 2370 tb->enableMoving(false);
2371 } 2371 }
2372 //mActionQuit->plug ( tb ); 2372 //mActionQuit->plug ( tb );
2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2373 //tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2374 2374
2375 //US link the searchwidget first to this. 2375 //US link the searchwidget first to this.
2376 // The real linkage to the toolbar happens later. 2376 // The real linkage to the toolbar happens later.
2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2377//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2378//US tb->insertItem( mIncSearchWidget ); 2378//US tb->insertItem( mIncSearchWidget );
2379/*US 2379/*US
2380 mIncSearchWidget = new IncSearchWidget( tb ); 2380 mIncSearchWidget = new IncSearchWidget( tb );
2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2381 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2382 SLOT( incrementalSearch( const QString& ) ) ); 2382 SLOT( incrementalSearch( const QString& ) ) );
2383 2383
2384 mJumpButtonBar = new JumpButtonBar( this, this ); 2384 mJumpButtonBar = new JumpButtonBar( this, this );
2385 2385
2386//US topLayout->addWidget( mJumpButtonBar ); 2386//US topLayout->addWidget( mJumpButtonBar );
2387 this->layout()->add( mJumpButtonBar ); 2387 this->layout()->add( mJumpButtonBar );
2388*/ 2388*/
2389 2389
2390#endif //KAB_EMBEDDED 2390#endif //KAB_EMBEDDED
2391 2391
2392 mActionExport2phone->plug( ExportMenu ); 2392 mActionExport2phone->plug( ExportMenu );
2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2393 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2394 syncManager->fillSyncMenu(); 2394 syncManager->fillSyncMenu();
2395 2395
2396} 2396}
2397void KABCore::showLicence() 2397void KABCore::showLicence()
2398{ 2398{
2399 KApplication::showLicence(); 2399 KApplication::showLicence();
2400} 2400}
2401 2401
2402void KABCore::manageCategories( ) 2402void KABCore::manageCategories( )
2403{ 2403{
2404 KABCatPrefs* cp = new KABCatPrefs(); 2404 KABCatPrefs* cp = new KABCatPrefs();
2405 cp->show(); 2405 cp->show();
2406 int w =cp->sizeHint().width() ; 2406 int w =cp->sizeHint().width() ;
2407 int h = cp->sizeHint().height() ; 2407 int h = cp->sizeHint().height() ;
2408 int dw = QApplication::desktop()->width(); 2408 int dw = QApplication::desktop()->width();
2409 int dh = QApplication::desktop()->height(); 2409 int dh = QApplication::desktop()->height();
2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2410 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2411 if ( !cp->exec() ) { 2411 if ( !cp->exec() ) {
2412 delete cp; 2412 delete cp;
2413 return; 2413 return;
2414 } 2414 }
2415 int count = 0; 2415 int count = 0;
2416 int cc = 0; 2416 int cc = 0;
2417 message( i18n("Please wait, processing categories...")); 2417 message( i18n("Please wait, processing categories..."));
2418 if ( cp->addCat() ) { 2418 if ( cp->addCat() ) {
2419 KABC::AddressBook::Iterator it; 2419 KABC::AddressBook::Iterator it;
2420 QStringList catList = KABPrefs::instance()->mCustomCategories; 2420 QStringList catList = KABPrefs::instance()->mCustomCategories;
2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2421 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2422 ++cc; 2422 ++cc;
2423 if ( cc %10 == 0) 2423 if ( cc %10 == 0)
2424 message(i18n("Processing contact #%1").arg(cc)); 2424 message(i18n("Processing contact #%1").arg(cc));
2425 QStringList catIncList = (*it).categories(); 2425 QStringList catIncList = (*it).categories();
2426 int i; 2426 int i;
2427 for( i = 0; i< catIncList.count(); ++i ) { 2427 for( i = 0; i< catIncList.count(); ++i ) {
2428 if ( !catList.contains (catIncList[i])) { 2428 if ( !catList.contains (catIncList[i])) {
2429 catList.append( catIncList[i] ); 2429 catList.append( catIncList[i] );
2430 //qDebug("add cat %s ", catIncList[i].latin1()); 2430 //qDebug("add cat %s ", catIncList[i].latin1());
2431 ++count; 2431 ++count;
2432 } 2432 }
2433 } 2433 }
2434 } 2434 }
2435 catList.sort(); 2435 catList.sort();
2436 KABPrefs::instance()->mCustomCategories = catList; 2436 KABPrefs::instance()->mCustomCategories = catList;
2437 KABPrefs::instance()->writeConfig(); 2437 KABPrefs::instance()->writeConfig();
2438 message(QString::number( count )+ i18n(" categories added to list! ")); 2438 message(QString::number( count )+ i18n(" categories added to list! "));
2439 } else { 2439 } else {
2440 QStringList catList = KABPrefs::instance()->mCustomCategories; 2440 QStringList catList = KABPrefs::instance()->mCustomCategories;
2441 QStringList catIncList; 2441 QStringList catIncList;
2442 QStringList newCatList; 2442 QStringList newCatList;
2443 KABC::AddressBook::Iterator it; 2443 KABC::AddressBook::Iterator it;
2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2444 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2445 ++cc; 2445 ++cc;
2446 if ( cc %10 == 0) 2446 if ( cc %10 == 0)
2447 message(i18n("Processing contact #%1").arg(cc)); 2447 message(i18n("Processing contact #%1").arg(cc));
2448 QStringList catIncList = (*it).categories(); 2448 QStringList catIncList = (*it).categories();
2449 int i; 2449 int i;
2450 if ( catIncList.count() ) { 2450 if ( catIncList.count() ) {
2451 newCatList.clear(); 2451 newCatList.clear();
2452 for( i = 0; i< catIncList.count(); ++i ) { 2452 for( i = 0; i< catIncList.count(); ++i ) {
2453 if ( catList.contains (catIncList[i])) { 2453 if ( catList.contains (catIncList[i])) {
2454 newCatList.append( catIncList[i] ); 2454 newCatList.append( catIncList[i] );
2455 } 2455 }
2456 } 2456 }
2457 newCatList.sort(); 2457 newCatList.sort();
2458 (*it).setCategories( newCatList ); 2458 (*it).setCategories( newCatList );
2459 mAddressBook->insertAddressee( (*it) ); 2459 mAddressBook->insertAddressee( (*it) );
2460 } 2460 }
2461 } 2461 }
2462 setModified( true ); 2462 setModified( true );
2463 mViewManager->refreshView(); 2463 mViewManager->refreshView();
2464 message( i18n("Removing categories done!")); 2464 message( i18n("Removing categories done!"));
2465 } 2465 }
2466 delete cp; 2466 delete cp;
2467} 2467}
2468void KABCore::removeVoice() 2468void KABCore::removeVoice()
2469{ 2469{
2470 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 2470 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
2471 return; 2471 return;
2472 XXPortSelectDialog dlg( this, false, this ); 2472 XXPortSelectDialog dlg( this, false, this );
2473 if ( !dlg.exec() ) 2473 if ( !dlg.exec() )
2474 return; 2474 return;
2475 mAddressBook->setUntagged(); 2475 mAddressBook->setUntagged();
2476 dlg.tagSelected(); 2476 dlg.tagSelected();
2477 message(i18n("Removing voice..."), false ); 2477 message(i18n("Removing voice..."), false );
2478 KABC::AddressBook::Iterator it; 2478 KABC::AddressBook::Iterator it;
2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2479 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2480 if ( (*it).tagged() ) { 2480 if ( (*it).tagged() ) {
2481 (*it).removeVoice(); 2481 (*it).removeVoice();
2482 } 2482 }
2483 } 2483 }
2484 message(i18n("Refreshing view...") ); 2484 message(i18n("Refreshing view...") );
2485 mViewManager->refreshView( "" ); 2485 mViewManager->refreshView( "" );
2486 Addressee add; 2486 Addressee add;
2487 mDetails->setAddressee( add ); 2487 mDetails->setAddressee( add );
2488 message(i18n("Remove voice completed!") ); 2488 message(i18n("Remove voice completed!") );
2489 2489
2490 2490
2491 2491
2492} 2492}
2493 2493
2494void KABCore::setFormattedName() 2494void KABCore::setFormattedName()
2495{ 2495{
2496 KABFormatPrefs setpref; 2496 KABFormatPrefs setpref;
2497 if ( !setpref.exec() ) { 2497 if ( !setpref.exec() ) {
2498 return; 2498 return;
2499 } 2499 }
2500 XXPortSelectDialog dlg( this, false, this ); 2500 XXPortSelectDialog dlg( this, false, this );
2501 if ( !dlg.exec() ) 2501 if ( !dlg.exec() )
2502 return; 2502 return;
2503 mAddressBook->setUntagged(); 2503 mAddressBook->setUntagged();
2504 dlg.tagSelected(); 2504 dlg.tagSelected();
2505 int count = 0; 2505 int count = 0;
2506 KABC::AddressBook::Iterator it; 2506 KABC::AddressBook::Iterator it;
2507 bool modified = false; 2507 bool modified = false;
2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2508 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2509 if ( (*it).tagged() ) { 2509 if ( (*it).tagged() ) {
2510 if ( (*it).uid().left( 2 ) == "la" ) 2510 if ( (*it).uid().left( 2 ) == "la" )
2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") ) 2511 if ( (*it).uid().left( 19 ) == QString("last-syncAddressee-") )
2512 continue; 2512 continue;
2513 ++count; 2513 ++count;
2514 if ( count %10 == 0 ) 2514 if ( count %10 == 0 )
2515 message(i18n("Changing contact #%1").arg( count ) ); 2515 message(i18n("Changing contact #%1").arg( count ) );
2516 QString fName; 2516 QString fName;
2517 if ( setpref.simple->isChecked() ) 2517 if ( setpref.simple->isChecked() )
2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2518 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2519 else if ( setpref.full->isChecked() ) 2519 else if ( setpref.full->isChecked() )
2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2520 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2521 else if ( setpref.reverse->isChecked() ) 2521 else if ( setpref.reverse->isChecked() )
2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2522 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2523 else 2523 else
2524 fName = (*it).organization(); 2524 fName = (*it).organization();
2525 if ( setpref.setCompany->isChecked() ) 2525 if ( setpref.setCompany->isChecked() )
2526 if ( fName.isEmpty() || fName =="," ) 2526 if ( fName.isEmpty() || fName =="," )
2527 fName = (*it).organization(); 2527 fName = (*it).organization();
2528 (*it).setFormattedName( fName ); 2528 (*it).setFormattedName( fName );
2529 (*it).setChanged( true ); 2529 (*it).setChanged( true );
2530 modified = true; 2530 modified = true;
2531 (*it).setRevision( QDateTime::currentDateTime() ); 2531 (*it).setRevision( QDateTime::currentDateTime() );
2532 } 2532 }
2533 } 2533 }
2534 message(i18n("Refreshing view...") ); 2534 message(i18n("Refreshing view...") );
2535 if ( modified ) 2535 if ( modified )
2536 setModified( true ); 2536 setModified( true );
2537 Addressee add; 2537 Addressee add;
2538 mDetails->setAddressee( add ); 2538 mDetails->setAddressee( add );
2539 if ( count == 0 ) 2539 if ( count == 0 )
2540 message(i18n("No contact changed!") ); 2540 message(i18n("No contact changed!") );
2541 else 2541 else
2542 message(i18n("%1 contacts changed!").arg( count ) ); 2542 message(i18n("%1 contacts changed!").arg( count ) );
2543} 2543}
2544 2544
2545void KABCore::clipboardDataChanged() 2545void KABCore::clipboardDataChanged()
2546{ 2546{
2547 2547
2548 if ( mReadWrite ) 2548 if ( mReadWrite )
2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2549 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2550 2550
2551} 2551}
2552 2552
2553void KABCore::updateActionMenu() 2553void KABCore::updateActionMenu()
2554{ 2554{
2555 UndoStack *undo = UndoStack::instance(); 2555 UndoStack *undo = UndoStack::instance();
2556 RedoStack *redo = RedoStack::instance(); 2556 RedoStack *redo = RedoStack::instance();
2557 2557
2558 if ( undo->isEmpty() ) 2558 if ( undo->isEmpty() )
2559 mActionUndo->setText( i18n( "Undo" ) ); 2559 mActionUndo->setText( i18n( "Undo" ) );
2560 else 2560 else
2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2561 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2562 2562
2563 mActionUndo->setEnabled( !undo->isEmpty() ); 2563 mActionUndo->setEnabled( !undo->isEmpty() );
2564 2564
2565 if ( !redo->top() ) 2565 if ( !redo->top() )
2566 mActionRedo->setText( i18n( "Redo" ) ); 2566 mActionRedo->setText( i18n( "Redo" ) );
2567 else 2567 else
2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2568 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2569 2569
2570 mActionRedo->setEnabled( !redo->isEmpty() ); 2570 mActionRedo->setEnabled( !redo->isEmpty() );
2571} 2571}
2572 2572
2573void KABCore::configureKeyBindings() 2573void KABCore::configureKeyBindings()
2574{ 2574{
2575#ifndef KAB_EMBEDDED 2575#ifndef KAB_EMBEDDED
2576 KKeyDialog::configure( actionCollection(), true ); 2576 KKeyDialog::configure( actionCollection(), true );
2577#else //KAB_EMBEDDED 2577#else //KAB_EMBEDDED
2578 qDebug("KABCore::configureKeyBindings() not implemented"); 2578 qDebug("KABCore::configureKeyBindings() not implemented");
2579#endif //KAB_EMBEDDED 2579#endif //KAB_EMBEDDED
2580} 2580}
2581 2581
2582#ifdef KAB_EMBEDDED 2582#ifdef KAB_EMBEDDED
2583void KABCore::configureResources() 2583void KABCore::configureResources()
2584{ 2584{
2585 KRES::KCMKResources dlg( this, "" , 0 ); 2585 KRES::KCMKResources dlg( this, "" , 0 );
2586 2586
2587 if ( !dlg.exec() ) 2587 if ( !dlg.exec() )
2588 return; 2588 return;
2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2589 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2590} 2590}
2591#endif //KAB_EMBEDDED 2591#endif //KAB_EMBEDDED
2592 2592
2593 2593
2594/* this method will be called through the QCop interface from Ko/Pi to select addresses 2594/* this method will be called through the QCop interface from Ko/Pi to select addresses
2595 * for the attendees list of an event. 2595 * for the attendees list of an event.
2596 */ 2596 */
2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2597void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2598{ 2598{
2599 qDebug("KABCore::requestForNameEmailUidList "); 2599 qDebug("KABCore::requestForNameEmailUidList ");
2600 bool ok = false; 2600 bool ok = false;
2601 mEmailSourceChannel = sourceChannel; 2601 mEmailSourceChannel = sourceChannel;
2602 mEmailSourceUID = uid; 2602 mEmailSourceUID = uid;
2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2603 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2604 //callContactdialog(); 2604 //callContactdialog();
2605#if 0 2605#if 0
2606 int wid = uid.toInt( &ok ); 2606 int wid = uid.toInt( &ok );
2607 qDebug("UID %s ", uid.latin1()); 2607 qDebug("UID %s ", uid.latin1());
2608 if ( ok ) { 2608 if ( ok ) {
2609 if ( wid != QApplication::desktop()->width() ) { 2609 if ( wid != QApplication::desktop()->width() ) {
2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ..."); 2610 qDebug("KA/Pi: Request from different desktop geometry. Resizing ...");
2611 message( i18n("Resizing, please wait...") ); 2611 message( i18n("Resizing, please wait...") );
2612 mMainWindow->showMinimized(); 2612 mMainWindow->showMinimized();
2613 /* 2613 /*
2614 { 2614 {
2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2615 QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2616 } 2616 }
2617 */ 2617 */
2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) ); 2618 QTimer::singleShot( 1,this, SLOT ( resizeAndCallContactdialog() ) );
2619 return; 2619 return;
2620 } 2620 }
2621 2621
2622 } else { 2622 } else {
2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid "); 2623 qDebug("KABCore::requestForNameEmailUidList:: Got invalid uid ");
2624 } 2624 }
2625 callContactdialog(); 2625 callContactdialog();
2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()"); 2626 //QCopEnvelope e("QPE/Application/kapi", "callContactdialog()");
2627#endif 2627#endif
2628} 2628}
2629void KABCore::resizeAndCallContactdialog() 2629void KABCore::resizeAndCallContactdialog()
2630{ 2630{
2631 updateMainWindow(); 2631 updateMainWindow();
2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) ); 2632 QTimer::singleShot( 10,this, SLOT ( callContactdialog() ) );
2633} 2633}
2634 2634
2635void KABCore::doRingSync() 2635void KABCore::doRingSync()
2636{ 2636{
2637 topLevelWidget()->raise(); 2637 topLevelWidget()->raise();
2638 syncManager->multiSync( false ); 2638 syncManager->multiSync( false );
2639} 2639}
2640void KABCore::callContactdialog() 2640void KABCore::callContactdialog()
2641{ 2641{
2642 static bool running = false; 2642 static bool running = false;
2643 if (running) return; 2643 if (running) return;
2644 running = true; 2644 running = true;
2645 QStringList nameList; 2645 QStringList nameList;
2646 QStringList emailList; 2646 QStringList emailList;
2647 QStringList uidList; 2647 QStringList uidList;
2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() ); 2648 qDebug(" KABCore::callContactdialog:DESKTOP WIDTH %d ", QApplication::desktop()->width() );
2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2649 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2650 uint i=0; 2650 uint i=0;
2651 for (i=0; i < list.count(); i++) 2651 for (i=0; i < list.count(); i++)
2652 { 2652 {
2653 nameList.append(list[i].realName()); 2653 nameList.append(list[i].realName());
2654 emailList.append(list[i].preferredEmail()); 2654 emailList.append(list[i].preferredEmail());
2655 uidList.append(list[i].uid()); 2655 uidList.append(list[i].uid());
2656 } 2656 }
2657 QString uid = mEmailSourceUID; 2657 QString uid = mEmailSourceUID;
2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1()); 2658 //qDebug("%s %s ", sourceChannel.latin1(), uid.latin1());
2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList); 2659 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(mEmailSourceChannel, uid, nameList, emailList, uidList);
2660 running = false; 2660 running = false;
2661} 2661}
2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2662/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2663 * to put them into the calendar. 2663 * to put them into the calendar.
2664 */ 2664 */
2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2665void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2666{ 2666{
2667 // qDebug("KABCore::requestForBirthdayList"); 2667 // qDebug("KABCore::requestForBirthdayList");
2668 QStringList birthdayList; 2668 QStringList birthdayList;
2669 QStringList anniversaryList; 2669 QStringList anniversaryList;
2670 QStringList realNameList; 2670 QStringList realNameList;
2671 QStringList preferredEmailList; 2671 QStringList preferredEmailList;
2672 QStringList assembledNameList; 2672 QStringList assembledNameList;
2673 QStringList uidList; 2673 QStringList uidList;
2674 2674
2675 KABC::AddressBook::Iterator it; 2675 KABC::AddressBook::Iterator it;
2676 2676
2677 int count = 0; 2677 int count = 0;
2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2678 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2679 ++count; 2679 ++count;
2680 } 2680 }
2681 QProgressBar bar(count,0 ); 2681 QProgressBar bar(count,0 );
2682 int w = 300; 2682 int w = 300;
2683 if ( QApplication::desktop()->width() < 320 ) 2683 if ( QApplication::desktop()->width() < 320 )
2684 w = 220; 2684 w = 220;
2685 int h = bar.sizeHint().height() ; 2685 int h = bar.sizeHint().height() ;
2686 int dw = QApplication::desktop()->width(); 2686 int dw = QApplication::desktop()->width();
2687 int dh = QApplication::desktop()->height(); 2687 int dh = QApplication::desktop()->height();
2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2688 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2689 bar.show(); 2689 bar.show();
2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2690 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2691 qApp->processEvents(); 2691 qApp->processEvents();
2692 2692
2693 QDate bday; 2693 QDate bday;
2694 QString anni; 2694 QString anni;
2695 QString formattedbday; 2695 QString formattedbday;
2696 2696
2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2697 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2698 { 2698 {
2699 if ( ! bar.isVisible() ) 2699 if ( ! bar.isVisible() )
2700 return; 2700 return;
2701 bar.setProgress( count++ ); 2701 bar.setProgress( count++ );
2702 qApp->processEvents(); 2702 qApp->processEvents();
2703 bday = (*it).birthday().date(); 2703 bday = (*it).birthday().date();
2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2704 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2705 2705
2706 if ( bday.isValid() || !anni.isEmpty()) 2706 if ( bday.isValid() || !anni.isEmpty())
2707 { 2707 {
2708 if (bday.isValid()) 2708 if (bday.isValid())
2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2709 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2710 else 2710 else
2711 formattedbday = "NOTVALID"; 2711 formattedbday = "NOTVALID";
2712 if (anni.isEmpty()) 2712 if (anni.isEmpty())
2713 anni = "INVALID"; 2713 anni = "INVALID";
2714 2714
2715 birthdayList.append(formattedbday); 2715 birthdayList.append(formattedbday);
2716 anniversaryList.append(anni); //should be ISODate 2716 anniversaryList.append(anni); //should be ISODate
2717 realNameList.append((*it).realName()); 2717 realNameList.append((*it).realName());
2718 preferredEmailList.append((*it).preferredEmail()); 2718 preferredEmailList.append((*it).preferredEmail());
2719 assembledNameList.append((*it).realName()); 2719 assembledNameList.append((*it).realName());
2720 uidList.append((*it).uid()); 2720 uidList.append((*it).uid());
2721 2721
2722 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2722 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2723 } 2723 }
2724 } 2724 }
2725 2725
2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2726 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2727 2727
2728} 2728}
2729 2729
2730/* this method will be called through the QCop interface from other apps to show details of a contact. 2730/* this method will be called through the QCop interface from other apps to show details of a contact.
2731 */ 2731 */
2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2732void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2733{ 2733{
2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2734 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2735 2735
2736 QString foundUid = QString::null; 2736 QString foundUid = QString::null;
2737 if ( ! uid.isEmpty() ) { 2737 if ( ! uid.isEmpty() ) {
2738 Addressee adrr = mAddressBook->findByUid( uid ); 2738 Addressee adrr = mAddressBook->findByUid( uid );
2739 if ( !adrr.isEmpty() ) { 2739 if ( !adrr.isEmpty() ) {
2740 foundUid = uid; 2740 foundUid = uid;
2741 } 2741 }
2742 if ( email == "sendbacklist" ) { 2742 if ( email == "sendbacklist" ) {
2743 //qDebug("ssssssssssssssssssssssend "); 2743 //qDebug("ssssssssssssssssssssssend ");
2744 QStringList nameList; 2744 QStringList nameList;
2745 QStringList emailList; 2745 QStringList emailList;
2746 QStringList uidList; 2746 QStringList uidList;
2747 nameList.append(adrr.realName()); 2747 nameList.append(adrr.realName());
2748 emailList = adrr.emails(); 2748 emailList = adrr.emails();
2749 uidList.append( adrr.preferredEmail()); 2749 uidList.append( adrr.preferredEmail());
2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2750 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2751 return; 2751 return;
2752 } 2752 }
2753 2753
2754 } 2754 }
2755 2755
2756 if ( email == "sendbacklist" ) 2756 if ( email == "sendbacklist" )
2757 return; 2757 return;
2758 if (foundUid.isEmpty()) 2758 if (foundUid.isEmpty())
2759 { 2759 {
2760 //find the uid of the person first 2760 //find the uid of the person first
2761 Addressee::List namelist; 2761 Addressee::List namelist;
2762 Addressee::List emaillist; 2762 Addressee::List emaillist;
2763 2763
2764 if (!name.isEmpty()) 2764 if (!name.isEmpty())
2765 namelist = mAddressBook->findByName( name ); 2765 namelist = mAddressBook->findByName( name );
2766 2766
2767 if (!email.isEmpty()) 2767 if (!email.isEmpty())
2768 emaillist = mAddressBook->findByEmail( email ); 2768 emaillist = mAddressBook->findByEmail( email );
2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2769 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2770 //check if we have a match in Namelist and Emaillist 2770 //check if we have a match in Namelist and Emaillist
2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2771 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2772 foundUid = emaillist[0].uid(); 2772 foundUid = emaillist[0].uid();
2773 } 2773 }
2774 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2774 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2775 foundUid = namelist[0].uid(); 2775 foundUid = namelist[0].uid();
2776 else 2776 else
2777 { 2777 {
2778 for (int i = 0; i < namelist.count(); i++) 2778 for (int i = 0; i < namelist.count(); i++)
2779 { 2779 {
2780 for (int j = 0; j < emaillist.count(); j++) 2780 for (int j = 0; j < emaillist.count(); j++)
2781 { 2781 {
2782 if (namelist[i] == emaillist[j]) 2782 if (namelist[i] == emaillist[j])
2783 { 2783 {
2784 foundUid = namelist[i].uid(); 2784 foundUid = namelist[i].uid();
2785 } 2785 }
2786 } 2786 }
2787 } 2787 }
2788 } 2788 }
2789 } 2789 }
2790 else 2790 else
2791 { 2791 {
2792 foundUid = uid; 2792 foundUid = uid;
2793 } 2793 }
2794 2794
2795 if (!foundUid.isEmpty()) 2795 if (!foundUid.isEmpty())
2796 { 2796 {
2797 2797
2798 // raise Ka/Pi if it is in the background 2798 // raise Ka/Pi if it is in the background
2799#ifndef DESKTOP_VERSION 2799#ifndef DESKTOP_VERSION
2800#ifndef KORG_NODCOP 2800#ifndef KORG_NODCOP
2801 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2801 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2802#endif 2802#endif
2803#endif 2803#endif
2804 2804
2805 mMainWindow->showMaximized(); 2805 mMainWindow->showMaximized();
2806 mMainWindow-> raise(); 2806 mMainWindow-> raise();
2807 2807
2808 mViewManager->setSelected( "", false); 2808 mViewManager->setSelected( "", false);
2809 mViewManager->refreshView( "" ); 2809 mViewManager->refreshView( "" );
2810 mViewManager->setSelected( foundUid, true ); 2810 mViewManager->setSelected( foundUid, true );
2811 mViewManager->refreshView( foundUid ); 2811 mViewManager->refreshView( foundUid );
2812 2812
2813 if ( !mMultipleViewsAtOnce ) 2813 if ( !mMultipleViewsAtOnce )
2814 { 2814 {
2815 setDetailsVisible( true ); 2815 setDetailsVisible( true );
2816 mActionDetails->setChecked(true); 2816 mActionDetails->setChecked(true);
2817 } 2817 }
2818 } 2818 }
2819} 2819}
2820void KABCore::storagehowto() 2820void KABCore::storagehowto()
2821{ 2821{
2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 2822 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
2823} 2823}
2824void KABCore::whatsnew() 2824void KABCore::whatsnew()
2825{ 2825{
2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2826 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2827} 2827}
2828void KABCore::synchowto() 2828void KABCore::synchowto()
2829{ 2829{
2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2830 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2831} 2831}
2832void KABCore::kdesynchowto() 2832void KABCore::kdesynchowto()
2833{ 2833{
2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2834 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2835} 2835}
2836void KABCore::multisynchowto() 2836void KABCore::multisynchowto()
2837{ 2837{
2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2838 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2839} 2839}
2840void KABCore::faq() 2840void KABCore::faq()
2841{ 2841{
2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2842 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2843} 2843}
2844 2844
2845#include <libkcal/syncdefines.h> 2845#include <libkcal/syncdefines.h>
2846 2846
2847KABC::Addressee KABCore::getLastSyncAddressee() 2847KABC::Addressee KABCore::getLastSyncAddressee()
2848{ 2848{
2849 Addressee lse; 2849 Addressee lse;
2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2850 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2851 2851
2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2853 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2854 if (lse.isEmpty()) { 2854 if (lse.isEmpty()) {
2855 qDebug("KA: Creating new last-syncAddressee "); 2855 qDebug("KA: Creating new last-syncAddressee ");
2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2856 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2857 QString sum = ""; 2857 QString sum = "";
2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2859 sum = "E: "; 2859 sum = "E: ";
2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2860 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2861 lse.setRevision( mLastAddressbookSync ); 2861 lse.setRevision( mLastAddressbookSync );
2862 lse.setCategories( i18n("SyncEvent") ); 2862 lse.setCategories( i18n("SyncEvent") );
2863 mAddressBook->insertAddressee( lse ); 2863 mAddressBook->insertAddressee( lse );
2864 } 2864 }
2865 return lse; 2865 return lse;
2866} 2866}
2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2867int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2868{ 2868{
2869 2869
2870 //void setZaurusId(int id); 2870 //void setZaurusId(int id);
2871 // int zaurusId() const; 2871 // int zaurusId() const;
2872 // void setZaurusUid(int id); 2872 // void setZaurusUid(int id);
2873 // int zaurusUid() const; 2873 // int zaurusUid() const;
2874 // void setZaurusStat(int id); 2874 // void setZaurusStat(int id);
2875 // int zaurusStat() const; 2875 // int zaurusStat() const;
2876 // 0 equal 2876 // 0 equal
2877 // 1 take local 2877 // 1 take local
2878 // 2 take remote 2878 // 2 take remote
2879 // 3 cancel 2879 // 3 cancel
2880 QDateTime lastSync = mLastAddressbookSync; 2880 QDateTime lastSync = mLastAddressbookSync;
2881 QDateTime localMod = local->revision(); 2881 QDateTime localMod = local->revision();
2882 QDateTime remoteMod = remote->revision(); 2882 QDateTime remoteMod = remote->revision();
2883 2883
2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2884 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2885 2885
2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2886 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2887 bool remCh, locCh; 2887 bool remCh, locCh;
2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2888 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2889 //if ( remCh ) 2889 //if ( remCh )
2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2890 // qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2891 locCh = ( localMod > mLastAddressbookSync ); 2891 locCh = ( localMod > mLastAddressbookSync );
2892 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2892 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2893 if ( !remCh && ! locCh ) { 2893 if ( !remCh && ! locCh ) {
2894 //qDebug("both not changed "); 2894 //qDebug("both not changed ");
2895 lastSync = localMod.addDays(1); 2895 lastSync = localMod.addDays(1);
2896 if ( mode <= SYNC_PREF_ASK ) 2896 if ( mode <= SYNC_PREF_ASK )
2897 return 0; 2897 return 0;
2898 } else { 2898 } else {
2899 if ( locCh ) { 2899 if ( locCh ) {
2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2900 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2901 lastSync = localMod.addDays( -1 ); 2901 lastSync = localMod.addDays( -1 );
2902 if ( !remCh ) 2902 if ( !remCh )
2903 remoteMod =( lastSync.addDays( -1 ) ); 2903 remoteMod =( lastSync.addDays( -1 ) );
2904 } else { 2904 } else {
2905 //qDebug(" not loc changed "); 2905 //qDebug(" not loc changed ");
2906 lastSync = localMod.addDays( 1 ); 2906 lastSync = localMod.addDays( 1 );
2907 if ( remCh ) { 2907 if ( remCh ) {
2908 //qDebug("rem changed "); 2908 //qDebug("rem changed ");
2909 remoteMod =( lastSync.addDays( 1 ) ); 2909 remoteMod =( lastSync.addDays( 1 ) );
2910 } 2910 }
2911 2911
2912 } 2912 }
2913 } 2913 }
2914 full = true; 2914 full = true;
2915 if ( mode < SYNC_PREF_ASK ) 2915 if ( mode < SYNC_PREF_ASK )
2916 mode = SYNC_PREF_ASK; 2916 mode = SYNC_PREF_ASK;
2917 } else { 2917 } else {
2918 if ( localMod == remoteMod ) 2918 if ( localMod == remoteMod )
2919 return 0; 2919 return 0;
2920 2920
2921 } 2921 }
2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2922 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2923 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2923 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2924 //full = true; //debug only 2924 //full = true; //debug only
2925 if ( full ) { 2925 if ( full ) {
2926 bool equ = ( (*local) == (*remote) ); 2926 bool equ = ( (*local) == (*remote) );
2927 if ( equ ) { 2927 if ( equ ) {
2928 //qDebug("equal "); 2928 //qDebug("equal ");
2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2929 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2930 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2931 } 2931 }
2932 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2932 if ( mode < SYNC_PREF_FORCE_LOCAL )
2933 return 0; 2933 return 0;
2934 2934
2935 }//else //debug only 2935 }//else //debug only
2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2936 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2937 } 2937 }
2938 int result; 2938 int result;
2939 bool localIsNew; 2939 bool localIsNew;
2940 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2940 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2941 2941
2942 if ( full && mode < SYNC_PREF_NEWEST ) 2942 if ( full && mode < SYNC_PREF_NEWEST )
2943 mode = SYNC_PREF_ASK; 2943 mode = SYNC_PREF_ASK;
2944 2944
2945 switch( mode ) { 2945 switch( mode ) {
2946 case SYNC_PREF_LOCAL: 2946 case SYNC_PREF_LOCAL:
2947 if ( lastSync > remoteMod ) 2947 if ( lastSync > remoteMod )
2948 return 1; 2948 return 1;
2949 if ( lastSync > localMod ) 2949 if ( lastSync > localMod )
2950 return 2; 2950 return 2;
2951 return 1; 2951 return 1;
2952 break; 2952 break;
2953 case SYNC_PREF_REMOTE: 2953 case SYNC_PREF_REMOTE:
2954 if ( lastSync > localMod ) 2954 if ( lastSync > localMod )
2955 return 2; 2955 return 2;
2956 if ( lastSync > remoteMod ) 2956 if ( lastSync > remoteMod )
2957 return 1; 2957 return 1;
2958 return 2; 2958 return 2;
2959 break; 2959 break;
2960 case SYNC_PREF_NEWEST: 2960 case SYNC_PREF_NEWEST:
2961 if ( localMod > remoteMod ) 2961 if ( localMod > remoteMod )
2962 return 1; 2962 return 1;
2963 else 2963 else
2964 return 2; 2964 return 2;
2965 break; 2965 break;
2966 case SYNC_PREF_ASK: 2966 case SYNC_PREF_ASK:
2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2967 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2968 if ( lastSync > remoteMod && lastSync > localMod) 2968 if ( lastSync > remoteMod && lastSync > localMod)
2969 return 0; 2969 return 0;
2970 if ( lastSync > remoteMod ) 2970 if ( lastSync > remoteMod )
2971 return 1; 2971 return 1;
2972 if ( lastSync > localMod ) { 2972 if ( lastSync > localMod ) {
2973 return 2; 2973 return 2;
2974 } 2974 }
2975 localIsNew = localMod >= remoteMod; 2975 localIsNew = localMod >= remoteMod;
2976 //qDebug("conflict! ************************************** "); 2976 //qDebug("conflict! ************************************** ");
2977 { 2977 {
2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2978 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2979 result = acd.executeD(localIsNew); 2979 result = acd.executeD(localIsNew);
2980 return result; 2980 return result;
2981 } 2981 }
2982 break; 2982 break;
2983 case SYNC_PREF_FORCE_LOCAL: 2983 case SYNC_PREF_FORCE_LOCAL:
2984 return 1; 2984 return 1;
2985 break; 2985 break;
2986 case SYNC_PREF_FORCE_REMOTE: 2986 case SYNC_PREF_FORCE_REMOTE:
2987 return 2; 2987 return 2;
2988 break; 2988 break;
2989 2989
2990 default: 2990 default:
2991 // SYNC_PREF_TAKE_BOTH not implemented 2991 // SYNC_PREF_TAKE_BOTH not implemented
2992 break; 2992 break;
2993 } 2993 }
2994 return 0; 2994 return 0;
2995} 2995}
2996 2996
2997 2997
2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2998bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2999{ 2999{
3000 bool syncOK = true; 3000 bool syncOK = true;
3001 int addedAddressee = 0; 3001 int addedAddressee = 0;
3002 int addedAddresseeR = 0; 3002 int addedAddresseeR = 0;
3003 int deletedAddresseeR = 0; 3003 int deletedAddresseeR = 0;
3004 int deletedAddresseeL = 0; 3004 int deletedAddresseeL = 0;
3005 int changedLocal = 0; 3005 int changedLocal = 0;
3006 int changedRemote = 0; 3006 int changedRemote = 0;
3007 int filteredIN = 0; 3007 int filteredIN = 0;
3008 int filteredOUT = 0; 3008 int filteredOUT = 0;
3009 3009
3010 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 3010 QString mCurrentSyncName = syncManager->getCurrentSyncName();
3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3011 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3012 3012
3013 //QPtrList<Addressee> el = local->rawAddressees(); 3013 //QPtrList<Addressee> el = local->rawAddressees();
3014 Addressee addresseeR; 3014 Addressee addresseeR;
3015 QString uid; 3015 QString uid;
3016 int take; 3016 int take;
3017 Addressee addresseeL; 3017 Addressee addresseeL;
3018 Addressee addresseeRSync; 3018 Addressee addresseeRSync;
3019 Addressee addresseeLSync; 3019 Addressee addresseeLSync;
3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 3020 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 3021 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
3022 bool fullDateRange = false; 3022 bool fullDateRange = false;
3023 local->resetTempSyncStat(); 3023 local->resetTempSyncStat();
3024 mLastAddressbookSync = QDateTime::currentDateTime(); 3024 mLastAddressbookSync = QDateTime::currentDateTime();
3025 if ( syncManager->syncWithDesktop() ) { 3025 if ( syncManager->syncWithDesktop() ) {
3026 // remote->removeSyncInfo( QString());//remove all info 3026 // remote->removeSyncInfo( QString());//remove all info
3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 3027 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 3028 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 3029 qDebug("KA: using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
3030 } else { 3030 } else {
3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime "); 3031 qDebug("KA: KSyncManager::mRequestedSyncEvent has invalid datatime ");
3032 } 3032 }
3033 } 3033 }
3034 QDateTime modifiedCalendar = mLastAddressbookSync; 3034 QDateTime modifiedCalendar = mLastAddressbookSync;
3035 addresseeLSync = getLastSyncAddressee(); 3035 addresseeLSync = getLastSyncAddressee();
3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1()); 3036 qDebug("KA: Last Sync %s ", addresseeLSync.revision().toString().latin1());
3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 3037 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
3038 if ( !addresseeR.isEmpty() ) { 3038 if ( !addresseeR.isEmpty() ) {
3039 addresseeRSync = addresseeR; 3039 addresseeRSync = addresseeR;
3040 remote->removeAddressee(addresseeR ); 3040 remote->removeAddressee(addresseeR );
3041 3041
3042 } else { 3042 } else {
3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3044 addresseeRSync = addresseeLSync ; 3044 addresseeRSync = addresseeLSync ;
3045 } else { 3045 } else {
3046 //qDebug("FULLDATE 1"); 3046 //qDebug("FULLDATE 1");
3047 fullDateRange = true; 3047 fullDateRange = true;
3048 Addressee newAdd; 3048 Addressee newAdd;
3049 addresseeRSync = newAdd; 3049 addresseeRSync = newAdd;
3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 3050 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 3051 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
3052 addresseeRSync.setRevision( mLastAddressbookSync ); 3052 addresseeRSync.setRevision( mLastAddressbookSync );
3053 addresseeRSync.setCategories( i18n("SyncAddressee") ); 3053 addresseeRSync.setCategories( i18n("SyncAddressee") );
3054 } 3054 }
3055 } 3055 }
3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 3056 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
3057 // qDebug("FULLDATE 2"); 3057 // qDebug("FULLDATE 2");
3058 fullDateRange = true; 3058 fullDateRange = true;
3059 } 3059 }
3060 if ( ! fullDateRange ) { 3060 if ( ! fullDateRange ) {
3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 3061 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
3062 3062
3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 3063 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 3064 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
3065 fullDateRange = true; 3065 fullDateRange = true;
3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 3066 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
3067 } 3067 }
3068 } 3068 }
3069 // fullDateRange = true; // debug only! 3069 // fullDateRange = true; // debug only!
3070 if ( fullDateRange ) 3070 if ( fullDateRange )
3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 3071 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
3072 else 3072 else
3073 mLastAddressbookSync = addresseeLSync.revision(); 3073 mLastAddressbookSync = addresseeLSync.revision();
3074 // for resyncing if own file has changed 3074 // for resyncing if own file has changed
3075 // PENDING fixme later when implemented 3075 // PENDING fixme later when implemented
3076#if 0 3076#if 0
3077 if ( mCurrentSyncDevice == "deleteaftersync" ) { 3077 if ( mCurrentSyncDevice == "deleteaftersync" ) {
3078 mLastAddressbookSync = loadedFileVersion; 3078 mLastAddressbookSync = loadedFileVersion;
3079 qDebug("setting mLastAddressbookSync "); 3079 qDebug("setting mLastAddressbookSync ");
3080 } 3080 }
3081#endif 3081#endif
3082 3082
3083 3083
3084 // ********** setting filters **************** 3084 // ********** setting filters ****************
3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 3085 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 3086 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
3087 3087
3088 //qDebug("*************************** "); 3088 //qDebug("*************************** ");
3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 3089 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
3090 QStringList er = remote->uidList(); 3090 QStringList er = remote->uidList();
3091 Addressee inR ;//= er.first(); 3091 Addressee inR ;//= er.first();
3092 Addressee inL; 3092 Addressee inL;
3093 3093
3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 3094 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
3095 3095
3096 int modulo = (er.count()/10)+1; 3096 int modulo = (er.count()/10)+1;
3097 int incCounter = 0; 3097 int incCounter = 0;
3098 while ( incCounter < er.count()) { 3098 while ( incCounter < er.count()) {
3099 if (syncManager->isProgressBarCanceled()) 3099 if (syncManager->isProgressBarCanceled())
3100 return false; 3100 return false;
3101 if ( incCounter % modulo == 0 ) 3101 if ( incCounter % modulo == 0 )
3102 syncManager->showProgressBar(incCounter); 3102 syncManager->showProgressBar(incCounter);
3103 3103
3104 uid = er[ incCounter ]; 3104 uid = er[ incCounter ];
3105 bool skipIncidence = false; 3105 bool skipIncidence = false;
3106 if ( uid.left(19) == QString("last-syncAddressee-") ) 3106 if ( uid.left(19) == QString("last-syncAddressee-") )
3107 skipIncidence = true; 3107 skipIncidence = true;
3108 QString idS,OidS; 3108 QString idS,OidS;
3109 qApp->processEvents(); 3109 qApp->processEvents();
3110 if ( !skipIncidence ) { 3110 if ( !skipIncidence ) {
3111 inL = local->findByUid( uid ); 3111 inL = local->findByUid( uid );
3112 inR = remote->findByUid( uid ); 3112 inR = remote->findByUid( uid );
3113 //inL.setResource( 0 ); 3113 //inL.setResource( 0 );
3114 //inR.setResource( 0 ); 3114 //inR.setResource( 0 );
3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 3115 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
3116 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3116 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 3117 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
3118 //qDebug("take %d %s ", take, inL.summary().latin1()); 3118 //qDebug("take %d %s ", take, inL.summary().latin1());
3119 if ( take == 3 ) 3119 if ( take == 3 )
3120 return false; 3120 return false;
3121 if ( take == 1 ) {// take local ********************** 3121 if ( take == 1 ) {// take local **********************
3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3123 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3124 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3125 local->insertAddressee( inL, false ); 3125 local->insertAddressee( inL, false );
3126 idS = inR.externalUID(); 3126 idS = inR.externalUID();
3127 OidS = inR.originalExternalUID(); 3127 OidS = inR.originalExternalUID();
3128 } 3128 }
3129 else 3129 else
3130 idS = inR.IDStr(); 3130 idS = inR.IDStr();
3131 remote->removeAddressee( inR ); 3131 remote->removeAddressee( inR );
3132 inR = inL; 3132 inR = inL;
3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 3133 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3134 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3135 inR.setOriginalExternalUID( OidS ); 3135 inR.setOriginalExternalUID( OidS );
3136 inR.setExternalUID( idS ); 3136 inR.setExternalUID( idS );
3137 if ( syncManager->syncWithDesktop() ) { 3137 if ( syncManager->syncWithDesktop() ) {
3138 inR.setIDStr("changed" ); 3138 inR.setIDStr("changed" );
3139 } 3139 }
3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 3140 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
3141 } else { 3141 } else {
3142 inR.setIDStr( idS ); 3142 inR.setIDStr( idS );
3143 } 3143 }
3144 inR.setResource( 0 ); 3144 inR.setResource( 0 );
3145 remote->insertAddressee( inR , false); 3145 remote->insertAddressee( inR , false);
3146 ++changedRemote; 3146 ++changedRemote;
3147 } else { // take == 2 take remote ********************** 3147 } else { // take == 2 take remote **********************
3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3149 if ( inR.revision().date().year() < 2004 ) 3149 if ( inR.revision().date().year() < 2004 )
3150 inR.setRevision( modifiedCalendar ); 3150 inR.setRevision( modifiedCalendar );
3151 } 3151 }
3152 idS = inL.IDStr(); 3152 idS = inL.IDStr();
3153 local->removeAddressee( inL ); 3153 local->removeAddressee( inL );
3154 inL = inR; 3154 inL = inR;
3155 inL.setIDStr( idS ); 3155 inL.setIDStr( idS );
3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3157 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3158 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3159 } 3159 }
3160 inL.setResource( 0 ); 3160 inL.setResource( 0 );
3161 local->insertAddressee( inL , false ); 3161 local->insertAddressee( inL , false );
3162 ++changedLocal; 3162 ++changedLocal;
3163 } 3163 }
3164 } 3164 }
3165 } 3165 }
3166 } else { // no conflict ********** add or delete remote 3166 } else { // no conflict ********** add or delete remote
3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 3167 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3168 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3169 QString des = addresseeLSync.note(); 3169 QString des = addresseeLSync.note();
3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 3170 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 3171 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
3172 remote->insertAddressee( inR, false ); 3172 remote->insertAddressee( inR, false );
3173 ++deletedAddresseeR; 3173 ++deletedAddresseeR;
3174 } else { 3174 } else {
3175 inR.setRevision( modifiedCalendar ); 3175 inR.setRevision( modifiedCalendar );
3176 remote->insertAddressee( inR, false ); 3176 remote->insertAddressee( inR, false );
3177 inL = inR; 3177 inL = inR;
3178 inL.setIDStr( ":" ); 3178 inL.setIDStr( ":" );
3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 3179 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 3180 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
3181 inL.setResource( 0 ); 3181 inL.setResource( 0 );
3182 local->insertAddressee( inL , false); 3182 local->insertAddressee( inL , false);
3183 ++addedAddressee; 3183 ++addedAddressee;
3184 } 3184 }
3185 } else { 3185 } else {
3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3186 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
3187 inR.setRevision( modifiedCalendar ); 3187 inR.setRevision( modifiedCalendar );
3188 remote->insertAddressee( inR, false ); 3188 remote->insertAddressee( inR, false );
3189 inR.setResource( 0 ); 3189 inR.setResource( 0 );
3190 local->insertAddressee( inR, false ); 3190 local->insertAddressee( inR, false );
3191 ++addedAddressee; 3191 ++addedAddressee;
3192 } else { 3192 } else {
3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3193 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
3194 remote->removeAddressee( inR ); 3194 remote->removeAddressee( inR );
3195 ++deletedAddresseeR; 3195 ++deletedAddresseeR;
3196 } 3196 }
3197 } 3197 }
3198 } else { 3198 } else {
3199 ++filteredIN; 3199 ++filteredIN;
3200 } 3200 }
3201 } 3201 }
3202 } 3202 }
3203 ++incCounter; 3203 ++incCounter;
3204 } 3204 }
3205 er.clear(); 3205 er.clear();
3206 QStringList el = local->uidList(); 3206 QStringList el = local->uidList();
3207 modulo = (el.count()/10)+1; 3207 modulo = (el.count()/10)+1;
3208 3208
3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3209 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3210 incCounter = 0; 3210 incCounter = 0;
3211 while ( incCounter < el.count()) { 3211 while ( incCounter < el.count()) {
3212 qApp->processEvents(); 3212 qApp->processEvents();
3213 if (syncManager->isProgressBarCanceled()) 3213 if (syncManager->isProgressBarCanceled())
3214 return false; 3214 return false;
3215 if ( incCounter % modulo == 0 ) 3215 if ( incCounter % modulo == 0 )
3216 syncManager->showProgressBar(incCounter); 3216 syncManager->showProgressBar(incCounter);
3217 uid = el[ incCounter ]; 3217 uid = el[ incCounter ];
3218 bool skipIncidence = false; 3218 bool skipIncidence = false;
3219 if ( uid.left(19) == QString("last-syncAddressee-") ) 3219 if ( uid.left(19) == QString("last-syncAddressee-") )
3220 skipIncidence = true; 3220 skipIncidence = true;
3221 if ( !skipIncidence ) { 3221 if ( !skipIncidence ) {
3222 inL = local->findByUid( uid ); 3222 inL = local->findByUid( uid );
3223 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3223 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3224 inR = remote->findByUid( uid ); 3224 inR = remote->findByUid( uid );
3225 if ( inR.isEmpty() ){ 3225 if ( inR.isEmpty() ){
3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3226 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3227 // no conflict ********** add or delete local 3227 // no conflict ********** add or delete local
3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3228 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3229 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3230 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3231 local->removeAddressee( inL ); 3231 local->removeAddressee( inL );
3232 ++deletedAddresseeL; 3232 ++deletedAddresseeL;
3233 } else { 3233 } else {
3234 if ( ! syncManager->mWriteBackExistingOnly ) { 3234 if ( ! syncManager->mWriteBackExistingOnly ) {
3235 inL.removeID(mCurrentSyncDevice ); 3235 inL.removeID(mCurrentSyncDevice );
3236 ++addedAddresseeR; 3236 ++addedAddresseeR;
3237 inL.setRevision( modifiedCalendar ); 3237 inL.setRevision( modifiedCalendar );
3238 local->insertAddressee( inL, false ); 3238 local->insertAddressee( inL, false );
3239 inR = inL; 3239 inR = inL;
3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3240 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3241 inR.setResource( 0 ); 3241 inR.setResource( 0 );
3242 remote->insertAddressee( inR, false ); 3242 remote->insertAddressee( inR, false );
3243 } 3243 }
3244 } 3244 }
3245 } else { 3245 } else {
3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3246 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3247 //qDebug("data %s ", inL.revision().toString().latin1()); 3247 //qDebug("data %s ", inL.revision().toString().latin1());
3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3248 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3249 local->removeAddressee( inL ); 3249 local->removeAddressee( inL );
3250 ++deletedAddresseeL; 3250 ++deletedAddresseeL;
3251 } else { 3251 } else {
3252 if ( ! syncManager->mWriteBackExistingOnly ) { 3252 if ( ! syncManager->mWriteBackExistingOnly ) {
3253 ++addedAddresseeR; 3253 ++addedAddresseeR;
3254 inL.setRevision( modifiedCalendar ); 3254 inL.setRevision( modifiedCalendar );
3255 local->insertAddressee( inL, false ); 3255 local->insertAddressee( inL, false );
3256 inR = inL; 3256 inR = inL;
3257 inR.setIDStr( ":" ); 3257 inR.setIDStr( ":" );
3258 inR.setResource( 0 ); 3258 inR.setResource( 0 );
3259 remote->insertAddressee( inR, false ); 3259 remote->insertAddressee( inR, false );
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 } else { 3263 } else {
3264 ++filteredOUT; 3264 ++filteredOUT;
3265 } 3265 }
3266 } 3266 }
3267 } 3267 }
3268 } 3268 }
3269 ++incCounter; 3269 ++incCounter;
3270 } 3270 }
3271 el.clear(); 3271 el.clear();
3272 syncManager->hideProgressBar(); 3272 syncManager->hideProgressBar();
3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3273 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3274 // get rid of micro seconds 3274 // get rid of micro seconds
3275 QTime t = mLastAddressbookSync.time(); 3275 QTime t = mLastAddressbookSync.time();
3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3276 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3277 addresseeLSync.setRevision( mLastAddressbookSync ); 3277 addresseeLSync.setRevision( mLastAddressbookSync );
3278 addresseeRSync.setRevision( mLastAddressbookSync ); 3278 addresseeRSync.setRevision( mLastAddressbookSync );
3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3279 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3280 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3281 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3282 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3283 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3284 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3285 addresseeRSync.setNote( "" ) ; 3285 addresseeRSync.setNote( "" ) ;
3286 addresseeLSync.setNote( "" ); 3286 addresseeLSync.setNote( "" );
3287 3287
3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3288 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3289 remote->insertAddressee( addresseeRSync, false ); 3289 remote->insertAddressee( addresseeRSync, false );
3290 local->insertAddressee( addresseeLSync, false ); 3290 local->insertAddressee( addresseeLSync, false );
3291 QString mes; 3291 QString mes;
3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3292 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3293 qDebug( mes ); 3293 qDebug( mes );
3294 mes = i18n("Local addressbook changed!\n") +mes; 3294 mes = i18n("Local addressbook changed!\n") +mes;
3295 if ( syncManager->mShowSyncSummary ) { 3295 if ( syncManager->mShowSyncSummary ) {
3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3296 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3297 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3298 qDebug("KA: WB cancelled "); 3298 qDebug("KA: WB cancelled ");
3299 syncManager->mWriteBackFile = false; 3299 syncManager->mWriteBackFile = false;
3300 return syncOK; 3300 return syncOK;
3301 } 3301 }
3302 } 3302 }
3303 return syncOK; 3303 return syncOK;
3304} 3304}
3305 3305
3306 3306
3307//this is a overwritten callbackmethods from the syncinterface 3307//this is a overwritten callbackmethods from the syncinterface
3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3308bool KABCore::sync(KSyncManager* manager, QString filename, int mode,QString resource)
3309{ 3309{
3310 3310
3311 //pending prepare addresseeview for output 3311 //pending prepare addresseeview for output
3312 //pending detect, if remote file has REV field. if not switch to external sync 3312 //pending detect, if remote file has REV field. if not switch to external sync
3313 mGlobalSyncMode = SYNC_MODE_NORMAL; 3313 mGlobalSyncMode = SYNC_MODE_NORMAL;
3314 if ( manager != syncManager ) 3314 if ( manager != syncManager )
3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3315 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3316 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3317 3317
3318 AddressBook abLocal(filename,"syncContact"); 3318 AddressBook abLocal(filename,"syncContact");
3319 bool syncOK = false; 3319 bool syncOK = false;
3320 if ( abLocal.load() ) { 3320 if ( abLocal.load() ) {
3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode ); 3321 qDebug("KA: Sync::AB loaded %s,sync mode %d",filename.latin1(), mode );
3322 bool external = false; 3322 bool external = false;
3323 bool isXML = false; 3323 bool isXML = false;
3324 if ( filename.right(4) == ".xml") { 3324 if ( filename.right(4) == ".xml") {
3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3325 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3326 isXML = true; 3326 isXML = true;
3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3327 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3328 } else { 3328 } else {
3329 external = !manager->mIsKapiFile; 3329 external = !manager->mIsKapiFile;
3330 if ( external ) { 3330 if ( external ) {
3331 qDebug("KA: Sync::Setting vcf mode to external "); 3331 qDebug("KA: Sync::Setting vcf mode to external ");
3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3332 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3333 AddressBook::Iterator it; 3333 AddressBook::Iterator it;
3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3334 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3335 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3335 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3336 (*it).computeCsum( mCurrentSyncDevice ); 3336 (*it).computeCsum( mCurrentSyncDevice );
3337 } 3337 }
3338 } 3338 }
3339 } 3339 }
3340 //AddressBook::Iterator it; 3340 //AddressBook::Iterator it;
3341 //QStringList vcards; 3341 //QStringList vcards;
3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3342 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3343 // qDebug("Name %s ", (*it).familyName().latin1()); 3343 // qDebug("Name %s ", (*it).familyName().latin1());
3344 //} 3344 //}
3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3345 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3346 syncManager->hideProgressBar(); 3346 syncManager->hideProgressBar();
3347 if ( syncOK ) { 3347 if ( syncOK ) {
3348 if ( syncManager->mWriteBackFile ) 3348 if ( syncManager->mWriteBackFile )
3349 { 3349 {
3350 if ( external ) 3350 if ( external )
3351 abLocal.removeSyncAddressees( !isXML); 3351 abLocal.removeSyncAddressees( !isXML);
3352 qDebug("KA: Sync::Saving remote AB "); 3352 qDebug("KA: Sync::Saving remote AB ");
3353 if ( ! abLocal.saveAB()) 3353 if ( ! abLocal.saveAB())
3354 qDebug("KA: sync::Error writing back AB to file "); 3354 qDebug("KA: sync::Error writing back AB to file ");
3355 if ( external ) { 3355 if ( external ) {
3356 // afterwrite processing 3356 // afterwrite processing
3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3357 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3358 } 3358 }
3359 } 3359 }
3360 } 3360 }
3361 setModified(); 3361 setModified();
3362 3362
3363 } 3363 }
3364 abLocal.removeResources(); 3364 abLocal.removeResources();
3365 if ( syncOK ) 3365 if ( syncOK )
3366 mViewManager->refreshView(); 3366 mViewManager->refreshView();
3367 return syncOK; 3367 return syncOK;
3368 3368
3369} 3369}
3370void KABCore::removeSyncInfo( QString syncProfile) 3370void KABCore::removeSyncInfo( QString syncProfile)
3371{ 3371{
3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3372 qDebug("KA: AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3373 mAddressBook->removeSyncInfo( syncProfile ); 3373 mAddressBook->removeSyncInfo( syncProfile );
3374 setModified(); 3374 setModified();
3375} 3375}
3376 3376
3377 3377
3378//this is a overwritten callbackmethods from the syncinterface 3378//this is a overwritten callbackmethods from the syncinterface
3379bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3379bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3380{ 3380{
3381 if ( resource == "phone" ) 3381 if ( resource == "phone" )
3382 return syncPhone(); 3382 return syncPhone();
3383 disableBR( true ); 3383 disableBR( true );
3384 if ( manager != syncManager ) 3384 if ( manager != syncManager )
3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3385 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3386 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3387 3387
3388 AddressBook abLocal( resource,"syncContact"); 3388 AddressBook abLocal( resource,"syncContact");
3389 bool syncOK = false; 3389 bool syncOK = false;
3390 message(i18n("Loading DTM address data..."), false); 3390 message(i18n("Loading DTM address data..."), false);
3391 if ( abLocal.load() ) { 3391 if ( abLocal.load() ) {
3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3392 qDebug("KA: AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3393 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3394 message(i18n("Sync preprocessing..."),false); 3394 message(i18n("Sync preprocessing..."),false);
3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3395 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3396 message(i18n("Synchronizing..."),false); 3396 message(i18n("Synchronizing..."),false);
3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3397 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3398 syncManager->hideProgressBar(); 3398 syncManager->hideProgressBar();
3399 if ( syncOK ) { 3399 if ( syncOK ) {
3400 if ( syncManager->mWriteBackFile ) { 3400 if ( syncManager->mWriteBackFile ) {
3401 abLocal.removeSyncAddressees( false ); 3401 abLocal.removeSyncAddressees( false );
3402 message(i18n("Saving DTM address data..."),false); 3402 message(i18n("Saving DTM address data..."),false);
3403 abLocal.saveAB(); 3403 abLocal.saveAB();
3404 message(i18n("Sync postprocessing..."),false); 3404 message(i18n("Sync postprocessing..."),false);
3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3405 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3406 } 3406 }
3407 } else 3407 } else
3408 message( i18n("Sync cancelled or failed.") ); 3408 message( i18n("Sync cancelled or failed.") );
3409 setModified(); 3409 setModified();
3410 } 3410 }
3411 abLocal.removeResources(); 3411 abLocal.removeResources();
3412 if ( syncOK ) { 3412 if ( syncOK ) {
3413 mViewManager->refreshView(); 3413 mViewManager->refreshView();
3414 message(i18n("DTM syncing finished.")); 3414 message(i18n("DTM syncing finished."));
3415 } 3415 }
3416 disableBR( false ); 3416 disableBR( false );
3417 return syncOK; 3417 return syncOK;
3418 3418
3419} 3419}
3420void KABCore::message( QString m, bool startTimer) 3420void KABCore::message( QString m, bool startTimer)
3421{ 3421{
3422 topLevelWidget()->setCaption( m ); 3422 topLevelWidget()->setCaption( m );
3423 qApp->processEvents(); 3423 qApp->processEvents();
3424 if ( startTimer ) 3424 if ( startTimer )
3425 mMessageTimer->start( 15000, true ); 3425 mMessageTimer->start( 15000, true );
3426 else 3426 else
3427 mMessageTimer->stop(); 3427 mMessageTimer->stop();
3428} 3428}
3429bool KABCore::syncPhone() 3429bool KABCore::syncPhone()
3430{ 3430{
3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3431 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3432 QString fileName = getPhoneFile(); 3432 QString fileName = getPhoneFile();
3433 if ( !PhoneAccess::readFromPhone( fileName) ) { 3433 if ( !PhoneAccess::readFromPhone( fileName) ) {
3434 message(i18n("Phone access failed!")); 3434 message(i18n("Phone access failed!"));
3435 return false; 3435 return false;
3436 } 3436 }
3437 AddressBook abLocal( fileName,"syncContact"); 3437 AddressBook abLocal( fileName,"syncContact");
3438 bool syncOK = false; 3438 bool syncOK = false;
3439 { 3439 {
3440 abLocal.importFromFile( fileName ); 3440 abLocal.importFromFile( fileName );
3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3441 qDebug("KA: AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3442 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3443 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3444 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3445 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3446 syncManager->hideProgressBar(); 3446 syncManager->hideProgressBar();
3447 if ( syncOK ) { 3447 if ( syncOK ) {
3448 if ( syncManager->mWriteBackFile ) { 3448 if ( syncManager->mWriteBackFile ) {
3449 abLocal.removeSyncAddressees( true ); 3449 abLocal.removeSyncAddressees( true );
3450 abLocal.saveABphone( fileName ); 3450 abLocal.saveABphone( fileName );
3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3451 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3452 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3453 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3454 } 3454 }
3455 } 3455 }
3456 setModified(); 3456 setModified();
3457 } 3457 }
3458 abLocal.removeResources(); 3458 abLocal.removeResources();
3459 if ( syncOK ) 3459 if ( syncOK )
3460 mViewManager->refreshView(); 3460 mViewManager->refreshView();
3461 return syncOK; 3461 return syncOK;
3462} 3462}
3463void KABCore::getFile( bool success ) 3463void KABCore::getFile( bool success )
3464{ 3464{
3465 if ( ! success ) { 3465 if ( ! success ) {
3466 message( i18n("Error receiving file. Nothing changed!") ); 3466 message( i18n("Error receiving file. Nothing changed!") );
3467 return; 3467 return;
3468 } 3468 }
3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3469 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3470 if ( count ) 3470 if ( count )
3471 setModified( true ); 3471 setModified( true );
3472 message( i18n("Pi-Sync successful!") ); 3472 message( i18n("Pi-Sync successful!") );
3473 mViewManager->refreshView(); 3473 mViewManager->refreshView();
3474} 3474}
3475void KABCore::syncFileRequest() 3475void KABCore::syncFileRequest()
3476{ 3476{
3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3477 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3478 syncManager->slotSyncMenu( 999 ); 3478 syncManager->slotSyncMenu( 999 );
3479 } 3479 }
3480 mAddressBook->export2File( sentSyncFile() ); 3480 mAddressBook->export2File( sentSyncFile() );
3481} 3481}
3482QString KABCore::sentSyncFile() 3482QString KABCore::sentSyncFile()
3483{ 3483{
3484#ifdef DESKTOP_VERSION 3484#ifdef DESKTOP_VERSION
3485 return locateLocal( "tmp", "copysyncab.vcf" ); 3485 return locateLocal( "tmp", "copysyncab.vcf" );
3486#else 3486#else
3487 return QString( "/tmp/copysyncab.vcf" ); 3487 return QString( "/tmp/copysyncab.vcf" );
3488#endif 3488#endif
3489} 3489}
3490 3490
3491void KABCore::setCaptionBack() 3491void KABCore::setCaptionBack()
3492{ 3492{
3493 mMessageTimer->stop(); 3493 mMessageTimer->stop();
3494 topLevelWidget()->setCaption( i18n("KA/Pi") ); 3494 topLevelWidget()->setCaption( i18n("KA/Pi") );
3495} 3495}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 42b7709..c4a0b3b 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,535 +1,535 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 98
99 99
100 /** 100 /**
101 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
102 */ 102 */
103 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
104 104
105 /** 105 /**
106 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
107 */ 107 */
108 static KConfig *config(); 108 static KConfig *config();
109 109
110 /** 110 /**
111 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
112 other classes can register their actions easily. 112 other classes can register their actions easily.
113 */ 113 */
114 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
115 115
116 /** 116 /**
117 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
118 */ 118 */
119 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
120 120
121 /** 121 /**
122 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
123 */ 123 */
124 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
125 125
126 /** 126 /**
127 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
128 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
129 the user. 129 the user.
130 */ 130 */
131 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
132 132
133#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
134 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 136
137#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
138 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
139 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
140#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
141 141
142 public slots: 142 public slots:
143#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
144 void createAboutData(); 144 void createAboutData();
145#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
146 void setDetailsToggle(); 146 void setDetailsToggle();
147 147
148 void showLicence(); 148 void showLicence();
149 void faq(); 149 void faq();
150 void whatsnew() ; 150 void whatsnew() ;
151 void synchowto() ; 151 void synchowto() ;
152 void storagehowto() ; 152 void storagehowto() ;
153 void multisynchowto() ; 153 void multisynchowto() ;
154 void kdesynchowto() ; 154 void kdesynchowto() ;
155 void writeToPhone(); 155 void writeToPhone();
156 156
157 /** 157 /**
158 Is called whenever a contact is selected in the view. 158 Is called whenever a contact is selected in the view.
159 */ 159 */
160 void setContactSelected( const QString &uid ); 160 void setContactSelected( const QString &uid );
161 161
162 /** 162 /**
163 Opens the preferred mail composer with all selected contacts as 163 Opens the preferred mail composer with all selected contacts as
164 arguments. 164 arguments.
165 */ 165 */
166 void sendMail(); 166 void sendMail();
167 167
168 /** 168 /**
169 Opens the preferred mail composer with the given contacts as 169 Opens the preferred mail composer with the given contacts as
170 arguments. 170 arguments.
171 */ 171 */
172 void sendMail( const QString& email ); 172 void sendMail( const QString& email );
173 173
174 174
175 void mailVCard(); 175 void mailVCard();
176 void mailVCard(const QStringList& uids); 176 void mailVCard(const QStringList& uids);
177 177
178 /** 178 /**
179 Beams the "WhoAmI contact. 179 Beams the "WhoAmI contact.
180 */ 180 */
181 void beamMySelf(); 181 void beamMySelf();
182 182
183 void beamVCard(); 183 void beamVCard();
184 void export2phone(); 184 void export2phone();
185 void beamVCard(const QStringList& uids); 185 void beamVCard(const QStringList& uids);
186 void beamDone( Ir *ir ); 186 void beamDone( Ir *ir );
187 187
188 188
189 /** 189 /**
190 Starts the preferred web browser with the given URL as argument. 190 Starts the preferred web browser with the given URL as argument.
191 */ 191 */
192 void browse( const QString& url ); 192 void browse( const QString& url );
193 193
194 /** 194 /**
195 Select all contacts in the view. 195 Select all contacts in the view.
196 */ 196 */
197 void selectAllContacts(); 197 void selectAllContacts();
198 198
199 /** 199 /**
200 Deletes all selected contacts from the address book. 200 Deletes all selected contacts from the address book.
201 */ 201 */
202 void deleteContacts(); 202 void deleteContacts();
203 203
204 /** 204 /**
205 Deletes given contacts from the address book. 205 Deletes given contacts from the address book.
206 206
207 @param uids The uids of the contacts, which shall be deleted. 207 @param uids The uids of the contacts, which shall be deleted.
208 */ 208 */
209 void deleteContacts( const QStringList &uids ); 209 void deleteContacts( const QStringList &uids );
210 210
211 /** 211 /**
212 Copys the selected contacts into clipboard for later pasting. 212 Copys the selected contacts into clipboard for later pasting.
213 */ 213 */
214 void copyContacts(); 214 void copyContacts();
215 215
216 /** 216 /**
217 Cuts the selected contacts and stores them for later pasting. 217 Cuts the selected contacts and stores them for later pasting.
218 */ 218 */
219 void cutContacts(); 219 void cutContacts();
220 220
221 /** 221 /**
222 Paste contacts from clipboard into the address book. 222 Paste contacts from clipboard into the address book.
223 */ 223 */
224 void pasteContacts(); 224 void pasteContacts();
225 225
226 /** 226 /**
227 Paste given contacts into the address book. 227 Paste given contacts into the address book.
228 228
229 @param list The list of addressee, which shall be pasted. 229 @param list The list of addressee, which shall be pasted.
230 */ 230 */
231 void pasteContacts( KABC::Addressee::List &list ); 231 void pasteContacts( KABC::Addressee::List &list );
232 232
233 /** 233 /**
234 Sets the whoAmI contact, that is used by many other programs to 234 Sets the whoAmI contact, that is used by many other programs to
235 get personal information about the current user. 235 get personal information about the current user.
236 */ 236 */
237 void setWhoAmI(); 237 void setWhoAmI();
238 238
239 /** 239 /**
240 Displays the category dialog and applies the result to all 240 Displays the category dialog and applies the result to all
241 selected contacts. 241 selected contacts.
242 */ 242 */
243 void setCategories(); 243 void setCategories();
244 void manageCategories(); 244 void manageCategories();
245 void editCategories(); 245 void editCategories();
246 246
247 /** 247 /**
248 Sets the field list of the Incremental Search Widget. 248 Sets the field list of the Incremental Search Widget.
249 */ 249 */
250 void setSearchFields( const KABC::Field::List &fields ); 250 void setSearchFields( const KABC::Field::List &fields );
251 251
252 /** 252 /**
253 Search with the current search field for a contact, that matches 253 Search with the current search field for a contact, that matches
254 the given text, and selects it in the view. 254 the given text, and selects it in the view.
255 */ 255 */
256 void incrementalSearch( const QString& text ); 256 void incrementalSearch( const QString& text );
257 void incrementalSearchJump( const QString& text ); 257 void incrementalSearchJump( const QString& text );
258 258
259 /** 259 /**
260 Marks the address book as modified. 260 Marks the address book as modified.
261 */ 261 */
262 void setModified(); 262 void setModified();
263 /** 263 /**
264 Marks the address book as modified without refreshing the view. 264 Marks the address book as modified without refreshing the view.
265 */ 265 */
266 void setModifiedWOrefresh(); 266 void setModifiedWOrefresh();
267 267
268 /** 268 /**
269 Marks the address book as modified concerning the argument. 269 Marks the address book as modified concerning the argument.
270 */ 270 */
271 void setModified( bool modified ); 271 void setModified( bool modified );
272 272
273 /** 273 /**
274 Returns whether the address book is modified. 274 Returns whether the address book is modified.
275 */ 275 */
276 bool modified() const; 276 bool modified() const;
277 277
278 /** 278 /**
279 Called whenever an contact is modified in the contact editor 279 Called whenever an contact is modified in the contact editor
280 dialog or the quick edit. 280 dialog or the quick edit.
281 */ 281 */
282 void contactModified( const KABC::Addressee &addr ); 282 void contactModified( const KABC::Addressee &addr );
283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); 283 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
284 284
285 /** 285 /**
286 DCOP METHODS. 286 DCOP METHODS.
287 */ 287 */
288 void addEmail( QString addr ); 288 void addEmail( QString addr );
289 void importVCard( const KURL& url, bool showPreview ); 289 void importVCard( const KURL& url, bool showPreview );
290 void importVCard( const QString& vCard, bool showPreview ); 290 void importVCard( const QString& vCard, bool showPreview );
291 void newContact(); 291 void newContact();
292 QString getNameByPhone( const QString& phone ); 292 QString getNameByPhone( const QString& phone );
293 /** 293 /**
294 END DCOP METHODS 294 END DCOP METHODS
295 */ 295 */
296 296
297 /** 297 /**
298 Saves the contents of the AddressBook back to disk. 298 Saves the contents of the AddressBook back to disk.
299 */ 299 */
300 void save(); 300 void save();
301 301
302 /** 302 /**
303 Undos the last command using the undo stack. 303 Undos the last command using the undo stack.
304 */ 304 */
305 void undo(); 305 void undo();
306 306
307 /** 307 /**
308 Redos the last command that was undone, using the redo stack. 308 Redos the last command that was undone, using the redo stack.
309 */ 309 */
310 void redo(); 310 void redo();
311 311
312 /** 312 /**
313 Shows the edit dialog for the given uid. If the uid is QString::null, 313 Shows the edit dialog for the given uid. If the uid is QString::null,
314 the method will try to find a selected addressee in the view. 314 the method will try to find a selected addressee in the view.
315 */ 315 */
316 void editContact( const QString &uid /*US = QString::null*/ ); 316 void editContact( const QString &uid /*US = QString::null*/ );
317//US added a second method without defaultparameter 317//US added a second method without defaultparameter
318 void editContact2(); 318 void editContact2();
319 319
320 /** 320 /**
321 Shows or edits the detail view for the given uid. If the uid is QString::null, 321 Shows or edits the detail view for the given uid. If the uid is QString::null,
322 the method will try to find a selected addressee in the view. 322 the method will try to find a selected addressee in the view.
323 */ 323 */
324 void executeContact( const QString &uid /*US = QString::null*/ ); 324 void executeContact( const QString &uid /*US = QString::null*/ );
325 325
326 /** 326 /**
327 Launches the configuration dialog. 327 Launches the configuration dialog.
328 */ 328 */
329 void openConfigDialog(); 329 void openConfigDialog();
330 void openConfigGlobalDialog(); 330 void openConfigGlobalDialog();
331 331
332 /** 332 /**
333 Launches the ldap search dialog. 333 Launches the ldap search dialog.
334 */ 334 */
335 void openLDAPDialog(); 335 void openLDAPDialog();
336 336
337 /** 337 /**
338 Creates a KAddressBookPrinter, which will display the print 338 Creates a KAddressBookPrinter, which will display the print
339 dialog and do the printing. 339 dialog and do the printing.
340 */ 340 */
341 void print(); 341 void print();
342 342
343 /** 343 /**
344 Registers a new GUI client, so plugins can register its actions. 344 Registers a new GUI client, so plugins can register its actions.
345 */ 345 */
346 void addGUIClient( KXMLGUIClient *client ); 346 void addGUIClient( KXMLGUIClient *client );
347 347
348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 348 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 349 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 350 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
351 351
352 352
353 signals: 353 signals:
354 void contactSelected( const QString &name ); 354 void contactSelected( const QString &name );
355 void contactSelected( const QPixmap &pixmap ); 355 void contactSelected( const QPixmap &pixmap );
356 public slots: 356 public slots:
357 void loadDataAfterStart(); 357 void loadDataAfterStart();
358 void recieve(QString cmsg ); 358 void recieve(QString cmsg );
359 void getFile( bool success ); 359 void getFile( bool success );
360 void syncFileRequest(); 360 void syncFileRequest();
361 void setDetailsVisible( bool visible ); 361 void setDetailsVisible( bool visible );
362 void setDetailsToState(); 362 void setDetailsToState();
363 363
364 void saveSettings(); 364 void saveSettings();
365 365
366 private slots: 366 private slots:
367 void updateToolBar(); 367 void updateToolBar();
368 void updateMainWindow(); 368 void updateMainWindow();
369 void receive( const QCString& cmsg, const QByteArray& data ); 369 void receive( const QCString& cmsg, const QByteArray& data );
370 void receiveStart( const QCString& cmsg, const QByteArray& data ); 370 void receiveStart( const QCString& cmsg, const QByteArray& data );
371 void toggleBeamReceive( ); 371 void toggleBeamReceive( );
372 void disableBR(bool); 372 void disableBR(bool);
373 void setJumpButtonBarVisible( bool visible ); 373 void setJumpButtonBarVisible( bool visible );
374 void setJumpButtonBar( bool visible ); 374 void setJumpButtonBar( bool visible );
375 void setCaptionBack(); 375 void setCaptionBack();
376 void resizeAndCallContactdialog(); 376 void resizeAndCallContactdialog();
377 void callContactdialog(); 377 void callContactdialog();
378 void doRingSync(); 378 void doRingSync();
379 379
380 void importFromOL(); 380 void importFromOL();
381 void extensionModified( const KABC::Addressee::List &list ); 381 void extensionModified( const KABC::Addressee::List &list );
382 void extensionChanged( int id ); 382 void extensionChanged( int id );
383 void clipboardDataChanged(); 383 void clipboardDataChanged();
384 void updateActionMenu(); 384 void updateActionMenu();
385 void configureKeyBindings(); 385 void configureKeyBindings();
386 void removeVoice(); 386 void removeVoice();
387 void setFormattedName(); 387 void setFormattedName();
388#ifdef KAB_EMBEDDED 388#ifdef KAB_EMBEDDED
389 void configureResources(); 389 void configureResources();
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 void slotEditorDestroyed( const QString &uid ); 392 void slotEditorDestroyed( const QString &uid );
393 void configurationChanged(); 393 void configurationChanged();
394 void addressBookChanged(); 394 void addressBookChanged();
395 395
396 private: 396 private:
397 QCString mCStringMess; 397 QCString mCStringMess;
398 QByteArray mByteData; 398 QByteArray mByteData;
399 QString mEmailSourceChannel; 399 QString mEmailSourceChannel;
400 QString mEmailSourceUID; 400 QString mEmailSourceUID;
401 void resizeEvent(QResizeEvent* e ); 401 void resizeEvent(QResizeEvent* e );
402 bool mBRdisabled; 402 bool mBRdisabled;
403#ifndef DESKTOP_VERSION 403#ifndef DESKTOP_VERSION
404 QCopChannel* infrared; 404 QCopChannel* infrared;
405#endif 405#endif
406 QTimer *mMessageTimer; 406 QTimer *mMessageTimer;
407 void initGUI(); 407 void initGUI();
408 void initActions(); 408 void initActions();
409 QString getPhoneFile(); 409 QString getPhoneFile();
410 410
411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 411 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
412 const char *name = 0 ); 412 const char *name = 0 );
413 413
414 KXMLGUIClient *mGUIClient; 414 KXMLGUIClient *mGUIClient;
415 415
416 KABC::AddressBook *mAddressBook; 416 KABC::AddressBook *mAddressBook;
417 417
418 ViewManager *mViewManager; 418 ViewManager *mViewManager;
419 // QSplitter *mDetailsSplitter; 419 // QSplitter *mDetailsSplitter;
420 KDGanttMinimizeSplitter *mExtensionBarSplitter; 420 KDGanttMinimizeSplitter *mExtensionBarSplitter;
421 ViewContainer *mDetails; 421 ViewContainer *mDetails;
422 KDGanttMinimizeSplitter* mMiniSplitter; 422 KDGanttMinimizeSplitter* mMiniSplitter;
423 XXPortManager *mXXPortManager; 423 XXPortManager *mXXPortManager;
424 JumpButtonBar *mJumpButtonBar; 424 JumpButtonBar *mJumpButtonBar;
425 IncSearchWidget *mIncSearchWidget; 425 IncSearchWidget *mIncSearchWidget;
426 ExtensionManager *mExtensionManager; 426 ExtensionManager *mExtensionManager;
427 427
428 KCMultiDialog *mConfigureDialog; 428 KCMultiDialog *mConfigureDialog;
429 429
430#ifndef KAB_EMBEDDED 430#ifndef KAB_EMBEDDED
431 LDAPSearchDialog *mLdapSearchDialog; 431 LDAPSearchDialog *mLdapSearchDialog;
432#endif //KAB_EMBEDDED 432#endif //KAB_EMBEDDED
433 // QDict<AddresseeEditorDialog> mEditorDict; 433 // QDict<AddresseeEditorDialog> mEditorDict;
434 AddresseeEditorDialog *mEditorDialog; 434 AddresseeEditorDialog *mEditorDialog;
435 bool mReadWrite; 435 bool mReadWrite;
436 bool mModified; 436 bool mModified;
437 bool mIsPart; 437 bool mIsPart;
438 bool mMultipleViewsAtOnce; 438 bool mMultipleViewsAtOnce;
439 439
440 440
441 //US file menu 441 //US file menu
442 KAction *mActionMail; 442 KAction *mActionMail;
443 KAction *mActionBeam; 443 KAction *mActionBeam;
444 KToggleAction *mActionBR; 444 KToggleAction *mActionBR;
445 KAction *mActionExport2phone; 445 KAction *mActionExport2phone;
446 KAction* mActionPrint; 446 KAction* mActionPrint;
447 KAction* mActionPrintDetails; 447 KAction* mActionPrintDetails;
448 KAction* mActionNewContact; 448 KAction* mActionNewContact;
449 KAction *mActionSave; 449 KAction *mActionSave;
450 KAction *mActionEditAddressee; 450 KAction *mActionEditAddressee;
451 KAction *mActionMailVCard; 451 KAction *mActionMailVCard;
452 KAction *mActionBeamVCard; 452 KAction *mActionBeamVCard;
453 453
454 KAction *mActionQuit; 454 KAction *mActionQuit;
455 455
456 //US edit menu 456 //US edit menu
457 KAction *mActionCopy; 457 KAction *mActionCopy;
458 KAction *mActionCut; 458 KAction *mActionCut;
459 KAction *mActionPaste; 459 KAction *mActionPaste;
460 KAction *mActionSelectAll; 460 KAction *mActionSelectAll;
461 KAction *mActionUndo; 461 KAction *mActionUndo;
462 KAction *mActionRedo; 462 KAction *mActionRedo;
463 KAction *mActionDelete; 463 KAction *mActionDelete;
464 464
465 //US settings menu 465 //US settings menu
466 KAction *mActionConfigResources; 466 KAction *mActionConfigResources;
467 KAction *mActionConfigGlobal; 467 KAction *mActionConfigGlobal;
468 KAction *mActionConfigKAddressbook; 468 KAction *mActionConfigKAddressbook;
469 KAction *mActionConfigShortcuts; 469 KAction *mActionConfigShortcuts;
470 KAction *mActionConfigureToolbars; 470 KAction *mActionConfigureToolbars;
471 KAction *mActionKeyBindings; 471 KAction *mActionKeyBindings;
472 KToggleAction *mActionJumpBar; 472 KToggleAction *mActionJumpBar;
473 KToggleAction *mActionDetails; 473 KToggleAction *mActionDetails;
474 KAction *mActionWhoAmI; 474 KAction *mActionWhoAmI;
475 KAction *mActionCategories; 475 KAction *mActionCategories;
476 KAction *mActionEditCategories; 476 KAction *mActionEditCategories;
477 KAction *mActionManageCategories; 477 KAction *mActionManageCategories;
478 KAction *mActionAboutKAddressbook; 478 KAction *mActionAboutKAddressbook;
479 KAction *mActionLicence; 479 KAction *mActionLicence;
480 KAction *mActionFaq; 480 KAction *mActionFaq;
481 KAction *mActionWN; 481 KAction *mActionWN;
482 KAction *mActionSyncHowto; 482 KAction *mActionSyncHowto;
483 KAction *mActionStorageHowto; 483 KAction *mActionStorageHowto;
484 KAction *mActionKdeSyncHowto; 484 KAction *mActionKdeSyncHowto;
485 KAction *mActionMultiSyncHowto; 485 KAction *mActionMultiSyncHowto;
486 486
487 KAction *mActionDeleteView; 487 KAction *mActionDeleteView;
488 488
489 QPopupMenu *viewMenu; 489 QPopupMenu *viewMenu;
490 QPopupMenu *filterMenu; 490 QPopupMenu *filterMenu;
491 QPopupMenu *settingsMenu; 491 QPopupMenu *settingsMenu;
492 QPopupMenu *changeMenu; 492 QPopupMenu *changeMenu;
493 QPopupMenu *beamMenu; 493 QPopupMenu *beamMenu;
494//US QAction *mActionSave; 494//US QAction *mActionSave;
495 QPopupMenu *ImportMenu; 495 QPopupMenu *ImportMenu;
496 QPopupMenu *ExportMenu; 496 QPopupMenu *ExportMenu;
497 //LR additional methods 497 //LR additional methods
498 KAction *mActionRemoveVoice; 498 KAction *mActionRemoveVoice;
499 KAction *mActionSetFormattedName; 499 KAction *mActionSetFormattedName;
500 KAction * mActionImportOL; 500 KAction * mActionImportOL;
501 501
502#ifndef KAB_EMBEDDED 502#ifndef KAB_EMBEDDED
503 KAddressBookService *mAddressBookService; 503 KAddressBookService *mAddressBookService;
504#endif //KAB_EMBEDDED 504#endif //KAB_EMBEDDED
505 505
506 class KABCorePrivate; 506 class KABCorePrivate;
507 KABCorePrivate *d; 507 KABCorePrivate *d;
508 //US bool mBlockSaveFlag; 508 //US bool mBlockSaveFlag;
509 509
510#ifdef KAB_EMBEDDED 510#ifdef KAB_EMBEDDED
511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 511 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
512#endif //KAB_EMBEDDED 512#endif //KAB_EMBEDDED
513 513
514 //this are the overwritten callbackmethods from the syncinterface 514 //this are the overwritten callbackmethods from the syncinterface
515 virtual bool sync(KSyncManager* manager, QString filename, int mode); 515 virtual bool sync(KSyncManager* manager, QString filename, int mode,QString resource);
516 virtual bool syncExternal(KSyncManager* manager, QString resource); 516 virtual bool syncExternal(KSyncManager* manager, QString resource);
517 virtual void removeSyncInfo( QString syncProfile); 517 virtual void removeSyncInfo( QString syncProfile);
518 bool syncPhone(); 518 bool syncPhone();
519 void message( QString m , bool startTimer = true); 519 void message( QString m , bool startTimer = true);
520 520
521 // LR ******************************* 521 // LR *******************************
522 // sync stuff! 522 // sync stuff!
523 QString sentSyncFile(); 523 QString sentSyncFile();
524 QPopupMenu *syncMenu; 524 QPopupMenu *syncMenu;
525 KSyncManager* syncManager; 525 KSyncManager* syncManager;
526 int mGlobalSyncMode; 526 int mGlobalSyncMode;
527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 527 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
528 KABC::Addressee getLastSyncAddressee(); 528 KABC::Addressee getLastSyncAddressee();
529 QDateTime mLastAddressbookSync; 529 QDateTime mLastAddressbookSync;
530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 530 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
531 // ********************* 531 // *********************
532 532
533}; 533};
534 534
535#endif 535#endif
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 31e103d..8965d3b 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,5176 +1,5189 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 flag_blockConflict = false; 369 flag_blockConflict = false;
370 flag_blockScrollBar = false; 370 flag_blockScrollBar = false;
371 flag_checkFileFirsttime = true; 371 flag_checkFileFirsttime = true;
372 flag_clearallviewsEventDisplay = false; 372 flag_clearallviewsEventDisplay = false;
373 flag_clearallviewsupdateView = false; 373 flag_clearallviewsupdateView = false;
374 mNextAlarmDateTime = QDateTime::currentDateTime(); 374 mNextAlarmDateTime = QDateTime::currentDateTime();
375 setFocusPolicy (NoFocus ); 375 setFocusPolicy (NoFocus );
376 mViewerCallerIsSearchDialog = false; 376 mViewerCallerIsSearchDialog = false;
377 mBlockShowDates = false; 377 mBlockShowDates = false;
378 mConflictingEvent = 0; 378 mConflictingEvent = 0;
379 mDatePickerMode = 0; 379 mDatePickerMode = 0;
380 mCurrentSyncDevice = ""; 380 mCurrentSyncDevice = "";
381 mViewManager = new KOViewManager( this ); 381 mViewManager = new KOViewManager( this );
382 mDialogManager = new KODialogManager( this ); 382 mDialogManager = new KODialogManager( this );
383 mEventViewerDialog = 0; 383 mEventViewerDialog = 0;
384 mModified = false; 384 mModified = false;
385 mReadOnly = false; 385 mReadOnly = false;
386 mSelectedIncidence = 0; 386 mSelectedIncidence = 0;
387 mCalPrinter = 0; 387 mCalPrinter = 0;
388 mFilters.setAutoDelete(true); 388 mFilters.setAutoDelete(true);
389 389
390 mCalendar->registerObserver( this ); 390 mCalendar->registerObserver( this );
391 // TODO: Make sure that view is updated, when calendar is changed. 391 // TODO: Make sure that view is updated, when calendar is changed.
392 392
393 mStorage = new FileStorage( mCalendar ); 393 mStorage = new FileStorage( mCalendar );
394 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 394 mNavigator = new DateNavigator( this, "datevav", mViewManager );
395 395
396 QBoxLayout *topLayout = (QBoxLayout*)layout(); 396 QBoxLayout *topLayout = (QBoxLayout*)layout();
397#ifndef KORG_NOSPLITTER 397#ifndef KORG_NOSPLITTER
398 // create the main layout frames. 398 // create the main layout frames.
399 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 399 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
400 topLayout->addWidget(mPanner); 400 topLayout->addWidget(mPanner);
401 401
402 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 402 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
403 "CalendarView::LeftFrame"); 403 "CalendarView::LeftFrame");
404 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 404 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
405 405
406 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 406 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
407 "CalendarView::DateNavigator" ); 407 "CalendarView::DateNavigator" );
408 408
409 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 409 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
410 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 410 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
411 mTodoList->setNavigator( mNavigator ); 411 mTodoList->setNavigator( mNavigator );
412 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 412 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
413 413
414#ifdef KORG_NORESOURCEVIEW 414#ifdef KORG_NORESOURCEVIEW
415 mResourceView = 0; 415 mResourceView = 0;
416#else 416#else
417 if ( mResourceManager ) { 417 if ( mResourceManager ) {
418 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 418 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
419 mResourceView->updateView(); 419 mResourceView->updateView();
420 connect( mResourceView, SIGNAL( resourcesChanged() ), 420 connect( mResourceView, SIGNAL( resourcesChanged() ),
421 SLOT( updateView() ) ); 421 SLOT( updateView() ) );
422 } else { 422 } else {
423 mResourceView = 0; 423 mResourceView = 0;
424 } 424 }
425#endif 425#endif
426 QWidget *rightBox = new QWidget( mPanner ); 426 QWidget *rightBox = new QWidget( mPanner );
427 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 427 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
428 428
429 mRightFrame = new QWidgetStack( rightBox ); 429 mRightFrame = new QWidgetStack( rightBox );
430 rightLayout->addWidget( mRightFrame, 1 ); 430 rightLayout->addWidget( mRightFrame, 1 );
431 431
432 mLeftFrame = mLeftSplitter; 432 mLeftFrame = mLeftSplitter;
433#else 433#else
434 //QWidget *mainBox = new QWidget( this ); 434 //QWidget *mainBox = new QWidget( this );
435 //QWidget *leftFrame = new QWidget( mainBox ); 435 //QWidget *leftFrame = new QWidget( mainBox );
436 //QBoxLayout * mainBoxLayout; 436 //QBoxLayout * mainBoxLayout;
437 if ( KOPrefs::instance()->mVerticalScreen ) { 437 if ( KOPrefs::instance()->mVerticalScreen ) {
438 //mainBoxLayout = new QVBoxLayout(mainBox); 438 //mainBoxLayout = new QVBoxLayout(mainBox);
439 //leftFrameLayout = new QHBoxLayout(leftFrame ); 439 //leftFrameLayout = new QHBoxLayout(leftFrame );
440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
444 } else { 444 } else {
445 //mainBoxLayout = new QHBoxLayout(mainBox); 445 //mainBoxLayout = new QHBoxLayout(mainBox);
446 //leftFrameLayout = new QVBoxLayout(leftFrame ); 446 //leftFrameLayout = new QVBoxLayout(leftFrame );
447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
451 } 451 }
452 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 452 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
453 //QBoxLayout * leftFrameLayout; 453 //QBoxLayout * leftFrameLayout;
454 topLayout->addWidget( mMainFrame ); 454 topLayout->addWidget( mMainFrame );
455#ifdef DESKTOP_VERSION 455#ifdef DESKTOP_VERSION
456 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 456 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
457 topLayout->addWidget( mDateScrollBar ); 457 topLayout->addWidget( mDateScrollBar );
458 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 458 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
459 if ( QApplication::desktop()->width() < 800 ) 459 if ( QApplication::desktop()->width() < 800 )
460 mDateScrollBar->hide(); 460 mDateScrollBar->hide();
461#endif 461#endif
462 //mainBoxLayout->addWidget (mLeftFrame); 462 //mainBoxLayout->addWidget (mLeftFrame);
463 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 463 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
464 "CalendarView::DateNavigator" ); 464 "CalendarView::DateNavigator" );
465#if 0 465#if 0
466 // FIXME 466 // FIXME
467 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 467 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
468 "CalendarView::DateNavigator", QDate::currentDate()); 468 "CalendarView::DateNavigator", QDate::currentDate());
469#endif 469#endif
470 // mDateNavigator->blockSignals( true ); 470 // mDateNavigator->blockSignals( true );
471 //leftFrameLayout->addWidget( mDateNavigator ); 471 //leftFrameLayout->addWidget( mDateNavigator );
472 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 472 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
473 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 473 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
474 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 474 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
475 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 475 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
476 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 476 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
477 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 477 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
478 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 478 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
480 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 480 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
481 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 481 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
482 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 482 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
483 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 483 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
484 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 484 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
485 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 485 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
486 486
487 487
488 mTodoList->setNavigator( mNavigator ); 488 mTodoList->setNavigator( mNavigator );
489#if 0 489#if 0
490 if ( QApplication::desktop()->width() < 480 ) { 490 if ( QApplication::desktop()->width() < 480 ) {
491 leftFrameLayout->addWidget(mFilterView); 491 leftFrameLayout->addWidget(mFilterView);
492 leftFrameLayout->addWidget(mTodoList, 2 ); 492 leftFrameLayout->addWidget(mTodoList, 2 );
493 493
494 } else { 494 } else {
495 leftFrameLayout->addWidget(mTodoList,2 ); 495 leftFrameLayout->addWidget(mTodoList,2 );
496 leftFrameLayout->addWidget(mFilterView ); 496 leftFrameLayout->addWidget(mFilterView );
497 } 497 }
498#endif 498#endif
499 mFilterView->hide(); 499 mFilterView->hide();
500 mCalEditView->hide(); 500 mCalEditView->hide();
501 QWidget *rightBox = new QWidget( mMainFrame ); 501 QWidget *rightBox = new QWidget( mMainFrame );
502 //mainBoxLayout->addWidget ( rightBox, 10 ); 502 //mainBoxLayout->addWidget ( rightBox, 10 );
503 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 503 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
504 mRightFrame = new QWidgetStack( rightBox ); 504 mRightFrame = new QWidgetStack( rightBox );
505 rightLayout->addWidget( mRightFrame, 10 ); 505 rightLayout->addWidget( mRightFrame, 10 );
506 506
507 //mLeftFrame = (QWidget *)leftFrame; 507 //mLeftFrame = (QWidget *)leftFrame;
508 if ( KOPrefs::instance()->mVerticalScreen ) { 508 if ( KOPrefs::instance()->mVerticalScreen ) {
509 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 509 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
510 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 510 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
511 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 511 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
512 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 512 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
513 } else { 513 } else {
514 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 514 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
515 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 515 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
516 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 516 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
517 } 517 }
518 if ( !KOPrefs::instance()->mShowDateNavigator) 518 if ( !KOPrefs::instance()->mShowDateNavigator)
519 mDateNavigator->hide(); 519 mDateNavigator->hide();
520 //qDebug("Calendarview Size %d %d ", width(), height()); 520 //qDebug("Calendarview Size %d %d ", width(), height());
521#endif 521#endif
522 522
523 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 523 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
524 SLOT( showDates( const KCal::DateList & ) ) ); 524 SLOT( showDates( const KCal::DateList & ) ) );
525 525
526 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 526 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
527 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 527 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
528 528
529 529
530 530
531 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 531 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
532 mViewManager, SLOT( showMonth( const QDate & ) ) ); 532 mViewManager, SLOT( showMonth( const QDate & ) ) );
533 533
534 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 534 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
535 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 535 mNavigator, SLOT( selectWeek( const QDate & ) ) );
536 536
537 connect( mDateNavigator, SIGNAL( goPrevYear() ), 537 connect( mDateNavigator, SIGNAL( goPrevYear() ),
538 mNavigator, SLOT( selectPreviousYear() ) ); 538 mNavigator, SLOT( selectPreviousYear() ) );
539 connect( mDateNavigator, SIGNAL( goNextYear() ), 539 connect( mDateNavigator, SIGNAL( goNextYear() ),
540 mNavigator, SLOT( selectNextYear() ) ); 540 mNavigator, SLOT( selectNextYear() ) );
541 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 541 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
542 mNavigator, SLOT( selectPreviousMonth() ) ); 542 mNavigator, SLOT( selectPreviousMonth() ) );
543 connect( mDateNavigator, SIGNAL( goNextMonth() ), 543 connect( mDateNavigator, SIGNAL( goNextMonth() ),
544 mNavigator, SLOT( selectNextMonth() ) ); 544 mNavigator, SLOT( selectNextMonth() ) );
545 545
546 connect( mDateNavigator, SIGNAL( goPrevious() ), 546 connect( mDateNavigator, SIGNAL( goPrevious() ),
547 mNavigator, SLOT( selectPrevious() ) ); 547 mNavigator, SLOT( selectPrevious() ) );
548 connect( mDateNavigator, SIGNAL( goNext() ), 548 connect( mDateNavigator, SIGNAL( goNext() ),
549 mNavigator, SLOT( selectNext() ) ); 549 mNavigator, SLOT( selectNext() ) );
550 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 550 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
551 mNavigator, SLOT( slotMonthSelect( int ) ) ); 551 mNavigator, SLOT( slotMonthSelect( int ) ) );
552 552
553 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 553 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
554 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 554 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
555#if 0 555#if 0
556 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 556 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
557 SLOT( incidenceAdded( Incidence *) ) ); 557 SLOT( incidenceAdded( Incidence *) ) );
558#endif 558#endif
559 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 559 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
560 560
561 connect( this, SIGNAL( configChanged() ), 561 connect( this, SIGNAL( configChanged() ),
562 mDateNavigator, SLOT( updateConfig() ) ); 562 mDateNavigator, SLOT( updateConfig() ) );
563 563
564 connect( mTodoList, SIGNAL( newTodoSignal() ), 564 connect( mTodoList, SIGNAL( newTodoSignal() ),
565 SLOT( newTodo() ) ); 565 SLOT( newTodo() ) );
566 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 566 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
567 SLOT( newSubTodo( Todo * ) ) ); 567 SLOT( newSubTodo( Todo * ) ) );
568 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 568 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
569 SLOT( editTodo( Todo * ) ) ); 569 SLOT( editTodo( Todo * ) ) );
570 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 570 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
571 SLOT( showTodo( Todo *) ) ); 571 SLOT( showTodo( Todo *) ) );
572 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 572 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
573 SLOT( deleteTodo( Todo *) ) ); 573 SLOT( deleteTodo( Todo *) ) );
574 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 574 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
575 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 575 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
576 SLOT( purgeCompleted() ) ); 576 SLOT( purgeCompleted() ) );
577 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 577 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
578 SIGNAL( todoModified( Todo *, int ) ) ); 578 SIGNAL( todoModified( Todo *, int ) ) );
579 579
580 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
581 this, SLOT ( cloneIncidence( Incidence * ) ) ); 581 this, SLOT ( cloneIncidence( Incidence * ) ) );
582 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 582 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
583 this, SLOT (cancelIncidence( Incidence * ) ) ); 583 this, SLOT (cancelIncidence( Incidence * ) ) );
584 584
585 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 585 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
586 this, SLOT ( moveIncidence( Incidence * ) ) ); 586 this, SLOT ( moveIncidence( Incidence * ) ) );
587 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 587 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
588 this, SLOT ( beamIncidence( Incidence * ) ) ); 588 this, SLOT ( beamIncidence( Incidence * ) ) );
589 589
590 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 590 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
591 this, SLOT ( todo_unsub( Todo * ) ) ); 591 this, SLOT ( todo_unsub( Todo * ) ) );
592 592
593 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 593 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
594 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 594 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
595 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 595 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
596 SLOT( updateTodo( Todo *, int ) ) ); 596 SLOT( updateTodo( Todo *, int ) ) );
597 connect( this, SIGNAL( todoModified( Todo *, int )), this, 597 connect( this, SIGNAL( todoModified( Todo *, int )), this,
598 SLOT( changeTodoDisplay( Todo *, int ) ) ); 598 SLOT( changeTodoDisplay( Todo *, int ) ) );
599 599
600 600
601 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 601 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
602 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 602 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
603 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 603 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
604 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 604 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
605 605
606 606
607 607
608 608
609 609
610 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 610 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
611 SLOT(checkClipboard())); 611 SLOT(checkClipboard()));
612 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 612 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
613 SLOT( processTodoListSelection( Incidence * ) ) ); 613 SLOT( processTodoListSelection( Incidence * ) ) );
614 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 614 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
615 615
616 // kdDebug() << "CalendarView::CalendarView() done" << endl; 616 // kdDebug() << "CalendarView::CalendarView() done" << endl;
617 617
618 mDateFrame = new QVBox(0,0,WType_Popup); 618 mDateFrame = new QVBox(0,0,WType_Popup);
619 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 619 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
620 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 620 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
621 mDateFrame->setLineWidth(3); 621 mDateFrame->setLineWidth(3);
622 mDateFrame->hide(); 622 mDateFrame->hide();
623 mDateFrame->setCaption( i18n( "Pick a date to display")); 623 mDateFrame->setCaption( i18n( "Pick a date to display"));
624 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 624 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
625 625
626 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 626 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
627 627
628 mEventEditor = mDialogManager->getEventEditor(); 628 mEventEditor = mDialogManager->getEventEditor();
629 mTodoEditor = mDialogManager->getTodoEditor(); 629 mTodoEditor = mDialogManager->getTodoEditor();
630 630
631 mFlagEditDescription = false; 631 mFlagEditDescription = false;
632 632
633 mSuspendTimer = new QTimer( this ); 633 mSuspendTimer = new QTimer( this );
634 mAlarmTimer = new QTimer( this ); 634 mAlarmTimer = new QTimer( this );
635 mRecheckAlarmTimer = new QTimer( this ); 635 mRecheckAlarmTimer = new QTimer( this );
636 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 636 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
637 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 637 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
638 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 638 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
639 mAlarmDialog = new AlarmDialog( this ); 639 mAlarmDialog = new AlarmDialog( this );
640 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 640 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
641 mAlarmDialog->setServerNotification( false ); 641 mAlarmDialog->setServerNotification( false );
642 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 642 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
643 643
644 644
645#ifndef DESKTOP_VERSION 645#ifndef DESKTOP_VERSION
646//US listen for arriving address resultsets 646//US listen for arriving address resultsets
647 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 647 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
648 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 648 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
649#endif 649#endif
650 mDateNavigator->setCalendar( mCalendar ); 650 mDateNavigator->setCalendar( mCalendar );
651} 651}
652 652
653 653
654CalendarView::~CalendarView() 654CalendarView::~CalendarView()
655{ 655{
656 // kdDebug() << "~CalendarView()" << endl; 656 // kdDebug() << "~CalendarView()" << endl;
657 //qDebug("CalendarView::~CalendarView() "); 657 //qDebug("CalendarView::~CalendarView() ");
658 delete mDialogManager; 658 delete mDialogManager;
659 delete mViewManager; 659 delete mViewManager;
660 delete mStorage; 660 delete mStorage;
661 delete mDateFrame ; 661 delete mDateFrame ;
662 delete mEventViewerDialog; 662 delete mEventViewerDialog;
663 //kdDebug() << "~CalendarView() done" << endl; 663 //kdDebug() << "~CalendarView() done" << endl;
664} 664}
665 665
666 666
667void CalendarView::nextConflict( bool all, bool allday ) 667void CalendarView::nextConflict( bool all, bool allday )
668{ 668{
669 if ( flag_blockConflict ) return; 669 if ( flag_blockConflict ) return;
670 flag_blockConflict = true; 670 flag_blockConflict = true;
671 QPtrList<Event> testlist = mCalendar->events(); 671 QPtrList<Event> testlist = mCalendar->events();
672 Event * test = testlist.first(); 672 Event * test = testlist.first();
673 while ( test ) { 673 while ( test ) {
674 test->setTagged( false ); 674 test->setTagged( false );
675 test = testlist.next(); 675 test = testlist.next();
676 } 676 }
677 QTime st ( 0,0,0); 677 QTime st ( 0,0,0);
678 if ( mViewManager->currentView() == mViewManager->agendaView() ) 678 if ( mViewManager->currentView() == mViewManager->agendaView() )
679 st = mViewManager->agendaView()->agenda()->getEndTime(); 679 st = mViewManager->agendaView()->agenda()->getEndTime();
680 //qDebug("time %s ", st.toString().latin1()); 680 //qDebug("time %s ", st.toString().latin1());
681 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 681 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
682 QDateTime conflict; 682 QDateTime conflict;
683 QDateTime retVal; 683 QDateTime retVal;
684 bool found = false; 684 bool found = false;
685 Event * cE = 0; 685 Event * cE = 0;
686 Event * cE2 = 0; 686 Event * cE2 = 0;
687 QPtrList<Event> testlist2 = testlist; 687 QPtrList<Event> testlist2 = testlist;
688 test = testlist.first(); 688 test = testlist.first();
689 bool skip = false; 689 bool skip = false;
690 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 690 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
691 //QTime tm; 691 //QTime tm;
692 //tm.start(); 692 //tm.start();
693 while ( test ) { 693 while ( test ) {
694 qApp->processEvents(); 694 qApp->processEvents();
695 skip = false; 695 skip = false;
696 if ( !all ) skip = ( allday != test->doesFloat() ); 696 if ( !all ) skip = ( allday != test->doesFloat() );
697 if ( !skip ) { 697 if ( !skip ) {
698 if ( found ) 698 if ( found )
699 skip = !test->matchTime( &startDT, &conflict ); 699 skip = !test->matchTime( &startDT, &conflict );
700 else 700 else
701 skip = !test->matchTime( &startDT, 0 ); 701 skip = !test->matchTime( &startDT, 0 );
702 } 702 }
703 if ( !skip ) { 703 if ( !skip ) {
704 Event * test2 = testlist2.first(); 704 Event * test2 = testlist2.first();
705 while ( test2 ) { 705 while ( test2 ) {
706 skip = test2->isTagged(); 706 skip = test2->isTagged();
707 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 707 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( found ) 709 if ( found )
710 skip = !test2->matchTime( &startDT, &conflict ); 710 skip = !test2->matchTime( &startDT, &conflict );
711 else 711 else
712 skip = !test2->matchTime( &startDT, 0 ); 712 skip = !test2->matchTime( &startDT, 0 );
713 } 713 }
714 if ( !skip ) { 714 if ( !skip ) {
715 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 715 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
716 //qDebug("overlap "); 716 //qDebug("overlap ");
717 if ( ! found ) { 717 if ( ! found ) {
718 if ( retVal >= startDT ) { 718 if ( retVal >= startDT ) {
719 conflict = retVal; 719 conflict = retVal;
720 cE = test; 720 cE = test;
721 cE2 = test2; 721 cE2 = test2;
722 found = true; 722 found = true;
723 } 723 }
724 } else { 724 } else {
725 if ( retVal >= startDT && retVal < conflict ) { 725 if ( retVal >= startDT && retVal < conflict ) {
726 conflict = retVal; 726 conflict = retVal;
727 cE = test; 727 cE = test;
728 cE2 = test2; 728 cE2 = test2;
729 } 729 }
730 } 730 }
731 } 731 }
732 } 732 }
733 test2 = testlist2.next(); 733 test2 = testlist2.next();
734 } 734 }
735 } 735 }
736 test->setTagged( true ); 736 test->setTagged( true );
737 test = testlist.next(); 737 test = testlist.next();
738 } 738 }
739 //qDebug("Search time : %d", tm.elapsed()); 739 //qDebug("Search time : %d", tm.elapsed());
740 if ( found ) { 740 if ( found ) {
741 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 741 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
742 mViewManager->showDayView(); 742 mViewManager->showDayView();
743 mNavigator->slotDaySelect( conflict.date() ); 743 mNavigator->slotDaySelect( conflict.date() );
744 int hour = conflict.time().hour(); 744 int hour = conflict.time().hour();
745 mViewManager->agendaView()->setStartHour( hour ); 745 mViewManager->agendaView()->setStartHour( hour );
746 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 746 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
747 flag_blockConflict = false; 747 flag_blockConflict = false;
748 return; 748 return;
749 } 749 }
750 750
751 topLevelWidget()->setCaption( i18n("No conflict found") ); 751 topLevelWidget()->setCaption( i18n("No conflict found") );
752 //qDebug("No conflict found "); 752 //qDebug("No conflict found ");
753 flag_blockConflict = false; 753 flag_blockConflict = false;
754 return; 754 return;
755} 755}
756 756
757void CalendarView::conflictAll() 757void CalendarView::conflictAll()
758{ 758{
759 nextConflict ( true, true ); 759 nextConflict ( true, true );
760} 760}
761void CalendarView::conflictAllday() 761void CalendarView::conflictAllday()
762{ 762{
763 nextConflict ( false, true ); 763 nextConflict ( false, true );
764} 764}
765void CalendarView::conflictNotAll() 765void CalendarView::conflictNotAll()
766{ 766{
767 nextConflict ( false, false ); 767 nextConflict ( false, false );
768} 768}
769 769
770void CalendarView::setCalReadOnly( int id, bool readO ) 770void CalendarView::setCalReadOnly( int id, bool readO )
771{ 771{
772 if ( readO ) { 772 if ( readO ) {
773 emit save(); 773 emit save();
774 } 774 }
775 mCalendar->setReadOnly( id, readO ); 775 mCalendar->setReadOnly( id, readO );
776} 776}
777void CalendarView::setScrollBarStep(int val ) 777void CalendarView::setScrollBarStep(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 mDateScrollBar->setLineStep ( val ); 780 mDateScrollBar->setLineStep ( val );
781#endif 781#endif
782} 782}
783void CalendarView::scrollBarValue(int val ) 783void CalendarView::scrollBarValue(int val )
784{ 784{
785#ifdef DESKTOP_VERSION 785#ifdef DESKTOP_VERSION
786 if ( QApplication::desktop()->width() < 800 ) return; 786 if ( QApplication::desktop()->width() < 800 ) return;
787 if ( flag_blockScrollBar ) return; 787 if ( flag_blockScrollBar ) return;
788 flag_blockScrollBar = true; 788 flag_blockScrollBar = true;
789 int count = mNavigator->selectedDates().count(); 789 int count = mNavigator->selectedDates().count();
790 int day = mNavigator->selectedDates().first().dayOfYear(); 790 int day = mNavigator->selectedDates().first().dayOfYear();
791 int stepdays = val; 791 int stepdays = val;
792 if ( mDateScrollBar->lineStep () <= count ) { 792 if ( mDateScrollBar->lineStep () <= count ) {
793 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 793 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
794 //qDebug("VAL %d ",val ); 794 //qDebug("VAL %d ",val );
795 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 795 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
796 stepdays = day+stepdays; 796 stepdays = day+stepdays;
797 if ( stepdays < 0 ) stepdays = 0; 797 if ( stepdays < 0 ) stepdays = 0;
798 } 798 }
799 if ( stepdays == day ) { 799 if ( stepdays == day ) {
800 flag_blockScrollBar = false; 800 flag_blockScrollBar = false;
801 return; 801 return;
802 } 802 }
803 int year = mNavigator->selectedDates().first().year(); 803 int year = mNavigator->selectedDates().first().year();
804 QDate d ( year,1,1 ); 804 QDate d ( year,1,1 );
805 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 805 mNavigator->selectDates( d.addDays( stepdays-1) , count );
806 flag_blockScrollBar = false; 806 flag_blockScrollBar = false;
807#endif 807#endif
808 808
809} 809}
810void CalendarView::updateView(const QDate &start, const QDate &end) 810void CalendarView::updateView(const QDate &start, const QDate &end)
811{ 811{
812#ifdef DESKTOP_VERSION 812#ifdef DESKTOP_VERSION
813 if ( ! mDateScrollBar->draggingSlider () ) { 813 if ( ! mDateScrollBar->draggingSlider () ) {
814 int dof = start.dayOfYear(); 814 int dof = start.dayOfYear();
815 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 815 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
816 if ( dof != mDateScrollBar->value() ) { 816 if ( dof != mDateScrollBar->value() ) {
817 mDateScrollBar->blockSignals( true ); 817 mDateScrollBar->blockSignals( true );
818 mDateScrollBar->setValue( start.dayOfYear()); 818 mDateScrollBar->setValue( start.dayOfYear());
819 mDateScrollBar->blockSignals( false ); 819 mDateScrollBar->blockSignals( false );
820 } 820 }
821 } 821 }
822#endif 822#endif
823 mTodoList->updateView(); 823 mTodoList->updateView();
824 mViewManager->updateView(start, end); 824 mViewManager->updateView(start, end);
825 //mDateNavigator->updateView(); 825 //mDateNavigator->updateView();
826} 826}
827 827
828 828
829 829
830void CalendarView::checkFiles() 830void CalendarView::checkFiles()
831{ 831{
832 QString message; 832 QString message;
833 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 833 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
834 KopiCalendarFile * cal = calendars.first(); 834 KopiCalendarFile * cal = calendars.first();
835 while ( cal ) { 835 while ( cal ) {
836 if ( cal->mErrorOnLoad ) { 836 if ( cal->mErrorOnLoad ) {
837 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 837 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
838 } 838 }
839 cal = calendars.next(); 839 cal = calendars.next();
840 } 840 }
841 if ( !message.isEmpty() ) { 841 if ( !message.isEmpty() ) {
842 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 842 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
843 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); 843 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
844 } 844 }
845 if ( flag_checkFileFirsttime ) { 845 if ( flag_checkFileFirsttime ) {
846 flag_checkFileFirsttime = false; 846 flag_checkFileFirsttime = false;
847 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 847 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
848 } 848 }
849} 849}
850void CalendarView::checkAlarms() 850void CalendarView::checkAlarms()
851{ 851{
852 KConfig *config = KOGlobals::config(); 852 KConfig *config = KOGlobals::config();
853 config->setGroup( "AppRun" ); 853 config->setGroup( "AppRun" );
854 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 854 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
855 int daysto = dt.daysTo( QDate::currentDate() ); 855 int daysto = dt.daysTo( QDate::currentDate() );
856 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 856 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
857 dt = dt.addDays( days ); 857 dt = dt.addDays( days );
858 int secto = dt.secsTo( QDateTime::currentDateTime() ); 858 int secto = dt.secsTo( QDateTime::currentDateTime() );
859 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 859 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
860 //qDebug("KO: Reading program stop %d ", secs); 860 //qDebug("KO: Reading program stop %d ", secs);
861 //secs -= ( 3600 * 24*3 ); // debug only 861 //secs -= ( 3600 * 24*3 ); // debug only
862 QDateTime latest = dt.addSecs ( secs ); 862 QDateTime latest = dt.addSecs ( secs );
863 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 863 qDebug("KO: Last termination on %s ", latest.toString().latin1());
864 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 864 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
865 QPtrList<Incidence> el = mCalendar->rawIncidences(); 865 QPtrList<Incidence> el = mCalendar->rawIncidences();
866 QPtrList<Incidence> al; 866 QPtrList<Incidence> al;
867 Incidence* inL = el.first(); 867 Incidence* inL = el.first();
868 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 868 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
869 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 869 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
870 while ( inL ) { 870 while ( inL ) {
871 bool ok = false; 871 bool ok = false;
872 int offset = 0; 872 int offset = 0;
873 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 873 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
874 if ( ok ) { 874 if ( ok ) {
875 //qDebug("OK %s",next.toString().latin1()); 875 //qDebug("OK %s",next.toString().latin1());
876 if ( next < cur ) { 876 if ( next < cur ) {
877 al.append( inL ); 877 al.append( inL );
878 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 878 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
879 } 879 }
880 } 880 }
881 inL = el.next(); 881 inL = el.next();
882 } 882 }
883 if ( al.count() ) { 883 if ( al.count() ) {
884 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 884 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
885 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 885 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
886 QVBoxLayout* lay = new QVBoxLayout( dia ); 886 QVBoxLayout* lay = new QVBoxLayout( dia );
887 lay->setSpacing( 0 ); 887 lay->setSpacing( 0 );
888 lay->setMargin( 0 ); 888 lay->setMargin( 0 );
889 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 889 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
890 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 890 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
891 lay->addWidget( matb ); 891 lay->addWidget( matb );
892 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 892 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
893 int wid = 210; 893 int wid = 210;
894 int x = QApplication::desktop()->width() - wid - 7; 894 int x = QApplication::desktop()->width() - wid - 7;
895 int y = QApplication::desktop()->height() - wid - 70; 895 int y = QApplication::desktop()->height() - wid - 70;
896 dia->setGeometry ( x,y,wid,wid); 896 dia->setGeometry ( x,y,wid,wid);
897 } else { 897 } else {
898 int si = 220; 898 int si = 220;
899 if ( QApplication::desktop()->width() > 470 ) 899 if ( QApplication::desktop()->width() > 470 )
900 si = 400; 900 si = 400;
901 dia->resize(si,si/2); 901 dia->resize(si,si/2);
902 } 902 }
903 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 903 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
904 dia->show(); 904 dia->show();
905 905
906 } 906 }
907#if 0 907#if 0
908 // for creating timetracker test data 908 // for creating timetracker test data
909 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 909 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
910 Todo * nt; 910 Todo * nt;
911 mCalendar->close(); 911 mCalendar->close();
912 { 912 {
913 Todo * root1 = new Todo; 913 Todo * root1 = new Todo;
914 mCalendar->addTodo( root1 ); 914 mCalendar->addTodo( root1 );
915 root1->setSummary( "Project1"); 915 root1->setSummary( "Project1");
916 root1->setPriority( 1 ); 916 root1->setPriority( 1 );
917 root1->setCategories( QString( "Cat_Pro1") ); 917 root1->setCategories( QString( "Cat_Pro1") );
918 root1->setDescription( "This is a test description of a root Project" ); 918 root1->setDescription( "This is a test description of a root Project" );
919 root1->setPercentComplete( 20 ); 919 root1->setPercentComplete( 20 );
920 updateView(); 920 updateView();
921 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 921 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
922 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 922 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
923 923
924 nt = new Todo; 924 nt = new Todo;
925 mCalendar->addTodo( nt ); 925 mCalendar->addTodo( nt );
926 nt->setSummary( "Planning Project1"); 926 nt->setSummary( "Planning Project1");
927 nt->setPriority( 1 ); 927 nt->setPriority( 1 );
928 nt->setDescription( "This is a test description of Planning Project1" ); 928 nt->setDescription( "This is a test description of Planning Project1" );
929 nt->setPercentComplete( 20 ); 929 nt->setPercentComplete( 20 );
930 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 930 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
931 931
932 932
933 Todo * sub1 = nt; 933 Todo * sub1 = nt;
934 sub1->setRelatedTo( root1 ); 934 sub1->setRelatedTo( root1 );
935 935
936 nt = new Todo; 936 nt = new Todo;
937 mCalendar->addTodo( nt ); 937 mCalendar->addTodo( nt );
938 nt->setSummary( "Planning Project1: Lutz"); 938 nt->setSummary( "Planning Project1: Lutz");
939 nt->setPriority( 1 ); 939 nt->setPriority( 1 );
940 nt->setDescription( "This todo counts the actual work of a person on a project" ); 940 nt->setDescription( "This todo counts the actual work of a person on a project" );
941 nt->setPercentComplete( 20 ); 941 nt->setPercentComplete( 20 );
942 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); 942 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") );
943 Todo * workLutz11 = nt; 943 Todo * workLutz11 = nt;
944 workLutz11->setRelatedTo( sub1 ); 944 workLutz11->setRelatedTo( sub1 );
945 945
946 nt = new Todo; 946 nt = new Todo;
947 mCalendar->addTodo( nt ); 947 mCalendar->addTodo( nt );
948 nt->setSummary( "Planning Project1: Norbert"); 948 nt->setSummary( "Planning Project1: Norbert");
949 nt->setPriority( 1 ); 949 nt->setPriority( 1 );
950 nt->setDescription( "This todo counts the actual work of a person on a project" ); 950 nt->setDescription( "This todo counts the actual work of a person on a project" );
951 nt->setPercentComplete( 20 ); 951 nt->setPercentComplete( 20 );
952 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); 952 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") );
953 Todo * workNorbert11 = nt; 953 Todo * workNorbert11 = nt;
954 workNorbert11->setRelatedTo( sub1 ); 954 workNorbert11->setRelatedTo( sub1 );
955 955
956 nt = new Todo; 956 nt = new Todo;
957 mCalendar->addTodo( nt ); 957 mCalendar->addTodo( nt );
958 nt->setSummary( "Work on 1"); 958 nt->setSummary( "Work on 1");
959 nt->setPriority( 1 ); 959 nt->setPriority( 1 );
960 nt->setDescription( "This is a test description of Work Project_1" ); 960 nt->setDescription( "This is a test description of Work Project_1" );
961 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); 961 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") );
962 nt->setPercentComplete( 20 ); 962 nt->setPercentComplete( 20 );
963 963
964 Todo * sub2 = nt; 964 Todo * sub2 = nt;
965 sub2->setRelatedTo( root1 ); 965 sub2->setRelatedTo( root1 );
966 966
967 967
968 nt = new Todo; 968 nt = new Todo;
969 mCalendar->addTodo( nt ); 969 mCalendar->addTodo( nt );
970 nt->setSummary( "Work on 1: Lutz"); 970 nt->setSummary( "Work on 1: Lutz");
971 nt->setPriority( 1 ); 971 nt->setPriority( 1 );
972 nt->setDescription( "This todo counts the actual work of a person on a project" ); 972 nt->setDescription( "This todo counts the actual work of a person on a project" );
973 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); 973 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") );
974 nt->setPercentComplete( 20 ); 974 nt->setPercentComplete( 20 );
975 Todo * workLutz12 = nt; 975 Todo * workLutz12 = nt;
976 workLutz12->setRelatedTo( sub2 ); 976 workLutz12->setRelatedTo( sub2 );
977 977
978 nt = new Todo; 978 nt = new Todo;
979 mCalendar->addTodo( nt ); 979 mCalendar->addTodo( nt );
980 nt->setSummary( "Work on 1: Norbert"); 980 nt->setSummary( "Work on 1: Norbert");
981 nt->setPriority( 1 ); 981 nt->setPriority( 1 );
982 nt->setDescription( "This todo counts the actual work of a person on a project" ); 982 nt->setDescription( "This todo counts the actual work of a person on a project" );
983 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); 983 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") );
984 nt->setPercentComplete( 20 ); 984 nt->setPercentComplete( 20 );
985 Todo * workNorbert12 = nt; 985 Todo * workNorbert12 = nt;
986 workNorbert12->setRelatedTo( sub2 ); 986 workNorbert12->setRelatedTo( sub2 );
987 987
988 int secLenRunning = 7200; 988 int secLenRunning = 7200;
989 int secLenPausing = 3600 * 3; 989 int secLenPausing = 3600 * 3;
990 int dayInterval = 1; 990 int dayInterval = 1;
991 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 991 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
992 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 992 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
993 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 993 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
994 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 994 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
995 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 995 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
996 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 996 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
997 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 997 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
998 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 998 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
999 999
1000 } 1000 }
1001 1001
1002 { 1002 {
1003 Todo * root1 = new Todo; 1003 Todo * root1 = new Todo;
1004 mCalendar->addTodo( root1 ); 1004 mCalendar->addTodo( root1 );
1005 root1->setSummary( "Project2"); 1005 root1->setSummary( "Project2");
1006 root1->setPriority( 1 ); 1006 root1->setPriority( 1 );
1007 root1->setDescription( "This is a test description of a root Project 2" ); 1007 root1->setDescription( "This is a test description of a root Project 2" );
1008 root1->setPercentComplete( 20 ); 1008 root1->setPercentComplete( 20 );
1009 root1->setCategories( QString( "Cat_Pro2") ); 1009 root1->setCategories( QString( "Cat_Pro2") );
1010 updateView(); 1010 updateView();
1011 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 1011 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1012 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 1012 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
1013 int secLenRunning = 7200; 1013 int secLenRunning = 7200;
1014 int secLenPausing = 3600 * 3; 1014 int secLenPausing = 3600 * 3;
1015 int dayInterval = 1; 1015 int dayInterval = 1;
1016 1016
1017 nt = new Todo; 1017 nt = new Todo;
1018 mCalendar->addTodo( nt ); 1018 mCalendar->addTodo( nt );
1019 nt->setSummary( "Planning Project2"); 1019 nt->setSummary( "Planning Project2");
1020 nt->setPriority( 1 ); 1020 nt->setPriority( 1 );
1021 nt->setDescription( "This is a test description of Planning_Project_2" ); 1021 nt->setDescription( "This is a test description of Planning_Project_2" );
1022 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); 1022 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") );
1023 nt->setPercentComplete( 20 ); 1023 nt->setPercentComplete( 20 );
1024 1024
1025 1025
1026 Todo * sub1 = nt; 1026 Todo * sub1 = nt;
1027 sub1->setRelatedTo( root1 ); 1027 sub1->setRelatedTo( root1 );
1028 1028
1029 nt = new Todo; 1029 nt = new Todo;
1030 mCalendar->addTodo( nt ); 1030 mCalendar->addTodo( nt );
1031 nt->setSummary( "Planning Project2: Lutz"); 1031 nt->setSummary( "Planning Project2: Lutz");
1032 nt->setPriority( 1 ); 1032 nt->setPriority( 1 );
1033 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1033 nt->setDescription( "This todo counts the actual work of a person on a project" );
1034 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); 1034 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") );
1035 nt->setPercentComplete( 20 ); 1035 nt->setPercentComplete( 20 );
1036 Todo * workLutz11 = nt; 1036 Todo * workLutz11 = nt;
1037 workLutz11->setRelatedTo( sub1 ); 1037 workLutz11->setRelatedTo( sub1 );
1038 1038
1039 nt = new Todo; 1039 nt = new Todo;
1040 mCalendar->addTodo( nt ); 1040 mCalendar->addTodo( nt );
1041 nt->setSummary( "Planning Project2: Norbert"); 1041 nt->setSummary( "Planning Project2: Norbert");
1042 nt->setPriority( 1 ); 1042 nt->setPriority( 1 );
1043 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1043 nt->setDescription( "This todo counts the actual work of a person on a project" );
1044 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); 1044 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") );
1045 nt->setPercentComplete( 20 ); 1045 nt->setPercentComplete( 20 );
1046 Todo * workNorbert11 = nt; 1046 Todo * workNorbert11 = nt;
1047 workNorbert11->setRelatedTo( sub1 ); 1047 workNorbert11->setRelatedTo( sub1 );
1048 1048
1049 nt = new Todo; 1049 nt = new Todo;
1050 mCalendar->addTodo( nt ); 1050 mCalendar->addTodo( nt );
1051 nt->setSummary( "Work on 2"); 1051 nt->setSummary( "Work on 2");
1052 nt->setPriority( 1 ); 1052 nt->setPriority( 1 );
1053 nt->setDescription( "This is a test description of Work Project_2" ); 1053 nt->setDescription( "This is a test description of Work Project_2" );
1054 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); 1054 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") );
1055 nt->setPercentComplete( 20 ); 1055 nt->setPercentComplete( 20 );
1056 1056
1057 Todo * sub2 = nt; 1057 Todo * sub2 = nt;
1058 sub2->setRelatedTo( root1 ); 1058 sub2->setRelatedTo( root1 );
1059 1059
1060 1060
1061 nt = new Todo; 1061 nt = new Todo;
1062 mCalendar->addTodo( nt ); 1062 mCalendar->addTodo( nt );
1063 nt->setSummary( "Work on 2: Lutz"); 1063 nt->setSummary( "Work on 2: Lutz");
1064 nt->setPriority( 1 ); 1064 nt->setPriority( 1 );
1065 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1065 nt->setDescription( "This todo counts the actual work of a person on a project" );
1066 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); 1066 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") );
1067 nt->setPercentComplete( 20 ); 1067 nt->setPercentComplete( 20 );
1068 Todo * workLutz12 = nt; 1068 Todo * workLutz12 = nt;
1069 workLutz12->setRelatedTo( sub2 ); 1069 workLutz12->setRelatedTo( sub2 );
1070 1070
1071 nt = new Todo; 1071 nt = new Todo;
1072 mCalendar->addTodo( nt ); 1072 mCalendar->addTodo( nt );
1073 nt->setSummary( "Work on 2: Norbert"); 1073 nt->setSummary( "Work on 2: Norbert");
1074 nt->setPriority( 1 ); 1074 nt->setPriority( 1 );
1075 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1075 nt->setDescription( "This todo counts the actual work of a person on a project" );
1076 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); 1076 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") );
1077 nt->setPercentComplete( 20 ); 1077 nt->setPercentComplete( 20 );
1078 Todo * workNorbert12 = nt; 1078 Todo * workNorbert12 = nt;
1079 workNorbert12->setRelatedTo( sub2 ); 1079 workNorbert12->setRelatedTo( sub2 );
1080 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1080 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1081 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1081 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1082 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1082 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1083 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1083 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1084 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1084 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1085 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1085 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1086 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1086 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1087 } 1087 }
1088 updateView(); 1088 updateView();
1089#endif 1089#endif
1090 1090
1091} 1091}
1092void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1092void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1093{ 1093{
1094 static int ccc = 0; 1094 static int ccc = 0;
1095 ++ccc; 1095 ++ccc;
1096 QDateTime t_start = start; 1096 QDateTime t_start = start;
1097 runT->setPriority( 5 ); 1097 runT->setPriority( 5 );
1098 runT->setPercentComplete( 0 ); 1098 runT->setPercentComplete( 0 );
1099 int count = 0; 1099 int count = 0;
1100 int prio = 5; 1100 int prio = 5;
1101 int complete = 0; 1101 int complete = 0;
1102 while ( t_start < end ) { 1102 while ( t_start < end ) {
1103 ++count; 1103 ++count;
1104 if ( count > ccc ) { 1104 if ( count > ccc ) {
1105 count = 0; 1105 count = 0;
1106 --prio; 1106 --prio;
1107 if ( prio == 0 ) prio = 5; 1107 if ( prio == 0 ) prio = 5;
1108 complete += 20; 1108 complete += 20;
1109 if ( complete > 100 ) complete = 0; 1109 if ( complete > 100 ) complete = 0;
1110 runT->setPriority( prio ); 1110 runT->setPriority( prio );
1111 runT->setPercentComplete( complete ); 1111 runT->setPercentComplete( complete );
1112 } 1112 }
1113 runT->setRunning( true ); 1113 runT->setRunning( true );
1114 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1114 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1115 if ( dayInterval ) 1115 if ( dayInterval )
1116 t_start = t_start.addDays( dayInterval ); 1116 t_start = t_start.addDays( dayInterval );
1117 else { 1117 else {
1118 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1118 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1119 } 1119 }
1120 } 1120 }
1121} 1121}
1122 1122
1123void CalendarView::showDay( QDate d ) 1123void CalendarView::showDay( QDate d )
1124{ 1124{
1125 dateNavigator()->blockSignals( true ); 1125 dateNavigator()->blockSignals( true );
1126 dateNavigator()->selectDate( d ); 1126 dateNavigator()->selectDate( d );
1127 dateNavigator()->blockSignals( false ); 1127 dateNavigator()->blockSignals( false );
1128 mViewManager->showDayView(); 1128 mViewManager->showDayView();
1129 //dateNavigator()->selectDate( d ); 1129 //dateNavigator()->selectDate( d );
1130} 1130}
1131void CalendarView::timerAlarm() 1131void CalendarView::timerAlarm()
1132{ 1132{
1133 //qDebug("CalendarView::timerAlarm() "); 1133 //qDebug("CalendarView::timerAlarm() ");
1134 computeAlarm(mAlarmNotification ); 1134 computeAlarm(mAlarmNotification );
1135} 1135}
1136 1136
1137void CalendarView::suspendAlarm() 1137void CalendarView::suspendAlarm()
1138{ 1138{
1139 //qDebug(" CalendarView::suspendAlarm() "); 1139 //qDebug(" CalendarView::suspendAlarm() ");
1140 computeAlarm(mSuspendAlarmNotification ); 1140 computeAlarm(mSuspendAlarmNotification );
1141 1141
1142} 1142}
1143 1143
1144void CalendarView::startAlarm( QString mess , QString filename) 1144void CalendarView::startAlarm( QString mess , QString filename)
1145{ 1145{
1146 1146
1147 topLevelWidget()->showNormal(); 1147 topLevelWidget()->showNormal();
1148 topLevelWidget()->setActiveWindow(); 1148 topLevelWidget()->setActiveWindow();
1149 topLevelWidget()->raise(); 1149 topLevelWidget()->raise();
1150 1150
1151 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1151 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1152 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1152 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1153 1153
1154} 1154}
1155 1155
1156void CalendarView::checkNextTimerAlarm() 1156void CalendarView::checkNextTimerAlarm()
1157{ 1157{
1158 mCalendar->checkAlarmForIncidence( 0, true ); 1158 mCalendar->checkAlarmForIncidence( 0, true );
1159} 1159}
1160 1160
1161void CalendarView::computeAlarm( QString msg ) 1161void CalendarView::computeAlarm( QString msg )
1162{ 1162{
1163 1163
1164 QString mess = msg; 1164 QString mess = msg;
1165 QString mAlarmMessage = mess.mid( 9 ); 1165 QString mAlarmMessage = mess.mid( 9 );
1166 QString filename = MainWindow::resourcePath(); 1166 QString filename = MainWindow::resourcePath();
1167 filename += "koalarm.wav"; 1167 filename += "koalarm.wav";
1168 QString tempfilename; 1168 QString tempfilename;
1169 if ( mess.left( 13 ) == "suspend_alarm") { 1169 if ( mess.left( 13 ) == "suspend_alarm") {
1170 bool error = false; 1170 bool error = false;
1171 int len = mess.mid( 13 ).find("+++"); 1171 int len = mess.mid( 13 ).find("+++");
1172 if ( len < 2 ) 1172 if ( len < 2 )
1173 error = true; 1173 error = true;
1174 else { 1174 else {
1175 tempfilename = mess.mid( 13, len ); 1175 tempfilename = mess.mid( 13, len );
1176 if ( !QFile::exists( tempfilename ) ) 1176 if ( !QFile::exists( tempfilename ) )
1177 error = true; 1177 error = true;
1178 } 1178 }
1179 if ( ! error ) { 1179 if ( ! error ) {
1180 filename = tempfilename; 1180 filename = tempfilename;
1181 } 1181 }
1182 mAlarmMessage = mess.mid( 13+len+3 ); 1182 mAlarmMessage = mess.mid( 13+len+3 );
1183 //qDebug("suspend file %s ",tempfilename.latin1() ); 1183 //qDebug("suspend file %s ",tempfilename.latin1() );
1184 startAlarm( mAlarmMessage, filename); 1184 startAlarm( mAlarmMessage, filename);
1185 return; 1185 return;
1186 } 1186 }
1187 if ( mess.left( 11 ) == "timer_alarm") { 1187 if ( mess.left( 11 ) == "timer_alarm") {
1188 //mTimerTime = 0; 1188 //mTimerTime = 0;
1189 startAlarm( mess.mid( 11 ), filename ); 1189 startAlarm( mess.mid( 11 ), filename );
1190 return; 1190 return;
1191 } 1191 }
1192 if ( mess.left( 10 ) == "proc_alarm") { 1192 if ( mess.left( 10 ) == "proc_alarm") {
1193 bool error = false; 1193 bool error = false;
1194 int len = mess.mid( 10 ).find("+++"); 1194 int len = mess.mid( 10 ).find("+++");
1195 if ( len < 2 ) 1195 if ( len < 2 )
1196 error = true; 1196 error = true;
1197 else { 1197 else {
1198 tempfilename = mess.mid( 10, len ); 1198 tempfilename = mess.mid( 10, len );
1199 if ( !QFile::exists( tempfilename ) ) 1199 if ( !QFile::exists( tempfilename ) )
1200 error = true; 1200 error = true;
1201 } 1201 }
1202 if ( error ) { 1202 if ( error ) {
1203 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1203 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1204 mAlarmMessage += mess.mid( 10+len+3+9 ); 1204 mAlarmMessage += mess.mid( 10+len+3+9 );
1205 } else { 1205 } else {
1206 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1206 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1207 //qDebug("-----system command %s ",tempfilename.latin1() ); 1207 //qDebug("-----system command %s ",tempfilename.latin1() );
1208#ifndef _WIN32_ 1208#ifndef _WIN32_
1209 if ( vfork () == 0 ) { 1209 if ( vfork () == 0 ) {
1210 execl ( tempfilename.latin1(), 0 ); 1210 execl ( tempfilename.latin1(), 0 );
1211 return; 1211 return;
1212 } 1212 }
1213#else 1213#else
1214 QProcess* p = new QProcess(); 1214 QProcess* p = new QProcess();
1215 p->addArgument( tempfilename.latin1() ); 1215 p->addArgument( tempfilename.latin1() );
1216 p->start(); 1216 p->start();
1217 return; 1217 return;
1218#endif 1218#endif
1219 1219
1220 return; 1220 return;
1221 } 1221 }
1222 1222
1223 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1223 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1224 } 1224 }
1225 if ( mess.left( 11 ) == "audio_alarm") { 1225 if ( mess.left( 11 ) == "audio_alarm") {
1226 bool error = false; 1226 bool error = false;
1227 int len = mess.mid( 11 ).find("+++"); 1227 int len = mess.mid( 11 ).find("+++");
1228 if ( len < 2 ) 1228 if ( len < 2 )
1229 error = true; 1229 error = true;
1230 else { 1230 else {
1231 tempfilename = mess.mid( 11, len ); 1231 tempfilename = mess.mid( 11, len );
1232 if ( !QFile::exists( tempfilename ) ) 1232 if ( !QFile::exists( tempfilename ) )
1233 error = true; 1233 error = true;
1234 } 1234 }
1235 if ( ! error ) { 1235 if ( ! error ) {
1236 filename = tempfilename; 1236 filename = tempfilename;
1237 } 1237 }
1238 mAlarmMessage = mess.mid( 11+len+3+9 ); 1238 mAlarmMessage = mess.mid( 11+len+3+9 );
1239 //qDebug("audio file command %s ",tempfilename.latin1() ); 1239 //qDebug("audio file command %s ",tempfilename.latin1() );
1240 } 1240 }
1241 if ( mess.left( 9 ) == "cal_alarm") { 1241 if ( mess.left( 9 ) == "cal_alarm") {
1242 mAlarmMessage = mess.mid( 9 ) ; 1242 mAlarmMessage = mess.mid( 9 ) ;
1243 } 1243 }
1244 1244
1245 startAlarm( mAlarmMessage, filename ); 1245 startAlarm( mAlarmMessage, filename );
1246 1246
1247 1247
1248} 1248}
1249 1249
1250void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1250void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1251{ 1251{
1252 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1252 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1253 1253
1254 mSuspendAlarmNotification = noti; 1254 mSuspendAlarmNotification = noti;
1255 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1255 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1256 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1256 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1257 mSuspendTimer->start( ms , true ); 1257 mSuspendTimer->start( ms , true );
1258#ifdef DESKTOP_VERSION 1258#ifdef DESKTOP_VERSION
1259 if ( QApplication::desktop()->width() < 1024 ) { 1259 if ( QApplication::desktop()->width() < 1024 ) {
1260 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1260 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1261 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1261 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1262 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1262 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1263 QFile file( fn ); 1263 QFile file( fn );
1264 if (!file.open( IO_WriteOnly ) ) { 1264 if (!file.open( IO_WriteOnly ) ) {
1265 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1265 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1266 } else { 1266 } else {
1267 QTextStream ts( &file ); 1267 QTextStream ts( &file );
1268 ts << mess; 1268 ts << mess;
1269 file.close(); 1269 file.close();
1270 } 1270 }
1271 } 1271 }
1272#endif 1272#endif
1273 1273
1274} 1274}
1275 1275
1276void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1276void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1277{ 1277{
1278 mNextAlarmDateTime = qdt; 1278 mNextAlarmDateTime = qdt;
1279 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1279 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1280 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1280 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1281#ifndef DESKTOP_VERSION 1281#ifndef DESKTOP_VERSION
1282 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1282 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1283#endif 1283#endif
1284 return; 1284 return;
1285 } 1285 }
1286#ifdef DESKTOP_VERSION 1286#ifdef DESKTOP_VERSION
1287 if ( QApplication::desktop()->width() < 1024 ) { 1287 if ( QApplication::desktop()->width() < 1024 ) {
1288 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1288 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1289 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1289 //qDebug("nextalarm = \n%s ",mess.latin1() );
1290 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1290 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1291 QFile file( fn ); 1291 QFile file( fn );
1292 if (!file.open( IO_WriteOnly ) ) { 1292 if (!file.open( IO_WriteOnly ) ) {
1293 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1293 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1294 } else { 1294 } else {
1295 QTextStream ts( &file ); 1295 QTextStream ts( &file );
1296 ts << mess; 1296 ts << mess;
1297 file.close(); 1297 file.close();
1298 } 1298 }
1299 } 1299 }
1300#endif 1300#endif
1301 int maxSec; 1301 int maxSec;
1302 //maxSec = 5; //testing only 1302 //maxSec = 5; //testing only
1303 maxSec = 86400+3600; // one day+1hour 1303 maxSec = 86400+3600; // one day+1hour
1304 mAlarmNotification = noti; 1304 mAlarmNotification = noti;
1305 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1305 int sec = QDateTime::currentDateTime().secsTo( qdt );
1306 if ( sec > maxSec ) { 1306 if ( sec > maxSec ) {
1307 mRecheckAlarmTimer->start( maxSec * 1000 ); 1307 mRecheckAlarmTimer->start( maxSec * 1000 );
1308 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1308 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1309 return; 1309 return;
1310 } else { 1310 } else {
1311 mRecheckAlarmTimer->stop(); 1311 mRecheckAlarmTimer->stop();
1312 } 1312 }
1313 //qDebug("Alarm timer started with secs: %d ", sec); 1313 //qDebug("Alarm timer started with secs: %d ", sec);
1314 mAlarmTimer->start( sec * 1000 , true ); 1314 mAlarmTimer->start( sec * 1000 , true );
1315 1315
1316} 1316}
1317// called by mRecheckAlarmTimer to get next alarm 1317// called by mRecheckAlarmTimer to get next alarm
1318// we need this, because a QTimer has only a max range of 25 days 1318// we need this, because a QTimer has only a max range of 25 days
1319void CalendarView::recheckTimerAlarm() 1319void CalendarView::recheckTimerAlarm()
1320{ 1320{
1321 mAlarmTimer->stop(); 1321 mAlarmTimer->stop();
1322 mRecheckAlarmTimer->stop(); 1322 mRecheckAlarmTimer->stop();
1323 mCalendar->checkAlarmForIncidence( 0, true ); 1323 mCalendar->checkAlarmForIncidence( 0, true );
1324} 1324}
1325#ifndef DESKTOP_VERSION 1325#ifndef DESKTOP_VERSION
1326void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1326void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1327#else 1327#else
1328void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1328void CalendarView::removeAlarm(const QDateTime &, const QString & )
1329#endif 1329#endif
1330{ 1330{
1331 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1331 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1332 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1332 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1333#ifndef DESKTOP_VERSION 1333#ifndef DESKTOP_VERSION
1334 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1334 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1335#endif 1335#endif
1336 return; 1336 return;
1337 } 1337 }
1338 mAlarmTimer->stop(); 1338 mAlarmTimer->stop();
1339} 1339}
1340void CalendarView::selectWeekNum ( int num ) 1340void CalendarView::selectWeekNum ( int num )
1341{ 1341{
1342 dateNavigator()->blockSignals( true ); 1342 dateNavigator()->blockSignals( true );
1343 dateNavigator()->selectWeek( num ); 1343 dateNavigator()->selectWeek( num );
1344 dateNavigator()->blockSignals( false ); 1344 dateNavigator()->blockSignals( false );
1345 mViewManager->showWeekView(); 1345 mViewManager->showWeekView();
1346} 1346}
1347KOViewManager *CalendarView::viewManager() 1347KOViewManager *CalendarView::viewManager()
1348{ 1348{
1349 return mViewManager; 1349 return mViewManager;
1350} 1350}
1351 1351
1352KODialogManager *CalendarView::dialogManager() 1352KODialogManager *CalendarView::dialogManager()
1353{ 1353{
1354 return mDialogManager; 1354 return mDialogManager;
1355} 1355}
1356 1356
1357QDate CalendarView::startDate() 1357QDate CalendarView::startDate()
1358{ 1358{
1359 DateList dates = mNavigator->selectedDates(); 1359 DateList dates = mNavigator->selectedDates();
1360 1360
1361 return dates.first(); 1361 return dates.first();
1362} 1362}
1363 1363
1364QDate CalendarView::endDate() 1364QDate CalendarView::endDate()
1365{ 1365{
1366 DateList dates = mNavigator->selectedDates(); 1366 DateList dates = mNavigator->selectedDates();
1367 1367
1368 return dates.last(); 1368 return dates.last();
1369} 1369}
1370 1370
1371 1371
1372void CalendarView::createPrinter() 1372void CalendarView::createPrinter()
1373{ 1373{
1374#ifndef KORG_NOPRINTER 1374#ifndef KORG_NOPRINTER
1375 if (!mCalPrinter) { 1375 if (!mCalPrinter) {
1376 mCalPrinter = new CalPrinter(this, mCalendar); 1376 mCalPrinter = new CalPrinter(this, mCalendar);
1377 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1377 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1378 } 1378 }
1379#endif 1379#endif
1380} 1380}
1381 1381
1382 1382
1383//KOPrefs::instance()->mWriteBackFile 1383//KOPrefs::instance()->mWriteBackFile
1384//KOPrefs::instance()->mWriteBackExistingOnly 1384//KOPrefs::instance()->mWriteBackExistingOnly
1385 1385
1386// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1386// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1387// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1387// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1388// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1388// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1389// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1389// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1390// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1390// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1391// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1391// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1392 1392
1393int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1393int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1394{ 1394{
1395 1395
1396 // 0 equal 1396 // 0 equal
1397 // 1 take local 1397 // 1 take local
1398 // 2 take remote 1398 // 2 take remote
1399 // 3 cancel 1399 // 3 cancel
1400 QDateTime lastSync = mLastCalendarSync; 1400 QDateTime lastSync = mLastCalendarSync;
1401 QDateTime localMod = local->lastModified(); 1401 QDateTime localMod = local->lastModified();
1402 QDateTime remoteMod = remote->lastModified(); 1402 QDateTime remoteMod = remote->lastModified();
1403 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1403 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1404 bool remCh, locCh; 1404 bool remCh, locCh;
1405 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1405 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1406 //if ( remCh ) 1406 //if ( remCh )
1407 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1407 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1408 locCh = ( localMod > mLastCalendarSync ); 1408 locCh = ( localMod > mLastCalendarSync );
1409 if ( !remCh && ! locCh ) { 1409 if ( !remCh && ! locCh ) {
1410 //qDebug("both not changed "); 1410 //qDebug("both not changed ");
1411 lastSync = localMod.addDays(1); 1411 lastSync = localMod.addDays(1);
1412 if ( mode <= SYNC_PREF_ASK ) 1412 if ( mode <= SYNC_PREF_ASK )
1413 return 0; 1413 return 0;
1414 } else { 1414 } else {
1415 if ( locCh ) { 1415 if ( locCh ) {
1416 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1416 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1417 lastSync = localMod.addDays( -1 ); 1417 lastSync = localMod.addDays( -1 );
1418 if ( !remCh ) 1418 if ( !remCh )
1419 remoteMod = ( lastSync.addDays( -1 ) ); 1419 remoteMod = ( lastSync.addDays( -1 ) );
1420 } else { 1420 } else {
1421 //qDebug(" not loc changed "); 1421 //qDebug(" not loc changed ");
1422 lastSync = localMod.addDays( 1 ); 1422 lastSync = localMod.addDays( 1 );
1423 if ( remCh ) 1423 if ( remCh )
1424 remoteMod =( lastSync.addDays( 1 ) ); 1424 remoteMod =( lastSync.addDays( 1 ) );
1425 1425
1426 } 1426 }
1427 } 1427 }
1428 full = true; 1428 full = true;
1429 if ( mode < SYNC_PREF_ASK ) 1429 if ( mode < SYNC_PREF_ASK )
1430 mode = SYNC_PREF_ASK; 1430 mode = SYNC_PREF_ASK;
1431 } else { 1431 } else {
1432 if ( localMod == remoteMod ) 1432 if ( localMod == remoteMod )
1433 // if ( local->revision() == remote->revision() ) 1433 // if ( local->revision() == remote->revision() )
1434 return 0; 1434 return 0;
1435 1435
1436 } 1436 }
1437 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1437 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1438 1438
1439 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1439 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1440 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1440 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1441 //full = true; //debug only 1441 //full = true; //debug only
1442 if ( full ) { 1442 if ( full ) {
1443 bool equ = false; 1443 bool equ = false;
1444 if ( local->typeID() == eventID ) { 1444 if ( local->typeID() == eventID ) {
1445 equ = (*((Event*) local) == *((Event*) remote)); 1445 equ = (*((Event*) local) == *((Event*) remote));
1446 } 1446 }
1447 else if ( local->typeID() == todoID ) 1447 else if ( local->typeID() == todoID )
1448 equ = (*((Todo*) local) == (*(Todo*) remote)); 1448 equ = (*((Todo*) local) == (*(Todo*) remote));
1449 else if ( local->typeID() == journalID ) 1449 else if ( local->typeID() == journalID )
1450 equ = (*((Journal*) local) == *((Journal*) remote)); 1450 equ = (*((Journal*) local) == *((Journal*) remote));
1451 if ( equ ) { 1451 if ( equ ) {
1452 //qDebug("equal "); 1452 //qDebug("equal ");
1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1454 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1454 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1455 } 1455 }
1456 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1456 if ( mode < SYNC_PREF_FORCE_LOCAL )
1457 return 0; 1457 return 0;
1458 1458
1459 }//else //debug only 1459 }//else //debug only
1460 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1460 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1461 } 1461 }
1462 int result; 1462 int result;
1463 bool localIsNew; 1463 bool localIsNew;
1464 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1464 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1465 1465
1466 1466
1467 // ************************************************ 1467 // ************************************************
1468 // ************************************************ 1468 // ************************************************
1469 // ************************************************ 1469 // ************************************************
1470 // We may have that lastSync > remoteMod AND lastSync > localMod 1470 // We may have that lastSync > remoteMod AND lastSync > localMod
1471 // BUT remoteMod != localMod 1471 // BUT remoteMod != localMod
1472 1472
1473 1473
1474 if ( full && mode < SYNC_PREF_NEWEST ) 1474 if ( full && mode < SYNC_PREF_NEWEST )
1475 mode = SYNC_PREF_ASK; 1475 mode = SYNC_PREF_ASK;
1476 1476
1477 switch( mode ) { 1477 switch( mode ) {
1478 case SYNC_PREF_LOCAL: 1478 case SYNC_PREF_LOCAL:
1479 if ( lastSync > remoteMod ) 1479 if ( lastSync > remoteMod )
1480 return 1; 1480 return 1;
1481 if ( lastSync > localMod ) 1481 if ( lastSync > localMod )
1482 return 2; 1482 return 2;
1483 return 1; 1483 return 1;
1484 break; 1484 break;
1485 case SYNC_PREF_REMOTE: 1485 case SYNC_PREF_REMOTE:
1486 if ( lastSync > localMod ) 1486 if ( lastSync > localMod )
1487 return 2; 1487 return 2;
1488 if ( lastSync > remoteMod ) 1488 if ( lastSync > remoteMod )
1489 return 1; 1489 return 1;
1490 return 2; 1490 return 2;
1491 break; 1491 break;
1492 case SYNC_PREF_NEWEST: 1492 case SYNC_PREF_NEWEST:
1493 if ( localMod >= remoteMod ) 1493 if ( localMod >= remoteMod )
1494 return 1; 1494 return 1;
1495 else 1495 else
1496 return 2; 1496 return 2;
1497 break; 1497 break;
1498 case SYNC_PREF_ASK: 1498 case SYNC_PREF_ASK:
1499 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1499 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1500 if ( lastSync > remoteMod && lastSync > localMod) 1500 if ( lastSync > remoteMod && lastSync > localMod)
1501 return 0; 1501 return 0;
1502 if ( lastSync > remoteMod ) 1502 if ( lastSync > remoteMod )
1503 return 1; 1503 return 1;
1504 if ( lastSync > localMod ) 1504 if ( lastSync > localMod )
1505 return 2; 1505 return 2;
1506 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1506 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1507 localIsNew = localMod >= remoteMod; 1507 localIsNew = localMod >= remoteMod;
1508 if ( localIsNew ) 1508 if ( localIsNew )
1509 getEventViewerDialog()->setColorMode( 1 ); 1509 getEventViewerDialog()->setColorMode( 1 );
1510 else 1510 else
1511 getEventViewerDialog()->setColorMode( 2 ); 1511 getEventViewerDialog()->setColorMode( 2 );
1512 getEventViewerDialog()->setIncidence(local); 1512 getEventViewerDialog()->setIncidence(local);
1513 if ( localIsNew ) 1513 if ( localIsNew )
1514 getEventViewerDialog()->setColorMode( 2 ); 1514 getEventViewerDialog()->setColorMode( 2 );
1515 else 1515 else
1516 getEventViewerDialog()->setColorMode( 1 ); 1516 getEventViewerDialog()->setColorMode( 1 );
1517 getEventViewerDialog()->addIncidence(remote); 1517 getEventViewerDialog()->addIncidence(remote);
1518 getEventViewerDialog()->setColorMode( 0 ); 1518 getEventViewerDialog()->setColorMode( 0 );
1519 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1519 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1520 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1520 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1521 getEventViewerDialog()->showMe(); 1521 getEventViewerDialog()->showMe();
1522 result = getEventViewerDialog()->executeS( localIsNew ); 1522 result = getEventViewerDialog()->executeS( localIsNew );
1523 return result; 1523 return result;
1524 1524
1525 break; 1525 break;
1526 case SYNC_PREF_FORCE_LOCAL: 1526 case SYNC_PREF_FORCE_LOCAL:
1527 return 1; 1527 return 1;
1528 break; 1528 break;
1529 case SYNC_PREF_FORCE_REMOTE: 1529 case SYNC_PREF_FORCE_REMOTE:
1530 return 2; 1530 return 2;
1531 break; 1531 break;
1532 1532
1533 default: 1533 default:
1534 // SYNC_PREF_TAKE_BOTH not implemented 1534 // SYNC_PREF_TAKE_BOTH not implemented
1535 break; 1535 break;
1536 } 1536 }
1537 return 0; 1537 return 0;
1538} 1538}
1539Event* CalendarView::getLastSyncEvent() 1539Event* CalendarView::getLastSyncEvent()
1540{ 1540{
1541 Event* lse; 1541 Event* lse;
1542 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1542 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1543 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1543 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1544 if (!lse) { 1544 if (!lse) {
1545 lse = new Event(); 1545 lse = new Event();
1546 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1546 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1547 QString sum = ""; 1547 QString sum = "";
1548 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1548 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1549 sum = "E: "; 1549 sum = "E: ";
1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1551 lse->setDtStart( mLastCalendarSync ); 1551 lse->setDtStart( mLastCalendarSync );
1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1553 lse->setCategories( i18n("SyncEvent") ); 1553 lse->setCategories( i18n("SyncEvent") );
1554 lse->setReadOnly( true ); 1554 lse->setReadOnly( true );
1555 mCalendar->addEvent( lse ); 1555 mCalendar->addEvent( lse );
1556 } 1556 }
1557 1557
1558 return lse; 1558 return lse;
1559 1559
1560} 1560}
1561 1561
1562// we check, if the to delete event has a id for a profile 1562// we check, if the to delete event has a id for a profile
1563// if yes, we set this id in the profile to delete 1563// if yes, we set this id in the profile to delete
1564void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1564void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1565{ 1565{
1566 if ( lastSync.count() == 0 ) { 1566 if ( lastSync.count() == 0 ) {
1567 //qDebug(" lastSync.count() == 0"); 1567 //qDebug(" lastSync.count() == 0");
1568 return; 1568 return;
1569 } 1569 }
1570 if ( toDelete->typeID() == journalID ) 1570 if ( toDelete->typeID() == journalID )
1571 return; 1571 return;
1572 1572
1573 Event* eve = lastSync.first(); 1573 Event* eve = lastSync.first();
1574 1574
1575 while ( eve ) { 1575 while ( eve ) {
1576 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1576 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1577 if ( !id.isEmpty() ) { 1577 if ( !id.isEmpty() ) {
1578 QString des = eve->description(); 1578 QString des = eve->description();
1579 QString pref = "e"; 1579 QString pref = "e";
1580 if ( toDelete->typeID() == todoID ) 1580 if ( toDelete->typeID() == todoID )
1581 pref = "t"; 1581 pref = "t";
1582 des += pref+ id + ","; 1582 des += pref+ id + ",";
1583 eve->setReadOnly( false ); 1583 eve->setReadOnly( false );
1584 eve->setDescription( des ); 1584 eve->setDescription( des );
1585 //qDebug("setdes %s ", des.latin1()); 1585 //qDebug("setdes %s ", des.latin1());
1586 eve->setReadOnly( true ); 1586 eve->setReadOnly( true );
1587 } 1587 }
1588 eve = lastSync.next(); 1588 eve = lastSync.next();
1589 } 1589 }
1590 1590
1591} 1591}
1592void CalendarView::checkExternalId( Incidence * inc ) 1592void CalendarView::checkExternalId( Incidence * inc )
1593{ 1593{
1594 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1594 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1595 checkExternSyncEvent( lastSync, inc ); 1595 checkExternSyncEvent( lastSync, inc );
1596 1596
1597} 1597}
1598bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1598bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1599{ 1599{
1600 bool syncOK = true; 1600 bool syncOK = true;
1601 int addedEvent = 0; 1601 int addedEvent = 0;
1602 int addedEventR = 0; 1602 int addedEventR = 0;
1603 int deletedEventR = 0; 1603 int deletedEventR = 0;
1604 int deletedEventL = 0; 1604 int deletedEventL = 0;
1605 int changedLocal = 0; 1605 int changedLocal = 0;
1606 int changedRemote = 0; 1606 int changedRemote = 0;
1607 int filteredIN = 0; 1607 int filteredIN = 0;
1608 int filteredOUT = 0; 1608 int filteredOUT = 0;
1609 //QPtrList<Event> el = local->rawEvents(); 1609 //QPtrList<Event> el = local->rawEvents();
1610 Event* eventR; 1610 Event* eventR;
1611 QString uid; 1611 QString uid;
1612 int take; 1612 int take;
1613 Event* eventRSync; 1613 Event* eventRSync;
1614 Event* eventLSync; 1614 Event* eventLSync;
1615 clearAllViews(); 1615 clearAllViews();
1616 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1616 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1617 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1617 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1618 bool fullDateRange = false; 1618 bool fullDateRange = false;
1619 local->resetTempSyncStat(); 1619 local->resetTempSyncStat();
1620 mLastCalendarSync = QDateTime::currentDateTime(); 1620 mLastCalendarSync = QDateTime::currentDateTime();
1621 if ( mSyncManager->syncWithDesktop() ) { 1621 if ( mSyncManager->syncWithDesktop() ) {
1622 remote->resetPilotStat(1); 1622 remote->resetPilotStat(1);
1623 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1623 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1624 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1624 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1625 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1625 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1626 } else { 1626 } else {
1627 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1627 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1628 } 1628 }
1629 } 1629 }
1630 QDateTime modifiedCalendar = mLastCalendarSync; 1630 QDateTime modifiedCalendar = mLastCalendarSync;
1631 eventLSync = getLastSyncEvent(); 1631 eventLSync = getLastSyncEvent();
1632 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1632 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1633 if ( eventR ) { 1633 if ( eventR ) {
1634 qDebug("last-syncEvent on remote found "); 1634 qDebug("last-syncEvent on remote found ");
1635 eventRSync = (Event*) eventR->clone(); 1635 eventRSync = (Event*) eventR->clone();
1636 remote->deleteEvent(eventR ); 1636 remote->deleteEvent(eventR );
1637 1637
1638 } else { 1638 } else {
1639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1640 eventRSync = (Event*)eventLSync->clone(); 1640 eventRSync = (Event*)eventLSync->clone();
1641 } else { 1641 } else {
1642 fullDateRange = true; 1642 fullDateRange = true;
1643 eventRSync = new Event(); 1643 eventRSync = new Event();
1644 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1644 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1645 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1645 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1646 eventRSync->setDtStart( mLastCalendarSync ); 1646 eventRSync->setDtStart( mLastCalendarSync );
1647 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1647 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1648 eventRSync->setCategories( i18n("SyncEvent") ); 1648 eventRSync->setCategories( i18n("SyncEvent") );
1649 } 1649 }
1650 } 1650 }
1651 if ( eventLSync->dtStart() == mLastCalendarSync ) 1651 if ( eventLSync->dtStart() == mLastCalendarSync )
1652 fullDateRange = true; 1652 fullDateRange = true;
1653 1653
1654 if ( ! fullDateRange ) { 1654 if ( ! fullDateRange ) {
1655 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1655 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1656 1656
1657 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1657 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1658 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1658 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1659 fullDateRange = true; 1659 fullDateRange = true;
1660 } 1660 }
1661 } 1661 }
1662 if ( mSyncManager->syncWithDesktop() ) { 1662 if ( mSyncManager->syncWithDesktop() ) {
1663 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1663 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1664 } 1664 }
1665 if ( fullDateRange ) 1665 if ( fullDateRange )
1666 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1666 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1667 else 1667 else
1668 mLastCalendarSync = eventLSync->dtStart(); 1668 mLastCalendarSync = eventLSync->dtStart();
1669 // for resyncing if own file has changed 1669 // for resyncing if own file has changed
1670 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1670 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1671 mLastCalendarSync = loadedFileVersion; 1671 mLastCalendarSync = loadedFileVersion;
1672 //qDebug("setting mLastCalendarSync "); 1672 //qDebug("setting mLastCalendarSync ");
1673 } 1673 }
1674 //qDebug("*************************** "); 1674 //qDebug("*************************** ");
1675 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1675 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1676 QPtrList<Incidence> er = remote->rawIncidences(); 1676 QPtrList<Incidence> er = remote->rawIncidences();
1677 Incidence* inR = er.first(); 1677 Incidence* inR = er.first();
1678 Incidence* inL; 1678 Incidence* inL;
1679 QProgressBar bar( er.count(),0 ); 1679 QProgressBar bar( er.count(),0 );
1680 bar.setCaption (i18n("Syncing - close to abort!") ); 1680 bar.setCaption (i18n("Syncing - close to abort!") );
1681 1681
1682 // ************** setting up filter ************* 1682 // ************** setting up filter *************
1683 CalFilter *filterIN = 0; 1683 CalFilter *filterIN = 0;
1684 CalFilter *filterOUT = 0; 1684 CalFilter *filterOUT = 0;
1685 CalFilter *filter = mFilters.first(); 1685 CalFilter *filter = mFilters.first();
1686 while(filter) { 1686 while(filter) {
1687 if ( filter->name() == mSyncManager->mFilterInCal ) 1687 if ( filter->name() == mSyncManager->mFilterInCal )
1688 filterIN = filter; 1688 filterIN = filter;
1689 if ( filter->name() == mSyncManager->mFilterOutCal ) 1689 if ( filter->name() == mSyncManager->mFilterOutCal )
1690 filterOUT = filter; 1690 filterOUT = filter;
1691 filter = mFilters.next(); 1691 filter = mFilters.next();
1692 } 1692 }
1693 int w = 300; 1693 int w = 300;
1694 if ( QApplication::desktop()->width() < 320 ) 1694 if ( QApplication::desktop()->width() < 320 )
1695 w = 220; 1695 w = 220;
1696 int h = bar.sizeHint().height() ; 1696 int h = bar.sizeHint().height() ;
1697 int dw = QApplication::desktop()->width(); 1697 int dw = QApplication::desktop()->width();
1698 int dh = QApplication::desktop()->height(); 1698 int dh = QApplication::desktop()->height();
1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1700 bar.show(); 1700 bar.show();
1701 int modulo = (er.count()/10)+1; 1701 int modulo = (er.count()/10)+1;
1702 int incCounter = 0; 1702 int incCounter = 0;
1703 while ( inR ) { 1703 while ( inR ) {
1704 if ( ! bar.isVisible() ) 1704 if ( ! bar.isVisible() )
1705 return false; 1705 return false;
1706 if ( incCounter % modulo == 0 ) 1706 if ( incCounter % modulo == 0 )
1707 bar.setProgress( incCounter ); 1707 bar.setProgress( incCounter );
1708 ++incCounter; 1708 ++incCounter;
1709 uid = inR->uid(); 1709 uid = inR->uid();
1710 bool skipIncidence = false; 1710 bool skipIncidence = false;
1711 if ( uid.left(15) == QString("last-syncEvent-") ) 1711 if ( uid.left(15) == QString("last-syncEvent-") )
1712 skipIncidence = true; 1712 skipIncidence = true;
1713 QString idS; 1713 QString idS;
1714 qApp->processEvents(); 1714 qApp->processEvents();
1715 if ( !skipIncidence ) { 1715 if ( !skipIncidence ) {
1716 inL = local->incidenceForUid( uid , false ); 1716 inL = local->incidenceForUid( uid , false );
1717 if ( inL ) { // maybe conflict - same uid in both calendars 1717 if ( inL ) { // maybe conflict - same uid in both calendars
1718 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1718 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1719 //qDebug("take %d %s ", take, inL->summary().latin1()); 1719 //qDebug("take %d %s ", take, inL->summary().latin1());
1720 if ( take == 3 ) 1720 if ( take == 3 )
1721 return false; 1721 return false;
1722 if ( take == 1 ) {// take local ********************** 1722 if ( take == 1 ) {// take local **********************
1723 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1723 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1725 else 1725 else
1726 idS = inR->IDStr(); 1726 idS = inR->IDStr();
1727 int calID = inR->calID(); 1727 int calID = inR->calID();
1728 remote->deleteIncidence( inR ); 1728 remote->deleteIncidence( inR );
1729 inR = inL->clone(); 1729 inR = inL->clone();
1730 inR->setCalID( calID ); 1730 inR->setCalID( calID );
1731 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1731 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1732 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1732 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1733 inR->setIDStr( idS ); 1733 inR->setIDStr( idS );
1734 remote->addIncidence( inR ); 1734 remote->addIncidence( inR );
1735 if ( mSyncManager->syncWithDesktop() ) 1735 if ( mSyncManager->syncWithDesktop() )
1736 inR->setPilotId( 2 ); 1736 inR->setPilotId( 2 );
1737 ++changedRemote; 1737 ++changedRemote;
1738 } else {// take remote ********************** 1738 } else {// take remote **********************
1739 if ( !inL->isReadOnly() ) { 1739 if ( !inL->isReadOnly() ) {
1740 idS = inL->IDStr(); 1740 idS = inL->IDStr();
1741 int pid = inL->pilotId(); 1741 int pid = inL->pilotId();
1742 int calID = inL->calID(); 1742 int calID = inL->calID();
1743 local->deleteIncidence( inL ); 1743 local->deleteIncidence( inL );
1744 inL = inR->clone(); 1744 inL = inR->clone();
1745 inL->setCalID( calID ); 1745 inL->setCalID( calID );
1746 if ( mSyncManager->syncWithDesktop() ) 1746 if ( mSyncManager->syncWithDesktop() )
1747 inL->setPilotId( pid ); 1747 inL->setPilotId( pid );
1748 inL->setIDStr( idS ); 1748 inL->setIDStr( idS );
1749 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1749 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1750 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1750 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1751 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1751 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1752 } 1752 }
1753 local->addIncidence( inL ); 1753 local->addIncidence( inL );
1754 ++changedLocal; 1754 ++changedLocal;
1755 } 1755 }
1756 } 1756 }
1757 } 1757 }
1758 } else { // no conflict ********** add or delete remote 1758 } else { // no conflict ********** add or delete remote
1759 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1759 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1761 QString des = eventLSync->description(); 1761 QString des = eventLSync->description();
1762 QString pref = "e"; 1762 QString pref = "e";
1763 if ( inR->typeID() == todoID ) 1763 if ( inR->typeID() == todoID )
1764 pref = "t"; 1764 pref = "t";
1765 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1765 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1766 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1766 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1767 //remote->deleteIncidence( inR ); 1767 //remote->deleteIncidence( inR );
1768 ++deletedEventR; 1768 ++deletedEventR;
1769 } else { 1769 } else {
1770 inR->setLastModified( modifiedCalendar ); 1770 inR->setLastModified( modifiedCalendar );
1771 inL = inR->clone(); 1771 inL = inR->clone();
1772 inL->setIDStr( ":" ); 1772 inL->setIDStr( ":" );
1773 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1773 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1774 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1774 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1775 1775
1776 inL->setCalID( 0 );// add to default cal 1776 inL->setCalID( 0 );// add to default cal
1777 local->addIncidence( inL ); 1777 local->addIncidence( inL );
1778 ++addedEvent; 1778 ++addedEvent;
1779 1779
1780 } 1780 }
1781 } else { 1781 } else {
1782 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1782 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1783 inR->setLastModified( modifiedCalendar ); 1783 inR->setLastModified( modifiedCalendar );
1784 inL = inR->clone(); 1784 inL = inR->clone();
1785 inL->setIDStr( ":" ); 1785 inL->setIDStr( ":" );
1786 inL->setCalID( 0 );// add to default cal 1786 inL->setCalID( 0 );// add to default cal
1787 local->addIncidence( inL ); 1787 local->addIncidence( inL );
1788 ++addedEvent; 1788 ++addedEvent;
1789 1789
1790 } else { 1790 } else {
1791 checkExternSyncEvent(eventRSyncSharp, inR); 1791 checkExternSyncEvent(eventRSyncSharp, inR);
1792 remote->deleteIncidence( inR ); 1792 remote->deleteIncidence( inR );
1793 ++deletedEventR; 1793 ++deletedEventR;
1794 } 1794 }
1795 } 1795 }
1796 } else { 1796 } else {
1797 ++filteredIN; 1797 ++filteredIN;
1798 } 1798 }
1799 } 1799 }
1800 } 1800 }
1801 inR = er.next(); 1801 inR = er.next();
1802 } 1802 }
1803 QPtrList<Incidence> el = local->rawIncidences(); 1803 QPtrList<Incidence> el = local->rawIncidences();
1804 inL = el.first(); 1804 inL = el.first();
1805 modulo = (el.count()/10)+1; 1805 modulo = (el.count()/10)+1;
1806 bar.setCaption (i18n("Add / remove events") ); 1806 bar.setCaption (i18n("Add / remove events") );
1807 bar.setTotalSteps ( el.count() ) ; 1807 bar.setTotalSteps ( el.count() ) ;
1808 bar.show(); 1808 bar.show();
1809 incCounter = 0; 1809 incCounter = 0;
1810 1810
1811 while ( inL ) { 1811 while ( inL ) {
1812 1812
1813 qApp->processEvents(); 1813 qApp->processEvents();
1814 if ( ! bar.isVisible() ) 1814 if ( ! bar.isVisible() )
1815 return false; 1815 return false;
1816 if ( incCounter % modulo == 0 ) 1816 if ( incCounter % modulo == 0 )
1817 bar.setProgress( incCounter ); 1817 bar.setProgress( incCounter );
1818 ++incCounter; 1818 ++incCounter;
1819 uid = inL->uid(); 1819 uid = inL->uid();
1820 bool skipIncidence = false; 1820 bool skipIncidence = false;
1821 if ( uid.left(15) == QString("last-syncEvent-") ) 1821 if ( uid.left(15) == QString("last-syncEvent-") )
1822 skipIncidence = true; 1822 skipIncidence = true;
1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1824 skipIncidence = true; 1824 skipIncidence = true;
1825 if ( !skipIncidence ) { 1825 if ( !skipIncidence ) {
1826 inR = remote->incidenceForUid( uid , true ); 1826 inR = remote->incidenceForUid( uid , true );
1827 if ( ! inR ) { 1827 if ( ! inR ) {
1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1829 // no conflict ********** add or delete local 1829 // no conflict ********** add or delete local
1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1832 checkExternSyncEvent(eventLSyncSharp, inL); 1832 checkExternSyncEvent(eventLSyncSharp, inL);
1833 local->deleteIncidence( inL ); 1833 local->deleteIncidence( inL );
1834 ++deletedEventL; 1834 ++deletedEventL;
1835 } else { 1835 } else {
1836 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1836 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1837 inL->removeID(mCurrentSyncDevice ); 1837 inL->removeID(mCurrentSyncDevice );
1838 ++addedEventR; 1838 ++addedEventR;
1839 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1839 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1840 inL->setLastModified( modifiedCalendar ); 1840 inL->setLastModified( modifiedCalendar );
1841 inR = inL->clone(); 1841 inR = inL->clone();
1842 inR->setIDStr( ":" ); 1842 inR->setIDStr( ":" );
1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1844 inR->setCalID( 0 );// add to default cal 1844 inR->setCalID( 0 );// add to default cal
1845 remote->addIncidence( inR ); 1845 remote->addIncidence( inR );
1846 } 1846 }
1847 } 1847 }
1848 } else { 1848 } else {
1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1850 checkExternSyncEvent(eventLSyncSharp, inL); 1850 checkExternSyncEvent(eventLSyncSharp, inL);
1851 local->deleteIncidence( inL ); 1851 local->deleteIncidence( inL );
1852 ++deletedEventL; 1852 ++deletedEventL;
1853 } else { 1853 } else {
1854 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1854 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1855 ++addedEventR; 1855 ++addedEventR;
1856 inL->setLastModified( modifiedCalendar ); 1856 inL->setLastModified( modifiedCalendar );
1857 inR = inL->clone(); 1857 inR = inL->clone();
1858 inR->setIDStr( ":" ); 1858 inR->setIDStr( ":" );
1859 inR->setCalID( 0 );// add to default cal 1859 inR->setCalID( 0 );// add to default cal
1860 remote->addIncidence( inR ); 1860 remote->addIncidence( inR );
1861 } 1861 }
1862 } 1862 }
1863 } 1863 }
1864 } else { 1864 } else {
1865 ++filteredOUT; 1865 ++filteredOUT;
1866 } 1866 }
1867 } 1867 }
1868 } 1868 }
1869 inL = el.next(); 1869 inL = el.next();
1870 } 1870 }
1871 int delFut = 0; 1871 int delFut = 0;
1872 int remRem = 0; 1872 int remRem = 0;
1873 if ( mSyncManager->mWriteBackInFuture ) { 1873 if ( mSyncManager->mWriteBackInFuture ) {
1874 er = remote->rawIncidences(); 1874 er = remote->rawIncidences();
1875 remRem = er.count(); 1875 remRem = er.count();
1876 inR = er.first(); 1876 inR = er.first();
1877 QDateTime dt; 1877 QDateTime dt;
1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1880 while ( inR ) { 1880 while ( inR ) {
1881 if ( inR->typeID() == todoID ) { 1881 if ( inR->typeID() == todoID ) {
1882 Todo * t = (Todo*)inR; 1882 Todo * t = (Todo*)inR;
1883 if ( t->hasDueDate() ) 1883 if ( t->hasDueDate() )
1884 dt = t->dtDue(); 1884 dt = t->dtDue();
1885 else 1885 else
1886 dt = cur.addSecs( 62 ); 1886 dt = cur.addSecs( 62 );
1887 } 1887 }
1888 else if (inR->typeID() == eventID ) { 1888 else if (inR->typeID() == eventID ) {
1889 bool ok; 1889 bool ok;
1890 dt = inR->getNextOccurence( cur, &ok ); 1890 dt = inR->getNextOccurence( cur, &ok );
1891 if ( !ok ) 1891 if ( !ok )
1892 dt = cur.addSecs( -62 ); 1892 dt = cur.addSecs( -62 );
1893 } 1893 }
1894 else 1894 else
1895 dt = inR->dtStart(); 1895 dt = inR->dtStart();
1896 if ( dt < cur || dt > end ) { 1896 if ( dt < cur || dt > end ) {
1897 remote->deleteIncidence( inR ); 1897 remote->deleteIncidence( inR );
1898 ++delFut; 1898 ++delFut;
1899 } 1899 }
1900 inR = er.next(); 1900 inR = er.next();
1901 } 1901 }
1902 } 1902 }
1903 bar.hide(); 1903 bar.hide();
1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1905 eventLSync->setReadOnly( false ); 1905 eventLSync->setReadOnly( false );
1906 eventLSync->setDtStart( mLastCalendarSync ); 1906 eventLSync->setDtStart( mLastCalendarSync );
1907 eventRSync->setDtStart( mLastCalendarSync ); 1907 eventRSync->setDtStart( mLastCalendarSync );
1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1912 eventLSync->setReadOnly( true ); 1912 eventLSync->setReadOnly( true );
1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1915 remote->addEvent( eventRSync ); 1915 remote->addEvent( eventRSync );
1916 else 1916 else
1917 delete eventRSync; 1917 delete eventRSync;
1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1919 QString mes; 1919 QString mes;
1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1921 QString delmess; 1921 QString delmess;
1922 if ( delFut ) { 1922 if ( delFut ) {
1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1924 mes += delmess; 1924 mes += delmess;
1925 } 1925 }
1926 mes = i18n("Local calendar changed!\n") +mes; 1926 mes = i18n("Local calendar changed!\n") +mes;
1927 mCalendar->checkAlarmForIncidence( 0, true ); 1927 mCalendar->checkAlarmForIncidence( 0, true );
1928 qDebug( mes ); 1928 qDebug( mes );
1929 if ( mSyncManager->mShowSyncSummary ) { 1929 if ( mSyncManager->mShowSyncSummary ) {
1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1932 qDebug("KO: WB cancelled "); 1932 qDebug("KO: WB cancelled ");
1933 mSyncManager->mWriteBackFile = false; 1933 mSyncManager->mWriteBackFile = false;
1934 return syncOK; 1934 return syncOK;
1935 } 1935 }
1936 } 1936 }
1937 return syncOK; 1937 return syncOK;
1938} 1938}
1939 1939
1940void CalendarView::setSyncDevice( QString s ) 1940void CalendarView::setSyncDevice( QString s )
1941{ 1941{
1942 mCurrentSyncDevice= s; 1942 mCurrentSyncDevice= s;
1943} 1943}
1944void CalendarView::setSyncName( QString s ) 1944void CalendarView::setSyncName( QString s )
1945{ 1945{
1946 mCurrentSyncName= s; 1946 mCurrentSyncName= s;
1947} 1947}
1948bool CalendarView::syncCalendar(QString filename, int mode) 1948bool CalendarView::syncCalendar(QString filename, int mode)
1949{ 1949{
1950 //qDebug("syncCalendar %s ", filename.latin1()); 1950 //qDebug("syncCalendar %s ", filename.latin1());
1951 mGlobalSyncMode = SYNC_MODE_NORMAL; 1951 mGlobalSyncMode = SYNC_MODE_NORMAL;
1952 CalendarLocal* calendar = new CalendarLocal(); 1952 CalendarLocal* calendar = new CalendarLocal();
1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1954 FileStorage* storage = new FileStorage( calendar ); 1954 FileStorage* storage = new FileStorage( calendar );
1955 bool syncOK = false; 1955 bool syncOK = false;
1956 storage->setFileName( filename ); 1956 storage->setFileName( filename );
1957 // qDebug("loading ... "); 1957 // qDebug("loading ... ");
1958 if ( storage->load() ) { 1958 if ( storage->load() ) {
1959 getEventViewerDialog()->setSyncMode( true ); 1959 getEventViewerDialog()->setSyncMode( true );
1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1961 getEventViewerDialog()->setSyncMode( false ); 1961 getEventViewerDialog()->setSyncMode( false );
1962 if ( syncOK ) { 1962 if ( syncOK ) {
1963 if ( mSyncManager->mWriteBackFile ) 1963 if ( mSyncManager->mWriteBackFile )
1964 { 1964 {
1965 storage->setSaveFormat( new ICalFormat() ); 1965 storage->setSaveFormat( new ICalFormat() );
1966 storage->save(); 1966 storage->save();
1967 } 1967 }
1968 } 1968 }
1969 setModified( true ); 1969 setModified( true );
1970 } 1970 }
1971 delete storage; 1971 delete storage;
1972 delete calendar; 1972 delete calendar;
1973 if ( syncOK ) 1973 if ( syncOK )
1974 updateView(); 1974 updateView();
1975 return syncOK; 1975 return syncOK;
1976} 1976}
1977 1977
1978void CalendarView::syncExternal( int mode ) 1978void CalendarView::syncExternal( int mode )
1979{ 1979{
1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1981
1982 qApp->processEvents(); 1981 qApp->processEvents();
1983 CalendarLocal* calendar = new CalendarLocal(); 1982 CalendarLocal* calendar = new CalendarLocal();
1984 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1983 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1985 bool syncOK = false; 1984 bool syncOK = false;
1986 bool loadSuccess = false; 1985 bool loadSuccess = false;
1987 PhoneFormat* phoneFormat = 0; 1986 PhoneFormat* phoneFormat = 0;
1988 emit tempDisableBR(true); 1987 emit tempDisableBR(true);
1989#ifndef DESKTOP_VERSION 1988#ifndef DESKTOP_VERSION
1990 SharpFormat* sharpFormat = 0; 1989 SharpFormat* sharpFormat = 0;
1991 if ( mode == 0 ) { // sharp 1990 if ( mode == 0 ) { // sharp
1992 sharpFormat = new SharpFormat () ; 1991 sharpFormat = new SharpFormat () ;
1993 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1992 loadSuccess = sharpFormat->load( calendar, mCalendar );
1994 1993
1995 } else 1994 } else
1996#endif 1995#endif
1997 if ( mode == 1 ) { // phone 1996 if ( mode == 1 ) { // phone
1998 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1997 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1999 mSyncManager->mPhoneDevice, 1998 mSyncManager->mPhoneDevice,
2000 mSyncManager->mPhoneConnection, 1999 mSyncManager->mPhoneConnection,
2001 mSyncManager->mPhoneModel); 2000 mSyncManager->mPhoneModel);
2002 loadSuccess = phoneFormat->load( calendar,mCalendar); 2001 loadSuccess = phoneFormat->load( calendar,mCalendar);
2003 2002
2004 } else { 2003 } else {
2005 emit tempDisableBR(false); 2004 emit tempDisableBR(false);
2006 return; 2005 return;
2007 } 2006 }
2008 if ( loadSuccess ) { 2007 if ( loadSuccess ) {
2009 getEventViewerDialog()->setSyncMode( true ); 2008 getEventViewerDialog()->setSyncMode( true );
2010 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2009 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2011 getEventViewerDialog()->setSyncMode( false ); 2010 getEventViewerDialog()->setSyncMode( false );
2012 qApp->processEvents(); 2011 qApp->processEvents();
2013 if ( syncOK ) { 2012 if ( syncOK ) {
2014 if ( mSyncManager->mWriteBackFile ) 2013 if ( mSyncManager->mWriteBackFile )
2015 { 2014 {
2016 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2015 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2017 Incidence* inc = iL.first(); 2016 Incidence* inc = iL.first();
2018 if ( phoneFormat ) { 2017 if ( phoneFormat ) {
2019 while ( inc ) { 2018 while ( inc ) {
2020 inc->removeID(mCurrentSyncDevice); 2019 inc->removeID(mCurrentSyncDevice);
2021 inc = iL.next(); 2020 inc = iL.next();
2022 } 2021 }
2023 } 2022 }
2024#ifndef DESKTOP_VERSION 2023#ifndef DESKTOP_VERSION
2025 if ( sharpFormat ) 2024 if ( sharpFormat )
2026 sharpFormat->save(calendar); 2025 sharpFormat->save(calendar);
2027#endif 2026#endif
2028 if ( phoneFormat ) 2027 if ( phoneFormat )
2029 phoneFormat->save(calendar); 2028 phoneFormat->save(calendar);
2030 iL = calendar->rawIncidences(); 2029 iL = calendar->rawIncidences();
2031 inc = iL.first(); 2030 inc = iL.first();
2032 Incidence* loc; 2031 Incidence* loc;
2033 while ( inc ) { 2032 while ( inc ) {
2034 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2033 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2035 loc = mCalendar->incidence(inc->uid() ); 2034 loc = mCalendar->incidence(inc->uid() );
2036 if ( loc ) { 2035 if ( loc ) {
2037 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2036 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2038 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2037 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2039 } 2038 }
2040 } 2039 }
2041 inc = iL.next(); 2040 inc = iL.next();
2042 } 2041 }
2043 Incidence* lse = getLastSyncEvent(); 2042 Incidence* lse = getLastSyncEvent();
2044 if ( lse ) { 2043 if ( lse ) {
2045 lse->setReadOnly( false ); 2044 lse->setReadOnly( false );
2046 lse->setDescription( "" ); 2045 lse->setDescription( "" );
2047 lse->setReadOnly( true ); 2046 lse->setReadOnly( true );
2048 } 2047 }
2049 } 2048 }
2050 } else { 2049 } else {
2051 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2050 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2052 } 2051 }
2053 setModified( true ); 2052 setModified( true );
2054 } else { 2053 } else {
2055 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2054 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2056 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2055 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2057 question, i18n("Ok")) ; 2056 question, i18n("Ok")) ;
2058 2057
2059 } 2058 }
2060 delete calendar; 2059 delete calendar;
2061 updateView(); 2060 updateView();
2062 emit tempDisableBR(false); 2061 emit tempDisableBR(false);
2063 return ;//syncOK; 2062 return ;//syncOK;
2064 2063
2065} 2064}
2066 2065
2067bool CalendarView::importBday() 2066bool CalendarView::importBday()
2068{ 2067{
2069#ifndef KORG_NOKABC 2068#ifndef KORG_NOKABC
2070 2069
2071#ifdef DESKTOP_VERSION 2070#ifdef DESKTOP_VERSION
2072 int curCal = mCalendar->defaultCalendar(); 2071 int curCal = mCalendar->defaultCalendar();
2073 int bd = mCalEditView->getBirtdayID(); 2072 int bd = mCalEditView->getBirtdayID();
2074 if ( bd == 0 ) 2073 if ( bd == 0 )
2075 return false; 2074 return false;
2076 mCalendar->setDefaultCalendar( bd ); 2075 mCalendar->setDefaultCalendar( bd );
2077 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2076 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2078 KABC::AddressBook::Iterator it; 2077 KABC::AddressBook::Iterator it;
2079 int count = 0; 2078 int count = 0;
2080 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2079 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2081 ++count; 2080 ++count;
2082 } 2081 }
2083 QProgressBar bar(count,0 ); 2082 QProgressBar bar(count,0 );
2084 int w = 300; 2083 int w = 300;
2085 if ( QApplication::desktop()->width() < 320 ) 2084 if ( QApplication::desktop()->width() < 320 )
2086 w = 220; 2085 w = 220;
2087 int h = bar.sizeHint().height() ; 2086 int h = bar.sizeHint().height() ;
2088 int dw = QApplication::desktop()->width(); 2087 int dw = QApplication::desktop()->width();
2089 int dh = QApplication::desktop()->height(); 2088 int dh = QApplication::desktop()->height();
2090 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2089 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2091 bar.show(); 2090 bar.show();
2092 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2091 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2093 qApp->processEvents(); 2092 qApp->processEvents();
2094 count = 0; 2093 count = 0;
2095 int addCount = 0; 2094 int addCount = 0;
2096 KCal::Attendee* a = 0; 2095 KCal::Attendee* a = 0;
2097 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2096 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2098 if ( ! bar.isVisible() ) 2097 if ( ! bar.isVisible() )
2099 return false; 2098 return false;
2100 bar.setProgress( count++ ); 2099 bar.setProgress( count++ );
2101 qApp->processEvents(); 2100 qApp->processEvents();
2102 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2101 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2103 if ( (*it).birthday().date().isValid() ){ 2102 if ( (*it).birthday().date().isValid() ){
2104 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2103 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2105 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2104 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2106 ++addCount; 2105 ++addCount;
2107 } 2106 }
2108 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2107 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2109 if ( anni.isValid() ){ 2108 if ( anni.isValid() ){
2110 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2109 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2111 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2110 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2112 ++addCount; 2111 ++addCount;
2113 } 2112 }
2114 } 2113 }
2115 mCalendar->setDefaultCalendar( curCal ); 2114 mCalendar->setDefaultCalendar( curCal );
2116 updateView(); 2115 updateView();
2117 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2116 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2118#else //DESKTOP_VERSION 2117#else //DESKTOP_VERSION
2119 2118
2120 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2119 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2121 // the result should now arrive through method insertBirthdays 2120 // the result should now arrive through method insertBirthdays
2122 2121
2123#endif //DESKTOP_VERSION 2122#endif //DESKTOP_VERSION
2124 2123
2125#endif //KORG_NOKABC 2124#endif //KORG_NOKABC
2126 2125
2127 2126
2128 return true; 2127 return true;
2129} 2128}
2130 2129
2131// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2130// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2132void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2131void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2133 const QStringList& anniversaryList, const QStringList& realNameList, 2132 const QStringList& anniversaryList, const QStringList& realNameList,
2134 const QStringList& emailList, const QStringList& assembledNameList, 2133 const QStringList& emailList, const QStringList& assembledNameList,
2135 const QStringList& uidList) 2134 const QStringList& uidList)
2136{ 2135{
2137 2136
2138 //qDebug("KO::CalendarView::insertBirthdays"); 2137 //qDebug("KO::CalendarView::insertBirthdays");
2139 if (uid == this->name()) 2138 if (uid == this->name())
2140 { 2139 {
2141 int curCal = mCalendar->defaultCalendar(); 2140 int curCal = mCalendar->defaultCalendar();
2142 int bd = mCalEditView->getBirtdayID(); 2141 int bd = mCalEditView->getBirtdayID();
2143 if ( bd == 0 ) 2142 if ( bd == 0 )
2144 return; 2143 return;
2145 mCalendar->setDefaultCalendar( bd ); 2144 mCalendar->setDefaultCalendar( bd );
2146 2145
2147 2146
2148 int count = birthdayList.count(); 2147 int count = birthdayList.count();
2149 int addCount = 0; 2148 int addCount = 0;
2150 KCal::Attendee* a = 0; 2149 KCal::Attendee* a = 0;
2151 2150
2152 //qDebug("CalView 1 %i", count); 2151 //qDebug("CalView 1 %i", count);
2153 2152
2154 QProgressBar bar(count,0 ); 2153 QProgressBar bar(count,0 );
2155 int w = 300; 2154 int w = 300;
2156 if ( QApplication::desktop()->width() < 320 ) 2155 if ( QApplication::desktop()->width() < 320 )
2157 w = 220; 2156 w = 220;
2158 int h = bar.sizeHint().height() ; 2157 int h = bar.sizeHint().height() ;
2159 int dw = QApplication::desktop()->width(); 2158 int dw = QApplication::desktop()->width();
2160 int dh = QApplication::desktop()->height(); 2159 int dh = QApplication::desktop()->height();
2161 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2160 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2162 bar.show(); 2161 bar.show();
2163 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2162 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2164 qApp->processEvents(); 2163 qApp->processEvents();
2165 2164
2166 QDate birthday; 2165 QDate birthday;
2167 QDate anniversary; 2166 QDate anniversary;
2168 QString realName; 2167 QString realName;
2169 QString email; 2168 QString email;
2170 QString assembledName; 2169 QString assembledName;
2171 QString uid; 2170 QString uid;
2172 bool ok = true; 2171 bool ok = true;
2173 for ( int i = 0; i < count; i++) 2172 for ( int i = 0; i < count; i++)
2174 { 2173 {
2175 if ( ! bar.isVisible() ) 2174 if ( ! bar.isVisible() )
2176 return; 2175 return;
2177 bar.setProgress( i ); 2176 bar.setProgress( i );
2178 qApp->processEvents(); 2177 qApp->processEvents();
2179 2178
2180 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2179 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2181 if (!ok) { 2180 if (!ok) {
2182 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2181 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2183 } 2182 }
2184 2183
2185 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2184 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2186 if (!ok) { 2185 if (!ok) {
2187 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2186 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2188 } 2187 }
2189 realName = realNameList[i]; 2188 realName = realNameList[i];
2190 email = emailList[i]; 2189 email = emailList[i];
2191 assembledName = assembledNameList[i]; 2190 assembledName = assembledNameList[i];
2192 uid = uidList[i]; 2191 uid = uidList[i];
2193 //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() ); 2192 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
2194 2193
2195 if ( birthday.isValid() ){ 2194 if ( birthday.isValid() ){
2196 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2195 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2197 KCal::Attendee::ReqParticipant,uid) ; 2196 KCal::Attendee::ReqParticipant,uid) ;
2198 if ( addAnniversary( birthday, assembledName, a, true ) ) 2197 if ( addAnniversary( birthday, assembledName, a, true ) )
2199 ++addCount; 2198 ++addCount;
2200 } 2199 }
2201 2200
2202 if ( anniversary.isValid() ){ 2201 if ( anniversary.isValid() ){
2203 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2202 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2204 KCal::Attendee::ReqParticipant,uid) ; 2203 KCal::Attendee::ReqParticipant,uid) ;
2205 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2204 if ( addAnniversary( anniversary, assembledName, a, false ) )
2206 ++addCount; 2205 ++addCount;
2207 } 2206 }
2208 } 2207 }
2209 2208
2210 mCalendar->setDefaultCalendar( curCal ); 2209 mCalendar->setDefaultCalendar( curCal );
2211 updateView(); 2210 updateView();
2212 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2211 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2213 2212
2214 } 2213 }
2215 2214
2216} 2215}
2217 2216
2218 2217
2219 2218
2220bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2219bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2221{ 2220{
2222 //qDebug("addAnni "); 2221 //qDebug("addAnni ");
2223 Event * ev = new Event(); 2222 Event * ev = new Event();
2224 ev->setOrganizer(KOPrefs::instance()->email()); 2223 ev->setOrganizer(KOPrefs::instance()->email());
2225 if ( a ) { 2224 if ( a ) {
2226 ev->addAttendee( a ); 2225 ev->addAttendee( a );
2227 } 2226 }
2228 QString kind; 2227 QString kind;
2229 if ( birthday ) { 2228 if ( birthday ) {
2230 kind = i18n( "Birthday" ); 2229 kind = i18n( "Birthday" );
2231 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2230 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2232 } 2231 }
2233 else { 2232 else {
2234 kind = i18n( "Anniversary" ); 2233 kind = i18n( "Anniversary" );
2235 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2234 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2236 } 2235 }
2237 ev->setCategories( kind ); 2236 ev->setCategories( kind );
2238 ev->setDtStart( QDateTime(date) ); 2237 ev->setDtStart( QDateTime(date) );
2239 ev->setDtEnd( QDateTime(date) ); 2238 ev->setDtEnd( QDateTime(date) );
2240 ev->setFloats( true ); 2239 ev->setFloats( true );
2241 Recurrence * rec = ev->recurrence(); 2240 Recurrence * rec = ev->recurrence();
2242 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2241 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2243 rec->addYearlyNum( date.month() ); 2242 rec->addYearlyNum( date.month() );
2244 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2243 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2245 delete ev; 2244 delete ev;
2246 return false; 2245 return false;
2247 } 2246 }
2248 return true; 2247 return true;
2249 2248
2250} 2249}
2251bool CalendarView::importQtopia( const QString &categories, 2250bool CalendarView::importQtopia( const QString &categories,
2252 const QString &datebook, 2251 const QString &datebook,
2253 const QString &todolist ) 2252 const QString &todolist )
2254{ 2253{
2255 2254
2256 QtopiaFormat qtopiaFormat; 2255 QtopiaFormat qtopiaFormat;
2257 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2256 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2258 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2257 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2259 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2258 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2260 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2259 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2261 2260
2262 updateView(); 2261 updateView();
2263 return true; 2262 return true;
2264 2263
2265#if 0 2264#if 0
2266 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2265 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2267 mCurrentSyncDevice = "qtopia-XML"; 2266 mCurrentSyncDevice = "qtopia-XML";
2268 if ( mSyncManager->mAskForPreferences ) 2267 if ( mSyncManager->mAskForPreferences )
2269 edit_sync_options(); 2268 edit_sync_options();
2270 qApp->processEvents(); 2269 qApp->processEvents();
2271 CalendarLocal* calendar = new CalendarLocal(); 2270 CalendarLocal* calendar = new CalendarLocal();
2272 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2271 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2273 bool syncOK = false; 2272 bool syncOK = false;
2274 QtopiaFormat qtopiaFormat; 2273 QtopiaFormat qtopiaFormat;
2275 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2274 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2276 bool loadOk = true; 2275 bool loadOk = true;
2277 if ( !categories.isEmpty() ) 2276 if ( !categories.isEmpty() )
2278 loadOk = qtopiaFormat.load( calendar, categories ); 2277 loadOk = qtopiaFormat.load( calendar, categories );
2279 if ( loadOk && !datebook.isEmpty() ) 2278 if ( loadOk && !datebook.isEmpty() )
2280 loadOk = qtopiaFormat.load( calendar, datebook ); 2279 loadOk = qtopiaFormat.load( calendar, datebook );
2281 if ( loadOk && !todolist.isEmpty() ) 2280 if ( loadOk && !todolist.isEmpty() )
2282 loadOk = qtopiaFormat.load( calendar, todolist ); 2281 loadOk = qtopiaFormat.load( calendar, todolist );
2283 2282
2284 if ( loadOk ) { 2283 if ( loadOk ) {
2285 getEventViewerDialog()->setSyncMode( true ); 2284 getEventViewerDialog()->setSyncMode( true );
2286 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2285 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2287 getEventViewerDialog()->setSyncMode( false ); 2286 getEventViewerDialog()->setSyncMode( false );
2288 qApp->processEvents(); 2287 qApp->processEvents();
2289 if ( syncOK ) { 2288 if ( syncOK ) {
2290 if ( mSyncManager->mWriteBackFile ) 2289 if ( mSyncManager->mWriteBackFile )
2291 { 2290 {
2292 // write back XML file 2291 // write back XML file
2293 2292
2294 } 2293 }
2295 setModified( true ); 2294 setModified( true );
2296 } 2295 }
2297 } else { 2296 } else {
2298 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2297 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2299 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2298 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2300 question, i18n("Ok")) ; 2299 question, i18n("Ok")) ;
2301 } 2300 }
2302 delete calendar; 2301 delete calendar;
2303 updateView(); 2302 updateView();
2304 return syncOK; 2303 return syncOK;
2305 2304
2306 2305
2307#endif 2306#endif
2308 2307
2309} 2308}
2310 2309
2311void CalendarView::setSyncEventsReadOnly() 2310void CalendarView::setSyncEventsReadOnly()
2312{ 2311{
2313 mCalendar->setSyncEventsReadOnly(); 2312 mCalendar->setSyncEventsReadOnly();
2314} 2313}
2315 2314
2316bool CalendarView::loadCalendars() 2315bool CalendarView::loadCalendars()
2317{ 2316{
2318 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2317 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2319 KopiCalendarFile * cal = calendars.first(); 2318 KopiCalendarFile * cal = calendars.first();
2320 mCalendar->setDefaultCalendar( 1 ); 2319 mCalendar->setDefaultCalendar( 1 );
2321 openCalendar( MainWindow::defaultFileName(), false ); 2320 openCalendar( MainWindow::defaultFileName(), false );
2322 cal = calendars.next(); 2321 cal = calendars.next();
2323 while ( cal ) { 2322 while ( cal ) {
2324 addCalendar( cal ); 2323 addCalendar( cal );
2325 cal = calendars.next(); 2324 cal = calendars.next();
2326 } 2325 }
2327 restoreCalendarSettings(); 2326 restoreCalendarSettings();
2328 return true; 2327 return true;
2329} 2328}
2330bool CalendarView::restoreCalendarSettings() 2329bool CalendarView::restoreCalendarSettings()
2331{ 2330{
2332 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2331 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2333 KopiCalendarFile * cal = calendars.first(); 2332 KopiCalendarFile * cal = calendars.first();
2334 while ( cal ) { 2333 while ( cal ) {
2335 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2334 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2336 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2335 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2337 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2336 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2338 if ( cal->isStandard ) 2337 if ( cal->isStandard )
2339 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2338 mCalendar->setDefaultCalendar( cal->mCalNumber );
2340 cal = calendars.next(); 2339 cal = calendars.next();
2341 } 2340 }
2342 setSyncEventsReadOnly(); 2341 setSyncEventsReadOnly();
2343 mCalendar->reInitAlarmSettings(); 2342 mCalendar->reInitAlarmSettings();
2344 updateUnmanagedViews(); 2343 updateUnmanagedViews();
2345 updateView(); 2344 updateView();
2346 return true; 2345 return true;
2347} 2346}
2348void CalendarView::addCalendarId( int id ) 2347void CalendarView::addCalendarId( int id )
2349{ 2348{
2350 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2349 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2351 if ( cal ) 2350 if ( cal )
2352 addCalendar( cal ); 2351 addCalendar( cal );
2353} 2352}
2354bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2353bool CalendarView::addCalendar( KopiCalendarFile * cal )
2355{ 2354{
2356 cal->mErrorOnLoad = false; 2355 cal->mErrorOnLoad = false;
2357 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2356 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2358 cal->mLoadDt = QDateTime::currentDateTime(); 2357 cal->mLoadDt = QDateTime::currentDateTime();
2359 return true; 2358 return true;
2360 } 2359 }
2361 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2360 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2362 cal->mErrorOnLoad = true; 2361 cal->mErrorOnLoad = true;
2363 return false; 2362 return false;
2364} 2363}
2365bool CalendarView::openCalendar(QString filename, bool merge) 2364bool CalendarView::openCalendar(QString filename, bool merge)
2366{ 2365{
2367 2366
2368 if (filename.isEmpty()) { 2367 if (filename.isEmpty()) {
2369 return false; 2368 return false;
2370 } 2369 }
2371 2370
2372 if (!QFile::exists(filename)) { 2371 if (!QFile::exists(filename)) {
2373 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2372 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2374 return false; 2373 return false;
2375 } 2374 }
2376 2375
2377 globalFlagBlockAgenda = 1; 2376 globalFlagBlockAgenda = 1;
2378 clearAllViews(); 2377 clearAllViews();
2379 if (!merge) { 2378 if (!merge) {
2380 mViewManager->setDocumentId( filename ); 2379 mViewManager->setDocumentId( filename );
2381 mCalendar->close(); 2380 mCalendar->close();
2382 } 2381 }
2383 mStorage->setFileName( filename ); 2382 mStorage->setFileName( filename );
2384 2383
2385 if ( mStorage->load() ) { 2384 if ( mStorage->load() ) {
2386 if ( merge ) ;//setModified( true ); 2385 if ( merge ) ;//setModified( true );
2387 else { 2386 else {
2388 //setModified( true ); 2387 //setModified( true );
2389 mViewManager->setDocumentId( filename ); 2388 mViewManager->setDocumentId( filename );
2390 mDialogManager->setDocumentId( filename ); 2389 mDialogManager->setDocumentId( filename );
2391 mTodoList->setDocumentId( filename ); 2390 mTodoList->setDocumentId( filename );
2392 } 2391 }
2393 globalFlagBlockAgenda = 2; 2392 globalFlagBlockAgenda = 2;
2394 // if ( getLastSyncEvent() ) 2393 // if ( getLastSyncEvent() )
2395 // getLastSyncEvent()->setReadOnly( true ); 2394 // getLastSyncEvent()->setReadOnly( true );
2396 mCalendar->reInitAlarmSettings(); 2395 mCalendar->reInitAlarmSettings();
2397 setSyncEventsReadOnly(); 2396 setSyncEventsReadOnly();
2398 //updateUnmanagedViews(); 2397 //updateUnmanagedViews();
2399 //updateView(); 2398 //updateView();
2400 if ( filename != MainWindow::defaultFileName() ) { 2399 if ( filename != MainWindow::defaultFileName() ) {
2401 saveCalendar( MainWindow::defaultFileName() ); 2400 saveCalendar( MainWindow::defaultFileName() );
2402 } else { 2401 } else {
2403 QFileInfo finf ( MainWindow::defaultFileName()); 2402 QFileInfo finf ( MainWindow::defaultFileName());
2404 if ( finf.exists() ) { 2403 if ( finf.exists() ) {
2405 setLoadedFileVersion( finf.lastModified () ); 2404 setLoadedFileVersion( finf.lastModified () );
2406 } 2405 }
2407 } 2406 }
2408 return true; 2407 return true;
2409 } else { 2408 } else {
2410 // while failing to load, the calendar object could 2409 // while failing to load, the calendar object could
2411 // have become partially populated. Clear it out. 2410 // have become partially populated. Clear it out.
2412 if ( !merge ) { 2411 if ( !merge ) {
2413 mCalendar->close(); 2412 mCalendar->close();
2414 mViewManager->setDocumentId( filename ); 2413 mViewManager->setDocumentId( filename );
2415 mDialogManager->setDocumentId( filename ); 2414 mDialogManager->setDocumentId( filename );
2416 mTodoList->setDocumentId( filename ); 2415 mTodoList->setDocumentId( filename );
2417 } 2416 }
2418 2417
2419 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2418 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2420 2419
2421 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2420 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2422 globalFlagBlockAgenda = 2; 2421 globalFlagBlockAgenda = 2;
2423 mCalendar->reInitAlarmSettings(); 2422 mCalendar->reInitAlarmSettings();
2424 setSyncEventsReadOnly(); 2423 setSyncEventsReadOnly();
2425 updateUnmanagedViews(); 2424 updateUnmanagedViews();
2426 updateView(); 2425 updateView();
2427 } 2426 }
2428 return false; 2427 return false;
2429} 2428}
2430void CalendarView::mergeFile( QString fn ) 2429void CalendarView::mergeFile( QString fn )
2431{ 2430{
2432 clearAllViews(); 2431 clearAllViews();
2433 mCalendar->mergeCalendarFile( fn ); 2432 mCalendar->mergeCalendarFile( fn );
2434 mCalendar->reInitAlarmSettings(); 2433 mCalendar->reInitAlarmSettings();
2435 setSyncEventsReadOnly(); 2434 setSyncEventsReadOnly();
2436 updateUnmanagedViews(); 2435 updateUnmanagedViews();
2437 updateView(); 2436 updateView();
2438} 2437}
2439void CalendarView::showOpenError() 2438void CalendarView::showOpenError()
2440{ 2439{
2441 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2440 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2442} 2441}
2443void CalendarView::setLoadedFileVersion(QDateTime dt) 2442void CalendarView::setLoadedFileVersion(QDateTime dt)
2444{ 2443{
2445 loadedFileVersion = dt; 2444 loadedFileVersion = dt;
2446} 2445}
2447bool CalendarView::checkFileChanged(QString fn) 2446bool CalendarView::checkFileChanged(QString fn)
2448{ 2447{
2449 QFileInfo finf ( fn ); 2448 QFileInfo finf ( fn );
2450 if ( !finf.exists() ) 2449 if ( !finf.exists() )
2451 return true; 2450 return true;
2452 QDateTime dt = finf.lastModified (); 2451 QDateTime dt = finf.lastModified ();
2453 if ( dt <= loadedFileVersion ) 2452 if ( dt <= loadedFileVersion )
2454 return false; 2453 return false;
2455 return true; 2454 return true;
2456 2455
2457} 2456}
2458void CalendarView::watchSavedFile() 2457void CalendarView::watchSavedFile()
2459{ 2458{
2460 QFileInfo finf ( MainWindow::defaultFileName()); 2459 QFileInfo finf ( MainWindow::defaultFileName());
2461 if ( !finf.exists() ) 2460 if ( !finf.exists() )
2462 return; 2461 return;
2463 QDateTime dt = finf.lastModified (); 2462 QDateTime dt = finf.lastModified ();
2464 if ( dt < loadedFileVersion ) { 2463 if ( dt < loadedFileVersion ) {
2465 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2464 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2466 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2465 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2467 return; 2466 return;
2468 } 2467 }
2469 loadedFileVersion = dt; 2468 loadedFileVersion = dt;
2470} 2469}
2471bool CalendarView::checkAllFileVersions() 2470bool CalendarView::checkAllFileVersions()
2472{ 2471{
2473 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2472 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2474 KopiCalendarFile * cal = calendars.first(); 2473 KopiCalendarFile * cal = calendars.first();
2475 mCalendar->setDefaultCalendar( 1 ); 2474 mCalendar->setDefaultCalendar( 1 );
2476 mCalendar->setDefaultCalendarEnabledOnly(); 2475 mCalendar->setDefaultCalendarEnabledOnly();
2477 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2476 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2478 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2477 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2479 restoreCalendarSettings(); 2478 restoreCalendarSettings();
2480 return false; 2479 return false;
2481 } 2480 }
2482 } 2481 }
2483 cal = calendars.next(); 2482 cal = calendars.next();
2484 QDateTime storeTemp = loadedFileVersion; 2483 QDateTime storeTemp = loadedFileVersion;
2485 while ( cal ) { 2484 while ( cal ) {
2486 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2485 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2487 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2486 mCalendar->setDefaultCalendar( cal->mCalNumber );
2488 mCalendar->setDefaultCalendarEnabledOnly(); 2487 mCalendar->setDefaultCalendarEnabledOnly();
2489 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2488 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2490 if ( !checkFileVersion(cal->mFileName )) { 2489 if ( !checkFileVersion(cal->mFileName )) {
2491 loadedFileVersion = storeTemp; 2490 loadedFileVersion = storeTemp;
2492 restoreCalendarSettings(); 2491 restoreCalendarSettings();
2493 return false; 2492 return false;
2494 } 2493 }
2495 } 2494 }
2496 cal = calendars.next(); 2495 cal = calendars.next();
2497 } 2496 }
2498 loadedFileVersion = storeTemp; 2497 loadedFileVersion = storeTemp;
2499 return true; 2498 return true;
2500} 2499}
2501bool CalendarView::checkFileVersion(QString fn) 2500bool CalendarView::checkFileVersion(QString fn)
2502{ 2501{
2503 QFileInfo finf ( fn ); 2502 QFileInfo finf ( fn );
2504 if ( !finf.exists() ) 2503 if ( !finf.exists() )
2505 return true; 2504 return true;
2506 QDateTime dt = finf.lastModified (); 2505 QDateTime dt = finf.lastModified ();
2507 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2506 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2508 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2507 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2509 if ( dt <= loadedFileVersion ) 2508 if ( dt <= loadedFileVersion )
2510 return true; 2509 return true;
2511 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2510 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2512 i18n("KO/Pi Warning"),i18n("Overwrite"), 2511 i18n("KO/Pi Warning"),i18n("Overwrite"),
2513 i18n("Sync+save")); 2512 i18n("Sync+save"));
2514 2513
2515 if ( km == KMessageBox::Cancel ) 2514 if ( km == KMessageBox::Cancel )
2516 return false; 2515 return false;
2517 if ( km == KMessageBox::Yes ) 2516 if ( km == KMessageBox::Yes )
2518 return true; 2517 return true;
2519 2518
2520 setSyncDevice("deleteaftersync" ); 2519 setSyncDevice("deleteaftersync" );
2521 mSyncManager->mAskForPreferences = true; 2520 mSyncManager->mAskForPreferences = true;
2522 mSyncManager->mSyncAlgoPrefs = 3; 2521 mSyncManager->mSyncAlgoPrefs = 3;
2523 mSyncManager->mWriteBackFile = false; 2522 mSyncManager->mWriteBackFile = false;
2524 mSyncManager->mWriteBackExistingOnly = false; 2523 mSyncManager->mWriteBackExistingOnly = false;
2525 mSyncManager->mShowSyncSummary = false; 2524 mSyncManager->mShowSyncSummary = false;
2526 syncCalendar( fn, 3 ); 2525 syncCalendar( fn, 3 );
2527 Event * e = getLastSyncEvent(); 2526 Event * e = getLastSyncEvent();
2528 if ( e ) 2527 if ( e )
2529 mCalendar->deleteEvent( e ); 2528 mCalendar->deleteEvent( e );
2530 return true; 2529 return true;
2531} 2530}
2532bool CalendarView::saveCalendars() 2531bool CalendarView::saveCalendars()
2533{ 2532{
2534 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2533 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2535 KopiCalendarFile * cal = calendars.first(); 2534 KopiCalendarFile * cal = calendars.first();
2536 mCalendar->setDefaultCalendar( 1 ); 2535 mCalendar->setDefaultCalendar( 1 );
2537 mCalendar->setDefaultCalendarEnabledOnly(); 2536 mCalendar->setDefaultCalendarEnabledOnly();
2538 QString saveError; 2537 QString saveError;
2539 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2538 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2540 saveError = cal->mName +"\n"; 2539 saveError = cal->mName +"\n";
2541 cal = calendars.next(); 2540 cal = calendars.next();
2542 while ( cal ) { 2541 while ( cal ) {
2543 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2542 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2544 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2543 mCalendar->setDefaultCalendar( cal->mCalNumber );
2545 mCalendar->setDefaultCalendarEnabledOnly(); 2544 mCalendar->setDefaultCalendarEnabledOnly();
2546 if ( saveCalendar( cal->mFileName ) ) 2545 if ( saveCalendar( cal->mFileName ) )
2547 cal->mLoadDt = QDateTime::currentDateTime(); 2546 cal->mLoadDt = QDateTime::currentDateTime();
2548 else 2547 else
2549 saveError += cal->mName + "\n"; 2548 saveError += cal->mName + "\n";
2550 } 2549 }
2551 cal = calendars.next(); 2550 cal = calendars.next();
2552 } 2551 }
2553 restoreCalendarSettings(); 2552 restoreCalendarSettings();
2554 //saveError = "test error"; 2553 //saveError = "test error";
2555 if ( !saveError.isEmpty() ) { 2554 if ( !saveError.isEmpty() ) {
2556 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2555 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2557 KMessageBox::error(this, saveError, i18n("Error saving data")); 2556 KMessageBox::error(this, saveError, i18n("Error saving data"));
2558 return false; 2557 return false;
2559 } 2558 }
2560 return true; 2559 return true;
2561} 2560}
2562bool CalendarView::saveCalendar( QString filename ) 2561bool CalendarView::saveCalendar( QString filename )
2563{ 2562{
2564 2563
2565 // Store back all unsaved data into calendar object 2564 // Store back all unsaved data into calendar object
2566 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2565 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2567 if ( mViewManager->currentView() ) 2566 if ( mViewManager->currentView() )
2568 mViewManager->currentView()->flushView(); 2567 mViewManager->currentView()->flushView();
2569 2568
2570 2569
2571 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2570 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2572 mStorage->setSaveFormat( new ICalFormat() ); 2571 mStorage->setSaveFormat( new ICalFormat() );
2573 mStorage->setFileName( filename ); 2572 mStorage->setFileName( filename );
2574 bool success; 2573 bool success;
2575 success = mStorage->save(); 2574 success = mStorage->save();
2576 if ( !success ) { 2575 if ( !success ) {
2577 return false; 2576 return false;
2578 } 2577 }
2579 if ( filename == MainWindow::defaultFileName() ) { 2578 if ( filename == MainWindow::defaultFileName() ) {
2580 setLoadedFileVersion( lfv ); 2579 setLoadedFileVersion( lfv );
2581 watchSavedFile(); 2580 watchSavedFile();
2582 } 2581 }
2583 return true; 2582 return true;
2584} 2583}
2585 2584
2586void CalendarView::closeCalendar() 2585void CalendarView::closeCalendar()
2587{ 2586{
2588 2587
2589 // child windows no longer valid 2588 // child windows no longer valid
2590 clearAllViews(); 2589 clearAllViews();
2591 emit closingDown(); 2590 emit closingDown();
2592 2591
2593 mCalendar->close(); 2592 mCalendar->close();
2594 setModified(false); 2593 setModified(false);
2595 updateView(); 2594 updateView();
2596} 2595}
2597 2596
2598void CalendarView::archiveCalendar() 2597void CalendarView::archiveCalendar()
2599{ 2598{
2600 mDialogManager->showArchiveDialog(); 2599 mDialogManager->showArchiveDialog();
2601} 2600}
2602 2601
2603 2602
2604void CalendarView::readSettings() 2603void CalendarView::readSettings()
2605{ 2604{
2606 2605
2607 2606
2608 // mViewManager->showAgendaView(); 2607 // mViewManager->showAgendaView();
2609 QString str; 2608 QString str;
2610 //qDebug("CalendarView::readSettings() "); 2609 //qDebug("CalendarView::readSettings() ");
2611 // read settings from the KConfig, supplying reasonable 2610 // read settings from the KConfig, supplying reasonable
2612 // defaults where none are to be found 2611 // defaults where none are to be found
2613 KConfig *config = KOGlobals::config(); 2612 KConfig *config = KOGlobals::config();
2614#ifndef KORG_NOSPLITTER 2613#ifndef KORG_NOSPLITTER
2615 config->setGroup("KOrganizer Geometry"); 2614 config->setGroup("KOrganizer Geometry");
2616 2615
2617 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2616 QValueList<int> sizes = config->readIntListEntry("Separator1");
2618 if (sizes.count() != 2) { 2617 if (sizes.count() != 2) {
2619 sizes << mDateNavigator->minimumSizeHint().width(); 2618 sizes << mDateNavigator->minimumSizeHint().width();
2620 sizes << 300; 2619 sizes << 300;
2621 } 2620 }
2622 mPanner->setSizes(sizes); 2621 mPanner->setSizes(sizes);
2623 2622
2624 sizes = config->readIntListEntry("Separator2"); 2623 sizes = config->readIntListEntry("Separator2");
2625 if ( ( mResourceView && sizes.count() == 4 ) || 2624 if ( ( mResourceView && sizes.count() == 4 ) ||
2626 ( !mResourceView && sizes.count() == 3 ) ) { 2625 ( !mResourceView && sizes.count() == 3 ) ) {
2627 mLeftSplitter->setSizes(sizes); 2626 mLeftSplitter->setSizes(sizes);
2628 } 2627 }
2629#endif 2628#endif
2630 globalFlagBlockAgenda = 1; 2629 globalFlagBlockAgenda = 1;
2631 mViewManager->showAgendaView(); 2630 mViewManager->showAgendaView();
2632 //mViewManager->readSettings( config ); 2631 //mViewManager->readSettings( config );
2633 mTodoList->restoreLayout(config,QString("Todo Layout")); 2632 mTodoList->restoreLayout(config,QString("Todo Layout"));
2634 readFilterSettings(config); 2633 readFilterSettings(config);
2635 2634
2636#ifdef DESKTOP_VERSION 2635#ifdef DESKTOP_VERSION
2637 config->setGroup("WidgetLayout"); 2636 config->setGroup("WidgetLayout");
2638 QStringList list; 2637 QStringList list;
2639 list = config->readListEntry("MainLayout"); 2638 list = config->readListEntry("MainLayout");
2640 int x,y,w,h; 2639 int x,y,w,h;
2641 if ( ! list.isEmpty() ) { 2640 if ( ! list.isEmpty() ) {
2642 x = list[0].toInt(); 2641 x = list[0].toInt();
2643 y = list[1].toInt(); 2642 y = list[1].toInt();
2644 w = list[2].toInt(); 2643 w = list[2].toInt();
2645 h = list[3].toInt(); 2644 h = list[3].toInt();
2646 KApplication::testCoords( &x,&y,&w,&h ); 2645 KApplication::testCoords( &x,&y,&w,&h );
2647 topLevelWidget()->setGeometry(x,y,w,h); 2646 topLevelWidget()->setGeometry(x,y,w,h);
2648 2647
2649 } else { 2648 } else {
2650 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2649 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2651 } 2650 }
2652 list = config->readListEntry("EditEventLayout"); 2651 list = config->readListEntry("EditEventLayout");
2653 if ( ! list.isEmpty() ) { 2652 if ( ! list.isEmpty() ) {
2654 x = list[0].toInt(); 2653 x = list[0].toInt();
2655 y = list[1].toInt(); 2654 y = list[1].toInt();
2656 w = list[2].toInt(); 2655 w = list[2].toInt();
2657 h = list[3].toInt(); 2656 h = list[3].toInt();
2658 KApplication::testCoords( &x,&y,&w,&h ); 2657 KApplication::testCoords( &x,&y,&w,&h );
2659 mEventEditor->setGeometry(x,y,w,h); 2658 mEventEditor->setGeometry(x,y,w,h);
2660 2659
2661 } 2660 }
2662 list = config->readListEntry("EditTodoLayout"); 2661 list = config->readListEntry("EditTodoLayout");
2663 if ( ! list.isEmpty() ) { 2662 if ( ! list.isEmpty() ) {
2664 x = list[0].toInt(); 2663 x = list[0].toInt();
2665 y = list[1].toInt(); 2664 y = list[1].toInt();
2666 w = list[2].toInt(); 2665 w = list[2].toInt();
2667 h = list[3].toInt(); 2666 h = list[3].toInt();
2668 KApplication::testCoords( &x,&y,&w,&h ); 2667 KApplication::testCoords( &x,&y,&w,&h );
2669 mTodoEditor->setGeometry(x,y,w,h); 2668 mTodoEditor->setGeometry(x,y,w,h);
2670 2669
2671 } 2670 }
2672 list = config->readListEntry("ViewerLayout"); 2671 list = config->readListEntry("ViewerLayout");
2673 if ( ! list.isEmpty() ) { 2672 if ( ! list.isEmpty() ) {
2674 x = list[0].toInt(); 2673 x = list[0].toInt();
2675 y = list[1].toInt(); 2674 y = list[1].toInt();
2676 w = list[2].toInt(); 2675 w = list[2].toInt();
2677 h = list[3].toInt(); 2676 h = list[3].toInt();
2678 KApplication::testCoords( &x,&y,&w,&h ); 2677 KApplication::testCoords( &x,&y,&w,&h );
2679 getEventViewerDialog()->setGeometry(x,y,w,h); 2678 getEventViewerDialog()->setGeometry(x,y,w,h);
2680 } 2679 }
2681#endif 2680#endif
2682 config->setGroup( "Views" ); 2681 config->setGroup( "Views" );
2683 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2682 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2684 2683
2685 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2684 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2686 2685
2687 int resetval = 0; 2686 int resetval = 0;
2688 int maxVal = 0; 2687 int maxVal = 0;
2689 if (sizes.count() != 3) { 2688 if (sizes.count() != 3) {
2690 if ( KOPrefs::instance()->mVerticalScreen ) { 2689 if ( KOPrefs::instance()->mVerticalScreen ) {
2691 resetval = mDateNavigator->sizeHint().width()+2; 2690 resetval = mDateNavigator->sizeHint().width()+2;
2692 } else { 2691 } else {
2693 resetval = mDateNavigator->sizeHint().height()+2; 2692 resetval = mDateNavigator->sizeHint().height()+2;
2694 } 2693 }
2695 } 2694 }
2696 if ( resetval ) { 2695 if ( resetval ) {
2697 sizes.clear(); 2696 sizes.clear();
2698 if ( KOPrefs::instance()->mVerticalScreen ) { 2697 if ( KOPrefs::instance()->mVerticalScreen ) {
2699 maxVal = QApplication::desktop()->width() -10; 2698 maxVal = QApplication::desktop()->width() -10;
2700 } else { 2699 } else {
2701 maxVal = QApplication::desktop()->height()-10; 2700 maxVal = QApplication::desktop()->height()-10;
2702 } 2701 }
2703 sizes << resetval; 2702 sizes << resetval;
2704 if ( maxVal < resetval + resetval) 2703 if ( maxVal < resetval + resetval)
2705 resetval = maxVal - resetval; 2704 resetval = maxVal - resetval;
2706 sizes << resetval; 2705 sizes << resetval;
2707 sizes << 100; 2706 sizes << 100;
2708 } 2707 }
2709 mLeftFrame->setSizes(sizes); 2708 mLeftFrame->setSizes(sizes);
2710 sizes = config->readIntListEntry("Main Splitter Frame"); 2709 sizes = config->readIntListEntry("Main Splitter Frame");
2711 resetval = 0; 2710 resetval = 0;
2712 maxVal = 0; 2711 maxVal = 0;
2713 if (sizes.count() != 2) { 2712 if (sizes.count() != 2) {
2714 if ( !KOPrefs::instance()->mVerticalScreen ) { 2713 if ( !KOPrefs::instance()->mVerticalScreen ) {
2715 resetval = mDateNavigator->sizeHint().width()+2; 2714 resetval = mDateNavigator->sizeHint().width()+2;
2716 } else { 2715 } else {
2717 resetval = mDateNavigator->sizeHint().height()+2; 2716 resetval = mDateNavigator->sizeHint().height()+2;
2718 } 2717 }
2719 } 2718 }
2720 if ( resetval ) { 2719 if ( resetval ) {
2721 sizes.clear(); 2720 sizes.clear();
2722 if ( !KOPrefs::instance()->mVerticalScreen ) { 2721 if ( !KOPrefs::instance()->mVerticalScreen ) {
2723 maxVal = QApplication::desktop()->width() -10; 2722 maxVal = QApplication::desktop()->width() -10;
2724 } else { 2723 } else {
2725 maxVal = QApplication::desktop()->height()-10; 2724 maxVal = QApplication::desktop()->height()-10;
2726 } 2725 }
2727 sizes << resetval; 2726 sizes << resetval;
2728 if ( maxVal < resetval + resetval) 2727 if ( maxVal < resetval + resetval)
2729 resetval = maxVal - resetval; 2728 resetval = maxVal - resetval;
2730 sizes << resetval; 2729 sizes << resetval;
2731 } 2730 }
2732 mMainFrame->setSizes(sizes); 2731 mMainFrame->setSizes(sizes);
2733 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2732 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2734 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2733 else if ( dateCount == 7 ) mNavigator->selectWeek();
2735 else mNavigator->selectDates( dateCount ); 2734 else mNavigator->selectDates( dateCount );
2736 // mViewManager->readSettings( config ); 2735 // mViewManager->readSettings( config );
2737 updateConfig(); 2736 updateConfig();
2738 globalFlagBlockAgenda = 2; 2737 globalFlagBlockAgenda = 2;
2739 mViewManager->readSettings( config ); 2738 mViewManager->readSettings( config );
2740 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2739 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2741} 2740}
2742 2741
2743void CalendarView::checkSuspendAlarm() 2742void CalendarView::checkSuspendAlarm()
2744{ 2743{
2745 if ( mSuspendTimer->isActive() ) { 2744 if ( mSuspendTimer->isActive() ) {
2746 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2745 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2747 } 2746 }
2748} 2747}
2749void CalendarView::writeSettings() 2748void CalendarView::writeSettings()
2750{ 2749{
2751 // kdDebug() << "CalendarView::writeSettings" << endl; 2750 // kdDebug() << "CalendarView::writeSettings" << endl;
2752 2751
2753 KConfig *config = KOGlobals::config(); 2752 KConfig *config = KOGlobals::config();
2754 2753
2755 mViewManager->writeSettings( config ); 2754 mViewManager->writeSettings( config );
2756 mTodoList->saveLayout(config,QString("Todo Layout")); 2755 mTodoList->saveLayout(config,QString("Todo Layout"));
2757 mDialogManager->writeSettings( config ); 2756 mDialogManager->writeSettings( config );
2758 //KOPrefs::instance()->usrWriteConfig(); 2757 //KOPrefs::instance()->usrWriteConfig();
2759 KOPrefs::instance()->writeConfig(); 2758 KOPrefs::instance()->writeConfig();
2760 2759
2761 writeFilterSettings(config); 2760 writeFilterSettings(config);
2762 config->setGroup( "AppRun" ); 2761 config->setGroup( "AppRun" );
2763 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2762 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2764 int days = dt.daysTo( QDate::currentDate() ); 2763 int days = dt.daysTo( QDate::currentDate() );
2765 dt = dt.addDays( days ); 2764 dt = dt.addDays( days );
2766 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2765 int secs = dt.secsTo( QDateTime::currentDateTime() );
2767 config->writeEntry( "LatestProgramStopDays", days ); 2766 config->writeEntry( "LatestProgramStopDays", days );
2768 config->writeEntry( "LatestProgramStopSecs", secs ); 2767 config->writeEntry( "LatestProgramStopSecs", secs );
2769 //qDebug("KO: Writing stop time: %d ", secs); 2768 //qDebug("KO: Writing stop time: %d ", secs);
2770 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2769 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2771 //QDateTime latest = dt.addSecs ( secs ); 2770 //QDateTime latest = dt.addSecs ( secs );
2772 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2771 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2773 config->setGroup( "Views" ); 2772 config->setGroup( "Views" );
2774 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2773 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2775 2774
2776#if 0 2775#if 0
2777 qDebug("********************* "); 2776 qDebug("********************* ");
2778 qDebug("Testcode secsto "); 2777 qDebug("Testcode secsto ");
2779 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2778 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2780 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2779 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2781 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2780 int secsto = dt_nodaylight.secsTo( dt_daylight );
2782 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2781 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2783 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2782 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2784 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2783 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2785 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2784 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2786 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2785 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2787 qDebug("********************* testcode end"); 2786 qDebug("********************* testcode end");
2788 2787
2789#endif 2788#endif
2790 2789
2791 QValueList<int> listINT = mLeftFrame->sizes(); 2790 QValueList<int> listINT = mLeftFrame->sizes();
2792 config->writeEntry("Left Splitter Frame",listINT); 2791 config->writeEntry("Left Splitter Frame",listINT);
2793 QValueList<int> listINT2 = mMainFrame->sizes(); 2792 QValueList<int> listINT2 = mMainFrame->sizes();
2794 config->writeEntry("Main Splitter Frame",listINT2); 2793 config->writeEntry("Main Splitter Frame",listINT2);
2795#ifdef DESKTOP_VERSION 2794#ifdef DESKTOP_VERSION
2796 config->setGroup("WidgetLayout"); 2795 config->setGroup("WidgetLayout");
2797 QStringList list ;//= config->readListEntry("MainLayout"); 2796 QStringList list ;//= config->readListEntry("MainLayout");
2798 int x,y,w,h; 2797 int x,y,w,h;
2799 QWidget* wid; 2798 QWidget* wid;
2800 wid = topLevelWidget(); 2799 wid = topLevelWidget();
2801 x = wid->geometry().x(); 2800 x = wid->geometry().x();
2802 y = wid->geometry().y(); 2801 y = wid->geometry().y();
2803 w = wid->width(); 2802 w = wid->width();
2804 h = wid->height(); 2803 h = wid->height();
2805 list.clear(); 2804 list.clear();
2806 list << QString::number( x ); 2805 list << QString::number( x );
2807 list << QString::number( y ); 2806 list << QString::number( y );
2808 list << QString::number( w ); 2807 list << QString::number( w );
2809 list << QString::number( h ); 2808 list << QString::number( h );
2810 config->writeEntry("MainLayout",list ); 2809 config->writeEntry("MainLayout",list );
2811 2810
2812 wid = mEventEditor; 2811 wid = mEventEditor;
2813 x = wid->geometry().x(); 2812 x = wid->geometry().x();
2814 y = wid->geometry().y(); 2813 y = wid->geometry().y();
2815 w = wid->width(); 2814 w = wid->width();
2816 h = wid->height(); 2815 h = wid->height();
2817 list.clear(); 2816 list.clear();
2818 list << QString::number( x ); 2817 list << QString::number( x );
2819 list << QString::number( y ); 2818 list << QString::number( y );
2820 list << QString::number( w ); 2819 list << QString::number( w );
2821 list << QString::number( h ); 2820 list << QString::number( h );
2822 config->writeEntry("EditEventLayout",list ); 2821 config->writeEntry("EditEventLayout",list );
2823 2822
2824 wid = mTodoEditor; 2823 wid = mTodoEditor;
2825 x = wid->geometry().x(); 2824 x = wid->geometry().x();
2826 y = wid->geometry().y(); 2825 y = wid->geometry().y();
2827 w = wid->width(); 2826 w = wid->width();
2828 h = wid->height(); 2827 h = wid->height();
2829 list.clear(); 2828 list.clear();
2830 list << QString::number( x ); 2829 list << QString::number( x );
2831 list << QString::number( y ); 2830 list << QString::number( y );
2832 list << QString::number( w ); 2831 list << QString::number( w );
2833 list << QString::number( h ); 2832 list << QString::number( h );
2834 config->writeEntry("EditTodoLayout",list ); 2833 config->writeEntry("EditTodoLayout",list );
2835 wid = getEventViewerDialog(); 2834 wid = getEventViewerDialog();
2836 x = wid->geometry().x(); 2835 x = wid->geometry().x();
2837 y = wid->geometry().y(); 2836 y = wid->geometry().y();
2838 w = wid->width(); 2837 w = wid->width();
2839 h = wid->height(); 2838 h = wid->height();
2840 list.clear(); 2839 list.clear();
2841 list << QString::number( x ); 2840 list << QString::number( x );
2842 list << QString::number( y ); 2841 list << QString::number( y );
2843 list << QString::number( w ); 2842 list << QString::number( w );
2844 list << QString::number( h ); 2843 list << QString::number( h );
2845 config->writeEntry("ViewerLayout",list ); 2844 config->writeEntry("ViewerLayout",list );
2846 wid = mDialogManager->getSearchDialog(); 2845 wid = mDialogManager->getSearchDialog();
2847 if ( wid ) { 2846 if ( wid ) {
2848 x = wid->geometry().x(); 2847 x = wid->geometry().x();
2849 y = wid->geometry().y(); 2848 y = wid->geometry().y();
2850 w = wid->width(); 2849 w = wid->width();
2851 h = wid->height(); 2850 h = wid->height();
2852 list.clear(); 2851 list.clear();
2853 list << QString::number( x ); 2852 list << QString::number( x );
2854 list << QString::number( y ); 2853 list << QString::number( y );
2855 list << QString::number( w ); 2854 list << QString::number( w );
2856 list << QString::number( h ); 2855 list << QString::number( h );
2857 config->writeEntry("SearchLayout",list ); 2856 config->writeEntry("SearchLayout",list );
2858 } 2857 }
2859#endif 2858#endif
2860 2859
2861 2860
2862 config->sync(); 2861 config->sync();
2863} 2862}
2864 2863
2865void CalendarView::readFilterSettings(KConfig *config) 2864void CalendarView::readFilterSettings(KConfig *config)
2866{ 2865{
2867 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2866 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2868 2867
2869 mFilters.clear(); 2868 mFilters.clear();
2870 2869
2871 config->setGroup("General"); 2870 config->setGroup("General");
2872 QStringList filterList = config->readListEntry("CalendarFilters"); 2871 QStringList filterList = config->readListEntry("CalendarFilters");
2873 2872
2874 QStringList::ConstIterator it = filterList.begin(); 2873 QStringList::ConstIterator it = filterList.begin();
2875 QStringList::ConstIterator end = filterList.end(); 2874 QStringList::ConstIterator end = filterList.end();
2876 while(it != end) { 2875 while(it != end) {
2877 // kdDebug() << " filter: " << (*it) << endl; 2876 // kdDebug() << " filter: " << (*it) << endl;
2878 2877
2879 CalFilter *filter; 2878 CalFilter *filter;
2880 filter = new CalFilter(*it); 2879 filter = new CalFilter(*it);
2881 config->setGroup("Filter_" + (*it).utf8()); 2880 config->setGroup("Filter_" + (*it).utf8());
2882 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2881 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2883 filter->setCriteria(config->readNumEntry("Criteria",0)); 2882 filter->setCriteria(config->readNumEntry("Criteria",0));
2884 filter->setCategoryList(config->readListEntry("CategoryList")); 2883 filter->setCategoryList(config->readListEntry("CategoryList"));
2885 mFilters.append(filter); 2884 mFilters.append(filter);
2886 2885
2887 ++it; 2886 ++it;
2888 } 2887 }
2889 2888
2890 if (mFilters.count() == 0) { 2889 if (mFilters.count() == 0) {
2891 CalFilter *filter = new CalFilter(i18n("Default")); 2890 CalFilter *filter = new CalFilter(i18n("Default"));
2892 mFilters.append(filter); 2891 mFilters.append(filter);
2893 } 2892 }
2894 mFilterView->updateFilters(); 2893 mFilterView->updateFilters();
2895 config->setGroup("FilterView"); 2894 config->setGroup("FilterView");
2896 2895
2897 mFilterView->blockSignals(true); 2896 mFilterView->blockSignals(true);
2898 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2897 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2899 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2898 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2900 mFilterView->blockSignals(false); 2899 mFilterView->blockSignals(false);
2901 // We do it manually to avoid it being done twice by the above calls 2900 // We do it manually to avoid it being done twice by the above calls
2902 updateFilter(); 2901 updateFilter();
2903} 2902}
2904 2903
2905void CalendarView::writeFilterSettings(KConfig *config) 2904void CalendarView::writeFilterSettings(KConfig *config)
2906{ 2905{
2907 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2906 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2908 2907
2909 QStringList filterList; 2908 QStringList filterList;
2910 2909
2911 CalFilter *filter = mFilters.first(); 2910 CalFilter *filter = mFilters.first();
2912 while(filter) { 2911 while(filter) {
2913 // kdDebug() << " fn: " << filter->name() << endl; 2912 // kdDebug() << " fn: " << filter->name() << endl;
2914 filterList << filter->name(); 2913 filterList << filter->name();
2915 config->setGroup("Filter_" + filter->name().utf8()); 2914 config->setGroup("Filter_" + filter->name().utf8());
2916 config->writeEntry("Criteria",filter->criteria()); 2915 config->writeEntry("Criteria",filter->criteria());
2917 config->writeEntry("CategoryList",filter->categoryList()); 2916 config->writeEntry("CategoryList",filter->categoryList());
2918 filter = mFilters.next(); 2917 filter = mFilters.next();
2919 } 2918 }
2920 config->setGroup("General"); 2919 config->setGroup("General");
2921 config->writeEntry("CalendarFilters",filterList); 2920 config->writeEntry("CalendarFilters",filterList);
2922 2921
2923 config->setGroup("FilterView"); 2922 config->setGroup("FilterView");
2924 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2923 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2925 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2924 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2926} 2925}
2927 2926
2928 2927
2929void CalendarView::goToday() 2928void CalendarView::goToday()
2930{ 2929{
2931 if ( mViewManager->currentView()->isMonthView() ) 2930 if ( mViewManager->currentView()->isMonthView() )
2932 mNavigator->selectTodayMonth(); 2931 mNavigator->selectTodayMonth();
2933 else 2932 else
2934 mNavigator->selectToday(); 2933 mNavigator->selectToday();
2935} 2934}
2936 2935
2937void CalendarView::goNext() 2936void CalendarView::goNext()
2938{ 2937{
2939 mNavigator->selectNext(); 2938 mNavigator->selectNext();
2940} 2939}
2941 2940
2942void CalendarView::goPrevious() 2941void CalendarView::goPrevious()
2943{ 2942{
2944 mNavigator->selectPrevious(); 2943 mNavigator->selectPrevious();
2945} 2944}
2946void CalendarView::goNextMonth() 2945void CalendarView::goNextMonth()
2947{ 2946{
2948 mNavigator->selectNextMonth(); 2947 mNavigator->selectNextMonth();
2949} 2948}
2950 2949
2951void CalendarView::goPreviousMonth() 2950void CalendarView::goPreviousMonth()
2952{ 2951{
2953 mNavigator->selectPreviousMonth(); 2952 mNavigator->selectPreviousMonth();
2954} 2953}
2955 2954
2956void CalendarView::updateConfig() 2955void CalendarView::updateConfig()
2957{ 2956{
2958 if ( KOPrefs::instance()->mUseAppColors ) 2957 if ( KOPrefs::instance()->mUseAppColors )
2959 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2958 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2960 emit configChanged(); 2959 emit configChanged();
2961 mTodoList->updateConfig(); 2960 mTodoList->updateConfig();
2962 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2961 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2963 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2962 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2964 // To make the "fill window" configurations work 2963 // To make the "fill window" configurations work
2965 //mViewManager->raiseCurrentView(); 2964 //mViewManager->raiseCurrentView();
2966} 2965}
2967 2966
2968 2967
2969void CalendarView::eventChanged(Event *event) 2968void CalendarView::eventChanged(Event *event)
2970{ 2969{
2971 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2970 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2972 //updateUnmanagedViews(); 2971 //updateUnmanagedViews();
2973} 2972}
2974 2973
2975void CalendarView::eventAdded(Event *event) 2974void CalendarView::eventAdded(Event *event)
2976{ 2975{
2977 changeEventDisplay(event,KOGlobals::EVENTADDED); 2976 changeEventDisplay(event,KOGlobals::EVENTADDED);
2978} 2977}
2979 2978
2980void CalendarView::eventToBeDeleted(Event *) 2979void CalendarView::eventToBeDeleted(Event *)
2981{ 2980{
2982 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2981 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2983} 2982}
2984 2983
2985void CalendarView::eventDeleted() 2984void CalendarView::eventDeleted()
2986{ 2985{
2987 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2986 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2988} 2987}
2989void CalendarView::changeTodoDisplay(Todo *which, int action) 2988void CalendarView::changeTodoDisplay(Todo *which, int action)
2990{ 2989{
2991 changeIncidenceDisplay((Incidence *)which, action); 2990 changeIncidenceDisplay((Incidence *)which, action);
2992 mDateNavigator->updateView(); //LR 2991 mDateNavigator->updateView(); //LR
2993 //mDialogManager->updateSearchDialog(); 2992 //mDialogManager->updateSearchDialog();
2994 2993
2995 if (which) { 2994 if (which) {
2996 mViewManager->updateWNview(); 2995 mViewManager->updateWNview();
2997 //mTodoList->updateView(); 2996 //mTodoList->updateView();
2998 } 2997 }
2999 2998
3000} 2999}
3001 3000
3002void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 3001void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
3003{ 3002{
3004 updateUnmanagedViews(); 3003 updateUnmanagedViews();
3005 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 3004 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
3006 if ( action == KOGlobals::EVENTDELETED ) { //delete 3005 if ( action == KOGlobals::EVENTDELETED ) { //delete
3007 mCalendar->checkAlarmForIncidence( 0, true ); 3006 mCalendar->checkAlarmForIncidence( 0, true );
3008 if ( mEventViewerDialog ) 3007 if ( mEventViewerDialog )
3009 mEventViewerDialog->hide(); 3008 mEventViewerDialog->hide();
3010 } 3009 }
3011 else 3010 else
3012 mCalendar->checkAlarmForIncidence( which , false ); 3011 mCalendar->checkAlarmForIncidence( which , false );
3013} 3012}
3014 3013
3015// most of the changeEventDisplays() right now just call the view's 3014// most of the changeEventDisplays() right now just call the view's
3016// total update mode, but they SHOULD be recoded to be more refresh-efficient. 3015// total update mode, but they SHOULD be recoded to be more refresh-efficient.
3017void CalendarView::changeEventDisplay(Event *which, int action) 3016void CalendarView::changeEventDisplay(Event *which, int action)
3018{ 3017{
3019 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 3018 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
3020 changeIncidenceDisplay((Incidence *)which, action); 3019 changeIncidenceDisplay((Incidence *)which, action);
3021 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3020 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3022 if ( flag_clearallviewsEventDisplay ) { 3021 if ( flag_clearallviewsEventDisplay ) {
3023 clearAllViews(); 3022 clearAllViews();
3024 flag_clearallviewsEventDisplay = false; 3023 flag_clearallviewsEventDisplay = false;
3025 } 3024 }
3026 return; 3025 return;
3027 } 3026 }
3028 flag_clearallviewsEventDisplay = true; 3027 flag_clearallviewsEventDisplay = true;
3029 mDateNavigator->updateView(); 3028 mDateNavigator->updateView();
3030 //mDialogManager->updateSearchDialog(); 3029 //mDialogManager->updateSearchDialog();
3031 if (which) { 3030 if (which) {
3032 // If there is an event view visible update the display 3031 // If there is an event view visible update the display
3033 mViewManager->currentView()->changeEventDisplay(which,action); 3032 mViewManager->currentView()->changeEventDisplay(which,action);
3034 // TODO: check, if update needed 3033 // TODO: check, if update needed
3035 // if (which->getTodoStatus()) { 3034 // if (which->getTodoStatus()) {
3036 mTodoList->updateView(); 3035 mTodoList->updateView();
3037 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { 3036 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) {
3038 mConflictingEvent = which ; 3037 mConflictingEvent = which ;
3039 int time = 1000; 3038 int time = 1000;
3040#ifdef DESKTOP_VERSION 3039#ifdef DESKTOP_VERSION
3041 time = 500; 3040 time = 500;
3042#endif 3041#endif
3043 bool checkC = false; 3042 bool checkC = false;
3044 if ( mConflictingEvent->doesFloat() ) { 3043 if ( mConflictingEvent->doesFloat() ) {
3045 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay 3044 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay
3046 || KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3045 || KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3047 } else { 3046 } else {
3048 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay 3047 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay
3049 || KOPrefs::instance()->mCheckConflictsNonADNonAD; 3048 || KOPrefs::instance()->mCheckConflictsNonADNonAD;
3050 } 3049 }
3051 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) 3050 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent )
3052 checkC = false; 3051 checkC = false;
3053 if ( checkC ) 3052 if ( checkC )
3054 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3053 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3055 } 3054 }
3056 // } 3055 // }
3057 } else { 3056 } else {
3058 mViewManager->currentView()->updateView(); 3057 mViewManager->currentView()->updateView();
3059 } 3058 }
3060} 3059}
3061void CalendarView::checkConflictForEvent() 3060void CalendarView::checkConflictForEvent()
3062{ 3061{
3063 3062
3064 if (!KOPrefs::instance()->mConfirm) 3063 if (!KOPrefs::instance()->mConfirm)
3065 return; 3064 return;
3066 if ( ! mConflictingEvent ) return; 3065 if ( ! mConflictingEvent ) return;
3067 Event * conflictingEvent = mConflictingEvent; 3066 Event * conflictingEvent = mConflictingEvent;
3068 mConflictingEvent = 0; 3067 mConflictingEvent = 0;
3069 QDateTime current = QDateTime::currentDateTime(); 3068 QDateTime current = QDateTime::currentDateTime();
3070 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3069 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3071 return; 3070 return;
3072 } 3071 }
3073 CalFilter *filterIN = 0; 3072 CalFilter *filterIN = 0;
3074 CalFilter *filterALL = 0; 3073 CalFilter *filterALL = 0;
3075 CalFilter *filter = mFilters.first(); 3074 CalFilter *filter = mFilters.first();
3076 while(filter) { 3075 while(filter) {
3077 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3076 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3078 filterIN = filter; 3077 filterIN = filter;
3079 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3078 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3080 filterALL = filter; 3079 filterALL = filter;
3081 filter = mFilters.next(); 3080 filter = mFilters.next();
3082 } 3081 }
3083 if ( filterIN ) { 3082 if ( filterIN ) {
3084 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3083 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3085 return; 3084 return;
3086 } 3085 }
3087 } 3086 }
3088 QPtrList<Event> testlist = mCalendar->events(); 3087 QPtrList<Event> testlist = mCalendar->events();
3089 Event * test = testlist.first(); 3088 Event * test = testlist.first();
3090 QDateTime conflict; 3089 QDateTime conflict;
3091 QDateTime retVal; 3090 QDateTime retVal;
3092 bool found = false; 3091 bool found = false;
3093 Event * cE = 0; 3092 Event * cE = 0;
3094 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3093 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3095 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3094 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3096 if ( !conflictingEvent->doesFloat() ) { 3095 if ( !conflictingEvent->doesFloat() ) {
3097 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3096 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3098 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3097 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3099 } 3098 }
3100 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3099 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3101 while ( test ) { 3100 while ( test ) {
3102 qApp->processEvents(); 3101 qApp->processEvents();
3103 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3102 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3104 3103
3105 if ( !skip ) { 3104 if ( !skip ) {
3106 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) 3105 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent )
3107 skip = true; 3106 skip = true;
3108 } 3107 }
3109 if ( !skip ) { 3108 if ( !skip ) {
3110 if ( filterALL ) { 3109 if ( filterALL ) {
3111 if ( !filterALL->filterCalendarItem( test ) ) { 3110 if ( !filterALL->filterCalendarItem( test ) ) {
3112 skip = true; 3111 skip = true;
3113 } 3112 }
3114 } 3113 }
3115 if ( !skip ) { 3114 if ( !skip ) {
3116 if ( found ) 3115 if ( found )
3117 skip = !test->matchTime( &current, &conflict ); 3116 skip = !test->matchTime( &current, &conflict );
3118 else 3117 else
3119 skip = !test->matchTime( &current, 0 ); 3118 skip = !test->matchTime( &current, 0 );
3120 if ( !skip ) { 3119 if ( !skip ) {
3121 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3120 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3122 if ( ! found ) { 3121 if ( ! found ) {
3123 conflict = retVal; 3122 conflict = retVal;
3124 cE = test; 3123 cE = test;
3125 } else { 3124 } else {
3126 if ( retVal < conflict ) { 3125 if ( retVal < conflict ) {
3127 conflict = retVal; 3126 conflict = retVal;
3128 cE = test; 3127 cE = test;
3129 } 3128 }
3130 } 3129 }
3131 found = true; 3130 found = true;
3132 } 3131 }
3133 } 3132 }
3134 } 3133 }
3135 } 3134 }
3136 test = testlist.next(); 3135 test = testlist.next();
3137 } 3136 }
3138 topLevelWidget()->setCaption( i18n("KO/Pi") ); 3137 topLevelWidget()->setCaption( i18n("KO/Pi") );
3139 if ( found ) { 3138 if ( found ) {
3140 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 3139 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
3141 qApp->processEvents(); 3140 qApp->processEvents();
3142 int km = KMessageBox::warningContinueCancel(this,mess, 3141 int km = KMessageBox::warningContinueCancel(this,mess,
3143 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); 3142 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!"));
3144 if ( km != KMessageBox::Continue ) { 3143 if ( km != KMessageBox::Continue ) {
3145 return; 3144 return;
3146 } 3145 }
3147 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 3146 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
3148 mViewManager->showDayView(); 3147 mViewManager->showDayView();
3149 mNavigator->slotDaySelect( conflict.date() ); 3148 mNavigator->slotDaySelect( conflict.date() );
3150 int hour = conflict.time().hour(); 3149 int hour = conflict.time().hour();
3151 mViewManager->agendaView()->setStartHour( hour ); 3150 mViewManager->agendaView()->setStartHour( hour );
3152 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 3151 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
3153 } else 3152 } else
3154 topLevelWidget()->setCaption( i18n("No conflict found") ); 3153 topLevelWidget()->setCaption( i18n("No conflict found") );
3155 return; 3154 return;
3156 3155
3157} 3156}
3158 3157
3159void CalendarView::updateTodoViews() 3158void CalendarView::updateTodoViews()
3160{ 3159{
3161 mTodoList->updateView(); 3160 mTodoList->updateView();
3162 mViewManager->currentView()->updateView(); 3161 mViewManager->currentView()->updateView();
3163 3162
3164} 3163}
3165 3164
3166 3165
3167 3166
3168void CalendarView::clearAllViews() 3167void CalendarView::clearAllViews()
3169{ 3168{
3170 mTodoList->clearList(); 3169 mTodoList->clearList();
3171 mViewManager->clearAllViews(); 3170 mViewManager->clearAllViews();
3172 SearchDialog * sd = mDialogManager->getSearchDialog(); 3171 SearchDialog * sd = mDialogManager->getSearchDialog();
3173 if ( sd ) { 3172 if ( sd ) {
3174 KOListView* kol = sd->listview(); 3173 KOListView* kol = sd->listview();
3175 if ( kol ) 3174 if ( kol )
3176 kol->clearList(); 3175 kol->clearList();
3177 } 3176 }
3178} 3177}
3179void CalendarView::updateView() 3178void CalendarView::updateView()
3180{ 3179{
3181 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3180 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3182 if ( flag_clearallviewsupdateView ) { 3181 if ( flag_clearallviewsupdateView ) {
3183 clearAllViews(); 3182 clearAllViews();
3184 flag_clearallviewsupdateView = false; 3183 flag_clearallviewsupdateView = false;
3185 } 3184 }
3186 return; 3185 return;
3187 } 3186 }
3188 flag_clearallviewsupdateView = true; 3187 flag_clearallviewsupdateView = true;
3189 DateList tmpList = mNavigator->selectedDates(); 3188 DateList tmpList = mNavigator->selectedDates();
3190 3189
3191 if ( KOPrefs::instance()->mHideNonStartedTodos ) 3190 if ( KOPrefs::instance()->mHideNonStartedTodos )
3192 mTodoList->updateView(); 3191 mTodoList->updateView();
3193 // We assume that the navigator only selects consecutive days. 3192 // We assume that the navigator only selects consecutive days.
3194 updateView( tmpList.first(), tmpList.last() ); 3193 updateView( tmpList.first(), tmpList.last() );
3195} 3194}
3196 3195
3197void CalendarView::updateUnmanagedViews() 3196void CalendarView::updateUnmanagedViews()
3198{ 3197{
3199 mDateNavigator->updateDayMatrix(); 3198 mDateNavigator->updateDayMatrix();
3200} 3199}
3201 3200
3202int CalendarView::msgItemDelete(const QString name) 3201int CalendarView::msgItemDelete(const QString name)
3203{ 3202{
3204 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 3203 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
3205 i18n("This item will be\npermanently deleted."), 3204 i18n("This item will be\npermanently deleted."),
3206 i18n("KO/Pi Confirmation"),i18n("Delete")); 3205 i18n("KO/Pi Confirmation"),i18n("Delete"));
3207} 3206}
3208 3207
3209 3208
3210void CalendarView::edit_cut() 3209void CalendarView::edit_cut()
3211{ 3210{
3212 Event *anEvent=0; 3211 Event *anEvent=0;
3213 3212
3214 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3213 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3215 3214
3216 if (mViewManager->currentView()->isEventView()) { 3215 if (mViewManager->currentView()->isEventView()) {
3217 if ( incidence && incidence->typeID() == eventID ) { 3216 if ( incidence && incidence->typeID() == eventID ) {
3218 anEvent = static_cast<Event *>(incidence); 3217 anEvent = static_cast<Event *>(incidence);
3219 } 3218 }
3220 } 3219 }
3221 3220
3222 if (!anEvent) { 3221 if (!anEvent) {
3223 KNotifyClient::beep(); 3222 KNotifyClient::beep();
3224 return; 3223 return;
3225 } 3224 }
3226 DndFactory factory( mCalendar ); 3225 DndFactory factory( mCalendar );
3227 factory.cutIncidence(anEvent); 3226 factory.cutIncidence(anEvent);
3228 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3227 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3229} 3228}
3230 3229
3231void CalendarView::edit_copy() 3230void CalendarView::edit_copy()
3232{ 3231{
3233 Event *anEvent=0; 3232 Event *anEvent=0;
3234 3233
3235 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3234 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3236 3235
3237 if (mViewManager->currentView()->isEventView()) { 3236 if (mViewManager->currentView()->isEventView()) {
3238 if ( incidence && incidence->typeID() == eventID ) { 3237 if ( incidence && incidence->typeID() == eventID ) {
3239 anEvent = static_cast<Event *>(incidence); 3238 anEvent = static_cast<Event *>(incidence);
3240 } 3239 }
3241 } 3240 }
3242 3241
3243 if (!anEvent) { 3242 if (!anEvent) {
3244 KNotifyClient::beep(); 3243 KNotifyClient::beep();
3245 return; 3244 return;
3246 } 3245 }
3247 DndFactory factory( mCalendar ); 3246 DndFactory factory( mCalendar );
3248 factory.copyIncidence(anEvent); 3247 factory.copyIncidence(anEvent);
3249} 3248}
3250 3249
3251void CalendarView::edit_paste() 3250void CalendarView::edit_paste()
3252{ 3251{
3253 QDate date = mNavigator->selectedDates().first(); 3252 QDate date = mNavigator->selectedDates().first();
3254 3253
3255 DndFactory factory( mCalendar ); 3254 DndFactory factory( mCalendar );
3256 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 3255 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
3257 3256
3258 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 3257 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
3259} 3258}
3260void CalendarView::edit_global_options() 3259void CalendarView::edit_global_options()
3261{ 3260{
3262 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 3261 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
3263 emit save(); 3262 emit save();
3264 emit saveStopTimer(); 3263 emit saveStopTimer();
3265 mDialogManager->showGlobalOptionsDialog(); 3264 mDialogManager->showGlobalOptionsDialog();
3266 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 3265 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
3267 emit saveStopTimer(); 3266 emit saveStopTimer();
3268 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 3267 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
3269 i18n("Timezone settings"),i18n("Reload"))) { 3268 i18n("Timezone settings"),i18n("Reload"))) {
3270 qDebug("KO: TZ reload cancelled "); 3269 qDebug("KO: TZ reload cancelled ");
3271 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3270 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3272 return; 3271 return;
3273 } 3272 }
3274 qDebug("KO: Timezone change "); 3273 qDebug("KO: Timezone change ");
3275 loadCalendars(); 3274 loadCalendars();
3276 setModified(true); 3275 setModified(true);
3277 } 3276 }
3278 else 3277 else
3279 qDebug("KO: No tz change "); 3278 qDebug("KO: No tz change ");
3280} 3279}
3281void CalendarView::edit_options() 3280void CalendarView::edit_options()
3282{ 3281{
3283 mDialogManager->showOptionsDialog(); 3282 mDialogManager->showOptionsDialog();
3284} 3283}
3285 3284
3286 3285
3287void CalendarView::slotSelectPickerDate( QDate d) 3286void CalendarView::slotSelectPickerDate( QDate d)
3288{ 3287{
3289 mDateFrame->hide(); 3288 mDateFrame->hide();
3290 if ( mDatePickerMode == 1 ) { 3289 if ( mDatePickerMode == 1 ) {
3291 mNavigator->slotDaySelect( d ); 3290 mNavigator->slotDaySelect( d );
3292 } else if ( mDatePickerMode == 2 ) { 3291 } else if ( mDatePickerMode == 2 ) {
3293 if ( mMoveIncidence->typeID() == todoID ) { 3292 if ( mMoveIncidence->typeID() == todoID ) {
3294 Todo * to = (Todo *) mMoveIncidence; 3293 Todo * to = (Todo *) mMoveIncidence;
3295 QTime tim; 3294 QTime tim;
3296 int len = 0; 3295 int len = 0;
3297 if ( to->hasStartDate() && to->hasDueDate() ) 3296 if ( to->hasStartDate() && to->hasDueDate() )
3298 len = to->dtStart().secsTo( to->dtDue()); 3297 len = to->dtStart().secsTo( to->dtDue());
3299 if ( to->hasDueDate() ) 3298 if ( to->hasDueDate() )
3300 tim = to->dtDue().time(); 3299 tim = to->dtDue().time();
3301 else { 3300 else {
3302 tim = QTime ( 0,0,0 ); 3301 tim = QTime ( 0,0,0 );
3303 to->setFloats( true ); 3302 to->setFloats( true );
3304 to->setHasDueDate( true ); 3303 to->setHasDueDate( true );
3305 } 3304 }
3306 QDateTime dt ( d,tim ); 3305 QDateTime dt ( d,tim );
3307 to->setDtDue( dt ); 3306 to->setDtDue( dt );
3308 3307
3309 if ( to->hasStartDate() ) { 3308 if ( to->hasStartDate() ) {
3310 if ( len>0 ) 3309 if ( len>0 )
3311 to->setDtStart(to->dtDue().addSecs( -len )); 3310 to->setDtStart(to->dtDue().addSecs( -len ));
3312 else 3311 else
3313 if (to->dtStart() > to->dtDue() ) 3312 if (to->dtStart() > to->dtDue() )
3314 to->setDtStart(to->dtDue().addDays( -3 )); 3313 to->setDtStart(to->dtDue().addDays( -3 ));
3315 } 3314 }
3316 3315
3317 todoChanged( to ); 3316 todoChanged( to );
3318 } else if ( mMoveIncidence->typeID() == eventID ) { 3317 } else if ( mMoveIncidence->typeID() == eventID ) {
3319 if ( mMoveIncidence->doesRecur() ) { 3318 if ( mMoveIncidence->doesRecur() ) {
3320#if 0 3319#if 0
3321 // PENDING implement this 3320 // PENDING implement this
3322 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3321 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3323 mCalendar()->addIncidence( newInc ); 3322 mCalendar()->addIncidence( newInc );
3324 if ( mMoveIncidence->typeID() == todoID ) 3323 if ( mMoveIncidence->typeID() == todoID )
3325 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3324 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3326 else 3325 else
3327 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3326 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3328 mMoveIncidence = newInc; 3327 mMoveIncidence = newInc;
3329 3328
3330#endif 3329#endif
3331 } 3330 }
3332 QTime tim = mMoveIncidence->dtStart().time(); 3331 QTime tim = mMoveIncidence->dtStart().time();
3333 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3332 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3334 QDateTime dt ( d,tim ); 3333 QDateTime dt ( d,tim );
3335 mMoveIncidence->setDtStart( dt ); 3334 mMoveIncidence->setDtStart( dt );
3336 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3335 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3337 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3336 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3338 } else if ( mMoveIncidence->typeID() == journalID ) { 3337 } else if ( mMoveIncidence->typeID() == journalID ) {
3339 QTime tim = mMoveIncidence->dtStart().time(); 3338 QTime tim = mMoveIncidence->dtStart().time();
3340 QDateTime dt ( d,tim ); 3339 QDateTime dt ( d,tim );
3341 mMoveIncidence->setDtStart( dt ); 3340 mMoveIncidence->setDtStart( dt );
3342 updateView(); 3341 updateView();
3343 } 3342 }
3344 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3343 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3345 } 3344 }
3346} 3345}
3347 3346
3348void CalendarView::removeCategories() 3347void CalendarView::removeCategories()
3349{ 3348{
3350 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3349 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3351 QStringList catList = KOPrefs::instance()->mCustomCategories; 3350 QStringList catList = KOPrefs::instance()->mCustomCategories;
3352 QStringList catIncList; 3351 QStringList catIncList;
3353 QStringList newCatList; 3352 QStringList newCatList;
3354 Incidence* inc = incList.first(); 3353 Incidence* inc = incList.first();
3355 uint i; 3354 uint i;
3356 while ( inc ) { 3355 while ( inc ) {
3357 newCatList.clear(); 3356 newCatList.clear();
3358 catIncList = inc->categories() ; 3357 catIncList = inc->categories() ;
3359 for( i = 0; i< catIncList.count(); ++i ) { 3358 for( i = 0; i< catIncList.count(); ++i ) {
3360 if ( catList.contains (catIncList[i])) 3359 if ( catList.contains (catIncList[i]))
3361 newCatList.append( catIncList[i] ); 3360 newCatList.append( catIncList[i] );
3362 } 3361 }
3363 newCatList.sort(); 3362 newCatList.sort();
3364 inc->setCategories( newCatList.join(",") ); 3363 inc->setCategories( newCatList.join(",") );
3365 inc = incList.next(); 3364 inc = incList.next();
3366 } 3365 }
3367} 3366}
3368 3367
3369int CalendarView::addCategories() 3368int CalendarView::addCategories()
3370{ 3369{
3371 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3370 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3372 QStringList catList = KOPrefs::instance()->mCustomCategories; 3371 QStringList catList = KOPrefs::instance()->mCustomCategories;
3373 QStringList catIncList; 3372 QStringList catIncList;
3374 Incidence* inc = incList.first(); 3373 Incidence* inc = incList.first();
3375 uint i; 3374 uint i;
3376 int count = 0; 3375 int count = 0;
3377 while ( inc ) { 3376 while ( inc ) {
3378 catIncList = inc->categories() ; 3377 catIncList = inc->categories() ;
3379 for( i = 0; i< catIncList.count(); ++i ) { 3378 for( i = 0; i< catIncList.count(); ++i ) {
3380 if ( !catList.contains (catIncList[i])) { 3379 if ( !catList.contains (catIncList[i])) {
3381 catList.append( catIncList[i] ); 3380 catList.append( catIncList[i] );
3382 //qDebug("add cat %s ", catIncList[i].latin1()); 3381 //qDebug("add cat %s ", catIncList[i].latin1());
3383 ++count; 3382 ++count;
3384 } 3383 }
3385 } 3384 }
3386 inc = incList.next(); 3385 inc = incList.next();
3387 } 3386 }
3388 catList.sort(); 3387 catList.sort();
3389 KOPrefs::instance()->mCustomCategories = catList; 3388 KOPrefs::instance()->mCustomCategories = catList;
3390 return count; 3389 return count;
3391} 3390}
3392 3391
3393void CalendarView::editCategories() 3392void CalendarView::editCategories()
3394{ 3393{
3395 qDebug("CalendarView::editCategories() "); 3394 qDebug("CalendarView::editCategories() ");
3396 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3395 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3397 ced.exec(); 3396 ced.exec();
3398} 3397}
3399void CalendarView::manageCategories() 3398void CalendarView::manageCategories()
3400{ 3399{
3401 KOCatPrefs* cp = new KOCatPrefs(); 3400 KOCatPrefs* cp = new KOCatPrefs();
3402 cp->show(); 3401 cp->show();
3403 int w =cp->sizeHint().width() ; 3402 int w =cp->sizeHint().width() ;
3404 int h = cp->sizeHint().height() ; 3403 int h = cp->sizeHint().height() ;
3405 int dw = QApplication::desktop()->width(); 3404 int dw = QApplication::desktop()->width();
3406 int dh = QApplication::desktop()->height(); 3405 int dh = QApplication::desktop()->height();
3407 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3406 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3408 if ( !cp->exec() ) { 3407 if ( !cp->exec() ) {
3409 delete cp; 3408 delete cp;
3410 return; 3409 return;
3411 } 3410 }
3412 int count = 0; 3411 int count = 0;
3413 if ( cp->addCat() ) { 3412 if ( cp->addCat() ) {
3414 count = addCategories(); 3413 count = addCategories();
3415 if ( count ) { 3414 if ( count ) {
3416 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3415 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3417 writeSettings(); 3416 writeSettings();
3418 } else 3417 } else
3419 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3418 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3420 } else { 3419 } else {
3421 removeCategories(); 3420 removeCategories();
3422 updateView(); 3421 updateView();
3423 } 3422 }
3424 delete cp; 3423 delete cp;
3425} 3424}
3426 3425
3427void CalendarView::beamIncidence(Incidence * Inc) 3426void CalendarView::beamIncidence(Incidence * Inc)
3428{ 3427{
3429 QPtrList<Incidence> delSel ; 3428 QPtrList<Incidence> delSel ;
3430 delSel.append(Inc); 3429 delSel.append(Inc);
3431 beamIncidenceList( delSel ); 3430 beamIncidenceList( delSel );
3432} 3431}
3433void CalendarView::beamCalendar() 3432void CalendarView::beamCalendar()
3434{ 3433{
3435 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3434 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3436 //qDebug("beamCalendar() "); 3435 //qDebug("beamCalendar() ");
3437 beamIncidenceList( delSel ); 3436 beamIncidenceList( delSel );
3438} 3437}
3439void CalendarView::beamFilteredCalendar() 3438void CalendarView::beamFilteredCalendar()
3440{ 3439{
3441 QPtrList<Incidence> delSel = mCalendar->incidences(); 3440 QPtrList<Incidence> delSel = mCalendar->incidences();
3442 //qDebug("beamFilteredCalendar() "); 3441 //qDebug("beamFilteredCalendar() ");
3443 beamIncidenceList( delSel ); 3442 beamIncidenceList( delSel );
3444} 3443}
3445void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3444void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3446{ 3445{
3447 3446
3448 KOBeamPrefs beamDialog; 3447 KOBeamPrefs beamDialog;
3449 if ( beamDialog.exec () == QDialog::Rejected ) 3448 if ( beamDialog.exec () == QDialog::Rejected )
3450 return; 3449 return;
3451#ifdef DESKTOP_VERSION 3450#ifdef DESKTOP_VERSION
3452 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3451 QString fn = locateLocal( "tmp", "kopibeamfile" );
3453#else 3452#else
3454 QString fn = "/tmp/kopibeamfile"; 3453 QString fn = "/tmp/kopibeamfile";
3455#endif 3454#endif
3456 QString mes; 3455 QString mes;
3457 bool createbup = true; 3456 bool createbup = true;
3458 if ( createbup ) { 3457 if ( createbup ) {
3459 QString description = "\n"; 3458 QString description = "\n";
3460 CalendarLocal* cal = new CalendarLocal(); 3459 CalendarLocal* cal = new CalendarLocal();
3461 if ( beamDialog.beamLocal() ) 3460 if ( beamDialog.beamLocal() )
3462 cal->setLocalTime(); 3461 cal->setLocalTime();
3463 else 3462 else
3464 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3463 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3465 Incidence *incidence = delSel.first(); 3464 Incidence *incidence = delSel.first();
3466 bool addText = false; 3465 bool addText = false;
3467 if ( delSel.count() < 10 ) 3466 if ( delSel.count() < 10 )
3468 addText = true; 3467 addText = true;
3469 else { 3468 else {
3470 description.sprintf(i18n(" %d items?"),delSel.count() ); 3469 description.sprintf(i18n(" %d items?"),delSel.count() );
3471 } 3470 }
3472 while ( incidence ) { 3471 while ( incidence ) {
3473 Incidence *in = incidence->clone(); 3472 Incidence *in = incidence->clone();
3474 if ( ! in->summary().isEmpty() ) { 3473 if ( ! in->summary().isEmpty() ) {
3475 in->setDescription(""); 3474 in->setDescription("");
3476 } else { 3475 } else {
3477 in->setSummary( in->description().left(20)); 3476 in->setSummary( in->description().left(20));
3478 in->setDescription(""); 3477 in->setDescription("");
3479 } 3478 }
3480 if ( addText ) 3479 if ( addText )
3481 description += in->summary() + "\n"; 3480 description += in->summary() + "\n";
3482 cal->addIncidence( in ); 3481 cal->addIncidence( in );
3483 incidence = delSel.next(); 3482 incidence = delSel.next();
3484 } 3483 }
3485 if ( beamDialog.beamVcal() ) { 3484 if ( beamDialog.beamVcal() ) {
3486 fn += ".vcs"; 3485 fn += ".vcs";
3487 FileStorage storage( cal, fn, new VCalFormat ); 3486 FileStorage storage( cal, fn, new VCalFormat );
3488 storage.save(); 3487 storage.save();
3489 } else { 3488 } else {
3490 fn += ".ics"; 3489 fn += ".ics";
3491 FileStorage storage( cal, fn, new ICalFormat( ) ); 3490 FileStorage storage( cal, fn, new ICalFormat( ) );
3492 storage.save(); 3491 storage.save();
3493 } 3492 }
3494 delete cal; 3493 delete cal;
3495 mes = i18n("KO/Pi: Ready for beaming"); 3494 mes = i18n("KO/Pi: Ready for beaming");
3496 topLevelWidget()->setCaption(mes); 3495 topLevelWidget()->setCaption(mes);
3497 KApplication::convert2latin1( fn ); 3496 KApplication::convert2latin1( fn );
3498#ifndef DESKTOP_VERSION 3497#ifndef DESKTOP_VERSION
3499 Ir *ir = new Ir( this ); 3498 Ir *ir = new Ir( this );
3500 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3499 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3501 ir->send( fn, description, "text/x-vCalendar" ); 3500 ir->send( fn, description, "text/x-vCalendar" );
3502#endif 3501#endif
3503 } 3502 }
3504} 3503}
3505 3504
3506#ifndef DESKTOP_VERSION 3505#ifndef DESKTOP_VERSION
3507void CalendarView::beamDone( Ir *ir ) 3506void CalendarView::beamDone( Ir *ir )
3508{ 3507{
3509 delete ir; 3508 delete ir;
3510 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3509 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3511 topLevelWidget()->raise(); 3510 topLevelWidget()->raise();
3512} 3511}
3513#else 3512#else
3514void CalendarView::beamDone( Ir *){;} 3513void CalendarView::beamDone( Ir *){;}
3515#endif 3514#endif
3516void CalendarView::moveIncidence(Incidence * inc ) 3515void CalendarView::moveIncidence(Incidence * inc )
3517{ 3516{
3518 if ( !inc ) return; 3517 if ( !inc ) return;
3519 showDatePickerPopup(); 3518 showDatePickerPopup();
3520 mDatePickerMode = 2; 3519 mDatePickerMode = 2;
3521 mMoveIncidence = inc ; 3520 mMoveIncidence = inc ;
3522 QDate da; 3521 QDate da;
3523 if ( mMoveIncidence->typeID() == todoID ) { 3522 if ( mMoveIncidence->typeID() == todoID ) {
3524 Todo * to = (Todo *) mMoveIncidence; 3523 Todo * to = (Todo *) mMoveIncidence;
3525 if ( to->hasDueDate() ) 3524 if ( to->hasDueDate() )
3526 da = to->dtDue().date(); 3525 da = to->dtDue().date();
3527 else 3526 else
3528 da = QDate::currentDate(); 3527 da = QDate::currentDate();
3529 } else { 3528 } else {
3530 da = mMoveIncidence->dtStart().date(); 3529 da = mMoveIncidence->dtStart().date();
3531 } 3530 }
3532 //PENDING set date for recurring incidence to date of recurrence 3531 //PENDING set date for recurring incidence to date of recurrence
3533 //mMoveIncidenceOldDate; 3532 //mMoveIncidenceOldDate;
3534 mDatePicker->setDate( da ); 3533 mDatePicker->setDate( da );
3535} 3534}
3536void CalendarView::showDatePickerPopup() 3535void CalendarView::showDatePickerPopup()
3537{ 3536{
3538 if ( mDateFrame->isVisible() ) 3537 if ( mDateFrame->isVisible() )
3539 mDateFrame->hide(); 3538 mDateFrame->hide();
3540 else { 3539 else {
3541 int offX = 0, offY = 0; 3540 int offX = 0, offY = 0;
3542#ifdef DESKTOP_VERSION 3541#ifdef DESKTOP_VERSION
3543 int w =mDatePicker->sizeHint().width() ; 3542 int w =mDatePicker->sizeHint().width() ;
3544 int h = mDatePicker->sizeHint().height() ; 3543 int h = mDatePicker->sizeHint().height() ;
3545 int dw = topLevelWidget()->width(); 3544 int dw = topLevelWidget()->width();
3546 int dh = topLevelWidget()->height(); 3545 int dh = topLevelWidget()->height();
3547 offX = topLevelWidget()->x(); 3546 offX = topLevelWidget()->x();
3548 offY = topLevelWidget()->y(); 3547 offY = topLevelWidget()->y();
3549#else 3548#else
3550 int w =mDatePicker->sizeHint().width() ; 3549 int w =mDatePicker->sizeHint().width() ;
3551 int h = mDatePicker->sizeHint().height() ; 3550 int h = mDatePicker->sizeHint().height() ;
3552 int dw = QApplication::desktop()->width(); 3551 int dw = QApplication::desktop()->width();
3553 int dh = QApplication::desktop()->height(); 3552 int dh = QApplication::desktop()->height();
3554#endif 3553#endif
3555 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3554 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3556 mDateFrame->show(); 3555 mDateFrame->show();
3557 } 3556 }
3558} 3557}
3559void CalendarView::showDatePicker( ) 3558void CalendarView::showDatePicker( )
3560{ 3559{
3561 showDatePickerPopup(); 3560 showDatePickerPopup();
3562 mDatePickerMode = 1; 3561 mDatePickerMode = 1;
3563 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3562 mDatePicker->setDate( mNavigator->selectedDates().first() );
3564} 3563}
3565 3564
3566void CalendarView::showEventEditor() 3565void CalendarView::showEventEditor()
3567{ 3566{
3568#ifdef DESKTOP_VERSION 3567#ifdef DESKTOP_VERSION
3569 int x,y,w,h; 3568 int x,y,w,h;
3570 x = mEventEditor->geometry().x(); 3569 x = mEventEditor->geometry().x();
3571 y = mEventEditor->geometry().y(); 3570 y = mEventEditor->geometry().y();
3572 w = mEventEditor->width(); 3571 w = mEventEditor->width();
3573 h = mEventEditor->height(); 3572 h = mEventEditor->height();
3574 mEventEditor->show(); 3573 mEventEditor->show();
3575 mEventEditor->setGeometry(x,y,w,h); 3574 mEventEditor->setGeometry(x,y,w,h);
3576#else 3575#else
3577 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3576 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3578 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3577 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3579 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3578 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3580 qApp->processEvents(); 3579 qApp->processEvents();
3581 delete mEventEditor; 3580 delete mEventEditor;
3582 mEventEditor = mDialogManager->getEventEditor(); 3581 mEventEditor = mDialogManager->getEventEditor();
3583 topLevelWidget()->setCaption( i18n("") ); 3582 topLevelWidget()->setCaption( i18n("") );
3584 } 3583 }
3585 mEventEditor->showMaximized(); 3584 mEventEditor->showMaximized();
3586#endif 3585#endif
3587} 3586}
3588void CalendarView::showTodoEditor() 3587void CalendarView::showTodoEditor()
3589{ 3588{
3590#ifdef DESKTOP_VERSION 3589#ifdef DESKTOP_VERSION
3591 int x,y,w,h; 3590 int x,y,w,h;
3592 x = mTodoEditor->geometry().x(); 3591 x = mTodoEditor->geometry().x();
3593 y = mTodoEditor->geometry().y(); 3592 y = mTodoEditor->geometry().y();
3594 w = mTodoEditor->width(); 3593 w = mTodoEditor->width();
3595 h = mTodoEditor->height(); 3594 h = mTodoEditor->height();
3596 mTodoEditor->show(); 3595 mTodoEditor->show();
3597 mTodoEditor->setGeometry(x,y,w,h); 3596 mTodoEditor->setGeometry(x,y,w,h);
3598#else 3597#else
3599 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3598 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3600 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3599 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3601 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3600 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3602 qApp->processEvents(); 3601 qApp->processEvents();
3603 delete mTodoEditor; 3602 delete mTodoEditor;
3604 mTodoEditor = mDialogManager->getTodoEditor(); 3603 mTodoEditor = mDialogManager->getTodoEditor();
3605 topLevelWidget()->setCaption( i18n("") ); 3604 topLevelWidget()->setCaption( i18n("") );
3606 } 3605 }
3607 mTodoEditor->showMaximized(); 3606 mTodoEditor->showMaximized();
3608#endif 3607#endif
3609} 3608}
3610 3609
3611void CalendarView::cloneIncidence() 3610void CalendarView::cloneIncidence()
3612{ 3611{
3613 Incidence *incidence = currentSelection(); 3612 Incidence *incidence = currentSelection();
3614 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3613 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3615 if ( incidence ) { 3614 if ( incidence ) {
3616 cloneIncidence(incidence); 3615 cloneIncidence(incidence);
3617 } 3616 }
3618} 3617}
3619void CalendarView::moveIncidence() 3618void CalendarView::moveIncidence()
3620{ 3619{
3621 Incidence *incidence = currentSelection(); 3620 Incidence *incidence = currentSelection();
3622 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3621 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3623 if ( incidence ) { 3622 if ( incidence ) {
3624 moveIncidence(incidence); 3623 moveIncidence(incidence);
3625 } 3624 }
3626} 3625}
3627void CalendarView::beamIncidence() 3626void CalendarView::beamIncidence()
3628{ 3627{
3629 Incidence *incidence = currentSelection(); 3628 Incidence *incidence = currentSelection();
3630 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3629 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3631 if ( incidence ) { 3630 if ( incidence ) {
3632 beamIncidence(incidence); 3631 beamIncidence(incidence);
3633 } 3632 }
3634} 3633}
3635void CalendarView::toggleCancelIncidence() 3634void CalendarView::toggleCancelIncidence()
3636{ 3635{
3637 Incidence *incidence = currentSelection(); 3636 Incidence *incidence = currentSelection();
3638 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3637 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3639 if ( incidence ) { 3638 if ( incidence ) {
3640 cancelIncidence(incidence); 3639 cancelIncidence(incidence);
3641 } 3640 }
3642} 3641}
3643 3642
3644 3643
3645void CalendarView::cancelIncidence(Incidence * inc ) 3644void CalendarView::cancelIncidence(Incidence * inc )
3646{ 3645{
3647 inc->setCancelled( ! inc->cancelled() ); 3646 inc->setCancelled( ! inc->cancelled() );
3648 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3647 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3649 updateView(); 3648 updateView();
3650} 3649}
3651void CalendarView::cloneIncidence(Incidence * orgInc ) 3650void CalendarView::cloneIncidence(Incidence * orgInc )
3652{ 3651{
3653 Incidence * newInc = orgInc->clone(); 3652 Incidence * newInc = orgInc->clone();
3654 newInc->recreate(); 3653 newInc->recreate();
3655 3654
3656 if ( newInc->typeID() == todoID ) { 3655 if ( newInc->typeID() == todoID ) {
3657 Todo* t = (Todo*) newInc; 3656 Todo* t = (Todo*) newInc;
3658 bool cloneSub = false; 3657 bool cloneSub = false;
3659 if ( orgInc->relations().count() ) { 3658 if ( orgInc->relations().count() ) {
3660 int result = KMessageBox::warningYesNoCancel(this, 3659 int result = KMessageBox::warningYesNoCancel(this,
3661 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), 3660 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
3662 i18n("Todo has subtodos"), 3661 i18n("Todo has subtodos"),
3663 i18n("Yes"), 3662 i18n("Yes"),
3664 i18n("No")); 3663 i18n("No"));
3665 3664
3666 if ( result == KMessageBox::Cancel ) { 3665 if ( result == KMessageBox::Cancel ) {
3667 delete t; 3666 delete t;
3668 return; 3667 return;
3669 } 3668 }
3670 if (result == KMessageBox::Yes) cloneSub = true; 3669 if (result == KMessageBox::Yes) cloneSub = true;
3671 } 3670 }
3672 showTodoEditor(); 3671 showTodoEditor();
3673 mTodoEditor->editTodo( t ); 3672 mTodoEditor->editTodo( t );
3674 if ( mTodoEditor->exec() ) { 3673 if ( mTodoEditor->exec() ) {
3675 if ( cloneSub ) { 3674 if ( cloneSub ) {
3676 orgInc->cloneRelations( t ); 3675 orgInc->cloneRelations( t );
3677 mCalendar->addIncidenceBranch( t ); 3676 mCalendar->addIncidenceBranch( t );
3678 updateView(); 3677 updateView();
3679 3678
3680 } else { 3679 } else {
3681 mCalendar->addTodo( t ); 3680 mCalendar->addTodo( t );
3682 updateView(); 3681 updateView();
3683 } 3682 }
3684 } else { 3683 } else {
3685 delete t; 3684 delete t;
3686 } 3685 }
3687 } 3686 }
3688 else if ( newInc->typeID() == eventID ) { 3687 else if ( newInc->typeID() == eventID ) {
3689 Event* e = (Event*) newInc; 3688 Event* e = (Event*) newInc;
3690 showEventEditor(); 3689 showEventEditor();
3691 mEventEditor->editEvent( e ); 3690 mEventEditor->editEvent( e );
3692 if ( mEventEditor->exec() ) { 3691 if ( mEventEditor->exec() ) {
3693 mCalendar->addEvent( e ); 3692 mCalendar->addEvent( e );
3694 updateView(); 3693 updateView();
3695 } else { 3694 } else {
3696 delete e; 3695 delete e;
3697 } 3696 }
3698 } else if ( newInc->typeID() == journalID ) { 3697 } else if ( newInc->typeID() == journalID ) {
3699 mCalendar->addJournal( (Journal*) newInc ); 3698 mCalendar->addJournal( (Journal*) newInc );
3700 editJournal( (Journal*) newInc ); 3699 editJournal( (Journal*) newInc );
3701 } 3700 }
3702 setActiveWindow(); 3701 setActiveWindow();
3703} 3702}
3704 3703
3705void CalendarView::newEvent() 3704void CalendarView::newEvent()
3706{ 3705{
3707 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3706 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3708 KOAgendaView *aView = mViewManager->agendaView(); 3707 KOAgendaView *aView = mViewManager->agendaView();
3709 if (aView) { 3708 if (aView) {
3710 if (aView->selectionStart().isValid()) { 3709 if (aView->selectionStart().isValid()) {
3711 if (aView->selectedIsAllDay()) { 3710 if (aView->selectedIsAllDay()) {
3712 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3711 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3713 } else { 3712 } else {
3714 newEvent(aView->selectionStart(),aView->selectionEnd()); 3713 newEvent(aView->selectionStart(),aView->selectionEnd());
3715 } 3714 }
3716 return; 3715 return;
3717 } 3716 }
3718 } 3717 }
3719 3718
3720 QDate date = mNavigator->selectedDates().first(); 3719 QDate date = mNavigator->selectedDates().first();
3721#if 0 3720#if 0
3722 QDateTime current = QDateTime::currentDateTime(); 3721 QDateTime current = QDateTime::currentDateTime();
3723 if ( date <= current.date() ) { 3722 if ( date <= current.date() ) {
3724 int hour = current.time().hour() +1; 3723 int hour = current.time().hour() +1;
3725 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3724 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3726 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3725 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3727 } else 3726 } else
3728#endif 3727#endif
3729 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3728 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3730 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3729 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3731 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3730 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3732} 3731}
3733 3732
3734void CalendarView::newEvent(QDateTime fh) 3733void CalendarView::newEvent(QDateTime fh)
3735{ 3734{
3736 newEvent(fh, 3735 newEvent(fh,
3737 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3736 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3738} 3737}
3739 3738
3740void CalendarView::newEvent(QDate dt) 3739void CalendarView::newEvent(QDate dt)
3741{ 3740{
3742 newEvent(QDateTime(dt, QTime(0,0,0)), 3741 newEvent(QDateTime(dt, QTime(0,0,0)),
3743 QDateTime(dt, QTime(0,0,0)), true); 3742 QDateTime(dt, QTime(0,0,0)), true);
3744} 3743}
3745void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3744void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3746{ 3745{
3747 newEvent(fromHint, toHint, false); 3746 newEvent(fromHint, toHint, false);
3748} 3747}
3749void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3748void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3750{ 3749{
3751 3750
3752 showEventEditor(); 3751 showEventEditor();
3753 mEventEditor->newEvent(fromHint,toHint,allDay); 3752 mEventEditor->newEvent(fromHint,toHint,allDay);
3754 if ( mFilterView->filtersEnabled() ) { 3753 if ( mFilterView->filtersEnabled() ) {
3755 CalFilter *filter = mFilterView->selectedFilter(); 3754 CalFilter *filter = mFilterView->selectedFilter();
3756 if (filter && filter->showCategories()) { 3755 if (filter && filter->showCategories()) {
3757 mEventEditor->setCategories(filter->categoryList().join(",") ); 3756 mEventEditor->setCategories(filter->categoryList().join(",") );
3758 } 3757 }
3759 if ( filter ) 3758 if ( filter )
3760 mEventEditor->setSecrecy( filter->getSecrecy() ); 3759 mEventEditor->setSecrecy( filter->getSecrecy() );
3761 } 3760 }
3762 mEventEditor->exec(); 3761 mEventEditor->exec();
3763 setActiveWindow(); 3762 setActiveWindow();
3764} 3763}
3765void CalendarView::todoAdded(Todo * t) 3764void CalendarView::todoAdded(Todo * t)
3766{ 3765{
3767 3766
3768 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3767 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3769 updateTodoViews(); 3768 updateTodoViews();
3770} 3769}
3771void CalendarView::todoChanged(Todo * t) 3770void CalendarView::todoChanged(Todo * t)
3772{ 3771{
3773 emit todoModified( t, 4 ); 3772 emit todoModified( t, 4 );
3774 // updateTodoViews(); 3773 // updateTodoViews();
3775} 3774}
3776void CalendarView::todoToBeDeleted(Todo *) 3775void CalendarView::todoToBeDeleted(Todo *)
3777{ 3776{
3778 //qDebug("todoToBeDeleted(Todo *) "); 3777 //qDebug("todoToBeDeleted(Todo *) ");
3779 updateTodoViews(); 3778 updateTodoViews();
3780} 3779}
3781void CalendarView::todoDeleted() 3780void CalendarView::todoDeleted()
3782{ 3781{
3783 //qDebug(" todoDeleted()"); 3782 //qDebug(" todoDeleted()");
3784 updateTodoViews(); 3783 updateTodoViews();
3785} 3784}
3786 3785
3787 3786
3788void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3787void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3789{ 3788{
3790 showTodoEditor(); 3789 showTodoEditor();
3791 mTodoEditor->newTodo(dt,0,allday); 3790 mTodoEditor->newTodo(dt,0,allday);
3792 if ( mFilterView->filtersEnabled() ) { 3791 if ( mFilterView->filtersEnabled() ) {
3793 CalFilter *filter = mFilterView->selectedFilter(); 3792 CalFilter *filter = mFilterView->selectedFilter();
3794 if (filter && filter->showCategories()) { 3793 if (filter && filter->showCategories()) {
3795 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3794 mTodoEditor->setCategories(filter->categoryList().join(",") );
3796 } 3795 }
3797 if ( filter ) 3796 if ( filter )
3798 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3797 mTodoEditor->setSecrecy( filter->getSecrecy() );
3799 } 3798 }
3800 mTodoEditor->exec(); 3799 mTodoEditor->exec();
3801 setActiveWindow(); 3800 setActiveWindow();
3802} 3801}
3803 3802
3804void CalendarView::newTodo() 3803void CalendarView::newTodo()
3805{ 3804{
3806 newTodoDateTime( QDateTime(),true ); 3805 newTodoDateTime( QDateTime(),true );
3807} 3806}
3808 3807
3809void CalendarView::newSubTodo() 3808void CalendarView::newSubTodo()
3810{ 3809{
3811 Todo *todo = selectedTodo(); 3810 Todo *todo = selectedTodo();
3812 if ( todo ) newSubTodo( todo ); 3811 if ( todo ) newSubTodo( todo );
3813} 3812}
3814 3813
3815void CalendarView::newSubTodo(Todo *parentEvent) 3814void CalendarView::newSubTodo(Todo *parentEvent)
3816{ 3815{
3817 3816
3818 showTodoEditor(); 3817 showTodoEditor();
3819 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3818 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3820 mTodoEditor->exec(); 3819 mTodoEditor->exec();
3821 setActiveWindow(); 3820 setActiveWindow();
3822} 3821}
3823 3822
3824void CalendarView::newFloatingEvent() 3823void CalendarView::newFloatingEvent()
3825{ 3824{
3826 DateList tmpList = mNavigator->selectedDates(); 3825 DateList tmpList = mNavigator->selectedDates();
3827 QDate date = tmpList.first(); 3826 QDate date = tmpList.first();
3828 3827
3829 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3828 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3830 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3829 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3831} 3830}
3832 3831
3833 3832
3834void CalendarView::editEvent( Event *event ) 3833void CalendarView::editEvent( Event *event )
3835{ 3834{
3836 3835
3837 if ( !event ) return; 3836 if ( !event ) return;
3838 if ( event->isReadOnly() ) { 3837 if ( event->isReadOnly() ) {
3839 showEvent( event ); 3838 showEvent( event );
3840 return; 3839 return;
3841 } 3840 }
3842 showEventEditor(); 3841 showEventEditor();
3843 mEventEditor->editEvent( event , mFlagEditDescription); 3842 mEventEditor->editEvent( event , mFlagEditDescription);
3844 mEventEditor->exec(); 3843 mEventEditor->exec();
3845 setActiveWindow(); 3844 setActiveWindow();
3846 3845
3847} 3846}
3848void CalendarView::editJournal( Journal *jour ) 3847void CalendarView::editJournal( Journal *jour )
3849{ 3848{
3850 if ( !jour ) return; 3849 if ( !jour ) return;
3851 mDialogManager->hideSearchDialog(); 3850 mDialogManager->hideSearchDialog();
3852 mViewManager->showJournalView(); 3851 mViewManager->showJournalView();
3853 mNavigator->slotDaySelect( jour->dtStart().date() ); 3852 mNavigator->slotDaySelect( jour->dtStart().date() );
3854} 3853}
3855void CalendarView::editTodo( Todo *todo ) 3854void CalendarView::editTodo( Todo *todo )
3856{ 3855{
3857 if ( !todo ) return; 3856 if ( !todo ) return;
3858 3857
3859 if ( todo->isReadOnly() ) { 3858 if ( todo->isReadOnly() ) {
3860 showTodo( todo ); 3859 showTodo( todo );
3861 return; 3860 return;
3862 } 3861 }
3863 showTodoEditor(); 3862 showTodoEditor();
3864 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3863 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3865 mTodoEditor->exec(); 3864 mTodoEditor->exec();
3866 setActiveWindow(); 3865 setActiveWindow();
3867 3866
3868} 3867}
3869 3868
3870KOEventViewerDialog* CalendarView::getEventViewerDialog() 3869KOEventViewerDialog* CalendarView::getEventViewerDialog()
3871{ 3870{
3872 if ( !mEventViewerDialog ) { 3871 if ( !mEventViewerDialog ) {
3873 mEventViewerDialog = new KOEventViewerDialog(0); 3872 mEventViewerDialog = new KOEventViewerDialog(0);
3874 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3873 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3875 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3874 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3876 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3875 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3877 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3876 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3878 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3877 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3879 viewManager(), SLOT( showAgendaView( bool ) ) ); 3878 viewManager(), SLOT( showAgendaView( bool ) ) );
3880 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3879 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3881 this, SLOT( slotViewerClosed() ) ); 3880 this, SLOT( slotViewerClosed() ) );
3882 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3881 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3883 this, SLOT( todoChanged(Todo *) ) ); 3882 this, SLOT( todoChanged(Todo *) ) );
3884 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3883 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3885 mEventViewerDialog->resize( 640, 480 ); 3884 mEventViewerDialog->resize( 640, 480 );
3886 3885
3887 } 3886 }
3888 return mEventViewerDialog; 3887 return mEventViewerDialog;
3889} 3888}
3890void CalendarView::showEvent(Event *event) 3889void CalendarView::showEvent(Event *event)
3891{ 3890{
3892 getEventViewerDialog()->setEvent(event); 3891 getEventViewerDialog()->setEvent(event);
3893 getEventViewerDialog()->showMe(); 3892 getEventViewerDialog()->showMe();
3894} 3893}
3895 3894
3896void CalendarView::showTodo(Todo *event) 3895void CalendarView::showTodo(Todo *event)
3897{ 3896{
3898 getEventViewerDialog()->setTodo(event); 3897 getEventViewerDialog()->setTodo(event);
3899 getEventViewerDialog()->showMe(); 3898 getEventViewerDialog()->showMe();
3900} 3899}
3901void CalendarView::showJournal( Journal *jour ) 3900void CalendarView::showJournal( Journal *jour )
3902{ 3901{
3903 getEventViewerDialog()->setJournal(jour); 3902 getEventViewerDialog()->setJournal(jour);
3904 getEventViewerDialog()->showMe(); 3903 getEventViewerDialog()->showMe();
3905 3904
3906} 3905}
3907// void CalendarView::todoModified (Todo *event, int changed) 3906// void CalendarView::todoModified (Todo *event, int changed)
3908// { 3907// {
3909// // if (mDialogList.find (event) != mDialogList.end ()) { 3908// // if (mDialogList.find (event) != mDialogList.end ()) {
3910// // kdDebug() << "Todo modified and open" << endl; 3909// // kdDebug() << "Todo modified and open" << endl;
3911// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3910// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3912// // temp->modified (changed); 3911// // temp->modified (changed);
3913 3912
3914// // } 3913// // }
3915 3914
3916// mViewManager->updateView(); 3915// mViewManager->updateView();
3917// } 3916// }
3918 3917
3919void CalendarView::appointment_show() 3918void CalendarView::appointment_show()
3920{ 3919{
3921 Event *anEvent = 0; 3920 Event *anEvent = 0;
3922 3921
3923 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3922 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3924 3923
3925 if (mViewManager->currentView()->isEventView()) { 3924 if (mViewManager->currentView()->isEventView()) {
3926 if ( incidence && incidence->typeID() == eventID ) { 3925 if ( incidence && incidence->typeID() == eventID ) {
3927 anEvent = static_cast<Event *>(incidence); 3926 anEvent = static_cast<Event *>(incidence);
3928 } 3927 }
3929 } 3928 }
3930 3929
3931 if (!anEvent) { 3930 if (!anEvent) {
3932 KNotifyClient::beep(); 3931 KNotifyClient::beep();
3933 return; 3932 return;
3934 } 3933 }
3935 3934
3936 showEvent(anEvent); 3935 showEvent(anEvent);
3937} 3936}
3938 3937
3939void CalendarView::appointment_edit() 3938void CalendarView::appointment_edit()
3940{ 3939{
3941 Event *anEvent = 0; 3940 Event *anEvent = 0;
3942 3941
3943 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3942 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3944 3943
3945 if (mViewManager->currentView()->isEventView()) { 3944 if (mViewManager->currentView()->isEventView()) {
3946 if ( incidence && incidence->typeID() == eventID ) { 3945 if ( incidence && incidence->typeID() == eventID ) {
3947 anEvent = static_cast<Event *>(incidence); 3946 anEvent = static_cast<Event *>(incidence);
3948 } 3947 }
3949 } 3948 }
3950 3949
3951 if (!anEvent) { 3950 if (!anEvent) {
3952 KNotifyClient::beep(); 3951 KNotifyClient::beep();
3953 return; 3952 return;
3954 } 3953 }
3955 3954
3956 editEvent(anEvent); 3955 editEvent(anEvent);
3957} 3956}
3958 3957
3959void CalendarView::appointment_delete() 3958void CalendarView::appointment_delete()
3960{ 3959{
3961 Event *anEvent = 0; 3960 Event *anEvent = 0;
3962 3961
3963 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3962 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3964 3963
3965 if (mViewManager->currentView()->isEventView()) { 3964 if (mViewManager->currentView()->isEventView()) {
3966 if ( incidence && incidence->typeID() == eventID ) { 3965 if ( incidence && incidence->typeID() == eventID ) {
3967 anEvent = static_cast<Event *>(incidence); 3966 anEvent = static_cast<Event *>(incidence);
3968 } 3967 }
3969 } 3968 }
3970 3969
3971 if (!anEvent) { 3970 if (!anEvent) {
3972 KNotifyClient::beep(); 3971 KNotifyClient::beep();
3973 return; 3972 return;
3974 } 3973 }
3975 3974
3976 deleteEvent(anEvent); 3975 deleteEvent(anEvent);
3977} 3976}
3978 3977
3979void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3978void CalendarView::todo_resub( Todo * parent, Todo * sub )
3980{ 3979{
3981 if (!sub) return; 3980 if (!sub) return;
3982 if ( sub->relatedTo() == parent ) 3981 if ( sub->relatedTo() == parent )
3983 return; 3982 return;
3984 sub->setRelatedTo(parent); 3983 sub->setRelatedTo(parent);
3985 sub->updated(); 3984 sub->updated();
3986 setModified(true); 3985 setModified(true);
3987 updateView(); 3986 updateView();
3988} 3987}
3989void CalendarView::todo_unsub(Todo *anTodo ) 3988void CalendarView::todo_unsub(Todo *anTodo )
3990{ 3989{
3991 todo_resub( 0, anTodo ); 3990 todo_resub( 0, anTodo );
3992} 3991}
3993 3992
3994void CalendarView::deleteTodo(Todo *todo) 3993void CalendarView::deleteTodo(Todo *todo)
3995{ 3994{
3996 if (!todo) { 3995 if (!todo) {
3997 KNotifyClient::beep(); 3996 KNotifyClient::beep();
3998 return; 3997 return;
3999 } 3998 }
4000 if (KOPrefs::instance()->mConfirm) { 3999 if (KOPrefs::instance()->mConfirm) {
4001 QString text = KGlobal::formatMessage ( todo->summary(),0 ); 4000 QString text = KGlobal::formatMessage ( todo->summary(),0 );
4002 if (!todo->relations().isEmpty()) { 4001 if (!todo->relations().isEmpty()) {
4003 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 4002 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
4004 4003
4005 } 4004 }
4006 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { 4005 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
4007 case KMessageBox::Continue: // OK 4006 case KMessageBox::Continue: // OK
4008 bool deleteT = false; 4007 bool deleteT = false;
4009 if (!todo->relations().isEmpty()) { 4008 if (!todo->relations().isEmpty()) {
4010 deleteT = removeCompletedSubTodos( todo ); 4009 deleteT = removeCompletedSubTodos( todo );
4011 } 4010 }
4012 // deleteT == true: todo already deleted in removeCompletedSubTodos 4011 // deleteT == true: todo already deleted in removeCompletedSubTodos
4013 if ( !deleteT ) { 4012 if ( !deleteT ) {
4014 checkExternalId( todo ); 4013 checkExternalId( todo );
4015 calendar()->deleteTodo(todo); 4014 calendar()->deleteTodo(todo);
4016 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4015 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4017 } 4016 }
4018 updateView(); 4017 updateView();
4019 break; 4018 break;
4020 } // switch 4019 } // switch
4021 } else { 4020 } else {
4022 checkExternalId( todo ); 4021 checkExternalId( todo );
4023 mCalendar->deleteTodo(todo); 4022 mCalendar->deleteTodo(todo);
4024 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4023 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4025 updateView(); 4024 updateView();
4026 } 4025 }
4027 4026
4028 emit updateSearchDialog(); 4027 emit updateSearchDialog();
4029} 4028}
4030void CalendarView::deleteJournal(Journal *jour) 4029void CalendarView::deleteJournal(Journal *jour)
4031{ 4030{
4032 if (!jour) { 4031 if (!jour) {
4033 KNotifyClient::beep(); 4032 KNotifyClient::beep();
4034 return; 4033 return;
4035 } 4034 }
4036 if (KOPrefs::instance()->mConfirm) { 4035 if (KOPrefs::instance()->mConfirm) {
4037 4036
4038 QString des; 4037 QString des;
4039 if ( !jour->summary().isEmpty() ) { 4038 if ( !jour->summary().isEmpty() ) {
4040 des = jour->summary(); 4039 des = jour->summary();
4041 } else { 4040 } else {
4042 des = jour->description().left(30); 4041 des = jour->description().left(30);
4043 des = des.simplifyWhiteSpace (); 4042 des = des.simplifyWhiteSpace ();
4044 des.replace (QRegExp ("\\n"),"" ); 4043 des.replace (QRegExp ("\\n"),"" );
4045 des.replace (QRegExp ("\\r"),"" ); 4044 des.replace (QRegExp ("\\r"),"" );
4046 } 4045 }
4047 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { 4046 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
4048 case KMessageBox::Continue: // OK 4047 case KMessageBox::Continue: // OK
4049 calendar()->deleteJournal(jour); 4048 calendar()->deleteJournal(jour);
4050 updateView(); 4049 updateView();
4051 break; 4050 break;
4052 } // switch 4051 } // switch
4053 } else { 4052 } else {
4054 calendar()->deleteJournal(jour);; 4053 calendar()->deleteJournal(jour);;
4055 updateView(); 4054 updateView();
4056 } 4055 }
4057 emit updateSearchDialog(); 4056 emit updateSearchDialog();
4058} 4057}
4059 4058
4060void CalendarView::deleteEvent(Event *anEvent) 4059void CalendarView::deleteEvent(Event *anEvent)
4061{ 4060{
4062 if (!anEvent) { 4061 if (!anEvent) {
4063 KNotifyClient::beep(); 4062 KNotifyClient::beep();
4064 return; 4063 return;
4065 } 4064 }
4066 4065
4067 if (anEvent->doesRecur()) { 4066 if (anEvent->doesRecur()) {
4068 QDate itemDate = mViewManager->currentSelectionDate(); 4067 QDate itemDate = mViewManager->currentSelectionDate();
4069 int km; 4068 int km;
4070 if (!itemDate.isValid()) { 4069 if (!itemDate.isValid()) {
4071 //kdDebug() << "Date Not Valid" << endl; 4070 //kdDebug() << "Date Not Valid" << endl;
4072 if (KOPrefs::instance()->mConfirm) { 4071 if (KOPrefs::instance()->mConfirm) {
4073 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4072 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4074 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 4073 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
4075 i18n("KO/Pi Confirmation"),i18n("Delete All")); 4074 i18n("KO/Pi Confirmation"),i18n("Delete All"));
4076 if ( km == KMessageBox::Continue ) 4075 if ( km == KMessageBox::Continue )
4077 km = KMessageBox::No; // No = all below 4076 km = KMessageBox::No; // No = all below
4078 } else 4077 } else
4079 km = KMessageBox::No; 4078 km = KMessageBox::No;
4080 } else { 4079 } else {
4081 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4080 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4082 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 4081 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
4083 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 4082 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
4084 i18n("KO/Pi Confirmation"),i18n("Current"), 4083 i18n("KO/Pi Confirmation"),i18n("Current"),
4085 i18n("All")); 4084 i18n("All"));
4086 } 4085 }
4087 switch(km) { 4086 switch(km) {
4088 4087
4089 case KMessageBox::No: // Continue // all 4088 case KMessageBox::No: // Continue // all
4090 //qDebug("KMessageBox::No "); 4089 //qDebug("KMessageBox::No ");
4091 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4090 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4092 schedule(Scheduler::Cancel,anEvent); 4091 schedule(Scheduler::Cancel,anEvent);
4093 4092
4094 checkExternalId( anEvent); 4093 checkExternalId( anEvent);
4095 mCalendar->deleteEvent(anEvent); 4094 mCalendar->deleteEvent(anEvent);
4096 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 4095 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
4097 break; 4096 break;
4098 4097
4099 // Disabled because it does not work 4098 // Disabled because it does not work
4100 //#if 0 4099 //#if 0
4101 case KMessageBox::Yes: // just this one 4100 case KMessageBox::Yes: // just this one
4102 //QDate qd = mNavigator->selectedDates().first(); 4101 //QDate qd = mNavigator->selectedDates().first();
4103 //if (!qd.isValid()) { 4102 //if (!qd.isValid()) {
4104 // kdDebug() << "no date selected, or invalid date" << endl; 4103 // kdDebug() << "no date selected, or invalid date" << endl;
4105 // KNotifyClient::beep(); 4104 // KNotifyClient::beep();
4106 // return; 4105 // return;
4107 //} 4106 //}
4108 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 4107 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
4109 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 4108 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
4110 anEvent->addExDate(itemDate); 4109 anEvent->addExDate(itemDate);
4111 int duration = anEvent->recurrence()->duration(); 4110 int duration = anEvent->recurrence()->duration();
4112 if ( duration > 0 ) { 4111 if ( duration > 0 ) {
4113 anEvent->recurrence()->setDuration( duration - 1 ); 4112 anEvent->recurrence()->setDuration( duration - 1 );
4114 } 4113 }
4115 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 4114 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
4116 } 4115 }
4117 break; 4116 break;
4118 //#endif 4117 //#endif
4119 } // switch 4118 } // switch
4120 } else { 4119 } else {
4121 if (KOPrefs::instance()->mConfirm) { 4120 if (KOPrefs::instance()->mConfirm) {
4122 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4121 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4123 i18n("\nAre you sure you want\nto delete this event?"), 4122 i18n("\nAre you sure you want\nto delete this event?"),
4124 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 4123 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
4125 case KMessageBox::Continue: // OK 4124 case KMessageBox::Continue: // OK
4126 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4125 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4127 schedule(Scheduler::Cancel,anEvent); 4126 schedule(Scheduler::Cancel,anEvent);
4128 checkExternalId( anEvent); 4127 checkExternalId( anEvent);
4129 mCalendar->deleteEvent(anEvent); 4128 mCalendar->deleteEvent(anEvent);
4130 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4129 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4131 break; 4130 break;
4132 } // switch 4131 } // switch
4133 } else { 4132 } else {
4134 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4133 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4135 schedule(Scheduler::Cancel,anEvent); 4134 schedule(Scheduler::Cancel,anEvent);
4136 checkExternalId( anEvent); 4135 checkExternalId( anEvent);
4137 mCalendar->deleteEvent(anEvent); 4136 mCalendar->deleteEvent(anEvent);
4138 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4137 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4139 } 4138 }
4140 } // if-else 4139 } // if-else
4141 emit updateSearchDialog(); 4140 emit updateSearchDialog();
4142} 4141}
4143 4142
4144bool CalendarView::deleteEvent(const QString &uid) 4143bool CalendarView::deleteEvent(const QString &uid)
4145{ 4144{
4146 Event *ev = mCalendar->event(uid); 4145 Event *ev = mCalendar->event(uid);
4147 if (ev) { 4146 if (ev) {
4148 deleteEvent(ev); 4147 deleteEvent(ev);
4149 return true; 4148 return true;
4150 } else { 4149 } else {
4151 return false; 4150 return false;
4152 } 4151 }
4153} 4152}
4154 4153
4155/*****************************************************************************/ 4154/*****************************************************************************/
4156 4155
4157void CalendarView::action_mail() 4156void CalendarView::action_mail()
4158{ 4157{
4159#ifndef KORG_NOMAIL 4158#ifndef KORG_NOMAIL
4160 KOMailClient mailClient; 4159 KOMailClient mailClient;
4161 4160
4162 Incidence *incidence = currentSelection(); 4161 Incidence *incidence = currentSelection();
4163 4162
4164 if (!incidence) { 4163 if (!incidence) {
4165 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4164 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4166 return; 4165 return;
4167 } 4166 }
4168 if(incidence->attendeeCount() == 0 ) { 4167 if(incidence->attendeeCount() == 0 ) {
4169 KMessageBox::sorry(this, 4168 KMessageBox::sorry(this,
4170 i18n("Can't generate mail:\nNo attendees defined.\n")); 4169 i18n("Can't generate mail:\nNo attendees defined.\n"));
4171 return; 4170 return;
4172 } 4171 }
4173 4172
4174 CalendarLocal cal_tmp; 4173 CalendarLocal cal_tmp;
4175 Event *event = 0; 4174 Event *event = 0;
4176 Event *ev = 0; 4175 Event *ev = 0;
4177 if ( incidence && incidence->typeID() == eventID ) { 4176 if ( incidence && incidence->typeID() == eventID ) {
4178 event = static_cast<Event *>(incidence); 4177 event = static_cast<Event *>(incidence);
4179 ev = new Event(*event); 4178 ev = new Event(*event);
4180 cal_tmp.addEvent(ev); 4179 cal_tmp.addEvent(ev);
4181 } 4180 }
4182 ICalFormat mForm(); 4181 ICalFormat mForm();
4183 QString attachment = mForm.toString( &cal_tmp ); 4182 QString attachment = mForm.toString( &cal_tmp );
4184 if (ev) delete(ev); 4183 if (ev) delete(ev);
4185 4184
4186 mailClient.mailAttendees(currentSelection(), attachment); 4185 mailClient.mailAttendees(currentSelection(), attachment);
4187 4186
4188#endif 4187#endif
4189 4188
4190#if 0 4189#if 0
4191 Event *anEvent = 0; 4190 Event *anEvent = 0;
4192 if (mViewManager->currentView()->isEventView()) { 4191 if (mViewManager->currentView()->isEventView()) {
4193 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 4192 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
4194 } 4193 }
4195 4194
4196 if (!anEvent) { 4195 if (!anEvent) {
4197 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4196 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4198 return; 4197 return;
4199 } 4198 }
4200 if(anEvent->attendeeCount() == 0 ) { 4199 if(anEvent->attendeeCount() == 0 ) {
4201 KMessageBox::sorry(this, 4200 KMessageBox::sorry(this,
4202 i18n("Can't generate mail:\nNo attendees defined.\n")); 4201 i18n("Can't generate mail:\nNo attendees defined.\n"));
4203 return; 4202 return;
4204 } 4203 }
4205 4204
4206 mailobject.emailEvent(anEvent); 4205 mailobject.emailEvent(anEvent);
4207#endif 4206#endif
4208} 4207}
4209 4208
4210 4209
4211void CalendarView::schedule_publish(Incidence *incidence) 4210void CalendarView::schedule_publish(Incidence *incidence)
4212{ 4211{
4213 Event *event = 0; 4212 Event *event = 0;
4214 Todo *todo = 0; 4213 Todo *todo = 0;
4215 4214
4216 if (incidence == 0) { 4215 if (incidence == 0) {
4217 incidence = mViewManager->currentView()->selectedIncidences().first(); 4216 incidence = mViewManager->currentView()->selectedIncidences().first();
4218 if (incidence == 0) { 4217 if (incidence == 0) {
4219 incidence = mTodoList->selectedIncidences().first(); 4218 incidence = mTodoList->selectedIncidences().first();
4220 } 4219 }
4221 } 4220 }
4222 if ( incidence && incidence->typeID() == eventID ) { 4221 if ( incidence && incidence->typeID() == eventID ) {
4223 event = static_cast<Event *>(incidence); 4222 event = static_cast<Event *>(incidence);
4224 } else { 4223 } else {
4225 if ( incidence && incidence->typeID() == todoID ) { 4224 if ( incidence && incidence->typeID() == todoID ) {
4226 todo = static_cast<Todo *>(incidence); 4225 todo = static_cast<Todo *>(incidence);
4227 } 4226 }
4228 } 4227 }
4229 4228
4230 if (!event && !todo) { 4229 if (!event && !todo) {
4231 KMessageBox::sorry(this,i18n("No event selected.")); 4230 KMessageBox::sorry(this,i18n("No event selected."));
4232 return; 4231 return;
4233 } 4232 }
4234 4233
4235 PublishDialog *publishdlg = new PublishDialog(); 4234 PublishDialog *publishdlg = new PublishDialog();
4236 if (incidence->attendeeCount()>0) { 4235 if (incidence->attendeeCount()>0) {
4237 QPtrList<Attendee> attendees = incidence->attendees(); 4236 QPtrList<Attendee> attendees = incidence->attendees();
4238 attendees.first(); 4237 attendees.first();
4239 while ( attendees.current()!=0 ) { 4238 while ( attendees.current()!=0 ) {
4240 publishdlg->addAttendee(attendees.current()); 4239 publishdlg->addAttendee(attendees.current());
4241 attendees.next(); 4240 attendees.next();
4242 } 4241 }
4243 } 4242 }
4244 bool send = true; 4243 bool send = true;
4245 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 4244 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
4246 if ( publishdlg->exec() != QDialog::Accepted ) 4245 if ( publishdlg->exec() != QDialog::Accepted )
4247 send = false; 4246 send = false;
4248 } 4247 }
4249 if ( send ) { 4248 if ( send ) {
4250 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4249 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4251 if ( event ) { 4250 if ( event ) {
4252 Event *ev = new Event(*event); 4251 Event *ev = new Event(*event);
4253 ev->registerObserver(0); 4252 ev->registerObserver(0);
4254 ev->clearAttendees(); 4253 ev->clearAttendees();
4255 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4254 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4256 delete(ev); 4255 delete(ev);
4257 } 4256 }
4258 } else { 4257 } else {
4259 if ( todo ) { 4258 if ( todo ) {
4260 Todo *ev = new Todo(*todo); 4259 Todo *ev = new Todo(*todo);
4261 ev->registerObserver(0); 4260 ev->registerObserver(0);
4262 ev->clearAttendees(); 4261 ev->clearAttendees();
4263 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4262 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4264 delete(ev); 4263 delete(ev);
4265 } 4264 }
4266 } 4265 }
4267 } 4266 }
4268 } 4267 }
4269 delete publishdlg; 4268 delete publishdlg;
4270} 4269}
4271 4270
4272void CalendarView::schedule_request(Incidence *incidence) 4271void CalendarView::schedule_request(Incidence *incidence)
4273{ 4272{
4274 schedule(Scheduler::Request,incidence); 4273 schedule(Scheduler::Request,incidence);
4275} 4274}
4276 4275
4277void CalendarView::schedule_refresh(Incidence *incidence) 4276void CalendarView::schedule_refresh(Incidence *incidence)
4278{ 4277{
4279 schedule(Scheduler::Refresh,incidence); 4278 schedule(Scheduler::Refresh,incidence);
4280} 4279}
4281 4280
4282void CalendarView::schedule_cancel(Incidence *incidence) 4281void CalendarView::schedule_cancel(Incidence *incidence)
4283{ 4282{
4284 schedule(Scheduler::Cancel,incidence); 4283 schedule(Scheduler::Cancel,incidence);
4285} 4284}
4286 4285
4287void CalendarView::schedule_add(Incidence *incidence) 4286void CalendarView::schedule_add(Incidence *incidence)
4288{ 4287{
4289 schedule(Scheduler::Add,incidence); 4288 schedule(Scheduler::Add,incidence);
4290} 4289}
4291 4290
4292void CalendarView::schedule_reply(Incidence *incidence) 4291void CalendarView::schedule_reply(Incidence *incidence)
4293{ 4292{
4294 schedule(Scheduler::Reply,incidence); 4293 schedule(Scheduler::Reply,incidence);
4295} 4294}
4296 4295
4297void CalendarView::schedule_counter(Incidence *incidence) 4296void CalendarView::schedule_counter(Incidence *incidence)
4298{ 4297{
4299 schedule(Scheduler::Counter,incidence); 4298 schedule(Scheduler::Counter,incidence);
4300} 4299}
4301 4300
4302void CalendarView::schedule_declinecounter(Incidence *incidence) 4301void CalendarView::schedule_declinecounter(Incidence *incidence)
4303{ 4302{
4304 schedule(Scheduler::Declinecounter,incidence); 4303 schedule(Scheduler::Declinecounter,incidence);
4305} 4304}
4306 4305
4307void CalendarView::schedule_publish_freebusy(int daysToPublish) 4306void CalendarView::schedule_publish_freebusy(int daysToPublish)
4308{ 4307{
4309 QDateTime start = QDateTime::currentDateTime(); 4308 QDateTime start = QDateTime::currentDateTime();
4310 QDateTime end = start.addDays(daysToPublish); 4309 QDateTime end = start.addDays(daysToPublish);
4311 4310
4312 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 4311 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
4313 freebusy->setOrganizer(KOPrefs::instance()->email()); 4312 freebusy->setOrganizer(KOPrefs::instance()->email());
4314 4313
4315 4314
4316 PublishDialog *publishdlg = new PublishDialog(); 4315 PublishDialog *publishdlg = new PublishDialog();
4317 if ( publishdlg->exec() == QDialog::Accepted ) { 4316 if ( publishdlg->exec() == QDialog::Accepted ) {
4318 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4317 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4319 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 4318 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
4320 delete(freebusy); 4319 delete(freebusy);
4321 } 4320 }
4322 } 4321 }
4323 delete publishdlg; 4322 delete publishdlg;
4324} 4323}
4325 4324
4326void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 4325void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
4327{ 4326{
4328 Event *event = 0; 4327 Event *event = 0;
4329 Todo *todo = 0; 4328 Todo *todo = 0;
4330 4329
4331 if (incidence == 0) { 4330 if (incidence == 0) {
4332 incidence = mViewManager->currentView()->selectedIncidences().first(); 4331 incidence = mViewManager->currentView()->selectedIncidences().first();
4333 if (incidence == 0) { 4332 if (incidence == 0) {
4334 incidence = mTodoList->selectedIncidences().first(); 4333 incidence = mTodoList->selectedIncidences().first();
4335 } 4334 }
4336 } 4335 }
4337 if ( incidence && incidence->typeID() == eventID ) { 4336 if ( incidence && incidence->typeID() == eventID ) {
4338 event = static_cast<Event *>(incidence); 4337 event = static_cast<Event *>(incidence);
4339 } 4338 }
4340 if ( incidence && incidence->typeID() == todoID ) { 4339 if ( incidence && incidence->typeID() == todoID ) {
4341 todo = static_cast<Todo *>(incidence); 4340 todo = static_cast<Todo *>(incidence);
4342 } 4341 }
4343 4342
4344 if (!event && !todo) { 4343 if (!event && !todo) {
4345 KMessageBox::sorry(this,i18n("No event selected.")); 4344 KMessageBox::sorry(this,i18n("No event selected."));
4346 return; 4345 return;
4347 } 4346 }
4348 4347
4349 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 4348 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
4350 KMessageBox::sorry(this,i18n("The event has no attendees.")); 4349 KMessageBox::sorry(this,i18n("The event has no attendees."));
4351 return; 4350 return;
4352 } 4351 }
4353 4352
4354 Event *ev = 0; 4353 Event *ev = 0;
4355 if (event) ev = new Event(*event); 4354 if (event) ev = new Event(*event);
4356 Todo *to = 0; 4355 Todo *to = 0;
4357 if (todo) to = new Todo(*todo); 4356 if (todo) to = new Todo(*todo);
4358 4357
4359 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4358 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4360 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4359 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4361 if (!me) { 4360 if (!me) {
4362 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4361 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4363 return; 4362 return;
4364 } 4363 }
4365 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4364 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4366 StatusDialog *statdlg = new StatusDialog(this); 4365 StatusDialog *statdlg = new StatusDialog(this);
4367 if (!statdlg->exec()==QDialog::Accepted) return; 4366 if (!statdlg->exec()==QDialog::Accepted) return;
4368 me->setStatus( statdlg->status() ); 4367 me->setStatus( statdlg->status() );
4369 delete(statdlg); 4368 delete(statdlg);
4370 } 4369 }
4371 Attendee *menew = new Attendee(*me); 4370 Attendee *menew = new Attendee(*me);
4372 if (ev) { 4371 if (ev) {
4373 ev->clearAttendees(); 4372 ev->clearAttendees();
4374 ev->addAttendee(menew,false); 4373 ev->addAttendee(menew,false);
4375 } else { 4374 } else {
4376 if (to) { 4375 if (to) {
4377 todo->clearAttendees(); 4376 todo->clearAttendees();
4378 todo->addAttendee(menew,false); 4377 todo->addAttendee(menew,false);
4379 } 4378 }
4380 } 4379 }
4381 } 4380 }
4382 4381
4383 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4382 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4384 if (ev) { 4383 if (ev) {
4385 if ( !dlg->addMessage(ev,method) ) delete(ev); 4384 if ( !dlg->addMessage(ev,method) ) delete(ev);
4386 } else { 4385 } else {
4387 if (to) { 4386 if (to) {
4388 if ( !dlg->addMessage(to,method) ) delete(to); 4387 if ( !dlg->addMessage(to,method) ) delete(to);
4389 } 4388 }
4390 } 4389 }
4391} 4390}
4392 4391
4393void CalendarView::openAddressbook() 4392void CalendarView::openAddressbook()
4394{ 4393{
4395 KRun::runCommand("kaddressbook"); 4394 KRun::runCommand("kaddressbook");
4396} 4395}
4397 4396
4398void CalendarView::setModified(bool modified) 4397void CalendarView::setModified(bool modified)
4399{ 4398{
4400 //qDebug("CalendarView::setModified %d ", modified); 4399 //qDebug("CalendarView::setModified %d ", modified);
4401 if ( modified ) 4400 if ( modified )
4402 emit signalmodified(); 4401 emit signalmodified();
4403 mModified = modified; 4402 mModified = modified;
4404 if ( mModified ) 4403 if ( mModified )
4405 emit modifiedChanged(mModified); 4404 emit modifiedChanged(mModified);
4406 4405
4407} 4406}
4408 4407
4409bool CalendarView::isReadOnly() 4408bool CalendarView::isReadOnly()
4410{ 4409{
4411 return mReadOnly; 4410 return mReadOnly;
4412} 4411}
4413 4412
4414void CalendarView::setReadOnly(bool readOnly) 4413void CalendarView::setReadOnly(bool readOnly)
4415{ 4414{
4416 if (mReadOnly != readOnly) { 4415 if (mReadOnly != readOnly) {
4417 mReadOnly = readOnly; 4416 mReadOnly = readOnly;
4418 emit readOnlyChanged(mReadOnly); 4417 emit readOnlyChanged(mReadOnly);
4419 } 4418 }
4420} 4419}
4421 4420
4422bool CalendarView::isModified() 4421bool CalendarView::isModified()
4423{ 4422{
4424 return mModified; 4423 return mModified;
4425} 4424}
4426void CalendarView::slotprintSelInc() 4425void CalendarView::slotprintSelInc()
4427{ 4426{
4428 if ( currentSelection() == 0 ) { 4427 if ( currentSelection() == 0 ) {
4429 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4428 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4430 return; 4429 return;
4431 } 4430 }
4432 showIncidence(); 4431 showIncidence();
4433 getEventViewerDialog()->print(); 4432 getEventViewerDialog()->print();
4434 4433
4435} 4434}
4436void CalendarView::printSetup() 4435void CalendarView::printSetup()
4437{ 4436{
4438#ifndef KORG_NOPRINTER 4437#ifndef KORG_NOPRINTER
4439 createPrinter(); 4438 createPrinter();
4440 4439
4441 mCalPrinter->setupPrinter(); 4440 mCalPrinter->setupPrinter();
4442#endif 4441#endif
4443} 4442}
4444 4443
4445void CalendarView::print() 4444void CalendarView::print()
4446{ 4445{
4447#ifndef KORG_NOPRINTER 4446#ifndef KORG_NOPRINTER
4448 createPrinter(); 4447 createPrinter();
4449 4448
4450 DateList tmpDateList = mNavigator->selectedDates(); 4449 DateList tmpDateList = mNavigator->selectedDates();
4451 mCalPrinter->print(CalPrinter::Month, 4450 mCalPrinter->print(CalPrinter::Month,
4452 tmpDateList.first(), tmpDateList.last()); 4451 tmpDateList.first(), tmpDateList.last());
4453#endif 4452#endif
4454} 4453}
4455 4454
4456void CalendarView::printPreview() 4455void CalendarView::printPreview()
4457{ 4456{
4458#ifndef KORG_NOPRINTER 4457#ifndef KORG_NOPRINTER
4459 kdDebug() << "CalendarView::printPreview()" << endl; 4458 kdDebug() << "CalendarView::printPreview()" << endl;
4460 4459
4461 createPrinter(); 4460 createPrinter();
4462 4461
4463 DateList tmpDateList = mNavigator->selectedDates(); 4462 DateList tmpDateList = mNavigator->selectedDates();
4464 4463
4465 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 4464 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
4466 tmpDateList.last()); 4465 tmpDateList.last());
4467#endif 4466#endif
4468} 4467}
4469bool CalendarView::exportICalendar( QString filename ) 4468bool CalendarView::exportICalendar( QString filename )
4470{ 4469{
4471 // Force correct extension 4470 // Force correct extension
4472 if (filename.right(4) != ".ics") filename += ".ics"; 4471 if (filename.right(4) != ".ics") filename += ".ics";
4473 4472
4474 FileStorage storage( mCalendar, filename, new ICalFormat() ); 4473 FileStorage storage( mCalendar, filename, new ICalFormat() );
4475 return storage.save(); 4474 return storage.save();
4476} 4475}
4477 4476
4478bool CalendarView::exportICalendar() 4477bool CalendarView::exportICalendar()
4479{ 4478{
4480 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); 4479 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) );
4481} 4480}
4482 4481
4483bool CalendarView::exportVCalendar( QString filename ) 4482bool CalendarView::exportVCalendar( QString filename )
4484{ 4483{
4485 if (mCalendar->journals().count() > 0) { 4484 if (mCalendar->journals().count() > 0) {
4486 int result = KMessageBox::warningContinueCancel(this, 4485 int result = KMessageBox::warningContinueCancel(this,
4487 i18n("The journal entries can not be\nexported to a vCalendar file."), 4486 i18n("The journal entries can not be\nexported to a vCalendar file."),
4488 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 4487 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
4489 true); 4488 true);
4490 if (result != KMessageBox::Continue) return false; 4489 if (result != KMessageBox::Continue) return false;
4491 } 4490 }
4492 4491
4493 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 4492 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
4494 4493
4495 // Force correct extension 4494 // Force correct extension
4496 if (filename.right(4) != ".vcs") filename += ".vcs"; 4495 if (filename.right(4) != ".vcs") filename += ".vcs";
4497 4496
4498 FileStorage storage( mCalendar, filename, new VCalFormat ); 4497 FileStorage storage( mCalendar, filename, new VCalFormat );
4499 return storage.save(); 4498 return storage.save();
4500 4499
4501} 4500}
4502 4501
4503void CalendarView::eventUpdated(Incidence *) 4502void CalendarView::eventUpdated(Incidence *)
4504{ 4503{
4505 setModified(); 4504 setModified();
4506 // Don't call updateView here. The code, which has caused the update of the 4505 // Don't call updateView here. The code, which has caused the update of the
4507 // event is responsible for updating the view. 4506 // event is responsible for updating the view.
4508 // updateView(); 4507 // updateView();
4509} 4508}
4510 4509
4511void CalendarView::adaptNavigationUnits() 4510void CalendarView::adaptNavigationUnits()
4512{ 4511{
4513 if (mViewManager->currentView()->isEventView()) { 4512 if (mViewManager->currentView()->isEventView()) {
4514 int days = mViewManager->currentView()->currentDateCount(); 4513 int days = mViewManager->currentView()->currentDateCount();
4515 if (days == 1) { 4514 if (days == 1) {
4516 emit changeNavStringPrev(i18n("&Previous Day")); 4515 emit changeNavStringPrev(i18n("&Previous Day"));
4517 emit changeNavStringNext(i18n("&Next Day")); 4516 emit changeNavStringNext(i18n("&Next Day"));
4518 } else { 4517 } else {
4519 emit changeNavStringPrev(i18n("&Previous Week")); 4518 emit changeNavStringPrev(i18n("&Previous Week"));
4520 emit changeNavStringNext(i18n("&Next Week")); 4519 emit changeNavStringNext(i18n("&Next Week"));
4521 } 4520 }
4522 } 4521 }
4523} 4522}
4524 4523
4525void CalendarView::processMainViewSelection( Incidence *incidence ) 4524void CalendarView::processMainViewSelection( Incidence *incidence )
4526{ 4525{
4527 if ( incidence ) mTodoList->clearSelection(); 4526 if ( incidence ) mTodoList->clearSelection();
4528 processIncidenceSelection( incidence ); 4527 processIncidenceSelection( incidence );
4529} 4528}
4530 4529
4531void CalendarView::processTodoListSelection( Incidence *incidence ) 4530void CalendarView::processTodoListSelection( Incidence *incidence )
4532{ 4531{
4533 if ( incidence && mViewManager->currentView() ) { 4532 if ( incidence && mViewManager->currentView() ) {
4534 mViewManager->currentView()->clearSelection(); 4533 mViewManager->currentView()->clearSelection();
4535 } 4534 }
4536 processIncidenceSelection( incidence ); 4535 processIncidenceSelection( incidence );
4537} 4536}
4538 4537
4539void CalendarView::processIncidenceSelection( Incidence *incidence ) 4538void CalendarView::processIncidenceSelection( Incidence *incidence )
4540{ 4539{
4541 emit incidenceSelected( incidence ); 4540 emit incidenceSelected( incidence );
4542 if ( incidence == mSelectedIncidence ) return; 4541 if ( incidence == mSelectedIncidence ) return;
4543 mSelectedIncidence = incidence; 4542 mSelectedIncidence = incidence;
4544 4543
4545 if ( incidence && incidence->typeID() == eventID ) { 4544 if ( incidence && incidence->typeID() == eventID ) {
4546 Event *event = static_cast<Event *>( incidence ); 4545 Event *event = static_cast<Event *>( incidence );
4547 if ( event->organizer() == KOPrefs::instance()->email() ) { 4546 if ( event->organizer() == KOPrefs::instance()->email() ) {
4548 emit organizerEventsSelected( true ); 4547 emit organizerEventsSelected( true );
4549 } else { 4548 } else {
4550 emit organizerEventsSelected(false); 4549 emit organizerEventsSelected(false);
4551 } 4550 }
4552 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4551 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4553 KOPrefs::instance()->email() ) ) { 4552 KOPrefs::instance()->email() ) ) {
4554 emit groupEventsSelected( true ); 4553 emit groupEventsSelected( true );
4555 } else { 4554 } else {
4556 emit groupEventsSelected(false); 4555 emit groupEventsSelected(false);
4557 } 4556 }
4558 return; 4557 return;
4559 } else { 4558 } else {
4560 if ( incidence && incidence->typeID() == todoID ) { 4559 if ( incidence && incidence->typeID() == todoID ) {
4561 emit todoSelected( true ); 4560 emit todoSelected( true );
4562 Todo *event = static_cast<Todo *>( incidence ); 4561 Todo *event = static_cast<Todo *>( incidence );
4563 if ( event->organizer() == KOPrefs::instance()->email() ) { 4562 if ( event->organizer() == KOPrefs::instance()->email() ) {
4564 emit organizerEventsSelected( true ); 4563 emit organizerEventsSelected( true );
4565 } else { 4564 } else {
4566 emit organizerEventsSelected(false); 4565 emit organizerEventsSelected(false);
4567 } 4566 }
4568 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4567 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4569 KOPrefs::instance()->email() ) ) { 4568 KOPrefs::instance()->email() ) ) {
4570 emit groupEventsSelected( true ); 4569 emit groupEventsSelected( true );
4571 } else { 4570 } else {
4572 emit groupEventsSelected(false); 4571 emit groupEventsSelected(false);
4573 } 4572 }
4574 return; 4573 return;
4575 } else { 4574 } else {
4576 emit todoSelected( false ); 4575 emit todoSelected( false );
4577 emit organizerEventsSelected(false); 4576 emit organizerEventsSelected(false);
4578 emit groupEventsSelected(false); 4577 emit groupEventsSelected(false);
4579 } 4578 }
4580 return; 4579 return;
4581 } 4580 }
4582 4581
4583 /* if ( incidence && incidence->typeID() == todoID ) { 4582 /* if ( incidence && incidence->typeID() == todoID ) {
4584 emit todoSelected( true ); 4583 emit todoSelected( true );
4585 } else { 4584 } else {
4586 emit todoSelected( false ); 4585 emit todoSelected( false );
4587 }*/ 4586 }*/
4588} 4587}
4589 4588
4590 4589
4591void CalendarView::checkClipboard() 4590void CalendarView::checkClipboard()
4592{ 4591{
4593#ifndef KORG_NODND 4592#ifndef KORG_NODND
4594 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4593 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4595 emit pasteEnabled(true); 4594 emit pasteEnabled(true);
4596 } else { 4595 } else {
4597 emit pasteEnabled(false); 4596 emit pasteEnabled(false);
4598 } 4597 }
4599#endif 4598#endif
4600} 4599}
4601 4600
4602void CalendarView::showDates(const DateList &selectedDates) 4601void CalendarView::showDates(const DateList &selectedDates)
4603{ 4602{
4604 // kdDebug() << "CalendarView::selectDates()" << endl; 4603 // kdDebug() << "CalendarView::selectDates()" << endl;
4605 4604
4606 4605
4607 if ( !mBlockShowDates ) { 4606 if ( !mBlockShowDates ) {
4608 if ( mViewManager->currentView() ) { 4607 if ( mViewManager->currentView() ) {
4609 updateView( selectedDates.first(), selectedDates.last() ); 4608 updateView( selectedDates.first(), selectedDates.last() );
4610 } else { 4609 } else {
4611 mViewManager->showAgendaView(); 4610 mViewManager->showAgendaView();
4612 } 4611 }
4613 } 4612 }
4614 4613
4615 QDate date = selectedDates.first(); 4614 QDate date = selectedDates.first();
4616 if ( ! date.isValid() ) { 4615 if ( ! date.isValid() ) {
4617 topLevelWidget()->setCaption(""); 4616 topLevelWidget()->setCaption("");
4618 return; 4617 return;
4619 } 4618 }
4620 4619
4621 QString selDates; 4620 QString selDates;
4622 selDates = KGlobal::locale()->formatDate( date, true); 4621 selDates = KGlobal::locale()->formatDate( date, true);
4623 if (selectedDates.first() < selectedDates.last() ) 4622 if (selectedDates.first() < selectedDates.last() )
4624 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4623 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4625 else { 4624 else {
4626 QString addString; 4625 QString addString;
4627 if ( date == QDateTime::currentDateTime().date() ) 4626 if ( date == QDateTime::currentDateTime().date() )
4628 addString = i18n("Today"); 4627 addString = i18n("Today");
4629 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4628 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4630 addString = i18n("Tomorrow"); 4629 addString = i18n("Tomorrow");
4631 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4630 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4632 addString = i18n("Yesterday"); 4631 addString = i18n("Yesterday");
4633 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4632 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4634 addString = i18n("Day before yesterday"); 4633 addString = i18n("Day before yesterday");
4635 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4634 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4636 addString = i18n("Day after tomorrow"); 4635 addString = i18n("Day after tomorrow");
4637 if ( !addString.isEmpty() ) { 4636 if ( !addString.isEmpty() ) {
4638 topLevelWidget()->setCaption( addString+", " + selDates ); 4637 topLevelWidget()->setCaption( addString+", " + selDates );
4639 return; 4638 return;
4640 } 4639 }
4641 } 4640 }
4642 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4641 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4643 4642
4644} 4643}
4645 4644
4646QPtrList<CalFilter> CalendarView::filters() 4645QPtrList<CalFilter> CalendarView::filters()
4647{ 4646{
4648 return mFilters; 4647 return mFilters;
4649 4648
4650} 4649}
4651void CalendarView::editFilters() 4650void CalendarView::editFilters()
4652{ 4651{
4653 // kdDebug() << "CalendarView::editFilters()" << endl; 4652 // kdDebug() << "CalendarView::editFilters()" << endl;
4654 4653
4655 CalFilter *filter = mFilters.first(); 4654 CalFilter *filter = mFilters.first();
4656 while(filter) { 4655 while(filter) {
4657 filter = mFilters.next(); 4656 filter = mFilters.next();
4658 } 4657 }
4659 4658
4660 mDialogManager->showFilterEditDialog(&mFilters); 4659 mDialogManager->showFilterEditDialog(&mFilters);
4661 updateFilter(); 4660 updateFilter();
4662} 4661}
4663void CalendarView::toggleFilter() 4662void CalendarView::toggleFilter()
4664{ 4663{
4665 if ( mLeftFrame->isHidden() ) { 4664 if ( mLeftFrame->isHidden() ) {
4666 toggleExpand(); 4665 toggleExpand();
4667 showFilter( true ); 4666 showFilter( true );
4668 } else 4667 } else
4669 showFilter(! mCalEditView->isVisible()); 4668 showFilter(! mCalEditView->isVisible());
4670} 4669}
4671 4670
4672KOFilterView *CalendarView::filterView() 4671KOFilterView *CalendarView::filterView()
4673{ 4672{
4674 return mFilterView; 4673 return mFilterView;
4675} 4674}
4676void CalendarView::selectFilter( int fil ) 4675void CalendarView::selectFilter( int fil )
4677{ 4676{
4678 mFilterView->setSelectedFilter( fil ); 4677 mFilterView->setSelectedFilter( fil );
4679 updateUnmanagedViews(); 4678 updateUnmanagedViews();
4680} 4679}
4681void CalendarView::showFilter(bool visible) 4680void CalendarView::showFilter(bool visible)
4682{ 4681{
4683#if 1 4682#if 1
4684 if (visible) { 4683 if (visible) {
4685 mCalEditView->readConfig(); 4684 mCalEditView->readConfig();
4686 mCalEditView->show(); 4685 mCalEditView->show();
4687 QValueList<int> sizes; 4686 QValueList<int> sizes;
4688 sizes = mLeftFrame->sizes(); 4687 sizes = mLeftFrame->sizes();
4689 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4688 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4690 sizes.clear(); 4689 sizes.clear();
4691 sizes << 100; 4690 sizes << 100;
4692 sizes << 0; 4691 sizes << 0;
4693 sizes << 0; 4692 sizes << 0;
4694 sizes << 100; 4693 sizes << 100;
4695 mLeftFrame->setSizes(sizes); 4694 mLeftFrame->setSizes(sizes);
4696 } 4695 }
4697#if 0 4696#if 0
4698 sizes = mLeftFrame->sizes(); 4697 sizes = mLeftFrame->sizes();
4699 int ccc = 0; 4698 int ccc = 0;
4700 while ( ccc < sizes.count()) { 4699 while ( ccc < sizes.count()) {
4701 qDebug("size %d %d ", ccc, sizes[ccc]); 4700 qDebug("size %d %d ", ccc, sizes[ccc]);
4702 ++ccc; 4701 ++ccc;
4703 } 4702 }
4704#endif 4703#endif
4705 4704
4706 } 4705 }
4707 else { 4706 else {
4708 mCalEditView->hide(); 4707 mCalEditView->hide();
4709 } 4708 }
4710#else 4709#else
4711 if (visible) mFilterView->show(); 4710 if (visible) mFilterView->show();
4712 else mFilterView->hide(); 4711 else mFilterView->hide();
4713#endif 4712#endif
4714} 4713}
4715void CalendarView::toggleFilerEnabled( ) 4714void CalendarView::toggleFilerEnabled( )
4716{ 4715{
4717 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4716 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4718 if ( !mFilterView->filtersEnabled() ) 4717 if ( !mFilterView->filtersEnabled() )
4719 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4718 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4720 updateUnmanagedViews(); 4719 updateUnmanagedViews();
4721 4720
4722} 4721}
4723void CalendarView::updateFilter() 4722void CalendarView::updateFilter()
4724{ 4723{
4725 CalFilter *filter = mFilterView->selectedFilter(); 4724 CalFilter *filter = mFilterView->selectedFilter();
4726 if (filter) { 4725 if (filter) {
4727 QString mess; 4726 QString mess;
4728 if (mFilterView->filtersEnabled()) { 4727 if (mFilterView->filtersEnabled()) {
4729 mess = i18n("Filter selected: ")+filter->name(); 4728 mess = i18n("Filter selected: ")+filter->name();
4730 filter->setEnabled(true); 4729 filter->setEnabled(true);
4731 } 4730 }
4732 else filter->setEnabled(false); 4731 else filter->setEnabled(false);
4733 mCalendar->setFilter(filter); 4732 mCalendar->setFilter(filter);
4734 updateView(); 4733 updateView();
4735 if ( !mess.isEmpty() ) 4734 if ( !mess.isEmpty() )
4736 topLevelWidget()->setCaption( mess ); 4735 topLevelWidget()->setCaption( mess );
4737 4736
4738 } 4737 }
4739 emit filtersUpdated(); 4738 emit filtersUpdated();
4740} 4739}
4741 4740
4742void CalendarView::filterEdited() 4741void CalendarView::filterEdited()
4743{ 4742{
4744 mFilterView->updateFilters(); 4743 mFilterView->updateFilters();
4745 updateFilter(); 4744 updateFilter();
4746 writeSettings(); 4745 writeSettings();
4747} 4746}
4748 4747
4749 4748
4750void CalendarView::takeOverEvent() 4749void CalendarView::takeOverEvent()
4751{ 4750{
4752 Incidence *incidence = currentSelection(); 4751 Incidence *incidence = currentSelection();
4753 4752
4754 if (!incidence) return; 4753 if (!incidence) return;
4755 4754
4756 incidence->setOrganizer(KOPrefs::instance()->email()); 4755 incidence->setOrganizer(KOPrefs::instance()->email());
4757 incidence->recreate(); 4756 incidence->recreate();
4758 incidence->setReadOnly(false); 4757 incidence->setReadOnly(false);
4759 4758
4760 updateView(); 4759 updateView();
4761} 4760}
4762 4761
4763void CalendarView::takeOverCalendar() 4762void CalendarView::takeOverCalendar()
4764{ 4763{
4765 // TODO: Create Calendar::allIncidences() function and use it here 4764 // TODO: Create Calendar::allIncidences() function and use it here
4766 4765
4767 clearAllViews(); 4766 clearAllViews();
4768 QPtrList<Event> events = mCalendar->events(); 4767 QPtrList<Event> events = mCalendar->events();
4769 for(uint i=0; i<events.count(); ++i) { 4768 for(uint i=0; i<events.count(); ++i) {
4770 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4769 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4771 events.at(i)->recreate(); 4770 events.at(i)->recreate();
4772 events.at(i)->setReadOnly(false); 4771 events.at(i)->setReadOnly(false);
4773 } 4772 }
4774 4773
4775 QPtrList<Todo> todos = mCalendar->todos(); 4774 QPtrList<Todo> todos = mCalendar->todos();
4776 for(uint i=0; i<todos.count(); ++i) { 4775 for(uint i=0; i<todos.count(); ++i) {
4777 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4776 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4778 todos.at(i)->recreate(); 4777 todos.at(i)->recreate();
4779 todos.at(i)->setReadOnly(false); 4778 todos.at(i)->setReadOnly(false);
4780 } 4779 }
4781 4780
4782 QPtrList<Journal> journals = mCalendar->journals(); 4781 QPtrList<Journal> journals = mCalendar->journals();
4783 for(uint i=0; i<journals.count(); ++i) { 4782 for(uint i=0; i<journals.count(); ++i) {
4784 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4783 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4785 journals.at(i)->recreate(); 4784 journals.at(i)->recreate();
4786 journals.at(i)->setReadOnly(false); 4785 journals.at(i)->setReadOnly(false);
4787 } 4786 }
4788 4787
4789 updateView(); 4788 updateView();
4790} 4789}
4791 4790
4792void CalendarView::showIntro() 4791void CalendarView::showIntro()
4793{ 4792{
4794 kdDebug() << "To be implemented." << endl; 4793 kdDebug() << "To be implemented." << endl;
4795} 4794}
4796 4795
4797QWidgetStack *CalendarView::viewStack() 4796QWidgetStack *CalendarView::viewStack()
4798{ 4797{
4799 return mRightFrame; 4798 return mRightFrame;
4800} 4799}
4801 4800
4802QWidget *CalendarView::leftFrame() 4801QWidget *CalendarView::leftFrame()
4803{ 4802{
4804 return ( QWidget *)mLeftFrame; 4803 return ( QWidget *)mLeftFrame;
4805} 4804}
4806 4805
4807DateNavigator *CalendarView::dateNavigator() 4806DateNavigator *CalendarView::dateNavigator()
4808{ 4807{
4809 return mNavigator; 4808 return mNavigator;
4810} 4809}
4811 4810
4812KDateNavigator* CalendarView::dateNavigatorWidget() 4811KDateNavigator* CalendarView::dateNavigatorWidget()
4813{ 4812{
4814 return mDateNavigator->navigatorView(); 4813 return mDateNavigator->navigatorView();
4815} 4814}
4816void CalendarView::toggleDateNavigatorWidget() 4815void CalendarView::toggleDateNavigatorWidget()
4817{ 4816{
4818 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4817 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4819 4818
4820 if (!KOPrefs::instance()->mShowDateNavigator ) 4819 if (!KOPrefs::instance()->mShowDateNavigator )
4821 mDateNavigator->hide(); 4820 mDateNavigator->hide();
4822 else 4821 else
4823 mDateNavigator->show(); 4822 mDateNavigator->show();
4824} 4823}
4825void CalendarView::addView(KOrg::BaseView *view) 4824void CalendarView::addView(KOrg::BaseView *view)
4826{ 4825{
4827 mViewManager->addView(view); 4826 mViewManager->addView(view);
4828} 4827}
4829 4828
4830void CalendarView::showView(KOrg::BaseView *view) 4829void CalendarView::showView(KOrg::BaseView *view)
4831{ 4830{
4832 mViewManager->showView(view, mLeftFrame->isVisible()); 4831 mViewManager->showView(view, mLeftFrame->isVisible());
4833} 4832}
4834 4833
4835Incidence *CalendarView::currentSelection() 4834Incidence *CalendarView::currentSelection()
4836{ 4835{
4837 return mViewManager->currentSelection(); 4836 return mViewManager->currentSelection();
4838} 4837}
4839void CalendarView::toggleAllDaySize() 4838void CalendarView::toggleAllDaySize()
4840{ 4839{
4841 /* 4840 /*
4842 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4841 if ( KOPrefs::instance()->mAllDaySize > 47 )
4843 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4842 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4844 else 4843 else
4845 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4844 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4846 */ 4845 */
4847 viewManager()->agendaView()->toggleAllDay(); 4846 viewManager()->agendaView()->toggleAllDay();
4848} 4847}
4849void CalendarView::toggleExpand() 4848void CalendarView::toggleExpand()
4850{ 4849{
4851 // if ( mLeftFrame->isHidden() ) { 4850 // if ( mLeftFrame->isHidden() ) {
4852 // mLeftFrame->show(); 4851 // mLeftFrame->show();
4853 // emit calendarViewExpanded( false ); 4852 // emit calendarViewExpanded( false );
4854 // } else { 4853 // } else {
4855 // mLeftFrame->hide(); 4854 // mLeftFrame->hide();
4856 // emit calendarViewExpanded( true ); 4855 // emit calendarViewExpanded( true );
4857 // } 4856 // }
4858 //qDebug(" CalendarView::toggleExpand()"); 4857 //qDebug(" CalendarView::toggleExpand()");
4859 globalFlagBlockAgenda = 1; 4858 globalFlagBlockAgenda = 1;
4860 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4859 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4861 globalFlagBlockAgenda = 5; 4860 globalFlagBlockAgenda = 5;
4862 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4861 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4863 //mViewManager->showView( 0, true ); 4862 //mViewManager->showView( 0, true );
4864} 4863}
4865 4864
4866void CalendarView::calendarModified( bool modified, Calendar * ) 4865void CalendarView::calendarModified( bool modified, Calendar * )
4867{ 4866{
4868 setModified( modified ); 4867 setModified( modified );
4869} 4868}
4870 4869
4871Todo *CalendarView::selectedTodo() 4870Todo *CalendarView::selectedTodo()
4872{ 4871{
4873 Incidence *incidence = currentSelection(); 4872 Incidence *incidence = currentSelection();
4874 if ( incidence && incidence->typeID() == todoID ) { 4873 if ( incidence && incidence->typeID() == todoID ) {
4875 return static_cast<Todo *>( incidence ); 4874 return static_cast<Todo *>( incidence );
4876 } 4875 }
4877 4876
4878 incidence = mTodoList->selectedIncidences().first(); 4877 incidence = mTodoList->selectedIncidences().first();
4879 if ( incidence && incidence->typeID() == todoID ) { 4878 if ( incidence && incidence->typeID() == todoID ) {
4880 return static_cast<Todo *>( incidence ); 4879 return static_cast<Todo *>( incidence );
4881 } 4880 }
4882 4881
4883 return 0; 4882 return 0;
4884} 4883}
4885 4884
4886void CalendarView::showIncidence() 4885void CalendarView::showIncidence()
4887{ 4886{
4888 mViewerCallerIsSearchDialog = false; 4887 mViewerCallerIsSearchDialog = false;
4889 Incidence *incidence = currentSelection(); 4888 Incidence *incidence = currentSelection();
4890 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4889 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4891 if ( incidence ) { 4890 if ( incidence ) {
4892 ShowIncidenceVisitor v; 4891 ShowIncidenceVisitor v;
4893 v.act( incidence, this ); 4892 v.act( incidence, this );
4894 } 4893 }
4895} 4894}
4896void CalendarView::editIncidenceDescription() 4895void CalendarView::editIncidenceDescription()
4897{ 4896{
4898 mFlagEditDescription = true; 4897 mFlagEditDescription = true;
4899 editIncidence(); 4898 editIncidence();
4900 mFlagEditDescription = false; 4899 mFlagEditDescription = false;
4901} 4900}
4902void CalendarView::editIncidence() 4901void CalendarView::editIncidence()
4903{ 4902{
4904 // qDebug("editIncidence() "); 4903 // qDebug("editIncidence() ");
4905 Incidence *incidence = currentSelection(); 4904 Incidence *incidence = currentSelection();
4906 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4905 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4907 if ( incidence ) { 4906 if ( incidence ) {
4908 EditIncidenceVisitor v; 4907 EditIncidenceVisitor v;
4909 v.act( incidence, this ); 4908 v.act( incidence, this );
4910 } 4909 }
4911} 4910}
4912 4911
4913void CalendarView::deleteIncidence() 4912void CalendarView::deleteIncidence()
4914{ 4913{
4915 Incidence *incidence = currentSelection(); 4914 Incidence *incidence = currentSelection();
4916 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4915 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4917 if ( incidence ) { 4916 if ( incidence ) {
4918 deleteIncidence(incidence); 4917 deleteIncidence(incidence);
4919 } 4918 }
4920} 4919}
4921void CalendarView::showIncidence(QString uid) 4920void CalendarView::showIncidence(QString uid)
4922{ 4921{
4923 Incidence *inc = mCalendar->incidence( uid ); 4922 Incidence *inc = mCalendar->incidence( uid );
4924 if ( inc ) 4923 if ( inc )
4925 showIncidence( inc ); 4924 showIncidence( inc );
4926} 4925}
4927void CalendarView::showIncidence(Incidence *incidence) 4926void CalendarView::showIncidence(Incidence *incidence)
4928{ 4927{
4929 mViewerCallerIsSearchDialog = false; 4928 mViewerCallerIsSearchDialog = false;
4930 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4929 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4931 if ( sender() && mDialogManager->getSearchDialog() ) { 4930 if ( sender() && mDialogManager->getSearchDialog() ) {
4932 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4931 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4933 mViewerCallerIsSearchDialog = true; 4932 mViewerCallerIsSearchDialog = true;
4934 } 4933 }
4935 } 4934 }
4936 if ( incidence ) { 4935 if ( incidence ) {
4937 ShowIncidenceVisitor v; 4936 ShowIncidenceVisitor v;
4938 v.act( incidence, this ); 4937 v.act( incidence, this );
4939 } 4938 }
4940} 4939}
4941 4940
4942void CalendarView::editIncidence(Incidence *incidence) 4941void CalendarView::editIncidence(Incidence *incidence)
4943{ 4942{
4944 if ( incidence ) { 4943 if ( incidence ) {
4945 4944
4946 EditIncidenceVisitor v; 4945 EditIncidenceVisitor v;
4947 v.act( incidence, this ); 4946 v.act( incidence, this );
4948 4947
4949 } 4948 }
4950} 4949}
4951 4950
4952void CalendarView::deleteIncidence(Incidence *incidence) 4951void CalendarView::deleteIncidence(Incidence *incidence)
4953{ 4952{
4954 //qDebug(" CalendarView::deleteIncidence "); 4953 //qDebug(" CalendarView::deleteIncidence ");
4955 if ( incidence == 0 ) { 4954 if ( incidence == 0 ) {
4956 updateView(); 4955 updateView();
4957 emit updateSearchDialog(); 4956 emit updateSearchDialog();
4958 return; 4957 return;
4959 } 4958 }
4960 if ( incidence ) { 4959 if ( incidence ) {
4961 DeleteIncidenceVisitor v; 4960 DeleteIncidenceVisitor v;
4962 v.act( incidence, this ); 4961 v.act( incidence, this );
4963 } 4962 }
4964} 4963}
4965 4964
4966 4965
4967void CalendarView::lookForOutgoingMessages() 4966void CalendarView::lookForOutgoingMessages()
4968{ 4967{
4969 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4968 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4970 ogd->loadMessages(); 4969 ogd->loadMessages();
4971} 4970}
4972 4971
4973void CalendarView::lookForIncomingMessages() 4972void CalendarView::lookForIncomingMessages()
4974{ 4973{
4975 IncomingDialog *icd = mDialogManager->incomingDialog(); 4974 IncomingDialog *icd = mDialogManager->incomingDialog();
4976 icd->retrieve(); 4975 icd->retrieve();
4977} 4976}
4978 4977
4979bool CalendarView::removeCompletedSubTodos( Todo* t ) 4978bool CalendarView::removeCompletedSubTodos( Todo* t )
4980{ 4979{
4981 bool deleteTodo = true; 4980 bool deleteTodo = true;
4982 QPtrList<Incidence> subTodos; 4981 QPtrList<Incidence> subTodos;
4983 Incidence *aTodo; 4982 Incidence *aTodo;
4984 subTodos = t->relations(); 4983 subTodos = t->relations();
4985 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4984 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4986 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4985 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4987 deleteTodo = false; 4986 deleteTodo = false;
4988 } 4987 }
4989 if ( deleteTodo ) { 4988 if ( deleteTodo ) {
4990 if ( t->isCompleted() && !t->doesRecur()) { 4989 if ( t->isCompleted() && !t->doesRecur()) {
4991 checkExternalId( t ); 4990 checkExternalId( t );
4992 mCalendar->deleteTodo( t ); 4991 mCalendar->deleteTodo( t );
4993 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4992 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4994 } 4993 }
4995 else 4994 else
4996 deleteTodo = false; 4995 deleteTodo = false;
4997 } 4996 }
4998 return deleteTodo; 4997 return deleteTodo;
4999 4998
5000} 4999}
5001void CalendarView::purgeCompleted() 5000void CalendarView::purgeCompleted()
5002{ 5001{
5003 int result = KMessageBox::warningContinueCancel(this, 5002 int result = KMessageBox::warningContinueCancel(this,
5004 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5003 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5005 5004
5006 if (result == KMessageBox::Continue) { 5005 if (result == KMessageBox::Continue) {
5007 5006
5008 QPtrList<Todo> todoCal; 5007 QPtrList<Todo> todoCal;
5009 QPtrList<Todo> rootTodos; 5008 QPtrList<Todo> rootTodos;
5010 //QPtrList<Incidence> rel; 5009 //QPtrList<Incidence> rel;
5011 Todo *aTodo; 5010 Todo *aTodo;
5012 todoCal = calendar()->todos(); 5011 todoCal = calendar()->todos();
5013 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5012 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5014 if ( !aTodo->relatedTo() ) 5013 if ( !aTodo->relatedTo() )
5015 rootTodos.append( aTodo ); 5014 rootTodos.append( aTodo );
5016 } 5015 }
5017 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5016 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5018 removeCompletedSubTodos( aTodo ); 5017 removeCompletedSubTodos( aTodo );
5019 } 5018 }
5020 5019
5021 updateView(); 5020 updateView();
5022 } 5021 }
5023} 5022}
5024 5023
5025void CalendarView::slotCalendarChanged() 5024void CalendarView::slotCalendarChanged()
5026{ 5025{
5027 ; 5026 ;
5028} 5027}
5029 5028
5030void CalendarView::keyPressEvent ( QKeyEvent *e) 5029void CalendarView::keyPressEvent ( QKeyEvent *e)
5031{ 5030{
5032 //qDebug("CalendarView::keyPressEvent "); 5031 //qDebug("CalendarView::keyPressEvent ");
5033 e->ignore(); 5032 e->ignore();
5034} 5033}
5035 5034
5036 5035
5037bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 5036bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5038{ 5037{
5039 5038
5040 if ( manager != mSyncManager) 5039 if ( manager != mSyncManager)
5041 qDebug("KO: Internal error-1. SyncManager mismatch "); 5040 qDebug("KO: Internal error-1. SyncManager mismatch ");
5042 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5041 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5043 qDebug("KO: SyncKDE request detected!"); 5042 qDebug("KO: SyncKDE request detected!");
5044 } 5043 }
5045 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5044 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5046 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5045 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5047 return syncCalendar( filename, mode ); 5046 if ( !resource.isEmpty() ) {
5047 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
5048 qDebug( "KO: Sync request for resource: %s", resource.latin1() );
5049
5050 if ( !exclusiveSyncResource ) {
5051 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
5052 return false;
5053 }
5054 mCalendar->setDefaultCalendar( exclusiveSyncResource );
5055 mCalendar->setDefaultCalendarEnabledOnly();
5056 }
5057 bool result = syncCalendar( filename, mode );
5058 if ( !resource.isEmpty() )
5059 restoreCalendarSettings();
5060 return result;
5048} 5061}
5049bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 5062bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
5050{ 5063{
5051 //mSyncManager = manager; 5064 //mSyncManager = manager;
5052 if ( manager != mSyncManager) 5065 if ( manager != mSyncManager)
5053 qDebug("KO: Internal error-2. SyncManager mismatch "); 5066 qDebug("KO: Internal error-2. SyncManager mismatch ");
5054 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5067 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5055 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5068 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5056 if ( resource == "sharp" ) 5069 if ( resource == "sharp" )
5057 syncExternal( 0 ); 5070 syncExternal( 0 );
5058 if ( resource == "phone" ) 5071 if ( resource == "phone" )
5059 syncExternal( 1 ); 5072 syncExternal( 1 );
5060 // pending setmodified 5073 // pending setmodified
5061 return true; 5074 return true;
5062} 5075}
5063void CalendarView::setSyncManager(KSyncManager* manager) 5076void CalendarView::setSyncManager(KSyncManager* manager)
5064{ 5077{
5065 mSyncManager = manager; 5078 mSyncManager = manager;
5066} 5079}
5067 5080
5068void CalendarView::removeSyncInfo( QString syncProfile) 5081void CalendarView::removeSyncInfo( QString syncProfile)
5069{ 5082{
5070 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 5083 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
5071 mCalendar->removeSyncInfo( syncProfile ); 5084 mCalendar->removeSyncInfo( syncProfile );
5072 5085
5073} 5086}
5074 5087
5075void CalendarView::undo_delete() 5088void CalendarView::undo_delete()
5076{ 5089{
5077 //qDebug("undo_delete() "); 5090 //qDebug("undo_delete() ");
5078 Incidence* undo = mCalendar->undoIncidence(); 5091 Incidence* undo = mCalendar->undoIncidence();
5079 if ( !undo ) { 5092 if ( !undo ) {
5080 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 5093 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
5081 i18n("KO/Pi")); 5094 i18n("KO/Pi"));
5082 return; 5095 return;
5083 } 5096 }
5084 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 5097 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
5085 i18n("\nAre you sure you want\nto restore this?"), 5098 i18n("\nAre you sure you want\nto restore this?"),
5086 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 5099 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
5087 mCalendar->undoDeleteIncidence(); 5100 mCalendar->undoDeleteIncidence();
5088 updateView(); 5101 updateView();
5089 } 5102 }
5090} 5103}
5091 5104
5092void CalendarView::slotViewerClosed() 5105void CalendarView::slotViewerClosed()
5093{ 5106{
5094 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 5107 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
5095} 5108}
5096 5109
5097void CalendarView::resetFocus() 5110void CalendarView::resetFocus()
5098{ 5111{
5099 if ( mViewerCallerIsSearchDialog ) { 5112 if ( mViewerCallerIsSearchDialog ) {
5100 if ( mDialogManager->getSearchDialog()->isVisible() ){ 5113 if ( mDialogManager->getSearchDialog()->isVisible() ){
5101 mDialogManager->getSearchDialog()->raise(); 5114 mDialogManager->getSearchDialog()->raise();
5102 mDialogManager->getSearchDialog()->setActiveWindow(); 5115 mDialogManager->getSearchDialog()->setActiveWindow();
5103 mDialogManager->getSearchDialog()->listview()->resetFocus(); 5116 mDialogManager->getSearchDialog()->listview()->resetFocus();
5104 } else 5117 } else
5105 mViewerCallerIsSearchDialog = false; 5118 mViewerCallerIsSearchDialog = false;
5106 } 5119 }
5107 if ( !mViewerCallerIsSearchDialog ) { 5120 if ( !mViewerCallerIsSearchDialog ) {
5108 //mViewManager->currentView()->setFocus(); 5121 //mViewManager->currentView()->setFocus();
5109 //qDebug("sssssssssssssssset focus "); 5122 //qDebug("sssssssssssssssset focus ");
5110 topLevelWidget()->raise(); 5123 topLevelWidget()->raise();
5111 setActiveWindow(); 5124 setActiveWindow();
5112 //setFocus(); 5125 //setFocus();
5113 } 5126 }
5114 mViewerCallerIsSearchDialog = false; 5127 mViewerCallerIsSearchDialog = false;
5115} 5128}
5116 5129
5117void CalendarView::showNextAlarms() 5130void CalendarView::showNextAlarms()
5118{ 5131{
5119 QString message; 5132 QString message;
5120 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 5133 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
5121 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 5134 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
5122 QString sum = mCalendar->nextSummary(); 5135 QString sum = mCalendar->nextSummary();
5123 QDateTime nextA = mNextAlarmDateTime; 5136 QDateTime nextA = mNextAlarmDateTime;
5124 QDateTime cur = QDateTime::currentDateTime(); 5137 QDateTime cur = QDateTime::currentDateTime();
5125 int secs = cur.secsTo( nextA ); 5138 int secs = cur.secsTo( nextA );
5126 int min = secs /60; 5139 int min = secs /60;
5127 int hours = min /60; 5140 int hours = min /60;
5128 min = min % 60; 5141 min = min % 60;
5129 int days = hours /24; 5142 int days = hours /24;
5130 hours = hours % 24; 5143 hours = hours % 24;
5131 5144
5132 //message = i18n("The next alarm is in:\n"); 5145 //message = i18n("The next alarm is in:\n");
5133 if ( days > 1 ) 5146 if ( days > 1 )
5134 message += i18n("%1 days\n").arg( days ); 5147 message += i18n("%1 days\n").arg( days );
5135 else if ( days == 1 ) 5148 else if ( days == 1 )
5136 message += i18n("1 day\n"); 5149 message += i18n("1 day\n");
5137 if ( hours > 1 ) 5150 if ( hours > 1 )
5138 message += i18n("%1 hours\n").arg( hours ); 5151 message += i18n("%1 hours\n").arg( hours );
5139 else if ( hours == 1 ) 5152 else if ( hours == 1 )
5140 message += i18n("1 hour\n"); 5153 message += i18n("1 hour\n");
5141 if ( min > 1 ) 5154 if ( min > 1 )
5142 message += i18n("%1 minutes\n").arg( min ); 5155 message += i18n("%1 minutes\n").arg( min );
5143 else if ( min == 1 ) 5156 else if ( min == 1 )
5144 message += i18n("1 minute\n"); 5157 message += i18n("1 minute\n");
5145 if ( message.isEmpty() ) 5158 if ( message.isEmpty() )
5146 message = i18n("The next alarm is in\nless than one minute!"); 5159 message = i18n("The next alarm is in\nless than one minute!");
5147 else 5160 else
5148 message = i18n("The next alarm is in:\n") + message; 5161 message = i18n("The next alarm is in:\n") + message;
5149 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 5162 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
5150 } else { 5163 } else {
5151 message = i18n("There is no next alarm."); 5164 message = i18n("There is no next alarm.");
5152 5165
5153 } 5166 }
5154#ifdef DESKTOP_VERSION 5167#ifdef DESKTOP_VERSION
5155 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 5168 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
5156 message += i18n("\nThe internal alarm notification is disabled!\n"); 5169 message += i18n("\nThe internal alarm notification is disabled!\n");
5157 message += i18n("Enable it in the settings menu, TAB alarm."); 5170 message += i18n("Enable it in the settings menu, TAB alarm.");
5158 } 5171 }
5159 5172
5160#endif 5173#endif
5161 KMessageBox::information( this, message); 5174 KMessageBox::information( this, message);
5162} 5175}
5163 5176
5164void CalendarView::displayCalendarInfo( int id ) 5177void CalendarView::displayCalendarInfo( int id )
5165{ 5178{
5166 int e, t,j; 5179 int e, t,j;
5167 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 5180 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
5168 QString name = kkf->mName; 5181 QString name = kkf->mName;
5169 mCalendar->getIncidenceCount( id, e, t, j ); 5182 mCalendar->getIncidenceCount( id, e, t, j );
5170 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 5183 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
5171 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); 5184 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file);
5172 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); 5185 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j );
5173 KMessageBox::information( this, mess ); 5186 KMessageBox::information( this, mess );
5174 5187
5175 5188
5176} 5189}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 80f7ed4..f85b6a3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,675 +1,675 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#include <qscrollbar.h> 33#include <qscrollbar.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qtopia/ir.h> 35#include <qtopia/ir.h>
36#else 36#else
37#define Ir char 37#define Ir char
38#endif 38#endif
39#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
40#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
44 44
45#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
46 46
47#include <ksyncmanager.h> 47#include <ksyncmanager.h>
48//#include <koprefs.h> 48//#include <koprefs.h>
49 49
50class QWidgetStack; 50class QWidgetStack;
51class QSplitter; 51class QSplitter;
52class KopiCalendarFile; 52class KopiCalendarFile;
53class CalPrinter; 53class CalPrinter;
54class KOFilterView; 54class KOFilterView;
55class KOCalEditView; 55class KOCalEditView;
56class KOViewManager; 56class KOViewManager;
57class KODialogManager; 57class KODialogManager;
58class KOTodoView; 58class KOTodoView;
59class KDateNavigator; 59class KDateNavigator;
60class DateNavigatorContainer; 60class DateNavigatorContainer;
61class DateNavigator; 61class DateNavigator;
62class KOIncidenceEditor; 62class KOIncidenceEditor;
63class KDatePicker; 63class KDatePicker;
64class ResourceView; 64class ResourceView;
65class KOEventEditor; 65class KOEventEditor;
66class KOTodoEditor ; 66class KOTodoEditor ;
67class KOEventViewerDialog; 67class KOEventViewerDialog;
68class KOBeamPrefs; 68class KOBeamPrefs;
69class KSyncProfile; 69class KSyncProfile;
70class AlarmDialog; 70class AlarmDialog;
71class KCal::Attendee; 71class KCal::Attendee;
72 72
73namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
74 74
75using namespace KCal; 75using namespace KCal;
76 76
77/** 77/**
78 This is the main calendar widget. It provides the different vies on t he 78 This is the main calendar widget. It provides the different vies on t he
79 calendar data as well as the date navigator. It also handles synchronisation 79 calendar data as well as the date navigator. It also handles synchronisation
80 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
81 event editor, search dialog etc. 81 event editor, search dialog etc.
82 82
83 @short main calendar view widget 83 @short main calendar view widget
84 @author Cornelius Schumacher 84 @author Cornelius Schumacher
85*/ 85*/
86 86
87#include <qtextbrowser.h> 87#include <qtextbrowser.h>
88#include <qtextcodec.h> 88#include <qtextcodec.h>
89 89
90class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
91 Q_OBJECT 91 Q_OBJECT
92 public: 92 public:
93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
94 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
95 void setSource(const QString & n); 95 void setSource(const QString & n);
96 96
97 private: 97 private:
98 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
99 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
100 signals: 100 signals:
101 void showIncidence( QString uid); 101 void showIncidence( QString uid);
102}; 102};
103 103
104 104
105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 public: 108 public:
109 /** 109 /**
110 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
111 111
112 @param calendar calendar document 112 @param calendar calendar document
113 @param parent parent window 113 @param parent parent window
114 @param name Qt internal widget object name 114 @param name Qt internal widget object name
115 */ 115 */
116 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
119 const char *name = 0 ); 119 const char *name = 0 );
120 virtual ~CalendarView(); 120 virtual ~CalendarView();
121 121
122 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
123 123
124 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
125 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
126 126
127 QDate startDate(); 127 QDate startDate();
128 QDate endDate(); 128 QDate endDate();
129 129
130 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
131 QWidget *leftFrame(); 131 QWidget *leftFrame();
132 132
133 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
134 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
135 135
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 142
143 signals: 143 signals:
144 void save (); 144 void save ();
145 void saveStopTimer (); 145 void saveStopTimer ();
146 void tempDisableBR(bool); 146 void tempDisableBR(bool);
147 /** This todo has been modified */ 147 /** This todo has been modified */
148 void todoModified(Todo *, int); 148 void todoModified(Todo *, int);
149 149
150 /** when change is made to options dialog, the topwidget will catch this 150 /** when change is made to options dialog, the topwidget will catch this
151 * and emit this signal which notifies all widgets which have registered 151 * and emit this signal which notifies all widgets which have registered
152 * for notification to update their settings. */ 152 * for notification to update their settings. */
153 void configChanged(); 153 void configChanged();
154 /** emitted when the topwidget is closing down, so that any attached 154 /** emitted when the topwidget is closing down, so that any attached
155 child windows can also close. */ 155 child windows can also close. */
156 void closingDown(); 156 void closingDown();
157 /** emitted right before we die */ 157 /** emitted right before we die */
158 void closed(QWidget *); 158 void closed(QWidget *);
159 159
160 /** Emitted when state of modified flag changes */ 160 /** Emitted when state of modified flag changes */
161 void modifiedChanged(bool); 161 void modifiedChanged(bool);
162 void signalmodified(); 162 void signalmodified();
163 163
164 /** Emitted when state of read-only flag changes */ 164 /** Emitted when state of read-only flag changes */
165 void readOnlyChanged(bool); 165 void readOnlyChanged(bool);
166 166
167 /** Emitted when the unit of navigation changes */ 167 /** Emitted when the unit of navigation changes */
168 void changeNavStringPrev(const QString &); 168 void changeNavStringPrev(const QString &);
169 void changeNavStringNext(const QString &); 169 void changeNavStringNext(const QString &);
170 170
171 /** Emitted when state of events selection has changed and user is organizer*/ 171 /** Emitted when state of events selection has changed and user is organizer*/
172 void organizerEventsSelected(bool); 172 void organizerEventsSelected(bool);
173 /** Emitted when state of events selection has changed and user is attendee*/ 173 /** Emitted when state of events selection has changed and user is attendee*/
174 void groupEventsSelected(bool); 174 void groupEventsSelected(bool);
175 /** 175 /**
176 Emitted when an incidence gets selected. If the selection is cleared the 176 Emitted when an incidence gets selected. If the selection is cleared the
177 signal is emitted with 0 as argument. 177 signal is emitted with 0 as argument.
178 */ 178 */
179 void incidenceSelected( Incidence * ); 179 void incidenceSelected( Incidence * );
180 /** Emitted, when a todoitem is selected or deselected. */ 180 /** Emitted, when a todoitem is selected or deselected. */
181 void todoSelected( bool ); 181 void todoSelected( bool );
182 182
183 /** 183 /**
184 Emitted, when clipboard content changes. Parameter indicates if paste 184 Emitted, when clipboard content changes. Parameter indicates if paste
185 is possible or not. 185 is possible or not.
186 */ 186 */
187 void pasteEnabled(bool); 187 void pasteEnabled(bool);
188 188
189 /** Emitted, when the number of incoming messages has changed. */ 189 /** Emitted, when the number of incoming messages has changed. */
190 void numIncomingChanged(int); 190 void numIncomingChanged(int);
191 191
192 /** Emitted, when the number of outgoing messages has changed. */ 192 /** Emitted, when the number of outgoing messages has changed. */
193 void numOutgoingChanged(int); 193 void numOutgoingChanged(int);
194 194
195 /** Send status message, which can e.g. be displayed in the status bar. */ 195 /** Send status message, which can e.g. be displayed in the status bar. */
196 void statusMessage(const QString &); 196 void statusMessage(const QString &);
197 197
198 void calendarViewExpanded( bool ); 198 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 199 void updateSearchDialog();
200 void filtersUpdated(); 200 void filtersUpdated();
201 201
202 202
203 public slots: 203 public slots:
204 void displayCalendarInfo( int id ); 204 void displayCalendarInfo( int id );
205 void nextConflict( bool all, bool allday ); 205 void nextConflict( bool all, bool allday );
206 void conflictAll(); 206 void conflictAll();
207 void conflictAllday(); 207 void conflictAllday();
208 void conflictNotAll(); 208 void conflictNotAll();
209 void setCalReadOnly( int id, bool readO ); 209 void setCalReadOnly( int id, bool readO );
210 void checkAlarms(); 210 void checkAlarms();
211 void checkFiles(); 211 void checkFiles();
212 void slotprintSelInc(); 212 void slotprintSelInc();
213 void showNextAlarms(); 213 void showNextAlarms();
214 void showOpenError(); 214 void showOpenError();
215 void watchSavedFile(); 215 void watchSavedFile();
216 void recheckTimerAlarm(); 216 void recheckTimerAlarm();
217 void checkNextTimerAlarm(); 217 void checkNextTimerAlarm();
218 void addAlarm(const QDateTime &qdt, const QString &noti ); 218 void addAlarm(const QDateTime &qdt, const QString &noti );
219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
220 void removeAlarm(const QDateTime &qdt, const QString &noti ); 220 void removeAlarm(const QDateTime &qdt, const QString &noti );
221 221
222 /** options dialog made a changed to the configuration. we catch this 222 /** options dialog made a changed to the configuration. we catch this
223 * and notify all widgets which need to update their configuration. */ 223 * and notify all widgets which need to update their configuration. */
224 void updateConfig(); 224 void updateConfig();
225 225
226 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 226 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
227 const QStringList& anniversaryList, const QStringList& realNameList, 227 const QStringList& anniversaryList, const QStringList& realNameList,
228 const QStringList& emailList, const QStringList& assembledNameList, 228 const QStringList& emailList, const QStringList& assembledNameList,
229 const QStringList& uidList); 229 const QStringList& uidList);
230 230
231 /** 231 /**
232 Load calendar from file \a filename. If \a merge is true, load 232 Load calendar from file \a filename. If \a merge is true, load
233 calendar into existing one, if it is false, clear calendar, before 233 calendar into existing one, if it is false, clear calendar, before
234 loading. Return true, if calendar could be successfully loaded. 234 loading. Return true, if calendar could be successfully loaded.
235 */ 235 */
236 bool openCalendar(QString filename, bool merge=false); 236 bool openCalendar(QString filename, bool merge=false);
237 bool loadCalendars(); 237 bool loadCalendars();
238 bool saveCalendars(); 238 bool saveCalendars();
239 bool restoreCalendarSettings(); 239 bool restoreCalendarSettings();
240 bool addCalendar( KopiCalendarFile * ); 240 bool addCalendar( KopiCalendarFile * );
241 void addCalendarId( int id ); 241 void addCalendarId( int id );
242 bool syncCalendar(QString filename,int mode = 0 ); 242 bool syncCalendar(QString filename,int mode = 0 );
243 243
244 /** 244 /**
245 Save calendar data to file. Return true if calendar could be 245 Save calendar data to file. Return true if calendar could be
246 successfully saved. 246 successfully saved.
247 */ 247 */
248 bool saveCalendar(QString filename); 248 bool saveCalendar(QString filename);
249 249
250 /** 250 /**
251 Close calendar. Clear calendar data and reset views to display an empty 251 Close calendar. Clear calendar data and reset views to display an empty
252 calendar. 252 calendar.
253 */ 253 */
254 void closeCalendar(); 254 void closeCalendar();
255 255
256 /** Archive old events of calendar */ 256 /** Archive old events of calendar */
257 void archiveCalendar(); 257 void archiveCalendar();
258 258
259 void showIncidence(); 259 void showIncidence();
260 void editIncidence(); 260 void editIncidence();
261 void editIncidenceDescription(); 261 void editIncidenceDescription();
262 void deleteIncidence(); 262 void deleteIncidence();
263 void cloneIncidence(); 263 void cloneIncidence();
264 void moveIncidence(); 264 void moveIncidence();
265 void beamIncidence(); 265 void beamIncidence();
266 void toggleCancelIncidence(); 266 void toggleCancelIncidence();
267 267
268 /** create an editeventwin with supplied date/time, and if bool is true, 268 /** create an editeventwin with supplied date/time, and if bool is true,
269 * make the event take all day. */ 269 * make the event take all day. */
270 void newEvent(QDateTime, QDateTime, bool allDay ); 270 void newEvent(QDateTime, QDateTime, bool allDay );
271 void newEvent(QDateTime, QDateTime); 271 void newEvent(QDateTime, QDateTime);
272 void newEvent(QDateTime fh); 272 void newEvent(QDateTime fh);
273 void newEvent(QDate dt); 273 void newEvent(QDate dt);
274 /** create new event without having a date hint. Takes current date as 274 /** create new event without having a date hint. Takes current date as
275 default hint. */ 275 default hint. */
276 void newEvent(); 276 void newEvent();
277 void newFloatingEvent(); 277 void newFloatingEvent();
278 278
279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
280 void showIncidence(Incidence *); 280 void showIncidence(Incidence *);
281 void showIncidence(QString uid); 281 void showIncidence(QString uid);
282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
283 void editIncidence(Incidence *); 283 void editIncidence(Incidence *);
284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
285 void deleteIncidence(Incidence *); 285 void deleteIncidence(Incidence *);
286 void cloneIncidence(Incidence *); 286 void cloneIncidence(Incidence *);
287 void cancelIncidence(Incidence *); 287 void cancelIncidence(Incidence *);
288 /** Create an editor for the supplied event. */ 288 /** Create an editor for the supplied event. */
289 void editEvent(Event *); 289 void editEvent(Event *);
290 /** Delete the supplied event. */ 290 /** Delete the supplied event. */
291 void deleteEvent(Event *); 291 void deleteEvent(Event *);
292 /** Delete the event with the given unique ID. Returns false, if event wasn't 292 /** Delete the event with the given unique ID. Returns false, if event wasn't
293 found. */ 293 found. */
294 bool deleteEvent(const QString &uid); 294 bool deleteEvent(const QString &uid);
295 /** Create a read-only viewer dialog for the supplied event. */ 295 /** Create a read-only viewer dialog for the supplied event. */
296 void showEvent(Event *); 296 void showEvent(Event *);
297 297
298 void editJournal(Journal *); 298 void editJournal(Journal *);
299 void showJournal(Journal *); 299 void showJournal(Journal *);
300 void deleteJournal(Journal *); 300 void deleteJournal(Journal *);
301 /** Create an editor dialog for a todo */ 301 /** Create an editor dialog for a todo */
302 void editTodo(Todo *); 302 void editTodo(Todo *);
303 /** Create a read-only viewer dialog for the supplied todo */ 303 /** Create a read-only viewer dialog for the supplied todo */
304 void showTodo(Todo *); 304 void showTodo(Todo *);
305 /** create new todo */ 305 /** create new todo */
306 void newTodo(); 306 void newTodo();
307 void newTodoDateTime(QDateTime, bool allday); 307 void newTodoDateTime(QDateTime, bool allday);
308 /** create new todo with a parent todo */ 308 /** create new todo with a parent todo */
309 void newSubTodo(); 309 void newSubTodo();
310 /** create new todo with a parent todo */ 310 /** create new todo with a parent todo */
311 void newSubTodo(Todo *); 311 void newSubTodo(Todo *);
312 /** Delete todo */ 312 /** Delete todo */
313 void deleteTodo(Todo *); 313 void deleteTodo(Todo *);
314 314
315 315
316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
317 * emitted as result. */ 317 * emitted as result. */
318 void checkClipboard(); 318 void checkClipboard();
319 319
320 /** using the KConfig associated with the kapp variable, read in the 320 /** using the KConfig associated with the kapp variable, read in the
321 * settings from the config file. 321 * settings from the config file.
322 */ 322 */
323 void readSettings(); 323 void readSettings();
324 324
325 /** write current state to config file. */ 325 /** write current state to config file. */
326 void writeSettings(); 326 void writeSettings();
327 327
328 /** read settings for calendar filters */ 328 /** read settings for calendar filters */
329 void readFilterSettings(KConfig *config); 329 void readFilterSettings(KConfig *config);
330 330
331 /** write settings for calendar filters */ 331 /** write settings for calendar filters */
332 void writeFilterSettings(KConfig *config); 332 void writeFilterSettings(KConfig *config);
333 333
334 /** passes on the message that an event has changed to the currently 334 /** passes on the message that an event has changed to the currently
335 * activated view so that it can make appropriate display changes. */ 335 * activated view so that it can make appropriate display changes. */
336 void changeEventDisplay(Event *, int); 336 void changeEventDisplay(Event *, int);
337 void changeIncidenceDisplay(Incidence *, int); 337 void changeIncidenceDisplay(Incidence *, int);
338 void changeTodoDisplay(Todo *, int); 338 void changeTodoDisplay(Todo *, int);
339 339
340 void eventAdded(Event *); 340 void eventAdded(Event *);
341 void eventChanged(Event *); 341 void eventChanged(Event *);
342 void eventToBeDeleted(Event *); 342 void eventToBeDeleted(Event *);
343 void eventDeleted(); 343 void eventDeleted();
344 344
345 void todoAdded(Todo *); 345 void todoAdded(Todo *);
346 void todoChanged(Todo *); 346 void todoChanged(Todo *);
347 void todoToBeDeleted(Todo *); 347 void todoToBeDeleted(Todo *);
348 void todoDeleted(); 348 void todoDeleted();
349 349
350 void updateView(const QDate &start, const QDate &end); 350 void updateView(const QDate &start, const QDate &end);
351 void updateView(); 351 void updateView();
352 void clearAllViews(); 352 void clearAllViews();
353 353
354 /** Full update of visible todo views */ 354 /** Full update of visible todo views */
355 void updateTodoViews(); 355 void updateTodoViews();
356 356
357 void updateUnmanagedViews(); 357 void updateUnmanagedViews();
358 358
359 /** cut the current appointment to the clipboard */ 359 /** cut the current appointment to the clipboard */
360 void edit_cut(); 360 void edit_cut();
361 361
362 /** copy the current appointment(s) to the clipboard */ 362 /** copy the current appointment(s) to the clipboard */
363 void edit_copy(); 363 void edit_copy();
364 364
365 /** paste the current vobject(s) in the clipboard buffer into calendar */ 365 /** paste the current vobject(s) in the clipboard buffer into calendar */
366 void edit_paste(); 366 void edit_paste();
367 367
368 /** edit viewing and configuration options. */ 368 /** edit viewing and configuration options. */
369 void edit_options(); 369 void edit_options();
370 void edit_global_options(); 370 void edit_global_options();
371 /** 371 /**
372 Functions for printing, previewing a print, and setting up printing 372 Functions for printing, previewing a print, and setting up printing
373 parameters. 373 parameters.
374 */ 374 */
375 void print(); 375 void print();
376 void printSetup(); 376 void printSetup();
377 void printPreview(); 377 void printPreview();
378 378
379 /** Export as iCalendar file */ 379 /** Export as iCalendar file */
380 bool exportICalendar(); 380 bool exportICalendar();
381 bool exportICalendar( QString fn ); 381 bool exportICalendar( QString fn );
382 382
383 /** Export as vCalendar file */ 383 /** Export as vCalendar file */
384 bool exportVCalendar( QString fn); 384 bool exportVCalendar( QString fn);
385 385
386 /** pop up a dialog to show an existing appointment. */ 386 /** pop up a dialog to show an existing appointment. */
387 void appointment_show(); 387 void appointment_show();
388 /** 388 /**
389 * pop up an Appointment Dialog to edit an existing appointment.Get 389 * pop up an Appointment Dialog to edit an existing appointment.Get
390 * information on the appointment from the list of unique IDs that is 390 * information on the appointment from the list of unique IDs that is
391 * currently in the View, called currIds. 391 * currently in the View, called currIds.
392 */ 392 */
393 void appointment_edit(); 393 void appointment_edit();
394 /** 394 /**
395 * pop up dialog confirming deletion of currently selected event in the 395 * pop up dialog confirming deletion of currently selected event in the
396 * View. 396 * View.
397 */ 397 */
398 void appointment_delete(); 398 void appointment_delete();
399 399
400 /** mails the currently selected event to a particular user as a vCalendar 400 /** mails the currently selected event to a particular user as a vCalendar
401 attachment. */ 401 attachment. */
402 void action_mail(); 402 void action_mail();
403 403
404 /* frees a subtodo from it's relation */ 404 /* frees a subtodo from it's relation */
405 void todo_unsub( Todo * ); 405 void todo_unsub( Todo * );
406 void todo_resub( Todo * parent, Todo * sub ); 406 void todo_resub( Todo * parent, Todo * sub );
407 407
408 /** Take ownership of selected event. */ 408 /** Take ownership of selected event. */
409 void takeOverEvent(); 409 void takeOverEvent();
410 410
411 /** Take ownership of all events in calendar. */ 411 /** Take ownership of all events in calendar. */
412 void takeOverCalendar(); 412 void takeOverCalendar();
413 413
414 /** query whether or not the calendar is "dirty". */ 414 /** query whether or not the calendar is "dirty". */
415 bool isModified(); 415 bool isModified();
416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
417 void setModified(bool modified=true); 417 void setModified(bool modified=true);
418 418
419 /** query if the calendar is read-only. */ 419 /** query if the calendar is read-only. */
420 bool isReadOnly(); 420 bool isReadOnly();
421 /** set state of calendar to read-only */ 421 /** set state of calendar to read-only */
422 void setReadOnly(bool readOnly=true); 422 void setReadOnly(bool readOnly=true);
423 423
424 void eventUpdated(Incidence *); 424 void eventUpdated(Incidence *);
425 425
426 /* iTIP scheduling actions */ 426 /* iTIP scheduling actions */
427 void schedule_publish(Incidence *incidence = 0); 427 void schedule_publish(Incidence *incidence = 0);
428 void schedule_request(Incidence *incidence = 0); 428 void schedule_request(Incidence *incidence = 0);
429 void schedule_refresh(Incidence *incidence = 0); 429 void schedule_refresh(Incidence *incidence = 0);
430 void schedule_cancel(Incidence *incidence = 0); 430 void schedule_cancel(Incidence *incidence = 0);
431 void schedule_add(Incidence *incidence = 0); 431 void schedule_add(Incidence *incidence = 0);
432 void schedule_reply(Incidence *incidence = 0); 432 void schedule_reply(Incidence *incidence = 0);
433 void schedule_counter(Incidence *incidence = 0); 433 void schedule_counter(Incidence *incidence = 0);
434 void schedule_declinecounter(Incidence *incidence = 0); 434 void schedule_declinecounter(Incidence *incidence = 0);
435 void schedule_publish_freebusy(int daysToPublish = 30); 435 void schedule_publish_freebusy(int daysToPublish = 30);
436 436
437 void openAddressbook(); 437 void openAddressbook();
438 438
439 void editFilters(); 439 void editFilters();
440 void toggleFilerEnabled(); 440 void toggleFilerEnabled();
441 QPtrList<CalFilter> filters(); 441 QPtrList<CalFilter> filters();
442 void toggleFilter(); 442 void toggleFilter();
443 void showFilter(bool visible); 443 void showFilter(bool visible);
444 void updateFilter(); 444 void updateFilter();
445 void filterEdited(); 445 void filterEdited();
446 void selectFilter( int ); 446 void selectFilter( int );
447 KOFilterView *filterView(); 447 KOFilterView *filterView();
448 448
449 void showIntro(); 449 void showIntro();
450 450
451 /** Move the curdatepient view date to today */ 451 /** Move the curdatepient view date to today */
452 void goToday(); 452 void goToday();
453 453
454 /** Move to the next date(s) in the current view */ 454 /** Move to the next date(s) in the current view */
455 void goNext(); 455 void goNext();
456 456
457 /** Move to the previous date(s) in the current view */ 457 /** Move to the previous date(s) in the current view */
458 void goPrevious(); 458 void goPrevious();
459 /** Move to the next date(s) in the current view */ 459 /** Move to the next date(s) in the current view */
460 void goNextMonth(); 460 void goNextMonth();
461 461
462 /** Move to the previous date(s) in the current view */ 462 /** Move to the previous date(s) in the current view */
463 void goPreviousMonth(); 463 void goPreviousMonth();
464 464
465 void toggleExpand(); 465 void toggleExpand();
466 void toggleDateNavigatorWidget(); 466 void toggleDateNavigatorWidget();
467 void toggleAllDaySize(); 467 void toggleAllDaySize();
468 468
469 /** Look for new messages in the inbox */ 469 /** Look for new messages in the inbox */
470 void lookForIncomingMessages(); 470 void lookForIncomingMessages();
471 /** Look for new messages in the outbox */ 471 /** Look for new messages in the outbox */
472 void lookForOutgoingMessages(); 472 void lookForOutgoingMessages();
473 473
474 void processMainViewSelection( Incidence * ); 474 void processMainViewSelection( Incidence * );
475 void processTodoListSelection( Incidence * ); 475 void processTodoListSelection( Incidence * );
476 476
477 void processIncidenceSelection( Incidence * ); 477 void processIncidenceSelection( Incidence * );
478 478
479 void purgeCompleted(); 479 void purgeCompleted();
480 bool removeCompletedSubTodos( Todo* ); 480 bool removeCompletedSubTodos( Todo* );
481 void slotCalendarChanged(); 481 void slotCalendarChanged();
482 bool importBday(); 482 bool importBday();
483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
484 bool importQtopia( const QString &categoriesFile, 484 bool importQtopia( const QString &categoriesFile,
485 const QString &datebookFile, 485 const QString &datebookFile,
486 const QString &tasklistFile ); 486 const QString &tasklistFile );
487 void syncExternal( int mode ); 487 void syncExternal( int mode );
488 void slotSelectPickerDate( QDate ) ; 488 void slotSelectPickerDate( QDate ) ;
489 void showDatePicker() ; 489 void showDatePicker() ;
490 void showDatePickerPopup() ; 490 void showDatePickerPopup() ;
491 void moveIncidence(Incidence *) ; 491 void moveIncidence(Incidence *) ;
492 void beamIncidence(Incidence *) ; 492 void beamIncidence(Incidence *) ;
493 void beamCalendar() ; 493 void beamCalendar() ;
494 void beamFilteredCalendar() ; 494 void beamFilteredCalendar() ;
495 void beamIncidenceList(QPtrList<Incidence>) ; 495 void beamIncidenceList(QPtrList<Incidence>) ;
496 void manageCategories(); 496 void manageCategories();
497 void editCategories(); 497 void editCategories();
498 int addCategories(); 498 int addCategories();
499 void removeCategories(); 499 void removeCategories();
500 void setSyncDevice( QString ); 500 void setSyncDevice( QString );
501 void setSyncName( QString ); 501 void setSyncName( QString );
502 void showDay( QDate ); 502 void showDay( QDate );
503 void undo_delete(); 503 void undo_delete();
504 protected slots: 504 protected slots:
505 void resetFocus(); 505 void resetFocus();
506 void scrollBarValue(int); 506 void scrollBarValue(int);
507 void slotViewerClosed(); 507 void slotViewerClosed();
508 void timerAlarm(); 508 void timerAlarm();
509 void suspendAlarm(); 509 void suspendAlarm();
510 void beamDone( Ir *ir ); 510 void beamDone( Ir *ir );
511 /** Select a view or adapt the current view to display the specified dates. */ 511 /** Select a view or adapt the current view to display the specified dates. */
512 void showDates( const KCal::DateList & ); 512 void showDates( const KCal::DateList & );
513 void selectWeekNum ( int ); 513 void selectWeekNum ( int );
514 void checkConflictForEvent(); 514 void checkConflictForEvent();
515 515
516 public: 516 public:
517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); 517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval );
518 // show a standard warning 518 // show a standard warning
519 // returns KMsgBox::yesNoCancel() 519 // returns KMsgBox::yesNoCancel()
520 int msgCalModified(); 520 int msgCalModified();
521 virtual bool sync(KSyncManager* manager, QString filename, int mode); 521 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource);
522 522
523 virtual bool syncExternal(KSyncManager* manager, QString resource); 523 virtual bool syncExternal(KSyncManager* manager, QString resource);
524 virtual void removeSyncInfo( QString syncProfile); 524 virtual void removeSyncInfo( QString syncProfile);
525 void setSyncManager(KSyncManager* manager); 525 void setSyncManager(KSyncManager* manager);
526 void setLoadedFileVersion(QDateTime); 526 void setLoadedFileVersion(QDateTime);
527 bool checkFileVersion(QString fn); 527 bool checkFileVersion(QString fn);
528 bool checkAllFileVersions(); 528 bool checkAllFileVersions();
529 bool checkFileChanged(QString fn); 529 bool checkFileChanged(QString fn);
530 Event* getLastSyncEvent(); 530 Event* getLastSyncEvent();
531 /** Adapt navigation units correpsonding to step size of navigation of the 531 /** Adapt navigation units correpsonding to step size of navigation of the
532 * current view. 532 * current view.
533 */ 533 */
534 void adaptNavigationUnits(); 534 void adaptNavigationUnits();
535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 537 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 539 void setScrollBarStep(int val );
540 540
541 protected: 541 protected:
542 Event *mConflictingEvent; 542 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 543 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 544
545 // returns KMsgBox::OKCandel() 545 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 546 int msgItemDelete(const QString name);
547 void showEventEditor(); 547 void showEventEditor();
548 void showTodoEditor(); 548 void showTodoEditor();
549 Todo *selectedTodo(); 549 Todo *selectedTodo();
550 private: 550 private:
551#ifdef DESKTOP_VERSION 551#ifdef DESKTOP_VERSION
552 QScrollBar * mDateScrollBar; 552 QScrollBar * mDateScrollBar;
553#endif 553#endif
554 bool flag_blockConflict; 554 bool flag_blockConflict;
555 bool flag_blockScrollBar; 555 bool flag_blockScrollBar;
556 bool flag_checkFileFirsttime; 556 bool flag_checkFileFirsttime;
557 bool flag_clearallviewsEventDisplay; 557 bool flag_clearallviewsEventDisplay;
558 bool flag_clearallviewsupdateView; 558 bool flag_clearallviewsupdateView;
559 QDateTime mNextAlarmDateTime; 559 QDateTime mNextAlarmDateTime;
560 bool mViewerCallerIsSearchDialog; 560 bool mViewerCallerIsSearchDialog;
561 bool mBlockShowDates; 561 bool mBlockShowDates;
562 KSyncManager* mSyncManager; 562 KSyncManager* mSyncManager;
563 AlarmDialog * mAlarmDialog; 563 AlarmDialog * mAlarmDialog;
564 QString mAlarmNotification; 564 QString mAlarmNotification;
565 QString mSuspendAlarmNotification; 565 QString mSuspendAlarmNotification;
566 QTimer* mSuspendTimer; 566 QTimer* mSuspendTimer;
567 QTimer* mAlarmTimer; 567 QTimer* mAlarmTimer;
568 QTimer* mRecheckAlarmTimer; 568 QTimer* mRecheckAlarmTimer;
569 void computeAlarm( QString ); 569 void computeAlarm( QString );
570 void startAlarm( QString, QString ); 570 void startAlarm( QString, QString );
571 void setSyncEventsReadOnly(); 571 void setSyncEventsReadOnly();
572 572
573 QDateTime loadedFileVersion; 573 QDateTime loadedFileVersion;
574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
575 void checkExternalId( Incidence * inc ); 575 void checkExternalId( Incidence * inc );
576 int mGlobalSyncMode; 576 int mGlobalSyncMode;
577 QString mCurrentSyncDevice; 577 QString mCurrentSyncDevice;
578 QString mCurrentSyncName; 578 QString mCurrentSyncName;
579 void init(); 579 void init();
580 int mDatePickerMode; 580 int mDatePickerMode;
581 bool mFlagEditDescription; 581 bool mFlagEditDescription;
582 QDateTime mLastCalendarSync; 582 QDateTime mLastCalendarSync;
583 void createPrinter(); 583 void createPrinter();
584 584
585 void calendarModified( bool, Calendar * ); 585 void calendarModified( bool, Calendar * );
586 586
587 CalPrinter *mCalPrinter; 587 CalPrinter *mCalPrinter;
588 588
589 QSplitter *mPanner; 589 QSplitter *mPanner;
590 QSplitter *mLeftSplitter; 590 QSplitter *mLeftSplitter;
591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
592 QWidgetStack *mRightFrame; 592 QWidgetStack *mRightFrame;
593 593
594 KDatePicker* mDatePicker; 594 KDatePicker* mDatePicker;
595 QVBox* mDateFrame; 595 QVBox* mDateFrame;
596 596
597 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 597 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
598 598
599 KOFilterView *mFilterView; 599 KOFilterView *mFilterView;
600 KOCalEditView *mCalEditView; 600 KOCalEditView *mCalEditView;
601 601
602 ResourceView *mResourceView; 602 ResourceView *mResourceView;
603 603
604 // calendar object for this viewing instance 604 // calendar object for this viewing instance
605 Calendar *mCalendar; 605 Calendar *mCalendar;
606 606
607 CalendarResourceManager *mResourceManager; 607 CalendarResourceManager *mResourceManager;
608 608
609 FileStorage *mStorage; 609 FileStorage *mStorage;
610 610
611 DateNavigator *mNavigator; 611 DateNavigator *mNavigator;
612 612
613 KOViewManager *mViewManager; 613 KOViewManager *mViewManager;
614 KODialogManager *mDialogManager; 614 KODialogManager *mDialogManager;
615 615
616 // Calendar filters 616 // Calendar filters
617 QPtrList<CalFilter> mFilters; 617 QPtrList<CalFilter> mFilters;
618 618
619 // various housekeeping variables. 619 // various housekeeping variables.
620 bool mModified; // flag indicating if calendar is modified 620 bool mModified; // flag indicating if calendar is modified
621 bool mReadOnly; // flag indicating if calendar is read-only 621 bool mReadOnly; // flag indicating if calendar is read-only
622 QDate mSaveSingleDate; 622 QDate mSaveSingleDate;
623 623
624 Incidence *mSelectedIncidence; 624 Incidence *mSelectedIncidence;
625 Incidence *mMoveIncidence; 625 Incidence *mMoveIncidence;
626 QDate mMoveIncidenceOldDate; 626 QDate mMoveIncidenceOldDate;
627 KOTodoView *mTodoList; 627 KOTodoView *mTodoList;
628 KOEventEditor * mEventEditor; 628 KOEventEditor * mEventEditor;
629 KOTodoEditor * mTodoEditor; 629 KOTodoEditor * mTodoEditor;
630 KOEventViewerDialog * mEventViewerDialog; 630 KOEventViewerDialog * mEventViewerDialog;
631 void keyPressEvent ( QKeyEvent *e) ; 631 void keyPressEvent ( QKeyEvent *e) ;
632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
633}; 633};
634 634
635 635
636class CalendarViewVisitor : public Incidence::Visitor 636class CalendarViewVisitor : public Incidence::Visitor
637{ 637{
638 public: 638 public:
639 CalendarViewVisitor() : mView( 0 ) {} 639 CalendarViewVisitor() : mView( 0 ) {}
640 640
641 bool act( Incidence *incidence, CalendarView *view ) 641 bool act( Incidence *incidence, CalendarView *view )
642 { 642 {
643 mView = view; 643 mView = view;
644 return incidence->accept( *this ); 644 return incidence->accept( *this );
645 } 645 }
646 646
647 protected: 647 protected:
648 CalendarView *mView; 648 CalendarView *mView;
649}; 649};
650 650
651class ShowIncidenceVisitor : public CalendarViewVisitor 651class ShowIncidenceVisitor : public CalendarViewVisitor
652{ 652{
653 protected: 653 protected:
654 bool visit( Event *event ) { mView->showEvent( event ); return true; } 654 bool visit( Event *event ) { mView->showEvent( event ); return true; }
655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
656 bool visit( Journal * j ) { mView->showJournal( j );return true; } 656 bool visit( Journal * j ) { mView->showJournal( j );return true; }
657}; 657};
658 658
659class EditIncidenceVisitor : public CalendarViewVisitor 659class EditIncidenceVisitor : public CalendarViewVisitor
660{ 660{
661 protected: 661 protected:
662 bool visit( Event *event ) { mView->editEvent( event ); return true; } 662 bool visit( Event *event ) { mView->editEvent( event ); return true; }
663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
664 bool visit( Journal *j ) { mView->editJournal( j); return true; } 664 bool visit( Journal *j ) { mView->editJournal( j); return true; }
665}; 665};
666 666
667class DeleteIncidenceVisitor : public CalendarViewVisitor 667class DeleteIncidenceVisitor : public CalendarViewVisitor
668{ 668{
669 protected: 669 protected:
670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
673}; 673};
674 674
675#endif 675#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 1b0e5f4..31ef338 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,636 +1,646 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mGlobalUpdateDisabled = false; 56 mGlobalUpdateDisabled = false;
57 mCategoryColors.setAutoDelete(true); 57 mCategoryColors.setAutoDelete(true);
58 fillMailDefaults(); 58 fillMailDefaults();
59 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 59 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
60 QColor defaultHolidayColor = QColor(255,0,0); 60 QColor defaultHolidayColor = QColor(255,0,0);
61 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 61 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
62 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 62 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
63 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 63 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
64 QColor defaultTodoDueTodayColor = QColor(255,220,100); 64 QColor defaultTodoDueTodayColor = QColor(255,220,100);
65 QColor defaultTodoOverdueColor = QColor(255,153,125); 65 QColor defaultTodoOverdueColor = QColor(255,153,125);
66 QColor defaultTodoRunColor = QColor(99,194,30); 66 QColor defaultTodoRunColor = QColor(99,194,30);
67 KPrefs::setCurrentGroup("General"); 67 KPrefs::setCurrentGroup("General");
68 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 68 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
69 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 69 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
70 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 70 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
71 addItemBool("ShowIconSearch",&mShowIconSearch,true); 71 addItemBool("ShowIconSearch",&mShowIconSearch,true);
72 addItemBool("ShowIconList",&mShowIconList,true); 72 addItemBool("ShowIconList",&mShowIconList,true);
73 addItemBool("ShowIconDay1",&mShowIconDay1,true); 73 addItemBool("ShowIconDay1",&mShowIconDay1,true);
74 addItemBool("ShowIconDay5",&mShowIconDay5,true); 74 addItemBool("ShowIconDay5",&mShowIconDay5,true);
75 addItemBool("ShowIconDay6",&mShowIconDay6,true); 75 addItemBool("ShowIconDay6",&mShowIconDay6,true);
76 addItemBool("ShowIconDay7",&mShowIconDay7,true); 76 addItemBool("ShowIconDay7",&mShowIconDay7,true);
77 addItemBool("ShowIconMonth",&mShowIconMonth,true); 77 addItemBool("ShowIconMonth",&mShowIconMonth,true);
78 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 78 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
79 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 79 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
80 addItemBool("ShowIconBack",&mShowIconBack,true); 80 addItemBool("ShowIconBack",&mShowIconBack,true);
81 addItemBool("ShowIconToday",&mShowIconToday,true); 81 addItemBool("ShowIconToday",&mShowIconToday,true);
82 addItemBool("ShowIconForward",&mShowIconForward,true); 82 addItemBool("ShowIconForward",&mShowIconForward,true);
83 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 83 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
84 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 84 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
85 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 85 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
86 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 86 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
87 addItemBool("ShowIconNext",&mShowIconNext,true); 87 addItemBool("ShowIconNext",&mShowIconNext,true);
88 addItemBool("ShowIconJournal",&mShowIconJournal,true); 88 addItemBool("ShowIconJournal",&mShowIconJournal,true);
89 addItemBool("ShowIconStretch",&mShowIconStretch,true); 89 addItemBool("ShowIconStretch",&mShowIconStretch,true);
90 addItemBool("ShowIconFilter",&mShowIconFilter,false); 90 addItemBool("ShowIconFilter",&mShowIconFilter,false);
91 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 91 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
92 92
93 bool addIcons = false; 93 bool addIcons = false;
94#ifdef DESKTOP_VERSION 94#ifdef DESKTOP_VERSION
95 addIcons = true; 95 addIcons = true;
96#endif 96#endif
97 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 97 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
98 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 98 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
99 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 99 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
100 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 100 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
101 101
102 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 102 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
103 103
104 addItemBool("AskForQuit",&mAskForQuit,false); 104 addItemBool("AskForQuit",&mAskForQuit,false);
105 105
106#ifndef DESKTOP_VERSION 106#ifndef DESKTOP_VERSION
107 addItemBool("ShowFullMenu",&mShowFullMenu,false); 107 addItemBool("ShowFullMenu",&mShowFullMenu,false);
108#else 108#else
109 addItemBool("ShowFullMenu",&mShowFullMenu,true); 109 addItemBool("ShowFullMenu",&mShowFullMenu,true);
110#endif 110#endif
111 addItemBool("ToolBarHor",&mToolBarHor, true ); 111 addItemBool("ToolBarHor",&mToolBarHor, true );
112 addItemBool("ToolBarUp",&mToolBarUp, false ); 112 addItemBool("ToolBarUp",&mToolBarUp, false );
113 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 113 addItemBool("ToolBarHorV",&mToolBarHorV, true );
114 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 114 addItemBool("ToolBarUpV",&mToolBarUpV, false );
115 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 115 addItemBool("ToolBarHorN",&mToolBarHorN, true );
116 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 116 addItemBool("ToolBarUpN",&mToolBarUpN, false );
117 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 117 addItemBool("ToolBarHorF",&mToolBarHorF, true );
118 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 118 addItemBool("ToolBarUpF",&mToolBarUpF, false );
119 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 119 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
120 addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false ); 120 addItemBool("WhatsNextTime2Lines",&mWhatsNextTime2Lines, false );
121 addItemInt("Whats Next Days",&mWhatsNextDays,3); 121 addItemInt("Whats Next Days",&mWhatsNextDays,3);
122 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 122 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
123 123
124 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 124 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
125 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 125 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
126 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 126 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
127 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 127 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
128 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 128 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
129 addItemInt("AllDay Size",&mAllDaySize,28); 129 addItemInt("AllDay Size",&mAllDaySize,28);
130 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 130 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
131 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 131 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
132 132
133 addItemStringList("LocationDefaults",&mLocationDefaults ); 133 addItemStringList("LocationDefaults",&mLocationDefaults );
134 addItemStringList("EventSummary User",&mEventSummaryUser); 134 addItemStringList("EventSummary User",&mEventSummaryUser);
135 addItemStringList("TodoSummary User",&mTodoSummaryUser); 135 addItemStringList("TodoSummary User",&mTodoSummaryUser);
136 addItemStringList("JournalSummary User",&mJournalSummaryUser); 136 addItemStringList("JournalSummary User",&mJournalSummaryUser);
137 137
138 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 138 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
139 addItemBool("Enable Project View",&mEnableProjectView,false); 139 addItemBool("Enable Project View",&mEnableProjectView,false);
140 addItemBool("Auto Save",&mAutoSave,false); 140 addItemBool("Auto Save",&mAutoSave,false);
141 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 141 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
142 addItemBool("Confirm Deletes",&mConfirm,true); 142 addItemBool("Confirm Deletes",&mConfirm,true);
143 addItemString("Archive File",&mArchiveFile); 143 addItemString("Archive File",&mArchiveFile);
144 addItemString("Html Export File",&mHtmlExportFile, 144 addItemString("Html Export File",&mHtmlExportFile,
145 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 145 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
146 addItemBool("Html With Save",&mHtmlWithSave,false); 146 addItemBool("Html With Save",&mHtmlWithSave,false);
147 147
148 KPrefs::setCurrentGroup("Personal Settings"); 148 KPrefs::setCurrentGroup("Personal Settings");
149 149
150 addItemInt("Mail Client",&mMailClient,MailClientKMail); 150 addItemInt("Mail Client",&mMailClient,MailClientKMail);
151 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 151 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
152 addItemBool("Bcc",&mBcc,false); 152 addItemBool("Bcc",&mBcc,false);
153 153
154 KPrefs::setCurrentGroup("Time & Date"); 154 KPrefs::setCurrentGroup("Time & Date");
155 155
156 156
157 addItemInt("Default Start Time",&mStartTime,10); 157 addItemInt("Default Start Time",&mStartTime,10);
158 addItemInt("Default Duration",&mDefaultDuration,2); 158 addItemInt("Default Duration",&mDefaultDuration,2);
159 addItemInt("Default Alarm Time",&mAlarmTime,3); 159 addItemInt("Default Alarm Time",&mAlarmTime,3);
160 KPrefs::setCurrentGroup("AlarmSettings"); 160 KPrefs::setCurrentGroup("AlarmSettings");
161 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 161 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
162 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 162 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
163 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 163 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
164 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 164 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
165 165
166 166
167 KPrefs::setCurrentGroup("Calendar"); 167 KPrefs::setCurrentGroup("Calendar");
168 168
169 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 169 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
170 170
171 KPrefs::setCurrentGroup("Fonts"); 171 KPrefs::setCurrentGroup("Fonts");
172 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 172 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
173 QFont fon = KGlobalSettings::generalFont(); 173 QFont fon = KGlobalSettings::generalFont();
174 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 174 addItemFont("TimeBar Font",&mTimeBarFont,fon );
175 addItemFont("MonthView Font",&mMonthViewFont,fon); 175 addItemFont("MonthView Font",&mMonthViewFont,fon);
176 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 176 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
177 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 177 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
178 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 178 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
179 addItemFont("TodoView Font",&mTodoViewFont,fon); 179 addItemFont("TodoView Font",&mTodoViewFont,fon);
180 addItemFont("ListView Font",&mListViewFont,fon); 180 addItemFont("ListView Font",&mListViewFont,fon);
181 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 181 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
182 addItemFont("EditBox Font",&mEditBoxFont,fon); 182 addItemFont("EditBox Font",&mEditBoxFont,fon);
183 addItemFont("JournalView Font",&mJornalViewFont,fon); 183 addItemFont("JournalView Font",&mJornalViewFont,fon);
184 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 184 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
185 addItemFont("EventView Font",&mEventViewFont,fon); 185 addItemFont("EventView Font",&mEventViewFont,fon);
186 186
187 KPrefs::setCurrentGroup("RemoteSyncing"); 187 KPrefs::setCurrentGroup("RemoteSyncing");
188 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 188 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
189 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 189 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
190 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 190 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
191 addItemInt("LastSyncTime",&mLastSyncTime,0); 191 addItemInt("LastSyncTime",&mLastSyncTime,0);
192 192
193#ifdef _WIN32_ 193#ifdef _WIN32_
194 QString hdp= locateLocal("data","korganizer")+"\\\\"; 194 QString hdp= locateLocal("data","korganizer")+"\\\\";
195#else 195#else
196 QString hdp= locateLocal("data","korganizer")+"/"; 196 QString hdp= locateLocal("data","korganizer")+"/";
197#endif 197#endif
198 198
199 KPrefs::setCurrentGroup("LoadSaveFileNames"); 199 KPrefs::setCurrentGroup("LoadSaveFileNames");
200 200
201 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 201 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
202 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 202 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
203 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 203 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
204 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 204 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
205 205
206 206
207 KPrefs::setCurrentGroup("Locale"); 207 KPrefs::setCurrentGroup("Locale");
208 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 208 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
209 209
210 210
211 KPrefs::setCurrentGroup("Colors"); 211 KPrefs::setCurrentGroup("Colors");
212 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 212 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
213 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 213 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
214 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 214 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
215 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 215 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
216 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 216 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
217 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 217 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
218 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 218 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
219 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 219 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
220 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 220 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
221 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 221 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
222 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 222 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
223 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 223 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
224 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 224 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
225 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 225 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
226 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 226 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
227 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 227 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
228 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 228 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
229 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 229 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
230 addItemBool("UseAppColors",&mUseAppColors,false); 230 addItemBool("UseAppColors",&mUseAppColors,false);
231 231
232 232
233 KPrefs::setCurrentGroup("Conflicts"); 233 KPrefs::setCurrentGroup("Conflicts");
234 addItemBool("EnableAutoDetect",&mDetectConflicts,true); 234 addItemBool("EnableAutoDetect",&mDetectConflicts,true);
235 addItemBool("CheckConflictsFree",&mIncludeFree,true); 235 addItemBool("CheckConflictsFree",&mIncludeFree,true);
236 addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false); 236 addItemBool("CheckConflictsAllDayAllDay",&mCheckConflictsAllDayAllDay,false);
237 addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false); 237 addItemBool("CheckConflictsAllDayNonAD",&mCheckConflictsAllDayNonAD,false);
238 addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false); 238 addItemBool("CheckConflictsNonADAllDay",&mCheckConflictsNonADAllDay,false);
239 addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true); 239 addItemBool("CheckConflictsNonADNonAD",&mCheckConflictsNonADNonAD,true);
240 addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" ); 240 addItemString("FilterConflictEditItem", &mFilterConflictEditItem ,"nofilter" );
241 addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" ); 241 addItemString("FilterConflictAllItem", &mFilterConflictAllItem ,"nofilter" );
242 242
243 KPrefs::setCurrentGroup("Views"); 243 KPrefs::setCurrentGroup("Views");
244 addItemBool("Block Popup Menu",&mBlockPopupMenu,false); 244 addItemBool("Block Popup Menu",&mBlockPopupMenu,false);
245 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 245 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
246 addItemInt("Hour Size",&mHourSize,8); 246 addItemInt("Hour Size",&mHourSize,8);
247 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 247 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
248 addItemBool("ShowLongAllday",&mLongAllday,true); 248 addItemBool("ShowLongAllday",&mLongAllday,true);
249 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 249 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
250 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 250 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
251 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 251 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
252 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 252 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
253 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 253 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
254 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 254 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
255#ifdef DESKTOP_VERION 255#ifdef DESKTOP_VERION
256 addItemBool("Enable ToolTips",&mEnableToolTips,true); 256 addItemBool("Enable ToolTips",&mEnableToolTips,true);
257#else 257#else
258 addItemBool("Enable ToolTips",&mEnableToolTips,false); 258 addItemBool("Enable ToolTips",&mEnableToolTips,false);
259#endif 259#endif
260 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 260 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
261 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 261 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
262 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 262 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
263 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 263 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
264 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 264 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
265 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 265 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
266 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 266 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
267 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 267 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
268 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 268 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
269 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 269 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
270 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 270 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
271 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 271 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
272 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 272 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
273 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 273 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
274 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 274 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
275 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 275 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
276 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 276 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
277 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 277 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
278 addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false); 278 addItemBool("MonthViewWeekRowlayout",&mMonthViewWeekRowlayout,false);
279 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 279 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
280 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 280 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
281#ifdef DESKTOP_VERSION 281#ifdef DESKTOP_VERSION
282 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 282 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
283#else 283#else
284 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 284 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
285#endif 285#endif
286 addItemInt("Day Begins",&mDayBegins,7); 286 addItemInt("Day Begins",&mDayBegins,7);
287 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 287 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
288 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 288 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
289 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 289 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
290 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 290 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
291 291
292 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 292 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
293 addItemBool("Full View Month",&mFullViewMonth,true); 293 addItemBool("Full View Month",&mFullViewMonth,true);
294 addItemBool("Full View Todo",&mFullViewTodo,true); 294 addItemBool("Full View Todo",&mFullViewTodo,true);
295 addItemBool("Quick Todo",&mEnableQuickTodo,false); 295 addItemBool("Quick Todo",&mEnableQuickTodo,false);
296 296
297 addItemInt("Next X Days",&mNextXDays,3); 297 addItemInt("Next X Days",&mNextXDays,3);
298 298
299 KPrefs::setCurrentGroup("Printer"); 299 KPrefs::setCurrentGroup("Printer");
300 300
301 KPrefs::setCurrentGroup("Layout"); 301 KPrefs::setCurrentGroup("Layout");
302 302
303 addItemBool("CompactDialogs",&mCompactDialogs,false); 303 addItemBool("CompactDialogs",&mCompactDialogs,false);
304 addItemBool("VerticalScreen",&mVerticalScreen,true); 304 addItemBool("VerticalScreen",&mVerticalScreen,true);
305 305
306 KPrefs::setCurrentGroup("KOrganizer Plugins"); 306 KPrefs::setCurrentGroup("KOrganizer Plugins");
307 307
308 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 308 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
309 309
310 KPrefs::setCurrentGroup("Group Scheduling"); 310 KPrefs::setCurrentGroup("Group Scheduling");
311 311
312 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 312 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
313 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 313 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
314 addItemStringList("AdditionalMails",&mAdditionalMails,""); 314 addItemStringList("AdditionalMails",&mAdditionalMails,"");
315 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 315 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
316 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 316 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
317 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 317 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
318 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 318 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
319 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 319 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
320 320
321 KPrefs::setCurrentGroup( "Editors" ); 321 KPrefs::setCurrentGroup( "Editors" );
322 322
323 addItemStringList( "EventTemplates", &mEventTemplates ); 323 addItemStringList( "EventTemplates", &mEventTemplates );
324 addItemStringList( "TodoTemplates", &mTodoTemplates ); 324 addItemStringList( "TodoTemplates", &mTodoTemplates );
325 325
326 addItemInt("DestinationPolicy",&mDestination,standardDestination); 326 addItemInt("DestinationPolicy",&mDestination,standardDestination);
327 327
328 KPrefs::setCurrentGroup( "ViewOptions" ); 328 KPrefs::setCurrentGroup( "ViewOptions" );
329 addItemBool("EVshowDetails",&mEVshowDetails,true); 329 addItemBool("EVshowDetails",&mEVshowDetails,true);
330 addItemBool("EVshowCreated",&mEVshowCreated,true); 330 addItemBool("EVshowCreated",&mEVshowCreated,true);
331 addItemBool("EVshowChanged",&mEVshowChanged,true); 331 addItemBool("EVshowChanged",&mEVshowChanged,true);
332 addItemBool("WTshowDetails",&mWTshowDetails,false); 332 addItemBool("WTshowDetails",&mWTshowDetails,false);
333 addItemBool("WTshowCreated",&mWTshowCreated,false); 333 addItemBool("WTshowCreated",&mWTshowCreated,false);
334 addItemBool("WTshowChanged",&mWTshowChanged,false); 334 addItemBool("WTshowChanged",&mWTshowChanged,false);
335 mCalendars.setAutoDelete( true ); 335 mCalendars.setAutoDelete( true );
336} 336}
337 337
338 338
339KOPrefs::~KOPrefs() 339KOPrefs::~KOPrefs()
340{ 340{
341 if (mInstance == this) 341 if (mInstance == this)
342 mInstance = insd.setObject(0); 342 mInstance = insd.setObject(0);
343 mCalendars.setAutoDelete( true ); 343 mCalendars.setAutoDelete( true );
344 mCalendars.clear(); 344 mCalendars.clear();
345 //qDebug("KOPrefs::~KOPrefs() "); 345 //qDebug("KOPrefs::~KOPrefs() ");
346} 346}
347 347
348 348
349KOPrefs *KOPrefs::instance() 349KOPrefs *KOPrefs::instance()
350{ 350{
351 if (!mInstance) { 351 if (!mInstance) {
352 mInstance = insd.setObject(new KOPrefs()); 352 mInstance = insd.setObject(new KOPrefs());
353 mInstance->readConfig(); 353 mInstance->readConfig();
354 } 354 }
355 355
356 return mInstance; 356 return mInstance;
357} 357}
358 358
359void KOPrefs::usrSetDefaults() 359void KOPrefs::usrSetDefaults()
360{ 360{
361 361
362} 362}
363 363
364void KOPrefs::fillMailDefaults() 364void KOPrefs::fillMailDefaults()
365{ 365{
366 if (mName.isEmpty()) mName = i18n("Anonymous"); 366 if (mName.isEmpty()) mName = i18n("Anonymous");
367 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 367 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
368} 368}
369 369
370void KOPrefs::setTimeZoneIdDefault() 370void KOPrefs::setTimeZoneIdDefault()
371{ 371{
372 ; 372 ;
373} 373}
374 374
375void KOPrefs::setAllDefaults() 375void KOPrefs::setAllDefaults()
376{ 376{
377 setCategoryDefaults(); 377 setCategoryDefaults();
378 mEventSummaryUser = getDefaultList() ; 378 mEventSummaryUser = getDefaultList() ;
379 mTodoSummaryUser = getDefaultList() ; 379 mTodoSummaryUser = getDefaultList() ;
380 mJournalSummaryUser = getDefaultList() ; 380 mJournalSummaryUser = getDefaultList() ;
381 mLocationDefaults = getLocationDefaultList(); 381 mLocationDefaults = getLocationDefaultList();
382} 382}
383 383
384void KOPrefs::setCategoryDefaults() 384void KOPrefs::setCategoryDefaults()
385{ 385{
386 mCustomCategories.clear(); 386 mCustomCategories.clear();
387 mCustomCategories = getDefaultList(); 387 mCustomCategories = getDefaultList();
388 388
389 QStringList::Iterator it; 389 QStringList::Iterator it;
390 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 390 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
391 setCategoryColor(*it,mDefaultCategoryColor); 391 setCategoryColor(*it,mDefaultCategoryColor);
392 } 392 }
393} 393}
394QStringList KOPrefs::getLocationDefaultList() 394QStringList KOPrefs::getLocationDefaultList()
395{ 395{
396 QStringList retval ; 396 QStringList retval ;
397 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 397 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
398 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 398 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
399 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 399 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
400 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 400 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
401 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 401 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
402 402
403 retval.sort(); 403 retval.sort();
404 return retval; 404 return retval;
405} 405}
406QStringList KOPrefs::getDefaultList() 406QStringList KOPrefs::getDefaultList()
407{ 407{
408 QStringList retval ; 408 QStringList retval ;
409 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer") 409 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Customer")
410 << i18n("Break") 410 << i18n("Break")
411 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts") 411 << i18n("Family") << i18n("Favorites") << i18n("Fishing") << i18n("Gifts")
412 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") 412 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts")
413 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal") 413 << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner") << i18n("Personal")
414 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping") 414 << i18n("PHB") << i18n("Phone Calls") << i18n("Shopping")
415 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV") 415 << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")
416 << i18n("Vacation") ; 416 << i18n("Vacation") ;
417 retval.sort(); 417 retval.sort();
418 //qDebug("cat %s ", retval.join("-").latin1()); 418 //qDebug("cat %s ", retval.join("-").latin1());
419 return retval; 419 return retval;
420} 420}
421// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema") 421// << i18n("Business Travel") << i18n("Education") << i18n("Hiking") << i18n("Hunting") << i18n("Recurring") << i18n("Personal Travel") << i18n("Speach") << i18n("Festival") << i18n("Competition")<< i18n("Party")<< i18n("Projects")<< i18n("Kids") << i18n("Special Occasion")<< i18n("Breakfast")<< i18n("Dinner") << i18n("Lunch")<< i18n("University")<< i18n("School")<< i18n("Flight")<< i18n("Key Customer") << i18n("VIP") << i18n("SyncEvent") << i18n("Cinema")
422void KOPrefs::usrReadConfig() 422void KOPrefs::usrReadConfig()
423{ 423{
424 config()->setGroup("General"); 424 config()->setGroup("General");
425 425
426 //qDebug("KOPrefs::usrReadConfig() "); 426 //qDebug("KOPrefs::usrReadConfig() ");
427 mCustomCategories = config()->readListEntry("Custom Categories"); 427 mCustomCategories = config()->readListEntry("Custom Categories");
428 mOldLoadedLanguage = mOldLanguage ; 428 mOldLoadedLanguage = mOldLanguage ;
429 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 429 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
430 if (mLocationDefaults.isEmpty()) { 430 if (mLocationDefaults.isEmpty()) {
431 mLocationDefaults = getLocationDefaultList(); 431 mLocationDefaults = getLocationDefaultList();
432 } 432 }
433 433
434 if (mEventSummaryUser.isEmpty()) { 434 if (mEventSummaryUser.isEmpty()) {
435 mEventSummaryUser = getDefaultList() ; 435 mEventSummaryUser = getDefaultList() ;
436 } 436 }
437 if (mTodoSummaryUser.isEmpty()) { 437 if (mTodoSummaryUser.isEmpty()) {
438 mTodoSummaryUser = getDefaultList() ; 438 mTodoSummaryUser = getDefaultList() ;
439 } 439 }
440 440
441 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 441 if (mCustomCategories.isEmpty()) setCategoryDefaults();
442 442
443 config()->setGroup("Personal Settings"); 443 config()->setGroup("Personal Settings");
444 mName = config()->readEntry("user_name",""); 444 mName = config()->readEntry("user_name","");
445 mEmail = config()->readEntry("user_email",""); 445 mEmail = config()->readEntry("user_email","");
446 fillMailDefaults(); 446 fillMailDefaults();
447 447
448 config()->setGroup("Category Colors"); 448 config()->setGroup("Category Colors");
449 QStringList::Iterator it; 449 QStringList::Iterator it;
450 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 450 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
451 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 451 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
452 452
453 } 453 }
454 KConfig fc (locateLocal("config","kopicalendarrc")); 454 KConfig fc (locateLocal("config","kopicalendarrc"));
455 fc.setGroup("CC"); 455 fc.setGroup("CC");
456 int numCals = fc.readNumEntry("NumberCalendars",0 ); 456 int numCals = fc.readNumEntry("NumberCalendars",0 );
457 mNextAvailableCalendar = 1; 457 mNextAvailableCalendar = 1;
458 if ( numCals == 0 ) { 458 if ( numCals == 0 ) {
459 KopiCalendarFile *kkf = getNewCalendar(); 459 KopiCalendarFile *kkf = getNewCalendar();
460 kkf->isStandard = true; 460 kkf->isStandard = true;
461 kkf->mName = i18n("Standard"); 461 kkf->mName = i18n("Standard");
462 kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) ); 462 kkf->mFileName = QDir::convertSeparators( locateLocal( "data", "korganizer/mycalendar.ics" ) );
463 } 463 }
464 while ( mNextAvailableCalendar <= numCals ) { 464 while ( mNextAvailableCalendar <= numCals ) {
465 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 465 //qDebug("Read cal #%d ", mNextAvailableCalendar );
466 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 466 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
467 KopiCalendarFile *kkf = getNewCalendar(); 467 KopiCalendarFile *kkf = getNewCalendar();
468 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 468 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
469 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 469 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
470 kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false ); 470 kkf->isRelative = fc.readBoolEntry( prefix+"_isRelative", false );
471 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 471 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
472 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 472 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
473 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 473 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
474 kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) ); 474 kkf->mFileName = QDir::convertSeparators( fc.readEntry( prefix+"_FileName", kkf->mFileName) );
475 kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) ); 475 kkf->mSavedFileName = QDir::convertSeparators( fc.readEntry( prefix+"_SavedFileName", kkf->mFileName) );
476 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 476 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
477 if ( kkf->mCalNumber == 1 ) { 477 if ( kkf->mCalNumber == 1 ) {
478 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 478 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
479 } 479 }
480 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() ); 480 //qDebug("NAME %s %s", kkf->mName.latin1(), i18n("Birthdays").latin1() );
481 if ( kkf->mName == i18n("Birthdays") ) { 481 if ( kkf->mName == i18n("Birthdays") ) {
482 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" ); 482 kkf->mFileName = locateLocal( "data", "korganizer/birthdays.ics" );
483 } 483 }
484 if ( kkf->isRelative ) 484 if ( kkf->isRelative )
485 kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName ); 485 kkf->mFileName = QDir::convertSeparators( KGlobalSettings::calendarDir() + kkf->mSavedFileName );
486 } 486 }
487 487
488 KPimPrefs::usrReadConfig(); 488 KPimPrefs::usrReadConfig();
489} 489}
490 490
491KopiCalendarFile * KOPrefs::getCalendar( int num ) 491KopiCalendarFile * KOPrefs::getCalendar( int num )
492{ 492{
493 return mDefCalColors[num-1]; 493 return mDefCalColors[num-1];
494} 494}
495 495
496KopiCalendarFile * KOPrefs::getNewCalendar() 496KopiCalendarFile * KOPrefs::getNewCalendar()
497{ 497{
498 KopiCalendarFile * kkf = new KopiCalendarFile(); 498 KopiCalendarFile * kkf = new KopiCalendarFile();
499 kkf->mCalNumber = mNextAvailableCalendar; 499 kkf->mCalNumber = mNextAvailableCalendar;
500 mDefCalColors.resize( mNextAvailableCalendar ); 500 mDefCalColors.resize( mNextAvailableCalendar );
501 mDefCalColors[mNextAvailableCalendar-1] = kkf; 501 mDefCalColors[mNextAvailableCalendar-1] = kkf;
502 ++mNextAvailableCalendar; 502 ++mNextAvailableCalendar;
503 kkf->mDefaultColor = mEventColor; 503 kkf->mDefaultColor = mEventColor;
504 kkf->mName = i18n("New Calendar"); 504 kkf->mName = i18n("New Calendar");
505 mCalendars.append( kkf ); 505 mCalendars.append( kkf );
506 return kkf; 506 return kkf;
507} 507}
508void KOPrefs::deleteCalendar( int num ) 508void KOPrefs::deleteCalendar( int num )
509{ 509{
510 KopiCalendarFile * kkf = mCalendars.first(); 510 KopiCalendarFile * kkf = mCalendars.first();
511 while ( kkf ) { 511 while ( kkf ) {
512 if ( kkf->mCalNumber == num ) { 512 if ( kkf->mCalNumber == num ) {
513 qDebug("KOPrefs::deleteCalendar %d ", num ); 513 qDebug("KOPrefs::deleteCalendar %d ", num );
514 mCalendars.remove( kkf ); 514 mCalendars.remove( kkf );
515 delete kkf; 515 delete kkf;
516 return; 516 return;
517 } 517 }
518 kkf = mCalendars.next(); 518 kkf = mCalendars.next();
519 } 519 }
520} 520}
521int KOPrefs::getCalendarID( const QString & name ) 521int KOPrefs::getCalendarID( const QString & name )
522{ 522{
523 KopiCalendarFile * kkf = mCalendars.first(); 523 KopiCalendarFile * kkf = mCalendars.first();
524 while ( kkf ) { 524 while ( kkf ) {
525 if ( name == kkf->mName) 525 if ( name == kkf->mName)
526 return kkf->mCalNumber; 526 return kkf->mCalNumber;
527 kkf = mCalendars.next(); 527 kkf = mCalendars.next();
528 } 528 }
529 return 1; 529 return 1;
530} 530}
531int KOPrefs::getFuzzyCalendarID( const QString & name )
532{
533 KopiCalendarFile * kkf = mCalendars.first();
534 while ( kkf ) {
535 if ( name.lower() == kkf->mName.lower())
536 return kkf->mCalNumber;
537 kkf = mCalendars.next();
538 }
539 return 0;
540}
531QString KOPrefs::calName( int calNum) const 541QString KOPrefs::calName( int calNum) const
532{ 542{
533 return (mDefCalColors[calNum-1])->mName; 543 return (mDefCalColors[calNum-1])->mName;
534} 544}
535QColor KOPrefs::defaultColor( int calNum ) const 545QColor KOPrefs::defaultColor( int calNum ) const
536{ 546{
537 if ( calNum == 1 ) return mEventColor; 547 if ( calNum == 1 ) return mEventColor;
538 return (mDefCalColors[calNum-1])->mDefaultColor; 548 return (mDefCalColors[calNum-1])->mDefaultColor;
539} 549}
540void KOPrefs::usrWriteConfig() 550void KOPrefs::usrWriteConfig()
541{ 551{
542 config()->setGroup("General"); 552 config()->setGroup("General");
543 config()->writeEntry("Custom Categories",mCustomCategories); 553 config()->writeEntry("Custom Categories",mCustomCategories);
544 554
545 config()->setGroup("Personal Settings"); 555 config()->setGroup("Personal Settings");
546 config()->writeEntry("user_name",mName); 556 config()->writeEntry("user_name",mName);
547 config()->writeEntry("user_email",mEmail); 557 config()->writeEntry("user_email",mEmail);
548 558
549 config()->setGroup("Category Colors"); 559 config()->setGroup("Category Colors");
550 QDictIterator<QColor> it(mCategoryColors); 560 QDictIterator<QColor> it(mCategoryColors);
551 while (it.current()) { 561 while (it.current()) {
552 config()->writeEntry(it.currentKey(),*(it.current())); 562 config()->writeEntry(it.currentKey(),*(it.current()));
553 ++it; 563 ++it;
554 } 564 }
555 KConfig fc (locateLocal("config","kopicalendarrc")); 565 KConfig fc (locateLocal("config","kopicalendarrc"));
556 fc.setGroup("CC"); 566 fc.setGroup("CC");
557 fc.deleteGroup( "CC"); 567 fc.deleteGroup( "CC");
558 fc.setGroup("CC"); 568 fc.setGroup("CC");
559 fc.writeEntry("NumberCalendars",mCalendars.count()); 569 fc.writeEntry("NumberCalendars",mCalendars.count());
560 int numCal = 1; 570 int numCal = 1;
561 int writeCal = 0; 571 int writeCal = 0;
562 while ( numCal < mNextAvailableCalendar ) { 572 while ( numCal < mNextAvailableCalendar ) {
563 KopiCalendarFile * kkf = mCalendars.first(); 573 KopiCalendarFile * kkf = mCalendars.first();
564 while ( kkf ) { 574 while ( kkf ) {
565 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 575 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
566 if ( kkf->mCalNumber == numCal ) { 576 if ( kkf->mCalNumber == numCal ) {
567 ++writeCal; 577 ++writeCal;
568 //qDebug("Write calendar %d %d ", numCal , writeCal); 578 //qDebug("Write calendar %d %d ", numCal , writeCal);
569 QString prefix = "Cal_" + QString::number( writeCal ); 579 QString prefix = "Cal_" + QString::number( writeCal );
570 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 580 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
571 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 581 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
572 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 582 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
573 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 583 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
574 fc.writeEntry( prefix+"_isRelative", kkf->isRelative ); 584 fc.writeEntry( prefix+"_isRelative", kkf->isRelative );
575 fc.writeEntry( prefix+"_Name", kkf->mName); 585 fc.writeEntry( prefix+"_Name", kkf->mName);
576 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 586 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
577 fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName); 587 fc.writeEntry( prefix+"_SavedFileName", kkf->mSavedFileName);
578 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 588 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
579 } 589 }
580 kkf = mCalendars.next(); 590 kkf = mCalendars.next();
581 } 591 }
582 ++numCal; 592 ++numCal;
583 } 593 }
584 fc.sync(); 594 fc.sync();
585 KPimPrefs::usrWriteConfig(); 595 KPimPrefs::usrWriteConfig();
586} 596}
587 597
588void KOPrefs::setCategoryColor(QString cat,const QColor & color) 598void KOPrefs::setCategoryColor(QString cat,const QColor & color)
589{ 599{
590 mCategoryColors.replace(cat,new QColor(color)); 600 mCategoryColors.replace(cat,new QColor(color));
591} 601}
592 602
593QColor *KOPrefs::categoryColor(QString cat) 603QColor *KOPrefs::categoryColor(QString cat)
594{ 604{
595 QColor *color = 0; 605 QColor *color = 0;
596 606
597 if (!cat.isEmpty()) color = mCategoryColors[cat]; 607 if (!cat.isEmpty()) color = mCategoryColors[cat];
598 608
599 if (color) return color; 609 if (color) return color;
600 else return &mDefaultCategoryColor; 610 else return &mDefaultCategoryColor;
601} 611}
602 612
603void KOPrefs::setFullName(const QString &name) 613void KOPrefs::setFullName(const QString &name)
604{ 614{
605 mName = name; 615 mName = name;
606} 616}
607 617
608void KOPrefs::setEmail(const QString &email) 618void KOPrefs::setEmail(const QString &email)
609{ 619{
610 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 620 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
611 mEmail = email; 621 mEmail = email;
612} 622}
613 623
614QString KOPrefs::fullName() 624QString KOPrefs::fullName()
615{ 625{
616 if (mEmailControlCenter) { 626 if (mEmailControlCenter) {
617 KEMailSettings settings; 627 KEMailSettings settings;
618 return settings.getSetting(KEMailSettings::RealName); 628 return settings.getSetting(KEMailSettings::RealName);
619 } else { 629 } else {
620 return mName; 630 return mName;
621 } 631 }
622} 632}
623 633
624QString KOPrefs::email() 634QString KOPrefs::email()
625{ 635{
626 if (mEmailControlCenter) { 636 if (mEmailControlCenter) {
627 KEMailSettings settings; 637 KEMailSettings settings;
628 return settings.getSetting(KEMailSettings::EmailAddress); 638 return settings.getSetting(KEMailSettings::EmailAddress);
629 } else { 639 } else {
630 return mEmail; 640 return mEmail;
631 } 641 }
632} 642}
633KConfig* KOPrefs::getConfig() 643KConfig* KOPrefs::getConfig()
634{ 644{
635 return config(); 645 return config();
636} 646}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index bac8010..70da096 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,376 +1,377 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mSavedFileName = "icalfile.ics"; 57 mSavedFileName = "icalfile.ics";
58 mCalNumber = 0; 58 mCalNumber = 0;
59 mDefaultColor = Qt::red; 59 mDefaultColor = Qt::red;
60 mErrorOnLoad = false; 60 mErrorOnLoad = false;
61 isRelative = false; 61 isRelative = false;
62 } 62 }
63 bool isStandard; 63 bool isStandard;
64 bool isEnabled; 64 bool isEnabled;
65 bool isAlarmEnabled; 65 bool isAlarmEnabled;
66 bool isReadOnly; 66 bool isReadOnly;
67 bool mErrorOnLoad; 67 bool mErrorOnLoad;
68 QString mName; 68 QString mName;
69 QString mFileName; 69 QString mFileName;
70 QString mSavedFileName; 70 QString mSavedFileName;
71 bool isRelative; 71 bool isRelative;
72 int mCalNumber; 72 int mCalNumber;
73 QColor mDefaultColor; 73 QColor mDefaultColor;
74 QDateTime mLoadDt; 74 QDateTime mLoadDt;
75}; 75};
76class KOPrefs : public KPimPrefs 76class KOPrefs : public KPimPrefs
77{ 77{
78 public: 78 public:
79 enum { FormatVCalendar, FormatICalendar }; 79 enum { FormatVCalendar, FormatICalendar };
80 enum { MailClientKMail, MailClientSendmail }; 80 enum { MailClientKMail, MailClientSendmail };
81 enum { IMIPDummy, IMIPKMail }; 81 enum { IMIPDummy, IMIPKMail };
82 enum { IMIPOutbox, IMIPdirectsend }; 82 enum { IMIPOutbox, IMIPdirectsend };
83 enum { neverAuto, addressbookAuto, selectedAuto }; 83 enum { neverAuto, addressbookAuto, selectedAuto };
84 enum { standardDestination, askDestination }; 84 enum { standardDestination, askDestination };
85 85
86 virtual ~KOPrefs(); 86 virtual ~KOPrefs();
87 87
88 /** Get instance of KOPrefs. It is made sure that there is only one 88 /** Get instance of KOPrefs. It is made sure that there is only one
89 instance. */ 89 instance. */
90 static KOPrefs *instance(); 90 static KOPrefs *instance();
91 91
92 /** Set preferences to default values */ 92 /** Set preferences to default values */
93 void usrSetDefaults(); 93 void usrSetDefaults();
94 94
95 /** Read preferences from config file */ 95 /** Read preferences from config file */
96 void usrReadConfig(); 96 void usrReadConfig();
97 97
98 /** Write preferences to config file */ 98 /** Write preferences to config file */
99 void usrWriteConfig(); 99 void usrWriteConfig();
100 void setCategoryDefaults(); 100 void setCategoryDefaults();
101 void setAllDefaults(); 101 void setAllDefaults();
102 KopiCalendarFile * getNewCalendar(); 102 KopiCalendarFile * getNewCalendar();
103 KopiCalendarFile * getCalendar( int ); 103 KopiCalendarFile * getCalendar( int );
104 void deleteCalendar( int ); 104 void deleteCalendar( int );
105 QColor defaultColor( int ) const; 105 QColor defaultColor( int ) const;
106 QString calName( int ) const; 106 QString calName( int ) const;
107 int getCalendarID( const QString & name ); 107 int getCalendarID( const QString & name );
108 int getFuzzyCalendarID( const QString & name );
108 protected: 109 protected:
109 void setTimeZoneIdDefault(); 110 void setTimeZoneIdDefault();
110 111
111 /** Fill empty mail fields with default values. */ 112 /** Fill empty mail fields with default values. */
112 void fillMailDefaults(); 113 void fillMailDefaults();
113 114
114 private: 115 private:
115 /** Constructor disabled for public. Use instance() to create a KOPrefs 116 /** Constructor disabled for public. Use instance() to create a KOPrefs
116 object. */ 117 object. */
117 KOPrefs(); 118 KOPrefs();
118 119
119 static KOPrefs *mInstance; 120 static KOPrefs *mInstance;
120 QStringList getDefaultList(); 121 QStringList getDefaultList();
121 QStringList getLocationDefaultList(); 122 QStringList getLocationDefaultList();
122 public: 123 public:
123 // preferences data 124 // preferences data
124 KConfig* getConfig(); 125 KConfig* getConfig();
125 void setFullName(const QString &); 126 void setFullName(const QString &);
126 QString fullName(); 127 QString fullName();
127 void setEmail(const QString &); 128 void setEmail(const QString &);
128 QString email(); 129 QString email();
129 130
130 QString mAdditional; 131 QString mAdditional;
131 132
132 bool mEmailControlCenter; 133 bool mEmailControlCenter;
133 134
134 bool mBcc; 135 bool mBcc;
135 bool mAutoSave; 136 bool mAutoSave;
136 int mAutoSaveInterval; 137 int mAutoSaveInterval;
137 bool mConfirm; 138 bool mConfirm;
138 139
139 bool mEnableGroupScheduling; 140 bool mEnableGroupScheduling;
140 bool mEnableProjectView; 141 bool mEnableProjectView;
141 142
142 int mDefaultFormat; 143 int mDefaultFormat;
143 int mMailClient; 144 int mMailClient;
144 145
145 int mStartTime; 146 int mStartTime;
146 int mDefaultDuration; 147 int mDefaultDuration;
147 int mAlarmTime; 148 int mAlarmTime;
148 149
149 int mWorkingHoursStart; 150 int mWorkingHoursStart;
150 int mWorkingHoursEnd; 151 int mWorkingHoursEnd;
151 bool mExcludeHolidays; 152 bool mExcludeHolidays;
152 bool mExcludeSaturdays; 153 bool mExcludeSaturdays;
153 bool mMarcusBainsShowSeconds; 154 bool mMarcusBainsShowSeconds;
154 155
155 QFont mTimeBarFont; 156 QFont mTimeBarFont;
156 QFont mMonthViewFont; 157 QFont mMonthViewFont;
157 QFont mAgendaViewFont; 158 QFont mAgendaViewFont;
158 QFont mMarcusBainsFont; 159 QFont mMarcusBainsFont;
159 QFont mTimeLabelsFont; 160 QFont mTimeLabelsFont;
160 QFont mTodoViewFont; 161 QFont mTodoViewFont;
161 QFont mListViewFont; 162 QFont mListViewFont;
162 QFont mDateNavigatorFont; 163 QFont mDateNavigatorFont;
163 QFont mEditBoxFont; 164 QFont mEditBoxFont;
164 QFont mJornalViewFont; 165 QFont mJornalViewFont;
165 QFont mWhatsNextFont; 166 QFont mWhatsNextFont;
166 QFont mEventViewFont; 167 QFont mEventViewFont;
167 168
168 169
169 170
170 171
171 QColor mHolidayColor; 172 QColor mHolidayColor;
172 QColor mHighlightColor; 173 QColor mHighlightColor;
173 QColor mEventColor; 174 QColor mEventColor;
174 QColor mTodoDoneColor; 175 QColor mTodoDoneColor;
175 QColor mAgendaBgColor; 176 QColor mAgendaBgColor;
176 QColor mWorkingHoursColor; 177 QColor mWorkingHoursColor;
177 QColor mTodoDueTodayColor; 178 QColor mTodoDueTodayColor;
178 QColor mTodoOverdueColor; 179 QColor mTodoOverdueColor;
179 QColor mTodoRunColor; 180 QColor mTodoRunColor;
180 QColor mMonthViewEvenColor; 181 QColor mMonthViewEvenColor;
181 QColor mMonthViewOddColor; 182 QColor mMonthViewOddColor;
182 QColor mMonthViewHolidayColor; 183 QColor mMonthViewHolidayColor;
183 bool mMonthViewUsesDayColors; 184 bool mMonthViewUsesDayColors;
184 bool mMonthViewSatSunTog; 185 bool mMonthViewSatSunTog;
185 bool mMonthViewWeek; 186 bool mMonthViewWeek;
186 bool mMonthViewWeekRowlayout; 187 bool mMonthViewWeekRowlayout;
187 QColor mAppColor1; 188 QColor mAppColor1;
188 QColor mAppColor2; 189 QColor mAppColor2;
189 bool mUseAppColors; 190 bool mUseAppColors;
190 191
191 int mDayBegins; 192 int mDayBegins;
192 int mHourSize; 193 int mHourSize;
193 int mAllDaySize; 194 int mAllDaySize;
194 bool mShowFullMenu; 195 bool mShowFullMenu;
195 bool mDailyRecur; 196 bool mDailyRecur;
196 bool mWeeklyRecur; 197 bool mWeeklyRecur;
197 bool mLongAllday; 198 bool mLongAllday;
198 bool mMonthDailyRecur; 199 bool mMonthDailyRecur;
199 bool mMonthWeeklyRecur; 200 bool mMonthWeeklyRecur;
200 bool mMonthShowIcons; 201 bool mMonthShowIcons;
201 bool mMonthShowTimes; 202 bool mMonthShowTimes;
202 bool mMonthShowShort; 203 bool mMonthShowShort;
203 bool mEnableToolTips; 204 bool mEnableToolTips;
204 bool mEnableMonthScroll; 205 bool mEnableMonthScroll;
205 bool mFullViewMonth; 206 bool mFullViewMonth;
206 bool mMonthViewUsesCategoryColor; 207 bool mMonthViewUsesCategoryColor;
207 bool mFullViewTodo; 208 bool mFullViewTodo;
208 bool mShowCompletedTodo; 209 bool mShowCompletedTodo;
209 bool mMarcusBainsEnabled; 210 bool mMarcusBainsEnabled;
210 int mNextXDays; 211 int mNextXDays;
211 int mWhatsNextDays; 212 int mWhatsNextDays;
212 bool mWhatsNextTime2Lines; 213 bool mWhatsNextTime2Lines;
213 int mWhatsNextPrios; 214 int mWhatsNextPrios;
214 bool mEnableQuickTodo; 215 bool mEnableQuickTodo;
215 216
216 bool mCompactDialogs; 217 bool mCompactDialogs;
217 bool mVerticalScreen; 218 bool mVerticalScreen;
218 219
219 bool mShowIconNewTodo; 220 bool mShowIconNewTodo;
220 bool mShowIconNewEvent; 221 bool mShowIconNewEvent;
221 bool mShowIconSearch; 222 bool mShowIconSearch;
222 bool mShowIconList; 223 bool mShowIconList;
223 bool mShowIconDay1; 224 bool mShowIconDay1;
224 bool mShowIconDay5; 225 bool mShowIconDay5;
225 bool mShowIconDay6; 226 bool mShowIconDay6;
226 bool mShowIconDay7; 227 bool mShowIconDay7;
227 bool mShowIconMonth; 228 bool mShowIconMonth;
228 bool mShowIconTodoview; 229 bool mShowIconTodoview;
229 bool mShowIconBackFast; 230 bool mShowIconBackFast;
230 bool mShowIconBack; 231 bool mShowIconBack;
231 bool mShowIconToday; 232 bool mShowIconToday;
232 bool mShowIconForward; 233 bool mShowIconForward;
233 bool mShowIconForwardFast; 234 bool mShowIconForwardFast;
234 bool mShowIconWhatsThis; 235 bool mShowIconWhatsThis;
235 bool mShowIconWeekNum; 236 bool mShowIconWeekNum;
236 bool mShowIconNextDays; 237 bool mShowIconNextDays;
237 bool mShowIconNext; 238 bool mShowIconNext;
238 bool mShowIconJournal; 239 bool mShowIconJournal;
239 bool mShowIconFilter; 240 bool mShowIconFilter;
240 bool mShowIconOnetoolbar; 241 bool mShowIconOnetoolbar;
241 bool mShowIconNavigator; 242 bool mShowIconNavigator;
242 bool mShowIconAllday; 243 bool mShowIconAllday;
243 bool mShowIconFilterview; 244 bool mShowIconFilterview;
244 bool mShowIconToggleFull; 245 bool mShowIconToggleFull;
245 246
246 bool mShowIconStretch; 247 bool mShowIconStretch;
247 248
248 bool mToolBarHor; 249 bool mToolBarHor;
249 bool mToolBarUp; 250 bool mToolBarUp;
250 bool mToolBarHorV; 251 bool mToolBarHorV;
251 bool mToolBarUpV; 252 bool mToolBarUpV;
252 bool mToolBarHorN; 253 bool mToolBarHorN;
253 bool mToolBarUpN; 254 bool mToolBarUpN;
254 bool mToolBarHorF; 255 bool mToolBarHorF;
255 bool mToolBarUpF; 256 bool mToolBarUpF;
256 bool mToolBarMiniIcons; 257 bool mToolBarMiniIcons;
257 258
258 bool mAskForQuit; 259 bool mAskForQuit;
259 bool mUsePassWd; 260 bool mUsePassWd;
260 bool mShowSyncEvents; 261 bool mShowSyncEvents;
261 bool mShowTodoInAgenda; 262 bool mShowTodoInAgenda;
262 bool mShowCompletedTodoInAgenda; 263 bool mShowCompletedTodoInAgenda;
263 bool mShowTimeInAgenda; 264 bool mShowTimeInAgenda;
264 bool mHideNonStartedTodos; 265 bool mHideNonStartedTodos;
265 266
266 bool mBlockPopupMenu; 267 bool mBlockPopupMenu;
267 268
268 int mLastSyncTime; 269 int mLastSyncTime;
269 void setCategoryColor(QString cat,const QColor & color); 270 void setCategoryColor(QString cat,const QColor & color);
270 QColor *categoryColor(QString cat); 271 QColor *categoryColor(QString cat);
271 272
272 QString mArchiveFile; 273 QString mArchiveFile;
273 QString mHtmlExportFile; 274 QString mHtmlExportFile;
274 bool mHtmlWithSave; 275 bool mHtmlWithSave;
275 276
276 QStringList mSelectedPlugins; 277 QStringList mSelectedPlugins;
277 278
278 QString mLastImportFile; 279 QString mLastImportFile;
279 QString mLastVcalFile; 280 QString mLastVcalFile;
280 QString mLastSaveFile; 281 QString mLastSaveFile;
281 QString mLastLoadFile; 282 QString mLastLoadFile;
282 283
283 284
284 QString mDefaultAlarmFile; 285 QString mDefaultAlarmFile;
285 int mIMIPScheduler; 286 int mIMIPScheduler;
286 int mIMIPSend; 287 int mIMIPSend;
287 QStringList mAdditionalMails; 288 QStringList mAdditionalMails;
288 int mIMIPAutoRefresh; 289 int mIMIPAutoRefresh;
289 int mIMIPAutoInsertReply; 290 int mIMIPAutoInsertReply;
290 int mIMIPAutoInsertRequest; 291 int mIMIPAutoInsertRequest;
291 int mIMIPAutoFreeBusy; 292 int mIMIPAutoFreeBusy;
292 int mIMIPAutoFreeBusyReply; 293 int mIMIPAutoFreeBusyReply;
293 294
294 QStringList mTodoTemplates; 295 QStringList mTodoTemplates;
295 QStringList mEventTemplates; 296 QStringList mEventTemplates;
296 297
297 int mDestination; 298 int mDestination;
298 299
299 300
300 bool mEditOnDoubleClick; 301 bool mEditOnDoubleClick;
301 bool mViewChangeHoldFullscreen; 302 bool mViewChangeHoldFullscreen;
302 bool mViewChangeHoldNonFullscreen; 303 bool mViewChangeHoldNonFullscreen;
303 bool mCenterOnCurrentTime; 304 bool mCenterOnCurrentTime;
304 bool mSetTimeToDayStartAt; 305 bool mSetTimeToDayStartAt;
305 bool mHighlightCurrentDay; 306 bool mHighlightCurrentDay;
306 bool mUseHighlightLightColor; 307 bool mUseHighlightLightColor;
307 bool mListViewMonthTimespan; 308 bool mListViewMonthTimespan;
308 bool mWNViewShowsParents; 309 bool mWNViewShowsParents;
309 bool mWNViewShowsPast; 310 bool mWNViewShowsPast;
310 bool mWNViewShowLocation; 311 bool mWNViewShowLocation;
311 bool mTodoViewShowsPercentage; 312 bool mTodoViewShowsPercentage;
312 bool mTodoViewUsesCatColors; 313 bool mTodoViewUsesCatColors;
313 bool mMonthViewUsesBigFont; 314 bool mMonthViewUsesBigFont;
314 bool mTodoViewUsesSmallFont; 315 bool mTodoViewUsesSmallFont;
315 bool mTodoViewUsesForegroundColor; 316 bool mTodoViewUsesForegroundColor;
316 bool mMonthViewUsesForegroundColor; 317 bool mMonthViewUsesForegroundColor;
317 318
318 bool mHightlightDateTimeEdit; 319 bool mHightlightDateTimeEdit;
319 bool mShortDateInViewer; 320 bool mShortDateInViewer;
320 321
321 bool mShowDateNavigator; 322 bool mShowDateNavigator;
322 323
323 QStringList mLocationDefaults; 324 QStringList mLocationDefaults;
324 QStringList mEventSummaryUser; 325 QStringList mEventSummaryUser;
325 QStringList mTodoSummaryUser; 326 QStringList mTodoSummaryUser;
326 QStringList mJournalSummaryUser; 327 QStringList mJournalSummaryUser;
327 328
328 bool mUseInternalAlarmNotification; 329 bool mUseInternalAlarmNotification;
329 int mAlarmPlayBeeps; 330 int mAlarmPlayBeeps;
330 int mAlarmSuspendTime; 331 int mAlarmSuspendTime;
331 int mAlarmSuspendCount; 332 int mAlarmSuspendCount;
332 int mAlarmBeepInterval; 333 int mAlarmBeepInterval;
333 int mOldLanguage; 334 int mOldLanguage;
334 int mOldLoadedLanguage; 335 int mOldLoadedLanguage;
335 336
336 337
337 QString mActiveSyncPort; 338 QString mActiveSyncPort;
338 QString mActiveSyncIP; 339 QString mActiveSyncIP;
339 340
340 // settings for eventviewer 341 // settings for eventviewer
341 bool mEVshowDetails; 342 bool mEVshowDetails;
342 bool mEVshowCreated; 343 bool mEVshowCreated;
343 bool mEVshowChanged; 344 bool mEVshowChanged;
344 bool mWTshowDetails; 345 bool mWTshowDetails;
345 bool mWTshowCreated; 346 bool mWTshowCreated;
346 bool mWTshowChanged; 347 bool mWTshowChanged;
347 348
348 int mCurrentDisplayedView; 349 int mCurrentDisplayedView;
349 QPtrList<KopiCalendarFile> mCalendars; 350 QPtrList<KopiCalendarFile> mCalendars;
350 int mNextAvailableCalendar; 351 int mNextAvailableCalendar;
351 bool mGlobalUpdateDisabled; 352 bool mGlobalUpdateDisabled;
352 353
353 354
354 bool mDetectConflicts; 355 bool mDetectConflicts;
355 bool mIncludeFree; 356 bool mIncludeFree;
356 bool mCheckConflictsAllDayAllDay; 357 bool mCheckConflictsAllDayAllDay;
357 bool mCheckConflictsAllDayNonAD; 358 bool mCheckConflictsAllDayNonAD;
358 bool mCheckConflictsNonADAllDay; 359 bool mCheckConflictsNonADAllDay;
359 bool mCheckConflictsNonADNonAD; 360 bool mCheckConflictsNonADNonAD;
360 QString mFilterConflictEditItem; 361 QString mFilterConflictEditItem;
361 QString mFilterConflictAllItem; 362 QString mFilterConflictAllItem;
362 363
363 private: 364 private:
364 QDict<QColor> mCategoryColors; 365 QDict<QColor> mCategoryColors;
365 QArray<KopiCalendarFile*> mDefCalColors; 366 QArray<KopiCalendarFile*> mDefCalColors;
366 QColor mDefaultCategoryColor; 367 QColor mDefaultCategoryColor;
367 368
368 QFont mDefaultTimeBarFont; 369 QFont mDefaultTimeBarFont;
369 QFont mDefaultViewFont; 370 QFont mDefaultViewFont;
370 QFont mDefaultMonthViewFont; 371 QFont mDefaultMonthViewFont;
371 372
372 QString mName; 373 QString mName;
373 QString mEmail; 374 QString mEmail;
374}; 375};
375 376
376#endif 377#endif
diff --git a/libkdepim/ksyncmanager.cpp b/libkdepim/ksyncmanager.cpp
index d71264f..a64eb34 100644
--- a/libkdepim/ksyncmanager.cpp
+++ b/libkdepim/ksyncmanager.cpp
@@ -1,1720 +1,1751 @@
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#include <qapplication.h> 52#include <qapplication.h>
53 53
54#include <klocale.h> 54#include <klocale.h>
55#include <kglobal.h> 55#include <kglobal.h>
56#include <kconfig.h> 56#include <kconfig.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58 58
59QDateTime KSyncManager::mRequestedSyncEvent; 59QDateTime KSyncManager::mRequestedSyncEvent;
60 60
61 61
62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu) 62KSyncManager::KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu)
63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu) 63 : QObject(), mPrefs(prefs ), mParent(parent),mImplementation(implementation), mTargetApp(ta), mSyncMenu(syncmenu)
64{ 64{
65 mServerSocket = 0; 65 mServerSocket = 0;
66 bar = new QProgressBar ( 1, 0 ); 66 bar = new QProgressBar ( 1, 0 );
67 bar->setCaption (""); 67 bar->setCaption ("");
68 mWriteBackInPast = 2; 68 mWriteBackInPast = 2;
69 69
70 70
71} 71}
72 72
73KSyncManager::~KSyncManager() 73KSyncManager::~KSyncManager()
74{ 74{
75 delete bar; 75 delete bar;
76} 76}
77 77
78void KSyncManager::setDefaultFileName( QString s) 78void KSyncManager::setDefaultFileName( QString s)
79{ 79{
80 mDefFileName = s ; 80 mDefFileName = s ;
81 if ( mPrefs->mPassiveSyncAutoStart ) 81 if ( mPrefs->mPassiveSyncAutoStart )
82 enableQuick( false ); 82 enableQuick( false );
83} 83}
84 84
85void KSyncManager::fillSyncMenu() 85void KSyncManager::fillSyncMenu()
86{ 86{
87 if ( mSyncMenu->count() ) 87 if ( mSyncMenu->count() )
88 mSyncMenu->clear(); 88 mSyncMenu->clear();
89 89
90 mSyncMenu->insertItem( i18n("Configure..."), 0 ); 90 mSyncMenu->insertItem( i18n("Configure..."), 0 );
91 mSyncMenu->insertSeparator(); 91 mSyncMenu->insertSeparator();
92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu ); 92 QPopupMenu *clearMenu = new QPopupMenu ( mSyncMenu );
93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 ); 93 mSyncMenu->insertItem( i18n("Remove sync info"),clearMenu, 5000 );
94 clearMenu->insertItem( i18n("For all profiles"), 1 ); 94 clearMenu->insertItem( i18n("For all profiles"), 1 );
95 clearMenu->insertSeparator(); 95 clearMenu->insertSeparator();
96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) ); 96 connect ( clearMenu, SIGNAL( activated ( int ) ), this, SLOT (slotClearMenu( int ) ) );
97 mSyncMenu->insertSeparator(); 97 mSyncMenu->insertSeparator();
98 if ( mServerSocket == 0 ) { 98 if ( mServerSocket == 0 ) {
99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 99 mSyncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
100 } else { 100 } else {
101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 101 mSyncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
102 } 102 }
103 mSyncMenu->insertSeparator(); 103 mSyncMenu->insertSeparator();
104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 ); 104 mSyncMenu->insertItem( i18n("Multiple sync"), 1 );
105 mSyncMenu->insertSeparator(); 105 mSyncMenu->insertSeparator();
106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 106 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
107 config.setGroup("General"); 107 config.setGroup("General");
108 QStringList prof = config.readListEntry("SyncProfileNames"); 108 QStringList prof = config.readListEntry("SyncProfileNames");
109 mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 109 mLocalMachineName = config.readEntry("LocalMachineName","undefined");
110 if ( prof.count() < 2 ) { 110 if ( prof.count() < 2 ) {
111 prof.clear(); 111 prof.clear();
112 QString externalName; 112 QString externalName;
113#ifdef DESKTOP_VERSION 113#ifdef DESKTOP_VERSION
114#ifdef _WIN32_ 114#ifdef _WIN32_
115 externalName = "OutLook(not_implemented)"; 115 externalName = "OutLook(not_implemented)";
116#else 116#else
117 externalName = "KDE_Desktop"; 117 externalName = "KDE_Desktop";
118#endif 118#endif
119#else 119#else
120 externalName = "Sharp_DTM"; 120 externalName = "Sharp_DTM";
121#endif 121#endif
122 prof << externalName; 122 prof << externalName;
123 prof << i18n("Local_file"); 123 prof << i18n("Local_file");
124 prof << i18n("Last_file"); 124 prof << i18n("Last_file");
125 KSyncProfile* temp = new KSyncProfile (); 125 KSyncProfile* temp = new KSyncProfile ();
126 temp->setName( prof[0] ); 126 temp->setName( prof[0] );
127 temp->writeConfig(&config); 127 temp->writeConfig(&config);
128 temp->setName( prof[1] ); 128 temp->setName( prof[1] );
129 temp->writeConfig(&config); 129 temp->writeConfig(&config);
130 temp->setName( prof[2] ); 130 temp->setName( prof[2] );
131 temp->writeConfig(&config); 131 temp->writeConfig(&config);
132 config.setGroup("General"); 132 config.setGroup("General");
133 config.writeEntry("SyncProfileNames",prof); 133 config.writeEntry("SyncProfileNames",prof);
134 config.writeEntry("ExternSyncProfiles",externalName); 134 config.writeEntry("ExternSyncProfiles",externalName);
135 config.sync(); 135 config.sync();
136 delete temp; 136 delete temp;
137 } 137 }
138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 138 mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
139 mSyncProfileNames = prof; 139 mSyncProfileNames = prof;
140 unsigned int i; 140 unsigned int i;
141 for ( i = 0; i < prof.count(); ++i ) { 141 for ( i = 0; i < prof.count(); ++i ) {
142 QString insertText = prof[i]; 142 QString insertText = prof[i];
143 if ( i == 0 ) { 143 if ( i == 0 ) {
144#ifdef DESKTOP_VERSION 144#ifdef DESKTOP_VERSION
145#ifdef _WIN32_ 145#ifdef _WIN32_
146 insertText = "OutLook(not_implemented)"; 146 insertText = "OutLook(not_implemented)";
147#else 147#else
148 insertText = "KDE_Desktop"; 148 insertText = "KDE_Desktop";
149#endif 149#endif
150#else 150#else
151 insertText = "Sharp_DTM"; 151 insertText = "Sharp_DTM";
152#endif 152#endif
153 } 153 }
154 mSyncMenu->insertItem( insertText, 1000+i ); 154 mSyncMenu->insertItem( insertText, 1000+i );
155 clearMenu->insertItem( insertText, 1000+i ); 155 clearMenu->insertItem( insertText, 1000+i );
156 if ( i == 2 ) 156 if ( i == 2 )
157 mSyncMenu->insertSeparator(); 157 mSyncMenu->insertSeparator();
158 } 158 }
159 QDir app_dir; 159 QDir app_dir;
160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available 160 //US do not display SharpDTM if app is pwmpi, or no sharpfiles available
161 if ( mTargetApp == PWMPI) { 161 if ( mTargetApp == PWMPI) {
162 mSyncMenu->removeItem( 1000 ); 162 mSyncMenu->removeItem( 1000 );
163 clearMenu->removeItem( 1000 ); 163 clearMenu->removeItem( 1000 );
164 } 164 }
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 166 else if (!app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
167 mSyncMenu->removeItem( 1000 ); 167 mSyncMenu->removeItem( 1000 );
168 clearMenu->removeItem( 1000 ); 168 clearMenu->removeItem( 1000 );
169 } 169 }
170#endif 170#endif
171 mSyncMenu->removeItem( 1002 ); 171 mSyncMenu->removeItem( 1002 );
172 clearMenu->removeItem( 1002 ); 172 clearMenu->removeItem( 1002 );
173} 173}
174void KSyncManager::slotClearMenu( int action ) 174void KSyncManager::slotClearMenu( int action )
175{ 175{
176 QString syncDevice; 176 QString syncDevice;
177 if ( action > 999 ) { 177 if ( action > 999 ) {
178 syncDevice = mSyncProfileNames[action - 1000] ; 178 syncDevice = mSyncProfileNames[action - 1000] ;
179 } 179 }
180 180
181 181
182 182
183 int result = 0; 183 int result = 0;
184 QString sd; 184 QString sd;
185 if ( syncDevice.isEmpty() ) 185 if ( syncDevice.isEmpty() )
186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?"); 186 sd = i18n("Do you want to\nclear all sync info\nof all profiles?");
187 else 187 else
188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice ); 188 sd = i18n("Do you want to\nclear the sync\ninfo of profile\n%1?\n"). arg( syncDevice );
189 189
190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0, 190 result = QMessageBox::warning( mParent, i18n("Warning!"),sd,i18n("OK"), i18n("Cancel"), 0,
191 0, 1 ); 191 0, 1 );
192 if ( result ) 192 if ( result )
193 return; 193 return;
194 mImplementation->removeSyncInfo( syncDevice ); 194 mImplementation->removeSyncInfo( syncDevice );
195} 195}
196void KSyncManager::slotSyncMenu( int action ) 196void KSyncManager::slotSyncMenu( int action )
197{ 197{
198 qDebug("KSM::syncaction %d ", action); 198 qDebug("KSM::syncaction %d ", action);
199 mCurrentResourceLocal = "";
199 if ( action == 5000 ) 200 if ( action == 5000 )
200 return; 201 return;
201 mSyncWithDesktop = false; 202 mSyncWithDesktop = false;
202 if ( action == 0 ) { 203 if ( action == 0 ) {
203 204
204 // seems to be a Qt2 event handling bug 205 // seems to be a Qt2 event handling bug
205 // syncmenu.clear causes a segfault at first time 206 // syncmenu.clear causes a segfault at first time
206 // when we call it after the main event loop, it is ok 207 // when we call it after the main event loop, it is ok
207 // same behaviour when calling OM/Pi via QCOP for the first time 208 // same behaviour when calling OM/Pi via QCOP for the first time
208 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 209 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
209 //confSync(); 210 //confSync();
210 211
211 return; 212 return;
212 } 213 }
213 if ( action == 1 ) { 214 if ( action == 1 ) {
214 multiSync( true ); 215 multiSync( true );
215 return; 216 return;
216 } 217 }
217 if ( action == 2 ) { 218 if ( action == 2 ) {
218 enableQuick(); 219 enableQuick();
219 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 220 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
220 return; 221 return;
221 } 222 }
222 if ( action == 3 ) { 223 if ( action == 3 ) {
223 delete mServerSocket; 224 delete mServerSocket;
224 mServerSocket = 0; 225 mServerSocket = 0;
225 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 226 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
226 return; 227 return;
227 } 228 }
228 229
229 if (blockSave()) 230 if (blockSave())
230 return; 231 return;
231 232
232 setBlockSave(true); 233 setBlockSave(true);
233 bool silent = false; 234 bool silent = false;
234 if ( action == 999 ) { 235 if ( action == 999 ) {
235 //special mode for silent syncing 236 //special mode for silent syncing
236 action = 1000; 237 action = 1000;
237 silent = true; 238 silent = true;
238 } 239 }
239 240
240 mCurrentSyncProfile = action - 1000 ; 241 mCurrentSyncProfile = action - 1000 ;
241 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ; 242 mCurrentSyncDevice = mSyncProfileNames[mCurrentSyncProfile] ;
242 mCurrentSyncName = mLocalMachineName ; 243 mCurrentSyncName = mLocalMachineName ;
243 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 244 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
244 KSyncProfile* temp = new KSyncProfile (); 245 KSyncProfile* temp = new KSyncProfile ();
245 temp->setName(mSyncProfileNames[mCurrentSyncProfile]); 246 temp->setName(mSyncProfileNames[mCurrentSyncProfile]);
246 temp->readConfig(&config); 247 temp->readConfig(&config);
247 if (silent) { 248 if (silent) {
248 mAskForPreferences = false; 249 mAskForPreferences = false;
249 mShowSyncSummary = false; 250 mShowSyncSummary = false;
250 mWriteBackFile = true; 251 mWriteBackFile = true;
251 mSyncAlgoPrefs = 2;// take newest 252 mSyncAlgoPrefs = 2;// take newest
252 } 253 }
253 else { 254 else {
254 mAskForPreferences = temp->getAskForPreferences(); 255 mAskForPreferences = temp->getAskForPreferences();
255 mShowSyncSummary = temp->getShowSummaryAfterSync(); 256 mShowSyncSummary = temp->getShowSummaryAfterSync();
256 mWriteBackFile = temp->getWriteBackFile(); 257 mWriteBackFile = temp->getWriteBackFile();
257 mSyncAlgoPrefs = temp->getSyncPrefs(); 258 mSyncAlgoPrefs = temp->getSyncPrefs();
258 } 259 }
259 mWriteBackExistingOnly = temp->getWriteBackExisting(); 260 mWriteBackExistingOnly = temp->getWriteBackExisting();
260 mIsKapiFile = temp->getIsKapiFile(); 261 mIsKapiFile = temp->getIsKapiFile();
261 mWriteBackInFuture = 0; 262 mWriteBackInFuture = 0;
262 if ( temp->getWriteBackFuture() ) { 263 if ( temp->getWriteBackFuture() ) {
263 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 264 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
264 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 265 mWriteBackInPast = temp->getWriteBackPastWeeks( );
265 } 266 }
266 mFilterInCal = temp->getFilterInCal(); 267 mFilterInCal = temp->getFilterInCal();
267 mFilterOutCal = temp->getFilterOutCal(); 268 mFilterOutCal = temp->getFilterOutCal();
268 mFilterInAB = temp->getFilterInAB(); 269 mFilterInAB = temp->getFilterInAB();
269 mFilterOutAB = temp->getFilterOutAB(); 270 mFilterOutAB = temp->getFilterOutAB();
270 271
271 if ( action == 1000 ) { 272 if ( action == 1000 ) {
272 mIsKapiFile = false; 273 mIsKapiFile = false;
273#ifdef DESKTOP_VERSION 274#ifdef DESKTOP_VERSION
274 syncKDE(); 275 syncKDE();
275#else 276#else
276 syncSharp(); 277 syncSharp();
277#endif 278#endif
278 279
279 } else if ( action == 1001 ) { 280 } else if ( action == 1001 ) {
280 syncLocalFile(); 281 syncLocalFile();
281 282
282 } else if ( action == 1002 ) { 283 } else if ( action == 1002 ) {
283 mWriteBackFile = false; 284 mWriteBackFile = false;
284 mAskForPreferences = false; 285 mAskForPreferences = false;
285 mShowSyncSummary = false; 286 mShowSyncSummary = false;
286 mSyncAlgoPrefs = 3; 287 mSyncAlgoPrefs = 3;
287 quickSyncLocalFile(); 288 quickSyncLocalFile();
288 289
289 } else if ( action >= 1003 ) { 290 } else if ( action >= 1003 ) {
290 if ( temp->getIsLocalFileSync() ) { 291 if ( temp->getIsLocalFileSync() ) {
291 switch(mTargetApp) 292 switch(mTargetApp)
292 { 293 {
293 case (KAPI): 294 case (KAPI):
294 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 295 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
295 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 296 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
296 break; 297 break;
297 case (KOPI): 298 case (KOPI):
298 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 299 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
299 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 300 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
300 break; 301 break;
301 case (PWMPI): 302 case (PWMPI):
302 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 303 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
303 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 304 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
304 break; 305 break;
305 default: 306 default:
306 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 307 qDebug("KSM::slotSyncMenu: invalid apptype selected");
307 break; 308 break;
308 309
309 } 310 }
310 } else { 311 } else {
311 if ( temp->getIsPhoneSync() ) { 312 if ( temp->getIsPhoneSync() ) {
312 mPhoneDevice = temp->getPhoneDevice( ) ; 313 mPhoneDevice = temp->getPhoneDevice( ) ;
313 mPhoneConnection = temp->getPhoneConnection( ); 314 mPhoneConnection = temp->getPhoneConnection( );
314 mPhoneModel = temp->getPhoneModel( ); 315 mPhoneModel = temp->getPhoneModel( );
315 syncPhone(); 316 syncPhone();
316 } else if ( temp->getIsPiSync() ) { 317 } else if ( temp->getIsPiSync()|| temp->getIsPiSyncSpec()) {
318 mSpecificResources.clear();
317 if ( mTargetApp == KAPI ) { 319 if ( mTargetApp == KAPI ) {
318 mPassWordPiSync = temp->getRemotePwAB(); 320 mPassWordPiSync = temp->getRemotePwAB();
319 mActiveSyncPort = temp->getRemotePortAB(); 321 mActiveSyncPort = temp->getRemotePortAB();
320 mActiveSyncIP = temp->getRemoteIPAB(); 322 mActiveSyncIP = temp->getRemoteIPAB();
321 } else if ( mTargetApp == KOPI ) { 323 } else if ( mTargetApp == KOPI ) {
324 if ( temp->getIsPiSyncSpec() )
325 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
322 mPassWordPiSync = temp->getRemotePw(); 326 mPassWordPiSync = temp->getRemotePw();
323 mActiveSyncPort = temp->getRemotePort(); 327 mActiveSyncPort = temp->getRemotePort();
324 mActiveSyncIP = temp->getRemoteIP(); 328 mActiveSyncIP = temp->getRemoteIP();
325 } else { 329 } else {
326 mPassWordPiSync = temp->getRemotePwPWM(); 330 mPassWordPiSync = temp->getRemotePwPWM();
327 mActiveSyncPort = temp->getRemotePortPWM(); 331 mActiveSyncPort = temp->getRemotePortPWM();
328 mActiveSyncIP = temp->getRemoteIPPWM(); 332 mActiveSyncIP = temp->getRemoteIPPWM();
329 } 333 }
330 syncPi(); 334 syncPi();
331 while ( !mPisyncFinished ) { 335 while ( !mPisyncFinished ) {
332 //qDebug("waiting "); 336 //qDebug("waiting ");
333 qApp->processEvents(); 337 qApp->processEvents();
334 } 338 }
335 } else 339 } else
336 syncRemote( temp ); 340 syncRemote( temp );
337 341
338 } 342 }
339 } 343 }
340 delete temp; 344 delete temp;
341 setBlockSave(false); 345 setBlockSave(false);
342} 346}
343 347
344void KSyncManager::enableQuick( bool ask ) 348void KSyncManager::enableQuick( bool ask )
345{ 349{
346 bool autoStart; 350 bool autoStart;
347 bool changed = false; 351 bool changed = false;
348 if ( ask ) { 352 if ( ask ) {
349 QDialog dia ( 0, "input-dialog", true ); 353 QDialog dia ( 0, "input-dialog", true );
350 QLineEdit lab ( &dia ); 354 QLineEdit lab ( &dia );
351 QVBoxLayout lay( &dia ); 355 QVBoxLayout lay( &dia );
352 lab.setText( mPrefs->mPassiveSyncPort ); 356 lab.setText( mPrefs->mPassiveSyncPort );
353 lay.setMargin(7); 357 lay.setMargin(7);
354 lay.setSpacing(7); 358 lay.setSpacing(7);
355 int po = 9197+mTargetApp; 359 int po = 9197+mTargetApp;
356 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia ); 360 QLabel label ( i18n("Port number (Default: %1)\nValid range from 1 to 65535").arg(po), &dia );
357 lay.addWidget( &label); 361 lay.addWidget( &label);
358 lay.addWidget( &lab); 362 lay.addWidget( &lab);
359 363
360 QLineEdit lepw ( &dia ); 364 QLineEdit lepw ( &dia );
361 lepw.setText( mPrefs->mPassiveSyncPw ); 365 lepw.setText( mPrefs->mPassiveSyncPw );
362 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 366 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
363 lay.addWidget( &label2); 367 lay.addWidget( &label2);
364 lay.addWidget( &lepw); 368 lay.addWidget( &lepw);
365 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia ); 369 QCheckBox autostart(i18n("Automatically start\nat application startup"), &dia );
366 lay.addWidget( &autostart); 370 lay.addWidget( &autostart);
367 autostart.setChecked( mPrefs->mPassiveSyncAutoStart ); 371 autostart.setChecked( mPrefs->mPassiveSyncAutoStart );
368#ifdef DESKTOP_VERSION 372#ifdef DESKTOP_VERSION
369#ifdef _WIN32_ 373#ifdef _WIN32_
370 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia ); 374 QCheckBox syncdesktop( i18n("Automatically sync with Outlook\nwhen receiving sync request"),&dia );
371 syncdesktop.hide();// not implemented! 375 syncdesktop.hide();// not implemented!
372#else 376#else
373 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia ); 377 QCheckBox syncdesktop( i18n("Automatically sync with KDE-Desktop\nwhen receiving sync request"),&dia );
374#endif 378#endif
375 lay.addWidget( &syncdesktop); 379 lay.addWidget( &syncdesktop);
376#else 380#else
377 mPrefs->mPassiveSyncWithDesktop = false; 381 mPrefs->mPassiveSyncWithDesktop = false;
378 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia ); 382 QCheckBox syncdesktop( i18n("Automatically sync\nwith KDE-Desktop"),&dia );
379 syncdesktop.hide(); 383 syncdesktop.hide();
380#endif 384#endif
381 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop ); 385 syncdesktop.setChecked( mPrefs->mPassiveSyncWithDesktop );
382 386
383 QPushButton pb ( "OK", &dia); 387 QPushButton pb ( "OK", &dia);
384 lay.addWidget( &pb ); 388 lay.addWidget( &pb );
385 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 389 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
386 dia.resize( 230,120 ); 390 dia.resize( 230,120 );
387 dia.setCaption( i18n("Enter port for Pi-Sync") ); 391 dia.setCaption( i18n("Enter port for Pi-Sync") );
388 dia.show(); 392 dia.show();
389#ifndef DESKTOP_VERSION 393#ifndef DESKTOP_VERSION
390 int dw = QApplication::desktop()->width(); 394 int dw = QApplication::desktop()->width();
391 int dh = QApplication::desktop()->height(); 395 int dh = QApplication::desktop()->height();
392 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 ); 396 dia.move( (dw-dia.width())/2, (dh - dia.height() )/2 );
393#endif 397#endif
394 if ( ! dia.exec() ) 398 if ( ! dia.exec() )
395 return; 399 return;
396 dia.hide(); 400 dia.hide();
397 qApp->processEvents(); 401 qApp->processEvents();
398 if ( mPrefs->mPassiveSyncPw != lepw.text() ) { 402 if ( mPrefs->mPassiveSyncPw != lepw.text() ) {
399 changed = true; 403 changed = true;
400 mPrefs->mPassiveSyncPw = lepw.text(); 404 mPrefs->mPassiveSyncPw = lepw.text();
401 } 405 }
402 if ( mPrefs->mPassiveSyncPort != lab.text() ) { 406 if ( mPrefs->mPassiveSyncPort != lab.text() ) {
403 mPrefs->mPassiveSyncPort = lab.text(); 407 mPrefs->mPassiveSyncPort = lab.text();
404 changed = true; 408 changed = true;
405 } 409 }
406 autoStart = autostart.isChecked(); 410 autoStart = autostart.isChecked();
407 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) { 411 if (mPrefs->mPassiveSyncWithDesktop != syncdesktop.isChecked() ) {
408 changed = true; 412 changed = true;
409 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked(); 413 mPrefs->mPassiveSyncWithDesktop = syncdesktop.isChecked();
410 } 414 }
411 } 415 }
412 else 416 else
413 autoStart = mPrefs->mPassiveSyncAutoStart; 417 autoStart = mPrefs->mPassiveSyncAutoStart;
414 if ( autoStart != mPrefs->mPassiveSyncAutoStart ) 418 if ( autoStart != mPrefs->mPassiveSyncAutoStart )
415 changed = true; 419 changed = true;
416 bool ok; 420 bool ok;
417 mPrefs->mPassiveSyncAutoStart = false; 421 mPrefs->mPassiveSyncAutoStart = false;
418 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok); 422 Q_UINT32 port_t = mPrefs->mPassiveSyncPort.toUInt(&ok);
419 qDebug("%d ", port_t); 423 qDebug("%d ", port_t);
420 if ( ! ok || port_t > 65535 ) { 424 if ( ! ok || port_t > 65535 ) {
421 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error")); 425 KMessageBox::information( 0, i18n("No valid port number:\n%1").arg ( mPrefs->mPassiveSyncPort ), i18n("Pi-Sync Port Error"));
422 return; 426 return;
423 } 427 }
424 Q_UINT16 port = port_t; 428 Q_UINT16 port = port_t;
425 //qDebug("port %d ", port); 429 //qDebug("port %d ", port);
426 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 ); 430 mServerSocket = new KServerSocket ( mPrefs->mPassiveSyncPw, port ,1 );
427 mServerSocket->setFileName( defaultFileName() );//bbb 431 mServerSocket->setFileName( defaultFileName() );//bbb
428 if ( !mServerSocket->ok() ) { 432 if ( !mServerSocket->ok() ) {
429 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) ); 433 QTimer::singleShot( 2000, this, SLOT ( displayErrorPort() ) );
430 delete mServerSocket; 434 delete mServerSocket;
431 mServerSocket = 0; 435 mServerSocket = 0;
432 return; 436 return;
433 } 437 }
434 mPrefs->mPassiveSyncAutoStart = autoStart; 438 mPrefs->mPassiveSyncAutoStart = autoStart;
435 if ( changed ) { 439 if ( changed ) {
436 mPrefs->writeConfig(); 440 mPrefs->writeConfig();
437 } 441 }
438 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) ); 442 connect( mServerSocket, SIGNAL ( request_file() ),this, SIGNAL ( request_file() ) );
439 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) ); 443 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SIGNAL ( getFile( bool ) ) );
440} 444}
441void KSyncManager::displayErrorPort() 445void KSyncManager::displayErrorPort()
442{ 446{
443 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error")); 447 KMessageBox::information( 0, i18n("<b>Enabling Pi-Sync failed!</b> Failed to bind or listen to the port %1! Is another instance already listening to that port?").arg( mPrefs->mPassiveSyncPort) , i18n("Pi-Sync Port Error"));
444} 448}
445void KSyncManager::syncLocalFile() 449void KSyncManager::syncLocalFile()
446{ 450{
447 451
448 QString fn =mPrefs->mLastSyncedLocalFile; 452 QString fn =mPrefs->mLastSyncedLocalFile;
449 QString ext; 453 QString ext;
450 454
451 switch(mTargetApp) 455 switch(mTargetApp)
452 { 456 {
453 case (KAPI): 457 case (KAPI):
454 ext = "(*.vcf)"; 458 ext = "(*.vcf)";
455 break; 459 break;
456 case (KOPI): 460 case (KOPI):
457 ext = "(*.ics/*.vcs)"; 461 ext = "(*.ics/*.vcs)";
458 break; 462 break;
459 case (PWMPI): 463 case (PWMPI):
460 ext = "(*.pwm)"; 464 ext = "(*.pwm)";
461 break; 465 break;
462 default: 466 default:
463 qDebug("KSM::syncLocalFile: invalid apptype selected"); 467 qDebug("KSM::syncLocalFile: invalid apptype selected");
464 break; 468 break;
465 469
466 } 470 }
467 471
468 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent ); 472 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename"+ext), mParent );
469 if ( fn == "" ) 473 if ( fn == "" )
470 return; 474 return;
471 if ( syncWithFile( fn, false ) ) { 475 if ( syncWithFile( fn, false ) ) {
472 qDebug("KSM::syncLocalFile() successful "); 476 qDebug("KSM::syncLocalFile() successful ");
473 } 477 }
474 478
475} 479}
476 480
477bool KSyncManager::syncWithFile( QString fn , bool quick ) 481bool KSyncManager::syncWithFile( QString fn , bool quick )
478{ 482{
479 bool ret = false; 483 bool ret = false;
480 QFileInfo info; 484 QFileInfo info;
481 info.setFile( fn ); 485 info.setFile( fn );
482 QString mess; 486 QString mess;
483 if ( !info. exists() ) { 487 if ( !info. exists() ) {
484 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 488 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
485 QMessageBox::warning( mParent, i18n("Warning!"), 489 QMessageBox::warning( mParent, i18n("Warning!"),
486 mess ); 490 mess );
487 return ret; 491 return ret;
488 } 492 }
489 int result = 0; 493 int result = 0;
490 if ( !quick ) { 494 if ( !quick ) {
491 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 495 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
492 result = QMessageBox::warning( mParent, i18n("Warning!"), 496 result = QMessageBox::warning( mParent, i18n("Warning!"),
493 mess, 497 mess,
494 i18n("Sync"), i18n("Cancel"), 0, 498 i18n("Sync"), i18n("Cancel"), 0,
495 0, 1 ); 499 0, 1 );
496 if ( result ) 500 if ( result )
497 return false; 501 return false;
498 } 502 }
499 if ( mAskForPreferences ) 503 if ( mAskForPreferences )
500 if ( !edit_sync_options()) { 504 if ( !edit_sync_options()) {
501 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 505 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
502 return false; 506 return false;
503 } 507 }
504 if ( result == 0 ) { 508 if ( result == 0 ) {
505 //qDebug("Now sycing ... "); 509 //qDebug("Now sycing ... ");
506 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ) ) 510 if ( ret = mImplementation->sync( this, fn, mSyncAlgoPrefs ,mCurrentResourceLocal ) )
507 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") ); 511 mParent->topLevelWidget()->setCaption( i18n("Synchronization successful") );
508 else 512 else
509 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 513 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
510 if ( ! quick ) 514 if ( ! quick )
511 mPrefs->mLastSyncedLocalFile = fn; 515 mPrefs->mLastSyncedLocalFile = fn;
512 } 516 }
513 return ret; 517 return ret;
514} 518}
515 519
516void KSyncManager::quickSyncLocalFile() 520void KSyncManager::quickSyncLocalFile()
517{ 521{
518 522
519 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) { 523 if ( syncWithFile( mPrefs->mLastSyncedLocalFile, true ) ) {
520 qDebug("KSM::quick syncLocalFile() successful "); 524 qDebug("KSM::quick syncLocalFile() successful ");
521 525
522 } 526 }
523} 527}
524 528
525void KSyncManager::multiSync( bool askforPrefs ) 529void KSyncManager::multiSync( bool askforPrefs )
526{ 530{
527 if (blockSave()) 531 if (blockSave())
528 return; 532 return;
529 setBlockSave(true); 533 setBlockSave(true);
534 mCurrentResourceLocal = "";
530 if ( askforPrefs ) { 535 if ( askforPrefs ) {
531 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 536 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
532 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"), 537 if ( QMessageBox::information( mParent, i18n("KDE-Pim Sync"),
533 question, 538 question,
534 i18n("Yes"), i18n("No"), 539 i18n("Yes"), i18n("No"),
535 0, 0 ) != 0 ) { 540 0, 0 ) != 0 ) {
536 setBlockSave(false); 541 setBlockSave(false);
537 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!")); 542 mParent->topLevelWidget()->setCaption(i18n("Aborted! Nothing synced!"));
538 return; 543 return;
539 } 544 }
540 } 545 }
541 mCurrentSyncDevice = i18n("Multiple profiles") ; 546 mCurrentSyncDevice = i18n("Multiple profiles") ;
542 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs; 547 mSyncAlgoPrefs = mPrefs->mRingSyncAlgoPrefs;
543 if ( askforPrefs ) { 548 if ( askforPrefs ) {
544 if ( !edit_sync_options()) { 549 if ( !edit_sync_options()) {
545 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") ); 550 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted.") );
546 return; 551 return;
547 } 552 }
548 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs; 553 mPrefs->mRingSyncAlgoPrefs = mSyncAlgoPrefs;
549 } 554 }
550 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") ); 555 mParent->topLevelWidget()->setCaption(i18n("Multiple sync started.") );
551 qApp->processEvents(); 556 qApp->processEvents();
552 int num = ringSync() ; 557 int num = ringSync() ;
553 if ( num > 1 ) 558 if ( num > 1 )
554 ringSync(); 559 ringSync();
555 setBlockSave(false); 560 setBlockSave(false);
556 if ( num ) 561 if ( num )
557 emit save(); 562 emit save();
558 if ( num ) 563 if ( num )
559 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) ); 564 mParent->topLevelWidget()->setCaption(i18n("%1 profiles synced. Multiple sync complete!").arg(num) );
560 else 565 else
561 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 566 mParent->topLevelWidget()->setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
562 return; 567 return;
563} 568}
564 569
565int KSyncManager::ringSync() 570int KSyncManager::ringSync()
566{ 571{
567 572
568 int syncedProfiles = 0; 573 int syncedProfiles = 0;
569 unsigned int i; 574 unsigned int i;
570 QTime timer; 575 QTime timer;
571 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 576 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
572 QStringList syncProfileNames = mSyncProfileNames; 577 QStringList syncProfileNames = mSyncProfileNames;
573 KSyncProfile* temp = new KSyncProfile (); 578 KSyncProfile* temp = new KSyncProfile ();
574 mAskForPreferences = false; 579 mAskForPreferences = false;
580 mCurrentResourceLocal = "";
575 for ( i = 0; i < syncProfileNames.count(); ++i ) { 581 for ( i = 0; i < syncProfileNames.count(); ++i ) {
576 mCurrentSyncProfile = i; 582 mCurrentSyncProfile = i;
577 temp->setName(syncProfileNames[mCurrentSyncProfile]); 583 temp->setName(syncProfileNames[mCurrentSyncProfile]);
578 temp->readConfig(&config); 584 temp->readConfig(&config);
579 585
580 bool includeInRingSync = false; 586 bool includeInRingSync = false;
581 switch(mTargetApp) 587 switch(mTargetApp)
582 { 588 {
583 case (KAPI): 589 case (KAPI):
584 includeInRingSync = temp->getIncludeInRingSyncAB(); 590 includeInRingSync = temp->getIncludeInRingSyncAB();
585 break; 591 break;
586 case (KOPI): 592 case (KOPI):
587 includeInRingSync = temp->getIncludeInRingSync(); 593 includeInRingSync = temp->getIncludeInRingSync();
588 break; 594 break;
589 case (PWMPI): 595 case (PWMPI):
590 includeInRingSync = temp->getIncludeInRingSyncPWM(); 596 includeInRingSync = temp->getIncludeInRingSyncPWM();
591 break; 597 break;
592 default: 598 default:
593 qDebug("KSM::ringSync: invalid apptype selected"); 599 qDebug("KSM::ringSync: invalid apptype selected");
594 break; 600 break;
595 601
596 } 602 }
597 603
598 604
599 if ( includeInRingSync && ( i < 1 || i > 2 )) { 605 if ( includeInRingSync && ( i < 1 || i > 2 )) {
600 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 606 mParent->topLevelWidget()->setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
601 ++syncedProfiles; 607 ++syncedProfiles;
602 mSyncWithDesktop = false; 608 mSyncWithDesktop = false;
603 // mAskForPreferences = temp->getAskForPreferences(); 609 // mAskForPreferences = temp->getAskForPreferences();
604 mWriteBackFile = temp->getWriteBackFile(); 610 mWriteBackFile = temp->getWriteBackFile();
605 mWriteBackExistingOnly = temp->getWriteBackExisting(); 611 mWriteBackExistingOnly = temp->getWriteBackExisting();
606 mIsKapiFile = temp->getIsKapiFile(); 612 mIsKapiFile = temp->getIsKapiFile();
607 mWriteBackInFuture = 0; 613 mWriteBackInFuture = 0;
608 if ( temp->getWriteBackFuture() ) { 614 if ( temp->getWriteBackFuture() ) {
609 mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 615 mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
610 mWriteBackInPast = temp->getWriteBackPastWeeks( ); 616 mWriteBackInPast = temp->getWriteBackPastWeeks( );
611 } 617 }
612 mFilterInCal = temp->getFilterInCal(); 618 mFilterInCal = temp->getFilterInCal();
613 mFilterOutCal = temp->getFilterOutCal(); 619 mFilterOutCal = temp->getFilterOutCal();
614 mFilterInAB = temp->getFilterInAB(); 620 mFilterInAB = temp->getFilterInAB();
615 mFilterOutAB = temp->getFilterOutAB(); 621 mFilterOutAB = temp->getFilterOutAB();
616 mShowSyncSummary = false; 622 mShowSyncSummary = false;
617 mCurrentSyncDevice = syncProfileNames[i] ; 623 mCurrentSyncDevice = syncProfileNames[i] ;
618 mCurrentSyncName = mLocalMachineName; 624 mCurrentSyncName = mLocalMachineName;
619 if ( i == 0 ) { 625 if ( i == 0 ) {
620 mIsKapiFile = false; 626 mIsKapiFile = false;
621#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
622 syncKDE(); 628 syncKDE();
623#else 629#else
624 syncSharp(); 630 syncSharp();
625#endif 631#endif
626 } else { 632 } else {
627 if ( temp->getIsLocalFileSync() ) { 633 if ( temp->getIsLocalFileSync() ) {
628 switch(mTargetApp) 634 switch(mTargetApp)
629 { 635 {
630 case (KAPI): 636 case (KAPI):
631 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 637 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
632 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 638 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
633 break; 639 break;
634 case (KOPI): 640 case (KOPI):
635 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 641 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
636 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName(); 642 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileName();
637 break; 643 break;
638 case (PWMPI): 644 case (PWMPI):
639 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) ) 645 if ( syncWithFile( temp->getRemoteFileNamePWM( ), false ) )
640 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM(); 646 mPrefs->mLastSyncedLocalFile = temp->getRemoteFileNamePWM();
641 break; 647 break;
642 default: 648 default:
643 qDebug("KSM: invalid apptype selected"); 649 qDebug("KSM: invalid apptype selected");
644 break; 650 break;
645 } 651 }
646 } else { 652 } else {
647 if ( temp->getIsPhoneSync() ) { 653 if ( temp->getIsPhoneSync() ) {
648 mPhoneDevice = temp->getPhoneDevice( ) ; 654 mPhoneDevice = temp->getPhoneDevice( ) ;
649 mPhoneConnection = temp->getPhoneConnection( ); 655 mPhoneConnection = temp->getPhoneConnection( );
650 mPhoneModel = temp->getPhoneModel( ); 656 mPhoneModel = temp->getPhoneModel( );
651 syncPhone(); 657 syncPhone();
652 } else if ( temp->getIsPiSync() ) { 658 } else if ( temp->getIsPiSync() || temp->getIsPiSyncSpec()) {
659 mSpecificResources.clear();
653 if ( mTargetApp == KAPI ) { 660 if ( mTargetApp == KAPI ) {
654 mPassWordPiSync = temp->getRemotePwAB(); 661 mPassWordPiSync = temp->getRemotePwAB();
655 mActiveSyncPort = temp->getRemotePortAB(); 662 mActiveSyncPort = temp->getRemotePortAB();
656 mActiveSyncIP = temp->getRemoteIPAB(); 663 mActiveSyncIP = temp->getRemoteIPAB();
657 } else if ( mTargetApp == KOPI ) { 664 } else if ( mTargetApp == KOPI ) {
665 mSpecificResources = QStringList::split( ":", temp->getResSpecKopi() );
658 mPassWordPiSync = temp->getRemotePw(); 666 mPassWordPiSync = temp->getRemotePw();
659 mActiveSyncPort = temp->getRemotePort(); 667 mActiveSyncPort = temp->getRemotePort();
660 mActiveSyncIP = temp->getRemoteIP(); 668 mActiveSyncIP = temp->getRemoteIP();
661 } else { 669 } else {
662 mPassWordPiSync = temp->getRemotePwPWM(); 670 mPassWordPiSync = temp->getRemotePwPWM();
663 mActiveSyncPort = temp->getRemotePortPWM(); 671 mActiveSyncPort = temp->getRemotePortPWM();
664 mActiveSyncIP = temp->getRemoteIPPWM(); 672 mActiveSyncIP = temp->getRemoteIPPWM();
665 } 673 }
666 syncPi(); 674 syncPi();
667 while ( !mPisyncFinished ) { 675 while ( !mPisyncFinished ) {
668 //qDebug("waiting "); 676 //qDebug("waiting ");
669 qApp->processEvents(); 677 qApp->processEvents();
670 } 678 }
671 timer.start(); 679 timer.start();
672 while ( timer.elapsed () < 2000 ) { 680 while ( timer.elapsed () < 2000 ) {
673 qApp->processEvents(); 681 qApp->processEvents();
674 } 682 }
675 } else 683 } else
676 syncRemote( temp, false ); 684 syncRemote( temp, false );
677 685
678 } 686 }
679 } 687 }
680 timer.start(); 688 timer.start();
681 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") ); 689 mParent->topLevelWidget()->setCaption(i18n("Multiple sync in progress ... please wait!") );
682 while ( timer.elapsed () < 2000 ) { 690 while ( timer.elapsed () < 2000 ) {
683 qApp->processEvents(); 691 qApp->processEvents();
684#ifndef _WIN32_ 692#ifndef _WIN32_
685 sleep (1); 693 sleep (1);
686#endif 694#endif
687 } 695 }
688 696
689 } 697 }
690 698
691 } 699 }
692 delete temp; 700 delete temp;
693 return syncedProfiles; 701 return syncedProfiles;
694} 702}
695 703
696void KSyncManager::syncRemote( KSyncProfile* prof, bool ask) 704void KSyncManager::syncRemote( KSyncProfile* prof, bool ask)
697{ 705{
698 QString question; 706 QString question;
699 if ( ask ) { 707 if ( ask ) {
700 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 708 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
701 if ( QMessageBox::information( mParent, i18n("Sync"), 709 if ( QMessageBox::information( mParent, i18n("Sync"),
702 question, 710 question,
703 i18n("Yes"), i18n("No"), 711 i18n("Yes"), i18n("No"),
704 0, 0 ) != 0 ) 712 0, 0 ) != 0 )
705 return; 713 return;
706 } 714 }
707 715
708 QString preCommand; 716 QString preCommand;
709 QString localTempFile; 717 QString localTempFile;
710 QString postCommand; 718 QString postCommand;
711 719
712 switch(mTargetApp) 720 switch(mTargetApp)
713 { 721 {
714 case (KAPI): 722 case (KAPI):
715 preCommand = prof->getPreSyncCommandAB(); 723 preCommand = prof->getPreSyncCommandAB();
716 postCommand = prof->getPostSyncCommandAB(); 724 postCommand = prof->getPostSyncCommandAB();
717 localTempFile = prof->getLocalTempFileAB(); 725 localTempFile = prof->getLocalTempFileAB();
718 break; 726 break;
719 case (KOPI): 727 case (KOPI):
720 preCommand = prof->getPreSyncCommand(); 728 preCommand = prof->getPreSyncCommand();
721 postCommand = prof->getPostSyncCommand(); 729 postCommand = prof->getPostSyncCommand();
722 localTempFile = prof->getLocalTempFile(); 730 localTempFile = prof->getLocalTempFile();
723 break; 731 break;
724 case (PWMPI): 732 case (PWMPI):
725 preCommand = prof->getPreSyncCommandPWM(); 733 preCommand = prof->getPreSyncCommandPWM();
726 postCommand = prof->getPostSyncCommandPWM(); 734 postCommand = prof->getPostSyncCommandPWM();
727 localTempFile = prof->getLocalTempFilePWM(); 735 localTempFile = prof->getLocalTempFilePWM();
728 break; 736 break;
729 default: 737 default:
730 qDebug("KSM::syncRemote: invalid apptype selected"); 738 qDebug("KSM::syncRemote: invalid apptype selected");
731 break; 739 break;
732 } 740 }
733 741
734 742
735 int fi; 743 int fi;
736 if ( (fi = preCommand.find("$PWD$")) > 0 ) { 744 if ( (fi = preCommand.find("$PWD$")) > 0 ) {
737 QString pwd = getPassword(); 745 QString pwd = getPassword();
738 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 ); 746 preCommand = preCommand.left( fi )+ pwd + preCommand.mid( fi+5 );
739 747
740 } 748 }
741 int maxlen = 30; 749 int maxlen = 30;
742 if ( QApplication::desktop()->width() > 320 ) 750 if ( QApplication::desktop()->width() > 320 )
743 maxlen += 25; 751 maxlen += 25;
744 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) ); 752 mParent->topLevelWidget()->setCaption ( i18n( "Copy remote file to local machine..." ) );
745 int fileSize = 0; 753 int fileSize = 0;
746 int result = system ( preCommand ); 754 int result = system ( preCommand );
747 // 0 : okay 755 // 0 : okay
748 // 256: no such file or dir 756 // 256: no such file or dir
749 // 757 //
750 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result ); 758 qDebug("KSM::Sync: Remote copy result(0 = okay): %d ",result );
751 if ( result != 0 ) { 759 if ( result != 0 ) {
752 unsigned int len = maxlen; 760 unsigned int len = maxlen;
753 while ( len < preCommand.length() ) { 761 while ( len < preCommand.length() ) {
754 preCommand.insert( len , "\n" ); 762 preCommand.insert( len , "\n" );
755 len += maxlen +2; 763 len += maxlen +2;
756 } 764 }
757 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) ; 765 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) ;
758 QMessageBox::information( mParent, i18n("Sync - ERROR"), 766 QMessageBox::information( mParent, i18n("Sync - ERROR"),
759 question, 767 question,
760 i18n("Okay!")) ; 768 i18n("Okay!")) ;
761 mParent->topLevelWidget()->setCaption ("KDE-Pim"); 769 mParent->topLevelWidget()->setCaption ("KDE-Pim");
762 return; 770 return;
763 } 771 }
764 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) ); 772 mParent->topLevelWidget()->setCaption ( i18n( "Copying succeed." ) );
765 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 773 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
766 774
767 if ( syncWithFile( localTempFile, true ) ) { 775 if ( syncWithFile( localTempFile, true ) ) {
768 776
769 if ( mWriteBackFile ) { 777 if ( mWriteBackFile ) {
770 int fi; 778 int fi;
771 if ( (fi = postCommand.find("$PWD$")) > 0 ) { 779 if ( (fi = postCommand.find("$PWD$")) > 0 ) {
772 QString pwd = getPassword(); 780 QString pwd = getPassword();
773 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 ); 781 postCommand = postCommand.left( fi )+ pwd + postCommand.mid( fi+5 );
774 782
775 } 783 }
776 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) ); 784 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file ..." ) );
777 result = system ( postCommand ); 785 result = system ( postCommand );
778 qDebug("KSM::Sync:Writing back file result: %d ", result); 786 qDebug("KSM::Sync:Writing back file result: %d ", result);
779 if ( result != 0 ) { 787 if ( result != 0 ) {
780 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 788 mParent->topLevelWidget()->setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
781 return; 789 return;
782 } else { 790 } else {
783 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) ); 791 mParent->topLevelWidget()->setCaption ( i18n( "Syncronization sucessfully completed" ) );
784 } 792 }
785 } 793 }
786 } 794 }
787 return; 795 return;
788} 796}
789bool KSyncManager::edit_pisync_options() 797bool KSyncManager::edit_pisync_options()
790{ 798{
791 QDialog dia( mParent, "dia", true ); 799 QDialog dia( mParent, "dia", true );
792 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice ); 800 dia.setCaption( i18n("Pi-Sync options for device: " ) +mCurrentSyncDevice );
793 QVBoxLayout lay ( &dia ); 801 QVBoxLayout lay ( &dia );
794 lay.setSpacing( 5 ); 802 lay.setSpacing( 5 );
795 lay.setMargin( 3 ); 803 lay.setMargin( 3 );
796 QLabel lab1 ( i18n("Password for remote access:"), &dia); 804 QLabel lab1 ( i18n("Password for remote access:"), &dia);
797 lay.addWidget( &lab1 ); 805 lay.addWidget( &lab1 );
798 QLineEdit le1 (&dia ); 806 QLineEdit le1 (&dia );
799 lay.addWidget( &le1 ); 807 lay.addWidget( &le1 );
800 QLabel lab2 ( i18n("Remote IP address:"), &dia); 808 QLabel lab2 ( i18n("Remote IP address:"), &dia);
801 lay.addWidget( &lab2 ); 809 lay.addWidget( &lab2 );
802 QLineEdit le2 (&dia ); 810 QLineEdit le2 (&dia );
803 lay.addWidget( &le2 ); 811 lay.addWidget( &le2 );
804 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia); 812 QLabel lab3 ( i18n("Remote port number:\n(May be: 1 - 65535)"), &dia);
805 lay.addWidget( &lab3 ); 813 lay.addWidget( &lab3 );
806 QLineEdit le3 (&dia ); 814 QLineEdit le3 (&dia );
807 lay.addWidget( &le3 ); 815 lay.addWidget( &le3 );
808 QPushButton pb ( "OK", &dia); 816 QPushButton pb ( "OK", &dia);
809 lay.addWidget( &pb ); 817 lay.addWidget( &pb );
810 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 818 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
811 le1.setText( mPassWordPiSync ); 819 le1.setText( mPassWordPiSync );
812 le2.setText( mActiveSyncIP ); 820 le2.setText( mActiveSyncIP );
813 le3.setText( mActiveSyncPort ); 821 le3.setText( mActiveSyncPort );
814 if ( dia.exec() ) { 822 if ( dia.exec() ) {
815 mPassWordPiSync = le1.text(); 823 mPassWordPiSync = le1.text();
816 mActiveSyncPort = le3.text(); 824 mActiveSyncPort = le3.text();
817 mActiveSyncIP = le2.text(); 825 mActiveSyncIP = le2.text();
818 return true; 826 return true;
819 } 827 }
820 return false; 828 return false;
821} 829}
822bool KSyncManager::edit_sync_options() 830bool KSyncManager::edit_sync_options()
823{ 831{
824 832
825 QDialog dia( mParent, "dia", true ); 833 QDialog dia( mParent, "dia", true );
826 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 834 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
827 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 835 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
828 QVBoxLayout lay ( &dia ); 836 QVBoxLayout lay ( &dia );
829 lay.setSpacing( 2 ); 837 lay.setSpacing( 2 );
830 lay.setMargin( 3 ); 838 lay.setMargin( 3 );
831 lay.addWidget(&gr); 839 lay.addWidget(&gr);
832 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 840 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
833 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 841 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
834 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 842 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
835 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 843 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
836 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 844 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
837 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 845 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
838 //QRadioButton both( i18n("Take both on conflict"), &gr ); 846 //QRadioButton both( i18n("Take both on conflict"), &gr );
839 QPushButton pb ( "OK", &dia); 847 QPushButton pb ( "OK", &dia);
840 lay.addWidget( &pb ); 848 lay.addWidget( &pb );
841 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 849 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
842 switch ( mSyncAlgoPrefs ) { 850 switch ( mSyncAlgoPrefs ) {
843 case 0: 851 case 0:
844 loc.setChecked( true); 852 loc.setChecked( true);
845 break; 853 break;
846 case 1: 854 case 1:
847 rem.setChecked( true ); 855 rem.setChecked( true );
848 break; 856 break;
849 case 2: 857 case 2:
850 newest.setChecked( true); 858 newest.setChecked( true);
851 break; 859 break;
852 case 3: 860 case 3:
853 ask.setChecked( true); 861 ask.setChecked( true);
854 break; 862 break;
855 case 4: 863 case 4:
856 f_loc.setChecked( true); 864 f_loc.setChecked( true);
857 break; 865 break;
858 case 5: 866 case 5:
859 f_rem.setChecked( true); 867 f_rem.setChecked( true);
860 break; 868 break;
861 case 6: 869 case 6:
862 // both.setChecked( true); 870 // both.setChecked( true);
863 break; 871 break;
864 default: 872 default:
865 break; 873 break;
866 } 874 }
867 if ( dia.exec() ) { 875 if ( dia.exec() ) {
868 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 876 mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
869 return true; 877 return true;
870 } 878 }
871 return false; 879 return false;
872} 880}
873 881
874QString KSyncManager::getPassword( ) 882QString KSyncManager::getPassword( )
875{ 883{
876 QString retfile = ""; 884 QString retfile = "";
877 QDialog dia ( mParent, "input-dialog", true ); 885 QDialog dia ( mParent, "input-dialog", true );
878 QLineEdit lab ( &dia ); 886 QLineEdit lab ( &dia );
879 lab.setEchoMode( QLineEdit::Password ); 887 lab.setEchoMode( QLineEdit::Password );
880 QVBoxLayout lay( &dia ); 888 QVBoxLayout lay( &dia );
881 lay.setMargin(7); 889 lay.setMargin(7);
882 lay.setSpacing(7); 890 lay.setSpacing(7);
883 lay.addWidget( &lab); 891 lay.addWidget( &lab);
884 dia.setFixedSize( 230,50 ); 892 dia.setFixedSize( 230,50 );
885 dia.setCaption( i18n("Enter password") ); 893 dia.setCaption( i18n("Enter password") );
886 QPushButton pb ( "OK", &dia); 894 QPushButton pb ( "OK", &dia);
887 lay.addWidget( &pb ); 895 lay.addWidget( &pb );
888 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 896 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
889 dia.show(); 897 dia.show();
890 int res = dia.exec(); 898 int res = dia.exec();
891 if ( res ) 899 if ( res )
892 retfile = lab.text(); 900 retfile = lab.text();
893 dia.hide(); 901 dia.hide();
894 qApp->processEvents(); 902 qApp->processEvents();
895 return retfile; 903 return retfile;
896 904
897} 905}
898 906
899 907
900void KSyncManager::confSync() 908void KSyncManager::confSync()
901{ 909{
902 static KSyncPrefsDialog* sp = 0; 910 static KSyncPrefsDialog* sp = 0;
903 if ( ! sp ) { 911 if ( ! sp ) {
904 sp = new KSyncPrefsDialog( mParent, "syncprefs", true ); 912 sp = new KSyncPrefsDialog( mParent, "syncprefs", true );
905 } 913 }
906 sp->usrReadConfig(); 914 sp->usrReadConfig();
907#ifndef DESKTOP_VERSION 915#ifndef DESKTOP_VERSION
908 sp->showMaximized(); 916 sp->showMaximized();
909#else 917#else
910 sp->show(); 918 sp->show();
911#endif 919#endif
912 sp->exec(); 920 sp->exec();
913 QStringList oldSyncProfileNames = mSyncProfileNames; 921 QStringList oldSyncProfileNames = mSyncProfileNames;
914 mSyncProfileNames = sp->getSyncProfileNames(); 922 mSyncProfileNames = sp->getSyncProfileNames();
915 mLocalMachineName = sp->getLocalMachineName (); 923 mLocalMachineName = sp->getLocalMachineName ();
916 int ii; 924 int ii;
917 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) { 925 for ( ii = 0; ii < oldSyncProfileNames.count(); ++ii ) {
918 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) ) 926 if ( ! mSyncProfileNames.contains( oldSyncProfileNames[ii] ) )
919 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] ); 927 mImplementation->removeSyncInfo( oldSyncProfileNames[ii] );
920 } 928 }
921 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 929 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
922} 930}
923void KSyncManager::syncKDE() 931void KSyncManager::syncKDE()
924{ 932{
925 mSyncWithDesktop = true; 933 mSyncWithDesktop = true;
926 emit save(); 934 emit save();
927 switch(mTargetApp) 935 switch(mTargetApp)
928 { 936 {
929 case (KAPI): 937 case (KAPI):
930 { 938 {
931#ifdef DESKTOP_VERSION 939#ifdef DESKTOP_VERSION
932 QString command = "kdeabdump33"; 940 QString command = "kdeabdump33";
933 QString commandfile = "kdeabdump33"; 941 QString commandfile = "kdeabdump33";
934 QString commandpath = qApp->applicationDirPath () + "/"; 942 QString commandpath = qApp->applicationDirPath () + "/";
935#else 943#else
936 QString command = "kdeabdump33"; 944 QString command = "kdeabdump33";
937 QString commandfile = "kdeabdump33"; 945 QString commandfile = "kdeabdump33";
938 QString commandpath = QDir::homeDirPath ()+"/"; 946 QString commandpath = QDir::homeDirPath ()+"/";
939#endif 947#endif
940 if ( ! QFile::exists ( commandpath+commandfile ) ) 948 if ( ! QFile::exists ( commandpath+commandfile ) )
941 command = commandfile; 949 command = commandfile;
942 else 950 else
943 command = commandpath+commandfile; 951 command = commandpath+commandfile;
944 952
945 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf"; 953 QString fileName = QDir::homeDirPath ()+"/.kdeaddressbookdump.vcf";
946 int result = system ( command.latin1()); 954 int result = system ( command.latin1());
947 qDebug("AB dump 33 command call result: %d ", result); 955 qDebug("AB dump 33 command call result: %d ", result);
948 if ( result != 0 ) { 956 if ( result != 0 ) {
949 qDebug("Calling AB dump version 33 failed. Trying 34... "); 957 qDebug("Calling AB dump version 33 failed. Trying 34... ");
950 commandfile = "kdeabdump34"; 958 commandfile = "kdeabdump34";
951 if ( ! QFile::exists ( commandpath+commandfile ) ) 959 if ( ! QFile::exists ( commandpath+commandfile ) )
952 command = commandfile; 960 command = commandfile;
953 else 961 else
954 command = commandpath+commandfile; 962 command = commandpath+commandfile;
955 result = system ( command.latin1()); 963 result = system ( command.latin1());
956 qDebug("AB dump 34 command call result: %d ", result); 964 qDebug("AB dump 34 command call result: %d ", result);
957 if ( result != 0 ) { 965 if ( result != 0 ) {
958 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 966 KMessageBox::error( 0, i18n("Error accessing KDE addressbook data.\nMake sure the file\n%1kdeabdump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
959 return; 967 return;
960 } 968 }
961 } 969 }
962 if ( syncWithFile( fileName,true ) ) { 970 if ( syncWithFile( fileName,true ) ) {
963 if ( mWriteBackFile ) { 971 if ( mWriteBackFile ) {
964 command += " --read"; 972 command += " --read";
965 system ( command.latin1()); 973 system ( command.latin1());
966 } 974 }
967 } 975 }
968 976
969 } 977 }
970 break; 978 break;
971 case (KOPI): 979 case (KOPI):
972 { 980 {
973#ifdef DESKTOP_VERSION 981#ifdef DESKTOP_VERSION
974 QString command = "kdecaldump33"; 982 QString command = "kdecaldump33";
975 QString commandfile = "kdecaldump33"; 983 QString commandfile = "kdecaldump33";
976 QString commandpath = qApp->applicationDirPath () + "/"; 984 QString commandpath = qApp->applicationDirPath () + "/";
977#else 985#else
978 QString command = "kdecaldump33"; 986 QString command = "kdecaldump33";
979 QString commandfile = "kdecaldump33"; 987 QString commandfile = "kdecaldump33";
980 QString commandpath = QDir::homeDirPath ()+"/"; 988 QString commandpath = QDir::homeDirPath ()+"/";
981#endif 989#endif
982 if ( ! QFile::exists ( commandpath+commandfile ) ) 990 if ( ! QFile::exists ( commandpath+commandfile ) )
983 command = commandfile; 991 command = commandfile;
984 else 992 else
985 command = commandpath+commandfile; 993 command = commandpath+commandfile;
986 994
987 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; 995 QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics";
988 int result = system ( command.latin1()); 996 int result = system ( command.latin1());
989 qDebug("Cal dump 33 command call result result: %d ", result); 997 qDebug("Cal dump 33 command call result result: %d ", result);
990 if ( result != 0 ) { 998 if ( result != 0 ) {
991 qDebug("Calling CAL dump version 33 failed. Trying 34... "); 999 qDebug("Calling CAL dump version 33 failed. Trying 34... ");
992 commandfile = "kdecaldump34"; 1000 commandfile = "kdecaldump34";
993 if ( ! QFile::exists ( commandpath+commandfile ) ) 1001 if ( ! QFile::exists ( commandpath+commandfile ) )
994 command = commandfile; 1002 command = commandfile;
995 else 1003 else
996 command = commandpath+commandfile; 1004 command = commandpath+commandfile;
997 result = system ( command.latin1()); 1005 result = system ( command.latin1());
998 qDebug("Cal dump 34 command call result result: %d ", result); 1006 qDebug("Cal dump 34 command call result result: %d ", result);
999 if ( result != 0 ) { 1007 if ( result != 0 ) {
1000 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath )); 1008 KMessageBox::error( 0, i18n("Error accessing KDE calendar data.\nMake sure the file\n%1kdecaldump3x\nexists ( x = 3 or 4 ).\nSupported KDE versions are 3.3 and 3.4.\nUsed version should be auto detected.\n").arg( commandpath ));
1001 return; 1009 return;
1002 } 1010 }
1003 } 1011 }
1004 if ( syncWithFile( fileName,true ) ) { 1012 if ( syncWithFile( fileName,true ) ) {
1005 if ( mWriteBackFile ) { 1013 if ( mWriteBackFile ) {
1006 command += " --read"; 1014 command += " --read";
1007 system ( command.latin1()); 1015 system ( command.latin1());
1008 } 1016 }
1009 } 1017 }
1010 1018
1011 } 1019 }
1012 break; 1020 break;
1013 case (PWMPI): 1021 case (PWMPI):
1014 1022
1015 break; 1023 break;
1016 default: 1024 default:
1017 qDebug("KSM::slotSyncMenu: invalid apptype selected"); 1025 qDebug("KSM::slotSyncMenu: invalid apptype selected");
1018 break; 1026 break;
1019 1027
1020 } 1028 }
1021} 1029}
1022 1030
1023void KSyncManager::syncSharp() 1031void KSyncManager::syncSharp()
1024{ 1032{
1025 1033
1026 if ( ! syncExternalApplication("sharp") ) 1034 if ( ! syncExternalApplication("sharp") )
1027 qDebug("KSM::ERROR sync sharp "); 1035 qDebug("KSM::ERROR sync sharp ");
1028} 1036}
1029 1037
1030bool KSyncManager::syncExternalApplication(QString resource) 1038bool KSyncManager::syncExternalApplication(QString resource)
1031{ 1039{
1032 1040
1033 emit save(); 1041 emit save();
1034 1042
1035 if ( mAskForPreferences ) 1043 if ( mAskForPreferences )
1036 if ( !edit_sync_options()) { 1044 if ( !edit_sync_options()) {
1037 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1045 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1038 return false; 1046 return false;
1039 } 1047 }
1040 1048
1041 qDebug("KSM::Sync extern %s", resource.latin1()); 1049 qDebug("KSM::Sync extern %s", resource.latin1());
1042 1050
1043 bool syncOK = mImplementation->syncExternal(this, resource); 1051 bool syncOK = mImplementation->syncExternal(this, resource);
1044 1052
1045 return syncOK; 1053 return syncOK;
1046 1054
1047} 1055}
1048 1056
1049void KSyncManager::syncPhone() 1057void KSyncManager::syncPhone()
1050{ 1058{
1051 1059
1052 syncExternalApplication("phone"); 1060 syncExternalApplication("phone");
1053 1061
1054} 1062}
1055 1063
1056void KSyncManager::showProgressBar(int percentage, QString caption, int total) 1064void KSyncManager::showProgressBar(int percentage, QString caption, int total)
1057{ 1065{
1058 if (!bar->isVisible()) 1066 if (!bar->isVisible())
1059 { 1067 {
1060 int w = 300; 1068 int w = 300;
1061 if ( QApplication::desktop()->width() < 320 ) 1069 if ( QApplication::desktop()->width() < 320 )
1062 w = 220; 1070 w = 220;
1063 int h = bar->sizeHint().height() ; 1071 int h = bar->sizeHint().height() ;
1064 int dw = QApplication::desktop()->width(); 1072 int dw = QApplication::desktop()->width();
1065 int dh = QApplication::desktop()->height(); 1073 int dh = QApplication::desktop()->height();
1066 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1074 bar->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1067 bar->setCaption (caption); 1075 bar->setCaption (caption);
1068 bar->setTotalSteps ( total ) ; 1076 bar->setTotalSteps ( total ) ;
1069 bar->show(); 1077 bar->show();
1070 } 1078 }
1071 bar->raise(); 1079 bar->raise();
1072 bar->setProgress( percentage ); 1080 bar->setProgress( percentage );
1073 qApp->processEvents(); 1081 qApp->processEvents();
1074} 1082}
1075 1083
1076void KSyncManager::hideProgressBar() 1084void KSyncManager::hideProgressBar()
1077{ 1085{
1078 bar->hide(); 1086 bar->hide();
1079 qApp->processEvents(); 1087 qApp->processEvents();
1080} 1088}
1081 1089
1082bool KSyncManager::isProgressBarCanceled() 1090bool KSyncManager::isProgressBarCanceled()
1083{ 1091{
1084 return !bar->isVisible(); 1092 return !bar->isVisible();
1085} 1093}
1086 1094
1087QString KSyncManager::syncFileName() 1095QString KSyncManager::syncFileName()
1088{ 1096{
1089 1097
1090 QString fn = "tempfile"; 1098 QString fn = "tempfile";
1091 switch(mTargetApp) 1099 switch(mTargetApp)
1092 { 1100 {
1093 case (KAPI): 1101 case (KAPI):
1094 fn = "tempsyncab.vcf"; 1102 fn = "tempsyncab.vcf";
1095 break; 1103 break;
1096 case (KOPI): 1104 case (KOPI):
1097 fn = "tempsynccal.ics"; 1105 fn = "tempsynccal.ics";
1098 break; 1106 break;
1099 case (PWMPI): 1107 case (PWMPI):
1100 fn = "tempsyncpw.pwm"; 1108 fn = "tempsyncpw.pwm";
1101 break; 1109 break;
1102 default: 1110 default:
1103 break; 1111 break;
1104 } 1112 }
1105#ifdef DESKTOP_VERSION 1113#ifdef DESKTOP_VERSION
1106 return locateLocal( "tmp", fn ); 1114 return locateLocal( "tmp", fn );
1107#else 1115#else
1108 return (QString( "/tmp/" )+ fn ); 1116 return (QString( "/tmp/" )+ fn );
1109#endif 1117#endif
1110} 1118}
1111 1119
1112void KSyncManager::syncPi() 1120void KSyncManager::syncPi()
1113{ 1121{
1114 mIsKapiFile = true; 1122 mIsKapiFile = true;
1115 mPisyncFinished = false; 1123 mPisyncFinished = false;
1116 qApp->processEvents(); 1124 qApp->processEvents();
1117 if ( mAskForPreferences ) 1125 if ( mAskForPreferences )
1118 if ( !edit_pisync_options()) { 1126 if ( !edit_pisync_options()) {
1119 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") ); 1127 mParent->topLevelWidget()->setCaption( i18n("Syncing aborted. Nothing synced.") );
1120 mPisyncFinished = true; 1128 mPisyncFinished = true;
1121 return; 1129 return;
1122 } 1130 }
1123 bool ok; 1131 bool ok;
1124 Q_UINT16 port = mActiveSyncPort.toUInt(&ok); 1132 Q_UINT16 port = mActiveSyncPort.toUInt(&ok);
1125 if ( ! ok ) { 1133 if ( ! ok ) {
1126 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1134 mParent->topLevelWidget()->setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1127 mPisyncFinished = true; 1135 mPisyncFinished = true;
1128 return; 1136 return;
1129 } 1137 }
1130 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() ); 1138 mCurrentResourceLocal = "";
1131 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1139 mCurrentResourceRemote = "";
1132 commandSocket->readFile( syncFileName() ); 1140 if ( mSpecificResources.count() ) {
1141 int startLocal = 0;
1142 int startRemote = mSpecificResources.count()/2;
1143 while ( startLocal < mSpecificResources.count()/2 ) {
1144 mPisyncFinished = false;
1145 mCurrentResourceLocal = mSpecificResources[ startLocal ];
1146 mCurrentResourceRemote = mSpecificResources[ startRemote ];
1147 KCommandSocket* commandSocket = new KCommandSocket( mCurrentResourceRemote, mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1148 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1149 commandSocket->readFile( syncFileName() );
1150 while ( !mPisyncFinished ) {
1151 //qDebug("waiting ");
1152 qApp->processEvents();
1153 }
1154 ++startLocal;
1155 }
1156 } else {
1157 KCommandSocket* commandSocket = new KCommandSocket( "", mPassWordPiSync, port, mActiveSyncIP, this, mParent->topLevelWidget() );
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1159 commandSocket->readFile( syncFileName() );
1160 }
1133} 1161}
1134 1162
1135void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state) 1163void KSyncManager::deleteCommandSocket(KCommandSocket*s, int state)
1136{ 1164{
1137 //enum { success, errorW, errorR, quiet }; 1165 //enum { success, errorW, errorR, quiet };
1138 1166
1139 1167
1140 1168
1141 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW || 1169 if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ||state == KCommandSocket::errorPW ||
1142 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) { 1170 state == KCommandSocket::errorCA ||state == KCommandSocket::errorFI ||state == KCommandSocket::errorUN||state == KCommandSocket::errorED ) {
1143 if ( state == KCommandSocket::errorPW ) 1171 if ( state == KCommandSocket::errorPW )
1144 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") ); 1172 mParent->topLevelWidget()->setCaption( i18n("Wrong password: Receiving remote file failed.") );
1145 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO ) 1173 else if ( state == KCommandSocket::errorR ||state == KCommandSocket::errorTO )
1146 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") ); 1174 mParent->topLevelWidget()->setCaption( i18n("ERROR: Receiving remote file failed.") );
1147 else if ( state == KCommandSocket::errorCA ) 1175 else if ( state == KCommandSocket::errorCA )
1148 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") ); 1176 mParent->topLevelWidget()->setCaption( i18n("Sync cancelled from remote.") );
1149 else if ( state == KCommandSocket::errorFI ) 1177 else if ( state == KCommandSocket::errorFI )
1150 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") ); 1178 mParent->topLevelWidget()->setCaption( i18n("File error on remote.") );
1151 else if ( state == KCommandSocket::errorED ) 1179 else if ( state == KCommandSocket::errorED )
1152 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") ); 1180 mParent->topLevelWidget()->setCaption( i18n("Please close error dialog on remote.") );
1153 else if ( state == KCommandSocket::errorUN ) 1181 else if ( state == KCommandSocket::errorUN )
1154 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") ); 1182 mParent->topLevelWidget()->setCaption( i18n("Unknown error on remote.") );
1155 delete s; 1183 delete s;
1156 if ( state == KCommandSocket::errorR ) { 1184 if ( state == KCommandSocket::errorR ) {
1157 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget()); 1185 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget());
1158 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1186 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1159 commandSocket->sendStop(); 1187 commandSocket->sendStop();
1160 } 1188 }
1161 mPisyncFinished = true; 1189 mPisyncFinished = true;
1162 return; 1190 return;
1163 1191
1164 } else if ( state == KCommandSocket::errorW ) { 1192 } else if ( state == KCommandSocket::errorW ) {
1165 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") ); 1193 mParent->topLevelWidget()->setCaption( i18n("ERROR:Writing back file failed.") );
1166 mPisyncFinished = true; 1194 mPisyncFinished = true;
1167 1195
1168 } else if ( state == KCommandSocket::successR ) { 1196 } else if ( state == KCommandSocket::successR ) {
1169 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1197 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1170 1198
1171 } else if ( state == KCommandSocket::successW ) { 1199 } else if ( state == KCommandSocket::successW ) {
1172 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") ); 1200 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync successful!") );
1173 mPisyncFinished = true; 1201 mPisyncFinished = true;
1174 } else if ( state == KCommandSocket::quiet ){ 1202 } else if ( state == KCommandSocket::quiet ){
1175 qDebug("KSS: quiet "); 1203 qDebug("KSS: quiet ");
1176 mPisyncFinished = true; 1204 mPisyncFinished = true;
1177 } else { 1205 } else {
1178 qDebug("KSS: Error: unknown state: %d ", state); 1206 qDebug("KSS: Error: unknown state: %d ", state);
1179 mPisyncFinished = true; 1207 mPisyncFinished = true;
1180 } 1208 }
1181 1209
1182 delete s; 1210 delete s;
1183} 1211}
1184 1212
1185void KSyncManager::readFileFromSocket() 1213void KSyncManager::readFileFromSocket()
1186{ 1214{
1187 QString fileName = syncFileName(); 1215 QString fileName = syncFileName();
1188 bool syncOK = true; 1216 bool syncOK = true;
1189 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") ); 1217 mParent->topLevelWidget()->setCaption( i18n("Remote file saved to temp file.") );
1190 if ( ! syncWithFile( fileName , true ) ) { 1218 if ( ! syncWithFile( fileName , true ) ) {
1191 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") ); 1219 mParent->topLevelWidget()->setCaption( i18n("Syncing failed.") );
1192 syncOK = false; 1220 syncOK = false;
1193 } 1221 }
1194 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() ); 1222 KCommandSocket* commandSocket = new KCommandSocket( "",mPassWordPiSync, mActiveSyncPort.toUInt(), mActiveSyncIP, this, mParent->topLevelWidget() );
1195 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1223 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1196 if ( mWriteBackFile && syncOK ) { 1224 if ( mWriteBackFile && syncOK ) {
1197 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") ); 1225 mParent->topLevelWidget()->setCaption( i18n("Sending back file ...") );
1198 commandSocket->writeFile( fileName ); 1226 commandSocket->writeFile( fileName );
1199 } 1227 }
1200 else { 1228 else {
1201 commandSocket->sendStop(); 1229 commandSocket->sendStop();
1202 if ( syncOK ) 1230 if ( syncOK )
1203 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") ); 1231 mParent->topLevelWidget()->setCaption( i18n("Pi-Sync succesful!") );
1204 mPisyncFinished = true; 1232 mPisyncFinished = true;
1205 } 1233 }
1206} 1234}
1207 1235
1208KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 1236KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
1209{ 1237{
1210 mPassWord = pw; 1238 mPassWord = pw;
1211 mSocket = 0; 1239 mSocket = 0;
1212 mSyncActionDialog = 0; 1240 mSyncActionDialog = 0;
1213 blockRC = false; 1241 blockRC = false;
1214 mErrorMessage = 0; 1242 mErrorMessage = 0;
1215} 1243}
1216 1244
1217void KServerSocket::newConnection ( int socket ) 1245void KServerSocket::newConnection ( int socket )
1218{ 1246{
1219 // qDebug("KServerSocket:New connection %d ", socket); 1247 // qDebug("KServerSocket:New connection %d ", socket);
1220 if ( mSocket ) { 1248 if ( mSocket ) {
1221 qDebug("KSS::newConnection Socket deleted! "); 1249 qDebug("KSS::newConnection Socket deleted! ");
1222 delete mSocket; 1250 delete mSocket;
1223 mSocket = 0; 1251 mSocket = 0;
1224 } 1252 }
1225 mSocket = new QSocket( this ); 1253 mSocket = new QSocket( this );
1226 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 1254 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
1227 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 1255 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
1228 mSocket->setSocket( socket ); 1256 mSocket->setSocket( socket );
1229} 1257}
1230 1258
1231void KServerSocket::discardClient() 1259void KServerSocket::discardClient()
1232{ 1260{
1233 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1261 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1234} 1262}
1235void KServerSocket::deleteSocket() 1263void KServerSocket::deleteSocket()
1236{ 1264{
1237 qDebug("KSS::deleteSocket"); 1265 qDebug("KSS::deleteSocket");
1238 if ( mSocket ) { 1266 if ( mSocket ) {
1239 delete mSocket; 1267 delete mSocket;
1240 mSocket = 0; 1268 mSocket = 0;
1241 } 1269 }
1242 if ( mErrorMessage ) 1270 if ( mErrorMessage )
1243 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage())); 1271 QTimer::singleShot( 10, this , SLOT ( displayErrorMessage()));
1244} 1272}
1245void KServerSocket::readClient() 1273void KServerSocket::readClient()
1246{ 1274{
1247 if ( blockRC ) 1275 if ( blockRC )
1248 return; 1276 return;
1249 if ( mSocket == 0 ) { 1277 if ( mSocket == 0 ) {
1250 qDebug("ERROR::KSS::readClient(): mSocket == 0 "); 1278 qDebug("ERROR::KSS::readClient(): mSocket == 0 ");
1251 return; 1279 return;
1252 } 1280 }
1253 if ( mErrorMessage ) { 1281 if ( mErrorMessage ) {
1254 mErrorMessage = 999; 1282 mErrorMessage = 999;
1255 error_connect("ERROR_ED\r\n\r\n"); 1283 error_connect("ERROR_ED\r\n\r\n");
1256 return; 1284 return;
1257 } 1285 }
1258 mErrorMessage = 0; 1286 mErrorMessage = 0;
1259 //qDebug("KServerSocket::readClient()"); 1287 //qDebug("KServerSocket::readClient()");
1260 if ( mSocket->canReadLine() ) { 1288 if ( mSocket->canReadLine() ) {
1261 QString line = mSocket->readLine(); 1289 QString line = mSocket->readLine();
1262 //qDebug("KServerSocket readline: %s ", line.latin1()); 1290 //qDebug("KServerSocket readline: %s ", line.latin1());
1263 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); 1291 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line );
1264 if ( tokens[0] == "GET" ) { 1292 if ( tokens[0] == "GET" ) {
1265 if ( tokens[1] == mPassWord ) { 1293 if ( tokens[1] == mPassWord ) {
1266 //emit sendFile( mSocket ); 1294 //emit sendFile( mSocket );
1267 bool ok = false; 1295 bool ok = false;
1268 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok); 1296 QDateTime dt = KGlobal::locale()->readDateTime( tokens[2], KLocale::ISODate, &ok);
1269 if ( ok ) { 1297 if ( ok ) {
1270 KSyncManager::mRequestedSyncEvent = dt; 1298 KSyncManager::mRequestedSyncEvent = dt;
1271 } 1299 }
1272 else 1300 else
1273 KSyncManager::mRequestedSyncEvent = QDateTime(); 1301 KSyncManager::mRequestedSyncEvent = QDateTime();
1274 send_file(); 1302 send_file();
1275 } 1303 }
1276 else { 1304 else {
1277 mErrorMessage = 1; 1305 mErrorMessage = 1;
1278 error_connect("ERROR_PW\r\n\r\n"); 1306 error_connect("ERROR_PW\r\n\r\n");
1279 } 1307 }
1280 } 1308 }
1281 if ( tokens[0] == "PUT" ) { 1309 if ( tokens[0] == "PUT" ) {
1282 if ( tokens[1] == mPassWord ) { 1310 if ( tokens[1] == mPassWord ) {
1283 //emit getFile( mSocket ); 1311 //emit getFile( mSocket );
1284 blockRC = true; 1312 blockRC = true;
1285 get_file(); 1313 get_file();
1286 } 1314 }
1287 else { 1315 else {
1288 mErrorMessage = 2; 1316 mErrorMessage = 2;
1289 error_connect("ERROR_PW\r\n\r\n"); 1317 error_connect("ERROR_PW\r\n\r\n");
1290 end_connect(); 1318 end_connect();
1291 } 1319 }
1292 } 1320 }
1293 if ( tokens[0] == "STOP" ) { 1321 if ( tokens[0] == "STOP" ) {
1294 //emit endConnect(); 1322 //emit endConnect();
1295 end_connect(); 1323 end_connect();
1296 } 1324 }
1297 } 1325 }
1298} 1326}
1299void KServerSocket::displayErrorMessage() 1327void KServerSocket::displayErrorMessage()
1300{ 1328{
1301 if ( mErrorMessage == 1 ) { 1329 if ( mErrorMessage == 1 ) {
1302 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error")); 1330 KMessageBox::error( 0, i18n("Got send file request\nwith invalid password"), i18n("Pi-Sync Error"));
1303 mErrorMessage = 0; 1331 mErrorMessage = 0;
1304 } 1332 }
1305 else if ( mErrorMessage == 2 ) { 1333 else if ( mErrorMessage == 2 ) {
1306 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error")); 1334 KMessageBox::error( 0, i18n("Got receive file request\nwith invalid password"), i18n("Pi-Sync Error"));
1307 mErrorMessage = 0; 1335 mErrorMessage = 0;
1308 } 1336 }
1309} 1337}
1310void KServerSocket::error_connect( QString errmess ) 1338void KServerSocket::error_connect( QString errmess )
1311{ 1339{
1312 QTextStream os( mSocket ); 1340 QTextStream os( mSocket );
1313 os.setEncoding( QTextStream::Latin1 ); 1341 os.setEncoding( QTextStream::Latin1 );
1314 os << errmess ; 1342 os << errmess ;
1315 mSocket->close(); 1343 mSocket->close();
1316 if ( mSocket->state() == QSocket::Idle ) { 1344 if ( mSocket->state() == QSocket::Idle ) {
1317 QTimer::singleShot( 0, this , SLOT ( discardClient())); 1345 QTimer::singleShot( 0, this , SLOT ( discardClient()));
1318 } 1346 }
1319} 1347}
1320void KServerSocket::end_connect() 1348void KServerSocket::end_connect()
1321{ 1349{
1322 delete mSyncActionDialog; 1350 delete mSyncActionDialog;
1323 mSyncActionDialog = 0; 1351 mSyncActionDialog = 0;
1324} 1352}
1325void KServerSocket::send_file() 1353void KServerSocket::send_file()
1326{ 1354{
1327 //qDebug("MainWindow::sendFile(QSocket* s) "); 1355 //qDebug("MainWindow::sendFile(QSocket* s) ");
1328 if ( mSyncActionDialog ) 1356 if ( mSyncActionDialog )
1329 delete mSyncActionDialog; 1357 delete mSyncActionDialog;
1330 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 1358 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
1331 mSyncActionDialog->setCaption(i18n("Received sync request")); 1359 mSyncActionDialog->setCaption(i18n("Received sync request"));
1332 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); 1360 QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog );
1333 label->setAlignment ( Qt::AlignHCenter ); 1361 label->setAlignment ( Qt::AlignHCenter );
1334 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 1362 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
1335 lay->addWidget( label); 1363 lay->addWidget( label);
1336 lay->setMargin(7); 1364 lay->setMargin(7);
1337 lay->setSpacing(7); 1365 lay->setSpacing(7);
1338 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1366 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1339 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent ); 1367 int secs = QDateTime::currentDateTime().secsTo( KSyncManager::mRequestedSyncEvent );
1340 //secs = 333; 1368 //secs = 333;
1341 if ( secs < 0 ) 1369 if ( secs < 0 )
1342 secs = secs * (-1); 1370 secs = secs * (-1);
1343 if ( secs > 30 ) 1371 if ( secs > 30 )
1344 //if ( true ) 1372 //if ( true )
1345 { 1373 {
1346 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs ); 1374 QString warning = i18n("Clock skew of\nsyncing devices\nis %1 seconds!").arg( secs );
1347 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1375 QLabel* label = new QLabel( warning, mSyncActionDialog );
1348 label->setAlignment ( Qt::AlignHCenter ); 1376 label->setAlignment ( Qt::AlignHCenter );
1349 lay->addWidget( label); 1377 lay->addWidget( label);
1350 if ( secs > 180 ) 1378 if ( secs > 180 )
1351 { 1379 {
1352 if ( secs > 300 ) { 1380 if ( secs > 300 ) {
1353 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) { 1381 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(0, i18n("The clocks of the syncing\ndevices have a difference\nof more than 5 minutes.\nPlease adjust your clocks.\nYou may get wrong syncing results!\nPlease confirm synchronization!"), i18n("High clock skew!"),i18n("Synchronize!"))) {
1354 qDebug("KSS::Sync cancelled ,cs"); 1382 qDebug("KSS::Sync cancelled ,cs");
1355 mErrorMessage = 0; 1383 mErrorMessage = 0;
1356 end_connect(); 1384 end_connect();
1357 error_connect("ERROR_CA\r\n\r\n"); 1385 error_connect("ERROR_CA\r\n\r\n");
1358 return ; 1386 return ;
1359 } 1387 }
1360 } 1388 }
1361 QFont f = label->font(); 1389 QFont f = label->font();
1362 f.setPointSize ( f.pointSize() *2 ); 1390 f.setPointSize ( f.pointSize() *2 );
1363 f. setBold (true ); 1391 f. setBold (true );
1364 QLabel* label = new QLabel( warning, mSyncActionDialog ); 1392 QLabel* label = new QLabel( warning, mSyncActionDialog );
1365 label->setFont( f ); 1393 label->setFont( f );
1366 warning = i18n("ADJUST\nYOUR\nCLOCKS!"); 1394 warning = i18n("ADJUST\nYOUR\nCLOCKS!");
1367 label->setText( warning ); 1395 label->setText( warning );
1368 label->setAlignment ( Qt::AlignHCenter ); 1396 label->setAlignment ( Qt::AlignHCenter );
1369 lay->addWidget( label); 1397 lay->addWidget( label);
1370 mSyncActionDialog->setFixedSize( 230, 300); 1398 mSyncActionDialog->setFixedSize( 230, 300);
1371 } else { 1399 } else {
1372 mSyncActionDialog->setFixedSize( 230, 200); 1400 mSyncActionDialog->setFixedSize( 230, 200);
1373 } 1401 }
1374 } else { 1402 } else {
1375 mSyncActionDialog->setFixedSize( 230, 120); 1403 mSyncActionDialog->setFixedSize( 230, 120);
1376 } 1404 }
1377 } else 1405 } else
1378 mSyncActionDialog->setFixedSize( 230, 120); 1406 mSyncActionDialog->setFixedSize( 230, 120);
1379 mSyncActionDialog->show(); 1407 mSyncActionDialog->show();
1380 mSyncActionDialog->raise(); 1408 mSyncActionDialog->raise();
1381 emit request_file(); 1409 emit request_file();
1382 qApp->processEvents(); 1410 qApp->processEvents();
1383 QString fileName = mFileName; 1411 QString fileName = mFileName;
1384 QFile file( fileName ); 1412 QFile file( fileName );
1385 if (!file.open( IO_ReadOnly ) ) { 1413 if (!file.open( IO_ReadOnly ) ) {
1386 mErrorMessage = 0; 1414 mErrorMessage = 0;
1387 end_connect(); 1415 end_connect();
1388 error_connect("ERROR_FI\r\n\r\n"); 1416 error_connect("ERROR_FI\r\n\r\n");
1389 return ; 1417 return ;
1390 } 1418 }
1391 mSyncActionDialog->setCaption( i18n("Sending file...") ); 1419 mSyncActionDialog->setCaption( i18n("Sending file...") );
1392 QTextStream ts( &file ); 1420 QTextStream ts( &file );
1393 ts.setEncoding( QTextStream::Latin1 ); 1421 ts.setEncoding( QTextStream::Latin1 );
1394 1422
1395 QTextStream os( mSocket ); 1423 QTextStream os( mSocket );
1396 os.setEncoding( QTextStream::Latin1 ); 1424 os.setEncoding( QTextStream::Latin1 );
1397 while ( ! ts.atEnd() ) { 1425 while ( ! ts.atEnd() ) {
1398 os << ts.readLine() << "\r\n"; 1426 os << ts.readLine() << "\r\n";
1399 } 1427 }
1400 os << "\r\n"; 1428 os << "\r\n";
1401 //os << ts.read(); 1429 //os << ts.read();
1402 file.close(); 1430 file.close();
1403 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 1431 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
1404 mSocket->close(); 1432 mSocket->close();
1405 if ( mSocket->state() == QSocket::Idle ) 1433 if ( mSocket->state() == QSocket::Idle )
1406 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1434 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1407} 1435}
1408void KServerSocket::get_file() 1436void KServerSocket::get_file()
1409{ 1437{
1410 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 1438 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
1411 1439
1412 piTime.start(); 1440 piTime.start();
1413 piFileString = ""; 1441 piFileString = "";
1414 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 1442 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
1415} 1443}
1416 1444
1417 1445
1418void KServerSocket::readBackFileFromSocket() 1446void KServerSocket::readBackFileFromSocket()
1419{ 1447{
1420 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 1448 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
1421 while ( mSocket->canReadLine () ) { 1449 while ( mSocket->canReadLine () ) {
1422 piTime.restart(); 1450 piTime.restart();
1423 QString line = mSocket->readLine (); 1451 QString line = mSocket->readLine ();
1424 piFileString += line; 1452 piFileString += line;
1425 //qDebug("readline: %s ", line.latin1()); 1453 //qDebug("readline: %s ", line.latin1());
1426 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 1454 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
1427 1455
1428 } 1456 }
1429 if ( piTime.elapsed () < 3000 ) { 1457 if ( piTime.elapsed () < 3000 ) {
1430 // wait for more 1458 // wait for more
1431 //qDebug("waitformore "); 1459 //qDebug("waitformore ");
1432 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 1460 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
1433 return; 1461 return;
1434 } 1462 }
1435 QString fileName = mFileName; 1463 QString fileName = mFileName;
1436 QFile file ( fileName ); 1464 QFile file ( fileName );
1437 if (!file.open( IO_WriteOnly ) ) { 1465 if (!file.open( IO_WriteOnly ) ) {
1438 delete mSyncActionDialog; 1466 delete mSyncActionDialog;
1439 mSyncActionDialog = 0; 1467 mSyncActionDialog = 0;
1440 qDebug("KSS:Error open read back file "); 1468 qDebug("KSS:Error open read back file ");
1441 piFileString = ""; 1469 piFileString = "";
1442 emit file_received( false ); 1470 emit file_received( false );
1443 blockRC = false; 1471 blockRC = false;
1444 return ; 1472 return ;
1445 1473
1446 } 1474 }
1447 1475
1448 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1476 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1449 QTextStream ts ( &file ); 1477 QTextStream ts ( &file );
1450 ts.setEncoding( QTextStream::Latin1 ); 1478 ts.setEncoding( QTextStream::Latin1 );
1451 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 1479 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
1452 ts << piFileString; 1480 ts << piFileString;
1453 mSocket->close(); 1481 mSocket->close();
1454 if ( mSocket->state() == QSocket::Idle ) 1482 if ( mSocket->state() == QSocket::Idle )
1455 QTimer::singleShot( 10, this , SLOT ( discardClient())); 1483 QTimer::singleShot( 10, this , SLOT ( discardClient()));
1456 file.close(); 1484 file.close();
1457 piFileString = ""; 1485 piFileString = "";
1458 emit file_received( true ); 1486 emit file_received( true );
1459 delete mSyncActionDialog; 1487 delete mSyncActionDialog;
1460 mSyncActionDialog = 0; 1488 mSyncActionDialog = 0;
1461 blockRC = false; 1489 blockRC = false;
1462 1490
1463} 1491}
1464 1492
1465KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name ) 1493KCommandSocket::KCommandSocket ( QString remres, QString password, Q_UINT16 port, QString host, QObject * parent, QWidget * cap, const char * name ): QObject( parent, name )
1466{ 1494{
1495 mRemoteResource = remres;
1496 if ( mRemoteResource.isEmpty() )
1497 mRemoteResource = "ALL";
1467 mPassWord = password; 1498 mPassWord = password;
1468 mSocket = 0; 1499 mSocket = 0;
1469 mFirst = false; 1500 mFirst = false;
1470 mFirstLine = true; 1501 mFirstLine = true;
1471 mPort = port; 1502 mPort = port;
1472 mHost = host; 1503 mHost = host;
1473 tlw = cap; 1504 tlw = cap;
1474 mRetVal = quiet; 1505 mRetVal = quiet;
1475 mTimerSocket = new QTimer ( this ); 1506 mTimerSocket = new QTimer ( this );
1476 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) ); 1507 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( updateConnectDialog() ) );
1477 mConnectProgress.setCaption( i18n("Pi-Sync") ); 1508 mConnectProgress.setCaption( i18n("Pi-Sync") );
1478 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) ); 1509 connect( &mConnectProgress, SIGNAL ( cancelled () ), this, SLOT ( deleteSocket() ) );
1479 mConnectCount = -1; 1510 mConnectCount = -1;
1480} 1511}
1481void KCommandSocket::sendFileRequest() 1512void KCommandSocket::sendFileRequest()
1482{ 1513{
1483 if ( tlw ) 1514 if ( tlw )
1484 tlw->setCaption( i18n("Connected! Sending request for remote file ...") ); 1515 tlw->setCaption( i18n("Connected! Sending request for remote file ...") );
1485 mConnectProgress.hide(); 1516 mConnectProgress.hide();
1486 mConnectCount = 300;mConnectMax = 300; 1517 mConnectCount = 300;mConnectMax = 300;
1487 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") ); 1518 mConnectProgress.setCaption( i18n("Pi-Sync: Connected!") );
1488 mTimerSocket->start( 100, true ); 1519 mTimerSocket->start( 100, true );
1489 QTextStream os( mSocket ); 1520 QTextStream os( mSocket );
1490 os.setEncoding( QTextStream::Latin1 ); 1521 os.setEncoding( QTextStream::Latin1 );
1491 1522
1492 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate ); 1523 QString curDt = " " +KGlobal::locale()->formatDateTime(QDateTime::currentDateTime().addSecs(-1),true, true,KLocale::ISODate );
1493 os << "GET " << mPassWord << curDt <<"\r\n\r\n"; 1524 os << "GET " << mPassWord << curDt << mRemoteResource << "\r\n\r\n";
1494} 1525}
1495 1526
1496void KCommandSocket::readFile( QString fn ) 1527void KCommandSocket::readFile( QString fn )
1497{ 1528{
1498 if ( !mSocket ) { 1529 if ( !mSocket ) {
1499 mSocket = new QSocket( this ); 1530 mSocket = new QSocket( this );
1500 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 1531 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
1501 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1532 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1502 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() )); 1533 connect( mSocket, SIGNAL(connected ()), this, SLOT(sendFileRequest() ));
1503 } 1534 }
1504 mFileString = ""; 1535 mFileString = "";
1505 mFileName = fn; 1536 mFileName = fn;
1506 mFirst = true; 1537 mFirst = true;
1507 if ( tlw ) 1538 if ( tlw )
1508 tlw->setCaption( i18n("Trying to connect to remote...") ); 1539 tlw->setCaption( i18n("Trying to connect to remote...") );
1509 mConnectCount = 30;mConnectMax = 30; 1540 mConnectCount = 30;mConnectMax = 30;
1510 mTimerSocket->start( 1000, true ); 1541 mTimerSocket->start( 1000, true );
1511 mSocket->connectToHost( mHost, mPort ); 1542 mSocket->connectToHost( mHost, mPort );
1512 qDebug("KSS: Waiting for connection"); 1543 qDebug("KSS: Waiting for connection");
1513} 1544}
1514void KCommandSocket::updateConnectDialog() 1545void KCommandSocket::updateConnectDialog()
1515{ 1546{
1516 1547
1517 if ( mConnectCount == mConnectMax ) { 1548 if ( mConnectCount == mConnectMax ) {
1518 //qDebug("MAXX %d", mConnectMax); 1549 //qDebug("MAXX %d", mConnectMax);
1519 mConnectProgress.setTotalSteps ( 30 ); 1550 mConnectProgress.setTotalSteps ( 30 );
1520 mConnectProgress.show(); 1551 mConnectProgress.show();
1521 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") ); 1552 mConnectProgress.setLabelText( i18n("Trying to connect to remote...") );
1522 } 1553 }
1523 //qDebug("updateConnectDialog() %d", mConnectCount); 1554 //qDebug("updateConnectDialog() %d", mConnectCount);
1524 mConnectProgress.raise(); 1555 mConnectProgress.raise();
1525 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 ); 1556 mConnectProgress.setProgress( (mConnectMax - mConnectCount)%30 );
1526 --mConnectCount; 1557 --mConnectCount;
1527 if ( mConnectCount > 0 ) 1558 if ( mConnectCount > 0 )
1528 mTimerSocket->start( 1000, true ); 1559 mTimerSocket->start( 1000, true );
1529 else 1560 else
1530 deleteSocket(); 1561 deleteSocket();
1531 1562
1532} 1563}
1533void KCommandSocket::writeFile( QString fileName ) 1564void KCommandSocket::writeFile( QString fileName )
1534{ 1565{
1535 if ( !mSocket ) { 1566 if ( !mSocket ) {
1536 mSocket = new QSocket( this ); 1567 mSocket = new QSocket( this );
1537 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1568 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1538 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 1569 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
1539 } 1570 }
1540 mFileName = fileName ; 1571 mFileName = fileName ;
1541 mConnectCount = 30;mConnectMax = 30; 1572 mConnectCount = 30;mConnectMax = 30;
1542 mTimerSocket->start( 1000, true ); 1573 mTimerSocket->start( 1000, true );
1543 mSocket->connectToHost( mHost, mPort ); 1574 mSocket->connectToHost( mHost, mPort );
1544} 1575}
1545void KCommandSocket::writeFileToSocket() 1576void KCommandSocket::writeFileToSocket()
1546{ 1577{
1547 mTimerSocket->stop(); 1578 mTimerSocket->stop();
1548 QFile file2( mFileName ); 1579 QFile file2( mFileName );
1549 if (!file2.open( IO_ReadOnly ) ) { 1580 if (!file2.open( IO_ReadOnly ) ) {
1550 mConnectProgress.hide(); 1581 mConnectProgress.hide();
1551 mConnectCount = -1; 1582 mConnectCount = -1;
1552 mRetVal= errorW; 1583 mRetVal= errorW;
1553 mSocket->close(); 1584 mSocket->close();
1554 if ( mSocket->state() == QSocket::Idle ) 1585 if ( mSocket->state() == QSocket::Idle )
1555 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1586 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1556 return ; 1587 return ;
1557 } 1588 }
1558 mConnectProgress.setTotalSteps ( file2.size() ); 1589 mConnectProgress.setTotalSteps ( file2.size() );
1559 mConnectProgress.show(); 1590 mConnectProgress.show();
1560 int count = 0; 1591 int count = 0;
1561 mConnectProgress.setLabelText( i18n("Sending back synced file...") ); 1592 mConnectProgress.setLabelText( i18n("Sending back synced file...") );
1562 mConnectProgress.setProgress( count ); 1593 mConnectProgress.setProgress( count );
1563 mConnectProgress.blockSignals( true ); 1594 mConnectProgress.blockSignals( true );
1564 QTextStream ts2( &file2 ); 1595 QTextStream ts2( &file2 );
1565 ts2.setEncoding( QTextStream::Latin1 ); 1596 ts2.setEncoding( QTextStream::Latin1 );
1566 QTextStream os2( mSocket ); 1597 QTextStream os2( mSocket );
1567 os2.setEncoding( QTextStream::Latin1 ); 1598 os2.setEncoding( QTextStream::Latin1 );
1568 os2 << "PUT " << mPassWord << "\r\n\r\n";; 1599 os2 << "PUT " << mPassWord << "\r\n\r\n";;
1569 int byteCount = 0; 1600 int byteCount = 0;
1570 int byteMax = file2.size()/53; 1601 int byteMax = file2.size()/53;
1571 while ( ! ts2.atEnd() ) { 1602 while ( ! ts2.atEnd() ) {
1572 qApp->processEvents(); 1603 qApp->processEvents();
1573 if ( byteCount > byteMax ) { 1604 if ( byteCount > byteMax ) {
1574 byteCount = 0; 1605 byteCount = 0;
1575 mConnectProgress.setProgress( count ); 1606 mConnectProgress.setProgress( count );
1576 } 1607 }
1577 QString temp = ts2.readLine(); 1608 QString temp = ts2.readLine();
1578 count += temp.length(); 1609 count += temp.length();
1579 byteCount += temp.length(); 1610 byteCount += temp.length();
1580 os2 << temp << "\r\n"; 1611 os2 << temp << "\r\n";
1581 } 1612 }
1582 file2.close(); 1613 file2.close();
1583 mConnectProgress.hide(); 1614 mConnectProgress.hide();
1584 mConnectCount = -1; 1615 mConnectCount = -1;
1585 os2 << "\r\n"; 1616 os2 << "\r\n";
1586 mRetVal= successW; 1617 mRetVal= successW;
1587 mSocket->close(); 1618 mSocket->close();
1588 if ( mSocket->state() == QSocket::Idle ) 1619 if ( mSocket->state() == QSocket::Idle )
1589 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1620 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1590 mConnectProgress.blockSignals( false ); 1621 mConnectProgress.blockSignals( false );
1591} 1622}
1592void KCommandSocket::sendStop() 1623void KCommandSocket::sendStop()
1593{ 1624{
1594 if ( !mSocket ) { 1625 if ( !mSocket ) {
1595 mSocket = new QSocket( this ); 1626 mSocket = new QSocket( this );
1596 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1627 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1597 } 1628 }
1598 mSocket->connectToHost( mHost, mPort ); 1629 mSocket->connectToHost( mHost, mPort );
1599 QTextStream os2( mSocket ); 1630 QTextStream os2( mSocket );
1600 os2.setEncoding( QTextStream::Latin1 ); 1631 os2.setEncoding( QTextStream::Latin1 );
1601 os2 << "STOP\r\n\r\n"; 1632 os2 << "STOP\r\n\r\n";
1602 mSocket->close(); 1633 mSocket->close();
1603 if ( mSocket->state() == QSocket::Idle ) 1634 if ( mSocket->state() == QSocket::Idle )
1604 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 1635 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
1605} 1636}
1606 1637
1607void KCommandSocket::startReadFileFromSocket() 1638void KCommandSocket::startReadFileFromSocket()
1608{ 1639{
1609 if ( ! mFirst ) 1640 if ( ! mFirst )
1610 return; 1641 return;
1611 mConnectProgress.setLabelText( i18n("Receiving file from remote...") ); 1642 mConnectProgress.setLabelText( i18n("Receiving file from remote...") );
1612 mFirst = false; 1643 mFirst = false;
1613 mFileString = ""; 1644 mFileString = "";
1614 mTime.start(); 1645 mTime.start();
1615 mFirstLine = true; 1646 mFirstLine = true;
1616 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 1647 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
1617 1648
1618} 1649}
1619void KCommandSocket::readFileFromSocket() 1650void KCommandSocket::readFileFromSocket()
1620{ 1651{
1621 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 1652 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
1622 while ( mSocket->canReadLine () ) { 1653 while ( mSocket->canReadLine () ) {
1623 mTime.restart(); 1654 mTime.restart();
1624 QString line = mSocket->readLine (); 1655 QString line = mSocket->readLine ();
1625 if ( mFirstLine ) { 1656 if ( mFirstLine ) {
1626 mFirstLine = false; 1657 mFirstLine = false;
1627 if ( line.left( 6 ) == "ERROR_" ) { 1658 if ( line.left( 6 ) == "ERROR_" ) {
1628 mTimerSocket->stop(); 1659 mTimerSocket->stop();
1629 mConnectCount = -1; 1660 mConnectCount = -1;
1630 if ( line.left( 8 ) == "ERROR_PW" ) { 1661 if ( line.left( 8 ) == "ERROR_PW" ) {
1631 mRetVal = errorPW; 1662 mRetVal = errorPW;
1632 deleteSocket(); 1663 deleteSocket();
1633 return ; 1664 return ;
1634 } 1665 }
1635 if ( line.left( 8 ) == "ERROR_CA" ) { 1666 if ( line.left( 8 ) == "ERROR_CA" ) {
1636 mRetVal = errorCA; 1667 mRetVal = errorCA;
1637 deleteSocket(); 1668 deleteSocket();
1638 return ; 1669 return ;
1639 } 1670 }
1640 if ( line.left( 8 ) == "ERROR_FI" ) { 1671 if ( line.left( 8 ) == "ERROR_FI" ) {
1641 mRetVal = errorFI; 1672 mRetVal = errorFI;
1642 deleteSocket(); 1673 deleteSocket();
1643 return ; 1674 return ;
1644 } 1675 }
1645 if ( line.left( 8 ) == "ERROR_ED" ) { 1676 if ( line.left( 8 ) == "ERROR_ED" ) {
1646 mRetVal = errorED; 1677 mRetVal = errorED;
1647 deleteSocket(); 1678 deleteSocket();
1648 return ; 1679 return ;
1649 } 1680 }
1650 mRetVal = errorUN; 1681 mRetVal = errorUN;
1651 deleteSocket(); 1682 deleteSocket();
1652 return ; 1683 return ;
1653 } 1684 }
1654 } 1685 }
1655 mFileString += line; 1686 mFileString += line;
1656 //qDebug("readline: %s ", line.latin1()); 1687 //qDebug("readline: %s ", line.latin1());
1657 } 1688 }
1658 if ( mTime.elapsed () < 3000 ) { 1689 if ( mTime.elapsed () < 3000 ) {
1659 // wait for more 1690 // wait for more
1660 //qDebug("waitformore "); 1691 //qDebug("waitformore ");
1661 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 1692 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
1662 return; 1693 return;
1663 } 1694 }
1664 mTimerSocket->stop(); 1695 mTimerSocket->stop();
1665 mConnectCount = -1; 1696 mConnectCount = -1;
1666 mConnectProgress.hide(); 1697 mConnectProgress.hide();
1667 QString fileName = mFileName; 1698 QString fileName = mFileName;
1668 QFile file ( fileName ); 1699 QFile file ( fileName );
1669 if (!file.open( IO_WriteOnly ) ) { 1700 if (!file.open( IO_WriteOnly ) ) {
1670 mFileString = ""; 1701 mFileString = "";
1671 mRetVal = errorR; 1702 mRetVal = errorR;
1672 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() ); 1703 qDebug("KSS:Error open temp sync file for writing: %s",fileName.latin1() );
1673 deleteSocket(); 1704 deleteSocket();
1674 return ; 1705 return ;
1675 1706
1676 } 1707 }
1677 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1708 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1678 QTextStream ts ( &file ); 1709 QTextStream ts ( &file );
1679 ts.setEncoding( QTextStream::Latin1 ); 1710 ts.setEncoding( QTextStream::Latin1 );
1680 ts << mFileString; 1711 ts << mFileString;
1681 file.close(); 1712 file.close();
1682 mFileString = ""; 1713 mFileString = "";
1683 mRetVal = successR; 1714 mRetVal = successR;
1684 mSocket->close(); 1715 mSocket->close();
1685 // if state is not idle, deleteSocket(); is called via 1716 // if state is not idle, deleteSocket(); is called via
1686 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 1717 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
1687 if ( mSocket->state() == QSocket::Idle ) 1718 if ( mSocket->state() == QSocket::Idle )
1688 deleteSocket(); 1719 deleteSocket();
1689} 1720}
1690 1721
1691void KCommandSocket::deleteSocket() 1722void KCommandSocket::deleteSocket()
1692{ 1723{
1693 //qDebug("KCommandSocket::deleteSocket() "); 1724 //qDebug("KCommandSocket::deleteSocket() ");
1694 mConnectProgress.hide(); 1725 mConnectProgress.hide();
1695 1726
1696 if ( mConnectCount >= 0 ) { 1727 if ( mConnectCount >= 0 ) {
1697 mTimerSocket->stop(); 1728 mTimerSocket->stop();
1698 mRetVal = errorTO; 1729 mRetVal = errorTO;
1699 qDebug("KCS::Connection to remote host timed out"); 1730 qDebug("KCS::Connection to remote host timed out");
1700 if ( mSocket ) { 1731 if ( mSocket ) {
1701 mSocket->close(); 1732 mSocket->close();
1702 //if ( mSocket->state() == QSocket::Idle ) 1733 //if ( mSocket->state() == QSocket::Idle )
1703 // deleteSocket(); 1734 // deleteSocket();
1704 delete mSocket; 1735 delete mSocket;
1705 mSocket = 0; 1736 mSocket = 0;
1706 } 1737 }
1707 if ( mConnectCount == 0 ) 1738 if ( mConnectCount == 0 )
1708 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?")); 1739 KMessageBox::error( 0, i18n("Connection to remote\nhost timed out!\nDid you forgot to enable\nsyncing on remote host?"));
1709 else if ( tlw ) 1740 else if ( tlw )
1710 tlw->setCaption( i18n("Connection to remote host cancelled!") ); 1741 tlw->setCaption( i18n("Connection to remote host cancelled!") );
1711 emit commandFinished( this, mRetVal ); 1742 emit commandFinished( this, mRetVal );
1712 return; 1743 return;
1713 } 1744 }
1714 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 1745 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
1715 if ( mSocket) 1746 if ( mSocket)
1716 delete mSocket; 1747 delete mSocket;
1717 mSocket = 0; 1748 mSocket = 0;
1718 qDebug("commandFinished "); 1749 qDebug("commandFinished ");
1719 emit commandFinished( this, mRetVal ); 1750 emit commandFinished( this, mRetVal );
1720} 1751}
diff --git a/libkdepim/ksyncmanager.h b/libkdepim/ksyncmanager.h
index d3734da..f4654ce 100644
--- a/libkdepim/ksyncmanager.h
+++ b/libkdepim/ksyncmanager.h
@@ -1,237 +1,241 @@
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#include <qprogressdialog.h> 32#include <qprogressdialog.h>
33#include <kdialog.h> 33#include <kdialog.h>
34 34
35class QPopupMenu; 35class QPopupMenu;
36class KSyncProfile; 36class KSyncProfile;
37class KPimPrefs; 37class KPimPrefs;
38class QWidget; 38class QWidget;
39class KSyncManager; 39class KSyncManager;
40class KSyncInterface; 40class KSyncInterface;
41class QProgressBar; 41class QProgressBar;
42 42
43 43
44class KServerSocket : public QServerSocket 44class KServerSocket : public QServerSocket
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 47
48 public: 48 public:
49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); 49 KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 );
50 50
51 void newConnection ( int socket ) ; 51 void newConnection ( int socket ) ;
52 void setFileName( QString fn ) {mFileName = fn;}; 52 void setFileName( QString fn ) {mFileName = fn;};
53 signals: 53 signals:
54 void file_received( bool ); 54 void file_received( bool );
55 void request_file(); 55 void request_file();
56 void saveFile(); 56 void saveFile();
57 void endConnect(); 57 void endConnect();
58 private slots: 58 private slots:
59 void discardClient(); 59 void discardClient();
60 void deleteSocket(); 60 void deleteSocket();
61 void readClient(); 61 void readClient();
62 void displayErrorMessage(); 62 void displayErrorMessage();
63 void readBackFileFromSocket(); 63 void readBackFileFromSocket();
64 private : 64 private :
65 int mErrorMessage; 65 int mErrorMessage;
66 bool blockRC; 66 bool blockRC;
67 void send_file(); 67 void send_file();
68 void get_file(); 68 void get_file();
69 void end_connect(); 69 void end_connect();
70 void error_connect( QString ); 70 void error_connect( QString );
71 QDialog* mSyncActionDialog; 71 QDialog* mSyncActionDialog;
72 QSocket* mSocket; 72 QSocket* mSocket;
73 QString mPassWord; 73 QString mPassWord;
74 QString mFileName; 74 QString mFileName;
75 QTime piTime; 75 QTime piTime;
76 QString piFileString; 76 QString piFileString;
77}; 77};
78 78
79class KCommandSocket : public QObject 79class KCommandSocket : public QObject
80{ 80{
81 Q_OBJECT 81 Q_OBJECT
82 public: 82 public:
83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet }; 83 enum state { successR, errorR, successW, errorW, errorTO, errorPW, errorCA, errorFI, errorUN, errorED,quiet };
84 KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 ); 84 KCommandSocket (QString remoteResource, QString password, Q_UINT16 port, QString host, QObject * parent=0, QWidget* cap = 0, const char * name=0 );
85 void readFile( QString ); 85 void readFile( QString );
86 void writeFile( QString ); 86 void writeFile( QString );
87 void sendStop(); 87 void sendStop();
88 88
89 private slots : 89 private slots :
90 void sendFileRequest(); 90 void sendFileRequest();
91 void updateConnectDialog(); 91 void updateConnectDialog();
92 92
93 signals: 93 signals:
94 void commandFinished( KCommandSocket*, int ); 94 void commandFinished( KCommandSocket*, int );
95 private slots: 95 private slots:
96 void startReadFileFromSocket(); 96 void startReadFileFromSocket();
97 void readFileFromSocket(); 97 void readFileFromSocket();
98 void deleteSocket(); 98 void deleteSocket();
99 void writeFileToSocket(); 99 void writeFileToSocket();
100 private : 100 private :
101 QString mRemoteResource;
101 int mConnectCount; 102 int mConnectCount;
102 int mConnectMax; 103 int mConnectMax;
103 KProgressDialog mConnectProgress; 104 KProgressDialog mConnectProgress;
104 QWidget* tlw; 105 QWidget* tlw;
105 QSocket* mSocket; 106 QSocket* mSocket;
106 QString mPassWord; 107 QString mPassWord;
107 Q_UINT16 mPort; 108 Q_UINT16 mPort;
108 QString mHost; 109 QString mHost;
109 QString mFileName; 110 QString mFileName;
110 QTimer* mTimerSocket; 111 QTimer* mTimerSocket;
111 int mRetVal; 112 int mRetVal;
112 QTime mTime; 113 QTime mTime;
113 QString mFileString; 114 QString mFileString;
114 bool mFirst; 115 bool mFirst;
115 bool mFirstLine; 116 bool mFirstLine;
116}; 117};
117 118
118 119
119class KSyncManager : public QObject 120class KSyncManager : public QObject
120{ 121{
121 Q_OBJECT 122 Q_OBJECT
122 123
123 public: 124 public:
124 enum TargetApp { 125 enum TargetApp {
125 KOPI = 0, 126 KOPI = 0,
126 KAPI = 1, 127 KAPI = 1,
127 PWMPI = 2 }; 128 PWMPI = 2 };
128 129
129 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu); 130 KSyncManager(QWidget* parent, KSyncInterface* implementation, TargetApp ta, KPimPrefs* prefs, QPopupMenu* syncmenu);
130 ~KSyncManager() ; 131 ~KSyncManager() ;
131 132
132 void multiSync( bool askforPrefs ); 133 void multiSync( bool askforPrefs );
133 bool blockSave() { return mBlockSaveFlag; } 134 bool blockSave() { return mBlockSaveFlag; }
134 void setBlockSave(bool sa) { mBlockSaveFlag = sa; } 135 void setBlockSave(bool sa) { mBlockSaveFlag = sa; }
135 void setDefaultFileName( QString s) ; 136 void setDefaultFileName( QString s) ;
136 QString defaultFileName() { return mDefFileName ;} 137 QString defaultFileName() { return mDefFileName ;}
137 QString syncFileName(); 138 QString syncFileName();
138 void enableQuick( bool ask = true); 139 void enableQuick( bool ask = true);
139 140
140 bool syncWithDesktop () { return mSyncWithDesktop;} 141 bool syncWithDesktop () { return mSyncWithDesktop;}
141 QString getCurrentSyncDevice() { return mCurrentSyncDevice; } 142 QString getCurrentSyncDevice() { return mCurrentSyncDevice; }
142 QString getCurrentSyncName() { return mCurrentSyncName; } 143 QString getCurrentSyncName() { return mCurrentSyncName; }
143 144
144 void showProgressBar(int percentage, QString caption = QString::null, int total=100); 145 void showProgressBar(int percentage, QString caption = QString::null, int total=100);
145 void hideProgressBar(); 146 void hideProgressBar();
146 bool isProgressBarCanceled(); 147 bool isProgressBarCanceled();
147 148
148 // sync stuff 149 // sync stuff
149 QString mLocalMachineName; 150 QString mLocalMachineName;
150 QStringList mExternSyncProfiles; 151 QStringList mExternSyncProfiles;
151 QStringList mSyncProfileNames; 152 QStringList mSyncProfileNames;
152 bool mAskForPreferences; 153 bool mAskForPreferences;
153 bool mShowSyncSummary; 154 bool mShowSyncSummary;
154 bool mIsKapiFile; 155 bool mIsKapiFile;
155 bool mWriteBackExistingOnly; 156 bool mWriteBackExistingOnly;
156 int mSyncAlgoPrefs; 157 int mSyncAlgoPrefs;
157 bool mWriteBackFile; 158 bool mWriteBackFile;
158 int mWriteBackInFuture; 159 int mWriteBackInFuture;
159 int mWriteBackInPast; 160 int mWriteBackInPast;
160 QString mPhoneDevice; 161 QString mPhoneDevice;
161 QString mPhoneConnection; 162 QString mPhoneConnection;
162 QString mPhoneModel; 163 QString mPhoneModel;
163 QString mPassWordPiSync; 164 QString mPassWordPiSync;
164 QString mActiveSyncPort; 165 QString mActiveSyncPort;
165 QString mActiveSyncIP ; 166 QString mActiveSyncIP ;
166 QString mFilterInCal; 167 QString mFilterInCal;
167 QString mFilterOutCal; 168 QString mFilterOutCal;
168 QString mFilterInAB; 169 QString mFilterInAB;
169 QString mFilterOutAB; 170 QString mFilterOutAB;
170 static QDateTime mRequestedSyncEvent; 171 static QDateTime mRequestedSyncEvent;
171 172
172 signals: 173 signals:
173 void save(); 174 void save();
174 void request_file(); 175 void request_file();
175 void getFile( bool ); 176 void getFile( bool );
176 177
177 public slots: 178 public slots:
178 void slotSyncMenu( int ); 179 void slotSyncMenu( int );
179 void slotClearMenu( int action ); 180 void slotClearMenu( int action );
180 void deleteCommandSocket(KCommandSocket*s, int state); 181 void deleteCommandSocket(KCommandSocket*s, int state);
181 void readFileFromSocket(); 182 void readFileFromSocket();
182 void fillSyncMenu(); 183 void fillSyncMenu();
183 184
184 private: 185 private:
185 void syncPi(); 186 void syncPi();
186 KServerSocket * mServerSocket; 187 KServerSocket * mServerSocket;
187 KPimPrefs* mPrefs; 188 KPimPrefs* mPrefs;
188 QString mDefFileName; 189 QString mDefFileName;
189 QString mCurrentSyncDevice; 190 QString mCurrentSyncDevice;
190 QString mCurrentSyncName; 191 QString mCurrentSyncName;
191 void quickSyncLocalFile(); 192 void quickSyncLocalFile();
192 bool syncWithFile( QString fn , bool quick ); 193 bool syncWithFile( QString fn , bool quick );
193 void syncLocalFile(); 194 void syncLocalFile();
194 void syncPhone(); 195 void syncPhone();
195 void syncSharp(); 196 void syncSharp();
196 void syncKDE(); 197 void syncKDE();
197 bool syncExternalApplication(QString); 198 bool syncExternalApplication(QString);
198 int mCurrentSyncProfile ; 199 int mCurrentSyncProfile ;
199 void syncRemote( KSyncProfile* prof, bool ask = true); 200 void syncRemote( KSyncProfile* prof, bool ask = true);
200 bool edit_sync_options(); 201 bool edit_sync_options();
201 bool edit_pisync_options(); 202 bool edit_pisync_options();
202 int ringSync(); 203 int ringSync();
203 QString getPassword( ); 204 QString getPassword( );
204 bool mPisyncFinished; 205 bool mPisyncFinished;
206 QStringList mSpecificResources;
207 QString mCurrentResourceLocal;
208 QString mCurrentResourceRemote;
205 bool mBlockSaveFlag; 209 bool mBlockSaveFlag;
206 QWidget* mParent; 210 QWidget* mParent;
207 KSyncInterface* mImplementation; 211 KSyncInterface* mImplementation;
208 TargetApp mTargetApp; 212 TargetApp mTargetApp;
209 QPopupMenu* mSyncMenu; 213 QPopupMenu* mSyncMenu;
210 QProgressBar* bar; 214 QProgressBar* bar;
211 bool mSyncWithDesktop; 215 bool mSyncWithDesktop;
212 216
213private slots: 217private slots:
214 void displayErrorPort(); 218 void displayErrorPort();
215 void confSync(); 219 void confSync();
216 220
217 221
218}; 222};
219 223
220 224
221class KSyncInterface 225class KSyncInterface
222{ 226{
223 public : 227 public :
224 virtual void removeSyncInfo( QString syncProfile) = 0; 228 virtual void removeSyncInfo( QString syncProfile) = 0;
225 virtual bool sync(KSyncManager* manager, QString filename, int mode) = 0; 229 virtual bool sync(KSyncManager* manager, QString filename, int mode, QString resource) = 0;
226 virtual bool syncExternal(KSyncManager* manager, QString resource) 230 virtual bool syncExternal(KSyncManager* manager, QString resource)
227 { 231 {
228 // empty implementation, because some syncable applications do not 232 // empty implementation, because some syncable applications do not
229 // have an external(sharpdtm) syncmode, like pwmanager. 233 // have an external(sharpdtm) syncmode, like pwmanager.
230 return false; 234 return false;
231 } 235 }
232 236
233 237
234}; 238};
235 239
236 240
237#endif 241#endif
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 292cde1..27f7932 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,903 +1,903 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46#include <qvgroupbox.h> 46#include <qvgroupbox.h>
47#include <qhgroupbox.h> 47#include <qhgroupbox.h>
48 48
49#include <kcolorbutton.h> 49#include <kcolorbutton.h>
50#include <kdebug.h> 50#include <kdebug.h>
51#include <klocale.h> 51#include <klocale.h>
52#include <kglobal.h> 52#include <kglobal.h>
53#include <kfontdialog.h> 53#include <kfontdialog.h>
54#include <kmessagebox.h> 54#include <kmessagebox.h>
55#include <kcolordialog.h> 55#include <kcolordialog.h>
56#include <kiconloader.h> 56#include <kiconloader.h>
57#include <kemailsettings.h> 57#include <kemailsettings.h>
58#include <kstandarddirs.h> 58#include <kstandarddirs.h>
59#include <kfiledialog.h> 59#include <kfiledialog.h>
60#include <kmessagebox.h> 60#include <kmessagebox.h>
61 61
62//#include <kurlrequester.h> 62//#include <kurlrequester.h>
63#include <klineedit.h> 63#include <klineedit.h>
64#include "ksyncprofile.h" 64#include "ksyncprofile.h"
65 65
66 66
67//#include "koprefs.h" 67//#include "koprefs.h"
68 68
69#include "ksyncprefsdialog.h" 69#include "ksyncprefsdialog.h"
70//#include "koglobals.h" 70//#include "koglobals.h"
71 71
72 72
73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 73KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
74 KDialog(parent,name,true) 74 KDialog(parent,name,true)
75{ 75{
76 76
77 setCaption( i18n("Synchronization Preferences")); 77 setCaption( i18n("Synchronization Preferences"));
78 78
79 mSyncProfiles.setAutoDelete( true ); 79 mSyncProfiles.setAutoDelete( true );
80 setupSyncAlgTab(); 80 setupSyncAlgTab();
81} 81}
82 82
83 83
84KSyncPrefsDialog::~KSyncPrefsDialog() 84KSyncPrefsDialog::~KSyncPrefsDialog()
85{ 85{
86} 86}
87 87
88void KSyncPrefsDialog::setupSyncAlgTab() 88void KSyncPrefsDialog::setupSyncAlgTab()
89{ 89{
90 QLabel * lab; 90 QLabel * lab;
91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 91 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
92 QVBox * mainbox = new QVBox( this ); 92 QVBox * mainbox = new QVBox( this );
93 QScrollView* sv = new QScrollView( mainbox ); 93 QScrollView* sv = new QScrollView( mainbox );
94 QHBoxLayout * lay = new QHBoxLayout( this ); 94 QHBoxLayout * lay = new QHBoxLayout( this );
95 lay->addWidget( mainbox ); 95 lay->addWidget( mainbox );
96 QHBox * b_box = new QHBox( mainbox ); 96 QHBox * b_box = new QHBox( mainbox );
97 97
98 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 98 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
100 button = new QPushButton( i18n("Cancel"), b_box ); 100 button = new QPushButton( i18n("Cancel"), b_box );
101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 101 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
102 //QBoxLayout * sl = new QVBoxLayout(this ); 102 //QBoxLayout * sl = new QVBoxLayout(this );
103 //sl->addWidget ( sv ); 103 //sl->addWidget ( sv );
104 sv->setResizePolicy ( QScrollView::AutoOneFit ); 104 sv->setResizePolicy ( QScrollView::AutoOneFit );
105 QFrame *topFrame = new QFrame ( sv ); 105 QFrame *topFrame = new QFrame ( sv );
106 sv->addChild( topFrame ); 106 sv->addChild( topFrame );
107 mSetupSyncAlgTab = topFrame; 107 mSetupSyncAlgTab = topFrame;
108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 108 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
109 topLayout->setSpacing(spacingHint()); 109 topLayout->setSpacing(spacingHint());
110 topLayout->setMargin(marginHint()); 110 topLayout->setMargin(marginHint());
111 111
112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 112 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
113 int iii = 0; 113 int iii = 0;
114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 114 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
115 //++iii; 115 //++iii;
116 116
117 mMyMachineName = new QLineEdit(topFrame); 117 mMyMachineName = new QLineEdit(topFrame);
118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 118 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
119 topLayout->addWidget(lab ,iii,0); 119 topLayout->addWidget(lab ,iii,0);
120 topLayout->addWidget(mMyMachineName,iii,1); 120 topLayout->addWidget(mMyMachineName,iii,1);
121 ++iii; 121 ++iii;
122 122
123 QHBox* buttonbox = new QHBox( topFrame); 123 QHBox* buttonbox = new QHBox( topFrame);
124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 124 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
125 ++iii; 125 ++iii;
126 button = new QPushButton( i18n("New profile"), buttonbox ); 126 button = new QPushButton( i18n("New profile"), buttonbox );
127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 127 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
128 128
129 button = new QPushButton( i18n("Clone profile"), buttonbox ); 129 button = new QPushButton( i18n("Clone profile"), buttonbox );
130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 130 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
131 131
132 button = new QPushButton( i18n("Delete profile"), buttonbox ); 132 button = new QPushButton( i18n("Delete profile"), buttonbox );
133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 133 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
134 134
135 mProfileBox = new QComboBox(topFrame); 135 mProfileBox = new QComboBox(topFrame);
136 mProfileBox->setEditable ( true ); 136 mProfileBox->setEditable ( true );
137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion); 137 mProfileBox->setInsertionPolicy(QComboBox::NoInsertion);
138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 138 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 139 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
140 140
141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 141 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
142 topLayout->addWidget(lab ,iii,0); 142 topLayout->addWidget(lab ,iii,0);
143 topLayout->addWidget(mProfileBox, iii,1); 143 topLayout->addWidget(mProfileBox, iii,1);
144 ++iii; 144 ++iii;
145 145
146 146
147 147
148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame); 148 QHGroupBox *iims = new QHGroupBox( i18n("Multiple Sync options"), topFrame);
149 new QLabel( i18n("Include in multiple "), iims ); 149 new QLabel( i18n("Include in multiple "), iims );
150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims ); 150 mIncludeInRing = new QCheckBox( i18n("calendar "), iims );
151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims ); 151 mIncludeInRingAB = new QCheckBox( i18n("addressbook "), iims );
152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims ); 152 mIncludeInRingPWM = new QCheckBox( i18n("pwmanager"), iims );
153 new QLabel( i18n(" sync"), iims ); 153 new QLabel( i18n(" sync"), iims );
154 topLayout->addMultiCellWidget(iims, iii,iii,0,1); 154 topLayout->addMultiCellWidget(iims, iii,iii,0,1);
155 ++iii; 155 ++iii;
156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame); 156 QVGroupBox* gb0 = new QVGroupBox( i18n("Sync algo options"), topFrame);
157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1); 157 topLayout->addMultiCellWidget(gb0, iii,iii,0,1);
158 ++iii; 158 ++iii;
159 QButtonGroup* gr; 159 QButtonGroup* gr;
160 { 160 {
161 QVGroupBox* topFrame = gb0; 161 QVGroupBox* topFrame = gb0;
162 162
163 163
164 164
165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 165 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 166 //topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
167 //++iii; 167 //++iii;
168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 168 gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1); 169 //topLayout->addMultiCellWidget(gr, iii,iii,0,1);
170 //++iii; 170 //++iii;
171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 171 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 172 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 173 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 174 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 175 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 176 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
177 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 177 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
178 178
179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 179 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 180 //topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
181 //++iii; 181 //++iii;
182 182
183#if 0 183#if 0
184 QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame); 184 QHGroupBox* gb51 = new QHGroupBox( i18n("Local resources to sync with:"), topFrame);
185 { 185 {
186 QVBox * fibo2 = new QVBox ( gb51 ); 186 QVBox * fibo2 = new QVBox ( gb51 );
187 new QLabel ( i18n("Calendar resources:"), fibo2 ); 187 new QLabel ( i18n("Calendar resources:"), fibo2 );
188 //mFilterInCal = new QComboBox( fibo2 ); 188 //mFilterInCal = new QComboBox( fibo2 );
189 fibo2 = new QVBox ( gb51 ); 189 fibo2 = new QVBox ( gb51 );
190 new QLabel ( i18n("Addressbook resources:"), fibo2 ); 190 new QLabel ( i18n("Addressbook resources:"), fibo2 );
191 //mFilterInAB = new QComboBox( fibo2 ); 191 //mFilterInAB = new QComboBox( fibo2 );
192 } 192 }
193#endif 193#endif
194 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame); 194 QHGroupBox* gb5 = new QHGroupBox( i18n("Apply filter when adding data to local:"), topFrame);
195 QVBox * fibo2 = new QVBox ( gb5 ); 195 QVBox * fibo2 = new QVBox ( gb5 );
196 new QLabel ( i18n("Incoming calendar filter:"), fibo2 ); 196 new QLabel ( i18n("Incoming calendar filter:"), fibo2 );
197 mFilterInCal = new QComboBox( fibo2 ); 197 mFilterInCal = new QComboBox( fibo2 );
198 fibo2 = new QVBox ( gb5 ); 198 fibo2 = new QVBox ( gb5 );
199 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 ); 199 new QLabel ( i18n("Incoming addressbook filter:"), fibo2 );
200 mFilterInAB = new QComboBox( fibo2 ); 200 mFilterInAB = new QComboBox( fibo2 );
201 201
202 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame ); 202 mWriteBackFile = new QCheckBox( i18n("Write back synced data"), topFrame );
203 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 203 // topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
204 // ++iii; 204 // ++iii;
205 205
206 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame); 206 QVGroupBox* gb2 = new QVGroupBox( i18n("Write back options"), topFrame);
207 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1); 207 //topLayout->addMultiCellWidget(gb2, iii,iii,0,1);
208 //++iii; 208 //++iii;
209 { 209 {
210 QVGroupBox*topFrame = gb2; 210 QVGroupBox*topFrame = gb2;
211 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame ); 211 mWriteBackExisting= new QCheckBox( i18n("Write back (on remote) existing entries only"), topFrame );
212 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame); 212 QHGroupBox* gb4 = new QHGroupBox( i18n("Apply filter when adding data to remote:"), topFrame);
213 QVBox * fibo = new QVBox ( gb4 ); 213 QVBox * fibo = new QVBox ( gb4 );
214 new QLabel ( i18n("Outgoing calendar filter:"), fibo ); 214 new QLabel ( i18n("Outgoing calendar filter:"), fibo );
215 mFilterOutCal = new QComboBox( fibo ); 215 mFilterOutCal = new QComboBox( fibo );
216 fibo = new QVBox ( gb4 ); 216 fibo = new QVBox ( gb4 );
217 new QLabel ( i18n("Outgoing addressbook filter:"), fibo ); 217 new QLabel ( i18n("Outgoing addressbook filter:"), fibo );
218 mFilterOutAB = new QComboBox( fibo ); 218 mFilterOutAB = new QComboBox( fibo );
219 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 219 //topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
220 //++iii; 220 //++iii;
221 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame ); 221 mWriteBackFuture= new QCheckBox( i18n("Write back (calendar) entries for time period only"), topFrame );
222 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1); 222 //topLayout->addMultiCellWidget(mWriteBackFuture, iii,iii,0,1);
223 //++iii; 223 //++iii;
224 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame); 224 QHGroupBox* gb3 = new QHGroupBox( i18n("Time period"), topFrame);
225 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) ); 225 connect ( mWriteBackFuture, SIGNAL( toggled ( bool ) ), gb3, SLOT ( setEnabled ( bool ) ) );
226 new QLabel( i18n("From ") , gb3 ); 226 new QLabel( i18n("From ") , gb3 );
227 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3); 227 mWriteBackPastWeeks= new QSpinBox(1,104, 1, gb3);
228 new QLabel( i18n(" weeks in the past to ") , gb3 ); 228 new QLabel( i18n(" weeks in the past to ") , gb3 );
229 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3); 229 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, gb3);
230 new QLabel( i18n(" weeks in the future ") , gb3 ); 230 new QLabel( i18n(" weeks in the future ") , gb3 );
231 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1); 231 //topLayout->addMultiCellWidget(mWriteBackFutureWeeks, iii,iii,1,1);
232 //++iii; 232 //++iii;
233 gb3->setEnabled( false ); 233 gb3->setEnabled( false );
234 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) ); 234 connect ( mWriteBackExisting, SIGNAL( toggled ( bool ) ), gb4, SLOT ( setDisabled ( bool ) ) );
235 } 235 }
236 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) ); 236 connect ( mWriteBackFile, SIGNAL( toggled ( bool ) ), gb2, SLOT ( setEnabled ( bool ) ) );
237 237
238 } 238 }
239 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 239 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
240 gr = proGr; 240 gr = proGr;
241 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 241 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
242 ++iii; 242 ++iii;
243 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 243 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
244 mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); 244 mIsPi = new QRadioButton ( i18n("Pi-Sync - all resources ( direct Kx/Pi to Kx/Pi sync )"), gr );
245 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 245 connect (mIsPi, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
246 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr ); 246 mIsPiSpecific = new QRadioButton ( i18n("Pi-Sync - selected resources ( direct Kx/Pi to Kx/Pi sync )"), gr );
247 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 247 connect (mIsPiSpecific, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
248 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 248 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
249 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 249 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
250 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr ); 250 mIsPhone = new QRadioButton ( i18n("Mobile device (cell phone)"), gr );
251 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 251 connect (mIsPhone, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
252 252
253 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame); 253 QVGroupBox* gb1 = new QVGroupBox( i18n("Profile kind specific settings"), topFrame);
254 topLayout->addMultiCellWidget(gb1, iii,iii,0,1); 254 topLayout->addMultiCellWidget(gb1, iii,iii,0,1);
255 ++iii; 255 ++iii;
256 256
257 // ****************************************** 257 // ******************************************
258 // Profile kind specific settings 258 // Profile kind specific settings
259 { 259 {
260 // *** phone ******************************* 260 // *** phone *******************************
261 QVGroupBox* topFrame = gb1; 261 QVGroupBox* topFrame = gb1;
262 phoneWidget = new QVBox( topFrame); 262 phoneWidget = new QVBox( topFrame);
263 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1); 263 //topLayout->addMultiCellWidget(phoneWidget, iii,iii,0,1);
264 //++iii; 264 //++iii;
265 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget ); 265 mWriteContactToSIM = 0;//new QCheckBox( i18n("Sync contacts with phone SIM card (If not, sync with phone memory)"), phoneWidget );
266 QHBox* temphb = new QHBox( phoneWidget ); 266 QHBox* temphb = new QHBox( phoneWidget );
267 new QLabel( i18n("I/O device: "), temphb ); 267 new QLabel( i18n("I/O device: "), temphb );
268 mPhoneDevice = new QLineEdit( temphb); 268 mPhoneDevice = new QLineEdit( temphb);
269 button = new QPushButton( i18n("Help..."), temphb ); 269 button = new QPushButton( i18n("Help..."), temphb );
270 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) ); 270 connect ( button, SIGNAL( clicked()), this, SLOT ( helpDevice() ) );
271 271
272 272
273 temphb = new QHBox( phoneWidget ); 273 temphb = new QHBox( phoneWidget );
274 new QLabel( i18n("Connection: "), temphb ); 274 new QLabel( i18n("Connection: "), temphb );
275 mPhoneConnection = new QLineEdit( temphb); 275 mPhoneConnection = new QLineEdit( temphb);
276 button = new QPushButton( i18n("Help..."), temphb ); 276 button = new QPushButton( i18n("Help..."), temphb );
277 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) ); 277 connect ( button, SIGNAL( clicked()), this, SLOT ( helpConnection() ) );
278 278
279 279
280 temphb = new QHBox( phoneWidget ); 280 temphb = new QHBox( phoneWidget );
281 new QLabel( i18n("Model(opt.): "), temphb ); 281 new QLabel( i18n("Model(opt.): "), temphb );
282 mPhoneModel = new QLineEdit( temphb); 282 mPhoneModel = new QLineEdit( temphb);
283 button = new QPushButton( i18n("Help..."), temphb ); 283 button = new QPushButton( i18n("Help..."), temphb );
284 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) ); 284 connect ( button, SIGNAL( clicked()), this, SLOT ( helpModel() ) );
285 285
286 // *** local******************************* 286 // *** local*******************************
287 localFileWidget = new QVBox( topFrame); 287 localFileWidget = new QVBox( topFrame);
288 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 288 //topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
289 //++iii; 289 //++iii;
290 temphb = new QHBox( localFileWidget ); 290 temphb = new QHBox( localFileWidget );
291 291
292 lab = new QLabel( i18n("Local file Cal:"), temphb ); 292 lab = new QLabel( i18n("Local file Cal:"), temphb );
293 lab = new QLabel( i18n("Local file ABook:"), temphb ); 293 lab = new QLabel( i18n("Local file ABook:"), temphb );
294 lab = new QLabel( i18n("Local file PWMgr:"), temphb ); 294 lab = new QLabel( i18n("Local file PWMgr:"), temphb );
295 temphb = new QHBox( localFileWidget ); 295 temphb = new QHBox( localFileWidget );
296 button = new QPushButton( i18n("Choose..."), temphb ); 296 button = new QPushButton( i18n("Choose..."), temphb );
297 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 297 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
298 button = new QPushButton( i18n("Choose..."), temphb ); 298 button = new QPushButton( i18n("Choose..."), temphb );
299 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) ); 299 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFileAB() ) );
300 button = new QPushButton( i18n("Choose..."), temphb ); 300 button = new QPushButton( i18n("Choose..."), temphb );
301 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) ); 301 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFilePWM() ) );
302 temphb = new QHBox( localFileWidget ); 302 temphb = new QHBox( localFileWidget );
303 303
304 mRemoteFile = new QLineEdit( temphb); 304 mRemoteFile = new QLineEdit( temphb);
305 mRemoteFileAB = new QLineEdit( temphb); 305 mRemoteFileAB = new QLineEdit( temphb);
306 mRemoteFilePWM = new QLineEdit( temphb); 306 mRemoteFilePWM = new QLineEdit( temphb);
307 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget ); 307 mIsKapiFileL = new QCheckBox( i18n("Addressbook file (*.vcf) is used by KA/Pi"), localFileWidget );
308 308
309 309
310 // *** remote******************************* 310 // *** remote*******************************
311 remoteFileWidget = new QVBox( topFrame); 311 remoteFileWidget = new QVBox( topFrame);
312 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 312 //topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
313 //++iii; 313 //++iii;
314 temphb = new QHBox( remoteFileWidget ); 314 temphb = new QHBox( remoteFileWidget );
315 new QLabel( i18n("Calendar:"), temphb); 315 new QLabel( i18n("Calendar:"), temphb);
316 new QLabel( i18n("AddressBook:"), temphb); 316 new QLabel( i18n("AddressBook:"), temphb);
317 new QLabel( i18n("PWManager:"), temphb); 317 new QLabel( i18n("PWManager:"), temphb);
318 318
319 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 319 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
320 temphb = new QHBox( remoteFileWidget ); 320 temphb = new QHBox( remoteFileWidget );
321 mRemotePrecommand = new QLineEdit(temphb); 321 mRemotePrecommand = new QLineEdit(temphb);
322 mRemotePrecommandAB = new QLineEdit(temphb); 322 mRemotePrecommandAB = new QLineEdit(temphb);
323 mRemotePrecommandPWM = new QLineEdit(temphb); 323 mRemotePrecommandPWM = new QLineEdit(temphb);
324 324
325 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 325 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
326 temphb = new QHBox( remoteFileWidget ); 326 temphb = new QHBox( remoteFileWidget );
327 mLocalTempFile = new QLineEdit(temphb); 327 mLocalTempFile = new QLineEdit(temphb);
328 mLocalTempFileAB = new QLineEdit(temphb); 328 mLocalTempFileAB = new QLineEdit(temphb);
329 mLocalTempFilePWM = new QLineEdit(temphb); 329 mLocalTempFilePWM = new QLineEdit(temphb);
330 330
331 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 331 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
332 temphb = new QHBox( remoteFileWidget ); 332 temphb = new QHBox( remoteFileWidget );
333 mRemotePostcommand = new QLineEdit(temphb ); 333 mRemotePostcommand = new QLineEdit(temphb );
334 mRemotePostcommandAB = new QLineEdit(temphb ); 334 mRemotePostcommandAB = new QLineEdit(temphb );
335 mRemotePostcommandPWM = new QLineEdit(temphb ); 335 mRemotePostcommandPWM = new QLineEdit(temphb );
336 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget ); 336 mIsKapiFileR = new QCheckBox( i18n("Addressbook file is used by KA/Pi"), remoteFileWidget );
337 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 337 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
338 temphb = new QHBox( remoteFileWidget ); 338 temphb = new QHBox( remoteFileWidget );
339 button = new QPushButton( i18n("ssh/scp"), temphb ); 339 button = new QPushButton( i18n("ssh/scp"), temphb );
340 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 340 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
341 button = new QPushButton( i18n("ftp"), temphb ); 341 button = new QPushButton( i18n("ftp"), temphb );
342 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 342 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
343 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 343 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
344 344
345 // *** pi-sync******************************* 345 // *** pi-sync*******************************
346 piWidget = new QVBox( topFrame); 346 piWidget = new QVBox( topFrame);
347 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1); 347 //topLayout->addMultiCellWidget(piWidget, iii,iii,0,1);
348 //++iii; 348 //++iii;
349 temphb = new QHBox( piWidget ); 349 temphb = new QHBox( piWidget );
350 new QLabel( i18n("Calendar:"), temphb); 350 new QLabel( i18n("Calendar:"), temphb);
351 new QLabel( i18n("AddressBook:"), temphb); 351 new QLabel( i18n("AddressBook:"), temphb);
352 new QLabel( i18n("PWManager:"), temphb); 352 new QLabel( i18n("PWManager:"), temphb);
353 353
354 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget); 354 lab = new QLabel( i18n("Password for remote access: (could be the same for each)"), piWidget);
355 temphb = new QHBox( piWidget ); 355 temphb = new QHBox( piWidget );
356 mRemotePw = new QLineEdit(temphb); 356 mRemotePw = new QLineEdit(temphb);
357 mRemotePwAB = new QLineEdit(temphb); 357 mRemotePwAB = new QLineEdit(temphb);
358 mRemotePwPWM = new QLineEdit(temphb); 358 mRemotePwPWM = new QLineEdit(temphb);
359 359
360 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget); 360 lab = new QLabel( i18n("Remote IP address: (could be the same for each)"), piWidget);
361 temphb = new QHBox( piWidget ); 361 temphb = new QHBox( piWidget );
362 mRemoteIP = new QLineEdit(temphb); 362 mRemoteIP = new QLineEdit(temphb);
363 mRemoteIPAB = new QLineEdit(temphb); 363 mRemoteIPAB = new QLineEdit(temphb);
364 mRemoteIPPWM = new QLineEdit(temphb); 364 mRemoteIPPWM = new QLineEdit(temphb);
365 365
366 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget); 366 lab = new QLabel( i18n("Remote port number: (should be different for each)"), piWidget);
367 temphb = new QHBox( piWidget ); 367 temphb = new QHBox( piWidget );
368 mRemotePort = new QLineEdit(temphb); 368 mRemotePort = new QLineEdit(temphb);
369 mRemotePortAB = new QLineEdit(temphb); 369 mRemotePortAB = new QLineEdit(temphb);
370 mRemotePortPWM = new QLineEdit(temphb); 370 mRemotePortPWM = new QLineEdit(temphb);
371 371
372 lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget); 372 lab = new QLabel( i18n("Local/remote Resource sync partners"), piWidget);
373 mTableBox = new QHBox( piWidget ); 373 mTableBox = new QHBox( piWidget );
374 mResTableKopi = new QTable( 1, 1, mTableBox ); 374 mResTableKopi = new QTable( 1, 1, mTableBox );
375 mResTableKapi = new QTable( 1, 1, mTableBox ); 375 mResTableKapi = new QTable( 1, 1, mTableBox );
376 mResTablePwmpi = new QTable( 1, 1, mTableBox ); 376 mResTablePwmpi = new QTable( 1, 1, mTableBox );
377 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 377 mResTableKopi->horizontalHeader()->setLabel( 0, i18n("Remote") );
378 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 378 mResTableKapi->horizontalHeader()->setLabel( 0, i18n("Remote") );
379 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") ); 379 mResTablePwmpi->horizontalHeader()->setLabel( 0, i18n("Remote") );
380 mResTableKopi->setLeftMargin( 80 ); 380 mResTableKopi->setLeftMargin( 80 );
381 } 381 }
382 // ****************************************** 382 // ******************************************
383 // Profile kind specific settings END 383 // Profile kind specific settings END
384 384
385} 385}
386 386
387void KSyncPrefsDialog::readResources() 387void KSyncPrefsDialog::readResources()
388{ 388{
389 mResourcesKopi.clear(); 389 mResourcesKopi.clear();
390 mResourcesKapi.clear(); 390 mResourcesKapi.clear();
391 KConfig fc(locateLocal("config","kopicalendarrc")); 391 KConfig fc(locateLocal("config","kopicalendarrc"));
392 fc.setGroup("CC"); 392 fc.setGroup("CC");
393 int numCals = fc.readNumEntry("NumberCalendars",0 ); 393 int numCals = fc.readNumEntry("NumberCalendars",0 );
394 int curCal = 1; 394 int curCal = 1;
395 while ( curCal <= numCals ) { 395 while ( curCal <= numCals ) {
396 QString prefix = "Cal_" +QString::number( curCal ); 396 QString prefix = "Cal_" +QString::number( curCal );
397 QString name = fc.readEntry( prefix+"_Name", "Calendar"); 397 QString name = fc.readEntry( prefix+"_Name", "Calendar");
398 mResourcesKopi.append( name ); 398 mResourcesKopi.append( name );
399 ++curCal; 399 ++curCal;
400 } 400 }
401 mResTableKopi->setNumRows( mResourcesKopi.count() ); 401 mResTableKopi->setNumRows( mResourcesKopi.count() );
402 int i; 402 int i;
403 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 403 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] ); 404 mResTableKopi->verticalHeader ()->setLabel( i, mResourcesKopi[i] );
405 } 405 }
406} 406}
407void KSyncPrefsDialog::readFilter() 407void KSyncPrefsDialog::readFilter()
408{ 408{
409 mFilterKapi.clear(); 409 mFilterKapi.clear();
410 mFilterKopi.clear(); 410 mFilterKopi.clear();
411 KConfig cfgko(locateLocal("config","korganizerrc")); 411 KConfig cfgko(locateLocal("config","korganizerrc"));
412 KConfig cfgka(locateLocal("config","kaddressbookrc")); 412 KConfig cfgka(locateLocal("config","kaddressbookrc"));
413 cfgko.setGroup("General"); 413 cfgko.setGroup("General");
414 mFilterKopi = cfgko.readListEntry("CalendarFilters"); 414 mFilterKopi = cfgko.readListEntry("CalendarFilters");
415 cfgka.setGroup("Filter"); 415 cfgka.setGroup("Filter");
416 int count = cfgka.readNumEntry( "Count", 0 ); 416 int count = cfgka.readNumEntry( "Count", 0 );
417 for ( int i = 0; i < count; i++ ) { 417 for ( int i = 0; i < count; i++ ) {
418 cfgka.setGroup("Filter_"+QString::number( i ) ); 418 cfgka.setGroup("Filter_"+QString::number( i ) );
419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") ); 419 mFilterKapi.append( cfgka.readEntry("Name", "internal error") );
420 } 420 }
421 mFilterOutCal->clear(); 421 mFilterOutCal->clear();
422 mFilterInCal->clear(); 422 mFilterInCal->clear();
423 mFilterOutAB->clear(); 423 mFilterOutAB->clear();
424 mFilterInAB->clear(); 424 mFilterInAB->clear();
425 QStringList temp = mFilterKopi; 425 QStringList temp = mFilterKopi;
426 temp.prepend(i18n("No Filter") ); 426 temp.prepend(i18n("No Filter") );
427 mFilterOutCal->insertStringList( temp ); 427 mFilterOutCal->insertStringList( temp );
428 mFilterInCal->insertStringList( temp ); 428 mFilterInCal->insertStringList( temp );
429 temp = mFilterKapi; 429 temp = mFilterKapi;
430 temp.prepend(i18n("No Filter") ); 430 temp.prepend(i18n("No Filter") );
431 mFilterOutAB->insertStringList( temp ); 431 mFilterOutAB->insertStringList( temp );
432 mFilterInAB->insertStringList( temp ); 432 mFilterInAB->insertStringList( temp );
433} 433}
434 434
435void KSyncPrefsDialog::slotOK() 435void KSyncPrefsDialog::slotOK()
436{ 436{
437 if ( mMyMachineName->text() == "undefined" ) { 437 if ( mMyMachineName->text() == "undefined" ) {
438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 438 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
439 return; 439 return;
440 } 440 }
441 int i; 441 int i;
442 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 442 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 443 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 444 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
445 return; 445 return;
446 } 446 }
447 } 447 }
448 usrWriteConfig(); 448 usrWriteConfig();
449 QDialog::accept(); 449 QDialog::accept();
450} 450}
451void KSyncPrefsDialog::accept() 451void KSyncPrefsDialog::accept()
452{ 452{
453 slotOK(); 453 slotOK();
454} 454}
455void KSyncPrefsDialog::chooseFile() 455void KSyncPrefsDialog::chooseFile()
456{ 456{
457 QString fn = QDir::homeDirPath(); 457 QString fn = QDir::homeDirPath();
458 458
459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 459 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
460 if ( fn == "" ) 460 if ( fn == "" )
461 return; 461 return;
462 mRemoteFile->setText( fn ); 462 mRemoteFile->setText( fn );
463} 463}
464 464
465void KSyncPrefsDialog::chooseFileAB() 465void KSyncPrefsDialog::chooseFileAB()
466{ 466{
467 QString fn = QDir::homeDirPath(); 467 QString fn = QDir::homeDirPath();
468 468
469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this ); 469 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.vcf)"), this );
470 if ( fn == "" ) 470 if ( fn == "" )
471 return; 471 return;
472 mRemoteFileAB->setText( fn ); 472 mRemoteFileAB->setText( fn );
473} 473}
474 474
475void KSyncPrefsDialog::chooseFilePWM() 475void KSyncPrefsDialog::chooseFilePWM()
476{ 476{
477 QString fn = QDir::homeDirPath(); 477 QString fn = QDir::homeDirPath();
478 478
479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this ); 479 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.pwm)"), this );
480 if ( fn == "" ) 480 if ( fn == "" )
481 return; 481 return;
482 mRemoteFilePWM->setText( fn ); 482 mRemoteFilePWM->setText( fn );
483} 483}
484 484
485void KSyncPrefsDialog::textChanged( const QString & s ) 485void KSyncPrefsDialog::textChanged( const QString & s )
486{ 486{
487 if ( mProfileBox->count() == 0 ) 487 if ( mProfileBox->count() == 0 )
488 return; 488 return;
489 if ( currentSelection < 3 ) { 489 if ( currentSelection < 3 ) {
490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 490 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
491 mProfileBox->blockSignals( true ); 491 mProfileBox->blockSignals( true );
492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 492 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
493 mProfileBox->blockSignals( false ); 493 mProfileBox->blockSignals( false );
494 return; 494 return;
495 } 495 }
496 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 496 //qDebug("cur i %d ",mProfileBox-> currentItem () );
497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 497 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 498 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
499 prof->setName( s ); 499 prof->setName( s );
500 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 500 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
501} 501}
502void KSyncPrefsDialog::profileChanged( int item ) 502void KSyncPrefsDialog::profileChanged( int item )
503{ 503{
504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() ); 504 //qDebug("KSyncPrefsDialog::profileChanged before %d, count %d ", item, mProfileBox->count() );
505 KSyncProfile* prof; 505 KSyncProfile* prof;
506 saveProfile(); 506 saveProfile();
507 readFilter(); 507 readFilter();
508 readResources(); 508 readResources();
509 currentSelection = item; 509 currentSelection = item;
510 prof = mSyncProfiles.at(item) ; 510 prof = mSyncProfiles.at(item) ;
511 511
512 mRemotePw->setText(prof->getRemotePw()); 512 mRemotePw->setText(prof->getRemotePw());
513 mRemoteIP->setText(prof->getRemoteIP()); 513 mRemoteIP->setText(prof->getRemoteIP());
514 mRemotePort->setText(prof->getRemotePort()); 514 mRemotePort->setText(prof->getRemotePort());
515 515
516 mRemotePwAB->setText(prof->getRemotePwAB()); 516 mRemotePwAB->setText(prof->getRemotePwAB());
517 mRemoteIPAB->setText(prof->getRemoteIPAB()); 517 mRemoteIPAB->setText(prof->getRemoteIPAB());
518 mRemotePortAB->setText(prof->getRemotePortAB()); 518 mRemotePortAB->setText(prof->getRemotePortAB());
519 519
520 mRemotePwPWM->setText(prof->getRemotePwPWM()); 520 mRemotePwPWM->setText(prof->getRemotePwPWM());
521 mRemoteIPPWM->setText(prof->getRemoteIPPWM()); 521 mRemoteIPPWM->setText(prof->getRemoteIPPWM());
522 mRemotePortPWM->setText(prof->getRemotePortPWM()); 522 mRemotePortPWM->setText(prof->getRemotePortPWM());
523 523
524 mRemotePrecommand->setText(prof->getPreSyncCommand()); 524 mRemotePrecommand->setText(prof->getPreSyncCommand());
525 mRemotePostcommand->setText(prof->getPostSyncCommand()); 525 mRemotePostcommand->setText(prof->getPostSyncCommand());
526 mLocalTempFile->setText(prof->getLocalTempFile()); 526 mLocalTempFile->setText(prof->getLocalTempFile());
527 mRemoteFile->setText(prof->getRemoteFileName()) ; 527 mRemoteFile->setText(prof->getRemoteFileName()) ;
528 528
529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB()); 529 mRemotePrecommandAB->setText(prof->getPreSyncCommandAB());
530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB()); 530 mRemotePostcommandAB->setText(prof->getPostSyncCommandAB());
531 mLocalTempFileAB->setText(prof->getLocalTempFileAB()); 531 mLocalTempFileAB->setText(prof->getLocalTempFileAB());
532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ; 532 mRemoteFileAB->setText(prof->getRemoteFileNameAB()) ;
533 533
534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM()); 534 mRemotePrecommandPWM->setText(prof->getPreSyncCommandPWM());
535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM()); 535 mRemotePostcommandPWM->setText(prof->getPostSyncCommandPWM());
536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM()); 536 mLocalTempFilePWM->setText(prof->getLocalTempFilePWM());
537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ; 537 mRemoteFilePWM->setText(prof->getRemoteFileNamePWM()) ;
538 538
539 if ( mWriteContactToSIM ) 539 if ( mWriteContactToSIM )
540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM()); 540 mWriteContactToSIM->setChecked( prof->getWriteContactToSIM());
541 mPhoneDevice->setText(prof->getPhoneDevice()); 541 mPhoneDevice->setText(prof->getPhoneDevice());
542 mPhoneConnection->setText(prof->getPhoneConnection()); 542 mPhoneConnection->setText(prof->getPhoneConnection());
543 mPhoneModel->setText(prof->getPhoneModel()); 543 mPhoneModel->setText(prof->getPhoneModel());
544 544
545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 545 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
546 mAskForPreferences->setChecked( prof->getAskForPreferences()); 546 mAskForPreferences->setChecked( prof->getAskForPreferences());
547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 547 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
548 mWriteBackFile->setChecked( prof->getWriteBackFile()); 548 mWriteBackFile->setChecked( prof->getWriteBackFile());
549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 549 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() ); 550 mIncludeInRingAB->setChecked( prof->getIncludeInRingSyncAB() );
551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() ); 551 mIncludeInRingPWM->setChecked( prof->getIncludeInRingSyncPWM() );
552 mWriteBackFuture->setChecked( prof->getWriteBackFuture()); 552 mWriteBackFuture->setChecked( prof->getWriteBackFuture());
553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() ); 553 mWriteBackFutureWeeks->setValue( prof->getWriteBackFutureWeeks() );
554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() ); 554 mWriteBackPastWeeks->setValue( prof->getWriteBackPastWeeks() );
555 555
556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 ); 556 mFilterInCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterInCal () ) + 1 );
557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 ); 557 mFilterOutCal->setCurrentItem( mFilterKopi.findIndex(prof->getFilterOutCal () ) + 1 );
558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 ); 558 mFilterInAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterInAB () ) + 1 );
559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 ); 559 mFilterOutAB->setCurrentItem( mFilterKapi.findIndex(prof->getFilterOutAB () ) + 1 );
560 560
561 switch ( prof->getSyncPrefs() ) { 561 switch ( prof->getSyncPrefs() ) {
562 case 0: 562 case 0:
563 loc->setChecked( true); 563 loc->setChecked( true);
564 break; 564 break;
565 case 1: 565 case 1:
566 rem->setChecked( true ); 566 rem->setChecked( true );
567 break; 567 break;
568 case 2: 568 case 2:
569 newest->setChecked( true); 569 newest->setChecked( true);
570 break; 570 break;
571 case 3: 571 case 3:
572 ask->setChecked( true); 572 ask->setChecked( true);
573 break; 573 break;
574 case 4: 574 case 4:
575 f_loc->setChecked( true); 575 f_loc->setChecked( true);
576 break; 576 break;
577 case 5: 577 case 5:
578 f_rem->setChecked( true); 578 f_rem->setChecked( true);
579 break; 579 break;
580 case 6: 580 case 6:
581 //both->setChecked( true); 581 //both->setChecked( true);
582 break; 582 break;
583 default: 583 default:
584 break; 584 break;
585 } 585 }
586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 586 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
587 mIsPhone->setChecked(prof->getIsPhoneSync()) ; 587 mIsPhone->setChecked(prof->getIsPhoneSync()) ;
588 mIsPi->setChecked(prof->getIsPiSync()) ; 588 mIsPi->setChecked(prof->getIsPiSync()) ;
589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ; 589 mIsPiSpecific->setChecked(prof->getIsPiSyncSpec()) ;
590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ; 590 mIsKapiFileL->setChecked(prof->getIsKapiFile()) ;
591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ; 591 mIsKapiFileR->setChecked(prof->getIsKapiFile()) ;
592 592
593 593
594 QStringList res = QStringList::split( ":",prof->getResSpecKopi()); 594 QStringList res = QStringList::split( ":",prof->getResSpecKopi());
595 int i; 595 int i= res.count()/2;
596 for ( i = 0;i < res.count(); ++i ) { 596 for ( ;i < res.count(); ++i ) {
597 mResTableKopi->setText( i, 0, res[i] ); 597 mResTableKopi->setText( i, 0, res[i] );
598 } 598 }
599 res = QStringList::split( ":",prof->getResSpecKapi()); 599 res = QStringList::split( ":",prof->getResSpecKapi());
600 for ( i = 0;i < res.count(); ++i ) { 600 for ( i = 0;i < res.count(); ++i ) {
601 mResTableKapi->setText( i, 0, res[i] ); 601 mResTableKapi->setText( i, 0, res[i] );
602 } 602 }
603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec()); 603 mIsNotLocal->setChecked(!prof->getIsLocalFileSync() && !prof->getIsPhoneSync() &&!prof->getIsPiSync() &&!prof->getIsPiSyncSpec());
604 proGr->setEnabled( item > 2 ); 604 proGr->setEnabled( item > 2 );
605 if ( item < 3 ) { 605 if ( item < 3 ) {
606 localFileWidget->hide(); 606 localFileWidget->hide();
607 remoteFileWidget->hide(); 607 remoteFileWidget->hide();
608 phoneWidget->hide(); 608 phoneWidget->hide();
609 piWidget->hide(); 609 piWidget->hide();
610 610
611 } else 611 } else
612 kindChanged( prof->getIsLocalFileSync() ); 612 kindChanged( prof->getIsLocalFileSync() );
613} 613}
614 614
615void KSyncPrefsDialog::fillSSH() 615void KSyncPrefsDialog::fillSSH()
616{ 616{
617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 617 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
618 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 618 mLocalTempFile->setText("/tmp/mycalendar.ics" );
619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 619 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 620 mRemotePrecommandAB->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
621 mLocalTempFileAB->setText("/tmp/std.vcf" ); 621 mLocalTempFileAB->setText("/tmp/std.vcf" );
622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" ); 622 mRemotePostcommandAB->setText("scp /tmp/std.vcf zaurus@192.168.0.65:/home/zaurus/kdepim/apps/kabc/std.vcf" );
623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 623 mRemotePrecommandPWM->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 624 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" ); 625 mRemotePostcommandPWM->setText("scp /tmp/passwords.pwm zaurus@192.168.0.65:/home/zaurus/kdepim/apps/pwmanager/pwmanager.pwm" );
626} 626}
627void KSyncPrefsDialog::fillFTP() 627void KSyncPrefsDialog::fillFTP()
628{ 628{
629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 629 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
630 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 630 mLocalTempFile->setText("/tmp/mycalendar.ics" );
631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 631 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" ); 632 mRemotePrecommandAB->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf" );
633 mLocalTempFileAB->setText("/tmp/std.vcf" ); 633 mLocalTempFileAB->setText("/tmp/std.vcf" );
634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" ); 634 mRemotePostcommandAB->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/kabc/std.vcf /tmp/std.vcf" );
635 635
636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" ); 636 mRemotePrecommandPWM->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm" );
637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" ); 637 mLocalTempFilePWM->setText("/tmp/passwords.pwm" );
638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" ); 638 mRemotePostcommandPWM->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/pwmanager/passwords.pwm /tmp/passwords.pwm" );
639 639
640} 640}
641void KSyncPrefsDialog::kindChanged( bool b ) 641void KSyncPrefsDialog::kindChanged( bool b )
642{ 642{
643 643
644 if ( mIsLocal->isChecked () ) { 644 if ( mIsLocal->isChecked () ) {
645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() ); 645 mIsKapiFileL->setChecked( mIsKapiFileR->isChecked() );
646 } else { 646 } else {
647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() ); 647 mIsKapiFileR->setChecked( mIsKapiFileL->isChecked() );
648 } 648 }
649 649
650 if ( mIsLocal->isChecked () ) 650 if ( mIsLocal->isChecked () )
651 localFileWidget->show(); 651 localFileWidget->show();
652 else 652 else
653 localFileWidget->hide(); 653 localFileWidget->hide();
654 654
655 if ( mIsNotLocal->isChecked () ) 655 if ( mIsNotLocal->isChecked () )
656 remoteFileWidget->show(); 656 remoteFileWidget->show();
657 else 657 else
658 remoteFileWidget->hide(); 658 remoteFileWidget->hide();
659 659
660 if ( mIsPhone->isChecked () ) { 660 if ( mIsPhone->isChecked () ) {
661 phoneWidget->show(); 661 phoneWidget->show();
662 } 662 }
663 else { 663 else {
664 phoneWidget->hide(); 664 phoneWidget->hide();
665 } 665 }
666 666
667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) { 667 if ( mIsPi->isChecked () || mIsPiSpecific->isChecked () ) {
668 piWidget->show(); 668 piWidget->show();
669 if (mIsPiSpecific->isChecked () ) { 669 if (mIsPiSpecific->isChecked () ) {
670 mTableBox->show(); 670 mTableBox->show();
671 } 671 }
672 else { 672 else {
673 mTableBox->hide(); 673 mTableBox->hide();
674 } 674 }
675 } 675 }
676 else { 676 else {
677 piWidget->hide(); 677 piWidget->hide();
678 } 678 }
679 679
680 680
681} 681}
682void KSyncPrefsDialog::deleteProfile() 682void KSyncPrefsDialog::deleteProfile()
683{ 683{
684 //qDebug("KSyncPrefsDialog::deleteProfile() "); 684 //qDebug("KSyncPrefsDialog::deleteProfile() ");
685 if ( currentSelection >= 0 ) { 685 if ( currentSelection >= 0 ) {
686 if ( currentSelection < 3 ) { 686 if ( currentSelection < 3 ) {
687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 687 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
688 return; 688 return;
689 } 689 }
690 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 690 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
691 mSyncProfiles.remove( temp ); 691 mSyncProfiles.remove( temp );
692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 692 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
693 insertProfiles(); 693 insertProfiles();
694 } 694 }
695} 695}
696 696
697void KSyncPrefsDialog::saveProfile() 697void KSyncPrefsDialog::saveProfile()
698{ 698{
699 KSyncProfile* prof; 699 KSyncProfile* prof;
700 if ( currentSelection >= 0 ) { 700 if ( currentSelection >= 0 ) {
701 prof = mSyncProfiles.at(currentSelection) ; 701 prof = mSyncProfiles.at(currentSelection) ;
702 702
703 prof->setRemotePw( mRemotePw->text()); 703 prof->setRemotePw( mRemotePw->text());
704 prof->setRemoteIP( mRemoteIP->text()); 704 prof->setRemoteIP( mRemoteIP->text());
705 prof->setRemotePort( mRemotePort->text()); 705 prof->setRemotePort( mRemotePort->text());
706 706
707 prof->setRemotePwAB( mRemotePwAB->text()); 707 prof->setRemotePwAB( mRemotePwAB->text());
708 prof->setRemoteIPAB( mRemoteIPAB->text()); 708 prof->setRemoteIPAB( mRemoteIPAB->text());
709 prof->setRemotePortAB( mRemotePortAB->text()); 709 prof->setRemotePortAB( mRemotePortAB->text());
710 710
711 prof->setRemotePwPWM( mRemotePwPWM->text()); 711 prof->setRemotePwPWM( mRemotePwPWM->text());
712 prof->setRemoteIPPWM( mRemoteIPPWM->text()); 712 prof->setRemoteIPPWM( mRemoteIPPWM->text());
713 prof->setRemotePortPWM( mRemotePortPWM->text()); 713 prof->setRemotePortPWM( mRemotePortPWM->text());
714 714
715 prof->setPreSyncCommand( mRemotePrecommand->text()); 715 prof->setPreSyncCommand( mRemotePrecommand->text());
716 prof->setPostSyncCommand( mRemotePostcommand->text() ); 716 prof->setPostSyncCommand( mRemotePostcommand->text() );
717 prof->setLocalTempFile( mLocalTempFile->text()); 717 prof->setLocalTempFile( mLocalTempFile->text());
718 prof->setRemoteFileName( mRemoteFile->text() ); 718 prof->setRemoteFileName( mRemoteFile->text() );
719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text()); 719 prof->setPreSyncCommandAB( mRemotePrecommandAB->text());
720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() ); 720 prof->setPostSyncCommandAB( mRemotePostcommandAB->text() );
721 prof->setLocalTempFileAB( mLocalTempFileAB->text()); 721 prof->setLocalTempFileAB( mLocalTempFileAB->text());
722 prof->setRemoteFileNameAB( mRemoteFileAB->text() ); 722 prof->setRemoteFileNameAB( mRemoteFileAB->text() );
723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text()); 723 prof->setPreSyncCommandPWM( mRemotePrecommandPWM->text());
724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() ); 724 prof->setPostSyncCommandPWM( mRemotePostcommandPWM->text() );
725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text()); 725 prof->setLocalTempFilePWM( mLocalTempFilePWM->text());
726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() ); 726 prof->setRemoteFileNamePWM( mRemoteFilePWM->text() );
727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 727 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
728 prof->setAskForPreferences( mAskForPreferences->isChecked()); 728 prof->setAskForPreferences( mAskForPreferences->isChecked());
729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 729 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
730 prof->setWriteBackFile( mWriteBackFile->isChecked()); 730 prof->setWriteBackFile( mWriteBackFile->isChecked());
731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 731 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() ); 732 prof->setIncludeInRingSyncAB( mIncludeInRingAB->isChecked() );
733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() ); 733 prof->setIncludeInRingSyncPWM( mIncludeInRingPWM->isChecked() );
734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 734 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
735 prof->setSyncPrefs( syncprefs); 735 prof->setSyncPrefs( syncprefs);
736 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 736 prof->setIsLocalFileSync( mIsLocal->isChecked() );
737 prof->setIsPhoneSync( mIsPhone->isChecked() ); 737 prof->setIsPhoneSync( mIsPhone->isChecked() );
738 prof->setIsPiSync( mIsPi->isChecked() ); 738 prof->setIsPiSync( mIsPi->isChecked() );
739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() ); 739 prof->setIsPiSyncSpec( mIsPiSpecific->isChecked() );
740 prof->setIsKapiFile( mIsKapiFileL->isChecked() ); 740 prof->setIsKapiFile( mIsKapiFileL->isChecked() );
741 prof->setWriteBackFuture(mWriteBackFuture->isChecked()); 741 prof->setWriteBackFuture(mWriteBackFuture->isChecked());
742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value()); 742 prof->setWriteBackFutureWeeks(mWriteBackFutureWeeks->value());
743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value()); 743 prof->setWriteBackPastWeeks(mWriteBackPastWeeks->value());
744 if ( mWriteContactToSIM ) 744 if ( mWriteContactToSIM )
745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked()); 745 prof->setWriteContactToSIM(mWriteContactToSIM->isChecked());
746 prof->setPhoneDevice( mPhoneDevice->text() ); 746 prof->setPhoneDevice( mPhoneDevice->text() );
747 prof->setPhoneConnection( mPhoneConnection->text() ); 747 prof->setPhoneConnection( mPhoneConnection->text() );
748 prof->setPhoneModel( mPhoneModel->text() ); 748 prof->setPhoneModel( mPhoneModel->text() );
749 prof->setFilterInCal ( mFilterInCal->currentText ()); 749 prof->setFilterInCal ( mFilterInCal->currentText ());
750 prof->setFilterOutCal ( mFilterOutCal ->currentText ()); 750 prof->setFilterOutCal ( mFilterOutCal ->currentText ());
751 prof->setFilterInAB ( mFilterInAB ->currentText ()); 751 prof->setFilterInAB ( mFilterInAB ->currentText ());
752 prof->setFilterOutAB ( mFilterOutAB ->currentText ()); 752 prof->setFilterOutAB ( mFilterOutAB ->currentText ());
753 if ( mIsPiSpecific->isChecked() ) { 753 if ( mIsPiSpecific->isChecked() ) {
754 754
755 QStringList res; 755 QStringList res = mResourcesKopi;
756 int i; 756 int i;
757 for ( i = 0;i < mResourcesKopi.count(); ++i ) { 757 for ( i = 0;i < mResourcesKopi.count(); ++i ) {
758 res.append( mResTableKopi->text( i, 0 )); 758 res.append( mResTableKopi->text( i, 0 ));
759 } 759 }
760 prof->setResSpecKopi( res.join(":")); 760 prof->setResSpecKopi( res.join(":"));
761 } 761 }
762 } 762 }
763} 763}
764 764
765void KSyncPrefsDialog::insertProfiles() 765void KSyncPrefsDialog::insertProfiles()
766{ 766{
767 int curItem = mProfileBox->currentItem(); 767 int curItem = mProfileBox->currentItem();
768 mProfileBox->blockSignals( true ); 768 mProfileBox->blockSignals( true );
769 mProfileBox->clear(); 769 mProfileBox->clear();
770 mProfileBox->insertStringList (mSyncProfileNames ); 770 mProfileBox->insertStringList (mSyncProfileNames );
771 int item = mSyncProfileNames.count() -1; 771 int item = mSyncProfileNames.count() -1;
772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 772 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
773 mProfileBox->setCurrentItem( curItem ); 773 mProfileBox->setCurrentItem( curItem );
774 else if ( item >= 0 ) { 774 else if ( item >= 0 ) {
775 mProfileBox->setCurrentItem( item ); 775 mProfileBox->setCurrentItem( item );
776 } 776 }
777 currentSelection = -1; 777 currentSelection = -1;
778 if ( mSyncProfileNames.count() > 0 ) { 778 if ( mSyncProfileNames.count() > 0 ) {
779 //qDebug(" profileChanged( mProfileBox->currentItem() "); 779 //qDebug(" profileChanged( mProfileBox->currentItem() ");
780 profileChanged( mProfileBox->currentItem() ); 780 profileChanged( mProfileBox->currentItem() );
781 currentSelection = mProfileBox->currentItem(); 781 currentSelection = mProfileBox->currentItem();
782 } 782 }
783 mProfileBox->blockSignals( false ); 783 mProfileBox->blockSignals( false );
784} 784}
785 785
786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 786void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
787{ 787{
788 saveProfile(); 788 saveProfile();
789 mSyncProfiles.append( temp ); 789 mSyncProfiles.append( temp );
790 mSyncProfileNames << temp->getName(); 790 mSyncProfileNames << temp->getName();
791 insertProfiles(); 791 insertProfiles();
792 int last = mProfileBox->count() -1; 792 int last = mProfileBox->count() -1;
793 mProfileBox->blockSignals( true ); 793 mProfileBox->blockSignals( true );
794 mProfileBox->setCurrentItem( last ); 794 mProfileBox->setCurrentItem( last );
795 mProfileBox->blockSignals( false ); 795 mProfileBox->blockSignals( false );
796 profileChanged(last); 796 profileChanged(last);
797} 797}
798void KSyncPrefsDialog::newProfile() 798void KSyncPrefsDialog::newProfile()
799{ 799{
800 addProfile ( new KSyncProfile () ); 800 addProfile ( new KSyncProfile () );
801} 801}
802 802
803void KSyncPrefsDialog::cloneProfile() 803void KSyncPrefsDialog::cloneProfile()
804{ 804{
805 if ( currentSelection >= 0 ) 805 if ( currentSelection >= 0 )
806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 806 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
807 else 807 else
808 newProfile(); 808 newProfile();
809} 809}
810 810
811void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 811void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
812{ 812{
813 mMyMachineName->setText( name ); 813 mMyMachineName->setText( name );
814 814
815} 815}
816QString KSyncPrefsDialog::getLocalMachineName ( ) 816QString KSyncPrefsDialog::getLocalMachineName ( )
817{ 817{
818 return mMyMachineName->text(); 818 return mMyMachineName->text();
819} 819}
820 820
821QStringList KSyncPrefsDialog::getSyncProfileNames() 821QStringList KSyncPrefsDialog::getSyncProfileNames()
822{ 822{
823 return mSyncProfileNames; 823 return mSyncProfileNames;
824} 824}
825void KSyncPrefsDialog::usrReadConfig() 825void KSyncPrefsDialog::usrReadConfig()
826{ 826{
827 //KConfig *config = KOGlobals::config(); 827 //KConfig *config = KOGlobals::config();
828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 828 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
829 config.setGroup("General"); 829 config.setGroup("General");
830 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 830 mSyncProfileNames =config.readListEntry("SyncProfileNames");
831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined")); 831 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
832 int i; 832 int i;
833 KSyncProfile* temp ; 833 KSyncProfile* temp ;
834 mSyncProfiles.clear(); 834 mSyncProfiles.clear();
835 for ( i = 0; i < mSyncProfileNames.count();++i ) { 835 for ( i = 0; i < mSyncProfileNames.count();++i ) {
836 temp = new KSyncProfile (); 836 temp = new KSyncProfile ();
837 temp->setName( mSyncProfileNames[i] ); 837 temp->setName( mSyncProfileNames[i] );
838 temp->readConfig( &config ); 838 temp->readConfig( &config );
839 mSyncProfiles.append( temp ); 839 mSyncProfiles.append( temp );
840 } 840 }
841 insertProfiles(); 841 insertProfiles();
842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 842 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
843} 843}
844 844
845 845
846void KSyncPrefsDialog::usrWriteConfig() 846void KSyncPrefsDialog::usrWriteConfig()
847{ 847{
848 saveProfile(); 848 saveProfile();
849 if ( currentSelection >= 0 ) 849 if ( currentSelection >= 0 )
850 profileChanged(currentSelection); 850 profileChanged(currentSelection);
851 //KConfig *config = KOGlobals::config(); 851 //KConfig *config = KOGlobals::config();
852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 852 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
853 KSyncProfile* prof = mSyncProfiles.first(); 853 KSyncProfile* prof = mSyncProfiles.first();
854 QStringList externalSyncProfileNames; 854 QStringList externalSyncProfileNames;
855 externalSyncProfileNames.append("Sharp_DTM");; 855 externalSyncProfileNames.append("Sharp_DTM");;
856 while ( prof ) { 856 while ( prof ) {
857 prof->writeConfig(&config); 857 prof->writeConfig(&config);
858 if ( prof->getIsPhoneSync( ) ) 858 if ( prof->getIsPhoneSync( ) )
859 externalSyncProfileNames.append(prof->getName( ) ); 859 externalSyncProfileNames.append(prof->getName( ) );
860 prof = mSyncProfiles.next(); 860 prof = mSyncProfiles.next();
861 } 861 }
862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 862 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 863 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
864 config.setGroup("General"); 864 config.setGroup("General");
865 config.writeEntry("SyncProfileNames",mSyncProfileNames); 865 config.writeEntry("SyncProfileNames",mSyncProfileNames);
866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames); 866 config.writeEntry("ExternSyncProfiles",externalSyncProfileNames);
867 config.writeEntry("LocalMachineName",mMyMachineName->text()); 867 config.writeEntry("LocalMachineName",mMyMachineName->text());
868 config.sync(); 868 config.sync();
869} 869}
870 870
871void KSyncPrefsDialog::helpDevice() 871void KSyncPrefsDialog::helpDevice()
872{ 872{
873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n"); 873 QString hint = i18n("Insert device where\nphone is connected. E.g.:\n");
874#ifdef _WIN32_ 874#ifdef _WIN32_
875 hint += "Leave empty for Irda.\n" 875 hint += "Leave empty for Irda.\n"
876 "com1:\n(first serial port)\n" 876 "com1:\n(first serial port)\n"
877 "usb not supported\n" 877 "usb not supported\n"
878 "???\n(bluetooth device address)\n"; 878 "???\n(bluetooth device address)\n";
879 879
880#else 880#else
881 hint += "/dev/ircomm\n(Irda)\n" 881 hint += "/dev/ircomm\n(Irda)\n"
882 "/dev/ttyS0\n(first serial port)\n" 882 "/dev/ttyS0\n(first serial port)\n"
883 "/dev/ttyUSB0\n(first device usb port)\n" 883 "/dev/ttyUSB0\n(first device usb port)\n"
884 "???\n(bluetooth device address)\n"; 884 "???\n(bluetooth device address)\n";
885#endif 885#endif
886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 886 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
887} 887}
888void KSyncPrefsDialog::helpModel() 888void KSyncPrefsDialog::helpModel()
889{ 889{
890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n"); 890 QString hint = i18n("Recommended: Leave empty!\n(Such that model can\nbe auto detected)\nOr insert name of model:\n");
891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection"; 891 hint += "E.g. for Nokia 6310i:\n6310i\nAlso possible:\nobex\nfor Obex connection";
892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 892 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
893 893
894} 894}
895void KSyncPrefsDialog::helpConnection() 895void KSyncPrefsDialog::helpConnection()
896{ 896{
897 QString hint = i18n("Insert kind of connection,e.g.:\n"); 897 QString hint = i18n("Insert kind of connection,e.g.:\n");
898 hint += "irda | Nokia FBUS over infrared\n" 898 hint += "irda | Nokia FBUS over infrared\n"
899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n" 899 "irdaat | AT commands infrared\n(for Siemens/Sony-Erricsson)\n"
900 "irdaobex | set also model as obex\n" 900 "irdaobex | set also model as obex\n"
901 "fbus | Nokia FBUS2 serial\n"; 901 "fbus | Nokia FBUS2 serial\n";
902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config")); 902 KMessageBox::information(this,hint,i18n("KDE-Pim sync config"));
903} 903}