summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-22 04:45:07 (UTC)
committer zautrix <zautrix>2004-09-22 04:45:07 (UTC)
commitbbeffa56ee51d30b84bcadaf22234b8227958f31 (patch) (unidiff)
tree040ce64f3e618ef4b76ddfa80d34a245d59ef1b5
parenta56783aace3496c8b40008d0dec4c42437165e54 (diff)
downloadkdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.zip
kdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.tar.gz
kdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.tar.bz2
desktop compile fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp3
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp1
-rw-r--r--libkdepim/kpimglobalprefs.cpp1
-rw-r--r--libkdepim/kprefswidget.h1
-rw-r--r--libkdepim/libkdepim.pro2
5 files changed, 7 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1b40d71..df634d0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3067 +1,3068 @@
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/* 24/*
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 <qprogressbar.h> 37#include <qprogressbar.h>
37 38
38#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
39#include <qclipboard.h> 40#include <qclipboard.h>
40#include <qdir.h> 41#include <qdir.h>
41#include <qfile.h> 42#include <qfile.h>
42#include <qapplicaton.h> 43#include <qapplicaton.h>
43#include <qprogressbar.h> 44#include <qprogressbar.h>
44#include <qlayout.h> 45#include <qlayout.h>
45#include <qregexp.h> 46#include <qregexp.h>
46#include <qvbox.h> 47#include <qvbox.h>
47#include <kabc/addresseelist.h> 48#include <kabc/addresseelist.h>
48#include <kabc/errorhandler.h> 49#include <kabc/errorhandler.h>
49#include <kabc/resource.h> 50#include <kabc/resource.h>
50#include <kabc/vcardconverter.h> 51#include <kabc/vcardconverter.h>
51#include <kapplication.h> 52#include <kapplication.h>
52#include <kactionclasses.h> 53#include <kactionclasses.h>
53#include <kcmultidialog.h> 54#include <kcmultidialog.h>
54#include <kdebug.h> 55#include <kdebug.h>
55#include <kdeversion.h> 56#include <kdeversion.h>
56#include <kkeydialog.h> 57#include <kkeydialog.h>
57#include <kmessagebox.h> 58#include <kmessagebox.h>
58#include <kprinter.h> 59#include <kprinter.h>
59#include <kprotocolinfo.h> 60#include <kprotocolinfo.h>
60#include <kresources/selectdialog.h> 61#include <kresources/selectdialog.h>
61#include <kstandarddirs.h> 62#include <kstandarddirs.h>
62#include <ktempfile.h> 63#include <ktempfile.h>
63#include <kxmlguiclient.h> 64#include <kxmlguiclient.h>
64#include <kaboutdata.h> 65#include <kaboutdata.h>
65#include <libkdepim/categoryselectdialog.h> 66#include <libkdepim/categoryselectdialog.h>
66 67
67#include "addresseeutil.h" 68#include "addresseeutil.h"
68#include "addresseeeditordialog.h" 69#include "addresseeeditordialog.h"
69#include "extensionmanager.h" 70#include "extensionmanager.h"
70#include "kstdaction.h" 71#include "kstdaction.h"
71#include "kaddressbookservice.h" 72#include "kaddressbookservice.h"
72#include "ldapsearchdialog.h" 73#include "ldapsearchdialog.h"
73#include "printing/printingwizard.h" 74#include "printing/printingwizard.h"
74#else // KAB_EMBEDDED 75#else // KAB_EMBEDDED
75 76
76#include <kapplication.h> 77#include <kapplication.h>
77#include "KDGanttMinimizeSplitter.h" 78#include "KDGanttMinimizeSplitter.h"
78#include "kaddressbookmain.h" 79#include "kaddressbookmain.h"
79#include "kactioncollection.h" 80#include "kactioncollection.h"
80#include "addresseedialog.h" 81#include "addresseedialog.h"
81//US 82//US
82#include <addresseeview.h> 83#include <addresseeview.h>
83 84
84#include <qapp.h> 85#include <qapp.h>
85#include <qmenubar.h> 86#include <qmenubar.h>
86//#include <qtoolbar.h> 87//#include <qtoolbar.h>
87#include <qmessagebox.h> 88#include <qmessagebox.h>
88#include <kdebug.h> 89#include <kdebug.h>
89#include <kiconloader.h> // needed for SmallIcon 90#include <kiconloader.h> // needed for SmallIcon
90#include <kresources/kcmkresources.h> 91#include <kresources/kcmkresources.h>
91#include <ktoolbar.h> 92#include <ktoolbar.h>
92 93
93 94
94//#include <qlabel.h> 95//#include <qlabel.h>
95 96
96 97
97#ifndef DESKTOP_VERSION 98#ifndef DESKTOP_VERSION
98#include <qpe/ir.h> 99#include <qpe/ir.h>
99#include <qpe/qpemenubar.h> 100#include <qpe/qpemenubar.h>
100#include <qtopia/qcopenvelope_qws.h> 101#include <qtopia/qcopenvelope_qws.h>
101#else 102#else
102 103
103#include <qmenubar.h> 104#include <qmenubar.h>
104#endif 105#endif
105 106
106#endif // KAB_EMBEDDED 107#endif // KAB_EMBEDDED
107#include "kcmconfigs/kcmkabconfig.h" 108#include "kcmconfigs/kcmkabconfig.h"
108#include "kcmconfigs/kcmkdepimconfig.h" 109#include "kcmconfigs/kcmkdepimconfig.h"
109#include "kpimglobalprefs.h" 110#include "kpimglobalprefs.h"
110#include "externalapphandler.h" 111#include "externalapphandler.h"
111 112
112 113
113#include <kresources/selectdialog.h> 114#include <kresources/selectdialog.h>
114#include <kmessagebox.h> 115#include <kmessagebox.h>
115 116
116#include <picture.h> 117#include <picture.h>
117#include <resource.h> 118#include <resource.h>
118 119
119//US#include <qsplitter.h> 120//US#include <qsplitter.h>
120#include <qmap.h> 121#include <qmap.h>
121#include <qdir.h> 122#include <qdir.h>
122#include <qfile.h> 123#include <qfile.h>
123#include <qvbox.h> 124#include <qvbox.h>
124#include <qlayout.h> 125#include <qlayout.h>
125#include <qclipboard.h> 126#include <qclipboard.h>
126#include <qtextstream.h> 127#include <qtextstream.h>
127 128
128#include <libkdepim/categoryselectdialog.h> 129#include <libkdepim/categoryselectdialog.h>
129#include <kabc/vcardconverter.h> 130#include <kabc/vcardconverter.h>
130 131
131 132
132#include "addresseeutil.h" 133#include "addresseeutil.h"
133#include "undocmds.h" 134#include "undocmds.h"
134#include "addresseeeditordialog.h" 135#include "addresseeeditordialog.h"
135#include "viewmanager.h" 136#include "viewmanager.h"
136#include "details/detailsviewcontainer.h" 137#include "details/detailsviewcontainer.h"
137#include "kabprefs.h" 138#include "kabprefs.h"
138#include "xxportmanager.h" 139#include "xxportmanager.h"
139#include "incsearchwidget.h" 140#include "incsearchwidget.h"
140#include "jumpbuttonbar.h" 141#include "jumpbuttonbar.h"
141#include "extensionmanager.h" 142#include "extensionmanager.h"
142#include "addresseeconfig.h" 143#include "addresseeconfig.h"
143#include <kcmultidialog.h> 144#include <kcmultidialog.h>
144 145
145#ifdef _WIN32_ 146#ifdef _WIN32_
146 147
147#include "kaimportoldialog.h" 148#include "kaimportoldialog.h"
148#else 149#else
149#include <unistd.h> 150#include <unistd.h>
150#endif 151#endif
151// sync includes 152// sync includes
152#include <libkdepim/ksyncprofile.h> 153#include <libkdepim/ksyncprofile.h>
153#include <libkdepim/ksyncprefsdialog.h> 154#include <libkdepim/ksyncprefsdialog.h>
154 155
155 156
156bool pasteWithNewUid = true; 157bool pasteWithNewUid = true;
157 158
158#ifdef KAB_EMBEDDED 159#ifdef KAB_EMBEDDED
159KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 160KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
160 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 161 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
161 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 162 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
162 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 163 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
163#else //KAB_EMBEDDED 164#else //KAB_EMBEDDED
164KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 165KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
165 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 166 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
166 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 167 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
167 mReadWrite( readWrite ), mModified( false ) 168 mReadWrite( readWrite ), mModified( false )
168#endif //KAB_EMBEDDED 169#endif //KAB_EMBEDDED
169{ 170{
170 171
171 mBlockSaveFlag = false; 172 mBlockSaveFlag = false;
172 mExtensionBarSplitter = 0; 173 mExtensionBarSplitter = 0;
173 mIsPart = !parent->inherits( "KAddressBookMain" ); 174 mIsPart = !parent->inherits( "KAddressBookMain" );
174 175
175 mAddressBook = KABC::StdAddressBook::self(); 176 mAddressBook = KABC::StdAddressBook::self();
176 KABC::StdAddressBook::setAutomaticSave( false ); 177 KABC::StdAddressBook::setAutomaticSave( false );
177 178
178#ifndef KAB_EMBEDDED 179#ifndef KAB_EMBEDDED
179 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 180 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
180#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
181 182
182 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 183 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
183 SLOT( addressBookChanged() ) ); 184 SLOT( addressBookChanged() ) );
184 185
185#if 0 186#if 0
186 // LP moved to addressbook init method 187 // LP moved to addressbook init method
187 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 188 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
188 "X-Department", "KADDRESSBOOK" ); 189 "X-Department", "KADDRESSBOOK" );
189 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 190 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
190 "X-Profession", "KADDRESSBOOK" ); 191 "X-Profession", "KADDRESSBOOK" );
191 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 192 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
192 "X-AssistantsName", "KADDRESSBOOK" ); 193 "X-AssistantsName", "KADDRESSBOOK" );
193 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 194 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
194 "X-ManagersName", "KADDRESSBOOK" ); 195 "X-ManagersName", "KADDRESSBOOK" );
195 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
196 "X-SpousesName", "KADDRESSBOOK" ); 197 "X-SpousesName", "KADDRESSBOOK" );
197 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 198 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
198 "X-Office", "KADDRESSBOOK" ); 199 "X-Office", "KADDRESSBOOK" );
199 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 200 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
200 "X-IMAddress", "KADDRESSBOOK" ); 201 "X-IMAddress", "KADDRESSBOOK" );
201 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 202 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
202 "X-Anniversary", "KADDRESSBOOK" ); 203 "X-Anniversary", "KADDRESSBOOK" );
203 204
204 //US added this field to become compatible with Opie/qtopia addressbook 205 //US added this field to become compatible with Opie/qtopia addressbook
205 // values can be "female" or "male" or "". An empty field represents undefined. 206 // values can be "female" or "male" or "". An empty field represents undefined.
206 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 207 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
207 "X-Gender", "KADDRESSBOOK" ); 208 "X-Gender", "KADDRESSBOOK" );
208 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 209 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
209 "X-Children", "KADDRESSBOOK" ); 210 "X-Children", "KADDRESSBOOK" );
210 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 211 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
211 "X-FreeBusyUrl", "KADDRESSBOOK" ); 212 "X-FreeBusyUrl", "KADDRESSBOOK" );
212#endif 213#endif
213 initGUI(); 214 initGUI();
214 215
215 mIncSearchWidget->setFocus(); 216 mIncSearchWidget->setFocus();
216 217
217 218
218 connect( mViewManager, SIGNAL( selected( const QString& ) ), 219 connect( mViewManager, SIGNAL( selected( const QString& ) ),
219 SLOT( setContactSelected( const QString& ) ) ); 220 SLOT( setContactSelected( const QString& ) ) );
220 connect( mViewManager, SIGNAL( executed( const QString& ) ), 221 connect( mViewManager, SIGNAL( executed( const QString& ) ),
221 SLOT( executeContact( const QString& ) ) ); 222 SLOT( executeContact( const QString& ) ) );
222 223
223 connect( mViewManager, SIGNAL( deleteRequest( ) ), 224 connect( mViewManager, SIGNAL( deleteRequest( ) ),
224 SLOT( deleteContacts( ) ) ); 225 SLOT( deleteContacts( ) ) );
225 connect( mViewManager, SIGNAL( modified() ), 226 connect( mViewManager, SIGNAL( modified() ),
226 SLOT( setModified() ) ); 227 SLOT( setModified() ) );
227 228
228 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 229 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
229 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 230 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
230 231
231 connect( mXXPortManager, SIGNAL( modified() ), 232 connect( mXXPortManager, SIGNAL( modified() ),
232 SLOT( setModified() ) ); 233 SLOT( setModified() ) );
233 234
234 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 235 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
235 SLOT( incrementalSearch( const QString& ) ) ); 236 SLOT( incrementalSearch( const QString& ) ) );
236 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 237 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
237 mJumpButtonBar, SLOT( recreateButtons() ) ); 238 mJumpButtonBar, SLOT( recreateButtons() ) );
238 239
239 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 240 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
240 SLOT( sendMail( const QString& ) ) ); 241 SLOT( sendMail( const QString& ) ) );
241 242
242 243
243 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 244 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
244 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&))); 245 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&)));
245 246
246 247
247#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED
248 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 249 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
249 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 250 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
250 251
251 connect( mDetails, SIGNAL( browse( const QString& ) ), 252 connect( mDetails, SIGNAL( browse( const QString& ) ),
252 SLOT( browse( const QString& ) ) ); 253 SLOT( browse( const QString& ) ) );
253 254
254 255
255 mAddressBookService = new KAddressBookService( this ); 256 mAddressBookService = new KAddressBookService( this );
256 257
257#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
258 mEditorDialog = 0; 259 mEditorDialog = 0;
259 createAddresseeEditorDialog( this ); 260 createAddresseeEditorDialog( this );
260 setModified( false ); 261 setModified( false );
261} 262}
262 263
263KABCore::~KABCore() 264KABCore::~KABCore()
264{ 265{
265 // save(); 266 // save();
266 //saveSettings(); 267 //saveSettings();
267 //KABPrefs::instance()->writeConfig(); 268 //KABPrefs::instance()->writeConfig();
268 delete AddresseeConfig::instance(); 269 delete AddresseeConfig::instance();
269 mAddressBook = 0; 270 mAddressBook = 0;
270 KABC::StdAddressBook::close(); 271 KABC::StdAddressBook::close();
271} 272}
272 273
273void KABCore::restoreSettings() 274void KABCore::restoreSettings()
274{ 275{
275 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 276 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
276 277
277 bool state; 278 bool state;
278 279
279 if (mMultipleViewsAtOnce) 280 if (mMultipleViewsAtOnce)
280 state = KABPrefs::instance()->mDetailsPageVisible; 281 state = KABPrefs::instance()->mDetailsPageVisible;
281 else 282 else
282 state = false; 283 state = false;
283 284
284 mActionDetails->setChecked( state ); 285 mActionDetails->setChecked( state );
285 setDetailsVisible( state ); 286 setDetailsVisible( state );
286 287
287 state = KABPrefs::instance()->mJumpButtonBarVisible; 288 state = KABPrefs::instance()->mJumpButtonBarVisible;
288 289
289 mActionJumpBar->setChecked( state ); 290 mActionJumpBar->setChecked( state );
290 setJumpButtonBarVisible( state ); 291 setJumpButtonBarVisible( state );
291/*US 292/*US
292 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 293 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
293 if ( splitterSize.count() == 0 ) { 294 if ( splitterSize.count() == 0 ) {
294 splitterSize.append( width() / 2 ); 295 splitterSize.append( width() / 2 );
295 splitterSize.append( width() / 2 ); 296 splitterSize.append( width() / 2 );
296 } 297 }
297 mMiniSplitter->setSizes( splitterSize ); 298 mMiniSplitter->setSizes( splitterSize );
298 if ( mExtensionBarSplitter ) { 299 if ( mExtensionBarSplitter ) {
299 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 300 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
300 if ( splitterSize.count() == 0 ) { 301 if ( splitterSize.count() == 0 ) {
301 splitterSize.append( width() / 2 ); 302 splitterSize.append( width() / 2 );
302 splitterSize.append( width() / 2 ); 303 splitterSize.append( width() / 2 );
303 } 304 }
304 mExtensionBarSplitter->setSizes( splitterSize ); 305 mExtensionBarSplitter->setSizes( splitterSize );
305 306
306 } 307 }
307*/ 308*/
308 mViewManager->restoreSettings(); 309 mViewManager->restoreSettings();
309 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 310 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
310 mExtensionManager->restoreSettings(); 311 mExtensionManager->restoreSettings();
311#ifdef DESKTOP_VERSION 312#ifdef DESKTOP_VERSION
312 int wid = width(); 313 int wid = width();
313 if ( wid < 10 ) 314 if ( wid < 10 )
314 wid = 400; 315 wid = 400;
315#else 316#else
316 int wid = QApplication::desktop()->width(); 317 int wid = QApplication::desktop()->width();
317 if ( wid < 640 ) 318 if ( wid < 640 )
318 wid = QApplication::desktop()->height(); 319 wid = QApplication::desktop()->height();
319#endif 320#endif
320 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 321 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
321 if ( true /*splitterSize.count() == 0*/ ) { 322 if ( true /*splitterSize.count() == 0*/ ) {
322 splitterSize.append( wid / 2 ); 323 splitterSize.append( wid / 2 );
323 splitterSize.append( wid / 2 ); 324 splitterSize.append( wid / 2 );
324 } 325 }
325 mMiniSplitter->setSizes( splitterSize ); 326 mMiniSplitter->setSizes( splitterSize );
326 if ( mExtensionBarSplitter ) { 327 if ( mExtensionBarSplitter ) {
327 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 328 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
328 if ( true /*splitterSize.count() == 0*/ ) { 329 if ( true /*splitterSize.count() == 0*/ ) {
329 splitterSize.append( wid / 2 ); 330 splitterSize.append( wid / 2 );
330 splitterSize.append( wid / 2 ); 331 splitterSize.append( wid / 2 );
331 } 332 }
332 mExtensionBarSplitter->setSizes( splitterSize ); 333 mExtensionBarSplitter->setSizes( splitterSize );
333 334
334 } 335 }
335 336
336 337
337} 338}
338 339
339void KABCore::saveSettings() 340void KABCore::saveSettings()
340{ 341{
341 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 342 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
342 if ( mExtensionBarSplitter ) 343 if ( mExtensionBarSplitter )
343 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 344 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
344 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 345 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
345 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 346 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
346#ifndef KAB_EMBEDDED 347#ifndef KAB_EMBEDDED
347 348
348 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 349 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
349 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 350 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
350#endif //KAB_EMBEDDED 351#endif //KAB_EMBEDDED
351 mExtensionManager->saveSettings(); 352 mExtensionManager->saveSettings();
352 mViewManager->saveSettings(); 353 mViewManager->saveSettings();
353 354
354 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 355 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
355} 356}
356 357
357KABC::AddressBook *KABCore::addressBook() const 358KABC::AddressBook *KABCore::addressBook() const
358{ 359{
359 return mAddressBook; 360 return mAddressBook;
360} 361}
361 362
362KConfig *KABCore::config() 363KConfig *KABCore::config()
363{ 364{
364#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
365 return KABPrefs::instance()->config(); 366 return KABPrefs::instance()->config();
366#else //KAB_EMBEDDED 367#else //KAB_EMBEDDED
367 return KABPrefs::instance()->getConfig(); 368 return KABPrefs::instance()->getConfig();
368#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
369} 370}
370 371
371KActionCollection *KABCore::actionCollection() const 372KActionCollection *KABCore::actionCollection() const
372{ 373{
373 return mGUIClient->actionCollection(); 374 return mGUIClient->actionCollection();
374} 375}
375 376
376KABC::Field *KABCore::currentSearchField() const 377KABC::Field *KABCore::currentSearchField() const
377{ 378{
378 if (mIncSearchWidget) 379 if (mIncSearchWidget)
379 return mIncSearchWidget->currentField(); 380 return mIncSearchWidget->currentField();
380 else 381 else
381 return 0; 382 return 0;
382} 383}
383 384
384QStringList KABCore::selectedUIDs() const 385QStringList KABCore::selectedUIDs() const
385{ 386{
386 return mViewManager->selectedUids(); 387 return mViewManager->selectedUids();
387} 388}
388 389
389KABC::Resource *KABCore::requestResource( QWidget *parent ) 390KABC::Resource *KABCore::requestResource( QWidget *parent )
390{ 391{
391 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 392 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
392 393
393 QPtrList<KRES::Resource> kresResources; 394 QPtrList<KRES::Resource> kresResources;
394 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 395 QPtrListIterator<KABC::Resource> resIt( kabcResources );
395 KABC::Resource *resource; 396 KABC::Resource *resource;
396 while ( ( resource = resIt.current() ) != 0 ) { 397 while ( ( resource = resIt.current() ) != 0 ) {
397 ++resIt; 398 ++resIt;
398 if ( !resource->readOnly() ) { 399 if ( !resource->readOnly() ) {
399 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 400 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
400 if ( res ) 401 if ( res )
401 kresResources.append( res ); 402 kresResources.append( res );
402 } 403 }
403 } 404 }
404 405
405 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 406 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
406 return static_cast<KABC::Resource*>( res ); 407 return static_cast<KABC::Resource*>( res );
407} 408}
408 409
409#ifndef KAB_EMBEDDED 410#ifndef KAB_EMBEDDED
410KAboutData *KABCore::createAboutData() 411KAboutData *KABCore::createAboutData()
411#else //KAB_EMBEDDED 412#else //KAB_EMBEDDED
412void KABCore::createAboutData() 413void KABCore::createAboutData()
413#endif //KAB_EMBEDDED 414#endif //KAB_EMBEDDED
414{ 415{
415#ifndef KAB_EMBEDDED 416#ifndef KAB_EMBEDDED
416 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 417 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
417 "3.1", I18N_NOOP( "The KDE Address Book" ), 418 "3.1", I18N_NOOP( "The KDE Address Book" ),
418 KAboutData::License_GPL_V2, 419 KAboutData::License_GPL_V2,
419 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 420 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
420 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 421 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
421 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 422 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
422 about->addAuthor( "Cornelius Schumacher", 423 about->addAuthor( "Cornelius Schumacher",
423 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 424 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
424 "schumacher@kde.org" ); 425 "schumacher@kde.org" );
425 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 426 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
426 "mpilone@slac.com" ); 427 "mpilone@slac.com" );
427 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 428 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
428 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 429 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
429 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 430 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
430 "michel@klaralvdalens-datakonsult.se" ); 431 "michel@klaralvdalens-datakonsult.se" );
431 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 432 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
432 "hansen@kde.org" ); 433 "hansen@kde.org" );
433 434
434 return about; 435 return about;
435#endif //KAB_EMBEDDED 436#endif //KAB_EMBEDDED
436 437
437 QString version; 438 QString version;
438#include <../version> 439#include <../version>
439 QMessageBox::about( this, "About KAddressbook/Pi", 440 QMessageBox::about( this, "About KAddressbook/Pi",
440 "KAddressbook/Platform-independent\n" 441 "KAddressbook/Platform-independent\n"
441 "(KA/Pi) " +version + " - " + 442 "(KA/Pi) " +version + " - " +
442#ifdef DESKTOP_VERSION 443#ifdef DESKTOP_VERSION
443 "Desktop Edition\n" 444 "Desktop Edition\n"
444#else 445#else
445 "PDA-Edition\n" 446 "PDA-Edition\n"
446 "for: Zaurus 5500 / 7x0 / 8x0\n" 447 "for: Zaurus 5500 / 7x0 / 8x0\n"
447#endif 448#endif
448 449
449 "(c) 2004 Ulf Schenk\n" 450 "(c) 2004 Ulf Schenk\n"
450 "(c) 2004 Lutz Rogowski\n" 451 "(c) 2004 Lutz Rogowski\n"
451 "(c) 1997-2003, The KDE PIM Team\n" 452 "(c) 1997-2003, The KDE PIM Team\n"
452 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 453 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
453 "Don Sanders Original author\n" 454 "Don Sanders Original author\n"
454 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 455 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
455 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 456 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
456 "Greg Stern DCOP interface\n" 457 "Greg Stern DCOP interface\n"
457 "Mark Westcot Contact pinning\n" 458 "Mark Westcot Contact pinning\n"
458 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 459 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
459 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 460 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
460#ifdef _WIN32_ 461#ifdef _WIN32_
461 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 462 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
462#endif 463#endif
463 ); 464 );
464} 465}
465 466
466void KABCore::setContactSelected( const QString &uid ) 467void KABCore::setContactSelected( const QString &uid )
467{ 468{
468 KABC::Addressee addr = mAddressBook->findByUid( uid ); 469 KABC::Addressee addr = mAddressBook->findByUid( uid );
469 if ( !mDetails->isHidden() ) 470 if ( !mDetails->isHidden() )
470 mDetails->setAddressee( addr ); 471 mDetails->setAddressee( addr );
471 472
472 if ( !addr.isEmpty() ) { 473 if ( !addr.isEmpty() ) {
473 emit contactSelected( addr.formattedName() ); 474 emit contactSelected( addr.formattedName() );
474 KABC::Picture pic = addr.photo(); 475 KABC::Picture pic = addr.photo();
475 if ( pic.isIntern() ) { 476 if ( pic.isIntern() ) {
476//US emit contactSelected( pic.data() ); 477//US emit contactSelected( pic.data() );
477//US instead use: 478//US instead use:
478 QPixmap px; 479 QPixmap px;
479 if (pic.data().isNull() != true) 480 if (pic.data().isNull() != true)
480 { 481 {
481 px.convertFromImage(pic.data()); 482 px.convertFromImage(pic.data());
482 } 483 }
483 484
484 emit contactSelected( px ); 485 emit contactSelected( px );
485 } 486 }
486 } 487 }
487 488
488 489
489 mExtensionManager->setSelectionChanged(); 490 mExtensionManager->setSelectionChanged();
490 491
491 // update the actions 492 // update the actions
492 bool selected = !uid.isEmpty(); 493 bool selected = !uid.isEmpty();
493 494
494 if ( mReadWrite ) { 495 if ( mReadWrite ) {
495 mActionCut->setEnabled( selected ); 496 mActionCut->setEnabled( selected );
496 mActionPaste->setEnabled( selected ); 497 mActionPaste->setEnabled( selected );
497 } 498 }
498 499
499 mActionCopy->setEnabled( selected ); 500 mActionCopy->setEnabled( selected );
500 mActionDelete->setEnabled( selected ); 501 mActionDelete->setEnabled( selected );
501 mActionEditAddressee->setEnabled( selected ); 502 mActionEditAddressee->setEnabled( selected );
502 mActionMail->setEnabled( selected ); 503 mActionMail->setEnabled( selected );
503 mActionMailVCard->setEnabled( selected ); 504 mActionMailVCard->setEnabled( selected );
504 //if (mActionBeam) 505 //if (mActionBeam)
505 //mActionBeam->setEnabled( selected ); 506 //mActionBeam->setEnabled( selected );
506 507
507 if (mActionBeamVCard) 508 if (mActionBeamVCard)
508 mActionBeamVCard->setEnabled( selected ); 509 mActionBeamVCard->setEnabled( selected );
509 510
510 mActionWhoAmI->setEnabled( selected ); 511 mActionWhoAmI->setEnabled( selected );
511 mActionCategories->setEnabled( selected ); 512 mActionCategories->setEnabled( selected );
512} 513}
513 514
514void KABCore::sendMail() 515void KABCore::sendMail()
515{ 516{
516 sendMail( mViewManager->selectedEmails().join( ", " ) ); 517 sendMail( mViewManager->selectedEmails().join( ", " ) );
517} 518}
518 519
519void KABCore::sendMail( const QString& emaillist ) 520void KABCore::sendMail( const QString& emaillist )
520{ 521{
521 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 522 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
522 if (emaillist.contains(",") > 0) 523 if (emaillist.contains(",") > 0)
523 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 524 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
524 else 525 else
525 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 526 ExternalAppHandler::instance()->mailToOneContact( emaillist );
526} 527}
527 528
528 529
529 530
530void KABCore::mailVCard() 531void KABCore::mailVCard()
531{ 532{
532 QStringList uids = mViewManager->selectedUids(); 533 QStringList uids = mViewManager->selectedUids();
533 if ( !uids.isEmpty() ) 534 if ( !uids.isEmpty() )
534 mailVCard( uids ); 535 mailVCard( uids );
535} 536}
536 537
537void KABCore::mailVCard( const QStringList& uids ) 538void KABCore::mailVCard( const QStringList& uids )
538{ 539{
539 QStringList urls; 540 QStringList urls;
540 541
541// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 542// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
542 543
543 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 544 QString dirName = "/tmp/" + KApplication::randomString( 8 );
544 545
545 546
546 547
547 QDir().mkdir( dirName, true ); 548 QDir().mkdir( dirName, true );
548 549
549 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 550 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
550 KABC::Addressee a = mAddressBook->findByUid( *it ); 551 KABC::Addressee a = mAddressBook->findByUid( *it );
551 552
552 if ( a.isEmpty() ) 553 if ( a.isEmpty() )
553 continue; 554 continue;
554 555
555 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 556 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
556 557
557 QString fileName = dirName + "/" + name; 558 QString fileName = dirName + "/" + name;
558 559
559 QFile outFile(fileName); 560 QFile outFile(fileName);
560 561
561 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 562 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
562 KABC::VCardConverter converter; 563 KABC::VCardConverter converter;
563 QString vcard; 564 QString vcard;
564 565
565 converter.addresseeToVCard( a, vcard ); 566 converter.addresseeToVCard( a, vcard );
566 567
567 QTextStream t( &outFile ); // use a text stream 568 QTextStream t( &outFile ); // use a text stream
568 t.setEncoding( QTextStream::UnicodeUTF8 ); 569 t.setEncoding( QTextStream::UnicodeUTF8 );
569 t << vcard; 570 t << vcard;
570 571
571 outFile.close(); 572 outFile.close();
572 573
573 urls.append( fileName ); 574 urls.append( fileName );
574 } 575 }
575 } 576 }
576 577
577 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 578 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
578 579
579 580
580/*US 581/*US
581 kapp->invokeMailer( QString::null, QString::null, QString::null, 582 kapp->invokeMailer( QString::null, QString::null, QString::null,
582 QString::null, // subject 583 QString::null, // subject
583 QString::null, // body 584 QString::null, // body
584 QString::null, 585 QString::null,
585 urls ); // attachments 586 urls ); // attachments
586*/ 587*/
587 588
588} 589}
589 590
590/** 591/**
591 Beams the "WhoAmI contact. 592 Beams the "WhoAmI contact.
592*/ 593*/
593void KABCore::beamMySelf() 594void KABCore::beamMySelf()
594{ 595{
595 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 596 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
596 if (!a.isEmpty()) 597 if (!a.isEmpty())
597 { 598 {
598 QStringList uids; 599 QStringList uids;
599 uids << a.uid(); 600 uids << a.uid();
600 601
601 beamVCard(uids); 602 beamVCard(uids);
602 } else { 603 } else {
603 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 604 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
604 605
605 606
606 } 607 }
607} 608}
608 609
609void KABCore::beamVCard() 610void KABCore::beamVCard()
610{ 611{
611 QStringList uids = mViewManager->selectedUids(); 612 QStringList uids = mViewManager->selectedUids();
612 if ( !uids.isEmpty() ) 613 if ( !uids.isEmpty() )
613 beamVCard( uids ); 614 beamVCard( uids );
614} 615}
615 616
616 617
617void KABCore::beamVCard(const QStringList& uids) 618void KABCore::beamVCard(const QStringList& uids)
618{ 619{
619/*US 620/*US
620 QString beamFilename; 621 QString beamFilename;
621 Opie::OPimContact c; 622 Opie::OPimContact c;
622 if ( actionPersonal->isOn() ) { 623 if ( actionPersonal->isOn() ) {
623 beamFilename = addressbookPersonalVCardName(); 624 beamFilename = addressbookPersonalVCardName();
624 if ( !QFile::exists( beamFilename ) ) 625 if ( !QFile::exists( beamFilename ) )
625 return; // can't beam a non-existent file 626 return; // can't beam a non-existent file
626 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 627 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
627 beamFilename ); 628 beamFilename );
628 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 629 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
629 Opie::OPimContactAccess::List allList = access->allRecords(); 630 Opie::OPimContactAccess::List allList = access->allRecords();
630 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 631 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
631 c = *it; 632 c = *it;
632 633
633 delete access; 634 delete access;
634 } else { 635 } else {
635 unlink( beamfile ); // delete if exists 636 unlink( beamfile ); // delete if exists
636 mkdir("/tmp/obex/", 0755); 637 mkdir("/tmp/obex/", 0755);
637 c = m_abView -> currentEntry(); 638 c = m_abView -> currentEntry();
638 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 639 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
639 beamfile ); 640 beamfile );
640 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 641 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
641 access->add( c ); 642 access->add( c );
642 access->save(); 643 access->save();
643 delete access; 644 delete access;
644 645
645 beamFilename = beamfile; 646 beamFilename = beamfile;
646 } 647 }
647 648
648 owarn << "Beaming: " << beamFilename << oendl; 649 owarn << "Beaming: " << beamFilename << oendl;
649*/ 650*/
650 651
651#if 0 652#if 0
652 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 653 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
653 654
654 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 655 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
655 656
656 QString name = "contact.vcf"; 657 QString name = "contact.vcf";
657 658
658 QString fileName = dirName + "/" + name; 659 QString fileName = dirName + "/" + name;
659#endif 660#endif
660 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 661 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
661 // 662 //
662 QString fileName = "/tmp/kapibeamfile.vcf"; 663 QString fileName = "/tmp/kapibeamfile.vcf";
663 664
664 665
665 //QDir().mkdir( dirName, true ); 666 //QDir().mkdir( dirName, true );
666 667
667 668
668 KABC::VCardConverter converter; 669 KABC::VCardConverter converter;
669 QString description; 670 QString description;
670 QString datastream; 671 QString datastream;
671 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 672 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
672 KABC::Addressee a = mAddressBook->findByUid( *it ); 673 KABC::Addressee a = mAddressBook->findByUid( *it );
673 674
674 if ( a.isEmpty() ) 675 if ( a.isEmpty() )
675 continue; 676 continue;
676 677
677 if (description.isEmpty()) 678 if (description.isEmpty())
678 description = a.formattedName(); 679 description = a.formattedName();
679 680
680 QString vcard; 681 QString vcard;
681 converter.addresseeToVCard( a, vcard ); 682 converter.addresseeToVCard( a, vcard );
682 int start = 0; 683 int start = 0;
683 int next; 684 int next;
684 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 685 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
685 int semi = vcard.find(";", next); 686 int semi = vcard.find(";", next);
686 int dopp = vcard.find(":", next); 687 int dopp = vcard.find(":", next);
687 int sep; 688 int sep;
688 if ( semi < dopp && semi >= 0 ) 689 if ( semi < dopp && semi >= 0 )
689 sep = semi ; 690 sep = semi ;
690 else 691 else
691 sep = dopp; 692 sep = dopp;
692 datastream +=vcard.mid( start, next - start); 693 datastream +=vcard.mid( start, next - start);
693 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 694 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
694 start = sep; 695 start = sep;
695 } 696 }
696 datastream += vcard.mid( start,vcard.length() ); 697 datastream += vcard.mid( start,vcard.length() );
697 } 698 }
698#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
699 QFile outFile(fileName); 700 QFile outFile(fileName);
700 if ( outFile.open(IO_WriteOnly) ) { 701 if ( outFile.open(IO_WriteOnly) ) {
701 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 702 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
702 QTextStream t( &outFile ); // use a text stream 703 QTextStream t( &outFile ); // use a text stream
703 t.setEncoding( QTextStream::UnicodeUTF8 ); 704 t.setEncoding( QTextStream::UnicodeUTF8 );
704 t <<datastream; 705 t <<datastream;
705 outFile.close(); 706 outFile.close();
706 Ir *ir = new Ir( this ); 707 Ir *ir = new Ir( this );
707 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 708 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
708 ir->send( fileName, description, "text/x-vCard" ); 709 ir->send( fileName, description, "text/x-vCard" );
709 } else { 710 } else {
710 qDebug("Error open temp beam file "); 711 qDebug("Error open temp beam file ");
711 return; 712 return;
712 } 713 }
713#endif 714#endif
714 715
715} 716}
716 717
717void KABCore::beamDone( Ir *ir ) 718void KABCore::beamDone( Ir *ir )
718{ 719{
719#ifndef DESKTOP_VERSION 720#ifndef DESKTOP_VERSION
720 delete ir; 721 delete ir;
721#endif 722#endif
722} 723}
723 724
724 725
725void KABCore::browse( const QString& url ) 726void KABCore::browse( const QString& url )
726{ 727{
727#ifndef KAB_EMBEDDED 728#ifndef KAB_EMBEDDED
728 kapp->invokeBrowser( url ); 729 kapp->invokeBrowser( url );
729#else //KAB_EMBEDDED 730#else //KAB_EMBEDDED
730 qDebug("KABCore::browse must be fixed"); 731 qDebug("KABCore::browse must be fixed");
731#endif //KAB_EMBEDDED 732#endif //KAB_EMBEDDED
732} 733}
733 734
734void KABCore::selectAllContacts() 735void KABCore::selectAllContacts()
735{ 736{
736 mViewManager->setSelected( QString::null, true ); 737 mViewManager->setSelected( QString::null, true );
737} 738}
738 739
739void KABCore::deleteContacts() 740void KABCore::deleteContacts()
740{ 741{
741 QStringList uidList = mViewManager->selectedUids(); 742 QStringList uidList = mViewManager->selectedUids();
742 deleteContacts( uidList ); 743 deleteContacts( uidList );
743} 744}
744 745
745void KABCore::deleteContacts( const QStringList &uids ) 746void KABCore::deleteContacts( const QStringList &uids )
746{ 747{
747 if ( uids.count() > 0 ) { 748 if ( uids.count() > 0 ) {
748 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 749 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
749 UndoStack::instance()->push( command ); 750 UndoStack::instance()->push( command );
750 RedoStack::instance()->clear(); 751 RedoStack::instance()->clear();
751 752
752 // now if we deleted anything, refresh 753 // now if we deleted anything, refresh
753 setContactSelected( QString::null ); 754 setContactSelected( QString::null );
754 setModified( true ); 755 setModified( true );
755 } 756 }
756} 757}
757 758
758void KABCore::copyContacts() 759void KABCore::copyContacts()
759{ 760{
760 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 761 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
761 762
762 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 763 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
763 764
764 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 765 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
765 766
766 QClipboard *cb = QApplication::clipboard(); 767 QClipboard *cb = QApplication::clipboard();
767 cb->setText( clipText ); 768 cb->setText( clipText );
768} 769}
769 770
770void KABCore::cutContacts() 771void KABCore::cutContacts()
771{ 772{
772 QStringList uidList = mViewManager->selectedUids(); 773 QStringList uidList = mViewManager->selectedUids();
773 774
774//US if ( uidList.size() > 0 ) { 775//US if ( uidList.size() > 0 ) {
775 if ( uidList.count() > 0 ) { 776 if ( uidList.count() > 0 ) {
776 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 777 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
777 UndoStack::instance()->push( command ); 778 UndoStack::instance()->push( command );
778 RedoStack::instance()->clear(); 779 RedoStack::instance()->clear();
779 780
780 setModified( true ); 781 setModified( true );
781 } 782 }
782} 783}
783 784
784void KABCore::pasteContacts() 785void KABCore::pasteContacts()
785{ 786{
786 QClipboard *cb = QApplication::clipboard(); 787 QClipboard *cb = QApplication::clipboard();
787 788
788 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 789 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
789 790
790 pasteContacts( list ); 791 pasteContacts( list );
791} 792}
792 793
793void KABCore::pasteContacts( KABC::Addressee::List &list ) 794void KABCore::pasteContacts( KABC::Addressee::List &list )
794{ 795{
795 KABC::Resource *resource = requestResource( this ); 796 KABC::Resource *resource = requestResource( this );
796 KABC::Addressee::List::Iterator it; 797 KABC::Addressee::List::Iterator it;
797 for ( it = list.begin(); it != list.end(); ++it ) 798 for ( it = list.begin(); it != list.end(); ++it )
798 (*it).setResource( resource ); 799 (*it).setResource( resource );
799 800
800 PwPasteCommand *command = new PwPasteCommand( this, list ); 801 PwPasteCommand *command = new PwPasteCommand( this, list );
801 UndoStack::instance()->push( command ); 802 UndoStack::instance()->push( command );
802 RedoStack::instance()->clear(); 803 RedoStack::instance()->clear();
803 804
804 setModified( true ); 805 setModified( true );
805} 806}
806 807
807void KABCore::setWhoAmI() 808void KABCore::setWhoAmI()
808{ 809{
809 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 810 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
810 811
811 if ( addrList.count() > 1 ) { 812 if ( addrList.count() > 1 ) {
812 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 813 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
813 return; 814 return;
814 } 815 }
815 816
816 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 817 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
817 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 818 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
818 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 819 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
819} 820}
820 821
821void KABCore::setCategories() 822void KABCore::setCategories()
822{ 823{
823 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 824 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
824 if ( !dlg.exec() ) 825 if ( !dlg.exec() )
825 return; 826 return;
826 827
827 bool merge = false; 828 bool merge = false;
828 QString msg = i18n( "Merge with existing categories?" ); 829 QString msg = i18n( "Merge with existing categories?" );
829 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 830 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
830 merge = true; 831 merge = true;
831 832
832 QStringList categories = dlg.selectedCategories(); 833 QStringList categories = dlg.selectedCategories();
833 834
834 QStringList uids = mViewManager->selectedUids(); 835 QStringList uids = mViewManager->selectedUids();
835 QStringList::Iterator it; 836 QStringList::Iterator it;
836 for ( it = uids.begin(); it != uids.end(); ++it ) { 837 for ( it = uids.begin(); it != uids.end(); ++it ) {
837 KABC::Addressee addr = mAddressBook->findByUid( *it ); 838 KABC::Addressee addr = mAddressBook->findByUid( *it );
838 if ( !addr.isEmpty() ) { 839 if ( !addr.isEmpty() ) {
839 if ( !merge ) 840 if ( !merge )
840 addr.setCategories( categories ); 841 addr.setCategories( categories );
841 else { 842 else {
842 QStringList addrCategories = addr.categories(); 843 QStringList addrCategories = addr.categories();
843 QStringList::Iterator catIt; 844 QStringList::Iterator catIt;
844 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 845 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
845 if ( !addrCategories.contains( *catIt ) ) 846 if ( !addrCategories.contains( *catIt ) )
846 addrCategories.append( *catIt ); 847 addrCategories.append( *catIt );
847 } 848 }
848 addr.setCategories( addrCategories ); 849 addr.setCategories( addrCategories );
849 } 850 }
850 851
851 mAddressBook->insertAddressee( addr ); 852 mAddressBook->insertAddressee( addr );
852 } 853 }
853 } 854 }
854 855
855 if ( uids.count() > 0 ) 856 if ( uids.count() > 0 )
856 setModified( true ); 857 setModified( true );
857} 858}
858 859
859void KABCore::setSearchFields( const KABC::Field::List &fields ) 860void KABCore::setSearchFields( const KABC::Field::List &fields )
860{ 861{
861 mIncSearchWidget->setFields( fields ); 862 mIncSearchWidget->setFields( fields );
862} 863}
863 864
864void KABCore::incrementalSearch( const QString& text ) 865void KABCore::incrementalSearch( const QString& text )
865{ 866{
866 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 867 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
867} 868}
868 869
869void KABCore::setModified() 870void KABCore::setModified()
870{ 871{
871 setModified( true ); 872 setModified( true );
872} 873}
873 874
874void KABCore::setModifiedWOrefresh() 875void KABCore::setModifiedWOrefresh()
875{ 876{
876 // qDebug("KABCore::setModifiedWOrefresh() "); 877 // qDebug("KABCore::setModifiedWOrefresh() ");
877 mModified = true; 878 mModified = true;
878 mActionSave->setEnabled( mModified ); 879 mActionSave->setEnabled( mModified );
879#ifdef DESKTOP_VERSION 880#ifdef DESKTOP_VERSION
880 mDetails->refreshView(); 881 mDetails->refreshView();
881#endif 882#endif
882 883
883} 884}
884void KABCore::setModified( bool modified ) 885void KABCore::setModified( bool modified )
885{ 886{
886 mModified = modified; 887 mModified = modified;
887 mActionSave->setEnabled( mModified ); 888 mActionSave->setEnabled( mModified );
888 889
889 if ( modified ) 890 if ( modified )
890 mJumpButtonBar->recreateButtons(); 891 mJumpButtonBar->recreateButtons();
891 892
892 mViewManager->refreshView(); 893 mViewManager->refreshView();
893 mDetails->refreshView(); 894 mDetails->refreshView();
894 895
895} 896}
896 897
897bool KABCore::modified() const 898bool KABCore::modified() const
898{ 899{
899 return mModified; 900 return mModified;
900} 901}
901 902
902void KABCore::contactModified( const KABC::Addressee &addr ) 903void KABCore::contactModified( const KABC::Addressee &addr )
903{ 904{
904 905
905 Command *command = 0; 906 Command *command = 0;
906 QString uid; 907 QString uid;
907 908
908 // check if it exists already 909 // check if it exists already
909 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 910 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
910 if ( origAddr.isEmpty() ) 911 if ( origAddr.isEmpty() )
911 command = new PwNewCommand( mAddressBook, addr ); 912 command = new PwNewCommand( mAddressBook, addr );
912 else { 913 else {
913 command = new PwEditCommand( mAddressBook, origAddr, addr ); 914 command = new PwEditCommand( mAddressBook, origAddr, addr );
914 uid = addr.uid(); 915 uid = addr.uid();
915 } 916 }
916 917
917 UndoStack::instance()->push( command ); 918 UndoStack::instance()->push( command );
918 RedoStack::instance()->clear(); 919 RedoStack::instance()->clear();
919 920
920 setModified( true ); 921 setModified( true );
921} 922}
922 923
923void KABCore::newContact() 924void KABCore::newContact()
924{ 925{
925 926
926 927
927 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 928 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
928 929
929 QPtrList<KRES::Resource> kresResources; 930 QPtrList<KRES::Resource> kresResources;
930 QPtrListIterator<KABC::Resource> it( kabcResources ); 931 QPtrListIterator<KABC::Resource> it( kabcResources );
931 KABC::Resource *resource; 932 KABC::Resource *resource;
932 while ( ( resource = it.current() ) != 0 ) { 933 while ( ( resource = it.current() ) != 0 ) {
933 ++it; 934 ++it;
934 if ( !resource->readOnly() ) { 935 if ( !resource->readOnly() ) {
935 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 936 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
936 if ( res ) 937 if ( res )
937 kresResources.append( res ); 938 kresResources.append( res );
938 } 939 }
939 } 940 }
940 941
941 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 942 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
942 resource = static_cast<KABC::Resource*>( res ); 943 resource = static_cast<KABC::Resource*>( res );
943 944
944 if ( resource ) { 945 if ( resource ) {
945 KABC::Addressee addr; 946 KABC::Addressee addr;
946 addr.setResource( resource ); 947 addr.setResource( resource );
947 mEditorDialog->setAddressee( addr ); 948 mEditorDialog->setAddressee( addr );
948 KApplication::execDialog ( mEditorDialog ); 949 KApplication::execDialog ( mEditorDialog );
949 950
950 } else 951 } else
951 return; 952 return;
952 953
953 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 954 // mEditorDict.insert( dialog->addressee().uid(), dialog );
954 955
955 956
956} 957}
957 958
958void KABCore::addEmail( QString aStr ) 959void KABCore::addEmail( QString aStr )
959{ 960{
960#ifndef KAB_EMBEDDED 961#ifndef KAB_EMBEDDED
961 QString fullName, email; 962 QString fullName, email;
962 963
963 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 964 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
964 965
965 // Try to lookup the addressee matching the email address 966 // Try to lookup the addressee matching the email address
966 bool found = false; 967 bool found = false;
967 QStringList emailList; 968 QStringList emailList;
968 KABC::AddressBook::Iterator it; 969 KABC::AddressBook::Iterator it;
969 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 970 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
970 emailList = (*it).emails(); 971 emailList = (*it).emails();
971 if ( emailList.contains( email ) > 0 ) { 972 if ( emailList.contains( email ) > 0 ) {
972 found = true; 973 found = true;
973 (*it).setNameFromString( fullName ); 974 (*it).setNameFromString( fullName );
974 editContact( (*it).uid() ); 975 editContact( (*it).uid() );
975 } 976 }
976 } 977 }
977 978
978 if ( !found ) { 979 if ( !found ) {
979 KABC::Addressee addr; 980 KABC::Addressee addr;
980 addr.setNameFromString( fullName ); 981 addr.setNameFromString( fullName );
981 addr.insertEmail( email, true ); 982 addr.insertEmail( email, true );
982 983
983 mAddressBook->insertAddressee( addr ); 984 mAddressBook->insertAddressee( addr );
984 mViewManager->refreshView( addr.uid() ); 985 mViewManager->refreshView( addr.uid() );
985 editContact( addr.uid() ); 986 editContact( addr.uid() );
986 } 987 }
987#else //KAB_EMBEDDED 988#else //KAB_EMBEDDED
988 qDebug("KABCore::addEmail finsih method"); 989 qDebug("KABCore::addEmail finsih method");
989#endif //KAB_EMBEDDED 990#endif //KAB_EMBEDDED
990} 991}
991 992
992void KABCore::importVCard( const KURL &url, bool showPreview ) 993void KABCore::importVCard( const KURL &url, bool showPreview )
993{ 994{
994 mXXPortManager->importVCard( url, showPreview ); 995 mXXPortManager->importVCard( url, showPreview );
995} 996}
996void KABCore::importFromOL() 997void KABCore::importFromOL()
997{ 998{
998#ifdef _WIN32_ 999#ifdef _WIN32_
999 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1000 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1000 idgl->exec(); 1001 idgl->exec();
1001 KABC::Addressee::List list = idgl->getAddressList(); 1002 KABC::Addressee::List list = idgl->getAddressList();
1002 if ( list.count() > 0 ) { 1003 if ( list.count() > 0 ) {
1003 KABC::Addressee::List listNew; 1004 KABC::Addressee::List listNew;
1004 KABC::Addressee::List listExisting; 1005 KABC::Addressee::List listExisting;
1005 KABC::Addressee::List::Iterator it; 1006 KABC::Addressee::List::Iterator it;
1006 KABC::AddressBook::Iterator iter; 1007 KABC::AddressBook::Iterator iter;
1007 for ( it = list.begin(); it != list.end(); ++it ) { 1008 for ( it = list.begin(); it != list.end(); ++it ) {
1008 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1009 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1009 listNew.append( (*it) ); 1010 listNew.append( (*it) );
1010 else 1011 else
1011 listExisting.append( (*it) ); 1012 listExisting.append( (*it) );
1012 } 1013 }
1013 if ( listExisting.count() > 0 ) 1014 if ( listExisting.count() > 0 )
1014 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1015 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1015 if ( listNew.count() > 0 ) { 1016 if ( listNew.count() > 0 ) {
1016 pasteWithNewUid = false; 1017 pasteWithNewUid = false;
1017 pasteContacts( listNew ); 1018 pasteContacts( listNew );
1018 pasteWithNewUid = true; 1019 pasteWithNewUid = true;
1019 } 1020 }
1020 } 1021 }
1021 delete idgl; 1022 delete idgl;
1022#endif 1023#endif
1023} 1024}
1024 1025
1025void KABCore::importVCard( const QString &vCard, bool showPreview ) 1026void KABCore::importVCard( const QString &vCard, bool showPreview )
1026{ 1027{
1027 mXXPortManager->importVCard( vCard, showPreview ); 1028 mXXPortManager->importVCard( vCard, showPreview );
1028} 1029}
1029 1030
1030//US added a second method without defaultparameter 1031//US added a second method without defaultparameter
1031void KABCore::editContact2() { 1032void KABCore::editContact2() {
1032 editContact( QString::null ); 1033 editContact( QString::null );
1033} 1034}
1034 1035
1035void KABCore::editContact( const QString &uid ) 1036void KABCore::editContact( const QString &uid )
1036{ 1037{
1037 1038
1038 if ( mExtensionManager->isQuickEditVisible() ) 1039 if ( mExtensionManager->isQuickEditVisible() )
1039 return; 1040 return;
1040 1041
1041 // First, locate the contact entry 1042 // First, locate the contact entry
1042 QString localUID = uid; 1043 QString localUID = uid;
1043 if ( localUID.isNull() ) { 1044 if ( localUID.isNull() ) {
1044 QStringList uidList = mViewManager->selectedUids(); 1045 QStringList uidList = mViewManager->selectedUids();
1045 if ( uidList.count() > 0 ) 1046 if ( uidList.count() > 0 )
1046 localUID = *( uidList.at( 0 ) ); 1047 localUID = *( uidList.at( 0 ) );
1047 } 1048 }
1048 1049
1049 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1050 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1050 if ( !addr.isEmpty() ) { 1051 if ( !addr.isEmpty() ) {
1051 mEditorDialog->setAddressee( addr ); 1052 mEditorDialog->setAddressee( addr );
1052 KApplication::execDialog ( mEditorDialog ); 1053 KApplication::execDialog ( mEditorDialog );
1053 } 1054 }
1054} 1055}
1055 1056
1056/** 1057/**
1057 Shows or edits the detail view for the given uid. If the uid is QString::null, 1058 Shows or edits the detail view for the given uid. If the uid is QString::null,
1058 the method will try to find a selected addressee in the view. 1059 the method will try to find a selected addressee in the view.
1059 */ 1060 */
1060void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1061void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1061{ 1062{
1062 if ( mMultipleViewsAtOnce ) 1063 if ( mMultipleViewsAtOnce )
1063 { 1064 {
1064 editContact( uid ); 1065 editContact( uid );
1065 } 1066 }
1066 else 1067 else
1067 { 1068 {
1068 setDetailsVisible( true ); 1069 setDetailsVisible( true );
1069 mActionDetails->setChecked(true); 1070 mActionDetails->setChecked(true);
1070 } 1071 }
1071 1072
1072} 1073}
1073 1074
1074void KABCore::save() 1075void KABCore::save()
1075{ 1076{
1076 if (mBlockSaveFlag) 1077 if (mBlockSaveFlag)
1077 return; 1078 return;
1078 mBlockSaveFlag = true; 1079 mBlockSaveFlag = true;
1079 if ( !mModified ) 1080 if ( !mModified )
1080 return; 1081 return;
1081 QString text = i18n( "There was an error while attempting to save\n the " 1082 QString text = i18n( "There was an error while attempting to save\n the "
1082 "address book. Please check that some \nother application is " 1083 "address book. Please check that some \nother application is "
1083 "not using it. " ); 1084 "not using it. " );
1084 statusMessage(i18n("Saving addressbook ... ")); 1085 statusMessage(i18n("Saving addressbook ... "));
1085#ifndef KAB_EMBEDDED 1086#ifndef KAB_EMBEDDED
1086 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1087 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1087 if ( !b || !b->save() ) { 1088 if ( !b || !b->save() ) {
1088 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1089 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1089 } 1090 }
1090#else //KAB_EMBEDDED 1091#else //KAB_EMBEDDED
1091 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1092 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1092 if ( !b || !b->save() ) { 1093 if ( !b || !b->save() ) {
1093 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1094 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1094 } 1095 }
1095#endif //KAB_EMBEDDED 1096#endif //KAB_EMBEDDED
1096 1097
1097 statusMessage(i18n("Addressbook saved!")); 1098 statusMessage(i18n("Addressbook saved!"));
1098 setModified( false ); 1099 setModified( false );
1099 mBlockSaveFlag = false; 1100 mBlockSaveFlag = false;
1100} 1101}
1101 1102
1102void KABCore::statusMessage(QString mess , int time ) 1103void KABCore::statusMessage(QString mess , int time )
1103{ 1104{
1104 //topLevelWidget()->setCaption( mess ); 1105 //topLevelWidget()->setCaption( mess );
1105 // pending setting timer to revome message 1106 // pending setting timer to revome message
1106} 1107}
1107void KABCore::undo() 1108void KABCore::undo()
1108{ 1109{
1109 UndoStack::instance()->undo(); 1110 UndoStack::instance()->undo();
1110 1111
1111 // Refresh the view 1112 // Refresh the view
1112 mViewManager->refreshView(); 1113 mViewManager->refreshView();
1113} 1114}
1114 1115
1115void KABCore::redo() 1116void KABCore::redo()
1116{ 1117{
1117 RedoStack::instance()->redo(); 1118 RedoStack::instance()->redo();
1118 1119
1119 // Refresh the view 1120 // Refresh the view
1120 mViewManager->refreshView(); 1121 mViewManager->refreshView();
1121} 1122}
1122 1123
1123void KABCore::setJumpButtonBarVisible( bool visible ) 1124void KABCore::setJumpButtonBarVisible( bool visible )
1124{ 1125{
1125 if (mMultipleViewsAtOnce) 1126 if (mMultipleViewsAtOnce)
1126 { 1127 {
1127 if ( visible ) 1128 if ( visible )
1128 mJumpButtonBar->show(); 1129 mJumpButtonBar->show();
1129 else 1130 else
1130 mJumpButtonBar->hide(); 1131 mJumpButtonBar->hide();
1131 } 1132 }
1132 else 1133 else
1133 { 1134 {
1134 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1135 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1135 if (mViewManager->isVisible()) 1136 if (mViewManager->isVisible())
1136 { 1137 {
1137 if ( visible ) 1138 if ( visible )
1138 mJumpButtonBar->show(); 1139 mJumpButtonBar->show();
1139 else 1140 else
1140 mJumpButtonBar->hide(); 1141 mJumpButtonBar->hide();
1141 } 1142 }
1142 else 1143 else
1143 { 1144 {
1144 mJumpButtonBar->hide(); 1145 mJumpButtonBar->hide();
1145 } 1146 }
1146 } 1147 }
1147} 1148}
1148 1149
1149 1150
1150void KABCore::setDetailsToState() 1151void KABCore::setDetailsToState()
1151{ 1152{
1152 setDetailsVisible( mActionDetails->isChecked() ); 1153 setDetailsVisible( mActionDetails->isChecked() );
1153} 1154}
1154 1155
1155 1156
1156 1157
1157void KABCore::setDetailsVisible( bool visible ) 1158void KABCore::setDetailsVisible( bool visible )
1158{ 1159{
1159 if (visible && mDetails->isHidden()) 1160 if (visible && mDetails->isHidden())
1160 { 1161 {
1161 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1162 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1162 if ( addrList.count() > 0 ) 1163 if ( addrList.count() > 0 )
1163 mDetails->setAddressee( addrList[ 0 ] ); 1164 mDetails->setAddressee( addrList[ 0 ] );
1164 } 1165 }
1165 1166
1166 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1167 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1167 // the listview and the detailview. We do that by changing the splitbar size. 1168 // the listview and the detailview. We do that by changing the splitbar size.
1168 if (mMultipleViewsAtOnce) 1169 if (mMultipleViewsAtOnce)
1169 { 1170 {
1170 if ( visible ) 1171 if ( visible )
1171 mDetails->show(); 1172 mDetails->show();
1172 else 1173 else
1173 mDetails->hide(); 1174 mDetails->hide();
1174 } 1175 }
1175 else 1176 else
1176 { 1177 {
1177 if ( visible ) { 1178 if ( visible ) {
1178 mViewManager->hide(); 1179 mViewManager->hide();
1179 mDetails->show(); 1180 mDetails->show();
1180 } 1181 }
1181 else { 1182 else {
1182 mViewManager->show(); 1183 mViewManager->show();
1183 mDetails->hide(); 1184 mDetails->hide();
1184 } 1185 }
1185 setJumpButtonBarVisible( !visible ); 1186 setJumpButtonBarVisible( !visible );
1186 } 1187 }
1187 1188
1188} 1189}
1189 1190
1190void KABCore::extensionChanged( int id ) 1191void KABCore::extensionChanged( int id )
1191{ 1192{
1192 //change the details view only for non desktop systems 1193 //change the details view only for non desktop systems
1193#ifndef DESKTOP_VERSION 1194#ifndef DESKTOP_VERSION
1194 1195
1195 if (id == 0) 1196 if (id == 0)
1196 { 1197 {
1197 //the user disabled the extension. 1198 //the user disabled the extension.
1198 1199
1199 if (mMultipleViewsAtOnce) 1200 if (mMultipleViewsAtOnce)
1200 { // enable detailsview again 1201 { // enable detailsview again
1201 setDetailsVisible( true ); 1202 setDetailsVisible( true );
1202 mActionDetails->setChecked( true ); 1203 mActionDetails->setChecked( true );
1203 } 1204 }
1204 else 1205 else
1205 { //go back to the listview 1206 { //go back to the listview
1206 setDetailsVisible( false ); 1207 setDetailsVisible( false );
1207 mActionDetails->setChecked( false ); 1208 mActionDetails->setChecked( false );
1208 mActionDetails->setEnabled(true); 1209 mActionDetails->setEnabled(true);
1209 } 1210 }
1210 1211
1211 } 1212 }
1212 else 1213 else
1213 { 1214 {
1214 //the user enabled the extension. 1215 //the user enabled the extension.
1215 setDetailsVisible( false ); 1216 setDetailsVisible( false );
1216 mActionDetails->setChecked( false ); 1217 mActionDetails->setChecked( false );
1217 1218
1218 if (!mMultipleViewsAtOnce) 1219 if (!mMultipleViewsAtOnce)
1219 { 1220 {
1220 mActionDetails->setEnabled(false); 1221 mActionDetails->setEnabled(false);
1221 } 1222 }
1222 1223
1223 mExtensionManager->setSelectionChanged(); 1224 mExtensionManager->setSelectionChanged();
1224 1225
1225 } 1226 }
1226 1227
1227#endif// DESKTOP_VERSION 1228#endif// DESKTOP_VERSION
1228 1229
1229} 1230}
1230 1231
1231 1232
1232void KABCore::extensionModified( const KABC::Addressee::List &list ) 1233void KABCore::extensionModified( const KABC::Addressee::List &list )
1233{ 1234{
1234 1235
1235 if ( list.count() != 0 ) { 1236 if ( list.count() != 0 ) {
1236 KABC::Addressee::List::ConstIterator it; 1237 KABC::Addressee::List::ConstIterator it;
1237 for ( it = list.begin(); it != list.end(); ++it ) 1238 for ( it = list.begin(); it != list.end(); ++it )
1238 mAddressBook->insertAddressee( *it ); 1239 mAddressBook->insertAddressee( *it );
1239 if ( list.count() > 1 ) 1240 if ( list.count() > 1 )
1240 setModified(); 1241 setModified();
1241 else 1242 else
1242 setModifiedWOrefresh(); 1243 setModifiedWOrefresh();
1243 } 1244 }
1244 if ( list.count() == 0 ) 1245 if ( list.count() == 0 )
1245 mViewManager->refreshView(); 1246 mViewManager->refreshView();
1246 else 1247 else
1247 mViewManager->refreshView( list[ 0 ].uid() ); 1248 mViewManager->refreshView( list[ 0 ].uid() );
1248 1249
1249 1250
1250 1251
1251} 1252}
1252 1253
1253QString KABCore::getNameByPhone( const QString &phone ) 1254QString KABCore::getNameByPhone( const QString &phone )
1254{ 1255{
1255#ifndef KAB_EMBEDDED 1256#ifndef KAB_EMBEDDED
1256 QRegExp r( "[/*/-/ ]" ); 1257 QRegExp r( "[/*/-/ ]" );
1257 QString localPhone( phone ); 1258 QString localPhone( phone );
1258 1259
1259 bool found = false; 1260 bool found = false;
1260 QString ownerName = ""; 1261 QString ownerName = "";
1261 KABC::AddressBook::Iterator iter; 1262 KABC::AddressBook::Iterator iter;
1262 KABC::PhoneNumber::List::Iterator phoneIter; 1263 KABC::PhoneNumber::List::Iterator phoneIter;
1263 KABC::PhoneNumber::List phoneList; 1264 KABC::PhoneNumber::List phoneList;
1264 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1265 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1265 phoneList = (*iter).phoneNumbers(); 1266 phoneList = (*iter).phoneNumbers();
1266 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1267 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1267 ++phoneIter) { 1268 ++phoneIter) {
1268 // Get rid of separator chars so just the numbers are compared. 1269 // Get rid of separator chars so just the numbers are compared.
1269 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1270 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1270 ownerName = (*iter).formattedName(); 1271 ownerName = (*iter).formattedName();
1271 found = true; 1272 found = true;
1272 } 1273 }
1273 } 1274 }
1274 } 1275 }
1275 1276
1276 return ownerName; 1277 return ownerName;
1277#else //KAB_EMBEDDED 1278#else //KAB_EMBEDDED
1278 qDebug("KABCore::getNameByPhone finsih method"); 1279 qDebug("KABCore::getNameByPhone finsih method");
1279 return ""; 1280 return "";
1280#endif //KAB_EMBEDDED 1281#endif //KAB_EMBEDDED
1281 1282
1282} 1283}
1283 1284
1284void KABCore::openConfigDialog() 1285void KABCore::openConfigDialog()
1285{ 1286{
1286 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1287 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1287 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1288 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1288 ConfigureDialog->addModule(kabcfg ); 1289 ConfigureDialog->addModule(kabcfg );
1289 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1290 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1290 ConfigureDialog->addModule(kdelibcfg ); 1291 ConfigureDialog->addModule(kdelibcfg );
1291 1292
1292 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1293 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1293 this, SLOT( configurationChanged() ) ); 1294 this, SLOT( configurationChanged() ) );
1294 connect( ConfigureDialog, SIGNAL( okClicked() ), 1295 connect( ConfigureDialog, SIGNAL( okClicked() ),
1295 this, SLOT( configurationChanged() ) ); 1296 this, SLOT( configurationChanged() ) );
1296 saveSettings(); 1297 saveSettings();
1297#ifndef DESKTOP_VERSION 1298#ifndef DESKTOP_VERSION
1298 ConfigureDialog->showMaximized(); 1299 ConfigureDialog->showMaximized();
1299#endif 1300#endif
1300 if ( ConfigureDialog->exec() ) 1301 if ( ConfigureDialog->exec() )
1301 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1302 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1302 delete ConfigureDialog; 1303 delete ConfigureDialog;
1303} 1304}
1304 1305
1305void KABCore::openLDAPDialog() 1306void KABCore::openLDAPDialog()
1306{ 1307{
1307#ifndef KAB_EMBEDDED 1308#ifndef KAB_EMBEDDED
1308 if ( !mLdapSearchDialog ) { 1309 if ( !mLdapSearchDialog ) {
1309 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1310 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1310 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1311 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1311 SLOT( refreshView() ) ); 1312 SLOT( refreshView() ) );
1312 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1313 SLOT( setModified() ) ); 1314 SLOT( setModified() ) );
1314 } else 1315 } else
1315 mLdapSearchDialog->restoreSettings(); 1316 mLdapSearchDialog->restoreSettings();
1316 1317
1317 if ( mLdapSearchDialog->isOK() ) 1318 if ( mLdapSearchDialog->isOK() )
1318 mLdapSearchDialog->exec(); 1319 mLdapSearchDialog->exec();
1319#else //KAB_EMBEDDED 1320#else //KAB_EMBEDDED
1320 qDebug("KABCore::openLDAPDialog() finsih method"); 1321 qDebug("KABCore::openLDAPDialog() finsih method");
1321#endif //KAB_EMBEDDED 1322#endif //KAB_EMBEDDED
1322} 1323}
1323 1324
1324void KABCore::print() 1325void KABCore::print()
1325{ 1326{
1326#ifndef KAB_EMBEDDED 1327#ifndef KAB_EMBEDDED
1327 KPrinter printer; 1328 KPrinter printer;
1328 if ( !printer.setup( this ) ) 1329 if ( !printer.setup( this ) )
1329 return; 1330 return;
1330 1331
1331 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1332 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1332 mViewManager->selectedUids(), this ); 1333 mViewManager->selectedUids(), this );
1333 1334
1334 wizard.exec(); 1335 wizard.exec();
1335#else //KAB_EMBEDDED 1336#else //KAB_EMBEDDED
1336 qDebug("KABCore::print() finsih method"); 1337 qDebug("KABCore::print() finsih method");
1337#endif //KAB_EMBEDDED 1338#endif //KAB_EMBEDDED
1338 1339
1339} 1340}
1340 1341
1341 1342
1342void KABCore::addGUIClient( KXMLGUIClient *client ) 1343void KABCore::addGUIClient( KXMLGUIClient *client )
1343{ 1344{
1344 if ( mGUIClient ) 1345 if ( mGUIClient )
1345 mGUIClient->insertChildClient( client ); 1346 mGUIClient->insertChildClient( client );
1346 else 1347 else
1347 KMessageBox::error( this, "no KXMLGUICLient"); 1348 KMessageBox::error( this, "no KXMLGUICLient");
1348} 1349}
1349 1350
1350 1351
1351void KABCore::configurationChanged() 1352void KABCore::configurationChanged()
1352{ 1353{
1353 mExtensionManager->reconfigure(); 1354 mExtensionManager->reconfigure();
1354} 1355}
1355 1356
1356void KABCore::addressBookChanged() 1357void KABCore::addressBookChanged()
1357{ 1358{
1358/*US 1359/*US
1359 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1360 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1360 while ( it.current() ) { 1361 while ( it.current() ) {
1361 if ( it.current()->dirty() ) { 1362 if ( it.current()->dirty() ) {
1362 QString text = i18n( "Data has been changed externally. Unsaved " 1363 QString text = i18n( "Data has been changed externally. Unsaved "
1363 "changes will be lost." ); 1364 "changes will be lost." );
1364 KMessageBox::information( this, text ); 1365 KMessageBox::information( this, text );
1365 } 1366 }
1366 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1367 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1367 ++it; 1368 ++it;
1368 } 1369 }
1369*/ 1370*/
1370 if (mEditorDialog) 1371 if (mEditorDialog)
1371 { 1372 {
1372 if (mEditorDialog->dirty()) 1373 if (mEditorDialog->dirty())
1373 { 1374 {
1374 QString text = i18n( "Data has been changed externally. Unsaved " 1375 QString text = i18n( "Data has been changed externally. Unsaved "
1375 "changes will be lost." ); 1376 "changes will be lost." );
1376 KMessageBox::information( this, text ); 1377 KMessageBox::information( this, text );
1377 } 1378 }
1378 QString currentuid = mEditorDialog->addressee().uid(); 1379 QString currentuid = mEditorDialog->addressee().uid();
1379 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1380 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1380 } 1381 }
1381 mViewManager->refreshView(); 1382 mViewManager->refreshView();
1382// mDetails->refreshView(); 1383// mDetails->refreshView();
1383 1384
1384 1385
1385} 1386}
1386 1387
1387AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1388AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1388 const char *name ) 1389 const char *name )
1389{ 1390{
1390 1391
1391 if ( mEditorDialog == 0 ) { 1392 if ( mEditorDialog == 0 ) {
1392 mEditorDialog = new AddresseeEditorDialog( this, parent, 1393 mEditorDialog = new AddresseeEditorDialog( this, parent,
1393 name ? name : "editorDialog" ); 1394 name ? name : "editorDialog" );
1394 1395
1395 1396
1396 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1397 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1397 SLOT( contactModified( const KABC::Addressee& ) ) ); 1398 SLOT( contactModified( const KABC::Addressee& ) ) );
1398 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1399 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1399 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1400 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1400 } 1401 }
1401 1402
1402 return mEditorDialog; 1403 return mEditorDialog;
1403} 1404}
1404 1405
1405void KABCore::slotEditorDestroyed( const QString &uid ) 1406void KABCore::slotEditorDestroyed( const QString &uid )
1406{ 1407{
1407 //mEditorDict.remove( uid ); 1408 //mEditorDict.remove( uid );
1408} 1409}
1409 1410
1410void KABCore::initGUI() 1411void KABCore::initGUI()
1411{ 1412{
1412#ifndef KAB_EMBEDDED 1413#ifndef KAB_EMBEDDED
1413 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1414 QHBoxLayout *topLayout = new QHBoxLayout( this );
1414 topLayout->setSpacing( KDialogBase::spacingHint() ); 1415 topLayout->setSpacing( KDialogBase::spacingHint() );
1415 1416
1416 mExtensionBarSplitter = new QSplitter( this ); 1417 mExtensionBarSplitter = new QSplitter( this );
1417 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1418 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1418 1419
1419 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1420 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1420 1421
1421 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1422 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1422 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1423 mIncSearchWidget = new IncSearchWidget( viewSpace );
1423 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1424 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1424 SLOT( incrementalSearch( const QString& ) ) ); 1425 SLOT( incrementalSearch( const QString& ) ) );
1425 1426
1426 mViewManager = new ViewManager( this, viewSpace ); 1427 mViewManager = new ViewManager( this, viewSpace );
1427 viewSpace->setStretchFactor( mViewManager, 1 ); 1428 viewSpace->setStretchFactor( mViewManager, 1 );
1428 1429
1429 mDetails = new ViewContainer( mDetailsSplitter ); 1430 mDetails = new ViewContainer( mDetailsSplitter );
1430 1431
1431 mJumpButtonBar = new JumpButtonBar( this, this ); 1432 mJumpButtonBar = new JumpButtonBar( this, this );
1432 1433
1433 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1434 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1434 1435
1435 topLayout->addWidget( mExtensionBarSplitter ); 1436 topLayout->addWidget( mExtensionBarSplitter );
1436 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1437 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1437 topLayout->addWidget( mJumpButtonBar ); 1438 topLayout->addWidget( mJumpButtonBar );
1438 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1439 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1439 1440
1440 mXXPortManager = new XXPortManager( this, this ); 1441 mXXPortManager = new XXPortManager( this, this );
1441 1442
1442#else //KAB_EMBEDDED 1443#else //KAB_EMBEDDED
1443 //US initialize viewMenu before settingup viewmanager. 1444 //US initialize viewMenu before settingup viewmanager.
1444 // Viewmanager needs this menu to plugin submenues. 1445 // Viewmanager needs this menu to plugin submenues.
1445 viewMenu = new QPopupMenu( this ); 1446 viewMenu = new QPopupMenu( this );
1446 settingsMenu = new QPopupMenu( this ); 1447 settingsMenu = new QPopupMenu( this );
1447 //filterMenu = new QPopupMenu( this ); 1448 //filterMenu = new QPopupMenu( this );
1448 ImportMenu = new QPopupMenu( this ); 1449 ImportMenu = new QPopupMenu( this );
1449 ExportMenu = new QPopupMenu( this ); 1450 ExportMenu = new QPopupMenu( this );
1450 syncMenu = new QPopupMenu( this ); 1451 syncMenu = new QPopupMenu( this );
1451 changeMenu= new QPopupMenu( this ); 1452 changeMenu= new QPopupMenu( this );
1452 1453
1453//US since we have no splitter for the embedded system, setup 1454//US since we have no splitter for the embedded system, setup
1454// a layout with two frames. One left and one right. 1455// a layout with two frames. One left and one right.
1455 1456
1456 QBoxLayout *topLayout; 1457 QBoxLayout *topLayout;
1457 1458
1458 // = new QHBoxLayout( this ); 1459 // = new QHBoxLayout( this );
1459// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1460// QBoxLayout *topLayout = (QBoxLayout*)layout();
1460 1461
1461// QWidget *mainBox = new QWidget( this ); 1462// QWidget *mainBox = new QWidget( this );
1462// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1463// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1463 1464
1464#ifdef DESKTOP_VERSION 1465#ifdef DESKTOP_VERSION
1465 topLayout = new QHBoxLayout( this ); 1466 topLayout = new QHBoxLayout( this );
1466 1467
1467 1468
1468 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1469 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1469 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1470 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1470 1471
1471 topLayout->addWidget(mMiniSplitter ); 1472 topLayout->addWidget(mMiniSplitter );
1472 1473
1473 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1474 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1474 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1475 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1475 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1476 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1476 mDetails = new ViewContainer( mMiniSplitter ); 1477 mDetails = new ViewContainer( mMiniSplitter );
1477 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1478 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1478#else 1479#else
1479 if ( QApplication::desktop()->width() > 480 ) { 1480 if ( QApplication::desktop()->width() > 480 ) {
1480 topLayout = new QHBoxLayout( this ); 1481 topLayout = new QHBoxLayout( this );
1481 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1482 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1482 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1483 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1483 } else { 1484 } else {
1484 1485
1485 topLayout = new QHBoxLayout( this ); 1486 topLayout = new QHBoxLayout( this );
1486 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1487 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1487 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1488 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1488 } 1489 }
1489 1490
1490 topLayout->addWidget(mMiniSplitter ); 1491 topLayout->addWidget(mMiniSplitter );
1491 mViewManager = new ViewManager( this, mMiniSplitter ); 1492 mViewManager = new ViewManager( this, mMiniSplitter );
1492 mDetails = new ViewContainer( mMiniSplitter ); 1493 mDetails = new ViewContainer( mMiniSplitter );
1493 1494
1494 1495
1495 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1496 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1496#endif 1497#endif
1497 //eh->hide(); 1498 //eh->hide();
1498 // topLayout->addWidget(mExtensionManager ); 1499 // topLayout->addWidget(mExtensionManager );
1499 1500
1500 1501
1501/*US 1502/*US
1502#ifndef KAB_NOSPLITTER 1503#ifndef KAB_NOSPLITTER
1503 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1504 QHBoxLayout *topLayout = new QHBoxLayout( this );
1504//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1505//US topLayout->setSpacing( KDialogBase::spacingHint() );
1505 topLayout->setSpacing( 10 ); 1506 topLayout->setSpacing( 10 );
1506 1507
1507 mDetailsSplitter = new QSplitter( this ); 1508 mDetailsSplitter = new QSplitter( this );
1508 1509
1509 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1510 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1510 1511
1511 mViewManager = new ViewManager( this, viewSpace ); 1512 mViewManager = new ViewManager( this, viewSpace );
1512 viewSpace->setStretchFactor( mViewManager, 1 ); 1513 viewSpace->setStretchFactor( mViewManager, 1 );
1513 1514
1514 mDetails = new ViewContainer( mDetailsSplitter ); 1515 mDetails = new ViewContainer( mDetailsSplitter );
1515 1516
1516 topLayout->addWidget( mDetailsSplitter ); 1517 topLayout->addWidget( mDetailsSplitter );
1517 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1518 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1518#else //KAB_NOSPLITTER 1519#else //KAB_NOSPLITTER
1519 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1520 QHBoxLayout *topLayout = new QHBoxLayout( this );
1520//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1521//US topLayout->setSpacing( KDialogBase::spacingHint() );
1521 topLayout->setSpacing( 10 ); 1522 topLayout->setSpacing( 10 );
1522 1523
1523// mDetailsSplitter = new QSplitter( this ); 1524// mDetailsSplitter = new QSplitter( this );
1524 1525
1525 QVBox *viewSpace = new QVBox( this ); 1526 QVBox *viewSpace = new QVBox( this );
1526 1527
1527 mViewManager = new ViewManager( this, viewSpace ); 1528 mViewManager = new ViewManager( this, viewSpace );
1528 viewSpace->setStretchFactor( mViewManager, 1 ); 1529 viewSpace->setStretchFactor( mViewManager, 1 );
1529 1530
1530 mDetails = new ViewContainer( this ); 1531 mDetails = new ViewContainer( this );
1531 1532
1532 topLayout->addWidget( viewSpace ); 1533 topLayout->addWidget( viewSpace );
1533// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1534// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1534 topLayout->addWidget( mDetails ); 1535 topLayout->addWidget( mDetails );
1535#endif //KAB_NOSPLITTER 1536#endif //KAB_NOSPLITTER
1536*/ 1537*/
1537 1538
1538 1539
1539#endif //KAB_EMBEDDED 1540#endif //KAB_EMBEDDED
1540 initActions(); 1541 initActions();
1541 1542
1542#ifdef KAB_EMBEDDED 1543#ifdef KAB_EMBEDDED
1543 addActionsManually(); 1544 addActionsManually();
1544 //US make sure the export and import menues are initialized before creating the xxPortManager. 1545 //US make sure the export and import menues are initialized before creating the xxPortManager.
1545 mXXPortManager = new XXPortManager( this, this ); 1546 mXXPortManager = new XXPortManager( this, this );
1546 1547
1547 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1548 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1548 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1549 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1549 // mActionQuit->plug ( mMainWindow->toolBar()); 1550 // mActionQuit->plug ( mMainWindow->toolBar());
1550 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1551 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1551 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1552 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1552 // mIncSearchWidget->hide(); 1553 // mIncSearchWidget->hide();
1553 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1554 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1554 SLOT( incrementalSearch( const QString& ) ) ); 1555 SLOT( incrementalSearch( const QString& ) ) );
1555 1556
1556 1557
1557 mJumpButtonBar = new JumpButtonBar( this, this ); 1558 mJumpButtonBar = new JumpButtonBar( this, this );
1558 1559
1559 topLayout->addWidget( mJumpButtonBar ); 1560 topLayout->addWidget( mJumpButtonBar );
1560//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1561//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1561 1562
1562// mMainWindow->getIconToolBar()->raise(); 1563// mMainWindow->getIconToolBar()->raise();
1563 1564
1564#endif //KAB_EMBEDDED 1565#endif //KAB_EMBEDDED
1565 1566
1566} 1567}
1567void KABCore::initActions() 1568void KABCore::initActions()
1568{ 1569{
1569//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1570//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1570 1571
1571#ifndef KAB_EMBEDDED 1572#ifndef KAB_EMBEDDED
1572 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1573 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1573 SLOT( clipboardDataChanged() ) ); 1574 SLOT( clipboardDataChanged() ) );
1574#endif //KAB_EMBEDDED 1575#endif //KAB_EMBEDDED
1575 1576
1576 // file menu 1577 // file menu
1577 if ( mIsPart ) { 1578 if ( mIsPart ) {
1578 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1579 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1579 SLOT( sendMail() ), actionCollection(), 1580 SLOT( sendMail() ), actionCollection(),
1580 "kaddressbook_mail" ); 1581 "kaddressbook_mail" );
1581 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1582 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1582 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1583 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1583 1584
1584 } else { 1585 } else {
1585 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1586 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1586 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1587 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1587 } 1588 }
1588 1589
1589 1590
1590 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1591 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1591 SLOT( save() ), actionCollection(), "file_sync" ); 1592 SLOT( save() ), actionCollection(), "file_sync" );
1592 1593
1593 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1594 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1594 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1595 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1595 1596
1596 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1597 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1597 this, SLOT( mailVCard() ), 1598 this, SLOT( mailVCard() ),
1598 actionCollection(), "file_mail_vcard"); 1599 actionCollection(), "file_mail_vcard");
1599 1600
1600 mActionBeamVCard = 0; 1601 mActionBeamVCard = 0;
1601 mActionBeam = 0; 1602 mActionBeam = 0;
1602 1603
1603#ifndef DESKTOP_VERSION 1604#ifndef DESKTOP_VERSION
1604 if ( Ir::supported() ) { 1605 if ( Ir::supported() ) {
1605 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1606 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1606 SLOT( beamVCard() ), actionCollection(), 1607 SLOT( beamVCard() ), actionCollection(),
1607 "kaddressbook_beam_vcard" ); 1608 "kaddressbook_beam_vcard" );
1608 1609
1609 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1610 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1610 SLOT( beamMySelf() ), actionCollection(), 1611 SLOT( beamMySelf() ), actionCollection(),
1611 "kaddressbook_beam_myself" ); 1612 "kaddressbook_beam_myself" );
1612 } 1613 }
1613#endif 1614#endif
1614 1615
1615 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1616 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1616 this, SLOT( editContact2() ), 1617 this, SLOT( editContact2() ),
1617 actionCollection(), "file_properties" ); 1618 actionCollection(), "file_properties" );
1618 1619
1619#ifdef KAB_EMBEDDED 1620#ifdef KAB_EMBEDDED
1620 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1621 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1621 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1622 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1622 mMainWindow, SLOT( exit() ), 1623 mMainWindow, SLOT( exit() ),
1623 actionCollection(), "quit" ); 1624 actionCollection(), "quit" );
1624#endif //KAB_EMBEDDED 1625#endif //KAB_EMBEDDED
1625 1626
1626 // edit menu 1627 // edit menu
1627 if ( mIsPart ) { 1628 if ( mIsPart ) {
1628 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1629 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1629 SLOT( copyContacts() ), actionCollection(), 1630 SLOT( copyContacts() ), actionCollection(),
1630 "kaddressbook_copy" ); 1631 "kaddressbook_copy" );
1631 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1632 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1632 SLOT( cutContacts() ), actionCollection(), 1633 SLOT( cutContacts() ), actionCollection(),
1633 "kaddressbook_cut" ); 1634 "kaddressbook_cut" );
1634 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1635 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1635 SLOT( pasteContacts() ), actionCollection(), 1636 SLOT( pasteContacts() ), actionCollection(),
1636 "kaddressbook_paste" ); 1637 "kaddressbook_paste" );
1637 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1638 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1638 SLOT( selectAllContacts() ), actionCollection(), 1639 SLOT( selectAllContacts() ), actionCollection(),
1639 "kaddressbook_select_all" ); 1640 "kaddressbook_select_all" );
1640 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1641 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1641 SLOT( undo() ), actionCollection(), 1642 SLOT( undo() ), actionCollection(),
1642 "kaddressbook_undo" ); 1643 "kaddressbook_undo" );
1643 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1644 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1644 this, SLOT( redo() ), actionCollection(), 1645 this, SLOT( redo() ), actionCollection(),
1645 "kaddressbook_redo" ); 1646 "kaddressbook_redo" );
1646 } else { 1647 } else {
1647 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1648 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1648 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1649 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1649 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1650 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1650 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1651 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1651 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1652 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1652 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1653 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1653 } 1654 }
1654 1655
1655 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1656 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1656 Key_Delete, this, SLOT( deleteContacts() ), 1657 Key_Delete, this, SLOT( deleteContacts() ),
1657 actionCollection(), "edit_delete" ); 1658 actionCollection(), "edit_delete" );
1658 1659
1659 mActionUndo->setEnabled( false ); 1660 mActionUndo->setEnabled( false );
1660 mActionRedo->setEnabled( false ); 1661 mActionRedo->setEnabled( false );
1661 1662
1662 // settings menu 1663 // settings menu
1663#ifdef KAB_EMBEDDED 1664#ifdef KAB_EMBEDDED
1664//US special menuentry to configure the addressbook resources. On KDE 1665//US special menuentry to configure the addressbook resources. On KDE
1665// you do that through the control center !!! 1666// you do that through the control center !!!
1666 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1667 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1667 SLOT( configureResources() ), actionCollection(), 1668 SLOT( configureResources() ), actionCollection(),
1668 "kaddressbook_configure_resources" ); 1669 "kaddressbook_configure_resources" );
1669#endif //KAB_EMBEDDED 1670#endif //KAB_EMBEDDED
1670 1671
1671 if ( mIsPart ) { 1672 if ( mIsPart ) {
1672 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1673 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1673 SLOT( openConfigDialog() ), actionCollection(), 1674 SLOT( openConfigDialog() ), actionCollection(),
1674 "kaddressbook_configure" ); 1675 "kaddressbook_configure" );
1675 1676
1676 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1677 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1677 this, SLOT( configureKeyBindings() ), actionCollection(), 1678 this, SLOT( configureKeyBindings() ), actionCollection(),
1678 "kaddressbook_configure_shortcuts" ); 1679 "kaddressbook_configure_shortcuts" );
1679#ifdef KAB_EMBEDDED 1680#ifdef KAB_EMBEDDED
1680 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1681 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1681 mActionConfigureToolbars->setEnabled( false ); 1682 mActionConfigureToolbars->setEnabled( false );
1682#endif //KAB_EMBEDDED 1683#endif //KAB_EMBEDDED
1683 1684
1684 } else { 1685 } else {
1685 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1686 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1686 1687
1687 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1688 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1688 } 1689 }
1689 1690
1690 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1691 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1691 actionCollection(), "options_show_jump_bar" ); 1692 actionCollection(), "options_show_jump_bar" );
1692 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1693 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1693 1694
1694 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 1695 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1695 actionCollection(), "options_show_details" ); 1696 actionCollection(), "options_show_details" );
1696 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1697 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1697 1698
1698 // misc 1699 // misc
1699 // only enable LDAP lookup if we can handle the protocol 1700 // only enable LDAP lookup if we can handle the protocol
1700#ifndef KAB_EMBEDDED 1701#ifndef KAB_EMBEDDED
1701 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1702 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1702 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1703 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1703 this, SLOT( openLDAPDialog() ), actionCollection(), 1704 this, SLOT( openLDAPDialog() ), actionCollection(),
1704 "ldap_lookup" ); 1705 "ldap_lookup" );
1705 } 1706 }
1706#else //KAB_EMBEDDED 1707#else //KAB_EMBEDDED
1707 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1708 //qDebug("KABCore::initActions() LDAP has to be implemented");
1708#endif //KAB_EMBEDDED 1709#endif //KAB_EMBEDDED
1709 1710
1710 1711
1711 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1712 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1712 SLOT( setWhoAmI() ), actionCollection(), 1713 SLOT( setWhoAmI() ), actionCollection(),
1713 "set_personal" ); 1714 "set_personal" );
1714 1715
1715 1716
1716 1717
1717 1718
1718 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1719 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1719 SLOT( setCategories() ), actionCollection(), 1720 SLOT( setCategories() ), actionCollection(),
1720 "edit_set_categories" ); 1721 "edit_set_categories" );
1721 1722
1722 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1723 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1723 SLOT( removeVoice() ), actionCollection(), 1724 SLOT( removeVoice() ), actionCollection(),
1724 "remove_voice" ); 1725 "remove_voice" );
1725 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 1726 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
1726 SLOT( importFromOL() ), actionCollection(), 1727 SLOT( importFromOL() ), actionCollection(),
1727 "import_OL" ); 1728 "import_OL" );
1728#ifdef KAB_EMBEDDED 1729#ifdef KAB_EMBEDDED
1729 mActionLicence = new KAction( i18n( "Licence" ), 0, 1730 mActionLicence = new KAction( i18n( "Licence" ), 0,
1730 this, SLOT( showLicence() ), actionCollection(), 1731 this, SLOT( showLicence() ), actionCollection(),
1731 "licence_about_data" ); 1732 "licence_about_data" );
1732 mActionFaq = new KAction( i18n( "Faq" ), 0, 1733 mActionFaq = new KAction( i18n( "Faq" ), 0,
1733 this, SLOT( faq() ), actionCollection(), 1734 this, SLOT( faq() ), actionCollection(),
1734 "faq_about_data" ); 1735 "faq_about_data" );
1735 1736
1736 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1737 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1737 this, SLOT( createAboutData() ), actionCollection(), 1738 this, SLOT( createAboutData() ), actionCollection(),
1738 "kaddressbook_about_data" ); 1739 "kaddressbook_about_data" );
1739#endif //KAB_EMBEDDED 1740#endif //KAB_EMBEDDED
1740 1741
1741 clipboardDataChanged(); 1742 clipboardDataChanged();
1742 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1743 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1743 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1744 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1744} 1745}
1745 1746
1746//US we need this function, to plug all actions into the correct menues. 1747//US we need this function, to plug all actions into the correct menues.
1747// KDE uses a XML format to plug the actions, but we work her without this overhead. 1748// KDE uses a XML format to plug the actions, but we work her without this overhead.
1748void KABCore::addActionsManually() 1749void KABCore::addActionsManually()
1749{ 1750{
1750//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1751//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1751 1752
1752#ifdef KAB_EMBEDDED 1753#ifdef KAB_EMBEDDED
1753 QPopupMenu *fileMenu = new QPopupMenu( this ); 1754 QPopupMenu *fileMenu = new QPopupMenu( this );
1754 QPopupMenu *editMenu = new QPopupMenu( this ); 1755 QPopupMenu *editMenu = new QPopupMenu( this );
1755 QPopupMenu *helpMenu = new QPopupMenu( this ); 1756 QPopupMenu *helpMenu = new QPopupMenu( this );
1756 1757
1757 KToolBar* tb = mMainWindow->toolBar(); 1758 KToolBar* tb = mMainWindow->toolBar();
1758 1759
1759#ifdef DESKTOP_VERSION 1760#ifdef DESKTOP_VERSION
1760 QMenuBar* mb = mMainWindow->menuBar(); 1761 QMenuBar* mb = mMainWindow->menuBar();
1761 1762
1762 //US setup menubar. 1763 //US setup menubar.
1763 //Disable the following block if you do not want to have a menubar. 1764 //Disable the following block if you do not want to have a menubar.
1764 mb->insertItem( "&File", fileMenu ); 1765 mb->insertItem( "&File", fileMenu );
1765 mb->insertItem( "&Edit", editMenu ); 1766 mb->insertItem( "&Edit", editMenu );
1766 mb->insertItem( "&View", viewMenu ); 1767 mb->insertItem( "&View", viewMenu );
1767 mb->insertItem( "&Settings", settingsMenu ); 1768 mb->insertItem( "&Settings", settingsMenu );
1768 mb->insertItem( i18n("Synchronize"), syncMenu ); 1769 mb->insertItem( i18n("Synchronize"), syncMenu );
1769 mb->insertItem( "&Change selected", changeMenu ); 1770 mb->insertItem( "&Change selected", changeMenu );
1770 mb->insertItem( "&Help", helpMenu ); 1771 mb->insertItem( "&Help", helpMenu );
1771 mIncSearchWidget = new IncSearchWidget( tb ); 1772 mIncSearchWidget = new IncSearchWidget( tb );
1772 // tb->insertWidget(-1, 0, mIncSearchWidget); 1773 // tb->insertWidget(-1, 0, mIncSearchWidget);
1773 1774
1774#else 1775#else
1775 //US setup toolbar 1776 //US setup toolbar
1776 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 1777 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
1777 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1778 QPopupMenu *popupBarTB = new QPopupMenu( this );
1778 menuBarTB->insertItem( "ME", popupBarTB); 1779 menuBarTB->insertItem( "ME", popupBarTB);
1779 tb->insertWidget(-1, 0, menuBarTB); 1780 tb->insertWidget(-1, 0, menuBarTB);
1780 mIncSearchWidget = new IncSearchWidget( tb ); 1781 mIncSearchWidget = new IncSearchWidget( tb );
1781 1782
1782 tb->enableMoving(false); 1783 tb->enableMoving(false);
1783 popupBarTB->insertItem( "&File", fileMenu ); 1784 popupBarTB->insertItem( "&File", fileMenu );
1784 popupBarTB->insertItem( "&Edit", editMenu ); 1785 popupBarTB->insertItem( "&Edit", editMenu );
1785 popupBarTB->insertItem( "&View", viewMenu ); 1786 popupBarTB->insertItem( "&View", viewMenu );
1786 popupBarTB->insertItem( "&Settings", settingsMenu ); 1787 popupBarTB->insertItem( "&Settings", settingsMenu );
1787 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 1788 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
1788 mViewManager->getFilterAction()->plug ( popupBarTB); 1789 mViewManager->getFilterAction()->plug ( popupBarTB);
1789 popupBarTB->insertItem( "&Change selected", changeMenu ); 1790 popupBarTB->insertItem( "&Change selected", changeMenu );
1790 popupBarTB->insertItem( "&Help", helpMenu ); 1791 popupBarTB->insertItem( "&Help", helpMenu );
1791 if (QApplication::desktop()->width() > 320 ) { 1792 if (QApplication::desktop()->width() > 320 ) {
1792 // mViewManager->getFilterAction()->plug ( tb); 1793 // mViewManager->getFilterAction()->plug ( tb);
1793 } 1794 }
1794#endif 1795#endif
1795 // mActionQuit->plug ( mMainWindow->toolBar()); 1796 // mActionQuit->plug ( mMainWindow->toolBar());
1796 1797
1797 1798
1798 1799
1799 //US Now connect the actions with the menue entries. 1800 //US Now connect the actions with the menue entries.
1800 mActionPrint->plug( fileMenu ); 1801 mActionPrint->plug( fileMenu );
1801 mActionMail->plug( fileMenu ); 1802 mActionMail->plug( fileMenu );
1802 fileMenu->insertSeparator(); 1803 fileMenu->insertSeparator();
1803 1804
1804 mActionNewContact->plug( fileMenu ); 1805 mActionNewContact->plug( fileMenu );
1805 mActionNewContact->plug( tb ); 1806 mActionNewContact->plug( tb );
1806 1807
1807 mActionEditAddressee->plug( fileMenu ); 1808 mActionEditAddressee->plug( fileMenu );
1808 if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 1809 if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
1809 (!KABPrefs::instance()->mMultipleViewsAtOnce )) 1810 (!KABPrefs::instance()->mMultipleViewsAtOnce ))
1810 mActionEditAddressee->plug( tb ); 1811 mActionEditAddressee->plug( tb );
1811 1812
1812 fileMenu->insertSeparator(); 1813 fileMenu->insertSeparator();
1813 mActionSave->plug( fileMenu ); 1814 mActionSave->plug( fileMenu );
1814 fileMenu->insertItem( "&Import", ImportMenu ); 1815 fileMenu->insertItem( "&Import", ImportMenu );
1815 fileMenu->insertItem( "&Export", ExportMenu ); 1816 fileMenu->insertItem( "&Export", ExportMenu );
1816 fileMenu->insertSeparator(); 1817 fileMenu->insertSeparator();
1817 mActionMailVCard->plug( fileMenu ); 1818 mActionMailVCard->plug( fileMenu );
1818#ifndef DESKTOP_VERSION 1819#ifndef DESKTOP_VERSION
1819 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1820 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1820 if ( Ir::supported() ) mActionBeam->plug(fileMenu ); 1821 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1821#endif 1822#endif
1822 fileMenu->insertSeparator(); 1823 fileMenu->insertSeparator();
1823 mActionQuit->plug( fileMenu ); 1824 mActionQuit->plug( fileMenu );
1824#ifdef _WIN32_ 1825#ifdef _WIN32_
1825 mActionImportOL->plug( ImportMenu ); 1826 mActionImportOL->plug( ImportMenu );
1826#endif 1827#endif
1827 // edit menu 1828 // edit menu
1828 mActionUndo->plug( editMenu ); 1829 mActionUndo->plug( editMenu );
1829 mActionRedo->plug( editMenu ); 1830 mActionRedo->plug( editMenu );
1830 editMenu->insertSeparator(); 1831 editMenu->insertSeparator();
1831 mActionCut->plug( editMenu ); 1832 mActionCut->plug( editMenu );
1832 mActionCopy->plug( editMenu ); 1833 mActionCopy->plug( editMenu );
1833 mActionPaste->plug( editMenu ); 1834 mActionPaste->plug( editMenu );
1834 mActionDelete->plug( editMenu ); 1835 mActionDelete->plug( editMenu );
1835 editMenu->insertSeparator(); 1836 editMenu->insertSeparator();
1836 mActionSelectAll->plug( editMenu ); 1837 mActionSelectAll->plug( editMenu );
1837 1838
1838 mActionRemoveVoice->plug( changeMenu ); 1839 mActionRemoveVoice->plug( changeMenu );
1839 // settings menu 1840 // settings menu
1840//US special menuentry to configure the addressbook resources. On KDE 1841//US special menuentry to configure the addressbook resources. On KDE
1841// you do that through the control center !!! 1842// you do that through the control center !!!
1842 mActionConfigResources->plug( settingsMenu ); 1843 mActionConfigResources->plug( settingsMenu );
1843 settingsMenu->insertSeparator(); 1844 settingsMenu->insertSeparator();
1844 1845
1845 mActionConfigKAddressbook->plug( settingsMenu ); 1846 mActionConfigKAddressbook->plug( settingsMenu );
1846 1847
1847 if ( mIsPart ) { 1848 if ( mIsPart ) {
1848 mActionConfigShortcuts->plug( settingsMenu ); 1849 mActionConfigShortcuts->plug( settingsMenu );
1849 mActionConfigureToolbars->plug( settingsMenu ); 1850 mActionConfigureToolbars->plug( settingsMenu );
1850 1851
1851 } else { 1852 } else {
1852 mActionKeyBindings->plug( settingsMenu ); 1853 mActionKeyBindings->plug( settingsMenu );
1853 } 1854 }
1854 1855
1855 settingsMenu->insertSeparator(); 1856 settingsMenu->insertSeparator();
1856 1857
1857 mActionJumpBar->plug( settingsMenu ); 1858 mActionJumpBar->plug( settingsMenu );
1858 mActionDetails->plug( settingsMenu ); 1859 mActionDetails->plug( settingsMenu );
1859 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 1860 if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
1860 mActionDetails->plug( tb ); 1861 mActionDetails->plug( tb );
1861 settingsMenu->insertSeparator(); 1862 settingsMenu->insertSeparator();
1862 1863
1863 mActionWhoAmI->plug( settingsMenu ); 1864 mActionWhoAmI->plug( settingsMenu );
1864 mActionCategories->plug( settingsMenu ); 1865 mActionCategories->plug( settingsMenu );
1865 1866
1866 mActionLicence->plug( helpMenu ); 1867 mActionLicence->plug( helpMenu );
1867 mActionFaq->plug( helpMenu ); 1868 mActionFaq->plug( helpMenu );
1868 mActionAboutKAddressbook->plug( helpMenu ); 1869 mActionAboutKAddressbook->plug( helpMenu );
1869 1870
1870 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 1871 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
1871 1872
1872 mActionSave->plug( tb ); 1873 mActionSave->plug( tb );
1873 mViewManager->getFilterAction()->plug ( tb); 1874 mViewManager->getFilterAction()->plug ( tb);
1874 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) { 1875 if (KGlobal::getDesktopSize() == KGlobal::Desktop ) {
1875 mActionUndo->plug( tb ); 1876 mActionUndo->plug( tb );
1876 mActionDelete->plug( tb ); 1877 mActionDelete->plug( tb );
1877 mActionRedo->plug( tb ); 1878 mActionRedo->plug( tb );
1878 } 1879 }
1879 } 1880 }
1880 //mActionQuit->plug ( tb ); 1881 //mActionQuit->plug ( tb );
1881 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1882 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1882 1883
1883 //US link the searchwidget first to this. 1884 //US link the searchwidget first to this.
1884 // The real linkage to the toolbar happens later. 1885 // The real linkage to the toolbar happens later.
1885//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1886//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1886//US tb->insertItem( mIncSearchWidget ); 1887//US tb->insertItem( mIncSearchWidget );
1887/*US 1888/*US
1888 mIncSearchWidget = new IncSearchWidget( tb ); 1889 mIncSearchWidget = new IncSearchWidget( tb );
1889 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1890 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1890 SLOT( incrementalSearch( const QString& ) ) ); 1891 SLOT( incrementalSearch( const QString& ) ) );
1891 1892
1892 mJumpButtonBar = new JumpButtonBar( this, this ); 1893 mJumpButtonBar = new JumpButtonBar( this, this );
1893 1894
1894//US topLayout->addWidget( mJumpButtonBar ); 1895//US topLayout->addWidget( mJumpButtonBar );
1895 this->layout()->add( mJumpButtonBar ); 1896 this->layout()->add( mJumpButtonBar );
1896*/ 1897*/
1897 1898
1898#endif //KAB_EMBEDDED 1899#endif //KAB_EMBEDDED
1899 1900
1900 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 1901 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
1901 fillSyncMenu(); 1902 fillSyncMenu();
1902 1903
1903} 1904}
1904void KABCore::showLicence() 1905void KABCore::showLicence()
1905{ 1906{
1906 KApplication::showLicence(); 1907 KApplication::showLicence();
1907} 1908}
1908void KABCore::removeVoice() 1909void KABCore::removeVoice()
1909{ 1910{
1910 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 ) 1911 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 )
1911 return; 1912 return;
1912 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1913 KABC::Addressee::List list = mViewManager->selectedAddressees();
1913 KABC::Addressee::List::Iterator it; 1914 KABC::Addressee::List::Iterator it;
1914 for ( it = list.begin(); it != list.end(); ++it ) { 1915 for ( it = list.begin(); it != list.end(); ++it ) {
1915 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1916 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1916 PhoneNumber::List::Iterator phoneIt; 1917 PhoneNumber::List::Iterator phoneIt;
1917 bool found = false; 1918 bool found = false;
1918 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1919 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1919 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1920 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1920 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1921 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1921 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1922 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1922 (*it).insertPhoneNumber( (*phoneIt) ); 1923 (*it).insertPhoneNumber( (*phoneIt) );
1923 found = true; 1924 found = true;
1924 } 1925 }
1925 } 1926 }
1926 1927
1927 } 1928 }
1928 if ( found ) 1929 if ( found )
1929 contactModified((*it) ); 1930 contactModified((*it) );
1930 } 1931 }
1931} 1932}
1932 1933
1933 1934
1934 1935
1935void KABCore::clipboardDataChanged() 1936void KABCore::clipboardDataChanged()
1936{ 1937{
1937 1938
1938 if ( mReadWrite ) 1939 if ( mReadWrite )
1939 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1940 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1940 1941
1941} 1942}
1942 1943
1943void KABCore::updateActionMenu() 1944void KABCore::updateActionMenu()
1944{ 1945{
1945 UndoStack *undo = UndoStack::instance(); 1946 UndoStack *undo = UndoStack::instance();
1946 RedoStack *redo = RedoStack::instance(); 1947 RedoStack *redo = RedoStack::instance();
1947 1948
1948 if ( undo->isEmpty() ) 1949 if ( undo->isEmpty() )
1949 mActionUndo->setText( i18n( "Undo" ) ); 1950 mActionUndo->setText( i18n( "Undo" ) );
1950 else 1951 else
1951 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1952 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1952 1953
1953 mActionUndo->setEnabled( !undo->isEmpty() ); 1954 mActionUndo->setEnabled( !undo->isEmpty() );
1954 1955
1955 if ( !redo->top() ) 1956 if ( !redo->top() )
1956 mActionRedo->setText( i18n( "Redo" ) ); 1957 mActionRedo->setText( i18n( "Redo" ) );
1957 else 1958 else
1958 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1959 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1959 1960
1960 mActionRedo->setEnabled( !redo->isEmpty() ); 1961 mActionRedo->setEnabled( !redo->isEmpty() );
1961} 1962}
1962 1963
1963void KABCore::configureKeyBindings() 1964void KABCore::configureKeyBindings()
1964{ 1965{
1965#ifndef KAB_EMBEDDED 1966#ifndef KAB_EMBEDDED
1966 KKeyDialog::configure( actionCollection(), true ); 1967 KKeyDialog::configure( actionCollection(), true );
1967#else //KAB_EMBEDDED 1968#else //KAB_EMBEDDED
1968 qDebug("KABCore::configureKeyBindings() not implemented"); 1969 qDebug("KABCore::configureKeyBindings() not implemented");
1969#endif //KAB_EMBEDDED 1970#endif //KAB_EMBEDDED
1970} 1971}
1971 1972
1972#ifdef KAB_EMBEDDED 1973#ifdef KAB_EMBEDDED
1973void KABCore::configureResources() 1974void KABCore::configureResources()
1974{ 1975{
1975 KRES::KCMKResources dlg( this, "" , 0 ); 1976 KRES::KCMKResources dlg( this, "" , 0 );
1976 1977
1977 if ( !dlg.exec() ) 1978 if ( !dlg.exec() )
1978 return; 1979 return;
1979 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1980 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1980} 1981}
1981#endif //KAB_EMBEDDED 1982#endif //KAB_EMBEDDED
1982 1983
1983 1984
1984/* this method will be called through the QCop interface from Ko/Pi to select addresses 1985/* this method will be called through the QCop interface from Ko/Pi to select addresses
1985 * for the attendees list of an event. 1986 * for the attendees list of an event.
1986 */ 1987 */
1987void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 1988void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
1988{ 1989{
1989 QStringList nameList; 1990 QStringList nameList;
1990 QStringList emailList; 1991 QStringList emailList;
1991 QStringList uidList; 1992 QStringList uidList;
1992 1993
1993 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 1994 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
1994 uint i=0; 1995 uint i=0;
1995 for (i=0; i < list.count(); i++) 1996 for (i=0; i < list.count(); i++)
1996 { 1997 {
1997 nameList.append(list[i].realName()); 1998 nameList.append(list[i].realName());
1998 emailList.append(list[i].preferredEmail()); 1999 emailList.append(list[i].preferredEmail());
1999 uidList.append(list[i].uid()); 2000 uidList.append(list[i].uid());
2000 } 2001 }
2001 2002
2002 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2003 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2003 2004
2004} 2005}
2005 2006
2006/* this method will be called through the QCop interface from other apps to show details of a contact. 2007/* this method will be called through the QCop interface from other apps to show details of a contact.
2007 */ 2008 */
2008void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2009void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2009{ 2010{
2010 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2011 qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2011 2012
2012 QString foundUid = QString::null; 2013 QString foundUid = QString::null;
2013 if ( ! uid.isEmpty() ) { 2014 if ( ! uid.isEmpty() ) {
2014 Addressee adrr = mAddressBook->findByUid( uid ); 2015 Addressee adrr = mAddressBook->findByUid( uid );
2015 if ( !adrr.isEmpty() ) { 2016 if ( !adrr.isEmpty() ) {
2016 foundUid = uid; 2017 foundUid = uid;
2017 } 2018 }
2018 if ( email == "sendbacklist" ) { 2019 if ( email == "sendbacklist" ) {
2019 //qDebug("ssssssssssssssssssssssend "); 2020 //qDebug("ssssssssssssssssssssssend ");
2020 QStringList nameList; 2021 QStringList nameList;
2021 QStringList emailList; 2022 QStringList emailList;
2022 QStringList uidList; 2023 QStringList uidList;
2023 nameList.append(adrr.realName()); 2024 nameList.append(adrr.realName());
2024 emailList = adrr.emails(); 2025 emailList = adrr.emails();
2025 uidList.append( adrr.preferredEmail()); 2026 uidList.append( adrr.preferredEmail());
2026 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2027 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2027 return; 2028 return;
2028 } 2029 }
2029 2030
2030 } 2031 }
2031 2032
2032 if ( email == "sendbacklist" ) 2033 if ( email == "sendbacklist" )
2033 return; 2034 return;
2034 if (foundUid.isEmpty()) 2035 if (foundUid.isEmpty())
2035 { 2036 {
2036 //find the uid of the person first 2037 //find the uid of the person first
2037 Addressee::List namelist; 2038 Addressee::List namelist;
2038 Addressee::List emaillist; 2039 Addressee::List emaillist;
2039 2040
2040 if (!name.isEmpty()) 2041 if (!name.isEmpty())
2041 namelist = mAddressBook->findByName( name ); 2042 namelist = mAddressBook->findByName( name );
2042 2043
2043 if (!email.isEmpty()) 2044 if (!email.isEmpty())
2044 emaillist = mAddressBook->findByEmail( email ); 2045 emaillist = mAddressBook->findByEmail( email );
2045 qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2046 qDebug("count %d %d ", namelist.count(),emaillist.count() );
2046 //check if we have a match in Namelist and Emaillist 2047 //check if we have a match in Namelist and Emaillist
2047 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2048 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2048 foundUid = emaillist[0].uid(); 2049 foundUid = emaillist[0].uid();
2049 } 2050 }
2050 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2051 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2051 foundUid = namelist[0].uid(); 2052 foundUid = namelist[0].uid();
2052 else 2053 else
2053 { 2054 {
2054 for (int i = 0; i < namelist.count(); i++) 2055 for (int i = 0; i < namelist.count(); i++)
2055 { 2056 {
2056 for (int j = 0; j < emaillist.count(); j++) 2057 for (int j = 0; j < emaillist.count(); j++)
2057 { 2058 {
2058 if (namelist[i] == emaillist[j]) 2059 if (namelist[i] == emaillist[j])
2059 { 2060 {
2060 foundUid = namelist[i].uid(); 2061 foundUid = namelist[i].uid();
2061 } 2062 }
2062 } 2063 }
2063 } 2064 }
2064 } 2065 }
2065 } 2066 }
2066 else 2067 else
2067 { 2068 {
2068 foundUid = uid; 2069 foundUid = uid;
2069 } 2070 }
2070 2071
2071 if (!foundUid.isEmpty()) 2072 if (!foundUid.isEmpty())
2072 { 2073 {
2073 2074
2074 // raise Ka/Pi if it is in the background 2075 // raise Ka/Pi if it is in the background
2075#ifndef DESKTOP_VERSION 2076#ifndef DESKTOP_VERSION
2076#ifndef KORG_NODCOP 2077#ifndef KORG_NODCOP
2077 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2078 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2078#endif 2079#endif
2079#endif 2080#endif
2080 2081
2081 mMainWindow->showMaximized(); 2082 mMainWindow->showMaximized();
2082 mMainWindow-> raise(); 2083 mMainWindow-> raise();
2083 2084
2084 mViewManager->setSelected( "", false); 2085 mViewManager->setSelected( "", false);
2085 mViewManager->refreshView( "" ); 2086 mViewManager->refreshView( "" );
2086 mViewManager->setSelected( foundUid, true ); 2087 mViewManager->setSelected( foundUid, true );
2087 mViewManager->refreshView( foundUid ); 2088 mViewManager->refreshView( foundUid );
2088 2089
2089 if ( !mMultipleViewsAtOnce ) 2090 if ( !mMultipleViewsAtOnce )
2090 { 2091 {
2091 setDetailsVisible( true ); 2092 setDetailsVisible( true );
2092 mActionDetails->setChecked(true); 2093 mActionDetails->setChecked(true);
2093 } 2094 }
2094 } 2095 }
2095} 2096}
2096 2097
2097 2098
2098void KABCore::faq() 2099void KABCore::faq()
2099{ 2100{
2100 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2101 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2101} 2102}
2102 2103
2103 2104
2104void KABCore::fillSyncMenu() 2105void KABCore::fillSyncMenu()
2105{ 2106{
2106 if ( syncMenu->count() ) 2107 if ( syncMenu->count() )
2107 syncMenu->clear(); 2108 syncMenu->clear();
2108 syncMenu->insertItem( i18n("Configure..."), 0 ); 2109 syncMenu->insertItem( i18n("Configure..."), 0 );
2109 syncMenu->insertSeparator(); 2110 syncMenu->insertSeparator();
2110 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 2111 syncMenu->insertItem( i18n("Multiple sync"), 1 );
2111 syncMenu->insertSeparator(); 2112 syncMenu->insertSeparator();
2112 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2113 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2113 config.setGroup("General"); 2114 config.setGroup("General");
2114 QStringList prof = config.readListEntry("SyncProfileNames"); 2115 QStringList prof = config.readListEntry("SyncProfileNames");
2115 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 2116 KABPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
2116 if ( prof.count() < 3 ) { 2117 if ( prof.count() < 3 ) {
2117 prof.clear(); 2118 prof.clear();
2118 prof << i18n("Sharp_DTM"); 2119 prof << i18n("Sharp_DTM");
2119 prof << i18n("Local_file"); 2120 prof << i18n("Local_file");
2120 prof << i18n("Last_file"); 2121 prof << i18n("Last_file");
2121 KSyncProfile* temp = new KSyncProfile (); 2122 KSyncProfile* temp = new KSyncProfile ();
2122 temp->setName( prof[0] ); 2123 temp->setName( prof[0] );
2123 temp->writeConfig(&config); 2124 temp->writeConfig(&config);
2124 temp->setName( prof[1] ); 2125 temp->setName( prof[1] );
2125 temp->writeConfig(&config); 2126 temp->writeConfig(&config);
2126 temp->setName( prof[2] ); 2127 temp->setName( prof[2] );
2127 temp->writeConfig(&config); 2128 temp->writeConfig(&config);
2128 config.setGroup("General"); 2129 config.setGroup("General");
2129 config.writeEntry("SyncProfileNames",prof); 2130 config.writeEntry("SyncProfileNames",prof);
2130 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 2131 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
2131 config.sync(); 2132 config.sync();
2132 delete temp; 2133 delete temp;
2133 } 2134 }
2134 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 2135 KABPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
2135 KABPrefs::instance()->mSyncProfileNames = prof; 2136 KABPrefs::instance()->mSyncProfileNames = prof;
2136 int i; 2137 int i;
2137 for ( i = 0; i < prof.count(); ++i ) { 2138 for ( i = 0; i < prof.count(); ++i ) {
2138 2139
2139 syncMenu->insertItem( prof[i], 1000+i ); 2140 syncMenu->insertItem( prof[i], 1000+i );
2140 if ( i == 2 ) 2141 if ( i == 2 )
2141 syncMenu->insertSeparator(); 2142 syncMenu->insertSeparator();
2142 } 2143 }
2143 QDir app_dir; 2144 QDir app_dir;
2144 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 2145 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
2145 syncMenu->setItemEnabled( false , 1000 ); 2146 syncMenu->setItemEnabled( false , 1000 );
2146 } 2147 }
2147 //probaly useless 2148 //probaly useless
2148 //mView->setupExternSyncProfiles(); 2149 //mView->setupExternSyncProfiles();
2149} 2150}
2150void KABCore::slotSyncMenu( int action ) 2151void KABCore::slotSyncMenu( int action )
2151{ 2152{
2152 //qDebug("syncaction %d ", action); 2153 //qDebug("syncaction %d ", action);
2153 if ( action == 0 ) { 2154 if ( action == 0 ) {
2154 2155
2155 // seems to be a Qt2 event handling bug 2156 // seems to be a Qt2 event handling bug
2156 // syncmenu.clear causes a segfault at first time 2157 // syncmenu.clear causes a segfault at first time
2157 // when we call it after the main event loop, it is ok 2158 // when we call it after the main event loop, it is ok
2158 // same behaviour when calling OM/Pi via QCOP for the first time 2159 // same behaviour when calling OM/Pi via QCOP for the first time
2159 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 2160 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
2160 //confSync(); 2161 //confSync();
2161 2162
2162 return; 2163 return;
2163 } 2164 }
2164 if ( action == 1 ) { 2165 if ( action == 1 ) {
2165 multiSync( true ); 2166 multiSync( true );
2166 return; 2167 return;
2167 } 2168 }
2168 2169
2169 if (mBlockSaveFlag) 2170 if (mBlockSaveFlag)
2170 return; 2171 return;
2171 mBlockSaveFlag = true; 2172 mBlockSaveFlag = true;
2172 mCurrentSyncProfile = action - 1000 ; 2173 mCurrentSyncProfile = action - 1000 ;
2173 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ; 2174 mCurrentSyncDevice = KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ;
2174 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ; 2175 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName ;
2175 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2176 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2176 KSyncProfile* temp = new KSyncProfile (); 2177 KSyncProfile* temp = new KSyncProfile ();
2177 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2178 temp->setName(KABPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2178 temp->readConfig(&config); 2179 temp->readConfig(&config);
2179 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2180 KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2180 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 2181 KABPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
2181 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2182 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2182 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2183 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2183 KABPrefs::instance()->mWriteBackInFuture = 0; 2184 KABPrefs::instance()->mWriteBackInFuture = 0;
2184 if ( temp->getWriteBackFuture() ) 2185 if ( temp->getWriteBackFuture() )
2185 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2186 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2186 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 2187 KABPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
2187 if ( action == 1000 ) { 2188 if ( action == 1000 ) {
2188 syncSharp(); 2189 syncSharp();
2189 2190
2190 } else if ( action == 1001 ) { 2191 } else if ( action == 1001 ) {
2191 syncLocalFile(); 2192 syncLocalFile();
2192 2193
2193 } else if ( action == 1002 ) { 2194 } else if ( action == 1002 ) {
2194 quickSyncLocalFile(); 2195 quickSyncLocalFile();
2195 2196
2196 } else if ( action >= 1003 ) { 2197 } else if ( action >= 1003 ) {
2197 if ( temp->getIsLocalFileSync() ) { 2198 if ( temp->getIsLocalFileSync() ) {
2198 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) ) 2199 if ( syncWithFile( temp->getRemoteFileNameAB( ), false ) )
2199 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 2200 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2200 } else { 2201 } else {
2201 if ( temp->getIsPhoneSync() ) { 2202 if ( temp->getIsPhoneSync() ) {
2202 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2203 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2203 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2204 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2204 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2205 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2205 syncPhone(); 2206 syncPhone();
2206 } else 2207 } else
2207 syncRemote( temp ); 2208 syncRemote( temp );
2208 2209
2209 } 2210 }
2210 } 2211 }
2211 delete temp; 2212 delete temp;
2212 mBlockSaveFlag = false; 2213 mBlockSaveFlag = false;
2213} 2214}
2214 2215
2215void KABCore::syncLocalFile() 2216void KABCore::syncLocalFile()
2216{ 2217{
2217 2218
2218 QString fn =KABPrefs::instance()->mLastSyncedLocalFile; 2219 QString fn =KABPrefs::instance()->mLastSyncedLocalFile;
2219 2220
2220 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2221 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2221 if ( fn == "" ) 2222 if ( fn == "" )
2222 return; 2223 return;
2223 if ( syncWithFile( fn, false ) ) { 2224 if ( syncWithFile( fn, false ) ) {
2224 qDebug("syncLocalFile() successful "); 2225 qDebug("syncLocalFile() successful ");
2225 } 2226 }
2226 2227
2227} 2228}
2228bool KABCore::syncWithFile( QString fn , bool quick ) 2229bool KABCore::syncWithFile( QString fn , bool quick )
2229{ 2230{
2230 bool ret = false; 2231 bool ret = false;
2231 QFileInfo info; 2232 QFileInfo info;
2232 info.setFile( fn ); 2233 info.setFile( fn );
2233 QString mess; 2234 QString mess;
2234 bool loadbup = true; 2235 bool loadbup = true;
2235 if ( !info. exists() ) { 2236 if ( !info. exists() ) {
2236 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2237 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2237 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2238 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2238 mess ); 2239 mess );
2239 return ret; 2240 return ret;
2240 } 2241 }
2241 int result = 0; 2242 int result = 0;
2242 if ( !quick ) { 2243 if ( !quick ) {
2243 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2244 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2244 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2245 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2245 mess, 2246 mess,
2246 i18n("Sync"), i18n("Cancel"), 0, 2247 i18n("Sync"), i18n("Cancel"), 0,
2247 0, 1 ); 2248 0, 1 );
2248 if ( result ) 2249 if ( result )
2249 return false; 2250 return false;
2250 } 2251 }
2251 if ( KABPrefs::instance()->mAskForPreferences ) 2252 if ( KABPrefs::instance()->mAskForPreferences )
2252 edit_sync_options(); 2253 edit_sync_options();
2253 if ( result == 0 ) { 2254 if ( result == 0 ) {
2254 //qDebug("Now sycing ... "); 2255 //qDebug("Now sycing ... ");
2255 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) ) 2256 if ( ret = syncAB( fn, KABPrefs::instance()->mSyncAlgoPrefs ) )
2256 setCaption( i18n("Synchronization successful") ); 2257 setCaption( i18n("Synchronization successful") );
2257 else 2258 else
2258 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2259 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2259 if ( ! quick ) 2260 if ( ! quick )
2260 KABPrefs::instance()->mLastSyncedLocalFile = fn; 2261 KABPrefs::instance()->mLastSyncedLocalFile = fn;
2261 setModified(); 2262 setModified();
2262 } 2263 }
2263 return ret; 2264 return ret;
2264} 2265}
2265void KABCore::quickSyncLocalFile() 2266void KABCore::quickSyncLocalFile()
2266{ 2267{
2267 2268
2268 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2269 if ( syncWithFile( KABPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2269 qDebug("quick syncLocalFile() successful "); 2270 qDebug("quick syncLocalFile() successful ");
2270 2271
2271 } 2272 }
2272} 2273}
2273void KABCore::multiSync( bool askforPrefs ) 2274void KABCore::multiSync( bool askforPrefs )
2274{ 2275{
2275 if (mBlockSaveFlag) 2276 if (mBlockSaveFlag)
2276 return; 2277 return;
2277 mBlockSaveFlag = true; 2278 mBlockSaveFlag = true;
2278 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 2279 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
2279 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2280 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2280 question, 2281 question,
2281 i18n("Yes"), i18n("No"), 2282 i18n("Yes"), i18n("No"),
2282 0, 0 ) != 0 ) { 2283 0, 0 ) != 0 ) {
2283 mBlockSaveFlag = false; 2284 mBlockSaveFlag = false;
2284 setCaption(i18n("Aborted! Nothing synced!")); 2285 setCaption(i18n("Aborted! Nothing synced!"));
2285 return; 2286 return;
2286 } 2287 }
2287 mCurrentSyncDevice = i18n("Multiple profiles") ; 2288 mCurrentSyncDevice = i18n("Multiple profiles") ;
2288 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs; 2289 KABPrefs::instance()->mSyncAlgoPrefs = KABPrefs::instance()->mRingSyncAlgoPrefs;
2289 if ( askforPrefs ) { 2290 if ( askforPrefs ) {
2290 edit_sync_options(); 2291 edit_sync_options();
2291 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs; 2292 KABPrefs::instance()->mRingSyncAlgoPrefs = KABPrefs::instance()->mSyncAlgoPrefs;
2292 } 2293 }
2293 setCaption(i18n("Multiple sync started.") ); 2294 setCaption(i18n("Multiple sync started.") );
2294 qApp->processEvents(); 2295 qApp->processEvents();
2295 int num = ringSync() ; 2296 int num = ringSync() ;
2296 if ( num > 1 ) 2297 if ( num > 1 )
2297 ringSync(); 2298 ringSync();
2298 mBlockSaveFlag = false; 2299 mBlockSaveFlag = false;
2299 if ( num ) 2300 if ( num )
2300 save(); 2301 save();
2301 if ( num ) 2302 if ( num )
2302 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 2303 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
2303 else 2304 else
2304 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 2305 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
2305 return; 2306 return;
2306} 2307}
2307int KABCore::ringSync() 2308int KABCore::ringSync()
2308{ 2309{
2309 int syncedProfiles = 0; 2310 int syncedProfiles = 0;
2310 int i; 2311 int i;
2311 QTime timer; 2312 QTime timer;
2312 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 2313 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
2313 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames; 2314 QStringList syncProfileNames = KABPrefs::instance()->mSyncProfileNames;
2314 KSyncProfile* temp = new KSyncProfile (); 2315 KSyncProfile* temp = new KSyncProfile ();
2315 KABPrefs::instance()->mAskForPreferences = false; 2316 KABPrefs::instance()->mAskForPreferences = false;
2316 for ( i = 0; i < syncProfileNames.count(); ++i ) { 2317 for ( i = 0; i < syncProfileNames.count(); ++i ) {
2317 mCurrentSyncProfile = i; 2318 mCurrentSyncProfile = i;
2318 temp->setName(syncProfileNames[mCurrentSyncProfile]); 2319 temp->setName(syncProfileNames[mCurrentSyncProfile]);
2319 temp->readConfig(&config); 2320 temp->readConfig(&config);
2320 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) { 2321 if ( temp->getIncludeInRingSyncAB() && ( i < 1 || i > 2 )) {
2321 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 2322 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
2322 ++syncedProfiles; 2323 ++syncedProfiles;
2323 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 2324 // KABPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
2324 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 2325 KABPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
2325 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 2326 KABPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
2326 KABPrefs::instance()->mWriteBackInFuture = 0; 2327 KABPrefs::instance()->mWriteBackInFuture = 0;
2327 if ( temp->getWriteBackFuture() ) 2328 if ( temp->getWriteBackFuture() )
2328 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 2329 KABPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
2329 KABPrefs::instance()->mShowSyncSummary = false; 2330 KABPrefs::instance()->mShowSyncSummary = false;
2330 mCurrentSyncDevice = syncProfileNames[i] ; 2331 mCurrentSyncDevice = syncProfileNames[i] ;
2331 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName; 2332 mCurrentSyncName = KABPrefs::instance()->mLocalMachineName;
2332 if ( i == 0 ) { 2333 if ( i == 0 ) {
2333 syncSharp(); 2334 syncSharp();
2334 } else { 2335 } else {
2335 if ( temp->getIsLocalFileSync() ) { 2336 if ( temp->getIsLocalFileSync() ) {
2336 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) ) 2337 if ( syncWithFile( temp->getRemoteFileNameAB( ), true ) )
2337 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB(); 2338 KABPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileNameAB();
2338 } else { 2339 } else {
2339 if ( temp->getIsPhoneSync() ) { 2340 if ( temp->getIsPhoneSync() ) {
2340 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 2341 KABPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
2341 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 2342 KABPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
2342 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 2343 KABPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
2343 syncPhone(); 2344 syncPhone();
2344 } else 2345 } else
2345 syncRemote( temp, false ); 2346 syncRemote( temp, false );
2346 2347
2347 } 2348 }
2348 } 2349 }
2349 timer.start(); 2350 timer.start();
2350 setCaption(i18n("Multiple sync in progress ... please wait!") ); 2351 setCaption(i18n("Multiple sync in progress ... please wait!") );
2351 while ( timer.elapsed () < 2000 ) { 2352 while ( timer.elapsed () < 2000 ) {
2352 qApp->processEvents(); 2353 qApp->processEvents();
2353#ifndef _WIN32_ 2354#ifndef _WIN32_
2354 sleep (1); 2355 sleep (1);
2355#endif 2356#endif
2356 } 2357 }
2357 2358
2358 } 2359 }
2359 2360
2360 } 2361 }
2361 delete temp; 2362 delete temp;
2362 return syncedProfiles; 2363 return syncedProfiles;
2363} 2364}
2364 2365
2365void KABCore::syncRemote( KSyncProfile* prof, bool ask) 2366void KABCore::syncRemote( KSyncProfile* prof, bool ask)
2366{ 2367{
2367 QString question; 2368 QString question;
2368 if ( ask ) { 2369 if ( ask ) {
2369 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2370 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2370 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2371 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2371 question, 2372 question,
2372 i18n("Yes"), i18n("No"), 2373 i18n("Yes"), i18n("No"),
2373 0, 0 ) != 0 ) 2374 0, 0 ) != 0 )
2374 return; 2375 return;
2375 } 2376 }
2376 QString command = prof->getPreSyncCommandAB(); 2377 QString command = prof->getPreSyncCommandAB();
2377 int fi; 2378 int fi;
2378 if ( (fi = command.find("$PWD$")) > 0 ) { 2379 if ( (fi = command.find("$PWD$")) > 0 ) {
2379 QString pwd = getPassword(); 2380 QString pwd = getPassword();
2380 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2381 command = command.left( fi )+ pwd + command.mid( fi+5 );
2381 2382
2382 } 2383 }
2383 int maxlen = 30; 2384 int maxlen = 30;
2384 if ( QApplication::desktop()->width() > 320 ) 2385 if ( QApplication::desktop()->width() > 320 )
2385 maxlen += 25; 2386 maxlen += 25;
2386 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2387 setCaption ( i18n( "Copy remote file to local machine..." ) );
2387 int fileSize = 0; 2388 int fileSize = 0;
2388 int result = system ( command ); 2389 int result = system ( command );
2389 // 0 : okay 2390 // 0 : okay
2390 // 256: no such file or dir 2391 // 256: no such file or dir
2391 // 2392 //
2392 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2393 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2393 if ( result != 0 ) { 2394 if ( result != 0 ) {
2394 int len = maxlen; 2395 int len = maxlen;
2395 while ( len < command.length() ) { 2396 while ( len < command.length() ) {
2396 command.insert( len , "\n" ); 2397 command.insert( len , "\n" );
2397 len += maxlen +2; 2398 len += maxlen +2;
2398 } 2399 }
2399 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2400 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2400 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2401 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2401 question, 2402 question,
2402 i18n("Okay!")) ; 2403 i18n("Okay!")) ;
2403 setCaption ("KO/Pi"); 2404 setCaption ("KO/Pi");
2404 return; 2405 return;
2405 } 2406 }
2406 setCaption ( i18n( "Copying succeed." ) ); 2407 setCaption ( i18n( "Copying succeed." ) );
2407 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2408 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2408 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) { 2409 if ( syncWithFile( prof->getLocalTempFileAB(), true ) ) {
2409// Event* e = mView->getLastSyncEvent(); 2410// Event* e = mView->getLastSyncEvent();
2410// e->setReadOnly( false ); 2411// e->setReadOnly( false );
2411// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2412// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2412// e->setReadOnly( true ); 2413// e->setReadOnly( true );
2413 if ( KABPrefs::instance()->mWriteBackFile ) { 2414 if ( KABPrefs::instance()->mWriteBackFile ) {
2414 command = prof->getPostSyncCommandAB(); 2415 command = prof->getPostSyncCommandAB();
2415 int fi; 2416 int fi;
2416 if ( (fi = command.find("$PWD$")) > 0 ) { 2417 if ( (fi = command.find("$PWD$")) > 0 ) {
2417 QString pwd = getPassword(); 2418 QString pwd = getPassword();
2418 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2419 command = command.left( fi )+ pwd + command.mid( fi+5 );
2419 2420
2420 } 2421 }
2421 setCaption ( i18n( "Writing back file ..." ) ); 2422 setCaption ( i18n( "Writing back file ..." ) );
2422 result = system ( command ); 2423 result = system ( command );
2423 qDebug("KO: Writing back file result: %d ", result); 2424 qDebug("KO: Writing back file result: %d ", result);
2424 if ( result != 0 ) { 2425 if ( result != 0 ) {
2425 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2426 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2426 return; 2427 return;
2427 } else { 2428 } else {
2428 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2429 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2429 } 2430 }
2430 } 2431 }
2431 } 2432 }
2432 return; 2433 return;
2433} 2434}
2434#include <qpushbutton.h> 2435#include <qpushbutton.h>
2435#include <qradiobutton.h> 2436#include <qradiobutton.h>
2436#include <qbuttongroup.h> 2437#include <qbuttongroup.h>
2437void KABCore::edit_sync_options() 2438void KABCore::edit_sync_options()
2438{ 2439{
2439 //mDialogManager->showSyncOptions(); 2440 //mDialogManager->showSyncOptions();
2440 //KABPrefs::instance()->mSyncAlgoPrefs 2441 //KABPrefs::instance()->mSyncAlgoPrefs
2441 QDialog dia( this, "dia", true ); 2442 QDialog dia( this, "dia", true );
2442 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2443 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2443 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2444 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2444 QVBoxLayout lay ( &dia ); 2445 QVBoxLayout lay ( &dia );
2445 lay.setSpacing( 2 ); 2446 lay.setSpacing( 2 );
2446 lay.setMargin( 3 ); 2447 lay.setMargin( 3 );
2447 lay.addWidget(&gr); 2448 lay.addWidget(&gr);
2448 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2449 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2449 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2450 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2450 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2451 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2451 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2452 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2452 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2453 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2453 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2454 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2454 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2455 //QRadioButton both( i18n("Take both on conflict"), &gr );
2455 QPushButton pb ( "OK", &dia); 2456 QPushButton pb ( "OK", &dia);
2456 lay.addWidget( &pb ); 2457 lay.addWidget( &pb );
2457 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2458 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2458 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) { 2459 switch ( KABPrefs::instance()->mSyncAlgoPrefs ) {
2459 case 0: 2460 case 0:
2460 loc.setChecked( true); 2461 loc.setChecked( true);
2461 break; 2462 break;
2462 case 1: 2463 case 1:
2463 rem.setChecked( true ); 2464 rem.setChecked( true );
2464 break; 2465 break;
2465 case 2: 2466 case 2:
2466 newest.setChecked( true); 2467 newest.setChecked( true);
2467 break; 2468 break;
2468 case 3: 2469 case 3:
2469 ask.setChecked( true); 2470 ask.setChecked( true);
2470 break; 2471 break;
2471 case 4: 2472 case 4:
2472 f_loc.setChecked( true); 2473 f_loc.setChecked( true);
2473 break; 2474 break;
2474 case 5: 2475 case 5:
2475 f_rem.setChecked( true); 2476 f_rem.setChecked( true);
2476 break; 2477 break;
2477 case 6: 2478 case 6:
2478 // both.setChecked( true); 2479 // both.setChecked( true);
2479 break; 2480 break;
2480 default: 2481 default:
2481 break; 2482 break;
2482 } 2483 }
2483 if ( dia.exec() ) { 2484 if ( dia.exec() ) {
2484 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2485 KABPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2485 } 2486 }
2486 2487
2487 2488
2488} 2489}
2489QString KABCore::getPassword( ) 2490QString KABCore::getPassword( )
2490{ 2491{
2491 QString retfile = ""; 2492 QString retfile = "";
2492 QDialog dia ( this, "input-dialog", true ); 2493 QDialog dia ( this, "input-dialog", true );
2493 QLineEdit lab ( &dia ); 2494 QLineEdit lab ( &dia );
2494 lab.setEchoMode( QLineEdit::Password ); 2495 lab.setEchoMode( QLineEdit::Password );
2495 QVBoxLayout lay( &dia ); 2496 QVBoxLayout lay( &dia );
2496 lay.setMargin(7); 2497 lay.setMargin(7);
2497 lay.setSpacing(7); 2498 lay.setSpacing(7);
2498 lay.addWidget( &lab); 2499 lay.addWidget( &lab);
2499 dia.setFixedSize( 230,50 ); 2500 dia.setFixedSize( 230,50 );
2500 dia.setCaption( i18n("Enter password") ); 2501 dia.setCaption( i18n("Enter password") );
2501 QPushButton pb ( "OK", &dia); 2502 QPushButton pb ( "OK", &dia);
2502 lay.addWidget( &pb ); 2503 lay.addWidget( &pb );
2503 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2504 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2504 dia.show(); 2505 dia.show();
2505 int res = dia.exec(); 2506 int res = dia.exec();
2506 if ( res ) 2507 if ( res )
2507 retfile = lab.text(); 2508 retfile = lab.text();
2508 dia.hide(); 2509 dia.hide();
2509 qApp->processEvents(); 2510 qApp->processEvents();
2510 return retfile; 2511 return retfile;
2511 2512
2512} 2513}
2513#include <libkcal/syncdefines.h> 2514#include <libkcal/syncdefines.h>
2514 2515
2515KABC::Addressee KABCore::getLastSyncAddressee() 2516KABC::Addressee KABCore::getLastSyncAddressee()
2516{ 2517{
2517 Addressee lse; 2518 Addressee lse;
2518 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2519 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2519 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2520 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2520 if (lse.isEmpty()) { 2521 if (lse.isEmpty()) {
2521 qDebug("Creating new last-syncAddressee "); 2522 qDebug("Creating new last-syncAddressee ");
2522 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2523 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2523 QString sum = ""; 2524 QString sum = "";
2524 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2525 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2525 sum = "E: "; 2526 sum = "E: ";
2526 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2527 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2527 lse.setRevision( mLastAddressbookSync ); 2528 lse.setRevision( mLastAddressbookSync );
2528 lse.setCategories( i18n("SyncEvent") ); 2529 lse.setCategories( i18n("SyncEvent") );
2529 mAddressBook->insertAddressee( lse ); 2530 mAddressBook->insertAddressee( lse );
2530 } 2531 }
2531 return lse; 2532 return lse;
2532} 2533}
2533int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2534int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2534{ 2535{
2535 2536
2536 //void setZaurusId(int id); 2537 //void setZaurusId(int id);
2537 // int zaurusId() const; 2538 // int zaurusId() const;
2538 // void setZaurusUid(int id); 2539 // void setZaurusUid(int id);
2539 // int zaurusUid() const; 2540 // int zaurusUid() const;
2540 // void setZaurusStat(int id); 2541 // void setZaurusStat(int id);
2541 // int zaurusStat() const; 2542 // int zaurusStat() const;
2542 // 0 equal 2543 // 0 equal
2543 // 1 take local 2544 // 1 take local
2544 // 2 take remote 2545 // 2 take remote
2545 // 3 cancel 2546 // 3 cancel
2546 QDateTime lastSync = mLastAddressbookSync; 2547 QDateTime lastSync = mLastAddressbookSync;
2547 QDateTime localMod = local->revision(); 2548 QDateTime localMod = local->revision();
2548 QDateTime remoteMod = remote->revision(); 2549 QDateTime remoteMod = remote->revision();
2549 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2550 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2550 bool remCh, locCh; 2551 bool remCh, locCh;
2551 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2552 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2552 2553
2553 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2554 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2554 locCh = ( localMod > mLastAddressbookSync ); 2555 locCh = ( localMod > mLastAddressbookSync );
2555 if ( !remCh && ! locCh ) { 2556 if ( !remCh && ! locCh ) {
2556 //qDebug("both not changed "); 2557 //qDebug("both not changed ");
2557 lastSync = localMod.addDays(1); 2558 lastSync = localMod.addDays(1);
2558 if ( mode <= SYNC_PREF_ASK ) 2559 if ( mode <= SYNC_PREF_ASK )
2559 return 0; 2560 return 0;
2560 } else { 2561 } else {
2561 if ( locCh ) { 2562 if ( locCh ) {
2562 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2563 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2563 lastSync = localMod.addDays( -1 ); 2564 lastSync = localMod.addDays( -1 );
2564 if ( !remCh ) 2565 if ( !remCh )
2565 remoteMod =( lastSync.addDays( -1 ) ); 2566 remoteMod =( lastSync.addDays( -1 ) );
2566 } else { 2567 } else {
2567 //qDebug(" not loc changed "); 2568 //qDebug(" not loc changed ");
2568 lastSync = localMod.addDays( 1 ); 2569 lastSync = localMod.addDays( 1 );
2569 if ( remCh ) 2570 if ( remCh )
2570 remoteMod =( lastSync.addDays( 1 ) ); 2571 remoteMod =( lastSync.addDays( 1 ) );
2571 2572
2572 } 2573 }
2573 } 2574 }
2574 full = true; 2575 full = true;
2575 if ( mode < SYNC_PREF_ASK ) 2576 if ( mode < SYNC_PREF_ASK )
2576 mode = SYNC_PREF_ASK; 2577 mode = SYNC_PREF_ASK;
2577 } else { 2578 } else {
2578 if ( localMod == remoteMod ) 2579 if ( localMod == remoteMod )
2579 return 0; 2580 return 0;
2580 2581
2581 } 2582 }
2582 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 2583 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
2583 2584
2584 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod); 2585 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , localMod, remote->lastModified().toString().latin1(), remoteMod);
2585 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 2586 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
2586 //full = true; //debug only 2587 //full = true; //debug only
2587 if ( full ) { 2588 if ( full ) {
2588 bool equ = ( (*local) == (*remote) ); 2589 bool equ = ( (*local) == (*remote) );
2589 if ( equ ) { 2590 if ( equ ) {
2590 //qDebug("equal "); 2591 //qDebug("equal ");
2591 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2592 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2592 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2593 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2593 } 2594 }
2594 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2595 if ( mode < SYNC_PREF_FORCE_LOCAL )
2595 return 0; 2596 return 0;
2596 2597
2597 }//else //debug only 2598 }//else //debug only
2598 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2599 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2599 } 2600 }
2600 int result; 2601 int result;
2601 bool localIsNew; 2602 bool localIsNew;
2602 //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() ); 2603 //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() );
2603 2604
2604 if ( full && mode < SYNC_PREF_NEWEST ) 2605 if ( full && mode < SYNC_PREF_NEWEST )
2605 mode = SYNC_PREF_ASK; 2606 mode = SYNC_PREF_ASK;
2606 2607
2607 switch( mode ) { 2608 switch( mode ) {
2608 case SYNC_PREF_LOCAL: 2609 case SYNC_PREF_LOCAL:
2609 if ( lastSync > remoteMod ) 2610 if ( lastSync > remoteMod )
2610 return 1; 2611 return 1;
2611 if ( lastSync > localMod ) 2612 if ( lastSync > localMod )
2612 return 2; 2613 return 2;
2613 return 1; 2614 return 1;
2614 break; 2615 break;
2615 case SYNC_PREF_REMOTE: 2616 case SYNC_PREF_REMOTE:
2616 if ( lastSync > remoteMod ) 2617 if ( lastSync > remoteMod )
2617 return 1; 2618 return 1;
2618 if ( lastSync > localMod ) 2619 if ( lastSync > localMod )
2619 return 2; 2620 return 2;
2620 return 2; 2621 return 2;
2621 break; 2622 break;
2622 case SYNC_PREF_NEWEST: 2623 case SYNC_PREF_NEWEST:
2623 if ( localMod > remoteMod ) 2624 if ( localMod > remoteMod )
2624 return 1; 2625 return 1;
2625 else 2626 else
2626 return 2; 2627 return 2;
2627 break; 2628 break;
2628 case SYNC_PREF_ASK: 2629 case SYNC_PREF_ASK:
2629 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2630 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2630 if ( lastSync > remoteMod ) 2631 if ( lastSync > remoteMod )
2631 return 1; 2632 return 1;
2632 if ( lastSync > localMod ) 2633 if ( lastSync > localMod )
2633 return 2; 2634 return 2;
2634 localIsNew = localMod >= remoteMod; 2635 localIsNew = localMod >= remoteMod;
2635 //qDebug("conflict! ************************************** "); 2636 //qDebug("conflict! ************************************** ");
2636 { 2637 {
2637 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2638 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2638 result = acd.executeD(localIsNew); 2639 result = acd.executeD(localIsNew);
2639 return result; 2640 return result;
2640 } 2641 }
2641 break; 2642 break;
2642 case SYNC_PREF_FORCE_LOCAL: 2643 case SYNC_PREF_FORCE_LOCAL:
2643 return 1; 2644 return 1;
2644 break; 2645 break;
2645 case SYNC_PREF_FORCE_REMOTE: 2646 case SYNC_PREF_FORCE_REMOTE:
2646 return 2; 2647 return 2;
2647 break; 2648 break;
2648 2649
2649 default: 2650 default:
2650 // SYNC_PREF_TAKE_BOTH not implemented 2651 // SYNC_PREF_TAKE_BOTH not implemented
2651 break; 2652 break;
2652 } 2653 }
2653 return 0; 2654 return 0;
2654} 2655}
2655bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2656bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2656{ 2657{
2657 bool syncOK = true; 2658 bool syncOK = true;
2658 int addedAddressee = 0; 2659 int addedAddressee = 0;
2659 int addedAddresseeR = 0; 2660 int addedAddresseeR = 0;
2660 int deletedAddresseeR = 0; 2661 int deletedAddresseeR = 0;
2661 int deletedAddresseeL = 0; 2662 int deletedAddresseeL = 0;
2662 int changedLocal = 0; 2663 int changedLocal = 0;
2663 int changedRemote = 0; 2664 int changedRemote = 0;
2664 //QPtrList<Addressee> el = local->rawAddressees(); 2665 //QPtrList<Addressee> el = local->rawAddressees();
2665 Addressee addresseeR; 2666 Addressee addresseeR;
2666 QString uid; 2667 QString uid;
2667 int take; 2668 int take;
2668 Addressee addresseeL; 2669 Addressee addresseeL;
2669 Addressee addresseeRSync; 2670 Addressee addresseeRSync;
2670 Addressee addresseeLSync; 2671 Addressee addresseeLSync;
2671 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2672 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2672 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2673 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2673 bool fullDateRange = false; 2674 bool fullDateRange = false;
2674 local->resetTempSyncStat(); 2675 local->resetTempSyncStat();
2675 mLastAddressbookSync = QDateTime::currentDateTime(); 2676 mLastAddressbookSync = QDateTime::currentDateTime();
2676 QDateTime modifiedCalendar = mLastAddressbookSync;; 2677 QDateTime modifiedCalendar = mLastAddressbookSync;;
2677 addresseeLSync = getLastSyncAddressee(); 2678 addresseeLSync = getLastSyncAddressee();
2678 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2679 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2679 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2680 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2680 if ( !addresseeR.isEmpty() ) { 2681 if ( !addresseeR.isEmpty() ) {
2681 addresseeRSync = addresseeR; 2682 addresseeRSync = addresseeR;
2682 remote->removeAddressee(addresseeR ); 2683 remote->removeAddressee(addresseeR );
2683 2684
2684 } else { 2685 } else {
2685 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2686 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2686 addresseeRSync = addresseeLSync ; 2687 addresseeRSync = addresseeLSync ;
2687 } else { 2688 } else {
2688 qDebug("FULLDATE 1"); 2689 qDebug("FULLDATE 1");
2689 fullDateRange = true; 2690 fullDateRange = true;
2690 Addressee newAdd; 2691 Addressee newAdd;
2691 addresseeRSync = newAdd; 2692 addresseeRSync = newAdd;
2692 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2693 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2693 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2694 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2694 addresseeRSync.setRevision( mLastAddressbookSync ); 2695 addresseeRSync.setRevision( mLastAddressbookSync );
2695 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2696 addresseeRSync.setCategories( i18n("SyncAddressee") );
2696 } 2697 }
2697 } 2698 }
2698 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2699 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2699 qDebug("FULLDATE 2"); 2700 qDebug("FULLDATE 2");
2700 fullDateRange = true; 2701 fullDateRange = true;
2701 } 2702 }
2702 if ( ! fullDateRange ) { 2703 if ( ! fullDateRange ) {
2703 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2704 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2704 2705
2705 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2706 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2706 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2707 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2707 fullDateRange = true; 2708 fullDateRange = true;
2708 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2709 qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2709 } 2710 }
2710 } 2711 }
2711 // fullDateRange = true; // debug only! 2712 // fullDateRange = true; // debug only!
2712 if ( fullDateRange ) 2713 if ( fullDateRange )
2713 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2714 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2714 else 2715 else
2715 mLastAddressbookSync = addresseeLSync.revision(); 2716 mLastAddressbookSync = addresseeLSync.revision();
2716 // for resyncing if own file has changed 2717 // for resyncing if own file has changed
2717 // PENDING fixme later when implemented 2718 // PENDING fixme later when implemented
2718#if 0 2719#if 0
2719 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2720 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2720 mLastAddressbookSync = loadedFileVersion; 2721 mLastAddressbookSync = loadedFileVersion;
2721 qDebug("setting mLastAddressbookSync "); 2722 qDebug("setting mLastAddressbookSync ");
2722 } 2723 }
2723#endif 2724#endif
2724 2725
2725 //qDebug("*************************** "); 2726 //qDebug("*************************** ");
2726 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2727 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2727 QStringList er = remote->uidList(); 2728 QStringList er = remote->uidList();
2728 Addressee inR ;//= er.first(); 2729 Addressee inR ;//= er.first();
2729 Addressee inL; 2730 Addressee inL;
2730 QProgressBar bar( er.count(),0 ); 2731 QProgressBar bar( er.count(),0 );
2731 bar.setCaption (i18n("Syncing - close to abort!") ); 2732 bar.setCaption (i18n("Syncing - close to abort!") );
2732 2733
2733 int w = 300; 2734 int w = 300;
2734 if ( QApplication::desktop()->width() < 320 ) 2735 if ( QApplication::desktop()->width() < 320 )
2735 w = 220; 2736 w = 220;
2736 int h = bar.sizeHint().height() ; 2737 int h = bar.sizeHint().height() ;
2737 int dw = QApplication::desktop()->width(); 2738 int dw = QApplication::desktop()->width();
2738 int dh = QApplication::desktop()->height(); 2739 int dh = QApplication::desktop()->height();
2739 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2740 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2740 bar.show(); 2741 bar.show();
2741 int modulo = (er.count()/10)+1; 2742 int modulo = (er.count()/10)+1;
2742 int incCounter = 0; 2743 int incCounter = 0;
2743 while ( incCounter < er.count()) { 2744 while ( incCounter < er.count()) {
2744 if ( ! bar.isVisible() ) 2745 if ( ! bar.isVisible() )
2745 return false; 2746 return false;
2746 if ( incCounter % modulo == 0 ) 2747 if ( incCounter % modulo == 0 )
2747 bar.setProgress( incCounter ); 2748 bar.setProgress( incCounter );
2748 uid = er[ incCounter ]; 2749 uid = er[ incCounter ];
2749 bool skipIncidence = false; 2750 bool skipIncidence = false;
2750 if ( uid.left(19) == QString("last-syncAddressee-") ) 2751 if ( uid.left(19) == QString("last-syncAddressee-") )
2751 skipIncidence = true; 2752 skipIncidence = true;
2752 QString idS,OidS; 2753 QString idS,OidS;
2753 qApp->processEvents(); 2754 qApp->processEvents();
2754 if ( !skipIncidence ) { 2755 if ( !skipIncidence ) {
2755 inL = local->findByUid( uid ); 2756 inL = local->findByUid( uid );
2756 inR = remote->findByUid( uid ); 2757 inR = remote->findByUid( uid );
2757 //inL.setResource( 0 ); 2758 //inL.setResource( 0 );
2758 //inR.setResource( 0 ); 2759 //inR.setResource( 0 );
2759 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2760 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2760 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) { 2761 if ( take = takeAddressee( &inL, &inR, mode, fullDateRange ) ) {
2761 //qDebug("take %d %s ", take, inL.summary().latin1()); 2762 //qDebug("take %d %s ", take, inL.summary().latin1());
2762 if ( take == 3 ) 2763 if ( take == 3 )
2763 return false; 2764 return false;
2764 if ( take == 1 ) {// take local 2765 if ( take == 1 ) {// take local
2765 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2766 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2766 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2767 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2767 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2768 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2768 local->insertAddressee( inL, false ); 2769 local->insertAddressee( inL, false );
2769 idS = inR.externalUID(); 2770 idS = inR.externalUID();
2770 OidS = inR.originalExternalUID(); 2771 OidS = inR.originalExternalUID();
2771 } 2772 }
2772 else 2773 else
2773 idS = inR.IDStr(); 2774 idS = inR.IDStr();
2774 remote->removeAddressee( inR ); 2775 remote->removeAddressee( inR );
2775 inR = inL; 2776 inR = inL;
2776 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2777 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2777 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2778 inR.setOriginalExternalUID( OidS ); 2779 inR.setOriginalExternalUID( OidS );
2779 inR.setExternalUID( idS ); 2780 inR.setExternalUID( idS );
2780 } else { 2781 } else {
2781 inR.setIDStr( idS ); 2782 inR.setIDStr( idS );
2782 } 2783 }
2783 inR.setResource( 0 ); 2784 inR.setResource( 0 );
2784 remote->insertAddressee( inR , false); 2785 remote->insertAddressee( inR , false);
2785 ++changedRemote; 2786 ++changedRemote;
2786 } else { // take == 2 take remote 2787 } else { // take == 2 take remote
2787 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2788 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2788 if ( inR.revision().date().year() < 2004 ) 2789 if ( inR.revision().date().year() < 2004 )
2789 inR.setRevision( modifiedCalendar ); 2790 inR.setRevision( modifiedCalendar );
2790 } 2791 }
2791 idS = inL.IDStr(); 2792 idS = inL.IDStr();
2792 local->removeAddressee( inL ); 2793 local->removeAddressee( inL );
2793 inL = inR; 2794 inL = inR;
2794 inL.setIDStr( idS ); 2795 inL.setIDStr( idS );
2795 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2796 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2796 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2797 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2797 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2798 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2798 } 2799 }
2799 inL.setResource( 0 ); 2800 inL.setResource( 0 );
2800 local->insertAddressee( inL , false ); 2801 local->insertAddressee( inL , false );
2801 ++changedLocal; 2802 ++changedLocal;
2802 } 2803 }
2803 } 2804 }
2804 } else { // no conflict 2805 } else { // no conflict
2805 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2806 QString des = addresseeLSync.note(); 2807 QString des = addresseeLSync.note();
2807 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2808 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2808 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2809 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2809 remote->insertAddressee( inR, false ); 2810 remote->insertAddressee( inR, false );
2810 ++deletedAddresseeR; 2811 ++deletedAddresseeR;
2811 } else { 2812 } else {
2812 inR.setRevision( modifiedCalendar ); 2813 inR.setRevision( modifiedCalendar );
2813 remote->insertAddressee( inR, false ); 2814 remote->insertAddressee( inR, false );
2814 inL = inR; 2815 inL = inR;
2815 inL.setResource( 0 ); 2816 inL.setResource( 0 );
2816 local->insertAddressee( inL , false); 2817 local->insertAddressee( inL , false);
2817 ++addedAddressee; 2818 ++addedAddressee;
2818 } 2819 }
2819 } else { 2820 } else {
2820 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2821 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2821 inR.setRevision( modifiedCalendar ); 2822 inR.setRevision( modifiedCalendar );
2822 remote->insertAddressee( inR, false ); 2823 remote->insertAddressee( inR, false );
2823 inR.setResource( 0 ); 2824 inR.setResource( 0 );
2824 local->insertAddressee( inR, false ); 2825 local->insertAddressee( inR, false );
2825 ++addedAddressee; 2826 ++addedAddressee;
2826 } else { 2827 } else {
2827 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2828 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2828 remote->removeAddressee( inR ); 2829 remote->removeAddressee( inR );
2829 ++deletedAddresseeR; 2830 ++deletedAddresseeR;
2830 } 2831 }
2831 } 2832 }
2832 } 2833 }
2833 } 2834 }
2834 ++incCounter; 2835 ++incCounter;
2835 } 2836 }
2836 er.clear(); 2837 er.clear();
2837 QStringList el = local->uidList(); 2838 QStringList el = local->uidList();
2838 modulo = (el.count()/10)+1; 2839 modulo = (el.count()/10)+1;
2839 bar.setCaption (i18n("Add / remove addressees") ); 2840 bar.setCaption (i18n("Add / remove addressees") );
2840 bar.setTotalSteps ( el.count() ) ; 2841 bar.setTotalSteps ( el.count() ) ;
2841 bar.show(); 2842 bar.show();
2842 incCounter = 0; 2843 incCounter = 0;
2843 while ( incCounter < el.count()) { 2844 while ( incCounter < el.count()) {
2844 qApp->processEvents(); 2845 qApp->processEvents();
2845 if ( ! bar.isVisible() ) 2846 if ( ! bar.isVisible() )
2846 return false; 2847 return false;
2847 if ( incCounter % modulo == 0 ) 2848 if ( incCounter % modulo == 0 )
2848 bar.setProgress( incCounter ); 2849 bar.setProgress( incCounter );
2849 uid = el[ incCounter ]; 2850 uid = el[ incCounter ];
2850 bool skipIncidence = false; 2851 bool skipIncidence = false;
2851 if ( uid.left(19) == QString("last-syncAddressee-") ) 2852 if ( uid.left(19) == QString("last-syncAddressee-") )
2852 skipIncidence = true; 2853 skipIncidence = true;
2853 if ( !skipIncidence ) { 2854 if ( !skipIncidence ) {
2854 inL = local->findByUid( uid ); 2855 inL = local->findByUid( uid );
2855 inR = remote->findByUid( uid ); 2856 inR = remote->findByUid( uid );
2856 if ( inR.isEmpty() ) { 2857 if ( inR.isEmpty() ) {
2857 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2858 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2858 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 2859 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2859 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2860 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2860 local->removeAddressee( inL ); 2861 local->removeAddressee( inL );
2861 ++deletedAddresseeL; 2862 ++deletedAddresseeL;
2862 } else { 2863 } else {
2863 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2864 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2864 inL.removeID(mCurrentSyncDevice ); 2865 inL.removeID(mCurrentSyncDevice );
2865 ++addedAddresseeR; 2866 ++addedAddresseeR;
2866 inL.setRevision( modifiedCalendar ); 2867 inL.setRevision( modifiedCalendar );
2867 local->insertAddressee( inL, false ); 2868 local->insertAddressee( inL, false );
2868 inR = inL; 2869 inR = inL;
2869 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 2870 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2870 inR.setResource( 0 ); 2871 inR.setResource( 0 );
2871 remote->insertAddressee( inR, false ); 2872 remote->insertAddressee( inR, false );
2872 } 2873 }
2873 } 2874 }
2874 } else { 2875 } else {
2875 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 2876 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2876 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 2877 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2877 local->removeAddressee( inL ); 2878 local->removeAddressee( inL );
2878 ++deletedAddresseeL; 2879 ++deletedAddresseeL;
2879 } else { 2880 } else {
2880 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) { 2881 if ( ! KABPrefs::instance()->mWriteBackExistingOnly ) {
2881 ++addedAddresseeR; 2882 ++addedAddresseeR;
2882 inL.setRevision( modifiedCalendar ); 2883 inL.setRevision( modifiedCalendar );
2883 local->insertAddressee( inL, false ); 2884 local->insertAddressee( inL, false );
2884 inR = inL; 2885 inR = inL;
2885 inR.setResource( 0 ); 2886 inR.setResource( 0 );
2886 remote->insertAddressee( inR, false ); 2887 remote->insertAddressee( inR, false );
2887 } 2888 }
2888 } 2889 }
2889 } 2890 }
2890 } 2891 }
2891 } 2892 }
2892 ++incCounter; 2893 ++incCounter;
2893 } 2894 }
2894 el.clear(); 2895 el.clear();
2895 bar.hide(); 2896 bar.hide();
2896 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 2897 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2897 // get rid of micro seconds 2898 // get rid of micro seconds
2898 QTime t = mLastAddressbookSync.time(); 2899 QTime t = mLastAddressbookSync.time();
2899 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 2900 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2900 addresseeLSync.setRevision( mLastAddressbookSync ); 2901 addresseeLSync.setRevision( mLastAddressbookSync );
2901 addresseeRSync.setRevision( mLastAddressbookSync ); 2902 addresseeRSync.setRevision( mLastAddressbookSync );
2902 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 2903 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2903 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 2904 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2904 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 2905 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2905 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 2906 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2906 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 2907 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2907 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 2908 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2908 addresseeRSync.setNote( "" ) ; 2909 addresseeRSync.setNote( "" ) ;
2909 addresseeLSync.setNote( "" ); 2910 addresseeLSync.setNote( "" );
2910 2911
2911 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 2912 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2912 remote->insertAddressee( addresseeRSync, false ); 2913 remote->insertAddressee( addresseeRSync, false );
2913 local->insertAddressee( addresseeLSync, false ); 2914 local->insertAddressee( addresseeLSync, false );
2914 QString mes; 2915 QString mes;
2915 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 2916 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"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2916 if ( KABPrefs::instance()->mShowSyncSummary ) { 2917 if ( KABPrefs::instance()->mShowSyncSummary ) {
2917 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") ); 2918 KMessageBox::information(this, mes, i18n("KA/Pi Synchronization") );
2918 } 2919 }
2919 qDebug( mes ); 2920 qDebug( mes );
2920 return syncOK; 2921 return syncOK;
2921} 2922}
2922 2923
2923bool KABCore::syncAB(QString filename, int mode) 2924bool KABCore::syncAB(QString filename, int mode)
2924{ 2925{
2925 2926
2926 //pending prepare addresseeview for output 2927 //pending prepare addresseeview for output
2927 //pending detect, if remote file has REV field. if not switch to external sync 2928 //pending detect, if remote file has REV field. if not switch to external sync
2928 mGlobalSyncMode = SYNC_MODE_NORMAL; 2929 mGlobalSyncMode = SYNC_MODE_NORMAL;
2929 AddressBook abLocal(filename,"syncContact"); 2930 AddressBook abLocal(filename,"syncContact");
2930 bool syncOK = false; 2931 bool syncOK = false;
2931 if ( abLocal.load() ) { 2932 if ( abLocal.load() ) {
2932 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 2933 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
2933 bool external = false; 2934 bool external = false;
2934 bool isXML = false; 2935 bool isXML = false;
2935 if ( filename.right(4) == ".xml") { 2936 if ( filename.right(4) == ".xml") {
2936 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2937 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2937 isXML = true; 2938 isXML = true;
2938 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 2939 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
2939 } else { 2940 } else {
2940 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2941 Addressee lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2941 if ( ! lse.isEmpty() ) { 2942 if ( ! lse.isEmpty() ) {
2942 if ( lse.familyName().left(4) == "!E: " ) 2943 if ( lse.familyName().left(4) == "!E: " )
2943 external = true; 2944 external = true;
2944 } else { 2945 } else {
2945 bool found = false; 2946 bool found = false;
2946 AddressBook::Iterator it; 2947 AddressBook::Iterator it;
2947 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2948 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2948 if ( (*it).revision().date().year() > 2003 ) { 2949 if ( (*it).revision().date().year() > 2003 ) {
2949 found = true; 2950 found = true;
2950 break; 2951 break;
2951 } 2952 }
2952 } 2953 }
2953 external = ! found; 2954 external = ! found;
2954 } 2955 }
2955 2956
2956 if ( external ) { 2957 if ( external ) {
2957 qDebug("Setting vcf mode to external "); 2958 qDebug("Setting vcf mode to external ");
2958 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2959 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2959 AddressBook::Iterator it; 2960 AddressBook::Iterator it;
2960 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2961 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2961 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 2962 (*it).setID( mCurrentSyncDevice, (*it).uid() );
2962 (*it).computeCsum( mCurrentSyncDevice ); 2963 (*it).computeCsum( mCurrentSyncDevice );
2963 } 2964 }
2964 } 2965 }
2965 } 2966 }
2966 //AddressBook::Iterator it; 2967 //AddressBook::Iterator it;
2967 //QStringList vcards; 2968 //QStringList vcards;
2968 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 2969 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
2969 // qDebug("Name %s ", (*it).familyName().latin1()); 2970 // qDebug("Name %s ", (*it).familyName().latin1());
2970 //} 2971 //}
2971 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 2972 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
2972 if ( syncOK ) { 2973 if ( syncOK ) {
2973 if ( KABPrefs::instance()->mWriteBackFile ) 2974 if ( KABPrefs::instance()->mWriteBackFile )
2974 { 2975 {
2975 if ( external ) 2976 if ( external )
2976 abLocal.removeSyncAddressees( !isXML); 2977 abLocal.removeSyncAddressees( !isXML);
2977 qDebug("Saving remote AB "); 2978 qDebug("Saving remote AB ");
2978 abLocal.saveAB(); 2979 abLocal.saveAB();
2979 if ( isXML ) { 2980 if ( isXML ) {
2980 // afterwrite processing 2981 // afterwrite processing
2981 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 2982 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
2982 } 2983 }
2983 } 2984 }
2984 } 2985 }
2985 setModified(); 2986 setModified();
2986 2987
2987 } 2988 }
2988 if ( syncOK ) 2989 if ( syncOK )
2989 mViewManager->refreshView(); 2990 mViewManager->refreshView();
2990 return syncOK; 2991 return syncOK;
2991#if 0 2992#if 0
2992 2993
2993 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 2994 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
2994 getEventViewerDialog()->setSyncMode( true ); 2995 getEventViewerDialog()->setSyncMode( true );
2995 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 2996 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
2996 getEventViewerDialog()->setSyncMode( false ); 2997 getEventViewerDialog()->setSyncMode( false );
2997 if ( syncOK ) { 2998 if ( syncOK ) {
2998 if ( KOPrefs::instance()->mWriteBackFile ) 2999 if ( KOPrefs::instance()->mWriteBackFile )
2999 { 3000 {
3000 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3001 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3001 storage->save(); 3002 storage->save();
3002 } 3003 }
3003 } 3004 }
3004 setModified(); 3005 setModified();
3005 } 3006 }
3006 3007
3007#endif 3008#endif
3008} 3009}
3009 3010
3010void KABCore::confSync() 3011void KABCore::confSync()
3011{ 3012{
3012 static KSyncPrefsDialog* sp = 0; 3013 static KSyncPrefsDialog* sp = 0;
3013 if ( ! sp ) { 3014 if ( ! sp ) {
3014 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 3015 sp = new KSyncPrefsDialog( this, "syncprefs", true );
3015 } 3016 }
3016 sp->usrReadConfig(); 3017 sp->usrReadConfig();
3017#ifndef DESKTOP_VERSION 3018#ifndef DESKTOP_VERSION
3018 sp->showMaximized(); 3019 sp->showMaximized();
3019#else 3020#else
3020 sp->show(); 3021 sp->show();
3021#endif 3022#endif
3022 sp->exec(); 3023 sp->exec();
3023 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 3024 KABPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
3024 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 3025 KABPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
3025 fillSyncMenu(); 3026 fillSyncMenu();
3026} 3027}
3027void KABCore::syncSharp() 3028void KABCore::syncSharp()
3028{ 3029{
3029 if ( ! syncExternal("sharp") ) 3030 if ( ! syncExternal("sharp") )
3030 qDebug("ERROR sync sharp ");; 3031 qDebug("ERROR sync sharp ");;
3031} 3032}
3032bool KABCore::syncExternal(QString resource) 3033bool KABCore::syncExternal(QString resource)
3033{ 3034{
3034 if ( mModified ) 3035 if ( mModified )
3035 save(); 3036 save();
3036 if ( KABPrefs::instance()->mAskForPreferences ) 3037 if ( KABPrefs::instance()->mAskForPreferences )
3037 edit_sync_options(); 3038 edit_sync_options();
3038 qDebug("syncSharp() "); 3039 qDebug("syncSharp() ");
3039 AddressBook abLocal( resource,"syncContact"); 3040 AddressBook abLocal( resource,"syncContact");
3040 bool syncOK = false; 3041 bool syncOK = false;
3041 if ( abLocal.load() ) { 3042 if ( abLocal.load() ) {
3042 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3043 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3043 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3044 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3044 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice ); 3045 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice );
3045 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs ); 3046 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, KABPrefs::instance()->mSyncAlgoPrefs );
3046 if ( syncOK ) { 3047 if ( syncOK ) {
3047 if ( KABPrefs::instance()->mWriteBackFile ) { 3048 if ( KABPrefs::instance()->mWriteBackFile ) {
3048 abLocal.saveAB(); 3049 abLocal.saveAB();
3049 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ); 3050 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice );
3050 } 3051 }
3051 } 3052 }
3052 setModified(); 3053 setModified();
3053 } 3054 }
3054 if ( syncOK ) 3055 if ( syncOK )
3055 mViewManager->refreshView(); 3056 mViewManager->refreshView();
3056 return syncOK; 3057 return syncOK;
3057 3058
3058} 3059}
3059void KABCore::syncPhone() 3060void KABCore::syncPhone()
3060{ 3061{
3061 if ( mModified ) 3062 if ( mModified )
3062 save(); 3063 save();
3063 qDebug("pending syncPhone(); "); 3064 qDebug("pending syncPhone(); ");
3064 //mView->syncPhone(); 3065 //mView->syncPhone();
3065 setModified(); 3066 setModified();
3066 3067
3067} 3068}
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index 073ab74..03034b4 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -1,774 +1,775 @@
1/* 1/*
2 This file is part of KdePim/Pi. 2 This file is part of KdePim/Pi.
3 Copyright (c) 2004 Ulf Schenk 3 Copyright (c) 2004 Ulf Schenk
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/* 24/*
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 <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h> 37#include <qbuttongroup.h>
38#include <qfile.h> 38#include <qfile.h>
39#include <qregexp.h>
39 40
40#include <kdialog.h> 41#include <kdialog.h>
41#include <klocale.h> 42#include <klocale.h>
42#include <kdateedit.h> 43#include <kdateedit.h>
43#include <kglobal.h> 44#include <kglobal.h>
44#include <stdlib.h> 45#include <stdlib.h>
45 46
46/*US 47/*US
47#include <qcheckbox.h> 48#include <qcheckbox.h>
48#include <qframe.h> 49#include <qframe.h>
49#include <qpushbutton.h> 50#include <qpushbutton.h>
50#include <qcombobox.h> 51#include <qcombobox.h>
51#include <qlineedit.h> 52#include <qlineedit.h>
52#include <qlabel.h> 53#include <qlabel.h>
53#include <qfile.h> 54#include <qfile.h>
54 55
55#include <kconfig.h> 56#include <kconfig.h>
56#include <kdebug.h> 57#include <kdebug.h>
57#include <kdialog.h> 58#include <kdialog.h>
58#include <klistview.h> 59#include <klistview.h>
59#include <klocale.h> 60#include <klocale.h>
60#include <kglobal.h> 61#include <kglobal.h>
61#include <kmessagebox.h> 62#include <kmessagebox.h>
62#include <kstandarddirs.h> 63#include <kstandarddirs.h>
63 64
64#ifndef KAB_EMBEDDED 65#ifndef KAB_EMBEDDED
65#include <ktrader.h> 66#include <ktrader.h>
66#else // KAB_EMBEDDED 67#else // KAB_EMBEDDED
67#include <mergewidget.h> 68#include <mergewidget.h>
68#include <distributionlistwidget.h> 69#include <distributionlistwidget.h>
69#endif // KAB_EMBEDDED 70#endif // KAB_EMBEDDED
70 71
71#include "addresseewidget.h" 72#include "addresseewidget.h"
72#include "extensionconfigdialog.h" 73#include "extensionconfigdialog.h"
73#include "extensionwidget.h" 74#include "extensionwidget.h"
74*/ 75*/
75 76
76#include "qapplication.h" 77#include "qapplication.h"
77 78
78#include "kpimglobalprefs.h" 79#include "kpimglobalprefs.h"
79 80
80#include "kdepimconfigwidget.h" 81#include "kdepimconfigwidget.h"
81 82
82 83
83KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name ) 84KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
84 : KPrefsWidget(prefs, parent, name ) 85 : KPrefsWidget(prefs, parent, name )
85{ 86{
86 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 87 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
87 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 88 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
88 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 89 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
89 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 90 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
90 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 91 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
91 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 92 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
92 93
93 94
94 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 95 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
95 KDialog::spacingHint() ); 96 KDialog::spacingHint() );
96 97
97 tabWidget = new QTabWidget( this ); 98 tabWidget = new QTabWidget( this );
98 topLayout->addWidget( tabWidget ); 99 topLayout->addWidget( tabWidget );
99 100
100 101
101 setupLocaleTab(); 102 setupLocaleTab();
102 setupLocaleDateTab(); 103 setupLocaleDateTab();
103 setupTimeZoneTab(); 104 setupTimeZoneTab();
104 setupExternalAppTab(); 105 setupExternalAppTab();
105 106
106} 107}
107void KDEPIMConfigWidget::showTimeZoneTab() 108void KDEPIMConfigWidget::showTimeZoneTab()
108{ 109{
109 tabWidget->setCurrentPage ( 2 ) ; 110 tabWidget->setCurrentPage ( 2 ) ;
110} 111}
111void KDEPIMConfigWidget::setupExternalAppTab() 112void KDEPIMConfigWidget::setupExternalAppTab()
112{ 113{
113 QWidget *externalAppsPage = new QWidget( this ); 114 QWidget *externalAppsPage = new QWidget( this );
114 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 115 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
115 KDialog::spacingHintSmall() ); 116 KDialog::spacingHintSmall() );
116 117
117 mExternalApps = new QComboBox( externalAppsPage ); 118 mExternalApps = new QComboBox( externalAppsPage );
118 119
119 QMap<ExternalAppHandler::Types, QString>::Iterator it; 120 QMap<ExternalAppHandler::Types, QString>::Iterator it;
120 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 121 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
121 mExternalApps->insertItem( it.data(), it.key() ); 122 mExternalApps->insertItem( it.data(), it.key() );
122 123
123 layout->addWidget( mExternalApps ); 124 layout->addWidget( mExternalApps );
124 125
125 connect( mExternalApps, SIGNAL( activated( int ) ), 126 connect( mExternalApps, SIGNAL( activated( int ) ),
126 this, SLOT (externalapp_changed( int ) ) ); 127 this, SLOT (externalapp_changed( int ) ) );
127 128
128 129
129 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 130 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
130 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 131 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
131 132
132 133
133 mClient = new QComboBox( mExternalAppGroupBox ); 134 mClient = new QComboBox( mExternalAppGroupBox );
134 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 135 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
135 136
136 connect( mClient, SIGNAL( activated( int ) ), 137 connect( mClient, SIGNAL( activated( int ) ),
137 this, SLOT (client_changed( int ) ) ); 138 this, SLOT (client_changed( int ) ) );
138 139
139 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 140 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
140 boxLayout->addWidget( lab, 1, 0 ); 141 boxLayout->addWidget( lab, 1, 0 );
141 mChannel = new QLineEdit(mExternalAppGroupBox); 142 mChannel = new QLineEdit(mExternalAppGroupBox);
142 mChannel->setReadOnly(true); 143 mChannel->setReadOnly(true);
143 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); 144 boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 );
144 145
145 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); 146 lab = new QLabel( i18n("Message:"), mExternalAppGroupBox);
146 boxLayout->addWidget( lab, 3, 0 ); 147 boxLayout->addWidget( lab, 3, 0 );
147 mMessage = new QLineEdit(mExternalAppGroupBox); 148 mMessage = new QLineEdit(mExternalAppGroupBox);
148 mMessage->setReadOnly(true); 149 mMessage->setReadOnly(true);
149 boxLayout->addWidget( mMessage , 4, 0); 150 boxLayout->addWidget( mMessage , 4, 0);
150 151
151 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); 152 lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox);
152 boxLayout->addWidget( lab, 3, 1 ); 153 boxLayout->addWidget( lab, 3, 1 );
153 mParameters = new QLineEdit(mExternalAppGroupBox); 154 mParameters = new QLineEdit(mExternalAppGroupBox);
154 mParameters->setReadOnly(true); 155 mParameters->setReadOnly(true);
155 boxLayout->addWidget( mParameters, 4, 1 ); 156 boxLayout->addWidget( mParameters, 4, 1 );
156 157
157 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox); 158 lab = new QLabel( i18n("HINT: Delimiter=; Name=%1,Email=%2"), mExternalAppGroupBox);
158 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 ); 159 boxLayout->addMultiCellWidget( lab, 5, 5, 0, 1 );
159 160
160 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); 161 lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox);
161 boxLayout->addWidget( lab, 6, 0 ); 162 boxLayout->addWidget( lab, 6, 0 );
162 mMessage2 = new QLineEdit(mExternalAppGroupBox); 163 mMessage2 = new QLineEdit(mExternalAppGroupBox);
163 mMessage2->setReadOnly(true); 164 mMessage2->setReadOnly(true);
164 boxLayout->addWidget( mMessage2 , 7, 0); 165 boxLayout->addWidget( mMessage2 , 7, 0);
165 166
166 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); 167 lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox);
167 boxLayout->addWidget( lab, 6, 1 ); 168 boxLayout->addWidget( lab, 6, 1 );
168 mParameters2 = new QLineEdit(mExternalAppGroupBox); 169 mParameters2 = new QLineEdit(mExternalAppGroupBox);
169 mParameters2->setReadOnly(true); 170 mParameters2->setReadOnly(true);
170 boxLayout->addWidget( mParameters2, 7, 1 ); 171 boxLayout->addWidget( mParameters2, 7, 1 );
171 172
172 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 173 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
173 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 174 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
174 175
175 176
176 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 177 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
177 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 178 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
178 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 179 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
179 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 180 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
180 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 181 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
181 182
182 183
183 layout->addWidget( mExternalAppGroupBox ); 184 layout->addWidget( mExternalAppGroupBox );
184 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 185 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
185 186
186} 187}
187 188
188 189
189void KDEPIMConfigWidget::setupLocaleDateTab() 190void KDEPIMConfigWidget::setupLocaleDateTab()
190{ 191{
191 QWidget *topFrame = new QWidget( this ); 192 QWidget *topFrame = new QWidget( this );
192 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2); 193 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2);
193 194
194 topLayout->setSpacing(KDialog::spacingHint()); 195 topLayout->setSpacing(KDialog::spacingHint());
195 topLayout->setMargin(KDialog::marginHint()); 196 topLayout->setMargin(KDialog::marginHint());
196 int iii = 0; 197 int iii = 0;
197 198
198 199
199 KPrefsWidRadios *syncPrefsGroup = 200 KPrefsWidRadios *syncPrefsGroup =
200 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame); 201 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
201 QString format; 202 QString format;
202 if ( QApplication::desktop()->width() < 480 ) 203 if ( QApplication::desktop()->width() < 480 )
203 format = "(%d.%m.%Y)"; 204 format = "(%d.%m.%Y)";
204 else 205 else
205 format = "(%d.%m.%Y|%A %d %B %Y)"; 206 format = "(%d.%m.%Y|%A %d %B %Y)";
206 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format)); 207 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
207 if ( QApplication::desktop()->width() < 480 ) 208 if ( QApplication::desktop()->width() < 480 )
208 format = "(%m.%d.%Y)"; 209 format = "(%m.%d.%Y)";
209 else 210 else
210 format = "(%m.%d.%Y|%A %B %d %Y)"; 211 format = "(%m.%d.%Y|%A %B %d %Y)";
211 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format)); 212 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
212 if ( QApplication::desktop()->width() < 480 ) 213 if ( QApplication::desktop()->width() < 480 )
213 format = "(%Y-%m-%d)"; 214 format = "(%Y-%m-%d)";
214 else 215 else
215 format = "(%Y-%m-%d|%A %Y %B %d)"; 216 format = "(%Y-%m-%d|%A %Y %B %d)";
216 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format)); 217 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
217 syncPrefsGroup->addRadio(i18n("User defined")); 218 syncPrefsGroup->addRadio(i18n("User defined"));
218 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 219 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
219 ++iii; 220 ++iii;
220 ++iii; 221 ++iii;
221 QLabel * lab; 222 QLabel * lab;
222 mUserDateFormatLong = new QLineEdit(topFrame); 223 mUserDateFormatLong = new QLineEdit(topFrame);
223 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame); 224 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
224 topLayout->addWidget(lab ,iii,0); 225 topLayout->addWidget(lab ,iii,0);
225 topLayout->addWidget(mUserDateFormatLong,iii,1); 226 topLayout->addWidget(mUserDateFormatLong,iii,1);
226 ++iii; 227 ++iii;
227 mUserDateFormatShort = new QLineEdit(topFrame); 228 mUserDateFormatShort = new QLineEdit(topFrame);
228 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame); 229 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
229 topLayout->addWidget(lab ,iii,0); 230 topLayout->addWidget(lab ,iii,0);
230 topLayout->addWidget(mUserDateFormatShort,iii,1); 231 topLayout->addWidget(mUserDateFormatShort,iii,1);
231 ++iii; 232 ++iii;
232 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame); 233 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
233 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 234 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
234 ++iii; 235 ++iii;
235 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame); 236 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
236 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 237 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
237 ++iii; 238 ++iii;
238 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame); 239 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
239 topLayout->addMultiCellWidget(lab ,iii,iii,0,1); 240 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
240 ++iii; 241 ++iii;
241 242
242 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 243 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
243 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 244 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
244 245
245 246
246 tabWidget->addTab( topFrame, i18n( "Date Format" ) ); 247 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
247} 248}
248 249
249void KDEPIMConfigWidget::setupLocaleTab() 250void KDEPIMConfigWidget::setupLocaleTab()
250{ 251{
251 252
252 QWidget *topFrame = new QWidget( this ); 253 QWidget *topFrame = new QWidget( this );
253 QGridLayout *topLayout = new QGridLayout(topFrame,4,2); 254 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
254 255
255 topLayout->setSpacing(KDialog::spacingHint()); 256 topLayout->setSpacing(KDialog::spacingHint());
256 topLayout->setMargin(KDialog::marginHint()); 257 topLayout->setMargin(KDialog::marginHint());
257 int iii = 0; 258 int iii = 0;
258 KPrefsWidRadios *syncPrefsGroup = 259 KPrefsWidRadios *syncPrefsGroup =
259 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame); 260 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
260 syncPrefsGroup->addRadio(i18n("English")); 261 syncPrefsGroup->addRadio(i18n("English"));
261 syncPrefsGroup->addRadio(i18n("German")); 262 syncPrefsGroup->addRadio(i18n("German"));
262 syncPrefsGroup->addRadio(i18n("French")); 263 syncPrefsGroup->addRadio(i18n("French"));
263 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)")); 264 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
264 if ( QApplication::desktop()->width() < 300 ) 265 if ( QApplication::desktop()->width() < 300 )
265 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical); 266 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
266 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1); 267 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
267 ++iii; 268 ++iii;
268 269
269 syncPrefsGroup = 270 syncPrefsGroup =
270 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame); 271 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
271 if ( QApplication::desktop()->width() > 300 ) 272 if ( QApplication::desktop()->width() > 300 )
272 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 273 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
273 syncPrefsGroup->addRadio(i18n("24:00")); 274 syncPrefsGroup->addRadio(i18n("24:00"));
274 syncPrefsGroup->addRadio(i18n("12:00am")); 275 syncPrefsGroup->addRadio(i18n("12:00am"));
275 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical); 276 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
276 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1); 277 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
277 ++iii; 278 ++iii;
278 279
279 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"), 280 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
280 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame); 281 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
281 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 282 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
282 ++iii; 283 ++iii;
283 284
284 285
285 tabWidget->addTab( topFrame, i18n( "Locale" ) ); 286 tabWidget->addTab( topFrame, i18n( "Locale" ) );
286 287
287} 288}
288 289
289 290
290void KDEPIMConfigWidget::setupTimeZoneTab() 291void KDEPIMConfigWidget::setupTimeZoneTab()
291{ 292{
292 QWidget *topFrame = new QWidget( this ); 293 QWidget *topFrame = new QWidget( this );
293 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2); 294 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2);
294 topLayout->setSpacing(KDialog::spacingHint()); 295 topLayout->setSpacing(KDialog::spacingHint());
295 topLayout->setMargin(KDialog::marginHint()); 296 topLayout->setMargin(KDialog::marginHint());
296 297
297 QHBox *timeZoneBox = new QHBox( topFrame ); 298 QHBox *timeZoneBox = new QHBox( topFrame );
298 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 ); 299 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
299 300
300 new QLabel( i18n("Timezone:"), timeZoneBox ); 301 new QLabel( i18n("Timezone:"), timeZoneBox );
301 mTimeZoneCombo = new QComboBox( timeZoneBox ); 302 mTimeZoneCombo = new QComboBox( timeZoneBox );
302 if ( QApplication::desktop()->width() < 300 ) { 303 if ( QApplication::desktop()->width() < 300 ) {
303 mTimeZoneCombo->setMaximumWidth(150); 304 mTimeZoneCombo->setMaximumWidth(150);
304 } 305 }
305 306
306 QStringList list; 307 QStringList list;
307 list = KGlobal::locale()->timeZoneList(); 308 list = KGlobal::locale()->timeZoneList();
308 mTimeZoneCombo->insertStringList(list); 309 mTimeZoneCombo->insertStringList(list);
309 310
310 // find the currently set time zone and select it 311 // find the currently set time zone and select it
311 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId; 312 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
312 int nCurrentlySet = 11; 313 int nCurrentlySet = 11;
313 for (int i = 0; i < mTimeZoneCombo->count(); i++) 314 for (int i = 0; i < mTimeZoneCombo->count(); i++)
314 { 315 {
315 if (mTimeZoneCombo->text(i) == sCurrentlySet) 316 if (mTimeZoneCombo->text(i) == sCurrentlySet)
316 { 317 {
317 nCurrentlySet = i; 318 nCurrentlySet = i;
318 break; 319 break;
319 } 320 }
320 } 321 }
321 mTimeZoneCombo->setCurrentItem(nCurrentlySet); 322 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
322 int iii = 1; 323 int iii = 1;
323 KPrefsWidBool *sb = 324 KPrefsWidBool *sb =
324 addWidBool(i18n("Timezone has daylight saving"), 325 addWidBool(i18n("Timezone has daylight saving"),
325 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame); 326 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
326 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1); 327 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
327 ++iii; 328 ++iii;
328 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame ); 329 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
329 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 330 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
330 ++iii; 331 ++iii;
331 lab = new QLabel( i18n("The year in the date is ignored."), topFrame ); 332 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
332 topLayout->addMultiCellWidget(lab, iii,iii,0,1); 333 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
333 ++iii; 334 ++iii;
334 lab = new QLabel( i18n("Daylight start:"), topFrame ); 335 lab = new QLabel( i18n("Daylight start:"), topFrame );
335 topLayout->addWidget(lab, iii,0); 336 topLayout->addWidget(lab, iii,0);
336 mStartDateSavingEdit = new KDateEdit(topFrame); 337 mStartDateSavingEdit = new KDateEdit(topFrame);
337 topLayout->addWidget(mStartDateSavingEdit, iii,1); 338 topLayout->addWidget(mStartDateSavingEdit, iii,1);
338 ++iii; 339 ++iii;
339 340
340 lab = new QLabel( i18n("Daylight end:"), topFrame ); 341 lab = new QLabel( i18n("Daylight end:"), topFrame );
341 topLayout->addWidget(lab, iii,0); 342 topLayout->addWidget(lab, iii,0);
342 mEndDateSavingEdit = new KDateEdit(topFrame); 343 mEndDateSavingEdit = new KDateEdit(topFrame);
343 topLayout->addWidget(mEndDateSavingEdit, iii,1); 344 topLayout->addWidget(mEndDateSavingEdit, iii,1);
344 ++iii; 345 ++iii;
345 QDate current ( 2001, 1,1); 346 QDate current ( 2001, 1,1);
346 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1)); 347 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
347 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1)); 348 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
348 349
349 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 350 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
350 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) ); 351 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
351 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) ); 352 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
352 353
353 354
354 355
355 tabWidget->addTab( topFrame, i18n( "Time Zone" ) ); 356 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
356 357
357} 358}
358 359
359void KDEPIMConfigWidget::externalapp_changed( int newApp ) 360void KDEPIMConfigWidget::externalapp_changed( int newApp )
360{ 361{
361 // first store the current data 362 // first store the current data
362 saveEditFieldSettings(); 363 saveEditFieldSettings();
363 364
364 // set mCurrentApp 365 // set mCurrentApp
365 mCurrentApp = (ExternalAppHandler::Types)newApp; 366 mCurrentApp = (ExternalAppHandler::Types)newApp;
366 367
367 // set mCurrentClient 368 // set mCurrentClient
368 switch(mCurrentApp) 369 switch(mCurrentApp)
369 { 370 {
370 case(ExternalAppHandler::EMAIL): 371 case(ExternalAppHandler::EMAIL):
371 mCurrentClient = mEmailClient; 372 mCurrentClient = mEmailClient;
372 break; 373 break;
373 case(ExternalAppHandler::PHONE): 374 case(ExternalAppHandler::PHONE):
374 mCurrentClient = mPhoneClient; 375 mCurrentClient = mPhoneClient;
375 break; 376 break;
376 case(ExternalAppHandler::SMS): 377 case(ExternalAppHandler::SMS):
377 mCurrentClient = mSMSClient; 378 mCurrentClient = mSMSClient;
378 break; 379 break;
379 case(ExternalAppHandler::FAX): 380 case(ExternalAppHandler::FAX):
380 mCurrentClient = mFaxClient; 381 mCurrentClient = mFaxClient;
381 break; 382 break;
382 case(ExternalAppHandler::PAGER): 383 case(ExternalAppHandler::PAGER):
383 mCurrentClient = mPagerClient; 384 mCurrentClient = mPagerClient;
384 break; 385 break;
385 case(ExternalAppHandler::SIP): 386 case(ExternalAppHandler::SIP):
386 mCurrentClient = mSipClient; 387 mCurrentClient = mSipClient;
387 break; 388 break;
388 default: 389 default:
389 return; 390 return;
390 } 391 }
391 392
392 // and at last update the widgets 393 // and at last update the widgets
393 updateClientWidgets(); 394 updateClientWidgets();
394} 395}
395 396
396 397
397 398
398void KDEPIMConfigWidget::client_changed( int newClient ) 399void KDEPIMConfigWidget::client_changed( int newClient )
399{ 400{
400 if (newClient == mCurrentClient) 401 if (newClient == mCurrentClient)
401 return; 402 return;
402 403
403 // first store the current data 404 // first store the current data
404 saveEditFieldSettings(); 405 saveEditFieldSettings();
405 406
406 407
407 //then reset the clientvariable 408 //then reset the clientvariable
408 mCurrentClient = newClient; 409 mCurrentClient = newClient;
409 410
410 // and at last update the widgets 411 // and at last update the widgets
411 updateClientWidgets(); 412 updateClientWidgets();
412 413
413 KPrefsWidget::modified(); 414 KPrefsWidget::modified();
414} 415}
415 416
416void KDEPIMConfigWidget::saveEditFieldSettings() 417void KDEPIMConfigWidget::saveEditFieldSettings()
417{ 418{
418 419
419 switch(mCurrentApp) 420 switch(mCurrentApp)
420 { 421 {
421 case(ExternalAppHandler::EMAIL): 422 case(ExternalAppHandler::EMAIL):
422 mEmailClient = mClient->currentItem(); 423 mEmailClient = mClient->currentItem();
423 break; 424 break;
424 case(ExternalAppHandler::PHONE): 425 case(ExternalAppHandler::PHONE):
425 mPhoneClient= mClient->currentItem(); 426 mPhoneClient= mClient->currentItem();
426 break; 427 break;
427 case(ExternalAppHandler::SMS): 428 case(ExternalAppHandler::SMS):
428 mSMSClient = mClient->currentItem(); 429 mSMSClient = mClient->currentItem();
429 break; 430 break;
430 case(ExternalAppHandler::FAX): 431 case(ExternalAppHandler::FAX):
431 mFaxClient = mClient->currentItem(); 432 mFaxClient = mClient->currentItem();
432 break; 433 break;
433 case(ExternalAppHandler::PAGER): 434 case(ExternalAppHandler::PAGER):
434 mPagerClient = mClient->currentItem(); 435 mPagerClient = mClient->currentItem();
435 break; 436 break;
436 case(ExternalAppHandler::SIP): 437 case(ExternalAppHandler::SIP):
437 mSipClient = mClient->currentItem(); 438 mSipClient = mClient->currentItem();
438 break; 439 break;
439 default: 440 default:
440 return; 441 return;
441 } 442 }
442 443
443 //store the current data back to the apropriate membervariables if we had set it to "other" 444 //store the current data back to the apropriate membervariables if we had set it to "other"
444 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 445 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
445 { 446 {
446 mEmailOtherChannel = mChannel->text(); 447 mEmailOtherChannel = mChannel->text();
447 mEmailOtherMessage = mMessage->text(); 448 mEmailOtherMessage = mMessage->text();
448 mEmailOtherMessageParameters = mParameters->text(); 449 mEmailOtherMessageParameters = mParameters->text();
449 mEmailOtherMessage2 = mMessage2->text(); 450 mEmailOtherMessage2 = mMessage2->text();
450 mEmailOtherMessageParameters2 = mParameters2->text(); 451 mEmailOtherMessageParameters2 = mParameters2->text();
451 } 452 }
452 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 453 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
453 { 454 {
454 mPhoneOtherChannel = mChannel->text(); 455 mPhoneOtherChannel = mChannel->text();
455 mPhoneOtherMessage = mMessage->text(); 456 mPhoneOtherMessage = mMessage->text();
456 mPhoneOtherMessageParameters = mParameters->text(); 457 mPhoneOtherMessageParameters = mParameters->text();
457 } 458 }
458 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 459 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
459 { 460 {
460 mSMSOtherChannel = mChannel->text(); 461 mSMSOtherChannel = mChannel->text();
461 mSMSOtherMessage = mMessage->text(); 462 mSMSOtherMessage = mMessage->text();
462 mSMSOtherMessageParameters = mParameters->text(); 463 mSMSOtherMessageParameters = mParameters->text();
463 } 464 }
464 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 465 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
465 { 466 {
466 mFaxOtherChannel = mChannel->text(); 467 mFaxOtherChannel = mChannel->text();
467 mFaxOtherMessage = mMessage->text(); 468 mFaxOtherMessage = mMessage->text();
468 mFaxOtherMessageParameters = mParameters->text(); 469 mFaxOtherMessageParameters = mParameters->text();
469 } 470 }
470 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 471 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
471 { 472 {
472 mPagerOtherChannel = mChannel->text(); 473 mPagerOtherChannel = mChannel->text();
473 mPagerOtherMessage = mMessage->text(); 474 mPagerOtherMessage = mMessage->text();
474 mPagerOtherMessageParameters = mParameters->text(); 475 mPagerOtherMessageParameters = mParameters->text();
475 } 476 }
476 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 477 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
477 { 478 {
478 mSipOtherChannel = mChannel->text(); 479 mSipOtherChannel = mChannel->text();
479 mSipOtherMessage = mMessage->text(); 480 mSipOtherMessage = mMessage->text();
480 mSipOtherMessageParameters = mParameters->text(); 481 mSipOtherMessageParameters = mParameters->text();
481 } 482 }
482 483
483 484
484} 485}
485 486
486void KDEPIMConfigWidget::updateClientWidgets() 487void KDEPIMConfigWidget::updateClientWidgets()
487{ 488{
488 bool blocked = signalsBlocked(); 489 bool blocked = signalsBlocked();
489 blockSignals( true ); 490 blockSignals( true );
490 491
491 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display 492 // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display
492 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); 493 QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp );
493 if (it == mExternalAppsMap.end()) 494 if (it == mExternalAppsMap.end())
494 return; 495 return;
495 496
496 // update group box 497 // update group box
497 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); 498 mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data()));
498 499
499 //update the entries in the client combobox 500 //update the entries in the client combobox
500 mClient->clear(); 501 mClient->clear();
501 502
502 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); 503 QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp);
503 DefaultAppItem* dai; 504 DefaultAppItem* dai;
504 for ( dai=items.first(); dai != 0; dai=items.next() ) 505 for ( dai=items.first(); dai != 0; dai=items.next() )
505 { 506 {
506 mClient->insertItem( i18n(dai->_label), dai->_id ); 507 mClient->insertItem( i18n(dai->_label), dai->_id );
507 508
508 if (dai->_id == mCurrentClient) 509 if (dai->_id == mCurrentClient)
509 { 510 {
510 //restore the edit fields with the data of the local membervariables if we had set it to "other". 511 //restore the edit fields with the data of the local membervariables if we had set it to "other".
511 //Otherwise take the default data from externalapphandler. 512 //Otherwise take the default data from externalapphandler.
512 mChannel->setText(dai->_channel); 513 mChannel->setText(dai->_channel);
513 mMessage->setText(dai->_message); 514 mMessage->setText(dai->_message);
514 mParameters->setText(dai->_parameters); 515 mParameters->setText(dai->_parameters);
515 mMessage2->setText(dai->_message2); 516 mMessage2->setText(dai->_message2);
516 mParameters2->setText(dai->_parameters2); 517 mParameters2->setText(dai->_parameters2);
517 518
518 519
519 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 520 if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
520 { 521 {
521 mChannel->setText(mEmailOtherChannel); 522 mChannel->setText(mEmailOtherChannel);
522 mMessage->setText(mEmailOtherMessage); 523 mMessage->setText(mEmailOtherMessage);
523 mParameters->setText(mEmailOtherMessageParameters); 524 mParameters->setText(mEmailOtherMessageParameters);
524 mMessage2->setText(mEmailOtherMessage2); 525 mMessage2->setText(mEmailOtherMessage2);
525 mParameters2->setText(mEmailOtherMessageParameters2); 526 mParameters2->setText(mEmailOtherMessageParameters2);
526 } 527 }
527 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 528 else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
528 { 529 {
529 mChannel->setText(mPhoneOtherChannel); 530 mChannel->setText(mPhoneOtherChannel);
530 mMessage->setText(mPhoneOtherMessage); 531 mMessage->setText(mPhoneOtherMessage);
531 mParameters->setText(mPhoneOtherMessageParameters); 532 mParameters->setText(mPhoneOtherMessageParameters);
532 } 533 }
533 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 534 else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
534 { 535 {
535 mChannel->setText(mSMSOtherChannel); 536 mChannel->setText(mSMSOtherChannel);
536 mMessage->setText(mSMSOtherMessage); 537 mMessage->setText(mSMSOtherMessage);
537 mParameters->setText(mSMSOtherMessageParameters); 538 mParameters->setText(mSMSOtherMessageParameters);
538 } 539 }
539 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 540 else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
540 { 541 {
541 mChannel->setText(mFaxOtherChannel); 542 mChannel->setText(mFaxOtherChannel);
542 mMessage->setText(mFaxOtherMessage); 543 mMessage->setText(mFaxOtherMessage);
543 mParameters->setText(mFaxOtherMessageParameters); 544 mParameters->setText(mFaxOtherMessageParameters);
544 } 545 }
545 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 546 else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
546 { 547 {
547 mChannel->setText(mPagerOtherChannel); 548 mChannel->setText(mPagerOtherChannel);
548 mMessage->setText(mPagerOtherMessage); 549 mMessage->setText(mPagerOtherMessage);
549 mParameters->setText(mPagerOtherMessageParameters); 550 mParameters->setText(mPagerOtherMessageParameters);
550 } 551 }
551 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)) 552 else if ((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))
552 { 553 {
553 mChannel->setText(mSipOtherChannel); 554 mChannel->setText(mSipOtherChannel);
554 mMessage->setText(mSipOtherMessage); 555 mMessage->setText(mSipOtherMessage);
555 mParameters->setText(mSipOtherMessageParameters); 556 mParameters->setText(mSipOtherMessageParameters);
556 } 557 }
557 } 558 }
558 559
559 } 560 }
560 561
561 bool readonly; 562 bool readonly;
562 bool enabled; 563 bool enabled;
563 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) 564 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC))
564 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) 565 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC))
565 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) 566 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC))
566 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) 567 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC))
567 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) 568 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))
568 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC))) 569 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::OTHER_SIC)))
569 { 570 {
570 readonly = false; 571 readonly = false;
571 } 572 }
572 else 573 else
573 { 574 {
574 readonly = true; 575 readonly = true;
575 } 576 }
576 577
577 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) 578 if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC))
578 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) 579 ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC))
579 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) 580 ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC))
580 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) 581 ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC))
581 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC)) 582 ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))
582 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC))) 583 ||((mCurrentApp == ExternalAppHandler::SIP) && (mCurrentClient == KPimGlobalPrefs::NONE_SIC)))
583 { 584 {
584 enabled = false; 585 enabled = false;
585 } 586 }
586 else 587 else
587 { 588 {
588 enabled = true; 589 enabled = true;
589 } 590 }
590 591
591 592
592 mChannel->setReadOnly(readonly); 593 mChannel->setReadOnly(readonly);
593 mMessage->setReadOnly(readonly); 594 mMessage->setReadOnly(readonly);
594 mParameters->setReadOnly(readonly); 595 mParameters->setReadOnly(readonly);
595 mMessage2->setReadOnly(readonly); 596 mMessage2->setReadOnly(readonly);
596 mParameters2->setReadOnly(readonly); 597 mParameters2->setReadOnly(readonly);
597 598
598 mChannel->setEnabled(enabled); 599 mChannel->setEnabled(enabled);
599 mMessage->setEnabled(enabled); 600 mMessage->setEnabled(enabled);
600 mParameters->setEnabled(enabled); 601 mParameters->setEnabled(enabled);
601 mMessage2->setEnabled(enabled); 602 mMessage2->setEnabled(enabled);
602 mParameters2->setEnabled(enabled); 603 mParameters2->setEnabled(enabled);
603 604
604 605
605 606
606 mClient->setCurrentItem(mCurrentClient); 607 mClient->setCurrentItem(mCurrentClient);
607 608
608 609
609 // enable/disable the extra message/parameter field 610 // enable/disable the extra message/parameter field
610 if (mCurrentApp == ExternalAppHandler::EMAIL) 611 if (mCurrentApp == ExternalAppHandler::EMAIL)
611 { 612 {
612 } 613 }
613 else 614 else
614 { 615 {
615 mMessage2->setText( "" ); 616 mMessage2->setText( "" );
616 mParameters2->setText( "" ); 617 mParameters2->setText( "" );
617 } 618 }
618 619
619 if (enabled == true) { 620 if (enabled == true) {
620 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 621 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
621 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 622 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
622 } 623 }
623 624
624 625
625 blockSignals( blocked ); 626 blockSignals( blocked );
626 627
627} 628}
628 629
629void KDEPIMConfigWidget::usrReadConfig() 630void KDEPIMConfigWidget::usrReadConfig()
630{ 631{
631 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 632 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
632 633
633 bool blocked = signalsBlocked(); 634 bool blocked = signalsBlocked();
634 blockSignals( true ); 635 blockSignals( true );
635 636
636 QString dummy = prefs->mUserDateFormatLong; 637 QString dummy = prefs->mUserDateFormatLong;
637 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") )); 638 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
638 dummy = prefs->mUserDateFormatShort; 639 dummy = prefs->mUserDateFormatShort;
639 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") )); 640 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
640 641
641 QDate current ( 2001, 1,1); 642 QDate current ( 2001, 1,1);
642 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1)); 643 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
643 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1)); 644 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
644 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId)); 645 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
645 646
646 647
647 648
648 649
649 mEmailClient = prefs->mEmailClient; 650 mEmailClient = prefs->mEmailClient;
650 mEmailOtherChannel = prefs->mEmailOtherChannel; 651 mEmailOtherChannel = prefs->mEmailOtherChannel;
651 mEmailOtherMessage = prefs->mEmailOtherMessage; 652 mEmailOtherMessage = prefs->mEmailOtherMessage;
652 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 653 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
653 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 654 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
654 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 655 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
655 656
656 mPhoneClient = prefs->mPhoneClient; 657 mPhoneClient = prefs->mPhoneClient;
657 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 658 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
658 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 659 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
659 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 660 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
660 661
661 mFaxClient = prefs->mFaxClient; 662 mFaxClient = prefs->mFaxClient;
662 mFaxOtherChannel = prefs->mFaxOtherChannel; 663 mFaxOtherChannel = prefs->mFaxOtherChannel;
663 mFaxOtherMessage = prefs->mFaxOtherMessage; 664 mFaxOtherMessage = prefs->mFaxOtherMessage;
664 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; 665 mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters;
665 666
666 mSMSClient = prefs->mSMSClient; 667 mSMSClient = prefs->mSMSClient;
667 mSMSOtherChannel = prefs->mSMSOtherChannel; 668 mSMSOtherChannel = prefs->mSMSOtherChannel;
668 mSMSOtherMessage = prefs->mSMSOtherMessage; 669 mSMSOtherMessage = prefs->mSMSOtherMessage;
669 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; 670 mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters;
670 671
671 mPagerClient = prefs->mPagerClient; 672 mPagerClient = prefs->mPagerClient;
672 mPagerOtherChannel = prefs->mPagerOtherChannel; 673 mPagerOtherChannel = prefs->mPagerOtherChannel;
673 mPagerOtherMessage = prefs->mPagerOtherMessage; 674 mPagerOtherMessage = prefs->mPagerOtherMessage;
674 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; 675 mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters;
675 676
676 mSipClient = prefs->mPagerClient; 677 mSipClient = prefs->mPagerClient;
677 mSipOtherChannel = prefs->mSipOtherChannel; 678 mSipOtherChannel = prefs->mSipOtherChannel;
678 mSipOtherMessage = prefs->mSipOtherMessage; 679 mSipOtherMessage = prefs->mSipOtherMessage;
679 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 680 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
680 681
681 mCurrentApp = ExternalAppHandler::EMAIL; 682 mCurrentApp = ExternalAppHandler::EMAIL;
682 mCurrentClient = mEmailClient; 683 mCurrentClient = mEmailClient;
683 684
684 updateClientWidgets(); 685 updateClientWidgets();
685 686
686 blockSignals( blocked ); 687 blockSignals( blocked );
687 688
688} 689}
689 690
690void KDEPIMConfigWidget::usrWriteConfig() 691void KDEPIMConfigWidget::usrWriteConfig()
691{ 692{
692 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance(); 693 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
693 694
694 saveEditFieldSettings(); 695 saveEditFieldSettings();
695 696
696 697
697 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") ); 698 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
698 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") ); 699 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
699 700
700 prefs->mTimeZoneId = mTimeZoneCombo->currentText(); 701 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
701 QDate date; 702 QDate date;
702 date = mStartDateSavingEdit->date(); 703 date = mStartDateSavingEdit->date();
703 int sub = 0; 704 int sub = 0;
704 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 705 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
705 sub = 1; 706 sub = 1;
706 prefs->mDaylightsavingStart = date.dayOfYear()-sub; 707 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
707 date = mEndDateSavingEdit->date(); 708 date = mEndDateSavingEdit->date();
708 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 ) 709 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
709 sub = 1; 710 sub = 1;
710 else 711 else
711 sub = 0; 712 sub = 0;
712 prefs->mDaylightsavingEnd = date.dayOfYear()-sub; 713 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
713 714
714 715
715 prefs->mEmailClient = mEmailClient; 716 prefs->mEmailClient = mEmailClient;
716 prefs->mEmailOtherChannel = mEmailOtherChannel; 717 prefs->mEmailOtherChannel = mEmailOtherChannel;
717 prefs->mEmailOtherMessage = mEmailOtherMessage; 718 prefs->mEmailOtherMessage = mEmailOtherMessage;
718 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 719 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
719 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 720 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
720 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 721 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
721 722
722 prefs->mPhoneClient = mPhoneClient; 723 prefs->mPhoneClient = mPhoneClient;
723 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 724 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
724 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 725 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
725 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 726 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
726 727
727 prefs->mFaxClient = mFaxClient; 728 prefs->mFaxClient = mFaxClient;
728 prefs->mFaxOtherChannel = mFaxOtherChannel; 729 prefs->mFaxOtherChannel = mFaxOtherChannel;
729 prefs->mFaxOtherMessage = mFaxOtherMessage; 730 prefs->mFaxOtherMessage = mFaxOtherMessage;
730 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; 731 prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters;
731 732
732 prefs->mSMSClient = mSMSClient; 733 prefs->mSMSClient = mSMSClient;
733 prefs->mSMSOtherChannel = mSMSOtherChannel; 734 prefs->mSMSOtherChannel = mSMSOtherChannel;
734 prefs->mSMSOtherMessage = mSMSOtherMessage; 735 prefs->mSMSOtherMessage = mSMSOtherMessage;
735 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; 736 prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters;
736 737
737 prefs->mPagerClient = mPagerClient; 738 prefs->mPagerClient = mPagerClient;
738 prefs->mPagerOtherChannel = mPagerOtherChannel; 739 prefs->mPagerOtherChannel = mPagerOtherChannel;
739 prefs->mPagerOtherMessage = mPagerOtherMessage; 740 prefs->mPagerOtherMessage = mPagerOtherMessage;
740 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 741 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
741 742
742 743
743 prefs->mSipClient = mSipClient; 744 prefs->mSipClient = mSipClient;
744 prefs->mSipOtherChannel = mSipOtherChannel; 745 prefs->mSipOtherChannel = mSipOtherChannel;
745 prefs->mSipOtherMessage = mSipOtherMessage; 746 prefs->mSipOtherMessage = mSipOtherMessage;
746 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 747 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
747 748
748 //release the cache that other views can access the changed values instantanious 749 //release the cache that other views can access the changed values instantanious
749 ExternalAppHandler::instance()->loadConfig(); 750 ExternalAppHandler::instance()->loadConfig();
750 KPimGlobalPrefs::instance()->setGlobalConfig(); 751 KPimGlobalPrefs::instance()->setGlobalConfig();
751} 752}
752 753
753 754
754void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text, 755void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
755 const QStringList *tags) 756 const QStringList *tags)
756{ 757{
757 if (tags) { 758 if (tags) {
758 int i = tags->findIndex(text); 759 int i = tags->findIndex(text);
759 if (i > 0) combo->setCurrentItem(i); 760 if (i > 0) combo->setCurrentItem(i);
760 } else { 761 } else {
761 for(int i=0;i<combo->count();++i) { 762 for(int i=0;i<combo->count();++i) {
762 if (combo->text(i) == text) { 763 if (combo->text(i) == text) {
763 combo->setCurrentItem(i); 764 combo->setCurrentItem(i);
764 break; 765 break;
765 } 766 }
766 } 767 }
767 } 768 }
768} 769}
769 770
770 771
771void KDEPIMConfigWidget::textChanged( const QString& text ) 772void KDEPIMConfigWidget::textChanged( const QString& text )
772{ 773{
773 emit changed( true ); 774 emit changed( true );
774} 775}
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index a896a0f..b2b7663 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,132 +1,133 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 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/* 24/*
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 <kglobal.h> 31#include <kglobal.h>
32#include <kconfig.h> 32#include <kconfig.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kstaticdeleter.h> 35#include <kstaticdeleter.h>
36 36
37#include <qregexp.h>
37#include "kpimglobalprefs.h" 38#include "kpimglobalprefs.h"
38 39
39KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
40static KStaticDeleter<KPimGlobalPrefs> staticDeleter; 41static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
41 42
42 43
43KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
44 : KPrefs("microkdeglobalrc") 45 : KPrefs("microkdeglobalrc")
45{ 46{
46 47
47 KPrefs::setCurrentGroup("Locale"); 48 KPrefs::setCurrentGroup("Locale");
48 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 49 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
49 addItemInt("PreferredTime",&mPreferredTime,0); 50 addItemInt("PreferredTime",&mPreferredTime,0);
50 addItemInt("PreferredDate",&mPreferredDate,0); 51 addItemInt("PreferredDate",&mPreferredDate,0);
51 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 52 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
52 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); 53 //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
53 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 54 // addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
54 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 55 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
55 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 56 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
56 57
57 KPrefs::setCurrentGroup("Time & Date"); 58 KPrefs::setCurrentGroup("Time & Date");
58 59
59 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 60 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
60 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 61 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
61 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 62 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
62 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 63 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
63 64
64 65
65 66
66 67
67 KPrefs::setCurrentGroup( "ExternalApplications" ); 68 KPrefs::setCurrentGroup( "ExternalApplications" );
68 69
69 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); 70 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC );
70 addItemString( "EmailChannel", &mEmailOtherChannel, "" ); 71 addItemString( "EmailChannel", &mEmailOtherChannel, "" );
71 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); 72 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
72 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); 73 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
73 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); 74 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
74 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); 75 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
75 76
76 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); 77 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC );
77 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); 78 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
78 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); 79 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
79 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); 80 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
80 81
81 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); 82 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
82 addItemString( "FaxChannel", &mFaxOtherChannel, "" ); 83 addItemString( "FaxChannel", &mFaxOtherChannel, "" );
83 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); 84 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
84 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); 85 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
85 86
86 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); 87 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
87 addItemString( "SMSChannel", &mSMSOtherChannel, "" ); 88 addItemString( "SMSChannel", &mSMSOtherChannel, "" );
88 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); 89 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
89 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); 90 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
90 91
91 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); 92 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
92 addItemString( "PagerChannel", &mPagerOtherChannel, "" ); 93 addItemString( "PagerChannel", &mPagerOtherChannel, "" );
93 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); 94 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
94 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); 95 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
95 96
96 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC ); 97 addItemInt( "SIPChannelType", &mSipClient, NONE_SIC );
97 addItemString( "SIPChannel", &mSipOtherChannel, "" ); 98 addItemString( "SIPChannel", &mSipOtherChannel, "" );
98 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 99 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
99 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 100 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
100 101
101} 102}
102 103
103void KPimGlobalPrefs::setGlobalConfig() 104void KPimGlobalPrefs::setGlobalConfig()
104{ 105{
105 106
106 KGlobal::locale()->setHore24Format( !mPreferredTime ); 107 KGlobal::locale()->setHore24Format( !mPreferredTime );
107 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 108 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
108 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 109 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
109 KGlobal::locale()->setLanguage( mPreferredLanguage ); 110 KGlobal::locale()->setLanguage( mPreferredLanguage );
110 QString dummy = mUserDateFormatLong; 111 QString dummy = mUserDateFormatLong;
111 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 112 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
112 dummy = mUserDateFormatShort; 113 dummy = mUserDateFormatShort;
113 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 114 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
114 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 115 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
115 mDaylightsavingStart, 116 mDaylightsavingStart,
116 mDaylightsavingEnd ); 117 mDaylightsavingEnd );
117 KGlobal::locale()->setTimezone( mTimeZoneId ); 118 KGlobal::locale()->setTimezone( mTimeZoneId );
118 119
119} 120}
120KPimGlobalPrefs::~KPimGlobalPrefs() 121KPimGlobalPrefs::~KPimGlobalPrefs()
121{ 122{
122} 123}
123 124
124KPimGlobalPrefs *KPimGlobalPrefs::instance() 125KPimGlobalPrefs *KPimGlobalPrefs::instance()
125{ 126{
126 if ( !sInstance ) { 127 if ( !sInstance ) {
127 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); 128 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() );
128 sInstance->readConfig(); 129 sInstance->readConfig();
129 } 130 }
130 131
131 return sInstance; 132 return sInstance;
132} 133}
diff --git a/libkdepim/kprefswidget.h b/libkdepim/kprefswidget.h
index 8a24515..8543a39 100644
--- a/libkdepim/kprefswidget.h
+++ b/libkdepim/kprefswidget.h
@@ -1,454 +1,455 @@
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// $Id$ 23// $Id$
24 24
25#ifndef _KPREFSWIDGET_H 25#ifndef _KPREFSWIDGET_H
26#define _KPREFSWIDGET_H 26#define _KPREFSWIDGET_H
27 27
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qlineedit.h> 29#include <qlineedit.h>
30#include <qpushbutton.h>
30 31
31#include <qwidget.h> 32#include <qwidget.h>
32 33
33class KPrefs; 34class KPrefs;
34 35
35class KColorButton; 36class KColorButton;
36class QCheckBox; 37class QCheckBox;
37class QLabel; 38class QLabel;
38class QSpinBox; 39class QSpinBox;
39class QButtonGroup; 40class QButtonGroup;
40 41
41/** 42/**
42 @short Base class for widgets used by @ref KPrefsDialog. 43 @short Base class for widgets used by @ref KPrefsDialog.
43 @author Cornelius Schumacher 44 @author Cornelius Schumacher
44 @see KPrefsDialog 45 @see KPrefsDialog
45 46
46 This class provides the interface for the preferences widgets used by 47 This class provides the interface for the preferences widgets used by
47 KPrefsDialog. 48 KPrefsDialog.
48*/ 49*/
49class KPrefsWid : public QObject 50class KPrefsWid : public QObject
50{ 51{
51 Q_OBJECT 52 Q_OBJECT
52 public: 53 public:
53 /** 54 /**
54 This function is called to read value of the setting from the 55 This function is called to read value of the setting from the
55 stored configuration and display it in the widget. 56 stored configuration and display it in the widget.
56 */ 57 */
57 virtual void readConfig() = 0; 58 virtual void readConfig() = 0;
58 /** 59 /**
59 This function is called to write the current setting of the widget to the 60 This function is called to write the current setting of the widget to the
60 stored configuration. 61 stored configuration.
61 */ 62 */
62 virtual void writeConfig() = 0; 63 virtual void writeConfig() = 0;
63 64
64 //connect to this signal if you want to be notified of changes 65 //connect to this signal if you want to be notified of changes
65 signals: 66 signals:
66 void modified(); 67 void modified();
67 68
68}; 69};
69 70
70/** 71/**
71 @short Widget for bool settings in @ref KPrefsDialog. 72 @short Widget for bool settings in @ref KPrefsDialog.
72 73
73 This class provides a widget for configuring bool values. It is meant to be 74 This class provides a widget for configuring bool values. It is meant to be
74 used by KPrefsDialog. The user is responsible for the layout management. 75 used by KPrefsDialog. The user is responsible for the layout management.
75*/ 76*/
76class KPrefsWidBool : public KPrefsWid 77class KPrefsWidBool : public KPrefsWid
77{ 78{
78 public: 79 public:
79 /** 80 /**
80 Create a bool widget consisting of a QCheckbox. 81 Create a bool widget consisting of a QCheckbox.
81 82
82 @param text Text of QCheckBox. 83 @param text Text of QCheckBox.
83 @param reference Pointer to variable read and written by this widget. 84 @param reference Pointer to variable read and written by this widget.
84 @param parent Parent widget. 85 @param parent Parent widget.
85 */ 86 */
86 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent); 87 KPrefsWidBool(const QString &text,bool *reference,QWidget *parent);
87 88
88 /** 89 /**
89 Return the QCheckbox used by this widget. 90 Return the QCheckbox used by this widget.
90 */ 91 */
91 QCheckBox *checkBox(); 92 QCheckBox *checkBox();
92 93
93 void readConfig(); 94 void readConfig();
94 void writeConfig(); 95 void writeConfig();
95 96
96 private: 97 private:
97 bool *mReference; 98 bool *mReference;
98 99
99 QCheckBox *mCheck; 100 QCheckBox *mCheck;
100}; 101};
101 102
102/** 103/**
103 @short Widget for time settings in @ref KPrefsDialog. 104 @short Widget for time settings in @ref KPrefsDialog.
104 105
105 This class provides a widget for configuring time values. It is meant to be 106 This class provides a widget for configuring time values. It is meant to be
106 used by KPrefsDialog. The user is responsible for the layout management. 107 used by KPrefsDialog. The user is responsible for the layout management.
107*/ 108*/
108class KPrefsWidTime : public KPrefsWid 109class KPrefsWidTime : public KPrefsWid
109{ 110{
110 public: 111 public:
111 /** 112 /**
112 Create a time widget consisting of a label and a spinbox. 113 Create a time widget consisting of a label and a spinbox.
113 114
114 @param text Text of Label. 115 @param text Text of Label.
115 @param reference Pointer to variable read and written by this widget. 116 @param reference Pointer to variable read and written by this widget.
116 @param parent Parent widget. 117 @param parent Parent widget.
117 */ 118 */
118 KPrefsWidTime(const QString &text,int *reference,QWidget *parent); 119 KPrefsWidTime(const QString &text,int *reference,QWidget *parent);
119 120
120 /** 121 /**
121 Return QLabel used by this widget. 122 Return QLabel used by this widget.
122 */ 123 */
123 QLabel *label(); 124 QLabel *label();
124 /** 125 /**
125 Return QSpinBox used by this widget. 126 Return QSpinBox used by this widget.
126 */ 127 */
127 QSpinBox *spinBox(); 128 QSpinBox *spinBox();
128 129
129 void readConfig(); 130 void readConfig();
130 void writeConfig(); 131 void writeConfig();
131 132
132 private: 133 private:
133 int *mReference; 134 int *mReference;
134 135
135 QLabel *mLabel; 136 QLabel *mLabel;
136 QSpinBox *mSpin; 137 QSpinBox *mSpin;
137}; 138};
138 139
139/** 140/**
140 @short Widget for color settings in @ref KPrefsDialog. 141 @short Widget for color settings in @ref KPrefsDialog.
141 142
142 This class provides a widget for configuring color values. It is meant to be 143 This class provides a widget for configuring color values. It is meant to be
143 used by KPrefsDialog. The user is responsible for the layout management. 144 used by KPrefsDialog. The user is responsible for the layout management.
144*/ 145*/
145class KPrefsWidColor : public KPrefsWid 146class KPrefsWidColor : public KPrefsWid
146{ 147{
147 public: 148 public:
148 /** 149 /**
149 Create a color widget consisting of a test field and a button for opening 150 Create a color widget consisting of a test field and a button for opening
150 a color dialog. 151 a color dialog.
151 152
152 @param text Text of button. 153 @param text Text of button.
153 @param reference Pointer to variable read and written by this widget. 154 @param reference Pointer to variable read and written by this widget.
154 @param parent Parent widget. 155 @param parent Parent widget.
155 */ 156 */
156 KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent); 157 KPrefsWidColor(const QString &text,QColor *reference,QWidget *parent);
157 /** 158 /**
158 Destruct color setting widget. 159 Destruct color setting widget.
159 */ 160 */
160 ~KPrefsWidColor(); 161 ~KPrefsWidColor();
161 162
162 /** 163 /**
163 Return QLabel for the button 164 Return QLabel for the button
164 */ 165 */
165 QLabel *label(); 166 QLabel *label();
166 /** 167 /**
167 Return button opening the color dialog. 168 Return button opening the color dialog.
168 */ 169 */
169 KColorButton *button(); 170 KColorButton *button();
170 171
171 void readConfig(); 172 void readConfig();
172 void writeConfig(); 173 void writeConfig();
173 174
174 private: 175 private:
175 QColor *mReference; 176 QColor *mReference;
176 177
177 QLabel *mLabel; 178 QLabel *mLabel;
178 KColorButton *mButton; 179 KColorButton *mButton;
179}; 180};
180 181
181/** 182/**
182 @short Widget for font settings in @ref KPrefsDialog. 183 @short Widget for font settings in @ref KPrefsDialog.
183 184
184 This class provides a widget for configuring font values. It is meant to be 185 This class provides a widget for configuring font values. It is meant to be
185 used by KPrefsDialog. The user is responsible for the layout management. 186 used by KPrefsDialog. The user is responsible for the layout management.
186*/ 187*/
187class KPrefsWidFont : public KPrefsWid 188class KPrefsWidFont : public KPrefsWid
188{ 189{
189 Q_OBJECT 190 Q_OBJECT
190 public: 191 public:
191 /** 192 /**
192 Create a font widget consisting of a test field and a button for opening 193 Create a font widget consisting of a test field and a button for opening
193 a font dialog. 194 a font dialog.
194 195
195 @param label Text of label. 196 @param label Text of label.
196 @param reference Pointer to variable read and written by this widget. 197 @param reference Pointer to variable read and written by this widget.
197 @param parent Parent widget. 198 @param parent Parent widget.
198 */ 199 */
199 KPrefsWidFont(const QString &sampleText,const QString &labelText, 200 KPrefsWidFont(const QString &sampleText,const QString &labelText,
200 QFont *reference,QWidget *parent); 201 QFont *reference,QWidget *parent);
201 /** 202 /**
202 Destruct font setting widget. 203 Destruct font setting widget.
203 */ 204 */
204 ~KPrefsWidFont(); 205 ~KPrefsWidFont();
205 206
206 /** 207 /**
207 Return label. 208 Return label.
208 */ 209 */
209 QLabel *label(); 210 QLabel *label();
210 /** 211 /**
211 Return QFrame used as preview field. 212 Return QFrame used as preview field.
212 */ 213 */
213 QLabel *preview(); 214 QLabel *preview();
214 /** 215 /**
215 Return button opening the font dialog. 216 Return button opening the font dialog.
216 */ 217 */
217 QPushButton *button(); 218 QPushButton *button();
218 219
219 void readConfig(); 220 void readConfig();
220 void writeConfig(); 221 void writeConfig();
221 222
222 protected slots: 223 protected slots:
223 void selectFont(); 224 void selectFont();
224 225
225 private: 226 private:
226 QFont *mReference; 227 QFont *mReference;
227 228
228 QLabel *mLabel; 229 QLabel *mLabel;
229 QLabel *mPreview; 230 QLabel *mPreview;
230 QPushButton *mButton; 231 QPushButton *mButton;
231}; 232};
232 233
233/** 234/**
234 @short Widget for settings represented by a group of radio buttons in 235 @short Widget for settings represented by a group of radio buttons in
235 @ref KPrefsDialog. 236 @ref KPrefsDialog.
236 237
237 This class provides a widget for configuring selections. It is meant to be 238 This class provides a widget for configuring selections. It is meant to be
238 used by KPrefsDialog. The user is responsible for the layout management. The 239 used by KPrefsDialog. The user is responsible for the layout management. The
239 setting is interpreted as an int value, corresponding to the position of the 240 setting is interpreted as an int value, corresponding to the position of the
240 radio button. The position of the button is defined by the sequence of @ref 241 radio button. The position of the button is defined by the sequence of @ref
241 addRadio() calls, starting with 0. 242 addRadio() calls, starting with 0.
242*/ 243*/
243class KPrefsWidRadios : public KPrefsWid 244class KPrefsWidRadios : public KPrefsWid
244{ 245{
245 public: 246 public:
246 /** 247 /**
247 Create a widget for selection of an option. It consists of a box with 248 Create a widget for selection of an option. It consists of a box with
248 several radio buttons. 249 several radio buttons.
249 250
250 @param text Text of main box. 251 @param text Text of main box.
251 @param reference Pointer to variable read and written by this widget. 252 @param reference Pointer to variable read and written by this widget.
252 @param parent Parent widget. 253 @param parent Parent widget.
253 */ 254 */
254 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent); 255 KPrefsWidRadios(const QString &text,int *reference,QWidget *parent);
255 virtual ~KPrefsWidRadios(); 256 virtual ~KPrefsWidRadios();
256 257
257 /** 258 /**
258 Add a radio button. 259 Add a radio button.
259 260
260 @param text Text of the button. 261 @param text Text of the button.
261 */ 262 */
262 void addRadio(const QString &text); 263 void addRadio(const QString &text);
263 264
264 /** 265 /**
265 Return the box widget used by this widget. 266 Return the box widget used by this widget.
266 */ 267 */
267 QButtonGroup *groupBox(); 268 QButtonGroup *groupBox();
268 269
269 void readConfig(); 270 void readConfig();
270 void writeConfig(); 271 void writeConfig();
271 272
272 private: 273 private:
273 int *mReference; 274 int *mReference;
274 275
275 QButtonGroup *mBox; 276 QButtonGroup *mBox;
276}; 277};
277 278
278 279
279/** 280/**
280 @short Widget for string settings in @ref KPrefsDialog. 281 @short Widget for string settings in @ref KPrefsDialog.
281 282
282 This class provides a widget for configuring string values. It is meant to be 283 This class provides a widget for configuring string values. It is meant to be
283 used by KPrefsDialog. The user is responsible for the layout management. 284 used by KPrefsDialog. The user is responsible for the layout management.
284*/ 285*/
285class KPrefsWidString : public KPrefsWid 286class KPrefsWidString : public KPrefsWid
286{ 287{
287 public: 288 public:
288 /** 289 /**
289 Create a string widget consisting of a test label and a line edit. 290 Create a string widget consisting of a test label and a line edit.
290 291
291 @param text Text of label. 292 @param text Text of label.
292 @param reference Pointer to variable read and written by this widget. 293 @param reference Pointer to variable read and written by this widget.
293 @param parent Parent widget. 294 @param parent Parent widget.
294 */ 295 */
295 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal); 296 KPrefsWidString(const QString &text,QString *reference,QWidget *parent,QLineEdit::EchoMode echomode=QLineEdit::Normal);
296 /** 297 /**
297 Destructor. 298 Destructor.
298 */ 299 */
299 virtual ~KPrefsWidString(); 300 virtual ~KPrefsWidString();
300 301
301 /** 302 /**
302 Return label used by this widget. 303 Return label used by this widget.
303 */ 304 */
304 QLabel *label(); 305 QLabel *label();
305 /** 306 /**
306 Return QLineEdit used by this widget. 307 Return QLineEdit used by this widget.
307 */ 308 */
308 QLineEdit *lineEdit(); 309 QLineEdit *lineEdit();
309 310
310 void readConfig(); 311 void readConfig();
311 void writeConfig(); 312 void writeConfig();
312 313
313 private: 314 private:
314 QString *mReference; 315 QString *mReference;
315 316
316 QLabel *mLabel; 317 QLabel *mLabel;
317 QLineEdit *mEdit; 318 QLineEdit *mEdit;
318}; 319};
319 320
320 321
321/** 322/**
322 @short Base class for a preferences widget. 323 @short Base class for a preferences widget.
323 324
324 This class provides the framework for a preferences widget. You have to 325 This class provides the framework for a preferences widget. You have to
325 subclass it and add the code to create the actual configuration widgets and 326 subclass it and add the code to create the actual configuration widgets and
326 do the layout management. 327 do the layout management.
327 328
328 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For 329 KPrefsWidget provides functions to add subclasses of @ref KPrefsWid. For
329 these widgets the reading, writing and setting to default values is handled 330 these widgets the reading, writing and setting to default values is handled
330 automatically. Custom widgets have to be handled in the functions @ref 331 automatically. Custom widgets have to be handled in the functions @ref
331 usrReadConfig() and @ref usrWriteConfig(). 332 usrReadConfig() and @ref usrWriteConfig().
332*/ 333*/
333class KPrefsWidget : public QWidget 334class KPrefsWidget : public QWidget
334{ 335{
335 Q_OBJECT 336 Q_OBJECT
336 public: 337 public:
337 /** 338 /**
338 Create a KPrefsDialog for a KPrefs object. 339 Create a KPrefsDialog for a KPrefs object.
339 340
340 @param prefs KPrefs object used to access te configuration. 341 @param prefs KPrefs object used to access te configuration.
341 @param parent Parent widget. 342 @param parent Parent widget.
342 @param name Widget name. 343 @param name Widget name.
343 */ 344 */
344 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0); 345 KPrefsWidget(KPrefs *prefs,QWidget *parent=0,const char *name=0);
345 /** 346 /**
346 Destructor. 347 Destructor.
347 */ 348 */
348 virtual ~KPrefsWidget(); 349 virtual ~KPrefsWidget();
349 350
350 /** 351 /**
351 Register a custom KPrefsWid object. 352 Register a custom KPrefsWid object.
352 */ 353 */
353 void addWid(KPrefsWid *); 354 void addWid(KPrefsWid *);
354 /** 355 /**
355 Register a @ref KPrefsWidBool object. 356 Register a @ref KPrefsWidBool object.
356 357
357 @param text Text of bool widget. 358 @param text Text of bool widget.
358 @param reference Reference to variable storing the setting. 359 @param reference Reference to variable storing the setting.
359 @param parent Parent widget. 360 @param parent Parent widget.
360 */ 361 */
361 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent); 362 KPrefsWidBool *addWidBool(const QString &text,bool *reference,QWidget *parent);
362 /** 363 /**
363 Register a @ref KPrefsWidTime object. 364 Register a @ref KPrefsWidTime object.
364 365
365 @param text Text of time widget. 366 @param text Text of time widget.
366 @param reference Reference to variable storing the setting. 367 @param reference Reference to variable storing the setting.
367 @param parent Parent widget. 368 @param parent Parent widget.
368 */ 369 */
369 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent); 370 KPrefsWidTime *addWidTime(const QString &text,int *reference,QWidget *parent);
370 /** 371 /**
371 Register a @ref KPrefsWidColor object. 372 Register a @ref KPrefsWidColor object.
372 373
373 @param text Text of color widget. 374 @param text Text of color widget.
374 @param reference Reference to variable storing the setting. 375 @param reference Reference to variable storing the setting.
375 @param parent Parent widget. 376 @param parent Parent widget.
376 */ 377 */
377 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent); 378 KPrefsWidColor *addWidColor(const QString &text,QColor *reference,QWidget *parent);
378 /** 379 /**
379 Register a @ref KPrefsWidRadios object. 380 Register a @ref KPrefsWidRadios object.
380 381
381 @param text Text of radio button box widget. 382 @param text Text of radio button box widget.
382 @param reference Reference to variable storing the setting. 383 @param reference Reference to variable storing the setting.
383 @param parent Parent widget. 384 @param parent Parent widget.
384 */ 385 */
385 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent); 386 KPrefsWidRadios *addWidRadios(const QString &text,int *reference,QWidget *parent);
386 /** 387 /**
387 Register a @ref KPrefsWidString object. 388 Register a @ref KPrefsWidString object.
388 389
389 @param text Text of string widget. 390 @param text Text of string widget.
390 @param reference Reference to variable storing the setting. 391 @param reference Reference to variable storing the setting.
391 @param parent Parent widget. 392 @param parent Parent widget.
392 */ 393 */
393 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent); 394 KPrefsWidString *addWidString(const QString &text,QString *reference,QWidget *parent);
394 /** 395 /**
395 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password. 396 Register a password @ref KPrefsWidString object, with echomode set to QLineEdit::Password.
396 397
397 @param text Text of string widget. 398 @param text Text of string widget.
398 @param reference Reference to variable storing the setting. 399 @param reference Reference to variable storing the setting.
399 @param parent Parent widget. 400 @param parent Parent widget.
400 */ 401 */
401 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent); 402 KPrefsWidString *addWidPassword (const QString &text,QString *reference,QWidget *parent);
402 /** 403 /**
403 Register a @ref KPrefsWidFont object. 404 Register a @ref KPrefsWidFont object.
404 405
405 @param sampleText Sample text of font widget. 406 @param sampleText Sample text of font widget.
406 @param buttonText Button text of font widget. 407 @param buttonText Button text of font widget.
407 @param reference Reference to variable storing the setting. 408 @param reference Reference to variable storing the setting.
408 @param parent Parent widget. 409 @param parent Parent widget.
409 */ 410 */
410 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText, 411 KPrefsWidFont *addWidFont(const QString &sampleText,const QString &buttonText,
411 QFont *reference,QWidget *parent); 412 QFont *reference,QWidget *parent);
412 413
413 public slots: 414 public slots:
414 /** Set all widgets to default values. */ 415 /** Set all widgets to default values. */
415 void setDefaults(); 416 void setDefaults();
416 417
417 /** Read preferences from config file. */ 418 /** Read preferences from config file. */
418 void readConfig(); 419 void readConfig();
419 420
420 /** Write preferences to config file. */ 421 /** Write preferences to config file. */
421 void writeConfig(); 422 void writeConfig();
422 423
423 /** connect this slot to all UI elements */ 424 /** connect this slot to all UI elements */
424 void modified(); 425 void modified();
425 426
426 signals: 427 signals:
427 /** Emitted when the a changed configuration has been stored. */ 428 /** Emitted when the a changed configuration has been stored. */
428 //US void configChanged(); 429 //US void configChanged();
429 void changed( bool ); 430 void changed( bool );
430 431
431 protected slots: 432 protected slots:
432 /** Apply changes to preferences */ 433 /** Apply changes to preferences */
433 //US void slotApply(); 434 //US void slotApply();
434 435
435 //US void accept(); 436 //US void accept();
436 /** Accept changes to preferences and close dialog */ 437 /** Accept changes to preferences and close dialog */
437 //US void slotOk(); 438 //US void slotOk();
438 439
439 /** Set preferences to default values */ 440 /** Set preferences to default values */
440 //US void slotDefault(); 441 //US void slotDefault();
441 442
442 protected: 443 protected:
443 /** Implement this to read custom configuration widgets. */ 444 /** Implement this to read custom configuration widgets. */
444 virtual void usrReadConfig() {} 445 virtual void usrReadConfig() {}
445 /** Implement this to write custom configuration widgets. */ 446 /** Implement this to write custom configuration widgets. */
446 virtual void usrWriteConfig() {} 447 virtual void usrWriteConfig() {}
447 448
448 private: 449 private:
449 KPrefs *mPrefs; 450 KPrefs *mPrefs;
450 451
451 QPtrList<KPrefsWid> mPrefsWids; 452 QPtrList<KPrefsWid> mPrefsWids;
452}; 453};
453 454
454#endif 455#endif
diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro
index 1fedac7..7231842 100644
--- a/libkdepim/libkdepim.pro
+++ b/libkdepim/libkdepim.pro
@@ -1,55 +1,57 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG = qt warn_on 2 CONFIG = qt warn_on
3DEFINES +=KORG_NOKABC 3DEFINES +=KORG_NOKABC
4TARGET = microkdepim 4TARGET = microkdepim
5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . .. 5INCLUDEPATH += ../microkde ../microkde/kdecore ../microkde/kdeui . ..
6DESTDIR=../bin 6DESTDIR=../bin
7 7
8DEFINES += DESKTOP_VERSION 8DEFINES += DESKTOP_VERSION
9include( ../variables.pri ) 9include( ../variables.pri )
10unix : { 10unix : {
11OBJECTS_DIR = obj/unix 11OBJECTS_DIR = obj/unix
12MOC_DIR = moc/unix 12MOC_DIR = moc/unix
13} 13}
14win32: { 14win32: {
15DEFINES += _WIN32_ 15DEFINES += _WIN32_
16OBJECTS_DIR = obj/win 16OBJECTS_DIR = obj/win
17MOC_DIR = moc/win 17MOC_DIR = moc/win
18} 18}
19INTERFACES = \ 19INTERFACES = \
20 20
21HEADERS = \ 21HEADERS = \
22 categoryeditdialog.h \ 22 categoryeditdialog.h \
23 categoryeditdialog_base.h \ 23 categoryeditdialog_base.h \
24 categoryselectdialog.h \ 24 categoryselectdialog.h \
25 categoryselectdialog_base.h \ 25 categoryselectdialog_base.h \
26 externalapphandler.h \ 26 externalapphandler.h \
27 kdateedit.h \ 27 kdateedit.h \
28 kdatepicker.h \ 28 kdatepicker.h \
29 kinputdialog.h \ 29 kinputdialog.h \
30 kpimprefs.h \ 30 kpimprefs.h \
31 kpimglobalprefs.h \ 31 kpimglobalprefs.h \
32 kprefsdialog.h \ 32 kprefsdialog.h \
33 kprefswidget.h \
33 ksyncprofile.h \ 34 ksyncprofile.h \
34 ksyncprefsdialog.h \ 35 ksyncprefsdialog.h \
35 kcmconfigs/kcmkdepimconfig.h \ 36 kcmconfigs/kcmkdepimconfig.h \
36 kcmconfigs/kdepimconfigwidget.h 37 kcmconfigs/kdepimconfigwidget.h
37 38
38SOURCES = \ 39SOURCES = \
39 categoryeditdialog.cpp \ 40 categoryeditdialog.cpp \
40 categoryeditdialog_base.cpp \ 41 categoryeditdialog_base.cpp \
41 categoryselectdialog.cpp \ 42 categoryselectdialog.cpp \
42 categoryselectdialog_base.cpp \ 43 categoryselectdialog_base.cpp \
43 externalapphandler.cpp \ 44 externalapphandler.cpp \
44 kdateedit.cpp \ 45 kdateedit.cpp \
45 kdatepicker.cpp \ 46 kdatepicker.cpp \
46 kinputdialog.cpp \ 47 kinputdialog.cpp \
47 kpimprefs.cpp \ 48 kpimprefs.cpp \
48 kpimglobalprefs.cpp \ 49 kpimglobalprefs.cpp \
49 kprefsdialog.cpp \ 50 kprefsdialog.cpp \
51 kprefswidget.cpp \
50 ksyncprofile.cpp \ 52 ksyncprofile.cpp \
51 ksyncprefsdialog.cpp \ 53 ksyncprefsdialog.cpp \
52 kcmconfigs/kcmkdepimconfig.cpp \ 54 kcmconfigs/kcmkdepimconfig.cpp \
53 kcmconfigs/kdepimconfigwidget.cpp 55 kcmconfigs/kdepimconfigwidget.cpp
54 56
55 57