summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp49
1 files changed, 35 insertions, 14 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d891b07..25891a0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1853 +1,1874 @@
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#include "kabcore.h" 24#include "kabcore.h"
25 25
26#include <stdaddressbook.h> 26#include <stdaddressbook.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#include <qclipboard.h> 30#include <qclipboard.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplicaton.h> 33#include <qapplicaton.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qvbox.h> 36#include <qvbox.h>
37#include <kabc/addresseelist.h> 37#include <kabc/addresseelist.h>
38#include <kabc/errorhandler.h> 38#include <kabc/errorhandler.h>
39#include <kabc/resource.h> 39#include <kabc/resource.h>
40#include <kabc/vcardconverter.h> 40#include <kabc/vcardconverter.h>
41#include <kapplication.h> 41#include <kapplication.h>
42#include <kactionclasses.h> 42#include <kactionclasses.h>
43#include <kcmultidialog.h> 43#include <kcmultidialog.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <kdeversion.h> 45#include <kdeversion.h>
46#include <kkeydialog.h> 46#include <kkeydialog.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kprinter.h> 48#include <kprinter.h>
49#include <kprotocolinfo.h> 49#include <kprotocolinfo.h>
50#include <kresources/selectdialog.h> 50#include <kresources/selectdialog.h>
51#include <kstandarddirs.h> 51#include <kstandarddirs.h>
52#include <ktempfile.h> 52#include <ktempfile.h>
53#include <kxmlguiclient.h> 53#include <kxmlguiclient.h>
54#include <kaboutdata.h> 54#include <kaboutdata.h>
55#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
56 56
57#include "addresseeutil.h" 57#include "addresseeutil.h"
58#include "addresseeeditordialog.h" 58#include "addresseeeditordialog.h"
59#include "extensionmanager.h" 59#include "extensionmanager.h"
60#include "kstdaction.h" 60#include "kstdaction.h"
61#include "kaddressbookservice.h" 61#include "kaddressbookservice.h"
62#include "ldapsearchdialog.h" 62#include "ldapsearchdialog.h"
63#include "printing/printingwizard.h" 63#include "printing/printingwizard.h"
64#else // KAB_EMBEDDED 64#else // KAB_EMBEDDED
65 65
66#include <kapplication.h> 66#include <kapplication.h>
67#include "KDGanttMinimizeSplitter.h" 67#include "KDGanttMinimizeSplitter.h"
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include <qapp.h> 70#include <qapp.h>
71#include <qmenubar.h> 71#include <qmenubar.h>
72//#include <qtoolbar.h> 72//#include <qtoolbar.h>
73#include <qmessagebox.h> 73#include <qmessagebox.h>
74#include <kdebug.h> 74#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 75#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 76#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 77#include <ktoolbar.h>
78 78
79#include <kcmkabconfig.h> 79#include <kcmkabconfig.h>
80 80
81//#include <qlabel.h> 81//#include <qlabel.h>
82 82
83 83
84#ifdef Q_WS_QWS 84#ifdef Q_WS_QWS
85#include <qtopia/services.h> 85#include <qtopia/services.h>
86#include <qtopia/qcopenvelope_qws.h> 86#include <qtopia/qcopenvelope_qws.h>
87#endif 87#endif
88#include <qpe/ir.h> 88#include <qpe/ir.h>
89 89
90#endif // KAB_EMBEDDED 90#endif // KAB_EMBEDDED
91#include <kcmkabconfig.h> 91#include <kcmkabconfig.h>
92 92
93 93
94#include <kresources/selectdialog.h> 94#include <kresources/selectdialog.h>
95#include <kmessagebox.h> 95#include <kmessagebox.h>
96 96
97#include <picture.h> 97#include <picture.h>
98#include <resource.h> 98#include <resource.h>
99 99
100//US#include <qsplitter.h> 100//US#include <qsplitter.h>
101#include <qmap.h> 101#include <qmap.h>
102#include <qdir.h> 102#include <qdir.h>
103#include <qfile.h> 103#include <qfile.h>
104#include <qvbox.h> 104#include <qvbox.h>
105#include <qlayout.h> 105#include <qlayout.h>
106#include <qclipboard.h> 106#include <qclipboard.h>
107#include <qtextstream.h> 107#include <qtextstream.h>
108 108
109#include <libkdepim/categoryselectdialog.h> 109#include <libkdepim/categoryselectdialog.h>
110#include <kabc/vcardconverter.h> 110#include <kabc/vcardconverter.h>
111 111
112 112
113#include "addresseeutil.h" 113#include "addresseeutil.h"
114#include "undocmds.h" 114#include "undocmds.h"
115#include "addresseeeditordialog.h" 115#include "addresseeeditordialog.h"
116#include "viewmanager.h" 116#include "viewmanager.h"
117#include "details/detailsviewcontainer.h" 117#include "details/detailsviewcontainer.h"
118#include "kabprefs.h" 118#include "kabprefs.h"
119#include "xxportmanager.h" 119#include "xxportmanager.h"
120#include "incsearchwidget.h" 120#include "incsearchwidget.h"
121#include "jumpbuttonbar.h" 121#include "jumpbuttonbar.h"
122#include "extensionmanager.h" 122#include "extensionmanager.h"
123#include "addresseeconfig.h" 123#include "addresseeconfig.h"
124#include <kcmultidialog.h> 124#include <kcmultidialog.h>
125 125
126#ifdef _WIN32_ 126#ifdef _WIN32_
127 127
128#include "kaimportoldialog.h" 128#include "kaimportoldialog.h"
129#endif 129#endif
130 130
131bool pasteWithNewUid = true; 131bool pasteWithNewUid = true;
132 132
133#ifdef KAB_EMBEDDED 133#ifdef KAB_EMBEDDED
134KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 134KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
135 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 135 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
136 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 136 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
137 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 137 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
138#else //KAB_EMBEDDED 138#else //KAB_EMBEDDED
139KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 139KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
140 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 140 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
141 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 141 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
142 mReadWrite( readWrite ), mModified( false ) 142 mReadWrite( readWrite ), mModified( false )
143#endif //KAB_EMBEDDED 143#endif //KAB_EMBEDDED
144{ 144{
145 145
146 mExtensionBarSplitter = 0; 146 mExtensionBarSplitter = 0;
147 mIsPart = !parent->inherits( "KAddressBookMain" ); 147 mIsPart = !parent->inherits( "KAddressBookMain" );
148 148
149 mAddressBook = KABC::StdAddressBook::self(); 149 mAddressBook = KABC::StdAddressBook::self();
150 KABC::StdAddressBook::setAutomaticSave( false ); 150 KABC::StdAddressBook::setAutomaticSave( false );
151 151
152#ifndef KAB_EMBEDDED 152#ifndef KAB_EMBEDDED
153 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 153 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
154#endif //KAB_EMBEDDED 154#endif //KAB_EMBEDDED
155 155
156 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 156 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
157 SLOT( addressBookChanged() ) ); 157 SLOT( addressBookChanged() ) );
158 158
159 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 159 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
160 "X-Department", "KADDRESSBOOK" ); 160 "X-Department", "KADDRESSBOOK" );
161 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 161 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
162 "X-Profession", "KADDRESSBOOK" ); 162 "X-Profession", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 163 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
164 "X-AssistantsName", "KADDRESSBOOK" ); 164 "X-AssistantsName", "KADDRESSBOOK" );
165 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 165 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
166 "X-ManagersName", "KADDRESSBOOK" ); 166 "X-ManagersName", "KADDRESSBOOK" );
167 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 167 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
168 "X-SpousesName", "KADDRESSBOOK" ); 168 "X-SpousesName", "KADDRESSBOOK" );
169 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 169 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
170 "X-Office", "KADDRESSBOOK" ); 170 "X-Office", "KADDRESSBOOK" );
171 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 171 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
172 "X-IMAddress", "KADDRESSBOOK" ); 172 "X-IMAddress", "KADDRESSBOOK" );
173 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 173 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
174 "X-Anniversary", "KADDRESSBOOK" ); 174 "X-Anniversary", "KADDRESSBOOK" );
175 175
176 //US added this field to become compatible with Opie/qtopia addressbook 176 //US added this field to become compatible with Opie/qtopia addressbook
177 // values can be "female" or "male" or "". An empty field represents undefined. 177 // values can be "female" or "male" or "". An empty field represents undefined.
178 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 178 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
179 "X-Gender", "KADDRESSBOOK" ); 179 "X-Gender", "KADDRESSBOOK" );
180 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 180 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
181 "X-Children", "KADDRESSBOOK" ); 181 "X-Children", "KADDRESSBOOK" );
182 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 182 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
183 "X-FreeBusyUrl", "KADDRESSBOOK" ); 183 "X-FreeBusyUrl", "KADDRESSBOOK" );
184 184
185 initGUI(); 185 initGUI();
186 186
187 mIncSearchWidget->setFocus(); 187 mIncSearchWidget->setFocus();
188 188
189 189
190 connect( mViewManager, SIGNAL( selected( const QString& ) ), 190 connect( mViewManager, SIGNAL( selected( const QString& ) ),
191 SLOT( setContactSelected( const QString& ) ) ); 191 SLOT( setContactSelected( const QString& ) ) );
192 connect( mViewManager, SIGNAL( executed( const QString& ) ), 192 connect( mViewManager, SIGNAL( executed( const QString& ) ),
193 SLOT( editContact( const QString& ) ) ); 193 SLOT( editContact( const QString& ) ) );
194 connect( mViewManager, SIGNAL( deleteRequest( ) ), 194 connect( mViewManager, SIGNAL( deleteRequest( ) ),
195 SLOT( deleteContacts( ) ) ); 195 SLOT( deleteContacts( ) ) );
196 connect( mViewManager, SIGNAL( modified() ), 196 connect( mViewManager, SIGNAL( modified() ),
197 SLOT( setModified() ) ); 197 SLOT( setModified() ) );
198 198
199 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 199 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
200 200
201 connect( mXXPortManager, SIGNAL( modified() ), 201 connect( mXXPortManager, SIGNAL( modified() ),
202 SLOT( setModified() ) ); 202 SLOT( setModified() ) );
203 203
204 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 204 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
205 SLOT( incrementalSearch( const QString& ) ) ); 205 SLOT( incrementalSearch( const QString& ) ) );
206 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 206 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
207 mJumpButtonBar, SLOT( recreateButtons() ) ); 207 mJumpButtonBar, SLOT( recreateButtons() ) );
208 208
209 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 209 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
210 SLOT( sendMail( const QString& ) ) ); 210 SLOT( sendMail( const QString& ) ) );
211 211
212#ifndef KAB_EMBEDDED 212#ifndef KAB_EMBEDDED
213 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 213 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
214 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 214 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
215 215
216 connect( mDetails, SIGNAL( browse( const QString& ) ), 216 connect( mDetails, SIGNAL( browse( const QString& ) ),
217 SLOT( browse( const QString& ) ) ); 217 SLOT( browse( const QString& ) ) );
218 218
219 mAddressBookService = new KAddressBookService( this ); 219 mAddressBookService = new KAddressBookService( this );
220 220
221#endif //KAB_EMBEDDED 221#endif //KAB_EMBEDDED
222 mEditorDialog = 0; 222 mEditorDialog = 0;
223 createAddresseeEditorDialog( this ); 223 createAddresseeEditorDialog( this );
224 setModified( false ); 224 setModified( false );
225} 225}
226 226
227KABCore::~KABCore() 227KABCore::~KABCore()
228{ 228{
229 // save(); 229 // save();
230 //saveSettings(); 230 //saveSettings();
231 //KABPrefs::instance()->writeConfig(); 231 //KABPrefs::instance()->writeConfig();
232 delete AddresseeConfig::instance(); 232 delete AddresseeConfig::instance();
233 mAddressBook = 0; 233 mAddressBook = 0;
234 KABC::StdAddressBook::close(); 234 KABC::StdAddressBook::close();
235} 235}
236 236
237void KABCore::restoreSettings() 237void KABCore::restoreSettings()
238{ 238{
239 bool state = KABPrefs::instance()->mJumpButtonBarVisible; 239 bool state = KABPrefs::instance()->mJumpButtonBarVisible;
240 240
241 mActionJumpBar->setChecked( state ); 241 mActionJumpBar->setChecked( state );
242 setJumpButtonBarVisible( state ); 242 setJumpButtonBarVisible( state );
243 243
244 state = KABPrefs::instance()->mDetailsPageVisible; 244 state = KABPrefs::instance()->mDetailsPageVisible;
245 245
246 mActionDetails->setChecked( state ); 246 mActionDetails->setChecked( state );
247 setDetailsVisible( state ); 247 setDetailsVisible( state );
248 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 248 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
249 if ( splitterSize.count() == 0 ) { 249 if ( splitterSize.count() == 0 ) {
250 splitterSize.append( width() / 2 ); 250 splitterSize.append( width() / 2 );
251 splitterSize.append( width() / 2 ); 251 splitterSize.append( width() / 2 );
252 } 252 }
253 mMiniSplitter->setSizes( splitterSize ); 253 mMiniSplitter->setSizes( splitterSize );
254 if ( mExtensionBarSplitter ) { 254 if ( mExtensionBarSplitter ) {
255 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 255 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
256 if ( splitterSize.count() == 0 ) { 256 if ( splitterSize.count() == 0 ) {
257 splitterSize.append( width() / 2 ); 257 splitterSize.append( width() / 2 );
258 splitterSize.append( width() / 2 ); 258 splitterSize.append( width() / 2 );
259 } 259 }
260 mExtensionBarSplitter->setSizes( splitterSize ); 260 mExtensionBarSplitter->setSizes( splitterSize );
261 261
262 } 262 }
263#ifndef KAB_EMBEDDED 263#ifndef KAB_EMBEDDED
264 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; 264 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter;
265 if ( splitterSize.count() == 0 ) { 265 if ( splitterSize.count() == 0 ) {
266 splitterSize.append( width() / 2 ); 266 splitterSize.append( width() / 2 );
267 splitterSize.append( width() / 2 ); 267 splitterSize.append( width() / 2 );
268 } 268 }
269 mExtensionBarSplitter->setSizes( splitterSize ); 269 mExtensionBarSplitter->setSizes( splitterSize );
270 270
271 splitterSize = KABPrefs::instance()->mDetailsSplitter; 271 splitterSize = KABPrefs::instance()->mDetailsSplitter;
272 if ( splitterSize.count() == 0 ) { 272 if ( splitterSize.count() == 0 ) {
273 splitterSize.append( height() / 2 ); 273 splitterSize.append( height() / 2 );
274 splitterSize.append( height() / 2 ); 274 splitterSize.append( height() / 2 );
275 } 275 }
276 mDetailsSplitter->setSizes( splitterSize ); 276 mDetailsSplitter->setSizes( splitterSize );
277 277
278 mExtensionManager->restoreSettings(); 278 mExtensionManager->restoreSettings();
279 279
280#endif //KAB_EMBEDDED 280#endif //KAB_EMBEDDED
281 281
282 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 282 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
283 283
284 mViewManager->restoreSettings(); 284 mViewManager->restoreSettings();
285 mExtensionManager->restoreSettings(); 285 mExtensionManager->restoreSettings();
286} 286}
287 287
288void KABCore::saveSettings() 288void KABCore::saveSettings()
289{ 289{
290 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 290 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
291 if ( mExtensionBarSplitter ) 291 if ( mExtensionBarSplitter )
292 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 292 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
293 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 293 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
294 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 294 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
295#ifndef KAB_EMBEDDED 295#ifndef KAB_EMBEDDED
296 296
297 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 297 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
298 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 298 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
299#endif //KAB_EMBEDDED 299#endif //KAB_EMBEDDED
300 mExtensionManager->saveSettings(); 300 mExtensionManager->saveSettings();
301 mViewManager->saveSettings(); 301 mViewManager->saveSettings();
302 302
303 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 303 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
304 304
305} 305}
306 306
307KABC::AddressBook *KABCore::addressBook() const 307KABC::AddressBook *KABCore::addressBook() const
308{ 308{
309 return mAddressBook; 309 return mAddressBook;
310} 310}
311 311
312KConfig *KABCore::config() 312KConfig *KABCore::config()
313{ 313{
314#ifndef KAB_EMBEDDED 314#ifndef KAB_EMBEDDED
315 return KABPrefs::instance()->config(); 315 return KABPrefs::instance()->config();
316#else //KAB_EMBEDDED 316#else //KAB_EMBEDDED
317 return KABPrefs::instance()->getConfig(); 317 return KABPrefs::instance()->getConfig();
318#endif //KAB_EMBEDDED 318#endif //KAB_EMBEDDED
319} 319}
320 320
321KActionCollection *KABCore::actionCollection() const 321KActionCollection *KABCore::actionCollection() const
322{ 322{
323 return mGUIClient->actionCollection(); 323 return mGUIClient->actionCollection();
324} 324}
325 325
326KABC::Field *KABCore::currentSearchField() const 326KABC::Field *KABCore::currentSearchField() const
327{ 327{
328 if (mIncSearchWidget) 328 if (mIncSearchWidget)
329 return mIncSearchWidget->currentField(); 329 return mIncSearchWidget->currentField();
330 else 330 else
331 return 0; 331 return 0;
332} 332}
333 333
334QStringList KABCore::selectedUIDs() const 334QStringList KABCore::selectedUIDs() const
335{ 335{
336 return mViewManager->selectedUids(); 336 return mViewManager->selectedUids();
337} 337}
338 338
339KABC::Resource *KABCore::requestResource( QWidget *parent ) 339KABC::Resource *KABCore::requestResource( QWidget *parent )
340{ 340{
341 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 341 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
342 342
343 QPtrList<KRES::Resource> kresResources; 343 QPtrList<KRES::Resource> kresResources;
344 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 344 QPtrListIterator<KABC::Resource> resIt( kabcResources );
345 KABC::Resource *resource; 345 KABC::Resource *resource;
346 while ( ( resource = resIt.current() ) != 0 ) { 346 while ( ( resource = resIt.current() ) != 0 ) {
347 ++resIt; 347 ++resIt;
348 if ( !resource->readOnly() ) { 348 if ( !resource->readOnly() ) {
349 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 349 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
350 if ( res ) 350 if ( res )
351 kresResources.append( res ); 351 kresResources.append( res );
352 } 352 }
353 } 353 }
354 354
355 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 355 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
356 return static_cast<KABC::Resource*>( res ); 356 return static_cast<KABC::Resource*>( res );
357} 357}
358 358
359#ifndef KAB_EMBEDDED 359#ifndef KAB_EMBEDDED
360KAboutData *KABCore::createAboutData() 360KAboutData *KABCore::createAboutData()
361#else //KAB_EMBEDDED 361#else //KAB_EMBEDDED
362void KABCore::createAboutData() 362void KABCore::createAboutData()
363#endif //KAB_EMBEDDED 363#endif //KAB_EMBEDDED
364{ 364{
365#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
366 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 366 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
367 "3.1", I18N_NOOP( "The KDE Address Book" ), 367 "3.1", I18N_NOOP( "The KDE Address Book" ),
368 KAboutData::License_GPL_V2, 368 KAboutData::License_GPL_V2,
369 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 369 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
370 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 370 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
371 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 371 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
372 about->addAuthor( "Cornelius Schumacher", 372 about->addAuthor( "Cornelius Schumacher",
373 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 373 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
374 "schumacher@kde.org" ); 374 "schumacher@kde.org" );
375 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 375 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
376 "mpilone@slac.com" ); 376 "mpilone@slac.com" );
377 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 377 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
378 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 378 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
379 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 379 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
380 "michel@klaralvdalens-datakonsult.se" ); 380 "michel@klaralvdalens-datakonsult.se" );
381 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 381 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
382 "hansen@kde.org" ); 382 "hansen@kde.org" );
383 383
384 return about; 384 return about;
385#endif //KAB_EMBEDDED 385#endif //KAB_EMBEDDED
386 386
387 QString version; 387 QString version;
388#include <../version> 388#include <../version>
389 QMessageBox::about( this, "About KAddressbook/Pi", 389 QMessageBox::about( this, "About KAddressbook/Pi",
390 "KAddressbook/Platform-independent\n" 390 "KAddressbook/Platform-independent\n"
391 "(KA/Pi) " +version + " - " + 391 "(KA/Pi) " +version + " - " +
392#ifdef DESKTOP_VERSION 392#ifdef DESKTOP_VERSION
393 "Desktop Edition\n" 393 "Desktop Edition\n"
394#else 394#else
395 "PDA-Edition\n" 395 "PDA-Edition\n"
396 "for: Zaurus 5500 / 7x0 / 8x0\n" 396 "for: Zaurus 5500 / 7x0 / 8x0\n"
397#endif 397#endif
398 398
399 "(c) 2004 Ulf Schenk\n" 399 "(c) 2004 Ulf Schenk\n"
400 "(c) 1997-2003, The KDE PIM Team\n" 400 "(c) 1997-2003, The KDE PIM Team\n"
401 "Tobias Koenig Current maintainer tokoe@kde.org\n" 401 "Tobias Koenig Current maintainer tokoe@kde.org\n"
402 "Don Sanders Original author\n" 402 "Don Sanders Original author\n"
403 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 403 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
404 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 404 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
405 "Greg Stern DCOP interface\n" 405 "Greg Stern DCOP interface\n"
406 "Mark Westcot Contact pinning\n" 406 "Mark Westcot Contact pinning\n"
407 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 407 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
408 "Steffen Hansen LDAP Lookup hansen@kde.org\n" 408 "Steffen Hansen LDAP Lookup hansen@kde.org\n"
409#ifdef _WIN32_ 409#ifdef _WIN32_
410 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" 410 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n"
411#endif 411#endif
412 ); 412 );
413} 413}
414 414
415void KABCore::setContactSelected( const QString &uid ) 415void KABCore::setContactSelected( const QString &uid )
416{ 416{
417 KABC::Addressee addr = mAddressBook->findByUid( uid ); 417 KABC::Addressee addr = mAddressBook->findByUid( uid );
418 if ( !mDetails->isHidden() ) 418 if ( !mDetails->isHidden() )
419 mDetails->setAddressee( addr ); 419 mDetails->setAddressee( addr );
420 420
421 if ( !addr.isEmpty() ) { 421 if ( !addr.isEmpty() ) {
422 emit contactSelected( addr.formattedName() ); 422 emit contactSelected( addr.formattedName() );
423 KABC::Picture pic = addr.photo(); 423 KABC::Picture pic = addr.photo();
424 if ( pic.isIntern() ) { 424 if ( pic.isIntern() ) {
425//US emit contactSelected( pic.data() ); 425//US emit contactSelected( pic.data() );
426//US instead use: 426//US instead use:
427 QPixmap px; 427 QPixmap px;
428 if (pic.data().isNull() != true) 428 if (pic.data().isNull() != true)
429 { 429 {
430 px.convertFromImage(pic.data()); 430 px.convertFromImage(pic.data());
431 } 431 }
432 432
433 emit contactSelected( px ); 433 emit contactSelected( px );
434 } 434 }
435 } 435 }
436 436
437 437
438 mExtensionManager->setSelectionChanged(); 438 mExtensionManager->setSelectionChanged();
439 439
440 // update the actions 440 // update the actions
441 bool selected = !uid.isEmpty(); 441 bool selected = !uid.isEmpty();
442 442
443 if ( mReadWrite ) { 443 if ( mReadWrite ) {
444 mActionCut->setEnabled( selected ); 444 mActionCut->setEnabled( selected );
445 mActionPaste->setEnabled( selected ); 445 mActionPaste->setEnabled( selected );
446 } 446 }
447 447
448 mActionCopy->setEnabled( selected ); 448 mActionCopy->setEnabled( selected );
449 mActionDelete->setEnabled( selected ); 449 mActionDelete->setEnabled( selected );
450 mActionEditAddressee->setEnabled( selected ); 450 mActionEditAddressee->setEnabled( selected );
451 mActionMail->setEnabled( selected ); 451 mActionMail->setEnabled( selected );
452 mActionMailVCard->setEnabled( selected ); 452 mActionMailVCard->setEnabled( selected );
453 if (mActionBeam) 453 //if (mActionBeam)
454 mActionBeam->setEnabled( selected ); 454 //mActionBeam->setEnabled( selected );
455 455
456 if (mActionBeam) 456 if (mActionBeamVCard)
457 mActionBeamVCard->setEnabled( selected ); 457 mActionBeamVCard->setEnabled( selected );
458 458
459 mActionWhoAmI->setEnabled( selected ); 459 mActionWhoAmI->setEnabled( selected );
460 mActionCategories->setEnabled( selected ); 460 mActionCategories->setEnabled( selected );
461} 461}
462 462
463void KABCore::sendMail() 463void KABCore::sendMail()
464{ 464{
465 sendMail( mViewManager->selectedEmails().join( ", " ) ); 465 sendMail( mViewManager->selectedEmails().join( ", " ) );
466} 466}
467 467
468void KABCore::sendMail( const QString& email ) 468void KABCore::sendMail( const QString& email )
469{ 469{
470//US original kde implementation : kapp->invokeMailer( email, "" ); 470//US original kde implementation : kapp->invokeMailer( email, "" );
471 471
472/*US original qtopia implementation 472/*US original qtopia implementation
473 PimContact c = abList->currentEntry(); 473 PimContact c = abList->currentEntry();
474 QString name = c.fileAs(); 474 QString name = c.fileAs();
475 QString email = c.defaultEmail(); 475 QString email = c.defaultEmail();
476#ifndef QT_NO_COP 476#ifndef QT_NO_COP
477 QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)"); 477 QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)");
478 e << name << email; 478 e << name << email;
479#else 479#else
480*/ 480*/
481 481
482 482
483#ifndef QT_NO_COP 483#ifndef QT_NO_COP
484 QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); 484 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
485 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); 485 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
486 486
487 QCopEnvelope e(channel, "writeMail(QString,QString)"); 487 QCopEnvelope e(channel, "writeMail(QString,QString)");
488 //US we need no names in the To field. The emailadresses are enough 488 //US we need no names in the To field. The emailadresses are enough
489 e << "" << email; 489 e << "" << email;
490#else 490#else
491 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); 491 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
492#endif 492#endif
493} 493}
494 494
495 495
496 496
497void KABCore::mailVCard() 497void KABCore::mailVCard()
498{ 498{
499 QStringList uids = mViewManager->selectedUids(); 499 QStringList uids = mViewManager->selectedUids();
500 if ( !uids.isEmpty() ) 500 if ( !uids.isEmpty() )
501 mailVCard( uids ); 501 mailVCard( uids );
502} 502}
503 503
504void KABCore::mailVCard( const QStringList& uids ) 504void KABCore::mailVCard( const QStringList& uids )
505{ 505{
506 QStringList urls; 506 QStringList urls;
507 507
508 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 508 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
509 509
510/*US 510/*US
511 // Create a temp dir, so that we can put the files in it with proper names 511 // Create a temp dir, so that we can put the files in it with proper names
512 KTempFile tempDir; 512 KTempFile tempDir;
513 if ( tempDir.status() != 0 ) { 513 if ( tempDir.status() != 0 ) {
514 kdWarning() << strerror( tempDir.status() ) << endl; 514 kdWarning() << strerror( tempDir.status() ) << endl;
515 return; 515 return;
516 } 516 }
517 517
518 QString dirName = tempDir.name(); 518 QString dirName = tempDir.name();
519 tempDir.unlink(); 519 tempDir.unlink();
520*/ 520*/
521 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 521 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
522 522
523 523
524 524
525 QDir().mkdir( dirName, true ); 525 QDir().mkdir( dirName, true );
526 526
527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 527 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
528 KABC::Addressee a = mAddressBook->findByUid( *it ); 528 KABC::Addressee a = mAddressBook->findByUid( *it );
529 529
530 if ( a.isEmpty() ) 530 if ( a.isEmpty() )
531 continue; 531 continue;
532 532
533 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 533 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
534 534
535 QString fileName = dirName + "/" + name; 535 QString fileName = dirName + "/" + name;
536 536
537 QFile outFile(fileName); 537 QFile outFile(fileName);
538 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 538 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
539 KABC::VCardConverter converter; 539 KABC::VCardConverter converter;
540 QString vcard; 540 QString vcard;
541 541
542 converter.addresseeToVCard( a, vcard ); 542 converter.addresseeToVCard( a, vcard );
543 543
544 QTextStream t( &outFile ); // use a text stream 544 QTextStream t( &outFile ); // use a text stream
545 t.setEncoding( QTextStream::UnicodeUTF8 ); 545 t.setEncoding( QTextStream::UnicodeUTF8 );
546 t << vcard; 546 t << vcard;
547 547
548 outFile.close(); 548 outFile.close();
549 549
550 urls.append( fileName ); 550 urls.append( fileName );
551 } 551 }
552 } 552 }
553/*US 553/*US
554 kapp->invokeMailer( QString::null, QString::null, QString::null, 554 kapp->invokeMailer( QString::null, QString::null, QString::null,
555 QString::null, // subject 555 QString::null, // subject
556 QString::null, // body 556 QString::null, // body
557 QString::null, 557 QString::null,
558 urls ); // attachments 558 urls ); // attachments
559*/ 559*/
560#ifndef QT_NO_COP 560#ifndef QT_NO_COP
561 QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); 561 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
562 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); 562 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
563 563
564 QMap<QString, QString> parameterMap; 564 QMap<QString, QString> parameterMap;
565 parameterMap.insert("ATTACHMENT<n>", urls.join(", ")); 565 parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
566 566
567 QCopEnvelope e(channel, "writeMail(QMap(QString,QString))"); 567 QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
568 e << parameterMap; 568 e << parameterMap;
569#else 569#else
570 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); 570 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
571#endif 571#endif
572 572
573 573
574} 574}
575 575
576/** 576/**
577 Beams the "WhoAmI contact. 577 Beams the "WhoAmI contact.
578*/ 578*/
579void KABCore::beamMySelf() 579void KABCore::beamMySelf()
580{ 580{
581 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 581 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
582 if (!a.isEmpty()) 582 if (!a.isEmpty())
583 { 583 {
584 QStringList uids; 584 QStringList uids;
585 uids << a.uid(); 585 uids << a.uid();
586 586
587 beamVCard(uids); 587 beamVCard(uids);
588 } else {
589 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
590
591
588 } 592 }
589} 593}
590 594
591void KABCore::beamVCard() 595void KABCore::beamVCard()
592{ 596{
593 QStringList uids = mViewManager->selectedUids(); 597 QStringList uids = mViewManager->selectedUids();
594 if ( !uids.isEmpty() ) 598 if ( !uids.isEmpty() )
595 beamVCard( uids ); 599 beamVCard( uids );
596} 600}
597 601
598 602
599void KABCore::beamVCard(const QStringList& uids) 603void KABCore::beamVCard(const QStringList& uids)
600{ 604{
601/*US 605/*US
602 QString beamFilename; 606 QString beamFilename;
603 Opie::OPimContact c; 607 Opie::OPimContact c;
604 if ( actionPersonal->isOn() ) { 608 if ( actionPersonal->isOn() ) {
605 beamFilename = addressbookPersonalVCardName(); 609 beamFilename = addressbookPersonalVCardName();
606 if ( !QFile::exists( beamFilename ) ) 610 if ( !QFile::exists( beamFilename ) )
607 return; // can't beam a non-existent file 611 return; // can't beam a non-existent file
608 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 612 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
609 beamFilename ); 613 beamFilename );
610 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 614 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
611 Opie::OPimContactAccess::List allList = access->allRecords(); 615 Opie::OPimContactAccess::List allList = access->allRecords();
612 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 616 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
613 c = *it; 617 c = *it;
614 618
615 delete access; 619 delete access;
616 } else { 620 } else {
617 unlink( beamfile ); // delete if exists 621 unlink( beamfile ); // delete if exists
618 mkdir("/tmp/obex/", 0755); 622 mkdir("/tmp/obex/", 0755);
619 c = m_abView -> currentEntry(); 623 c = m_abView -> currentEntry();
620 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 624 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
621 beamfile ); 625 beamfile );
622 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 626 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
623 access->add( c ); 627 access->add( c );
624 access->save(); 628 access->save();
625 delete access; 629 delete access;
626 630
627 beamFilename = beamfile; 631 beamFilename = beamfile;
628 } 632 }
629 633
630 owarn << "Beaming: " << beamFilename << oendl; 634 owarn << "Beaming: " << beamFilename << oendl;
631*/ 635*/
636
637#if 0
632 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 638 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
633 639
634 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 640 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
635 641
636 QString name = "contact.vcf"; 642 QString name = "contact.vcf";
637 643
638 QString fileName = dirName + "/" + name; 644 QString fileName = dirName + "/" + name;
645#endif
646 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
647 //
648 QString fileName = "/tmp/kdepimbeamfile";
639 649
640 650
641 QDir().mkdir( dirName, true ); 651 //QDir().mkdir( dirName, true );
642 652
643 QFile outFile(fileName); 653 QFile outFile(fileName);
644 KABC::VCardConverter converter; 654 KABC::VCardConverter converter;
645 QString description; 655 QString description;
646 656
647 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 657 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
648 658
649 QTextStream t( &outFile ); // use a text stream 659 QTextStream t( &outFile ); // use a text stream
650 t.setEncoding( QTextStream::UnicodeUTF8 ); 660 t.setEncoding( QTextStream::UnicodeUTF8 );
651 661
652 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 662 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
653 KABC::Addressee a = mAddressBook->findByUid( *it ); 663 KABC::Addressee a = mAddressBook->findByUid( *it );
654 664
655 if ( a.isEmpty() ) 665 if ( a.isEmpty() )
656 continue; 666 continue;
657 667
658 if (description.isEmpty()) 668 if (description.isEmpty())
659 description = a.formattedName(); 669 description = a.formattedName();
660 670
661 QString vcard; 671 QString vcard;
662 converter.addresseeToVCard( a, vcard ); 672 converter.addresseeToVCard( a, vcard );
663 t << vcard; 673 t << vcard;
664 674
665 } 675 }
676 } else {
677 qDebug("Error open temp beam file ");
678 return;
666 } 679 }
667 680
668 outFile.close(); 681 outFile.close();
669 682
683#ifndef DESKTOP_VERSION
670 Ir *ir = new Ir( this ); 684 Ir *ir = new Ir( this );
671 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 685 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
672 ir->send( fileName, description, "text/x-vCard" ); 686 ir->send( fileName, description, "text/x-vCard" );
687#endif
673 688
674} 689}
675 690
676void KABCore::beamDone( Ir *ir ) 691void KABCore::beamDone( Ir *ir )
677{ 692{
693#ifndef DESKTOP_VERSION
678 delete ir; 694 delete ir;
695#endif
679} 696}
680 697
681 698
682void KABCore::browse( const QString& url ) 699void KABCore::browse( const QString& url )
683{ 700{
684#ifndef KAB_EMBEDDED 701#ifndef KAB_EMBEDDED
685 kapp->invokeBrowser( url ); 702 kapp->invokeBrowser( url );
686#else //KAB_EMBEDDED 703#else //KAB_EMBEDDED
687 qDebug("KABCore::browse must be fixed"); 704 qDebug("KABCore::browse must be fixed");
688#endif //KAB_EMBEDDED 705#endif //KAB_EMBEDDED
689} 706}
690 707
691void KABCore::selectAllContacts() 708void KABCore::selectAllContacts()
692{ 709{
693 mViewManager->setSelected( QString::null, true ); 710 mViewManager->setSelected( QString::null, true );
694} 711}
695 712
696void KABCore::deleteContacts() 713void KABCore::deleteContacts()
697{ 714{
698 QStringList uidList = mViewManager->selectedUids(); 715 QStringList uidList = mViewManager->selectedUids();
699 deleteContacts( uidList ); 716 deleteContacts( uidList );
700} 717}
701 718
702void KABCore::deleteContacts( const QStringList &uids ) 719void KABCore::deleteContacts( const QStringList &uids )
703{ 720{
704 if ( uids.count() > 0 ) { 721 if ( uids.count() > 0 ) {
705 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 722 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
706 UndoStack::instance()->push( command ); 723 UndoStack::instance()->push( command );
707 RedoStack::instance()->clear(); 724 RedoStack::instance()->clear();
708 725
709 // now if we deleted anything, refresh 726 // now if we deleted anything, refresh
710 setContactSelected( QString::null ); 727 setContactSelected( QString::null );
711 setModified( true ); 728 setModified( true );
712 } 729 }
713} 730}
714 731
715void KABCore::copyContacts() 732void KABCore::copyContacts()
716{ 733{
717 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 734 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
718 735
719 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 736 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
720 737
721 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 738 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
722 739
723 QClipboard *cb = QApplication::clipboard(); 740 QClipboard *cb = QApplication::clipboard();
724 cb->setText( clipText ); 741 cb->setText( clipText );
725} 742}
726 743
727void KABCore::cutContacts() 744void KABCore::cutContacts()
728{ 745{
729 QStringList uidList = mViewManager->selectedUids(); 746 QStringList uidList = mViewManager->selectedUids();
730 747
731//US if ( uidList.size() > 0 ) { 748//US if ( uidList.size() > 0 ) {
732 if ( uidList.count() > 0 ) { 749 if ( uidList.count() > 0 ) {
733 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 750 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
734 UndoStack::instance()->push( command ); 751 UndoStack::instance()->push( command );
735 RedoStack::instance()->clear(); 752 RedoStack::instance()->clear();
736 753
737 setModified( true ); 754 setModified( true );
738 } 755 }
739} 756}
740 757
741void KABCore::pasteContacts() 758void KABCore::pasteContacts()
742{ 759{
743 QClipboard *cb = QApplication::clipboard(); 760 QClipboard *cb = QApplication::clipboard();
744 761
745 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 762 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
746 763
747 pasteContacts( list ); 764 pasteContacts( list );
748} 765}
749 766
750void KABCore::pasteContacts( KABC::Addressee::List &list ) 767void KABCore::pasteContacts( KABC::Addressee::List &list )
751{ 768{
752 KABC::Resource *resource = requestResource( this ); 769 KABC::Resource *resource = requestResource( this );
753 KABC::Addressee::List::Iterator it; 770 KABC::Addressee::List::Iterator it;
754 for ( it = list.begin(); it != list.end(); ++it ) 771 for ( it = list.begin(); it != list.end(); ++it )
755 (*it).setResource( resource ); 772 (*it).setResource( resource );
756 773
757 PwPasteCommand *command = new PwPasteCommand( this, list ); 774 PwPasteCommand *command = new PwPasteCommand( this, list );
758 UndoStack::instance()->push( command ); 775 UndoStack::instance()->push( command );
759 RedoStack::instance()->clear(); 776 RedoStack::instance()->clear();
760 777
761 setModified( true ); 778 setModified( true );
762} 779}
763 780
764void KABCore::setWhoAmI() 781void KABCore::setWhoAmI()
765{ 782{
766 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 783 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
767 784
768 if ( addrList.count() > 1 ) { 785 if ( addrList.count() > 1 ) {
769 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 786 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
770 return; 787 return;
771 } 788 }
772 789
773 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 790 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
774 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 791 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
775 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 792 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
776} 793}
777 794
778void KABCore::setCategories() 795void KABCore::setCategories()
779{ 796{
780 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 797 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
781 if ( !dlg.exec() ) 798 if ( !dlg.exec() )
782 return; 799 return;
783 800
784 bool merge = false; 801 bool merge = false;
785 QString msg = i18n( "Merge with existing categories?" ); 802 QString msg = i18n( "Merge with existing categories?" );
786 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 803 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
787 merge = true; 804 merge = true;
788 805
789 QStringList categories = dlg.selectedCategories(); 806 QStringList categories = dlg.selectedCategories();
790 807
791 QStringList uids = mViewManager->selectedUids(); 808 QStringList uids = mViewManager->selectedUids();
792 QStringList::Iterator it; 809 QStringList::Iterator it;
793 for ( it = uids.begin(); it != uids.end(); ++it ) { 810 for ( it = uids.begin(); it != uids.end(); ++it ) {
794 KABC::Addressee addr = mAddressBook->findByUid( *it ); 811 KABC::Addressee addr = mAddressBook->findByUid( *it );
795 if ( !addr.isEmpty() ) { 812 if ( !addr.isEmpty() ) {
796 if ( !merge ) 813 if ( !merge )
797 addr.setCategories( categories ); 814 addr.setCategories( categories );
798 else { 815 else {
799 QStringList addrCategories = addr.categories(); 816 QStringList addrCategories = addr.categories();
800 QStringList::Iterator catIt; 817 QStringList::Iterator catIt;
801 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 818 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
802 if ( !addrCategories.contains( *catIt ) ) 819 if ( !addrCategories.contains( *catIt ) )
803 addrCategories.append( *catIt ); 820 addrCategories.append( *catIt );
804 } 821 }
805 addr.setCategories( addrCategories ); 822 addr.setCategories( addrCategories );
806 } 823 }
807 824
808 mAddressBook->insertAddressee( addr ); 825 mAddressBook->insertAddressee( addr );
809 } 826 }
810 } 827 }
811 828
812 if ( uids.count() > 0 ) 829 if ( uids.count() > 0 )
813 setModified( true ); 830 setModified( true );
814} 831}
815 832
816void KABCore::setSearchFields( const KABC::Field::List &fields ) 833void KABCore::setSearchFields( const KABC::Field::List &fields )
817{ 834{
818 mIncSearchWidget->setFields( fields ); 835 mIncSearchWidget->setFields( fields );
819} 836}
820 837
821void KABCore::incrementalSearch( const QString& text ) 838void KABCore::incrementalSearch( const QString& text )
822{ 839{
823 mViewManager->setSelected( QString::null, false ); 840 mViewManager->setSelected( QString::null, false );
824 841
825 if ( !text.isEmpty() ) { 842 if ( !text.isEmpty() ) {
826 KABC::Field *field = mIncSearchWidget->currentField(); 843 KABC::Field *field = mIncSearchWidget->currentField();
827 844
828 QString pattern = text.lower(); 845 QString pattern = text.lower();
829 846
830#if 1 //KDE_VERSION >= 319 847#if 1 //KDE_VERSION >= 319
831 KABC::AddresseeList list( mAddressBook->allAddressees() ); 848 KABC::AddresseeList list( mAddressBook->allAddressees() );
832 if ( field ) { 849 if ( field ) {
833 list.sortByField( field ); 850 list.sortByField( field );
834 KABC::AddresseeList::Iterator it; 851 KABC::AddresseeList::Iterator it;
835 for ( it = list.begin(); it != list.end(); ++it ) { 852 for ( it = list.begin(); it != list.end(); ++it ) {
836 if ( field->value( *it ).lower().startsWith( pattern ) ) { 853 if ( field->value( *it ).lower().startsWith( pattern ) ) {
837 mViewManager->setSelected( (*it).uid(), true ); 854 mViewManager->setSelected( (*it).uid(), true );
838 return; 855 return;
839 } 856 }
840 } 857 }
841 } else { 858 } else {
842 KABC::AddresseeList::Iterator it; 859 KABC::AddresseeList::Iterator it;
843 for ( it = list.begin(); it != list.end(); ++it ) { 860 for ( it = list.begin(); it != list.end(); ++it ) {
844 KABC::Field::List fieldList = mIncSearchWidget->fields(); 861 KABC::Field::List fieldList = mIncSearchWidget->fields();
845 KABC::Field::List::ConstIterator fieldIt; 862 KABC::Field::List::ConstIterator fieldIt;
846 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 863 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
847 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 864 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
848 mViewManager->setSelected( (*it).uid(), true ); 865 mViewManager->setSelected( (*it).uid(), true );
849 return; 866 return;
850 } 867 }
851 } 868 }
852 } 869 }
853 } 870 }
854#else 871#else
855 KABC::AddressBook::Iterator it; 872 KABC::AddressBook::Iterator it;
856 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 873 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
857 if ( field ) { 874 if ( field ) {
858 if ( field->value( *it ).lower().startsWith( pattern ) ) { 875 if ( field->value( *it ).lower().startsWith( pattern ) ) {
859 mViewManager->setSelected( (*it).uid(), true ); 876 mViewManager->setSelected( (*it).uid(), true );
860 return; 877 return;
861 } 878 }
862 } else { 879 } else {
863 KABC::Field::List fieldList = mIncSearchWidget->fields(); 880 KABC::Field::List fieldList = mIncSearchWidget->fields();
864 KABC::Field::List::ConstIterator fieldIt; 881 KABC::Field::List::ConstIterator fieldIt;
865 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 882 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
866 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 883 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
867 mViewManager->setSelected( (*it).uid(), true ); 884 mViewManager->setSelected( (*it).uid(), true );
868 return; 885 return;
869 } 886 }
870 } 887 }
871 } 888 }
872 } 889 }
873#endif 890#endif
874 } 891 }
875} 892}
876 893
877void KABCore::setModified() 894void KABCore::setModified()
878{ 895{
879 setModified( true ); 896 setModified( true );
880} 897}
881 898
882void KABCore::setModifiedWOrefresh() 899void KABCore::setModifiedWOrefresh()
883{ 900{
884 // qDebug("KABCore::setModifiedWOrefresh() "); 901 // qDebug("KABCore::setModifiedWOrefresh() ");
885 mModified = true; 902 mModified = true;
886 mActionSave->setEnabled( mModified ); 903 mActionSave->setEnabled( mModified );
887#ifdef DESKTOP_VERSION 904#ifdef DESKTOP_VERSION
888 mDetails->refreshView(); 905 mDetails->refreshView();
889#endif 906#endif
890 907
891} 908}
892void KABCore::setModified( bool modified ) 909void KABCore::setModified( bool modified )
893{ 910{
894 mModified = modified; 911 mModified = modified;
895 mActionSave->setEnabled( mModified ); 912 mActionSave->setEnabled( mModified );
896 913
897 if ( modified ) 914 if ( modified )
898 mJumpButtonBar->recreateButtons(); 915 mJumpButtonBar->recreateButtons();
899 916
900 mViewManager->refreshView(); 917 mViewManager->refreshView();
901 mDetails->refreshView(); 918 mDetails->refreshView();
902 919
903} 920}
904 921
905bool KABCore::modified() const 922bool KABCore::modified() const
906{ 923{
907 return mModified; 924 return mModified;
908} 925}
909 926
910void KABCore::contactModified( const KABC::Addressee &addr ) 927void KABCore::contactModified( const KABC::Addressee &addr )
911{ 928{
912 929
913 Command *command = 0; 930 Command *command = 0;
914 QString uid; 931 QString uid;
915 932
916 // check if it exists already 933 // check if it exists already
917 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 934 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
918 if ( origAddr.isEmpty() ) 935 if ( origAddr.isEmpty() )
919 command = new PwNewCommand( mAddressBook, addr ); 936 command = new PwNewCommand( mAddressBook, addr );
920 else { 937 else {
921 command = new PwEditCommand( mAddressBook, origAddr, addr ); 938 command = new PwEditCommand( mAddressBook, origAddr, addr );
922 uid = addr.uid(); 939 uid = addr.uid();
923 } 940 }
924 941
925 UndoStack::instance()->push( command ); 942 UndoStack::instance()->push( command );
926 RedoStack::instance()->clear(); 943 RedoStack::instance()->clear();
927 944
928 setModified( true ); 945 setModified( true );
929} 946}
930 947
931void KABCore::newContact() 948void KABCore::newContact()
932{ 949{
933 950
934 951
935 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 952 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
936 953
937 QPtrList<KRES::Resource> kresResources; 954 QPtrList<KRES::Resource> kresResources;
938 QPtrListIterator<KABC::Resource> it( kabcResources ); 955 QPtrListIterator<KABC::Resource> it( kabcResources );
939 KABC::Resource *resource; 956 KABC::Resource *resource;
940 while ( ( resource = it.current() ) != 0 ) { 957 while ( ( resource = it.current() ) != 0 ) {
941 ++it; 958 ++it;
942 if ( !resource->readOnly() ) { 959 if ( !resource->readOnly() ) {
943 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 960 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
944 if ( res ) 961 if ( res )
945 kresResources.append( res ); 962 kresResources.append( res );
946 } 963 }
947 } 964 }
948 965
949 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 966 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
950 resource = static_cast<KABC::Resource*>( res ); 967 resource = static_cast<KABC::Resource*>( res );
951 968
952 if ( resource ) { 969 if ( resource ) {
953 KABC::Addressee addr; 970 KABC::Addressee addr;
954 addr.setResource( resource ); 971 addr.setResource( resource );
955 mEditorDialog->setAddressee( addr ); 972 mEditorDialog->setAddressee( addr );
956 KApplication::execDialog ( mEditorDialog ); 973 KApplication::execDialog ( mEditorDialog );
957 974
958 } else 975 } else
959 return; 976 return;
960 977
961 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 978 // mEditorDict.insert( dialog->addressee().uid(), dialog );
962 979
963 980
964} 981}
965 982
966void KABCore::addEmail( QString aStr ) 983void KABCore::addEmail( QString aStr )
967{ 984{
968#ifndef KAB_EMBEDDED 985#ifndef KAB_EMBEDDED
969 QString fullName, email; 986 QString fullName, email;
970 987
971 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 988 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
972 989
973 // Try to lookup the addressee matching the email address 990 // Try to lookup the addressee matching the email address
974 bool found = false; 991 bool found = false;
975 QStringList emailList; 992 QStringList emailList;
976 KABC::AddressBook::Iterator it; 993 KABC::AddressBook::Iterator it;
977 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 994 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
978 emailList = (*it).emails(); 995 emailList = (*it).emails();
979 if ( emailList.contains( email ) > 0 ) { 996 if ( emailList.contains( email ) > 0 ) {
980 found = true; 997 found = true;
981 (*it).setNameFromString( fullName ); 998 (*it).setNameFromString( fullName );
982 editContact( (*it).uid() ); 999 editContact( (*it).uid() );
983 } 1000 }
984 } 1001 }
985 1002
986 if ( !found ) { 1003 if ( !found ) {
987 KABC::Addressee addr; 1004 KABC::Addressee addr;
988 addr.setNameFromString( fullName ); 1005 addr.setNameFromString( fullName );
989 addr.insertEmail( email, true ); 1006 addr.insertEmail( email, true );
990 1007
991 mAddressBook->insertAddressee( addr ); 1008 mAddressBook->insertAddressee( addr );
992 mViewManager->refreshView( addr.uid() ); 1009 mViewManager->refreshView( addr.uid() );
993 editContact( addr.uid() ); 1010 editContact( addr.uid() );
994 } 1011 }
995#else //KAB_EMBEDDED 1012#else //KAB_EMBEDDED
996 qDebug("KABCore::addEmail finsih method"); 1013 qDebug("KABCore::addEmail finsih method");
997#endif //KAB_EMBEDDED 1014#endif //KAB_EMBEDDED
998} 1015}
999 1016
1000void KABCore::importVCard( const KURL &url, bool showPreview ) 1017void KABCore::importVCard( const KURL &url, bool showPreview )
1001{ 1018{
1002 mXXPortManager->importVCard( url, showPreview ); 1019 mXXPortManager->importVCard( url, showPreview );
1003} 1020}
1004void KABCore::importFromOL() 1021void KABCore::importFromOL()
1005{ 1022{
1006#ifdef _WIN32_ 1023#ifdef _WIN32_
1007 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1024 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1008 idgl->exec(); 1025 idgl->exec();
1009 KABC::Addressee::List list = idgl->getAddressList(); 1026 KABC::Addressee::List list = idgl->getAddressList();
1010 if ( list.count() > 0 ) { 1027 if ( list.count() > 0 ) {
1011 KABC::Addressee::List listNew; 1028 KABC::Addressee::List listNew;
1012 KABC::Addressee::List listExisting; 1029 KABC::Addressee::List listExisting;
1013 KABC::Addressee::List::Iterator it; 1030 KABC::Addressee::List::Iterator it;
1014 KABC::AddressBook::Iterator iter; 1031 KABC::AddressBook::Iterator iter;
1015 for ( it = list.begin(); it != list.end(); ++it ) { 1032 for ( it = list.begin(); it != list.end(); ++it ) {
1016 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1033 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1017 listNew.append( (*it) ); 1034 listNew.append( (*it) );
1018 else 1035 else
1019 listExisting.append( (*it) ); 1036 listExisting.append( (*it) );
1020 } 1037 }
1021 if ( listExisting.count() > 0 ) 1038 if ( listExisting.count() > 0 )
1022 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1039 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1023 if ( listNew.count() > 0 ) { 1040 if ( listNew.count() > 0 ) {
1024 pasteWithNewUid = false; 1041 pasteWithNewUid = false;
1025 pasteContacts( listNew ); 1042 pasteContacts( listNew );
1026 pasteWithNewUid = true; 1043 pasteWithNewUid = true;
1027 } 1044 }
1028 } 1045 }
1029 delete idgl; 1046 delete idgl;
1030#endif 1047#endif
1031} 1048}
1032 1049
1033void KABCore::importVCard( const QString &vCard, bool showPreview ) 1050void KABCore::importVCard( const QString &vCard, bool showPreview )
1034{ 1051{
1035 mXXPortManager->importVCard( vCard, showPreview ); 1052 mXXPortManager->importVCard( vCard, showPreview );
1036} 1053}
1037 1054
1038//US added a second method without defaultparameter 1055//US added a second method without defaultparameter
1039void KABCore::editContact2() { 1056void KABCore::editContact2() {
1040 editContact( QString::null ); 1057 editContact( QString::null );
1041} 1058}
1042 1059
1043void KABCore::editContact( const QString &uid ) 1060void KABCore::editContact( const QString &uid )
1044{ 1061{
1045 1062
1046 if ( mExtensionManager->isQuickEditVisible() ) 1063 if ( mExtensionManager->isQuickEditVisible() )
1047 return; 1064 return;
1048 1065
1049 // First, locate the contact entry 1066 // First, locate the contact entry
1050 QString localUID = uid; 1067 QString localUID = uid;
1051 if ( localUID.isNull() ) { 1068 if ( localUID.isNull() ) {
1052 QStringList uidList = mViewManager->selectedUids(); 1069 QStringList uidList = mViewManager->selectedUids();
1053 if ( uidList.count() > 0 ) 1070 if ( uidList.count() > 0 )
1054 localUID = *( uidList.at( 0 ) ); 1071 localUID = *( uidList.at( 0 ) );
1055 } 1072 }
1056 1073
1057 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1074 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1058 if ( !addr.isEmpty() ) { 1075 if ( !addr.isEmpty() ) {
1059 mEditorDialog->setAddressee( addr ); 1076 mEditorDialog->setAddressee( addr );
1060 KApplication::execDialog ( mEditorDialog ); 1077 KApplication::execDialog ( mEditorDialog );
1061 } 1078 }
1062} 1079}
1063 1080
1064void KABCore::save() 1081void KABCore::save()
1065{ 1082{
1066 if ( !mModified ) 1083 if ( !mModified )
1067 return; 1084 return;
1068 QString text = i18n( "There was an error while attempting to save\n the " 1085 QString text = i18n( "There was an error while attempting to save\n the "
1069 "address book. Please check that some \nother application is " 1086 "address book. Please check that some \nother application is "
1070 "not using it. " ); 1087 "not using it. " );
1071 statusMessage(i18n("Saving addressbook ... ")); 1088 statusMessage(i18n("Saving addressbook ... "));
1072#ifndef KAB_EMBEDDED 1089#ifndef KAB_EMBEDDED
1073 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1090 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1074 if ( !b || !b->save() ) { 1091 if ( !b || !b->save() ) {
1075 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1092 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1076 } 1093 }
1077#else //KAB_EMBEDDED 1094#else //KAB_EMBEDDED
1078 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1095 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1079 if ( !b || !b->save() ) { 1096 if ( !b || !b->save() ) {
1080 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1097 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1081 } 1098 }
1082#endif //KAB_EMBEDDED 1099#endif //KAB_EMBEDDED
1083 1100
1084 statusMessage(i18n("Addressbook saved!")); 1101 statusMessage(i18n("Addressbook saved!"));
1085 setModified( false ); 1102 setModified( false );
1086} 1103}
1087 1104
1088void KABCore::statusMessage(QString mess , int time ) 1105void KABCore::statusMessage(QString mess , int time )
1089{ 1106{
1090 //topLevelWidget()->setCaption( mess ); 1107 //topLevelWidget()->setCaption( mess );
1091 // pending setting timer to revome message 1108 // pending setting timer to revome message
1092} 1109}
1093void KABCore::undo() 1110void KABCore::undo()
1094{ 1111{
1095 UndoStack::instance()->undo(); 1112 UndoStack::instance()->undo();
1096 1113
1097 // Refresh the view 1114 // Refresh the view
1098 mViewManager->refreshView(); 1115 mViewManager->refreshView();
1099} 1116}
1100 1117
1101void KABCore::redo() 1118void KABCore::redo()
1102{ 1119{
1103 RedoStack::instance()->redo(); 1120 RedoStack::instance()->redo();
1104 1121
1105 // Refresh the view 1122 // Refresh the view
1106 mViewManager->refreshView(); 1123 mViewManager->refreshView();
1107} 1124}
1108 1125
1109void KABCore::setJumpButtonBarVisible( bool visible ) 1126void KABCore::setJumpButtonBarVisible( bool visible )
1110{ 1127{
1111 if ( visible ) 1128 if ( visible )
1112 mJumpButtonBar->show(); 1129 mJumpButtonBar->show();
1113 else 1130 else
1114 mJumpButtonBar->hide(); 1131 mJumpButtonBar->hide();
1115} 1132}
1116void KABCore::setDetailsToState() 1133void KABCore::setDetailsToState()
1117{ 1134{
1118 setDetailsVisible( mActionDetails->isChecked() ); 1135 setDetailsVisible( mActionDetails->isChecked() );
1119} 1136}
1120 1137
1121void KABCore::setDetailsVisible( bool visible ) 1138void KABCore::setDetailsVisible( bool visible )
1122{ 1139{
1123 if ( visible ) 1140 if ( visible )
1124 mDetails->show(); 1141 mDetails->show();
1125 else 1142 else
1126 mDetails->hide(); 1143 mDetails->hide();
1127} 1144}
1128 1145
1129void KABCore::extensionModified( const KABC::Addressee::List &list ) 1146void KABCore::extensionModified( const KABC::Addressee::List &list )
1130{ 1147{
1131 1148
1132 if ( list.count() != 0 ) { 1149 if ( list.count() != 0 ) {
1133 KABC::Addressee::List::ConstIterator it; 1150 KABC::Addressee::List::ConstIterator it;
1134 for ( it = list.begin(); it != list.end(); ++it ) 1151 for ( it = list.begin(); it != list.end(); ++it )
1135 mAddressBook->insertAddressee( *it ); 1152 mAddressBook->insertAddressee( *it );
1136 if ( list.count() > 1 ) 1153 if ( list.count() > 1 )
1137 setModified(); 1154 setModified();
1138 else 1155 else
1139 setModifiedWOrefresh(); 1156 setModifiedWOrefresh();
1140 } 1157 }
1141 if ( list.count() == 0 ) 1158 if ( list.count() == 0 )
1142 mViewManager->refreshView(); 1159 mViewManager->refreshView();
1143 else 1160 else
1144 mViewManager->refreshView( list[ 0 ].uid() ); 1161 mViewManager->refreshView( list[ 0 ].uid() );
1145 1162
1146 1163
1147 1164
1148} 1165}
1149 1166
1150QString KABCore::getNameByPhone( const QString &phone ) 1167QString KABCore::getNameByPhone( const QString &phone )
1151{ 1168{
1152#ifndef KAB_EMBEDDED 1169#ifndef KAB_EMBEDDED
1153 QRegExp r( "[/*/-/ ]" ); 1170 QRegExp r( "[/*/-/ ]" );
1154 QString localPhone( phone ); 1171 QString localPhone( phone );
1155 1172
1156 bool found = false; 1173 bool found = false;
1157 QString ownerName = ""; 1174 QString ownerName = "";
1158 KABC::AddressBook::Iterator iter; 1175 KABC::AddressBook::Iterator iter;
1159 KABC::PhoneNumber::List::Iterator phoneIter; 1176 KABC::PhoneNumber::List::Iterator phoneIter;
1160 KABC::PhoneNumber::List phoneList; 1177 KABC::PhoneNumber::List phoneList;
1161 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1178 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1162 phoneList = (*iter).phoneNumbers(); 1179 phoneList = (*iter).phoneNumbers();
1163 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1180 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1164 ++phoneIter) { 1181 ++phoneIter) {
1165 // Get rid of separator chars so just the numbers are compared. 1182 // Get rid of separator chars so just the numbers are compared.
1166 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1183 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1167 ownerName = (*iter).formattedName(); 1184 ownerName = (*iter).formattedName();
1168 found = true; 1185 found = true;
1169 } 1186 }
1170 } 1187 }
1171 } 1188 }
1172 1189
1173 return ownerName; 1190 return ownerName;
1174#else //KAB_EMBEDDED 1191#else //KAB_EMBEDDED
1175 qDebug("KABCore::getNameByPhone finsih method"); 1192 qDebug("KABCore::getNameByPhone finsih method");
1176 return ""; 1193 return "";
1177#endif //KAB_EMBEDDED 1194#endif //KAB_EMBEDDED
1178 1195
1179} 1196}
1180 1197
1181void KABCore::openConfigDialog() 1198void KABCore::openConfigDialog()
1182{ 1199{
1183 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1200 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1184 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1201 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1185 ConfigureDialog->addModule(kabcfg ); 1202 ConfigureDialog->addModule(kabcfg );
1186 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1203 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1187 this, SLOT( configurationChanged() ) ); 1204 this, SLOT( configurationChanged() ) );
1188 connect( ConfigureDialog, SIGNAL( okClicked() ), 1205 connect( ConfigureDialog, SIGNAL( okClicked() ),
1189 this, SLOT( configurationChanged() ) ); 1206 this, SLOT( configurationChanged() ) );
1190 saveSettings(); 1207 saveSettings();
1191 ConfigureDialog->showMaximized(); 1208 ConfigureDialog->showMaximized();
1192 if ( ConfigureDialog->exec() ) 1209 if ( ConfigureDialog->exec() )
1193 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); 1210 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") );
1194 delete ConfigureDialog; 1211 delete ConfigureDialog;
1195} 1212}
1196 1213
1197void KABCore::openLDAPDialog() 1214void KABCore::openLDAPDialog()
1198{ 1215{
1199#ifndef KAB_EMBEDDED 1216#ifndef KAB_EMBEDDED
1200 if ( !mLdapSearchDialog ) { 1217 if ( !mLdapSearchDialog ) {
1201 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1218 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1202 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1219 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1203 SLOT( refreshView() ) ); 1220 SLOT( refreshView() ) );
1204 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1221 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1205 SLOT( setModified() ) ); 1222 SLOT( setModified() ) );
1206 } else 1223 } else
1207 mLdapSearchDialog->restoreSettings(); 1224 mLdapSearchDialog->restoreSettings();
1208 1225
1209 if ( mLdapSearchDialog->isOK() ) 1226 if ( mLdapSearchDialog->isOK() )
1210 mLdapSearchDialog->exec(); 1227 mLdapSearchDialog->exec();
1211#else //KAB_EMBEDDED 1228#else //KAB_EMBEDDED
1212 qDebug("KABCore::openLDAPDialog() finsih method"); 1229 qDebug("KABCore::openLDAPDialog() finsih method");
1213#endif //KAB_EMBEDDED 1230#endif //KAB_EMBEDDED
1214} 1231}
1215 1232
1216void KABCore::print() 1233void KABCore::print()
1217{ 1234{
1218#ifndef KAB_EMBEDDED 1235#ifndef KAB_EMBEDDED
1219 KPrinter printer; 1236 KPrinter printer;
1220 if ( !printer.setup( this ) ) 1237 if ( !printer.setup( this ) )
1221 return; 1238 return;
1222 1239
1223 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1240 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1224 mViewManager->selectedUids(), this ); 1241 mViewManager->selectedUids(), this );
1225 1242
1226 wizard.exec(); 1243 wizard.exec();
1227#else //KAB_EMBEDDED 1244#else //KAB_EMBEDDED
1228 qDebug("KABCore::print() finsih method"); 1245 qDebug("KABCore::print() finsih method");
1229#endif //KAB_EMBEDDED 1246#endif //KAB_EMBEDDED
1230 1247
1231} 1248}
1232 1249
1233 1250
1234void KABCore::addGUIClient( KXMLGUIClient *client ) 1251void KABCore::addGUIClient( KXMLGUIClient *client )
1235{ 1252{
1236 if ( mGUIClient ) 1253 if ( mGUIClient )
1237 mGUIClient->insertChildClient( client ); 1254 mGUIClient->insertChildClient( client );
1238 else 1255 else
1239 KMessageBox::error( this, "no KXMLGUICLient"); 1256 KMessageBox::error( this, "no KXMLGUICLient");
1240} 1257}
1241 1258
1242 1259
1243void KABCore::configurationChanged() 1260void KABCore::configurationChanged()
1244{ 1261{
1245 mExtensionManager->reconfigure(); 1262 mExtensionManager->reconfigure();
1246} 1263}
1247 1264
1248void KABCore::addressBookChanged() 1265void KABCore::addressBookChanged()
1249{ 1266{
1250/*US 1267/*US
1251 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1268 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1252 while ( it.current() ) { 1269 while ( it.current() ) {
1253 if ( it.current()->dirty() ) { 1270 if ( it.current()->dirty() ) {
1254 QString text = i18n( "Data has been changed externally. Unsaved " 1271 QString text = i18n( "Data has been changed externally. Unsaved "
1255 "changes will be lost." ); 1272 "changes will be lost." );
1256 KMessageBox::information( this, text ); 1273 KMessageBox::information( this, text );
1257 } 1274 }
1258 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1275 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1259 ++it; 1276 ++it;
1260 } 1277 }
1261*/ 1278*/
1262 if (mEditorDialog) 1279 if (mEditorDialog)
1263 { 1280 {
1264 if (mEditorDialog->dirty()) 1281 if (mEditorDialog->dirty())
1265 { 1282 {
1266 QString text = i18n( "Data has been changed externally. Unsaved " 1283 QString text = i18n( "Data has been changed externally. Unsaved "
1267 "changes will be lost." ); 1284 "changes will be lost." );
1268 KMessageBox::information( this, text ); 1285 KMessageBox::information( this, text );
1269 } 1286 }
1270 QString currentuid = mEditorDialog->addressee().uid(); 1287 QString currentuid = mEditorDialog->addressee().uid();
1271 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1288 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1272 } 1289 }
1273 mViewManager->refreshView(); 1290 mViewManager->refreshView();
1274// mDetails->refreshView(); 1291// mDetails->refreshView();
1275 1292
1276 1293
1277} 1294}
1278 1295
1279AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1296AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1280 const char *name ) 1297 const char *name )
1281{ 1298{
1282 1299
1283 if ( mEditorDialog == 0 ) { 1300 if ( mEditorDialog == 0 ) {
1284 mEditorDialog = new AddresseeEditorDialog( this, parent, 1301 mEditorDialog = new AddresseeEditorDialog( this, parent,
1285 name ? name : "editorDialog" ); 1302 name ? name : "editorDialog" );
1286 1303
1287 1304
1288 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1305 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1289 SLOT( contactModified( const KABC::Addressee& ) ) ); 1306 SLOT( contactModified( const KABC::Addressee& ) ) );
1290 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1307 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1291 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1308 // SLOT( slotEditorDestroyed( const QString& ) ) );
1292 } 1309 }
1293 1310
1294 return mEditorDialog; 1311 return mEditorDialog;
1295} 1312}
1296 1313
1297void KABCore::slotEditorDestroyed( const QString &uid ) 1314void KABCore::slotEditorDestroyed( const QString &uid )
1298{ 1315{
1299 //mEditorDict.remove( uid ); 1316 //mEditorDict.remove( uid );
1300} 1317}
1301 1318
1302void KABCore::initGUI() 1319void KABCore::initGUI()
1303{ 1320{
1304#ifndef KAB_EMBEDDED 1321#ifndef KAB_EMBEDDED
1305 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1322 QHBoxLayout *topLayout = new QHBoxLayout( this );
1306 topLayout->setSpacing( KDialogBase::spacingHint() ); 1323 topLayout->setSpacing( KDialogBase::spacingHint() );
1307 1324
1308 mExtensionBarSplitter = new QSplitter( this ); 1325 mExtensionBarSplitter = new QSplitter( this );
1309 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1326 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1310 1327
1311 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1328 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1312 1329
1313 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1330 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1314 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1331 mIncSearchWidget = new IncSearchWidget( viewSpace );
1315 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1332 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1316 SLOT( incrementalSearch( const QString& ) ) ); 1333 SLOT( incrementalSearch( const QString& ) ) );
1317 1334
1318 mViewManager = new ViewManager( this, viewSpace ); 1335 mViewManager = new ViewManager( this, viewSpace );
1319 viewSpace->setStretchFactor( mViewManager, 1 ); 1336 viewSpace->setStretchFactor( mViewManager, 1 );
1320 1337
1321 mDetails = new ViewContainer( mDetailsSplitter ); 1338 mDetails = new ViewContainer( mDetailsSplitter );
1322 1339
1323 mJumpButtonBar = new JumpButtonBar( this, this ); 1340 mJumpButtonBar = new JumpButtonBar( this, this );
1324 1341
1325 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1342 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1326 1343
1327 topLayout->addWidget( mExtensionBarSplitter ); 1344 topLayout->addWidget( mExtensionBarSplitter );
1328 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1345 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1329 topLayout->addWidget( mJumpButtonBar ); 1346 topLayout->addWidget( mJumpButtonBar );
1330 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1347 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1331 1348
1332 mXXPortManager = new XXPortManager( this, this ); 1349 mXXPortManager = new XXPortManager( this, this );
1333 1350
1334#else //KAB_EMBEDDED 1351#else //KAB_EMBEDDED
1335 //US initialize viewMenu before settingup viewmanager. 1352 //US initialize viewMenu before settingup viewmanager.
1336 // Viewmanager needs this menu to plugin submenues. 1353 // Viewmanager needs this menu to plugin submenues.
1337 viewMenu = new QPopupMenu( this ); 1354 viewMenu = new QPopupMenu( this );
1338 settingsMenu = new QPopupMenu( this ); 1355 settingsMenu = new QPopupMenu( this );
1339 //filterMenu = new QPopupMenu( this ); 1356 //filterMenu = new QPopupMenu( this );
1340 ImportMenu = new QPopupMenu( this ); 1357 ImportMenu = new QPopupMenu( this );
1341 ExportMenu = new QPopupMenu( this ); 1358 ExportMenu = new QPopupMenu( this );
1342 1359
1343 changeMenu= new QPopupMenu( this ); 1360 changeMenu= new QPopupMenu( this );
1344 1361
1345//US since we have no splitter for the embedded system, setup 1362//US since we have no splitter for the embedded system, setup
1346// a layout with two frames. One left and one right. 1363// a layout with two frames. One left and one right.
1347 1364
1348 QBoxLayout *topLayout; 1365 QBoxLayout *topLayout;
1349 1366
1350 // = new QHBoxLayout( this ); 1367 // = new QHBoxLayout( this );
1351// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1368// QBoxLayout *topLayout = (QBoxLayout*)layout();
1352 1369
1353// QWidget *mainBox = new QWidget( this ); 1370// QWidget *mainBox = new QWidget( this );
1354// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1371// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1355 1372
1356#ifdef DESKTOP_VERSION 1373#ifdef DESKTOP_VERSION
1357 topLayout = new QHBoxLayout( this ); 1374 topLayout = new QHBoxLayout( this );
1358 1375
1359 1376
1360 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1377 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1361 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1378 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1362 1379
1363 topLayout->addWidget(mMiniSplitter ); 1380 topLayout->addWidget(mMiniSplitter );
1364 1381
1365 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1382 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1366 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1383 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1367 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1384 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1368 mDetails = new ViewContainer( mMiniSplitter ); 1385 mDetails = new ViewContainer( mMiniSplitter );
1369 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1386 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1370#else 1387#else
1371 if ( QApplication::desktop()->width() > 480 ) { 1388 if ( QApplication::desktop()->width() > 480 ) {
1372 topLayout = new QHBoxLayout( this ); 1389 topLayout = new QHBoxLayout( this );
1373 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1390 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1374 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1391 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1375 } else { 1392 } else {
1376 1393
1377 topLayout = new QHBoxLayout( this ); 1394 topLayout = new QHBoxLayout( this );
1378 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1395 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1379 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1396 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1380 } 1397 }
1381 1398
1382 topLayout->addWidget(mMiniSplitter ); 1399 topLayout->addWidget(mMiniSplitter );
1383 mViewManager = new ViewManager( this, mMiniSplitter ); 1400 mViewManager = new ViewManager( this, mMiniSplitter );
1384 mDetails = new ViewContainer( mMiniSplitter ); 1401 mDetails = new ViewContainer( mMiniSplitter );
1385 1402
1386 1403
1387 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1404 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1388#endif 1405#endif
1389 //eh->hide(); 1406 //eh->hide();
1390 // topLayout->addWidget(mExtensionManager ); 1407 // topLayout->addWidget(mExtensionManager );
1391 1408
1392 1409
1393/*US 1410/*US
1394#ifndef KAB_NOSPLITTER 1411#ifndef KAB_NOSPLITTER
1395 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1412 QHBoxLayout *topLayout = new QHBoxLayout( this );
1396//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1413//US topLayout->setSpacing( KDialogBase::spacingHint() );
1397 topLayout->setSpacing( 10 ); 1414 topLayout->setSpacing( 10 );
1398 1415
1399 mDetailsSplitter = new QSplitter( this ); 1416 mDetailsSplitter = new QSplitter( this );
1400 1417
1401 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1418 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1402 1419
1403 mViewManager = new ViewManager( this, viewSpace ); 1420 mViewManager = new ViewManager( this, viewSpace );
1404 viewSpace->setStretchFactor( mViewManager, 1 ); 1421 viewSpace->setStretchFactor( mViewManager, 1 );
1405 1422
1406 mDetails = new ViewContainer( mDetailsSplitter ); 1423 mDetails = new ViewContainer( mDetailsSplitter );
1407 1424
1408 topLayout->addWidget( mDetailsSplitter ); 1425 topLayout->addWidget( mDetailsSplitter );
1409 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1426 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1410#else //KAB_NOSPLITTER 1427#else //KAB_NOSPLITTER
1411 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1428 QHBoxLayout *topLayout = new QHBoxLayout( this );
1412//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1429//US topLayout->setSpacing( KDialogBase::spacingHint() );
1413 topLayout->setSpacing( 10 ); 1430 topLayout->setSpacing( 10 );
1414 1431
1415// mDetailsSplitter = new QSplitter( this ); 1432// mDetailsSplitter = new QSplitter( this );
1416 1433
1417 QVBox *viewSpace = new QVBox( this ); 1434 QVBox *viewSpace = new QVBox( this );
1418 1435
1419 mViewManager = new ViewManager( this, viewSpace ); 1436 mViewManager = new ViewManager( this, viewSpace );
1420 viewSpace->setStretchFactor( mViewManager, 1 ); 1437 viewSpace->setStretchFactor( mViewManager, 1 );
1421 1438
1422 mDetails = new ViewContainer( this ); 1439 mDetails = new ViewContainer( this );
1423 1440
1424 topLayout->addWidget( viewSpace ); 1441 topLayout->addWidget( viewSpace );
1425// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1442// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1426 topLayout->addWidget( mDetails ); 1443 topLayout->addWidget( mDetails );
1427#endif //KAB_NOSPLITTER 1444#endif //KAB_NOSPLITTER
1428*/ 1445*/
1429 1446
1430 1447
1431#endif //KAB_EMBEDDED 1448#endif //KAB_EMBEDDED
1432 initActions(); 1449 initActions();
1433 1450
1434#ifdef KAB_EMBEDDED 1451#ifdef KAB_EMBEDDED
1435 addActionsManually(); 1452 addActionsManually();
1436 //US make sure the export and import menues are initialized before creating the xxPortManager. 1453 //US make sure the export and import menues are initialized before creating the xxPortManager.
1437 mXXPortManager = new XXPortManager( this, this ); 1454 mXXPortManager = new XXPortManager( this, this );
1438 1455
1439 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1456 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1440 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1457 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1441 // mActionQuit->plug ( mMainWindow->toolBar()); 1458 // mActionQuit->plug ( mMainWindow->toolBar());
1442 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1459 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1443 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1460 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1444 // mIncSearchWidget->hide(); 1461 // mIncSearchWidget->hide();
1445 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1462 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1446 SLOT( incrementalSearch( const QString& ) ) ); 1463 SLOT( incrementalSearch( const QString& ) ) );
1447 1464
1448 1465
1449 mJumpButtonBar = new JumpButtonBar( this, this ); 1466 mJumpButtonBar = new JumpButtonBar( this, this );
1450 1467
1451 topLayout->addWidget( mJumpButtonBar ); 1468 topLayout->addWidget( mJumpButtonBar );
1452//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1469//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1453 1470
1454// mMainWindow->getIconToolBar()->raise(); 1471// mMainWindow->getIconToolBar()->raise();
1455 1472
1456#endif //KAB_EMBEDDED 1473#endif //KAB_EMBEDDED
1457 1474
1458} 1475}
1459void KABCore::initActions() 1476void KABCore::initActions()
1460{ 1477{
1461//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1478//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1462 1479
1463#ifndef KAB_EMBEDDED 1480#ifndef KAB_EMBEDDED
1464 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1481 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1465 SLOT( clipboardDataChanged() ) ); 1482 SLOT( clipboardDataChanged() ) );
1466#endif //KAB_EMBEDDED 1483#endif //KAB_EMBEDDED
1467 1484
1468 // file menu 1485 // file menu
1469 if ( mIsPart ) { 1486 if ( mIsPart ) {
1470 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1487 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1471 SLOT( sendMail() ), actionCollection(), 1488 SLOT( sendMail() ), actionCollection(),
1472 "kaddressbook_mail" ); 1489 "kaddressbook_mail" );
1473 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1490 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1474 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1491 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1475 1492
1476 } else { 1493 } else {
1477 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1494 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1478 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1495 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1479 } 1496 }
1480 1497
1481 1498
1482 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1499 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1483 SLOT( save() ), actionCollection(), "file_sync" ); 1500 SLOT( save() ), actionCollection(), "file_sync" );
1484 1501
1485 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1502 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1486 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1503 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1487 1504
1488 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1505 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1489 this, SLOT( mailVCard() ), 1506 this, SLOT( mailVCard() ),
1490 actionCollection(), "file_mail_vcard"); 1507 actionCollection(), "file_mail_vcard");
1491 1508
1492 mActionBeamVCard = 0; 1509 mActionBeamVCard = 0;
1510 mActionBeam = 0;
1511
1512#ifndef DESKTOP_VERSION
1493 if ( Ir::supported() ) { 1513 if ( Ir::supported() ) {
1494 mActionBeamVCard = new KAction( i18n( "Beam v&Card" ), "beam", 0, this, 1514 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1495 SLOT( beamVCard() ), actionCollection(), 1515 SLOT( beamVCard() ), actionCollection(),
1496 "kaddressbook_beam_vcard" ); 1516 "kaddressbook_beam_vcard" );
1517
1518 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1519 SLOT( beamMySelf() ), actionCollection(),
1520 "kaddressbook_beam_myself" );
1497 } 1521 }
1498 1522#endif
1499 1523
1500 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1524 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1501 this, SLOT( editContact2() ), 1525 this, SLOT( editContact2() ),
1502 actionCollection(), "file_properties" ); 1526 actionCollection(), "file_properties" );
1503 1527
1504#ifdef KAB_EMBEDDED 1528#ifdef KAB_EMBEDDED
1505 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1529 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1506 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1530 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1507 mMainWindow, SLOT( exit() ), 1531 mMainWindow, SLOT( exit() ),
1508 actionCollection(), "quit" ); 1532 actionCollection(), "quit" );
1509#endif //KAB_EMBEDDED 1533#endif //KAB_EMBEDDED
1510 1534
1511 // edit menu 1535 // edit menu
1512 if ( mIsPart ) { 1536 if ( mIsPart ) {
1513 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1537 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1514 SLOT( copyContacts() ), actionCollection(), 1538 SLOT( copyContacts() ), actionCollection(),
1515 "kaddressbook_copy" ); 1539 "kaddressbook_copy" );
1516 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1540 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1517 SLOT( cutContacts() ), actionCollection(), 1541 SLOT( cutContacts() ), actionCollection(),
1518 "kaddressbook_cut" ); 1542 "kaddressbook_cut" );
1519 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1543 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1520 SLOT( pasteContacts() ), actionCollection(), 1544 SLOT( pasteContacts() ), actionCollection(),
1521 "kaddressbook_paste" ); 1545 "kaddressbook_paste" );
1522 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1546 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1523 SLOT( selectAllContacts() ), actionCollection(), 1547 SLOT( selectAllContacts() ), actionCollection(),
1524 "kaddressbook_select_all" ); 1548 "kaddressbook_select_all" );
1525 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1549 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1526 SLOT( undo() ), actionCollection(), 1550 SLOT( undo() ), actionCollection(),
1527 "kaddressbook_undo" ); 1551 "kaddressbook_undo" );
1528 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1552 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1529 this, SLOT( redo() ), actionCollection(), 1553 this, SLOT( redo() ), actionCollection(),
1530 "kaddressbook_redo" ); 1554 "kaddressbook_redo" );
1531 } else { 1555 } else {
1532 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1556 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1533 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1557 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1534 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1558 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1535 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1559 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1536 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1560 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1537 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1561 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1538 } 1562 }
1539 1563
1540 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1564 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1541 Key_Delete, this, SLOT( deleteContacts() ), 1565 Key_Delete, this, SLOT( deleteContacts() ),
1542 actionCollection(), "edit_delete" ); 1566 actionCollection(), "edit_delete" );
1543 1567
1544 mActionUndo->setEnabled( false ); 1568 mActionUndo->setEnabled( false );
1545 mActionRedo->setEnabled( false ); 1569 mActionRedo->setEnabled( false );
1546 1570
1547 // settings menu 1571 // settings menu
1548#ifdef KAB_EMBEDDED 1572#ifdef KAB_EMBEDDED
1549//US special menuentry to configure the addressbook resources. On KDE 1573//US special menuentry to configure the addressbook resources. On KDE
1550// you do that through the control center !!! 1574// you do that through the control center !!!
1551 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1575 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1552 SLOT( configureResources() ), actionCollection(), 1576 SLOT( configureResources() ), actionCollection(),
1553 "kaddressbook_configure_resources" ); 1577 "kaddressbook_configure_resources" );
1554#endif //KAB_EMBEDDED 1578#endif //KAB_EMBEDDED
1555 1579
1556 if ( mIsPart ) { 1580 if ( mIsPart ) {
1557 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1581 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1558 SLOT( openConfigDialog() ), actionCollection(), 1582 SLOT( openConfigDialog() ), actionCollection(),
1559 "kaddressbook_configure" ); 1583 "kaddressbook_configure" );
1560 1584
1561 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1585 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1562 this, SLOT( configureKeyBindings() ), actionCollection(), 1586 this, SLOT( configureKeyBindings() ), actionCollection(),
1563 "kaddressbook_configure_shortcuts" ); 1587 "kaddressbook_configure_shortcuts" );
1564#ifdef KAB_EMBEDDED 1588#ifdef KAB_EMBEDDED
1565 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1589 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1566 mActionConfigureToolbars->setEnabled( false ); 1590 mActionConfigureToolbars->setEnabled( false );
1567#endif //KAB_EMBEDDED 1591#endif //KAB_EMBEDDED
1568 1592
1569 } else { 1593 } else {
1570 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1594 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1571 1595
1572 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1596 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1573 } 1597 }
1574 1598
1575 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1599 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1576 actionCollection(), "options_show_jump_bar" ); 1600 actionCollection(), "options_show_jump_bar" );
1577 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1601 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1578 1602
1579 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, 1603 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0,
1580 actionCollection(), "options_show_details" ); 1604 actionCollection(), "options_show_details" );
1581 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1605 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1582 1606
1583 // misc 1607 // misc
1584 // only enable LDAP lookup if we can handle the protocol 1608 // only enable LDAP lookup if we can handle the protocol
1585#ifndef KAB_EMBEDDED 1609#ifndef KAB_EMBEDDED
1586 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1610 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1587 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1611 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1588 this, SLOT( openLDAPDialog() ), actionCollection(), 1612 this, SLOT( openLDAPDialog() ), actionCollection(),
1589 "ldap_lookup" ); 1613 "ldap_lookup" );
1590 } 1614 }
1591#else //KAB_EMBEDDED 1615#else //KAB_EMBEDDED
1592 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1616 //qDebug("KABCore::initActions() LDAP has to be implemented");
1593#endif //KAB_EMBEDDED 1617#endif //KAB_EMBEDDED
1594 1618
1595 1619
1596 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1620 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1597 SLOT( setWhoAmI() ), actionCollection(), 1621 SLOT( setWhoAmI() ), actionCollection(),
1598 "set_personal" ); 1622 "set_personal" );
1599 1623
1600 mActionBeam = 0; 1624
1601 if ( Ir::supported() ) {
1602 mActionBeam = new KAction( i18n( "&Beam Who Am I" ), "beam", 0, this,
1603 SLOT( beamMySelf() ), actionCollection(),
1604 "kaddressbook_beam_myself" );
1605 }
1606 1625
1607 1626
1608 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1627 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1609 SLOT( setCategories() ), actionCollection(), 1628 SLOT( setCategories() ), actionCollection(),
1610 "edit_set_categories" ); 1629 "edit_set_categories" );
1611 1630
1612 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1631 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1613 SLOT( removeVoice() ), actionCollection(), 1632 SLOT( removeVoice() ), actionCollection(),
1614 "remove_voice" ); 1633 "remove_voice" );
1615 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1634 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1616 SLOT( importFromOL() ), actionCollection(), 1635 SLOT( importFromOL() ), actionCollection(),
1617 "import_OL" ); 1636 "import_OL" );
1618#ifdef KAB_EMBEDDED 1637#ifdef KAB_EMBEDDED
1619 1638
1620 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1639 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1621 this, SLOT( createAboutData() ), actionCollection(), 1640 this, SLOT( createAboutData() ), actionCollection(),
1622 "kaddressbook_about_data" ); 1641 "kaddressbook_about_data" );
1623#endif //KAB_EMBEDDED 1642#endif //KAB_EMBEDDED
1624 1643
1625 clipboardDataChanged(); 1644 clipboardDataChanged();
1626 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1645 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1627 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1646 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1628} 1647}
1629 1648
1630//US we need this function, to plug all actions into the correct menues. 1649//US we need this function, to plug all actions into the correct menues.
1631// KDE uses a XML format to plug the actions, but we work her without this overhead. 1650// KDE uses a XML format to plug the actions, but we work her without this overhead.
1632void KABCore::addActionsManually() 1651void KABCore::addActionsManually()
1633{ 1652{
1634//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1653//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1635 1654
1636#ifdef KAB_EMBEDDED 1655#ifdef KAB_EMBEDDED
1637 QPopupMenu *fileMenu = new QPopupMenu( this ); 1656 QPopupMenu *fileMenu = new QPopupMenu( this );
1638 QPopupMenu *editMenu = new QPopupMenu( this ); 1657 QPopupMenu *editMenu = new QPopupMenu( this );
1639 QPopupMenu *helpMenu = new QPopupMenu( this ); 1658 QPopupMenu *helpMenu = new QPopupMenu( this );
1640 1659
1641 KToolBar* tb = mMainWindow->toolBar(); 1660 KToolBar* tb = mMainWindow->toolBar();
1642 1661
1643#ifdef DESKTOP_VERSION 1662#ifdef DESKTOP_VERSION
1644 QMenuBar* mb = mMainWindow->menuBar(); 1663 QMenuBar* mb = mMainWindow->menuBar();
1645 1664
1646 //US setup menubar. 1665 //US setup menubar.
1647 //Disable the following block if you do not want to have a menubar. 1666 //Disable the following block if you do not want to have a menubar.
1648 mb->insertItem( "&File", fileMenu ); 1667 mb->insertItem( "&File", fileMenu );
1649 mb->insertItem( "&Edit", editMenu ); 1668 mb->insertItem( "&Edit", editMenu );
1650 mb->insertItem( "&View", viewMenu ); 1669 mb->insertItem( "&View", viewMenu );
1651 mb->insertItem( "&Settings", settingsMenu ); 1670 mb->insertItem( "&Settings", settingsMenu );
1652 mb->insertItem( "&Change selected", changeMenu ); 1671 mb->insertItem( "&Change selected", changeMenu );
1653 mb->insertItem( "&Help", helpMenu ); 1672 mb->insertItem( "&Help", helpMenu );
1654 mIncSearchWidget = new IncSearchWidget( tb ); 1673 mIncSearchWidget = new IncSearchWidget( tb );
1655 // tb->insertWidget(-1, 0, mIncSearchWidget); 1674 // tb->insertWidget(-1, 0, mIncSearchWidget);
1656 1675
1657#else 1676#else
1658 //US setup toolbar 1677 //US setup toolbar
1659 QMenuBar *menuBarTB = new QMenuBar( tb ); 1678 QMenuBar *menuBarTB = new QMenuBar( tb );
1660 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1679 QPopupMenu *popupBarTB = new QPopupMenu( this );
1661 menuBarTB->insertItem( "ME", popupBarTB); 1680 menuBarTB->insertItem( "ME", popupBarTB);
1662 tb->insertWidget(-1, 0, menuBarTB); 1681 tb->insertWidget(-1, 0, menuBarTB);
1663 mIncSearchWidget = new IncSearchWidget( tb ); 1682 mIncSearchWidget = new IncSearchWidget( tb );
1664 1683
1665 tb->enableMoving(false); 1684 tb->enableMoving(false);
1666 popupBarTB->insertItem( "&File", fileMenu ); 1685 popupBarTB->insertItem( "&File", fileMenu );
1667 popupBarTB->insertItem( "&Edit", editMenu ); 1686 popupBarTB->insertItem( "&Edit", editMenu );
1668 popupBarTB->insertItem( "&View", viewMenu ); 1687 popupBarTB->insertItem( "&View", viewMenu );
1669 popupBarTB->insertItem( "&Settings", settingsMenu ); 1688 popupBarTB->insertItem( "&Settings", settingsMenu );
1670 mViewManager->getFilterAction()->plug ( popupBarTB); 1689 mViewManager->getFilterAction()->plug ( popupBarTB);
1671 popupBarTB->insertItem( "&Change selected", changeMenu ); 1690 popupBarTB->insertItem( "&Change selected", changeMenu );
1672 popupBarTB->insertItem( "&Help", helpMenu ); 1691 popupBarTB->insertItem( "&Help", helpMenu );
1673 if (QApplication::desktop()->width() > 320 ) { 1692 if (QApplication::desktop()->width() > 320 ) {
1674 // mViewManager->getFilterAction()->plug ( tb); 1693 // mViewManager->getFilterAction()->plug ( tb);
1675 } 1694 }
1676#endif 1695#endif
1677 // mActionQuit->plug ( mMainWindow->toolBar()); 1696 // mActionQuit->plug ( mMainWindow->toolBar());
1678 1697
1679 1698
1680 1699
1681 //US Now connect the actions with the menue entries. 1700 //US Now connect the actions with the menue entries.
1682 mActionPrint->plug( fileMenu ); 1701 mActionPrint->plug( fileMenu );
1683 mActionMail->plug( fileMenu ); 1702 mActionMail->plug( fileMenu );
1684 fileMenu->insertSeparator(); 1703 fileMenu->insertSeparator();
1685 1704
1686 mActionNewContact->plug( fileMenu ); 1705 mActionNewContact->plug( fileMenu );
1687 mActionNewContact->plug( tb ); 1706 mActionNewContact->plug( tb );
1688 1707
1689 mActionEditAddressee->plug( fileMenu ); 1708 mActionEditAddressee->plug( fileMenu );
1690 fileMenu->insertSeparator(); 1709 fileMenu->insertSeparator();
1691 mActionSave->plug( fileMenu ); 1710 mActionSave->plug( fileMenu );
1692 fileMenu->insertItem( "&Import", ImportMenu ); 1711 fileMenu->insertItem( "&Import", ImportMenu );
1693 fileMenu->insertItem( "&Emport", ExportMenu ); 1712 fileMenu->insertItem( "&Emport", ExportMenu );
1694 fileMenu->insertSeparator(); 1713 fileMenu->insertSeparator();
1695 mActionMailVCard->plug( fileMenu ); 1714 mActionMailVCard->plug( fileMenu );
1715#ifndef DESKTOP_VERSION
1696 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu ); 1716 if ( Ir::supported() ) mActionBeamVCard->plug( fileMenu );
1717 if ( Ir::supported() ) mActionBeam->plug(fileMenu );
1718#endif
1697 fileMenu->insertSeparator(); 1719 fileMenu->insertSeparator();
1698 mActionQuit->plug( fileMenu ); 1720 mActionQuit->plug( fileMenu );
1699#ifdef _WIN32_ 1721#ifdef _WIN32_
1700 mActionImportOL->plug( ImportMenu ); 1722 mActionImportOL->plug( ImportMenu );
1701#endif 1723#endif
1702 // edit menu 1724 // edit menu
1703 mActionUndo->plug( editMenu ); 1725 mActionUndo->plug( editMenu );
1704 mActionRedo->plug( editMenu ); 1726 mActionRedo->plug( editMenu );
1705 editMenu->insertSeparator(); 1727 editMenu->insertSeparator();
1706 mActionCut->plug( editMenu ); 1728 mActionCut->plug( editMenu );
1707 mActionCopy->plug( editMenu ); 1729 mActionCopy->plug( editMenu );
1708 mActionPaste->plug( editMenu ); 1730 mActionPaste->plug( editMenu );
1709 mActionDelete->plug( editMenu ); 1731 mActionDelete->plug( editMenu );
1710 editMenu->insertSeparator(); 1732 editMenu->insertSeparator();
1711 mActionSelectAll->plug( editMenu ); 1733 mActionSelectAll->plug( editMenu );
1712 1734
1713 mActionRemoveVoice->plug( changeMenu ); 1735 mActionRemoveVoice->plug( changeMenu );
1714 // settings menu 1736 // settings menu
1715//US special menuentry to configure the addressbook resources. On KDE 1737//US special menuentry to configure the addressbook resources. On KDE
1716// you do that through the control center !!! 1738// you do that through the control center !!!
1717 mActionConfigResources->plug( settingsMenu ); 1739 mActionConfigResources->plug( settingsMenu );
1718 settingsMenu->insertSeparator(); 1740 settingsMenu->insertSeparator();
1719 1741
1720 mActionConfigKAddressbook->plug( settingsMenu ); 1742 mActionConfigKAddressbook->plug( settingsMenu );
1721 1743
1722 if ( mIsPart ) { 1744 if ( mIsPart ) {
1723 mActionConfigShortcuts->plug( settingsMenu ); 1745 mActionConfigShortcuts->plug( settingsMenu );
1724 mActionConfigureToolbars->plug( settingsMenu ); 1746 mActionConfigureToolbars->plug( settingsMenu );
1725 1747
1726 } else { 1748 } else {
1727 mActionKeyBindings->plug( settingsMenu ); 1749 mActionKeyBindings->plug( settingsMenu );
1728 } 1750 }
1729 1751
1730 settingsMenu->insertSeparator(); 1752 settingsMenu->insertSeparator();
1731 1753
1732 mActionJumpBar->plug( settingsMenu ); 1754 mActionJumpBar->plug( settingsMenu );
1733 mActionDetails->plug( settingsMenu ); 1755 mActionDetails->plug( settingsMenu );
1734 settingsMenu->insertSeparator(); 1756 settingsMenu->insertSeparator();
1735 1757
1736 mActionWhoAmI->plug( settingsMenu ); 1758 mActionWhoAmI->plug( settingsMenu );
1737 if ( Ir::supported() ) mActionBeam->plug( settingsMenu );
1738 mActionCategories->plug( settingsMenu ); 1759 mActionCategories->plug( settingsMenu );
1739 1760
1740 mActionAboutKAddressbook->plug( helpMenu ); 1761 mActionAboutKAddressbook->plug( helpMenu );
1741 1762
1742 1763
1743 if (QApplication::desktop()->width() > 320 ) { 1764 if (QApplication::desktop()->width() > 320 ) {
1744 1765
1745 mActionEditAddressee->plug( tb ); 1766 mActionEditAddressee->plug( tb );
1746 mActionSave->plug( tb ); 1767 mActionSave->plug( tb );
1747 mViewManager->getFilterAction()->plug ( tb); 1768 mViewManager->getFilterAction()->plug ( tb);
1748 if (QApplication::desktop()->width() > 480 ) { 1769 if (QApplication::desktop()->width() > 480 ) {
1749 mActionUndo->plug( tb ); 1770 mActionUndo->plug( tb );
1750 mActionDelete->plug( tb ); 1771 mActionDelete->plug( tb );
1751 mActionRedo->plug( tb ); 1772 mActionRedo->plug( tb );
1752 } 1773 }
1753 } 1774 }
1754 //mActionQuit->plug ( tb ); 1775 //mActionQuit->plug ( tb );
1755 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1776 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1756 1777
1757 //US link the searchwidget first to this. 1778 //US link the searchwidget first to this.
1758 // The real linkage to the toolbar happens later. 1779 // The real linkage to the toolbar happens later.
1759//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1780//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1760//US tb->insertItem( mIncSearchWidget ); 1781//US tb->insertItem( mIncSearchWidget );
1761/*US 1782/*US
1762 mIncSearchWidget = new IncSearchWidget( tb ); 1783 mIncSearchWidget = new IncSearchWidget( tb );
1763 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1784 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1764 SLOT( incrementalSearch( const QString& ) ) ); 1785 SLOT( incrementalSearch( const QString& ) ) );
1765 1786
1766 mJumpButtonBar = new JumpButtonBar( this, this ); 1787 mJumpButtonBar = new JumpButtonBar( this, this );
1767 1788
1768//US topLayout->addWidget( mJumpButtonBar ); 1789//US topLayout->addWidget( mJumpButtonBar );
1769 this->layout()->add( mJumpButtonBar ); 1790 this->layout()->add( mJumpButtonBar );
1770*/ 1791*/
1771 1792
1772#endif //KAB_EMBEDDED 1793#endif //KAB_EMBEDDED
1773} 1794}
1774void KABCore::removeVoice() 1795void KABCore::removeVoice()
1775{ 1796{
1776 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 1797 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
1777 return; 1798 return;
1778 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1799 KABC::Addressee::List list = mViewManager->selectedAddressees();
1779 KABC::Addressee::List::Iterator it; 1800 KABC::Addressee::List::Iterator it;
1780 for ( it = list.begin(); it != list.end(); ++it ) { 1801 for ( it = list.begin(); it != list.end(); ++it ) {
1781 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1802 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1782 PhoneNumber::List::Iterator phoneIt; 1803 PhoneNumber::List::Iterator phoneIt;
1783 bool found = false; 1804 bool found = false;
1784 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1805 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1785 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1806 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1786 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1807 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1787 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1808 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1788 (*it).insertPhoneNumber( (*phoneIt) ); 1809 (*it).insertPhoneNumber( (*phoneIt) );
1789 found = true; 1810 found = true;
1790 } 1811 }
1791 } 1812 }
1792 1813
1793 } 1814 }
1794 if ( found ) 1815 if ( found )
1795 contactModified((*it) ); 1816 contactModified((*it) );
1796 } 1817 }
1797} 1818}
1798 1819
1799 1820
1800 1821
1801void KABCore::clipboardDataChanged() 1822void KABCore::clipboardDataChanged()
1802{ 1823{
1803 1824
1804 if ( mReadWrite ) 1825 if ( mReadWrite )
1805 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1826 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1806 1827
1807} 1828}
1808 1829
1809void KABCore::updateActionMenu() 1830void KABCore::updateActionMenu()
1810{ 1831{
1811 UndoStack *undo = UndoStack::instance(); 1832 UndoStack *undo = UndoStack::instance();
1812 RedoStack *redo = RedoStack::instance(); 1833 RedoStack *redo = RedoStack::instance();
1813 1834
1814 if ( undo->isEmpty() ) 1835 if ( undo->isEmpty() )
1815 mActionUndo->setText( i18n( "Undo" ) ); 1836 mActionUndo->setText( i18n( "Undo" ) );
1816 else 1837 else
1817 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1838 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1818 1839
1819 mActionUndo->setEnabled( !undo->isEmpty() ); 1840 mActionUndo->setEnabled( !undo->isEmpty() );
1820 1841
1821 if ( !redo->top() ) 1842 if ( !redo->top() )
1822 mActionRedo->setText( i18n( "Redo" ) ); 1843 mActionRedo->setText( i18n( "Redo" ) );
1823 else 1844 else
1824 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1845 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1825 1846
1826 mActionRedo->setEnabled( !redo->isEmpty() ); 1847 mActionRedo->setEnabled( !redo->isEmpty() );
1827} 1848}
1828 1849
1829void KABCore::configureKeyBindings() 1850void KABCore::configureKeyBindings()
1830{ 1851{
1831#ifndef KAB_EMBEDDED 1852#ifndef KAB_EMBEDDED
1832 KKeyDialog::configure( actionCollection(), true ); 1853 KKeyDialog::configure( actionCollection(), true );
1833#else //KAB_EMBEDDED 1854#else //KAB_EMBEDDED
1834 qDebug("KABCore::configureKeyBindings() not implemented"); 1855 qDebug("KABCore::configureKeyBindings() not implemented");
1835#endif //KAB_EMBEDDED 1856#endif //KAB_EMBEDDED
1836} 1857}
1837 1858
1838#ifdef KAB_EMBEDDED 1859#ifdef KAB_EMBEDDED
1839void KABCore::configureResources() 1860void KABCore::configureResources()
1840{ 1861{
1841 KRES::KCMKResources dlg( this, "" , 0 ); 1862 KRES::KCMKResources dlg( this, "" , 0 );
1842 1863
1843 if ( !dlg.exec() ) 1864 if ( !dlg.exec() )
1844 return; 1865 return;
1845 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1866 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1846} 1867}
1847#endif //KAB_EMBEDDED 1868#endif //KAB_EMBEDDED
1848 1869
1849 1870
1850 1871
1851#ifndef KAB_EMBEDDED 1872#ifndef KAB_EMBEDDED
1852#include "kabcore.moc" 1873#include "kabcore.moc"
1853#endif //KAB_EMBEDDED 1874#endif //KAB_EMBEDDED