summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-10 22:46:12 (UTC)
committer ulf69 <ulf69>2004-08-10 22:46:12 (UTC)
commit02d51ae409a353d3a79e976c26ccc1f652e55de8 (patch) (unidiff)
tree54d7a9f1eecd2ef9c3332f2bc22ff6ac6d9af335
parentdc81e96e29f619c6eb32c3ed18ff45b789c8504e (diff)
downloadkdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.zip
kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.gz
kdepimpi-02d51ae409a353d3a79e976c26ccc1f652e55de8.tar.bz2
final changes on how to send emails to selected contacts
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp26
1 files changed, 10 insertions, 16 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index d6f0cee..6610288 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1556 +1,1550 @@
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 79
80//#include <qlabel.h> 80//#include <qlabel.h>
81 81
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <qpe/ir.h> 84#include <qpe/ir.h>
85#endif 85#endif
86 86
87#endif // KAB_EMBEDDED 87#endif // KAB_EMBEDDED
88#include "kcmconfigs/kcmkabconfig.h" 88#include "kcmconfigs/kcmkabconfig.h"
89#include "kcmconfigs/kcmkdepimconfig.h" 89#include "kcmconfigs/kcmkdepimconfig.h"
90#include "kpimglobalprefs.h" 90#include "kpimglobalprefs.h"
91#include "externalapphandler.h" 91#include "externalapphandler.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 (mActionBeamVCard) 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& emaillist )
469{ 469{
470 bool result = ExternalAppHandler::instance()->mailToContacts(email); 470 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
471 if (emaillist.contains(",") > 0)
472 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
473 else
474 ExternalAppHandler::instance()->mailToOneContact( emaillist );
471} 475}
472 476
473 477
474 478
475void KABCore::mailVCard() 479void KABCore::mailVCard()
476{ 480{
477 QStringList uids = mViewManager->selectedUids(); 481 QStringList uids = mViewManager->selectedUids();
478 if ( !uids.isEmpty() ) 482 if ( !uids.isEmpty() )
479 mailVCard( uids ); 483 mailVCard( uids );
480} 484}
481 485
482void KABCore::mailVCard( const QStringList& uids ) 486void KABCore::mailVCard( const QStringList& uids )
483{ 487{
484 QStringList urls; 488 QStringList urls;
485 489
486 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 490// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
487 491
488/*US 492 QString dirName = "/tmp/" + KApplication::randomString( 8 );
489 // Create a temp dir, so that we can put the files in it with proper names
490 KTempFile tempDir;
491 if ( tempDir.status() != 0 ) {
492 kdWarning() << strerror( tempDir.status() ) << endl;
493 return;
494 }
495
496 QString dirName = tempDir.name();
497 tempDir.unlink();
498*/
499 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
500 493
501 494
502 495
503 QDir().mkdir( dirName, true ); 496 QDir().mkdir( dirName, true );
504 497
505 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 498 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
506 KABC::Addressee a = mAddressBook->findByUid( *it ); 499 KABC::Addressee a = mAddressBook->findByUid( *it );
507 500
508 if ( a.isEmpty() ) 501 if ( a.isEmpty() )
509 continue; 502 continue;
510 503
511 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 504 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
512 505
513 QString fileName = dirName + "/" + name; 506 QString fileName = dirName + "/" + name;
514 507
515 QFile outFile(fileName); 508 QFile outFile(fileName);
509
516 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 510 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
517 KABC::VCardConverter converter; 511 KABC::VCardConverter converter;
518 QString vcard; 512 QString vcard;
519 513
520 converter.addresseeToVCard( a, vcard ); 514 converter.addresseeToVCard( a, vcard );
521 515
522 QTextStream t( &outFile ); // use a text stream 516 QTextStream t( &outFile ); // use a text stream
523 t.setEncoding( QTextStream::UnicodeUTF8 ); 517 t.setEncoding( QTextStream::UnicodeUTF8 );
524 t << vcard; 518 t << vcard;
525 519
526 outFile.close(); 520 outFile.close();
527 521
528 urls.append( fileName ); 522 urls.append( fileName );
529 } 523 }
530 } 524 }
531 525
532 bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); 526 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
533 527
534 528
535/*US 529/*US
536 kapp->invokeMailer( QString::null, QString::null, QString::null, 530 kapp->invokeMailer( QString::null, QString::null, QString::null,
537 QString::null, // subject 531 QString::null, // subject
538 QString::null, // body 532 QString::null, // body
539 QString::null, 533 QString::null,
540 urls ); // attachments 534 urls ); // attachments
541*/ 535*/
542 536
543} 537}
544 538
545/** 539/**
546 Beams the "WhoAmI contact. 540 Beams the "WhoAmI contact.
547*/ 541*/
548void KABCore::beamMySelf() 542void KABCore::beamMySelf()
549{ 543{
550 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 544 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
551 if (!a.isEmpty()) 545 if (!a.isEmpty())
552 { 546 {
553 QStringList uids; 547 QStringList uids;
554 uids << a.uid(); 548 uids << a.uid();
555 549
556 beamVCard(uids); 550 beamVCard(uids);
557 } else { 551 } else {
558 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 552 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
559 553
560 554
561 } 555 }
562} 556}
563 557
564void KABCore::beamVCard() 558void KABCore::beamVCard()
565{ 559{
566 QStringList uids = mViewManager->selectedUids(); 560 QStringList uids = mViewManager->selectedUids();
567 if ( !uids.isEmpty() ) 561 if ( !uids.isEmpty() )
568 beamVCard( uids ); 562 beamVCard( uids );
569} 563}
570 564
571 565
572void KABCore::beamVCard(const QStringList& uids) 566void KABCore::beamVCard(const QStringList& uids)
573{ 567{
574/*US 568/*US
575 QString beamFilename; 569 QString beamFilename;
576 Opie::OPimContact c; 570 Opie::OPimContact c;
577 if ( actionPersonal->isOn() ) { 571 if ( actionPersonal->isOn() ) {
578 beamFilename = addressbookPersonalVCardName(); 572 beamFilename = addressbookPersonalVCardName();
579 if ( !QFile::exists( beamFilename ) ) 573 if ( !QFile::exists( beamFilename ) )
580 return; // can't beam a non-existent file 574 return; // can't beam a non-existent file
581 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 575 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
582 beamFilename ); 576 beamFilename );
583 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 577 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
584 Opie::OPimContactAccess::List allList = access->allRecords(); 578 Opie::OPimContactAccess::List allList = access->allRecords();
585 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 579 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
586 c = *it; 580 c = *it;
587 581
588 delete access; 582 delete access;
589 } else { 583 } else {
590 unlink( beamfile ); // delete if exists 584 unlink( beamfile ); // delete if exists
591 mkdir("/tmp/obex/", 0755); 585 mkdir("/tmp/obex/", 0755);
592 c = m_abView -> currentEntry(); 586 c = m_abView -> currentEntry();
593 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 587 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
594 beamfile ); 588 beamfile );
595 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 589 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
596 access->add( c ); 590 access->add( c );
597 access->save(); 591 access->save();
598 delete access; 592 delete access;
599 593
600 beamFilename = beamfile; 594 beamFilename = beamfile;
601 } 595 }
602 596
603 owarn << "Beaming: " << beamFilename << oendl; 597 owarn << "Beaming: " << beamFilename << oendl;
604*/ 598*/
605 599
606#if 0 600#if 0
607 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 601 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
608 602
609 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 603 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
610 604
611 QString name = "contact.vcf"; 605 QString name = "contact.vcf";
612 606
613 QString fileName = dirName + "/" + name; 607 QString fileName = dirName + "/" + name;
614#endif 608#endif
615 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 609 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
616 // 610 //
617 QString fileName = "/tmp/kdepimbeamfile"; 611 QString fileName = "/tmp/kdepimbeamfile";
618 612
619 613
620 //QDir().mkdir( dirName, true ); 614 //QDir().mkdir( dirName, true );
621 615
622 QFile outFile(fileName); 616 QFile outFile(fileName);
623 KABC::VCardConverter converter; 617 KABC::VCardConverter converter;
624 QString description; 618 QString description;
625 619
626 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 620 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
627 621
628 QTextStream t( &outFile ); // use a text stream 622 QTextStream t( &outFile ); // use a text stream
629 t.setEncoding( QTextStream::UnicodeUTF8 ); 623 t.setEncoding( QTextStream::UnicodeUTF8 );
630 624
631 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 625 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
632 KABC::Addressee a = mAddressBook->findByUid( *it ); 626 KABC::Addressee a = mAddressBook->findByUid( *it );
633 627
634 if ( a.isEmpty() ) 628 if ( a.isEmpty() )
635 continue; 629 continue;
636 630
637 if (description.isEmpty()) 631 if (description.isEmpty())
638 description = a.formattedName(); 632 description = a.formattedName();
639 633
640 QString vcard; 634 QString vcard;
641 converter.addresseeToVCard( a, vcard ); 635 converter.addresseeToVCard( a, vcard );
642 t << vcard; 636 t << vcard;
643 637
644 } 638 }
645 } else { 639 } else {
646 qDebug("Error open temp beam file "); 640 qDebug("Error open temp beam file ");
647 return; 641 return;
648 } 642 }
649 643
650 outFile.close(); 644 outFile.close();
651 645
652#ifndef DESKTOP_VERSION 646#ifndef DESKTOP_VERSION
653 Ir *ir = new Ir( this ); 647 Ir *ir = new Ir( this );
654 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 648 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
655 ir->send( fileName, description, "text/x-vCard" ); 649 ir->send( fileName, description, "text/x-vCard" );
656#endif 650#endif
657 651
658} 652}
659 653
660void KABCore::beamDone( Ir *ir ) 654void KABCore::beamDone( Ir *ir )
661{ 655{
662#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
663 delete ir; 657 delete ir;
664#endif 658#endif
665} 659}
666 660
667 661
668void KABCore::browse( const QString& url ) 662void KABCore::browse( const QString& url )
669{ 663{
670#ifndef KAB_EMBEDDED 664#ifndef KAB_EMBEDDED
671 kapp->invokeBrowser( url ); 665 kapp->invokeBrowser( url );
672#else //KAB_EMBEDDED 666#else //KAB_EMBEDDED
673 qDebug("KABCore::browse must be fixed"); 667 qDebug("KABCore::browse must be fixed");
674#endif //KAB_EMBEDDED 668#endif //KAB_EMBEDDED
675} 669}
676 670
677void KABCore::selectAllContacts() 671void KABCore::selectAllContacts()
678{ 672{
679 mViewManager->setSelected( QString::null, true ); 673 mViewManager->setSelected( QString::null, true );
680} 674}
681 675
682void KABCore::deleteContacts() 676void KABCore::deleteContacts()
683{ 677{
684 QStringList uidList = mViewManager->selectedUids(); 678 QStringList uidList = mViewManager->selectedUids();
685 deleteContacts( uidList ); 679 deleteContacts( uidList );
686} 680}
687 681
688void KABCore::deleteContacts( const QStringList &uids ) 682void KABCore::deleteContacts( const QStringList &uids )
689{ 683{
690 if ( uids.count() > 0 ) { 684 if ( uids.count() > 0 ) {
691 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 685 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
692 UndoStack::instance()->push( command ); 686 UndoStack::instance()->push( command );
693 RedoStack::instance()->clear(); 687 RedoStack::instance()->clear();
694 688
695 // now if we deleted anything, refresh 689 // now if we deleted anything, refresh
696 setContactSelected( QString::null ); 690 setContactSelected( QString::null );
697 setModified( true ); 691 setModified( true );
698 } 692 }
699} 693}
700 694
701void KABCore::copyContacts() 695void KABCore::copyContacts()
702{ 696{
703 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 697 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
704 698
705 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 699 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
706 700
707 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 701 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
708 702
709 QClipboard *cb = QApplication::clipboard(); 703 QClipboard *cb = QApplication::clipboard();
710 cb->setText( clipText ); 704 cb->setText( clipText );
711} 705}
712 706
713void KABCore::cutContacts() 707void KABCore::cutContacts()
714{ 708{
715 QStringList uidList = mViewManager->selectedUids(); 709 QStringList uidList = mViewManager->selectedUids();
716 710
717//US if ( uidList.size() > 0 ) { 711//US if ( uidList.size() > 0 ) {
718 if ( uidList.count() > 0 ) { 712 if ( uidList.count() > 0 ) {
719 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 713 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
720 UndoStack::instance()->push( command ); 714 UndoStack::instance()->push( command );
721 RedoStack::instance()->clear(); 715 RedoStack::instance()->clear();
722 716
723 setModified( true ); 717 setModified( true );
724 } 718 }
725} 719}
726 720
727void KABCore::pasteContacts() 721void KABCore::pasteContacts()
728{ 722{
729 QClipboard *cb = QApplication::clipboard(); 723 QClipboard *cb = QApplication::clipboard();
730 724
731 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 725 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
732 726
733 pasteContacts( list ); 727 pasteContacts( list );
734} 728}
735 729
736void KABCore::pasteContacts( KABC::Addressee::List &list ) 730void KABCore::pasteContacts( KABC::Addressee::List &list )
737{ 731{
738 KABC::Resource *resource = requestResource( this ); 732 KABC::Resource *resource = requestResource( this );
739 KABC::Addressee::List::Iterator it; 733 KABC::Addressee::List::Iterator it;
740 for ( it = list.begin(); it != list.end(); ++it ) 734 for ( it = list.begin(); it != list.end(); ++it )
741 (*it).setResource( resource ); 735 (*it).setResource( resource );
742 736
743 PwPasteCommand *command = new PwPasteCommand( this, list ); 737 PwPasteCommand *command = new PwPasteCommand( this, list );
744 UndoStack::instance()->push( command ); 738 UndoStack::instance()->push( command );
745 RedoStack::instance()->clear(); 739 RedoStack::instance()->clear();
746 740
747 setModified( true ); 741 setModified( true );
748} 742}
749 743
750void KABCore::setWhoAmI() 744void KABCore::setWhoAmI()
751{ 745{
752 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 746 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
753 747
754 if ( addrList.count() > 1 ) { 748 if ( addrList.count() > 1 ) {
755 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 749 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
756 return; 750 return;
757 } 751 }
758 752
759 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 753 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
760 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 754 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
761 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 755 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
762} 756}
763 757
764void KABCore::setCategories() 758void KABCore::setCategories()
765{ 759{
766 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 760 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
767 if ( !dlg.exec() ) 761 if ( !dlg.exec() )
768 return; 762 return;
769 763
770 bool merge = false; 764 bool merge = false;
771 QString msg = i18n( "Merge with existing categories?" ); 765 QString msg = i18n( "Merge with existing categories?" );
772 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 766 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
773 merge = true; 767 merge = true;
774 768
775 QStringList categories = dlg.selectedCategories(); 769 QStringList categories = dlg.selectedCategories();
776 770
777 QStringList uids = mViewManager->selectedUids(); 771 QStringList uids = mViewManager->selectedUids();
778 QStringList::Iterator it; 772 QStringList::Iterator it;
779 for ( it = uids.begin(); it != uids.end(); ++it ) { 773 for ( it = uids.begin(); it != uids.end(); ++it ) {
780 KABC::Addressee addr = mAddressBook->findByUid( *it ); 774 KABC::Addressee addr = mAddressBook->findByUid( *it );
781 if ( !addr.isEmpty() ) { 775 if ( !addr.isEmpty() ) {
782 if ( !merge ) 776 if ( !merge )
783 addr.setCategories( categories ); 777 addr.setCategories( categories );
784 else { 778 else {
785 QStringList addrCategories = addr.categories(); 779 QStringList addrCategories = addr.categories();
786 QStringList::Iterator catIt; 780 QStringList::Iterator catIt;
787 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 781 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
788 if ( !addrCategories.contains( *catIt ) ) 782 if ( !addrCategories.contains( *catIt ) )
789 addrCategories.append( *catIt ); 783 addrCategories.append( *catIt );
790 } 784 }
791 addr.setCategories( addrCategories ); 785 addr.setCategories( addrCategories );
792 } 786 }
793 787
794 mAddressBook->insertAddressee( addr ); 788 mAddressBook->insertAddressee( addr );
795 } 789 }
796 } 790 }
797 791
798 if ( uids.count() > 0 ) 792 if ( uids.count() > 0 )
799 setModified( true ); 793 setModified( true );
800} 794}
801 795
802void KABCore::setSearchFields( const KABC::Field::List &fields ) 796void KABCore::setSearchFields( const KABC::Field::List &fields )
803{ 797{
804 mIncSearchWidget->setFields( fields ); 798 mIncSearchWidget->setFields( fields );
805} 799}
806 800
807void KABCore::incrementalSearch( const QString& text ) 801void KABCore::incrementalSearch( const QString& text )
808{ 802{
809 mViewManager->setSelected( QString::null, false ); 803 mViewManager->setSelected( QString::null, false );
810 804
811 if ( !text.isEmpty() ) { 805 if ( !text.isEmpty() ) {
812 KABC::Field *field = mIncSearchWidget->currentField(); 806 KABC::Field *field = mIncSearchWidget->currentField();
813 807
814 QString pattern = text.lower(); 808 QString pattern = text.lower();
815 809
816#if 1 //KDE_VERSION >= 319 810#if 1 //KDE_VERSION >= 319
817 KABC::AddresseeList list( mAddressBook->allAddressees() ); 811 KABC::AddresseeList list( mAddressBook->allAddressees() );
818 if ( field ) { 812 if ( field ) {
819 list.sortByField( field ); 813 list.sortByField( field );
820 KABC::AddresseeList::Iterator it; 814 KABC::AddresseeList::Iterator it;
821 for ( it = list.begin(); it != list.end(); ++it ) { 815 for ( it = list.begin(); it != list.end(); ++it ) {
822 if ( field->value( *it ).lower().startsWith( pattern ) ) { 816 if ( field->value( *it ).lower().startsWith( pattern ) ) {
823 mViewManager->setSelected( (*it).uid(), true ); 817 mViewManager->setSelected( (*it).uid(), true );
824 return; 818 return;
825 } 819 }
826 } 820 }
827 } else { 821 } else {
828 KABC::AddresseeList::Iterator it; 822 KABC::AddresseeList::Iterator it;
829 for ( it = list.begin(); it != list.end(); ++it ) { 823 for ( it = list.begin(); it != list.end(); ++it ) {
830 KABC::Field::List fieldList = mIncSearchWidget->fields(); 824 KABC::Field::List fieldList = mIncSearchWidget->fields();
831 KABC::Field::List::ConstIterator fieldIt; 825 KABC::Field::List::ConstIterator fieldIt;
832 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 826 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
833 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 827 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
834 mViewManager->setSelected( (*it).uid(), true ); 828 mViewManager->setSelected( (*it).uid(), true );
835 return; 829 return;
836 } 830 }
837 } 831 }
838 } 832 }
839 } 833 }
840#else 834#else
841 KABC::AddressBook::Iterator it; 835 KABC::AddressBook::Iterator it;
842 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 836 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
843 if ( field ) { 837 if ( field ) {
844 if ( field->value( *it ).lower().startsWith( pattern ) ) { 838 if ( field->value( *it ).lower().startsWith( pattern ) ) {
845 mViewManager->setSelected( (*it).uid(), true ); 839 mViewManager->setSelected( (*it).uid(), true );
846 return; 840 return;
847 } 841 }
848 } else { 842 } else {
849 KABC::Field::List fieldList = mIncSearchWidget->fields(); 843 KABC::Field::List fieldList = mIncSearchWidget->fields();
850 KABC::Field::List::ConstIterator fieldIt; 844 KABC::Field::List::ConstIterator fieldIt;
851 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 845 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
852 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 846 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
853 mViewManager->setSelected( (*it).uid(), true ); 847 mViewManager->setSelected( (*it).uid(), true );
854 return; 848 return;
855 } 849 }
856 } 850 }
857 } 851 }
858 } 852 }
859#endif 853#endif
860 } 854 }
861} 855}
862 856
863void KABCore::setModified() 857void KABCore::setModified()
864{ 858{
865 setModified( true ); 859 setModified( true );
866} 860}
867 861
868void KABCore::setModifiedWOrefresh() 862void KABCore::setModifiedWOrefresh()
869{ 863{
870 // qDebug("KABCore::setModifiedWOrefresh() "); 864 // qDebug("KABCore::setModifiedWOrefresh() ");
871 mModified = true; 865 mModified = true;
872 mActionSave->setEnabled( mModified ); 866 mActionSave->setEnabled( mModified );
873#ifdef DESKTOP_VERSION 867#ifdef DESKTOP_VERSION
874 mDetails->refreshView(); 868 mDetails->refreshView();
875#endif 869#endif
876 870
877} 871}
878void KABCore::setModified( bool modified ) 872void KABCore::setModified( bool modified )
879{ 873{
880 mModified = modified; 874 mModified = modified;
881 mActionSave->setEnabled( mModified ); 875 mActionSave->setEnabled( mModified );
882 876
883 if ( modified ) 877 if ( modified )
884 mJumpButtonBar->recreateButtons(); 878 mJumpButtonBar->recreateButtons();
885 879
886 mViewManager->refreshView(); 880 mViewManager->refreshView();
887 mDetails->refreshView(); 881 mDetails->refreshView();
888 882
889} 883}
890 884
891bool KABCore::modified() const 885bool KABCore::modified() const
892{ 886{
893 return mModified; 887 return mModified;
894} 888}
895 889
896void KABCore::contactModified( const KABC::Addressee &addr ) 890void KABCore::contactModified( const KABC::Addressee &addr )
897{ 891{
898 892
899 Command *command = 0; 893 Command *command = 0;
900 QString uid; 894 QString uid;
901 895
902 // check if it exists already 896 // check if it exists already
903 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 897 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
904 if ( origAddr.isEmpty() ) 898 if ( origAddr.isEmpty() )
905 command = new PwNewCommand( mAddressBook, addr ); 899 command = new PwNewCommand( mAddressBook, addr );
906 else { 900 else {
907 command = new PwEditCommand( mAddressBook, origAddr, addr ); 901 command = new PwEditCommand( mAddressBook, origAddr, addr );
908 uid = addr.uid(); 902 uid = addr.uid();
909 } 903 }
910 904
911 UndoStack::instance()->push( command ); 905 UndoStack::instance()->push( command );
912 RedoStack::instance()->clear(); 906 RedoStack::instance()->clear();
913 907
914 setModified( true ); 908 setModified( true );
915} 909}
916 910
917void KABCore::newContact() 911void KABCore::newContact()
918{ 912{
919 913
920 914
921 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 915 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
922 916
923 QPtrList<KRES::Resource> kresResources; 917 QPtrList<KRES::Resource> kresResources;
924 QPtrListIterator<KABC::Resource> it( kabcResources ); 918 QPtrListIterator<KABC::Resource> it( kabcResources );
925 KABC::Resource *resource; 919 KABC::Resource *resource;
926 while ( ( resource = it.current() ) != 0 ) { 920 while ( ( resource = it.current() ) != 0 ) {
927 ++it; 921 ++it;
928 if ( !resource->readOnly() ) { 922 if ( !resource->readOnly() ) {
929 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 923 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
930 if ( res ) 924 if ( res )
931 kresResources.append( res ); 925 kresResources.append( res );
932 } 926 }
933 } 927 }
934 928
935 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 929 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
936 resource = static_cast<KABC::Resource*>( res ); 930 resource = static_cast<KABC::Resource*>( res );
937 931
938 if ( resource ) { 932 if ( resource ) {
939 KABC::Addressee addr; 933 KABC::Addressee addr;
940 addr.setResource( resource ); 934 addr.setResource( resource );
941 mEditorDialog->setAddressee( addr ); 935 mEditorDialog->setAddressee( addr );
942 KApplication::execDialog ( mEditorDialog ); 936 KApplication::execDialog ( mEditorDialog );
943 937
944 } else 938 } else
945 return; 939 return;
946 940
947 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 941 // mEditorDict.insert( dialog->addressee().uid(), dialog );
948 942
949 943
950} 944}
951 945
952void KABCore::addEmail( QString aStr ) 946void KABCore::addEmail( QString aStr )
953{ 947{
954#ifndef KAB_EMBEDDED 948#ifndef KAB_EMBEDDED
955 QString fullName, email; 949 QString fullName, email;
956 950
957 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 951 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
958 952
959 // Try to lookup the addressee matching the email address 953 // Try to lookup the addressee matching the email address
960 bool found = false; 954 bool found = false;
961 QStringList emailList; 955 QStringList emailList;
962 KABC::AddressBook::Iterator it; 956 KABC::AddressBook::Iterator it;
963 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 957 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
964 emailList = (*it).emails(); 958 emailList = (*it).emails();
965 if ( emailList.contains( email ) > 0 ) { 959 if ( emailList.contains( email ) > 0 ) {
966 found = true; 960 found = true;
967 (*it).setNameFromString( fullName ); 961 (*it).setNameFromString( fullName );
968 editContact( (*it).uid() ); 962 editContact( (*it).uid() );
969 } 963 }
970 } 964 }
971 965
972 if ( !found ) { 966 if ( !found ) {
973 KABC::Addressee addr; 967 KABC::Addressee addr;
974 addr.setNameFromString( fullName ); 968 addr.setNameFromString( fullName );
975 addr.insertEmail( email, true ); 969 addr.insertEmail( email, true );
976 970
977 mAddressBook->insertAddressee( addr ); 971 mAddressBook->insertAddressee( addr );
978 mViewManager->refreshView( addr.uid() ); 972 mViewManager->refreshView( addr.uid() );
979 editContact( addr.uid() ); 973 editContact( addr.uid() );
980 } 974 }
981#else //KAB_EMBEDDED 975#else //KAB_EMBEDDED
982 qDebug("KABCore::addEmail finsih method"); 976 qDebug("KABCore::addEmail finsih method");
983#endif //KAB_EMBEDDED 977#endif //KAB_EMBEDDED
984} 978}
985 979
986void KABCore::importVCard( const KURL &url, bool showPreview ) 980void KABCore::importVCard( const KURL &url, bool showPreview )
987{ 981{
988 mXXPortManager->importVCard( url, showPreview ); 982 mXXPortManager->importVCard( url, showPreview );
989} 983}
990void KABCore::importFromOL() 984void KABCore::importFromOL()
991{ 985{
992#ifdef _WIN32_ 986#ifdef _WIN32_
993 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 987 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
994 idgl->exec(); 988 idgl->exec();
995 KABC::Addressee::List list = idgl->getAddressList(); 989 KABC::Addressee::List list = idgl->getAddressList();
996 if ( list.count() > 0 ) { 990 if ( list.count() > 0 ) {
997 KABC::Addressee::List listNew; 991 KABC::Addressee::List listNew;
998 KABC::Addressee::List listExisting; 992 KABC::Addressee::List listExisting;
999 KABC::Addressee::List::Iterator it; 993 KABC::Addressee::List::Iterator it;
1000 KABC::AddressBook::Iterator iter; 994 KABC::AddressBook::Iterator iter;
1001 for ( it = list.begin(); it != list.end(); ++it ) { 995 for ( it = list.begin(); it != list.end(); ++it ) {
1002 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 996 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1003 listNew.append( (*it) ); 997 listNew.append( (*it) );
1004 else 998 else
1005 listExisting.append( (*it) ); 999 listExisting.append( (*it) );
1006 } 1000 }
1007 if ( listExisting.count() > 0 ) 1001 if ( listExisting.count() > 0 )
1008 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1002 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1009 if ( listNew.count() > 0 ) { 1003 if ( listNew.count() > 0 ) {
1010 pasteWithNewUid = false; 1004 pasteWithNewUid = false;
1011 pasteContacts( listNew ); 1005 pasteContacts( listNew );
1012 pasteWithNewUid = true; 1006 pasteWithNewUid = true;
1013 } 1007 }
1014 } 1008 }
1015 delete idgl; 1009 delete idgl;
1016#endif 1010#endif
1017} 1011}
1018 1012
1019void KABCore::importVCard( const QString &vCard, bool showPreview ) 1013void KABCore::importVCard( const QString &vCard, bool showPreview )
1020{ 1014{
1021 mXXPortManager->importVCard( vCard, showPreview ); 1015 mXXPortManager->importVCard( vCard, showPreview );
1022} 1016}
1023 1017
1024//US added a second method without defaultparameter 1018//US added a second method without defaultparameter
1025void KABCore::editContact2() { 1019void KABCore::editContact2() {
1026 editContact( QString::null ); 1020 editContact( QString::null );
1027} 1021}
1028 1022
1029void KABCore::editContact( const QString &uid ) 1023void KABCore::editContact( const QString &uid )
1030{ 1024{
1031 1025
1032 if ( mExtensionManager->isQuickEditVisible() ) 1026 if ( mExtensionManager->isQuickEditVisible() )
1033 return; 1027 return;
1034 1028
1035 // First, locate the contact entry 1029 // First, locate the contact entry
1036 QString localUID = uid; 1030 QString localUID = uid;
1037 if ( localUID.isNull() ) { 1031 if ( localUID.isNull() ) {
1038 QStringList uidList = mViewManager->selectedUids(); 1032 QStringList uidList = mViewManager->selectedUids();
1039 if ( uidList.count() > 0 ) 1033 if ( uidList.count() > 0 )
1040 localUID = *( uidList.at( 0 ) ); 1034 localUID = *( uidList.at( 0 ) );
1041 } 1035 }
1042 1036
1043 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1037 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1044 if ( !addr.isEmpty() ) { 1038 if ( !addr.isEmpty() ) {
1045 mEditorDialog->setAddressee( addr ); 1039 mEditorDialog->setAddressee( addr );
1046 KApplication::execDialog ( mEditorDialog ); 1040 KApplication::execDialog ( mEditorDialog );
1047 } 1041 }
1048} 1042}
1049 1043
1050void KABCore::save() 1044void KABCore::save()
1051{ 1045{
1052 if ( !mModified ) 1046 if ( !mModified )
1053 return; 1047 return;
1054 QString text = i18n( "There was an error while attempting to save\n the " 1048 QString text = i18n( "There was an error while attempting to save\n the "
1055 "address book. Please check that some \nother application is " 1049 "address book. Please check that some \nother application is "
1056 "not using it. " ); 1050 "not using it. " );
1057 statusMessage(i18n("Saving addressbook ... ")); 1051 statusMessage(i18n("Saving addressbook ... "));
1058#ifndef KAB_EMBEDDED 1052#ifndef KAB_EMBEDDED
1059 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1053 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1060 if ( !b || !b->save() ) { 1054 if ( !b || !b->save() ) {
1061 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1055 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1062 } 1056 }
1063#else //KAB_EMBEDDED 1057#else //KAB_EMBEDDED
1064 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1058 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1065 if ( !b || !b->save() ) { 1059 if ( !b || !b->save() ) {
1066 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1060 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1067 } 1061 }
1068#endif //KAB_EMBEDDED 1062#endif //KAB_EMBEDDED
1069 1063
1070 statusMessage(i18n("Addressbook saved!")); 1064 statusMessage(i18n("Addressbook saved!"));
1071 setModified( false ); 1065 setModified( false );
1072} 1066}
1073 1067
1074void KABCore::statusMessage(QString mess , int time ) 1068void KABCore::statusMessage(QString mess , int time )
1075{ 1069{
1076 //topLevelWidget()->setCaption( mess ); 1070 //topLevelWidget()->setCaption( mess );
1077 // pending setting timer to revome message 1071 // pending setting timer to revome message
1078} 1072}
1079void KABCore::undo() 1073void KABCore::undo()
1080{ 1074{
1081 UndoStack::instance()->undo(); 1075 UndoStack::instance()->undo();
1082 1076
1083 // Refresh the view 1077 // Refresh the view
1084 mViewManager->refreshView(); 1078 mViewManager->refreshView();
1085} 1079}
1086 1080
1087void KABCore::redo() 1081void KABCore::redo()
1088{ 1082{
1089 RedoStack::instance()->redo(); 1083 RedoStack::instance()->redo();
1090 1084
1091 // Refresh the view 1085 // Refresh the view
1092 mViewManager->refreshView(); 1086 mViewManager->refreshView();
1093} 1087}
1094 1088
1095void KABCore::setJumpButtonBarVisible( bool visible ) 1089void KABCore::setJumpButtonBarVisible( bool visible )
1096{ 1090{
1097 if ( visible ) 1091 if ( visible )
1098 mJumpButtonBar->show(); 1092 mJumpButtonBar->show();
1099 else 1093 else
1100 mJumpButtonBar->hide(); 1094 mJumpButtonBar->hide();
1101} 1095}
1102void KABCore::setDetailsToState() 1096void KABCore::setDetailsToState()
1103{ 1097{
1104 setDetailsVisible( mActionDetails->isChecked() ); 1098 setDetailsVisible( mActionDetails->isChecked() );
1105} 1099}
1106 1100
1107void KABCore::setDetailsVisible( bool visible ) 1101void KABCore::setDetailsVisible( bool visible )
1108{ 1102{
1109 if ( visible ) 1103 if ( visible )
1110 mDetails->show(); 1104 mDetails->show();
1111 else 1105 else
1112 mDetails->hide(); 1106 mDetails->hide();
1113} 1107}
1114 1108
1115void KABCore::extensionModified( const KABC::Addressee::List &list ) 1109void KABCore::extensionModified( const KABC::Addressee::List &list )
1116{ 1110{
1117 1111
1118 if ( list.count() != 0 ) { 1112 if ( list.count() != 0 ) {
1119 KABC::Addressee::List::ConstIterator it; 1113 KABC::Addressee::List::ConstIterator it;
1120 for ( it = list.begin(); it != list.end(); ++it ) 1114 for ( it = list.begin(); it != list.end(); ++it )
1121 mAddressBook->insertAddressee( *it ); 1115 mAddressBook->insertAddressee( *it );
1122 if ( list.count() > 1 ) 1116 if ( list.count() > 1 )
1123 setModified(); 1117 setModified();
1124 else 1118 else
1125 setModifiedWOrefresh(); 1119 setModifiedWOrefresh();
1126 } 1120 }
1127 if ( list.count() == 0 ) 1121 if ( list.count() == 0 )
1128 mViewManager->refreshView(); 1122 mViewManager->refreshView();
1129 else 1123 else
1130 mViewManager->refreshView( list[ 0 ].uid() ); 1124 mViewManager->refreshView( list[ 0 ].uid() );
1131 1125
1132 1126
1133 1127
1134} 1128}
1135 1129
1136QString KABCore::getNameByPhone( const QString &phone ) 1130QString KABCore::getNameByPhone( const QString &phone )
1137{ 1131{
1138#ifndef KAB_EMBEDDED 1132#ifndef KAB_EMBEDDED
1139 QRegExp r( "[/*/-/ ]" ); 1133 QRegExp r( "[/*/-/ ]" );
1140 QString localPhone( phone ); 1134 QString localPhone( phone );
1141 1135
1142 bool found = false; 1136 bool found = false;
1143 QString ownerName = ""; 1137 QString ownerName = "";
1144 KABC::AddressBook::Iterator iter; 1138 KABC::AddressBook::Iterator iter;
1145 KABC::PhoneNumber::List::Iterator phoneIter; 1139 KABC::PhoneNumber::List::Iterator phoneIter;
1146 KABC::PhoneNumber::List phoneList; 1140 KABC::PhoneNumber::List phoneList;
1147 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1141 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1148 phoneList = (*iter).phoneNumbers(); 1142 phoneList = (*iter).phoneNumbers();
1149 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1143 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1150 ++phoneIter) { 1144 ++phoneIter) {
1151 // Get rid of separator chars so just the numbers are compared. 1145 // Get rid of separator chars so just the numbers are compared.
1152 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1146 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1153 ownerName = (*iter).formattedName(); 1147 ownerName = (*iter).formattedName();
1154 found = true; 1148 found = true;
1155 } 1149 }
1156 } 1150 }
1157 } 1151 }
1158 1152
1159 return ownerName; 1153 return ownerName;
1160#else //KAB_EMBEDDED 1154#else //KAB_EMBEDDED
1161 qDebug("KABCore::getNameByPhone finsih method"); 1155 qDebug("KABCore::getNameByPhone finsih method");
1162 return ""; 1156 return "";
1163#endif //KAB_EMBEDDED 1157#endif //KAB_EMBEDDED
1164 1158
1165} 1159}
1166 1160
1167void KABCore::openConfigDialog() 1161void KABCore::openConfigDialog()
1168{ 1162{
1169 KABPrefs* kab_prefs = KABPrefs::instance(); 1163 KABPrefs* kab_prefs = KABPrefs::instance();
1170 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); 1164 KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance();
1171 1165
1172 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1166 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1173 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1167 KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1174 ConfigureDialog->addModule(kabcfg ); 1168 ConfigureDialog->addModule(kabcfg );
1175 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1169 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1176 ConfigureDialog->addModule(kdelibcfg ); 1170 ConfigureDialog->addModule(kdelibcfg );
1177 1171
1178 1172
1179 1173
1180 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1174 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1181 this, SLOT( configurationChanged() ) ); 1175 this, SLOT( configurationChanged() ) );
1182 connect( ConfigureDialog, SIGNAL( okClicked() ), 1176 connect( ConfigureDialog, SIGNAL( okClicked() ),
1183 this, SLOT( configurationChanged() ) ); 1177 this, SLOT( configurationChanged() ) );
1184 saveSettings(); 1178 saveSettings();
1185 ConfigureDialog->showMaximized(); 1179 ConfigureDialog->showMaximized();
1186 if ( ConfigureDialog->exec() ) 1180 if ( ConfigureDialog->exec() )
1187 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); 1181 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") );
1188 delete ConfigureDialog; 1182 delete ConfigureDialog;
1189} 1183}
1190 1184
1191void KABCore::openLDAPDialog() 1185void KABCore::openLDAPDialog()
1192{ 1186{
1193#ifndef KAB_EMBEDDED 1187#ifndef KAB_EMBEDDED
1194 if ( !mLdapSearchDialog ) { 1188 if ( !mLdapSearchDialog ) {
1195 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1189 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1196 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1190 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1197 SLOT( refreshView() ) ); 1191 SLOT( refreshView() ) );
1198 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1192 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1199 SLOT( setModified() ) ); 1193 SLOT( setModified() ) );
1200 } else 1194 } else
1201 mLdapSearchDialog->restoreSettings(); 1195 mLdapSearchDialog->restoreSettings();
1202 1196
1203 if ( mLdapSearchDialog->isOK() ) 1197 if ( mLdapSearchDialog->isOK() )
1204 mLdapSearchDialog->exec(); 1198 mLdapSearchDialog->exec();
1205#else //KAB_EMBEDDED 1199#else //KAB_EMBEDDED
1206 qDebug("KABCore::openLDAPDialog() finsih method"); 1200 qDebug("KABCore::openLDAPDialog() finsih method");
1207#endif //KAB_EMBEDDED 1201#endif //KAB_EMBEDDED
1208} 1202}
1209 1203
1210void KABCore::print() 1204void KABCore::print()
1211{ 1205{
1212#ifndef KAB_EMBEDDED 1206#ifndef KAB_EMBEDDED
1213 KPrinter printer; 1207 KPrinter printer;
1214 if ( !printer.setup( this ) ) 1208 if ( !printer.setup( this ) )
1215 return; 1209 return;
1216 1210
1217 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1211 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1218 mViewManager->selectedUids(), this ); 1212 mViewManager->selectedUids(), this );
1219 1213
1220 wizard.exec(); 1214 wizard.exec();
1221#else //KAB_EMBEDDED 1215#else //KAB_EMBEDDED
1222 qDebug("KABCore::print() finsih method"); 1216 qDebug("KABCore::print() finsih method");
1223#endif //KAB_EMBEDDED 1217#endif //KAB_EMBEDDED
1224 1218
1225} 1219}
1226 1220
1227 1221
1228void KABCore::addGUIClient( KXMLGUIClient *client ) 1222void KABCore::addGUIClient( KXMLGUIClient *client )
1229{ 1223{
1230 if ( mGUIClient ) 1224 if ( mGUIClient )
1231 mGUIClient->insertChildClient( client ); 1225 mGUIClient->insertChildClient( client );
1232 else 1226 else
1233 KMessageBox::error( this, "no KXMLGUICLient"); 1227 KMessageBox::error( this, "no KXMLGUICLient");
1234} 1228}
1235 1229
1236 1230
1237void KABCore::configurationChanged() 1231void KABCore::configurationChanged()
1238{ 1232{
1239 mExtensionManager->reconfigure(); 1233 mExtensionManager->reconfigure();
1240} 1234}
1241 1235
1242void KABCore::addressBookChanged() 1236void KABCore::addressBookChanged()
1243{ 1237{
1244/*US 1238/*US
1245 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1239 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1246 while ( it.current() ) { 1240 while ( it.current() ) {
1247 if ( it.current()->dirty() ) { 1241 if ( it.current()->dirty() ) {
1248 QString text = i18n( "Data has been changed externally. Unsaved " 1242 QString text = i18n( "Data has been changed externally. Unsaved "
1249 "changes will be lost." ); 1243 "changes will be lost." );
1250 KMessageBox::information( this, text ); 1244 KMessageBox::information( this, text );
1251 } 1245 }
1252 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1246 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1253 ++it; 1247 ++it;
1254 } 1248 }
1255*/ 1249*/
1256 if (mEditorDialog) 1250 if (mEditorDialog)
1257 { 1251 {
1258 if (mEditorDialog->dirty()) 1252 if (mEditorDialog->dirty())
1259 { 1253 {
1260 QString text = i18n( "Data has been changed externally. Unsaved " 1254 QString text = i18n( "Data has been changed externally. Unsaved "
1261 "changes will be lost." ); 1255 "changes will be lost." );
1262 KMessageBox::information( this, text ); 1256 KMessageBox::information( this, text );
1263 } 1257 }
1264 QString currentuid = mEditorDialog->addressee().uid(); 1258 QString currentuid = mEditorDialog->addressee().uid();
1265 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1259 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1266 } 1260 }
1267 mViewManager->refreshView(); 1261 mViewManager->refreshView();
1268// mDetails->refreshView(); 1262// mDetails->refreshView();
1269 1263
1270 1264
1271} 1265}
1272 1266
1273AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1267AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1274 const char *name ) 1268 const char *name )
1275{ 1269{
1276 1270
1277 if ( mEditorDialog == 0 ) { 1271 if ( mEditorDialog == 0 ) {
1278 mEditorDialog = new AddresseeEditorDialog( this, parent, 1272 mEditorDialog = new AddresseeEditorDialog( this, parent,
1279 name ? name : "editorDialog" ); 1273 name ? name : "editorDialog" );
1280 1274
1281 1275
1282 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1276 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1283 SLOT( contactModified( const KABC::Addressee& ) ) ); 1277 SLOT( contactModified( const KABC::Addressee& ) ) );
1284 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1278 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1285 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1279 // SLOT( slotEditorDestroyed( const QString& ) ) );
1286 } 1280 }
1287 1281
1288 return mEditorDialog; 1282 return mEditorDialog;
1289} 1283}
1290 1284
1291void KABCore::slotEditorDestroyed( const QString &uid ) 1285void KABCore::slotEditorDestroyed( const QString &uid )
1292{ 1286{
1293 //mEditorDict.remove( uid ); 1287 //mEditorDict.remove( uid );
1294} 1288}
1295 1289
1296void KABCore::initGUI() 1290void KABCore::initGUI()
1297{ 1291{
1298#ifndef KAB_EMBEDDED 1292#ifndef KAB_EMBEDDED
1299 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1293 QHBoxLayout *topLayout = new QHBoxLayout( this );
1300 topLayout->setSpacing( KDialogBase::spacingHint() ); 1294 topLayout->setSpacing( KDialogBase::spacingHint() );
1301 1295
1302 mExtensionBarSplitter = new QSplitter( this ); 1296 mExtensionBarSplitter = new QSplitter( this );
1303 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1297 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1304 1298
1305 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1299 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1306 1300
1307 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1301 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1308 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1302 mIncSearchWidget = new IncSearchWidget( viewSpace );
1309 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1303 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1310 SLOT( incrementalSearch( const QString& ) ) ); 1304 SLOT( incrementalSearch( const QString& ) ) );
1311 1305
1312 mViewManager = new ViewManager( this, viewSpace ); 1306 mViewManager = new ViewManager( this, viewSpace );
1313 viewSpace->setStretchFactor( mViewManager, 1 ); 1307 viewSpace->setStretchFactor( mViewManager, 1 );
1314 1308
1315 mDetails = new ViewContainer( mDetailsSplitter ); 1309 mDetails = new ViewContainer( mDetailsSplitter );
1316 1310
1317 mJumpButtonBar = new JumpButtonBar( this, this ); 1311 mJumpButtonBar = new JumpButtonBar( this, this );
1318 1312
1319 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1313 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1320 1314
1321 topLayout->addWidget( mExtensionBarSplitter ); 1315 topLayout->addWidget( mExtensionBarSplitter );
1322 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1316 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1323 topLayout->addWidget( mJumpButtonBar ); 1317 topLayout->addWidget( mJumpButtonBar );
1324 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1318 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1325 1319
1326 mXXPortManager = new XXPortManager( this, this ); 1320 mXXPortManager = new XXPortManager( this, this );
1327 1321
1328#else //KAB_EMBEDDED 1322#else //KAB_EMBEDDED
1329 //US initialize viewMenu before settingup viewmanager. 1323 //US initialize viewMenu before settingup viewmanager.
1330 // Viewmanager needs this menu to plugin submenues. 1324 // Viewmanager needs this menu to plugin submenues.
1331 viewMenu = new QPopupMenu( this ); 1325 viewMenu = new QPopupMenu( this );
1332 settingsMenu = new QPopupMenu( this ); 1326 settingsMenu = new QPopupMenu( this );
1333 //filterMenu = new QPopupMenu( this ); 1327 //filterMenu = new QPopupMenu( this );
1334 ImportMenu = new QPopupMenu( this ); 1328 ImportMenu = new QPopupMenu( this );
1335 ExportMenu = new QPopupMenu( this ); 1329 ExportMenu = new QPopupMenu( this );
1336 1330
1337 changeMenu= new QPopupMenu( this ); 1331 changeMenu= new QPopupMenu( this );
1338 1332
1339//US since we have no splitter for the embedded system, setup 1333//US since we have no splitter for the embedded system, setup
1340// a layout with two frames. One left and one right. 1334// a layout with two frames. One left and one right.
1341 1335
1342 QBoxLayout *topLayout; 1336 QBoxLayout *topLayout;
1343 1337
1344 // = new QHBoxLayout( this ); 1338 // = new QHBoxLayout( this );
1345// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1339// QBoxLayout *topLayout = (QBoxLayout*)layout();
1346 1340
1347// QWidget *mainBox = new QWidget( this ); 1341// QWidget *mainBox = new QWidget( this );
1348// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1342// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1349 1343
1350#ifdef DESKTOP_VERSION 1344#ifdef DESKTOP_VERSION
1351 topLayout = new QHBoxLayout( this ); 1345 topLayout = new QHBoxLayout( this );
1352 1346
1353 1347
1354 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1348 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1355 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1349 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1356 1350
1357 topLayout->addWidget(mMiniSplitter ); 1351 topLayout->addWidget(mMiniSplitter );
1358 1352
1359 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1353 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1360 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1354 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1361 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1355 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1362 mDetails = new ViewContainer( mMiniSplitter ); 1356 mDetails = new ViewContainer( mMiniSplitter );
1363 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1357 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1364#else 1358#else
1365 if ( QApplication::desktop()->width() > 480 ) { 1359 if ( QApplication::desktop()->width() > 480 ) {
1366 topLayout = new QHBoxLayout( this ); 1360 topLayout = new QHBoxLayout( this );
1367 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1361 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1368 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1362 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1369 } else { 1363 } else {
1370 1364
1371 topLayout = new QHBoxLayout( this ); 1365 topLayout = new QHBoxLayout( this );
1372 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1366 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1373 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1367 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1374 } 1368 }
1375 1369
1376 topLayout->addWidget(mMiniSplitter ); 1370 topLayout->addWidget(mMiniSplitter );
1377 mViewManager = new ViewManager( this, mMiniSplitter ); 1371 mViewManager = new ViewManager( this, mMiniSplitter );
1378 mDetails = new ViewContainer( mMiniSplitter ); 1372 mDetails = new ViewContainer( mMiniSplitter );
1379 1373
1380 1374
1381 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1375 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1382#endif 1376#endif
1383 //eh->hide(); 1377 //eh->hide();
1384 // topLayout->addWidget(mExtensionManager ); 1378 // topLayout->addWidget(mExtensionManager );
1385 1379
1386 1380
1387/*US 1381/*US
1388#ifndef KAB_NOSPLITTER 1382#ifndef KAB_NOSPLITTER
1389 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1383 QHBoxLayout *topLayout = new QHBoxLayout( this );
1390//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1384//US topLayout->setSpacing( KDialogBase::spacingHint() );
1391 topLayout->setSpacing( 10 ); 1385 topLayout->setSpacing( 10 );
1392 1386
1393 mDetailsSplitter = new QSplitter( this ); 1387 mDetailsSplitter = new QSplitter( this );
1394 1388
1395 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1389 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1396 1390
1397 mViewManager = new ViewManager( this, viewSpace ); 1391 mViewManager = new ViewManager( this, viewSpace );
1398 viewSpace->setStretchFactor( mViewManager, 1 ); 1392 viewSpace->setStretchFactor( mViewManager, 1 );
1399 1393
1400 mDetails = new ViewContainer( mDetailsSplitter ); 1394 mDetails = new ViewContainer( mDetailsSplitter );
1401 1395
1402 topLayout->addWidget( mDetailsSplitter ); 1396 topLayout->addWidget( mDetailsSplitter );
1403 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1397 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1404#else //KAB_NOSPLITTER 1398#else //KAB_NOSPLITTER
1405 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1399 QHBoxLayout *topLayout = new QHBoxLayout( this );
1406//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1400//US topLayout->setSpacing( KDialogBase::spacingHint() );
1407 topLayout->setSpacing( 10 ); 1401 topLayout->setSpacing( 10 );
1408 1402
1409// mDetailsSplitter = new QSplitter( this ); 1403// mDetailsSplitter = new QSplitter( this );
1410 1404
1411 QVBox *viewSpace = new QVBox( this ); 1405 QVBox *viewSpace = new QVBox( this );
1412 1406
1413 mViewManager = new ViewManager( this, viewSpace ); 1407 mViewManager = new ViewManager( this, viewSpace );
1414 viewSpace->setStretchFactor( mViewManager, 1 ); 1408 viewSpace->setStretchFactor( mViewManager, 1 );
1415 1409
1416 mDetails = new ViewContainer( this ); 1410 mDetails = new ViewContainer( this );
1417 1411
1418 topLayout->addWidget( viewSpace ); 1412 topLayout->addWidget( viewSpace );
1419// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1413// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1420 topLayout->addWidget( mDetails ); 1414 topLayout->addWidget( mDetails );
1421#endif //KAB_NOSPLITTER 1415#endif //KAB_NOSPLITTER
1422*/ 1416*/
1423 1417
1424 1418
1425#endif //KAB_EMBEDDED 1419#endif //KAB_EMBEDDED
1426 initActions(); 1420 initActions();
1427 1421
1428#ifdef KAB_EMBEDDED 1422#ifdef KAB_EMBEDDED
1429 addActionsManually(); 1423 addActionsManually();
1430 //US make sure the export and import menues are initialized before creating the xxPortManager. 1424 //US make sure the export and import menues are initialized before creating the xxPortManager.
1431 mXXPortManager = new XXPortManager( this, this ); 1425 mXXPortManager = new XXPortManager( this, this );
1432 1426
1433 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1427 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1434 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1428 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1435 // mActionQuit->plug ( mMainWindow->toolBar()); 1429 // mActionQuit->plug ( mMainWindow->toolBar());
1436 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1430 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1437 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1431 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1438 // mIncSearchWidget->hide(); 1432 // mIncSearchWidget->hide();
1439 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1433 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1440 SLOT( incrementalSearch( const QString& ) ) ); 1434 SLOT( incrementalSearch( const QString& ) ) );
1441 1435
1442 1436
1443 mJumpButtonBar = new JumpButtonBar( this, this ); 1437 mJumpButtonBar = new JumpButtonBar( this, this );
1444 1438
1445 topLayout->addWidget( mJumpButtonBar ); 1439 topLayout->addWidget( mJumpButtonBar );
1446//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1440//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1447 1441
1448// mMainWindow->getIconToolBar()->raise(); 1442// mMainWindow->getIconToolBar()->raise();
1449 1443
1450#endif //KAB_EMBEDDED 1444#endif //KAB_EMBEDDED
1451 1445
1452} 1446}
1453void KABCore::initActions() 1447void KABCore::initActions()
1454{ 1448{
1455//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1449//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1456 1450
1457#ifndef KAB_EMBEDDED 1451#ifndef KAB_EMBEDDED
1458 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1452 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1459 SLOT( clipboardDataChanged() ) ); 1453 SLOT( clipboardDataChanged() ) );
1460#endif //KAB_EMBEDDED 1454#endif //KAB_EMBEDDED
1461 1455
1462 // file menu 1456 // file menu
1463 if ( mIsPart ) { 1457 if ( mIsPart ) {
1464 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1458 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1465 SLOT( sendMail() ), actionCollection(), 1459 SLOT( sendMail() ), actionCollection(),
1466 "kaddressbook_mail" ); 1460 "kaddressbook_mail" );
1467 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1461 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1468 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1462 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1469 1463
1470 } else { 1464 } else {
1471 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1465 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1472 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1466 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1473 } 1467 }
1474 1468
1475 1469
1476 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1470 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1477 SLOT( save() ), actionCollection(), "file_sync" ); 1471 SLOT( save() ), actionCollection(), "file_sync" );
1478 1472
1479 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1473 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1480 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1474 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1481 1475
1482 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1476 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1483 this, SLOT( mailVCard() ), 1477 this, SLOT( mailVCard() ),
1484 actionCollection(), "file_mail_vcard"); 1478 actionCollection(), "file_mail_vcard");
1485 1479
1486 mActionBeamVCard = 0; 1480 mActionBeamVCard = 0;
1487 mActionBeam = 0; 1481 mActionBeam = 0;
1488 1482
1489#ifndef DESKTOP_VERSION 1483#ifndef DESKTOP_VERSION
1490 if ( Ir::supported() ) { 1484 if ( Ir::supported() ) {
1491 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this, 1485 mActionBeamVCard = new KAction( i18n( "Beam selected v&Card(s)" ), "beam", 0, this,
1492 SLOT( beamVCard() ), actionCollection(), 1486 SLOT( beamVCard() ), actionCollection(),
1493 "kaddressbook_beam_vcard" ); 1487 "kaddressbook_beam_vcard" );
1494 1488
1495 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1489 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1496 SLOT( beamMySelf() ), actionCollection(), 1490 SLOT( beamMySelf() ), actionCollection(),
1497 "kaddressbook_beam_myself" ); 1491 "kaddressbook_beam_myself" );
1498 } 1492 }
1499#endif 1493#endif
1500 1494
1501 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1495 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1502 this, SLOT( editContact2() ), 1496 this, SLOT( editContact2() ),
1503 actionCollection(), "file_properties" ); 1497 actionCollection(), "file_properties" );
1504 1498
1505#ifdef KAB_EMBEDDED 1499#ifdef KAB_EMBEDDED
1506 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1500 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1507 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1501 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1508 mMainWindow, SLOT( exit() ), 1502 mMainWindow, SLOT( exit() ),
1509 actionCollection(), "quit" ); 1503 actionCollection(), "quit" );
1510#endif //KAB_EMBEDDED 1504#endif //KAB_EMBEDDED
1511 1505
1512 // edit menu 1506 // edit menu
1513 if ( mIsPart ) { 1507 if ( mIsPart ) {
1514 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1508 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1515 SLOT( copyContacts() ), actionCollection(), 1509 SLOT( copyContacts() ), actionCollection(),
1516 "kaddressbook_copy" ); 1510 "kaddressbook_copy" );
1517 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1511 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1518 SLOT( cutContacts() ), actionCollection(), 1512 SLOT( cutContacts() ), actionCollection(),
1519 "kaddressbook_cut" ); 1513 "kaddressbook_cut" );
1520 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1514 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1521 SLOT( pasteContacts() ), actionCollection(), 1515 SLOT( pasteContacts() ), actionCollection(),
1522 "kaddressbook_paste" ); 1516 "kaddressbook_paste" );
1523 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1517 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1524 SLOT( selectAllContacts() ), actionCollection(), 1518 SLOT( selectAllContacts() ), actionCollection(),
1525 "kaddressbook_select_all" ); 1519 "kaddressbook_select_all" );
1526 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1520 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1527 SLOT( undo() ), actionCollection(), 1521 SLOT( undo() ), actionCollection(),
1528 "kaddressbook_undo" ); 1522 "kaddressbook_undo" );
1529 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1523 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1530 this, SLOT( redo() ), actionCollection(), 1524 this, SLOT( redo() ), actionCollection(),
1531 "kaddressbook_redo" ); 1525 "kaddressbook_redo" );
1532 } else { 1526 } else {
1533 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1527 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1534 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1528 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1535 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1529 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1536 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1530 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1537 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1531 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1538 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1532 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1539 } 1533 }
1540 1534
1541 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1535 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1542 Key_Delete, this, SLOT( deleteContacts() ), 1536 Key_Delete, this, SLOT( deleteContacts() ),
1543 actionCollection(), "edit_delete" ); 1537 actionCollection(), "edit_delete" );
1544 1538
1545 mActionUndo->setEnabled( false ); 1539 mActionUndo->setEnabled( false );
1546 mActionRedo->setEnabled( false ); 1540 mActionRedo->setEnabled( false );
1547 1541
1548 // settings menu 1542 // settings menu
1549#ifdef KAB_EMBEDDED 1543#ifdef KAB_EMBEDDED
1550//US special menuentry to configure the addressbook resources. On KDE 1544//US special menuentry to configure the addressbook resources. On KDE
1551// you do that through the control center !!! 1545// you do that through the control center !!!
1552 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1546 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1553 SLOT( configureResources() ), actionCollection(), 1547 SLOT( configureResources() ), actionCollection(),
1554 "kaddressbook_configure_resources" ); 1548 "kaddressbook_configure_resources" );
1555#endif //KAB_EMBEDDED 1549#endif //KAB_EMBEDDED
1556 1550