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