summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-10-28 17:09:29 (UTC)
committer ulf69 <ulf69>2004-10-28 17:09:29 (UTC)
commit5c64eb04c048d7e51f1c71621e1d37c5c0c580a0 (patch) (unidiff)
treec0c3a06395729d25feeb930479bb153d964a71db
parent709e2793be2dd47dc0a15488f43fd2f058db2036 (diff)
downloadkdepimpi-5c64eb04c048d7e51f1c71621e1d37c5c0c580a0.zip
kdepimpi-5c64eb04c048d7e51f1c71621e1d37c5c0c580a0.tar.gz
kdepimpi-5c64eb04c048d7e51f1c71621e1d37c5c0c580a0.tar.bz2
undo nextView fix. Zautrix did the same already in externalapphandler
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp9
1 files changed, 0 insertions, 9 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 9ef97c9..ea103a9 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1125 +1,1116 @@
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
358} 349}
359void KABCore::toggleBeamReceive( ) 350void KABCore::toggleBeamReceive( )
360{ 351{
361 if ( mBRdisabled ) 352 if ( mBRdisabled )
362 return; 353 return;
363#ifndef DESKTOP_VERSION 354#ifndef DESKTOP_VERSION
364 if ( infrared ) { 355 if ( infrared ) {
365 qDebug("AB disable BeamReceive "); 356 qDebug("AB disable BeamReceive ");
366 delete infrared; 357 delete infrared;
367 infrared = 0; 358 infrared = 0;
368 mActionBR->setChecked(false); 359 mActionBR->setChecked(false);
369 return; 360 return;
370 } 361 }
371 qDebug("AB enable BeamReceive "); 362 qDebug("AB enable BeamReceive ");
372 mActionBR->setChecked(true); 363 mActionBR->setChecked(true);
373 364
374 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 365 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
375 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 366 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
376#endif 367#endif
377} 368}
378 369
379 370
380void KABCore::disableBR(bool b) 371void KABCore::disableBR(bool b)
381{ 372{
382#ifndef DESKTOP_VERSION 373#ifndef DESKTOP_VERSION
383 if ( b ) { 374 if ( b ) {
384 if ( infrared ) { 375 if ( infrared ) {
385 toggleBeamReceive( ); 376 toggleBeamReceive( );
386 } 377 }
387 mBRdisabled = true; 378 mBRdisabled = true;
388 } else { 379 } else {
389 if ( mBRdisabled ) { 380 if ( mBRdisabled ) {
390 mBRdisabled = false; 381 mBRdisabled = false;
391 //toggleBeamReceive( ); 382 //toggleBeamReceive( );
392 } 383 }
393 } 384 }
394#endif 385#endif
395 386
396} 387}
397void KABCore::recieve( QString fn ) 388void KABCore::recieve( QString fn )
398{ 389{
399 //qDebug("KABCore::recieve "); 390 //qDebug("KABCore::recieve ");
400 int count = mAddressBook->importFromFile( fn, true ); 391 int count = mAddressBook->importFromFile( fn, true );
401 if ( count ) 392 if ( count )
402 setModified( true ); 393 setModified( true );
403 mViewManager->refreshView(); 394 mViewManager->refreshView();
404 message(i18n("%1 contact(s) received!").arg( count )); 395 message(i18n("%1 contact(s) received!").arg( count ));
405 topLevelWidget()->showMaximized(); 396 topLevelWidget()->showMaximized();
406 topLevelWidget()->raise(); 397 topLevelWidget()->raise();
407} 398}
408void KABCore::restoreSettings() 399void KABCore::restoreSettings()
409{ 400{
410 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 401 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
411 402
412 bool state; 403 bool state;
413 404
414 if (mMultipleViewsAtOnce) 405 if (mMultipleViewsAtOnce)
415 state = KABPrefs::instance()->mDetailsPageVisible; 406 state = KABPrefs::instance()->mDetailsPageVisible;
416 else 407 else
417 state = false; 408 state = false;
418 409
419 mActionDetails->setChecked( state ); 410 mActionDetails->setChecked( state );
420 setDetailsVisible( state ); 411 setDetailsVisible( state );
421 412
422 state = KABPrefs::instance()->mJumpButtonBarVisible; 413 state = KABPrefs::instance()->mJumpButtonBarVisible;
423 414
424 mActionJumpBar->setChecked( state ); 415 mActionJumpBar->setChecked( state );
425 setJumpButtonBarVisible( state ); 416 setJumpButtonBarVisible( state );
426/*US 417/*US
427 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 418 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
428 if ( splitterSize.count() == 0 ) { 419 if ( splitterSize.count() == 0 ) {
429 splitterSize.append( width() / 2 ); 420 splitterSize.append( width() / 2 );
430 splitterSize.append( width() / 2 ); 421 splitterSize.append( width() / 2 );
431 } 422 }
432 mMiniSplitter->setSizes( splitterSize ); 423 mMiniSplitter->setSizes( splitterSize );
433 if ( mExtensionBarSplitter ) { 424 if ( mExtensionBarSplitter ) {
434 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 425 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
435 if ( splitterSize.count() == 0 ) { 426 if ( splitterSize.count() == 0 ) {
436 splitterSize.append( width() / 2 ); 427 splitterSize.append( width() / 2 );
437 splitterSize.append( width() / 2 ); 428 splitterSize.append( width() / 2 );
438 } 429 }
439 mExtensionBarSplitter->setSizes( splitterSize ); 430 mExtensionBarSplitter->setSizes( splitterSize );
440 431
441 } 432 }
442*/ 433*/
443 mViewManager->restoreSettings(); 434 mViewManager->restoreSettings();
444 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 435 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
445 mExtensionManager->restoreSettings(); 436 mExtensionManager->restoreSettings();
446#ifdef DESKTOP_VERSION 437#ifdef DESKTOP_VERSION
447 int wid = width(); 438 int wid = width();
448 if ( wid < 10 ) 439 if ( wid < 10 )
449 wid = 400; 440 wid = 400;
450#else 441#else
451 int wid = QApplication::desktop()->width(); 442 int wid = QApplication::desktop()->width();
452 if ( wid < 640 ) 443 if ( wid < 640 )
453 wid = QApplication::desktop()->height(); 444 wid = QApplication::desktop()->height();
454#endif 445#endif
455 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 446 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
456 if ( true /*splitterSize.count() == 0*/ ) { 447 if ( true /*splitterSize.count() == 0*/ ) {
457 splitterSize.append( wid / 2 ); 448 splitterSize.append( wid / 2 );
458 splitterSize.append( wid / 2 ); 449 splitterSize.append( wid / 2 );
459 } 450 }
460 mMiniSplitter->setSizes( splitterSize ); 451 mMiniSplitter->setSizes( splitterSize );
461 if ( mExtensionBarSplitter ) { 452 if ( mExtensionBarSplitter ) {
462 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 453 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
463 if ( true /*splitterSize.count() == 0*/ ) { 454 if ( true /*splitterSize.count() == 0*/ ) {
464 splitterSize.append( wid / 2 ); 455 splitterSize.append( wid / 2 );
465 splitterSize.append( wid / 2 ); 456 splitterSize.append( wid / 2 );
466 } 457 }
467 mExtensionBarSplitter->setSizes( splitterSize ); 458 mExtensionBarSplitter->setSizes( splitterSize );
468 459
469 } 460 }
470 461
471 462
472} 463}
473 464
474void KABCore::saveSettings() 465void KABCore::saveSettings()
475{ 466{
476 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 467 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
477 if ( mExtensionBarSplitter ) 468 if ( mExtensionBarSplitter )
478 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 469 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
479 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 470 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
480 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 471 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
481#ifndef KAB_EMBEDDED 472#ifndef KAB_EMBEDDED
482 473
483 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 474 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
484 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 475 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
485#endif //KAB_EMBEDDED 476#endif //KAB_EMBEDDED
486 mExtensionManager->saveSettings(); 477 mExtensionManager->saveSettings();
487 mViewManager->saveSettings(); 478 mViewManager->saveSettings();
488 479
489 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 480 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
490} 481}
491 482
492KABC::AddressBook *KABCore::addressBook() const 483KABC::AddressBook *KABCore::addressBook() const
493{ 484{
494 return mAddressBook; 485 return mAddressBook;
495} 486}
496 487
497KConfig *KABCore::config() 488KConfig *KABCore::config()
498{ 489{
499#ifndef KAB_EMBEDDED 490#ifndef KAB_EMBEDDED
500 return KABPrefs::instance()->config(); 491 return KABPrefs::instance()->config();
501#else //KAB_EMBEDDED 492#else //KAB_EMBEDDED
502 return KABPrefs::instance()->getConfig(); 493 return KABPrefs::instance()->getConfig();
503#endif //KAB_EMBEDDED 494#endif //KAB_EMBEDDED
504} 495}
505 496
506KActionCollection *KABCore::actionCollection() const 497KActionCollection *KABCore::actionCollection() const
507{ 498{
508 return mGUIClient->actionCollection(); 499 return mGUIClient->actionCollection();
509} 500}
510 501
511KABC::Field *KABCore::currentSearchField() const 502KABC::Field *KABCore::currentSearchField() const
512{ 503{
513 if (mIncSearchWidget) 504 if (mIncSearchWidget)
514 return mIncSearchWidget->currentField(); 505 return mIncSearchWidget->currentField();
515 else 506 else
516 return 0; 507 return 0;
517} 508}
518 509
519QStringList KABCore::selectedUIDs() const 510QStringList KABCore::selectedUIDs() const
520{ 511{
521 return mViewManager->selectedUids(); 512 return mViewManager->selectedUids();
522} 513}
523 514
524KABC::Resource *KABCore::requestResource( QWidget *parent ) 515KABC::Resource *KABCore::requestResource( QWidget *parent )
525{ 516{
526 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 517 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
527 518
528 QPtrList<KRES::Resource> kresResources; 519 QPtrList<KRES::Resource> kresResources;
529 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 520 QPtrListIterator<KABC::Resource> resIt( kabcResources );
530 KABC::Resource *resource; 521 KABC::Resource *resource;
531 while ( ( resource = resIt.current() ) != 0 ) { 522 while ( ( resource = resIt.current() ) != 0 ) {
532 ++resIt; 523 ++resIt;
533 if ( !resource->readOnly() ) { 524 if ( !resource->readOnly() ) {
534 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 525 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
535 if ( res ) 526 if ( res )
536 kresResources.append( res ); 527 kresResources.append( res );
537 } 528 }
538 } 529 }
539 530
540 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 531 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
541 return static_cast<KABC::Resource*>( res ); 532 return static_cast<KABC::Resource*>( res );
542} 533}
543 534
544#ifndef KAB_EMBEDDED 535#ifndef KAB_EMBEDDED
545KAboutData *KABCore::createAboutData() 536KAboutData *KABCore::createAboutData()
546#else //KAB_EMBEDDED 537#else //KAB_EMBEDDED
547void KABCore::createAboutData() 538void KABCore::createAboutData()
548#endif //KAB_EMBEDDED 539#endif //KAB_EMBEDDED
549{ 540{
550#ifndef KAB_EMBEDDED 541#ifndef KAB_EMBEDDED
551 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 542 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
552 "3.1", I18N_NOOP( "The KDE Address Book" ), 543 "3.1", I18N_NOOP( "The KDE Address Book" ),
553 KAboutData::License_GPL_V2, 544 KAboutData::License_GPL_V2,
554 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 545 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
555 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 546 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
556 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 547 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
557 about->addAuthor( "Cornelius Schumacher", 548 about->addAuthor( "Cornelius Schumacher",
558 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 549 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
559 "schumacher@kde.org" ); 550 "schumacher@kde.org" );
560 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 551 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
561 "mpilone@slac.com" ); 552 "mpilone@slac.com" );
562 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 553 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
563 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 554 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
564 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 555 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
565 "michel@klaralvdalens-datakonsult.se" ); 556 "michel@klaralvdalens-datakonsult.se" );
566 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 557 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
567 "hansen@kde.org" ); 558 "hansen@kde.org" );
568 559
569 return about; 560 return about;
570#endif //KAB_EMBEDDED 561#endif //KAB_EMBEDDED
571 562
572 QString version; 563 QString version;
573#include <../version> 564#include <../version>
574 QMessageBox::about( this, "About KAddressbook/Pi", 565 QMessageBox::about( this, "About KAddressbook/Pi",
575 "KAddressbook/Platform-independent\n" 566 "KAddressbook/Platform-independent\n"
576 "(KA/Pi) " +version + " - " + 567 "(KA/Pi) " +version + " - " +
577#ifdef DESKTOP_VERSION 568#ifdef DESKTOP_VERSION
578 "Desktop Edition\n" 569 "Desktop Edition\n"
579#else 570#else
580 "PDA-Edition\n" 571 "PDA-Edition\n"
581 "for: Zaurus 5500 / 7x0 / 8x0\n" 572 "for: Zaurus 5500 / 7x0 / 8x0\n"
582#endif 573#endif
583 574
584 "(c) 2004 Ulf Schenk\n" 575 "(c) 2004 Ulf Schenk\n"
585 "(c) 2004 Lutz Rogowski\n" 576 "(c) 2004 Lutz Rogowski\n"
586 "(c) 1997-2003, The KDE PIM Team\n" 577 "(c) 1997-2003, The KDE PIM Team\n"
587 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 578 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
588 "Don Sanders Original author\n" 579 "Don Sanders Original author\n"
589 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 580 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
590 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 581 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
591 "Greg Stern DCOP interface\n" 582 "Greg Stern DCOP interface\n"
592 "Mark Westcot Contact pinning\n" 583 "Mark Westcot Contact pinning\n"
593 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 584 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
594 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 585 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
595#ifdef _WIN32_ 586#ifdef _WIN32_
596 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 587 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
597#endif 588#endif
598 ); 589 );
599} 590}
600 591
601void KABCore::setContactSelected( const QString &uid ) 592void KABCore::setContactSelected( const QString &uid )
602{ 593{
603 KABC::Addressee addr = mAddressBook->findByUid( uid ); 594 KABC::Addressee addr = mAddressBook->findByUid( uid );
604 if ( !mDetails->isHidden() ) 595 if ( !mDetails->isHidden() )
605 mDetails->setAddressee( addr ); 596 mDetails->setAddressee( addr );
606 597
607 if ( !addr.isEmpty() ) { 598 if ( !addr.isEmpty() ) {
608 emit contactSelected( addr.formattedName() ); 599 emit contactSelected( addr.formattedName() );
609 KABC::Picture pic = addr.photo(); 600 KABC::Picture pic = addr.photo();
610 if ( pic.isIntern() ) { 601 if ( pic.isIntern() ) {
611//US emit contactSelected( pic.data() ); 602//US emit contactSelected( pic.data() );
612//US instead use: 603//US instead use:
613 QPixmap px; 604 QPixmap px;
614 if (pic.data().isNull() != true) 605 if (pic.data().isNull() != true)
615 { 606 {
616 px.convertFromImage(pic.data()); 607 px.convertFromImage(pic.data());
617 } 608 }
618 609
619 emit contactSelected( px ); 610 emit contactSelected( px );
620 } 611 }
621 } 612 }
622 613
623 614
624 mExtensionManager->setSelectionChanged(); 615 mExtensionManager->setSelectionChanged();
625 616
626 // update the actions 617 // update the actions
627 bool selected = !uid.isEmpty(); 618 bool selected = !uid.isEmpty();
628 619
629 if ( mReadWrite ) { 620 if ( mReadWrite ) {
630 mActionCut->setEnabled( selected ); 621 mActionCut->setEnabled( selected );
631 mActionPaste->setEnabled( selected ); 622 mActionPaste->setEnabled( selected );
632 } 623 }
633 624
634 mActionCopy->setEnabled( selected ); 625 mActionCopy->setEnabled( selected );
635 mActionDelete->setEnabled( selected ); 626 mActionDelete->setEnabled( selected );
636 mActionEditAddressee->setEnabled( selected ); 627 mActionEditAddressee->setEnabled( selected );
637 mActionMail->setEnabled( selected ); 628 mActionMail->setEnabled( selected );
638 mActionMailVCard->setEnabled( selected ); 629 mActionMailVCard->setEnabled( selected );
639 //if (mActionBeam) 630 //if (mActionBeam)
640 //mActionBeam->setEnabled( selected ); 631 //mActionBeam->setEnabled( selected );
641 632
642 if (mActionBeamVCard) 633 if (mActionBeamVCard)
643 mActionBeamVCard->setEnabled( selected ); 634 mActionBeamVCard->setEnabled( selected );
644 635
645 mActionExport2phone->setEnabled( selected ); 636 mActionExport2phone->setEnabled( selected );
646 mActionWhoAmI->setEnabled( selected ); 637 mActionWhoAmI->setEnabled( selected );
647 mActionCategories->setEnabled( selected ); 638 mActionCategories->setEnabled( selected );
648} 639}
649 640
650void KABCore::sendMail() 641void KABCore::sendMail()
651{ 642{
652 sendMail( mViewManager->selectedEmails().join( ", " ) ); 643 sendMail( mViewManager->selectedEmails().join( ", " ) );
653} 644}
654 645
655void KABCore::sendMail( const QString& emaillist ) 646void KABCore::sendMail( const QString& emaillist )
656{ 647{
657 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 648 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
658 if (emaillist.contains(",") > 0) 649 if (emaillist.contains(",") > 0)
659 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 650 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
660 else 651 else
661 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 652 ExternalAppHandler::instance()->mailToOneContact( emaillist );
662} 653}
663 654
664 655
665 656
666void KABCore::mailVCard() 657void KABCore::mailVCard()
667{ 658{
668 QStringList uids = mViewManager->selectedUids(); 659 QStringList uids = mViewManager->selectedUids();
669 if ( !uids.isEmpty() ) 660 if ( !uids.isEmpty() )
670 mailVCard( uids ); 661 mailVCard( uids );
671} 662}
672 663
673void KABCore::mailVCard( const QStringList& uids ) 664void KABCore::mailVCard( const QStringList& uids )
674{ 665{
675 QStringList urls; 666 QStringList urls;
676 667
677// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 668// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
678 669
679 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 670 QString dirName = "/tmp/" + KApplication::randomString( 8 );
680 671
681 672
682 673
683 QDir().mkdir( dirName, true ); 674 QDir().mkdir( dirName, true );
684 675
685 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 676 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
686 KABC::Addressee a = mAddressBook->findByUid( *it ); 677 KABC::Addressee a = mAddressBook->findByUid( *it );
687 678
688 if ( a.isEmpty() ) 679 if ( a.isEmpty() )
689 continue; 680 continue;
690 681
691 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 682 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
692 683
693 QString fileName = dirName + "/" + name; 684 QString fileName = dirName + "/" + name;
694 685
695 QFile outFile(fileName); 686 QFile outFile(fileName);
696 687
697 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 688 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
698 KABC::VCardConverter converter; 689 KABC::VCardConverter converter;
699 QString vcard; 690 QString vcard;
700 691
701 converter.addresseeToVCard( a, vcard ); 692 converter.addresseeToVCard( a, vcard );
702 693
703 QTextStream t( &outFile ); // use a text stream 694 QTextStream t( &outFile ); // use a text stream
704 t.setEncoding( QTextStream::UnicodeUTF8 ); 695 t.setEncoding( QTextStream::UnicodeUTF8 );
705 t << vcard; 696 t << vcard;
706 697
707 outFile.close(); 698 outFile.close();
708 699
709 urls.append( fileName ); 700 urls.append( fileName );
710 } 701 }
711 } 702 }
712 703
713 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 704 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
714 705
715 706
716/*US 707/*US
717 kapp->invokeMailer( QString::null, QString::null, QString::null, 708 kapp->invokeMailer( QString::null, QString::null, QString::null,
718 QString::null, // subject 709 QString::null, // subject
719 QString::null, // body 710 QString::null, // body
720 QString::null, 711 QString::null,
721 urls ); // attachments 712 urls ); // attachments
722*/ 713*/
723 714
724} 715}
725 716
726/** 717/**
727 Beams the "WhoAmI contact. 718 Beams the "WhoAmI contact.
728*/ 719*/
729void KABCore::beamMySelf() 720void KABCore::beamMySelf()
730{ 721{
731 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 722 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
732 if (!a.isEmpty()) 723 if (!a.isEmpty())
733 { 724 {
734 QStringList uids; 725 QStringList uids;
735 uids << a.uid(); 726 uids << a.uid();
736 727
737 beamVCard(uids); 728 beamVCard(uids);
738 } else { 729 } else {
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" ) ); 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" ) );
740 731
741 732
742 } 733 }
743} 734}
744 735
745void KABCore::export2phone() 736void KABCore::export2phone()
746{ 737{
747 738
748 KAex2phonePrefs ex2phone; 739 KAex2phonePrefs ex2phone;
749 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 740 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
750 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 741 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
751 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 742 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
752 743
753 if ( !ex2phone.exec() ) { 744 if ( !ex2phone.exec() ) {
754 return; 745 return;
755 } 746 }
756 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 747 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
757 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 748 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
758 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 749 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
759 750
760 751
761 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 752 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
762 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 753 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
763 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 754 KPimGlobalPrefs::instance()->mEx2PhoneModel );
764 755
765 QStringList uids = mViewManager->selectedUids(); 756 QStringList uids = mViewManager->selectedUids();
766 if ( uids.isEmpty() ) 757 if ( uids.isEmpty() )
767 return; 758 return;
768 759
769 QString fileName = getPhoneFile(); 760 QString fileName = getPhoneFile();
770 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 761 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
771 return; 762 return;
772 763
773 message(i18n("Exporting to phone...")); 764 message(i18n("Exporting to phone..."));
774 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 765 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
775 766
776} 767}
777QString KABCore::getPhoneFile() 768QString KABCore::getPhoneFile()
778{ 769{
779#ifdef DESKTOP_VERSION 770#ifdef DESKTOP_VERSION
780 return locateLocal("tmp", "phonefile.vcf"); 771 return locateLocal("tmp", "phonefile.vcf");
781#else 772#else
782 return "/tmp/phonefile.vcf"; 773 return "/tmp/phonefile.vcf";
783#endif 774#endif
784 775
785} 776}
786void KABCore::writeToPhone( ) 777void KABCore::writeToPhone( )
787{ 778{
788 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 779 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
789 message(i18n("Export to phone finished!")); 780 message(i18n("Export to phone finished!"));
790 else 781 else
791 qDebug(i18n("Error exporting to phone")); 782 qDebug(i18n("Error exporting to phone"));
792} 783}
793void KABCore::beamVCard() 784void KABCore::beamVCard()
794{ 785{
795 QStringList uids = mViewManager->selectedUids(); 786 QStringList uids = mViewManager->selectedUids();
796 if ( !uids.isEmpty() ) 787 if ( !uids.isEmpty() )
797 beamVCard( uids ); 788 beamVCard( uids );
798} 789}
799 790
800 791
801void KABCore::beamVCard(const QStringList& uids) 792void KABCore::beamVCard(const QStringList& uids)
802{ 793{
803 794
804 // LR: we should use the /tmp dir on the Zaurus, 795 // LR: we should use the /tmp dir on the Zaurus,
805 // because: /tmp = RAM, (HOME)/kdepim = flash memory 796 // because: /tmp = RAM, (HOME)/kdepim = flash memory
806 797
807#ifdef DESKTOP_VERSION 798#ifdef DESKTOP_VERSION
808 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 799 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
809#else 800#else
810 QString fileName = "/tmp/kapibeamfile.vcf"; 801 QString fileName = "/tmp/kapibeamfile.vcf";
811#endif 802#endif
812 803
813 KABC::VCardConverter converter; 804 KABC::VCardConverter converter;
814 QString description; 805 QString description;
815 QString datastream; 806 QString datastream;
816 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 807 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
817 KABC::Addressee a = mAddressBook->findByUid( *it ); 808 KABC::Addressee a = mAddressBook->findByUid( *it );
818 809
819 if ( a.isEmpty() ) 810 if ( a.isEmpty() )
820 continue; 811 continue;
821 812
822 if (description.isEmpty()) 813 if (description.isEmpty())
823 description = a.formattedName(); 814 description = a.formattedName();
824 815
825 QString vcard; 816 QString vcard;
826 converter.addresseeToVCard( a, vcard ); 817 converter.addresseeToVCard( a, vcard );
827 int start = 0; 818 int start = 0;
828 int next; 819 int next;
829 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 820 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
830 int semi = vcard.find(";", next); 821 int semi = vcard.find(";", next);
831 int dopp = vcard.find(":", next); 822 int dopp = vcard.find(":", next);
832 int sep; 823 int sep;
833 if ( semi < dopp && semi >= 0 ) 824 if ( semi < dopp && semi >= 0 )
834 sep = semi ; 825 sep = semi ;
835 else 826 else
836 sep = dopp; 827 sep = dopp;
837 datastream +=vcard.mid( start, next - start); 828 datastream +=vcard.mid( start, next - start);
838 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 829 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
839 start = sep; 830 start = sep;
840 } 831 }
841 datastream += vcard.mid( start,vcard.length() ); 832 datastream += vcard.mid( start,vcard.length() );
842 } 833 }
843#ifndef DESKTOP_VERSION 834#ifndef DESKTOP_VERSION
844 QFile outFile(fileName); 835 QFile outFile(fileName);
845 if ( outFile.open(IO_WriteOnly) ) { 836 if ( outFile.open(IO_WriteOnly) ) {
846 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 837 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
847 QTextStream t( &outFile ); // use a text stream 838 QTextStream t( &outFile ); // use a text stream
848 //t.setEncoding( QTextStream::UnicodeUTF8 ); 839 //t.setEncoding( QTextStream::UnicodeUTF8 );
849 t.setEncoding( QTextStream::Latin1 ); 840 t.setEncoding( QTextStream::Latin1 );
850 t <<datastream.latin1(); 841 t <<datastream.latin1();
851 outFile.close(); 842 outFile.close();
852 Ir *ir = new Ir( this ); 843 Ir *ir = new Ir( this );
853 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 844 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
854 ir->send( fileName, description, "text/x-vCard" ); 845 ir->send( fileName, description, "text/x-vCard" );
855 } else { 846 } else {
856 qDebug("Error open temp beam file "); 847 qDebug("Error open temp beam file ");
857 return; 848 return;
858 } 849 }
859#endif 850#endif
860 851
861} 852}
862 853
863void KABCore::beamDone( Ir *ir ) 854void KABCore::beamDone( Ir *ir )
864{ 855{
865#ifndef DESKTOP_VERSION 856#ifndef DESKTOP_VERSION
866 delete ir; 857 delete ir;
867#endif 858#endif
868 topLevelWidget()->raise(); 859 topLevelWidget()->raise();
869 message( i18n("Beaming finished!") ); 860 message( i18n("Beaming finished!") );
870} 861}
871 862
872 863
873void KABCore::browse( const QString& url ) 864void KABCore::browse( const QString& url )
874{ 865{
875#ifndef KAB_EMBEDDED 866#ifndef KAB_EMBEDDED
876 kapp->invokeBrowser( url ); 867 kapp->invokeBrowser( url );
877#else //KAB_EMBEDDED 868#else //KAB_EMBEDDED
878 qDebug("KABCore::browse must be fixed"); 869 qDebug("KABCore::browse must be fixed");
879#endif //KAB_EMBEDDED 870#endif //KAB_EMBEDDED
880} 871}
881 872
882void KABCore::selectAllContacts() 873void KABCore::selectAllContacts()
883{ 874{
884 mViewManager->setSelected( QString::null, true ); 875 mViewManager->setSelected( QString::null, true );
885} 876}
886 877
887void KABCore::deleteContacts() 878void KABCore::deleteContacts()
888{ 879{
889 QStringList uidList = mViewManager->selectedUids(); 880 QStringList uidList = mViewManager->selectedUids();
890 deleteContacts( uidList ); 881 deleteContacts( uidList );
891} 882}
892 883
893void KABCore::deleteContacts( const QStringList &uids ) 884void KABCore::deleteContacts( const QStringList &uids )
894{ 885{
895 if ( uids.count() > 0 ) { 886 if ( uids.count() > 0 ) {
896 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 887 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
897 UndoStack::instance()->push( command ); 888 UndoStack::instance()->push( command );
898 RedoStack::instance()->clear(); 889 RedoStack::instance()->clear();
899 890
900 // now if we deleted anything, refresh 891 // now if we deleted anything, refresh
901 setContactSelected( QString::null ); 892 setContactSelected( QString::null );
902 setModified( true ); 893 setModified( true );
903 } 894 }
904} 895}
905 896
906void KABCore::copyContacts() 897void KABCore::copyContacts()
907{ 898{
908 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 899 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
909 900
910 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 901 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
911 902
912 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 903 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
913 904
914 QClipboard *cb = QApplication::clipboard(); 905 QClipboard *cb = QApplication::clipboard();
915 cb->setText( clipText ); 906 cb->setText( clipText );
916} 907}
917 908
918void KABCore::cutContacts() 909void KABCore::cutContacts()
919{ 910{
920 QStringList uidList = mViewManager->selectedUids(); 911 QStringList uidList = mViewManager->selectedUids();
921 912
922//US if ( uidList.size() > 0 ) { 913//US if ( uidList.size() > 0 ) {
923 if ( uidList.count() > 0 ) { 914 if ( uidList.count() > 0 ) {
924 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 915 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
925 UndoStack::instance()->push( command ); 916 UndoStack::instance()->push( command );
926 RedoStack::instance()->clear(); 917 RedoStack::instance()->clear();
927 918
928 setModified( true ); 919 setModified( true );
929 } 920 }
930} 921}
931 922
932void KABCore::pasteContacts() 923void KABCore::pasteContacts()
933{ 924{
934 QClipboard *cb = QApplication::clipboard(); 925 QClipboard *cb = QApplication::clipboard();
935 926
936 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 927 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
937 928
938 pasteContacts( list ); 929 pasteContacts( list );
939} 930}
940 931
941void KABCore::pasteContacts( KABC::Addressee::List &list ) 932void KABCore::pasteContacts( KABC::Addressee::List &list )
942{ 933{
943 KABC::Resource *resource = requestResource( this ); 934 KABC::Resource *resource = requestResource( this );
944 KABC::Addressee::List::Iterator it; 935 KABC::Addressee::List::Iterator it;
945 for ( it = list.begin(); it != list.end(); ++it ) 936 for ( it = list.begin(); it != list.end(); ++it )
946 (*it).setResource( resource ); 937 (*it).setResource( resource );
947 938
948 PwPasteCommand *command = new PwPasteCommand( this, list ); 939 PwPasteCommand *command = new PwPasteCommand( this, list );
949 UndoStack::instance()->push( command ); 940 UndoStack::instance()->push( command );
950 RedoStack::instance()->clear(); 941 RedoStack::instance()->clear();
951 942
952 setModified( true ); 943 setModified( true );
953} 944}
954 945
955void KABCore::setWhoAmI() 946void KABCore::setWhoAmI()
956{ 947{
957 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 948 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
958 949
959 if ( addrList.count() > 1 ) { 950 if ( addrList.count() > 1 ) {
960 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 951 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
961 return; 952 return;
962 } 953 }
963 954
964 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 955 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
965 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 956 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
966 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 957 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
967} 958}
968 959
969void KABCore::setCategories() 960void KABCore::setCategories()
970{ 961{
971 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 962 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
972 if ( !dlg.exec() ) 963 if ( !dlg.exec() )
973 return; 964 return;
974 965
975 bool merge = false; 966 bool merge = false;
976 QString msg = i18n( "Merge with existing categories?" ); 967 QString msg = i18n( "Merge with existing categories?" );
977 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 968 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
978 merge = true; 969 merge = true;
979 970
980 QStringList categories = dlg.selectedCategories(); 971 QStringList categories = dlg.selectedCategories();
981 972
982 QStringList uids = mViewManager->selectedUids(); 973 QStringList uids = mViewManager->selectedUids();
983 QStringList::Iterator it; 974 QStringList::Iterator it;
984 for ( it = uids.begin(); it != uids.end(); ++it ) { 975 for ( it = uids.begin(); it != uids.end(); ++it ) {
985 KABC::Addressee addr = mAddressBook->findByUid( *it ); 976 KABC::Addressee addr = mAddressBook->findByUid( *it );
986 if ( !addr.isEmpty() ) { 977 if ( !addr.isEmpty() ) {
987 if ( !merge ) 978 if ( !merge )
988 addr.setCategories( categories ); 979 addr.setCategories( categories );
989 else { 980 else {
990 QStringList addrCategories = addr.categories(); 981 QStringList addrCategories = addr.categories();
991 QStringList::Iterator catIt; 982 QStringList::Iterator catIt;
992 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 983 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
993 if ( !addrCategories.contains( *catIt ) ) 984 if ( !addrCategories.contains( *catIt ) )
994 addrCategories.append( *catIt ); 985 addrCategories.append( *catIt );
995 } 986 }
996 addr.setCategories( addrCategories ); 987 addr.setCategories( addrCategories );
997 } 988 }
998 989
999 mAddressBook->insertAddressee( addr ); 990 mAddressBook->insertAddressee( addr );
1000 } 991 }
1001 } 992 }
1002 993
1003 if ( uids.count() > 0 ) 994 if ( uids.count() > 0 )
1004 setModified( true ); 995 setModified( true );
1005} 996}
1006 997
1007void KABCore::setSearchFields( const KABC::Field::List &fields ) 998void KABCore::setSearchFields( const KABC::Field::List &fields )
1008{ 999{
1009 mIncSearchWidget->setFields( fields ); 1000 mIncSearchWidget->setFields( fields );
1010} 1001}
1011 1002
1012void KABCore::incrementalSearch( const QString& text ) 1003void KABCore::incrementalSearch( const QString& text )
1013{ 1004{
1014 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1005 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1015} 1006}
1016 1007
1017void KABCore::setModified() 1008void KABCore::setModified()
1018{ 1009{
1019 setModified( true ); 1010 setModified( true );
1020} 1011}
1021 1012
1022void KABCore::setModifiedWOrefresh() 1013void KABCore::setModifiedWOrefresh()
1023{ 1014{
1024 // qDebug("KABCore::setModifiedWOrefresh() "); 1015 // qDebug("KABCore::setModifiedWOrefresh() ");
1025 mModified = true; 1016 mModified = true;
1026 mActionSave->setEnabled( mModified ); 1017 mActionSave->setEnabled( mModified );
1027#ifdef DESKTOP_VERSION 1018#ifdef DESKTOP_VERSION
1028 mDetails->refreshView(); 1019 mDetails->refreshView();
1029#endif 1020#endif
1030 1021
1031} 1022}
1032void KABCore::setModified( bool modified ) 1023void KABCore::setModified( bool modified )
1033{ 1024{
1034 mModified = modified; 1025 mModified = modified;
1035 mActionSave->setEnabled( mModified ); 1026 mActionSave->setEnabled( mModified );
1036 1027
1037 if ( modified ) 1028 if ( modified )
1038 mJumpButtonBar->recreateButtons(); 1029 mJumpButtonBar->recreateButtons();
1039 1030
1040 mViewManager->refreshView(); 1031 mViewManager->refreshView();
1041 mDetails->refreshView(); 1032 mDetails->refreshView();
1042 1033
1043} 1034}
1044 1035
1045bool KABCore::modified() const 1036bool KABCore::modified() const
1046{ 1037{
1047 return mModified; 1038 return mModified;
1048} 1039}
1049 1040
1050void KABCore::contactModified( const KABC::Addressee &addr ) 1041void KABCore::contactModified( const KABC::Addressee &addr )
1051{ 1042{
1052 1043
1053 Command *command = 0; 1044 Command *command = 0;
1054 QString uid; 1045 QString uid;
1055 1046
1056 // check if it exists already 1047 // check if it exists already
1057 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1048 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1058 if ( origAddr.isEmpty() ) 1049 if ( origAddr.isEmpty() )
1059 command = new PwNewCommand( mAddressBook, addr ); 1050 command = new PwNewCommand( mAddressBook, addr );
1060 else { 1051 else {
1061 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1052 command = new PwEditCommand( mAddressBook, origAddr, addr );
1062 uid = addr.uid(); 1053 uid = addr.uid();
1063 } 1054 }
1064 1055
1065 UndoStack::instance()->push( command ); 1056 UndoStack::instance()->push( command );
1066 RedoStack::instance()->clear(); 1057 RedoStack::instance()->clear();
1067 1058
1068 setModified( true ); 1059 setModified( true );
1069} 1060}
1070 1061
1071void KABCore::newContact() 1062void KABCore::newContact()
1072{ 1063{
1073 1064
1074 1065
1075 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1066 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1076 1067
1077 QPtrList<KRES::Resource> kresResources; 1068 QPtrList<KRES::Resource> kresResources;
1078 QPtrListIterator<KABC::Resource> it( kabcResources ); 1069 QPtrListIterator<KABC::Resource> it( kabcResources );
1079 KABC::Resource *resource; 1070 KABC::Resource *resource;
1080 while ( ( resource = it.current() ) != 0 ) { 1071 while ( ( resource = it.current() ) != 0 ) {
1081 ++it; 1072 ++it;
1082 if ( !resource->readOnly() ) { 1073 if ( !resource->readOnly() ) {
1083 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1074 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1084 if ( res ) 1075 if ( res )
1085 kresResources.append( res ); 1076 kresResources.append( res );
1086 } 1077 }
1087 } 1078 }
1088 1079
1089 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1080 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1090 resource = static_cast<KABC::Resource*>( res ); 1081 resource = static_cast<KABC::Resource*>( res );
1091 1082
1092 if ( resource ) { 1083 if ( resource ) {
1093 KABC::Addressee addr; 1084 KABC::Addressee addr;
1094 addr.setResource( resource ); 1085 addr.setResource( resource );
1095 mEditorDialog->setAddressee( addr ); 1086 mEditorDialog->setAddressee( addr );
1096 KApplication::execDialog ( mEditorDialog ); 1087 KApplication::execDialog ( mEditorDialog );
1097 1088
1098 } else 1089 } else
1099 return; 1090 return;
1100 1091
1101 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1092 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1102 1093
1103 1094
1104} 1095}
1105 1096
1106void KABCore::addEmail( QString aStr ) 1097void KABCore::addEmail( QString aStr )
1107{ 1098{
1108#ifndef KAB_EMBEDDED 1099#ifndef KAB_EMBEDDED
1109 QString fullName, email; 1100 QString fullName, email;
1110 1101
1111 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1102 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1112 1103
1113 // Try to lookup the addressee matching the email address 1104 // Try to lookup the addressee matching the email address
1114 bool found = false; 1105 bool found = false;
1115 QStringList emailList; 1106 QStringList emailList;
1116 KABC::AddressBook::Iterator it; 1107 KABC::AddressBook::Iterator it;
1117 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1108 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1118 emailList = (*it).emails(); 1109 emailList = (*it).emails();
1119 if ( emailList.contains( email ) > 0 ) { 1110 if ( emailList.contains( email ) > 0 ) {
1120 found = true; 1111 found = true;
1121 (*it).setNameFromString( fullName ); 1112 (*it).setNameFromString( fullName );
1122 editContact( (*it).uid() ); 1113 editContact( (*it).uid() );
1123 } 1114 }
1124 } 1115 }
1125 1116