summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9c40142..a4f3579 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,2107 +1,2141 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 Async a special exception, permission is given to link this program 19 Async a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 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#ifdef _OL_IMPORT_ 158#ifdef _OL_IMPORT_
159#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
160#endif 160#endif
161#else 161#else
162#include <unistd.h> 162#include <unistd.h>
163#endif 163#endif
164// sync includes 164// sync includes
165#include <libkdepim/ksyncprofile.h> 165#include <libkdepim/ksyncprofile.h>
166#include <libkdepim/ksyncprefsdialog.h> 166#include <libkdepim/ksyncprefsdialog.h>
167 167
168 168
169class KABCatPrefs : public QDialog 169class KABCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from addressees"), format ); 185 new QRadioButton(i18n("Remove from addressees"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201class KABFormatPrefs : public QDialog 201class KABFormatPrefs : public QDialog
202{ 202{
203 public: 203 public:
204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) : 204 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 205 QDialog( parent, name, true )
206 { 206 {
207 setCaption( i18n("Set formatted name") ); 207 setCaption( i18n("Set formatted name") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 208 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 209 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 210 lay->setMargin( 3 );
211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this ); 211 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
212 lay->addWidget( lab ); 212 lay->addWidget( lab );
213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this ); 213 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
214 lay->addWidget( format ); 214 lay->addWidget( format );
215 format->setExclusive ( true ) ; 215 format->setExclusive ( true ) ;
216 simple = new QRadioButton(i18n("Simple: James Bond"), format ); 216 simple = new QRadioButton(i18n("Simple: James Bond"), format );
217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format ); 217 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format ); 218 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
219 company = new QRadioButton(i18n("Organization: MI6"), format ); 219 company = new QRadioButton(i18n("Organization: MI6"), format );
220 simple->setChecked( true ); 220 simple->setChecked( true );
221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this); 221 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
222 lay->addWidget( setCompany ); 222 lay->addWidget( setCompany );
223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this ); 223 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
224 lay->addWidget( ok ); 224 lay->addWidget( ok );
225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 225 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
226 lay->addWidget( cancel ); 226 lay->addWidget( cancel );
227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 227 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 228 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
229 //resize( 200, 200 ); 229 //resize( 200, 200 );
230 230
231 } 231 }
232public: 232public:
233 QRadioButton* simple, *full, *reverse, *company; 233 QRadioButton* simple, *full, *reverse, *company;
234 QCheckBox* setCompany; 234 QCheckBox* setCompany;
235}; 235};
236 236
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mIncSearchWidget = 0; 301 mIncSearchWidget = 0;
302 mMiniSplitter = 0; 302 mMiniSplitter = 0;
303 mExtensionBarSplitter = 0; 303 mExtensionBarSplitter = 0;
304 mIsPart = !parent->inherits( "KAddressBookMain" ); 304 mIsPart = !parent->inherits( "KAddressBookMain" );
305 mAddressBook = KABC::StdAddressBook::self(); 305 mAddressBook = KABC::StdAddressBook::self();
306 KABC::StdAddressBook::setAutomaticSave( false ); 306 KABC::StdAddressBook::setAutomaticSave( false );
307 307
308#ifndef KAB_EMBEDDED 308#ifndef KAB_EMBEDDED
309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
313 SLOT( addressBookChanged() ) ); 313 SLOT( addressBookChanged() ) );
314 314
315#if 0 315#if 0
316 // LR moved to addressbook init method 316 // LR moved to addressbook init method
317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
318 "X-Department", "KADDRESSBOOK" ); 318 "X-Department", "KADDRESSBOOK" );
319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
320 "X-Profession", "KADDRESSBOOK" ); 320 "X-Profession", "KADDRESSBOOK" );
321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
322 "X-AssistantsName", "KADDRESSBOOK" ); 322 "X-AssistantsName", "KADDRESSBOOK" );
323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
324 "X-ManagersName", "KADDRESSBOOK" ); 324 "X-ManagersName", "KADDRESSBOOK" );
325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
326 "X-SpousesName", "KADDRESSBOOK" ); 326 "X-SpousesName", "KADDRESSBOOK" );
327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
328 "X-Office", "KADDRESSBOOK" ); 328 "X-Office", "KADDRESSBOOK" );
329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
330 "X-IMAddress", "KADDRESSBOOK" ); 330 "X-IMAddress", "KADDRESSBOOK" );
331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
332 "X-Anniversary", "KADDRESSBOOK" ); 332 "X-Anniversary", "KADDRESSBOOK" );
333 333
334 //US added this field to become compatible with Opie/qtopia addressbook 334 //US added this field to become compatible with Opie/qtopia addressbook
335 // values can be "female" or "male" or "". An empty field represents undefined. 335 // values can be "female" or "male" or "". An empty field represents undefined.
336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
337 "X-Gender", "KADDRESSBOOK" ); 337 "X-Gender", "KADDRESSBOOK" );
338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
339 "X-Children", "KADDRESSBOOK" ); 339 "X-Children", "KADDRESSBOOK" );
340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
341 "X-FreeBusyUrl", "KADDRESSBOOK" ); 341 "X-FreeBusyUrl", "KADDRESSBOOK" );
342#endif 342#endif
343 initGUI(); 343 initGUI();
344 344
345 mIncSearchWidget->setFocus(); 345 mIncSearchWidget->setFocus();
346 346
347 347
348 connect( mViewManager, SIGNAL( selected( const QString& ) ), 348 connect( mViewManager, SIGNAL( selected( const QString& ) ),
349 SLOT( setContactSelected( const QString& ) ) ); 349 SLOT( setContactSelected( const QString& ) ) );
350 connect( mViewManager, SIGNAL( executed( const QString& ) ), 350 connect( mViewManager, SIGNAL( executed( const QString& ) ),
351 SLOT( executeContact( const QString& ) ) ); 351 SLOT( executeContact( const QString& ) ) );
352 352
353 connect( mViewManager, SIGNAL( deleteRequest( ) ), 353 connect( mViewManager, SIGNAL( deleteRequest( ) ),
354 SLOT( deleteContacts( ) ) ); 354 SLOT( deleteContacts( ) ) );
355 connect( mViewManager, SIGNAL( modified() ), 355 connect( mViewManager, SIGNAL( modified() ),
356 SLOT( setModified() ) ); 356 SLOT( setModified() ) );
357 357
358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
360 360
361 connect( mXXPortManager, SIGNAL( modified() ), 361 connect( mXXPortManager, SIGNAL( modified() ),
362 SLOT( setModified() ) ); 362 SLOT( setModified() ) );
363 363
364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
365 SLOT( incrementalSearchJump( const QString& ) ) ); 365 SLOT( incrementalSearchJump( const QString& ) ) );
366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 366 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
367 mJumpButtonBar, SLOT( recreateButtons() ) ); 367 mJumpButtonBar, SLOT( recreateButtons() ) );
368 368
369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 369 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
370 SLOT( sendMail( const QString& ) ) ); 370 SLOT( sendMail( const QString& ) ) );
371 371
372 372
373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 373 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
374 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&))); 374 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 375 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 376 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog())); 377 connect( ExternalAppHandler::instance(), SIGNAL (callContactdialog()),this, SLOT(callContactdialog()));
378 378
379 379
380#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 381 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
382 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 382 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
383 383
384 connect( mDetails, SIGNAL( browse( const QString& ) ), 384 connect( mDetails, SIGNAL( browse( const QString& ) ),
385 SLOT( browse( const QString& ) ) ); 385 SLOT( browse( const QString& ) ) );
386 386
387 387
388 mAddressBookService = new KAddressBookService( this ); 388 mAddressBookService = new KAddressBookService( this );
389 389
390#endif //KAB_EMBEDDED 390#endif //KAB_EMBEDDED
391 391
392 mMessageTimer = new QTimer( this ); 392 mMessageTimer = new QTimer( this );
393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 393 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
394 mEditorDialog = 0; 394 mEditorDialog = 0;
395 createAddresseeEditorDialog( this ); 395 createAddresseeEditorDialog( this );
396 setModified( false ); 396 setModified( false );
397 mBRdisabled = false; 397 mBRdisabled = false;
398#ifndef DESKTOP_VERSION 398#ifndef DESKTOP_VERSION
399 infrared = 0; 399 infrared = 0;
400#endif 400#endif
401 //toggleBeamReceive( ); 401 //toggleBeamReceive( );
402 mMainWindow->toolBar()->show(); 402 mMainWindow->toolBar()->show();
403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 403 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
404 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 404 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
405} 405}
406 406
407void KABCore::updateToolBar() 407void KABCore::updateToolBar()
408{ 408{
409 static int iii = 0; 409 static int iii = 0;
410 ++iii; 410 ++iii;
411 mMainWindow->toolBar()->repaintMe(); 411 mMainWindow->toolBar()->repaintMe();
412 if ( iii < 4 ) 412 if ( iii < 4 )
413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar())); 413 QTimer::singleShot( 100*iii, this , SLOT ( updateToolBar()));
414} 414}
415KABCore::~KABCore() 415KABCore::~KABCore()
416{ 416{
417 // save(); 417 // save();
418 //saveSettings(); 418 //saveSettings();
419 //KABPrefs::instance()->writeConfig(); 419 //KABPrefs::instance()->writeConfig();
420 delete AddresseeConfig::instance(); 420 delete AddresseeConfig::instance();
421 mAddressBook = 0; 421 mAddressBook = 0;
422 KABC::StdAddressBook::close(); 422 KABC::StdAddressBook::close();
423 423
424 delete syncManager; 424 delete syncManager;
425#ifndef DESKTOP_VERSION 425#ifndef DESKTOP_VERSION
426 if ( infrared ) 426 if ( infrared )
427 delete infrared; 427 delete infrared;
428#endif 428#endif
429} 429}
430void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 430void KABCore::receive( const QCString& cmsg, const QByteArray& data )
431{ 431{
432 //qDebug("KA: QCOP message received: %s ", cmsg.data() ); 432 //qDebug("KA: QCOP message received: %s ", cmsg.data() );
433 if ( cmsg == "setDocument(QString)" ) { 433 if ( cmsg == "setDocument(QString)" ) {
434 QDataStream stream( data, IO_ReadOnly ); 434 QDataStream stream( data, IO_ReadOnly );
435 QString fileName; 435 QString fileName;
436 stream >> fileName; 436 stream >> fileName;
437 recieve( fileName ); 437 recieve( fileName );
438 return; 438 return;
439 } 439 }
440} 440}
441void KABCore::toggleBeamReceive( ) 441void KABCore::toggleBeamReceive( )
442{ 442{
443 if ( mBRdisabled ) 443 if ( mBRdisabled )
444 return; 444 return;
445#ifndef DESKTOP_VERSION 445#ifndef DESKTOP_VERSION
446 if ( infrared ) { 446 if ( infrared ) {
447 qDebug("KA: AB disable BeamReceive "); 447 qDebug("KA: AB disable BeamReceive ");
448 delete infrared; 448 delete infrared;
449 infrared = 0; 449 infrared = 0;
450 mActionBR->setChecked(false); 450 mActionBR->setChecked(false);
451 return; 451 return;
452 } 452 }
453 qDebug("KA: AB enable BeamReceive "); 453 qDebug("KA: AB enable BeamReceive ");
454 mActionBR->setChecked(true); 454 mActionBR->setChecked(true);
455 455
456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 456 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 457 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
458#endif 458#endif
459} 459}
460 460
461 461
462void KABCore::disableBR(bool b) 462void KABCore::disableBR(bool b)
463{ 463{
464#ifndef DESKTOP_VERSION 464#ifndef DESKTOP_VERSION
465 if ( b ) { 465 if ( b ) {
466 if ( infrared ) { 466 if ( infrared ) {
467 toggleBeamReceive( ); 467 toggleBeamReceive( );
468 } 468 }
469 mBRdisabled = true; 469 mBRdisabled = true;
470 } else { 470 } else {
471 if ( mBRdisabled ) { 471 if ( mBRdisabled ) {
472 mBRdisabled = false; 472 mBRdisabled = false;
473 //toggleBeamReceive( ); 473 //toggleBeamReceive( );
474 } 474 }
475 } 475 }
476#endif 476#endif
477 477
478} 478}
479void KABCore::recieve( QString fn ) 479void KABCore::recieve( QString fn )
480{ 480{
481 //qDebug("KABCore::recieve "); 481 //qDebug("KABCore::recieve ");
482 int count = mAddressBook->importFromFile( fn, true ); 482 int count = mAddressBook->importFromFile( fn, true );
483 if ( count ) 483 if ( count )
484 setModified( true ); 484 setModified( true );
485 mViewManager->refreshView(); 485 mViewManager->refreshView();
486 message(i18n("%1 contact(s) received!").arg( count )); 486 message(i18n("%1 contact(s) received!").arg( count ));
487 topLevelWidget()->showMaximized(); 487 topLevelWidget()->showMaximized();
488 topLevelWidget()->raise(); 488 topLevelWidget()->raise();
489} 489}
490void KABCore::restoreSettings() 490void KABCore::restoreSettings()
491{ 491{
492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 492 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
493 493
494 bool state; 494 bool state;
495 495
496 if (mMultipleViewsAtOnce) 496 if (mMultipleViewsAtOnce)
497 state = KABPrefs::instance()->mDetailsPageVisible; 497 state = KABPrefs::instance()->mDetailsPageVisible;
498 else 498 else
499 state = false; 499 state = false;
500 500
501 mActionDetails->setChecked( state ); 501 mActionDetails->setChecked( state );
502 setDetailsVisible( state ); 502 setDetailsVisible( state );
503 503
504 state = KABPrefs::instance()->mJumpButtonBarVisible; 504 state = KABPrefs::instance()->mJumpButtonBarVisible;
505 505
506 mActionJumpBar->setChecked( state ); 506 mActionJumpBar->setChecked( state );
507 setJumpButtonBarVisible( state ); 507 setJumpButtonBarVisible( state );
508/*US 508/*US
509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 509 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
510 if ( splitterSize.count() == 0 ) { 510 if ( splitterSize.count() == 0 ) {
511 splitterSize.append( width() / 2 ); 511 splitterSize.append( width() / 2 );
512 splitterSize.append( width() / 2 ); 512 splitterSize.append( width() / 2 );
513 } 513 }
514 mMiniSplitter->setSizes( splitterSize ); 514 mMiniSplitter->setSizes( splitterSize );
515 if ( mExtensionBarSplitter ) { 515 if ( mExtensionBarSplitter ) {
516 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 516 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
517 if ( splitterSize.count() == 0 ) { 517 if ( splitterSize.count() == 0 ) {
518 splitterSize.append( width() / 2 ); 518 splitterSize.append( width() / 2 );
519 splitterSize.append( width() / 2 ); 519 splitterSize.append( width() / 2 );
520 } 520 }
521 mExtensionBarSplitter->setSizes( splitterSize ); 521 mExtensionBarSplitter->setSizes( splitterSize );
522 522
523 } 523 }
524*/ 524*/
525 mViewManager->restoreSettings(); 525 mViewManager->restoreSettings();
526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 526 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
527 mExtensionManager->restoreSettings(); 527 mExtensionManager->restoreSettings();
528#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
529 int wid = width(); 529 int wid = width();
530 if ( wid < 10 ) 530 if ( wid < 10 )
531 wid = 400; 531 wid = 400;
532#else 532#else
533 int wid = QApplication::desktop()->width(); 533 int wid = QApplication::desktop()->width();
534 if ( wid < 640 ) 534 if ( wid < 640 )
535 wid = QApplication::desktop()->height(); 535 wid = QApplication::desktop()->height();
536#endif 536#endif
537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 537 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
538 if ( true /*splitterSize.count() == 0*/ ) { 538 if ( true /*splitterSize.count() == 0*/ ) {
539 splitterSize.append( wid / 2 ); 539 splitterSize.append( wid / 2 );
540 splitterSize.append( wid / 2 ); 540 splitterSize.append( wid / 2 );
541 } 541 }
542 mMiniSplitter->setSizes( splitterSize ); 542 mMiniSplitter->setSizes( splitterSize );
543 if ( mExtensionBarSplitter ) { 543 if ( mExtensionBarSplitter ) {
544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 544 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
545 if ( true /*splitterSize.count() == 0*/ ) { 545 if ( true /*splitterSize.count() == 0*/ ) {
546 splitterSize.append( wid / 2 ); 546 splitterSize.append( wid / 2 );
547 splitterSize.append( wid / 2 ); 547 splitterSize.append( wid / 2 );
548 } 548 }
549 mExtensionBarSplitter->setSizes( splitterSize ); 549 mExtensionBarSplitter->setSizes( splitterSize );
550 550
551 } 551 }
552 552#ifdef DESKTOP_VERSION
553 553 KConfig *config = KABPrefs::instance()->getConfig();
554 config->setGroup("WidgetLayout");
555 QStringList list;
556 list = config->readListEntry("MainLayout");
557 int x,y,w,h;
558 if ( ! list.isEmpty() ) {
559 x = list[0].toInt();
560 y = list[1].toInt();
561 w = list[2].toInt();
562 h = list[3].toInt();
563 KApplication::testCoords( &x,&y,&w,&h );
564 topLevelWidget()->setGeometry(x,y,w,h);
565
566 } else {
567 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
568 }
569#endif
554} 570}
555 571
556void KABCore::saveSettings() 572void KABCore::saveSettings()
557{ 573{
558 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 574 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
559 if ( mExtensionBarSplitter ) 575 if ( mExtensionBarSplitter )
560 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 576 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
561 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 577 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
562 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 578 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
563#ifndef KAB_EMBEDDED 579#ifndef KAB_EMBEDDED
564 580
565 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 581 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
566 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 582 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
567#endif //KAB_EMBEDDED 583#endif //KAB_EMBEDDED
568 mExtensionManager->saveSettings(); 584 mExtensionManager->saveSettings();
569 mViewManager->saveSettings(); 585 mViewManager->saveSettings();
570 586
571 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 587 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
588#ifdef DESKTOP_VERSION
589 KConfig *config = KABPrefs::instance()->getConfig();
590 config->setGroup("WidgetLayout");
591 QStringList list ;//= config->readListEntry("MainLayout");
592 int x,y,w,h;
593 QWidget* wid;
594 wid = topLevelWidget();
595 x = wid->geometry().x();
596 y = wid->geometry().y();
597 w = wid->width();
598 h = wid->height();
599 list.clear();
600 list << QString::number( x );
601 list << QString::number( y );
602 list << QString::number( w );
603 list << QString::number( h );
604 config->writeEntry("MainLayout",list );
605#endif
572 KABPrefs::instance()->writeConfig(); 606 KABPrefs::instance()->writeConfig();
573 qDebug("KA: KABCore::saveSettings() "); 607 qDebug("KA: KABCore::saveSettings() ");
574} 608}
575 609
576KABC::AddressBook *KABCore::addressBook() const 610KABC::AddressBook *KABCore::addressBook() const
577{ 611{
578 return mAddressBook; 612 return mAddressBook;
579} 613}
580 614
581KConfig *KABCore::config() 615KConfig *KABCore::config()
582{ 616{
583#ifndef KAB_EMBEDDED 617#ifndef KAB_EMBEDDED
584 return KABPrefs::instance()->config(); 618 return KABPrefs::instance()->config();
585#else //KAB_EMBEDDED 619#else //KAB_EMBEDDED
586 return KABPrefs::instance()->getConfig(); 620 return KABPrefs::instance()->getConfig();
587#endif //KAB_EMBEDDED 621#endif //KAB_EMBEDDED
588} 622}
589 623
590KActionCollection *KABCore::actionCollection() const 624KActionCollection *KABCore::actionCollection() const
591{ 625{
592 return mGUIClient->actionCollection(); 626 return mGUIClient->actionCollection();
593} 627}
594 628
595KABC::Field *KABCore::currentSearchField() const 629KABC::Field *KABCore::currentSearchField() const
596{ 630{
597 if (mIncSearchWidget) 631 if (mIncSearchWidget)
598 return mIncSearchWidget->currentField(); 632 return mIncSearchWidget->currentField();
599 else 633 else
600 return 0; 634 return 0;
601} 635}
602 636
603QStringList KABCore::selectedUIDs() const 637QStringList KABCore::selectedUIDs() const
604{ 638{
605 return mViewManager->selectedUids(); 639 return mViewManager->selectedUids();
606} 640}
607 641
608KABC::Resource *KABCore::requestResource( QWidget *parent ) 642KABC::Resource *KABCore::requestResource( QWidget *parent )
609{ 643{
610 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 644 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
611 645
612 QPtrList<KRES::Resource> kresResources; 646 QPtrList<KRES::Resource> kresResources;
613 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 647 QPtrListIterator<KABC::Resource> resIt( kabcResources );
614 KABC::Resource *resource; 648 KABC::Resource *resource;
615 while ( ( resource = resIt.current() ) != 0 ) { 649 while ( ( resource = resIt.current() ) != 0 ) {
616 ++resIt; 650 ++resIt;
617 if ( !resource->readOnly() ) { 651 if ( !resource->readOnly() ) {
618 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 652 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
619 if ( res ) 653 if ( res )
620 kresResources.append( res ); 654 kresResources.append( res );
621 } 655 }
622 } 656 }
623 657
624 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 658 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
625 return static_cast<KABC::Resource*>( res ); 659 return static_cast<KABC::Resource*>( res );
626} 660}
627 661
628#ifndef KAB_EMBEDDED 662#ifndef KAB_EMBEDDED
629KAboutData *KABCore::createAboutData() 663KAboutData *KABCore::createAboutData()
630#else //KAB_EMBEDDED 664#else //KAB_EMBEDDED
631void KABCore::createAboutData() 665void KABCore::createAboutData()
632#endif //KAB_EMBEDDED 666#endif //KAB_EMBEDDED
633{ 667{
634 668
635 669
636 QString version; 670 QString version;
637#include <../version> 671#include <../version>
638 QMessageBox::about( this, "About KAddressbook/Pi", 672 QMessageBox::about( this, "About KAddressbook/Pi",
639 "KAddressbook/Platform-independent\n" 673 "KAddressbook/Platform-independent\n"
640 "(KA/Pi) " +version + " - " + 674 "(KA/Pi) " +version + " - " +
641#ifdef DESKTOP_VERSION 675#ifdef DESKTOP_VERSION
642 "Desktop Edition\n" 676 "Desktop Edition\n"
643#else 677#else
644 "PDA-Edition\n" 678 "PDA-Edition\n"
645 "for: Zaurus 5500 / 7x0 / 8x0\n" 679 "for: Zaurus 5500 / 7x0 / 8x0\n"
646#endif 680#endif
647 681
648 "(c) 2004 Ulf Schenk\n" 682 "(c) 2004 Ulf Schenk\n"
649 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n" 683 "(c) 2004-2005 Lutz Rogowski\nrogowski@kde.org\n"
650 "(c) 1997-2003, The KDE PIM Team\n" 684 "(c) 1997-2003, The KDE PIM Team\n"
651 "Tobias Koenig Maintainer\n" 685 "Tobias Koenig Maintainer\n"
652 "Don Sanders Original author\n" 686 "Don Sanders Original author\n"
653 "Cornelius Schumacher Co-maintainer\n" 687 "Cornelius Schumacher Co-maintainer\n"
654 "Mike Pilone GUI and framework redesign\n" 688 "Mike Pilone GUI and framework redesign\n"
655 "Greg Stern DCOP interface\n" 689 "Greg Stern DCOP interface\n"
656 "Mark Westcot Contact pinning\n" 690 "Mark Westcot Contact pinning\n"
657 "Michel Boyer de la Giroday LDAP Lookup\n" 691 "Michel Boyer de la Giroday LDAP Lookup\n"
658 "Steffen Hansen LDAP Lookup" 692 "Steffen Hansen LDAP Lookup"
659#ifdef _WIN32_ 693#ifdef _WIN32_
660 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 694 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
661#endif 695#endif
662 ); 696 );
663} 697}
664 698
665void KABCore::setContactSelected( const QString &uid ) 699void KABCore::setContactSelected( const QString &uid )
666{ 700{
667 KABC::Addressee addr = mAddressBook->findByUid( uid ); 701 KABC::Addressee addr = mAddressBook->findByUid( uid );
668 if ( !mDetails->isHidden() ) 702 if ( !mDetails->isHidden() )
669 mDetails->setAddressee( addr ); 703 mDetails->setAddressee( addr );
670 704
671 if ( !addr.isEmpty() ) { 705 if ( !addr.isEmpty() ) {
672 emit contactSelected( addr.formattedName() ); 706 emit contactSelected( addr.formattedName() );
673 KABC::Picture pic = addr.photo(); 707 KABC::Picture pic = addr.photo();
674 if ( pic.isIntern() ) { 708 if ( pic.isIntern() ) {
675//US emit contactSelected( pic.data() ); 709//US emit contactSelected( pic.data() );
676//US instead use: 710//US instead use:
677 QPixmap px; 711 QPixmap px;
678 if (pic.data().isNull() != true) 712 if (pic.data().isNull() != true)
679 { 713 {
680 px.convertFromImage(pic.data()); 714 px.convertFromImage(pic.data());
681 } 715 }
682 716
683 emit contactSelected( px ); 717 emit contactSelected( px );
684 } 718 }
685 } 719 }
686 720
687 721
688 mExtensionManager->setSelectionChanged(); 722 mExtensionManager->setSelectionChanged();
689 723
690 // update the actions 724 // update the actions
691 bool selected = !uid.isEmpty(); 725 bool selected = !uid.isEmpty();
692 726
693 if ( mReadWrite ) { 727 if ( mReadWrite ) {
694 mActionCut->setEnabled( selected ); 728 mActionCut->setEnabled( selected );
695 mActionPaste->setEnabled( selected ); 729 mActionPaste->setEnabled( selected );
696 } 730 }
697 731
698 mActionCopy->setEnabled( selected ); 732 mActionCopy->setEnabled( selected );
699 mActionDelete->setEnabled( selected ); 733 mActionDelete->setEnabled( selected );
700 mActionEditAddressee->setEnabled( selected ); 734 mActionEditAddressee->setEnabled( selected );
701 mActionMail->setEnabled( selected ); 735 mActionMail->setEnabled( selected );
702 mActionMailVCard->setEnabled( selected ); 736 mActionMailVCard->setEnabled( selected );
703 //if (mActionBeam) 737 //if (mActionBeam)
704 //mActionBeam->setEnabled( selected ); 738 //mActionBeam->setEnabled( selected );
705 mActionWhoAmI->setEnabled( selected ); 739 mActionWhoAmI->setEnabled( selected );
706} 740}
707 741
708void KABCore::sendMail() 742void KABCore::sendMail()
709{ 743{
710 sendMail( mViewManager->selectedEmails().join( ", " ) ); 744 sendMail( mViewManager->selectedEmails().join( ", " ) );
711} 745}
712 746
713void KABCore::sendMail( const QString& emaillist ) 747void KABCore::sendMail( const QString& emaillist )
714{ 748{
715 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 749 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
716 if (emaillist.contains(",") > 0) 750 if (emaillist.contains(",") > 0)
717 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 751 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
718 else 752 else
719 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 753 ExternalAppHandler::instance()->mailToOneContact( emaillist );
720} 754}
721 755
722 756
723 757
724void KABCore::mailVCard() 758void KABCore::mailVCard()
725{ 759{
726 QStringList uids = mViewManager->selectedUids(); 760 QStringList uids = mViewManager->selectedUids();
727 if ( !uids.isEmpty() ) 761 if ( !uids.isEmpty() )
728 mailVCard( uids ); 762 mailVCard( uids );
729} 763}
730 764
731void KABCore::mailVCard( const QStringList& uids ) 765void KABCore::mailVCard( const QStringList& uids )
732{ 766{
733 QStringList urls; 767 QStringList urls;
734 768
735// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 769// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
736 770
737 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 771 QString dirName = "/tmp/" + KApplication::randomString( 8 );
738 772
739 773
740 774
741 QDir().mkdir( dirName, true ); 775 QDir().mkdir( dirName, true );
742 776
743 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 777 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
744 KABC::Addressee a = mAddressBook->findByUid( *it ); 778 KABC::Addressee a = mAddressBook->findByUid( *it );
745 779
746 if ( a.isEmpty() ) 780 if ( a.isEmpty() )
747 continue; 781 continue;
748 782
749 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 783 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
750 784
751 QString fileName = dirName + "/" + name; 785 QString fileName = dirName + "/" + name;
752 786
753 QFile outFile(fileName); 787 QFile outFile(fileName);
754 788
755 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 789 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
756 KABC::VCardConverter converter; 790 KABC::VCardConverter converter;
757 QString vcard; 791 QString vcard;
758 792
759 converter.addresseeToVCard( a, vcard ); 793 converter.addresseeToVCard( a, vcard );
760 794
761 QTextStream t( &outFile ); // use a text stream 795 QTextStream t( &outFile ); // use a text stream
762 t.setEncoding( QTextStream::UnicodeUTF8 ); 796 t.setEncoding( QTextStream::UnicodeUTF8 );
763 t << vcard; 797 t << vcard;
764 798
765 outFile.close(); 799 outFile.close();
766 800
767 urls.append( fileName ); 801 urls.append( fileName );
768 } 802 }
769 } 803 }
770 804
771 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 805 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
772 806
773 807
774/*US 808/*US
775 kapp->invokeMailer( QString::null, QString::null, QString::null, 809 kapp->invokeMailer( QString::null, QString::null, QString::null,
776 QString::null, // subject 810 QString::null, // subject
777 QString::null, // body 811 QString::null, // body
778 QString::null, 812 QString::null,
779 urls ); // attachments 813 urls ); // attachments
780*/ 814*/
781 815
782} 816}
783 817
784/** 818/**
785 Beams the "WhoAmI contact. 819 Beams the "WhoAmI contact.
786*/ 820*/
787void KABCore::beamMySelf() 821void KABCore::beamMySelf()
788{ 822{
789 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 823 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
790 if (!a.isEmpty()) 824 if (!a.isEmpty())
791 { 825 {
792 QStringList uids; 826 QStringList uids;
793 uids << a.uid(); 827 uids << a.uid();
794 828
795 beamVCard(uids); 829 beamVCard(uids);
796 } else { 830 } else {
797 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 831 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
798 832
799 833
800 } 834 }
801} 835}
802void KABCore::updateMainWindow() 836void KABCore::updateMainWindow()
803{ 837{
804 mMainWindow->showMaximized(); 838 mMainWindow->showMaximized();
805 mMainWindow->update(); 839 mMainWindow->update();
806} 840}
807void KABCore::resizeEvent(QResizeEvent* e ) 841void KABCore::resizeEvent(QResizeEvent* e )
808{ 842{
809 if ( !mMiniSplitter ) 843 if ( !mMiniSplitter )
810 return; 844 return;
811 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 845 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
812 if ( QApplication::desktop()->width() >= 480 ) { 846 if ( QApplication::desktop()->width() >= 480 ) {
813 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 847 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
814 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 848 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
815 mMiniSplitter->setOrientation( Qt::Horizontal); 849 mMiniSplitter->setOrientation( Qt::Horizontal);
816 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 850 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
817 } 851 }
818 if ( QApplication::desktop()->width() <= 640 ) { 852 if ( QApplication::desktop()->width() <= 640 ) {
819 mMainWindow->showMinimized(); 853 mMainWindow->showMinimized();
820 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 854 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
821 mViewManager->getFilterAction()->setComboWidth( 150 ); 855 mViewManager->getFilterAction()->setComboWidth( 150 );
822 if ( mIncSearchWidget ) 856 if ( mIncSearchWidget )
823 mIncSearchWidget->setSize(); 857 mIncSearchWidget->setSize();
824 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 858 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
825 } 859 }
826 860
827 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 861 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
828 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 862 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
829 mMiniSplitter->setOrientation( Qt::Vertical ); 863 mMiniSplitter->setOrientation( Qt::Vertical );
830 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 864 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
831 } 865 }
832 if ( QApplication::desktop()->width() <= 640 ) { 866 if ( QApplication::desktop()->width() <= 640 ) {
833 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 867 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
834 mMainWindow->showMinimized(); 868 mMainWindow->showMinimized();
835 if ( KABPrefs::instance()->mHideSearchOnSwitch ) { 869 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
836 if ( mIncSearchWidget ) { 870 if ( mIncSearchWidget ) {
837 mIncSearchWidget->setSize(); 871 mIncSearchWidget->setSize();
838 } 872 }
839 } else { 873 } else {
840 mViewManager->getFilterAction()->setComboWidth( 0 ); 874 mViewManager->getFilterAction()->setComboWidth( 0 );
841 } 875 }
842 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 876 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
843 } 877 }
844 } 878 }
845 } 879 }
846 QWidget::resizeEvent( e ); 880 QWidget::resizeEvent( e );
847 881
848} 882}
849void KABCore::export2phone() 883void KABCore::export2phone()
850{ 884{
851 885
852 QStringList uids; 886 QStringList uids;
853 XXPortSelectDialog dlg( this, false, this ); 887 XXPortSelectDialog dlg( this, false, this );
854 if ( dlg.exec() ) 888 if ( dlg.exec() )
855 uids = dlg.uids(); 889 uids = dlg.uids();
856 else 890 else
857 return; 891 return;
858 if ( uids.isEmpty() ) 892 if ( uids.isEmpty() )
859 return; 893 return;
860 // qDebug("count %d ", uids.count()); 894 // qDebug("count %d ", uids.count());
861 895
862 KAex2phonePrefs ex2phone; 896 KAex2phonePrefs ex2phone;
863 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 897 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
864 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 898 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
865 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 899 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
866 900
867 if ( !ex2phone.exec() ) { 901 if ( !ex2phone.exec() ) {
868 return; 902 return;
869 } 903 }
870 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 904 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
871 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 905 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
872 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 906 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
873 907
874 908
875 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 909 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
876 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 910 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
877 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 911 KPimGlobalPrefs::instance()->mEx2PhoneModel );
878 912
879 QString fileName = getPhoneFile(); 913 QString fileName = getPhoneFile();
880 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 914 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
881 return; 915 return;
882 916
883 message(i18n("Exporting to phone...")); 917 message(i18n("Exporting to phone..."));
884 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 918 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
885 919
886} 920}
887QString KABCore::getPhoneFile() 921QString KABCore::getPhoneFile()
888{ 922{
889#ifdef DESKTOP_VERSION 923#ifdef DESKTOP_VERSION
890 return locateLocal("tmp", "phonefile.vcf"); 924 return locateLocal("tmp", "phonefile.vcf");
891#else 925#else
892 return "/tmp/phonefile.vcf"; 926 return "/tmp/phonefile.vcf";
893#endif 927#endif
894 928
895} 929}
896void KABCore::writeToPhone( ) 930void KABCore::writeToPhone( )
897{ 931{
898 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 932 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
899 message(i18n("Export to phone finished!")); 933 message(i18n("Export to phone finished!"));
900 else 934 else
901 qDebug(i18n("KA: Error exporting to phone")); 935 qDebug(i18n("KA: Error exporting to phone"));
902} 936}
903void KABCore::beamVCard() 937void KABCore::beamVCard()
904{ 938{
905 QStringList uids; 939 QStringList uids;
906 XXPortSelectDialog dlg( this, false, this ); 940 XXPortSelectDialog dlg( this, false, this );
907 if ( dlg.exec() ) 941 if ( dlg.exec() )
908 uids = dlg.uids(); 942 uids = dlg.uids();
909 else 943 else
910 return; 944 return;
911 if ( uids.isEmpty() ) 945 if ( uids.isEmpty() )
912 return; 946 return;
913 beamVCard( uids ); 947 beamVCard( uids );
914} 948}
915 949
916 950
917void KABCore::beamVCard(const QStringList& uids) 951void KABCore::beamVCard(const QStringList& uids)
918{ 952{
919 953
920 // LR: we should use the /tmp dir on the Zaurus, 954 // LR: we should use the /tmp dir on the Zaurus,
921 // because: /tmp = RAM, (HOME)/kdepim = flash memory 955 // because: /tmp = RAM, (HOME)/kdepim = flash memory
922 956
923#ifdef DESKTOP_VERSION 957#ifdef DESKTOP_VERSION
924 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 958 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
925#else 959#else
926 QString fileName = "/tmp/kapibeamfile.vcf"; 960 QString fileName = "/tmp/kapibeamfile.vcf";
927#endif 961#endif
928 962
929 KABC::VCardConverter converter; 963 KABC::VCardConverter converter;
930 QString description; 964 QString description;
931 QString datastream; 965 QString datastream;
932 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 966 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
933 KABC::Addressee a = mAddressBook->findByUid( *it ); 967 KABC::Addressee a = mAddressBook->findByUid( *it );
934 968
935 if ( a.isEmpty() ) 969 if ( a.isEmpty() )
936 continue; 970 continue;
937 971
938 if (description.isEmpty()) 972 if (description.isEmpty())
939 description = a.formattedName(); 973 description = a.formattedName();
940 974
941 QString vcard; 975 QString vcard;
942 converter.addresseeToVCard( a, vcard ); 976 converter.addresseeToVCard( a, vcard );
943 int start = 0; 977 int start = 0;
944 int next; 978 int next;
945 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 979 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
946 int semi = vcard.find(";", next); 980 int semi = vcard.find(";", next);
947 int dopp = vcard.find(":", next); 981 int dopp = vcard.find(":", next);
948 int sep; 982 int sep;
949 if ( semi < dopp && semi >= 0 ) 983 if ( semi < dopp && semi >= 0 )
950 sep = semi ; 984 sep = semi ;
951 else 985 else
952 sep = dopp; 986 sep = dopp;
953 datastream +=vcard.mid( start, next - start); 987 datastream +=vcard.mid( start, next - start);
954 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 988 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
955 start = sep; 989 start = sep;
956 } 990 }
957 datastream += vcard.mid( start,vcard.length() ); 991 datastream += vcard.mid( start,vcard.length() );
958 } 992 }
959#ifndef DESKTOP_VERSION 993#ifndef DESKTOP_VERSION
960 QFile outFile(fileName); 994 QFile outFile(fileName);
961 if ( outFile.open(IO_WriteOnly) ) { 995 if ( outFile.open(IO_WriteOnly) ) {
962 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 996 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
963 QTextStream t( &outFile ); // use a text stream 997 QTextStream t( &outFile ); // use a text stream
964 //t.setEncoding( QTextStream::UnicodeUTF8 ); 998 //t.setEncoding( QTextStream::UnicodeUTF8 );
965 t.setEncoding( QTextStream::Latin1 ); 999 t.setEncoding( QTextStream::Latin1 );
966 t <<datastream.latin1(); 1000 t <<datastream.latin1();
967 outFile.close(); 1001 outFile.close();
968 Ir *ir = new Ir( this ); 1002 Ir *ir = new Ir( this );
969 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 1003 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
970 ir->send( fileName, description, "text/x-vCard" ); 1004 ir->send( fileName, description, "text/x-vCard" );
971 } else { 1005 } else {
972 qDebug("KA: Error open temp beam file "); 1006 qDebug("KA: Error open temp beam file ");
973 return; 1007 return;
974 } 1008 }
975#endif 1009#endif
976 1010
977} 1011}
978 1012
979void KABCore::beamDone( Ir *ir ) 1013void KABCore::beamDone( Ir *ir )
980{ 1014{
981#ifndef DESKTOP_VERSION 1015#ifndef DESKTOP_VERSION
982 delete ir; 1016 delete ir;
983#endif 1017#endif
984 topLevelWidget()->raise(); 1018 topLevelWidget()->raise();
985 message( i18n("Beaming finished!") ); 1019 message( i18n("Beaming finished!") );
986} 1020}
987 1021
988 1022
989void KABCore::browse( const QString& url ) 1023void KABCore::browse( const QString& url )
990{ 1024{
991#ifndef KAB_EMBEDDED 1025#ifndef KAB_EMBEDDED
992 kapp->invokeBrowser( url ); 1026 kapp->invokeBrowser( url );
993#else //KAB_EMBEDDED 1027#else //KAB_EMBEDDED
994 qDebug("KABCore::browse must be fixed"); 1028 qDebug("KABCore::browse must be fixed");
995#endif //KAB_EMBEDDED 1029#endif //KAB_EMBEDDED
996} 1030}
997 1031
998void KABCore::selectAllContacts() 1032void KABCore::selectAllContacts()
999{ 1033{
1000 mViewManager->setSelected( QString::null, true ); 1034 mViewManager->setSelected( QString::null, true );
1001} 1035}
1002 1036
1003void KABCore::deleteContacts() 1037void KABCore::deleteContacts()
1004{ 1038{
1005 QStringList uidList = mViewManager->selectedUids(); 1039 QStringList uidList = mViewManager->selectedUids();
1006 deleteContacts( uidList ); 1040 deleteContacts( uidList );
1007} 1041}
1008 1042
1009void KABCore::deleteContacts( const QStringList &uids ) 1043void KABCore::deleteContacts( const QStringList &uids )
1010{ 1044{
1011 if ( uids.count() > 0 ) { 1045 if ( uids.count() > 0 ) {
1012 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1046 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
1013 UndoStack::instance()->push( command ); 1047 UndoStack::instance()->push( command );
1014 RedoStack::instance()->clear(); 1048 RedoStack::instance()->clear();
1015 1049
1016 // now if we deleted anything, refresh 1050 // now if we deleted anything, refresh
1017 setContactSelected( QString::null ); 1051 setContactSelected( QString::null );
1018 setModified( true ); 1052 setModified( true );
1019 } 1053 }
1020} 1054}
1021 1055
1022void KABCore::copyContacts() 1056void KABCore::copyContacts()
1023{ 1057{
1024 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1058 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1025 1059
1026 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1060 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
1027 1061
1028 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1062 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
1029 1063
1030 QClipboard *cb = QApplication::clipboard(); 1064 QClipboard *cb = QApplication::clipboard();
1031 cb->setText( clipText ); 1065 cb->setText( clipText );
1032} 1066}
1033 1067
1034void KABCore::cutContacts() 1068void KABCore::cutContacts()
1035{ 1069{
1036 QStringList uidList = mViewManager->selectedUids(); 1070 QStringList uidList = mViewManager->selectedUids();
1037 1071
1038//US if ( uidList.size() > 0 ) { 1072//US if ( uidList.size() > 0 ) {
1039 if ( uidList.count() > 0 ) { 1073 if ( uidList.count() > 0 ) {
1040 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1074 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1041 UndoStack::instance()->push( command ); 1075 UndoStack::instance()->push( command );
1042 RedoStack::instance()->clear(); 1076 RedoStack::instance()->clear();
1043 1077
1044 setModified( true ); 1078 setModified( true );
1045 } 1079 }
1046} 1080}
1047 1081
1048void KABCore::pasteContacts() 1082void KABCore::pasteContacts()
1049{ 1083{
1050 QClipboard *cb = QApplication::clipboard(); 1084 QClipboard *cb = QApplication::clipboard();
1051 1085
1052 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1086 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1053 1087
1054 pasteContacts( list ); 1088 pasteContacts( list );
1055} 1089}
1056 1090
1057void KABCore::pasteContacts( KABC::Addressee::List &list ) 1091void KABCore::pasteContacts( KABC::Addressee::List &list )
1058{ 1092{
1059 KABC::Resource *resource = requestResource( this ); 1093 KABC::Resource *resource = requestResource( this );
1060 KABC::Addressee::List::Iterator it; 1094 KABC::Addressee::List::Iterator it;
1061 for ( it = list.begin(); it != list.end(); ++it ) 1095 for ( it = list.begin(); it != list.end(); ++it )
1062 (*it).setResource( resource ); 1096 (*it).setResource( resource );
1063 1097
1064 PwPasteCommand *command = new PwPasteCommand( this, list ); 1098 PwPasteCommand *command = new PwPasteCommand( this, list );
1065 UndoStack::instance()->push( command ); 1099 UndoStack::instance()->push( command );
1066 RedoStack::instance()->clear(); 1100 RedoStack::instance()->clear();
1067 1101
1068 setModified( true ); 1102 setModified( true );
1069} 1103}
1070 1104
1071void KABCore::setWhoAmI() 1105void KABCore::setWhoAmI()
1072{ 1106{
1073 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1107 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1074 1108
1075 if ( addrList.count() > 1 ) { 1109 if ( addrList.count() > 1 ) {
1076 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1110 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1077 return; 1111 return;
1078 } 1112 }
1079 1113
1080 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1114 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1081 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1115 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1082 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1116 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1083} 1117}
1084void KABCore::editCategories() 1118void KABCore::editCategories()
1085{ 1119{
1086 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1120 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1087 dlg.exec(); 1121 dlg.exec();
1088} 1122}
1089void KABCore::setCategories() 1123void KABCore::setCategories()
1090{ 1124{
1091 1125
1092 QStringList uids; 1126 QStringList uids;
1093 XXPortSelectDialog dlgx( this, false, this ); 1127 XXPortSelectDialog dlgx( this, false, this );
1094 if ( dlgx.exec() ) 1128 if ( dlgx.exec() )
1095 uids = dlgx.uids(); 1129 uids = dlgx.uids();
1096 else 1130 else
1097 return; 1131 return;
1098 if ( uids.isEmpty() ) 1132 if ( uids.isEmpty() )
1099 return; 1133 return;
1100 // qDebug("count %d ", uids.count()); 1134 // qDebug("count %d ", uids.count());
1101 1135
1102 1136
1103 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1137 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1104 if ( !dlg.exec() ) { 1138 if ( !dlg.exec() ) {
1105 message( i18n("Setting categories cancelled") ); 1139 message( i18n("Setting categories cancelled") );
1106 return; 1140 return;
1107 } 1141 }
1108 bool merge = false; 1142 bool merge = false;
1109 QString msg = i18n( "Merge with existing categories?" ); 1143 QString msg = i18n( "Merge with existing categories?" );
1110 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1144 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1111 merge = true; 1145 merge = true;
1112 1146
1113 message( i18n("Setting categories ... please wait!") ); 1147 message( i18n("Setting categories ... please wait!") );
1114 QStringList categories = dlg.selectedCategories(); 1148 QStringList categories = dlg.selectedCategories();
1115 1149
1116 //QStringList uids = mViewManager->selectedUids(); 1150 //QStringList uids = mViewManager->selectedUids();
1117 QStringList::Iterator it; 1151 QStringList::Iterator it;
1118 for ( it = uids.begin(); it != uids.end(); ++it ) { 1152 for ( it = uids.begin(); it != uids.end(); ++it ) {
1119 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1153 KABC::Addressee addr = mAddressBook->findByUid( *it );
1120 if ( !addr.isEmpty() ) { 1154 if ( !addr.isEmpty() ) {
1121 if ( !merge ) 1155 if ( !merge )
1122 addr.setCategories( categories ); 1156 addr.setCategories( categories );
1123 else { 1157 else {
1124 QStringList addrCategories = addr.categories(); 1158 QStringList addrCategories = addr.categories();
1125 QStringList::Iterator catIt; 1159 QStringList::Iterator catIt;
1126 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1160 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1127 if ( !addrCategories.contains( *catIt ) ) 1161 if ( !addrCategories.contains( *catIt ) )
1128 addrCategories.append( *catIt ); 1162 addrCategories.append( *catIt );
1129 } 1163 }
1130 addr.setCategories( addrCategories ); 1164 addr.setCategories( addrCategories );
1131 } 1165 }
1132 mAddressBook->insertAddressee( addr ); 1166 mAddressBook->insertAddressee( addr );
1133 } 1167 }
1134 } 1168 }
1135 1169
1136 if ( uids.count() > 0 ) 1170 if ( uids.count() > 0 )
1137 setModified( true ); 1171 setModified( true );
1138 message( i18n("Setting categories completed!") ); 1172 message( i18n("Setting categories completed!") );
1139} 1173}
1140 1174
1141void KABCore::setSearchFields( const KABC::Field::List &fields ) 1175void KABCore::setSearchFields( const KABC::Field::List &fields )
1142{ 1176{
1143 mIncSearchWidget->setFields( fields ); 1177 mIncSearchWidget->setFields( fields );
1144} 1178}
1145 1179
1146void KABCore::incrementalSearch( const QString& text ) 1180void KABCore::incrementalSearch( const QString& text )
1147{ 1181{
1148 QString stext; 1182 QString stext;
1149 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) { 1183 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1150 stext = "*" + text; 1184 stext = "*" + text;
1151 } else { 1185 } else {
1152 stext = text; 1186 stext = text;
1153 } 1187 }
1154 mViewManager->doSearch( stext, mIncSearchWidget->currentField() ); 1188 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1155} 1189}
1156void KABCore::incrementalSearchJump( const QString& text ) 1190void KABCore::incrementalSearchJump( const QString& text )
1157{ 1191{
1158 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1192 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1159} 1193}
1160 1194
1161void KABCore::setModified() 1195void KABCore::setModified()
1162{ 1196{
1163 setModified( true ); 1197 setModified( true );
1164} 1198}
1165 1199
1166void KABCore::setModifiedWOrefresh() 1200void KABCore::setModifiedWOrefresh()
1167{ 1201{
1168 // qDebug("KABCore::setModifiedWOrefresh() "); 1202 // qDebug("KABCore::setModifiedWOrefresh() ");
1169 mModified = true; 1203 mModified = true;
1170 mActionSave->setEnabled( mModified ); 1204 mActionSave->setEnabled( mModified );
1171 1205
1172 1206
1173} 1207}
1174void KABCore::setModified( bool modified ) 1208void KABCore::setModified( bool modified )
1175{ 1209{
1176 mModified = modified; 1210 mModified = modified;
1177 mActionSave->setEnabled( mModified ); 1211 mActionSave->setEnabled( mModified );
1178 1212
1179 if ( modified ) 1213 if ( modified )
1180 mJumpButtonBar->recreateButtons(); 1214 mJumpButtonBar->recreateButtons();
1181 1215
1182 mViewManager->refreshView(); 1216 mViewManager->refreshView();
1183 1217
1184} 1218}
1185 1219
1186bool KABCore::modified() const 1220bool KABCore::modified() const
1187{ 1221{
1188 return mModified; 1222 return mModified;
1189} 1223}
1190 1224
1191void KABCore::contactModified( const KABC::Addressee &addr ) 1225void KABCore::contactModified( const KABC::Addressee &addr )
1192{ 1226{
1193 addrModified( addr ); 1227 addrModified( addr );
1194#if 0 // debug only 1228#if 0 // debug only
1195 KABC::Addressee ad = addr; 1229 KABC::Addressee ad = addr;
1196 ad.computeCsum( "123"); 1230 ad.computeCsum( "123");
1197#endif 1231#endif
1198} 1232}
1199 1233
1200void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1234void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1201{ 1235{
1202 1236
1203 Command *command = 0; 1237 Command *command = 0;
1204 QString uid; 1238 QString uid;
1205 1239
1206 // check if it exists already 1240 // check if it exists already
1207 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1241 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1208 if ( origAddr.isEmpty() ) 1242 if ( origAddr.isEmpty() )
1209 command = new PwNewCommand( mAddressBook, addr ); 1243 command = new PwNewCommand( mAddressBook, addr );
1210 else { 1244 else {
1211 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1245 command = new PwEditCommand( mAddressBook, origAddr, addr );
1212 uid = addr.uid(); 1246 uid = addr.uid();
1213 } 1247 }
1214 1248
1215 UndoStack::instance()->push( command ); 1249 UndoStack::instance()->push( command );
1216 RedoStack::instance()->clear(); 1250 RedoStack::instance()->clear();
1217 if ( updateDetails ) 1251 if ( updateDetails )
1218 mDetails->setAddressee( addr ); 1252 mDetails->setAddressee( addr );
1219 setModified( true ); 1253 setModified( true );
1220} 1254}
1221 1255
1222void KABCore::newContact() 1256void KABCore::newContact()
1223{ 1257{
1224 1258
1225 1259
1226 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1260 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1227 1261
1228 QPtrList<KRES::Resource> kresResources; 1262 QPtrList<KRES::Resource> kresResources;
1229 QPtrListIterator<KABC::Resource> it( kabcResources ); 1263 QPtrListIterator<KABC::Resource> it( kabcResources );
1230 KABC::Resource *resource; 1264 KABC::Resource *resource;
1231 while ( ( resource = it.current() ) != 0 ) { 1265 while ( ( resource = it.current() ) != 0 ) {
1232 ++it; 1266 ++it;
1233 if ( !resource->readOnly() ) { 1267 if ( !resource->readOnly() ) {
1234 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1268 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1235 if ( res ) 1269 if ( res )
1236 kresResources.append( res ); 1270 kresResources.append( res );
1237 } 1271 }
1238 } 1272 }
1239 1273
1240 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1274 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1241 resource = static_cast<KABC::Resource*>( res ); 1275 resource = static_cast<KABC::Resource*>( res );
1242 1276
1243 if ( resource ) { 1277 if ( resource ) {
1244 KABC::Addressee addr; 1278 KABC::Addressee addr;
1245 addr.setResource( resource ); 1279 addr.setResource( resource );
1246 mEditorDialog->setAddressee( addr ); 1280 mEditorDialog->setAddressee( addr );
1247 mEditorDialog->setCaption( i18n("Edit new contact")); 1281 mEditorDialog->setCaption( i18n("Edit new contact"));
1248 KApplication::execDialog ( mEditorDialog ); 1282 KApplication::execDialog ( mEditorDialog );
1249 1283
1250 } else 1284 } else
1251 return; 1285 return;
1252 1286
1253 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1287 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1254 1288
1255 1289
1256} 1290}
1257 1291
1258void KABCore::addEmail( QString aStr ) 1292void KABCore::addEmail( QString aStr )
1259{ 1293{
1260#ifndef KAB_EMBEDDED 1294#ifndef KAB_EMBEDDED
1261 QString fullName, email; 1295 QString fullName, email;
1262 1296
1263 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1297 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1264 1298
1265 // Try to lookup the addressee matching the email address 1299 // Try to lookup the addressee matching the email address
1266 bool found = false; 1300 bool found = false;
1267 QStringList emailList; 1301 QStringList emailList;
1268 KABC::AddressBook::Iterator it; 1302 KABC::AddressBook::Iterator it;
1269 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1303 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1270 emailList = (*it).emails(); 1304 emailList = (*it).emails();
1271 if ( emailList.contains( email ) > 0 ) { 1305 if ( emailList.contains( email ) > 0 ) {
1272 found = true; 1306 found = true;
1273 (*it).setNameFromString( fullName ); 1307 (*it).setNameFromString( fullName );
1274 editContact( (*it).uid() ); 1308 editContact( (*it).uid() );
1275 } 1309 }
1276 } 1310 }
1277 1311
1278 if ( !found ) { 1312 if ( !found ) {
1279 KABC::Addressee addr; 1313 KABC::Addressee addr;
1280 addr.setNameFromString( fullName ); 1314 addr.setNameFromString( fullName );
1281 addr.insertEmail( email, true ); 1315 addr.insertEmail( email, true );
1282 1316
1283 mAddressBook->insertAddressee( addr ); 1317 mAddressBook->insertAddressee( addr );
1284 mViewManager->refreshView( addr.uid() ); 1318 mViewManager->refreshView( addr.uid() );
1285 editContact( addr.uid() ); 1319 editContact( addr.uid() );
1286 } 1320 }
1287#else //KAB_EMBEDDED 1321#else //KAB_EMBEDDED
1288 qDebug("KABCore::addEmail finsih method"); 1322 qDebug("KABCore::addEmail finsih method");
1289#endif //KAB_EMBEDDED 1323#endif //KAB_EMBEDDED
1290} 1324}
1291 1325
1292void KABCore::importVCard( const KURL &url, bool showPreview ) 1326void KABCore::importVCard( const KURL &url, bool showPreview )
1293{ 1327{
1294 mXXPortManager->importVCard( url, showPreview ); 1328 mXXPortManager->importVCard( url, showPreview );
1295} 1329}
1296void KABCore::importFromOL() 1330void KABCore::importFromOL()
1297{ 1331{
1298#ifdef _OL_IMPORT_ 1332#ifdef _OL_IMPORT_
1299 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1333 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1300 idgl->exec(); 1334 idgl->exec();
1301 KABC::Addressee::List list = idgl->getAddressList(); 1335 KABC::Addressee::List list = idgl->getAddressList();
1302 if ( list.count() > 0 ) { 1336 if ( list.count() > 0 ) {
1303 KABC::Addressee::List listNew; 1337 KABC::Addressee::List listNew;
1304 KABC::Addressee::List listExisting; 1338 KABC::Addressee::List listExisting;
1305 KABC::Addressee::List::Iterator it; 1339 KABC::Addressee::List::Iterator it;
1306 KABC::AddressBook::Iterator iter; 1340 KABC::AddressBook::Iterator iter;
1307 for ( it = list.begin(); it != list.end(); ++it ) { 1341 for ( it = list.begin(); it != list.end(); ++it ) {
1308 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1342 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1309 listNew.append( (*it) ); 1343 listNew.append( (*it) );
1310 else 1344 else
1311 listExisting.append( (*it) ); 1345 listExisting.append( (*it) );
1312 } 1346 }
1313 if ( listExisting.count() > 0 ) 1347 if ( listExisting.count() > 0 )
1314 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1348 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1315 if ( listNew.count() > 0 ) { 1349 if ( listNew.count() > 0 ) {
1316 pasteWithNewUid = false; 1350 pasteWithNewUid = false;
1317 pasteContacts( listNew ); 1351 pasteContacts( listNew );
1318 pasteWithNewUid = true; 1352 pasteWithNewUid = true;
1319 } 1353 }
1320 } 1354 }
1321 delete idgl; 1355 delete idgl;
1322#endif 1356#endif
1323} 1357}
1324 1358
1325void KABCore::importVCard( const QString &vCard, bool showPreview ) 1359void KABCore::importVCard( const QString &vCard, bool showPreview )
1326{ 1360{
1327 mXXPortManager->importVCard( vCard, showPreview ); 1361 mXXPortManager->importVCard( vCard, showPreview );
1328} 1362}
1329 1363
1330//US added a second method without defaultparameter 1364//US added a second method without defaultparameter
1331void KABCore::editContact2() { 1365void KABCore::editContact2() {
1332 editContact( QString::null ); 1366 editContact( QString::null );
1333} 1367}
1334 1368
1335void KABCore::editContact( const QString &uid ) 1369void KABCore::editContact( const QString &uid )
1336{ 1370{
1337 1371
1338 if ( mExtensionManager->isQuickEditVisible() ) 1372 if ( mExtensionManager->isQuickEditVisible() )
1339 return; 1373 return;
1340 1374
1341 // First, locate the contact entry 1375 // First, locate the contact entry
1342 QString localUID = uid; 1376 QString localUID = uid;
1343 if ( localUID.isNull() ) { 1377 if ( localUID.isNull() ) {
1344 QStringList uidList = mViewManager->selectedUids(); 1378 QStringList uidList = mViewManager->selectedUids();
1345 if ( uidList.count() > 0 ) 1379 if ( uidList.count() > 0 )
1346 localUID = *( uidList.at( 0 ) ); 1380 localUID = *( uidList.at( 0 ) );
1347 } 1381 }
1348 1382
1349 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1383 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1350 if ( !addr.isEmpty() ) { 1384 if ( !addr.isEmpty() ) {
1351 mEditorDialog->setAddressee( addr ); 1385 mEditorDialog->setAddressee( addr );
1352 KApplication::execDialog ( mEditorDialog ); 1386 KApplication::execDialog ( mEditorDialog );
1353 } 1387 }
1354} 1388}
1355 1389
1356/** 1390/**
1357 Shows or edits the detail view for the given uid. If the uid is QString::null, 1391 Shows or edits the detail view for the given uid. If the uid is QString::null,
1358 the method will try to find a selected addressee in the view. 1392 the method will try to find a selected addressee in the view.
1359 */ 1393 */
1360void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1394void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1361{ 1395{
1362 if ( mMultipleViewsAtOnce ) 1396 if ( mMultipleViewsAtOnce )
1363 { 1397 {
1364 editContact( uid ); 1398 editContact( uid );
1365 } 1399 }
1366 else 1400 else
1367 { 1401 {
1368 setDetailsVisible( true ); 1402 setDetailsVisible( true );
1369 mActionDetails->setChecked(true); 1403 mActionDetails->setChecked(true);
1370 } 1404 }
1371 1405
1372} 1406}
1373 1407
1374void KABCore::save() 1408void KABCore::save()
1375{ 1409{
1376 if (syncManager->blockSave()) 1410 if (syncManager->blockSave())
1377 return; 1411 return;
1378 if ( !mModified ) 1412 if ( !mModified )
1379 return; 1413 return;
1380 1414
1381 syncManager->setBlockSave(true); 1415 syncManager->setBlockSave(true);
1382 QString text = i18n( "There was an error while attempting to save\n the " 1416 QString text = i18n( "There was an error while attempting to save\n the "
1383 "address book. Please check that some \nother application is " 1417 "address book. Please check that some \nother application is "
1384 "not using it. " ); 1418 "not using it. " );
1385 message(i18n("Saving ... please wait! "), false); 1419 message(i18n("Saving ... please wait! "), false);
1386 //qApp->processEvents(); 1420 //qApp->processEvents();
1387#ifndef KAB_EMBEDDED 1421#ifndef KAB_EMBEDDED
1388 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1422 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1389 if ( !b || !b->save() ) { 1423 if ( !b || !b->save() ) {
1390 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1424 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1391 } 1425 }
1392#else //KAB_EMBEDDED 1426#else //KAB_EMBEDDED
1393 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1427 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1394 if ( !b || !b->save() ) { 1428 if ( !b || !b->save() ) {
1395 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1429 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1396 } 1430 }
1397#endif //KAB_EMBEDDED 1431#endif //KAB_EMBEDDED
1398 1432
1399 message(i18n("Addressbook saved!")); 1433 message(i18n("Addressbook saved!"));
1400 setModified( false ); 1434 setModified( false );
1401 syncManager->setBlockSave(false); 1435 syncManager->setBlockSave(false);
1402} 1436}
1403 1437
1404 1438
1405void KABCore::undo() 1439void KABCore::undo()
1406{ 1440{
1407 UndoStack::instance()->undo(); 1441 UndoStack::instance()->undo();
1408 1442
1409 // Refresh the view 1443 // Refresh the view
1410 mViewManager->refreshView(); 1444 mViewManager->refreshView();
1411} 1445}
1412 1446
1413void KABCore::redo() 1447void KABCore::redo()
1414{ 1448{
1415 RedoStack::instance()->redo(); 1449 RedoStack::instance()->redo();
1416 1450
1417 // Refresh the view 1451 // Refresh the view
1418 mViewManager->refreshView(); 1452 mViewManager->refreshView();
1419} 1453}
1420void KABCore::setJumpButtonBar( bool visible ) 1454void KABCore::setJumpButtonBar( bool visible )
1421{ 1455{
1422 setJumpButtonBarVisible(visible ); 1456 setJumpButtonBarVisible(visible );
1423 saveSettings(); 1457 saveSettings();
1424} 1458}
1425void KABCore::setJumpButtonBarVisible( bool visible ) 1459void KABCore::setJumpButtonBarVisible( bool visible )
1426{ 1460{
1427 if (mMultipleViewsAtOnce) 1461 if (mMultipleViewsAtOnce)
1428 { 1462 {
1429 if ( visible ) 1463 if ( visible )
1430 mJumpButtonBar->show(); 1464 mJumpButtonBar->show();
1431 else 1465 else
1432 mJumpButtonBar->hide(); 1466 mJumpButtonBar->hide();
1433 } 1467 }
1434 else 1468 else
1435 { 1469 {
1436 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1470 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1437 if (mViewManager->isVisible()) 1471 if (mViewManager->isVisible())
1438 { 1472 {
1439 if ( visible ) 1473 if ( visible )
1440 mJumpButtonBar->show(); 1474 mJumpButtonBar->show();
1441 else 1475 else
1442 mJumpButtonBar->hide(); 1476 mJumpButtonBar->hide();
1443 } 1477 }
1444 else 1478 else
1445 { 1479 {
1446 mJumpButtonBar->hide(); 1480 mJumpButtonBar->hide();
1447 } 1481 }
1448 } 1482 }
1449 if ( visible ) { 1483 if ( visible ) {
1450 if ( mIncSearchWidget->currentItem() == 0 ) { 1484 if ( mIncSearchWidget->currentItem() == 0 ) {
1451 message( i18n("Change search field enable jump bar") ); 1485 message( i18n("Change search field enable jump bar") );
1452 } 1486 }
1453 } 1487 }
1454} 1488}
1455 1489
1456 1490
1457void KABCore::setDetailsToState() 1491void KABCore::setDetailsToState()
1458{ 1492{
1459 setDetailsVisible( mActionDetails->isChecked() ); 1493 setDetailsVisible( mActionDetails->isChecked() );
1460} 1494}
1461void KABCore::setDetailsToggle() 1495void KABCore::setDetailsToggle()
1462{ 1496{
1463 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1497 mActionDetails->setChecked( !mActionDetails->isChecked() );
1464 setDetailsToState(); 1498 setDetailsToState();
1465} 1499}
1466 1500
1467 1501
1468 1502
1469void KABCore::setDetailsVisible( bool visible ) 1503void KABCore::setDetailsVisible( bool visible )
1470{ 1504{
1471 if (visible && mDetails->isHidden()) 1505 if (visible && mDetails->isHidden())
1472 { 1506 {
1473 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1507 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1474 if ( addrList.count() > 0 ) 1508 if ( addrList.count() > 0 )
1475 mDetails->setAddressee( addrList[ 0 ] ); 1509 mDetails->setAddressee( addrList[ 0 ] );
1476 } 1510 }
1477 1511
1478 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1512 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1479 // the listview and the detailview. We do that by changing the splitbar size. 1513 // the listview and the detailview. We do that by changing the splitbar size.
1480 if (mMultipleViewsAtOnce) 1514 if (mMultipleViewsAtOnce)
1481 { 1515 {
1482 if ( visible ) 1516 if ( visible )
1483 mDetails->show(); 1517 mDetails->show();
1484 else 1518 else
1485 mDetails->hide(); 1519 mDetails->hide();
1486 } 1520 }
1487 else 1521 else
1488 { 1522 {
1489 if ( visible ) { 1523 if ( visible ) {
1490 mViewManager->hide(); 1524 mViewManager->hide();
1491 mDetails->show(); 1525 mDetails->show();
1492 mIncSearchWidget->setFocus(); 1526 mIncSearchWidget->setFocus();
1493 } 1527 }
1494 else { 1528 else {
1495 mViewManager->show(); 1529 mViewManager->show();
1496 mDetails->hide(); 1530 mDetails->hide();
1497 mViewManager->setFocusAV(); 1531 mViewManager->setFocusAV();
1498 } 1532 }
1499 setJumpButtonBarVisible( !visible ); 1533 setJumpButtonBarVisible( !visible );
1500 } 1534 }
1501 1535
1502} 1536}
1503 1537
1504void KABCore::extensionChanged( int id ) 1538void KABCore::extensionChanged( int id )
1505{ 1539{
1506 //change the details view only for non desktop systems 1540 //change the details view only for non desktop systems
1507#ifndef DESKTOP_VERSION 1541#ifndef DESKTOP_VERSION
1508 1542
1509 if (id == 0) 1543 if (id == 0)
1510 { 1544 {
1511 //the user disabled the extension. 1545 //the user disabled the extension.
1512 1546
1513 if (mMultipleViewsAtOnce) 1547 if (mMultipleViewsAtOnce)
1514 { // enable detailsview again 1548 { // enable detailsview again
1515 setDetailsVisible( true ); 1549 setDetailsVisible( true );
1516 mActionDetails->setChecked( true ); 1550 mActionDetails->setChecked( true );
1517 } 1551 }
1518 else 1552 else
1519 { //go back to the listview 1553 { //go back to the listview
1520 setDetailsVisible( false ); 1554 setDetailsVisible( false );
1521 mActionDetails->setChecked( false ); 1555 mActionDetails->setChecked( false );
1522 mActionDetails->setEnabled(true); 1556 mActionDetails->setEnabled(true);
1523 } 1557 }
1524 1558
1525 } 1559 }
1526 else 1560 else
1527 { 1561 {
1528 //the user enabled the extension. 1562 //the user enabled the extension.
1529 setDetailsVisible( false ); 1563 setDetailsVisible( false );
1530 mActionDetails->setChecked( false ); 1564 mActionDetails->setChecked( false );
1531 1565
1532 if (!mMultipleViewsAtOnce) 1566 if (!mMultipleViewsAtOnce)
1533 { 1567 {
1534 mActionDetails->setEnabled(false); 1568 mActionDetails->setEnabled(false);
1535 } 1569 }
1536 1570
1537 mExtensionManager->setSelectionChanged(); 1571 mExtensionManager->setSelectionChanged();
1538 1572
1539 } 1573 }
1540 1574
1541#endif// DESKTOP_VERSION 1575#endif// DESKTOP_VERSION
1542 1576
1543} 1577}
1544 1578
1545 1579
1546void KABCore::extensionModified( const KABC::Addressee::List &list ) 1580void KABCore::extensionModified( const KABC::Addressee::List &list )
1547{ 1581{
1548 1582
1549 if ( list.count() != 0 ) { 1583 if ( list.count() != 0 ) {
1550 KABC::Addressee::List::ConstIterator it; 1584 KABC::Addressee::List::ConstIterator it;
1551 for ( it = list.begin(); it != list.end(); ++it ) 1585 for ( it = list.begin(); it != list.end(); ++it )
1552 mAddressBook->insertAddressee( *it ); 1586 mAddressBook->insertAddressee( *it );
1553 if ( list.count() > 1 ) 1587 if ( list.count() > 1 )
1554 setModified(); 1588 setModified();
1555 else 1589 else
1556 setModifiedWOrefresh(); 1590 setModifiedWOrefresh();
1557 } 1591 }
1558 if ( list.count() == 0 ) 1592 if ( list.count() == 0 )
1559 mViewManager->refreshView(); 1593 mViewManager->refreshView();
1560 else 1594 else
1561 mViewManager->refreshView( list[ 0 ].uid() ); 1595 mViewManager->refreshView( list[ 0 ].uid() );
1562 1596
1563 1597
1564 1598
1565} 1599}
1566 1600
1567QString KABCore::getNameByPhone( const QString &phone ) 1601QString KABCore::getNameByPhone( const QString &phone )
1568{ 1602{
1569#ifndef KAB_EMBEDDED 1603#ifndef KAB_EMBEDDED
1570 QRegExp r( "[/*/-/ ]" ); 1604 QRegExp r( "[/*/-/ ]" );
1571 QString localPhone( phone ); 1605 QString localPhone( phone );
1572 1606
1573 bool found = false; 1607 bool found = false;
1574 QString ownerName = ""; 1608 QString ownerName = "";
1575 KABC::AddressBook::Iterator iter; 1609 KABC::AddressBook::Iterator iter;
1576 KABC::PhoneNumber::List::Iterator phoneIter; 1610 KABC::PhoneNumber::List::Iterator phoneIter;
1577 KABC::PhoneNumber::List phoneList; 1611 KABC::PhoneNumber::List phoneList;
1578 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1612 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1579 phoneList = (*iter).phoneNumbers(); 1613 phoneList = (*iter).phoneNumbers();
1580 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1614 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1581 ++phoneIter) { 1615 ++phoneIter) {
1582 // Get rid of separator chars so just the numbers are compared. 1616 // Get rid of separator chars so just the numbers are compared.
1583 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1617 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1584 ownerName = (*iter).formattedName(); 1618 ownerName = (*iter).formattedName();
1585 found = true; 1619 found = true;
1586 } 1620 }
1587 } 1621 }
1588 } 1622 }
1589 1623
1590 return ownerName; 1624 return ownerName;
1591#else //KAB_EMBEDDED 1625#else //KAB_EMBEDDED
1592 qDebug("KABCore::getNameByPhone finsih method"); 1626 qDebug("KABCore::getNameByPhone finsih method");
1593 return ""; 1627 return "";
1594#endif //KAB_EMBEDDED 1628#endif //KAB_EMBEDDED
1595 1629
1596} 1630}
1597 1631
1598void KABCore::openConfigDialog() 1632void KABCore::openConfigDialog()
1599{ 1633{
1600 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1634 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1601 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1635 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1602 ConfigureDialog->addModule(kabcfg ); 1636 ConfigureDialog->addModule(kabcfg );
1603 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1637 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1604 ConfigureDialog->addModule(kdelibcfg ); 1638 ConfigureDialog->addModule(kdelibcfg );
1605 1639
1606 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1640 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1607 this, SLOT( configurationChanged() ) ); 1641 this, SLOT( configurationChanged() ) );
1608 connect( ConfigureDialog, SIGNAL( okClicked() ), 1642 connect( ConfigureDialog, SIGNAL( okClicked() ),
1609 this, SLOT( configurationChanged() ) ); 1643 this, SLOT( configurationChanged() ) );
1610 saveSettings(); 1644 saveSettings();
1611#ifndef DESKTOP_VERSION 1645#ifndef DESKTOP_VERSION
1612 ConfigureDialog->showMaximized(); 1646 ConfigureDialog->showMaximized();
1613#endif 1647#endif
1614 if ( ConfigureDialog->exec() ) 1648 if ( ConfigureDialog->exec() )
1615 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1649 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1616 delete ConfigureDialog; 1650 delete ConfigureDialog;
1617} 1651}
1618 1652
1619void KABCore::openLDAPDialog() 1653void KABCore::openLDAPDialog()
1620{ 1654{
1621#ifndef KAB_EMBEDDED 1655#ifndef KAB_EMBEDDED
1622 if ( !mLdapSearchDialog ) { 1656 if ( !mLdapSearchDialog ) {
1623 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1657 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1624 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1658 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1625 SLOT( refreshView() ) ); 1659 SLOT( refreshView() ) );
1626 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1660 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1627 SLOT( setModified() ) ); 1661 SLOT( setModified() ) );
1628 } else 1662 } else
1629 mLdapSearchDialog->restoreSettings(); 1663 mLdapSearchDialog->restoreSettings();
1630 1664
1631 if ( mLdapSearchDialog->isOK() ) 1665 if ( mLdapSearchDialog->isOK() )
1632 mLdapSearchDialog->exec(); 1666 mLdapSearchDialog->exec();
1633#else //KAB_EMBEDDED 1667#else //KAB_EMBEDDED
1634 qDebug("KABCore::openLDAPDialog() finsih method"); 1668 qDebug("KABCore::openLDAPDialog() finsih method");
1635#endif //KAB_EMBEDDED 1669#endif //KAB_EMBEDDED
1636} 1670}
1637 1671
1638void KABCore::print() 1672void KABCore::print()
1639{ 1673{
1640#ifndef KAB_EMBEDDED 1674#ifndef KAB_EMBEDDED
1641 KPrinter printer; 1675 KPrinter printer;
1642 if ( !printer.setup( this ) ) 1676 if ( !printer.setup( this ) )
1643 return; 1677 return;
1644 1678
1645 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1679 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1646 mViewManager->selectedUids(), this ); 1680 mViewManager->selectedUids(), this );
1647 1681
1648 wizard.exec(); 1682 wizard.exec();
1649#else //KAB_EMBEDDED 1683#else //KAB_EMBEDDED
1650 qDebug("KABCore::print() finsih method"); 1684 qDebug("KABCore::print() finsih method");
1651#endif //KAB_EMBEDDED 1685#endif //KAB_EMBEDDED
1652 1686
1653} 1687}
1654 1688
1655 1689
1656void KABCore::addGUIClient( KXMLGUIClient *client ) 1690void KABCore::addGUIClient( KXMLGUIClient *client )
1657{ 1691{
1658 if ( mGUIClient ) 1692 if ( mGUIClient )
1659 mGUIClient->insertChildClient( client ); 1693 mGUIClient->insertChildClient( client );
1660 else 1694 else
1661 KMessageBox::error( this, "no KXMLGUICLient"); 1695 KMessageBox::error( this, "no KXMLGUICLient");
1662} 1696}
1663 1697
1664 1698
1665void KABCore::configurationChanged() 1699void KABCore::configurationChanged()
1666{ 1700{
1667 mExtensionManager->reconfigure(); 1701 mExtensionManager->reconfigure();
1668} 1702}
1669 1703
1670void KABCore::addressBookChanged() 1704void KABCore::addressBookChanged()
1671{ 1705{
1672/*US 1706/*US
1673 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1707 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1674 while ( it.current() ) { 1708 while ( it.current() ) {
1675 if ( it.current()->dirty() ) { 1709 if ( it.current()->dirty() ) {
1676 QString text = i18n( "Data has been changed externally. Unsaved " 1710 QString text = i18n( "Data has been changed externally. Unsaved "
1677 "changes will be lost." ); 1711 "changes will be lost." );
1678 KMessageBox::information( this, text ); 1712 KMessageBox::information( this, text );
1679 } 1713 }
1680 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1714 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1681 ++it; 1715 ++it;
1682 } 1716 }
1683*/ 1717*/
1684 if (mEditorDialog) 1718 if (mEditorDialog)
1685 { 1719 {
1686 if (mEditorDialog->dirty()) 1720 if (mEditorDialog->dirty())
1687 { 1721 {
1688 QString text = i18n( "Data has been changed externally. Unsaved " 1722 QString text = i18n( "Data has been changed externally. Unsaved "
1689 "changes will be lost." ); 1723 "changes will be lost." );
1690 KMessageBox::information( this, text ); 1724 KMessageBox::information( this, text );
1691 } 1725 }
1692 QString currentuid = mEditorDialog->addressee().uid(); 1726 QString currentuid = mEditorDialog->addressee().uid();
1693 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1727 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1694 } 1728 }
1695 mViewManager->refreshView(); 1729 mViewManager->refreshView();
1696 1730
1697 1731
1698} 1732}
1699 1733
1700AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1734AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1701 const char *name ) 1735 const char *name )
1702{ 1736{
1703 1737
1704 if ( mEditorDialog == 0 ) { 1738 if ( mEditorDialog == 0 ) {
1705 mEditorDialog = new AddresseeEditorDialog( this, parent, 1739 mEditorDialog = new AddresseeEditorDialog( this, parent,
1706 name ? name : "editorDialog" ); 1740 name ? name : "editorDialog" );
1707 1741
1708 1742
1709 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1743 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1710 SLOT( contactModified( const KABC::Addressee& ) ) ); 1744 SLOT( contactModified( const KABC::Addressee& ) ) );
1711 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1745 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1712 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1746 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1713 } 1747 }
1714 1748
1715 return mEditorDialog; 1749 return mEditorDialog;
1716} 1750}
1717 1751
1718void KABCore::slotEditorDestroyed( const QString &uid ) 1752void KABCore::slotEditorDestroyed( const QString &uid )
1719{ 1753{
1720 //mEditorDict.remove( uid ); 1754 //mEditorDict.remove( uid );
1721} 1755}
1722 1756
1723void KABCore::initGUI() 1757void KABCore::initGUI()
1724{ 1758{
1725#ifndef KAB_EMBEDDED 1759#ifndef KAB_EMBEDDED
1726 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1760 QHBoxLayout *topLayout = new QHBoxLayout( this );
1727 topLayout->setSpacing( KDialogBase::spacingHint() ); 1761 topLayout->setSpacing( KDialogBase::spacingHint() );
1728 1762
1729 mExtensionBarSplitter = new QSplitter( this ); 1763 mExtensionBarSplitter = new QSplitter( this );
1730 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1764 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1731 1765
1732 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1766 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1733 1767
1734 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1768 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1735 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1769 mIncSearchWidget = new IncSearchWidget( viewSpace );
1736 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1770 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1737 SLOT( incrementalSearch( const QString& ) ) ); 1771 SLOT( incrementalSearch( const QString& ) ) );
1738 1772
1739 mViewManager = new ViewManager( this, viewSpace ); 1773 mViewManager = new ViewManager( this, viewSpace );
1740 viewSpace->setStretchFactor( mViewManager, 1 ); 1774 viewSpace->setStretchFactor( mViewManager, 1 );
1741 1775
1742 mDetails = new ViewContainer( mDetailsSplitter ); 1776 mDetails = new ViewContainer( mDetailsSplitter );
1743 1777
1744 mJumpButtonBar = new JumpButtonBar( this, this ); 1778 mJumpButtonBar = new JumpButtonBar( this, this );
1745 1779
1746 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1780 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1747 1781
1748 topLayout->addWidget( mExtensionBarSplitter ); 1782 topLayout->addWidget( mExtensionBarSplitter );
1749 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1783 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1750 topLayout->addWidget( mJumpButtonBar ); 1784 topLayout->addWidget( mJumpButtonBar );
1751 //topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1785 //topLayout->setStretchFactor( mJumpButtonBar, 1 );
1752 1786
1753 mXXPortManager = new XXPortManager( this, this ); 1787 mXXPortManager = new XXPortManager( this, this );
1754 1788
1755#else //KAB_EMBEDDED 1789#else //KAB_EMBEDDED
1756 //US initialize viewMenu before settingup viewmanager. 1790 //US initialize viewMenu before settingup viewmanager.
1757 // Viewmanager needs this menu to plugin submenues. 1791 // Viewmanager needs this menu to plugin submenues.
1758 viewMenu = new QPopupMenu( this ); 1792 viewMenu = new QPopupMenu( this );
1759 settingsMenu = new QPopupMenu( this ); 1793 settingsMenu = new QPopupMenu( this );
1760 //filterMenu = new QPopupMenu( this ); 1794 //filterMenu = new QPopupMenu( this );
1761 ImportMenu = new QPopupMenu( this ); 1795 ImportMenu = new QPopupMenu( this );
1762 ExportMenu = new QPopupMenu( this ); 1796 ExportMenu = new QPopupMenu( this );
1763 syncMenu = new QPopupMenu( this ); 1797 syncMenu = new QPopupMenu( this );
1764 changeMenu= new QPopupMenu( this ); 1798 changeMenu= new QPopupMenu( this );
1765 beamMenu= new QPopupMenu( this ); 1799 beamMenu= new QPopupMenu( this );
1766 1800
1767//US since we have no splitter for the embedded system, setup 1801//US since we have no splitter for the embedded system, setup
1768// a layout with two frames. One left and one right. 1802// a layout with two frames. One left and one right.
1769 1803
1770 QBoxLayout *topLayout; 1804 QBoxLayout *topLayout;
1771 1805
1772 // = new QHBoxLayout( this ); 1806 // = new QHBoxLayout( this );
1773// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1807// QBoxLayout *topLayout = (QBoxLayout*)layout();
1774 1808
1775// QWidget *mainBox = new QWidget( this ); 1809// QWidget *mainBox = new QWidget( this );
1776// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1810// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1777 1811
1778#ifdef DESKTOP_VERSION 1812#ifdef DESKTOP_VERSION
1779 topLayout = new QHBoxLayout( this ); 1813 topLayout = new QHBoxLayout( this );
1780 1814
1781 1815
1782 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1816 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1783 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1817 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1784 1818
1785 topLayout->addWidget(mMiniSplitter ); 1819 topLayout->addWidget(mMiniSplitter );
1786 1820
1787 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1821 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1788 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1822 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1789 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1823 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1790 mDetails = new ViewContainer( mMiniSplitter ); 1824 mDetails = new ViewContainer( mMiniSplitter );
1791 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1825 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1792#else 1826#else
1793 if ( QApplication::desktop()->width() > 480 ) { 1827 if ( QApplication::desktop()->width() > 480 ) {
1794 topLayout = new QHBoxLayout( this ); 1828 topLayout = new QHBoxLayout( this );
1795 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1829 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1796 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1830 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1797 } else { 1831 } else {
1798 1832
1799 topLayout = new QHBoxLayout( this ); 1833 topLayout = new QHBoxLayout( this );
1800 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1834 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1801 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1802 } 1836 }
1803 1837
1804 topLayout->addWidget(mMiniSplitter ); 1838 topLayout->addWidget(mMiniSplitter );
1805 mViewManager = new ViewManager( this, mMiniSplitter ); 1839 mViewManager = new ViewManager( this, mMiniSplitter );
1806 mDetails = new ViewContainer( mMiniSplitter ); 1840 mDetails = new ViewContainer( mMiniSplitter );
1807 1841
1808 1842
1809 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1843 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1810#endif 1844#endif
1811 //eh->hide(); 1845 //eh->hide();
1812 // topLayout->addWidget(mExtensionManager ); 1846 // topLayout->addWidget(mExtensionManager );
1813 1847
1814 1848
1815/*US 1849/*US
1816#ifndef KAB_NOSPLITTER 1850#ifndef KAB_NOSPLITTER
1817 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1851 QHBoxLayout *topLayout = new QHBoxLayout( this );
1818//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1852//US topLayout->setSpacing( KDialogBase::spacingHint() );
1819 topLayout->setSpacing( 10 ); 1853 topLayout->setSpacing( 10 );
1820 1854
1821 mDetailsSplitter = new QSplitter( this ); 1855 mDetailsSplitter = new QSplitter( this );
1822 1856
1823 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1857 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1824 1858
1825 mViewManager = new ViewManager( this, viewSpace ); 1859 mViewManager = new ViewManager( this, viewSpace );
1826 viewSpace->setStretchFactor( mViewManager, 1 ); 1860 viewSpace->setStretchFactor( mViewManager, 1 );
1827 1861
1828 mDetails = new ViewContainer( mDetailsSplitter ); 1862 mDetails = new ViewContainer( mDetailsSplitter );
1829 1863
1830 topLayout->addWidget( mDetailsSplitter ); 1864 topLayout->addWidget( mDetailsSplitter );
1831 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1865 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1832#else //KAB_NOSPLITTER 1866#else //KAB_NOSPLITTER
1833 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1867 QHBoxLayout *topLayout = new QHBoxLayout( this );
1834//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1868//US topLayout->setSpacing( KDialogBase::spacingHint() );
1835 topLayout->setSpacing( 10 ); 1869 topLayout->setSpacing( 10 );
1836 1870
1837// mDetailsSplitter = new QSplitter( this ); 1871// mDetailsSplitter = new QSplitter( this );
1838 1872
1839 QVBox *viewSpace = new QVBox( this ); 1873 QVBox *viewSpace = new QVBox( this );
1840 1874
1841 mViewManager = new ViewManager( this, viewSpace ); 1875 mViewManager = new ViewManager( this, viewSpace );
1842 viewSpace->setStretchFactor( mViewManager, 1 ); 1876 viewSpace->setStretchFactor( mViewManager, 1 );
1843 1877
1844 mDetails = new ViewContainer( this ); 1878 mDetails = new ViewContainer( this );
1845 1879
1846 topLayout->addWidget( viewSpace ); 1880 topLayout->addWidget( viewSpace );
1847// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1881// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1848 topLayout->addWidget( mDetails ); 1882 topLayout->addWidget( mDetails );
1849#endif //KAB_NOSPLITTER 1883#endif //KAB_NOSPLITTER
1850*/ 1884*/
1851 1885
1852 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1886 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1853 syncManager->setBlockSave(false); 1887 syncManager->setBlockSave(false);
1854 1888
1855 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1889 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1856 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1890 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1857 QString sync_file = sentSyncFile(); 1891 QString sync_file = sentSyncFile();
1858 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1892 //qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1859 syncManager->setDefaultFileName( sync_file ); 1893 syncManager->setDefaultFileName( sync_file );
1860 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1894 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1861 1895
1862#endif //KAB_EMBEDDED 1896#endif //KAB_EMBEDDED
1863 initActions(); 1897 initActions();
1864 1898
1865#ifdef KAB_EMBEDDED 1899#ifdef KAB_EMBEDDED
1866 addActionsManually(); 1900 addActionsManually();
1867 //US make sure the export and import menues are initialized before creating the xxPortManager. 1901 //US make sure the export and import menues are initialized before creating the xxPortManager.
1868 mXXPortManager = new XXPortManager( this, this ); 1902 mXXPortManager = new XXPortManager( this, this );
1869 1903
1870 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1904 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1871 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1905 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1872 // mActionQuit->plug ( mMainWindow->toolBar()); 1906 // mActionQuit->plug ( mMainWindow->toolBar());
1873 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1907 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1874 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1908 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1875 // mIncSearchWidget->hide(); 1909 // mIncSearchWidget->hide();
1876 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1910 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1877 SLOT( incrementalSearch( const QString& ) ) ); 1911 SLOT( incrementalSearch( const QString& ) ) );
1878 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1912 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1879 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1913 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1880 1914
1881 mJumpButtonBar = new JumpButtonBar( this, this ); 1915 mJumpButtonBar = new JumpButtonBar( this, this );
1882 1916
1883 topLayout->addWidget( mJumpButtonBar ); 1917 topLayout->addWidget( mJumpButtonBar );
1884//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1918//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1885 1919
1886// mMainWindow->getIconToolBar()->raise(); 1920// mMainWindow->getIconToolBar()->raise();
1887 1921
1888#endif //KAB_EMBEDDED 1922#endif //KAB_EMBEDDED
1889 1923
1890} 1924}
1891void KABCore::initActions() 1925void KABCore::initActions()
1892{ 1926{
1893//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1927//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1894 1928
1895#ifndef KAB_EMBEDDED 1929#ifndef KAB_EMBEDDED
1896 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1930 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1897 SLOT( clipboardDataChanged() ) ); 1931 SLOT( clipboardDataChanged() ) );
1898#endif //KAB_EMBEDDED 1932#endif //KAB_EMBEDDED
1899 1933
1900 // file menu 1934 // file menu
1901 1935
1902 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1936 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1903 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1937 //mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1904 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager, 1938 mActionPrint = new KAction( i18n( "&Print View" ), "fileprint", CTRL + Key_P, mViewManager,
1905 SLOT( printView() ), actionCollection(), "kaddressbook_print" ); 1939 SLOT( printView() ), actionCollection(), "kaddressbook_print" );
1906 1940
1907 1941
1908 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails, 1942 mActionPrintDetails = new KAction( i18n( "&Print Details" ), "fileprint", 0, mDetails,
1909 SLOT( printView() ), actionCollection(), "kaddressbook_print2" ); 1943 SLOT( printView() ), actionCollection(), "kaddressbook_print2" );
1910 1944
1911 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1945 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1912 SLOT( save() ), actionCollection(), "file_sync" ); 1946 SLOT( save() ), actionCollection(), "file_sync" );
1913 1947
1914 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1948 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1915 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1949 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1916 1950
1917 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1951 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1918 this, SLOT( mailVCard() ), 1952 this, SLOT( mailVCard() ),
1919 actionCollection(), "file_mail_vcard"); 1953 actionCollection(), "file_mail_vcard");
1920 1954
1921 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1955 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1922 SLOT( export2phone() ), actionCollection(), 1956 SLOT( export2phone() ), actionCollection(),
1923 "kaddressbook_ex2phone" ); 1957 "kaddressbook_ex2phone" );
1924 1958
1925 mActionBeamVCard = 0; 1959 mActionBeamVCard = 0;
1926 mActionBeam = 0; 1960 mActionBeam = 0;
1927 1961
1928#ifndef DESKTOP_VERSION 1962#ifndef DESKTOP_VERSION
1929 if ( Ir::supported() ) { 1963 if ( Ir::supported() ) {
1930 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1964 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1931 SLOT( beamVCard() ), actionCollection(), 1965 SLOT( beamVCard() ), actionCollection(),
1932 "kaddressbook_beam_vcard" ); 1966 "kaddressbook_beam_vcard" );
1933 1967
1934 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1968 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1935 SLOT( beamMySelf() ), actionCollection(), 1969 SLOT( beamMySelf() ), actionCollection(),
1936 "kaddressbook_beam_myself" ); 1970 "kaddressbook_beam_myself" );
1937 } 1971 }
1938#endif 1972#endif
1939 1973
1940 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1974 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1941 this, SLOT( editContact2() ), 1975 this, SLOT( editContact2() ),
1942 actionCollection(), "file_properties" ); 1976 actionCollection(), "file_properties" );
1943 1977
1944#ifdef KAB_EMBEDDED 1978#ifdef KAB_EMBEDDED
1945 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1979 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1946 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1980 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1947 mMainWindow, SLOT( exit() ), 1981 mMainWindow, SLOT( exit() ),
1948 actionCollection(), "quit" ); 1982 actionCollection(), "quit" );
1949#endif //KAB_EMBEDDED 1983#endif //KAB_EMBEDDED
1950 1984
1951 // edit menu 1985 // edit menu
1952 if ( mIsPart ) { 1986 if ( mIsPart ) {
1953 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1987 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1954 SLOT( copyContacts() ), actionCollection(), 1988 SLOT( copyContacts() ), actionCollection(),
1955 "kaddressbook_copy" ); 1989 "kaddressbook_copy" );
1956 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1990 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1957 SLOT( cutContacts() ), actionCollection(), 1991 SLOT( cutContacts() ), actionCollection(),
1958 "kaddressbook_cut" ); 1992 "kaddressbook_cut" );
1959 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1993 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1960 SLOT( pasteContacts() ), actionCollection(), 1994 SLOT( pasteContacts() ), actionCollection(),
1961 "kaddressbook_paste" ); 1995 "kaddressbook_paste" );
1962 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1996 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1963 SLOT( selectAllContacts() ), actionCollection(), 1997 SLOT( selectAllContacts() ), actionCollection(),
1964 "kaddressbook_select_all" ); 1998 "kaddressbook_select_all" );
1965 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1999 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1966 SLOT( undo() ), actionCollection(), 2000 SLOT( undo() ), actionCollection(),
1967 "kaddressbook_undo" ); 2001 "kaddressbook_undo" );
1968 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 2002 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1969 this, SLOT( redo() ), actionCollection(), 2003 this, SLOT( redo() ), actionCollection(),
1970 "kaddressbook_redo" ); 2004 "kaddressbook_redo" );
1971 } else { 2005 } else {
1972 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 2006 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1973 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 2007 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1974 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 2008 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1975 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 2009 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1976 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 2010 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1977 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 2011 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1978 } 2012 }
1979 2013
1980 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 2014 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1981 Key_Delete, this, SLOT( deleteContacts() ), 2015 Key_Delete, this, SLOT( deleteContacts() ),
1982 actionCollection(), "edit_delete" ); 2016 actionCollection(), "edit_delete" );
1983 2017
1984 mActionUndo->setEnabled( false ); 2018 mActionUndo->setEnabled( false );
1985 mActionRedo->setEnabled( false ); 2019 mActionRedo->setEnabled( false );
1986 2020
1987 // settings menu 2021 // settings menu
1988#ifdef KAB_EMBEDDED 2022#ifdef KAB_EMBEDDED
1989//US special menuentry to configure the addressbook resources. On KDE 2023//US special menuentry to configure the addressbook resources. On KDE
1990// you do that through the control center !!! 2024// you do that through the control center !!!
1991 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 2025 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1992 SLOT( configureResources() ), actionCollection(), 2026 SLOT( configureResources() ), actionCollection(),
1993 "kaddressbook_configure_resources" ); 2027 "kaddressbook_configure_resources" );
1994#endif //KAB_EMBEDDED 2028#endif //KAB_EMBEDDED
1995 2029
1996 if ( mIsPart ) { 2030 if ( mIsPart ) {
1997 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 2031 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1998 SLOT( openConfigDialog() ), actionCollection(), 2032 SLOT( openConfigDialog() ), actionCollection(),
1999 "kaddressbook_configure" ); 2033 "kaddressbook_configure" );
2000 2034
2001 //US not implemented yet 2035 //US not implemented yet
2002 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 2036 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
2003 // this, SLOT( configureKeyBindings() ), actionCollection(), 2037 // this, SLOT( configureKeyBindings() ), actionCollection(),
2004 // "kaddressbook_configure_shortcuts" ); 2038 // "kaddressbook_configure_shortcuts" );
2005#ifdef KAB_EMBEDDED 2039#ifdef KAB_EMBEDDED
2006 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 2040 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
2007 mActionConfigureToolbars->setEnabled( false ); 2041 mActionConfigureToolbars->setEnabled( false );
2008#endif //KAB_EMBEDDED 2042#endif //KAB_EMBEDDED
2009 2043
2010 } else { 2044 } else {
2011 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 2045 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
2012 2046
2013 //US not implemented yet 2047 //US not implemented yet
2014 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 2048 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
2015 } 2049 }
2016 2050
2017 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 2051 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
2018 actionCollection(), "options_show_jump_bar" ); 2052 actionCollection(), "options_show_jump_bar" );
2019 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) ); 2053 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBar( bool ) ) );
2020 2054
2021 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2055 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
2022 actionCollection(), "options_show_details" ); 2056 actionCollection(), "options_show_details" );
2023 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2057 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
2024 2058
2025 2059
2026 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2060 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
2027 SLOT( toggleBeamReceive() ), actionCollection(), 2061 SLOT( toggleBeamReceive() ), actionCollection(),
2028 "kaddressbook_beam_rec" ); 2062 "kaddressbook_beam_rec" );
2029 2063
2030 2064
2031 // misc 2065 // misc
2032 // only enable LDAP lookup if we can handle the protocol 2066 // only enable LDAP lookup if we can handle the protocol
2033#ifndef KAB_EMBEDDED 2067#ifndef KAB_EMBEDDED
2034 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2068 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
2035 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2069 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
2036 this, SLOT( openLDAPDialog() ), actionCollection(), 2070 this, SLOT( openLDAPDialog() ), actionCollection(),
2037 "ldap_lookup" ); 2071 "ldap_lookup" );
2038 } 2072 }
2039#else //KAB_EMBEDDED 2073#else //KAB_EMBEDDED
2040 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2074 //qDebug("KABCore::initActions() LDAP has to be implemented");
2041#endif //KAB_EMBEDDED 2075#endif //KAB_EMBEDDED
2042 2076
2043 2077
2044 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2078 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
2045 SLOT( setWhoAmI() ), actionCollection(), 2079 SLOT( setWhoAmI() ), actionCollection(),
2046 "set_personal" ); 2080 "set_personal" );
2047 2081
2048 2082
2049 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this, 2083 mActionCategories = new KAction( i18n( "Set Categories for Contacts..." ), 0, this,
2050 SLOT( setCategories() ), actionCollection(), 2084 SLOT( setCategories() ), actionCollection(),
2051 "edit_set_categories" ); 2085 "edit_set_categories" );
2052 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this, 2086 mActionEditCategories = new KAction( i18n( "Edit Category List..." ), 0, this,
2053 SLOT( editCategories() ), actionCollection(), 2087 SLOT( editCategories() ), actionCollection(),
2054 "edit__categories" ); 2088 "edit__categories" );
2055 2089
2056 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2090 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
2057 SLOT( removeVoice() ), actionCollection(), 2091 SLOT( removeVoice() ), actionCollection(),
2058 "remove_voice" ); 2092 "remove_voice" );
2059 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this, 2093 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2060 SLOT( setFormattedName() ), actionCollection(), 2094 SLOT( setFormattedName() ), actionCollection(),
2061 "set_formatted" ); 2095 "set_formatted" );
2062 2096
2063 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2097 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2064 SLOT( manageCategories() ), actionCollection(), 2098 SLOT( manageCategories() ), actionCollection(),
2065 "remove_voice" ); 2099 "remove_voice" );
2066 2100
2067 2101
2068 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2102 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2069 SLOT( importFromOL() ), actionCollection(), 2103 SLOT( importFromOL() ), actionCollection(),
2070 "import_OL" ); 2104 "import_OL" );
2071#ifdef KAB_EMBEDDED 2105#ifdef KAB_EMBEDDED
2072 mActionLicence = new KAction( i18n( "Licence" ), 0, 2106 mActionLicence = new KAction( i18n( "Licence" ), 0,
2073 this, SLOT( showLicence() ), actionCollection(), 2107 this, SLOT( showLicence() ), actionCollection(),
2074 "licence_about_data" ); 2108 "licence_about_data" );
2075 mActionFaq = new KAction( i18n( "Faq" ), 0, 2109 mActionFaq = new KAction( i18n( "Faq" ), 0,
2076 this, SLOT( faq() ), actionCollection(), 2110 this, SLOT( faq() ), actionCollection(),
2077 "faq_about_data" ); 2111 "faq_about_data" );
2078 mActionWN = new KAction( i18n( "What's New?" ), 0, 2112 mActionWN = new KAction( i18n( "What's New?" ), 0,
2079 this, SLOT( whatsnew() ), actionCollection(), 2113 this, SLOT( whatsnew() ), actionCollection(),
2080 "wn" ); 2114 "wn" );
2081 2115
2082 2116
2083 2117
2084 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0, 2118 mActionStorageHowto = new KAction( i18n( "Storage HowTo" ), 0,
2085 this, SLOT( storagehowto() ), actionCollection(), 2119 this, SLOT( storagehowto() ), actionCollection(),
2086 "storage" ); 2120 "storage" );
2087 2121
2088 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2122 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2089 this, SLOT( synchowto() ), actionCollection(), 2123 this, SLOT( synchowto() ), actionCollection(),
2090 "sync" ); 2124 "sync" );
2091 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2125 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2092 this, SLOT( kdesynchowto() ), actionCollection(), 2126 this, SLOT( kdesynchowto() ), actionCollection(),
2093 "kdesync" ); 2127 "kdesync" );
2094 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2128 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2095 this, SLOT( multisynchowto() ), actionCollection(), 2129 this, SLOT( multisynchowto() ), actionCollection(),
2096 "multisync" ); 2130 "multisync" );
2097 2131
2098 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2132 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2099 this, SLOT( createAboutData() ), actionCollection(), 2133 this, SLOT( createAboutData() ), actionCollection(),
2100 "kaddressbook_about_data" ); 2134 "kaddressbook_about_data" );
2101#endif //KAB_EMBEDDED 2135#endif //KAB_EMBEDDED
2102 2136
2103 clipboardDataChanged(); 2137 clipboardDataChanged();
2104 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2138 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2105 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2139 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2106} 2140}
2107 2141