summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 3ae23e8..a0fec91 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,518 +1,518 @@
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//US#include <qpe/resource.h> // needed for Resource::loadPixmap 81//US#include <qpe/resource.h> // needed for Resource::loadPixmap
82//#include <qlabel.h> 82//#include <qlabel.h>
83#endif // KAB_EMBEDDED 83#endif // KAB_EMBEDDED
84#include <kcmkabconfig.h> 84#include <kcmkabconfig.h>
85 85
86 86
87#include <kresources/selectdialog.h> 87#include <kresources/selectdialog.h>
88#include <kmessagebox.h> 88#include <kmessagebox.h>
89 89
90#include <picture.h> 90#include <picture.h>
91#include <resource.h> 91#include <resource.h>
92 92
93//US#include <qsplitter.h> 93//US#include <qsplitter.h>
94#include <qvbox.h> 94#include <qvbox.h>
95#include <qlayout.h> 95#include <qlayout.h>
96#include <qclipboard.h> 96#include <qclipboard.h>
97 97
98#include <libkdepim/categoryselectdialog.h> 98#include <libkdepim/categoryselectdialog.h>
99 99
100#include "addresseeutil.h" 100#include "addresseeutil.h"
101#include "undocmds.h" 101#include "undocmds.h"
102#include "addresseeeditordialog.h" 102#include "addresseeeditordialog.h"
103#include "viewmanager.h" 103#include "viewmanager.h"
104#include "details/detailsviewcontainer.h" 104#include "details/detailsviewcontainer.h"
105#include "kabprefs.h" 105#include "kabprefs.h"
106#include "xxportmanager.h" 106#include "xxportmanager.h"
107#include "incsearchwidget.h" 107#include "incsearchwidget.h"
108#include "jumpbuttonbar.h" 108#include "jumpbuttonbar.h"
109#include "extensionmanager.h" 109#include "extensionmanager.h"
110#include "addresseeconfig.h" 110#include "addresseeconfig.h"
111#include <kcmultidialog.h> 111#include <kcmultidialog.h>
112 112
113 113
114#ifdef KAB_EMBEDDED 114#ifdef KAB_EMBEDDED
115KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 115KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
116 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 116 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
117 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 117 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
118 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 118 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
119#else //KAB_EMBEDDED 119#else //KAB_EMBEDDED
120KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 120KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
121 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 121 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
122 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 122 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
123 mReadWrite( readWrite ), mModified( false ) 123 mReadWrite( readWrite ), mModified( false )
124#endif //KAB_EMBEDDED 124#endif //KAB_EMBEDDED
125{ 125{
126#ifdef KAB_EMBEDDED 126#ifdef KAB_EMBEDDED
127 //US we define here our own global actioncollection. 127 //US we define here our own global actioncollection.
128 //mActionCollection = new KActionCollection(this); 128 //mActionCollection = new KActionCollection(this);
129#endif //KAB_EMBEDDED 129#endif //KAB_EMBEDDED
130 mExtensionBarSplitter = 0; 130 mExtensionBarSplitter = 0;
131 mIsPart = !parent->inherits( "KAddressBookMain" ); 131 mIsPart = !parent->inherits( "KAddressBookMain" );
132 132
133 mAddressBook = KABC::StdAddressBook::self(); 133 mAddressBook = KABC::StdAddressBook::self();
134 KABC::StdAddressBook::setAutomaticSave( true ); 134 KABC::StdAddressBook::setAutomaticSave( false );
135 135
136#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
137 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 137 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
138#endif //KAB_EMBEDDED 138#endif //KAB_EMBEDDED
139 139
140 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 140 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
141 SLOT( addressBookChanged() ) ); 141 SLOT( addressBookChanged() ) );
142 142
143 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 143 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
144 "X-Department", "KADDRESSBOOK" ); 144 "X-Department", "KADDRESSBOOK" );
145 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 145 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
146 "X-Profession", "KADDRESSBOOK" ); 146 "X-Profession", "KADDRESSBOOK" );
147 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 147 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
148 "X-AssistantsName", "KADDRESSBOOK" ); 148 "X-AssistantsName", "KADDRESSBOOK" );
149 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 149 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
150 "X-ManagersName", "KADDRESSBOOK" ); 150 "X-ManagersName", "KADDRESSBOOK" );
151 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 151 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
152 "X-SpousesName", "KADDRESSBOOK" ); 152 "X-SpousesName", "KADDRESSBOOK" );
153 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 153 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
154 "X-Office", "KADDRESSBOOK" ); 154 "X-Office", "KADDRESSBOOK" );
155 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 155 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
156 "X-IMAddress", "KADDRESSBOOK" ); 156 "X-IMAddress", "KADDRESSBOOK" );
157 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 157 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
158 "X-Anniversary", "KADDRESSBOOK" ); 158 "X-Anniversary", "KADDRESSBOOK" );
159 159
160//US added this field to become compatible with Opie addressbook 160//US added this field to become compatible with Opie addressbook
161 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 161 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
162 "X-Gender", "KADDRESSBOOK" ); 162 "X-Gender", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 163 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
164 "X-Children", "KADDRESSBOOK" ); 164 "X-Children", "KADDRESSBOOK" );
165 165
166 initGUI(); 166 initGUI();
167 167
168 mIncSearchWidget->setFocus(); 168 mIncSearchWidget->setFocus();
169 169
170 170
171 connect( mViewManager, SIGNAL( selected( const QString& ) ), 171 connect( mViewManager, SIGNAL( selected( const QString& ) ),
172 SLOT( setContactSelected( const QString& ) ) ); 172 SLOT( setContactSelected( const QString& ) ) );
173 connect( mViewManager, SIGNAL( executed( const QString& ) ), 173 connect( mViewManager, SIGNAL( executed( const QString& ) ),
174 SLOT( editContact( const QString& ) ) ); 174 SLOT( editContact( const QString& ) ) );
175 connect( mViewManager, SIGNAL( deleteRequest( ) ), 175 connect( mViewManager, SIGNAL( deleteRequest( ) ),
176 SLOT( deleteContacts( ) ) ); 176 SLOT( deleteContacts( ) ) );
177 connect( mViewManager, SIGNAL( modified() ), 177 connect( mViewManager, SIGNAL( modified() ),
178 SLOT( setModified() ) ); 178 SLOT( setModified() ) );
179 179
180 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 180 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
181 181
182 connect( mXXPortManager, SIGNAL( modified() ), 182 connect( mXXPortManager, SIGNAL( modified() ),
183 SLOT( setModified() ) ); 183 SLOT( setModified() ) );
184 184
185 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 185 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
186 SLOT( incrementalSearch( const QString& ) ) ); 186 SLOT( incrementalSearch( const QString& ) ) );
187 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 187 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
188 mJumpButtonBar, SLOT( recreateButtons() ) ); 188 mJumpButtonBar, SLOT( recreateButtons() ) );
189 189
190#ifndef KAB_EMBEDDED 190#ifndef KAB_EMBEDDED
191 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 191 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
192 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 192 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
193 193
194 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 194 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
195 SLOT( sendMail( const QString& ) ) ); 195 SLOT( sendMail( const QString& ) ) );
196 connect( mDetails, SIGNAL( browse( const QString& ) ), 196 connect( mDetails, SIGNAL( browse( const QString& ) ),
197 SLOT( browse( const QString& ) ) ); 197 SLOT( browse( const QString& ) ) );
198 198
199 mAddressBookService = new KAddressBookService( this ); 199 mAddressBookService = new KAddressBookService( this );
200 200
201#endif //KAB_EMBEDDED 201#endif //KAB_EMBEDDED
202 mEditorDialog = 0; 202 mEditorDialog = 0;
203 createAddresseeEditorDialog( this ); 203 createAddresseeEditorDialog( this );
204 setModified( false ); 204 setModified( false );
205} 205}
206 206
207KABCore::~KABCore() 207KABCore::~KABCore()
208{ 208{
209 // save(); 209 // save();
210 //saveSettings(); 210 //saveSettings();
211 //KABPrefs::instance()->writeConfig(); 211 //KABPrefs::instance()->writeConfig();
212 delete AddresseeConfig::instance(); 212 delete AddresseeConfig::instance();
213 mAddressBook = 0; 213 mAddressBook = 0;
214 KABC::StdAddressBook::close(); 214 KABC::StdAddressBook::close();
215 215
216#ifdef KAB_EMBEDDED 216#ifdef KAB_EMBEDDED
217 //US we define here our own global actioncollection. 217 //US we define here our own global actioncollection.
218 // delete mActionCollection; 218 // delete mActionCollection;
219#endif //KAB_EMBEDDED 219#endif //KAB_EMBEDDED
220 220
221} 221}
222 222
223void KABCore::restoreSettings() 223void KABCore::restoreSettings()
224{ 224{
225 bool state = KABPrefs::instance()->mJumpButtonBarVisible; 225 bool state = KABPrefs::instance()->mJumpButtonBarVisible;
226 226
227 mActionJumpBar->setChecked( state ); 227 mActionJumpBar->setChecked( state );
228 setJumpButtonBarVisible( state ); 228 setJumpButtonBarVisible( state );
229 229
230 state = KABPrefs::instance()->mDetailsPageVisible; 230 state = KABPrefs::instance()->mDetailsPageVisible;
231 231
232 mActionDetails->setChecked( state ); 232 mActionDetails->setChecked( state );
233 setDetailsVisible( state ); 233 setDetailsVisible( state );
234 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 234 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
235 if ( splitterSize.count() == 0 ) { 235 if ( splitterSize.count() == 0 ) {
236 splitterSize.append( width() / 2 ); 236 splitterSize.append( width() / 2 );
237 splitterSize.append( width() / 2 ); 237 splitterSize.append( width() / 2 );
238 } 238 }
239 mMiniSplitter->setSizes( splitterSize ); 239 mMiniSplitter->setSizes( splitterSize );
240 if ( mExtensionBarSplitter ) { 240 if ( mExtensionBarSplitter ) {
241 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 241 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
242 if ( splitterSize.count() == 0 ) { 242 if ( splitterSize.count() == 0 ) {
243 splitterSize.append( width() / 2 ); 243 splitterSize.append( width() / 2 );
244 splitterSize.append( width() / 2 ); 244 splitterSize.append( width() / 2 );
245 } 245 }
246 mExtensionBarSplitter->setSizes( splitterSize ); 246 mExtensionBarSplitter->setSizes( splitterSize );
247 247
248 } 248 }
249#ifndef KAB_EMBEDDED 249#ifndef KAB_EMBEDDED
250 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; 250 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter;
251 if ( splitterSize.count() == 0 ) { 251 if ( splitterSize.count() == 0 ) {
252 splitterSize.append( width() / 2 ); 252 splitterSize.append( width() / 2 );
253 splitterSize.append( width() / 2 ); 253 splitterSize.append( width() / 2 );
254 } 254 }
255 mExtensionBarSplitter->setSizes( splitterSize ); 255 mExtensionBarSplitter->setSizes( splitterSize );
256 256
257 splitterSize = KABPrefs::instance()->mDetailsSplitter; 257 splitterSize = KABPrefs::instance()->mDetailsSplitter;
258 if ( splitterSize.count() == 0 ) { 258 if ( splitterSize.count() == 0 ) {
259 splitterSize.append( height() / 2 ); 259 splitterSize.append( height() / 2 );
260 splitterSize.append( height() / 2 ); 260 splitterSize.append( height() / 2 );
261 } 261 }
262 mDetailsSplitter->setSizes( splitterSize ); 262 mDetailsSplitter->setSizes( splitterSize );
263 263
264 mExtensionManager->restoreSettings(); 264 mExtensionManager->restoreSettings();
265 265
266#endif //KAB_EMBEDDED 266#endif //KAB_EMBEDDED
267 267
268 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 268 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
269 269
270 mViewManager->restoreSettings(); 270 mViewManager->restoreSettings();
271 mExtensionManager->restoreSettings(); 271 mExtensionManager->restoreSettings();
272} 272}
273 273
274void KABCore::saveSettings() 274void KABCore::saveSettings()
275{ 275{
276 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 276 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
277 if ( mExtensionBarSplitter ) 277 if ( mExtensionBarSplitter )
278 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 278 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
279 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 279 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
280 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 280 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
281#ifndef KAB_EMBEDDED 281#ifndef KAB_EMBEDDED
282 282
283 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 283 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
284 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 284 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
285#endif //KAB_EMBEDDED 285#endif //KAB_EMBEDDED
286 mExtensionManager->saveSettings(); 286 mExtensionManager->saveSettings();
287 mViewManager->saveSettings(); 287 mViewManager->saveSettings();
288 288
289 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 289 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
290 290
291} 291}
292 292
293KABC::AddressBook *KABCore::addressBook() const 293KABC::AddressBook *KABCore::addressBook() const
294{ 294{
295 return mAddressBook; 295 return mAddressBook;
296} 296}
297 297
298KConfig *KABCore::config() 298KConfig *KABCore::config()
299{ 299{
300#ifndef KAB_EMBEDDED 300#ifndef KAB_EMBEDDED
301 return KABPrefs::instance()->config(); 301 return KABPrefs::instance()->config();
302#else //KAB_EMBEDDED 302#else //KAB_EMBEDDED
303 return KABPrefs::instance()->getConfig(); 303 return KABPrefs::instance()->getConfig();
304#endif //KAB_EMBEDDED 304#endif //KAB_EMBEDDED
305} 305}
306 306
307KActionCollection *KABCore::actionCollection() const 307KActionCollection *KABCore::actionCollection() const
308{ 308{
309 return mGUIClient->actionCollection(); 309 return mGUIClient->actionCollection();
310} 310}
311 311
312KABC::Field *KABCore::currentSearchField() const 312KABC::Field *KABCore::currentSearchField() const
313{ 313{
314 if (mIncSearchWidget) 314 if (mIncSearchWidget)
315 return mIncSearchWidget->currentField(); 315 return mIncSearchWidget->currentField();
316 else 316 else
317 return 0; 317 return 0;
318} 318}
319 319
320QStringList KABCore::selectedUIDs() const 320QStringList KABCore::selectedUIDs() const
321{ 321{
322 return mViewManager->selectedUids(); 322 return mViewManager->selectedUids();
323} 323}
324 324
325KABC::Resource *KABCore::requestResource( QWidget *parent ) 325KABC::Resource *KABCore::requestResource( QWidget *parent )
326{ 326{
327 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 327 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
328 328
329 QPtrList<KRES::Resource> kresResources; 329 QPtrList<KRES::Resource> kresResources;
330 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 330 QPtrListIterator<KABC::Resource> resIt( kabcResources );
331 KABC::Resource *resource; 331 KABC::Resource *resource;
332 while ( ( resource = resIt.current() ) != 0 ) { 332 while ( ( resource = resIt.current() ) != 0 ) {
333 ++resIt; 333 ++resIt;
334 if ( !resource->readOnly() ) { 334 if ( !resource->readOnly() ) {
335 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 335 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
336 if ( res ) 336 if ( res )
337 kresResources.append( res ); 337 kresResources.append( res );
338 } 338 }
339 } 339 }
340 340
341 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 341 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
342 return static_cast<KABC::Resource*>( res ); 342 return static_cast<KABC::Resource*>( res );
343} 343}
344 344
345#ifndef KAB_EMBEDDED 345#ifndef KAB_EMBEDDED
346KAboutData *KABCore::createAboutData() 346KAboutData *KABCore::createAboutData()
347#else //KAB_EMBEDDED 347#else //KAB_EMBEDDED
348void KABCore::createAboutData() 348void KABCore::createAboutData()
349#endif //KAB_EMBEDDED 349#endif //KAB_EMBEDDED
350{ 350{
351#ifndef KAB_EMBEDDED 351#ifndef KAB_EMBEDDED
352 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 352 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
353 "3.1", I18N_NOOP( "The KDE Address Book" ), 353 "3.1", I18N_NOOP( "The KDE Address Book" ),
354 KAboutData::License_GPL_V2, 354 KAboutData::License_GPL_V2,
355 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 355 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
356 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 356 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
357 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 357 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
358 about->addAuthor( "Cornelius Schumacher", 358 about->addAuthor( "Cornelius Schumacher",
359 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 359 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
360 "schumacher@kde.org" ); 360 "schumacher@kde.org" );
361 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 361 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
362 "mpilone@slac.com" ); 362 "mpilone@slac.com" );
363 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 363 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
364 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 364 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
365 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 365 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
366 "michel@klaralvdalens-datakonsult.se" ); 366 "michel@klaralvdalens-datakonsult.se" );
367 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 367 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
368 "hansen@kde.org" ); 368 "hansen@kde.org" );
369 369
370 return about; 370 return about;
371#endif //KAB_EMBEDDED 371#endif //KAB_EMBEDDED
372 372
373 QString version; 373 QString version;
374#include <../version> 374#include <../version>
375 QMessageBox::about( this, "About KAddressbook/Pi", 375 QMessageBox::about( this, "About KAddressbook/Pi",
376 "KAddressbook/Platform-independent\n" 376 "KAddressbook/Platform-independent\n"
377 "(KA/Pi) " +version + " - " + 377 "(KA/Pi) " +version + " - " +
378#ifdef DESKTOP_VERSION 378#ifdef DESKTOP_VERSION
379 "Desktop Edition\n" 379 "Desktop Edition\n"
380#else 380#else
381 "PDA-Edition\n" 381 "PDA-Edition\n"
382 "for: Zaurus 5500 / 7x0 / 8x0\n" 382 "for: Zaurus 5500 / 7x0 / 8x0\n"
383#endif 383#endif
384 384
385 "(c) 2004 Ulf Schenk\n" 385 "(c) 2004 Ulf Schenk\n"
386 "(c) 1997-2003, The KDE PIM Team\n" 386 "(c) 1997-2003, The KDE PIM Team\n"
387 "Tobias Koenig Current maintainer tokoe@kde.org\n" 387 "Tobias Koenig Current maintainer tokoe@kde.org\n"
388 "Don Sanders Original author\n" 388 "Don Sanders Original author\n"
389 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 389 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
390 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 390 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
391 "Greg Stern DCOP interface\n" 391 "Greg Stern DCOP interface\n"
392 "Mark Westcot Contact pinning\n" 392 "Mark Westcot Contact pinning\n"
393 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 393 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
394 "Steffen Hansen LDAP Lookup hansen@kde.org\n" ); 394 "Steffen Hansen LDAP Lookup hansen@kde.org\n" );
395} 395}
396 396
397void KABCore::setContactSelected( const QString &uid ) 397void KABCore::setContactSelected( const QString &uid )
398{ 398{
399 KABC::Addressee addr = mAddressBook->findByUid( uid ); 399 KABC::Addressee addr = mAddressBook->findByUid( uid );
400 if ( !mDetails->isHidden() ) 400 if ( !mDetails->isHidden() )
401 mDetails->setAddressee( addr ); 401 mDetails->setAddressee( addr );
402 402
403 if ( !addr.isEmpty() ) { 403 if ( !addr.isEmpty() ) {
404 emit contactSelected( addr.formattedName() ); 404 emit contactSelected( addr.formattedName() );
405 KABC::Picture pic = addr.photo(); 405 KABC::Picture pic = addr.photo();
406 if ( pic.isIntern() ) { 406 if ( pic.isIntern() ) {
407//US emit contactSelected( pic.data() ); 407//US emit contactSelected( pic.data() );
408//US instead use: 408//US instead use:
409 QPixmap px; 409 QPixmap px;
410 if (pic.data().isNull() != true) 410 if (pic.data().isNull() != true)
411 { 411 {
412 px.convertFromImage(pic.data()); 412 px.convertFromImage(pic.data());
413 } 413 }
414 414
415 emit contactSelected( px ); 415 emit contactSelected( px );
416 } 416 }
417 } 417 }
418 418
419 419
420 mExtensionManager->setSelectionChanged(); 420 mExtensionManager->setSelectionChanged();
421 421
422 // update the actions 422 // update the actions
423 bool selected = !uid.isEmpty(); 423 bool selected = !uid.isEmpty();
424 424
425 if ( mReadWrite ) { 425 if ( mReadWrite ) {
426 mActionCut->setEnabled( selected ); 426 mActionCut->setEnabled( selected );
427 mActionPaste->setEnabled( selected ); 427 mActionPaste->setEnabled( selected );
428 } 428 }
429 429
430 mActionCopy->setEnabled( selected ); 430 mActionCopy->setEnabled( selected );
431 mActionDelete->setEnabled( selected ); 431 mActionDelete->setEnabled( selected );
432 mActionEditAddressee->setEnabled( selected ); 432 mActionEditAddressee->setEnabled( selected );
433 mActionMail->setEnabled( selected ); 433 mActionMail->setEnabled( selected );
434 mActionMailVCard->setEnabled( selected ); 434 mActionMailVCard->setEnabled( selected );
435 mActionWhoAmI->setEnabled( selected ); 435 mActionWhoAmI->setEnabled( selected );
436 mActionCategories->setEnabled( selected ); 436 mActionCategories->setEnabled( selected );
437} 437}
438 438
439void KABCore::sendMail() 439void KABCore::sendMail()
440{ 440{
441#ifndef KAB_EMBEDDED 441#ifndef KAB_EMBEDDED
442 sendMail( mViewManager->selectedEmails().join( ", " ) ); 442 sendMail( mViewManager->selectedEmails().join( ", " ) );
443#else //KAB_EMBEDDED 443#else //KAB_EMBEDDED
444 qDebug("KABCore::sendMail() ust be fixed"); 444 qDebug("KABCore::sendMail() ust be fixed");
445#endif //KAB_EMBEDDED 445#endif //KAB_EMBEDDED
446} 446}
447 447
448void KABCore::sendMail( const QString& email ) 448void KABCore::sendMail( const QString& email )
449{ 449{
450#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
451 kapp->invokeMailer( email, "" ); 451 kapp->invokeMailer( email, "" );
452#else //KAB_EMBEDDED 452#else //KAB_EMBEDDED
453 qDebug("KABCore::sendMail(const QString& email) ust be fixed"); 453 qDebug("KABCore::sendMail(const QString& email) ust be fixed");
454#endif //KAB_EMBEDDED 454#endif //KAB_EMBEDDED
455} 455}
456 456
457void KABCore::mailVCard() 457void KABCore::mailVCard()
458{ 458{
459#ifndef KAB_EMBEDDED 459#ifndef KAB_EMBEDDED
460 QStringList uids = mViewManager->selectedUids(); 460 QStringList uids = mViewManager->selectedUids();
461 if ( !uids.isEmpty() ) 461 if ( !uids.isEmpty() )
462 mailVCard( uids ); 462 mailVCard( uids );
463#else //KAB_EMBEDDED 463#else //KAB_EMBEDDED
464 qDebug("KABCore::mailVCard() must be fixed"); 464 qDebug("KABCore::mailVCard() must be fixed");
465#endif //KAB_EMBEDDED 465#endif //KAB_EMBEDDED
466} 466}
467 467
468void KABCore::mailVCard( const QStringList& uids ) 468void KABCore::mailVCard( const QStringList& uids )
469{ 469{
470#ifndef KAB_EMBEDDED 470#ifndef KAB_EMBEDDED
471 QStringList urls; 471 QStringList urls;
472 472
473 // Create a temp dir, so that we can put the files in it with proper names 473 // Create a temp dir, so that we can put the files in it with proper names
474 KTempFile tempDir; 474 KTempFile tempDir;
475 if ( tempDir.status() != 0 ) { 475 if ( tempDir.status() != 0 ) {
476 kdWarning() << strerror( tempDir.status() ) << endl; 476 kdWarning() << strerror( tempDir.status() ) << endl;
477 return; 477 return;
478 } 478 }
479 479
480 QString dirName = tempDir.name(); 480 QString dirName = tempDir.name();
481 tempDir.unlink(); 481 tempDir.unlink();
482 QDir().mkdir( dirName, true ); 482 QDir().mkdir( dirName, true );
483 483
484 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 484 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
485 KABC::Addressee a = mAddressBook->findByUid( *it ); 485 KABC::Addressee a = mAddressBook->findByUid( *it );
486 486
487 if ( a.isEmpty() ) 487 if ( a.isEmpty() )
488 continue; 488 continue;
489 489
490 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 490 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
491 491
492 QString fileName = dirName + "/" + name; 492 QString fileName = dirName + "/" + name;
493 493
494 QFile outFile(fileName); 494 QFile outFile(fileName);
495 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 495 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
496 KABC::VCardConverter converter; 496 KABC::VCardConverter converter;
497 QString vcard; 497 QString vcard;
498 498
499 converter.addresseeToVCard( a, vcard ); 499 converter.addresseeToVCard( a, vcard );
500 500
501 QTextStream t( &outFile ); // use a text stream 501 QTextStream t( &outFile ); // use a text stream
502 t.setEncoding( QTextStream::UnicodeUTF8 ); 502 t.setEncoding( QTextStream::UnicodeUTF8 );
503 t << vcard; 503 t << vcard;
504 504
505 outFile.close(); 505 outFile.close();
506 506
507 urls.append( fileName ); 507 urls.append( fileName );
508 } 508 }
509 } 509 }
510 510
511 kapp->invokeMailer( QString::null, QString::null, QString::null, 511 kapp->invokeMailer( QString::null, QString::null, QString::null,
512 QString::null, // subject 512 QString::null, // subject
513 QString::null, // body 513 QString::null, // body
514 QString::null, 514 QString::null,
515 urls ); // attachments 515 urls ); // attachments
516#else //KAB_EMBEDDED 516#else //KAB_EMBEDDED
517 qDebug("KABCore::mailVCard( must be fixed"); 517 qDebug("KABCore::mailVCard( must be fixed");
518#endif //KAB_EMBEDDED 518#endif //KAB_EMBEDDED