summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorulf69 <ulf69>2004-10-28 00:21:13 (UTC)
committer ulf69 <ulf69>2004-10-28 00:21:13 (UTC)
commit621a8505690485db909a573f83433873197595c0 (patch) (unidiff)
tree1a37fcbdbf439b1d0411ee4d40973fce521be6ea /kaddressbook
parent0b7fefe9f97ced1e4b2d93d26e12385aadb7b7e9 (diff)
downloadkdepimpi-621a8505690485db909a573f83433873197595c0.zip
kdepimpi-621a8505690485db909a573f83433873197595c0.tar.gz
kdepimpi-621a8505690485db909a573f83433873197595c0.tar.bz2
implemented "nextView" QCop message to toggle between table and detailview
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d1dcb6e..638abc9 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,860 +1,869 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118 118
119 119
120#include <kresources/selectdialog.h> 120#include <kresources/selectdialog.h>
121#include <kmessagebox.h> 121#include <kmessagebox.h>
122 122
123#include <picture.h> 123#include <picture.h>
124#include <resource.h> 124#include <resource.h>
125 125
126//US#include <qsplitter.h> 126//US#include <qsplitter.h>
127#include <qmap.h> 127#include <qmap.h>
128#include <qdir.h> 128#include <qdir.h>
129#include <qfile.h> 129#include <qfile.h>
130#include <qvbox.h> 130#include <qvbox.h>
131#include <qlayout.h> 131#include <qlayout.h>
132#include <qclipboard.h> 132#include <qclipboard.h>
133#include <qtextstream.h> 133#include <qtextstream.h>
134 134
135#include <libkdepim/categoryselectdialog.h> 135#include <libkdepim/categoryselectdialog.h>
136#include <kabc/vcardconverter.h> 136#include <kabc/vcardconverter.h>
137 137
138 138
139#include "addresseeutil.h" 139#include "addresseeutil.h"
140#include "undocmds.h" 140#include "undocmds.h"
141#include "addresseeeditordialog.h" 141#include "addresseeeditordialog.h"
142#include "viewmanager.h" 142#include "viewmanager.h"
143#include "details/detailsviewcontainer.h" 143#include "details/detailsviewcontainer.h"
144#include "kabprefs.h" 144#include "kabprefs.h"
145#include "xxportmanager.h" 145#include "xxportmanager.h"
146#include "incsearchwidget.h" 146#include "incsearchwidget.h"
147#include "jumpbuttonbar.h" 147#include "jumpbuttonbar.h"
148#include "extensionmanager.h" 148#include "extensionmanager.h"
149#include "addresseeconfig.h" 149#include "addresseeconfig.h"
150#include <kcmultidialog.h> 150#include <kcmultidialog.h>
151 151
152#ifdef _WIN32_ 152#ifdef _WIN32_
153 153
154#include "kaimportoldialog.h" 154#include "kaimportoldialog.h"
155#else 155#else
156#include <unistd.h> 156#include <unistd.h>
157#endif 157#endif
158// sync includes 158// sync includes
159#include <libkdepim/ksyncprofile.h> 159#include <libkdepim/ksyncprofile.h>
160#include <libkdepim/ksyncprefsdialog.h> 160#include <libkdepim/ksyncprefsdialog.h>
161 161
162class KAex2phonePrefs : public QDialog 162class KAex2phonePrefs : public QDialog
163{ 163{
164 public: 164 public:
165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 165 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
166 QDialog( parent, name, true ) 166 QDialog( parent, name, true )
167 { 167 {
168 setCaption( i18n("Export to phone options") ); 168 setCaption( i18n("Export to phone options") );
169 QVBoxLayout* lay = new QVBoxLayout( this ); 169 QVBoxLayout* lay = new QVBoxLayout( this );
170 lay->setSpacing( 3 ); 170 lay->setSpacing( 3 );
171 lay->setMargin( 3 ); 171 lay->setMargin( 3 );
172 QLabel *lab; 172 QLabel *lab;
173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 173 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
174 lab->setAlignment (AlignHCenter ); 174 lab->setAlignment (AlignHCenter );
175 QHBox* temphb; 175 QHBox* temphb;
176 temphb = new QHBox( this ); 176 temphb = new QHBox( this );
177 new QLabel( i18n("I/O device: "), temphb ); 177 new QLabel( i18n("I/O device: "), temphb );
178 mPhoneDevice = new QLineEdit( temphb); 178 mPhoneDevice = new QLineEdit( temphb);
179 lay->addWidget( temphb ); 179 lay->addWidget( temphb );
180 temphb = new QHBox( this ); 180 temphb = new QHBox( this );
181 new QLabel( i18n("Connection: "), temphb ); 181 new QLabel( i18n("Connection: "), temphb );
182 mPhoneConnection = new QLineEdit( temphb); 182 mPhoneConnection = new QLineEdit( temphb);
183 lay->addWidget( temphb ); 183 lay->addWidget( temphb );
184 temphb = new QHBox( this ); 184 temphb = new QHBox( this );
185 new QLabel( i18n("Model(opt.): "), temphb ); 185 new QLabel( i18n("Model(opt.): "), temphb );
186 mPhoneModel = new QLineEdit( temphb); 186 mPhoneModel = new QLineEdit( temphb);
187 lay->addWidget( temphb ); 187 lay->addWidget( temphb );
188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 188 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
189 // lay->addWidget( mWriteToSim ); 189 // lay->addWidget( mWriteToSim );
190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 190 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
191 lab->setAlignment (AlignHCenter ); 191 lab->setAlignment (AlignHCenter );
192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 192 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
193 lay->addWidget( ok ); 193 lay->addWidget( ok );
194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 194 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
195 lay->addWidget( cancel ); 195 lay->addWidget( cancel );
196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 196 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 197 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
198 resize( 220, 240 ); 198 resize( 220, 240 );
199 199
200 } 200 }
201 201
202public: 202public:
203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 203 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
204 QCheckBox* mWriteToSim; 204 QCheckBox* mWriteToSim;
205}; 205};
206 206
207 207
208bool pasteWithNewUid = true; 208bool pasteWithNewUid = true;
209 209
210#ifdef KAB_EMBEDDED 210#ifdef KAB_EMBEDDED
211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 211KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 212 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 213 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 214 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
215#else //KAB_EMBEDDED 215#else //KAB_EMBEDDED
216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 216KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 217 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 218 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
219 mReadWrite( readWrite ), mModified( false ) 219 mReadWrite( readWrite ), mModified( false )
220#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
221{ 221{
222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 222 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
223 // syncManager->setBlockSave(false); 223 // syncManager->setBlockSave(false);
224 mExtensionBarSplitter = 0; 224 mExtensionBarSplitter = 0;
225 mIsPart = !parent->inherits( "KAddressBookMain" ); 225 mIsPart = !parent->inherits( "KAddressBookMain" );
226 mAddressBook = KABC::StdAddressBook::self(); 226 mAddressBook = KABC::StdAddressBook::self();
227 KABC::StdAddressBook::setAutomaticSave( false ); 227 KABC::StdAddressBook::setAutomaticSave( false );
228 228
229#ifndef KAB_EMBEDDED 229#ifndef KAB_EMBEDDED
230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 230 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
231#endif //KAB_EMBEDDED 231#endif //KAB_EMBEDDED
232 232
233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 233 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
234 SLOT( addressBookChanged() ) ); 234 SLOT( addressBookChanged() ) );
235 235
236#if 0 236#if 0
237 // LP moved to addressbook init method 237 // LP moved to addressbook init method
238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 238 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
239 "X-Department", "KADDRESSBOOK" ); 239 "X-Department", "KADDRESSBOOK" );
240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 240 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
241 "X-Profession", "KADDRESSBOOK" ); 241 "X-Profession", "KADDRESSBOOK" );
242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 242 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
243 "X-AssistantsName", "KADDRESSBOOK" ); 243 "X-AssistantsName", "KADDRESSBOOK" );
244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 244 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
245 "X-ManagersName", "KADDRESSBOOK" ); 245 "X-ManagersName", "KADDRESSBOOK" );
246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 246 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
247 "X-SpousesName", "KADDRESSBOOK" ); 247 "X-SpousesName", "KADDRESSBOOK" );
248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 248 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
249 "X-Office", "KADDRESSBOOK" ); 249 "X-Office", "KADDRESSBOOK" );
250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 250 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
251 "X-IMAddress", "KADDRESSBOOK" ); 251 "X-IMAddress", "KADDRESSBOOK" );
252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 252 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
253 "X-Anniversary", "KADDRESSBOOK" ); 253 "X-Anniversary", "KADDRESSBOOK" );
254 254
255 //US added this field to become compatible with Opie/qtopia addressbook 255 //US added this field to become compatible with Opie/qtopia addressbook
256 // values can be "female" or "male" or "". An empty field represents undefined. 256 // values can be "female" or "male" or "". An empty field represents undefined.
257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 257 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
258 "X-Gender", "KADDRESSBOOK" ); 258 "X-Gender", "KADDRESSBOOK" );
259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 259 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
260 "X-Children", "KADDRESSBOOK" ); 260 "X-Children", "KADDRESSBOOK" );
261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 261 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
262 "X-FreeBusyUrl", "KADDRESSBOOK" ); 262 "X-FreeBusyUrl", "KADDRESSBOOK" );
263#endif 263#endif
264 initGUI(); 264 initGUI();
265 265
266 mIncSearchWidget->setFocus(); 266 mIncSearchWidget->setFocus();
267 267
268 268
269 connect( mViewManager, SIGNAL( selected( const QString& ) ), 269 connect( mViewManager, SIGNAL( selected( const QString& ) ),
270 SLOT( setContactSelected( const QString& ) ) ); 270 SLOT( setContactSelected( const QString& ) ) );
271 connect( mViewManager, SIGNAL( executed( const QString& ) ), 271 connect( mViewManager, SIGNAL( executed( const QString& ) ),
272 SLOT( executeContact( const QString& ) ) ); 272 SLOT( executeContact( const QString& ) ) );
273 273
274 connect( mViewManager, SIGNAL( deleteRequest( ) ), 274 connect( mViewManager, SIGNAL( deleteRequest( ) ),
275 SLOT( deleteContacts( ) ) ); 275 SLOT( deleteContacts( ) ) );
276 connect( mViewManager, SIGNAL( modified() ), 276 connect( mViewManager, SIGNAL( modified() ),
277 SLOT( setModified() ) ); 277 SLOT( setModified() ) );
278 278
279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 279 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 280 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
281 281
282 connect( mXXPortManager, SIGNAL( modified() ), 282 connect( mXXPortManager, SIGNAL( modified() ),
283 SLOT( setModified() ) ); 283 SLOT( setModified() ) );
284 284
285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 285 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
286 SLOT( incrementalSearch( const QString& ) ) ); 286 SLOT( incrementalSearch( const QString& ) ) );
287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 287 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
288 mJumpButtonBar, SLOT( recreateButtons() ) ); 288 mJumpButtonBar, SLOT( recreateButtons() ) );
289 289
290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 290 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
291 SLOT( sendMail( const QString& ) ) ); 291 SLOT( sendMail( const QString& ) ) );
292 292
293 293
294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 294 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
295 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&))); 295 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&)));
296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 296 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 297 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
298 298
299 299
300#ifndef KAB_EMBEDDED 300#ifndef KAB_EMBEDDED
301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 301 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
302 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 302 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
303 303
304 connect( mDetails, SIGNAL( browse( const QString& ) ), 304 connect( mDetails, SIGNAL( browse( const QString& ) ),
305 SLOT( browse( const QString& ) ) ); 305 SLOT( browse( const QString& ) ) );
306 306
307 307
308 mAddressBookService = new KAddressBookService( this ); 308 mAddressBookService = new KAddressBookService( this );
309 309
310#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
311 311
312 mMessageTimer = new QTimer( this ); 312 mMessageTimer = new QTimer( this );
313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 313 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
314 mEditorDialog = 0; 314 mEditorDialog = 0;
315 createAddresseeEditorDialog( this ); 315 createAddresseeEditorDialog( this );
316 setModified( false ); 316 setModified( false );
317 mBRdisabled = false; 317 mBRdisabled = false;
318#ifndef DESKTOP_VERSION 318#ifndef DESKTOP_VERSION
319 infrared = 0; 319 infrared = 0;
320#endif 320#endif
321 //toggleBeamReceive( ); 321 //toggleBeamReceive( );
322} 322}
323 323
324KABCore::~KABCore() 324KABCore::~KABCore()
325{ 325{
326 // save(); 326 // save();
327 //saveSettings(); 327 //saveSettings();
328 //KABPrefs::instance()->writeConfig(); 328 //KABPrefs::instance()->writeConfig();
329 delete AddresseeConfig::instance(); 329 delete AddresseeConfig::instance();
330 mAddressBook = 0; 330 mAddressBook = 0;
331 KABC::StdAddressBook::close(); 331 KABC::StdAddressBook::close();
332 332
333 delete syncManager; 333 delete syncManager;
334#ifndef DESKTOP_VERSION 334#ifndef DESKTOP_VERSION
335 if ( infrared ) 335 if ( infrared )
336 delete infrared; 336 delete infrared;
337#endif 337#endif
338} 338}
339void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 339void KABCore::receive( const QCString& cmsg, const QByteArray& data )
340{ 340{
341 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 341 qDebug("KA: QCOP message received: %s ", cmsg.data() );
342 if ( cmsg == "setDocument(QString)" ) { 342 if ( cmsg == "setDocument(QString)" ) {
343 QDataStream stream( data, IO_ReadOnly ); 343 QDataStream stream( data, IO_ReadOnly );
344 QString fileName; 344 QString fileName;
345 stream >> fileName; 345 stream >> fileName;
346 recieve( fileName ); 346 recieve( fileName );
347 return; 347 return;
348 } 348 }
349 else if ( cmsg == "nextView()" )
350 {
351 //toggle between details/ no details
352 bool b = !mActionDetails->isChecked();
353 setDetailsVisible( b );
354 mActionDetails->setChecked( b );
355 }
356
357
349} 358}
350void KABCore::toggleBeamReceive( ) 359void KABCore::toggleBeamReceive( )
351{ 360{
352 if ( mBRdisabled ) 361 if ( mBRdisabled )
353 return; 362 return;
354#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
355 if ( infrared ) { 364 if ( infrared ) {
356 qDebug("AB disable BeamReceive "); 365 qDebug("AB disable BeamReceive ");
357 delete infrared; 366 delete infrared;
358 infrared = 0; 367 infrared = 0;
359 mActionBR->setChecked(false); 368 mActionBR->setChecked(false);
360 return; 369 return;
361 } 370 }
362 qDebug("AB enable BeamReceive "); 371 qDebug("AB enable BeamReceive ");
363 mActionBR->setChecked(true); 372 mActionBR->setChecked(true);
364 373
365 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 374 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
366 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 375 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
367#endif 376#endif
368} 377}
369 378
370 379
371void KABCore::disableBR(bool b) 380void KABCore::disableBR(bool b)
372{ 381{
373#ifndef DESKTOP_VERSION 382#ifndef DESKTOP_VERSION
374 if ( b ) { 383 if ( b ) {
375 if ( infrared ) { 384 if ( infrared ) {
376 toggleBeamReceive( ); 385 toggleBeamReceive( );
377 } 386 }
378 mBRdisabled = true; 387 mBRdisabled = true;
379 } else { 388 } else {
380 if ( mBRdisabled ) { 389 if ( mBRdisabled ) {
381 mBRdisabled = false; 390 mBRdisabled = false;
382 //toggleBeamReceive( ); 391 //toggleBeamReceive( );
383 } 392 }
384 } 393 }
385#endif 394#endif
386 395
387} 396}
388void KABCore::recieve( QString fn ) 397void KABCore::recieve( QString fn )
389{ 398{
390 //qDebug("KABCore::recieve "); 399 //qDebug("KABCore::recieve ");
391 int count = mAddressBook->importFromFile( fn, true ); 400 int count = mAddressBook->importFromFile( fn, true );
392 if ( count ) 401 if ( count )
393 setModified( true ); 402 setModified( true );
394 mViewManager->refreshView(); 403 mViewManager->refreshView();
395 message(i18n("%1 contact(s) received!").arg( count )); 404 message(i18n("%1 contact(s) received!").arg( count ));
396 topLevelWidget()->showMaximized(); 405 topLevelWidget()->showMaximized();
397 topLevelWidget()->raise(); 406 topLevelWidget()->raise();
398} 407}
399void KABCore::restoreSettings() 408void KABCore::restoreSettings()
400{ 409{
401 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 410 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
402 411
403 bool state; 412 bool state;
404 413
405 if (mMultipleViewsAtOnce) 414 if (mMultipleViewsAtOnce)
406 state = KABPrefs::instance()->mDetailsPageVisible; 415 state = KABPrefs::instance()->mDetailsPageVisible;
407 else 416 else
408 state = false; 417 state = false;
409 418
410 mActionDetails->setChecked( state ); 419 mActionDetails->setChecked( state );
411 setDetailsVisible( state ); 420 setDetailsVisible( state );
412 421
413 state = KABPrefs::instance()->mJumpButtonBarVisible; 422 state = KABPrefs::instance()->mJumpButtonBarVisible;
414 423
415 mActionJumpBar->setChecked( state ); 424 mActionJumpBar->setChecked( state );
416 setJumpButtonBarVisible( state ); 425 setJumpButtonBarVisible( state );
417/*US 426/*US
418 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 427 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
419 if ( splitterSize.count() == 0 ) { 428 if ( splitterSize.count() == 0 ) {
420 splitterSize.append( width() / 2 ); 429 splitterSize.append( width() / 2 );
421 splitterSize.append( width() / 2 ); 430 splitterSize.append( width() / 2 );
422 } 431 }
423 mMiniSplitter->setSizes( splitterSize ); 432 mMiniSplitter->setSizes( splitterSize );
424 if ( mExtensionBarSplitter ) { 433 if ( mExtensionBarSplitter ) {
425 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 434 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
426 if ( splitterSize.count() == 0 ) { 435 if ( splitterSize.count() == 0 ) {
427 splitterSize.append( width() / 2 ); 436 splitterSize.append( width() / 2 );
428 splitterSize.append( width() / 2 ); 437 splitterSize.append( width() / 2 );
429 } 438 }
430 mExtensionBarSplitter->setSizes( splitterSize ); 439 mExtensionBarSplitter->setSizes( splitterSize );
431 440
432 } 441 }
433*/ 442*/
434 mViewManager->restoreSettings(); 443 mViewManager->restoreSettings();
435 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 444 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
436 mExtensionManager->restoreSettings(); 445 mExtensionManager->restoreSettings();
437#ifdef DESKTOP_VERSION 446#ifdef DESKTOP_VERSION
438 int wid = width(); 447 int wid = width();
439 if ( wid < 10 ) 448 if ( wid < 10 )
440 wid = 400; 449 wid = 400;
441#else 450#else
442 int wid = QApplication::desktop()->width(); 451 int wid = QApplication::desktop()->width();
443 if ( wid < 640 ) 452 if ( wid < 640 )
444 wid = QApplication::desktop()->height(); 453 wid = QApplication::desktop()->height();
445#endif 454#endif
446 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 455 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
447 if ( true /*splitterSize.count() == 0*/ ) { 456 if ( true /*splitterSize.count() == 0*/ ) {
448 splitterSize.append( wid / 2 ); 457 splitterSize.append( wid / 2 );
449 splitterSize.append( wid / 2 ); 458 splitterSize.append( wid / 2 );
450 } 459 }
451 mMiniSplitter->setSizes( splitterSize ); 460 mMiniSplitter->setSizes( splitterSize );
452 if ( mExtensionBarSplitter ) { 461 if ( mExtensionBarSplitter ) {
453 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 462 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
454 if ( true /*splitterSize.count() == 0*/ ) { 463 if ( true /*splitterSize.count() == 0*/ ) {
455 splitterSize.append( wid / 2 ); 464 splitterSize.append( wid / 2 );
456 splitterSize.append( wid / 2 ); 465 splitterSize.append( wid / 2 );
457 } 466 }
458 mExtensionBarSplitter->setSizes( splitterSize ); 467 mExtensionBarSplitter->setSizes( splitterSize );
459 468
460 } 469 }
461 470
462 471
463} 472}
464 473
465void KABCore::saveSettings() 474void KABCore::saveSettings()
466{ 475{
467 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 476 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
468 if ( mExtensionBarSplitter ) 477 if ( mExtensionBarSplitter )
469 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 478 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
470 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 479 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
471 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 480 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
472#ifndef KAB_EMBEDDED 481#ifndef KAB_EMBEDDED
473 482
474 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 483 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
475 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 484 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
476#endif //KAB_EMBEDDED 485#endif //KAB_EMBEDDED
477 mExtensionManager->saveSettings(); 486 mExtensionManager->saveSettings();
478 mViewManager->saveSettings(); 487 mViewManager->saveSettings();
479 488
480 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 489 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
481} 490}
482 491
483KABC::AddressBook *KABCore::addressBook() const 492KABC::AddressBook *KABCore::addressBook() const
484{ 493{
485 return mAddressBook; 494 return mAddressBook;
486} 495}
487 496
488KConfig *KABCore::config() 497KConfig *KABCore::config()
489{ 498{
490#ifndef KAB_EMBEDDED 499#ifndef KAB_EMBEDDED
491 return KABPrefs::instance()->config(); 500 return KABPrefs::instance()->config();
492#else //KAB_EMBEDDED 501#else //KAB_EMBEDDED
493 return KABPrefs::instance()->getConfig(); 502 return KABPrefs::instance()->getConfig();
494#endif //KAB_EMBEDDED 503#endif //KAB_EMBEDDED
495} 504}
496 505
497KActionCollection *KABCore::actionCollection() const 506KActionCollection *KABCore::actionCollection() const
498{ 507{
499 return mGUIClient->actionCollection(); 508 return mGUIClient->actionCollection();
500} 509}
501 510
502KABC::Field *KABCore::currentSearchField() const 511KABC::Field *KABCore::currentSearchField() const
503{ 512{
504 if (mIncSearchWidget) 513 if (mIncSearchWidget)
505 return mIncSearchWidget->currentField(); 514 return mIncSearchWidget->currentField();
506 else 515 else
507 return 0; 516 return 0;
508} 517}
509 518
510QStringList KABCore::selectedUIDs() const 519QStringList KABCore::selectedUIDs() const
511{ 520{
512 return mViewManager->selectedUids(); 521 return mViewManager->selectedUids();
513} 522}
514 523
515KABC::Resource *KABCore::requestResource( QWidget *parent ) 524KABC::Resource *KABCore::requestResource( QWidget *parent )
516{ 525{
517 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 526 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
518 527
519 QPtrList<KRES::Resource> kresResources; 528 QPtrList<KRES::Resource> kresResources;
520 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 529 QPtrListIterator<KABC::Resource> resIt( kabcResources );
521 KABC::Resource *resource; 530 KABC::Resource *resource;
522 while ( ( resource = resIt.current() ) != 0 ) { 531 while ( ( resource = resIt.current() ) != 0 ) {
523 ++resIt; 532 ++resIt;
524 if ( !resource->readOnly() ) { 533 if ( !resource->readOnly() ) {
525 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 534 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
526 if ( res ) 535 if ( res )
527 kresResources.append( res ); 536 kresResources.append( res );
528 } 537 }
529 } 538 }
530 539
531 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 540 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
532 return static_cast<KABC::Resource*>( res ); 541 return static_cast<KABC::Resource*>( res );
533} 542}
534 543
535#ifndef KAB_EMBEDDED 544#ifndef KAB_EMBEDDED
536KAboutData *KABCore::createAboutData() 545KAboutData *KABCore::createAboutData()
537#else //KAB_EMBEDDED 546#else //KAB_EMBEDDED
538void KABCore::createAboutData() 547void KABCore::createAboutData()
539#endif //KAB_EMBEDDED 548#endif //KAB_EMBEDDED
540{ 549{
541#ifndef KAB_EMBEDDED 550#ifndef KAB_EMBEDDED
542 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 551 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
543 "3.1", I18N_NOOP( "The KDE Address Book" ), 552 "3.1", I18N_NOOP( "The KDE Address Book" ),
544 KAboutData::License_GPL_V2, 553 KAboutData::License_GPL_V2,
545 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 554 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
546 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 555 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
547 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 556 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
548 about->addAuthor( "Cornelius Schumacher", 557 about->addAuthor( "Cornelius Schumacher",
549 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 558 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
550 "schumacher@kde.org" ); 559 "schumacher@kde.org" );
551 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 560 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
552 "mpilone@slac.com" ); 561 "mpilone@slac.com" );
553 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 562 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
554 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 563 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
555 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 564 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
556 "michel@klaralvdalens-datakonsult.se" ); 565 "michel@klaralvdalens-datakonsult.se" );
557 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 566 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
558 "hansen@kde.org" ); 567 "hansen@kde.org" );
559 568
560 return about; 569 return about;
561#endif //KAB_EMBEDDED 570#endif //KAB_EMBEDDED
562 571
563 QString version; 572 QString version;
564#include <../version> 573#include <../version>
565 QMessageBox::about( this, "About KAddressbook/Pi", 574 QMessageBox::about( this, "About KAddressbook/Pi",
566 "KAddressbook/Platform-independent\n" 575 "KAddressbook/Platform-independent\n"
567 "(KA/Pi) " +version + " - " + 576 "(KA/Pi) " +version + " - " +
568#ifdef DESKTOP_VERSION 577#ifdef DESKTOP_VERSION
569 "Desktop Edition\n" 578 "Desktop Edition\n"
570#else 579#else
571 "PDA-Edition\n" 580 "PDA-Edition\n"
572 "for: Zaurus 5500 / 7x0 / 8x0\n" 581 "for: Zaurus 5500 / 7x0 / 8x0\n"
573#endif 582#endif
574 583
575 "(c) 2004 Ulf Schenk\n" 584 "(c) 2004 Ulf Schenk\n"
576 "(c) 2004 Lutz Rogowski\n" 585 "(c) 2004 Lutz Rogowski\n"
577 "(c) 1997-2003, The KDE PIM Team\n" 586 "(c) 1997-2003, The KDE PIM Team\n"
578 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 587 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
579 "Don Sanders Original author\n" 588 "Don Sanders Original author\n"
580 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 589 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
581 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 590 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
582 "Greg Stern DCOP interface\n" 591 "Greg Stern DCOP interface\n"
583 "Mark Westcot Contact pinning\n" 592 "Mark Westcot Contact pinning\n"
584 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 593 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
585 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 594 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
586#ifdef _WIN32_ 595#ifdef _WIN32_
587 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 596 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
588#endif 597#endif
589 ); 598 );
590} 599}
591 600
592void KABCore::setContactSelected( const QString &uid ) 601void KABCore::setContactSelected( const QString &uid )
593{ 602{
594 KABC::Addressee addr = mAddressBook->findByUid( uid ); 603 KABC::Addressee addr = mAddressBook->findByUid( uid );
595 if ( !mDetails->isHidden() ) 604 if ( !mDetails->isHidden() )
596 mDetails->setAddressee( addr ); 605 mDetails->setAddressee( addr );
597 606
598 if ( !addr.isEmpty() ) { 607 if ( !addr.isEmpty() ) {
599 emit contactSelected( addr.formattedName() ); 608 emit contactSelected( addr.formattedName() );
600 KABC::Picture pic = addr.photo(); 609 KABC::Picture pic = addr.photo();
601 if ( pic.isIntern() ) { 610 if ( pic.isIntern() ) {
602//US emit contactSelected( pic.data() ); 611//US emit contactSelected( pic.data() );
603//US instead use: 612//US instead use:
604 QPixmap px; 613 QPixmap px;
605 if (pic.data().isNull() != true) 614 if (pic.data().isNull() != true)
606 { 615 {
607 px.convertFromImage(pic.data()); 616 px.convertFromImage(pic.data());
608 } 617 }
609 618
610 emit contactSelected( px ); 619 emit contactSelected( px );
611 } 620 }
612 } 621 }
613 622
614 623
615 mExtensionManager->setSelectionChanged(); 624 mExtensionManager->setSelectionChanged();
616 625
617 // update the actions 626 // update the actions
618 bool selected = !uid.isEmpty(); 627 bool selected = !uid.isEmpty();
619 628
620 if ( mReadWrite ) { 629 if ( mReadWrite ) {
621 mActionCut->setEnabled( selected ); 630 mActionCut->setEnabled( selected );
622 mActionPaste->setEnabled( selected ); 631 mActionPaste->setEnabled( selected );
623 } 632 }
624 633
625 mActionCopy->setEnabled( selected ); 634 mActionCopy->setEnabled( selected );
626 mActionDelete->setEnabled( selected ); 635 mActionDelete->setEnabled( selected );
627 mActionEditAddressee->setEnabled( selected ); 636 mActionEditAddressee->setEnabled( selected );
628 mActionMail->setEnabled( selected ); 637 mActionMail->setEnabled( selected );
629 mActionMailVCard->setEnabled( selected ); 638 mActionMailVCard->setEnabled( selected );
630 //if (mActionBeam) 639 //if (mActionBeam)
631 //mActionBeam->setEnabled( selected ); 640 //mActionBeam->setEnabled( selected );
632 641
633 if (mActionBeamVCard) 642 if (mActionBeamVCard)
634 mActionBeamVCard->setEnabled( selected ); 643 mActionBeamVCard->setEnabled( selected );
635 644
636 mActionExport2phone->setEnabled( selected ); 645 mActionExport2phone->setEnabled( selected );
637 mActionWhoAmI->setEnabled( selected ); 646 mActionWhoAmI->setEnabled( selected );
638 mActionCategories->setEnabled( selected ); 647 mActionCategories->setEnabled( selected );
639} 648}
640 649
641void KABCore::sendMail() 650void KABCore::sendMail()
642{ 651{
643 sendMail( mViewManager->selectedEmails().join( ", " ) ); 652 sendMail( mViewManager->selectedEmails().join( ", " ) );
644} 653}
645 654
646void KABCore::sendMail( const QString& emaillist ) 655void KABCore::sendMail( const QString& emaillist )
647{ 656{
648 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 657 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
649 if (emaillist.contains(",") > 0) 658 if (emaillist.contains(",") > 0)
650 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 659 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
651 else 660 else
652 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 661 ExternalAppHandler::instance()->mailToOneContact( emaillist );
653} 662}
654 663
655 664
656 665
657void KABCore::mailVCard() 666void KABCore::mailVCard()
658{ 667{
659 QStringList uids = mViewManager->selectedUids(); 668 QStringList uids = mViewManager->selectedUids();
660 if ( !uids.isEmpty() ) 669 if ( !uids.isEmpty() )
661 mailVCard( uids ); 670 mailVCard( uids );
662} 671}
663 672
664void KABCore::mailVCard( const QStringList& uids ) 673void KABCore::mailVCard( const QStringList& uids )
665{ 674{
666 QStringList urls; 675 QStringList urls;
667 676
668// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 677// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
669 678
670 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 679 QString dirName = "/tmp/" + KApplication::randomString( 8 );
671 680
672 681
673 682
674 QDir().mkdir( dirName, true ); 683 QDir().mkdir( dirName, true );
675 684
676 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 685 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
677 KABC::Addressee a = mAddressBook->findByUid( *it ); 686 KABC::Addressee a = mAddressBook->findByUid( *it );
678 687
679 if ( a.isEmpty() ) 688 if ( a.isEmpty() )
680 continue; 689 continue;
681 690
682 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 691 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
683 692
684 QString fileName = dirName + "/" + name; 693 QString fileName = dirName + "/" + name;
685 694
686 QFile outFile(fileName); 695 QFile outFile(fileName);
687 696
688 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 697 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
689 KABC::VCardConverter converter; 698 KABC::VCardConverter converter;
690 QString vcard; 699 QString vcard;
691 700
692 converter.addresseeToVCard( a, vcard ); 701 converter.addresseeToVCard( a, vcard );
693 702
694 QTextStream t( &outFile ); // use a text stream 703 QTextStream t( &outFile ); // use a text stream
695 t.setEncoding( QTextStream::UnicodeUTF8 ); 704 t.setEncoding( QTextStream::UnicodeUTF8 );
696 t << vcard; 705 t << vcard;
697 706
698 outFile.close(); 707 outFile.close();
699 708
700 urls.append( fileName ); 709 urls.append( fileName );
701 } 710 }
702 } 711 }
703 712
704 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 713 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
705 714
706 715
707/*US 716/*US
708 kapp->invokeMailer( QString::null, QString::null, QString::null, 717 kapp->invokeMailer( QString::null, QString::null, QString::null,
709 QString::null, // subject 718 QString::null, // subject
710 QString::null, // body 719 QString::null, // body
711 QString::null, 720 QString::null,
712 urls ); // attachments 721 urls ); // attachments
713*/ 722*/
714 723
715} 724}
716 725
717/** 726/**
718 Beams the "WhoAmI contact. 727 Beams the "WhoAmI contact.
719*/ 728*/
720void KABCore::beamMySelf() 729void KABCore::beamMySelf()
721{ 730{
722 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 731 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
723 if (!a.isEmpty()) 732 if (!a.isEmpty())
724 { 733 {
725 QStringList uids; 734 QStringList uids;
726 uids << a.uid(); 735 uids << a.uid();
727 736
728 beamVCard(uids); 737 beamVCard(uids);
729 } else { 738 } else {
730 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 739 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
731 740
732 741
733 } 742 }
734} 743}
735 744
736void KABCore::export2phone() 745void KABCore::export2phone()
737{ 746{
738 747
739 KAex2phonePrefs ex2phone; 748 KAex2phonePrefs ex2phone;
740 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 749 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
741 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 750 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
742 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 751 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
743 752
744 if ( !ex2phone.exec() ) { 753 if ( !ex2phone.exec() ) {
745 return; 754 return;
746 } 755 }
747 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 756 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
748 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 757 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
749 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 758 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
750 759
751 760
752 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 761 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
753 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 762 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
754 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 763 KPimGlobalPrefs::instance()->mEx2PhoneModel );
755 764
756 QStringList uids = mViewManager->selectedUids(); 765 QStringList uids = mViewManager->selectedUids();
757 if ( uids.isEmpty() ) 766 if ( uids.isEmpty() )
758 return; 767 return;
759 768
760 QString fileName = getPhoneFile(); 769 QString fileName = getPhoneFile();
761 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 770 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
762 return; 771 return;
763 772
764 message(i18n("Exporting to phone...")); 773 message(i18n("Exporting to phone..."));
765 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 774 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
766 775
767} 776}
768QString KABCore::getPhoneFile() 777QString KABCore::getPhoneFile()
769{ 778{
770#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
771 return locateLocal("tmp", "phonefile.vcf"); 780 return locateLocal("tmp", "phonefile.vcf");
772#else 781#else
773 return "/tmp/phonefile.vcf"; 782 return "/tmp/phonefile.vcf";
774#endif 783#endif
775 784
776} 785}
777void KABCore::writeToPhone( ) 786void KABCore::writeToPhone( )
778{ 787{
779 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 788 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
780 message(i18n("Export to phone finished!")); 789 message(i18n("Export to phone finished!"));
781 else 790 else
782 qDebug(i18n("Error exporting to phone")); 791 qDebug(i18n("Error exporting to phone"));
783} 792}
784void KABCore::beamVCard() 793void KABCore::beamVCard()
785{ 794{
786 QStringList uids = mViewManager->selectedUids(); 795 QStringList uids = mViewManager->selectedUids();
787 if ( !uids.isEmpty() ) 796 if ( !uids.isEmpty() )
788 beamVCard( uids ); 797 beamVCard( uids );
789} 798}
790 799
791 800
792void KABCore::beamVCard(const QStringList& uids) 801void KABCore::beamVCard(const QStringList& uids)
793{ 802{
794 803
795 // LR: we should use the /tmp dir on the Zaurus, 804 // LR: we should use the /tmp dir on the Zaurus,
796 // because: /tmp = RAM, (HOME)/kdepim = flash memory 805 // because: /tmp = RAM, (HOME)/kdepim = flash memory
797 806
798#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
799 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 808 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
800#else 809#else
801 QString fileName = "/tmp/kapibeamfile.vcf"; 810 QString fileName = "/tmp/kapibeamfile.vcf";
802#endif 811#endif
803 812
804 KABC::VCardConverter converter; 813 KABC::VCardConverter converter;
805 QString description; 814 QString description;
806 QString datastream; 815 QString datastream;
807 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 816 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
808 KABC::Addressee a = mAddressBook->findByUid( *it ); 817 KABC::Addressee a = mAddressBook->findByUid( *it );
809 818
810 if ( a.isEmpty() ) 819 if ( a.isEmpty() )
811 continue; 820 continue;
812 821
813 if (description.isEmpty()) 822 if (description.isEmpty())
814 description = a.formattedName(); 823 description = a.formattedName();
815 824
816 QString vcard; 825 QString vcard;
817 converter.addresseeToVCard( a, vcard ); 826 converter.addresseeToVCard( a, vcard );
818 int start = 0; 827 int start = 0;
819 int next; 828 int next;
820 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 829 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
821 int semi = vcard.find(";", next); 830 int semi = vcard.find(";", next);
822 int dopp = vcard.find(":", next); 831 int dopp = vcard.find(":", next);
823 int sep; 832 int sep;
824 if ( semi < dopp && semi >= 0 ) 833 if ( semi < dopp && semi >= 0 )
825 sep = semi ; 834 sep = semi ;
826 else 835 else
827 sep = dopp; 836 sep = dopp;
828 datastream +=vcard.mid( start, next - start); 837 datastream +=vcard.mid( start, next - start);
829 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 838 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
830 start = sep; 839 start = sep;
831 } 840 }
832 datastream += vcard.mid( start,vcard.length() ); 841 datastream += vcard.mid( start,vcard.length() );
833 } 842 }
834#ifndef DESKTOP_VERSION 843#ifndef DESKTOP_VERSION
835 QFile outFile(fileName); 844 QFile outFile(fileName);
836 if ( outFile.open(IO_WriteOnly) ) { 845 if ( outFile.open(IO_WriteOnly) ) {
837 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 846 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
838 QTextStream t( &outFile ); // use a text stream 847 QTextStream t( &outFile ); // use a text stream
839 //t.setEncoding( QTextStream::UnicodeUTF8 ); 848 //t.setEncoding( QTextStream::UnicodeUTF8 );
840 t.setEncoding( QTextStream::Latin1 ); 849 t.setEncoding( QTextStream::Latin1 );
841 t <<datastream.latin1(); 850 t <<datastream.latin1();
842 outFile.close(); 851 outFile.close();
843 Ir *ir = new Ir( this ); 852 Ir *ir = new Ir( this );
844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 853 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
845 ir->send( fileName, description, "text/x-vCard" ); 854 ir->send( fileName, description, "text/x-vCard" );
846 } else { 855 } else {
847 qDebug("Error open temp beam file "); 856 qDebug("Error open temp beam file ");
848 return; 857 return;
849 } 858 }
850#endif 859#endif
851 860
852} 861}
853 862
854void KABCore::beamDone( Ir *ir ) 863void KABCore::beamDone( Ir *ir )
855{ 864{
856#ifndef DESKTOP_VERSION 865#ifndef DESKTOP_VERSION
857 delete ir; 866 delete ir;
858#endif 867#endif
859 topLevelWidget()->raise(); 868 topLevelWidget()->raise();
860 message( i18n("Beaming finished!") ); 869 message( i18n("Beaming finished!") );