summaryrefslogtreecommitdiffabout
authorulf69 <ulf69>2004-08-05 22:50:37 (UTC)
committer ulf69 <ulf69>2004-08-05 22:50:37 (UTC)
commitc807547c32dd25e9d181d396590af9915b7a1166 (patch) (unidiff)
tree0950df8ef9653ab30e2faebf67bdd254e0ec1b8a
parentbb1dd236b41cbd5cc4aed3b320801aa07974122d (diff)
downloadkdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.zip
kdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.tar.gz
kdepimpi-c807547c32dd25e9d181d396590af9915b7a1166.tar.bz2
enabled the sending of emails to selected contacts, and mailing of vCards
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabcore.cpp254
-rw-r--r--kaddressbook/kabprefs.cpp47
-rw-r--r--kaddressbook/kabprefs.h58
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp167
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h48
-rw-r--r--microkde/kdialogbase.cpp25
-rw-r--r--microkde/kutils/kcmultidialog.cpp23
7 files changed, 392 insertions, 230 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index a7ca0ce..2a54900 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,627 +1,659 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include "kabcore.h" 24#include "kabcore.h"
25 25
26#include <stdaddressbook.h> 26#include <stdaddressbook.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#include <qclipboard.h> 30#include <qclipboard.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qfile.h> 32#include <qfile.h>
33#include <qapplicaton.h> 33#include <qapplicaton.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qregexp.h> 35#include <qregexp.h>
36#include <qvbox.h> 36#include <qvbox.h>
37#include <kabc/addresseelist.h> 37#include <kabc/addresseelist.h>
38#include <kabc/errorhandler.h> 38#include <kabc/errorhandler.h>
39#include <kabc/resource.h> 39#include <kabc/resource.h>
40#include <kabc/vcardconverter.h> 40#include <kabc/vcardconverter.h>
41#include <kapplication.h> 41#include <kapplication.h>
42#include <kactionclasses.h> 42#include <kactionclasses.h>
43#include <kcmultidialog.h> 43#include <kcmultidialog.h>
44#include <kdebug.h> 44#include <kdebug.h>
45#include <kdeversion.h> 45#include <kdeversion.h>
46#include <kkeydialog.h> 46#include <kkeydialog.h>
47#include <kmessagebox.h> 47#include <kmessagebox.h>
48#include <kprinter.h> 48#include <kprinter.h>
49#include <kprotocolinfo.h> 49#include <kprotocolinfo.h>
50#include <kresources/selectdialog.h> 50#include <kresources/selectdialog.h>
51#include <kstandarddirs.h> 51#include <kstandarddirs.h>
52#include <ktempfile.h> 52#include <ktempfile.h>
53#include <kxmlguiclient.h> 53#include <kxmlguiclient.h>
54#include <kaboutdata.h> 54#include <kaboutdata.h>
55#include <libkdepim/categoryselectdialog.h> 55#include <libkdepim/categoryselectdialog.h>
56 56
57#include "addresseeutil.h" 57#include "addresseeutil.h"
58#include "addresseeeditordialog.h" 58#include "addresseeeditordialog.h"
59#include "extensionmanager.h" 59#include "extensionmanager.h"
60#include "kstdaction.h" 60#include "kstdaction.h"
61#include "kaddressbookservice.h" 61#include "kaddressbookservice.h"
62#include "ldapsearchdialog.h" 62#include "ldapsearchdialog.h"
63#include "printing/printingwizard.h" 63#include "printing/printingwizard.h"
64#else // KAB_EMBEDDED 64#else // KAB_EMBEDDED
65 65
66#include <kapplication.h> 66#include <kapplication.h>
67#include "KDGanttMinimizeSplitter.h" 67#include "KDGanttMinimizeSplitter.h"
68#include "kaddressbookmain.h" 68#include "kaddressbookmain.h"
69#include "kactioncollection.h" 69#include "kactioncollection.h"
70#include <qapp.h> 70#include <qapp.h>
71#include <qmenubar.h> 71#include <qmenubar.h>
72//#include <qtoolbar.h> 72//#include <qtoolbar.h>
73#include <qmessagebox.h> 73#include <qmessagebox.h>
74#include <kdebug.h> 74#include <kdebug.h>
75#include <kiconloader.h> // needed for SmallIcon 75#include <kiconloader.h> // needed for SmallIcon
76#include <kresources/kcmkresources.h> 76#include <kresources/kcmkresources.h>
77#include <ktoolbar.h> 77#include <ktoolbar.h>
78 78
79#include <kcmkabconfig.h> 79#include <kcmkabconfig.h>
80 80
81//US#include <qpe/resource.h> // needed for Resource::loadPixmap
82//#include <qlabel.h> 81//#include <qlabel.h>
82
83
84#ifdef Q_WS_QWS
85#include <qtopia/services.h>
86#include <qtopia/qcopenvelope_qws.h>
87#endif
88
83#endif // KAB_EMBEDDED 89#endif // KAB_EMBEDDED
84#include <kcmkabconfig.h> 90#include <kcmkabconfig.h>
85 91
86 92
87#include <kresources/selectdialog.h> 93#include <kresources/selectdialog.h>
88#include <kmessagebox.h> 94#include <kmessagebox.h>
89 95
90#include <picture.h> 96#include <picture.h>
91#include <resource.h> 97#include <resource.h>
92 98
93//US#include <qsplitter.h> 99//US#include <qsplitter.h>
100#include <qmap.h>
101#include <qdir.h>
102#include <qfile.h>
94#include <qvbox.h> 103#include <qvbox.h>
95#include <qlayout.h> 104#include <qlayout.h>
96#include <qclipboard.h> 105#include <qclipboard.h>
106#include <qtextstream.h>
97 107
98#include <libkdepim/categoryselectdialog.h> 108#include <libkdepim/categoryselectdialog.h>
109#include <kabc/vcardconverter.h>
110
99 111
100#include "addresseeutil.h" 112#include "addresseeutil.h"
101#include "undocmds.h" 113#include "undocmds.h"
102#include "addresseeeditordialog.h" 114#include "addresseeeditordialog.h"
103#include "viewmanager.h" 115#include "viewmanager.h"
104#include "details/detailsviewcontainer.h" 116#include "details/detailsviewcontainer.h"
105#include "kabprefs.h" 117#include "kabprefs.h"
106#include "xxportmanager.h" 118#include "xxportmanager.h"
107#include "incsearchwidget.h" 119#include "incsearchwidget.h"
108#include "jumpbuttonbar.h" 120#include "jumpbuttonbar.h"
109#include "extensionmanager.h" 121#include "extensionmanager.h"
110#include "addresseeconfig.h" 122#include "addresseeconfig.h"
111#include <kcmultidialog.h> 123#include <kcmultidialog.h>
112 124
113#ifdef _WIN32_ 125#ifdef _WIN32_
114 126
115#include "kaimportoldialog.h" 127#include "kaimportoldialog.h"
116#endif 128#endif
117 129
118bool pasteWithNewUid = true; 130bool pasteWithNewUid = true;
119 131
120#ifdef KAB_EMBEDDED 132#ifdef KAB_EMBEDDED
121KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 133KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
122 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 134 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
123 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 135 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
124 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 136 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
125#else //KAB_EMBEDDED 137#else //KAB_EMBEDDED
126KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 138KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
127 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ), 139 : QWidget( parent, name ), mGUIClient( client ), mViewManager( 0 ),
128 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 140 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
129 mReadWrite( readWrite ), mModified( false ) 141 mReadWrite( readWrite ), mModified( false )
130#endif //KAB_EMBEDDED 142#endif //KAB_EMBEDDED
131{ 143{
132#ifdef KAB_EMBEDDED 144
133 //US we define here our own global actioncollection.
134 //mActionCollection = new KActionCollection(this);
135#endif //KAB_EMBEDDED
136 mExtensionBarSplitter = 0; 145 mExtensionBarSplitter = 0;
137 mIsPart = !parent->inherits( "KAddressBookMain" ); 146 mIsPart = !parent->inherits( "KAddressBookMain" );
138 147
139 mAddressBook = KABC::StdAddressBook::self(); 148 mAddressBook = KABC::StdAddressBook::self();
140 KABC::StdAddressBook::setAutomaticSave( false ); 149 KABC::StdAddressBook::setAutomaticSave( false );
141 150
142#ifndef KAB_EMBEDDED 151#ifndef KAB_EMBEDDED
143 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 152 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
144#endif //KAB_EMBEDDED 153#endif //KAB_EMBEDDED
145 154
146 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 155 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
147 SLOT( addressBookChanged() ) ); 156 SLOT( addressBookChanged() ) );
148 157
149 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 158 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
150 "X-Department", "KADDRESSBOOK" ); 159 "X-Department", "KADDRESSBOOK" );
151 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 160 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
152 "X-Profession", "KADDRESSBOOK" ); 161 "X-Profession", "KADDRESSBOOK" );
153 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 162 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
154 "X-AssistantsName", "KADDRESSBOOK" ); 163 "X-AssistantsName", "KADDRESSBOOK" );
155 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 164 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
156 "X-ManagersName", "KADDRESSBOOK" ); 165 "X-ManagersName", "KADDRESSBOOK" );
157 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 166 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
158 "X-SpousesName", "KADDRESSBOOK" ); 167 "X-SpousesName", "KADDRESSBOOK" );
159 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 168 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
160 "X-Office", "KADDRESSBOOK" ); 169 "X-Office", "KADDRESSBOOK" );
161 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 170 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
162 "X-IMAddress", "KADDRESSBOOK" ); 171 "X-IMAddress", "KADDRESSBOOK" );
163 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 172 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
164 "X-Anniversary", "KADDRESSBOOK" ); 173 "X-Anniversary", "KADDRESSBOOK" );
165 174
166 //US added this field to become compatible with Opie/qtopia addressbook 175 //US added this field to become compatible with Opie/qtopia addressbook
167 // values can be "female" or "male" or "". An empty field represents undefined. 176 // values can be "female" or "male" or "". An empty field represents undefined.
168 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 177 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
169 "X-Gender", "KADDRESSBOOK" ); 178 "X-Gender", "KADDRESSBOOK" );
170 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 179 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
171 "X-Children", "KADDRESSBOOK" ); 180 "X-Children", "KADDRESSBOOK" );
172 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 181 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
173 "X-FreeBusyUrl", "KADDRESSBOOK" ); 182 "X-FreeBusyUrl", "KADDRESSBOOK" );
174 183
175 initGUI(); 184 initGUI();
176 185
177 mIncSearchWidget->setFocus(); 186 mIncSearchWidget->setFocus();
178 187
179 188
180 connect( mViewManager, SIGNAL( selected( const QString& ) ), 189 connect( mViewManager, SIGNAL( selected( const QString& ) ),
181 SLOT( setContactSelected( const QString& ) ) ); 190 SLOT( setContactSelected( const QString& ) ) );
182 connect( mViewManager, SIGNAL( executed( const QString& ) ), 191 connect( mViewManager, SIGNAL( executed( const QString& ) ),
183 SLOT( editContact( const QString& ) ) ); 192 SLOT( editContact( const QString& ) ) );
184 connect( mViewManager, SIGNAL( deleteRequest( ) ), 193 connect( mViewManager, SIGNAL( deleteRequest( ) ),
185 SLOT( deleteContacts( ) ) ); 194 SLOT( deleteContacts( ) ) );
186 connect( mViewManager, SIGNAL( modified() ), 195 connect( mViewManager, SIGNAL( modified() ),
187 SLOT( setModified() ) ); 196 SLOT( setModified() ) );
188 197
189 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 198 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
190 199
191 connect( mXXPortManager, SIGNAL( modified() ), 200 connect( mXXPortManager, SIGNAL( modified() ),
192 SLOT( setModified() ) ); 201 SLOT( setModified() ) );
193 202
194 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 203 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
195 SLOT( incrementalSearch( const QString& ) ) ); 204 SLOT( incrementalSearch( const QString& ) ) );
196 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 205 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
197 mJumpButtonBar, SLOT( recreateButtons() ) ); 206 mJumpButtonBar, SLOT( recreateButtons() ) );
198 207
208 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
209 SLOT( sendMail( const QString& ) ) );
210
199#ifndef KAB_EMBEDDED 211#ifndef KAB_EMBEDDED
200 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 212 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
201 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 213 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
202 214
203 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
204 SLOT( sendMail( const QString& ) ) );
205 connect( mDetails, SIGNAL( browse( const QString& ) ), 215 connect( mDetails, SIGNAL( browse( const QString& ) ),
206 SLOT( browse( const QString& ) ) ); 216 SLOT( browse( const QString& ) ) );
207 217
208 mAddressBookService = new KAddressBookService( this ); 218 mAddressBookService = new KAddressBookService( this );
209 219
210#endif //KAB_EMBEDDED 220#endif //KAB_EMBEDDED
211 mEditorDialog = 0; 221 mEditorDialog = 0;
212 createAddresseeEditorDialog( this ); 222 createAddresseeEditorDialog( this );
213 setModified( false ); 223 setModified( false );
214} 224}
215 225
216KABCore::~KABCore() 226KABCore::~KABCore()
217{ 227{
218 // save(); 228 // save();
219 //saveSettings(); 229 //saveSettings();
220 //KABPrefs::instance()->writeConfig(); 230 //KABPrefs::instance()->writeConfig();
221 delete AddresseeConfig::instance(); 231 delete AddresseeConfig::instance();
222 mAddressBook = 0; 232 mAddressBook = 0;
223 KABC::StdAddressBook::close(); 233 KABC::StdAddressBook::close();
224
225#ifdef KAB_EMBEDDED
226 //US we define here our own global actioncollection.
227 // delete mActionCollection;
228#endif //KAB_EMBEDDED
229
230} 234}
231 235
232void KABCore::restoreSettings() 236void KABCore::restoreSettings()
233{ 237{
234 bool state = KABPrefs::instance()->mJumpButtonBarVisible; 238 bool state = KABPrefs::instance()->mJumpButtonBarVisible;
235 239
236 mActionJumpBar->setChecked( state ); 240 mActionJumpBar->setChecked( state );
237 setJumpButtonBarVisible( state ); 241 setJumpButtonBarVisible( state );
238 242
239 state = KABPrefs::instance()->mDetailsPageVisible; 243 state = KABPrefs::instance()->mDetailsPageVisible;
240 244
241 mActionDetails->setChecked( state ); 245 mActionDetails->setChecked( state );
242 setDetailsVisible( state ); 246 setDetailsVisible( state );
243 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 247 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
244 if ( splitterSize.count() == 0 ) { 248 if ( splitterSize.count() == 0 ) {
245 splitterSize.append( width() / 2 ); 249 splitterSize.append( width() / 2 );
246 splitterSize.append( width() / 2 ); 250 splitterSize.append( width() / 2 );
247 } 251 }
248 mMiniSplitter->setSizes( splitterSize ); 252 mMiniSplitter->setSizes( splitterSize );
249 if ( mExtensionBarSplitter ) { 253 if ( mExtensionBarSplitter ) {
250 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 254 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
251 if ( splitterSize.count() == 0 ) { 255 if ( splitterSize.count() == 0 ) {
252 splitterSize.append( width() / 2 ); 256 splitterSize.append( width() / 2 );
253 splitterSize.append( width() / 2 ); 257 splitterSize.append( width() / 2 );
254 } 258 }
255 mExtensionBarSplitter->setSizes( splitterSize ); 259 mExtensionBarSplitter->setSizes( splitterSize );
256 260
257 } 261 }
258#ifndef KAB_EMBEDDED 262#ifndef KAB_EMBEDDED
259 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter; 263 QValueList<int> splitterSize = KABPrefs::instance()->mExtensionsSplitter;
260 if ( splitterSize.count() == 0 ) { 264 if ( splitterSize.count() == 0 ) {
261 splitterSize.append( width() / 2 ); 265 splitterSize.append( width() / 2 );
262 splitterSize.append( width() / 2 ); 266 splitterSize.append( width() / 2 );
263 } 267 }
264 mExtensionBarSplitter->setSizes( splitterSize ); 268 mExtensionBarSplitter->setSizes( splitterSize );
265 269
266 splitterSize = KABPrefs::instance()->mDetailsSplitter; 270 splitterSize = KABPrefs::instance()->mDetailsSplitter;
267 if ( splitterSize.count() == 0 ) { 271 if ( splitterSize.count() == 0 ) {
268 splitterSize.append( height() / 2 ); 272 splitterSize.append( height() / 2 );
269 splitterSize.append( height() / 2 ); 273 splitterSize.append( height() / 2 );
270 } 274 }
271 mDetailsSplitter->setSizes( splitterSize ); 275 mDetailsSplitter->setSizes( splitterSize );
272 276
273 mExtensionManager->restoreSettings(); 277 mExtensionManager->restoreSettings();
274 278
275#endif //KAB_EMBEDDED 279#endif //KAB_EMBEDDED
276 280
277 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 281 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
278 282
279 mViewManager->restoreSettings(); 283 mViewManager->restoreSettings();
280 mExtensionManager->restoreSettings(); 284 mExtensionManager->restoreSettings();
281} 285}
282 286
283void KABCore::saveSettings() 287void KABCore::saveSettings()
284{ 288{
285 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 289 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
286 if ( mExtensionBarSplitter ) 290 if ( mExtensionBarSplitter )
287 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 291 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
288 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 292 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
289 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 293 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
290#ifndef KAB_EMBEDDED 294#ifndef KAB_EMBEDDED
291 295
292 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 296 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
293 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 297 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
294#endif //KAB_EMBEDDED 298#endif //KAB_EMBEDDED
295 mExtensionManager->saveSettings(); 299 mExtensionManager->saveSettings();
296 mViewManager->saveSettings(); 300 mViewManager->saveSettings();
297 301
298 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 302 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
299 303
300} 304}
301 305
302KABC::AddressBook *KABCore::addressBook() const 306KABC::AddressBook *KABCore::addressBook() const
303{ 307{
304 return mAddressBook; 308 return mAddressBook;
305} 309}
306 310
307KConfig *KABCore::config() 311KConfig *KABCore::config()
308{ 312{
309#ifndef KAB_EMBEDDED 313#ifndef KAB_EMBEDDED
310 return KABPrefs::instance()->config(); 314 return KABPrefs::instance()->config();
311#else //KAB_EMBEDDED 315#else //KAB_EMBEDDED
312 return KABPrefs::instance()->getConfig(); 316 return KABPrefs::instance()->getConfig();
313#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED
314} 318}
315 319
316KActionCollection *KABCore::actionCollection() const 320KActionCollection *KABCore::actionCollection() const
317{ 321{
318 return mGUIClient->actionCollection(); 322 return mGUIClient->actionCollection();
319} 323}
320 324
321KABC::Field *KABCore::currentSearchField() const 325KABC::Field *KABCore::currentSearchField() const
322{ 326{
323 if (mIncSearchWidget) 327 if (mIncSearchWidget)
324 return mIncSearchWidget->currentField(); 328 return mIncSearchWidget->currentField();
325 else 329 else
326 return 0; 330 return 0;
327} 331}
328 332
329QStringList KABCore::selectedUIDs() const 333QStringList KABCore::selectedUIDs() const
330{ 334{
331 return mViewManager->selectedUids(); 335 return mViewManager->selectedUids();
332} 336}
333 337
334KABC::Resource *KABCore::requestResource( QWidget *parent ) 338KABC::Resource *KABCore::requestResource( QWidget *parent )
335{ 339{
336 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 340 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
337 341
338 QPtrList<KRES::Resource> kresResources; 342 QPtrList<KRES::Resource> kresResources;
339 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 343 QPtrListIterator<KABC::Resource> resIt( kabcResources );
340 KABC::Resource *resource; 344 KABC::Resource *resource;
341 while ( ( resource = resIt.current() ) != 0 ) { 345 while ( ( resource = resIt.current() ) != 0 ) {
342 ++resIt; 346 ++resIt;
343 if ( !resource->readOnly() ) { 347 if ( !resource->readOnly() ) {
344 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 348 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
345 if ( res ) 349 if ( res )
346 kresResources.append( res ); 350 kresResources.append( res );
347 } 351 }
348 } 352 }
349 353
350 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 354 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
351 return static_cast<KABC::Resource*>( res ); 355 return static_cast<KABC::Resource*>( res );
352} 356}
353 357
354#ifndef KAB_EMBEDDED 358#ifndef KAB_EMBEDDED
355KAboutData *KABCore::createAboutData() 359KAboutData *KABCore::createAboutData()
356#else //KAB_EMBEDDED 360#else //KAB_EMBEDDED
357void KABCore::createAboutData() 361void KABCore::createAboutData()
358#endif //KAB_EMBEDDED 362#endif //KAB_EMBEDDED
359{ 363{
360#ifndef KAB_EMBEDDED 364#ifndef KAB_EMBEDDED
361 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 365 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
362 "3.1", I18N_NOOP( "The KDE Address Book" ), 366 "3.1", I18N_NOOP( "The KDE Address Book" ),
363 KAboutData::License_GPL_V2, 367 KAboutData::License_GPL_V2,
364 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 368 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
365 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 369 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
366 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 370 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
367 about->addAuthor( "Cornelius Schumacher", 371 about->addAuthor( "Cornelius Schumacher",
368 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 372 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
369 "schumacher@kde.org" ); 373 "schumacher@kde.org" );
370 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 374 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
371 "mpilone@slac.com" ); 375 "mpilone@slac.com" );
372 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 376 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
373 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 377 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
374 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 378 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
375 "michel@klaralvdalens-datakonsult.se" ); 379 "michel@klaralvdalens-datakonsult.se" );
376 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 380 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
377 "hansen@kde.org" ); 381 "hansen@kde.org" );
378 382
379 return about; 383 return about;
380#endif //KAB_EMBEDDED 384#endif //KAB_EMBEDDED
381 385
382 QString version; 386 QString version;
383#include <../version> 387#include <../version>
384 QMessageBox::about( this, "About KAddressbook/Pi", 388 QMessageBox::about( this, "About KAddressbook/Pi",
385 "KAddressbook/Platform-independent\n" 389 "KAddressbook/Platform-independent\n"
386 "(KA/Pi) " +version + " - " + 390 "(KA/Pi) " +version + " - " +
387#ifdef DESKTOP_VERSION 391#ifdef DESKTOP_VERSION
388 "Desktop Edition\n" 392 "Desktop Edition\n"
389#else 393#else
390 "PDA-Edition\n" 394 "PDA-Edition\n"
391 "for: Zaurus 5500 / 7x0 / 8x0\n" 395 "for: Zaurus 5500 / 7x0 / 8x0\n"
392#endif 396#endif
393 397
394 "(c) 2004 Ulf Schenk\n" 398 "(c) 2004 Ulf Schenk\n"
395 "(c) 1997-2003, The KDE PIM Team\n" 399 "(c) 1997-2003, The KDE PIM Team\n"
396 "Tobias Koenig Current maintainer tokoe@kde.org\n" 400 "Tobias Koenig Current maintainer tokoe@kde.org\n"
397 "Don Sanders Original author\n" 401 "Don Sanders Original author\n"
398 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n" 402 "Cornelius Schumacher Co-maintainer schumacher@kde.org\n"
399 "Mike Pilone GUI and framework redesign mpilone@slac.com\n" 403 "Mike Pilone GUI and framework redesign mpilone@slac.com\n"
400 "Greg Stern DCOP interface\n" 404 "Greg Stern DCOP interface\n"
401 "Mark Westcot Contact pinning\n" 405 "Mark Westcot Contact pinning\n"
402 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 406 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
403 "Steffen Hansen LDAP Lookup hansen@kde.org\n" 407 "Steffen Hansen LDAP Lookup hansen@kde.org\n"
404#ifdef _WIN32_ 408#ifdef _WIN32_
405 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n" 409 "(c) 2004 Lutz Rogowski Import from OL rogowski@kde.org\n"
406#endif 410#endif
407 ); 411 );
408} 412}
409 413
410void KABCore::setContactSelected( const QString &uid ) 414void KABCore::setContactSelected( const QString &uid )
411{ 415{
412 KABC::Addressee addr = mAddressBook->findByUid( uid ); 416 KABC::Addressee addr = mAddressBook->findByUid( uid );
413 if ( !mDetails->isHidden() ) 417 if ( !mDetails->isHidden() )
414 mDetails->setAddressee( addr ); 418 mDetails->setAddressee( addr );
415 419
416 if ( !addr.isEmpty() ) { 420 if ( !addr.isEmpty() ) {
417 emit contactSelected( addr.formattedName() ); 421 emit contactSelected( addr.formattedName() );
418 KABC::Picture pic = addr.photo(); 422 KABC::Picture pic = addr.photo();
419 if ( pic.isIntern() ) { 423 if ( pic.isIntern() ) {
420//US emit contactSelected( pic.data() ); 424//US emit contactSelected( pic.data() );
421//US instead use: 425//US instead use:
422 QPixmap px; 426 QPixmap px;
423 if (pic.data().isNull() != true) 427 if (pic.data().isNull() != true)
424 { 428 {
425 px.convertFromImage(pic.data()); 429 px.convertFromImage(pic.data());
426 } 430 }
427 431
428 emit contactSelected( px ); 432 emit contactSelected( px );
429 } 433 }
430 } 434 }
431 435
432 436
433 mExtensionManager->setSelectionChanged(); 437 mExtensionManager->setSelectionChanged();
434 438
435 // update the actions 439 // update the actions
436 bool selected = !uid.isEmpty(); 440 bool selected = !uid.isEmpty();
437 441
438 if ( mReadWrite ) { 442 if ( mReadWrite ) {
439 mActionCut->setEnabled( selected ); 443 mActionCut->setEnabled( selected );
440 mActionPaste->setEnabled( selected ); 444 mActionPaste->setEnabled( selected );
441 } 445 }
442 446
443 mActionCopy->setEnabled( selected ); 447 mActionCopy->setEnabled( selected );
444 mActionDelete->setEnabled( selected ); 448 mActionDelete->setEnabled( selected );
445 mActionEditAddressee->setEnabled( selected ); 449 mActionEditAddressee->setEnabled( selected );
446 mActionMail->setEnabled( selected ); 450 mActionMail->setEnabled( selected );
447 mActionMailVCard->setEnabled( selected ); 451 mActionMailVCard->setEnabled( selected );
448 mActionWhoAmI->setEnabled( selected ); 452 mActionWhoAmI->setEnabled( selected );
449 mActionCategories->setEnabled( selected ); 453 mActionCategories->setEnabled( selected );
450} 454}
451 455
452void KABCore::sendMail() 456void KABCore::sendMail()
453{ 457{
454#ifndef KAB_EMBEDDED
455 sendMail( mViewManager->selectedEmails().join( ", " ) ); 458 sendMail( mViewManager->selectedEmails().join( ", " ) );
456#else //KAB_EMBEDDED
457 qDebug("KABCore::sendMail() ust be fixed");
458#endif //KAB_EMBEDDED
459} 459}
460 460
461void KABCore::sendMail( const QString& email ) 461void KABCore::sendMail( const QString& email )
462{ 462{
463#ifndef KAB_EMBEDDED 463//US original kde implementation : kapp->invokeMailer( email, "" );
464 kapp->invokeMailer( email, "" ); 464
465#else //KAB_EMBEDDED 465/*US original qtopia implementation
466 qDebug("KABCore::sendMail(const QString& email) ust be fixed"); 466 PimContact c = abList->currentEntry();
467#endif //KAB_EMBEDDED 467 QString name = c.fileAs();
468 QString email = c.defaultEmail();
469#ifndef QT_NO_COP
470 QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)");
471 e << name << email;
472#else
473*/
474
475
476#ifndef QT_NO_COP
477 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
478 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
479
480 QCopEnvelope e(channel, "writeMail(QString,QString)");
481 //US we need no names in the To field. The emailadresses are enough
482 e << "" << email;
483#else
484 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
485#endif
468} 486}
469 487
470void KABCore::mailVCard() 488void KABCore::mailVCard()
471{ 489{
472#ifndef KAB_EMBEDDED
473 QStringList uids = mViewManager->selectedUids(); 490 QStringList uids = mViewManager->selectedUids();
474 if ( !uids.isEmpty() ) 491 if ( !uids.isEmpty() )
475 mailVCard( uids ); 492 mailVCard( uids );
476#else //KAB_EMBEDDED
477 qDebug("KABCore::mailVCard() must be fixed");
478#endif //KAB_EMBEDDED
479} 493}
480 494
481void KABCore::mailVCard( const QStringList& uids ) 495void KABCore::mailVCard( const QStringList& uids )
482{ 496{
483#ifndef KAB_EMBEDDED
484 QStringList urls; 497 QStringList urls;
485 498
499 QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
500
501/*US
486 // Create a temp dir, so that we can put the files in it with proper names 502 // Create a temp dir, so that we can put the files in it with proper names
487 KTempFile tempDir; 503 KTempFile tempDir;
488 if ( tempDir.status() != 0 ) { 504 if ( tempDir.status() != 0 ) {
489 kdWarning() << strerror( tempDir.status() ) << endl; 505 kdWarning() << strerror( tempDir.status() ) << endl;
490 return; 506 return;
491 } 507 }
492 508
493 QString dirName = tempDir.name(); 509 QString dirName = tempDir.name();
494 tempDir.unlink(); 510 tempDir.unlink();
511*/
512 QString dirName = tmpdir + "/" + KApplication::randomString( 8 );
513
514
515
495 QDir().mkdir( dirName, true ); 516 QDir().mkdir( dirName, true );
496 517
497 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 518 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
498 KABC::Addressee a = mAddressBook->findByUid( *it ); 519 KABC::Addressee a = mAddressBook->findByUid( *it );
499 520
500 if ( a.isEmpty() ) 521 if ( a.isEmpty() )
501 continue; 522 continue;
502 523
503 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 524 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
504 525
505 QString fileName = dirName + "/" + name; 526 QString fileName = dirName + "/" + name;
506 527
507 QFile outFile(fileName); 528 QFile outFile(fileName);
508 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 529 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
509 KABC::VCardConverter converter; 530 KABC::VCardConverter converter;
510 QString vcard; 531 QString vcard;
511 532
512 converter.addresseeToVCard( a, vcard ); 533 converter.addresseeToVCard( a, vcard );
513 534
514 QTextStream t( &outFile ); // use a text stream 535 QTextStream t( &outFile ); // use a text stream
515 t.setEncoding( QTextStream::UnicodeUTF8 ); 536 t.setEncoding( QTextStream::UnicodeUTF8 );
516 t << vcard; 537 t << vcard;
517 538
518 outFile.close(); 539 outFile.close();
519 540
520 urls.append( fileName ); 541 urls.append( fileName );
521 } 542 }
522 } 543 }
523 544/*US
524 kapp->invokeMailer( QString::null, QString::null, QString::null, 545 kapp->invokeMailer( QString::null, QString::null, QString::null,
525 QString::null, // subject 546 QString::null, // subject
526 QString::null, // body 547 QString::null, // body
527 QString::null, 548 QString::null,
528 urls ); // attachments 549 urls ); // attachments
529#else //KAB_EMBEDDED 550*/
530 qDebug("KABCore::mailVCard( must be fixed"); 551#ifndef QT_NO_COP
531#endif //KAB_EMBEDDED 552 QCString channel = KABPrefs::instance()->mEmailChannel.latin1();
553 qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")");
554
555 QMap<QString, QString> parameterMap;
556 parameterMap.insert("ATTACHMENT<n>", urls.join(", "));
557
558 QCopEnvelope e(channel, "writeMail(QMap(QString,QString))");
559 e << parameterMap;
560#else
561 KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) );
562#endif
563
532 564
533} 565}
534 566
535void KABCore::browse( const QString& url ) 567void KABCore::browse( const QString& url )
536{ 568{
537#ifndef KAB_EMBEDDED 569#ifndef KAB_EMBEDDED
538 kapp->invokeBrowser( url ); 570 kapp->invokeBrowser( url );
539#else //KAB_EMBEDDED 571#else //KAB_EMBEDDED
540 qDebug("KABCore::browse must be fixed"); 572 qDebug("KABCore::browse must be fixed");
541#endif //KAB_EMBEDDED 573#endif //KAB_EMBEDDED
542} 574}
543 575
544void KABCore::selectAllContacts() 576void KABCore::selectAllContacts()
545{ 577{
546 mViewManager->setSelected( QString::null, true ); 578 mViewManager->setSelected( QString::null, true );
547} 579}
548 580
549void KABCore::deleteContacts() 581void KABCore::deleteContacts()
550{ 582{
551 QStringList uidList = mViewManager->selectedUids(); 583 QStringList uidList = mViewManager->selectedUids();
552 deleteContacts( uidList ); 584 deleteContacts( uidList );
553} 585}
554 586
555void KABCore::deleteContacts( const QStringList &uids ) 587void KABCore::deleteContacts( const QStringList &uids )
556{ 588{
557 if ( uids.count() > 0 ) { 589 if ( uids.count() > 0 ) {
558 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 590 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
559 UndoStack::instance()->push( command ); 591 UndoStack::instance()->push( command );
560 RedoStack::instance()->clear(); 592 RedoStack::instance()->clear();
561 593
562 // now if we deleted anything, refresh 594 // now if we deleted anything, refresh
563 setContactSelected( QString::null ); 595 setContactSelected( QString::null );
564 setModified( true ); 596 setModified( true );
565 } 597 }
566} 598}
567 599
568void KABCore::copyContacts() 600void KABCore::copyContacts()
569{ 601{
570 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 602 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
571 603
572 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 604 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
573 605
574 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 606 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
575 607
576 QClipboard *cb = QApplication::clipboard(); 608 QClipboard *cb = QApplication::clipboard();
577 cb->setText( clipText ); 609 cb->setText( clipText );
578} 610}
579 611
580void KABCore::cutContacts() 612void KABCore::cutContacts()
581{ 613{
582 QStringList uidList = mViewManager->selectedUids(); 614 QStringList uidList = mViewManager->selectedUids();
583 615
584//US if ( uidList.size() > 0 ) { 616//US if ( uidList.size() > 0 ) {
585 if ( uidList.count() > 0 ) { 617 if ( uidList.count() > 0 ) {
586 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 618 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
587 UndoStack::instance()->push( command ); 619 UndoStack::instance()->push( command );
588 RedoStack::instance()->clear(); 620 RedoStack::instance()->clear();
589 621
590 setModified( true ); 622 setModified( true );
591 } 623 }
592} 624}
593 625
594void KABCore::pasteContacts() 626void KABCore::pasteContacts()
595{ 627{
596 QClipboard *cb = QApplication::clipboard(); 628 QClipboard *cb = QApplication::clipboard();
597 629
598 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 630 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
599 631
600 pasteContacts( list ); 632 pasteContacts( list );
601} 633}
602 634
603void KABCore::pasteContacts( KABC::Addressee::List &list ) 635void KABCore::pasteContacts( KABC::Addressee::List &list )
604{ 636{
605 KABC::Resource *resource = requestResource( this ); 637 KABC::Resource *resource = requestResource( this );
606 KABC::Addressee::List::Iterator it; 638 KABC::Addressee::List::Iterator it;
607 for ( it = list.begin(); it != list.end(); ++it ) 639 for ( it = list.begin(); it != list.end(); ++it )
608 (*it).setResource( resource ); 640 (*it).setResource( resource );
609 641
610 PwPasteCommand *command = new PwPasteCommand( this, list ); 642 PwPasteCommand *command = new PwPasteCommand( this, list );
611 UndoStack::instance()->push( command ); 643 UndoStack::instance()->push( command );
612 RedoStack::instance()->clear(); 644 RedoStack::instance()->clear();
613 645
614 setModified( true ); 646 setModified( true );
615} 647}
616 648
617void KABCore::setWhoAmI() 649void KABCore::setWhoAmI()
618{ 650{
619 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 651 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
620 652
621 if ( addrList.count() > 1 ) { 653 if ( addrList.count() > 1 ) {
622 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 654 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
623 return; 655 return;
624 } 656 }
625 657
626 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 658 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
627 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 659 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
@@ -659,1029 +691,1029 @@ void KABCore::setCategories()
659 } 691 }
660 692
661 mAddressBook->insertAddressee( addr ); 693 mAddressBook->insertAddressee( addr );
662 } 694 }
663 } 695 }
664 696
665 if ( uids.count() > 0 ) 697 if ( uids.count() > 0 )
666 setModified( true ); 698 setModified( true );
667} 699}
668 700
669void KABCore::setSearchFields( const KABC::Field::List &fields ) 701void KABCore::setSearchFields( const KABC::Field::List &fields )
670{ 702{
671 mIncSearchWidget->setFields( fields ); 703 mIncSearchWidget->setFields( fields );
672} 704}
673 705
674void KABCore::incrementalSearch( const QString& text ) 706void KABCore::incrementalSearch( const QString& text )
675{ 707{
676 mViewManager->setSelected( QString::null, false ); 708 mViewManager->setSelected( QString::null, false );
677 709
678 if ( !text.isEmpty() ) { 710 if ( !text.isEmpty() ) {
679 KABC::Field *field = mIncSearchWidget->currentField(); 711 KABC::Field *field = mIncSearchWidget->currentField();
680 712
681 QString pattern = text.lower(); 713 QString pattern = text.lower();
682 714
683#if 1 //KDE_VERSION >= 319 715#if 1 //KDE_VERSION >= 319
684 KABC::AddresseeList list( mAddressBook->allAddressees() ); 716 KABC::AddresseeList list( mAddressBook->allAddressees() );
685 if ( field ) { 717 if ( field ) {
686 list.sortByField( field ); 718 list.sortByField( field );
687 KABC::AddresseeList::Iterator it; 719 KABC::AddresseeList::Iterator it;
688 for ( it = list.begin(); it != list.end(); ++it ) { 720 for ( it = list.begin(); it != list.end(); ++it ) {
689 if ( field->value( *it ).lower().startsWith( pattern ) ) { 721 if ( field->value( *it ).lower().startsWith( pattern ) ) {
690 mViewManager->setSelected( (*it).uid(), true ); 722 mViewManager->setSelected( (*it).uid(), true );
691 return; 723 return;
692 } 724 }
693 } 725 }
694 } else { 726 } else {
695 KABC::AddresseeList::Iterator it; 727 KABC::AddresseeList::Iterator it;
696 for ( it = list.begin(); it != list.end(); ++it ) { 728 for ( it = list.begin(); it != list.end(); ++it ) {
697 KABC::Field::List fieldList = mIncSearchWidget->fields(); 729 KABC::Field::List fieldList = mIncSearchWidget->fields();
698 KABC::Field::List::ConstIterator fieldIt; 730 KABC::Field::List::ConstIterator fieldIt;
699 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 731 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
700 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 732 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
701 mViewManager->setSelected( (*it).uid(), true ); 733 mViewManager->setSelected( (*it).uid(), true );
702 return; 734 return;
703 } 735 }
704 } 736 }
705 } 737 }
706 } 738 }
707#else 739#else
708 KABC::AddressBook::Iterator it; 740 KABC::AddressBook::Iterator it;
709 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 741 for ( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
710 if ( field ) { 742 if ( field ) {
711 if ( field->value( *it ).lower().startsWith( pattern ) ) { 743 if ( field->value( *it ).lower().startsWith( pattern ) ) {
712 mViewManager->setSelected( (*it).uid(), true ); 744 mViewManager->setSelected( (*it).uid(), true );
713 return; 745 return;
714 } 746 }
715 } else { 747 } else {
716 KABC::Field::List fieldList = mIncSearchWidget->fields(); 748 KABC::Field::List fieldList = mIncSearchWidget->fields();
717 KABC::Field::List::ConstIterator fieldIt; 749 KABC::Field::List::ConstIterator fieldIt;
718 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 750 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
719 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) { 751 if ( (*fieldIt)->value( *it ).lower().startsWith( pattern ) ) {
720 mViewManager->setSelected( (*it).uid(), true ); 752 mViewManager->setSelected( (*it).uid(), true );
721 return; 753 return;
722 } 754 }
723 } 755 }
724 } 756 }
725 } 757 }
726#endif 758#endif
727 } 759 }
728} 760}
729 761
730void KABCore::setModified() 762void KABCore::setModified()
731{ 763{
732 setModified( true ); 764 setModified( true );
733} 765}
734 766
735void KABCore::setModifiedWOrefresh() 767void KABCore::setModifiedWOrefresh()
736{ 768{
737 // qDebug("KABCore::setModifiedWOrefresh() "); 769 // qDebug("KABCore::setModifiedWOrefresh() ");
738 mModified = true; 770 mModified = true;
739 mActionSave->setEnabled( mModified ); 771 mActionSave->setEnabled( mModified );
740#ifdef DESKTOP_VERSION 772#ifdef DESKTOP_VERSION
741 mDetails->refreshView(); 773 mDetails->refreshView();
742#endif 774#endif
743 775
744} 776}
745void KABCore::setModified( bool modified ) 777void KABCore::setModified( bool modified )
746{ 778{
747 mModified = modified; 779 mModified = modified;
748 mActionSave->setEnabled( mModified ); 780 mActionSave->setEnabled( mModified );
749 781
750 if ( modified ) 782 if ( modified )
751 mJumpButtonBar->recreateButtons(); 783 mJumpButtonBar->recreateButtons();
752 784
753 mViewManager->refreshView(); 785 mViewManager->refreshView();
754 mDetails->refreshView(); 786 mDetails->refreshView();
755 787
756} 788}
757 789
758bool KABCore::modified() const 790bool KABCore::modified() const
759{ 791{
760 return mModified; 792 return mModified;
761} 793}
762 794
763void KABCore::contactModified( const KABC::Addressee &addr ) 795void KABCore::contactModified( const KABC::Addressee &addr )
764{ 796{
765 797
766 Command *command = 0; 798 Command *command = 0;
767 QString uid; 799 QString uid;
768 800
769 // check if it exists already 801 // check if it exists already
770 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 802 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
771 if ( origAddr.isEmpty() ) 803 if ( origAddr.isEmpty() )
772 command = new PwNewCommand( mAddressBook, addr ); 804 command = new PwNewCommand( mAddressBook, addr );
773 else { 805 else {
774 command = new PwEditCommand( mAddressBook, origAddr, addr ); 806 command = new PwEditCommand( mAddressBook, origAddr, addr );
775 uid = addr.uid(); 807 uid = addr.uid();
776 } 808 }
777 809
778 UndoStack::instance()->push( command ); 810 UndoStack::instance()->push( command );
779 RedoStack::instance()->clear(); 811 RedoStack::instance()->clear();
780 812
781 setModified( true ); 813 setModified( true );
782} 814}
783 815
784void KABCore::newContact() 816void KABCore::newContact()
785{ 817{
786 818
787 819
788 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 820 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
789 821
790 QPtrList<KRES::Resource> kresResources; 822 QPtrList<KRES::Resource> kresResources;
791 QPtrListIterator<KABC::Resource> it( kabcResources ); 823 QPtrListIterator<KABC::Resource> it( kabcResources );
792 KABC::Resource *resource; 824 KABC::Resource *resource;
793 while ( ( resource = it.current() ) != 0 ) { 825 while ( ( resource = it.current() ) != 0 ) {
794 ++it; 826 ++it;
795 if ( !resource->readOnly() ) { 827 if ( !resource->readOnly() ) {
796 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 828 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
797 if ( res ) 829 if ( res )
798 kresResources.append( res ); 830 kresResources.append( res );
799 } 831 }
800 } 832 }
801 833
802 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 834 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
803 resource = static_cast<KABC::Resource*>( res ); 835 resource = static_cast<KABC::Resource*>( res );
804 836
805 if ( resource ) { 837 if ( resource ) {
806 KABC::Addressee addr; 838 KABC::Addressee addr;
807 addr.setResource( resource ); 839 addr.setResource( resource );
808 mEditorDialog->setAddressee( addr ); 840 mEditorDialog->setAddressee( addr );
809 KApplication::execDialog ( mEditorDialog ); 841 KApplication::execDialog ( mEditorDialog );
810 842
811 } else 843 } else
812 return; 844 return;
813 845
814 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 846 // mEditorDict.insert( dialog->addressee().uid(), dialog );
815 847
816 848
817} 849}
818 850
819void KABCore::addEmail( QString aStr ) 851void KABCore::addEmail( QString aStr )
820{ 852{
821#ifndef KAB_EMBEDDED 853#ifndef KAB_EMBEDDED
822 QString fullName, email; 854 QString fullName, email;
823 855
824 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 856 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
825 857
826 // Try to lookup the addressee matching the email address 858 // Try to lookup the addressee matching the email address
827 bool found = false; 859 bool found = false;
828 QStringList emailList; 860 QStringList emailList;
829 KABC::AddressBook::Iterator it; 861 KABC::AddressBook::Iterator it;
830 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 862 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
831 emailList = (*it).emails(); 863 emailList = (*it).emails();
832 if ( emailList.contains( email ) > 0 ) { 864 if ( emailList.contains( email ) > 0 ) {
833 found = true; 865 found = true;
834 (*it).setNameFromString( fullName ); 866 (*it).setNameFromString( fullName );
835 editContact( (*it).uid() ); 867 editContact( (*it).uid() );
836 } 868 }
837 } 869 }
838 870
839 if ( !found ) { 871 if ( !found ) {
840 KABC::Addressee addr; 872 KABC::Addressee addr;
841 addr.setNameFromString( fullName ); 873 addr.setNameFromString( fullName );
842 addr.insertEmail( email, true ); 874 addr.insertEmail( email, true );
843 875
844 mAddressBook->insertAddressee( addr ); 876 mAddressBook->insertAddressee( addr );
845 mViewManager->refreshView( addr.uid() ); 877 mViewManager->refreshView( addr.uid() );
846 editContact( addr.uid() ); 878 editContact( addr.uid() );
847 } 879 }
848#else //KAB_EMBEDDED 880#else //KAB_EMBEDDED
849 qDebug("KABCore::addEmail finsih method"); 881 qDebug("KABCore::addEmail finsih method");
850#endif //KAB_EMBEDDED 882#endif //KAB_EMBEDDED
851} 883}
852 884
853void KABCore::importVCard( const KURL &url, bool showPreview ) 885void KABCore::importVCard( const KURL &url, bool showPreview )
854{ 886{
855 mXXPortManager->importVCard( url, showPreview ); 887 mXXPortManager->importVCard( url, showPreview );
856} 888}
857void KABCore::importFromOL() 889void KABCore::importFromOL()
858{ 890{
859#ifdef _WIN32_ 891#ifdef _WIN32_
860 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 892 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
861 idgl->exec(); 893 idgl->exec();
862 KABC::Addressee::List list = idgl->getAddressList(); 894 KABC::Addressee::List list = idgl->getAddressList();
863 if ( list.count() > 0 ) { 895 if ( list.count() > 0 ) {
864 KABC::Addressee::List listNew; 896 KABC::Addressee::List listNew;
865 KABC::Addressee::List listExisting; 897 KABC::Addressee::List listExisting;
866 KABC::Addressee::List::Iterator it; 898 KABC::Addressee::List::Iterator it;
867 KABC::AddressBook::Iterator iter; 899 KABC::AddressBook::Iterator iter;
868 for ( it = list.begin(); it != list.end(); ++it ) { 900 for ( it = list.begin(); it != list.end(); ++it ) {
869 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 901 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
870 listNew.append( (*it) ); 902 listNew.append( (*it) );
871 else 903 else
872 listExisting.append( (*it) ); 904 listExisting.append( (*it) );
873 } 905 }
874 if ( listExisting.count() > 0 ) 906 if ( listExisting.count() > 0 )
875 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 907 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
876 if ( listNew.count() > 0 ) { 908 if ( listNew.count() > 0 ) {
877 pasteWithNewUid = false; 909 pasteWithNewUid = false;
878 pasteContacts( listNew ); 910 pasteContacts( listNew );
879 pasteWithNewUid = true; 911 pasteWithNewUid = true;
880 } 912 }
881 } 913 }
882 delete idgl; 914 delete idgl;
883#endif 915#endif
884} 916}
885 917
886void KABCore::importVCard( const QString &vCard, bool showPreview ) 918void KABCore::importVCard( const QString &vCard, bool showPreview )
887{ 919{
888 mXXPortManager->importVCard( vCard, showPreview ); 920 mXXPortManager->importVCard( vCard, showPreview );
889} 921}
890 922
891//US added a second method without defaultparameter 923//US added a second method without defaultparameter
892void KABCore::editContact2() { 924void KABCore::editContact2() {
893 editContact( QString::null ); 925 editContact( QString::null );
894} 926}
895 927
896void KABCore::editContact( const QString &uid ) 928void KABCore::editContact( const QString &uid )
897{ 929{
898 930
899 if ( mExtensionManager->isQuickEditVisible() ) 931 if ( mExtensionManager->isQuickEditVisible() )
900 return; 932 return;
901 933
902 // First, locate the contact entry 934 // First, locate the contact entry
903 QString localUID = uid; 935 QString localUID = uid;
904 if ( localUID.isNull() ) { 936 if ( localUID.isNull() ) {
905 QStringList uidList = mViewManager->selectedUids(); 937 QStringList uidList = mViewManager->selectedUids();
906 if ( uidList.count() > 0 ) 938 if ( uidList.count() > 0 )
907 localUID = *( uidList.at( 0 ) ); 939 localUID = *( uidList.at( 0 ) );
908 } 940 }
909 941
910 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 942 KABC::Addressee addr = mAddressBook->findByUid( localUID );
911 if ( !addr.isEmpty() ) { 943 if ( !addr.isEmpty() ) {
912 mEditorDialog->setAddressee( addr ); 944 mEditorDialog->setAddressee( addr );
913 KApplication::execDialog ( mEditorDialog ); 945 KApplication::execDialog ( mEditorDialog );
914 } 946 }
915} 947}
916 948
917void KABCore::save() 949void KABCore::save()
918{ 950{
919 if ( !mModified ) 951 if ( !mModified )
920 return; 952 return;
921 QString text = i18n( "There was an error while attempting to save\n the " 953 QString text = i18n( "There was an error while attempting to save\n the "
922 "address book. Please check that some \nother application is " 954 "address book. Please check that some \nother application is "
923 "not using it. " ); 955 "not using it. " );
924 statusMessage(i18n("Saving addressbook ... ")); 956 statusMessage(i18n("Saving addressbook ... "));
925#ifndef KAB_EMBEDDED 957#ifndef KAB_EMBEDDED
926 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 958 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
927 if ( !b || !b->save() ) { 959 if ( !b || !b->save() ) {
928 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 960 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
929 } 961 }
930#else //KAB_EMBEDDED 962#else //KAB_EMBEDDED
931 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 963 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
932 if ( !b || !b->save() ) { 964 if ( !b || !b->save() ) {
933 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 965 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
934 } 966 }
935#endif //KAB_EMBEDDED 967#endif //KAB_EMBEDDED
936 968
937 statusMessage(i18n("Addressbook saved!")); 969 statusMessage(i18n("Addressbook saved!"));
938 setModified( false ); 970 setModified( false );
939} 971}
940 972
941void KABCore::statusMessage(QString mess , int time ) 973void KABCore::statusMessage(QString mess , int time )
942{ 974{
943 //topLevelWidget()->setCaption( mess ); 975 //topLevelWidget()->setCaption( mess );
944 // pending setting timer to revome message 976 // pending setting timer to revome message
945} 977}
946void KABCore::undo() 978void KABCore::undo()
947{ 979{
948 UndoStack::instance()->undo(); 980 UndoStack::instance()->undo();
949 981
950 // Refresh the view 982 // Refresh the view
951 mViewManager->refreshView(); 983 mViewManager->refreshView();
952} 984}
953 985
954void KABCore::redo() 986void KABCore::redo()
955{ 987{
956 RedoStack::instance()->redo(); 988 RedoStack::instance()->redo();
957 989
958 // Refresh the view 990 // Refresh the view
959 mViewManager->refreshView(); 991 mViewManager->refreshView();
960} 992}
961 993
962void KABCore::setJumpButtonBarVisible( bool visible ) 994void KABCore::setJumpButtonBarVisible( bool visible )
963{ 995{
964 if ( visible ) 996 if ( visible )
965 mJumpButtonBar->show(); 997 mJumpButtonBar->show();
966 else 998 else
967 mJumpButtonBar->hide(); 999 mJumpButtonBar->hide();
968} 1000}
969void KABCore::setDetailsToState() 1001void KABCore::setDetailsToState()
970{ 1002{
971 setDetailsVisible( mActionDetails->isChecked() ); 1003 setDetailsVisible( mActionDetails->isChecked() );
972} 1004}
973 1005
974void KABCore::setDetailsVisible( bool visible ) 1006void KABCore::setDetailsVisible( bool visible )
975{ 1007{
976 if ( visible ) 1008 if ( visible )
977 mDetails->show(); 1009 mDetails->show();
978 else 1010 else
979 mDetails->hide(); 1011 mDetails->hide();
980} 1012}
981 1013
982void KABCore::extensionModified( const KABC::Addressee::List &list ) 1014void KABCore::extensionModified( const KABC::Addressee::List &list )
983{ 1015{
984 1016
985 if ( list.count() != 0 ) { 1017 if ( list.count() != 0 ) {
986 KABC::Addressee::List::ConstIterator it; 1018 KABC::Addressee::List::ConstIterator it;
987 for ( it = list.begin(); it != list.end(); ++it ) 1019 for ( it = list.begin(); it != list.end(); ++it )
988 mAddressBook->insertAddressee( *it ); 1020 mAddressBook->insertAddressee( *it );
989 if ( list.count() > 1 ) 1021 if ( list.count() > 1 )
990 setModified(); 1022 setModified();
991 else 1023 else
992 setModifiedWOrefresh(); 1024 setModifiedWOrefresh();
993 } 1025 }
994 if ( list.count() == 0 ) 1026 if ( list.count() == 0 )
995 mViewManager->refreshView(); 1027 mViewManager->refreshView();
996 else 1028 else
997 mViewManager->refreshView( list[ 0 ].uid() ); 1029 mViewManager->refreshView( list[ 0 ].uid() );
998 1030
999 1031
1000 1032
1001} 1033}
1002 1034
1003QString KABCore::getNameByPhone( const QString &phone ) 1035QString KABCore::getNameByPhone( const QString &phone )
1004{ 1036{
1005#ifndef KAB_EMBEDDED 1037#ifndef KAB_EMBEDDED
1006 QRegExp r( "[/*/-/ ]" ); 1038 QRegExp r( "[/*/-/ ]" );
1007 QString localPhone( phone ); 1039 QString localPhone( phone );
1008 1040
1009 bool found = false; 1041 bool found = false;
1010 QString ownerName = ""; 1042 QString ownerName = "";
1011 KABC::AddressBook::Iterator iter; 1043 KABC::AddressBook::Iterator iter;
1012 KABC::PhoneNumber::List::Iterator phoneIter; 1044 KABC::PhoneNumber::List::Iterator phoneIter;
1013 KABC::PhoneNumber::List phoneList; 1045 KABC::PhoneNumber::List phoneList;
1014 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1046 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1015 phoneList = (*iter).phoneNumbers(); 1047 phoneList = (*iter).phoneNumbers();
1016 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1048 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1017 ++phoneIter) { 1049 ++phoneIter) {
1018 // Get rid of separator chars so just the numbers are compared. 1050 // Get rid of separator chars so just the numbers are compared.
1019 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1051 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1020 ownerName = (*iter).formattedName(); 1052 ownerName = (*iter).formattedName();
1021 found = true; 1053 found = true;
1022 } 1054 }
1023 } 1055 }
1024 } 1056 }
1025 1057
1026 return ownerName; 1058 return ownerName;
1027#else //KAB_EMBEDDED 1059#else //KAB_EMBEDDED
1028 qDebug("KABCore::getNameByPhone finsih method"); 1060 qDebug("KABCore::getNameByPhone finsih method");
1029 return ""; 1061 return "";
1030#endif //KAB_EMBEDDED 1062#endif //KAB_EMBEDDED
1031 1063
1032} 1064}
1033 1065
1034void KABCore::openConfigDialog() 1066void KABCore::openConfigDialog()
1035{ 1067{
1036 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1068 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1037 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1069 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1038 ConfigureDialog->addModule(kabcfg ); 1070 ConfigureDialog->addModule(kabcfg );
1039 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1071 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1040 this, SLOT( configurationChanged() ) ); 1072 this, SLOT( configurationChanged() ) );
1041 connect( ConfigureDialog, SIGNAL( okClicked() ), 1073 connect( ConfigureDialog, SIGNAL( okClicked() ),
1042 this, SLOT( configurationChanged() ) ); 1074 this, SLOT( configurationChanged() ) );
1043 saveSettings(); 1075 saveSettings();
1044 ConfigureDialog->showMaximized(); 1076 ConfigureDialog->showMaximized();
1045 if ( ConfigureDialog->exec() ) 1077 if ( ConfigureDialog->exec() )
1046 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") ); 1078 KMessageBox::information( this, i18n("If you configured \nExtensions,\nplease restart!\n") );
1047 delete ConfigureDialog; 1079 delete ConfigureDialog;
1048} 1080}
1049 1081
1050void KABCore::openLDAPDialog() 1082void KABCore::openLDAPDialog()
1051{ 1083{
1052#ifndef KAB_EMBEDDED 1084#ifndef KAB_EMBEDDED
1053 if ( !mLdapSearchDialog ) { 1085 if ( !mLdapSearchDialog ) {
1054 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1086 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1055 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1087 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1056 SLOT( refreshView() ) ); 1088 SLOT( refreshView() ) );
1057 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1089 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1058 SLOT( setModified() ) ); 1090 SLOT( setModified() ) );
1059 } else 1091 } else
1060 mLdapSearchDialog->restoreSettings(); 1092 mLdapSearchDialog->restoreSettings();
1061 1093
1062 if ( mLdapSearchDialog->isOK() ) 1094 if ( mLdapSearchDialog->isOK() )
1063 mLdapSearchDialog->exec(); 1095 mLdapSearchDialog->exec();
1064#else //KAB_EMBEDDED 1096#else //KAB_EMBEDDED
1065 qDebug("KABCore::openLDAPDialog() finsih method"); 1097 qDebug("KABCore::openLDAPDialog() finsih method");
1066#endif //KAB_EMBEDDED 1098#endif //KAB_EMBEDDED
1067} 1099}
1068 1100
1069void KABCore::print() 1101void KABCore::print()
1070{ 1102{
1071#ifndef KAB_EMBEDDED 1103#ifndef KAB_EMBEDDED
1072 KPrinter printer; 1104 KPrinter printer;
1073 if ( !printer.setup( this ) ) 1105 if ( !printer.setup( this ) )
1074 return; 1106 return;
1075 1107
1076 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1108 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1077 mViewManager->selectedUids(), this ); 1109 mViewManager->selectedUids(), this );
1078 1110
1079 wizard.exec(); 1111 wizard.exec();
1080#else //KAB_EMBEDDED 1112#else //KAB_EMBEDDED
1081 qDebug("KABCore::print() finsih method"); 1113 qDebug("KABCore::print() finsih method");
1082#endif //KAB_EMBEDDED 1114#endif //KAB_EMBEDDED
1083 1115
1084} 1116}
1085 1117
1086 1118
1087void KABCore::addGUIClient( KXMLGUIClient *client ) 1119void KABCore::addGUIClient( KXMLGUIClient *client )
1088{ 1120{
1089 if ( mGUIClient ) 1121 if ( mGUIClient )
1090 mGUIClient->insertChildClient( client ); 1122 mGUIClient->insertChildClient( client );
1091 else 1123 else
1092 KMessageBox::error( this, "no KXMLGUICLient"); 1124 KMessageBox::error( this, "no KXMLGUICLient");
1093} 1125}
1094 1126
1095 1127
1096void KABCore::configurationChanged() 1128void KABCore::configurationChanged()
1097{ 1129{
1098 mExtensionManager->reconfigure(); 1130 mExtensionManager->reconfigure();
1099} 1131}
1100 1132
1101void KABCore::addressBookChanged() 1133void KABCore::addressBookChanged()
1102{ 1134{
1103/*US 1135/*US
1104 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1136 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1105 while ( it.current() ) { 1137 while ( it.current() ) {
1106 if ( it.current()->dirty() ) { 1138 if ( it.current()->dirty() ) {
1107 QString text = i18n( "Data has been changed externally. Unsaved " 1139 QString text = i18n( "Data has been changed externally. Unsaved "
1108 "changes will be lost." ); 1140 "changes will be lost." );
1109 KMessageBox::information( this, text ); 1141 KMessageBox::information( this, text );
1110 } 1142 }
1111 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1143 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1112 ++it; 1144 ++it;
1113 } 1145 }
1114*/ 1146*/
1115 if (mEditorDialog) 1147 if (mEditorDialog)
1116 { 1148 {
1117 if (mEditorDialog->dirty()) 1149 if (mEditorDialog->dirty())
1118 { 1150 {
1119 QString text = i18n( "Data has been changed externally. Unsaved " 1151 QString text = i18n( "Data has been changed externally. Unsaved "
1120 "changes will be lost." ); 1152 "changes will be lost." );
1121 KMessageBox::information( this, text ); 1153 KMessageBox::information( this, text );
1122 } 1154 }
1123 QString currentuid = mEditorDialog->addressee().uid(); 1155 QString currentuid = mEditorDialog->addressee().uid();
1124 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1156 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1125 } 1157 }
1126 mViewManager->refreshView(); 1158 mViewManager->refreshView();
1127// mDetails->refreshView(); 1159// mDetails->refreshView();
1128 1160
1129 1161
1130} 1162}
1131 1163
1132AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1164AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1133 const char *name ) 1165 const char *name )
1134{ 1166{
1135 1167
1136 if ( mEditorDialog == 0 ) { 1168 if ( mEditorDialog == 0 ) {
1137 mEditorDialog = new AddresseeEditorDialog( this, parent, 1169 mEditorDialog = new AddresseeEditorDialog( this, parent,
1138 name ? name : "editorDialog" ); 1170 name ? name : "editorDialog" );
1139 1171
1140 1172
1141 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1173 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1142 SLOT( contactModified( const KABC::Addressee& ) ) ); 1174 SLOT( contactModified( const KABC::Addressee& ) ) );
1143 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1175 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1144 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1176 // SLOT( slotEditorDestroyed( const QString& ) ) );
1145 } 1177 }
1146 1178
1147 return mEditorDialog; 1179 return mEditorDialog;
1148} 1180}
1149 1181
1150void KABCore::slotEditorDestroyed( const QString &uid ) 1182void KABCore::slotEditorDestroyed( const QString &uid )
1151{ 1183{
1152 //mEditorDict.remove( uid ); 1184 //mEditorDict.remove( uid );
1153} 1185}
1154 1186
1155void KABCore::initGUI() 1187void KABCore::initGUI()
1156{ 1188{
1157#ifndef KAB_EMBEDDED 1189#ifndef KAB_EMBEDDED
1158 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1190 QHBoxLayout *topLayout = new QHBoxLayout( this );
1159 topLayout->setSpacing( KDialogBase::spacingHint() ); 1191 topLayout->setSpacing( KDialogBase::spacingHint() );
1160 1192
1161 mExtensionBarSplitter = new QSplitter( this ); 1193 mExtensionBarSplitter = new QSplitter( this );
1162 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1194 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1163 1195
1164 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1196 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1165 1197
1166 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1198 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1167 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1199 mIncSearchWidget = new IncSearchWidget( viewSpace );
1168 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1200 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1169 SLOT( incrementalSearch( const QString& ) ) ); 1201 SLOT( incrementalSearch( const QString& ) ) );
1170 1202
1171 mViewManager = new ViewManager( this, viewSpace ); 1203 mViewManager = new ViewManager( this, viewSpace );
1172 viewSpace->setStretchFactor( mViewManager, 1 ); 1204 viewSpace->setStretchFactor( mViewManager, 1 );
1173 1205
1174 mDetails = new ViewContainer( mDetailsSplitter ); 1206 mDetails = new ViewContainer( mDetailsSplitter );
1175 1207
1176 mJumpButtonBar = new JumpButtonBar( this, this ); 1208 mJumpButtonBar = new JumpButtonBar( this, this );
1177 1209
1178 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1210 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1179 1211
1180 topLayout->addWidget( mExtensionBarSplitter ); 1212 topLayout->addWidget( mExtensionBarSplitter );
1181 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1213 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1182 topLayout->addWidget( mJumpButtonBar ); 1214 topLayout->addWidget( mJumpButtonBar );
1183 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1215 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1184 1216
1185 mXXPortManager = new XXPortManager( this, this ); 1217 mXXPortManager = new XXPortManager( this, this );
1186 1218
1187#else //KAB_EMBEDDED 1219#else //KAB_EMBEDDED
1188 //US initialize viewMenu before settingup viewmanager. 1220 //US initialize viewMenu before settingup viewmanager.
1189 // Viewmanager needs this menu to plugin submenues. 1221 // Viewmanager needs this menu to plugin submenues.
1190 viewMenu = new QPopupMenu( this ); 1222 viewMenu = new QPopupMenu( this );
1191 settingsMenu = new QPopupMenu( this ); 1223 settingsMenu = new QPopupMenu( this );
1192 //filterMenu = new QPopupMenu( this ); 1224 //filterMenu = new QPopupMenu( this );
1193 ImportMenu = new QPopupMenu( this ); 1225 ImportMenu = new QPopupMenu( this );
1194 ExportMenu = new QPopupMenu( this ); 1226 ExportMenu = new QPopupMenu( this );
1195 1227
1196 changeMenu= new QPopupMenu( this ); 1228 changeMenu= new QPopupMenu( this );
1197 1229
1198//US since we have no splitter for the embedded system, setup 1230//US since we have no splitter for the embedded system, setup
1199// a layout with two frames. One left and one right. 1231// a layout with two frames. One left and one right.
1200 1232
1201 QBoxLayout *topLayout; 1233 QBoxLayout *topLayout;
1202 1234
1203 // = new QHBoxLayout( this ); 1235 // = new QHBoxLayout( this );
1204// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1236// QBoxLayout *topLayout = (QBoxLayout*)layout();
1205 1237
1206// QWidget *mainBox = new QWidget( this ); 1238// QWidget *mainBox = new QWidget( this );
1207// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1239// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1208 1240
1209#ifdef DESKTOP_VERSION 1241#ifdef DESKTOP_VERSION
1210 topLayout = new QHBoxLayout( this ); 1242 topLayout = new QHBoxLayout( this );
1211 1243
1212 1244
1213 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1245 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1214 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1246 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1215 1247
1216 topLayout->addWidget(mMiniSplitter ); 1248 topLayout->addWidget(mMiniSplitter );
1217 1249
1218 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1250 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1219 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1251 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1220 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1252 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1221 mDetails = new ViewContainer( mMiniSplitter ); 1253 mDetails = new ViewContainer( mMiniSplitter );
1222 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1254 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1223#else 1255#else
1224 if ( QApplication::desktop()->width() > 480 ) { 1256 if ( QApplication::desktop()->width() > 480 ) {
1225 topLayout = new QHBoxLayout( this ); 1257 topLayout = new QHBoxLayout( this );
1226 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1258 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1227 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1259 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1228 } else { 1260 } else {
1229 1261
1230 topLayout = new QHBoxLayout( this ); 1262 topLayout = new QHBoxLayout( this );
1231 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1263 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1232 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1264 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1233 } 1265 }
1234 1266
1235 topLayout->addWidget(mMiniSplitter ); 1267 topLayout->addWidget(mMiniSplitter );
1236 mViewManager = new ViewManager( this, mMiniSplitter ); 1268 mViewManager = new ViewManager( this, mMiniSplitter );
1237 mDetails = new ViewContainer( mMiniSplitter ); 1269 mDetails = new ViewContainer( mMiniSplitter );
1238 1270
1239 1271
1240 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1272 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1241#endif 1273#endif
1242 //eh->hide(); 1274 //eh->hide();
1243 // topLayout->addWidget(mExtensionManager ); 1275 // topLayout->addWidget(mExtensionManager );
1244 1276
1245 1277
1246/*US 1278/*US
1247#ifndef KAB_NOSPLITTER 1279#ifndef KAB_NOSPLITTER
1248 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1280 QHBoxLayout *topLayout = new QHBoxLayout( this );
1249//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1281//US topLayout->setSpacing( KDialogBase::spacingHint() );
1250 topLayout->setSpacing( 10 ); 1282 topLayout->setSpacing( 10 );
1251 1283
1252 mDetailsSplitter = new QSplitter( this ); 1284 mDetailsSplitter = new QSplitter( this );
1253 1285
1254 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1286 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1255 1287
1256 mViewManager = new ViewManager( this, viewSpace ); 1288 mViewManager = new ViewManager( this, viewSpace );
1257 viewSpace->setStretchFactor( mViewManager, 1 ); 1289 viewSpace->setStretchFactor( mViewManager, 1 );
1258 1290
1259 mDetails = new ViewContainer( mDetailsSplitter ); 1291 mDetails = new ViewContainer( mDetailsSplitter );
1260 1292
1261 topLayout->addWidget( mDetailsSplitter ); 1293 topLayout->addWidget( mDetailsSplitter );
1262 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1294 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1263#else //KAB_NOSPLITTER 1295#else //KAB_NOSPLITTER
1264 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1296 QHBoxLayout *topLayout = new QHBoxLayout( this );
1265//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1297//US topLayout->setSpacing( KDialogBase::spacingHint() );
1266 topLayout->setSpacing( 10 ); 1298 topLayout->setSpacing( 10 );
1267 1299
1268// mDetailsSplitter = new QSplitter( this ); 1300// mDetailsSplitter = new QSplitter( this );
1269 1301
1270 QVBox *viewSpace = new QVBox( this ); 1302 QVBox *viewSpace = new QVBox( this );
1271 1303
1272 mViewManager = new ViewManager( this, viewSpace ); 1304 mViewManager = new ViewManager( this, viewSpace );
1273 viewSpace->setStretchFactor( mViewManager, 1 ); 1305 viewSpace->setStretchFactor( mViewManager, 1 );
1274 1306
1275 mDetails = new ViewContainer( this ); 1307 mDetails = new ViewContainer( this );
1276 1308
1277 topLayout->addWidget( viewSpace ); 1309 topLayout->addWidget( viewSpace );
1278// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1310// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1279 topLayout->addWidget( mDetails ); 1311 topLayout->addWidget( mDetails );
1280#endif //KAB_NOSPLITTER 1312#endif //KAB_NOSPLITTER
1281*/ 1313*/
1282 1314
1283 1315
1284#endif //KAB_EMBEDDED 1316#endif //KAB_EMBEDDED
1285 initActions(); 1317 initActions();
1286 1318
1287#ifdef KAB_EMBEDDED 1319#ifdef KAB_EMBEDDED
1288 addActionsManually(); 1320 addActionsManually();
1289 //US make sure the export and import menues are initialized before creating the xxPortManager. 1321 //US make sure the export and import menues are initialized before creating the xxPortManager.
1290 mXXPortManager = new XXPortManager( this, this ); 1322 mXXPortManager = new XXPortManager( this, this );
1291 1323
1292 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1324 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1293 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1325 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1294 // mActionQuit->plug ( mMainWindow->toolBar()); 1326 // mActionQuit->plug ( mMainWindow->toolBar());
1295 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1327 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1296 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1328 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1297 // mIncSearchWidget->hide(); 1329 // mIncSearchWidget->hide();
1298 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1330 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1299 SLOT( incrementalSearch( const QString& ) ) ); 1331 SLOT( incrementalSearch( const QString& ) ) );
1300 1332
1301 1333
1302 mJumpButtonBar = new JumpButtonBar( this, this ); 1334 mJumpButtonBar = new JumpButtonBar( this, this );
1303 1335
1304 topLayout->addWidget( mJumpButtonBar ); 1336 topLayout->addWidget( mJumpButtonBar );
1305//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1337//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1306 1338
1307// mMainWindow->getIconToolBar()->raise(); 1339// mMainWindow->getIconToolBar()->raise();
1308 1340
1309#endif //KAB_EMBEDDED 1341#endif //KAB_EMBEDDED
1310 1342
1311} 1343}
1312void KABCore::initActions() 1344void KABCore::initActions()
1313{ 1345{
1314//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1346//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1315 1347
1316#ifndef KAB_EMBEDDED 1348#ifndef KAB_EMBEDDED
1317 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1349 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1318 SLOT( clipboardDataChanged() ) ); 1350 SLOT( clipboardDataChanged() ) );
1319#endif //KAB_EMBEDDED 1351#endif //KAB_EMBEDDED
1320 1352
1321 // file menu 1353 // file menu
1322 if ( mIsPart ) { 1354 if ( mIsPart ) {
1323 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1355 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1324 SLOT( sendMail() ), actionCollection(), 1356 SLOT( sendMail() ), actionCollection(),
1325 "kaddressbook_mail" ); 1357 "kaddressbook_mail" );
1326 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1358 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1327 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1359 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1328 1360
1329 } else { 1361 } else {
1330 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1362 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1331 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1363 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1332 } 1364 }
1333 1365
1334 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1366 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1335 SLOT( save() ), actionCollection(), "file_sync" ); 1367 SLOT( save() ), actionCollection(), "file_sync" );
1336 1368
1337 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1369 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1338 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1370 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1339 1371
1340 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1372 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1341 this, SLOT( mailVCard() ), 1373 this, SLOT( mailVCard() ),
1342 actionCollection(), "file_mail_vcard"); 1374 actionCollection(), "file_mail_vcard");
1343 1375
1344 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1376 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1345 this, SLOT( editContact2() ), 1377 this, SLOT( editContact2() ),
1346 actionCollection(), "file_properties" ); 1378 actionCollection(), "file_properties" );
1347 1379
1348#ifdef KAB_EMBEDDED 1380#ifdef KAB_EMBEDDED
1349 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1381 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1350 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1382 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1351 mMainWindow, SLOT( exit() ), 1383 mMainWindow, SLOT( exit() ),
1352 actionCollection(), "quit" ); 1384 actionCollection(), "quit" );
1353#endif //KAB_EMBEDDED 1385#endif //KAB_EMBEDDED
1354 1386
1355 // edit menu 1387 // edit menu
1356 if ( mIsPart ) { 1388 if ( mIsPart ) {
1357 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1389 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1358 SLOT( copyContacts() ), actionCollection(), 1390 SLOT( copyContacts() ), actionCollection(),
1359 "kaddressbook_copy" ); 1391 "kaddressbook_copy" );
1360 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1392 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1361 SLOT( cutContacts() ), actionCollection(), 1393 SLOT( cutContacts() ), actionCollection(),
1362 "kaddressbook_cut" ); 1394 "kaddressbook_cut" );
1363 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1395 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1364 SLOT( pasteContacts() ), actionCollection(), 1396 SLOT( pasteContacts() ), actionCollection(),
1365 "kaddressbook_paste" ); 1397 "kaddressbook_paste" );
1366 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1398 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1367 SLOT( selectAllContacts() ), actionCollection(), 1399 SLOT( selectAllContacts() ), actionCollection(),
1368 "kaddressbook_select_all" ); 1400 "kaddressbook_select_all" );
1369 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1401 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1370 SLOT( undo() ), actionCollection(), 1402 SLOT( undo() ), actionCollection(),
1371 "kaddressbook_undo" ); 1403 "kaddressbook_undo" );
1372 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1404 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1373 this, SLOT( redo() ), actionCollection(), 1405 this, SLOT( redo() ), actionCollection(),
1374 "kaddressbook_redo" ); 1406 "kaddressbook_redo" );
1375 } else { 1407 } else {
1376 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1408 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1377 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1409 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1378 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1410 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1379 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1411 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1380 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1412 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1381 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1413 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1382 } 1414 }
1383 1415
1384 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1416 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1385 Key_Delete, this, SLOT( deleteContacts() ), 1417 Key_Delete, this, SLOT( deleteContacts() ),
1386 actionCollection(), "edit_delete" ); 1418 actionCollection(), "edit_delete" );
1387 1419
1388 mActionUndo->setEnabled( false ); 1420 mActionUndo->setEnabled( false );
1389 mActionRedo->setEnabled( false ); 1421 mActionRedo->setEnabled( false );
1390 1422
1391 // settings menu 1423 // settings menu
1392#ifdef KAB_EMBEDDED 1424#ifdef KAB_EMBEDDED
1393//US special menuentry to configure the addressbook resources. On KDE 1425//US special menuentry to configure the addressbook resources. On KDE
1394// you do that through the control center !!! 1426// you do that through the control center !!!
1395 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1427 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1396 SLOT( configureResources() ), actionCollection(), 1428 SLOT( configureResources() ), actionCollection(),
1397 "kaddressbook_configure_resources" ); 1429 "kaddressbook_configure_resources" );
1398#endif //KAB_EMBEDDED 1430#endif //KAB_EMBEDDED
1399 1431
1400 if ( mIsPart ) { 1432 if ( mIsPart ) {
1401 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1433 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1402 SLOT( openConfigDialog() ), actionCollection(), 1434 SLOT( openConfigDialog() ), actionCollection(),
1403 "kaddressbook_configure" ); 1435 "kaddressbook_configure" );
1404 1436
1405 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1437 mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1406 this, SLOT( configureKeyBindings() ), actionCollection(), 1438 this, SLOT( configureKeyBindings() ), actionCollection(),
1407 "kaddressbook_configure_shortcuts" ); 1439 "kaddressbook_configure_shortcuts" );
1408#ifdef KAB_EMBEDDED 1440#ifdef KAB_EMBEDDED
1409 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1441 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1410 mActionConfigureToolbars->setEnabled( false ); 1442 mActionConfigureToolbars->setEnabled( false );
1411#endif //KAB_EMBEDDED 1443#endif //KAB_EMBEDDED
1412 1444
1413 } else { 1445 } else {
1414 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1446 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1415 1447
1416 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1448 mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1417 } 1449 }
1418 1450
1419 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1451 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1420 actionCollection(), "options_show_jump_bar" ); 1452 actionCollection(), "options_show_jump_bar" );
1421 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 1453 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1422 1454
1423 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0, 1455 mActionDetails = new KToggleAction( i18n( "Show Details" ), 0, 0,
1424 actionCollection(), "options_show_details" ); 1456 actionCollection(), "options_show_details" );
1425 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 1457 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1426 1458
1427 // misc 1459 // misc
1428 // only enable LDAP lookup if we can handle the protocol 1460 // only enable LDAP lookup if we can handle the protocol
1429#ifndef KAB_EMBEDDED 1461#ifndef KAB_EMBEDDED
1430 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 1462 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1431 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 1463 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1432 this, SLOT( openLDAPDialog() ), actionCollection(), 1464 this, SLOT( openLDAPDialog() ), actionCollection(),
1433 "ldap_lookup" ); 1465 "ldap_lookup" );
1434 } 1466 }
1435#else //KAB_EMBEDDED 1467#else //KAB_EMBEDDED
1436 //qDebug("KABCore::initActions() LDAP has to be implemented"); 1468 //qDebug("KABCore::initActions() LDAP has to be implemented");
1437#endif //KAB_EMBEDDED 1469#endif //KAB_EMBEDDED
1438 1470
1439 1471
1440 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 1472 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1441 SLOT( setWhoAmI() ), actionCollection(), 1473 SLOT( setWhoAmI() ), actionCollection(),
1442 "set_personal" ); 1474 "set_personal" );
1443 1475
1444 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 1476 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1445 SLOT( setCategories() ), actionCollection(), 1477 SLOT( setCategories() ), actionCollection(),
1446 "edit_set_categories" ); 1478 "edit_set_categories" );
1447 1479
1448 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 1480 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1449 SLOT( removeVoice() ), actionCollection(), 1481 SLOT( removeVoice() ), actionCollection(),
1450 "remove_voice" ); 1482 "remove_voice" );
1451 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this, 1483 mActionImportOL = new KAction( i18n( "Import from OL..." ), 0, this,
1452 SLOT( importFromOL() ), actionCollection(), 1484 SLOT( importFromOL() ), actionCollection(),
1453 "import_OL" ); 1485 "import_OL" );
1454#ifdef KAB_EMBEDDED 1486#ifdef KAB_EMBEDDED
1455 1487
1456 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 1488 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
1457 this, SLOT( createAboutData() ), actionCollection(), 1489 this, SLOT( createAboutData() ), actionCollection(),
1458 "kaddressbook_about_data" ); 1490 "kaddressbook_about_data" );
1459#endif //KAB_EMBEDDED 1491#endif //KAB_EMBEDDED
1460 1492
1461 clipboardDataChanged(); 1493 clipboardDataChanged();
1462 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1494 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1463 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 1495 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
1464} 1496}
1465 1497
1466//US we need this function, to plug all actions into the correct menues. 1498//US we need this function, to plug all actions into the correct menues.
1467// KDE uses a XML format to plug the actions, but we work her without this overhead. 1499// KDE uses a XML format to plug the actions, but we work her without this overhead.
1468void KABCore::addActionsManually() 1500void KABCore::addActionsManually()
1469{ 1501{
1470//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1502//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1471 1503
1472#ifdef KAB_EMBEDDED 1504#ifdef KAB_EMBEDDED
1473 QPopupMenu *fileMenu = new QPopupMenu( this ); 1505 QPopupMenu *fileMenu = new QPopupMenu( this );
1474 QPopupMenu *editMenu = new QPopupMenu( this ); 1506 QPopupMenu *editMenu = new QPopupMenu( this );
1475 QPopupMenu *helpMenu = new QPopupMenu( this ); 1507 QPopupMenu *helpMenu = new QPopupMenu( this );
1476 1508
1477 KToolBar* tb = mMainWindow->toolBar(); 1509 KToolBar* tb = mMainWindow->toolBar();
1478 1510
1479#ifdef DESKTOP_VERSION 1511#ifdef DESKTOP_VERSION
1480 QMenuBar* mb = mMainWindow->menuBar(); 1512 QMenuBar* mb = mMainWindow->menuBar();
1481 1513
1482 //US setup menubar. 1514 //US setup menubar.
1483 //Disable the following block if you do not want to have a menubar. 1515 //Disable the following block if you do not want to have a menubar.
1484 mb->insertItem( "&File", fileMenu ); 1516 mb->insertItem( "&File", fileMenu );
1485 mb->insertItem( "&Edit", editMenu ); 1517 mb->insertItem( "&Edit", editMenu );
1486 mb->insertItem( "&View", viewMenu ); 1518 mb->insertItem( "&View", viewMenu );
1487 mb->insertItem( "&Settings", settingsMenu ); 1519 mb->insertItem( "&Settings", settingsMenu );
1488 mb->insertItem( "&Change selected", changeMenu ); 1520 mb->insertItem( "&Change selected", changeMenu );
1489 mb->insertItem( "&Help", helpMenu ); 1521 mb->insertItem( "&Help", helpMenu );
1490 mIncSearchWidget = new IncSearchWidget( tb ); 1522 mIncSearchWidget = new IncSearchWidget( tb );
1491 // tb->insertWidget(-1, 0, mIncSearchWidget); 1523 // tb->insertWidget(-1, 0, mIncSearchWidget);
1492 1524
1493#else 1525#else
1494 //US setup toolbar 1526 //US setup toolbar
1495 QMenuBar *menuBarTB = new QMenuBar( tb ); 1527 QMenuBar *menuBarTB = new QMenuBar( tb );
1496 QPopupMenu *popupBarTB = new QPopupMenu( this ); 1528 QPopupMenu *popupBarTB = new QPopupMenu( this );
1497 menuBarTB->insertItem( "ME", popupBarTB); 1529 menuBarTB->insertItem( "ME", popupBarTB);
1498 tb->insertWidget(-1, 0, menuBarTB); 1530 tb->insertWidget(-1, 0, menuBarTB);
1499 mIncSearchWidget = new IncSearchWidget( tb ); 1531 mIncSearchWidget = new IncSearchWidget( tb );
1500 1532
1501 tb->enableMoving(false); 1533 tb->enableMoving(false);
1502 popupBarTB->insertItem( "&File", fileMenu ); 1534 popupBarTB->insertItem( "&File", fileMenu );
1503 popupBarTB->insertItem( "&Edit", editMenu ); 1535 popupBarTB->insertItem( "&Edit", editMenu );
1504 popupBarTB->insertItem( "&View", viewMenu ); 1536 popupBarTB->insertItem( "&View", viewMenu );
1505 popupBarTB->insertItem( "&Settings", settingsMenu ); 1537 popupBarTB->insertItem( "&Settings", settingsMenu );
1506 mViewManager->getFilterAction()->plug ( popupBarTB); 1538 mViewManager->getFilterAction()->plug ( popupBarTB);
1507 popupBarTB->insertItem( "&Change selected", changeMenu ); 1539 popupBarTB->insertItem( "&Change selected", changeMenu );
1508 popupBarTB->insertItem( "&Help", helpMenu ); 1540 popupBarTB->insertItem( "&Help", helpMenu );
1509 if (QApplication::desktop()->width() > 320 ) { 1541 if (QApplication::desktop()->width() > 320 ) {
1510 // mViewManager->getFilterAction()->plug ( tb); 1542 // mViewManager->getFilterAction()->plug ( tb);
1511 } 1543 }
1512#endif 1544#endif
1513 // mActionQuit->plug ( mMainWindow->toolBar()); 1545 // mActionQuit->plug ( mMainWindow->toolBar());
1514 1546
1515 1547
1516 1548
1517 //US Now connect the actions with the menue entries. 1549 //US Now connect the actions with the menue entries.
1518 mActionPrint->plug( fileMenu ); 1550 mActionPrint->plug( fileMenu );
1519 mActionMail->plug( fileMenu ); 1551 mActionMail->plug( fileMenu );
1520 fileMenu->insertSeparator(); 1552 fileMenu->insertSeparator();
1521 1553
1522 mActionNewContact->plug( fileMenu ); 1554 mActionNewContact->plug( fileMenu );
1523 mActionNewContact->plug( tb ); 1555 mActionNewContact->plug( tb );
1524 1556
1525 mActionEditAddressee->plug( fileMenu ); 1557 mActionEditAddressee->plug( fileMenu );
1526 fileMenu->insertSeparator(); 1558 fileMenu->insertSeparator();
1527 mActionSave->plug( fileMenu ); 1559 mActionSave->plug( fileMenu );
1528 fileMenu->insertItem( "&Import", ImportMenu ); 1560 fileMenu->insertItem( "&Import", ImportMenu );
1529 fileMenu->insertItem( "&Emport", ExportMenu ); 1561 fileMenu->insertItem( "&Emport", ExportMenu );
1530 fileMenu->insertSeparator(); 1562 fileMenu->insertSeparator();
1531 mActionMailVCard->plug( fileMenu ); 1563 mActionMailVCard->plug( fileMenu );
1532 fileMenu->insertSeparator(); 1564 fileMenu->insertSeparator();
1533 mActionQuit->plug( fileMenu ); 1565 mActionQuit->plug( fileMenu );
1534#ifdef _WIN32_ 1566#ifdef _WIN32_
1535 mActionImportOL->plug( ImportMenu ); 1567 mActionImportOL->plug( ImportMenu );
1536#endif 1568#endif
1537 // edit menu 1569 // edit menu
1538 mActionUndo->plug( editMenu ); 1570 mActionUndo->plug( editMenu );
1539 mActionRedo->plug( editMenu ); 1571 mActionRedo->plug( editMenu );
1540 editMenu->insertSeparator(); 1572 editMenu->insertSeparator();
1541 mActionCut->plug( editMenu ); 1573 mActionCut->plug( editMenu );
1542 mActionCopy->plug( editMenu ); 1574 mActionCopy->plug( editMenu );
1543 mActionPaste->plug( editMenu ); 1575 mActionPaste->plug( editMenu );
1544 mActionDelete->plug( editMenu ); 1576 mActionDelete->plug( editMenu );
1545 editMenu->insertSeparator(); 1577 editMenu->insertSeparator();
1546 mActionSelectAll->plug( editMenu ); 1578 mActionSelectAll->plug( editMenu );
1547 1579
1548 mActionRemoveVoice->plug( changeMenu ); 1580 mActionRemoveVoice->plug( changeMenu );
1549 // settings menu 1581 // settings menu
1550//US special menuentry to configure the addressbook resources. On KDE 1582//US special menuentry to configure the addressbook resources. On KDE
1551// you do that through the control center !!! 1583// you do that through the control center !!!
1552 mActionConfigResources->plug( settingsMenu ); 1584 mActionConfigResources->plug( settingsMenu );
1553 settingsMenu->insertSeparator(); 1585 settingsMenu->insertSeparator();
1554 1586
1555 mActionConfigKAddressbook->plug( settingsMenu ); 1587 mActionConfigKAddressbook->plug( settingsMenu );
1556 1588
1557 if ( mIsPart ) { 1589 if ( mIsPart ) {
1558 mActionConfigShortcuts->plug( settingsMenu ); 1590 mActionConfigShortcuts->plug( settingsMenu );
1559 mActionConfigureToolbars->plug( settingsMenu ); 1591 mActionConfigureToolbars->plug( settingsMenu );
1560 1592
1561 } else { 1593 } else {
1562 mActionKeyBindings->plug( settingsMenu ); 1594 mActionKeyBindings->plug( settingsMenu );
1563 } 1595 }
1564 1596
1565 settingsMenu->insertSeparator(); 1597 settingsMenu->insertSeparator();
1566 1598
1567 mActionJumpBar->plug( settingsMenu ); 1599 mActionJumpBar->plug( settingsMenu );
1568 mActionDetails->plug( settingsMenu ); 1600 mActionDetails->plug( settingsMenu );
1569 settingsMenu->insertSeparator(); 1601 settingsMenu->insertSeparator();
1570 1602
1571 mActionWhoAmI->plug( settingsMenu ); 1603 mActionWhoAmI->plug( settingsMenu );
1572 mActionCategories->plug( settingsMenu ); 1604 mActionCategories->plug( settingsMenu );
1573 1605
1574 mActionAboutKAddressbook->plug( helpMenu ); 1606 mActionAboutKAddressbook->plug( helpMenu );
1575 1607
1576 1608
1577 if (QApplication::desktop()->width() > 320 ) { 1609 if (QApplication::desktop()->width() > 320 ) {
1578 1610
1579 mActionEditAddressee->plug( tb ); 1611 mActionEditAddressee->plug( tb );
1580 mActionSave->plug( tb ); 1612 mActionSave->plug( tb );
1581 mViewManager->getFilterAction()->plug ( tb); 1613 mViewManager->getFilterAction()->plug ( tb);
1582 if (QApplication::desktop()->width() > 480 ) { 1614 if (QApplication::desktop()->width() > 480 ) {
1583 mActionUndo->plug( tb ); 1615 mActionUndo->plug( tb );
1584 mActionDelete->plug( tb ); 1616 mActionDelete->plug( tb );
1585 mActionRedo->plug( tb ); 1617 mActionRedo->plug( tb );
1586 } 1618 }
1587 } 1619 }
1588 //mActionQuit->plug ( tb ); 1620 //mActionQuit->plug ( tb );
1589 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 1621 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
1590 1622
1591 //US link the searchwidget first to this. 1623 //US link the searchwidget first to this.
1592 // The real linkage to the toolbar happens later. 1624 // The real linkage to the toolbar happens later.
1593//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 1625//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
1594//US tb->insertItem( mIncSearchWidget ); 1626//US tb->insertItem( mIncSearchWidget );
1595/*US 1627/*US
1596 mIncSearchWidget = new IncSearchWidget( tb ); 1628 mIncSearchWidget = new IncSearchWidget( tb );
1597 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1629 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1598 SLOT( incrementalSearch( const QString& ) ) ); 1630 SLOT( incrementalSearch( const QString& ) ) );
1599 1631
1600 mJumpButtonBar = new JumpButtonBar( this, this ); 1632 mJumpButtonBar = new JumpButtonBar( this, this );
1601 1633
1602//US topLayout->addWidget( mJumpButtonBar ); 1634//US topLayout->addWidget( mJumpButtonBar );
1603 this->layout()->add( mJumpButtonBar ); 1635 this->layout()->add( mJumpButtonBar );
1604*/ 1636*/
1605 1637
1606#endif //KAB_EMBEDDED 1638#endif //KAB_EMBEDDED
1607} 1639}
1608void KABCore::removeVoice() 1640void KABCore::removeVoice()
1609{ 1641{
1610 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No ) 1642 if ( KMessageBox::questionYesNo( this, i18n("After importing, phone numbers\nmay have two or more types.\n(E.g. work+voice)\nThese numbers are shown as \"other\".\nClick Yes to remove the voice type\nfrom numbers with more than one type.\n\nRemove voice type?") ) == KMessageBox::No )
1611 return; 1643 return;
1612 KABC::Addressee::List list = mViewManager->selectedAddressees(); 1644 KABC::Addressee::List list = mViewManager->selectedAddressees();
1613 KABC::Addressee::List::Iterator it; 1645 KABC::Addressee::List::Iterator it;
1614 for ( it = list.begin(); it != list.end(); ++it ) { 1646 for ( it = list.begin(); it != list.end(); ++it ) {
1615 PhoneNumber::List phoneNumbers = (*it).phoneNumbers(); 1647 PhoneNumber::List phoneNumbers = (*it).phoneNumbers();
1616 PhoneNumber::List::Iterator phoneIt; 1648 PhoneNumber::List::Iterator phoneIt;
1617 bool found = false; 1649 bool found = false;
1618 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) { 1650 for ( phoneIt = phoneNumbers.begin(); phoneIt != phoneNumbers.end(); ++phoneIt ) {
1619 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found 1651 if ( (*phoneIt).type() & PhoneNumber::Voice) { // voice found
1620 if ((*phoneIt).type() - PhoneNumber::Voice ) { 1652 if ((*phoneIt).type() - PhoneNumber::Voice ) {
1621 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice ); 1653 (*phoneIt).setType((*phoneIt).type() - PhoneNumber::Voice );
1622 (*it).insertPhoneNumber( (*phoneIt) ); 1654 (*it).insertPhoneNumber( (*phoneIt) );
1623 found = true; 1655 found = true;
1624 } 1656 }
1625 } 1657 }
1626 1658
1627 } 1659 }
1628 if ( found ) 1660 if ( found )
1629 contactModified((*it) ); 1661 contactModified((*it) );
1630 } 1662 }
1631} 1663}
1632 1664
1633 1665
1634 1666
1635void KABCore::clipboardDataChanged() 1667void KABCore::clipboardDataChanged()
1636{ 1668{
1637 1669
1638 if ( mReadWrite ) 1670 if ( mReadWrite )
1639 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 1671 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
1640 1672
1641} 1673}
1642 1674
1643void KABCore::updateActionMenu() 1675void KABCore::updateActionMenu()
1644{ 1676{
1645 UndoStack *undo = UndoStack::instance(); 1677 UndoStack *undo = UndoStack::instance();
1646 RedoStack *redo = RedoStack::instance(); 1678 RedoStack *redo = RedoStack::instance();
1647 1679
1648 if ( undo->isEmpty() ) 1680 if ( undo->isEmpty() )
1649 mActionUndo->setText( i18n( "Undo" ) ); 1681 mActionUndo->setText( i18n( "Undo" ) );
1650 else 1682 else
1651 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 1683 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
1652 1684
1653 mActionUndo->setEnabled( !undo->isEmpty() ); 1685 mActionUndo->setEnabled( !undo->isEmpty() );
1654 1686
1655 if ( !redo->top() ) 1687 if ( !redo->top() )
1656 mActionRedo->setText( i18n( "Redo" ) ); 1688 mActionRedo->setText( i18n( "Redo" ) );
1657 else 1689 else
1658 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 1690 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
1659 1691
1660 mActionRedo->setEnabled( !redo->isEmpty() ); 1692 mActionRedo->setEnabled( !redo->isEmpty() );
1661} 1693}
1662 1694
1663void KABCore::configureKeyBindings() 1695void KABCore::configureKeyBindings()
1664{ 1696{
1665#ifndef KAB_EMBEDDED 1697#ifndef KAB_EMBEDDED
1666 KKeyDialog::configure( actionCollection(), true ); 1698 KKeyDialog::configure( actionCollection(), true );
1667#else //KAB_EMBEDDED 1699#else //KAB_EMBEDDED
1668 qDebug("KABCore::configureKeyBindings() not implemented"); 1700 qDebug("KABCore::configureKeyBindings() not implemented");
1669#endif //KAB_EMBEDDED 1701#endif //KAB_EMBEDDED
1670} 1702}
1671 1703
1672#ifdef KAB_EMBEDDED 1704#ifdef KAB_EMBEDDED
1673void KABCore::configureResources() 1705void KABCore::configureResources()
1674{ 1706{
1675 KRES::KCMKResources dlg( this, "" , 0 ); 1707 KRES::KCMKResources dlg( this, "" , 0 );
1676 1708
1677 if ( !dlg.exec() ) 1709 if ( !dlg.exec() )
1678 return; 1710 return;
1679 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 1711 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
1680} 1712}
1681#endif //KAB_EMBEDDED 1713#endif //KAB_EMBEDDED
1682 1714
1683 1715
1684 1716
1685#ifndef KAB_EMBEDDED 1717#ifndef KAB_EMBEDDED
1686#include "kabcore.moc" 1718#include "kabcore.moc"
1687#endif //KAB_EMBEDDED 1719#endif //KAB_EMBEDDED
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 5b3b1ab..8bd4b15 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,127 +1,130 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,false); 50 addItemBool("AskForQuit",&mAskForQuit,false);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 addItemInt( "EmailChannelType", &mEmailClient, OMPI );
54 addItemString( "EmailChannelOther", &mEmailChannel, "" );
55
53#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
54 57
55 KPrefs::setCurrentGroup( "MainWindow" ); 58 KPrefs::setCurrentGroup( "MainWindow" );
56 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
57 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
58 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
59 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 62 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
60 63
61 KPrefs::setCurrentGroup( "Extensions_General" ); 64 KPrefs::setCurrentGroup( "Extensions_General" );
62 QStringList defaultExtensions; 65 QStringList defaultExtensions;
63 defaultExtensions << "merge"; 66 defaultExtensions << "merge";
64 defaultExtensions << "distribution_list_editor"; 67 defaultExtensions << "distribution_list_editor";
65 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 68 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
66 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 69 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
67 70
68 KPrefs::setCurrentGroup( "Views" ); 71 KPrefs::setCurrentGroup( "Views" );
69 QString defaultView = i18n( "Default Table View" ); 72 QString defaultView = i18n( "Default Table View" );
70 addItemString( "CurrentView", &mCurrentView, defaultView ); 73 addItemString( "CurrentView", &mCurrentView, defaultView );
71 addItemStringList( "ViewNames", &mViewNames, defaultView ); 74 addItemStringList( "ViewNames", &mViewNames, defaultView );
72 75
73 KPrefs::setCurrentGroup( "Filters" ); 76 KPrefs::setCurrentGroup( "Filters" );
74 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 77 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
75 78
76} 79}
77 80
78KABPrefs::~KABPrefs() 81KABPrefs::~KABPrefs()
79{ 82{
80} 83}
81 84
82KABPrefs *KABPrefs::instance() 85KABPrefs *KABPrefs::instance()
83{ 86{
84 if ( !sInstance ) { 87 if ( !sInstance ) {
85#ifdef KAB_EMBEDDED 88#ifdef KAB_EMBEDDED
86 sInstance = staticDeleter.setObject( new KABPrefs() ); 89 sInstance = staticDeleter.setObject( new KABPrefs() );
87#else //KAB_EMBEDDED 90#else //KAB_EMBEDDED
88 //US the following line has changed ???. Why 91 //US the following line has changed ???. Why
89 staticDeleter.setObject( sInstance, new KABPrefs() ); 92 staticDeleter.setObject( sInstance, new KABPrefs() );
90#endif //KAB_EMBEDDED 93#endif //KAB_EMBEDDED
91 sInstance->readConfig(); 94 sInstance->readConfig();
92 } 95 }
93 96
94 return sInstance; 97 return sInstance;
95} 98}
96 99
97void KABPrefs::setCategoryDefaults() 100void KABPrefs::setCategoryDefaults()
98{ 101{
99 mCustomCategories.clear(); 102 mCustomCategories.clear();
100 103
101 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 104 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
102 << i18n( "Customer" ) << i18n( "Friend" ); 105 << i18n( "Customer" ) << i18n( "Friend" );
103} 106}
104 107
105 // US introduce a nonconst way to return the config object. 108 // US introduce a nonconst way to return the config object.
106KConfig* KABPrefs::getConfig() 109KConfig* KABPrefs::getConfig()
107{ 110{
108 return config(); 111 return config();
109} 112}
110 113
111 114
112/*US 115/*US
113void KABPrefs::usrSetDefaults() 116void KABPrefs::usrSetDefaults()
114{ 117{
115 KPimPrefs::usrSetDefaults(); 118 KPimPrefs::usrSetDefaults();
116} 119}
117 120
118void KABPrefs::usrReadConfig() 121void KABPrefs::usrReadConfig()
119{ 122{
120 KPimPrefs::usrReadConfig(); 123 KPimPrefs::usrReadConfig();
121} 124}
122 125
123void KABPrefs::usrWriteConfig() 126void KABPrefs::usrWriteConfig()
124{ 127{
125 KPimPrefs::usrWriteConfig(); 128 KPimPrefs::usrWriteConfig();
126} 129}
127*/ 130*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 370fc5b..c81a9a9 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,88 +1,100 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
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#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#include <libkdepim/kpimprefs.h> 29#include <libkdepim/kpimprefs.h>
30 30
31class KConfig; 31class KConfig;
32 32
33class KABPrefs : public KPimPrefs 33class KABPrefs : public KPimPrefs
34{ 34{
35 public: 35 public:
36 virtual ~KABPrefs(); 36 virtual ~KABPrefs();
37 37
38 static KABPrefs *instance(); 38 static KABPrefs *instance();
39 39
40 enum EMailClients {
41 OMPI = 0,
42 QTOPIA = 1,
43 OPIE = 2,
44 OTHER = 3
45 };
46
47
40 // General 48 // General
41 bool mHonorSingleClick; 49 bool mHonorSingleClick;
42 bool mAutomaticNameParsing; 50 bool mAutomaticNameParsing;
43 int mCurrentIncSearchField; 51 int mCurrentIncSearchField;
44 52
45#ifdef KAB_EMBEDDED 53#ifdef KAB_EMBEDDED
46 // US introduce a nonconst way to return the config object. 54 // US introduce a nonconst way to return the config object.
47 KConfig* getConfig(); 55 KConfig* getConfig();
48 56
49 bool mToolBarHor; 57 bool mToolBarHor;
50 bool mToolBarUp; 58 bool mToolBarUp;
51 bool mAskForQuit; 59 bool mAskForQuit;
60
61 int mEmailClient;
62 QString mEmailChannel;
63
52 /** Set preferences to default values */ 64 /** Set preferences to default values */
53// void usrSetDefaults(); 65// void usrSetDefaults();
54 66
55 /** Read preferences from config file */ 67 /** Read preferences from config file */
56// void usrReadConfig(); 68// void usrReadConfig();
57 69
58 /** Write preferences to config file */ 70 /** Write preferences to config file */
59// void usrWriteConfig(); 71// void usrWriteConfig();
60#endif //KAB_EMBEDDED 72#endif //KAB_EMBEDDED
61 73
62 74
63 // GUI 75 // GUI
64 bool mJumpButtonBarVisible; 76 bool mJumpButtonBarVisible;
65 bool mDetailsPageVisible; 77 bool mDetailsPageVisible;
66 QValueList<int> mExtensionsSplitter; 78 QValueList<int> mExtensionsSplitter;
67 QValueList<int> mDetailsSplitter; 79 QValueList<int> mDetailsSplitter;
68 80
69 // Extensions stuff 81 // Extensions stuff
70 int mCurrentExtension; 82 int mCurrentExtension;
71 QStringList mActiveExtensions; 83 QStringList mActiveExtensions;
72 84
73 // Views stuff 85 // Views stuff
74 QString mCurrentView; 86 QString mCurrentView;
75 QStringList mViewNames; 87 QStringList mViewNames;
76 88
77 // Filter 89 // Filter
78 int mCurrentFilter; 90 int mCurrentFilter;
79 91
80 void setCategoryDefaults(); 92 void setCategoryDefaults();
81 93
82 private: 94 private:
83 KABPrefs(); 95 KABPrefs();
84 96
85 static KABPrefs *sInstance; 97 static KABPrefs *sInstance;
86}; 98};
87 99
88#endif 100#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 38c7946..1bac26f 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,363 +1,470 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h>
31#include <qlineedit.h>
32#include <qlabel.h>
33#include <qfile.h>
30 34
31#include <kconfig.h> 35#include <kconfig.h>
32#include <kdebug.h> 36#include <kdebug.h>
33#include <kdialog.h> 37#include <kdialog.h>
34#include <klistview.h> 38#include <klistview.h>
35#include <klocale.h> 39#include <klocale.h>
36#include <kglobal.h> 40#include <kglobal.h>
37#include <kmessagebox.h> 41#include <kmessagebox.h>
38#include <kstandarddirs.h> 42#include <kstandarddirs.h>
39 43
40#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
41#include <ktrader.h> 45#include <ktrader.h>
42#else // KAB_EMBEDDED 46#else // KAB_EMBEDDED
43#include <mergewidget.h> 47#include <mergewidget.h>
44#include <distributionlistwidget.h> 48#include <distributionlistwidget.h>
45#endif // KAB_EMBEDDED 49#endif // KAB_EMBEDDED
46 50
47#include "addresseewidget.h" 51#include "addresseewidget.h"
48#include "extensionconfigdialog.h" 52#include "extensionconfigdialog.h"
49#include "extensionwidget.h" 53#include "extensionwidget.h"
50#include "kabprefs.h" 54#include "kabprefs.h"
51 55
52#include "kabconfigwidget.h" 56#include "kabconfigwidget.h"
53 57
54class ExtensionItem : public QCheckListItem 58class ExtensionItem : public QCheckListItem
55{ 59{
56 public: 60 public:
57 61
58#ifndef KAB_EMBEDDED 62#ifndef KAB_EMBEDDED
59 ExtensionItem( QListView *parent, const QString &text ); 63 ExtensionItem( QListView *parent, const QString &text );
60 void setService( const KService::Ptr &ptr ); 64 void setService( const KService::Ptr &ptr );
61#else //KAB_EMBEDDED 65#else //KAB_EMBEDDED
62 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 66 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
63 void setFactory( ExtensionFactory* fac ); 67 void setFactory( ExtensionFactory* fac );
64#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
65 69
66 bool configWidgetAvailable() const; 70 bool configWidgetAvailable() const;
67 ExtensionFactory *factory() const; 71 ExtensionFactory *factory() const;
68 72
69 virtual QString text( int column ) const; 73 virtual QString text( int column ) const;
70 74
71 private: 75 private:
72#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
73 KService::Ptr mPtr; 77 KService::Ptr mPtr;
74#else //KAB_EMBEDDED 78#else //KAB_EMBEDDED
75 ExtensionFactory* mFactory; 79 ExtensionFactory* mFactory;
76 QString mName; 80 QString mName;
77 QString mComment; 81 QString mComment;
78 82
79#endif //KAB_EMBEDDED 83#endif //KAB_EMBEDDED
80 84
81}; 85};
82 86
83KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
84 : QWidget( parent, name ) 88 : QWidget( parent, name )
85{ 89{
86 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
87 KDialog::spacingHint() ); 91 KDialog::spacingHint() );
88 92
89 QTabWidget *tabWidget = new QTabWidget( this ); 93 QTabWidget *tabWidget = new QTabWidget( this );
90 topLayout->addWidget( tabWidget ); 94 topLayout->addWidget( tabWidget );
91 95
92 // General page 96 // General page
93 QWidget *generalPage = new QWidget( this ); 97 QWidget *generalPage = new QWidget( this );
94 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
95 KDialog::spacingHintSmall() ); 99 KDialog::spacingHintSmall() );
96 100 //general groupbox
97 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); 101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
98 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); 102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
99 boxLayout->setAlignment( Qt::AlignTop ); 103 boxLayout->setAlignment( Qt::AlignTop );
100 boxLayout->setMargin(KDialog::marginHintSmall() ); 104 boxLayout->setMargin(KDialog::marginHintSmall() );
101 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; 105 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
102 groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); 106 groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
103 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 107 boxLayout->setSpacing( KDialog::spacingHintSmall() );
104 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); 108 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
105 boxLayout->addWidget( mViewsSingleClickBox ); 109 boxLayout->addWidget( mViewsSingleClickBox );
106 110
107 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); 111 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
108 boxLayout->addWidget( mNameParsing ); 112 boxLayout->addWidget( mNameParsing );
109 113
110 layout->addWidget( groupBox ); 114 layout->addWidget( groupBox );
111 115
116
117 //extensions groupbox
118
112 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); 119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage );
113 boxLayout = new QVBoxLayout( groupBox->layout() ); 120 boxLayout = new QVBoxLayout( groupBox->layout() );
114 boxLayout->setAlignment( Qt::AlignTop ); 121 boxLayout->setAlignment( Qt::AlignTop );
115 boxLayout->setMargin(KDialog::marginHintSmall()); 122 boxLayout->setMargin(KDialog::marginHintSmall());
116 boxLayout->setSpacing(KDialog::spacingHintSmall()); 123 boxLayout->setSpacing(KDialog::spacingHintSmall());
117 groupBox->layout()->setMargin(1) ; 124 groupBox->layout()->setMargin(1) ;
118 groupBox->layout()->setSpacing(0); 125 groupBox->layout()->setSpacing(0);
119 mExtensionView = new KListView( groupBox ); 126 mExtensionView = new KListView( groupBox );
120 mExtensionView->setAllColumnsShowFocus( true ); 127 mExtensionView->setAllColumnsShowFocus( true );
121 mExtensionView->addColumn( i18n( "Name" ) ); 128 mExtensionView->addColumn( i18n( "Name" ) );
122 mExtensionView->addColumn( i18n( "Description" ) ); 129 mExtensionView->addColumn( i18n( "Description" ) );
123 mExtensionView->setMaximumHeight(80); 130 mExtensionView->setMaximumHeight(80);
124 131
125 boxLayout->addWidget( mExtensionView ); 132 boxLayout->addWidget( mExtensionView );
126 133
127 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 134 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
128 mConfigureButton->setEnabled( false ); 135 mConfigureButton->setEnabled( false );
129 boxLayout->addWidget( mConfigureButton ); 136 boxLayout->addWidget( mConfigureButton );
130 137
131 layout->addWidget( groupBox ); 138 layout->addWidget( groupBox );
132 139
133 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 140 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
134 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 141 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
135 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 142 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
136 SLOT( selectionChanged( QListViewItem* ) ) ); 143 SLOT( selectionChanged( QListViewItem* ) ) );
137 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 144 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
138 SLOT( itemClicked( QListViewItem* ) ) ); 145 SLOT( itemClicked( QListViewItem* ) ) );
139 connect( mConfigureButton, SIGNAL( clicked() ), 146 connect( mConfigureButton, SIGNAL( clicked() ),
140 SLOT( configureExtension() ) ); 147 SLOT( configureExtension() ) );
141 148
142 tabWidget->addTab( generalPage, i18n( "General" ) ); 149 tabWidget->addTab( generalPage, i18n( "General" ) );
143 150
144 // Addressee page 151 // Addressee page
145 mAddresseeWidget = new AddresseeWidget( this ); 152 mAddresseeWidget = new AddresseeWidget( this );
146 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 153 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
147 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 154 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
155
156 // mailclient page
157 QWidget *mailclientPage = new QWidget( this );
158 layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(),
159 KDialog::spacingHintSmall() );
160
161 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage );
162 boxLayout = new QVBoxLayout( groupBox->layout() );
163 boxLayout->setAlignment( Qt::AlignTop );
164// boxLayout->setMargin(KDialog::marginHintSmall() );
165// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
166// groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
167// boxLayout->setSpacing( KDialog::spacingHintSmall() );
168
169 mEmailClient = new QComboBox( groupBox );
170 mEmailClient->insertItem( i18n("OM/Pi"), KABPrefs::OMPI );
171 mEmailClient->insertItem( i18n("Qtopia mail"), KABPrefs::QTOPIA );
172 mEmailClient->insertItem( i18n("Opie mail"), KABPrefs::OPIE );
173 mEmailClient->insertItem( i18n("Other"), KABPrefs::OTHER );
174 boxLayout->addWidget( mEmailClient );
175
176 connect( mEmailClient, SIGNAL( activated( int ) ),
177 this, SLOT (emailclient_changed( int ) ) );
178
179 QLabel* lab = new QLabel( i18n("Channel:"), groupBox);
180 boxLayout->addWidget( lab );
181 mEmailChannel = new QLineEdit(groupBox);
182 mEmailChannel->setReadOnly(true);
183 boxLayout->addWidget( mEmailChannel );
184
185 layout->addWidget( groupBox );
186 tabWidget->addTab( mailclientPage, i18n( "Mail" ) );
187
188
189
148} 190}
149 191
192
193
194void KABConfigWidget::emailclient_changed( int newClient )
195{
196 if (newClient == KABPrefs::OTHER)
197 mEmailChannel->setReadOnly(false);
198 else
199 mEmailChannel->setReadOnly(true);
200
201 QString opiepath = QString::fromLatin1( getenv("OPIEDIR") );
202 QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") );
203
204 if (opiepath.isEmpty())
205 opiepath = qtopiapath;
206
207 QString text = mEmailChannel->text();
208
209 if (newClient == KABPrefs::OPIE)
210 {
211 if ( QFile::exists( opiepath + "/bin/opiemail" ))
212 text = "QPE/Application/opiemail";
213 else
214 text = "FILENOTFOUND: " + opiepath + "/bin/opiemail";
215 }
216 else if (newClient == KABPrefs::QTOPIA)
217 {
218 if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
219 text = "QPE/Application/qtmail";
220 else
221 text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail";
222
223 }
224 else if (newClient == KABPrefs::OMPI)
225 {
226 if ( QFile::exists( qtopiapath + "/bin/ompi" ))
227 text = "QPE/Application/ompi";
228 else if ( QFile::exists( opiepath + "/bin/ompi" ))
229 text = "QPE/Application/ompi";
230 else
231 text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi";
232
233 }
234 else
235 {
236 //do nothing if we choosed other
237 }
238
239 mEmailChannel->setText( text );
240
241
242}
243
244
150void KABConfigWidget::restoreSettings() 245void KABConfigWidget::restoreSettings()
151{ 246{
152 bool blocked = signalsBlocked(); 247 bool blocked = signalsBlocked();
153 blockSignals( true ); 248 blockSignals( true );
154 249
155 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); 250 mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing );
156 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); 251 mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick );
252
253 mEmailChannel->setText( KABPrefs::instance()->mEmailChannel );
254 mEmailClient->setCurrentItem(KABPrefs::instance()->mEmailClient);
255
157 mAddresseeWidget->restoreSettings(); 256 mAddresseeWidget->restoreSettings();
158 257
159 restoreExtensionSettings(); 258 restoreExtensionSettings();
160 259
161 blockSignals( blocked ); 260 blockSignals( blocked );
162 261
163 emit changed( false ); 262 emit changed( false );
164} 263}
165 264
166void KABConfigWidget::saveSettings() 265void KABConfigWidget::saveSettings()
167{ 266{
168 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); 267 KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked();
169 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 268 KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked();
269
270 KABPrefs::instance()->mEmailClient = mEmailClient->currentItem();
271 KABPrefs::instance()->mEmailChannel = mEmailChannel->text();
272
170 mAddresseeWidget->saveSettings(); 273 mAddresseeWidget->saveSettings();
171 274
172 saveExtensionSettings(); 275 saveExtensionSettings();
173 KABPrefs::instance()->writeConfig(); 276 KABPrefs::instance()->writeConfig();
174 277
175 emit changed( false ); 278 emit changed( false );
176} 279}
177 280
178void KABConfigWidget::defaults() 281void KABConfigWidget::defaults()
179{ 282{
180 mNameParsing->setChecked( true ); 283 mNameParsing->setChecked( true );
181 mViewsSingleClickBox->setChecked( false ); 284 mViewsSingleClickBox->setChecked( false );
182 285
286 mEmailClient->setCurrentItem(KABPrefs::OMPI);
287 emailclient_changed( KABPrefs::OMPI );
288
289
183 emit changed( true ); 290 emit changed( true );
184} 291}
185 292
186void KABConfigWidget::modified() 293void KABConfigWidget::modified()
187{ 294{
188 emit changed( true ); 295 emit changed( true );
189} 296}
190 297
191void KABConfigWidget::restoreExtensionSettings() 298void KABConfigWidget::restoreExtensionSettings()
192{ 299{
193 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 300 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
194 301
195 mExtensionView->clear(); 302 mExtensionView->clear();
196 303
197#ifndef KAB_EMBEDDED 304#ifndef KAB_EMBEDDED
198 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 305 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
199 KTrader::OfferList::ConstIterator it; 306 KTrader::OfferList::ConstIterator it;
200 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 307 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
201 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 308 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
202 continue; 309 continue;
203 310
204 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 311 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
205 item->setService( *it ); 312 item->setService( *it );
206 if ( activeExtensions.contains( item->factory()->identifier() ) ) 313 if ( activeExtensions.contains( item->factory()->identifier() ) )
207 item->setOn( true ); 314 item->setOn( true );
208 } 315 }
209#else //KAB_EMBEDDED 316#else //KAB_EMBEDDED
210 ExtensionFactory *extensionFactory = new MergeFactory(); 317 ExtensionFactory *extensionFactory = new MergeFactory();
211 318
212 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 319 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
213 320
214 item->setFactory( extensionFactory ); 321 item->setFactory( extensionFactory );
215 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 322 if ( activeExtensions.contains( extensionFactory->identifier() ) )
216 item->setOn( true ); 323 item->setOn( true );
217
218 324
219 325
326
220 extensionFactory = new DistributionListFactory(); 327 extensionFactory = new DistributionListFactory();
221 328
222 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 329 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
223 330
224 item->setFactory( extensionFactory ); 331 item->setFactory( extensionFactory );
225 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 332 if ( activeExtensions.contains( extensionFactory->identifier() ) )
226 item->setOn( true ); 333 item->setOn( true );
227 334
228 335
229#endif //KAB_EMBEDDED 336#endif //KAB_EMBEDDED
230 337
231} 338}
232 339
233void KABConfigWidget::saveExtensionSettings() 340void KABConfigWidget::saveExtensionSettings()
234{ 341{
235 QStringList activeExtensions; 342 QStringList activeExtensions;
236 343
237 QPtrList<QListViewItem> list; 344 QPtrList<QListViewItem> list;
238 QListViewItemIterator it( mExtensionView ); 345 QListViewItemIterator it( mExtensionView );
239 while ( it.current() ) { 346 while ( it.current() ) {
240 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 347 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
241 if ( item ) { 348 if ( item ) {
242 if ( item->isOn() ) 349 if ( item->isOn() )
243 activeExtensions.append( item->factory()->identifier() ); 350 activeExtensions.append( item->factory()->identifier() );
244 } 351 }
245 ++it; 352 ++it;
246 } 353 }
247 354
248 KABPrefs::instance()->mActiveExtensions = activeExtensions; 355 KABPrefs::instance()->mActiveExtensions = activeExtensions;
249} 356}
250 357
251void KABConfigWidget::configureExtension() 358void KABConfigWidget::configureExtension()
252{ 359{
253 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 360 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
254 if ( !item ) 361 if ( !item )
255 return; 362 return;
256 363
257#ifndef KAB_EMBEDDED 364#ifndef KAB_EMBEDDED
258 KConfig config( "kaddressbookrc" ); 365 KConfig config( "kaddressbookrc" );
259#else //KAB_EMBEDDED 366#else //KAB_EMBEDDED
260 KConfig config( locateLocal("config", "kaddressbookrc") ); 367 KConfig config( locateLocal("config", "kaddressbookrc") );
261#endif //KAB_EMBEDDED 368#endif //KAB_EMBEDDED
262 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 369 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
263 370
264 ExtensionConfigDialog dlg( item->factory(), &config, this ); 371 ExtensionConfigDialog dlg( item->factory(), &config, this );
265 dlg.exec(); 372 dlg.exec();
266 373
267 config.sync(); 374 config.sync();
268} 375}
269 376
270void KABConfigWidget::selectionChanged( QListViewItem *i ) 377void KABConfigWidget::selectionChanged( QListViewItem *i )
271{ 378{
272 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 379 ExtensionItem *item = static_cast<ExtensionItem*>( i );
273 if ( !item ) 380 if ( !item )
274 return; 381 return;
275 382
276 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 383 mConfigureButton->setEnabled( item->configWidgetAvailable() );
277} 384}
278 385
279void KABConfigWidget::itemClicked( QListViewItem *item ) 386void KABConfigWidget::itemClicked( QListViewItem *item )
280{ 387{
281 if ( item != 0 ) 388 if ( item != 0 )
282 modified(); 389 modified();
283} 390}
284 391
285#ifndef KAB_EMBEDDED 392#ifndef KAB_EMBEDDED
286ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 393ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
287 : QCheckListItem( parent, text, CheckBox ) 394 : QCheckListItem( parent, text, CheckBox )
288{ 395{
289} 396}
290 397
291void ExtensionItem::setService( const KService::Ptr &ptr ) 398void ExtensionItem::setService( const KService::Ptr &ptr )
292{ 399{
293 mPtr = ptr; 400 mPtr = ptr;
294} 401}
295#else //KAB_EMBEDDED 402#else //KAB_EMBEDDED
296ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 403ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment )
297 : QCheckListItem( parent, text, CheckBox ) 404 : QCheckListItem( parent, text, CheckBox )
298{ 405{
299 mName = name; 406 mName = name;
300 mComment = comment; 407 mComment = comment;
301} 408}
302 409
303 410
304void ExtensionItem::setFactory( ExtensionFactory* fac ) 411void ExtensionItem::setFactory( ExtensionFactory* fac )
305{ 412{
306 mFactory = fac; 413 mFactory = fac;
307} 414}
308#endif //KAB_EMBEDDED 415#endif //KAB_EMBEDDED
309 416
310bool ExtensionItem::configWidgetAvailable() const 417bool ExtensionItem::configWidgetAvailable() const
311{ 418{
312#ifndef KAB_EMBEDDED 419#ifndef KAB_EMBEDDED
313 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 420 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
314 if ( !factory ) 421 if ( !factory )
315 return false; 422 return false;
316 423
317 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 424 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
318 if ( !extensionFactory ) 425 if ( !extensionFactory )
319 return false; 426 return false;
320 427
321 return extensionFactory->configureWidgetAvailable(); 428 return extensionFactory->configureWidgetAvailable();
322#else //KAB_EMBEDDED 429#else //KAB_EMBEDDED
323 return mFactory->configureWidgetAvailable(); 430 return mFactory->configureWidgetAvailable();
324#endif //KAB_EMBEDDED 431#endif //KAB_EMBEDDED
325 432
326} 433}
327 434
328ExtensionFactory *ExtensionItem::factory() const 435ExtensionFactory *ExtensionItem::factory() const
329{ 436{
330#ifndef KAB_EMBEDDED 437#ifndef KAB_EMBEDDED
331 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 438 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
332 if ( !factory ) 439 if ( !factory )
333 return 0; 440 return 0;
334 441
335 return static_cast<ExtensionFactory*>( factory ); 442 return static_cast<ExtensionFactory*>( factory );
336#else //KAB_EMBEDDED 443#else //KAB_EMBEDDED
337 return mFactory; 444 return mFactory;
338#endif //KAB_EMBEDDED 445#endif //KAB_EMBEDDED
339} 446}
340 447
341QString ExtensionItem::text( int column ) const 448QString ExtensionItem::text( int column ) const
342{ 449{
343#ifndef KAB_EMBEDDED 450#ifndef KAB_EMBEDDED
344 if ( column == 0 ) 451 if ( column == 0 )
345 return mPtr->name(); 452 return mPtr->name();
346 else if ( column == 1 ) 453 else if ( column == 1 )
347 return mPtr->comment(); 454 return mPtr->comment();
348 else 455 else
349 return QString::null; 456 return QString::null;
350#else //KAB_EMBEDDED 457#else //KAB_EMBEDDED
351 if ( column == 0 ) 458 if ( column == 0 )
352 return mName; 459 return mName;
353 else if ( column == 1 ) 460 else if ( column == 1 )
354 return mComment; 461 return mComment;
355 else 462 else
356 return QString::null; 463 return QString::null;
357#endif //KAB_EMBEDDED 464#endif //KAB_EMBEDDED
358} 465}
359 466
360#ifndef KAB_EMBEDDED 467#ifndef KAB_EMBEDDED
361#include "kabconfigwidget.moc" 468#include "kabconfigwidget.moc"
362#endif //KAB_EMBEDDED 469#endif //KAB_EMBEDDED
363 470
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 0f36d9e..9d1363b 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,72 +1,78 @@
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#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32 32class QComboBox;
33class QLineEdit;
33class KListView; 34class KListView;
34 35
35class AddresseeWidget; 36class AddresseeWidget;
36 37
37class KABConfigWidget : public QWidget 38class KABConfigWidget : public QWidget
38{ 39{
39 Q_OBJECT 40 Q_OBJECT
40 41
41 public: 42 public:
42 KABConfigWidget( QWidget *parent, const char *name = 0 ); 43 KABConfigWidget( QWidget *parent, const char *name = 0 );
43 44
44 void restoreSettings(); 45 void restoreSettings();
45 void saveSettings(); 46 void saveSettings();
46 void defaults(); 47 void defaults();
47 48
48 signals: 49 signals:
49 void changed( bool ); 50 void changed( bool );
50 51
51 public slots: 52 public slots:
52 void modified(); 53 void modified();
53 54
55
56
54 private slots: 57 private slots:
55 void configureExtension(); 58 void configureExtension();
56 void selectionChanged( QListViewItem* ); 59 void selectionChanged( QListViewItem* );
57 void itemClicked( QListViewItem* ); 60 void itemClicked( QListViewItem* );
61 void emailclient_changed( int newClient );
58 62
59 private: 63 private:
60 void restoreExtensionSettings(); 64 void restoreExtensionSettings();
61 void saveExtensionSettings(); 65 void saveExtensionSettings();
62 66
63 KListView *mExtensionView; 67 KListView *mExtensionView;
64 68
65 QCheckBox *mNameParsing; 69 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 70 QCheckBox *mViewsSingleClickBox;
67 QPushButton *mConfigureButton; 71 QPushButton *mConfigureButton;
72 QComboBox* mEmailClient;
73 QLineEdit* mEmailChannel;
68 74
69 AddresseeWidget *mAddresseeWidget; 75 AddresseeWidget *mAddresseeWidget;
70}; 76};
71 77
72#endif 78#endif
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp
index c953058..d1f7630 100644
--- a/microkde/kdialogbase.cpp
+++ b/microkde/kdialogbase.cpp
@@ -1,290 +1,289 @@
1#include <qtabwidget.h> 1#include <qtabwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qframe.h> 4#include <qframe.h>
5 5
6 6
7#include "klocale.h" 7#include "klocale.h"
8#include "kdebug.h" 8#include "kdebug.h"
9 9
10#include "kdialogbase.h" 10#include "kdialogbase.h"
11 11
12KDialogBase::KDialogBase() 12KDialogBase::KDialogBase()
13{ 13{
14} 14}
15 15
16KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, 16KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
17 const QString &caption, 17 const QString &caption,
18 int buttonMask, ButtonCode defaultButton, 18 int buttonMask, ButtonCode defaultButton,
19 bool separator, 19 bool separator,
20 const QString &user1, 20 const QString &user1,
21 const QString &user2, 21 const QString &user2,
22 const QString &user3) : 22 const QString &user3) :
23 KDialog( parent, name, modal ) 23 KDialog( parent, name, modal )
24{ 24{
25 init( caption, buttonMask, user1, user2 ); 25 init( caption, buttonMask, user1, user2 );
26 if (findButton( defaultButton ) ) 26 if (findButton( defaultButton ) )
27 (findButton( defaultButton ) )->setFocus(); 27 (findButton( defaultButton ) )->setFocus();
28 28
29} 29}
30 30
31KDialogBase::KDialogBase( int dialogFace, const QString &caption, 31KDialogBase::KDialogBase( int dialogFace, const QString &caption,
32 int buttonMask, ButtonCode defaultButton, 32 int buttonMask, ButtonCode defaultButton,
33 QWidget *parent, const char *name, bool modal, 33 QWidget *parent, const char *name, bool modal,
34 bool separator, 34 bool separator,
35 const QString &user1, 35 const QString &user1,
36 const QString &user2, 36 const QString &user2,
37 const QString &user3) : 37 const QString &user3) :
38 KDialog( parent, name, modal ) 38 KDialog( parent, name, modal )
39{ 39{
40 init( caption, buttonMask, user1, user2 ); 40 init( caption, buttonMask, user1, user2 );
41 if (findButton( defaultButton ) ) 41 if (findButton( defaultButton ) )
42 (findButton( defaultButton ) )->setFocus(); 42 (findButton( defaultButton ) )->setFocus();
43 43
44} 44}
45 45
46KDialogBase::~KDialogBase() 46KDialogBase::~KDialogBase()
47{ 47{
48} 48}
49 49
50void KDialogBase::init( const QString &caption, int buttonMask, 50void KDialogBase::init( const QString &caption, int buttonMask,
51 const QString &user1 ,const QString &user2 ) 51 const QString &user1 ,const QString &user2 )
52{ 52{
53 mMainWidget = 0; 53 mMainWidget = 0;
54 mTabWidget = 0; 54 mTabWidget = 0;
55 mPlainPage = 0; 55 mPlainPage = 0;
56 mTopLayout = 0; 56 mTopLayout = 0;
57 if ( !caption.isEmpty() ) { 57 if ( !caption.isEmpty() ) {
58 setCaption( caption ); 58 setCaption( caption );
59 } 59 }
60 60
61 if ( buttonMask & User1 ) { 61 if ( buttonMask & User1 ) {
62 mUser1Button = new QPushButton( user1, this ); 62 mUser1Button = new QPushButton( user1, this );
63 connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); 63 connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) );
64 } else { 64 } else {
65 mUser1Button = 0; 65 mUser1Button = 0;
66 } 66 }
67 if ( buttonMask & User2 ) { 67 if ( buttonMask & User2 ) {
68 mUser2Button = new QPushButton( user2, this ); 68 mUser2Button = new QPushButton( user2, this );
69 connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); 69 connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) );
70 } else { 70 } else {
71 mUser2Button = 0; 71 mUser2Button = 0;
72 } 72 }
73 73
74 if ( buttonMask & Ok ) { 74 if ( buttonMask & Ok ) {
75 mOkButton = new QPushButton( i18n("Ok"), this ); 75 mOkButton = new QPushButton( i18n("Ok"), this );
76 connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); 76 connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) );
77 } else { 77 } else {
78 mOkButton = 0; 78 mOkButton = 0;
79 } 79 }
80 if ( buttonMask & Default ) { 80 if ( buttonMask & Default ) {
81 qDebug("buttonMask & Default ");
82 mDefaultButton = new QPushButton( i18n("Default"), this ); 81 mDefaultButton = new QPushButton( i18n("Default"), this );
83 connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); 82 connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) );
84 } else { 83 } else {
85 mDefaultButton = 0; 84 mDefaultButton = 0;
86 } 85 }
87 86
88 if ( buttonMask & Apply ) { 87 if ( buttonMask & Apply ) {
89 mApplyButton = new QPushButton( i18n("Apply"), this ); 88 mApplyButton = new QPushButton( i18n("Apply"), this );
90 connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); 89 connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) );
91 } else { 90 } else {
92 mApplyButton = 0; 91 mApplyButton = 0;
93 } 92 }
94 93
95 if ( buttonMask & Cancel ) { 94 if ( buttonMask & Cancel ) {
96 mCancelButton = new QPushButton( i18n("Cancel"), this ); 95 mCancelButton = new QPushButton( i18n("Cancel"), this );
97 connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); 96 connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) );
98 } else { 97 } else {
99 mCancelButton = 0; 98 mCancelButton = 0;
100 } 99 }
101 100
102 if ( buttonMask & Close ) { 101 if ( buttonMask & Close ) {
103 mCloseButton = new QPushButton( i18n("Close"), this ); 102 mCloseButton = new QPushButton( i18n("Close"), this );
104 connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); 103 connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) );
105 } else { 104 } else {
106 mCloseButton = 0; 105 mCloseButton = 0;
107 } 106 }
108} 107}
109 108
110QTabWidget *KDialogBase::tabWidget() 109QTabWidget *KDialogBase::tabWidget()
111{ 110{
112 if ( !mTabWidget ) { 111 if ( !mTabWidget ) {
113 mTabWidget = new QTabWidget( this ); 112 mTabWidget = new QTabWidget( this );
114 setMainWidget( mTabWidget ); 113 setMainWidget( mTabWidget );
115 } 114 }
116 return mTabWidget; 115 return mTabWidget;
117} 116}
118 117
119void KDialogBase::hideButtons() 118void KDialogBase::hideButtons()
120{ 119{
121 if ( mUser1Button ) mUser1Button->hide() ; 120 if ( mUser1Button ) mUser1Button->hide() ;
122 if ( mUser2Button ) mUser2Button->hide() ; 121 if ( mUser2Button ) mUser2Button->hide() ;
123 if ( mOkButton ) mOkButton->hide() ; 122 if ( mOkButton ) mOkButton->hide() ;
124 if ( mApplyButton ) mApplyButton->hide() ; 123 if ( mApplyButton ) mApplyButton->hide() ;
125 if ( mDefaultButton ) mDefaultButton->hide(); 124 if ( mDefaultButton ) mDefaultButton->hide();
126 if ( mCancelButton ) mCancelButton->hide() ; 125 if ( mCancelButton ) mCancelButton->hide() ;
127 if ( mCloseButton ) mCloseButton->hide() ; 126 if ( mCloseButton ) mCloseButton->hide() ;
128 127
129} 128}
130void KDialogBase::initLayout() 129void KDialogBase::initLayout()
131{ 130{
132 131
133 delete mTopLayout; 132 delete mTopLayout;
134 mTopLayout = new QVBoxLayout( this ); 133 mTopLayout = new QVBoxLayout( this );
135 mTopLayout->setMargin( marginHint() ); 134 mTopLayout->setMargin( marginHint() );
136 mTopLayout->setSpacing( spacingHint() ); 135 mTopLayout->setSpacing( spacingHint() );
137 136
138 mTopLayout->addWidget( mMainWidget ); 137 mTopLayout->addWidget( mMainWidget );
139 138
140 QBoxLayout *buttonLayout = new QHBoxLayout; 139 QBoxLayout *buttonLayout = new QHBoxLayout;
141 mTopLayout->addLayout( buttonLayout ); 140 mTopLayout->addLayout( buttonLayout );
142 141
143 if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); 142 if ( mUser1Button ) buttonLayout->addWidget( mUser1Button );
144 if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); 143 if ( mUser2Button ) buttonLayout->addWidget( mUser2Button );
145 if ( mOkButton ) buttonLayout->addWidget( mOkButton ); 144 if ( mOkButton ) buttonLayout->addWidget( mOkButton );
146 if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); 145 if ( mApplyButton ) buttonLayout->addWidget( mApplyButton );
147 if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); 146 if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton );
148 if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); 147 if ( mCancelButton ) buttonLayout->addWidget( mCancelButton );
149 if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); 148 if ( mCloseButton ) buttonLayout->addWidget( mCloseButton );
150} 149}
151 150
152QFrame *KDialogBase::addPage( const QString &name ) 151QFrame *KDialogBase::addPage( const QString &name )
153{ 152{
154// kdDebug() << "KDialogBase::addPage(): " << name << endl; 153// kdDebug() << "KDialogBase::addPage(): " << name << endl;
155 QFrame *frame = new QFrame( tabWidget() ); 154 QFrame *frame = new QFrame( tabWidget() );
156 tabWidget()->addTab( frame, name ); 155 tabWidget()->addTab( frame, name );
157 return frame; 156 return frame;
158} 157}
159 158
160QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) 159QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & )
161{ 160{
162 return addPage( name ); 161 return addPage( name );
163} 162}
164 163
165 164
166void KDialogBase::setMainWidget( QWidget *widget ) 165void KDialogBase::setMainWidget( QWidget *widget )
167{ 166{
168 kdDebug() << "KDialogBase::setMainWidget()" << endl; 167 kdDebug() << "KDialogBase::setMainWidget()" << endl;
169 168
170 mMainWidget = widget; 169 mMainWidget = widget;
171 initLayout(); 170 initLayout();
172} 171}
173 172
174void KDialogBase::setButtonText( ButtonCode id, const QString &text ) 173void KDialogBase::setButtonText( ButtonCode id, const QString &text )
175{ 174{
176 QPushButton *button = findButton( id ); 175 QPushButton *button = findButton( id );
177 if ( button ) { 176 if ( button ) {
178 button->setText( text ); 177 button->setText( text );
179 } 178 }
180} 179}
181 180
182void KDialogBase::enableButton( ButtonCode id, bool state ) 181void KDialogBase::enableButton( ButtonCode id, bool state )
183{ 182{
184 QPushButton *button = findButton( id ); 183 QPushButton *button = findButton( id );
185 if ( button ) { 184 if ( button ) {
186 button->setEnabled( state ); 185 button->setEnabled( state );
187 } 186 }
188} 187}
189 188
190QPushButton *KDialogBase::findButton( ButtonCode id ) 189QPushButton *KDialogBase::findButton( ButtonCode id )
191{ 190{
192 QPushButton *button = 0; 191 QPushButton *button = 0;
193 switch ( id ) { 192 switch ( id ) {
194 case Ok: 193 case Ok:
195 button = mOkButton; 194 button = mOkButton;
196 break; 195 break;
197 case Apply: 196 case Apply:
198 button = mApplyButton; 197 button = mApplyButton;
199 break; 198 break;
200 case User1: 199 case User1:
201 button = mUser1Button; 200 button = mUser1Button;
202 break; 201 break;
203 case User2: 202 case User2:
204 button = mUser2Button; 203 button = mUser2Button;
205 break; 204 break;
206 case Cancel: 205 case Cancel:
207 button = mCancelButton; 206 button = mCancelButton;
208 break; 207 break;
209 case Default: 208 case Default:
210 button = mDefaultButton; 209 button = mDefaultButton;
211 break; 210 break;
212 case Close: 211 case Close:
213 button = mCloseButton; 212 button = mCloseButton;
214 break; 213 break;
215 default: 214 default:
216 break; 215 break;
217 } 216 }
218 return button; 217 return button;
219} 218}
220 219
221void KDialogBase::enableButtonOK( bool state ) 220void KDialogBase::enableButtonOK( bool state )
222{ 221{
223 enableButton( Ok, state ); 222 enableButton( Ok, state );
224} 223}
225 224
226void KDialogBase::enableButtonApply( bool state ) 225void KDialogBase::enableButtonApply( bool state )
227{ 226{
228 enableButton( Apply, state ); 227 enableButton( Apply, state );
229} 228}
230 229
231void KDialogBase::showButton( ButtonCode id, bool show ) 230void KDialogBase::showButton( ButtonCode id, bool show )
232{ 231{
233 QPushButton *button = findButton( id ); 232 QPushButton *button = findButton( id );
234 if ( button ) { 233 if ( button ) {
235 if ( show ) button->show(); 234 if ( show ) button->show();
236 else button->hide(); 235 else button->hide();
237 } 236 }
238} 237}
239 238
240int KDialogBase::pageIndex( QWidget *widget ) const 239int KDialogBase::pageIndex( QWidget *widget ) const
241{ 240{
242 return 0; 241 return 0;
243} 242}
244 243
245 244
246bool KDialogBase::showPage( int index ) 245bool KDialogBase::showPage( int index )
247{ 246{
248 tabWidget()->setCurrentPage( index );return false; 247 tabWidget()->setCurrentPage( index );return false;
249} 248}
250 249
251QFrame *KDialogBase::plainPage() 250QFrame *KDialogBase::plainPage()
252{ 251{
253 if ( !mPlainPage ) { 252 if ( !mPlainPage ) {
254 mPlainPage = new QFrame( this ); 253 mPlainPage = new QFrame( this );
255 setMainWidget( mPlainPage ); 254 setMainWidget( mPlainPage );
256 } 255 }
257 return mPlainPage; 256 return mPlainPage;
258} 257}
259 258
260void KDialogBase::slotOk() 259void KDialogBase::slotOk()
261{ 260{
262 emit okClicked(); 261 emit okClicked();
263 accept(); 262 accept();
264} 263}
265 264
266void KDialogBase::slotApply() 265void KDialogBase::slotApply()
267{ 266{
268 emit applyClicked(); 267 emit applyClicked();
269} 268}
270 269
271void KDialogBase::slotCancel() 270void KDialogBase::slotCancel()
272{ 271{
273 emit cancelClicked(); 272 emit cancelClicked();
274 reject(); 273 reject();
275} 274}
276 275
277void KDialogBase::slotClose() 276void KDialogBase::slotClose()
278{ 277{
279 emit closeClicked(); 278 emit closeClicked();
280 reject(); 279 reject();
281} 280}
282 281
283void KDialogBase::slotUser1() 282void KDialogBase::slotUser1()
284{ 283{
285 emit user1Clicked(); 284 emit user1Clicked();
286} 285}
287void KDialogBase::slotUser2() 286void KDialogBase::slotUser2()
288{ 287{
289 emit user2Clicked(); 288 emit user2Clicked();
290} 289}
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index 4136622..13be2ce 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -1,201 +1,204 @@
1/* 1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org> 2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> 3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20*/ 20*/
21 21
22#include <qhbox.h> 22#include <qhbox.h>
23#include <qvbox.h> 23#include <qvbox.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kglobal.h> 28#include <kglobal.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include <kiconloader.h> 30#include <kiconloader.h>
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32//US #include <klibloader.h> 32//US #include <klibloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kprocess.h> 34#include <kprocess.h>
35 35
36#include "kcmultidialog.h" 36#include "kcmultidialog.h"
37//US #include "kcmultidialog.moc" 37//US #include "kcmultidialog.moc"
38//US #include "kcmoduleloader.h" 38//US #include "kcmoduleloader.h"
39 39
40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) 40KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, 41 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
42 parent, name, modal, true), d(0L) 42 parent, name, modal, true), d(0L)
43{ 43{
44 enableButton(Apply, false); 44 enableButton(Apply, false);
45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); 45 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
46
47 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
48
46 _baseGroup = baseGroup; 49 _baseGroup = baseGroup;
47 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 50 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
48 setMainWidget(mMainWidget ); 51 setMainWidget(mMainWidget );
49#ifdef DESKTOP_VERSION 52#ifdef DESKTOP_VERSION
50 resize(640,480); 53 resize(640,480);
51#else 54#else
52 resize(640,480); 55 resize(640,480);
53 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); 56 setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
54 //showMaximized(); 57 //showMaximized();
55#endif 58#endif
56 59
57} 60}
58 61
59KCMultiDialog::~KCMultiDialog() 62KCMultiDialog::~KCMultiDialog()
60{ 63{
61//US moduleDict.setAutoDelete(true); 64//US moduleDict.setAutoDelete(true);
62} 65}
63 66
64void KCMultiDialog::slotDefault() 67void KCMultiDialog::slotDefault()
65{ 68{
66 69
67 int curPageIndex = mMainWidget->activePageIndex(); 70 int curPageIndex = mMainWidget->activePageIndex();
68 71
69 QPtrListIterator<KCModule> it(modules); 72 QPtrListIterator<KCModule> it(modules);
70 for (; it.current(); ++it) 73 for (; it.current(); ++it)
71 { 74 {
72 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) 75 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
73 { 76 {
74 (*it)->defaults(); 77 (*it)->defaults();
75 clientChanged(true); 78 clientChanged(true);
76 return; 79 return;
77 } 80 }
78 } 81 }
79 82
80} 83}
81 84
82void KCMultiDialog::slotApply() 85void KCMultiDialog::slotApply()
83{ 86{
84qDebug("KCMultiDialog::slotApply clicked"); 87qDebug("KCMultiDialog::slotApply clicked");
85 88
86 QPtrListIterator<KCModule> it(modules); 89 QPtrListIterator<KCModule> it(modules);
87 for (; it.current(); ++it) 90 for (; it.current(); ++it)
88 (*it)->save(); 91 (*it)->save();
89 clientChanged(false); 92 clientChanged(false);
90 93
91 emit applyClicked(); 94 emit applyClicked();
92 95
93} 96}
94 97
95 98
96void KCMultiDialog::slotOk() 99void KCMultiDialog::slotOk()
97{ 100{
98qDebug("KCMultiDialog::slotOk clicked"); 101qDebug("KCMultiDialog::slotOk clicked");
99 102
100 QPtrListIterator<KCModule> it(modules); 103 QPtrListIterator<KCModule> it(modules);
101 for (; it.current(); ++it) 104 for (; it.current(); ++it)
102 (*it)->save(); 105 (*it)->save();
103 accept(); 106 accept();
104 107
105 emit okClicked(); 108 emit okClicked();
106} 109}
107 110
108void KCMultiDialog::slotHelp() 111void KCMultiDialog::slotHelp()
109{ 112{
110/*US 113/*US
111 KURL url( KURL("help:/"), _docPath ); 114 KURL url( KURL("help:/"), _docPath );
112 115
113 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 116 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
114 KProcess process; 117 KProcess process;
115 process << "khelpcenter" 118 process << "khelpcenter"
116 << url.url(); 119 << url.url();
117 process.start(KProcess::DontCare); 120 process.start(KProcess::DontCare);
118 process.detach(); 121 process.detach();
119 } else { 122 } else {
120 new KRun(url); 123 new KRun(url);
121 } 124 }
122*/ 125*/
123} 126}
124 127
125void KCMultiDialog::clientChanged(bool state) 128void KCMultiDialog::clientChanged(bool state)
126{ 129{
127 enableButton(Apply, state); 130 enableButton(Apply, state);
128} 131}
129 132
130/*US 133/*US
131void KCMultiDialog::addModule(const QString& path, bool withfallback) 134void KCMultiDialog::addModule(const QString& path, bool withfallback)
132{ 135{
133 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 136 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
134 137
135 KCModuleInfo info(path, _baseGroup); 138 KCModuleInfo info(path, _baseGroup);
136 139
137 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 140 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
138 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 141 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
139 if(!page) { 142 if(!page) {
140 KCModuleLoader::unloadModule(info); 143 KCModuleLoader::unloadModule(info);
141 return; 144 return;
142 } 145 }
143 moduleDict.insert(page, new LoadInfo(path, withfallback)); 146 moduleDict.insert(page, new LoadInfo(path, withfallback));
144 if (modules.isEmpty()) 147 if (modules.isEmpty())
145 slotAboutToShow(page); 148 slotAboutToShow(page);
146} 149}
147*/ 150*/
148QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 151QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
149{ 152{
150 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 153 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
151 return page; 154 return page;
152 155
153} 156}
154//US special method for microkde. We dop noty want to load everything dynamically. 157//US special method for microkde. We dop noty want to load everything dynamically.
155void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 158void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
156{ 159{
157 160
158 modules.append(module); 161 modules.append(module);
159 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 162 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
160 163
161 164
162} 165}
163 166
164void KCMultiDialog::slotAboutToShow(QWidget *page) 167void KCMultiDialog::slotAboutToShow(QWidget *page)
165{ 168{
166/*US 169/*US
167 LoadInfo *loadInfo = moduleDict[page]; 170 LoadInfo *loadInfo = moduleDict[page];
168 if (!loadInfo) 171 if (!loadInfo)
169 return; 172 return;
170 173
171 QApplication::setOverrideCursor(Qt::WaitCursor); 174 QApplication::setOverrideCursor(Qt::WaitCursor);
172 175
173 moduleDict.remove(page); 176 moduleDict.remove(page);
174 177
175 KCModuleInfo info(loadInfo->path, _baseGroup); 178 KCModuleInfo info(loadInfo->path, _baseGroup);
176 179
177 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 180 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
178 181
179 if (!module) 182 if (!module)
180 { 183 {
181 QApplication::restoreOverrideCursor(); 184 QApplication::restoreOverrideCursor();
182 KCModuleLoader::showLastLoaderError(this); 185 KCModuleLoader::showLastLoaderError(this);
183 delete loadInfo; 186 delete loadInfo;
184 return; 187 return;
185 } 188 }
186 189
187 module->reparent(page,0,QPoint(0,0),true); 190 module->reparent(page,0,QPoint(0,0),true);
188 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 191 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
189 //setHelp( docpath, QString::null ); 192 //setHelp( docpath, QString::null );
190 _docPath = info.docPath(); 193 _docPath = info.docPath();
191 modules.append(module); 194 modules.append(module);
192 195
193 //KCGlobal::repairAccels( topLevelWidget() ); 196 //KCGlobal::repairAccels( topLevelWidget() );
194 197
195 delete loadInfo; 198 delete loadInfo;
196 199
197 QApplication::restoreOverrideCursor(); 200 QApplication::restoreOverrideCursor();
198*/ 201*/
199 202
200qDebug("KCMultiDialog::slotAboutToShow not implemented"); 203qDebug("KCMultiDialog::slotAboutToShow not implemented");
201} 204}