summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2004-09-22 04:45:07 (UTC)
committer zautrix <zautrix>2004-09-22 04:45:07 (UTC)
commitbbeffa56ee51d30b84bcadaf22234b8227958f31 (patch) (unidiff)
tree040ce64f3e618ef4b76ddfa80d34a245d59ef1b5 /kaddressbook
parenta56783aace3496c8b40008d0dec4c42437165e54 (diff)
downloadkdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.zip
kdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.tar.gz
kdepimpi-bbeffa56ee51d30b84bcadaf22234b8227958f31.tar.bz2
desktop compile fixes
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 1b40d71..df634d0 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,1576 +1,1577 @@
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/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h>
36#include <qprogressbar.h> 37#include <qprogressbar.h>
37 38
38#ifndef KAB_EMBEDDED 39#ifndef KAB_EMBEDDED
39#include <qclipboard.h> 40#include <qclipboard.h>
40#include <qdir.h> 41#include <qdir.h>
41#include <qfile.h> 42#include <qfile.h>
42#include <qapplicaton.h> 43#include <qapplicaton.h>
43#include <qprogressbar.h> 44#include <qprogressbar.h>
44#include <qlayout.h> 45#include <qlayout.h>
45#include <qregexp.h> 46#include <qregexp.h>
46#include <qvbox.h> 47#include <qvbox.h>
47#include <kabc/addresseelist.h> 48#include <kabc/addresseelist.h>
48#include <kabc/errorhandler.h> 49#include <kabc/errorhandler.h>
49#include <kabc/resource.h> 50#include <kabc/resource.h>
50#include <kabc/vcardconverter.h> 51#include <kabc/vcardconverter.h>
51#include <kapplication.h> 52#include <kapplication.h>
52#include <kactionclasses.h> 53#include <kactionclasses.h>
53#include <kcmultidialog.h> 54#include <kcmultidialog.h>
54#include <kdebug.h> 55#include <kdebug.h>
55#include <kdeversion.h> 56#include <kdeversion.h>
56#include <kkeydialog.h> 57#include <kkeydialog.h>
57#include <kmessagebox.h> 58#include <kmessagebox.h>
58#include <kprinter.h> 59#include <kprinter.h>
59#include <kprotocolinfo.h> 60#include <kprotocolinfo.h>
60#include <kresources/selectdialog.h> 61#include <kresources/selectdialog.h>
61#include <kstandarddirs.h> 62#include <kstandarddirs.h>
62#include <ktempfile.h> 63#include <ktempfile.h>
63#include <kxmlguiclient.h> 64#include <kxmlguiclient.h>
64#include <kaboutdata.h> 65#include <kaboutdata.h>
65#include <libkdepim/categoryselectdialog.h> 66#include <libkdepim/categoryselectdialog.h>
66 67
67#include "addresseeutil.h" 68#include "addresseeutil.h"
68#include "addresseeeditordialog.h" 69#include "addresseeeditordialog.h"
69#include "extensionmanager.h" 70#include "extensionmanager.h"
70#include "kstdaction.h" 71#include "kstdaction.h"
71#include "kaddressbookservice.h" 72#include "kaddressbookservice.h"
72#include "ldapsearchdialog.h" 73#include "ldapsearchdialog.h"
73#include "printing/printingwizard.h" 74#include "printing/printingwizard.h"
74#else // KAB_EMBEDDED 75#else // KAB_EMBEDDED
75 76
76#include <kapplication.h> 77#include <kapplication.h>
77#include "KDGanttMinimizeSplitter.h" 78#include "KDGanttMinimizeSplitter.h"
78#include "kaddressbookmain.h" 79#include "kaddressbookmain.h"
79#include "kactioncollection.h" 80#include "kactioncollection.h"
80#include "addresseedialog.h" 81#include "addresseedialog.h"
81//US 82//US
82#include <addresseeview.h> 83#include <addresseeview.h>
83 84
84#include <qapp.h> 85#include <qapp.h>
85#include <qmenubar.h> 86#include <qmenubar.h>
86//#include <qtoolbar.h> 87//#include <qtoolbar.h>
87#include <qmessagebox.h> 88#include <qmessagebox.h>
88#include <kdebug.h> 89#include <kdebug.h>
89#include <kiconloader.h> // needed for SmallIcon 90#include <kiconloader.h> // needed for SmallIcon
90#include <kresources/kcmkresources.h> 91#include <kresources/kcmkresources.h>
91#include <ktoolbar.h> 92#include <ktoolbar.h>
92 93
93 94
94//#include <qlabel.h> 95//#include <qlabel.h>
95 96
96 97
97#ifndef DESKTOP_VERSION 98#ifndef DESKTOP_VERSION
98#include <qpe/ir.h> 99#include <qpe/ir.h>
99#include <qpe/qpemenubar.h> 100#include <qpe/qpemenubar.h>
100#include <qtopia/qcopenvelope_qws.h> 101#include <qtopia/qcopenvelope_qws.h>
101#else 102#else
102 103
103#include <qmenubar.h> 104#include <qmenubar.h>
104#endif 105#endif
105 106
106#endif // KAB_EMBEDDED 107#endif // KAB_EMBEDDED
107#include "kcmconfigs/kcmkabconfig.h" 108#include "kcmconfigs/kcmkabconfig.h"
108#include "kcmconfigs/kcmkdepimconfig.h" 109#include "kcmconfigs/kcmkdepimconfig.h"
109#include "kpimglobalprefs.h" 110#include "kpimglobalprefs.h"
110#include "externalapphandler.h" 111#include "externalapphandler.h"
111 112
112 113
113#include <kresources/selectdialog.h> 114#include <kresources/selectdialog.h>
114#include <kmessagebox.h> 115#include <kmessagebox.h>
115 116
116#include <picture.h> 117#include <picture.h>
117#include <resource.h> 118#include <resource.h>
118 119
119//US#include <qsplitter.h> 120//US#include <qsplitter.h>
120#include <qmap.h> 121#include <qmap.h>
121#include <qdir.h> 122#include <qdir.h>
122#include <qfile.h> 123#include <qfile.h>
123#include <qvbox.h> 124#include <qvbox.h>
124#include <qlayout.h> 125#include <qlayout.h>
125#include <qclipboard.h> 126#include <qclipboard.h>
126#include <qtextstream.h> 127#include <qtextstream.h>
127 128
128#include <libkdepim/categoryselectdialog.h> 129#include <libkdepim/categoryselectdialog.h>
129#include <kabc/vcardconverter.h> 130#include <kabc/vcardconverter.h>
130 131
131 132
132#include "addresseeutil.h" 133#include "addresseeutil.h"
133#include "undocmds.h" 134#include "undocmds.h"
134#include "addresseeeditordialog.h" 135#include "addresseeeditordialog.h"
135#include "viewmanager.h" 136#include "viewmanager.h"
136#include "details/detailsviewcontainer.h" 137#include "details/detailsviewcontainer.h"
137#include "kabprefs.h" 138#include "kabprefs.h"
138#include "xxportmanager.h" 139#include "xxportmanager.h"
139#include "incsearchwidget.h" 140#include "incsearchwidget.h"
140#include "jumpbuttonbar.h" 141#include "jumpbuttonbar.h"
141#include "extensionmanager.h" 142#include "extensionmanager.h"
142#include "addresseeconfig.h" 143#include "addresseeconfig.h"
143#include <kcmultidialog.h> 144#include <kcmultidialog.h>
144 145
145#ifdef _WIN32_ 146#ifdef _WIN32_
146 147
147#include "kaimportoldialog.h" 148#include "kaimportoldialog.h"
148#else 149#else
149#include <unistd.h> 150#include <unistd.h>
150#endif 151#endif
151// sync includes 152// sync includes
152#include <libkdepim/ksyncprofile.h> 153#include <libkdepim/ksyncprofile.h>
153#include <libkdepim/ksyncprefsdialog.h> 154#include <libkdepim/ksyncprefsdialog.h>
154 155
155 156
156bool pasteWithNewUid = true; 157bool pasteWithNewUid = true;
157 158
158#ifdef KAB_EMBEDDED 159#ifdef KAB_EMBEDDED
159KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 160KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
160 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 161 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
161 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 162 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
162 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 163 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
163#else //KAB_EMBEDDED 164#else //KAB_EMBEDDED
164KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 165KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
165 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 166 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
166 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 167 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
167 mReadWrite( readWrite ), mModified( false ) 168 mReadWrite( readWrite ), mModified( false )
168#endif //KAB_EMBEDDED 169#endif //KAB_EMBEDDED
169{ 170{
170 171
171 mBlockSaveFlag = false; 172 mBlockSaveFlag = false;
172 mExtensionBarSplitter = 0; 173 mExtensionBarSplitter = 0;
173 mIsPart = !parent->inherits( "KAddressBookMain" ); 174 mIsPart = !parent->inherits( "KAddressBookMain" );
174 175
175 mAddressBook = KABC::StdAddressBook::self(); 176 mAddressBook = KABC::StdAddressBook::self();
176 KABC::StdAddressBook::setAutomaticSave( false ); 177 KABC::StdAddressBook::setAutomaticSave( false );
177 178
178#ifndef KAB_EMBEDDED 179#ifndef KAB_EMBEDDED
179 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 180 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
180#endif //KAB_EMBEDDED 181#endif //KAB_EMBEDDED
181 182
182 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 183 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
183 SLOT( addressBookChanged() ) ); 184 SLOT( addressBookChanged() ) );
184 185
185#if 0 186#if 0
186 // LP moved to addressbook init method 187 // LP moved to addressbook init method
187 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 188 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
188 "X-Department", "KADDRESSBOOK" ); 189 "X-Department", "KADDRESSBOOK" );
189 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 190 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
190 "X-Profession", "KADDRESSBOOK" ); 191 "X-Profession", "KADDRESSBOOK" );
191 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 192 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
192 "X-AssistantsName", "KADDRESSBOOK" ); 193 "X-AssistantsName", "KADDRESSBOOK" );
193 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 194 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
194 "X-ManagersName", "KADDRESSBOOK" ); 195 "X-ManagersName", "KADDRESSBOOK" );
195 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 196 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
196 "X-SpousesName", "KADDRESSBOOK" ); 197 "X-SpousesName", "KADDRESSBOOK" );
197 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 198 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
198 "X-Office", "KADDRESSBOOK" ); 199 "X-Office", "KADDRESSBOOK" );
199 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 200 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
200 "X-IMAddress", "KADDRESSBOOK" ); 201 "X-IMAddress", "KADDRESSBOOK" );
201 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 202 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
202 "X-Anniversary", "KADDRESSBOOK" ); 203 "X-Anniversary", "KADDRESSBOOK" );
203 204
204 //US added this field to become compatible with Opie/qtopia addressbook 205 //US added this field to become compatible with Opie/qtopia addressbook
205 // values can be "female" or "male" or "". An empty field represents undefined. 206 // values can be "female" or "male" or "". An empty field represents undefined.
206 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 207 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
207 "X-Gender", "KADDRESSBOOK" ); 208 "X-Gender", "KADDRESSBOOK" );
208 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 209 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
209 "X-Children", "KADDRESSBOOK" ); 210 "X-Children", "KADDRESSBOOK" );
210 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 211 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
211 "X-FreeBusyUrl", "KADDRESSBOOK" ); 212 "X-FreeBusyUrl", "KADDRESSBOOK" );
212#endif 213#endif
213 initGUI(); 214 initGUI();
214 215
215 mIncSearchWidget->setFocus(); 216 mIncSearchWidget->setFocus();
216 217
217 218
218 connect( mViewManager, SIGNAL( selected( const QString& ) ), 219 connect( mViewManager, SIGNAL( selected( const QString& ) ),
219 SLOT( setContactSelected( const QString& ) ) ); 220 SLOT( setContactSelected( const QString& ) ) );
220 connect( mViewManager, SIGNAL( executed( const QString& ) ), 221 connect( mViewManager, SIGNAL( executed( const QString& ) ),
221 SLOT( executeContact( const QString& ) ) ); 222 SLOT( executeContact( const QString& ) ) );
222 223
223 connect( mViewManager, SIGNAL( deleteRequest( ) ), 224 connect( mViewManager, SIGNAL( deleteRequest( ) ),
224 SLOT( deleteContacts( ) ) ); 225 SLOT( deleteContacts( ) ) );
225 connect( mViewManager, SIGNAL( modified() ), 226 connect( mViewManager, SIGNAL( modified() ),
226 SLOT( setModified() ) ); 227 SLOT( setModified() ) );
227 228
228 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 229 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
229 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 230 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
230 231
231 connect( mXXPortManager, SIGNAL( modified() ), 232 connect( mXXPortManager, SIGNAL( modified() ),
232 SLOT( setModified() ) ); 233 SLOT( setModified() ) );
233 234
234 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 235 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
235 SLOT( incrementalSearch( const QString& ) ) ); 236 SLOT( incrementalSearch( const QString& ) ) );
236 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 237 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
237 mJumpButtonBar, SLOT( recreateButtons() ) ); 238 mJumpButtonBar, SLOT( recreateButtons() ) );
238 239
239 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 240 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
240 SLOT( sendMail( const QString& ) ) ); 241 SLOT( sendMail( const QString& ) ) );
241 242
242 243
243 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 244 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
244 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 245 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
245 246
246 247
247#ifndef KAB_EMBEDDED 248#ifndef KAB_EMBEDDED
248 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 249 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
249 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 250 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
250 251
251 connect( mDetails, SIGNAL( browse( const QString& ) ), 252 connect( mDetails, SIGNAL( browse( const QString& ) ),
252 SLOT( browse( const QString& ) ) ); 253 SLOT( browse( const QString& ) ) );
253 254
254 255
255 mAddressBookService = new KAddressBookService( this ); 256 mAddressBookService = new KAddressBookService( this );
256 257
257#endif //KAB_EMBEDDED 258#endif //KAB_EMBEDDED
258 mEditorDialog = 0; 259 mEditorDialog = 0;
259 createAddresseeEditorDialog( this ); 260 createAddresseeEditorDialog( this );
260 setModified( false ); 261 setModified( false );
261} 262}
262 263
263KABCore::~KABCore() 264KABCore::~KABCore()
264{ 265{
265 // save(); 266 // save();
266 //saveSettings(); 267 //saveSettings();
267 //KABPrefs::instance()->writeConfig(); 268 //KABPrefs::instance()->writeConfig();
268 delete AddresseeConfig::instance(); 269 delete AddresseeConfig::instance();
269 mAddressBook = 0; 270 mAddressBook = 0;
270 KABC::StdAddressBook::close(); 271 KABC::StdAddressBook::close();
271} 272}
272 273
273void KABCore::restoreSettings() 274void KABCore::restoreSettings()
274{ 275{
275 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 276 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
276 277
277 bool state; 278 bool state;
278 279
279 if (mMultipleViewsAtOnce) 280 if (mMultipleViewsAtOnce)
280 state = KABPrefs::instance()->mDetailsPageVisible; 281 state = KABPrefs::instance()->mDetailsPageVisible;
281 else 282 else
282 state = false; 283 state = false;
283 284
284 mActionDetails->setChecked( state ); 285 mActionDetails->setChecked( state );
285 setDetailsVisible( state ); 286 setDetailsVisible( state );
286 287
287 state = KABPrefs::instance()->mJumpButtonBarVisible; 288 state = KABPrefs::instance()->mJumpButtonBarVisible;
288 289
289 mActionJumpBar->setChecked( state ); 290 mActionJumpBar->setChecked( state );
290 setJumpButtonBarVisible( state ); 291 setJumpButtonBarVisible( state );
291/*US 292/*US
292 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 293 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
293 if ( splitterSize.count() == 0 ) { 294 if ( splitterSize.count() == 0 ) {
294 splitterSize.append( width() / 2 ); 295 splitterSize.append( width() / 2 );
295 splitterSize.append( width() / 2 ); 296 splitterSize.append( width() / 2 );
296 } 297 }
297 mMiniSplitter->setSizes( splitterSize ); 298 mMiniSplitter->setSizes( splitterSize );
298 if ( mExtensionBarSplitter ) { 299 if ( mExtensionBarSplitter ) {
299 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 300 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
300 if ( splitterSize.count() == 0 ) { 301 if ( splitterSize.count() == 0 ) {
301 splitterSize.append( width() / 2 ); 302 splitterSize.append( width() / 2 );
302 splitterSize.append( width() / 2 ); 303 splitterSize.append( width() / 2 );
303 } 304 }
304 mExtensionBarSplitter->setSizes( splitterSize ); 305 mExtensionBarSplitter->setSizes( splitterSize );
305 306
306 } 307 }
307*/ 308*/
308 mViewManager->restoreSettings(); 309 mViewManager->restoreSettings();
309 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 310 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
310 mExtensionManager->restoreSettings(); 311 mExtensionManager->restoreSettings();
311#ifdef DESKTOP_VERSION 312#ifdef DESKTOP_VERSION
312 int wid = width(); 313 int wid = width();
313 if ( wid < 10 ) 314 if ( wid < 10 )
314 wid = 400; 315 wid = 400;
315#else 316#else
316 int wid = QApplication::desktop()->width(); 317 int wid = QApplication::desktop()->width();
317 if ( wid < 640 ) 318 if ( wid < 640 )
318 wid = QApplication::desktop()->height(); 319 wid = QApplication::desktop()->height();
319#endif 320#endif
320 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 321 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
321 if ( true /*splitterSize.count() == 0*/ ) { 322 if ( true /*splitterSize.count() == 0*/ ) {
322 splitterSize.append( wid / 2 ); 323 splitterSize.append( wid / 2 );
323 splitterSize.append( wid / 2 ); 324 splitterSize.append( wid / 2 );
324 } 325 }
325 mMiniSplitter->setSizes( splitterSize ); 326 mMiniSplitter->setSizes( splitterSize );
326 if ( mExtensionBarSplitter ) { 327 if ( mExtensionBarSplitter ) {
327 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 328 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
328 if ( true /*splitterSize.count() == 0*/ ) { 329 if ( true /*splitterSize.count() == 0*/ ) {
329 splitterSize.append( wid / 2 ); 330 splitterSize.append( wid / 2 );
330 splitterSize.append( wid / 2 ); 331 splitterSize.append( wid / 2 );
331 } 332 }
332 mExtensionBarSplitter->setSizes( splitterSize ); 333 mExtensionBarSplitter->setSizes( splitterSize );
333 334
334 } 335 }
335 336
336 337
337} 338}
338 339
339void KABCore::saveSettings() 340void KABCore::saveSettings()
340{ 341{
341 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 342 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
342 if ( mExtensionBarSplitter ) 343 if ( mExtensionBarSplitter )
343 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 344 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
344 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 345 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
345 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 346 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
346#ifndef KAB_EMBEDDED 347#ifndef KAB_EMBEDDED
347 348
348 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 349 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
349 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 350 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
350#endif //KAB_EMBEDDED 351#endif //KAB_EMBEDDED
351 mExtensionManager->saveSettings(); 352 mExtensionManager->saveSettings();
352 mViewManager->saveSettings(); 353 mViewManager->saveSettings();
353 354
354 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 355 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
355} 356}
356 357
357KABC::AddressBook *KABCore::addressBook() const 358KABC::AddressBook *KABCore::addressBook() const
358{ 359{
359 return mAddressBook; 360 return mAddressBook;
360} 361}
361 362
362KConfig *KABCore::config() 363KConfig *KABCore::config()
363{ 364{
364#ifndef KAB_EMBEDDED 365#ifndef KAB_EMBEDDED
365 return KABPrefs::instance()->config(); 366 return KABPrefs::instance()->config();
366#else //KAB_EMBEDDED 367#else //KAB_EMBEDDED
367 return KABPrefs::instance()->getConfig(); 368 return KABPrefs::instance()->getConfig();
368#endif //KAB_EMBEDDED 369#endif //KAB_EMBEDDED
369} 370}
370 371
371KActionCollection *KABCore::actionCollection() const 372KActionCollection *KABCore::actionCollection() const
372{ 373{
373 return mGUIClient->actionCollection(); 374 return mGUIClient->actionCollection();
374} 375}
375 376
376KABC::Field *KABCore::currentSearchField() const 377KABC::Field *KABCore::currentSearchField() const
377{ 378{
378 if (mIncSearchWidget) 379 if (mIncSearchWidget)
379 return mIncSearchWidget->currentField(); 380 return mIncSearchWidget->currentField();
380 else 381 else
381 return 0; 382 return 0;
382} 383}
383 384
384QStringList KABCore::selectedUIDs() const 385QStringList KABCore::selectedUIDs() const
385{ 386{
386 return mViewManager->selectedUids(); 387 return mViewManager->selectedUids();
387} 388}
388 389
389KABC::Resource *KABCore::requestResource( QWidget *parent ) 390KABC::Resource *KABCore::requestResource( QWidget *parent )
390{ 391{
391 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 392 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
392 393
393 QPtrList<KRES::Resource> kresResources; 394 QPtrList<KRES::Resource> kresResources;
394 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 395 QPtrListIterator<KABC::Resource> resIt( kabcResources );
395 KABC::Resource *resource; 396 KABC::Resource *resource;
396 while ( ( resource = resIt.current() ) != 0 ) { 397 while ( ( resource = resIt.current() ) != 0 ) {
397 ++resIt; 398 ++resIt;
398 if ( !resource->readOnly() ) { 399 if ( !resource->readOnly() ) {
399 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 400 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
400 if ( res ) 401 if ( res )
401 kresResources.append( res ); 402 kresResources.append( res );
402 } 403 }
403 } 404 }
404 405
405 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 406 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
406 return static_cast<KABC::Resource*>( res ); 407 return static_cast<KABC::Resource*>( res );
407} 408}
408 409
409#ifndef KAB_EMBEDDED 410#ifndef KAB_EMBEDDED
410KAboutData *KABCore::createAboutData() 411KAboutData *KABCore::createAboutData()
411#else //KAB_EMBEDDED 412#else //KAB_EMBEDDED
412void KABCore::createAboutData() 413void KABCore::createAboutData()
413#endif //KAB_EMBEDDED 414#endif //KAB_EMBEDDED
414{ 415{
415#ifndef KAB_EMBEDDED 416#ifndef KAB_EMBEDDED
416 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 417 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
417 "3.1", I18N_NOOP( "The KDE Address Book" ), 418 "3.1", I18N_NOOP( "The KDE Address Book" ),
418 KAboutData::License_GPL_V2, 419 KAboutData::License_GPL_V2,
419 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 420 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
420 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 421 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
421 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 422 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
422 about->addAuthor( "Cornelius Schumacher", 423 about->addAuthor( "Cornelius Schumacher",
423 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 424 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
424 "schumacher@kde.org" ); 425 "schumacher@kde.org" );
425 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 426 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
426 "mpilone@slac.com" ); 427 "mpilone@slac.com" );
427 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 428 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
428 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 429 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
429 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 430 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
430 "michel@klaralvdalens-datakonsult.se" ); 431 "michel@klaralvdalens-datakonsult.se" );
431 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 432 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
432 "hansen@kde.org" ); 433 "hansen@kde.org" );
433 434
434 return about; 435 return about;
435#endif //KAB_EMBEDDED 436#endif //KAB_EMBEDDED
436 437
437 QString version; 438 QString version;
438#include <../version> 439#include <../version>
439 QMessageBox::about( this, "About KAddressbook/Pi", 440 QMessageBox::about( this, "About KAddressbook/Pi",
440 "KAddressbook/Platform-independent\n" 441 "KAddressbook/Platform-independent\n"
441 "(KA/Pi) " +version + " - " + 442 "(KA/Pi) " +version + " - " +
442#ifdef DESKTOP_VERSION 443#ifdef DESKTOP_VERSION
443 "Desktop Edition\n" 444 "Desktop Edition\n"
444#else 445#else
445 "PDA-Edition\n" 446 "PDA-Edition\n"
446 "for: Zaurus 5500 / 7x0 / 8x0\n" 447 "for: Zaurus 5500 / 7x0 / 8x0\n"
447#endif 448#endif
448 449
449 "(c) 2004 Ulf Schenk\n" 450 "(c) 2004 Ulf Schenk\n"
450 "(c) 2004 Lutz Rogowski\n" 451 "(c) 2004 Lutz Rogowski\n"
451 "(c) 1997-2003, The KDE PIM Team\n" 452 "(c) 1997-2003, The KDE PIM Team\n"
452 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 453 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
453 "Don Sanders Original author\n" 454 "Don Sanders Original author\n"
454 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 455 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
455 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 456 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
456 "Greg Stern DCOP interface\n" 457 "Greg Stern DCOP interface\n"
457 "Mark Westcot Contact pinning\n" 458 "Mark Westcot Contact pinning\n"
458 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 459 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
459 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 460 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
460#ifdef _WIN32_ 461#ifdef _WIN32_
461 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 462 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
462#endif 463#endif
463 ); 464 );
464} 465}
465 466
466void KABCore::setContactSelected( const QString &uid ) 467void KABCore::setContactSelected( const QString &uid )
467{ 468{
468 KABC::Addressee addr = mAddressBook->findByUid( uid ); 469 KABC::Addressee addr = mAddressBook->findByUid( uid );
469 if ( !mDetails->isHidden() ) 470 if ( !mDetails->isHidden() )
470 mDetails->setAddressee( addr ); 471 mDetails->setAddressee( addr );
471 472
472 if ( !addr.isEmpty() ) { 473 if ( !addr.isEmpty() ) {
473 emit contactSelected( addr.formattedName() ); 474 emit contactSelected( addr.formattedName() );
474 KABC::Picture pic = addr.photo(); 475 KABC::Picture pic = addr.photo();
475 if ( pic.isIntern() ) { 476 if ( pic.isIntern() ) {
476//US emit contactSelected( pic.data() ); 477//US emit contactSelected( pic.data() );
477//US instead use: 478//US instead use:
478 QPixmap px; 479 QPixmap px;
479 if (pic.data().isNull() != true) 480 if (pic.data().isNull() != true)
480 { 481 {
481 px.convertFromImage(pic.data()); 482 px.convertFromImage(pic.data());
482 } 483 }
483 484
484 emit contactSelected( px ); 485 emit contactSelected( px );
485 } 486 }
486 } 487 }
487 488
488 489
489 mExtensionManager->setSelectionChanged(); 490 mExtensionManager->setSelectionChanged();
490 491
491 // update the actions 492 // update the actions
492 bool selected = !uid.isEmpty(); 493 bool selected = !uid.isEmpty();
493 494
494 if ( mReadWrite ) { 495 if ( mReadWrite ) {
495 mActionCut->setEnabled( selected ); 496 mActionCut->setEnabled( selected );
496 mActionPaste->setEnabled( selected ); 497 mActionPaste->setEnabled( selected );
497 } 498 }
498 499
499 mActionCopy->setEnabled( selected ); 500 mActionCopy->setEnabled( selected );
500 mActionDelete->setEnabled( selected ); 501 mActionDelete->setEnabled( selected );
501 mActionEditAddressee->setEnabled( selected ); 502 mActionEditAddressee->setEnabled( selected );
502 mActionMail->setEnabled( selected ); 503 mActionMail->setEnabled( selected );
503 mActionMailVCard->setEnabled( selected ); 504 mActionMailVCard->setEnabled( selected );
504 //if (mActionBeam) 505 //if (mActionBeam)
505 //mActionBeam->setEnabled( selected ); 506 //mActionBeam->setEnabled( selected );
506 507
507 if (mActionBeamVCard) 508 if (mActionBeamVCard)
508 mActionBeamVCard->setEnabled( selected ); 509 mActionBeamVCard->setEnabled( selected );
509 510
510 mActionWhoAmI->setEnabled( selected ); 511 mActionWhoAmI->setEnabled( selected );
511 mActionCategories->setEnabled( selected ); 512 mActionCategories->setEnabled( selected );
512} 513}
513 514
514void KABCore::sendMail() 515void KABCore::sendMail()
515{ 516{
516 sendMail( mViewManager->selectedEmails().join( ", " ) ); 517 sendMail( mViewManager->selectedEmails().join( ", " ) );
517} 518}
518 519
519void KABCore::sendMail( const QString& emaillist ) 520void KABCore::sendMail( const QString& emaillist )
520{ 521{
521 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 522 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
522 if (emaillist.contains(",") > 0) 523 if (emaillist.contains(",") > 0)
523 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 524 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
524 else 525 else
525 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 526 ExternalAppHandler::instance()->mailToOneContact( emaillist );
526} 527}
527 528
528 529
529 530
530void KABCore::mailVCard() 531void KABCore::mailVCard()
531{ 532{
532 QStringList uids = mViewManager->selectedUids(); 533 QStringList uids = mViewManager->selectedUids();
533 if ( !uids.isEmpty() ) 534 if ( !uids.isEmpty() )
534 mailVCard( uids ); 535 mailVCard( uids );
535} 536}
536 537
537void KABCore::mailVCard( const QStringList& uids ) 538void KABCore::mailVCard( const QStringList& uids )
538{ 539{
539 QStringList urls; 540 QStringList urls;
540 541
541// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 542// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
542 543
543 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 544 QString dirName = "/tmp/" + KApplication::randomString( 8 );
544 545
545 546
546 547
547 QDir().mkdir( dirName, true ); 548 QDir().mkdir( dirName, true );
548 549
549 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 550 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
550 KABC::Addressee a = mAddressBook->findByUid( *it ); 551 KABC::Addressee a = mAddressBook->findByUid( *it );
551 552
552 if ( a.isEmpty() ) 553 if ( a.isEmpty() )
553 continue; 554 continue;
554 555
555 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 556 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
556 557
557 QString fileName = dirName + "/" + name; 558 QString fileName = dirName + "/" + name;
558 559
559 QFile outFile(fileName); 560 QFile outFile(fileName);
560 561
561 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 562 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
562 KABC::VCardConverter converter; 563 KABC::VCardConverter converter;
563 QString vcard; 564 QString vcard;
564 565
565 converter.addresseeToVCard( a, vcard ); 566 converter.addresseeToVCard( a, vcard );
566 567
567 QTextStream t( &outFile ); // use a text stream 568 QTextStream t( &outFile ); // use a text stream
568 t.setEncoding( QTextStream::UnicodeUTF8 ); 569 t.setEncoding( QTextStream::UnicodeUTF8 );
569 t << vcard; 570 t << vcard;
570 571
571 outFile.close(); 572 outFile.close();
572 573
573 urls.append( fileName ); 574 urls.append( fileName );
574 } 575 }
575 } 576 }
576 577
577 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 578 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
578 579
579 580
580/*US 581/*US
581 kapp->invokeMailer( QString::null, QString::null, QString::null, 582 kapp->invokeMailer( QString::null, QString::null, QString::null,
582 QString::null, // subject 583 QString::null, // subject
583 QString::null, // body 584 QString::null, // body
584 QString::null, 585 QString::null,
585 urls ); // attachments 586 urls ); // attachments
586*/ 587*/
587 588
588} 589}
589 590
590/** 591/**
591 Beams the "WhoAmI contact. 592 Beams the "WhoAmI contact.
592*/ 593*/
593void KABCore::beamMySelf() 594void KABCore::beamMySelf()
594{ 595{
595 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 596 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
596 if (!a.isEmpty()) 597 if (!a.isEmpty())
597 { 598 {
598 QStringList uids; 599 QStringList uids;
599 uids << a.uid(); 600 uids << a.uid();
600 601
601 beamVCard(uids); 602 beamVCard(uids);
602 } else { 603 } else {
603 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 604 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
604 605
605 606
606 } 607 }
607} 608}
608 609
609void KABCore::beamVCard() 610void KABCore::beamVCard()
610{ 611{
611 QStringList uids = mViewManager->selectedUids(); 612 QStringList uids = mViewManager->selectedUids();
612 if ( !uids.isEmpty() ) 613 if ( !uids.isEmpty() )
613 beamVCard( uids ); 614 beamVCard( uids );
614} 615}
615 616
616 617
617void KABCore::beamVCard(const QStringList& uids) 618void KABCore::beamVCard(const QStringList& uids)
618{ 619{
619/*US 620/*US
620 QString beamFilename; 621 QString beamFilename;
621 Opie::OPimContact c; 622 Opie::OPimContact c;
622 if ( actionPersonal->isOn() ) { 623 if ( actionPersonal->isOn() ) {
623 beamFilename = addressbookPersonalVCardName(); 624 beamFilename = addressbookPersonalVCardName();
624 if ( !QFile::exists( beamFilename ) ) 625 if ( !QFile::exists( beamFilename ) )
625 return; // can't beam a non-existent file 626 return; // can't beam a non-existent file
626 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 627 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
627 beamFilename ); 628 beamFilename );
628 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 629 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
629 Opie::OPimContactAccess::List allList = access->allRecords(); 630 Opie::OPimContactAccess::List allList = access->allRecords();
630 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first 631 Opie::OPimContactAccess::List::Iterator it = allList.begin(); // Just take first
631 c = *it; 632 c = *it;
632 633
633 delete access; 634 delete access;
634 } else { 635 } else {
635 unlink( beamfile ); // delete if exists 636 unlink( beamfile ); // delete if exists
636 mkdir("/tmp/obex/", 0755); 637 mkdir("/tmp/obex/", 0755);
637 c = m_abView -> currentEntry(); 638 c = m_abView -> currentEntry();
638 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null, 639 Opie::OPimContactAccessBackend* vcard_backend = new Opie::OPimContactAccessBackend_VCard( QString::null,
639 beamfile ); 640 beamfile );
640 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true ); 641 Opie::OPimContactAccess* access = new Opie::OPimContactAccess ( "addressbook", QString::null , vcard_backend, true );
641 access->add( c ); 642 access->add( c );
642 access->save(); 643 access->save();
643 delete access; 644 delete access;
644 645
645 beamFilename = beamfile; 646 beamFilename = beamfile;
646 } 647 }
647 648
648 owarn << "Beaming: " << beamFilename << oendl; 649 owarn << "Beaming: " << beamFilename << oendl;
649*/ 650*/
650 651
651#if 0 652#if 0
652 QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 653 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
653 654
654 QString dirName = tmpdir + "/" + KApplication::randomString( 8 ); 655 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
655 656
656 QString name = "contact.vcf"; 657 QString name = "contact.vcf";
657 658
658 QString fileName = dirName + "/" + name; 659 QString fileName = dirName + "/" + name;
659#endif 660#endif
660 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory 661 // LR: we should use the /tmp dir, because: /tmp = RAM, (HOME)/kdepim = flash memory
661 // 662 //
662 QString fileName = "/tmp/kapibeamfile.vcf"; 663 QString fileName = "/tmp/kapibeamfile.vcf";
663 664
664 665
665 //QDir().mkdir( dirName, true ); 666 //QDir().mkdir( dirName, true );
666 667
667 668
668 KABC::VCardConverter converter; 669 KABC::VCardConverter converter;
669 QString description; 670 QString description;
670 QString datastream; 671 QString datastream;
671 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 672 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
672 KABC::Addressee a = mAddressBook->findByUid( *it ); 673 KABC::Addressee a = mAddressBook->findByUid( *it );
673 674
674 if ( a.isEmpty() ) 675 if ( a.isEmpty() )
675 continue; 676 continue;
676 677
677 if (description.isEmpty()) 678 if (description.isEmpty())
678 description = a.formattedName(); 679 description = a.formattedName();
679 680
680 QString vcard; 681 QString vcard;
681 converter.addresseeToVCard( a, vcard ); 682 converter.addresseeToVCard( a, vcard );
682 int start = 0; 683 int start = 0;
683 int next; 684 int next;
684 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 685 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
685 int semi = vcard.find(";", next); 686 int semi = vcard.find(";", next);
686 int dopp = vcard.find(":", next); 687 int dopp = vcard.find(":", next);
687 int sep; 688 int sep;
688 if ( semi < dopp && semi >= 0 ) 689 if ( semi < dopp && semi >= 0 )
689 sep = semi ; 690 sep = semi ;
690 else 691 else
691 sep = dopp; 692 sep = dopp;
692 datastream +=vcard.mid( start, next - start); 693 datastream +=vcard.mid( start, next - start);
693 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 694 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
694 start = sep; 695 start = sep;
695 } 696 }
696 datastream += vcard.mid( start,vcard.length() ); 697 datastream += vcard.mid( start,vcard.length() );
697 } 698 }
698#ifndef DESKTOP_VERSION 699#ifndef DESKTOP_VERSION
699 QFile outFile(fileName); 700 QFile outFile(fileName);
700 if ( outFile.open(IO_WriteOnly) ) { 701 if ( outFile.open(IO_WriteOnly) ) {
701 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 702 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
702 QTextStream t( &outFile ); // use a text stream 703 QTextStream t( &outFile ); // use a text stream
703 t.setEncoding( QTextStream::UnicodeUTF8 ); 704 t.setEncoding( QTextStream::UnicodeUTF8 );
704 t <<datastream; 705 t <<datastream;
705 outFile.close(); 706 outFile.close();
706 Ir *ir = new Ir( this ); 707 Ir *ir = new Ir( this );
707 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 708 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
708 ir->send( fileName, description, "text/x-vCard" ); 709 ir->send( fileName, description, "text/x-vCard" );
709 } else { 710 } else {
710 qDebug("Error open temp beam file "); 711 qDebug("Error open temp beam file ");
711 return; 712 return;
712 } 713 }
713#endif 714#endif
714 715
715} 716}
716 717
717void KABCore::beamDone( Ir *ir ) 718void KABCore::beamDone( Ir *ir )
718{ 719{
719#ifndef DESKTOP_VERSION 720#ifndef DESKTOP_VERSION
720 delete ir; 721 delete ir;
721#endif 722#endif
722} 723}
723 724
724 725
725void KABCore::browse( const QString& url ) 726void KABCore::browse( const QString& url )
726{ 727{
727#ifndef KAB_EMBEDDED 728#ifndef KAB_EMBEDDED
728 kapp->invokeBrowser( url ); 729 kapp->invokeBrowser( url );
729#else //KAB_EMBEDDED 730#else //KAB_EMBEDDED
730 qDebug("KABCore::browse must be fixed"); 731 qDebug("KABCore::browse must be fixed");
731#endif //KAB_EMBEDDED 732#endif //KAB_EMBEDDED
732} 733}
733 734
734void KABCore::selectAllContacts() 735void KABCore::selectAllContacts()
735{ 736{
736 mViewManager->setSelected( QString::null, true ); 737 mViewManager->setSelected( QString::null, true );
737} 738}
738 739
739void KABCore::deleteContacts() 740void KABCore::deleteContacts()
740{ 741{
741 QStringList uidList = mViewManager->selectedUids(); 742 QStringList uidList = mViewManager->selectedUids();
742 deleteContacts( uidList ); 743 deleteContacts( uidList );
743} 744}
744 745
745void KABCore::deleteContacts( const QStringList &uids ) 746void KABCore::deleteContacts( const QStringList &uids )
746{ 747{
747 if ( uids.count() > 0 ) { 748 if ( uids.count() > 0 ) {
748 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 749 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
749 UndoStack::instance()->push( command ); 750 UndoStack::instance()->push( command );
750 RedoStack::instance()->clear(); 751 RedoStack::instance()->clear();
751 752
752 // now if we deleted anything, refresh 753 // now if we deleted anything, refresh
753 setContactSelected( QString::null ); 754 setContactSelected( QString::null );
754 setModified( true ); 755 setModified( true );
755 } 756 }
756} 757}
757 758
758void KABCore::copyContacts() 759void KABCore::copyContacts()
759{ 760{
760 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 761 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
761 762
762 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 763 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
763 764
764 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 765 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
765 766
766 QClipboard *cb = QApplication::clipboard(); 767 QClipboard *cb = QApplication::clipboard();
767 cb->setText( clipText ); 768 cb->setText( clipText );
768} 769}
769 770
770void KABCore::cutContacts() 771void KABCore::cutContacts()
771{ 772{
772 QStringList uidList = mViewManager->selectedUids(); 773 QStringList uidList = mViewManager->selectedUids();
773 774
774//US if ( uidList.size() > 0 ) { 775//US if ( uidList.size() > 0 ) {
775 if ( uidList.count() > 0 ) { 776 if ( uidList.count() > 0 ) {
776 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 777 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
777 UndoStack::instance()->push( command ); 778 UndoStack::instance()->push( command );
778 RedoStack::instance()->clear(); 779 RedoStack::instance()->clear();
779 780
780 setModified( true ); 781 setModified( true );
781 } 782 }
782} 783}
783 784
784void KABCore::pasteContacts() 785void KABCore::pasteContacts()
785{ 786{
786 QClipboard *cb = QApplication::clipboard(); 787 QClipboard *cb = QApplication::clipboard();
787 788
788 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 789 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
789 790
790 pasteContacts( list ); 791 pasteContacts( list );
791} 792}
792 793
793void KABCore::pasteContacts( KABC::Addressee::List &list ) 794void KABCore::pasteContacts( KABC::Addressee::List &list )
794{ 795{
795 KABC::Resource *resource = requestResource( this ); 796 KABC::Resource *resource = requestResource( this );
796 KABC::Addressee::List::Iterator it; 797 KABC::Addressee::List::Iterator it;
797 for ( it = list.begin(); it != list.end(); ++it ) 798 for ( it = list.begin(); it != list.end(); ++it )
798 (*it).setResource( resource ); 799 (*it).setResource( resource );
799 800
800 PwPasteCommand *command = new PwPasteCommand( this, list ); 801 PwPasteCommand *command = new PwPasteCommand( this, list );
801 UndoStack::instance()->push( command ); 802 UndoStack::instance()->push( command );
802 RedoStack::instance()->clear(); 803 RedoStack::instance()->clear();
803 804
804 setModified( true ); 805 setModified( true );
805} 806}
806 807
807void KABCore::setWhoAmI() 808void KABCore::setWhoAmI()
808{ 809{
809 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 810 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
810 811
811 if ( addrList.count() > 1 ) { 812 if ( addrList.count() > 1 ) {
812 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 813 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
813 return; 814 return;
814 } 815 }
815 816
816 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 817 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
817 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 818 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
818 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 819 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
819} 820}
820 821
821void KABCore::setCategories() 822void KABCore::setCategories()
822{ 823{
823 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 824 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
824 if ( !dlg.exec() ) 825 if ( !dlg.exec() )
825 return; 826 return;
826 827
827 bool merge = false; 828 bool merge = false;
828 QString msg = i18n( "Merge with existing categories?" ); 829 QString msg = i18n( "Merge with existing categories?" );
829 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 830 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
830 merge = true; 831 merge = true;
831 832
832 QStringList categories = dlg.selectedCategories(); 833 QStringList categories = dlg.selectedCategories();
833 834
834 QStringList uids = mViewManager->selectedUids(); 835 QStringList uids = mViewManager->selectedUids();
835 QStringList::Iterator it; 836 QStringList::Iterator it;
836 for ( it = uids.begin(); it != uids.end(); ++it ) { 837 for ( it = uids.begin(); it != uids.end(); ++it ) {
837 KABC::Addressee addr = mAddressBook->findByUid( *it ); 838 KABC::Addressee addr = mAddressBook->findByUid( *it );
838 if ( !addr.isEmpty() ) { 839 if ( !addr.isEmpty() ) {
839 if ( !merge ) 840 if ( !merge )
840 addr.setCategories( categories ); 841 addr.setCategories( categories );
841 else { 842 else {
842 QStringList addrCategories = addr.categories(); 843 QStringList addrCategories = addr.categories();
843 QStringList::Iterator catIt; 844 QStringList::Iterator catIt;
844 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 845 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
845 if ( !addrCategories.contains( *catIt ) ) 846 if ( !addrCategories.contains( *catIt ) )
846 addrCategories.append( *catIt ); 847 addrCategories.append( *catIt );
847 } 848 }
848 addr.setCategories( addrCategories ); 849 addr.setCategories( addrCategories );
849 } 850 }
850 851
851 mAddressBook->insertAddressee( addr ); 852 mAddressBook->insertAddressee( addr );
852 } 853 }
853 } 854 }
854 855
855 if ( uids.count() > 0 ) 856 if ( uids.count() > 0 )
856 setModified( true ); 857 setModified( true );
857} 858}
858 859
859void KABCore::setSearchFields( const KABC::Field::List &fields ) 860void KABCore::setSearchFields( const KABC::Field::List &fields )
860{ 861{
861 mIncSearchWidget->setFields( fields ); 862 mIncSearchWidget->setFields( fields );
862} 863}
863 864
864void KABCore::incrementalSearch( const QString& text ) 865void KABCore::incrementalSearch( const QString& text )
865{ 866{
866 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 867 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
867} 868}
868 869
869void KABCore::setModified() 870void KABCore::setModified()
870{ 871{
871 setModified( true ); 872 setModified( true );
872} 873}
873 874
874void KABCore::setModifiedWOrefresh() 875void KABCore::setModifiedWOrefresh()
875{ 876{
876 // qDebug("KABCore::setModifiedWOrefresh() "); 877 // qDebug("KABCore::setModifiedWOrefresh() ");
877 mModified = true; 878 mModified = true;
878 mActionSave->setEnabled( mModified ); 879 mActionSave->setEnabled( mModified );
879#ifdef DESKTOP_VERSION 880#ifdef DESKTOP_VERSION
880 mDetails->refreshView(); 881 mDetails->refreshView();
881#endif 882#endif
882 883
883} 884}
884void KABCore::setModified( bool modified ) 885void KABCore::setModified( bool modified )
885{ 886{
886 mModified = modified; 887 mModified = modified;
887 mActionSave->setEnabled( mModified ); 888 mActionSave->setEnabled( mModified );
888 889
889 if ( modified ) 890 if ( modified )
890 mJumpButtonBar->recreateButtons(); 891 mJumpButtonBar->recreateButtons();
891 892
892 mViewManager->refreshView(); 893 mViewManager->refreshView();
893 mDetails->refreshView(); 894 mDetails->refreshView();
894 895
895} 896}
896 897
897bool KABCore::modified() const 898bool KABCore::modified() const
898{ 899{
899 return mModified; 900 return mModified;
900} 901}
901 902
902void KABCore::contactModified( const KABC::Addressee &addr ) 903void KABCore::contactModified( const KABC::Addressee &addr )
903{ 904{
904 905
905 Command *command = 0; 906 Command *command = 0;
906 QString uid; 907 QString uid;
907 908
908 // check if it exists already 909 // check if it exists already
909 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 910 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
910 if ( origAddr.isEmpty() ) 911 if ( origAddr.isEmpty() )
911 command = new PwNewCommand( mAddressBook, addr ); 912 command = new PwNewCommand( mAddressBook, addr );
912 else { 913 else {
913 command = new PwEditCommand( mAddressBook, origAddr, addr ); 914 command = new PwEditCommand( mAddressBook, origAddr, addr );
914 uid = addr.uid(); 915 uid = addr.uid();
915 } 916 }
916 917
917 UndoStack::instance()->push( command ); 918 UndoStack::instance()->push( command );
918 RedoStack::instance()->clear(); 919 RedoStack::instance()->clear();
919 920
920 setModified( true ); 921 setModified( true );
921} 922}
922 923
923void KABCore::newContact() 924void KABCore::newContact()
924{ 925{
925 926
926 927
927 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 928 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
928 929
929 QPtrList<KRES::Resource> kresResources; 930 QPtrList<KRES::Resource> kresResources;
930 QPtrListIterator<KABC::Resource> it( kabcResources ); 931 QPtrListIterator<KABC::Resource> it( kabcResources );
931 KABC::Resource *resource; 932 KABC::Resource *resource;
932 while ( ( resource = it.current() ) != 0 ) { 933 while ( ( resource = it.current() ) != 0 ) {
933 ++it; 934 ++it;
934 if ( !resource->readOnly() ) { 935 if ( !resource->readOnly() ) {
935 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 936 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
936 if ( res ) 937 if ( res )
937 kresResources.append( res ); 938 kresResources.append( res );
938 } 939 }
939 } 940 }
940 941
941 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 942 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
942 resource = static_cast<KABC::Resource*>( res ); 943 resource = static_cast<KABC::Resource*>( res );
943 944
944 if ( resource ) { 945 if ( resource ) {
945 KABC::Addressee addr; 946 KABC::Addressee addr;
946 addr.setResource( resource ); 947 addr.setResource( resource );
947 mEditorDialog->setAddressee( addr ); 948 mEditorDialog->setAddressee( addr );
948 KApplication::execDialog ( mEditorDialog ); 949 KApplication::execDialog ( mEditorDialog );
949 950
950 } else 951 } else
951 return; 952 return;
952 953
953 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 954 // mEditorDict.insert( dialog->addressee().uid(), dialog );
954 955
955 956
956} 957}
957 958
958void KABCore::addEmail( QString aStr ) 959void KABCore::addEmail( QString aStr )
959{ 960{
960#ifndef KAB_EMBEDDED 961#ifndef KAB_EMBEDDED
961 QString fullName, email; 962 QString fullName, email;
962 963
963 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 964 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
964 965
965 // Try to lookup the addressee matching the email address 966 // Try to lookup the addressee matching the email address
966 bool found = false; 967 bool found = false;
967 QStringList emailList; 968 QStringList emailList;
968 KABC::AddressBook::Iterator it; 969 KABC::AddressBook::Iterator it;
969 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 970 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
970 emailList = (*it).emails(); 971 emailList = (*it).emails();
971 if ( emailList.contains( email ) > 0 ) { 972 if ( emailList.contains( email ) > 0 ) {
972 found = true; 973 found = true;
973 (*it).setNameFromString( fullName ); 974 (*it).setNameFromString( fullName );
974 editContact( (*it).uid() ); 975 editContact( (*it).uid() );
975 } 976 }
976 } 977 }
977 978
978 if ( !found ) { 979 if ( !found ) {
979 KABC::Addressee addr; 980 KABC::Addressee addr;
980 addr.setNameFromString( fullName ); 981 addr.setNameFromString( fullName );
981 addr.insertEmail( email, true ); 982 addr.insertEmail( email, true );
982 983
983 mAddressBook->insertAddressee( addr ); 984 mAddressBook->insertAddressee( addr );
984 mViewManager->refreshView( addr.uid() ); 985 mViewManager->refreshView( addr.uid() );
985 editContact( addr.uid() ); 986 editContact( addr.uid() );
986 } 987 }
987#else //KAB_EMBEDDED 988#else //KAB_EMBEDDED
988 qDebug("KABCore::addEmail finsih method"); 989 qDebug("KABCore::addEmail finsih method");
989#endif //KAB_EMBEDDED 990#endif //KAB_EMBEDDED
990} 991}
991 992
992void KABCore::importVCard( const KURL &url, bool showPreview ) 993void KABCore::importVCard( const KURL &url, bool showPreview )
993{ 994{
994 mXXPortManager->importVCard( url, showPreview ); 995 mXXPortManager->importVCard( url, showPreview );
995} 996}
996void KABCore::importFromOL() 997void KABCore::importFromOL()
997{ 998{
998#ifdef _WIN32_ 999#ifdef _WIN32_
999 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1000 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1000 idgl->exec(); 1001 idgl->exec();
1001 KABC::Addressee::List list = idgl->getAddressList(); 1002 KABC::Addressee::List list = idgl->getAddressList();
1002 if ( list.count() > 0 ) { 1003 if ( list.count() > 0 ) {
1003 KABC::Addressee::List listNew; 1004 KABC::Addressee::List listNew;
1004 KABC::Addressee::List listExisting; 1005 KABC::Addressee::List listExisting;
1005 KABC::Addressee::List::Iterator it; 1006 KABC::Addressee::List::Iterator it;
1006 KABC::AddressBook::Iterator iter; 1007 KABC::AddressBook::Iterator iter;
1007 for ( it = list.begin(); it != list.end(); ++it ) { 1008 for ( it = list.begin(); it != list.end(); ++it ) {
1008 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1009 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1009 listNew.append( (*it) ); 1010 listNew.append( (*it) );
1010 else 1011 else
1011 listExisting.append( (*it) ); 1012 listExisting.append( (*it) );
1012 } 1013 }
1013 if ( listExisting.count() > 0 ) 1014 if ( listExisting.count() > 0 )
1014 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1015 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1015 if ( listNew.count() > 0 ) { 1016 if ( listNew.count() > 0 ) {
1016 pasteWithNewUid = false; 1017 pasteWithNewUid = false;
1017 pasteContacts( listNew ); 1018 pasteContacts( listNew );
1018 pasteWithNewUid = true; 1019 pasteWithNewUid = true;
1019 } 1020 }
1020 } 1021 }
1021 delete idgl; 1022 delete idgl;
1022#endif 1023#endif
1023} 1024}
1024 1025
1025void KABCore::importVCard( const QString &vCard, bool showPreview ) 1026void KABCore::importVCard( const QString &vCard, bool showPreview )
1026{ 1027{
1027 mXXPortManager->importVCard( vCard, showPreview ); 1028 mXXPortManager->importVCard( vCard, showPreview );
1028} 1029}
1029 1030
1030//US added a second method without defaultparameter 1031//US added a second method without defaultparameter
1031void KABCore::editContact2() { 1032void KABCore::editContact2() {
1032 editContact( QString::null ); 1033 editContact( QString::null );
1033} 1034}
1034 1035
1035void KABCore::editContact( const QString &uid ) 1036void KABCore::editContact( const QString &uid )
1036{ 1037{
1037 1038
1038 if ( mExtensionManager->isQuickEditVisible() ) 1039 if ( mExtensionManager->isQuickEditVisible() )
1039 return; 1040 return;
1040 1041
1041 // First, locate the contact entry 1042 // First, locate the contact entry
1042 QString localUID = uid; 1043 QString localUID = uid;
1043 if ( localUID.isNull() ) { 1044 if ( localUID.isNull() ) {
1044 QStringList uidList = mViewManager->selectedUids(); 1045 QStringList uidList = mViewManager->selectedUids();
1045 if ( uidList.count() > 0 ) 1046 if ( uidList.count() > 0 )
1046 localUID = *( uidList.at( 0 ) ); 1047 localUID = *( uidList.at( 0 ) );
1047 } 1048 }
1048 1049
1049 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1050 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1050 if ( !addr.isEmpty() ) { 1051 if ( !addr.isEmpty() ) {
1051 mEditorDialog->setAddressee( addr ); 1052 mEditorDialog->setAddressee( addr );
1052 KApplication::execDialog ( mEditorDialog ); 1053 KApplication::execDialog ( mEditorDialog );
1053 } 1054 }
1054} 1055}
1055 1056
1056/** 1057/**
1057 Shows or edits the detail view for the given uid. If the uid is QString::null, 1058 Shows or edits the detail view for the given uid. If the uid is QString::null,
1058 the method will try to find a selected addressee in the view. 1059 the method will try to find a selected addressee in the view.
1059 */ 1060 */
1060void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1061void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1061{ 1062{
1062 if ( mMultipleViewsAtOnce ) 1063 if ( mMultipleViewsAtOnce )
1063 { 1064 {
1064 editContact( uid ); 1065 editContact( uid );
1065 } 1066 }
1066 else 1067 else
1067 { 1068 {
1068 setDetailsVisible( true ); 1069 setDetailsVisible( true );
1069 mActionDetails->setChecked(true); 1070 mActionDetails->setChecked(true);
1070 } 1071 }
1071 1072
1072} 1073}
1073 1074
1074void KABCore::save() 1075void KABCore::save()
1075{ 1076{
1076 if (mBlockSaveFlag) 1077 if (mBlockSaveFlag)
1077 return; 1078 return;
1078 mBlockSaveFlag = true; 1079 mBlockSaveFlag = true;
1079 if ( !mModified ) 1080 if ( !mModified )
1080 return; 1081 return;
1081 QString text = i18n( "There was an error while attempting to save\n the " 1082 QString text = i18n( "There was an error while attempting to save\n the "
1082 "address book. Please check that some \nother application is " 1083 "address book. Please check that some \nother application is "
1083 "not using it. " ); 1084 "not using it. " );
1084 statusMessage(i18n("Saving addressbook ... ")); 1085 statusMessage(i18n("Saving addressbook ... "));
1085#ifndef KAB_EMBEDDED 1086#ifndef KAB_EMBEDDED
1086 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1087 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1087 if ( !b || !b->save() ) { 1088 if ( !b || !b->save() ) {
1088 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1089 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1089 } 1090 }
1090#else //KAB_EMBEDDED 1091#else //KAB_EMBEDDED
1091 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1092 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1092 if ( !b || !b->save() ) { 1093 if ( !b || !b->save() ) {
1093 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1094 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1094 } 1095 }
1095#endif //KAB_EMBEDDED 1096#endif //KAB_EMBEDDED
1096 1097
1097 statusMessage(i18n("Addressbook saved!")); 1098 statusMessage(i18n("Addressbook saved!"));
1098 setModified( false ); 1099 setModified( false );
1099 mBlockSaveFlag = false; 1100 mBlockSaveFlag = false;
1100} 1101}
1101 1102
1102void KABCore::statusMessage(QString mess , int time ) 1103void KABCore::statusMessage(QString mess , int time )
1103{ 1104{
1104 //topLevelWidget()->setCaption( mess ); 1105 //topLevelWidget()->setCaption( mess );
1105 // pending setting timer to revome message 1106 // pending setting timer to revome message
1106} 1107}
1107void KABCore::undo() 1108void KABCore::undo()
1108{ 1109{
1109 UndoStack::instance()->undo(); 1110 UndoStack::instance()->undo();
1110 1111
1111 // Refresh the view 1112 // Refresh the view
1112 mViewManager->refreshView(); 1113 mViewManager->refreshView();
1113} 1114}
1114 1115
1115void KABCore::redo() 1116void KABCore::redo()
1116{ 1117{
1117 RedoStack::instance()->redo(); 1118 RedoStack::instance()->redo();
1118 1119
1119 // Refresh the view 1120 // Refresh the view
1120 mViewManager->refreshView(); 1121 mViewManager->refreshView();
1121} 1122}
1122 1123
1123void KABCore::setJumpButtonBarVisible( bool visible ) 1124void KABCore::setJumpButtonBarVisible( bool visible )
1124{ 1125{
1125 if (mMultipleViewsAtOnce) 1126 if (mMultipleViewsAtOnce)
1126 { 1127 {
1127 if ( visible ) 1128 if ( visible )
1128 mJumpButtonBar->show(); 1129 mJumpButtonBar->show();
1129 else 1130 else
1130 mJumpButtonBar->hide(); 1131 mJumpButtonBar->hide();
1131 } 1132 }
1132 else 1133 else
1133 { 1134 {
1134 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1135 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1135 if (mViewManager->isVisible()) 1136 if (mViewManager->isVisible())
1136 { 1137 {
1137 if ( visible ) 1138 if ( visible )
1138 mJumpButtonBar->show(); 1139 mJumpButtonBar->show();
1139 else 1140 else
1140 mJumpButtonBar->hide(); 1141 mJumpButtonBar->hide();
1141 } 1142 }
1142 else 1143 else
1143 { 1144 {
1144 mJumpButtonBar->hide(); 1145 mJumpButtonBar->hide();
1145 } 1146 }
1146 } 1147 }
1147} 1148}
1148 1149
1149 1150
1150void KABCore::setDetailsToState() 1151void KABCore::setDetailsToState()
1151{ 1152{
1152 setDetailsVisible( mActionDetails->isChecked() ); 1153 setDetailsVisible( mActionDetails->isChecked() );
1153} 1154}
1154 1155
1155 1156
1156 1157
1157void KABCore::setDetailsVisible( bool visible ) 1158void KABCore::setDetailsVisible( bool visible )
1158{ 1159{
1159 if (visible && mDetails->isHidden()) 1160 if (visible && mDetails->isHidden())
1160 { 1161 {
1161 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1162 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1162 if ( addrList.count() > 0 ) 1163 if ( addrList.count() > 0 )
1163 mDetails->setAddressee( addrList[ 0 ] ); 1164 mDetails->setAddressee( addrList[ 0 ] );
1164 } 1165 }
1165 1166
1166 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1167 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1167 // the listview and the detailview. We do that by changing the splitbar size. 1168 // the listview and the detailview. We do that by changing the splitbar size.
1168 if (mMultipleViewsAtOnce) 1169 if (mMultipleViewsAtOnce)
1169 { 1170 {
1170 if ( visible ) 1171 if ( visible )
1171 mDetails->show(); 1172 mDetails->show();
1172 else 1173 else
1173 mDetails->hide(); 1174 mDetails->hide();
1174 } 1175 }
1175 else 1176 else
1176 { 1177 {
1177 if ( visible ) { 1178 if ( visible ) {
1178 mViewManager->hide(); 1179 mViewManager->hide();
1179 mDetails->show(); 1180 mDetails->show();
1180 } 1181 }
1181 else { 1182 else {
1182 mViewManager->show(); 1183 mViewManager->show();
1183 mDetails->hide(); 1184 mDetails->hide();
1184 } 1185 }
1185 setJumpButtonBarVisible( !visible ); 1186 setJumpButtonBarVisible( !visible );
1186 } 1187 }
1187 1188
1188} 1189}
1189 1190
1190void KABCore::extensionChanged( int id ) 1191void KABCore::extensionChanged( int id )
1191{ 1192{
1192 //change the details view only for non desktop systems 1193 //change the details view only for non desktop systems
1193#ifndef DESKTOP_VERSION 1194#ifndef DESKTOP_VERSION
1194 1195
1195 if (id == 0) 1196 if (id == 0)
1196 { 1197 {
1197 //the user disabled the extension. 1198 //the user disabled the extension.
1198 1199
1199 if (mMultipleViewsAtOnce) 1200 if (mMultipleViewsAtOnce)
1200 { // enable detailsview again 1201 { // enable detailsview again
1201 setDetailsVisible( true ); 1202 setDetailsVisible( true );
1202 mActionDetails->setChecked( true ); 1203 mActionDetails->setChecked( true );
1203 } 1204 }
1204 else 1205 else
1205 { //go back to the listview 1206 { //go back to the listview
1206 setDetailsVisible( false ); 1207 setDetailsVisible( false );
1207 mActionDetails->setChecked( false ); 1208 mActionDetails->setChecked( false );
1208 mActionDetails->setEnabled(true); 1209 mActionDetails->setEnabled(true);
1209 } 1210 }
1210 1211
1211 } 1212 }
1212 else 1213 else
1213 { 1214 {
1214 //the user enabled the extension. 1215 //the user enabled the extension.
1215 setDetailsVisible( false ); 1216 setDetailsVisible( false );
1216 mActionDetails->setChecked( false ); 1217 mActionDetails->setChecked( false );
1217 1218
1218 if (!mMultipleViewsAtOnce) 1219 if (!mMultipleViewsAtOnce)
1219 { 1220 {
1220 mActionDetails->setEnabled(false); 1221 mActionDetails->setEnabled(false);
1221 } 1222 }
1222 1223
1223 mExtensionManager->setSelectionChanged(); 1224 mExtensionManager->setSelectionChanged();
1224 1225
1225 } 1226 }
1226 1227
1227#endif// DESKTOP_VERSION 1228#endif// DESKTOP_VERSION
1228 1229
1229} 1230}
1230 1231
1231 1232
1232void KABCore::extensionModified( const KABC::Addressee::List &list ) 1233void KABCore::extensionModified( const KABC::Addressee::List &list )
1233{ 1234{
1234 1235
1235 if ( list.count() != 0 ) { 1236 if ( list.count() != 0 ) {
1236 KABC::Addressee::List::ConstIterator it; 1237 KABC::Addressee::List::ConstIterator it;
1237 for ( it = list.begin(); it != list.end(); ++it ) 1238 for ( it = list.begin(); it != list.end(); ++it )
1238 mAddressBook->insertAddressee( *it ); 1239 mAddressBook->insertAddressee( *it );
1239 if ( list.count() > 1 ) 1240 if ( list.count() > 1 )
1240 setModified(); 1241 setModified();
1241 else 1242 else
1242 setModifiedWOrefresh(); 1243 setModifiedWOrefresh();
1243 } 1244 }
1244 if ( list.count() == 0 ) 1245 if ( list.count() == 0 )
1245 mViewManager->refreshView(); 1246 mViewManager->refreshView();
1246 else 1247 else
1247 mViewManager->refreshView( list[ 0 ].uid() ); 1248 mViewManager->refreshView( list[ 0 ].uid() );
1248 1249
1249 1250
1250 1251
1251} 1252}
1252 1253
1253QString KABCore::getNameByPhone( const QString &phone ) 1254QString KABCore::getNameByPhone( const QString &phone )
1254{ 1255{
1255#ifndef KAB_EMBEDDED 1256#ifndef KAB_EMBEDDED
1256 QRegExp r( "[/*/-/ ]" ); 1257 QRegExp r( "[/*/-/ ]" );
1257 QString localPhone( phone ); 1258 QString localPhone( phone );
1258 1259
1259 bool found = false; 1260 bool found = false;
1260 QString ownerName = ""; 1261 QString ownerName = "";
1261 KABC::AddressBook::Iterator iter; 1262 KABC::AddressBook::Iterator iter;
1262 KABC::PhoneNumber::List::Iterator phoneIter; 1263 KABC::PhoneNumber::List::Iterator phoneIter;
1263 KABC::PhoneNumber::List phoneList; 1264 KABC::PhoneNumber::List phoneList;
1264 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1265 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1265 phoneList = (*iter).phoneNumbers(); 1266 phoneList = (*iter).phoneNumbers();
1266 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1267 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1267 ++phoneIter) { 1268 ++phoneIter) {
1268 // Get rid of separator chars so just the numbers are compared. 1269 // Get rid of separator chars so just the numbers are compared.
1269 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1270 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1270 ownerName = (*iter).formattedName(); 1271 ownerName = (*iter).formattedName();
1271 found = true; 1272 found = true;
1272 } 1273 }
1273 } 1274 }
1274 } 1275 }
1275 1276
1276 return ownerName; 1277 return ownerName;
1277#else //KAB_EMBEDDED 1278#else //KAB_EMBEDDED
1278 qDebug("KABCore::getNameByPhone finsih method"); 1279 qDebug("KABCore::getNameByPhone finsih method");
1279 return ""; 1280 return "";
1280#endif //KAB_EMBEDDED 1281#endif //KAB_EMBEDDED
1281 1282
1282} 1283}
1283 1284
1284void KABCore::openConfigDialog() 1285void KABCore::openConfigDialog()
1285{ 1286{
1286 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1287 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1287 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1288 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1288 ConfigureDialog->addModule(kabcfg ); 1289 ConfigureDialog->addModule(kabcfg );
1289 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1290 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1290 ConfigureDialog->addModule(kdelibcfg ); 1291 ConfigureDialog->addModule(kdelibcfg );
1291 1292
1292 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1293 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1293 this, SLOT( configurationChanged() ) ); 1294 this, SLOT( configurationChanged() ) );
1294 connect( ConfigureDialog, SIGNAL( okClicked() ), 1295 connect( ConfigureDialog, SIGNAL( okClicked() ),
1295 this, SLOT( configurationChanged() ) ); 1296 this, SLOT( configurationChanged() ) );
1296 saveSettings(); 1297 saveSettings();
1297#ifndef DESKTOP_VERSION 1298#ifndef DESKTOP_VERSION
1298 ConfigureDialog->showMaximized(); 1299 ConfigureDialog->showMaximized();
1299#endif 1300#endif
1300 if ( ConfigureDialog->exec() ) 1301 if ( ConfigureDialog->exec() )
1301 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1302 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1302 delete ConfigureDialog; 1303 delete ConfigureDialog;
1303} 1304}
1304 1305
1305void KABCore::openLDAPDialog() 1306void KABCore::openLDAPDialog()
1306{ 1307{
1307#ifndef KAB_EMBEDDED 1308#ifndef KAB_EMBEDDED
1308 if ( !mLdapSearchDialog ) { 1309 if ( !mLdapSearchDialog ) {
1309 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1310 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1310 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1311 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1311 SLOT( refreshView() ) ); 1312 SLOT( refreshView() ) );
1312 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1313 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1313 SLOT( setModified() ) ); 1314 SLOT( setModified() ) );
1314 } else 1315 } else
1315 mLdapSearchDialog->restoreSettings(); 1316 mLdapSearchDialog->restoreSettings();
1316 1317
1317 if ( mLdapSearchDialog->isOK() ) 1318 if ( mLdapSearchDialog->isOK() )
1318 mLdapSearchDialog->exec(); 1319 mLdapSearchDialog->exec();
1319#else //KAB_EMBEDDED 1320#else //KAB_EMBEDDED
1320 qDebug("KABCore::openLDAPDialog() finsih method"); 1321 qDebug("KABCore::openLDAPDialog() finsih method");
1321#endif //KAB_EMBEDDED 1322#endif //KAB_EMBEDDED
1322} 1323}
1323 1324
1324void KABCore::print() 1325void KABCore::print()
1325{ 1326{
1326#ifndef KAB_EMBEDDED 1327#ifndef KAB_EMBEDDED
1327 KPrinter printer; 1328 KPrinter printer;
1328 if ( !printer.setup( this ) ) 1329 if ( !printer.setup( this ) )
1329 return; 1330 return;
1330 1331
1331 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1332 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1332 mViewManager->selectedUids(), this ); 1333 mViewManager->selectedUids(), this );
1333 1334
1334 wizard.exec(); 1335 wizard.exec();
1335#else //KAB_EMBEDDED 1336#else //KAB_EMBEDDED
1336 qDebug("KABCore::print() finsih method"); 1337 qDebug("KABCore::print() finsih method");
1337#endif //KAB_EMBEDDED 1338#endif //KAB_EMBEDDED
1338 1339
1339} 1340}
1340 1341
1341 1342
1342void KABCore::addGUIClient( KXMLGUIClient *client ) 1343void KABCore::addGUIClient( KXMLGUIClient *client )
1343{ 1344{
1344 if ( mGUIClient ) 1345 if ( mGUIClient )
1345 mGUIClient->insertChildClient( client ); 1346 mGUIClient->insertChildClient( client );
1346 else 1347 else
1347 KMessageBox::error( this, "no KXMLGUICLient"); 1348 KMessageBox::error( this, "no KXMLGUICLient");
1348} 1349}
1349 1350
1350 1351
1351void KABCore::configurationChanged() 1352void KABCore::configurationChanged()
1352{ 1353{
1353 mExtensionManager->reconfigure(); 1354 mExtensionManager->reconfigure();
1354} 1355}
1355 1356
1356void KABCore::addressBookChanged() 1357void KABCore::addressBookChanged()
1357{ 1358{
1358/*US 1359/*US
1359 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1360 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1360 while ( it.current() ) { 1361 while ( it.current() ) {
1361 if ( it.current()->dirty() ) { 1362 if ( it.current()->dirty() ) {
1362 QString text = i18n( "Data has been changed externally. Unsaved " 1363 QString text = i18n( "Data has been changed externally. Unsaved "
1363 "changes will be lost." ); 1364 "changes will be lost." );
1364 KMessageBox::information( this, text ); 1365 KMessageBox::information( this, text );
1365 } 1366 }
1366 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1367 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1367 ++it; 1368 ++it;
1368 } 1369 }
1369*/ 1370*/
1370 if (mEditorDialog) 1371 if (mEditorDialog)
1371 { 1372 {
1372 if (mEditorDialog->dirty()) 1373 if (mEditorDialog->dirty())
1373 { 1374 {
1374 QString text = i18n( "Data has been changed externally. Unsaved " 1375 QString text = i18n( "Data has been changed externally. Unsaved "
1375 "changes will be lost." ); 1376 "changes will be lost." );
1376 KMessageBox::information( this, text ); 1377 KMessageBox::information( this, text );
1377 } 1378 }
1378 QString currentuid = mEditorDialog->addressee().uid(); 1379 QString currentuid = mEditorDialog->addressee().uid();
1379 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1380 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1380 } 1381 }
1381 mViewManager->refreshView(); 1382 mViewManager->refreshView();
1382// mDetails->refreshView(); 1383// mDetails->refreshView();
1383 1384
1384 1385
1385} 1386}
1386 1387
1387AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1388AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1388 const char *name ) 1389 const char *name )
1389{ 1390{
1390 1391
1391 if ( mEditorDialog == 0 ) { 1392 if ( mEditorDialog == 0 ) {
1392 mEditorDialog = new AddresseeEditorDialog( this, parent, 1393 mEditorDialog = new AddresseeEditorDialog( this, parent,
1393 name ? name : "editorDialog" ); 1394 name ? name : "editorDialog" );
1394 1395
1395 1396
1396 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1397 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1397 SLOT( contactModified( const KABC::Addressee& ) ) ); 1398 SLOT( contactModified( const KABC::Addressee& ) ) );
1398 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1399 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1399 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1400 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1400 } 1401 }
1401 1402
1402 return mEditorDialog; 1403 return mEditorDialog;
1403} 1404}
1404 1405
1405void KABCore::slotEditorDestroyed( const QString &uid ) 1406void KABCore::slotEditorDestroyed( const QString &uid )
1406{ 1407{
1407 //mEditorDict.remove( uid ); 1408 //mEditorDict.remove( uid );
1408} 1409}
1409 1410
1410void KABCore::initGUI() 1411void KABCore::initGUI()
1411{ 1412{
1412#ifndef KAB_EMBEDDED 1413#ifndef KAB_EMBEDDED
1413 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1414 QHBoxLayout *topLayout = new QHBoxLayout( this );
1414 topLayout->setSpacing( KDialogBase::spacingHint() ); 1415 topLayout->setSpacing( KDialogBase::spacingHint() );
1415 1416
1416 mExtensionBarSplitter = new QSplitter( this ); 1417 mExtensionBarSplitter = new QSplitter( this );
1417 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1418 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1418 1419
1419 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1420 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1420 1421
1421 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1422 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1422 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1423 mIncSearchWidget = new IncSearchWidget( viewSpace );
1423 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1424 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1424 SLOT( incrementalSearch( const QString& ) ) ); 1425 SLOT( incrementalSearch( const QString& ) ) );
1425 1426
1426 mViewManager = new ViewManager( this, viewSpace ); 1427 mViewManager = new ViewManager( this, viewSpace );
1427 viewSpace->setStretchFactor( mViewManager, 1 ); 1428 viewSpace->setStretchFactor( mViewManager, 1 );
1428 1429
1429 mDetails = new ViewContainer( mDetailsSplitter ); 1430 mDetails = new ViewContainer( mDetailsSplitter );
1430 1431
1431 mJumpButtonBar = new JumpButtonBar( this, this ); 1432 mJumpButtonBar = new JumpButtonBar( this, this );
1432 1433
1433 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1434 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1434 1435
1435 topLayout->addWidget( mExtensionBarSplitter ); 1436 topLayout->addWidget( mExtensionBarSplitter );
1436 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1437 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1437 topLayout->addWidget( mJumpButtonBar ); 1438 topLayout->addWidget( mJumpButtonBar );
1438 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1439 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1439 1440
1440 mXXPortManager = new XXPortManager( this, this ); 1441 mXXPortManager = new XXPortManager( this, this );
1441 1442
1442#else //KAB_EMBEDDED 1443#else //KAB_EMBEDDED
1443 //US initialize viewMenu before settingup viewmanager. 1444 //US initialize viewMenu before settingup viewmanager.
1444 // Viewmanager needs this menu to plugin submenues. 1445 // Viewmanager needs this menu to plugin submenues.
1445 viewMenu = new QPopupMenu( this ); 1446 viewMenu = new QPopupMenu( this );
1446 settingsMenu = new QPopupMenu( this ); 1447 settingsMenu = new QPopupMenu( this );
1447 //filterMenu = new QPopupMenu( this ); 1448 //filterMenu = new QPopupMenu( this );
1448 ImportMenu = new QPopupMenu( this ); 1449 ImportMenu = new QPopupMenu( this );
1449 ExportMenu = new QPopupMenu( this ); 1450 ExportMenu = new QPopupMenu( this );
1450 syncMenu = new QPopupMenu( this ); 1451 syncMenu = new QPopupMenu( this );
1451 changeMenu= new QPopupMenu( this ); 1452 changeMenu= new QPopupMenu( this );
1452 1453
1453//US since we have no splitter for the embedded system, setup 1454//US since we have no splitter for the embedded system, setup
1454// a layout with two frames. One left and one right. 1455// a layout with two frames. One left and one right.
1455 1456
1456 QBoxLayout *topLayout; 1457 QBoxLayout *topLayout;
1457 1458
1458 // = new QHBoxLayout( this ); 1459 // = new QHBoxLayout( this );
1459// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1460// QBoxLayout *topLayout = (QBoxLayout*)layout();
1460 1461
1461// QWidget *mainBox = new QWidget( this ); 1462// QWidget *mainBox = new QWidget( this );
1462// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1463// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1463 1464
1464#ifdef DESKTOP_VERSION 1465#ifdef DESKTOP_VERSION
1465 topLayout = new QHBoxLayout( this ); 1466 topLayout = new QHBoxLayout( this );
1466 1467
1467 1468
1468 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1469 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1469 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1470 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1470 1471
1471 topLayout->addWidget(mMiniSplitter ); 1472 topLayout->addWidget(mMiniSplitter );
1472 1473
1473 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1474 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1474 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1475 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1475 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1476 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1476 mDetails = new ViewContainer( mMiniSplitter ); 1477 mDetails = new ViewContainer( mMiniSplitter );
1477 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1478 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1478#else 1479#else
1479 if ( QApplication::desktop()->width() > 480 ) { 1480 if ( QApplication::desktop()->width() > 480 ) {
1480 topLayout = new QHBoxLayout( this ); 1481 topLayout = new QHBoxLayout( this );
1481 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1482 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1482 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1483 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1483 } else { 1484 } else {
1484 1485
1485 topLayout = new QHBoxLayout( this ); 1486 topLayout = new QHBoxLayout( this );
1486 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1487 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1487 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1488 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1488 } 1489 }
1489 1490
1490 topLayout->addWidget(mMiniSplitter ); 1491 topLayout->addWidget(mMiniSplitter );
1491 mViewManager = new ViewManager( this, mMiniSplitter ); 1492 mViewManager = new ViewManager( this, mMiniSplitter );
1492 mDetails = new ViewContainer( mMiniSplitter ); 1493 mDetails = new ViewContainer( mMiniSplitter );
1493 1494
1494 1495
1495 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1496 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1496#endif 1497#endif
1497 //eh->hide(); 1498 //eh->hide();
1498 // topLayout->addWidget(mExtensionManager ); 1499 // topLayout->addWidget(mExtensionManager );
1499 1500
1500 1501
1501/*US 1502/*US
1502#ifndef KAB_NOSPLITTER 1503#ifndef KAB_NOSPLITTER
1503 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1504 QHBoxLayout *topLayout = new QHBoxLayout( this );
1504//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1505//US topLayout->setSpacing( KDialogBase::spacingHint() );
1505 topLayout->setSpacing( 10 ); 1506 topLayout->setSpacing( 10 );
1506 1507
1507 mDetailsSplitter = new QSplitter( this ); 1508 mDetailsSplitter = new QSplitter( this );
1508 1509
1509 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1510 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1510 1511
1511 mViewManager = new ViewManager( this, viewSpace ); 1512 mViewManager = new ViewManager( this, viewSpace );
1512 viewSpace->setStretchFactor( mViewManager, 1 ); 1513 viewSpace->setStretchFactor( mViewManager, 1 );
1513 1514
1514 mDetails = new ViewContainer( mDetailsSplitter ); 1515 mDetails = new ViewContainer( mDetailsSplitter );
1515 1516
1516 topLayout->addWidget( mDetailsSplitter ); 1517 topLayout->addWidget( mDetailsSplitter );
1517 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1518 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1518#else //KAB_NOSPLITTER 1519#else //KAB_NOSPLITTER
1519 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1520 QHBoxLayout *topLayout = new QHBoxLayout( this );
1520//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1521//US topLayout->setSpacing( KDialogBase::spacingHint() );
1521 topLayout->setSpacing( 10 ); 1522 topLayout->setSpacing( 10 );
1522 1523
1523// mDetailsSplitter = new QSplitter( this ); 1524// mDetailsSplitter = new QSplitter( this );
1524 1525
1525 QVBox *viewSpace = new QVBox( this ); 1526 QVBox *viewSpace = new QVBox( this );
1526 1527
1527 mViewManager = new ViewManager( this, viewSpace ); 1528 mViewManager = new ViewManager( this, viewSpace );
1528 viewSpace->setStretchFactor( mViewManager, 1 ); 1529 viewSpace->setStretchFactor( mViewManager, 1 );
1529 1530
1530 mDetails = new ViewContainer( this ); 1531 mDetails = new ViewContainer( this );
1531 1532
1532 topLayout->addWidget( viewSpace ); 1533 topLayout->addWidget( viewSpace );
1533// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1534// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1534 topLayout->addWidget( mDetails ); 1535 topLayout->addWidget( mDetails );
1535#endif //KAB_NOSPLITTER 1536#endif //KAB_NOSPLITTER
1536*/ 1537*/
1537 1538
1538 1539
1539#endif //KAB_EMBEDDED 1540#endif //KAB_EMBEDDED
1540 initActions(); 1541 initActions();
1541 1542
1542#ifdef KAB_EMBEDDED 1543#ifdef KAB_EMBEDDED
1543 addActionsManually(); 1544 addActionsManually();
1544 //US make sure the export and import menues are initialized before creating the xxPortManager. 1545 //US make sure the export and import menues are initialized before creating the xxPortManager.
1545 mXXPortManager = new XXPortManager( this, this ); 1546 mXXPortManager = new XXPortManager( this, this );
1546 1547
1547 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1548 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1548 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1549 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1549 // mActionQuit->plug ( mMainWindow->toolBar()); 1550 // mActionQuit->plug ( mMainWindow->toolBar());
1550 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1551 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1551 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1552 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1552 // mIncSearchWidget->hide(); 1553 // mIncSearchWidget->hide();
1553 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1554 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1554 SLOT( incrementalSearch( const QString& ) ) ); 1555 SLOT( incrementalSearch( const QString& ) ) );
1555 1556
1556 1557
1557 mJumpButtonBar = new JumpButtonBar( this, this ); 1558 mJumpButtonBar = new JumpButtonBar( this, this );
1558 1559
1559 topLayout->addWidget( mJumpButtonBar ); 1560 topLayout->addWidget( mJumpButtonBar );
1560//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1561//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1561 1562
1562// mMainWindow->getIconToolBar()->raise(); 1563// mMainWindow->getIconToolBar()->raise();
1563 1564
1564#endif //KAB_EMBEDDED 1565#endif //KAB_EMBEDDED
1565 1566
1566} 1567}
1567void KABCore::initActions() 1568void KABCore::initActions()
1568{ 1569{
1569//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1570//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1570 1571
1571#ifndef KAB_EMBEDDED 1572#ifndef KAB_EMBEDDED
1572 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1573 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1573 SLOT( clipboardDataChanged() ) ); 1574 SLOT( clipboardDataChanged() ) );
1574#endif //KAB_EMBEDDED 1575#endif //KAB_EMBEDDED
1575 1576
1576 // file menu 1577 // file menu