summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-01-17 19:49:42 (UTC)
committer zautrix <zautrix>2005-01-17 19:49:42 (UTC)
commit522486966ecf041a6e49913b6e420d58d4284837 (patch) (unidiff)
treed15da3e6ef9ec4638eba4aaf9f14ef0c5eaecd04 /kaddressbook
parent32479683283fc9f20d369ac9671ba0f8a33d3381 (diff)
downloadkdepimpi-522486966ecf041a6e49913b6e420d58d4284837.zip
kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.gz
kdepimpi-522486966ecf041a6e49913b6e420d58d4284837.tar.bz2
const fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp33
-rw-r--r--kaddressbook/kabcore.h2
2 files changed, 28 insertions, 7 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d393660..42e147f 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3284 +1,3305 @@
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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h" 154#include "nameeditdialog.h"
155#include <kcmultidialog.h> 155#include <kcmultidialog.h>
156 156
157#ifdef _WIN32_ 157#ifdef _WIN32_
158 158
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#else 160#else
161#include <unistd.h> 161#include <unistd.h>
162#endif 162#endif
163// sync includes 163// sync includes
164#include <libkdepim/ksyncprofile.h> 164#include <libkdepim/ksyncprofile.h>
165#include <libkdepim/ksyncprefsdialog.h> 165#include <libkdepim/ksyncprefsdialog.h>
166 166
167 167
168class KABCatPrefs : public QDialog 168class KABCatPrefs : public QDialog
169{ 169{
170 public: 170 public:
171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
172 QDialog( parent, name, true ) 172 QDialog( parent, name, true )
173 { 173 {
174 setCaption( i18n("Manage new Categories") ); 174 setCaption( i18n("Manage new Categories") );
175 QVBoxLayout* lay = new QVBoxLayout( this ); 175 QVBoxLayout* lay = new QVBoxLayout( this );
176 lay->setSpacing( 3 ); 176 lay->setSpacing( 3 );
177 lay->setMargin( 3 ); 177 lay->setMargin( 3 );
178 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 178 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
179 lay->addWidget( lab ); 179 lay->addWidget( lab );
180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
181 lay->addWidget( format ); 181 lay->addWidget( format );
182 format->setExclusive ( true ) ; 182 format->setExclusive ( true ) ;
183 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 183 addCatBut = new QRadioButton(i18n("Add to category list"), format );
184 new QRadioButton(i18n("Remove from addressees"), format ); 184 new QRadioButton(i18n("Remove from addressees"), format );
185 addCatBut->setChecked( true ); 185 addCatBut->setChecked( true );
186 QPushButton * ok = new QPushButton( i18n("OK"), this ); 186 QPushButton * ok = new QPushButton( i18n("OK"), this );
187 lay->addWidget( ok ); 187 lay->addWidget( ok );
188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
189 lay->addWidget( cancel ); 189 lay->addWidget( cancel );
190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
192 resize( 200, 200 ); 192 resize( 200, 200 );
193 } 193 }
194 194
195 bool addCat() { return addCatBut->isChecked(); } 195 bool addCat() { return addCatBut->isChecked(); }
196private: 196private:
197 QRadioButton* addCatBut; 197 QRadioButton* addCatBut;
198}; 198};
199 199
200class KABFormatPrefs : public QDialog 200class KABFormatPrefs : public QDialog
201{ 201{
202 public: 202 public:
203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
204 QDialog( parent, name, true ) 204 QDialog( parent, name, true )
205 { 205 {
206 setCaption( i18n("Set formatted name") ); 206 setCaption( i18n("Set formatted name") );
207 QVBoxLayout* lay = new QVBoxLayout( this ); 207 QVBoxLayout* lay = new QVBoxLayout( this );
208 lay->setSpacing( 3 ); 208 lay->setSpacing( 3 );
209 lay->setMargin( 3 ); 209 lay->setMargin( 3 );
210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
211 lay->addWidget( lab ); 211 lay->addWidget( lab );
212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
213 lay->addWidget( format ); 213 lay->addWidget( format );
214 format->setExclusive ( true ) ; 214 format->setExclusive ( true ) ;
215 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 215 simple = new QRadioButton(i18n("Simple: James Bond"), format );
216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
218 company = new QRadioButton(i18n("Organization: MI6"), format ); 218 company = new QRadioButton(i18n("Organization: MI6"), format );
219 simple->setChecked( true ); 219 simple->setChecked( true );
220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
221 lay->addWidget( setCompany ); 221 lay->addWidget( setCompany );
222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
223 lay->addWidget( ok ); 223 lay->addWidget( ok );
224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
225 lay->addWidget( cancel ); 225 lay->addWidget( cancel );
226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
228 //resize( 200, 200 ); 228 //resize( 200, 200 );
229 229
230 } 230 }
231public: 231public:
232 QRadioButton* simple, *full, *reverse, *company; 232 QRadioButton* simple, *full, *reverse, *company;
233 QCheckBox* setCompany; 233 QCheckBox* setCompany;
234}; 234};
235 235
236 236
237 237
238class KAex2phonePrefs : public QDialog 238class KAex2phonePrefs : public QDialog
239{ 239{
240 public: 240 public:
241 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 241 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
242 QDialog( parent, name, true ) 242 QDialog( parent, name, true )
243 { 243 {
244 setCaption( i18n("Export to phone options") ); 244 setCaption( i18n("Export to phone options") );
245 QVBoxLayout* lay = new QVBoxLayout( this ); 245 QVBoxLayout* lay = new QVBoxLayout( this );
246 lay->setSpacing( 3 ); 246 lay->setSpacing( 3 );
247 lay->setMargin( 3 ); 247 lay->setMargin( 3 );
248 QLabel *lab; 248 QLabel *lab;
249 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 249 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
250 lab->setAlignment (AlignHCenter ); 250 lab->setAlignment (AlignHCenter );
251 QHBox* temphb; 251 QHBox* temphb;
252 temphb = new QHBox( this ); 252 temphb = new QHBox( this );
253 new QLabel( i18n("I/O device: "), temphb ); 253 new QLabel( i18n("I/O device: "), temphb );
254 mPhoneDevice = new QLineEdit( temphb); 254 mPhoneDevice = new QLineEdit( temphb);
255 lay->addWidget( temphb ); 255 lay->addWidget( temphb );
256 temphb = new QHBox( this ); 256 temphb = new QHBox( this );
257 new QLabel( i18n("Connection: "), temphb ); 257 new QLabel( i18n("Connection: "), temphb );
258 mPhoneConnection = new QLineEdit( temphb); 258 mPhoneConnection = new QLineEdit( temphb);
259 lay->addWidget( temphb ); 259 lay->addWidget( temphb );
260 temphb = new QHBox( this ); 260 temphb = new QHBox( this );
261 new QLabel( i18n("Model(opt.): "), temphb ); 261 new QLabel( i18n("Model(opt.): "), temphb );
262 mPhoneModel = new QLineEdit( temphb); 262 mPhoneModel = new QLineEdit( temphb);
263 lay->addWidget( temphb ); 263 lay->addWidget( temphb );
264 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 264 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
265 // lay->addWidget( mWriteToSim ); 265 // lay->addWidget( mWriteToSim );
266 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 266 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
267 lab->setAlignment (AlignHCenter); 267 lab->setAlignment (AlignHCenter);
268 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 268 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
269 lay->addWidget( ok ); 269 lay->addWidget( ok );
270 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 270 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
271 lay->addWidget( cancel ); 271 lay->addWidget( cancel );
272 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 272 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
273 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 273 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
274 resize( 220, 240 ); 274 resize( 220, 240 );
275 275
276 } 276 }
277 277
278public: 278public:
279 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 279 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
280 QCheckBox* mWriteToSim; 280 QCheckBox* mWriteToSim;
281}; 281};
282 282
283 283
284bool pasteWithNewUid = true; 284bool pasteWithNewUid = true;
285 285
286#ifdef KAB_EMBEDDED 286#ifdef KAB_EMBEDDED
287KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 287KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
288 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 288 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
289 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 289 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
290 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 290 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
291#else //KAB_EMBEDDED 291#else //KAB_EMBEDDED
292KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 292KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
293 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 293 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
294 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 294 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
295 mReadWrite( readWrite ), mModified( false ) 295 mReadWrite( readWrite ), mModified( false )
296#endif //KAB_EMBEDDED 296#endif //KAB_EMBEDDED
297{ 297{
298 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 298 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
299 // syncManager->setBlockSave(false); 299 // syncManager->setBlockSave(false);
300 mMiniSplitter = 0; 300 mMiniSplitter = 0;
301 mExtensionBarSplitter = 0; 301 mExtensionBarSplitter = 0;
302 mIsPart = !parent->inherits( "KAddressBookMain" ); 302 mIsPart = !parent->inherits( "KAddressBookMain" );
303 mAddressBook = KABC::StdAddressBook::self(); 303 mAddressBook = KABC::StdAddressBook::self();
304 KABC::StdAddressBook::setAutomaticSave( false ); 304 KABC::StdAddressBook::setAutomaticSave( false );
305 305
306#ifndef KAB_EMBEDDED 306#ifndef KAB_EMBEDDED
307 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 307 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
308#endif //KAB_EMBEDDED 308#endif //KAB_EMBEDDED
309 309
310 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 310 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
311 SLOT( addressBookChanged() ) ); 311 SLOT( addressBookChanged() ) );
312 312
313#if 0 313#if 0
314 // LP moved to addressbook init method 314 // LP moved to addressbook init method
315 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 315 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
316 "X-Department", "KADDRESSBOOK" ); 316 "X-Department", "KADDRESSBOOK" );
317 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
318 "X-Profession", "KADDRESSBOOK" ); 318 "X-Profession", "KADDRESSBOOK" );
319 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
320 "X-AssistantsName", "KADDRESSBOOK" ); 320 "X-AssistantsName", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
322 "X-ManagersName", "KADDRESSBOOK" ); 322 "X-ManagersName", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 323 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
324 "X-SpousesName", "KADDRESSBOOK" ); 324 "X-SpousesName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
326 "X-Office", "KADDRESSBOOK" ); 326 "X-Office", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
328 "X-IMAddress", "KADDRESSBOOK" ); 328 "X-IMAddress", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
330 "X-Anniversary", "KADDRESSBOOK" ); 330 "X-Anniversary", "KADDRESSBOOK" );
331 331
332 //US added this field to become compatible with Opie/qtopia addressbook 332 //US added this field to become compatible with Opie/qtopia addressbook
333 // values can be "female" or "male" or "". An empty field represents undefined. 333 // values can be "female" or "male" or "". An empty field represents undefined.
334 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 334 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
335 "X-Gender", "KADDRESSBOOK" ); 335 "X-Gender", "KADDRESSBOOK" );
336 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
337 "X-Children", "KADDRESSBOOK" ); 337 "X-Children", "KADDRESSBOOK" );
338 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
339 "X-FreeBusyUrl", "KADDRESSBOOK" ); 339 "X-FreeBusyUrl", "KADDRESSBOOK" );
340#endif 340#endif
341 initGUI(); 341 initGUI();
342 342
343 mIncSearchWidget->setFocus(); 343 mIncSearchWidget->setFocus();
344 344
345 345
346 connect( mViewManager, SIGNAL( selected( const QString& ) ), 346 connect( mViewManager, SIGNAL( selected( const QString& ) ),
347 SLOT( setContactSelected( const QString& ) ) ); 347 SLOT( setContactSelected( const QString& ) ) );
348 connect( mViewManager, SIGNAL( executed( const QString& ) ), 348 connect( mViewManager, SIGNAL( executed( const QString& ) ),
349 SLOT( executeContact( const QString& ) ) ); 349 SLOT( executeContact( const QString& ) ) );
350 350
351 connect( mViewManager, SIGNAL( deleteRequest( ) ), 351 connect( mViewManager, SIGNAL( deleteRequest( ) ),
352 SLOT( deleteContacts( ) ) ); 352 SLOT( deleteContacts( ) ) );
353 connect( mViewManager, SIGNAL( modified() ), 353 connect( mViewManager, SIGNAL( modified() ),
354 SLOT( setModified() ) ); 354 SLOT( setModified() ) );
355 355
356 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 356 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
357 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 357 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
358 358
359 connect( mXXPortManager, SIGNAL( modified() ), 359 connect( mXXPortManager, SIGNAL( modified() ),
360 SLOT( setModified() ) ); 360 SLOT( setModified() ) );
361 361
362 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 362 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
363 SLOT( incrementalSearch( const QString& ) ) ); 363 SLOT( incrementalSearch( const QString& ) ) );
364 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 364 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
365 mJumpButtonBar, SLOT( recreateButtons() ) ); 365 mJumpButtonBar, SLOT( recreateButtons() ) );
366 366
367 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 367 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
368 SLOT( sendMail( const QString& ) ) ); 368 SLOT( sendMail( const QString& ) ) );
369 369
370 370
371 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 371 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
372 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&))); 372 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&)));
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
374 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 374 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
375 375
376 376
377#ifndef KAB_EMBEDDED 377#ifndef KAB_EMBEDDED
378 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 378 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
379 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 379 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
380 380
381 connect( mDetails, SIGNAL( browse( const QString& ) ), 381 connect( mDetails, SIGNAL( browse( const QString& ) ),
382 SLOT( browse( const QString& ) ) ); 382 SLOT( browse( const QString& ) ) );
383 383
384 384
385 mAddressBookService = new KAddressBookService( this ); 385 mAddressBookService = new KAddressBookService( this );
386 386
387#endif //KAB_EMBEDDED 387#endif //KAB_EMBEDDED
388 388
389 mMessageTimer = new QTimer( this ); 389 mMessageTimer = new QTimer( this );
390 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 390 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
391 mEditorDialog = 0; 391 mEditorDialog = 0;
392 createAddresseeEditorDialog( this ); 392 createAddresseeEditorDialog( this );
393 setModified( false ); 393 setModified( false );
394 mBRdisabled = false; 394 mBRdisabled = false;
395#ifndef DESKTOP_VERSION 395#ifndef DESKTOP_VERSION
396 infrared = 0; 396 infrared = 0;
397#endif 397#endif
398 //toggleBeamReceive( ); 398 //toggleBeamReceive( );
399 //mMainWindow->toolBar()->show(); 399 //mMainWindow->toolBar()->show();
400 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 400 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
401 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 401 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
402} 402}
403 403
404void KABCore::updateToolBar() 404void KABCore::updateToolBar()
405{ 405{
406 static int iii = 0; 406 static int iii = 0;
407 ++iii; 407 ++iii;
408 mMainWindow->toolBar()->repaintMe(); 408 mMainWindow->toolBar()->repaintMe();
409 if ( iii < 3 ) 409 if ( iii < 3 )
410 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 410 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
411} 411}
412KABCore::~KABCore() 412KABCore::~KABCore()
413{ 413{
414 // save(); 414 // save();
415 //saveSettings(); 415 //saveSettings();
416 //KABPrefs::instance()->writeConfig(); 416 //KABPrefs::instance()->writeConfig();
417 delete AddresseeConfig::instance(); 417 delete AddresseeConfig::instance();
418 mAddressBook = 0; 418 mAddressBook = 0;
419 KABC::StdAddressBook::close(); 419 KABC::StdAddressBook::close();
420 420
421 delete syncManager; 421 delete syncManager;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 if ( infrared ) 423 if ( infrared )
424 delete infrared; 424 delete infrared;
425#endif 425#endif
426} 426}
427void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 427void KABCore::receive( const QCString& cmsg, const QByteArray& data )
428{ 428{
429 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 429 qDebug("KA: QCOP message received: %s ", cmsg.data() );
430 if ( cmsg == "setDocument(QString)" ) { 430 if ( cmsg == "setDocument(QString)" ) {
431 QDataStream stream( data, IO_ReadOnly ); 431 QDataStream stream( data, IO_ReadOnly );
432 QString fileName; 432 QString fileName;
433 stream >> fileName; 433 stream >> fileName;
434 recieve( fileName ); 434 recieve( fileName );
435 return; 435 return;
436 } 436 }
437} 437}
438void KABCore::toggleBeamReceive( ) 438void KABCore::toggleBeamReceive( )
439{ 439{
440 if ( mBRdisabled ) 440 if ( mBRdisabled )
441 return; 441 return;
442#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
443 if ( infrared ) { 443 if ( infrared ) {
444 qDebug("AB disable BeamReceive "); 444 qDebug("AB disable BeamReceive ");
445 delete infrared; 445 delete infrared;
446 infrared = 0; 446 infrared = 0;
447 mActionBR->setChecked(false); 447 mActionBR->setChecked(false);
448 return; 448 return;
449 } 449 }
450 qDebug("AB enable BeamReceive "); 450 qDebug("AB enable BeamReceive ");
451 mActionBR->setChecked(true); 451 mActionBR->setChecked(true);
452 452
453 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 453 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
454 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 454 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
455#endif 455#endif
456} 456}
457 457
458 458
459void KABCore::disableBR(bool b) 459void KABCore::disableBR(bool b)
460{ 460{
461#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
462 if ( b ) { 462 if ( b ) {
463 if ( infrared ) { 463 if ( infrared ) {
464 toggleBeamReceive( ); 464 toggleBeamReceive( );
465 } 465 }
466 mBRdisabled = true; 466 mBRdisabled = true;
467 } else { 467 } else {
468 if ( mBRdisabled ) { 468 if ( mBRdisabled ) {
469 mBRdisabled = false; 469 mBRdisabled = false;
470 //toggleBeamReceive( ); 470 //toggleBeamReceive( );
471 } 471 }
472 } 472 }
473#endif 473#endif
474 474
475} 475}
476void KABCore::recieve( QString fn ) 476void KABCore::recieve( QString fn )
477{ 477{
478 //qDebug("KABCore::recieve "); 478 //qDebug("KABCore::recieve ");
479 int count = mAddressBook->importFromFile( fn, true ); 479 int count = mAddressBook->importFromFile( fn, true );
480 if ( count ) 480 if ( count )
481 setModified( true ); 481 setModified( true );
482 mViewManager->refreshView(); 482 mViewManager->refreshView();
483 message(i18n("%1 contact(s) received!").arg( count )); 483 message(i18n("%1 contact(s) received!").arg( count ));
484 topLevelWidget()->showMaximized(); 484 topLevelWidget()->showMaximized();
485 topLevelWidget()->raise(); 485 topLevelWidget()->raise();
486} 486}
487void KABCore::restoreSettings() 487void KABCore::restoreSettings()
488{ 488{
489 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 489 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
490 490
491 bool state; 491 bool state;
492 492
493 if (mMultipleViewsAtOnce) 493 if (mMultipleViewsAtOnce)
494 state = KABPrefs::instance()->mDetailsPageVisible; 494 state = KABPrefs::instance()->mDetailsPageVisible;
495 else 495 else
496 state = false; 496 state = false;
497 497
498 mActionDetails->setChecked( state ); 498 mActionDetails->setChecked( state );
499 setDetailsVisible( state ); 499 setDetailsVisible( state );
500 500
501 state = KABPrefs::instance()->mJumpButtonBarVisible; 501 state = KABPrefs::instance()->mJumpButtonBarVisible;
502 502
503 mActionJumpBar->setChecked( state ); 503 mActionJumpBar->setChecked( state );
504 setJumpButtonBarVisible( state ); 504 setJumpButtonBarVisible( state );
505/*US 505/*US
506 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 506 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
507 if ( splitterSize.count() == 0 ) { 507 if ( splitterSize.count() == 0 ) {
508 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
509 splitterSize.append( width() / 2 ); 509 splitterSize.append( width() / 2 );
510 } 510 }
511 mMiniSplitter->setSizes( splitterSize ); 511 mMiniSplitter->setSizes( splitterSize );
512 if ( mExtensionBarSplitter ) { 512 if ( mExtensionBarSplitter ) {
513 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 513 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
514 if ( splitterSize.count() == 0 ) { 514 if ( splitterSize.count() == 0 ) {
515 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
516 splitterSize.append( width() / 2 ); 516 splitterSize.append( width() / 2 );
517 } 517 }
518 mExtensionBarSplitter->setSizes( splitterSize ); 518 mExtensionBarSplitter->setSizes( splitterSize );
519 519
520 } 520 }
521*/ 521*/
522 mViewManager->restoreSettings(); 522 mViewManager->restoreSettings();
523 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 523 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
524 mExtensionManager->restoreSettings(); 524 mExtensionManager->restoreSettings();
525#ifdef DESKTOP_VERSION 525#ifdef DESKTOP_VERSION
526 int wid = width(); 526 int wid = width();
527 if ( wid < 10 ) 527 if ( wid < 10 )
528 wid = 400; 528 wid = 400;
529#else 529#else
530 int wid = QApplication::desktop()->width(); 530 int wid = QApplication::desktop()->width();
531 if ( wid < 640 ) 531 if ( wid < 640 )
532 wid = QApplication::desktop()->height(); 532 wid = QApplication::desktop()->height();
533#endif 533#endif
534 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 534 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
535 if ( true /*splitterSize.count() == 0*/ ) { 535 if ( true /*splitterSize.count() == 0*/ ) {
536 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
537 splitterSize.append( wid / 2 ); 537 splitterSize.append( wid / 2 );
538 } 538 }
539 mMiniSplitter->setSizes( splitterSize ); 539 mMiniSplitter->setSizes( splitterSize );
540 if ( mExtensionBarSplitter ) { 540 if ( mExtensionBarSplitter ) {
541 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 541 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
542 if ( true /*splitterSize.count() == 0*/ ) { 542 if ( true /*splitterSize.count() == 0*/ ) {
543 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
544 splitterSize.append( wid / 2 ); 544 splitterSize.append( wid / 2 );
545 } 545 }
546 mExtensionBarSplitter->setSizes( splitterSize ); 546 mExtensionBarSplitter->setSizes( splitterSize );
547 547
548 } 548 }
549 549
550 550
551} 551}
552 552
553void KABCore::saveSettings() 553void KABCore::saveSettings()
554{ 554{
555 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 555 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
556 if ( mExtensionBarSplitter ) 556 if ( mExtensionBarSplitter )
557 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 557 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
558 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 558 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
559 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 559 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
560#ifndef KAB_EMBEDDED 560#ifndef KAB_EMBEDDED
561 561
562 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 562 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
563 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 563 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
564#endif //KAB_EMBEDDED 564#endif //KAB_EMBEDDED
565 mExtensionManager->saveSettings(); 565 mExtensionManager->saveSettings();
566 mViewManager->saveSettings(); 566 mViewManager->saveSettings();
567 567
568 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 568 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
569 KABPrefs::instance()->writeConfig(); 569 KABPrefs::instance()->writeConfig();
570 qDebug("KABCore::saveSettings() "); 570 qDebug("KABCore::saveSettings() ");
571} 571}
572 572
573KABC::AddressBook *KABCore::addressBook() const 573KABC::AddressBook *KABCore::addressBook() const
574{ 574{
575 return mAddressBook; 575 return mAddressBook;
576} 576}
577 577
578KConfig *KABCore::config() 578KConfig *KABCore::config()
579{ 579{
580#ifndef KAB_EMBEDDED 580#ifndef KAB_EMBEDDED
581 return KABPrefs::instance()->config(); 581 return KABPrefs::instance()->config();
582#else //KAB_EMBEDDED 582#else //KAB_EMBEDDED
583 return KABPrefs::instance()->getConfig(); 583 return KABPrefs::instance()->getConfig();
584#endif //KAB_EMBEDDED 584#endif //KAB_EMBEDDED
585} 585}
586 586
587KActionCollection *KABCore::actionCollection() const 587KActionCollection *KABCore::actionCollection() const
588{ 588{
589 return mGUIClient->actionCollection(); 589 return mGUIClient->actionCollection();
590} 590}
591 591
592KABC::Field *KABCore::currentSearchField() const 592KABC::Field *KABCore::currentSearchField() const
593{ 593{
594 if (mIncSearchWidget) 594 if (mIncSearchWidget)
595 return mIncSearchWidget->currentField(); 595 return mIncSearchWidget->currentField();
596 else 596 else
597 return 0; 597 return 0;
598} 598}
599 599
600QStringList KABCore::selectedUIDs() const 600QStringList KABCore::selectedUIDs() const
601{ 601{
602 return mViewManager->selectedUids(); 602 return mViewManager->selectedUids();
603} 603}
604 604
605KABC::Resource *KABCore::requestResource( QWidget *parent ) 605KABC::Resource *KABCore::requestResource( QWidget *parent )
606{ 606{
607 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 607 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
608 608
609 QPtrList<KRES::Resource> kresResources; 609 QPtrList<KRES::Resource> kresResources;
610 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 610 QPtrListIterator<KABC::Resource> resIt( kabcResources );
611 KABC::Resource *resource; 611 KABC::Resource *resource;
612 while ( ( resource = resIt.current() ) != 0 ) { 612 while ( ( resource = resIt.current() ) != 0 ) {
613 ++resIt; 613 ++resIt;
614 if ( !resource->readOnly() ) { 614 if ( !resource->readOnly() ) {
615 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 615 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
616 if ( res ) 616 if ( res )
617 kresResources.append( res ); 617 kresResources.append( res );
618 } 618 }
619 } 619 }
620 620
621 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 621 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
622 return static_cast<KABC::Resource*>( res ); 622 return static_cast<KABC::Resource*>( res );
623} 623}
624 624
625#ifndef KAB_EMBEDDED 625#ifndef KAB_EMBEDDED
626KAboutData *KABCore::createAboutData() 626KAboutData *KABCore::createAboutData()
627#else //KAB_EMBEDDED 627#else //KAB_EMBEDDED
628void KABCore::createAboutData() 628void KABCore::createAboutData()
629#endif //KAB_EMBEDDED 629#endif //KAB_EMBEDDED
630{ 630{
631#ifndef KAB_EMBEDDED 631#ifndef KAB_EMBEDDED
632 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 632 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
633 "3.1", I18N_NOOP( "The KDE Address Book" ), 633 "3.1", I18N_NOOP( "The KDE Address Book" ),
634 KAboutData::License_GPL_V2, 634 KAboutData::License_GPL_V2,
635 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 635 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
636 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 636 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
637 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 637 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
638 about->addAuthor( "Cornelius Schumacher", 638 about->addAuthor( "Cornelius Schumacher",
639 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 639 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
640 "schumacher@kde.org" ); 640 "schumacher@kde.org" );
641 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 641 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
642 "mpilone@slac.com" ); 642 "mpilone@slac.com" );
643 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 643 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
644 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 644 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
645 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 645 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
646 "michel@klaralvdalens-datakonsult.se" ); 646 "michel@klaralvdalens-datakonsult.se" );
647 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 647 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
648 "hansen@kde.org" ); 648 "hansen@kde.org" );
649 649
650 return about; 650 return about;
651#endif //KAB_EMBEDDED 651#endif //KAB_EMBEDDED
652 652
653 QString version; 653 QString version;
654#include <../version> 654#include <../version>
655 QMessageBox::about( this, "About KAddressbook/Pi", 655 QMessageBox::about( this, "About KAddressbook/Pi",
656 "KAddressbook/Platform-independent\n" 656 "KAddressbook/Platform-independent\n"
657 "(KA/Pi) " +version + " - " + 657 "(KA/Pi) " +version + " - " +
658#ifdef DESKTOP_VERSION 658#ifdef DESKTOP_VERSION
659 "Desktop Edition\n" 659 "Desktop Edition\n"
660#else 660#else
661 "PDA-Edition\n" 661 "PDA-Edition\n"
662 "for: Zaurus 5500 / 7x0 / 8x0\n" 662 "for: Zaurus 5500 / 7x0 / 8x0\n"
663#endif 663#endif
664 664
665 "(c) 2004 Ulf Schenk\n" 665 "(c) 2004 Ulf Schenk\n"
666 "(c) 2004 Lutz Rogowski\n" 666 "(c) 2004 Lutz Rogowski\n"
667 "(c) 1997-2003, The KDE PIM Team\n" 667 "(c) 1997-2003, The KDE PIM Team\n"
668 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 668 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
669 "Don Sanders Original author\n" 669 "Don Sanders Original author\n"
670 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 670 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
671 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 671 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
672 "Greg Stern DCOP interface\n" 672 "Greg Stern DCOP interface\n"
673 "Mark Westcot Contact pinning\n" 673 "Mark Westcot Contact pinning\n"
674 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 674 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
675 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 675 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
676#ifdef _WIN32_ 676#ifdef _WIN32_
677 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 677 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
678#endif 678#endif
679 ); 679 );
680} 680}
681 681
682void KABCore::setContactSelected( const QString &uid ) 682void KABCore::setContactSelected( const QString &uid )
683{ 683{
684 KABC::Addressee addr = mAddressBook->findByUid( uid ); 684 KABC::Addressee addr = mAddressBook->findByUid( uid );
685 if ( !mDetails->isHidden() ) 685 if ( !mDetails->isHidden() )
686 mDetails->setAddressee( addr ); 686 mDetails->setAddressee( addr );
687 687
688 if ( !addr.isEmpty() ) { 688 if ( !addr.isEmpty() ) {
689 emit contactSelected( addr.formattedName() ); 689 emit contactSelected( addr.formattedName() );
690 KABC::Picture pic = addr.photo(); 690 KABC::Picture pic = addr.photo();
691 if ( pic.isIntern() ) { 691 if ( pic.isIntern() ) {
692//US emit contactSelected( pic.data() ); 692//US emit contactSelected( pic.data() );
693//US instead use: 693//US instead use:
694 QPixmap px; 694 QPixmap px;
695 if (pic.data().isNull() != true) 695 if (pic.data().isNull() != true)
696 { 696 {
697 px.convertFromImage(pic.data()); 697 px.convertFromImage(pic.data());
698 } 698 }
699 699
700 emit contactSelected( px ); 700 emit contactSelected( px );
701 } 701 }
702 } 702 }
703 703
704 704
705 mExtensionManager->setSelectionChanged(); 705 mExtensionManager->setSelectionChanged();
706 706
707 // update the actions 707 // update the actions
708 bool selected = !uid.isEmpty(); 708 bool selected = !uid.isEmpty();
709 709
710 if ( mReadWrite ) { 710 if ( mReadWrite ) {
711 mActionCut->setEnabled( selected ); 711 mActionCut->setEnabled( selected );
712 mActionPaste->setEnabled( selected ); 712 mActionPaste->setEnabled( selected );
713 } 713 }
714 714
715 mActionCopy->setEnabled( selected ); 715 mActionCopy->setEnabled( selected );
716 mActionDelete->setEnabled( selected ); 716 mActionDelete->setEnabled( selected );
717 mActionEditAddressee->setEnabled( selected ); 717 mActionEditAddressee->setEnabled( selected );
718 mActionMail->setEnabled( selected ); 718 mActionMail->setEnabled( selected );
719 mActionMailVCard->setEnabled( selected ); 719 mActionMailVCard->setEnabled( selected );
720 //if (mActionBeam) 720 //if (mActionBeam)
721 //mActionBeam->setEnabled( selected ); 721 //mActionBeam->setEnabled( selected );
722 mActionWhoAmI->setEnabled( selected ); 722 mActionWhoAmI->setEnabled( selected );
723} 723}
724 724
725void KABCore::sendMail() 725void KABCore::sendMail()
726{ 726{
727 sendMail( mViewManager->selectedEmails().join( ", " ) ); 727 sendMail( mViewManager->selectedEmails().join( ", " ) );
728} 728}
729 729
730void KABCore::sendMail( const QString& emaillist ) 730void KABCore::sendMail( const QString& emaillist )
731{ 731{
732 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 732 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
733 if (emaillist.contains(",") > 0) 733 if (emaillist.contains(",") > 0)
734 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 734 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
735 else 735 else
736 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 736 ExternalAppHandler::instance()->mailToOneContact( emaillist );
737} 737}
738 738
739 739
740 740
741void KABCore::mailVCard() 741void KABCore::mailVCard()
742{ 742{
743 QStringList uids = mViewManager->selectedUids(); 743 QStringList uids = mViewManager->selectedUids();
744 if ( !uids.isEmpty() ) 744 if ( !uids.isEmpty() )
745 mailVCard( uids ); 745 mailVCard( uids );
746} 746}
747 747
748void KABCore::mailVCard( const QStringList& uids ) 748void KABCore::mailVCard( const QStringList& uids )
749{ 749{
750 QStringList urls; 750 QStringList urls;
751 751
752// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 752// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
753 753
754 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 754 QString dirName = "/tmp/" + KApplication::randomString( 8 );
755 755
756 756
757 757
758 QDir().mkdir( dirName, true ); 758 QDir().mkdir( dirName, true );
759 759
760 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 760 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
761 KABC::Addressee a = mAddressBook->findByUid( *it ); 761 KABC::Addressee a = mAddressBook->findByUid( *it );
762 762
763 if ( a.isEmpty() ) 763 if ( a.isEmpty() )
764 continue; 764 continue;
765 765
766 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 766 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
767 767
768 QString fileName = dirName + "/" + name; 768 QString fileName = dirName + "/" + name;
769 769
770 QFile outFile(fileName); 770 QFile outFile(fileName);
771 771
772 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 772 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
773 KABC::VCardConverter converter; 773 KABC::VCardConverter converter;
774 QString vcard; 774 QString vcard;
775 775
776 converter.addresseeToVCard( a, vcard ); 776 converter.addresseeToVCard( a, vcard );
777 777
778 QTextStream t( &outFile ); // use a text stream 778 QTextStream t( &outFile ); // use a text stream
779 t.setEncoding( QTextStream::UnicodeUTF8 ); 779 t.setEncoding( QTextStream::UnicodeUTF8 );
780 t << vcard; 780 t << vcard;
781 781
782 outFile.close(); 782 outFile.close();
783 783
784 urls.append( fileName ); 784 urls.append( fileName );
785 } 785 }
786 } 786 }
787 787
788 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 788 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
789 789
790 790
791/*US 791/*US
792 kapp->invokeMailer( QString::null, QString::null, QString::null, 792 kapp->invokeMailer( QString::null, QString::null, QString::null,
793 QString::null, // subject 793 QString::null, // subject
794 QString::null, // body 794 QString::null, // body
795 QString::null, 795 QString::null,
796 urls ); // attachments 796 urls ); // attachments
797*/ 797*/
798 798
799} 799}
800 800
801/** 801/**
802 Beams the "WhoAmI contact. 802 Beams the "WhoAmI contact.
803*/ 803*/
804void KABCore::beamMySelf() 804void KABCore::beamMySelf()
805{ 805{
806 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 806 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
807 if (!a.isEmpty()) 807 if (!a.isEmpty())
808 { 808 {
809 QStringList uids; 809 QStringList uids;
810 uids << a.uid(); 810 uids << a.uid();
811 811
812 beamVCard(uids); 812 beamVCard(uids);
813 } else { 813 } else {
814 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 814 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
815 815
816 816
817 } 817 }
818} 818}
819void KABCore::updateMainWindow() 819void KABCore::updateMainWindow()
820{ 820{
821 821
822 mMainWindow->showMaximized(); 822 mMainWindow->showMaximized();
823 mMainWindow->update(); 823 mMainWindow->update();
824} 824}
825void KABCore::resizeEvent(QResizeEvent* e ) 825void KABCore::resizeEvent(QResizeEvent* e )
826{ 826{
827 if ( !mMiniSplitter ) 827 if ( !mMiniSplitter )
828 return; 828 return;
829 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 829 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
830 if ( QApplication::desktop()->width() >= 480 ) { 830 if ( QApplication::desktop()->width() >= 480 ) {
831 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 831 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
832 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 832 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
833 mMiniSplitter->setOrientation( Qt::Horizontal); 833 mMiniSplitter->setOrientation( Qt::Horizontal);
834 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 834 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
835 if ( QApplication::desktop()->width() <= 640 ) { 835 if ( QApplication::desktop()->width() <= 640 ) {
836 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 836 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
837 mViewManager->getFilterAction()->setComboWidth( 150 ); 837 mViewManager->getFilterAction()->setComboWidth( 150 );
838 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 838 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
839 } 839 }
840 } 840 }
841 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 841 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
842 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 842 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
843 mMiniSplitter->setOrientation( Qt::Vertical ); 843 mMiniSplitter->setOrientation( Qt::Vertical );
844 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 844 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
845 if ( QApplication::desktop()->width() <= 640 ) { 845 if ( QApplication::desktop()->width() <= 640 ) {
846 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 846 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
847 mMainWindow->showMinimized(); 847 mMainWindow->showMinimized();
848 mViewManager->getFilterAction()->setComboWidth( 0 ); 848 mViewManager->getFilterAction()->setComboWidth( 0 );
849 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 849 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
850 } 850 }
851 } 851 }
852 } 852 }
853 } 853 }
854 854
855} 855}
856void KABCore::export2phone() 856void KABCore::export2phone()
857{ 857{
858 858
859 QStringList uids; 859 QStringList uids;
860 XXPortSelectDialog dlg( this, false, this ); 860 XXPortSelectDialog dlg( this, false, this );
861 if ( dlg.exec() ) 861 if ( dlg.exec() )
862 uids = dlg.uids(); 862 uids = dlg.uids();
863 else 863 else
864 return; 864 return;
865 if ( uids.isEmpty() ) 865 if ( uids.isEmpty() )
866 return; 866 return;
867 // qDebug("count %d ", uids.count()); 867 // qDebug("count %d ", uids.count());
868 868
869 KAex2phonePrefs ex2phone; 869 KAex2phonePrefs ex2phone;
870 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 870 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
871 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 871 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
872 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 872 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
873 873
874 if ( !ex2phone.exec() ) { 874 if ( !ex2phone.exec() ) {
875 return; 875 return;
876 } 876 }
877 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 877 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
878 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 878 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
879 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 879 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
880 880
881 881
882 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 882 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
883 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 883 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
884 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 884 KPimGlobalPrefs::instance()->mEx2PhoneModel );
885 885
886 QString fileName = getPhoneFile(); 886 QString fileName = getPhoneFile();
887 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 887 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
888 return; 888 return;
889 889
890 message(i18n("Exporting to phone...")); 890 message(i18n("Exporting to phone..."));
891 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 891 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
892 892
893} 893}
894QString KABCore::getPhoneFile() 894QString KABCore::getPhoneFile()
895{ 895{
896#ifdef DESKTOP_VERSION 896#ifdef DESKTOP_VERSION
897 return locateLocal("tmp", "phonefile.vcf"); 897 return locateLocal("tmp", "phonefile.vcf");
898#else 898#else
899 return "/tmp/phonefile.vcf"; 899 return "/tmp/phonefile.vcf";
900#endif 900#endif
901 901
902} 902}
903void KABCore::writeToPhone( ) 903void KABCore::writeToPhone( )
904{ 904{
905 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 905 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
906 message(i18n("Export to phone finished!")); 906 message(i18n("Export to phone finished!"));
907 else 907 else
908 qDebug(i18n("Error exporting to phone")); 908 qDebug(i18n("Error exporting to phone"));
909} 909}
910void KABCore::beamVCard() 910void KABCore::beamVCard()
911{ 911{
912 QStringList uids; 912 QStringList uids;
913 XXPortSelectDialog dlg( this, false, this ); 913 XXPortSelectDialog dlg( this, false, this );
914 if ( dlg.exec() ) 914 if ( dlg.exec() )
915 uids = dlg.uids(); 915 uids = dlg.uids();
916 else 916 else
917 return; 917 return;
918 if ( uids.isEmpty() ) 918 if ( uids.isEmpty() )
919 return; 919 return;
920 beamVCard( uids ); 920 beamVCard( uids );
921} 921}
922 922
923 923
924void KABCore::beamVCard(const QStringList& uids) 924void KABCore::beamVCard(const QStringList& uids)
925{ 925{
926 926
927 // LR: we should use the /tmp dir on the Zaurus, 927 // LR: we should use the /tmp dir on the Zaurus,
928 // because: /tmp = RAM, (HOME)/kdepim = flash memory 928 // because: /tmp = RAM, (HOME)/kdepim = flash memory
929 929
930#ifdef DESKTOP_VERSION 930#ifdef DESKTOP_VERSION
931 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 931 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
932#else 932#else
933 QString fileName = "/tmp/kapibeamfile.vcf"; 933 QString fileName = "/tmp/kapibeamfile.vcf";
934#endif 934#endif
935 935
936 KABC::VCardConverter converter; 936 KABC::VCardConverter converter;
937 QString description; 937 QString description;
938 QString datastream; 938 QString datastream;
939 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 939 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
940 KABC::Addressee a = mAddressBook->findByUid( *it ); 940 KABC::Addressee a = mAddressBook->findByUid( *it );
941 941
942 if ( a.isEmpty() ) 942 if ( a.isEmpty() )
943 continue; 943 continue;
944 944
945 if (description.isEmpty()) 945 if (description.isEmpty())
946 description = a.formattedName(); 946 description = a.formattedName();
947 947
948 QString vcard; 948 QString vcard;
949 converter.addresseeToVCard( a, vcard ); 949 converter.addresseeToVCard( a, vcard );
950 int start = 0; 950 int start = 0;
951 int next; 951 int next;
952 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 952 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
953 int semi = vcard.find(";", next); 953 int semi = vcard.find(";", next);
954 int dopp = vcard.find(":", next); 954 int dopp = vcard.find(":", next);
955 int sep; 955 int sep;
956 if ( semi < dopp && semi >= 0 ) 956 if ( semi < dopp && semi >= 0 )
957 sep = semi ; 957 sep = semi ;
958 else 958 else
959 sep = dopp; 959 sep = dopp;
960 datastream +=vcard.mid( start, next - start); 960 datastream +=vcard.mid( start, next - start);
961 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 961 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
962 start = sep; 962 start = sep;
963 } 963 }
964 datastream += vcard.mid( start,vcard.length() ); 964 datastream += vcard.mid( start,vcard.length() );
965 } 965 }
966#ifndef DESKTOP_VERSION 966#ifndef DESKTOP_VERSION
967 QFile outFile(fileName); 967 QFile outFile(fileName);
968 if ( outFile.open(IO_WriteOnly) ) { 968 if ( outFile.open(IO_WriteOnly) ) {
969 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 969 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
970 QTextStream t( &outFile ); // use a text stream 970 QTextStream t( &outFile ); // use a text stream
971 //t.setEncoding( QTextStream::UnicodeUTF8 ); 971 //t.setEncoding( QTextStream::UnicodeUTF8 );
972 t.setEncoding( QTextStream::Latin1 ); 972 t.setEncoding( QTextStream::Latin1 );
973 t <<datastream.latin1(); 973 t <<datastream.latin1();
974 outFile.close(); 974 outFile.close();
975 Ir *ir = new Ir( this ); 975 Ir *ir = new Ir( this );
976 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 976 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
977 ir->send( fileName, description, "text/x-vCard" ); 977 ir->send( fileName, description, "text/x-vCard" );
978 } else { 978 } else {
979 qDebug("Error open temp beam file "); 979 qDebug("Error open temp beam file ");
980 return; 980 return;
981 } 981 }
982#endif 982#endif
983 983
984} 984}
985 985
986void KABCore::beamDone( Ir *ir ) 986void KABCore::beamDone( Ir *ir )
987{ 987{
988#ifndef DESKTOP_VERSION 988#ifndef DESKTOP_VERSION
989 delete ir; 989 delete ir;
990#endif 990#endif
991 topLevelWidget()->raise(); 991 topLevelWidget()->raise();
992 message( i18n("Beaming finished!") ); 992 message( i18n("Beaming finished!") );
993} 993}
994 994
995 995
996void KABCore::browse( const QString& url ) 996void KABCore::browse( const QString& url )
997{ 997{
998#ifndef KAB_EMBEDDED 998#ifndef KAB_EMBEDDED
999 kapp->invokeBrowser( url ); 999 kapp->invokeBrowser( url );
1000#else //KAB_EMBEDDED 1000#else //KAB_EMBEDDED
1001 qDebug("KABCore::browse must be fixed"); 1001 qDebug("KABCore::browse must be fixed");
1002#endif //KAB_EMBEDDED 1002#endif //KAB_EMBEDDED
1003} 1003}
1004 1004
1005void KABCore::selectAllContacts() 1005void KABCore::selectAllContacts()
1006{ 1006{
1007 mViewManager->setSelected( QString::null, true ); 1007 mViewManager->setSelected( QString::null, true );
1008} 1008}
1009 1009
1010void KABCore::deleteContacts() 1010void KABCore::deleteContacts()
1011{ 1011{
1012 QStringList uidList = mViewManager->selectedUids(); 1012 QStringList uidList = mViewManager->selectedUids();
1013 deleteContacts( uidList ); 1013 deleteContacts( uidList );
1014} 1014}
1015 1015
1016void KABCore::deleteContacts( const QStringList &uids ) 1016void KABCore::deleteContacts( const QStringList &uids )
1017{ 1017{
1018 if ( uids.count() > 0 ) { 1018 if ( uids.count() > 0 ) {
1019 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1019 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1020 UndoStack::instance()->push( command ); 1020 UndoStack::instance()->push( command );
1021 RedoStack::instance()->clear(); 1021 RedoStack::instance()->clear();
1022 1022
1023 // now if we deleted anything, refresh 1023 // now if we deleted anything, refresh
1024 setContactSelected( QString::null ); 1024 setContactSelected( QString::null );
1025 setModified( true ); 1025 setModified( true );
1026 } 1026 }
1027} 1027}
1028 1028
1029void KABCore::copyContacts() 1029void KABCore::copyContacts()
1030{ 1030{
1031 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1031 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1032 1032
1033 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1033 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1034 1034
1035 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1035 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1036 1036
1037 QClipboard *cb = QApplication::clipboard(); 1037 QClipboard *cb = QApplication::clipboard();
1038 cb->setText( clipText ); 1038 cb->setText( clipText );
1039} 1039}
1040 1040
1041void KABCore::cutContacts() 1041void KABCore::cutContacts()
1042{ 1042{
1043 QStringList uidList = mViewManager->selectedUids(); 1043 QStringList uidList = mViewManager->selectedUids();
1044 1044
1045//US if ( uidList.size() > 0 ) { 1045//US if ( uidList.size() > 0 ) {
1046 if ( uidList.count() > 0 ) { 1046 if ( uidList.count() > 0 ) {
1047 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1047 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1048 UndoStack::instance()->push( command ); 1048 UndoStack::instance()->push( command );
1049 RedoStack::instance()->clear(); 1049 RedoStack::instance()->clear();
1050 1050
1051 setModified( true ); 1051 setModified( true );
1052 } 1052 }
1053} 1053}
1054 1054
1055void KABCore::pasteContacts() 1055void KABCore::pasteContacts()
1056{ 1056{
1057 QClipboard *cb = QApplication::clipboard(); 1057 QClipboard *cb = QApplication::clipboard();
1058 1058
1059 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1059 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1060 1060
1061 pasteContacts( list ); 1061 pasteContacts( list );
1062} 1062}
1063 1063
1064void KABCore::pasteContacts( KABC::Addressee::List &list ) 1064void KABCore::pasteContacts( KABC::Addressee::List &list )
1065{ 1065{
1066 KABC::Resource *resource = requestResource( this ); 1066 KABC::Resource *resource = requestResource( this );
1067 KABC::Addressee::List::Iterator it; 1067 KABC::Addressee::List::Iterator it;
1068 for ( it = list.begin(); it != list.end(); ++it ) 1068 for ( it = list.begin(); it != list.end(); ++it )
1069 (*it).setResource( resource ); 1069 (*it).setResource( resource );
1070 1070
1071 PwPasteCommand *command = new PwPasteCommand( this, list ); 1071 PwPasteCommand *command = new PwPasteCommand( this, list );
1072 UndoStack::instance()->push( command ); 1072 UndoStack::instance()->push( command );
1073 RedoStack::instance()->clear(); 1073 RedoStack::instance()->clear();
1074 1074
1075 setModified( true ); 1075 setModified( true );
1076} 1076}
1077 1077
1078void KABCore::setWhoAmI() 1078void KABCore::setWhoAmI()
1079{ 1079{
1080 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1080 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1081 1081
1082 if ( addrList.count() > 1 ) { 1082 if ( addrList.count() > 1 ) {
1083 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1083 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1084 return; 1084 return;
1085 } 1085 }
1086 1086
1087 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1087 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1088 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1088 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1089 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1089 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1090} 1090}
1091void KABCore::editCategories() 1091void KABCore::editCategories()
1092{ 1092{
1093 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1093 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1094 dlg.exec(); 1094 dlg.exec();
1095} 1095}
1096void KABCore::setCategories() 1096void KABCore::setCategories()
1097{ 1097{
1098 1098
1099 QStringList uids; 1099 QStringList uids;
1100 XXPortSelectDialog dlgx( this, false, this ); 1100 XXPortSelectDialog dlgx( this, false, this );
1101 if ( dlgx.exec() ) 1101 if ( dlgx.exec() )
1102 uids = dlgx.uids(); 1102 uids = dlgx.uids();
1103 else 1103 else
1104 return; 1104 return;
1105 if ( uids.isEmpty() ) 1105 if ( uids.isEmpty() )
1106 return; 1106 return;
1107 // qDebug("count %d ", uids.count()); 1107 // qDebug("count %d ", uids.count());
1108 1108
1109 1109
1110 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1110 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1111 if ( !dlg.exec() ) { 1111 if ( !dlg.exec() ) {
1112 message( i18n("Setting categories cancelled") ); 1112 message( i18n("Setting categories cancelled") );
1113 return; 1113 return;
1114 } 1114 }
1115 bool merge = false; 1115 bool merge = false;
1116 QString msg = i18n( "Merge with existing categories?" ); 1116 QString msg = i18n( "Merge with existing categories?" );
1117 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1117 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1118 merge = true; 1118 merge = true;
1119 1119
1120 message( i18n("Setting categories ... please wait!") ); 1120 message( i18n("Setting categories ... please wait!") );
1121 QStringList categories = dlg.selectedCategories(); 1121 QStringList categories = dlg.selectedCategories();
1122 1122
1123 //QStringList uids = mViewManager->selectedUids(); 1123 //QStringList uids = mViewManager->selectedUids();
1124 QStringList::Iterator it; 1124 QStringList::Iterator it;
1125 for ( it = uids.begin(); it != uids.end(); ++it ) { 1125 for ( it = uids.begin(); it != uids.end(); ++it ) {
1126 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1126 KABC::Addressee addr = mAddressBook->findByUid( *it );
1127 if ( !addr.isEmpty() ) { 1127 if ( !addr.isEmpty() ) {
1128 if ( !merge ) 1128 if ( !merge )
1129 addr.setCategories( categories ); 1129 addr.setCategories( categories );
1130 else { 1130 else {
1131 QStringList addrCategories = addr.categories(); 1131 QStringList addrCategories = addr.categories();
1132 QStringList::Iterator catIt; 1132 QStringList::Iterator catIt;
1133 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1133 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1134 if ( !addrCategories.contains( *catIt ) ) 1134 if ( !addrCategories.contains( *catIt ) )
1135 addrCategories.append( *catIt ); 1135 addrCategories.append( *catIt );
1136 } 1136 }
1137 addr.setCategories( addrCategories ); 1137 addr.setCategories( addrCategories );
1138 } 1138 }
1139 mAddressBook->insertAddressee( addr ); 1139 mAddressBook->insertAddressee( addr );
1140 } 1140 }
1141 } 1141 }
1142 1142
1143 if ( uids.count() > 0 ) 1143 if ( uids.count() > 0 )
1144 setModified( true ); 1144 setModified( true );
1145 message( i18n("Setting categories completed!") ); 1145 message( i18n("Setting categories completed!") );
1146} 1146}
1147 1147
1148void KABCore::setSearchFields( const KABC::Field::List &fields ) 1148void KABCore::setSearchFields( const KABC::Field::List &fields )
1149{ 1149{
1150 mIncSearchWidget->setFields( fields ); 1150 mIncSearchWidget->setFields( fields );
1151} 1151}
1152 1152
1153void KABCore::incrementalSearch( const QString& text ) 1153void KABCore::incrementalSearch( const QString& text )
1154{ 1154{
1155 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1155 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1156} 1156}
1157 1157
1158void KABCore::setModified() 1158void KABCore::setModified()
1159{ 1159{
1160 setModified( true ); 1160 setModified( true );
1161} 1161}
1162 1162
1163void KABCore::setModifiedWOrefresh() 1163void KABCore::setModifiedWOrefresh()
1164{ 1164{
1165 // qDebug("KABCore::setModifiedWOrefresh() "); 1165 // qDebug("KABCore::setModifiedWOrefresh() ");
1166 mModified = true; 1166 mModified = true;
1167 mActionSave->setEnabled( mModified ); 1167 mActionSave->setEnabled( mModified );
1168 1168
1169 1169
1170} 1170}
1171void KABCore::setModified( bool modified ) 1171void KABCore::setModified( bool modified )
1172{ 1172{
1173 mModified = modified; 1173 mModified = modified;
1174 mActionSave->setEnabled( mModified ); 1174 mActionSave->setEnabled( mModified );
1175 1175
1176 if ( modified ) 1176 if ( modified )
1177 mJumpButtonBar->recreateButtons(); 1177 mJumpButtonBar->recreateButtons();
1178 1178
1179 mViewManager->refreshView(); 1179 mViewManager->refreshView();
1180 1180
1181} 1181}
1182 1182
1183bool KABCore::modified() const 1183bool KABCore::modified() const
1184{ 1184{
1185 return mModified; 1185 return mModified;
1186} 1186}
1187 1187
1188void KABCore::contactModified( const KABC::Addressee &addr ) 1188void KABCore::contactModified( const KABC::Addressee &addr )
1189{ 1189{
1190 addrModified( addr ); 1190 addrModified( addr );
1191} 1191}
1192 1192
1193void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1193void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1194{ 1194{
1195 1195
1196 Command *command = 0; 1196 Command *command = 0;
1197 QString uid; 1197 QString uid;
1198 1198
1199 // check if it exists already 1199 // check if it exists already
1200 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1200 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1201 if ( origAddr.isEmpty() ) 1201 if ( origAddr.isEmpty() )
1202 command = new PwNewCommand( mAddressBook, addr ); 1202 command = new PwNewCommand( mAddressBook, addr );
1203 else { 1203 else {
1204 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1204 command = new PwEditCommand( mAddressBook, origAddr, addr );
1205 uid = addr.uid(); 1205 uid = addr.uid();
1206 } 1206 }
1207 1207
1208 UndoStack::instance()->push( command ); 1208 UndoStack::instance()->push( command );
1209 RedoStack::instance()->clear(); 1209 RedoStack::instance()->clear();
1210 if ( updateDetails ) 1210 if ( updateDetails )
1211 mDetails->setAddressee( addr ); 1211 mDetails->setAddressee( addr );
1212 setModified( true ); 1212 setModified( true );
1213} 1213}
1214 1214
1215void KABCore::newContact() 1215void KABCore::newContact()
1216{ 1216{
1217 1217
1218 1218
1219 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1219 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1220 1220
1221 QPtrList<KRES::Resource> kresResources; 1221 QPtrList<KRES::Resource> kresResources;
1222 QPtrListIterator<KABC::Resource> it( kabcResources ); 1222 QPtrListIterator<KABC::Resource> it( kabcResources );
1223 KABC::Resource *resource; 1223 KABC::Resource *resource;
1224 while ( ( resource = it.current() ) != 0 ) { 1224 while ( ( resource = it.current() ) != 0 ) {
1225 ++it; 1225 ++it;
1226 if ( !resource->readOnly() ) { 1226 if ( !resource->readOnly() ) {
1227 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1227 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1228 if ( res ) 1228 if ( res )
1229 kresResources.append( res ); 1229 kresResources.append( res );
1230 } 1230 }
1231 } 1231 }
1232 1232
1233 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1233 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1234 resource = static_cast<KABC::Resource*>( res ); 1234 resource = static_cast<KABC::Resource*>( res );
1235 1235
1236 if ( resource ) { 1236 if ( resource ) {
1237 KABC::Addressee addr; 1237 KABC::Addressee addr;
1238 addr.setResource( resource ); 1238 addr.setResource( resource );
1239 mEditorDialog->setAddressee( addr ); 1239 mEditorDialog->setAddressee( addr );
1240 KApplication::execDialog ( mEditorDialog ); 1240 KApplication::execDialog ( mEditorDialog );
1241 1241
1242 } else 1242 } else
1243 return; 1243 return;
1244 1244
1245 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1245 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1246 1246
1247 1247
1248} 1248}
1249 1249
1250void KABCore::addEmail( QString aStr ) 1250void KABCore::addEmail( QString aStr )
1251{ 1251{
1252#ifndef KAB_EMBEDDED 1252#ifndef KAB_EMBEDDED
1253 QString fullName, email; 1253 QString fullName, email;
1254 1254
1255 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1255 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1256 1256
1257 // Try to lookup the addressee matching the email address 1257 // Try to lookup the addressee matching the email address
1258 bool found = false; 1258 bool found = false;
1259 QStringList emailList; 1259 QStringList emailList;
1260 KABC::AddressBook::Iterator it; 1260 KABC::AddressBook::Iterator it;
1261 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1261 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1262 emailList = (*it).emails(); 1262 emailList = (*it).emails();
1263 if ( emailList.contains( email ) > 0 ) { 1263 if ( emailList.contains( email ) > 0 ) {
1264 found = true; 1264 found = true;
1265 (*it).setNameFromString( fullName ); 1265 (*it).setNameFromString( fullName );
1266 editContact( (*it).uid() ); 1266 editContact( (*it).uid() );
1267 } 1267 }
1268 } 1268 }
1269 1269
1270 if ( !found ) { 1270 if ( !found ) {
1271 KABC::Addressee addr; 1271 KABC::Addressee addr;
1272 addr.setNameFromString( fullName ); 1272 addr.setNameFromString( fullName );
1273 addr.insertEmail( email, true ); 1273 addr.insertEmail( email, true );
1274 1274
1275 mAddressBook->insertAddressee( addr ); 1275 mAddressBook->insertAddressee( addr );
1276 mViewManager->refreshView( addr.uid() ); 1276 mViewManager->refreshView( addr.uid() );
1277 editContact( addr.uid() ); 1277 editContact( addr.uid() );
1278 } 1278 }
1279#else //KAB_EMBEDDED 1279#else //KAB_EMBEDDED
1280 qDebug("KABCore::addEmail finsih method"); 1280 qDebug("KABCore::addEmail finsih method");
1281#endif //KAB_EMBEDDED 1281#endif //KAB_EMBEDDED
1282} 1282}
1283 1283
1284void KABCore::importVCard( const KURL &url, bool showPreview ) 1284void KABCore::importVCard( const KURL &url, bool showPreview )
1285{ 1285{
1286 mXXPortManager->importVCard( url, showPreview ); 1286 mXXPortManager->importVCard( url, showPreview );
1287} 1287}
1288void KABCore::importFromOL() 1288void KABCore::importFromOL()
1289{ 1289{
1290#ifdef _WIN32_ 1290#ifdef _WIN32_
1291 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1291 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1292 idgl->exec(); 1292 idgl->exec();
1293 KABC::Addressee::List list = idgl->getAddressList(); 1293 KABC::Addressee::List list = idgl->getAddressList();
1294 if ( list.count() > 0 ) { 1294 if ( list.count() > 0 ) {
1295 KABC::Addressee::List listNew; 1295 KABC::Addressee::List listNew;
1296 KABC::Addressee::List listExisting; 1296 KABC::Addressee::List listExisting;
1297 KABC::Addressee::List::Iterator it; 1297 KABC::Addressee::List::Iterator it;
1298 KABC::AddressBook::Iterator iter; 1298 KABC::AddressBook::Iterator iter;
1299 for ( it = list.begin(); it != list.end(); ++it ) { 1299 for ( it = list.begin(); it != list.end(); ++it ) {
1300 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1300 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1301 listNew.append( (*it) ); 1301 listNew.append( (*it) );
1302 else 1302 else
1303 listExisting.append( (*it) ); 1303 listExisting.append( (*it) );
1304 } 1304 }
1305 if ( listExisting.count() > 0 ) 1305 if ( listExisting.count() > 0 )
1306 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1306 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1307 if ( listNew.count() > 0 ) { 1307 if ( listNew.count() > 0 ) {
1308 pasteWithNewUid = false; 1308 pasteWithNewUid = false;
1309 pasteContacts( listNew ); 1309 pasteContacts( listNew );
1310 pasteWithNewUid = true; 1310 pasteWithNewUid = true;
1311 } 1311 }
1312 } 1312 }
1313 delete idgl; 1313 delete idgl;
1314#endif 1314#endif
1315} 1315}
1316 1316
1317void KABCore::importVCard( const QString &vCard, bool showPreview ) 1317void KABCore::importVCard( const QString &vCard, bool showPreview )
1318{ 1318{
1319 mXXPortManager->importVCard( vCard, showPreview ); 1319 mXXPortManager->importVCard( vCard, showPreview );
1320} 1320}
1321 1321
1322//US added a second method without defaultparameter 1322//US added a second method without defaultparameter
1323void KABCore::editContact2() { 1323void KABCore::editContact2() {
1324 editContact( QString::null ); 1324 editContact( QString::null );
1325} 1325}
1326 1326
1327void KABCore::editContact( const QString &uid ) 1327void KABCore::editContact( const QString &uid )
1328{ 1328{
1329 1329
1330 if ( mExtensionManager->isQuickEditVisible() ) 1330 if ( mExtensionManager->isQuickEditVisible() )
1331 return; 1331 return;
1332 1332
1333 // First, locate the contact entry 1333 // First, locate the contact entry
1334 QString localUID = uid; 1334 QString localUID = uid;
1335 if ( localUID.isNull() ) { 1335 if ( localUID.isNull() ) {
1336 QStringList uidList = mViewManager->selectedUids(); 1336 QStringList uidList = mViewManager->selectedUids();
1337 if ( uidList.count() > 0 ) 1337 if ( uidList.count() > 0 )
1338 localUID = *( uidList.at( 0 ) ); 1338 localUID = *( uidList.at( 0 ) );
1339 } 1339 }
1340 1340
1341 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1341 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1342 if ( !addr.isEmpty() ) { 1342 if ( !addr.isEmpty() ) {
1343 mEditorDialog->setAddressee( addr ); 1343 mEditorDialog->setAddressee( addr );
1344 KApplication::execDialog ( mEditorDialog ); 1344 KApplication::execDialog ( mEditorDialog );
1345 } 1345 }
1346} 1346}
1347 1347
1348/** 1348/**
1349 Shows or edits the detail view for the given uid. If the uid is QString::null, 1349 Shows or edits the detail view for the given uid. If the uid is QString::null,
1350 the method will try to find a selected addressee in the view. 1350 the method will try to find a selected addressee in the view.
1351 */ 1351 */
1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1352void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1353{ 1353{
1354 if ( mMultipleViewsAtOnce ) 1354 if ( mMultipleViewsAtOnce )
1355 { 1355 {
1356 editContact( uid ); 1356 editContact( uid );
1357 } 1357 }
1358 else 1358 else
1359 { 1359 {
1360 setDetailsVisible( true ); 1360 setDetailsVisible( true );
1361 mActionDetails->setChecked(true); 1361 mActionDetails->setChecked(true);
1362 } 1362 }
1363 1363
1364} 1364}
1365 1365
1366void KABCore::save() 1366void KABCore::save()
1367{ 1367{
1368 if (syncManager->blockSave()) 1368 if (syncManager->blockSave())
1369 return; 1369 return;
1370 if ( !mModified ) 1370 if ( !mModified )
1371 return; 1371 return;
1372 1372
1373 syncManager->setBlockSave(true); 1373 syncManager->setBlockSave(true);
1374 QString text = i18n( "There was an error while attempting to save\n the " 1374 QString text = i18n( "There was an error while attempting to save\n the "
1375 "address book. Please check that some \nother application is " 1375 "address book. Please check that some \nother application is "
1376 "not using it. " ); 1376 "not using it. " );
1377 message(i18n("Saving ... please wait! ")); 1377 message(i18n("Saving ... please wait! "), false);
1378 qApp->processEvents(); 1378 //qApp->processEvents();
1379#ifndef KAB_EMBEDDED 1379#ifndef KAB_EMBEDDED
1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1380 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1381 if ( !b || !b->save() ) { 1381 if ( !b || !b->save() ) {
1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1382 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1383 } 1383 }
1384#else //KAB_EMBEDDED 1384#else //KAB_EMBEDDED
1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1385 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1386 if ( !b || !b->save() ) { 1386 if ( !b || !b->save() ) {
1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1387 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1388 } 1388 }
1389#endif //KAB_EMBEDDED 1389#endif //KAB_EMBEDDED
1390 1390
1391 message(i18n("Addressbook saved!")); 1391 message(i18n("Addressbook saved!"));
1392 setModified( false ); 1392 setModified( false );
1393 syncManager->setBlockSave(false); 1393 syncManager->setBlockSave(false);
1394} 1394}
1395 1395
1396 1396
1397void KABCore::undo() 1397void KABCore::undo()
1398{ 1398{
1399 UndoStack::instance()->undo(); 1399 UndoStack::instance()->undo();
1400 1400
1401 // Refresh the view 1401 // Refresh the view
1402 mViewManager->refreshView(); 1402 mViewManager->refreshView();
1403} 1403}
1404 1404
1405void KABCore::redo() 1405void KABCore::redo()
1406{ 1406{
1407 RedoStack::instance()->redo(); 1407 RedoStack::instance()->redo();
1408 1408
1409 // Refresh the view 1409 // Refresh the view
1410 mViewManager->refreshView(); 1410 mViewManager->refreshView();
1411} 1411}
1412 1412
1413void KABCore::setJumpButtonBarVisible( bool visible ) 1413void KABCore::setJumpButtonBarVisible( bool visible )
1414{ 1414{
1415 if (mMultipleViewsAtOnce) 1415 if (mMultipleViewsAtOnce)
1416 { 1416 {
1417 if ( visible ) 1417 if ( visible )
1418 mJumpButtonBar->show(); 1418 mJumpButtonBar->show();
1419 else 1419 else
1420 mJumpButtonBar->hide(); 1420 mJumpButtonBar->hide();
1421 } 1421 }
1422 else 1422 else
1423 { 1423 {
1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1424 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1425 if (mViewManager->isVisible()) 1425 if (mViewManager->isVisible())
1426 { 1426 {
1427 if ( visible ) 1427 if ( visible )
1428 mJumpButtonBar->show(); 1428 mJumpButtonBar->show();
1429 else 1429 else
1430 mJumpButtonBar->hide(); 1430 mJumpButtonBar->hide();
1431 } 1431 }
1432 else 1432 else
1433 { 1433 {
1434 mJumpButtonBar->hide(); 1434 mJumpButtonBar->hide();
1435 } 1435 }
1436 } 1436 }
1437} 1437}
1438 1438
1439 1439
1440void KABCore::setDetailsToState() 1440void KABCore::setDetailsToState()
1441{ 1441{
1442 setDetailsVisible( mActionDetails->isChecked() ); 1442 setDetailsVisible( mActionDetails->isChecked() );
1443} 1443}
1444void KABCore::setDetailsToggle() 1444void KABCore::setDetailsToggle()
1445{ 1445{
1446 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1446 mActionDetails->setChecked( !mActionDetails->isChecked() );
1447 setDetailsToState(); 1447 setDetailsToState();
1448} 1448}
1449 1449
1450 1450
1451 1451
1452void KABCore::setDetailsVisible( bool visible ) 1452void KABCore::setDetailsVisible( bool visible )
1453{ 1453{
1454 if (visible && mDetails->isHidden()) 1454 if (visible && mDetails->isHidden())
1455 { 1455 {
1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1456 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1457 if ( addrList.count() > 0 ) 1457 if ( addrList.count() > 0 )
1458 mDetails->setAddressee( addrList[ 0 ] ); 1458 mDetails->setAddressee( addrList[ 0 ] );
1459 } 1459 }
1460 1460
1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1461 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1462 // the listview and the detailview. We do that by changing the splitbar size. 1462 // the listview and the detailview. We do that by changing the splitbar size.
1463 if (mMultipleViewsAtOnce) 1463 if (mMultipleViewsAtOnce)
1464 { 1464 {
1465 if ( visible ) 1465 if ( visible )
1466 mDetails->show(); 1466 mDetails->show();
1467 else 1467 else
1468 mDetails->hide(); 1468 mDetails->hide();
1469 } 1469 }
1470 else 1470 else
1471 { 1471 {
1472 if ( visible ) { 1472 if ( visible ) {
1473 mViewManager->hide(); 1473 mViewManager->hide();
1474 mDetails->show(); 1474 mDetails->show();
1475 mIncSearchWidget->setFocus(); 1475 mIncSearchWidget->setFocus();
1476 } 1476 }
1477 else { 1477 else {
1478 mViewManager->show(); 1478 mViewManager->show();
1479 mDetails->hide(); 1479 mDetails->hide();
1480 mViewManager->setFocusAV(); 1480 mViewManager->setFocusAV();
1481 } 1481 }
1482 setJumpButtonBarVisible( !visible ); 1482 setJumpButtonBarVisible( !visible );
1483 } 1483 }
1484 1484
1485} 1485}
1486 1486
1487void KABCore::extensionChanged( int id ) 1487void KABCore::extensionChanged( int id )
1488{ 1488{
1489 //change the details view only for non desktop systems 1489 //change the details view only for non desktop systems
1490#ifndef DESKTOP_VERSION 1490#ifndef DESKTOP_VERSION
1491 1491
1492 if (id == 0) 1492 if (id == 0)
1493 { 1493 {
1494 //the user disabled the extension. 1494 //the user disabled the extension.
1495 1495
1496 if (mMultipleViewsAtOnce) 1496 if (mMultipleViewsAtOnce)
1497 { // enable detailsview again 1497 { // enable detailsview again
1498 setDetailsVisible( true ); 1498 setDetailsVisible( true );
1499 mActionDetails->setChecked( true ); 1499 mActionDetails->setChecked( true );
1500 } 1500 }
1501 else 1501 else
1502 { //go back to the listview 1502 { //go back to the listview
1503 setDetailsVisible( false ); 1503 setDetailsVisible( false );
1504 mActionDetails->setChecked( false ); 1504 mActionDetails->setChecked( false );
1505 mActionDetails->setEnabled(true); 1505 mActionDetails->setEnabled(true);
1506 } 1506 }
1507 1507
1508 } 1508 }
1509 else 1509 else
1510 { 1510 {
1511 //the user enabled the extension. 1511 //the user enabled the extension.
1512 setDetailsVisible( false ); 1512 setDetailsVisible( false );
1513 mActionDetails->setChecked( false ); 1513 mActionDetails->setChecked( false );
1514 1514
1515 if (!mMultipleViewsAtOnce) 1515 if (!mMultipleViewsAtOnce)
1516 { 1516 {
1517 mActionDetails->setEnabled(false); 1517 mActionDetails->setEnabled(false);
1518 } 1518 }
1519 1519
1520 mExtensionManager->setSelectionChanged(); 1520 mExtensionManager->setSelectionChanged();
1521 1521
1522 } 1522 }
1523 1523
1524#endif// DESKTOP_VERSION 1524#endif// DESKTOP_VERSION
1525 1525
1526} 1526}
1527 1527
1528 1528
1529void KABCore::extensionModified( const KABC::Addressee::List &list ) 1529void KABCore::extensionModified( const KABC::Addressee::List &list )
1530{ 1530{
1531 1531
1532 if ( list.count() != 0 ) { 1532 if ( list.count() != 0 ) {
1533 KABC::Addressee::List::ConstIterator it; 1533 KABC::Addressee::List::ConstIterator it;
1534 for ( it = list.begin(); it != list.end(); ++it ) 1534 for ( it = list.begin(); it != list.end(); ++it )
1535 mAddressBook->insertAddressee( *it ); 1535 mAddressBook->insertAddressee( *it );
1536 if ( list.count() > 1 ) 1536 if ( list.count() > 1 )
1537 setModified(); 1537 setModified();
1538 else 1538 else
1539 setModifiedWOrefresh(); 1539 setModifiedWOrefresh();
1540 } 1540 }
1541 if ( list.count() == 0 ) 1541 if ( list.count() == 0 )
1542 mViewManager->refreshView(); 1542 mViewManager->refreshView();
1543 else 1543 else
1544 mViewManager->refreshView( list[ 0 ].uid() ); 1544 mViewManager->refreshView( list[ 0 ].uid() );
1545 1545
1546 1546
1547 1547
1548} 1548}
1549 1549
1550QString KABCore::getNameByPhone( const QString &phone ) 1550QString KABCore::getNameByPhone( const QString &phone )
1551{ 1551{
1552#ifndef KAB_EMBEDDED 1552#ifndef KAB_EMBEDDED
1553 QRegExp r( "[/*/-/ ]" ); 1553 QRegExp r( "[/*/-/ ]" );
1554 QString localPhone( phone ); 1554 QString localPhone( phone );
1555 1555
1556 bool found = false; 1556 bool found = false;
1557 QString ownerName = ""; 1557 QString ownerName = "";
1558 KABC::AddressBook::Iterator iter; 1558 KABC::AddressBook::Iterator iter;
1559 KABC::PhoneNumber::List::Iterator phoneIter; 1559 KABC::PhoneNumber::List::Iterator phoneIter;
1560 KABC::PhoneNumber::List phoneList; 1560 KABC::PhoneNumber::List phoneList;
1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1561 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1562 phoneList = (*iter).phoneNumbers(); 1562 phoneList = (*iter).phoneNumbers();
1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1563 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1564 ++phoneIter) { 1564 ++phoneIter) {
1565 // Get rid of separator chars so just the numbers are compared. 1565 // Get rid of separator chars so just the numbers are compared.
1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1566 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1567 ownerName = (*iter).formattedName(); 1567 ownerName = (*iter).formattedName();
1568 found = true; 1568 found = true;
1569 } 1569 }
1570 } 1570 }
1571 } 1571 }
1572 1572
1573 return ownerName; 1573 return ownerName;
1574#else //KAB_EMBEDDED 1574#else //KAB_EMBEDDED
1575 qDebug("KABCore::getNameByPhone finsih method"); 1575 qDebug("KABCore::getNameByPhone finsih method");
1576 return ""; 1576 return "";
1577#endif //KAB_EMBEDDED 1577#endif //KAB_EMBEDDED
1578 1578
1579} 1579}
1580 1580
1581void KABCore::openConfigDialog() 1581void KABCore::openConfigDialog()
1582{ 1582{
1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1583 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1584 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1585 ConfigureDialog->addModule(kabcfg ); 1585 ConfigureDialog->addModule(kabcfg );
1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1586 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1587 ConfigureDialog->addModule(kdelibcfg ); 1587 ConfigureDialog->addModule(kdelibcfg );
1588 1588
1589 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1589 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1590 this, SLOT( configurationChanged() ) ); 1590 this, SLOT( configurationChanged() ) );
1591 connect( ConfigureDialog, SIGNAL( okClicked() ), 1591 connect( ConfigureDialog, SIGNAL( okClicked() ),
1592 this, SLOT( configurationChanged() ) ); 1592 this, SLOT( configurationChanged() ) );
1593 saveSettings(); 1593 saveSettings();
1594#ifndef DESKTOP_VERSION 1594#ifndef DESKTOP_VERSION
1595 ConfigureDialog->showMaximized(); 1595 ConfigureDialog->showMaximized();
1596#endif 1596#endif
1597 if ( ConfigureDialog->exec() ) 1597 if ( ConfigureDialog->exec() )
1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1598 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1599 delete ConfigureDialog; 1599 delete ConfigureDialog;
1600} 1600}
1601 1601
1602void KABCore::openLDAPDialog() 1602void KABCore::openLDAPDialog()
1603{ 1603{
1604#ifndef KAB_EMBEDDED 1604#ifndef KAB_EMBEDDED
1605 if ( !mLdapSearchDialog ) { 1605 if ( !mLdapSearchDialog ) {
1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1606 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1607 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1608 SLOT( refreshView() ) ); 1608 SLOT( refreshView() ) );
1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1609 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1610 SLOT( setModified() ) ); 1610 SLOT( setModified() ) );
1611 } else 1611 } else
1612 mLdapSearchDialog->restoreSettings(); 1612 mLdapSearchDialog->restoreSettings();
1613 1613
1614 if ( mLdapSearchDialog->isOK() ) 1614 if ( mLdapSearchDialog->isOK() )
1615 mLdapSearchDialog->exec(); 1615 mLdapSearchDialog->exec();
1616#else //KAB_EMBEDDED 1616#else //KAB_EMBEDDED
1617 qDebug("KABCore::openLDAPDialog() finsih method"); 1617 qDebug("KABCore::openLDAPDialog() finsih method");
1618#endif //KAB_EMBEDDED 1618#endif //KAB_EMBEDDED
1619} 1619}
1620 1620
1621void KABCore::print() 1621void KABCore::print()
1622{ 1622{
1623#ifndef KAB_EMBEDDED 1623#ifndef KAB_EMBEDDED
1624 KPrinter printer; 1624 KPrinter printer;
1625 if ( !printer.setup( this ) ) 1625 if ( !printer.setup( this ) )
1626 return; 1626 return;
1627 1627
1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1628 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1629 mViewManager->selectedUids(), this ); 1629 mViewManager->selectedUids(), this );
1630 1630
1631 wizard.exec(); 1631 wizard.exec();
1632#else //KAB_EMBEDDED 1632#else //KAB_EMBEDDED
1633 qDebug("KABCore::print() finsih method"); 1633 qDebug("KABCore::print() finsih method");
1634#endif //KAB_EMBEDDED 1634#endif //KAB_EMBEDDED
1635 1635
1636} 1636}
1637 1637
1638 1638
1639void KABCore::addGUIClient( KXMLGUIClient *client ) 1639void KABCore::addGUIClient( KXMLGUIClient *client )
1640{ 1640{
1641 if ( mGUIClient ) 1641 if ( mGUIClient )
1642 mGUIClient->insertChildClient( client ); 1642 mGUIClient->insertChildClient( client );
1643 else 1643 else
1644 KMessageBox::error( this, "no KXMLGUICLient"); 1644 KMessageBox::error( this, "no KXMLGUICLient");
1645} 1645}
1646 1646
1647 1647
1648void KABCore::configurationChanged() 1648void KABCore::configurationChanged()
1649{ 1649{
1650 mExtensionManager->reconfigure(); 1650 mExtensionManager->reconfigure();
1651} 1651}
1652 1652
1653void KABCore::addressBookChanged() 1653void KABCore::addressBookChanged()
1654{ 1654{
1655/*US 1655/*US
1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1656 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1657 while ( it.current() ) { 1657 while ( it.current() ) {
1658 if ( it.current()->dirty() ) { 1658 if ( it.current()->dirty() ) {
1659 QString text = i18n( "Data has been changed externally. Unsaved " 1659 QString text = i18n( "Data has been changed externally. Unsaved "
1660 "changes will be lost." ); 1660 "changes will be lost." );
1661 KMessageBox::information( this, text ); 1661 KMessageBox::information( this, text );
1662 } 1662 }
1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1663 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1664 ++it; 1664 ++it;
1665 } 1665 }
1666*/ 1666*/
1667 if (mEditorDialog) 1667 if (mEditorDialog)
1668 { 1668 {
1669 if (mEditorDialog->dirty()) 1669 if (mEditorDialog->dirty())
1670 { 1670 {
1671 QString text = i18n( "Data has been changed externally. Unsaved " 1671 QString text = i18n( "Data has been changed externally. Unsaved "
1672 "changes will be lost." ); 1672 "changes will be lost." );
1673 KMessageBox::information( this, text ); 1673 KMessageBox::information( this, text );
1674 } 1674 }
1675 QString currentuid = mEditorDialog->addressee().uid(); 1675 QString currentuid = mEditorDialog->addressee().uid();
1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1676 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1677 } 1677 }
1678 mViewManager->refreshView(); 1678 mViewManager->refreshView();
1679 1679
1680 1680
1681} 1681}
1682 1682
1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1683AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1684 const char *name ) 1684 const char *name )
1685{ 1685{
1686 1686
1687 if ( mEditorDialog == 0 ) { 1687 if ( mEditorDialog == 0 ) {
1688 mEditorDialog = new AddresseeEditorDialog( this, parent, 1688 mEditorDialog = new AddresseeEditorDialog( this, parent,
1689 name ? name : "editorDialog" ); 1689 name ? name : "editorDialog" );
1690 1690
1691 1691
1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1692 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1693 SLOT( contactModified( const KABC::Addressee& ) ) ); 1693 SLOT( contactModified( const KABC::Addressee& ) ) );
1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1694 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1695 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1695 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1696 } 1696 }
1697 1697
1698 return mEditorDialog; 1698 return mEditorDialog;
1699} 1699}
1700 1700
1701void KABCore::slotEditorDestroyed( const QString &uid ) 1701void KABCore::slotEditorDestroyed( const QString &uid )
1702{ 1702{
1703 //mEditorDict.remove( uid ); 1703 //mEditorDict.remove( uid );
1704} 1704}
1705 1705
1706void KABCore::initGUI() 1706void KABCore::initGUI()
1707{ 1707{
1708#ifndef KAB_EMBEDDED 1708#ifndef KAB_EMBEDDED
1709 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1709 QHBoxLayout *topLayout = new QHBoxLayout( this );
1710 topLayout->setSpacing( KDialogBase::spacingHint() ); 1710 topLayout->setSpacing( KDialogBase::spacingHint() );
1711 1711
1712 mExtensionBarSplitter = new QSplitter( this ); 1712 mExtensionBarSplitter = new QSplitter( this );
1713 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1713 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1714 1714
1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1715 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1716 1716
1717 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1717 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1718 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1718 mIncSearchWidget = new IncSearchWidget( viewSpace );
1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1719 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1720 SLOT( incrementalSearch( const QString& ) ) ); 1720 SLOT( incrementalSearch( const QString& ) ) );
1721 1721
1722 mViewManager = new ViewManager( this, viewSpace ); 1722 mViewManager = new ViewManager( this, viewSpace );
1723 viewSpace->setStretchFactor( mViewManager, 1 ); 1723 viewSpace->setStretchFactor( mViewManager, 1 );
1724 1724
1725 mDetails = new ViewContainer( mDetailsSplitter ); 1725 mDetails = new ViewContainer( mDetailsSplitter );
1726 1726
1727 mJumpButtonBar = new JumpButtonBar( this, this ); 1727 mJumpButtonBar = new JumpButtonBar( this, this );
1728 1728
1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1729 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1730 1730
1731 topLayout->addWidget( mExtensionBarSplitter ); 1731 topLayout->addWidget( mExtensionBarSplitter );
1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1732 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1733 topLayout->addWidget( mJumpButtonBar ); 1733 topLayout->addWidget( mJumpButtonBar );
1734 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1734 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1735 1735
1736 mXXPortManager = new XXPortManager( this, this ); 1736 mXXPortManager = new XXPortManager( this, this );
1737 1737
1738#else //KAB_EMBEDDED 1738#else //KAB_EMBEDDED
1739 //US initialize viewMenu before settingup viewmanager. 1739 //US initialize viewMenu before settingup viewmanager.
1740 // Viewmanager needs this menu to plugin submenues. 1740 // Viewmanager needs this menu to plugin submenues.
1741 viewMenu = new QPopupMenu( this ); 1741 viewMenu = new QPopupMenu( this );
1742 settingsMenu = new QPopupMenu( this ); 1742 settingsMenu = new QPopupMenu( this );
1743 //filterMenu = new QPopupMenu( this ); 1743 //filterMenu = new QPopupMenu( this );
1744 ImportMenu = new QPopupMenu( this ); 1744 ImportMenu = new QPopupMenu( this );
1745 ExportMenu = new QPopupMenu( this ); 1745 ExportMenu = new QPopupMenu( this );
1746 syncMenu = new QPopupMenu( this ); 1746 syncMenu = new QPopupMenu( this );
1747 changeMenu= new QPopupMenu( this ); 1747 changeMenu= new QPopupMenu( this );
1748 beamMenu= new QPopupMenu( this ); 1748 beamMenu= new QPopupMenu( this );
1749 1749
1750//US since we have no splitter for the embedded system, setup 1750//US since we have no splitter for the embedded system, setup
1751// a layout with two frames. One left and one right. 1751// a layout with two frames. One left and one right.
1752 1752
1753 QBoxLayout *topLayout; 1753 QBoxLayout *topLayout;
1754 1754
1755 // = new QHBoxLayout( this ); 1755 // = new QHBoxLayout( this );
1756// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1756// QBoxLayout *topLayout = (QBoxLayout*)layout();
1757 1757
1758// QWidget *mainBox = new QWidget( this ); 1758// QWidget *mainBox = new QWidget( this );
1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1759// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1760 1760
1761#ifdef DESKTOP_VERSION 1761#ifdef DESKTOP_VERSION
1762 topLayout = new QHBoxLayout( this ); 1762 topLayout = new QHBoxLayout( this );
1763 1763
1764 1764
1765 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1765 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1766 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1766 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1767 1767
1768 topLayout->addWidget(mMiniSplitter ); 1768 topLayout->addWidget(mMiniSplitter );
1769 1769
1770 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1770 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1771 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1771 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1772 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1772 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1773 mDetails = new ViewContainer( mMiniSplitter ); 1773 mDetails = new ViewContainer( mMiniSplitter );
1774 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1774 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1775#else 1775#else
1776 if ( QApplication::desktop()->width() > 480 ) { 1776 if ( QApplication::desktop()->width() > 480 ) {
1777 topLayout = new QHBoxLayout( this ); 1777 topLayout = new QHBoxLayout( this );
1778 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1778 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1779 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1779 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1780 } else { 1780 } else {
1781 1781
1782 topLayout = new QHBoxLayout( this ); 1782 topLayout = new QHBoxLayout( this );
1783 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1783 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1784 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1784 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1785 } 1785 }
1786 1786
1787 topLayout->addWidget(mMiniSplitter ); 1787 topLayout->addWidget(mMiniSplitter );
1788 mViewManager = new ViewManager( this, mMiniSplitter ); 1788 mViewManager = new ViewManager( this, mMiniSplitter );
1789 mDetails = new ViewContainer( mMiniSplitter ); 1789 mDetails = new ViewContainer( mMiniSplitter );
1790 1790
1791 1791
1792 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1792 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1793#endif 1793#endif
1794 //eh->hide(); 1794 //eh->hide();
1795 // topLayout->addWidget(mExtensionManager ); 1795 // topLayout->addWidget(mExtensionManager );
1796 1796
1797 1797
1798/*US 1798/*US
1799#ifndef KAB_NOSPLITTER 1799#ifndef KAB_NOSPLITTER
1800 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1800 QHBoxLayout *topLayout = new QHBoxLayout( this );
1801//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1801//US topLayout->setSpacing( KDialogBase::spacingHint() );
1802 topLayout->setSpacing( 10 ); 1802 topLayout->setSpacing( 10 );
1803 1803
1804 mDetailsSplitter = new QSplitter( this ); 1804 mDetailsSplitter = new QSplitter( this );
1805 1805
1806 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1806 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1807 1807
1808 mViewManager = new ViewManager( this, viewSpace ); 1808 mViewManager = new ViewManager( this, viewSpace );
1809 viewSpace->setStretchFactor( mViewManager, 1 ); 1809 viewSpace->setStretchFactor( mViewManager, 1 );
1810 1810
1811 mDetails = new ViewContainer( mDetailsSplitter ); 1811 mDetails = new ViewContainer( mDetailsSplitter );
1812 1812
1813 topLayout->addWidget( mDetailsSplitter ); 1813 topLayout->addWidget( mDetailsSplitter );
1814 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1814 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1815#else //KAB_NOSPLITTER 1815#else //KAB_NOSPLITTER
1816 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1816 QHBoxLayout *topLayout = new QHBoxLayout( this );
1817//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1817//US topLayout->setSpacing( KDialogBase::spacingHint() );
1818 topLayout->setSpacing( 10 ); 1818 topLayout->setSpacing( 10 );
1819 1819
1820// mDetailsSplitter = new QSplitter( this ); 1820// mDetailsSplitter = new QSplitter( this );
1821 1821
1822 QVBox *viewSpace = new QVBox( this ); 1822 QVBox *viewSpace = new QVBox( this );
1823 1823
1824 mViewManager = new ViewManager( this, viewSpace ); 1824 mViewManager = new ViewManager( this, viewSpace );
1825 viewSpace->setStretchFactor( mViewManager, 1 ); 1825 viewSpace->setStretchFactor( mViewManager, 1 );
1826 1826
1827 mDetails = new ViewContainer( this ); 1827 mDetails = new ViewContainer( this );
1828 1828
1829 topLayout->addWidget( viewSpace ); 1829 topLayout->addWidget( viewSpace );
1830// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1830// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1831 topLayout->addWidget( mDetails ); 1831 topLayout->addWidget( mDetails );
1832#endif //KAB_NOSPLITTER 1832#endif //KAB_NOSPLITTER
1833*/ 1833*/
1834 1834
1835 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1835 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1836 syncManager->setBlockSave(false); 1836 syncManager->setBlockSave(false);
1837 1837
1838 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1838 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1839 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1839 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1840 QString sync_file = sentSyncFile(); 1840 QString sync_file = sentSyncFile();
1841 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1841 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1842 syncManager->setDefaultFileName( sync_file ); 1842 syncManager->setDefaultFileName( sync_file );
1843 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1843 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1844 1844
1845#endif //KAB_EMBEDDED 1845#endif //KAB_EMBEDDED
1846 initActions(); 1846 initActions();
1847 1847
1848#ifdef KAB_EMBEDDED 1848#ifdef KAB_EMBEDDED
1849 addActionsManually(); 1849 addActionsManually();
1850 //US make sure the export and import menues are initialized before creating the xxPortManager. 1850 //US make sure the export and import menues are initialized before creating the xxPortManager.
1851 mXXPortManager = new XXPortManager( this, this ); 1851 mXXPortManager = new XXPortManager( this, this );
1852 1852
1853 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1853 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1854 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1854 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1855 // mActionQuit->plug ( mMainWindow->toolBar()); 1855 // mActionQuit->plug ( mMainWindow->toolBar());
1856 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1856 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1857 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1857 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1858 // mIncSearchWidget->hide(); 1858 // mIncSearchWidget->hide();
1859 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1859 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1860 SLOT( incrementalSearch( const QString& ) ) ); 1860 SLOT( incrementalSearch( const QString& ) ) );
1861 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1861 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1862 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1862 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1863 1863
1864 mJumpButtonBar = new JumpButtonBar( this, this ); 1864 mJumpButtonBar = new JumpButtonBar( this, this );
1865 1865
1866 topLayout->addWidget( mJumpButtonBar ); 1866 topLayout->addWidget( mJumpButtonBar );
1867//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1867//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1868 1868
1869// mMainWindow->getIconToolBar()->raise(); 1869// mMainWindow->getIconToolBar()->raise();
1870 1870
1871#endif //KAB_EMBEDDED 1871#endif //KAB_EMBEDDED
1872 1872
1873} 1873}
1874void KABCore::initActions() 1874void KABCore::initActions()
1875{ 1875{
1876//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1876//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1877 1877
1878#ifndef KAB_EMBEDDED 1878#ifndef KAB_EMBEDDED
1879 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1879 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1880 SLOT( clipboardDataChanged() ) ); 1880 SLOT( clipboardDataChanged() ) );
1881#endif //KAB_EMBEDDED 1881#endif //KAB_EMBEDDED
1882 1882
1883 // file menu 1883 // file menu
1884 1884
1885 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1885 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1886 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1886 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1887 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1887 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1888 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1888 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1889 1889
1890 1890
1891 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1891 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1892 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1892 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1893 1893
1894 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1894 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1895 SLOT( save() ), actionCollection(), "file_sync" ); 1895 SLOT( save() ), actionCollection(), "file_sync" );
1896 1896
1897 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1897 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1898 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1898 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1899 1899
1900 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1900 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1901 this, SLOT( mailVCard() ), 1901 this, SLOT( mailVCard() ),
1902 actionCollection(), "file_mail_vcard"); 1902 actionCollection(), "file_mail_vcard");
1903 1903
1904 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1904 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1905 SLOT( export2phone() ), actionCollection(), 1905 SLOT( export2phone() ), actionCollection(),
1906 "kaddressbook_ex2phone" ); 1906 "kaddressbook_ex2phone" );
1907 1907
1908 mActionBeamVCard = 0; 1908 mActionBeamVCard = 0;
1909 mActionBeam = 0; 1909 mActionBeam = 0;
1910 1910
1911#ifndef DESKTOP_VERSION 1911#ifndef DESKTOP_VERSION
1912 if ( Ir::supported() ) { 1912 if ( Ir::supported() ) {
1913 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1913 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1914 SLOT( beamVCard() ), actionCollection(), 1914 SLOT( beamVCard() ), actionCollection(),
1915 "kaddressbook_beam_vcard" ); 1915 "kaddressbook_beam_vcard" );
1916 1916
1917 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1917 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1918 SLOT( beamMySelf() ), actionCollection(), 1918 SLOT( beamMySelf() ), actionCollection(),
1919 "kaddressbook_beam_myself" ); 1919 "kaddressbook_beam_myself" );
1920 } 1920 }
1921#endif 1921#endif
1922 1922
1923 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1923 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1924 this, SLOT( editContact2() ), 1924 this, SLOT( editContact2() ),
1925 actionCollection(), "file_properties" ); 1925 actionCollection(), "file_properties" );
1926 1926
1927#ifdef KAB_EMBEDDED 1927#ifdef KAB_EMBEDDED
1928 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1928 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1929 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1929 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1930 mMainWindow, SLOT( exit() ), 1930 mMainWindow, SLOT( exit() ),
1931 actionCollection(), "quit" ); 1931 actionCollection(), "quit" );
1932#endif //KAB_EMBEDDED 1932#endif //KAB_EMBEDDED
1933 1933
1934 // edit menu 1934 // edit menu
1935 if ( mIsPart ) { 1935 if ( mIsPart ) {
1936 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1936 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1937 SLOT( copyContacts() ), actionCollection(), 1937 SLOT( copyContacts() ), actionCollection(),
1938 "kaddressbook_copy" ); 1938 "kaddressbook_copy" );
1939 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1939 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1940 SLOT( cutContacts() ), actionCollection(), 1940 SLOT( cutContacts() ), actionCollection(),
1941 "kaddressbook_cut" ); 1941 "kaddressbook_cut" );
1942 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1942 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1943 SLOT( pasteContacts() ), actionCollection(), 1943 SLOT( pasteContacts() ), actionCollection(),
1944 "kaddressbook_paste" ); 1944 "kaddressbook_paste" );
1945 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1945 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1946 SLOT( selectAllContacts() ), actionCollection(), 1946 SLOT( selectAllContacts() ), actionCollection(),
1947 "kaddressbook_select_all" ); 1947 "kaddressbook_select_all" );
1948 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1948 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1949 SLOT( undo() ), actionCollection(), 1949 SLOT( undo() ), actionCollection(),
1950 "kaddressbook_undo" ); 1950 "kaddressbook_undo" );
1951 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1951 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1952 this, SLOT( redo() ), actionCollection(), 1952 this, SLOT( redo() ), actionCollection(),
1953 "kaddressbook_redo" ); 1953 "kaddressbook_redo" );
1954 } else { 1954 } else {
1955 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1955 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1956 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1956 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1957 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1957 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1958 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1958 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1959 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1959 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1960 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1960 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1961 } 1961 }
1962 1962
1963 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1963 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1964 Key_Delete, this, SLOT( deleteContacts() ), 1964 Key_Delete, this, SLOT( deleteContacts() ),
1965 actionCollection(), "edit_delete" ); 1965 actionCollection(), "edit_delete" );
1966 1966
1967 mActionUndo->setEnabled( false ); 1967 mActionUndo->setEnabled( false );
1968 mActionRedo->setEnabled( false ); 1968 mActionRedo->setEnabled( false );
1969 1969
1970 // settings menu 1970 // settings menu
1971#ifdef KAB_EMBEDDED 1971#ifdef KAB_EMBEDDED
1972//US special menuentry to configure the addressbook resources. On KDE 1972//US special menuentry to configure the addressbook resources. On KDE
1973// you do that through the control center !!! 1973// you do that through the control center !!!
1974 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1974 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1975 SLOT( configureResources() ), actionCollection(), 1975 SLOT( configureResources() ), actionCollection(),
1976 "kaddressbook_configure_resources" ); 1976 "kaddressbook_configure_resources" );
1977#endif //KAB_EMBEDDED 1977#endif //KAB_EMBEDDED
1978 1978
1979 if ( mIsPart ) { 1979 if ( mIsPart ) {
1980 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1980 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1981 SLOT( openConfigDialog() ), actionCollection(), 1981 SLOT( openConfigDialog() ), actionCollection(),
1982 "kaddressbook_configure" ); 1982 "kaddressbook_configure" );
1983 1983
1984 //US not implemented yet 1984 //US not implemented yet
1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1985 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1986 // this, SLOT( configureKeyBindings() ), actionCollection(), 1986 // this, SLOT( configureKeyBindings() ), actionCollection(),
1987 // "kaddressbook_configure_shortcuts" ); 1987 // "kaddressbook_configure_shortcuts" );
1988#ifdef KAB_EMBEDDED 1988#ifdef KAB_EMBEDDED
1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1989 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1990 mActionConfigureToolbars->setEnabled( false ); 1990 mActionConfigureToolbars->setEnabled( false );
1991#endif //KAB_EMBEDDED 1991#endif //KAB_EMBEDDED
1992 1992
1993 } else { 1993 } else {
1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1994 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1995 1995
1996 //US not implemented yet 1996 //US not implemented yet
1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1997 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1998 } 1998 }
1999 1999
2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2000 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2001 actionCollection(), "options_show_jump_bar" ); 2001 actionCollection(), "options_show_jump_bar" );
2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2002 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
2003 2003
2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2004 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2005 actionCollection(), "options_show_details" ); 2005 actionCollection(), "options_show_details" );
2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2006 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2007 2007
2008 2008
2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2009 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2010 SLOT( toggleBeamReceive() ), actionCollection(), 2010 SLOT( toggleBeamReceive() ), actionCollection(),
2011 "kaddressbook_beam_rec" ); 2011 "kaddressbook_beam_rec" );
2012 2012
2013 2013
2014 // misc 2014 // misc
2015 // only enable LDAP lookup if we can handle the protocol 2015 // only enable LDAP lookup if we can handle the protocol
2016#ifndef KAB_EMBEDDED 2016#ifndef KAB_EMBEDDED
2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2017 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2018 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2019 this, SLOT( openLDAPDialog() ), actionCollection(), 2019 this, SLOT( openLDAPDialog() ), actionCollection(),
2020 "ldap_lookup" ); 2020 "ldap_lookup" );
2021 } 2021 }
2022#else //KAB_EMBEDDED 2022#else //KAB_EMBEDDED
2023 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2023 //qDebug("KABCore::initActions() LDAP has to be implemented");
2024#endif //KAB_EMBEDDED 2024#endif //KAB_EMBEDDED
2025 2025
2026 2026
2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2027 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2028 SLOT( setWhoAmI() ), actionCollection(), 2028 SLOT( setWhoAmI() ), actionCollection(),
2029 "set_personal" ); 2029 "set_personal" );
2030 2030
2031 2031
2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2032 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
2033 SLOT( setCategories() ), actionCollection(), 2033 SLOT( setCategories() ), actionCollection(),
2034 "edit_set_categories" ); 2034 "edit_set_categories" );
2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2035 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
2036 SLOT( editCategories() ), actionCollection(), 2036 SLOT( editCategories() ), actionCollection(),
2037 "edit__categories" ); 2037 "edit__categories" );
2038 2038
2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2039 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2040 SLOT( removeVoice() ), actionCollection(), 2040 SLOT( removeVoice() ), actionCollection(),
2041 "remove_voice" ); 2041 "remove_voice" );
2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2042 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2043 SLOT( setFormattedName() ), actionCollection(), 2043 SLOT( setFormattedName() ), actionCollection(),
2044 "set_formatted" ); 2044 "set_formatted" );
2045 2045
2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2046 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2047 SLOT( manageCategories() ), actionCollection(), 2047 SLOT( manageCategories() ), actionCollection(),
2048 "remove_voice" ); 2048 "remove_voice" );
2049 2049
2050 2050
2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2051 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2052 SLOT( importFromOL() ), actionCollection(), 2052 SLOT( importFromOL() ), actionCollection(),
2053 "import_OL" ); 2053 "import_OL" );
2054#ifdef KAB_EMBEDDED 2054#ifdef KAB_EMBEDDED
2055 mActionLicence = new KAction( i18n( "Licence" ), 0, 2055 mActionLicence = new KAction( i18n( "Licence" ), 0,
2056 this, SLOT( showLicence() ), actionCollection(), 2056 this, SLOT( showLicence() ), actionCollection(),
2057 "licence_about_data" ); 2057 "licence_about_data" );
2058 mActionFaq = new KAction( i18n( "Faq" ), 0, 2058 mActionFaq = new KAction( i18n( "Faq" ), 0,
2059 this, SLOT( faq() ), actionCollection(), 2059 this, SLOT( faq() ), actionCollection(),
2060 "faq_about_data" ); 2060 "faq_about_data" );
2061 mActionWN = new KAction( i18n( "What's New?" ), 0, 2061 mActionWN = new KAction( i18n( "What's New?" ), 0,
2062 this, SLOT( whatsnew() ), actionCollection(), 2062 this, SLOT( whatsnew() ), actionCollection(),
2063 "wn" ); 2063 "wn" );
2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2064 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2065 this, SLOT( synchowto() ), actionCollection(), 2065 this, SLOT( synchowto() ), actionCollection(),
2066 "sync" ); 2066 "sync" );
2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2067 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2068 this, SLOT( kdesynchowto() ), actionCollection(), 2068 this, SLOT( kdesynchowto() ), actionCollection(),
2069 "kdesync" ); 2069 "kdesync" );
2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2070 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2071 this, SLOT( multisynchowto() ), actionCollection(), 2071 this, SLOT( multisynchowto() ), actionCollection(),
2072 "multisync" ); 2072 "multisync" );
2073 2073
2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2074 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2075 this, SLOT( createAboutData() ), actionCollection(), 2075 this, SLOT( createAboutData() ), actionCollection(),
2076 "kaddressbook_about_data" ); 2076 "kaddressbook_about_data" );
2077#endif //KAB_EMBEDDED 2077#endif //KAB_EMBEDDED
2078 2078
2079 clipboardDataChanged(); 2079 clipboardDataChanged();
2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2080 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2081 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2082} 2082}
2083 2083
2084//US we need this function, to plug all actions into the correct menues. 2084//US we need this function, to plug all actions into the correct menues.
2085// KDE uses a XML format to plug the actions, but we work her without this overhead. 2085// KDE uses a XML format to plug the actions, but we work her without this overhead.
2086void KABCore::addActionsManually() 2086void KABCore::addActionsManually()
2087{ 2087{
2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2088//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2089 2089
2090#ifdef KAB_EMBEDDED 2090#ifdef KAB_EMBEDDED
2091 QPopupMenu *fileMenu = new QPopupMenu( this ); 2091 QPopupMenu *fileMenu = new QPopupMenu( this );
2092 QPopupMenu *editMenu = new QPopupMenu( this ); 2092 QPopupMenu *editMenu = new QPopupMenu( this );
2093 QPopupMenu *helpMenu = new QPopupMenu( this ); 2093 QPopupMenu *helpMenu = new QPopupMenu( this );
2094 2094
2095 KToolBar* tb = mMainWindow->toolBar(); 2095 KToolBar* tb = mMainWindow->toolBar();
2096 2096
2097#ifndef DESKTOP_VERSION 2097#ifndef DESKTOP_VERSION
2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2098 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2099#endif 2099#endif
2100 QMenuBar* mb = mMainWindow->menuBar(); 2100 QMenuBar* mb = mMainWindow->menuBar();
2101 2101
2102 //US setup menubar. 2102 //US setup menubar.
2103 //Disable the following block if you do not want to have a menubar. 2103 //Disable the following block if you do not want to have a menubar.
2104 mb->insertItem( i18n("&File"), fileMenu ); 2104 mb->insertItem( i18n("&File"), fileMenu );
2105 mb->insertItem( i18n("&Edit"), editMenu ); 2105 mb->insertItem( i18n("&Edit"), editMenu );
2106 mb->insertItem( i18n("&View"), viewMenu ); 2106 mb->insertItem( i18n("&View"), viewMenu );
2107 mb->insertItem( i18n("&Settings"), settingsMenu ); 2107 mb->insertItem( i18n("&Settings"), settingsMenu );
2108 mb->insertItem( i18n("Synchronize"), syncMenu ); 2108 mb->insertItem( i18n("Synchronize"), syncMenu );
2109 //mb->insertItem( i18n("&Change"), changeMenu ); 2109 //mb->insertItem( i18n("&Change"), changeMenu );
2110 mb->insertItem( i18n("&Help"), helpMenu ); 2110 mb->insertItem( i18n("&Help"), helpMenu );
2111 mIncSearchWidget = new IncSearchWidget( tb ); 2111 mIncSearchWidget = new IncSearchWidget( tb );
2112 // tb->insertWidget(-1, 0, mIncSearchWidget); 2112 // tb->insertWidget(-1, 0, mIncSearchWidget);
2113#ifndef DESKTOP_VERSION 2113#ifndef DESKTOP_VERSION
2114 } else { 2114 } else {
2115 //US setup toolbar 2115 //US setup toolbar
2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2116 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2117 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2117 QPopupMenu *popupBarTB = new QPopupMenu( this );
2118 menuBarTB->insertItem( "ME", popupBarTB); 2118 menuBarTB->insertItem( "ME", popupBarTB);
2119 tb->insertWidget(-1, 0, menuBarTB); 2119 tb->insertWidget(-1, 0, menuBarTB);
2120 mIncSearchWidget = new IncSearchWidget( tb ); 2120 mIncSearchWidget = new IncSearchWidget( tb );
2121 2121
2122 tb->enableMoving(false); 2122 tb->enableMoving(false);
2123 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2123 popupBarTB->insertItem( i18n("&File"), fileMenu );
2124 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2124 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2125 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2125 popupBarTB->insertItem( i18n("&View"), viewMenu );
2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2126 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2127 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2128 mViewManager->getFilterAction()->plug ( popupBarTB); 2128 mViewManager->getFilterAction()->plug ( popupBarTB);
2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2129 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2130 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2130 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2131 if (QApplication::desktop()->width() > 320 ) { 2131 if (QApplication::desktop()->width() > 320 ) {
2132 // mViewManager->getFilterAction()->plug ( tb); 2132 // mViewManager->getFilterAction()->plug ( tb);
2133 } 2133 }
2134 } 2134 }
2135#endif 2135#endif
2136 // mActionQuit->plug ( mMainWindow->toolBar()); 2136 // mActionQuit->plug ( mMainWindow->toolBar());
2137 2137
2138 2138
2139 2139
2140 //US Now connect the actions with the menue entries. 2140 //US Now connect the actions with the menue entries.
2141#ifdef DESKTOP_VERSION 2141#ifdef DESKTOP_VERSION
2142 mActionPrint->plug( fileMenu ); 2142 mActionPrint->plug( fileMenu );
2143 mActionPrintDetails->plug( fileMenu ); 2143 mActionPrintDetails->plug( fileMenu );
2144 fileMenu->insertSeparator(); 2144 fileMenu->insertSeparator();
2145#endif 2145#endif
2146 mActionMail->plug( fileMenu ); 2146 mActionMail->plug( fileMenu );
2147 fileMenu->insertSeparator(); 2147 fileMenu->insertSeparator();
2148 2148
2149 mActionNewContact->plug( fileMenu ); 2149 mActionNewContact->plug( fileMenu );
2150 mActionNewContact->plug( tb ); 2150 mActionNewContact->plug( tb );
2151 2151
2152 mActionEditAddressee->plug( fileMenu ); 2152 mActionEditAddressee->plug( fileMenu );
2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2153 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2154 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2155 mActionEditAddressee->plug( tb ); 2155 mActionEditAddressee->plug( tb );
2156 2156
2157 fileMenu->insertSeparator(); 2157 fileMenu->insertSeparator();
2158 mActionSave->plug( fileMenu ); 2158 mActionSave->plug( fileMenu );
2159 fileMenu->insertItem( "&Import", ImportMenu ); 2159 fileMenu->insertItem( "&Import", ImportMenu );
2160 fileMenu->insertItem( "&Export", ExportMenu ); 2160 fileMenu->insertItem( "&Export", ExportMenu );
2161 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2161 fileMenu->insertItem( i18n("&Change"), changeMenu );
2162#ifndef DESKTOP_VERSION 2162#ifndef DESKTOP_VERSION
2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2163 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2164#endif 2164#endif
2165#if 0 2165#if 0
2166 // PENDING fix MailVCard 2166 // PENDING fix MailVCard
2167 fileMenu->insertSeparator(); 2167 fileMenu->insertSeparator();
2168 mActionMailVCard->plug( fileMenu ); 2168 mActionMailVCard->plug( fileMenu );
2169#endif 2169#endif
2170#ifndef DESKTOP_VERSION 2170#ifndef DESKTOP_VERSION
2171 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2171 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2172 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2173 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2174#endif 2174#endif
2175 fileMenu->insertSeparator(); 2175 fileMenu->insertSeparator();
2176 mActionQuit->plug( fileMenu ); 2176 mActionQuit->plug( fileMenu );
2177#ifdef _WIN32_ 2177#ifdef _WIN32_
2178 mActionImportOL->plug( ImportMenu ); 2178 mActionImportOL->plug( ImportMenu );
2179#endif 2179#endif
2180 // edit menu 2180 // edit menu
2181 mActionUndo->plug( editMenu ); 2181 mActionUndo->plug( editMenu );
2182 mActionRedo->plug( editMenu ); 2182 mActionRedo->plug( editMenu );
2183 editMenu->insertSeparator(); 2183 editMenu->insertSeparator();
2184 mActionCut->plug( editMenu ); 2184 mActionCut->plug( editMenu );
2185 mActionCopy->plug( editMenu ); 2185 mActionCopy->plug( editMenu );
2186 mActionPaste->plug( editMenu ); 2186 mActionPaste->plug( editMenu );
2187 mActionDelete->plug( editMenu ); 2187 mActionDelete->plug( editMenu );
2188 editMenu->insertSeparator(); 2188 editMenu->insertSeparator();
2189 mActionSelectAll->plug( editMenu ); 2189 mActionSelectAll->plug( editMenu );
2190 2190
2191 mActionSetFormattedName->plug( changeMenu ); 2191 mActionSetFormattedName->plug( changeMenu );
2192 mActionRemoveVoice->plug( changeMenu ); 2192 mActionRemoveVoice->plug( changeMenu );
2193 // settings menu 2193 // settings menu
2194//US special menuentry to configure the addressbook resources. On KDE 2194//US special menuentry to configure the addressbook resources. On KDE
2195// you do that through the control center !!! 2195// you do that through the control center !!!
2196 mActionConfigResources->plug( settingsMenu ); 2196 mActionConfigResources->plug( settingsMenu );
2197 settingsMenu->insertSeparator(); 2197 settingsMenu->insertSeparator();
2198 2198
2199 mActionConfigKAddressbook->plug( settingsMenu ); 2199 mActionConfigKAddressbook->plug( settingsMenu );
2200 2200
2201 if ( mIsPart ) { 2201 if ( mIsPart ) {
2202 //US not implemented yet 2202 //US not implemented yet
2203 //mActionConfigShortcuts->plug( settingsMenu ); 2203 //mActionConfigShortcuts->plug( settingsMenu );
2204 //mActionConfigureToolbars->plug( settingsMenu ); 2204 //mActionConfigureToolbars->plug( settingsMenu );
2205 2205
2206 } else { 2206 } else {
2207 //US not implemented yet 2207 //US not implemented yet
2208 //mActionKeyBindings->plug( settingsMenu ); 2208 //mActionKeyBindings->plug( settingsMenu );
2209 } 2209 }
2210 2210
2211 settingsMenu->insertSeparator(); 2211 settingsMenu->insertSeparator();
2212 2212
2213 mActionJumpBar->plug( settingsMenu ); 2213 mActionJumpBar->plug( settingsMenu );
2214 mActionDetails->plug( settingsMenu ); 2214 mActionDetails->plug( settingsMenu );
2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2215 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2216 mActionDetails->plug( tb ); 2216 mActionDetails->plug( tb );
2217 settingsMenu->insertSeparator(); 2217 settingsMenu->insertSeparator();
2218#ifndef DESKTOP_VERSION 2218#ifndef DESKTOP_VERSION
2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2219 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2220#endif 2220#endif
2221 settingsMenu->insertSeparator(); 2221 settingsMenu->insertSeparator();
2222 2222
2223 mActionWhoAmI->plug( settingsMenu ); 2223 mActionWhoAmI->plug( settingsMenu );
2224 mActionEditCategories->plug( settingsMenu ); 2224 mActionEditCategories->plug( settingsMenu );
2225 mActionEditCategories->plug( changeMenu ); 2225 mActionEditCategories->plug( changeMenu );
2226 mActionCategories->plug( changeMenu ); 2226 mActionCategories->plug( changeMenu );
2227 mActionManageCategories->plug( changeMenu ); 2227 mActionManageCategories->plug( changeMenu );
2228 2228
2229 mActionCategories->plug( settingsMenu ); 2229 mActionCategories->plug( settingsMenu );
2230 mActionManageCategories->plug( settingsMenu ); 2230 mActionManageCategories->plug( settingsMenu );
2231 2231
2232 2232
2233 mActionWN->plug( helpMenu ); 2233 mActionWN->plug( helpMenu );
2234 mActionSyncHowto->plug( helpMenu ); 2234 mActionSyncHowto->plug( helpMenu );
2235 mActionKdeSyncHowto->plug( helpMenu ); 2235 mActionKdeSyncHowto->plug( helpMenu );
2236 mActionMultiSyncHowto->plug( helpMenu ); 2236 mActionMultiSyncHowto->plug( helpMenu );
2237 mActionFaq->plug( helpMenu ); 2237 mActionFaq->plug( helpMenu );
2238 mActionLicence->plug( helpMenu ); 2238 mActionLicence->plug( helpMenu );
2239 mActionAboutKAddressbook->plug( helpMenu ); 2239 mActionAboutKAddressbook->plug( helpMenu );
2240 2240
2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2241 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2242 2242
2243 mActionSave->plug( tb ); 2243 mActionSave->plug( tb );
2244 mViewManager->getFilterAction()->plug ( tb); 2244 mViewManager->getFilterAction()->plug ( tb);
2245 //LR hide filteraction on started in 480x640 2245 //LR hide filteraction on started in 480x640
2246 if (QApplication::desktop()->width() == 480 ) { 2246 if (QApplication::desktop()->width() == 480 ) {
2247 mViewManager->getFilterAction()->setComboWidth( 0 ); 2247 mViewManager->getFilterAction()->setComboWidth( 0 );
2248 } 2248 }
2249 mActionUndo->plug( tb ); 2249 mActionUndo->plug( tb );
2250 mActionDelete->plug( tb ); 2250 mActionDelete->plug( tb );
2251 mActionRedo->plug( tb ); 2251 mActionRedo->plug( tb );
2252 } else { 2252 } else {
2253 mActionSave->plug( tb ); 2253 mActionSave->plug( tb );
2254 tb->enableMoving(false); 2254 tb->enableMoving(false);
2255 } 2255 }
2256 //mActionQuit->plug ( tb ); 2256 //mActionQuit->plug ( tb );
2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2257 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2258 2258
2259 //US link the searchwidget first to this. 2259 //US link the searchwidget first to this.
2260 // The real linkage to the toolbar happens later. 2260 // The real linkage to the toolbar happens later.
2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2261//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2262//US tb->insertItem( mIncSearchWidget ); 2262//US tb->insertItem( mIncSearchWidget );
2263/*US 2263/*US
2264 mIncSearchWidget = new IncSearchWidget( tb ); 2264 mIncSearchWidget = new IncSearchWidget( tb );
2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2265 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2266 SLOT( incrementalSearch( const QString& ) ) ); 2266 SLOT( incrementalSearch( const QString& ) ) );
2267 2267
2268 mJumpButtonBar = new JumpButtonBar( this, this ); 2268 mJumpButtonBar = new JumpButtonBar( this, this );
2269 2269
2270//US topLayout->addWidget( mJumpButtonBar ); 2270//US topLayout->addWidget( mJumpButtonBar );
2271 this->layout()->add( mJumpButtonBar ); 2271 this->layout()->add( mJumpButtonBar );
2272*/ 2272*/
2273 2273
2274#endif //KAB_EMBEDDED 2274#endif //KAB_EMBEDDED
2275 2275
2276 mActionExport2phone->plug( ExportMenu ); 2276 mActionExport2phone->plug( ExportMenu );
2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2277 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2278 syncManager->fillSyncMenu(); 2278 syncManager->fillSyncMenu();
2279 2279
2280} 2280}
2281void KABCore::showLicence() 2281void KABCore::showLicence()
2282{ 2282{
2283 KApplication::showLicence(); 2283 KApplication::showLicence();
2284} 2284}
2285 2285
2286void KABCore::manageCategories( ) 2286void KABCore::manageCategories( )
2287{ 2287{
2288 KABCatPrefs* cp = new KABCatPrefs(); 2288 KABCatPrefs* cp = new KABCatPrefs();
2289 cp->show(); 2289 cp->show();
2290 int w =cp->sizeHint().width() ; 2290 int w =cp->sizeHint().width() ;
2291 int h = cp->sizeHint().height() ; 2291 int h = cp->sizeHint().height() ;
2292 int dw = QApplication::desktop()->width(); 2292 int dw = QApplication::desktop()->width();
2293 int dh = QApplication::desktop()->height(); 2293 int dh = QApplication::desktop()->height();
2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2294 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2295 if ( !cp->exec() ) { 2295 if ( !cp->exec() ) {
2296 delete cp; 2296 delete cp;
2297 return; 2297 return;
2298 } 2298 }
2299 int count = 0; 2299 int count = 0;
2300 int cc = 0;
2300 message( i18n("Please wait, processing categories...")); 2301 message( i18n("Please wait, processing categories..."));
2301 if ( cp->addCat() ) { 2302 if ( cp->addCat() ) {
2302 KABC::AddressBook::Iterator it; 2303 KABC::AddressBook::Iterator it;
2303 QStringList catList = KABPrefs::instance()->mCustomCategories; 2304 QStringList catList = KABPrefs::instance()->mCustomCategories;
2304 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2305 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2306 ++cc;
2307 if ( cc %10 == 0)
2308 message(i18n("Processing contact #%1").arg(cc));
2305 QStringList catIncList = (*it).categories(); 2309 QStringList catIncList = (*it).categories();
2306 int i; 2310 int i;
2307 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2308 if ( !catList.contains (catIncList[i])) { 2312 if ( !catList.contains (catIncList[i])) {
2309 catList.append( catIncList[i] ); 2313 catList.append( catIncList[i] );
2310 //qDebug("add cat %s ", catIncList[i].latin1()); 2314 //qDebug("add cat %s ", catIncList[i].latin1());
2311 ++count; 2315 ++count;
2312 } 2316 }
2313 } 2317 }
2314 } 2318 }
2315 catList.sort(); 2319 catList.sort();
2316 KABPrefs::instance()->mCustomCategories = catList; 2320 KABPrefs::instance()->mCustomCategories = catList;
2317 KABPrefs::instance()->writeConfig(); 2321 KABPrefs::instance()->writeConfig();
2318 message(QString::number( count )+ i18n(" categories added to list! ")); 2322 message(QString::number( count )+ i18n(" categories added to list! "));
2319 } else { 2323 } else {
2320 QStringList catList = KABPrefs::instance()->mCustomCategories; 2324 QStringList catList = KABPrefs::instance()->mCustomCategories;
2321 QStringList catIncList; 2325 QStringList catIncList;
2322 QStringList newCatList; 2326 QStringList newCatList;
2323 KABC::AddressBook::Iterator it; 2327 KABC::AddressBook::Iterator it;
2324 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2328 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2329 ++cc;
2330 if ( cc %10 == 0)
2331 message(i18n("Processing contact #%1").arg(cc));
2325 QStringList catIncList = (*it).categories(); 2332 QStringList catIncList = (*it).categories();
2326 int i; 2333 int i;
2327 if ( catIncList.count() ) { 2334 if ( catIncList.count() ) {
2328 newCatList.clear(); 2335 newCatList.clear();
2329 for( i = 0; i< catIncList.count(); ++i ) { 2336 for( i = 0; i< catIncList.count(); ++i ) {
2330 if ( catList.contains (catIncList[i])) { 2337 if ( catList.contains (catIncList[i])) {
2331 newCatList.append( catIncList[i] ); 2338 newCatList.append( catIncList[i] );
2332 } 2339 }
2333 } 2340 }
2334 newCatList.sort(); 2341 newCatList.sort();
2335 (*it).setCategories( newCatList ); 2342 (*it).setCategories( newCatList );
2336 mAddressBook->insertAddressee( (*it) ); 2343 mAddressBook->insertAddressee( (*it) );
2337 } 2344 }
2338 } 2345 }
2339 setModified( true ); 2346 setModified( true );
2340 mViewManager->refreshView(); 2347 mViewManager->refreshView();
2341 message( i18n("Removing categories done!")); 2348 message( i18n("Removing categories done!"));
2342 } 2349 }
2343 delete cp; 2350 delete cp;
2344} 2351}
2345void KABCore::removeVoice() 2352void KABCore::removeVoice()
2346{ 2353{
2347 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 ) 2354 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 )
2348 return; 2355 return;
2349 KABC::Addressee::List list; 2356 KABC::Addressee::List list;
2350 XXPortSelectDialog dlg( this, false, this ); 2357 XXPortSelectDialog dlg( this, false, this );
2351 if ( dlg.exec() ) 2358 if ( dlg.exec() )
2352 list = dlg.contacts(); 2359 list = dlg.contacts();
2353 else 2360 else
2354 return; 2361 return;
2355 KABC::Addressee::List::Iterator it; 2362 KABC::Addressee::List::Iterator it;
2356 for ( it = list.begin(); it != list.end(); ++it ) { 2363 for ( it = list.begin(); it != list.end(); ++it ) {
2357 if ( (*it).removeVoice() ) 2364 if ( (*it).removeVoice() )
2358 addrModified((*it), false ); 2365 addrModified((*it), false );
2359 } 2366 }
2360} 2367}
2361 2368
2362void KABCore::setFormattedName() 2369void KABCore::setFormattedName()
2363{ 2370{
2364 KABFormatPrefs setpref; 2371 KABFormatPrefs setpref;
2365 if ( !setpref.exec() ) { 2372 if ( !setpref.exec() ) {
2366 return; 2373 return;
2367 } 2374 }
2368 XXPortSelectDialog dlg( this, false, this ); 2375 XXPortSelectDialog dlg( this, false, this );
2369 if ( !dlg.exec() ) 2376 if ( !dlg.exec() )
2370 return; 2377 return;
2371 mAddressBook->setUntagged(); 2378 mAddressBook->setUntagged();
2372 dlg.tagSelected(); 2379 dlg.tagSelected();
2373 int count = 0; 2380 int count = 0;
2374 KABC::AddressBook::Iterator it; 2381 KABC::AddressBook::Iterator it;
2375 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2382 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2376 if ( (*it).tagged() ) { 2383 if ( (*it).tagged() ) {
2377 message(i18n("Changing contact #%1").arg( ++count ) ); 2384 ++count;
2385 if ( count %10 == 0 )
2386 message(i18n("Changing contact #%1").arg( count ) );
2378 qApp->processEvents(); 2387 qApp->processEvents();
2379 QString fName; 2388 QString fName;
2380 if ( setpref.simple->isChecked() ) 2389 if ( setpref.simple->isChecked() )
2381 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName ); 2390 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2382 else if ( setpref.full->isChecked() ) 2391 else if ( setpref.full->isChecked() )
2383 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName ); 2392 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2384 else if ( setpref.reverse->isChecked() ) 2393 else if ( setpref.reverse->isChecked() )
2385 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName ); 2394 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2386 else 2395 else
2387 fName = (*it).organization(); 2396 fName = (*it).organization();
2388 if ( setpref.setCompany->isChecked() ) 2397 if ( setpref.setCompany->isChecked() )
2389 if ( fName.isEmpty() || fName =="," ) 2398 if ( fName.isEmpty() || fName =="," )
2390 fName = (*it).organization(); 2399 fName = (*it).organization();
2391 (*it).setFormattedName( fName ); 2400 (*it).setFormattedName( fName );
2392 } 2401 }
2393 } 2402 }
2394 message(i18n("Refreshing view...") ); 2403 message(i18n("Refreshing view...") );
2404 qApp->processEvents();
2395 mViewManager->refreshView( "" ); 2405 mViewManager->refreshView( "" );
2396 Addressee add; 2406 Addressee add;
2397 mDetails->setAddressee( add ); 2407 mDetails->setAddressee( add );
2398 message(i18n("Setting formatted name completed!") ); 2408 message(i18n("Setting formatted name completed!") );
2399} 2409}
2400 2410
2401void KABCore::clipboardDataChanged() 2411void KABCore::clipboardDataChanged()
2402{ 2412{
2403 2413
2404 if ( mReadWrite ) 2414 if ( mReadWrite )
2405 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2415 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2406 2416
2407} 2417}
2408 2418
2409void KABCore::updateActionMenu() 2419void KABCore::updateActionMenu()
2410{ 2420{
2411 UndoStack *undo = UndoStack::instance(); 2421 UndoStack *undo = UndoStack::instance();
2412 RedoStack *redo = RedoStack::instance(); 2422 RedoStack *redo = RedoStack::instance();
2413 2423
2414 if ( undo->isEmpty() ) 2424 if ( undo->isEmpty() )
2415 mActionUndo->setText( i18n( "Undo" ) ); 2425 mActionUndo->setText( i18n( "Undo" ) );
2416 else 2426 else
2417 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2427 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2418 2428
2419 mActionUndo->setEnabled( !undo->isEmpty() ); 2429 mActionUndo->setEnabled( !undo->isEmpty() );
2420 2430
2421 if ( !redo->top() ) 2431 if ( !redo->top() )
2422 mActionRedo->setText( i18n( "Redo" ) ); 2432 mActionRedo->setText( i18n( "Redo" ) );
2423 else 2433 else
2424 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2434 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2425 2435
2426 mActionRedo->setEnabled( !redo->isEmpty() ); 2436 mActionRedo->setEnabled( !redo->isEmpty() );
2427} 2437}
2428 2438
2429void KABCore::configureKeyBindings() 2439void KABCore::configureKeyBindings()
2430{ 2440{
2431#ifndef KAB_EMBEDDED 2441#ifndef KAB_EMBEDDED
2432 KKeyDialog::configure( actionCollection(), true ); 2442 KKeyDialog::configure( actionCollection(), true );
2433#else //KAB_EMBEDDED 2443#else //KAB_EMBEDDED
2434 qDebug("KABCore::configureKeyBindings() not implemented"); 2444 qDebug("KABCore::configureKeyBindings() not implemented");
2435#endif //KAB_EMBEDDED 2445#endif //KAB_EMBEDDED
2436} 2446}
2437 2447
2438#ifdef KAB_EMBEDDED 2448#ifdef KAB_EMBEDDED
2439void KABCore::configureResources() 2449void KABCore::configureResources()
2440{ 2450{
2441 KRES::KCMKResources dlg( this, "" , 0 ); 2451 KRES::KCMKResources dlg( this, "" , 0 );
2442 2452
2443 if ( !dlg.exec() ) 2453 if ( !dlg.exec() )
2444 return; 2454 return;
2445 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2455 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2446} 2456}
2447#endif //KAB_EMBEDDED 2457#endif //KAB_EMBEDDED
2448 2458
2449 2459
2450/* this method will be called through the QCop interface from Ko/Pi to select addresses 2460/* this method will be called through the QCop interface from Ko/Pi to select addresses
2451 * for the attendees list of an event. 2461 * for the attendees list of an event.
2452 */ 2462 */
2453void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2463void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2454{ 2464{
2455 QStringList nameList; 2465 QStringList nameList;
2456 QStringList emailList; 2466 QStringList emailList;
2457 QStringList uidList; 2467 QStringList uidList;
2458 2468
2459 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2469 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2460 uint i=0; 2470 uint i=0;
2461 for (i=0; i < list.count(); i++) 2471 for (i=0; i < list.count(); i++)
2462 { 2472 {
2463 nameList.append(list[i].realName()); 2473 nameList.append(list[i].realName());
2464 emailList.append(list[i].preferredEmail()); 2474 emailList.append(list[i].preferredEmail());
2465 uidList.append(list[i].uid()); 2475 uidList.append(list[i].uid());
2466 } 2476 }
2467 2477
2468 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2478 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2469 2479
2470} 2480}
2471 2481
2472/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2482/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2473 * to put them into the calendar. 2483 * to put them into the calendar.
2474 */ 2484 */
2475void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2485void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2476{ 2486{
2477 // qDebug("KABCore::requestForBirthdayList"); 2487 // qDebug("KABCore::requestForBirthdayList");
2478 QStringList birthdayList; 2488 QStringList birthdayList;
2479 QStringList anniversaryList; 2489 QStringList anniversaryList;
2480 QStringList realNameList; 2490 QStringList realNameList;
2481 QStringList preferredEmailList; 2491 QStringList preferredEmailList;
2482 QStringList assembledNameList; 2492 QStringList assembledNameList;
2483 QStringList uidList; 2493 QStringList uidList;
2484 2494
2485 KABC::AddressBook::Iterator it; 2495 KABC::AddressBook::Iterator it;
2486 2496
2487 int count = 0; 2497 int count = 0;
2488 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2498 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2489 ++count; 2499 ++count;
2490 } 2500 }
2491 QProgressBar bar(count,0 ); 2501 QProgressBar bar(count,0 );
2492 int w = 300; 2502 int w = 300;
2493 if ( QApplication::desktop()->width() < 320 ) 2503 if ( QApplication::desktop()->width() < 320 )
2494 w = 220; 2504 w = 220;
2495 int h = bar.sizeHint().height() ; 2505 int h = bar.sizeHint().height() ;
2496 int dw = QApplication::desktop()->width(); 2506 int dw = QApplication::desktop()->width();
2497 int dh = QApplication::desktop()->height(); 2507 int dh = QApplication::desktop()->height();
2498 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2508 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2499 bar.show(); 2509 bar.show();
2500 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2510 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2501 qApp->processEvents(); 2511 qApp->processEvents();
2502 2512
2503 QDate bday; 2513 QDate bday;
2504 QString anni; 2514 QString anni;
2505 QString formattedbday; 2515 QString formattedbday;
2506 2516
2507 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2517 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2508 { 2518 {
2509 if ( ! bar.isVisible() ) 2519 if ( ! bar.isVisible() )
2510 return; 2520 return;
2511 bar.setProgress( count++ ); 2521 bar.setProgress( count++ );
2512 qApp->processEvents(); 2522 qApp->processEvents();
2513 bday = (*it).birthday().date(); 2523 bday = (*it).birthday().date();
2514 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2524 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2515 2525
2516 if ( bday.isValid() || !anni.isEmpty()) 2526 if ( bday.isValid() || !anni.isEmpty())
2517 { 2527 {
2518 if (bday.isValid()) 2528 if (bday.isValid())
2519 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2529 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2520 else 2530 else
2521 formattedbday = "NOTVALID"; 2531 formattedbday = "NOTVALID";
2522 if (anni.isEmpty()) 2532 if (anni.isEmpty())
2523 anni = "INVALID"; 2533 anni = "INVALID";
2524 2534
2525 birthdayList.append(formattedbday); 2535 birthdayList.append(formattedbday);
2526 anniversaryList.append(anni); //should be ISODate 2536 anniversaryList.append(anni); //should be ISODate
2527 realNameList.append((*it).realName()); 2537 realNameList.append((*it).realName());
2528 preferredEmailList.append((*it).preferredEmail()); 2538 preferredEmailList.append((*it).preferredEmail());
2529 assembledNameList.append((*it).assembledName()); 2539 assembledNameList.append((*it).assembledName());
2530 uidList.append((*it).uid()); 2540 uidList.append((*it).uid());
2531 2541
2532 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2542 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2533 } 2543 }
2534 } 2544 }
2535 2545
2536 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2546 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2537 2547
2538} 2548}
2539 2549
2540/* this method will be called through the QCop interface from other apps to show details of a contact. 2550/* this method will be called through the QCop interface from other apps to show details of a contact.
2541 */ 2551 */
2542void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2552void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2543{ 2553{
2544 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2554 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2545 2555
2546 QString foundUid = QString::null; 2556 QString foundUid = QString::null;
2547 if ( ! uid.isEmpty() ) { 2557 if ( ! uid.isEmpty() ) {
2548 Addressee adrr = mAddressBook->findByUid( uid ); 2558 Addressee adrr = mAddressBook->findByUid( uid );
2549 if ( !adrr.isEmpty() ) { 2559 if ( !adrr.isEmpty() ) {
2550 foundUid = uid; 2560 foundUid = uid;
2551 } 2561 }
2552 if ( email == "sendbacklist" ) { 2562 if ( email == "sendbacklist" ) {
2553 //qDebug("ssssssssssssssssssssssend "); 2563 //qDebug("ssssssssssssssssssssssend ");
2554 QStringList nameList; 2564 QStringList nameList;
2555 QStringList emailList; 2565 QStringList emailList;
2556 QStringList uidList; 2566 QStringList uidList;
2557 nameList.append(adrr.realName()); 2567 nameList.append(adrr.realName());
2558 emailList = adrr.emails(); 2568 emailList = adrr.emails();
2559 uidList.append( adrr.preferredEmail()); 2569 uidList.append( adrr.preferredEmail());
2560 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2570 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2561 return; 2571 return;
2562 } 2572 }
2563 2573
2564 } 2574 }
2565 2575
2566 if ( email == "sendbacklist" ) 2576 if ( email == "sendbacklist" )
2567 return; 2577 return;
2568 if (foundUid.isEmpty()) 2578 if (foundUid.isEmpty())
2569 { 2579 {
2570 //find the uid of the person first 2580 //find the uid of the person first
2571 Addressee::List namelist; 2581 Addressee::List namelist;
2572 Addressee::List emaillist; 2582 Addressee::List emaillist;
2573 2583
2574 if (!name.isEmpty()) 2584 if (!name.isEmpty())
2575 namelist = mAddressBook->findByName( name ); 2585 namelist = mAddressBook->findByName( name );
2576 2586
2577 if (!email.isEmpty()) 2587 if (!email.isEmpty())
2578 emaillist = mAddressBook->findByEmail( email ); 2588 emaillist = mAddressBook->findByEmail( email );
2579 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2589 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2580 //check if we have a match in Namelist and Emaillist 2590 //check if we have a match in Namelist and Emaillist
2581 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2591 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2582 foundUid = emaillist[0].uid(); 2592 foundUid = emaillist[0].uid();
2583 } 2593 }
2584 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2594 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2585 foundUid = namelist[0].uid(); 2595 foundUid = namelist[0].uid();
2586 else 2596 else
2587 { 2597 {
2588 for (int i = 0; i < namelist.count(); i++) 2598 for (int i = 0; i < namelist.count(); i++)
2589 { 2599 {
2590 for (int j = 0; j < emaillist.count(); j++) 2600 for (int j = 0; j < emaillist.count(); j++)
2591 { 2601 {
2592 if (namelist[i] == emaillist[j]) 2602 if (namelist[i] == emaillist[j])
2593 { 2603 {
2594 foundUid = namelist[i].uid(); 2604 foundUid = namelist[i].uid();
2595 } 2605 }
2596 } 2606 }
2597 } 2607 }
2598 } 2608 }
2599 } 2609 }
2600 else 2610 else
2601 { 2611 {
2602 foundUid = uid; 2612 foundUid = uid;
2603 } 2613 }
2604 2614
2605 if (!foundUid.isEmpty()) 2615 if (!foundUid.isEmpty())
2606 { 2616 {
2607 2617
2608 // raise Ka/Pi if it is in the background 2618 // raise Ka/Pi if it is in the background
2609#ifndef DESKTOP_VERSION 2619#ifndef DESKTOP_VERSION
2610#ifndef KORG_NODCOP 2620#ifndef KORG_NODCOP
2611 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2621 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2612#endif 2622#endif
2613#endif 2623#endif
2614 2624
2615 mMainWindow->showMaximized(); 2625 mMainWindow->showMaximized();
2616 mMainWindow-> raise(); 2626 mMainWindow-> raise();
2617 2627
2618 mViewManager->setSelected( "", false); 2628 mViewManager->setSelected( "", false);
2619 mViewManager->refreshView( "" ); 2629 mViewManager->refreshView( "" );
2620 mViewManager->setSelected( foundUid, true ); 2630 mViewManager->setSelected( foundUid, true );
2621 mViewManager->refreshView( foundUid ); 2631 mViewManager->refreshView( foundUid );
2622 2632
2623 if ( !mMultipleViewsAtOnce ) 2633 if ( !mMultipleViewsAtOnce )
2624 { 2634 {
2625 setDetailsVisible( true ); 2635 setDetailsVisible( true );
2626 mActionDetails->setChecked(true); 2636 mActionDetails->setChecked(true);
2627 } 2637 }
2628 } 2638 }
2629} 2639}
2630 2640
2631void KABCore::whatsnew() 2641void KABCore::whatsnew()
2632{ 2642{
2633 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2643 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2634} 2644}
2635void KABCore::synchowto() 2645void KABCore::synchowto()
2636{ 2646{
2637 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2647 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2638} 2648}
2639void KABCore::kdesynchowto() 2649void KABCore::kdesynchowto()
2640{ 2650{
2641 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2651 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2642} 2652}
2643void KABCore::multisynchowto() 2653void KABCore::multisynchowto()
2644{ 2654{
2645 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2655 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2646} 2656}
2647void KABCore::faq() 2657void KABCore::faq()
2648{ 2658{
2649 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2659 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2650} 2660}
2651 2661
2652#include <libkcal/syncdefines.h> 2662#include <libkcal/syncdefines.h>
2653 2663
2654KABC::Addressee KABCore::getLastSyncAddressee() 2664KABC::Addressee KABCore::getLastSyncAddressee()
2655{ 2665{
2656 Addressee lse; 2666 Addressee lse;
2657 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2667 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2658 2668
2659 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2669 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2660 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2670 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2661 if (lse.isEmpty()) { 2671 if (lse.isEmpty()) {
2662 qDebug("Creating new last-syncAddressee "); 2672 qDebug("Creating new last-syncAddressee ");
2663 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2673 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2664 QString sum = ""; 2674 QString sum = "";
2665 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2666 sum = "E: "; 2676 sum = "E: ";
2667 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2677 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2668 lse.setRevision( mLastAddressbookSync ); 2678 lse.setRevision( mLastAddressbookSync );
2669 lse.setCategories( i18n("SyncEvent") ); 2679 lse.setCategories( i18n("SyncEvent") );
2670 mAddressBook->insertAddressee( lse ); 2680 mAddressBook->insertAddressee( lse );
2671 } 2681 }
2672 return lse; 2682 return lse;
2673} 2683}
2674int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2684int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2675{ 2685{
2676 2686
2677 //void setZaurusId(int id); 2687 //void setZaurusId(int id);
2678 // int zaurusId() const; 2688 // int zaurusId() const;
2679 // void setZaurusUid(int id); 2689 // void setZaurusUid(int id);
2680 // int zaurusUid() const; 2690 // int zaurusUid() const;
2681 // void setZaurusStat(int id); 2691 // void setZaurusStat(int id);
2682 // int zaurusStat() const; 2692 // int zaurusStat() const;
2683 // 0 equal 2693 // 0 equal
2684 // 1 take local 2694 // 1 take local
2685 // 2 take remote 2695 // 2 take remote
2686 // 3 cancel 2696 // 3 cancel
2687 QDateTime lastSync = mLastAddressbookSync; 2697 QDateTime lastSync = mLastAddressbookSync;
2688 QDateTime localMod = local->revision(); 2698 QDateTime localMod = local->revision();
2689 QDateTime remoteMod = remote->revision(); 2699 QDateTime remoteMod = remote->revision();
2690 2700
2691 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2701 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2692 2702
2693 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2703 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2694 bool remCh, locCh; 2704 bool remCh, locCh;
2695 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2705 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2696 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2706 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2697 locCh = ( localMod > mLastAddressbookSync ); 2707 locCh = ( localMod > mLastAddressbookSync );
2698 //qDebug("cahnged rem %d loc %d",remCh, locCh ); 2708 //qDebug("cahnged rem %d loc %d",remCh, locCh );
2699 if ( !remCh && ! locCh ) { 2709 if ( !remCh && ! locCh ) {
2700 //qDebug("both not changed "); 2710 //qDebug("both not changed ");
2701 lastSync = localMod.addDays(1); 2711 lastSync = localMod.addDays(1);
2702 if ( mode <= SYNC_PREF_ASK ) 2712 if ( mode <= SYNC_PREF_ASK )
2703 return 0; 2713 return 0;
2704 } else { 2714 } else {
2705 if ( locCh ) { 2715 if ( locCh ) {
2706 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2716 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2707 lastSync = localMod.addDays( -1 ); 2717 lastSync = localMod.addDays( -1 );
2708 if ( !remCh ) 2718 if ( !remCh )
2709 remoteMod =( lastSync.addDays( -1 ) ); 2719 remoteMod =( lastSync.addDays( -1 ) );
2710 } else { 2720 } else {
2711 //qDebug(" not loc changed "); 2721 //qDebug(" not loc changed ");
2712 lastSync = localMod.addDays( 1 ); 2722 lastSync = localMod.addDays( 1 );
2713 if ( remCh ) { 2723 if ( remCh ) {
2714 //qDebug("rem changed "); 2724 //qDebug("rem changed ");
2715 remoteMod =( lastSync.addDays( 1 ) ); 2725 remoteMod =( lastSync.addDays( 1 ) );
2716 } 2726 }
2717 2727
2718 } 2728 }
2719 } 2729 }
2720 full = true; 2730 full = true;
2721 if ( mode < SYNC_PREF_ASK ) 2731 if ( mode < SYNC_PREF_ASK )
2722 mode = SYNC_PREF_ASK; 2732 mode = SYNC_PREF_ASK;
2723 } else { 2733 } else {
2724 if ( localMod == remoteMod ) 2734 if ( localMod == remoteMod )
2725 return 0; 2735 return 0;
2726 2736
2727 } 2737 }
2728 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2738 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2729 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2739 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2730 //full = true; //debug only 2740 //full = true; //debug only
2731 if ( full ) { 2741 if ( full ) {
2732 bool equ = ( (*local) == (*remote) ); 2742 bool equ = ( (*local) == (*remote) );
2733 if ( equ ) { 2743 if ( equ ) {
2734 //qDebug("equal "); 2744 //qDebug("equal ");
2735 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2745 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2736 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2746 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2737 } 2747 }
2738 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2748 if ( mode < SYNC_PREF_FORCE_LOCAL )
2739 return 0; 2749 return 0;
2740 2750
2741 }//else //debug only 2751 }//else //debug only
2742 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2752 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2743 } 2753 }
2744 int result; 2754 int result;
2745 bool localIsNew; 2755 bool localIsNew;
2746 //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() ); 2756 //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() );
2747 2757
2748 if ( full && mode < SYNC_PREF_NEWEST ) 2758 if ( full && mode < SYNC_PREF_NEWEST )
2749 mode = SYNC_PREF_ASK; 2759 mode = SYNC_PREF_ASK;
2750 2760
2751 switch( mode ) { 2761 switch( mode ) {
2752 case SYNC_PREF_LOCAL: 2762 case SYNC_PREF_LOCAL:
2753 if ( lastSync > remoteMod ) 2763 if ( lastSync > remoteMod )
2754 return 1; 2764 return 1;
2755 if ( lastSync > localMod ) 2765 if ( lastSync > localMod )
2756 return 2; 2766 return 2;
2757 return 1; 2767 return 1;
2758 break; 2768 break;
2759 case SYNC_PREF_REMOTE: 2769 case SYNC_PREF_REMOTE:
2760 if ( lastSync > remoteMod ) 2770 if ( lastSync > remoteMod )
2761 return 1; 2771 return 1;
2762 if ( lastSync > localMod ) 2772 if ( lastSync > localMod )
2763 return 2; 2773 return 2;
2764 return 2; 2774 return 2;
2765 break; 2775 break;
2766 case SYNC_PREF_NEWEST: 2776 case SYNC_PREF_NEWEST:
2767 if ( localMod > remoteMod ) 2777 if ( localMod > remoteMod )
2768 return 1; 2778 return 1;
2769 else 2779 else
2770 return 2; 2780 return 2;
2771 break; 2781 break;
2772 case SYNC_PREF_ASK: 2782 case SYNC_PREF_ASK:
2773 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2783 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2774 if ( lastSync > remoteMod ) 2784 if ( lastSync > remoteMod )
2775 return 1; 2785 return 1;
2776 if ( lastSync > localMod ) { 2786 if ( lastSync > localMod ) {
2777 return 2; 2787 return 2;
2778 } 2788 }
2779 localIsNew = localMod >= remoteMod; 2789 localIsNew = localMod >= remoteMod;
2780 //qDebug("conflict! ************************************** "); 2790 //qDebug("conflict! ************************************** ");
2781 { 2791 {
2782 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2792 KABC::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2783 result = acd.executeD(localIsNew); 2793 result = acd.executeD(localIsNew);
2784 return result; 2794 return result;
2785 } 2795 }
2786 break; 2796 break;
2787 case SYNC_PREF_FORCE_LOCAL: 2797 case SYNC_PREF_FORCE_LOCAL:
2788 return 1; 2798 return 1;
2789 break; 2799 break;
2790 case SYNC_PREF_FORCE_REMOTE: 2800 case SYNC_PREF_FORCE_REMOTE:
2791 return 2; 2801 return 2;
2792 break; 2802 break;
2793 2803
2794 default: 2804 default:
2795 // SYNC_PREF_TAKE_BOTH not implemented 2805 // SYNC_PREF_TAKE_BOTH not implemented
2796 break; 2806 break;
2797 } 2807 }
2798 return 0; 2808 return 0;
2799} 2809}
2800 2810
2801 2811
2802bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2812bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2803{ 2813{
2804 bool syncOK = true; 2814 bool syncOK = true;
2805 int addedAddressee = 0; 2815 int addedAddressee = 0;
2806 int addedAddresseeR = 0; 2816 int addedAddresseeR = 0;
2807 int deletedAddresseeR = 0; 2817 int deletedAddresseeR = 0;
2808 int deletedAddresseeL = 0; 2818 int deletedAddresseeL = 0;
2809 int changedLocal = 0; 2819 int changedLocal = 0;
2810 int changedRemote = 0; 2820 int changedRemote = 0;
2811 int filteredIN = 0; 2821 int filteredIN = 0;
2812 int filteredOUT = 0; 2822 int filteredOUT = 0;
2813 2823
2814 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2824 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2815 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2825 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2816 2826
2817 //QPtrList<Addressee> el = local->rawAddressees(); 2827 //QPtrList<Addressee> el = local->rawAddressees();
2818 Addressee addresseeR; 2828 Addressee addresseeR;
2819 QString uid; 2829 QString uid;
2820 int take; 2830 int take;
2821 Addressee addresseeL; 2831 Addressee addresseeL;
2822 Addressee addresseeRSync; 2832 Addressee addresseeRSync;
2823 Addressee addresseeLSync; 2833 Addressee addresseeLSync;
2824 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2834 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2825 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2835 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2826 bool fullDateRange = false; 2836 bool fullDateRange = false;
2827 local->resetTempSyncStat(); 2837 local->resetTempSyncStat();
2828 mLastAddressbookSync = QDateTime::currentDateTime(); 2838 mLastAddressbookSync = QDateTime::currentDateTime();
2829 if ( syncManager->syncWithDesktop() ) { 2839 if ( syncManager->syncWithDesktop() ) {
2830 // remote->removeSyncInfo( QString());//remove all info 2840 // remote->removeSyncInfo( QString());//remove all info
2831 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2841 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2832 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2842 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2833 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2843 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2834 } else { 2844 } else {
2835 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2845 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2836 } 2846 }
2837 } 2847 }
2838 QDateTime modifiedCalendar = mLastAddressbookSync; 2848 QDateTime modifiedCalendar = mLastAddressbookSync;
2839 addresseeLSync = getLastSyncAddressee(); 2849 addresseeLSync = getLastSyncAddressee();
2840 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2850 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2841 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2851 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2842 if ( !addresseeR.isEmpty() ) { 2852 if ( !addresseeR.isEmpty() ) {
2843 addresseeRSync = addresseeR; 2853 addresseeRSync = addresseeR;
2844 remote->removeAddressee(addresseeR ); 2854 remote->removeAddressee(addresseeR );
2845 2855
2846 } else { 2856 } else {
2847 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2857 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2848 addresseeRSync = addresseeLSync ; 2858 addresseeRSync = addresseeLSync ;
2849 } else { 2859 } else {
2850 //qDebug("FULLDATE 1"); 2860 //qDebug("FULLDATE 1");
2851 fullDateRange = true; 2861 fullDateRange = true;
2852 Addressee newAdd; 2862 Addressee newAdd;
2853 addresseeRSync = newAdd; 2863 addresseeRSync = newAdd;
2854 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2864 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2855 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2865 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2856 addresseeRSync.setRevision( mLastAddressbookSync ); 2866 addresseeRSync.setRevision( mLastAddressbookSync );
2857 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2867 addresseeRSync.setCategories( i18n("SyncAddressee") );
2858 } 2868 }
2859 } 2869 }
2860 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2870 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2861 // qDebug("FULLDATE 2"); 2871 // qDebug("FULLDATE 2");
2862 fullDateRange = true; 2872 fullDateRange = true;
2863 } 2873 }
2864 if ( ! fullDateRange ) { 2874 if ( ! fullDateRange ) {
2865 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2875 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2866 2876
2867 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2877 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2868 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2878 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2869 fullDateRange = true; 2879 fullDateRange = true;
2870 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2880 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2871 } 2881 }
2872 } 2882 }
2873 // fullDateRange = true; // debug only! 2883 // fullDateRange = true; // debug only!
2874 if ( fullDateRange ) 2884 if ( fullDateRange )
2875 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2885 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2876 else 2886 else
2877 mLastAddressbookSync = addresseeLSync.revision(); 2887 mLastAddressbookSync = addresseeLSync.revision();
2878 // for resyncing if own file has changed 2888 // for resyncing if own file has changed
2879 // PENDING fixme later when implemented 2889 // PENDING fixme later when implemented
2880#if 0 2890#if 0
2881 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2891 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2882 mLastAddressbookSync = loadedFileVersion; 2892 mLastAddressbookSync = loadedFileVersion;
2883 qDebug("setting mLastAddressbookSync "); 2893 qDebug("setting mLastAddressbookSync ");
2884 } 2894 }
2885#endif 2895#endif
2886 2896
2887 2897
2888 // ********** setting filters **************** 2898 // ********** setting filters ****************
2889 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB ); 2899 Filter filterIN = mViewManager->getFilterByName( syncManager->mFilterInAB );
2890 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB ); 2900 Filter filterOUT = mViewManager->getFilterByName( syncManager->mFilterOutAB );
2891 2901
2892 //qDebug("*************************** "); 2902 //qDebug("*************************** ");
2893 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2903 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2894 QStringList er = remote->uidList(); 2904 QStringList er = remote->uidList();
2895 Addressee inR ;//= er.first(); 2905 Addressee inR ;//= er.first();
2896 Addressee inL; 2906 Addressee inL;
2897 2907
2898 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2908 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2899 2909
2900 int modulo = (er.count()/10)+1; 2910 int modulo = (er.count()/10)+1;
2901 int incCounter = 0; 2911 int incCounter = 0;
2902 while ( incCounter < er.count()) { 2912 while ( incCounter < er.count()) {
2903 if (syncManager->isProgressBarCanceled()) 2913 if (syncManager->isProgressBarCanceled())
2904 return false; 2914 return false;
2905 if ( incCounter % modulo == 0 ) 2915 if ( incCounter % modulo == 0 )
2906 syncManager->showProgressBar(incCounter); 2916 syncManager->showProgressBar(incCounter);
2907 2917
2908 uid = er[ incCounter ]; 2918 uid = er[ incCounter ];
2909 bool skipIncidence = false; 2919 bool skipIncidence = false;
2910 if ( uid.left(19) == QString("last-syncAddressee-") ) 2920 if ( uid.left(19) == QString("last-syncAddressee-") )
2911 skipIncidence = true; 2921 skipIncidence = true;
2912 QString idS,OidS; 2922 QString idS,OidS;
2913 qApp->processEvents(); 2923 qApp->processEvents();
2914 if ( !skipIncidence ) { 2924 if ( !skipIncidence ) {
2915 inL = local->findByUid( uid ); 2925 inL = local->findByUid( uid );
2916 inR = remote->findByUid( uid ); 2926 inR = remote->findByUid( uid );
2917 //inL.setResource( 0 ); 2927 //inL.setResource( 0 );
2918 //inR.setResource( 0 ); 2928 //inR.setResource( 0 );
2919 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2929 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2920 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2930 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2921 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2931 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2922 //qDebug("take %d %s ", take, inL.summary().latin1()); 2932 //qDebug("take %d %s ", take, inL.summary().latin1());
2923 if ( take == 3 ) 2933 if ( take == 3 )
2924 return false; 2934 return false;
2925 if ( take == 1 ) {// take local ********************** 2935 if ( take == 1 ) {// take local **********************
2926 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2936 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2927 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2937 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2928 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2938 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2929 local->insertAddressee( inL, false ); 2939 local->insertAddressee( inL, false );
2930 idS = inR.externalUID(); 2940 idS = inR.externalUID();
2931 OidS = inR.originalExternalUID(); 2941 OidS = inR.originalExternalUID();
2932 } 2942 }
2933 else 2943 else
2934 idS = inR.IDStr(); 2944 idS = inR.IDStr();
2935 remote->removeAddressee( inR ); 2945 remote->removeAddressee( inR );
2936 inR = inL; 2946 inR = inL;
2937 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2947 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2938 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2948 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2939 inR.setOriginalExternalUID( OidS ); 2949 inR.setOriginalExternalUID( OidS );
2940 inR.setExternalUID( idS ); 2950 inR.setExternalUID( idS );
2941 if ( syncManager->syncWithDesktop() ) { 2951 if ( syncManager->syncWithDesktop() ) {
2942 inR.setIDStr("changed" ); 2952 inR.setIDStr("changed" );
2943 } 2953 }
2944 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2954 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2945 } else { 2955 } else {
2946 inR.setIDStr( idS ); 2956 inR.setIDStr( idS );
2947 } 2957 }
2948 inR.setResource( 0 ); 2958 inR.setResource( 0 );
2949 remote->insertAddressee( inR , false); 2959 remote->insertAddressee( inR , false);
2950 ++changedRemote; 2960 ++changedRemote;
2951 } else { // take == 2 take remote ********************** 2961 } else { // take == 2 take remote **********************
2952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2962 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2953 if ( inR.revision().date().year() < 2004 ) 2963 if ( inR.revision().date().year() < 2004 )
2954 inR.setRevision( modifiedCalendar ); 2964 inR.setRevision( modifiedCalendar );
2955 } 2965 }
2956 idS = inL.IDStr(); 2966 idS = inL.IDStr();
2957 local->removeAddressee( inL ); 2967 local->removeAddressee( inL );
2958 inL = inR; 2968 inL = inR;
2959 inL.setIDStr( idS ); 2969 inL.setIDStr( idS );
2960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2970 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2961 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2971 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2962 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2972 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2963 } 2973 }
2964 inL.setResource( 0 ); 2974 inL.setResource( 0 );
2965 local->insertAddressee( inL , false ); 2975 local->insertAddressee( inL , false );
2966 ++changedLocal; 2976 ++changedLocal;
2967 } 2977 }
2968 } 2978 }
2969 } 2979 }
2970 } else { // no conflict ********** add or delete remote 2980 } else { // no conflict ********** add or delete remote
2971 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) { 2981 if ( filterIN.name().isEmpty() || filterIN.filterAddressee( inR ) ) {
2972 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2982 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2973 QString des = addresseeLSync.note(); 2983 QString des = addresseeLSync.note();
2974 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2984 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2975 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2985 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2976 remote->insertAddressee( inR, false ); 2986 remote->insertAddressee( inR, false );
2977 ++deletedAddresseeR; 2987 ++deletedAddresseeR;
2978 } else { 2988 } else {
2979 inR.setRevision( modifiedCalendar ); 2989 inR.setRevision( modifiedCalendar );
2980 remote->insertAddressee( inR, false ); 2990 remote->insertAddressee( inR, false );
2981 inL = inR; 2991 inL = inR;
2982 inL.setIDStr( ":" ); 2992 inL.setIDStr( ":" );
2983 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2993 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2984 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2994 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2985 inL.setResource( 0 ); 2995 inL.setResource( 0 );
2986 local->insertAddressee( inL , false); 2996 local->insertAddressee( inL , false);
2987 ++addedAddressee; 2997 ++addedAddressee;
2988 } 2998 }
2989 } else { 2999 } else {
2990 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 3000 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2991 inR.setRevision( modifiedCalendar ); 3001 inR.setRevision( modifiedCalendar );
2992 remote->insertAddressee( inR, false ); 3002 remote->insertAddressee( inR, false );
2993 inR.setResource( 0 ); 3003 inR.setResource( 0 );
2994 local->insertAddressee( inR, false ); 3004 local->insertAddressee( inR, false );
2995 ++addedAddressee; 3005 ++addedAddressee;
2996 } else { 3006 } else {
2997 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 3007 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2998 remote->removeAddressee( inR ); 3008 remote->removeAddressee( inR );
2999 ++deletedAddresseeR; 3009 ++deletedAddresseeR;
3000 } 3010 }
3001 } 3011 }
3002 } else { 3012 } else {
3003 ++filteredIN; 3013 ++filteredIN;
3004 } 3014 }
3005 } 3015 }
3006 } 3016 }
3007 ++incCounter; 3017 ++incCounter;
3008 } 3018 }
3009 er.clear(); 3019 er.clear();
3010 QStringList el = local->uidList(); 3020 QStringList el = local->uidList();
3011 modulo = (el.count()/10)+1; 3021 modulo = (el.count()/10)+1;
3012 3022
3013 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 3023 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
3014 incCounter = 0; 3024 incCounter = 0;
3015 while ( incCounter < el.count()) { 3025 while ( incCounter < el.count()) {
3016 qApp->processEvents(); 3026 qApp->processEvents();
3017 if (syncManager->isProgressBarCanceled()) 3027 if (syncManager->isProgressBarCanceled())
3018 return false; 3028 return false;
3019 if ( incCounter % modulo == 0 ) 3029 if ( incCounter % modulo == 0 )
3020 syncManager->showProgressBar(incCounter); 3030 syncManager->showProgressBar(incCounter);
3021 uid = el[ incCounter ]; 3031 uid = el[ incCounter ];
3022 bool skipIncidence = false; 3032 bool skipIncidence = false;
3023 if ( uid.left(19) == QString("last-syncAddressee-") ) 3033 if ( uid.left(19) == QString("last-syncAddressee-") )
3024 skipIncidence = true; 3034 skipIncidence = true;
3025 if ( !skipIncidence ) { 3035 if ( !skipIncidence ) {
3026 inL = local->findByUid( uid ); 3036 inL = local->findByUid( uid );
3027 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3037 if ( !inL.resource() || inL.resource()->includeInSync() ) {
3028 inR = remote->findByUid( uid ); 3038 inR = remote->findByUid( uid );
3029 if ( inR.isEmpty() ){ 3039 if ( inR.isEmpty() ){
3030 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) { 3040 if ( filterOUT.name().isEmpty() || filterOUT.filterAddressee( inL ) ) {
3031 // no conflict ********** add or delete local 3041 // no conflict ********** add or delete local
3032 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3042 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
3033 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3043 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
3034 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3044 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3035 local->removeAddressee( inL ); 3045 local->removeAddressee( inL );
3036 ++deletedAddresseeL; 3046 ++deletedAddresseeL;
3037 } else { 3047 } else {
3038 if ( ! syncManager->mWriteBackExistingOnly ) { 3048 if ( ! syncManager->mWriteBackExistingOnly ) {
3039 inL.removeID(mCurrentSyncDevice ); 3049 inL.removeID(mCurrentSyncDevice );
3040 ++addedAddresseeR; 3050 ++addedAddresseeR;
3041 inL.setRevision( modifiedCalendar ); 3051 inL.setRevision( modifiedCalendar );
3042 local->insertAddressee( inL, false ); 3052 local->insertAddressee( inL, false );
3043 inR = inL; 3053 inR = inL;
3044 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3054 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
3045 inR.setResource( 0 ); 3055 inR.setResource( 0 );
3046 remote->insertAddressee( inR, false ); 3056 remote->insertAddressee( inR, false );
3047 } 3057 }
3048 } 3058 }
3049 } else { 3059 } else {
3050 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3060 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
3051 //qDebug("data %s ", inL.revision().toString().latin1()); 3061 //qDebug("data %s ", inL.revision().toString().latin1());
3052 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3062 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
3053 local->removeAddressee( inL ); 3063 local->removeAddressee( inL );
3054 ++deletedAddresseeL; 3064 ++deletedAddresseeL;
3055 } else { 3065 } else {
3056 if ( ! syncManager->mWriteBackExistingOnly ) { 3066 if ( ! syncManager->mWriteBackExistingOnly ) {
3057 ++addedAddresseeR; 3067 ++addedAddresseeR;
3058 inL.setRevision( modifiedCalendar ); 3068 inL.setRevision( modifiedCalendar );
3059 local->insertAddressee( inL, false ); 3069 local->insertAddressee( inL, false );
3060 inR = inL; 3070 inR = inL;
3061 inR.setIDStr( ":" ); 3071 inR.setIDStr( ":" );
3062 inR.setResource( 0 ); 3072 inR.setResource( 0 );
3063 remote->insertAddressee( inR, false ); 3073 remote->insertAddressee( inR, false );
3064 } 3074 }
3065 } 3075 }
3066 } 3076 }
3067 } else { 3077 } else {
3068 ++filteredOUT; 3078 ++filteredOUT;
3069 } 3079 }
3070 } 3080 }
3071 } 3081 }
3072 } 3082 }
3073 ++incCounter; 3083 ++incCounter;
3074 } 3084 }
3075 el.clear(); 3085 el.clear();
3076 syncManager->hideProgressBar(); 3086 syncManager->hideProgressBar();
3077 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3087 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
3078 // get rid of micro seconds 3088 // get rid of micro seconds
3079 QTime t = mLastAddressbookSync.time(); 3089 QTime t = mLastAddressbookSync.time();
3080 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3090 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
3081 addresseeLSync.setRevision( mLastAddressbookSync ); 3091 addresseeLSync.setRevision( mLastAddressbookSync );
3082 addresseeRSync.setRevision( mLastAddressbookSync ); 3092 addresseeRSync.setRevision( mLastAddressbookSync );
3083 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3093 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
3084 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3094 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
3085 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3095 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
3086 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3096 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
3087 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3097 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
3088 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3098 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
3089 addresseeRSync.setNote( "" ) ; 3099 addresseeRSync.setNote( "" ) ;
3090 addresseeLSync.setNote( "" ); 3100 addresseeLSync.setNote( "" );
3091 3101
3092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3102 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
3093 remote->insertAddressee( addresseeRSync, false ); 3103 remote->insertAddressee( addresseeRSync, false );
3094 local->insertAddressee( addresseeLSync, false ); 3104 local->insertAddressee( addresseeLSync, false );
3095 QString mes; 3105 QString mes;
3096 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT ); 3106 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR, filteredIN, filteredOUT );
3097 qDebug( mes ); 3107 qDebug( mes );
3098 mes = i18n("Local addressbook changed!\n") +mes; 3108 mes = i18n("Local addressbook changed!\n") +mes;
3099 if ( syncManager->mShowSyncSummary ) { 3109 if ( syncManager->mShowSyncSummary ) {
3100 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3110 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
3101 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3111 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
3102 qDebug("cancelled "); 3112 qDebug("cancelled ");
3103 return false; 3113 return false;
3104 } 3114 }
3105 } 3115 }
3106 return syncOK; 3116 return syncOK;
3107} 3117}
3108 3118
3109 3119
3110//this is a overwritten callbackmethods from the syncinterface 3120//this is a overwritten callbackmethods from the syncinterface
3111bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3121bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3112{ 3122{
3113 3123
3114 //pending prepare addresseeview for output 3124 //pending prepare addresseeview for output
3115 //pending detect, if remote file has REV field. if not switch to external sync 3125 //pending detect, if remote file has REV field. if not switch to external sync
3116 mGlobalSyncMode = SYNC_MODE_NORMAL; 3126 mGlobalSyncMode = SYNC_MODE_NORMAL;
3117 if ( manager != syncManager ) 3127 if ( manager != syncManager )
3118 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3128 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3119 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3129 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3120 3130
3121 AddressBook abLocal(filename,"syncContact"); 3131 AddressBook abLocal(filename,"syncContact");
3122 bool syncOK = false; 3132 bool syncOK = false;
3123 if ( abLocal.load() ) { 3133 if ( abLocal.load() ) {
3124 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3134 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3125 bool external = false; 3135 bool external = false;
3126 bool isXML = false; 3136 bool isXML = false;
3127 if ( filename.right(4) == ".xml") { 3137 if ( filename.right(4) == ".xml") {
3128 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3138 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3129 isXML = true; 3139 isXML = true;
3130 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3140 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3131 } else { 3141 } else {
3132 external = !manager->mIsKapiFile; 3142 external = !manager->mIsKapiFile;
3133 if ( external ) { 3143 if ( external ) {
3134 qDebug("Setting vcf mode to external "); 3144 qDebug("Setting vcf mode to external ");
3135 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3145 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3136 AddressBook::Iterator it; 3146 AddressBook::Iterator it;
3137 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3147 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3138 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3148 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3139 (*it).computeCsum( mCurrentSyncDevice ); 3149 (*it).computeCsum( mCurrentSyncDevice );
3140 } 3150 }
3141 } 3151 }
3142 } 3152 }
3143 //AddressBook::Iterator it; 3153 //AddressBook::Iterator it;
3144 //QStringList vcards; 3154 //QStringList vcards;
3145 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3155 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3146 // qDebug("Name %s ", (*it).familyName().latin1()); 3156 // qDebug("Name %s ", (*it).familyName().latin1());
3147 //} 3157 //}
3148 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3158 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3149 if ( syncOK ) { 3159 if ( syncOK ) {
3150 if ( syncManager->mWriteBackFile ) 3160 if ( syncManager->mWriteBackFile )
3151 { 3161 {
3152 if ( external ) 3162 if ( external )
3153 abLocal.removeSyncAddressees( !isXML); 3163 abLocal.removeSyncAddressees( !isXML);
3154 qDebug("Saving remote AB "); 3164 qDebug("Saving remote AB ");
3155 if ( ! abLocal.saveAB()) 3165 if ( ! abLocal.saveAB())
3156 qDebug("Error writing back AB to file "); 3166 qDebug("Error writing back AB to file ");
3157 if ( external ) { 3167 if ( external ) {
3158 // afterwrite processing 3168 // afterwrite processing
3159 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3169 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3160 } 3170 }
3161 } 3171 }
3162 } 3172 }
3163 setModified(); 3173 setModified();
3164 3174
3165 } 3175 }
3166 abLocal.removeResources(); 3176 abLocal.removeResources();
3167 if ( syncOK ) 3177 if ( syncOK )
3168 mViewManager->refreshView(); 3178 mViewManager->refreshView();
3169 return syncOK; 3179 return syncOK;
3170 3180
3171} 3181}
3172void KABCore::removeSyncInfo( QString syncProfile) 3182void KABCore::removeSyncInfo( QString syncProfile)
3173{ 3183{
3174 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3184 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3175 mAddressBook->removeSyncInfo( syncProfile ); 3185 mAddressBook->removeSyncInfo( syncProfile );
3176 setModified(); 3186 setModified();
3177} 3187}
3178 3188
3179 3189
3180//this is a overwritten callbackmethods from the syncinterface 3190//this is a overwritten callbackmethods from the syncinterface
3181bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3191bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3182{ 3192{
3183 if ( resource == "phone" ) 3193 if ( resource == "phone" )
3184 return syncPhone(); 3194 return syncPhone();
3185 disableBR( true ); 3195 disableBR( true );
3186 if ( manager != syncManager ) 3196 if ( manager != syncManager )
3187 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3197 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3188 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3198 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3189 3199
3190 AddressBook abLocal( resource,"syncContact"); 3200 AddressBook abLocal( resource,"syncContact");
3191 bool syncOK = false; 3201 bool syncOK = false;
3202 message(i18n("Loading DTM address data..."), false);
3192 if ( abLocal.load() ) { 3203 if ( abLocal.load() ) {
3193 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3204 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3194 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3205 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3206 message(i18n("Sync preprocessing..."),false);
3195 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3207 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3208 message(i18n("Synchronizing..."),false);
3196 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3209 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3197 if ( syncOK ) { 3210 if ( syncOK ) {
3198 if ( syncManager->mWriteBackFile ) { 3211 if ( syncManager->mWriteBackFile ) {
3199 abLocal.removeSyncAddressees( false ); 3212 abLocal.removeSyncAddressees( false );
3213 message(i18n("Saving DTM address data..."),false);
3200 abLocal.saveAB(); 3214 abLocal.saveAB();
3215 message(i18n("Sync postprocessing..."),false);
3201 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3216 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3202 } 3217 }
3203 } else 3218 } else
3204 message( i18n("Sync cancelled or failed.") ); 3219 message( i18n("Sync cancelled or failed.") );
3205 setModified(); 3220 setModified();
3206 } 3221 }
3207 abLocal.removeResources(); 3222 abLocal.removeResources();
3208 if ( syncOK ) 3223 if ( syncOK ) {
3209 mViewManager->refreshView(); 3224 mViewManager->refreshView();
3225 message(i18n("DTM syncing finished."));
3226 }
3210 disableBR( false ); 3227 disableBR( false );
3211 return syncOK; 3228 return syncOK;
3212 3229
3213} 3230}
3214void KABCore::message( QString m ) 3231void KABCore::message( QString m, bool startTimer)
3215{ 3232{
3216 topLevelWidget()->setCaption( m ); 3233 topLevelWidget()->setCaption( m );
3217 mMessageTimer->start( 20000, true ); 3234 qApp->processEvents();
3235 if ( startTimer )
3236 mMessageTimer->start( 15000, true );
3237 else
3238 mMessageTimer->stop();
3218} 3239}
3219bool KABCore::syncPhone() 3240bool KABCore::syncPhone()
3220{ 3241{
3221 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3242 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3222 QString fileName = getPhoneFile(); 3243 QString fileName = getPhoneFile();
3223 if ( !PhoneAccess::readFromPhone( fileName) ) { 3244 if ( !PhoneAccess::readFromPhone( fileName) ) {
3224 message(i18n("Phone access failed!")); 3245 message(i18n("Phone access failed!"));
3225 return false; 3246 return false;
3226 } 3247 }
3227 AddressBook abLocal( fileName,"syncContact"); 3248 AddressBook abLocal( fileName,"syncContact");
3228 bool syncOK = false; 3249 bool syncOK = false;
3229 { 3250 {
3230 abLocal.importFromFile( fileName ); 3251 abLocal.importFromFile( fileName );
3231 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3252 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3232 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3253 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3233 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3254 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3234 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3255 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3235 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3256 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3236 if ( syncOK ) { 3257 if ( syncOK ) {
3237 if ( syncManager->mWriteBackFile ) { 3258 if ( syncManager->mWriteBackFile ) {
3238 abLocal.removeSyncAddressees( true ); 3259 abLocal.removeSyncAddressees( true );
3239 abLocal.saveABphone( fileName ); 3260 abLocal.saveABphone( fileName );
3240 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3261 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3241 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3262 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3242 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3263 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3243 } 3264 }
3244 } 3265 }
3245 setModified(); 3266 setModified();
3246 } 3267 }
3247 abLocal.removeResources(); 3268 abLocal.removeResources();
3248 if ( syncOK ) 3269 if ( syncOK )
3249 mViewManager->refreshView(); 3270 mViewManager->refreshView();
3250 return syncOK; 3271 return syncOK;
3251} 3272}
3252void KABCore::getFile( bool success ) 3273void KABCore::getFile( bool success )
3253{ 3274{
3254 if ( ! success ) { 3275 if ( ! success ) {
3255 message( i18n("Error receiving file. Nothing changed!") ); 3276 message( i18n("Error receiving file. Nothing changed!") );
3256 return; 3277 return;
3257 } 3278 }
3258 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3279 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3259 if ( count ) 3280 if ( count )
3260 setModified( true ); 3281 setModified( true );
3261 message( i18n("Pi-Sync successful!") ); 3282 message( i18n("Pi-Sync successful!") );
3262 mViewManager->refreshView(); 3283 mViewManager->refreshView();
3263} 3284}
3264void KABCore::syncFileRequest() 3285void KABCore::syncFileRequest()
3265{ 3286{
3266 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3287 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3267 syncManager->slotSyncMenu( 999 ); 3288 syncManager->slotSyncMenu( 999 );
3268 } 3289 }
3269 mAddressBook->export2File( sentSyncFile() ); 3290 mAddressBook->export2File( sentSyncFile() );
3270} 3291}
3271QString KABCore::sentSyncFile() 3292QString KABCore::sentSyncFile()
3272{ 3293{
3273#ifdef DESKTOP_VERSION 3294#ifdef DESKTOP_VERSION
3274 return locateLocal( "tmp", "copysyncab.vcf" ); 3295 return locateLocal( "tmp", "copysyncab.vcf" );
3275#else 3296#else
3276 return QString( "/tmp/copysyncab.vcf" ); 3297 return QString( "/tmp/copysyncab.vcf" );
3277#endif 3298#endif
3278} 3299}
3279 3300
3280void KABCore::setCaptionBack() 3301void KABCore::setCaptionBack()
3281{ 3302{
3282 mMessageTimer->stop(); 3303 mMessageTimer->stop();
3283 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3304 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3284} 3305}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index ecfe6e9..786549a 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,519 +1,519 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 98
99 99
100 /** 100 /**
101 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
102 */ 102 */
103 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
104 104
105 /** 105 /**
106 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
107 */ 107 */
108 static KConfig *config(); 108 static KConfig *config();
109 109
110 /** 110 /**
111 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
112 other classes can register their actions easily. 112 other classes can register their actions easily.
113 */ 113 */
114 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
115 115
116 /** 116 /**
117 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
118 */ 118 */
119 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
120 120
121 /** 121 /**
122 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
123 */ 123 */
124 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
125 125
126 /** 126 /**
127 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
128 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
129 the user. 129 the user.
130 */ 130 */
131 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
132 132
133#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
134 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 136
137#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
138 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
139 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
140#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
141 141
142 public slots: 142 public slots:
143#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
144 void createAboutData(); 144 void createAboutData();
145#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
146 void setDetailsToggle(); 146 void setDetailsToggle();
147 147
148 void showLicence(); 148 void showLicence();
149 void faq(); 149 void faq();
150 void whatsnew() ; 150 void whatsnew() ;
151 void synchowto() ; 151 void synchowto() ;
152 void multisynchowto() ; 152 void multisynchowto() ;
153 void kdesynchowto() ; 153 void kdesynchowto() ;
154 void writeToPhone(); 154 void writeToPhone();
155 155
156 /** 156 /**
157 Is called whenever a contact is selected in the view. 157 Is called whenever a contact is selected in the view.
158 */ 158 */
159 void setContactSelected( const QString &uid ); 159 void setContactSelected( const QString &uid );
160 160
161 /** 161 /**
162 Opens the preferred mail composer with all selected contacts as 162 Opens the preferred mail composer with all selected contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail(); 165 void sendMail();
166 166
167 /** 167 /**
168 Opens the preferred mail composer with the given contacts as 168 Opens the preferred mail composer with the given contacts as
169 arguments. 169 arguments.
170 */ 170 */
171 void sendMail( const QString& email ); 171 void sendMail( const QString& email );
172 172
173 173
174 void mailVCard(); 174 void mailVCard();
175 void mailVCard(const QStringList& uids); 175 void mailVCard(const QStringList& uids);
176 176
177 /** 177 /**
178 Beams the "WhoAmI contact. 178 Beams the "WhoAmI contact.
179 */ 179 */
180 void beamMySelf(); 180 void beamMySelf();
181 181
182 void beamVCard(); 182 void beamVCard();
183 void export2phone(); 183 void export2phone();
184 void beamVCard(const QStringList& uids); 184 void beamVCard(const QStringList& uids);
185 void beamDone( Ir *ir ); 185 void beamDone( Ir *ir );
186 186
187 187
188 /** 188 /**
189 Starts the preferred web browser with the given URL as argument. 189 Starts the preferred web browser with the given URL as argument.
190 */ 190 */
191 void browse( const QString& url ); 191 void browse( const QString& url );
192 192
193 /** 193 /**
194 Select all contacts in the view. 194 Select all contacts in the view.
195 */ 195 */
196 void selectAllContacts(); 196 void selectAllContacts();
197 197
198 /** 198 /**
199 Deletes all selected contacts from the address book. 199 Deletes all selected contacts from the address book.
200 */ 200 */
201 void deleteContacts(); 201 void deleteContacts();
202 202
203 /** 203 /**
204 Deletes given contacts from the address book. 204 Deletes given contacts from the address book.
205 205
206 @param uids The uids of the contacts, which shall be deleted. 206 @param uids The uids of the contacts, which shall be deleted.
207 */ 207 */
208 void deleteContacts( const QStringList &uids ); 208 void deleteContacts( const QStringList &uids );
209 209
210 /** 210 /**
211 Copys the selected contacts into clipboard for later pasting. 211 Copys the selected contacts into clipboard for later pasting.
212 */ 212 */
213 void copyContacts(); 213 void copyContacts();
214 214
215 /** 215 /**
216 Cuts the selected contacts and stores them for later pasting. 216 Cuts the selected contacts and stores them for later pasting.
217 */ 217 */
218 void cutContacts(); 218 void cutContacts();
219 219
220 /** 220 /**
221 Paste contacts from clipboard into the address book. 221 Paste contacts from clipboard into the address book.
222 */ 222 */
223 void pasteContacts(); 223 void pasteContacts();
224 224
225 /** 225 /**
226 Paste given contacts into the address book. 226 Paste given contacts into the address book.
227 227
228 @param list The list of addressee, which shall be pasted. 228 @param list The list of addressee, which shall be pasted.
229 */ 229 */
230 void pasteContacts( KABC::Addressee::List &list ); 230 void pasteContacts( KABC::Addressee::List &list );
231 231
232 /** 232 /**
233 Sets the whoAmI contact, that is used by many other programs to 233 Sets the whoAmI contact, that is used by many other programs to
234 get personal information about the current user. 234 get personal information about the current user.
235 */ 235 */
236 void setWhoAmI(); 236 void setWhoAmI();
237 237
238 /** 238 /**
239 Displays the category dialog and applies the result to all 239 Displays the category dialog and applies the result to all
240 selected contacts. 240 selected contacts.
241 */ 241 */
242 void setCategories(); 242 void setCategories();
243 void manageCategories(); 243 void manageCategories();
244 void editCategories(); 244 void editCategories();
245 245
246 /** 246 /**
247 Sets the field list of the Incremental Search Widget. 247 Sets the field list of the Incremental Search Widget.
248 */ 248 */
249 void setSearchFields( const KABC::Field::List &fields ); 249 void setSearchFields( const KABC::Field::List &fields );
250 250
251 /** 251 /**
252 Search with the current search field for a contact, that matches 252 Search with the current search field for a contact, that matches
253 the given text, and selects it in the view. 253 the given text, and selects it in the view.
254 */ 254 */
255 void incrementalSearch( const QString& text ); 255 void incrementalSearch( const QString& text );
256 256
257 /** 257 /**
258 Marks the address book as modified. 258 Marks the address book as modified.
259 */ 259 */
260 void setModified(); 260 void setModified();
261 /** 261 /**
262 Marks the address book as modified without refreshing the view. 262 Marks the address book as modified without refreshing the view.
263 */ 263 */
264 void setModifiedWOrefresh(); 264 void setModifiedWOrefresh();
265 265
266 /** 266 /**
267 Marks the address book as modified concerning the argument. 267 Marks the address book as modified concerning the argument.
268 */ 268 */
269 void setModified( bool modified ); 269 void setModified( bool modified );
270 270
271 /** 271 /**
272 Returns whether the address book is modified. 272 Returns whether the address book is modified.
273 */ 273 */
274 bool modified() const; 274 bool modified() const;
275 275
276 /** 276 /**
277 Called whenever an contact is modified in the contact editor 277 Called whenever an contact is modified in the contact editor
278 dialog or the quick edit. 278 dialog or the quick edit.
279 */ 279 */
280 void contactModified( const KABC::Addressee &addr ); 280 void contactModified( const KABC::Addressee &addr );
281 void addrModified( const KABC::Addressee &addr, bool updateDetails = true ); 281 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
282 282
283 /** 283 /**
284 DCOP METHODS. 284 DCOP METHODS.
285 */ 285 */
286 void addEmail( QString addr ); 286 void addEmail( QString addr );
287 void importVCard( const KURL& url, bool showPreview ); 287 void importVCard( const KURL& url, bool showPreview );
288 void importVCard( const QString& vCard, bool showPreview ); 288 void importVCard( const QString& vCard, bool showPreview );
289 void newContact(); 289 void newContact();
290 QString getNameByPhone( const QString& phone ); 290 QString getNameByPhone( const QString& phone );
291 /** 291 /**
292 END DCOP METHODS 292 END DCOP METHODS
293 */ 293 */
294 294
295 /** 295 /**
296 Saves the contents of the AddressBook back to disk. 296 Saves the contents of the AddressBook back to disk.
297 */ 297 */
298 void save(); 298 void save();
299 299
300 /** 300 /**
301 Undos the last command using the undo stack. 301 Undos the last command using the undo stack.
302 */ 302 */
303 void undo(); 303 void undo();
304 304
305 /** 305 /**
306 Redos the last command that was undone, using the redo stack. 306 Redos the last command that was undone, using the redo stack.
307 */ 307 */
308 void redo(); 308 void redo();
309 309
310 /** 310 /**
311 Shows the edit dialog for the given uid. If the uid is QString::null, 311 Shows the edit dialog for the given uid. If the uid is QString::null,
312 the method will try to find a selected addressee in the view. 312 the method will try to find a selected addressee in the view.
313 */ 313 */
314 void editContact( const QString &uid /*US = QString::null*/ ); 314 void editContact( const QString &uid /*US = QString::null*/ );
315//US added a second method without defaultparameter 315//US added a second method without defaultparameter
316 void editContact2(); 316 void editContact2();
317 317
318 /** 318 /**
319 Shows or edits the detail view for the given uid. If the uid is QString::null, 319 Shows or edits the detail view for the given uid. If the uid is QString::null,
320 the method will try to find a selected addressee in the view. 320 the method will try to find a selected addressee in the view.
321 */ 321 */
322 void executeContact( const QString &uid /*US = QString::null*/ ); 322 void executeContact( const QString &uid /*US = QString::null*/ );
323 323
324 /** 324 /**
325 Launches the configuration dialog. 325 Launches the configuration dialog.
326 */ 326 */
327 void openConfigDialog(); 327 void openConfigDialog();
328 328
329 /** 329 /**
330 Launches the ldap search dialog. 330 Launches the ldap search dialog.
331 */ 331 */
332 void openLDAPDialog(); 332 void openLDAPDialog();
333 333
334 /** 334 /**
335 Creates a KAddressBookPrinter, which will display the print 335 Creates a KAddressBookPrinter, which will display the print
336 dialog and do the printing. 336 dialog and do the printing.
337 */ 337 */
338 void print(); 338 void print();
339 339
340 /** 340 /**
341 Registers a new GUI client, so plugins can register its actions. 341 Registers a new GUI client, so plugins can register its actions.
342 */ 342 */
343 void addGUIClient( KXMLGUIClient *client ); 343 void addGUIClient( KXMLGUIClient *client );
344 344
345 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 345 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
346 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 346 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
347 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 347 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
348 348
349 349
350 signals: 350 signals:
351 void contactSelected( const QString &name ); 351 void contactSelected( const QString &name );
352 void contactSelected( const QPixmap &pixmap ); 352 void contactSelected( const QPixmap &pixmap );
353 public slots: 353 public slots:
354 void recieve(QString cmsg ); 354 void recieve(QString cmsg );
355 void getFile( bool success ); 355 void getFile( bool success );
356 void syncFileRequest(); 356 void syncFileRequest();
357 void setDetailsVisible( bool visible ); 357 void setDetailsVisible( bool visible );
358 void setDetailsToState(); 358 void setDetailsToState();
359 359
360 void saveSettings(); 360 void saveSettings();
361 361
362 private slots: 362 private slots:
363 void updateToolBar(); 363 void updateToolBar();
364 void updateMainWindow(); 364 void updateMainWindow();
365 void receive( const QCString& cmsg, const QByteArray& data ); 365 void receive( const QCString& cmsg, const QByteArray& data );
366 void toggleBeamReceive( ); 366 void toggleBeamReceive( );
367 void disableBR(bool); 367 void disableBR(bool);
368 void setJumpButtonBarVisible( bool visible ); 368 void setJumpButtonBarVisible( bool visible );
369 void setCaptionBack(); 369 void setCaptionBack();
370 void importFromOL(); 370 void importFromOL();
371 void extensionModified( const KABC::Addressee::List &list ); 371 void extensionModified( const KABC::Addressee::List &list );
372 void extensionChanged( int id ); 372 void extensionChanged( int id );
373 void clipboardDataChanged(); 373 void clipboardDataChanged();
374 void updateActionMenu(); 374 void updateActionMenu();
375 void configureKeyBindings(); 375 void configureKeyBindings();
376 void removeVoice(); 376 void removeVoice();
377 void setFormattedName(); 377 void setFormattedName();
378#ifdef KAB_EMBEDDED 378#ifdef KAB_EMBEDDED
379 void configureResources(); 379 void configureResources();
380#endif //KAB_EMBEDDED 380#endif //KAB_EMBEDDED
381 381
382 void slotEditorDestroyed( const QString &uid ); 382 void slotEditorDestroyed( const QString &uid );
383 void configurationChanged(); 383 void configurationChanged();
384 void addressBookChanged(); 384 void addressBookChanged();
385 385
386 private: 386 private:
387 void resizeEvent(QResizeEvent* e ); 387 void resizeEvent(QResizeEvent* e );
388 bool mBRdisabled; 388 bool mBRdisabled;
389#ifndef DESKTOP_VERSION 389#ifndef DESKTOP_VERSION
390 QCopChannel* infrared; 390 QCopChannel* infrared;
391#endif 391#endif
392 QTimer *mMessageTimer; 392 QTimer *mMessageTimer;
393 void initGUI(); 393 void initGUI();
394 void initActions(); 394 void initActions();
395 QString getPhoneFile(); 395 QString getPhoneFile();
396 396
397 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 397 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
398 const char *name = 0 ); 398 const char *name = 0 );
399 399
400 KXMLGUIClient *mGUIClient; 400 KXMLGUIClient *mGUIClient;
401 401
402 KABC::AddressBook *mAddressBook; 402 KABC::AddressBook *mAddressBook;
403 403
404 ViewManager *mViewManager; 404 ViewManager *mViewManager;
405 // QSplitter *mDetailsSplitter; 405 // QSplitter *mDetailsSplitter;
406 KDGanttMinimizeSplitter *mExtensionBarSplitter; 406 KDGanttMinimizeSplitter *mExtensionBarSplitter;
407 ViewContainer *mDetails; 407 ViewContainer *mDetails;
408 KDGanttMinimizeSplitter* mMiniSplitter; 408 KDGanttMinimizeSplitter* mMiniSplitter;
409 XXPortManager *mXXPortManager; 409 XXPortManager *mXXPortManager;
410 JumpButtonBar *mJumpButtonBar; 410 JumpButtonBar *mJumpButtonBar;
411 IncSearchWidget *mIncSearchWidget; 411 IncSearchWidget *mIncSearchWidget;
412 ExtensionManager *mExtensionManager; 412 ExtensionManager *mExtensionManager;
413 413
414 KCMultiDialog *mConfigureDialog; 414 KCMultiDialog *mConfigureDialog;
415 415
416#ifndef KAB_EMBEDDED 416#ifndef KAB_EMBEDDED
417 LDAPSearchDialog *mLdapSearchDialog; 417 LDAPSearchDialog *mLdapSearchDialog;
418#endif //KAB_EMBEDDED 418#endif //KAB_EMBEDDED
419 // QDict<AddresseeEditorDialog> mEditorDict; 419 // QDict<AddresseeEditorDialog> mEditorDict;
420 AddresseeEditorDialog *mEditorDialog; 420 AddresseeEditorDialog *mEditorDialog;
421 bool mReadWrite; 421 bool mReadWrite;
422 bool mModified; 422 bool mModified;
423 bool mIsPart; 423 bool mIsPart;
424 bool mMultipleViewsAtOnce; 424 bool mMultipleViewsAtOnce;
425 425
426 426
427 //US file menu 427 //US file menu
428 KAction *mActionMail; 428 KAction *mActionMail;
429 KAction *mActionBeam; 429 KAction *mActionBeam;
430 KToggleAction *mActionBR; 430 KToggleAction *mActionBR;
431 KAction *mActionExport2phone; 431 KAction *mActionExport2phone;
432 KAction* mActionPrint; 432 KAction* mActionPrint;
433 KAction* mActionPrintDetails; 433 KAction* mActionPrintDetails;
434 KAction* mActionNewContact; 434 KAction* mActionNewContact;
435 KAction *mActionSave; 435 KAction *mActionSave;
436 KAction *mActionEditAddressee; 436 KAction *mActionEditAddressee;
437 KAction *mActionMailVCard; 437 KAction *mActionMailVCard;
438 KAction *mActionBeamVCard; 438 KAction *mActionBeamVCard;
439 439
440 KAction *mActionQuit; 440 KAction *mActionQuit;
441 441
442 //US edit menu 442 //US edit menu
443 KAction *mActionCopy; 443 KAction *mActionCopy;
444 KAction *mActionCut; 444 KAction *mActionCut;
445 KAction *mActionPaste; 445 KAction *mActionPaste;
446 KAction *mActionSelectAll; 446 KAction *mActionSelectAll;
447 KAction *mActionUndo; 447 KAction *mActionUndo;
448 KAction *mActionRedo; 448 KAction *mActionRedo;
449 KAction *mActionDelete; 449 KAction *mActionDelete;
450 450
451 //US settings menu 451 //US settings menu
452 KAction *mActionConfigResources; 452 KAction *mActionConfigResources;
453 KAction *mActionConfigKAddressbook; 453 KAction *mActionConfigKAddressbook;
454 KAction *mActionConfigShortcuts; 454 KAction *mActionConfigShortcuts;
455 KAction *mActionConfigureToolbars; 455 KAction *mActionConfigureToolbars;
456 KAction *mActionKeyBindings; 456 KAction *mActionKeyBindings;
457 KToggleAction *mActionJumpBar; 457 KToggleAction *mActionJumpBar;
458 KToggleAction *mActionDetails; 458 KToggleAction *mActionDetails;
459 KAction *mActionWhoAmI; 459 KAction *mActionWhoAmI;
460 KAction *mActionCategories; 460 KAction *mActionCategories;
461 KAction *mActionEditCategories; 461 KAction *mActionEditCategories;
462 KAction *mActionManageCategories; 462 KAction *mActionManageCategories;
463 KAction *mActionAboutKAddressbook; 463 KAction *mActionAboutKAddressbook;
464 KAction *mActionLicence; 464 KAction *mActionLicence;
465 KAction *mActionFaq; 465 KAction *mActionFaq;
466 KAction *mActionWN; 466 KAction *mActionWN;
467 KAction *mActionSyncHowto; 467 KAction *mActionSyncHowto;
468 KAction *mActionKdeSyncHowto; 468 KAction *mActionKdeSyncHowto;
469 KAction *mActionMultiSyncHowto; 469 KAction *mActionMultiSyncHowto;
470 470
471 KAction *mActionDeleteView; 471 KAction *mActionDeleteView;
472 472
473 QPopupMenu *viewMenu; 473 QPopupMenu *viewMenu;
474 QPopupMenu *filterMenu; 474 QPopupMenu *filterMenu;
475 QPopupMenu *settingsMenu; 475 QPopupMenu *settingsMenu;
476 QPopupMenu *changeMenu; 476 QPopupMenu *changeMenu;
477 QPopupMenu *beamMenu; 477 QPopupMenu *beamMenu;
478//US QAction *mActionSave; 478//US QAction *mActionSave;
479 QPopupMenu *ImportMenu; 479 QPopupMenu *ImportMenu;
480 QPopupMenu *ExportMenu; 480 QPopupMenu *ExportMenu;
481 //LR additional methods 481 //LR additional methods
482 KAction *mActionRemoveVoice; 482 KAction *mActionRemoveVoice;
483 KAction *mActionSetFormattedName; 483 KAction *mActionSetFormattedName;
484 KAction * mActionImportOL; 484 KAction * mActionImportOL;
485 485
486#ifndef KAB_EMBEDDED 486#ifndef KAB_EMBEDDED
487 KAddressBookService *mAddressBookService; 487 KAddressBookService *mAddressBookService;
488#endif //KAB_EMBEDDED 488#endif //KAB_EMBEDDED
489 489
490 class KABCorePrivate; 490 class KABCorePrivate;
491 KABCorePrivate *d; 491 KABCorePrivate *d;
492 //US bool mBlockSaveFlag; 492 //US bool mBlockSaveFlag;
493 493
494#ifdef KAB_EMBEDDED 494#ifdef KAB_EMBEDDED
495 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 495 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
496#endif //KAB_EMBEDDED 496#endif //KAB_EMBEDDED
497 497
498 //this are the overwritten callbackmethods from the syncinterface 498 //this are the overwritten callbackmethods from the syncinterface
499 virtual bool sync(KSyncManager* manager, QString filename, int mode); 499 virtual bool sync(KSyncManager* manager, QString filename, int mode);
500 virtual bool syncExternal(KSyncManager* manager, QString resource); 500 virtual bool syncExternal(KSyncManager* manager, QString resource);
501 virtual void removeSyncInfo( QString syncProfile); 501 virtual void removeSyncInfo( QString syncProfile);
502 bool syncPhone(); 502 bool syncPhone();
503 void message( QString m ); 503 void message( QString m , bool startTimer = true);
504 504
505 // LR ******************************* 505 // LR *******************************
506 // sync stuff! 506 // sync stuff!
507 QString sentSyncFile(); 507 QString sentSyncFile();
508 QPopupMenu *syncMenu; 508 QPopupMenu *syncMenu;
509 KSyncManager* syncManager; 509 KSyncManager* syncManager;
510 int mGlobalSyncMode; 510 int mGlobalSyncMode;
511 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 511 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
512 KABC::Addressee getLastSyncAddressee(); 512 KABC::Addressee getLastSyncAddressee();
513 QDateTime mLastAddressbookSync; 513 QDateTime mLastAddressbookSync;
514 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 514 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
515 // ********************* 515 // *********************
516 516
517}; 517};
518 518
519#endif 519#endif