summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/addresseeeditorwidget.cpp6
-rw-r--r--kaddressbook/extensionmanager.cpp7
-rw-r--r--kaddressbook/filter.cpp21
-rw-r--r--kaddressbook/kabcore.cpp87
-rw-r--r--kaddressbook/kabcore.h3
-rw-r--r--kaddressbook/kabprefs.cpp2
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp11
-rw-r--r--kaddressbook/nameeditdialog.cpp8
8 files changed, 113 insertions, 32 deletions
diff --git a/kaddressbook/addresseeeditorwidget.cpp b/kaddressbook/addresseeeditorwidget.cpp
index 3397e06..c6993e9 100644
--- a/kaddressbook/addresseeeditorwidget.cpp
+++ b/kaddressbook/addresseeeditorwidget.cpp
@@ -1,1346 +1,1348 @@
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#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qtabwidget.h> 30#include <qtabwidget.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#ifndef KAB_EMBEDDED 33#ifndef KAB_EMBEDDED
34#include <qtextedit.h> 34#include <qtextedit.h>
35 35
36#include <kaccelmanager.h> 36#include <kaccelmanager.h>
37#include "keywidget.h" 37#include "keywidget.h"
38#include "soundwidget.h" 38#include "soundwidget.h"
39 39
40#else //KAB_EMBEDDED 40#else //KAB_EMBEDDED
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#endif //KAB_EMBEDDED 42#endif //KAB_EMBEDDED
43 43
44 44
45#include "keywidget.h" 45#include "keywidget.h"
46#include "geowidget.h" 46#include "geowidget.h"
47#include "imagewidget.h" 47#include "imagewidget.h"
48#include "nameeditdialog.h" 48#include "nameeditdialog.h"
49#include "phoneeditwidget.h" 49#include "phoneeditwidget.h"
50#include "secrecywidget.h" 50#include "secrecywidget.h"
51 51
52 52
53#include <qtoolbutton.h> 53#include <qtoolbutton.h>
54#include <qtooltip.h> 54#include <qtooltip.h>
55 55
56#include <kapplication.h> 56#include <kapplication.h>
57#include <kconfig.h> 57#include <kconfig.h>
58#include <kcombobox.h> 58#include <kcombobox.h>
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kdialogbase.h> 60#include <kdialogbase.h>
61#include <kglobal.h> 61#include <kglobal.h>
62#include <kiconloader.h> 62#include <kiconloader.h>
63#include <klineedit.h> 63#include <klineedit.h>
64#include <klocale.h> 64#include <klocale.h>
65#include <kmessagebox.h> 65#include <kmessagebox.h>
66#include <kseparator.h> 66#include <kseparator.h>
67#include <ksqueezedtextlabel.h> 67#include <ksqueezedtextlabel.h>
68 68
69#include <libkdepim/categoryeditdialog.h> 69#include <libkdepim/categoryeditdialog.h>
70#include <libkdepim/categoryselectdialog.h> 70#include <libkdepim/categoryselectdialog.h>
71 71
72#include <libkdepim/kdateedit.h> 72#include <libkdepim/kdateedit.h>
73 73
74#include "addresseditwidget.h" 74#include "addresseditwidget.h"
75#include "emaileditwidget.h" 75#include "emaileditwidget.h"
76#include "kabcore.h" 76#include "kabcore.h"
77#include "kabprefs.h" 77#include "kabprefs.h"
78 78
79#include "addresseeeditorwidget.h" 79#include "addresseeeditorwidget.h"
80 80
81 81
82 82
83AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension, 83AddresseeEditorWidget::AddresseeEditorWidget( KABCore *core, bool isExtension,
84 QWidget *parent, const char *name ) 84 QWidget *parent, const char *name )
85 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ), 85 : ExtensionWidget( core, parent, name ), mIsExtension( isExtension ),
86 mBlockSignals( false ) 86 mBlockSignals( false )
87{ 87{
88 88
89 mAConfig = AddresseeConfig::instance(); 89 mAConfig = AddresseeConfig::instance();
90 90
91 mFormattedNameType = NameEditDialog::CustomName; 91 mFormattedNameType = NameEditDialog::CustomName;
92 initGUI(); 92 initGUI();
93 mCategoryDialog = 0; 93 mCategoryDialog = 0;
94 mCategoryEditDialog = 0; 94 mCategoryEditDialog = 0;
95 95
96 // Load the empty addressee as defaults 96 // Load the empty addressee as defaults
97 load(); 97 load();
98 98
99 mDirty = false; 99 mDirty = false;
100} 100}
101 101
102AddresseeEditorWidget::~AddresseeEditorWidget() 102AddresseeEditorWidget::~AddresseeEditorWidget()
103{ 103{
104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl; 104 kdDebug(5720) << "~AddresseeEditorWidget()" << endl;
105} 105}
106 106
107void AddresseeEditorWidget::contactsSelectionChanged() 107void AddresseeEditorWidget::contactsSelectionChanged()
108{ 108{
109 KABC::Addressee::List list = selectedContacts(); 109 KABC::Addressee::List list = selectedContacts();
110 110
111 mAddressee = list[ 0 ]; 111 mAddressee = list[ 0 ];
112 load(); 112 load();
113} 113}
114 114
115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr ) 115void AddresseeEditorWidget::setAddressee( const KABC::Addressee &addr )
116{ 116{
117 mAddressee = addr; 117 mAddressee = addr;
118 load(); 118 load();
119} 119}
120 120
121const KABC::Addressee &AddresseeEditorWidget::addressee() 121const KABC::Addressee &AddresseeEditorWidget::addressee()
122{ 122{
123 return mAddressee; 123 return mAddressee;
124} 124}
125 125
126void AddresseeEditorWidget::textChanged( const QString& ) 126void AddresseeEditorWidget::textChanged( const QString& )
127{ 127{
128 emitModified(); 128 emitModified();
129} 129}
130 130
131void AddresseeEditorWidget::initGUI() 131void AddresseeEditorWidget::initGUI()
132{ 132{
133 QVBoxLayout *layout = new QVBoxLayout( this ); 133 QVBoxLayout *layout = new QVBoxLayout( this );
134 134
135 mTabWidget = new QTabWidget( this ); 135 mTabWidget = new QTabWidget( this );
136 layout->addWidget( mTabWidget ); 136 layout->addWidget( mTabWidget );
137 137
138 setupTab1(); 138 setupTab1();
139 setupTab1_1(); 139 setupTab1_1();
140 setupTab2(); 140 setupTab2();
141 setupTab2_1(); 141 setupTab2_1();
142 setupTab3(); 142 setupTab3();
143 setupTab3_1(); 143 setupTab3_1();
144 144
145 mNameEdit->setFocus(); 145 mNameEdit->setFocus();
146 146
147 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ), 147 connect( mTabWidget, SIGNAL( currentChanged(QWidget*) ),
148 SLOT( pageChanged(QWidget*) ) ); 148 SLOT( pageChanged(QWidget*) ) );
149} 149}
150 150
151void AddresseeEditorWidget::setupTab1() 151void AddresseeEditorWidget::setupTab1()
152{ 152{
153 // This is the General tab 153 // This is the General tab
154 QWidget *tab1 = new QWidget( mTabWidget ); 154 QWidget *tab1 = new QWidget( mTabWidget );
155 155
156//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 ); 156//US QGridLayout *layout = new QGridLayout( tab1, 11, 7 );
157 QGridLayout *layout = new QGridLayout( tab1, 7, 1 ); 157 QGridLayout *layout = new QGridLayout( tab1, 7, 1 );
158 layout->setMargin( KDialogBase::marginHintSmall() ); 158 layout->setMargin( KDialogBase::marginHintSmall() );
159 layout->setSpacing( KDialogBase::spacingHintSmall() ); 159 layout->setSpacing( KDialogBase::spacingHintSmall() );
160 160
161 QLabel *label; 161 QLabel *label;
162 KSeparator* bar; 162 KSeparator* bar;
163 QPushButton *button; 163 QPushButton *button;
164 164
165 ////////////////////////////////// 165 //////////////////////////////////
166 // Upper left group (person info) 166 // Upper left group (person info)
167 167
168 // Person icon 168 // Person icon
169 /* LR 169 /* LR
170 label = new QLabel( tab1 ); 170 label = new QLabel( tab1 );
171//US ambiguous call. Add one more parameter 171//US ambiguous call. Add one more parameter
172//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 172//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
173 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 173 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
174 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 174 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
175 */ 175 */
176 // First name 176 // First name
177 button = new QPushButton( i18n( "Name..." ), tab1 ); 177 button = new QPushButton( i18n( "Name..." ), tab1 );
178//US QToolTip::add( button, i18n( "Edit the contact's name" ) ); 178//US QToolTip::add( button, i18n( "Edit the contact's name" ) );
179 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 179 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
180 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 180 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
181 SLOT( nameTextChanged( const QString& ) ) ); 181 SLOT( nameTextChanged( const QString& ) ) );
182 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 182 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
183 183
184 mNameLabel = new KSqueezedTextLabel( tab1 ); 184 mNameLabel = new KSqueezedTextLabel( tab1 );
185 mNameLabel->hide(); 185 mNameLabel->hide();
186 186
187 layout->addWidget( button, 0, 0 ); 187 layout->addWidget( button, 0, 0 );
188 layout->addWidget( mNameEdit, 0, 1 ); 188 layout->addWidget( mNameEdit, 0, 1 );
189 layout->addWidget( mNameLabel, 0, 1 ); 189 layout->addWidget( mNameLabel, 0, 1 );
190 190
191 label = new QLabel( i18n( "Role:" ), tab1 ); 191 label = new QLabel( i18n( "Role:" ), tab1 );
192 mRoleEdit = new KLineEdit( tab1 ); 192 mRoleEdit = new KLineEdit( tab1 );
193 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 193 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
194 SLOT( textChanged( const QString& ) ) ); 194 SLOT( textChanged( const QString& ) ) );
195 label->setBuddy( mRoleEdit ); 195 label->setBuddy( mRoleEdit );
196 layout->addWidget( label, 1, 0 ); 196 layout->addWidget( label, 1, 0 );
197 layout->addWidget( mRoleEdit, 1, 1 ); 197 layout->addWidget( mRoleEdit, 1, 1 );
198 198
199 // Organization 199 // Organization
200 label = new QLabel( i18n( "Organization:" ), tab1 ); 200 label = new QLabel( i18n( "Organization:" ), tab1 );
201 mOrgEdit = new KLineEdit( tab1 ); 201 mOrgEdit = new KLineEdit( tab1 );
202 label->setBuddy( mOrgEdit ); 202 label->setBuddy( mOrgEdit );
203 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 203 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
204 SLOT( textChanged( const QString& ) ) ); 204 SLOT( textChanged( const QString& ) ) );
205 layout->addWidget( label, 2, 0 ); 205 layout->addWidget( label, 2, 0 );
206 layout->addWidget( mOrgEdit, 2, 1 ); 206 layout->addWidget( mOrgEdit, 2, 1 );
207 207
208 // File as (formatted name) 208 // File as (formatted name)
209 label = new QLabel( i18n( "Formatted name:" ), tab1 ); 209 label = new QLabel( i18n( "Formatted name:" ), tab1 );
210 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 210 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
211 layout->addWidget( label, 3, 0 ); 211 layout->addWidget( label, 3, 0 );
212 layout->addWidget( mFormattedNameLabel, 3, 1 ); 212 layout->addWidget( mFormattedNameLabel, 3, 1 );
213 /* LR 213 /* LR
214 // Left hand separator. This separator doesn't go all the way 214 // Left hand separator. This separator doesn't go all the way
215 // across so the dialog still flows from top to bottom 215 // across so the dialog still flows from top to bottom
216 bar = new KSeparator( KSeparator::HLine, tab1 ); 216 bar = new KSeparator( KSeparator::HLine, tab1 );
217 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 217 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
218 */ 218 */
219 ////////////////////////////////////// 219 //////////////////////////////////////
220 220
221 /* LR 221 /* LR
222 // Phone numbers (upper right) 222 // Phone numbers (upper right)
223 label = new QLabel( tab1 ); 223 label = new QLabel( tab1 );
224//US loadIcon call is ambiguous. Add one more parameter 224//US loadIcon call is ambiguous. Add one more parameter
225//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 225//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
226 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 226 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
227//US layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 227//US layout->addMultiCellWidget( label, 0, 1, 3, 3 );
228 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 228 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
229 */ 229 */
230 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 230 mPhoneEditWidget = new PhoneEditWidget( tab1 );
231 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 231 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
232//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 232//US layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
233 int iii; 233 int iii;
234#ifndef DESKTOP_VERSION 234#ifndef DESKTOP_VERSION
235 iii = 7; 235 iii = 7;
236#else 236#else
237 iii = 8; 237 iii = 8;
238#endif 238#endif
239 layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 ); 239 layout->addMultiCellWidget( mPhoneEditWidget, 4, iii, 0, 1 );
240 ++iii; 240 ++iii;
241 /* LR 241 /* LR
242 bar = new KSeparator( KSeparator::HLine, tab1 ); 242 bar = new KSeparator( KSeparator::HLine, tab1 );
243//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 243//US layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
244 layout->addMultiCellWidget( bar, 9, 9, 0, 2 ); 244 layout->addMultiCellWidget( bar, 9, 9, 0, 2 );
245 */ 245 */
246/*US 246/*US
247 ////////////////////////////////////// 247 //////////////////////////////////////
248 // Addresses (lower left) 248 // Addresses (lower left)
249 label = new QLabel( tab1 ); 249 label = new QLabel( tab1 );
250//US loadIcon call is ambiguous. Add one more parameter 250//US loadIcon call is ambiguous. Add one more parameter
251//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 251//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
252 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 252 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
253 layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 253 layout->addMultiCellWidget( label, 5, 6, 0, 0 );
254 254
255 mAddressEditWidget = new AddressEditWidget( tab1 ); 255 mAddressEditWidget = new AddressEditWidget( tab1 );
256 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 256 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
257 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 257 layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
258 258
259 ////////////////////////////////////// 259 //////////////////////////////////////
260 // Email / Web (lower right) 260 // Email / Web (lower right)
261 label = new QLabel( tab1 ); 261 label = new QLabel( tab1 );
262//US loadIcon call is ambiguous. Add one more parameter 262//US loadIcon call is ambiguous. Add one more parameter
263//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 263//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
264 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 264 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
265 layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 265 layout->addMultiCellWidget( label, 5, 6, 3, 3 );
266 266
267 mEmailWidget = new EmailEditWidget( tab1 ); 267 mEmailWidget = new EmailEditWidget( tab1 );
268 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 268 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
269 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 269 layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
270 270
271 // add the separator 271 // add the separator
272 bar = new KSeparator( KSeparator::HLine, tab1 ); 272 bar = new KSeparator( KSeparator::HLine, tab1 );
273 layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 273 layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
274 274
275 label = new QLabel( tab1 ); 275 label = new QLabel( tab1 );
276//US loadIcon call is ambiguous. Add one more parameter 276//US loadIcon call is ambiguous. Add one more parameter
277//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 277//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
278 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 278 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
279 layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 279 layout->addMultiCellWidget( label, 8, 9, 3, 3 );
280 280
281 label = new QLabel( i18n( "URL:" ), tab1 ); 281 label = new QLabel( i18n( "URL:" ), tab1 );
282 mURLEdit = new KLineEdit( tab1 ); 282 mURLEdit = new KLineEdit( tab1 );
283 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 283 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
284 SLOT( textChanged( const QString& ) ) ); 284 SLOT( textChanged( const QString& ) ) );
285 label->setBuddy( mURLEdit ); 285 label->setBuddy( mURLEdit );
286 layout->addWidget( label, 8, 4 ); 286 layout->addWidget( label, 8, 4 );
287 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 287 layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
288 288
289 label = new QLabel( i18n( "&IM address:" ), tab1 ); 289 label = new QLabel( i18n( "&IM address:" ), tab1 );
290 mIMAddressEdit = new KLineEdit( tab1 ); 290 mIMAddressEdit = new KLineEdit( tab1 );
291 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 291 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
292 SLOT( textChanged( const QString& ) ) ); 292 SLOT( textChanged( const QString& ) ) );
293 label->setBuddy( mIMAddressEdit ); 293 label->setBuddy( mIMAddressEdit );
294 layout->addWidget( label, 9, 4 ); 294 layout->addWidget( label, 9, 4 );
295 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 295 layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
296 296
297 layout->addColSpacing( 6, 50 ); 297 layout->addColSpacing( 6, 50 );
298 298
299 bar = new KSeparator( KSeparator::HLine, tab1 ); 299 bar = new KSeparator( KSeparator::HLine, tab1 );
300 layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 300 layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
301*/ 301*/
302 /////////////////////////////////////// 302 ///////////////////////////////////////
303 QHBox *categoryBox = new QHBox( tab1 ,"cato"); 303 QHBox *categoryBox = new QHBox( tab1 ,"cato");
304 categoryBox->setSpacing( KDialogBase::spacingHint() ); 304 categoryBox->setSpacing( KDialogBase::spacingHint() );
305 categoryBox->setMargin( KDialogBase::marginHintSmall() ); 305 categoryBox->setMargin( KDialogBase::marginHintSmall() );
306 306
307 // Categories 307 // Categories
308 button = new QPushButton( i18n( "Categories" ), categoryBox ); 308 button = new QPushButton( i18n( "Categories" ), categoryBox );
309 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 309 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
310 310
311 mCategoryEdit = new KLineEdit( categoryBox ); 311 mCategoryEdit = new KLineEdit( categoryBox );
312 mCategoryEdit->setReadOnly( true ); 312 mCategoryEdit->setReadOnly( true );
313 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 313 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
314 SLOT( textChanged( const QString& ) ) ); 314 SLOT( textChanged( const QString& ) ) );
315 315
316 mSecrecyWidget = new SecrecyWidget( categoryBox ); 316 mSecrecyWidget = new SecrecyWidget( categoryBox );
317 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 317 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
318 318
319//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 319//US layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
320 layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 ); 320 layout->addMultiCellWidget( categoryBox, iii, iii, 0, 1 );
321 321
322 // Build the layout and add to the tab widget 322 // Build the layout and add to the tab widget
323 layout->activate(); // required 323 layout->activate(); // required
324 324
325 mTabWidget->addTab( tab1, i18n( "&General" ) ); 325 mTabWidget->addTab( tab1, i18n( "&General" ) );
326} 326}
327 327
328 328
329void AddresseeEditorWidget::setupTab1_1() 329void AddresseeEditorWidget::setupTab1_1()
330{ 330{
331 // This is the Address tab 331 // This is the Address tab
332 QWidget *tab1_1 = new QWidget( mTabWidget ); 332 QWidget *tab1_1 = new QWidget( mTabWidget );
333 333
334//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 ); 334//US QGridLayout *layout = new QGridLayout( tab1_1, 11, 7 );
335 QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 ); 335 QGridLayout *layout = new QGridLayout( tab1_1, 7, 2 );
336 layout->setMargin( KDialogBase::marginHintSmall() ); 336 layout->setMargin( KDialogBase::marginHintSmall() );
337 layout->setSpacing( KDialogBase::spacingHintSmall() ); 337 layout->setSpacing( KDialogBase::spacingHintSmall() );
338 338
339 QLabel *label; 339 QLabel *label;
340 KSeparator* bar; 340 KSeparator* bar;
341 QPushButton *button; 341 QPushButton *button;
342 342
343/*US 343/*US
344 ////////////////////////////////// 344 //////////////////////////////////
345 // Upper left group (person info) 345 // Upper left group (person info)
346 346
347 // Person icon 347 // Person icon
348 label = new QLabel( tab1 ); 348 label = new QLabel( tab1 );
349//US ambiguous call. Add one more parameter 349//US ambiguous call. Add one more parameter
350//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 350//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
351 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 351 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
352 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 352 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
353 353
354 // First name 354 // First name
355 button = new QPushButton( i18n( "Name..." ), tab1 ); 355 button = new QPushButton( i18n( "Name..." ), tab1 );
356 QToolTip::add( button, i18n( "Edit the contact's name" ) ); 356 QToolTip::add( button, i18n( "Edit the contact's name" ) );
357 mNameEdit = new KLineEdit( tab1, "mNameEdit" ); 357 mNameEdit = new KLineEdit( tab1, "mNameEdit" );
358 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 358 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
359 SLOT( nameTextChanged( const QString& ) ) ); 359 SLOT( nameTextChanged( const QString& ) ) );
360 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) ); 360 connect( button, SIGNAL( clicked() ), SLOT( nameButtonClicked() ) );
361 361
362#ifndef KAB_EMBEDDED 362#ifndef KAB_EMBEDDED
363 mNameLabel = new KSqueezedTextLabel( tab1 ); 363 mNameLabel = new KSqueezedTextLabel( tab1 );
364 mNameLabel->hide(); 364 mNameLabel->hide();
365#else //KAB_EMBEDDED 365#else //KAB_EMBEDDED
366qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 366qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
367#endif //KAB_EMBEDDED 367#endif //KAB_EMBEDDED
368 368
369 layout->addWidget( button, 0, 1 ); 369 layout->addWidget( button, 0, 1 );
370 layout->addWidget( mNameEdit, 0, 2 ); 370 layout->addWidget( mNameEdit, 0, 2 );
371 371
372#ifndef KAB_EMBEDDED 372#ifndef KAB_EMBEDDED
373 layout->addWidget( mNameLabel, 0, 2 ); 373 layout->addWidget( mNameLabel, 0, 2 );
374#else //KAB_EMBEDDED 374#else //KAB_EMBEDDED
375qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 375qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
376#endif //KAB_EMBEDDED 376#endif //KAB_EMBEDDED
377 377
378 label = new QLabel( i18n( "Role:" ), tab1 ); 378 label = new QLabel( i18n( "Role:" ), tab1 );
379 mRoleEdit = new KLineEdit( tab1 ); 379 mRoleEdit = new KLineEdit( tab1 );
380 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ), 380 connect( mRoleEdit, SIGNAL( textChanged( const QString& ) ),
381 SLOT( textChanged( const QString& ) ) ); 381 SLOT( textChanged( const QString& ) ) );
382 label->setBuddy( mRoleEdit ); 382 label->setBuddy( mRoleEdit );
383 layout->addWidget( label, 1, 1 ); 383 layout->addWidget( label, 1, 1 );
384 layout->addWidget( mRoleEdit, 1, 2 ); 384 layout->addWidget( mRoleEdit, 1, 2 );
385 385
386 // Organization 386 // Organization
387 label = new QLabel( i18n( "Organization:" ), tab1 ); 387 label = new QLabel( i18n( "Organization:" ), tab1 );
388 mOrgEdit = new KLineEdit( tab1 ); 388 mOrgEdit = new KLineEdit( tab1 );
389 label->setBuddy( mOrgEdit ); 389 label->setBuddy( mOrgEdit );
390 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ), 390 connect( mOrgEdit, SIGNAL( textChanged( const QString& ) ),
391 SLOT( textChanged( const QString& ) ) ); 391 SLOT( textChanged( const QString& ) ) );
392 layout->addWidget( label, 2, 1 ); 392 layout->addWidget( label, 2, 1 );
393 layout->addWidget( mOrgEdit, 2, 2 ); 393 layout->addWidget( mOrgEdit, 2, 2 );
394 394
395 // File as (formatted name) 395 // File as (formatted name)
396 label = new QLabel( i18n( "Formatted name:" ), tab1 ); 396 label = new QLabel( i18n( "Formatted name:" ), tab1 );
397#ifndef KAB_EMBEDDED 397#ifndef KAB_EMBEDDED
398 mFormattedNameLabel = new KSqueezedTextLabel( tab1 ); 398 mFormattedNameLabel = new KSqueezedTextLabel( tab1 );
399#else //KAB_EMBEDDED 399#else //KAB_EMBEDDED
400qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 400qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
401#endif //KAB_EMBEDDED 401#endif //KAB_EMBEDDED
402 layout->addWidget( label, 3, 1 ); 402 layout->addWidget( label, 3, 1 );
403#ifndef KAB_EMBEDDED 403#ifndef KAB_EMBEDDED
404 layout->addWidget( mFormattedNameLabel, 3, 2 ); 404 layout->addWidget( mFormattedNameLabel, 3, 2 );
405#else //KAB_EMBEDDED 405#else //KAB_EMBEDDED
406qDebug("AddresseeEditorWidget::setupTab1 has to be changed"); 406qDebug("AddresseeEditorWidget::setupTab1 has to be changed");
407#endif //KAB_EMBEDDED 407#endif //KAB_EMBEDDED
408 408
409 // Left hand separator. This separator doesn't go all the way 409 // Left hand separator. This separator doesn't go all the way
410 // across so the dialog still flows from top to bottom 410 // across so the dialog still flows from top to bottom
411 bar = new KSeparator( KSeparator::HLine, tab1 ); 411 bar = new KSeparator( KSeparator::HLine, tab1 );
412 layout->addMultiCellWidget( bar, 4, 4, 0, 2 ); 412 layout->addMultiCellWidget( bar, 4, 4, 0, 2 );
413 413
414 ////////////////////////////////////// 414 //////////////////////////////////////
415 // Phone numbers (upper right) 415 // Phone numbers (upper right)
416 label = new QLabel( tab1 ); 416 label = new QLabel( tab1 );
417//US loadIcon call is ambiguous. Add one more parameter 417//US loadIcon call is ambiguous. Add one more parameter
418//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) ); 418//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop ) );
419 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) ); 419 label->setPixmap( KGlobal::iconLoader()->loadIcon( "kaddressbook", KIcon::Desktop, 0 ) );
420 layout->addMultiCellWidget( label, 0, 1, 3, 3 ); 420 layout->addMultiCellWidget( label, 0, 1, 3, 3 );
421 421
422 mPhoneEditWidget = new PhoneEditWidget( tab1 ); 422 mPhoneEditWidget = new PhoneEditWidget( tab1 );
423 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 423 connect( mPhoneEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
424 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 ); 424 layout->addMultiCellWidget( mPhoneEditWidget, 0, 3, 4, 6 );
425 425
426 bar = new KSeparator( KSeparator::HLine, tab1 ); 426 bar = new KSeparator( KSeparator::HLine, tab1 );
427 layout->addMultiCellWidget( bar, 4, 4, 3, 6 ); 427 layout->addMultiCellWidget( bar, 4, 4, 3, 6 );
428*/ 428*/
429 ////////////////////////////////////// 429 //////////////////////////////////////
430 // Addresses (lower left) 430 // Addresses (lower left)
431 /* LR 431 /* LR
432 label = new QLabel( tab1_1 ); 432 label = new QLabel( tab1_1 );
433//US loadIcon call is ambiguous. Add one more parameter 433//US loadIcon call is ambiguous. Add one more parameter
434//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) ); 434//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop ) );
435 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) ); 435 label->setPixmap( KGlobal::iconLoader()->loadIcon( "gohome", KIcon::Desktop, 0 ) );
436//US layout->addMultiCellWidget( label, 5, 6, 0, 0 ); 436//US layout->addMultiCellWidget( label, 5, 6, 0, 0 );
437 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 437 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
438 */ 438 */
439 439
440 mAddressEditWidget = new AddressEditWidget( tab1_1 ); 440 mAddressEditWidget = new AddressEditWidget( tab1_1 );
441 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 441 connect( mAddressEditWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
442//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 ); 442//US layout->addMultiCellWidget( mAddressEditWidget, 5, 9, 1, 2 );
443 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 ); 443 layout->addMultiCellWidget( mAddressEditWidget, 0, 4, 0, 1 );
444 444
445//US 445//US
446/* LR 446/* LR
447 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 447 bar = new KSeparator( KSeparator::HLine, tab1_1 );
448 layout->addMultiCellWidget( bar, 5, 5, 0, 3 ); 448 layout->addMultiCellWidget( bar, 5, 5, 0, 3 );
449*/ 449*/
450 450
451 ////////////////////////////////////// 451 //////////////////////////////////////
452 // Email / Web (lower right) 452 // Email / Web (lower right)
453 /* LR 453 /* LR
454 label = new QLabel( tab1_1 ); 454 label = new QLabel( tab1_1 );
455//US loadIcon call is ambiguous. Add one more parameter 455//US loadIcon call is ambiguous. Add one more parameter
456//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) ); 456//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop) );
457 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) ); 457 label->setPixmap( KGlobal::iconLoader()->loadIcon( "email", KIcon::Desktop, 0) );
458//US layout->addMultiCellWidget( label, 5, 6, 3, 3 ); 458//US layout->addMultiCellWidget( label, 5, 6, 3, 3 );
459 layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 459 layout->addMultiCellWidget( label, 6, 7, 0, 0 );
460 */ 460 */
461 mEmailWidget = new EmailEditWidget( tab1_1 ); 461 mEmailWidget = new EmailEditWidget( tab1_1 );
462 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) ); 462 connect( mEmailWidget, SIGNAL( modified() ), SLOT( emitModified() ) );
463//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 ); 463//US layout->addMultiCellWidget( mEmailWidget, 5, 6, 4, 6 );
464 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 ); 464 layout->addMultiCellWidget( mEmailWidget, 5, 6, 0, 1 );
465 465
466 /* LR 466 /* LR
467 // add the separator 467 // add the separator
468 bar = new KSeparator( KSeparator::HLine, tab1_1 ); 468 bar = new KSeparator( KSeparator::HLine, tab1_1 );
469//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 ); 469//US layout->addMultiCellWidget( bar, 7, 7, 3, 6 );
470 layout->addMultiCellWidget( bar, 8, 8, 0, 3 ); 470 layout->addMultiCellWidget( bar, 8, 8, 0, 3 );
471 471
472 label = new QLabel( tab1_1 ); 472 label = new QLabel( tab1_1 );
473//US loadIcon call is ambiguous. Add one more parameter 473//US loadIcon call is ambiguous. Add one more parameter
474//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) ); 474//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop) );
475 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) ); 475 label->setPixmap( KGlobal::iconLoader()->loadIcon( "homepage", KIcon::Desktop, 0) );
476//US layout->addMultiCellWidget( label, 8, 9, 3, 3 ); 476//US layout->addMultiCellWidget( label, 8, 9, 3, 3 );
477 layout->addMultiCellWidget( label, 9, 10, 0, 0 ); 477 layout->addMultiCellWidget( label, 9, 10, 0, 0 );
478 */ 478 */
479 label = new QLabel( i18n( "URL:" ), tab1_1 ); 479 label = new QLabel( i18n( "URL:" ), tab1_1 );
480 mURLEdit = new KLineEdit( tab1_1 ); 480 mURLEdit = new KLineEdit( tab1_1 );
481 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ), 481 connect( mURLEdit, SIGNAL( textChanged( const QString& ) ),
482 SLOT( textChanged( const QString& ) ) ); 482 SLOT( textChanged( const QString& ) ) );
483 label->setBuddy( mURLEdit ); 483 label->setBuddy( mURLEdit );
484//US layout->addWidget( label, 8, 4 ); 484//US layout->addWidget( label, 8, 4 );
485 layout->addWidget( label, 7,0 ); 485 layout->addWidget( label, 7,0 );
486//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 ); 486//US layout->addMultiCellWidget( mURLEdit, 8, 8, 5, 6 );
487 layout->addWidget( mURLEdit, 7, 1); 487 layout->addWidget( mURLEdit, 7, 1);
488 488
489 label = new QLabel( i18n( "&IM address:" ), tab1_1 ); 489 label = new QLabel( i18n( "&IM address:" ), tab1_1 );
490 mIMAddressEdit = new KLineEdit( tab1_1 ); 490 mIMAddressEdit = new KLineEdit( tab1_1 );
491 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ), 491 connect( mIMAddressEdit, SIGNAL( textChanged( const QString& ) ),
492 SLOT( textChanged( const QString& ) ) ); 492 SLOT( textChanged( const QString& ) ) );
493 label->setBuddy( mIMAddressEdit ); 493 label->setBuddy( mIMAddressEdit );
494//US layout->addWidget( label, 9, 4 ); 494//US layout->addWidget( label, 9, 4 );
495 layout->addWidget( label, 8, 0 ); 495 layout->addWidget( label, 8, 0 );
496//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 ); 496//US layout->addMultiCellWidget( mIMAddressEdit, 9, 9, 5, 6 );
497 layout->addWidget( mIMAddressEdit, 8,1 ); 497 layout->addWidget( mIMAddressEdit, 8,1 );
498 498
499//US layout->addColSpacing( 6, 50 ); 499//US layout->addColSpacing( 6, 50 );
500 500
501//US bar = new KSeparator( KSeparator::HLine, tab1_1 ); 501//US bar = new KSeparator( KSeparator::HLine, tab1_1 );
502//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 ); 502//US layout->addMultiCellWidget( bar, 10, 10, 0, 6 );
503 503
504/*US 504/*US
505 /////////////////////////////////////// 505 ///////////////////////////////////////
506 QHBox *categoryBox = new QHBox( tab1 ); 506 QHBox *categoryBox = new QHBox( tab1 );
507 categoryBox->setSpacing( KDialogBase::spacingHintSmall() ); 507 categoryBox->setSpacing( KDialogBase::spacingHintSmall() );
508 508
509 // Categories 509 // Categories
510 button = new QPushButton( i18n( "Categories" ), categoryBox ); 510 button = new QPushButton( i18n( "Categories" ), categoryBox );
511 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) ); 511 connect( button, SIGNAL( clicked() ), SLOT( categoryButtonClicked() ) );
512 512
513 mCategoryEdit = new KLineEdit( categoryBox ); 513 mCategoryEdit = new KLineEdit( categoryBox );
514 mCategoryEdit->setReadOnly( true ); 514 mCategoryEdit->setReadOnly( true );
515 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ), 515 connect( mCategoryEdit, SIGNAL( textChanged( const QString& ) ),
516 SLOT( textChanged( const QString& ) ) ); 516 SLOT( textChanged( const QString& ) ) );
517 517
518 mSecrecyWidget = new SecrecyWidget( categoryBox ); 518 mSecrecyWidget = new SecrecyWidget( categoryBox );
519 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 519 connect( mSecrecyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
520 520
521 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 ); 521 layout->addMultiCellWidget( categoryBox, 11, 11, 0, 6 );
522*/ 522*/
523 // Build the layout and add to the tab widget 523 // Build the layout and add to the tab widget
524 layout->activate(); // required 524 layout->activate(); // required
525 525
526 mTabWidget->addTab( tab1_1, i18n( "&Address" ) ); 526 mTabWidget->addTab( tab1_1, i18n( "&Address" ) );
527} 527}
528 528
529 529
530 530
531void AddresseeEditorWidget::setupTab2() 531void AddresseeEditorWidget::setupTab2()
532{ 532{
533 // This is the Details tab 533 // This is the Details tab
534 QWidget *tab2 = new QWidget( mTabWidget ); 534 QWidget *tab2 = new QWidget( mTabWidget );
535 535
536 QGridLayout *layout = new QGridLayout( tab2, 8, 3 ); 536 QGridLayout *layout = new QGridLayout( tab2, 8, 3 );
537 layout->setMargin( KDialogBase::marginHintSmall() ); 537 layout->setMargin( KDialogBase::marginHintSmall() );
538 layout->setSpacing( KDialogBase::spacingHintSmall() ); 538 layout->setSpacing( KDialogBase::spacingHintSmall() );
539 539
540 QLabel *label; 540 QLabel *label;
541 KSeparator* bar; 541 KSeparator* bar;
542 542
543 /////////////////////// 543 ///////////////////////
544 // Office info 544 // Office info
545 545
546 // Department 546 // Department
547 label = new QLabel( tab2 ); 547 label = new QLabel( tab2 );
548//US loadIcon call is ambiguous. Add one more parameter 548//US loadIcon call is ambiguous. Add one more parameter
549//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 549//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
550 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 550 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
551 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 551 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
552 552
553 label = new QLabel( i18n( "Department:" ), tab2 ); 553 label = new QLabel( i18n( "Department:" ), tab2 );
554 layout->addWidget( label, 0, 1 ); 554 layout->addWidget( label, 0, 1 );
555 mDepartmentEdit = new KLineEdit( tab2 ); 555 mDepartmentEdit = new KLineEdit( tab2 );
556 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 556 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
557 SLOT( textChanged( const QString& ) ) ); 557 SLOT( textChanged( const QString& ) ) );
558 label->setBuddy( mDepartmentEdit ); 558 label->setBuddy( mDepartmentEdit );
559 layout->addWidget( mDepartmentEdit, 0, 2 ); 559 layout->addWidget( mDepartmentEdit, 0, 2 );
560 560
561 label = new QLabel( i18n( "Office:" ), tab2 ); 561 label = new QLabel( i18n( "Office:" ), tab2 );
562 layout->addWidget( label, 1, 1 ); 562 layout->addWidget( label, 1, 1 );
563 mOfficeEdit = new KLineEdit( tab2 ); 563 mOfficeEdit = new KLineEdit( tab2 );
564 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 564 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
565 SLOT( textChanged( const QString& ) ) ); 565 SLOT( textChanged( const QString& ) ) );
566 label->setBuddy( mOfficeEdit ); 566 label->setBuddy( mOfficeEdit );
567 layout->addWidget( mOfficeEdit, 1, 2 ); 567 layout->addWidget( mOfficeEdit, 1, 2 );
568 568
569 label = new QLabel( i18n( "Profession:" ), tab2 ); 569 label = new QLabel( i18n( "Profession:" ), tab2 );
570 layout->addWidget( label, 2, 1 ); 570 layout->addWidget( label, 2, 1 );
571 mProfessionEdit = new KLineEdit( tab2 ); 571 mProfessionEdit = new KLineEdit( tab2 );
572 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 572 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
573 SLOT( textChanged( const QString& ) ) ); 573 SLOT( textChanged( const QString& ) ) );
574 label->setBuddy( mProfessionEdit ); 574 label->setBuddy( mProfessionEdit );
575 layout->addWidget( mProfessionEdit, 2, 2 ); 575 layout->addWidget( mProfessionEdit, 2, 2 );
576 576
577 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 577 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
578//US layout->addWidget( label, 0, 3 ); 578//US layout->addWidget( label, 0, 3 );
579 layout->addWidget( label, 3, 1 ); 579 layout->addWidget( label, 3, 1 );
580 mManagerEdit = new KLineEdit( tab2 ); 580 mManagerEdit = new KLineEdit( tab2 );
581 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 581 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
582 SLOT( textChanged( const QString& ) ) ); 582 SLOT( textChanged( const QString& ) ) );
583 label->setBuddy( mManagerEdit ); 583 label->setBuddy( mManagerEdit );
584//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 584//US layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
585 layout->addWidget( mManagerEdit, 3, 2 ); 585 layout->addWidget( mManagerEdit, 3, 2 );
586 586
587 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 587 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
588//US layout->addWidget( label, 1, 3 ); 588//US layout->addWidget( label, 1, 3 );
589 layout->addWidget( label, 4, 1 ); 589 layout->addWidget( label, 4, 1 );
590 mAssistantEdit = new KLineEdit( tab2 ); 590 mAssistantEdit = new KLineEdit( tab2 );
591 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 591 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
592 SLOT( textChanged( const QString& ) ) ); 592 SLOT( textChanged( const QString& ) ) );
593 label->setBuddy( mAssistantEdit ); 593 label->setBuddy( mAssistantEdit );
594//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 594//US layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
595 layout->addWidget( mAssistantEdit, 4, 2 ); 595 layout->addWidget( mAssistantEdit, 4, 2 );
596 596
597 bar = new KSeparator( KSeparator::HLine, tab2 ); 597 bar = new KSeparator( KSeparator::HLine, tab2 );
598//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 598//US layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
599 layout->addMultiCellWidget( bar, 5, 5, 0, 2 ); 599 layout->addMultiCellWidget( bar, 5, 5, 0, 2 );
600 600
601 ///////////////////////////////////////////////// 601 /////////////////////////////////////////////////
602 // Personal info 602 // Personal info
603 603
604 //label = new QLabel( tab2 ); 604 //label = new QLabel( tab2 );
605//US loadIcon call is ambiguous. Add one more parameter 605//US loadIcon call is ambiguous. Add one more parameter
606//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 606//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
607 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 607 //label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
608//US layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 608//US layout->addMultiCellWidget( label, 4, 5, 0, 0 );
609 //layout->addMultiCellWidget( label, 6, 7, 0, 0 ); 609 //layout->addMultiCellWidget( label, 6, 7, 0, 0 );
610 610
611 611
612 int iii = 6; 612 int iii = 6;
613 613
614 if ( QApplication::desktop()->width() == 640 ) { 614 if ( QApplication::desktop()->width() == 640 ) {
615 QHBox * nbox = new QHBox ( tab2 ); 615 QHBox * nbox = new QHBox ( tab2 );
616 label = new QLabel( i18n( "Nick name:" )+" ", nbox ); 616 label = new QLabel( i18n( "Nick name:" )+" ", nbox );
617 mNicknameEdit = new KLineEdit( nbox ); 617 mNicknameEdit = new KLineEdit( nbox );
618 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 618 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
619 SLOT( textChanged( const QString& ) ) ); 619 SLOT( textChanged( const QString& ) ) );
620 label->setBuddy( mNicknameEdit ); 620 label->setBuddy( mNicknameEdit );
621 621
622 label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox ); 622 label = new QLabel( " "+i18n( "Spouse's name:" )+" ", nbox );
623 mSpouseEdit = new KLineEdit( nbox ); 623 mSpouseEdit = new KLineEdit( nbox );
624 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 624 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
625 SLOT( textChanged( const QString& ) ) ); 625 SLOT( textChanged( const QString& ) ) );
626 label->setBuddy( mSpouseEdit ); 626 label->setBuddy( mSpouseEdit );
627 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); 627 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
628 ++iii; 628 ++iii;
629 629
630 } else { 630 } else {
631 label = new QLabel( i18n( "Nick name:" ), tab2 ); 631 label = new QLabel( i18n( "Nick name:" ), tab2 );
632 layout->addWidget( label, iii, 1 ); 632 layout->addWidget( label, iii, 1 );
633 mNicknameEdit = new KLineEdit( tab2 ); 633 mNicknameEdit = new KLineEdit( tab2 );
634 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 634 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
635 SLOT( textChanged( const QString& ) ) ); 635 SLOT( textChanged( const QString& ) ) );
636 label->setBuddy( mNicknameEdit ); 636 label->setBuddy( mNicknameEdit );
637 layout->addWidget( mNicknameEdit, iii, 2 ); 637 layout->addWidget( mNicknameEdit, iii, 2 );
638 ++iii; 638 ++iii;
639 639
640 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 640 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
641 layout->addWidget( label, iii, 1 ); 641 layout->addWidget( label, iii, 1 );
642 mSpouseEdit = new KLineEdit( tab2 ); 642 mSpouseEdit = new KLineEdit( tab2 );
643 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 643 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
644 SLOT( textChanged( const QString& ) ) ); 644 SLOT( textChanged( const QString& ) ) );
645 label->setBuddy( mSpouseEdit ); 645 label->setBuddy( mSpouseEdit );
646 layout->addWidget( mSpouseEdit, iii, 2 ); 646 layout->addWidget( mSpouseEdit, iii, 2 );
647 ++iii; 647 ++iii;
648 } 648 }
649 649
650 label = new QLabel( i18n( "Children's names:" ), tab2 ); 650 label = new QLabel( i18n( "Children's names:" ), tab2 );
651 layout->addWidget( label, iii, 1 ); 651 layout->addWidget( label, iii, 1 );
652 mChildEdit = new KLineEdit( tab2 ); 652 mChildEdit = new KLineEdit( tab2 );
653 connect( mChildEdit, SIGNAL( textChanged( const QString& ) ), 653 connect( mChildEdit, SIGNAL( textChanged( const QString& ) ),
654 SLOT( textChanged( const QString& ) ) ); 654 SLOT( textChanged( const QString& ) ) );
655 label->setBuddy( mChildEdit ); 655 label->setBuddy( mChildEdit );
656 layout->addWidget( mChildEdit, iii, 2 ); 656 layout->addWidget( mChildEdit, iii, 2 );
657 ++iii; 657 ++iii;
658 if ( QApplication::desktop()->width() == 640 ) { 658 if ( QApplication::desktop()->width() == 640 ) {
659 QHBox * nbox = new QHBox ( tab2 ); 659 QHBox * nbox = new QHBox ( tab2 );
660 label = new QLabel( i18n( "Birthday:" )+" ", nbox ); 660 label = new QLabel( i18n( "Birthday:" )+" ", nbox );
661 mBirthdayPicker = new KDateEdit( nbox ); 661 mBirthdayPicker = new KDateEdit( nbox );
662 mBirthdayPicker->toggleDateFormat(); 662 mBirthdayPicker->toggleDateFormat();
663 mBirthdayPicker->setHandleInvalid( true ); 663 mBirthdayPicker->setHandleInvalid( true );
664 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 664 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
665 SLOT( dateChanged( QDate ) ) ); 665 SLOT( dateChanged( QDate ) ) );
666 666
667 label->setBuddy( mBirthdayPicker ); 667 label->setBuddy( mBirthdayPicker );
668 668
669 label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox ); 669 label = new QLabel( " "+i18n( "Anniversary:" )+" ", nbox );
670 mAnniversaryPicker = new KDateEdit( nbox ); 670 mAnniversaryPicker = new KDateEdit( nbox );
671 mAnniversaryPicker->setHandleInvalid( true ); 671 mAnniversaryPicker->setHandleInvalid( true );
672 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 672 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
673 SLOT( dateChanged( QDate ) ) ); 673 SLOT( dateChanged( QDate ) ) );
674 674
675 label->setBuddy( mAnniversaryPicker ); 675 label->setBuddy( mAnniversaryPicker );
676 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 ); 676 layout->addMultiCellWidget( nbox, iii, iii, 1, 2 );
677 ++iii; 677 ++iii;
678 678
679 } else { 679 } else {
680 680
681 label = new QLabel( i18n( "Birthday:" ), tab2 ); 681 label = new QLabel( i18n( "Birthday:" ), tab2 );
682 layout->addWidget( label, iii, 1 ); 682 layout->addWidget( label, iii, 1 );
683 mBirthdayPicker = new KDateEdit( tab2 ); 683 mBirthdayPicker = new KDateEdit( tab2 );
684 mBirthdayPicker->toggleDateFormat(); 684 mBirthdayPicker->toggleDateFormat();
685 mBirthdayPicker->setHandleInvalid( true ); 685 mBirthdayPicker->setHandleInvalid( true );
686 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 686 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
687 SLOT( dateChanged( QDate ) ) ); 687 SLOT( dateChanged( QDate ) ) );
688 688
689 label->setBuddy( mBirthdayPicker ); 689 label->setBuddy( mBirthdayPicker );
690 layout->addWidget( mBirthdayPicker, iii, 2 ); 690 layout->addWidget( mBirthdayPicker, iii, 2 );
691 ++iii; 691 ++iii;
692 692
693 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 693 label = new QLabel( i18n( "Anniversary:" ), tab2 );
694 layout->addWidget( label, iii, 1 ); 694 layout->addWidget( label, iii, 1 );
695 mAnniversaryPicker = new KDateEdit( tab2 ); 695 mAnniversaryPicker = new KDateEdit( tab2 );
696 mAnniversaryPicker->setHandleInvalid( true ); 696 mAnniversaryPicker->setHandleInvalid( true );
697 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 697 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
698 SLOT( dateChanged( QDate ) ) ); 698 SLOT( dateChanged( QDate ) ) );
699 699
700 label->setBuddy( mAnniversaryPicker ); 700 label->setBuddy( mAnniversaryPicker );
701 layout->addWidget( mAnniversaryPicker, iii, 2 ); 701 layout->addWidget( mAnniversaryPicker, iii, 2 );
702 ++iii; 702 ++iii;
703 703
704 } 704 }
705 705
706 label = new QLabel( i18n( "Gender:" ), tab2 ); 706 label = new QLabel( i18n( "Gender:" ), tab2 );
707 layout->addWidget( label, iii, 1 ); 707 layout->addWidget( label, iii, 1 );
708 mGenderBox = new QComboBox ( tab2 ); 708 mGenderBox = new QComboBox ( tab2 );
709 mGenderBox->insertItem ( i18n( "ALIEN (gender undefined)" )); 709 mGenderBox->insertItem ( i18n( "ALIEN (gender undefined)" ));
710 mGenderBox->insertItem ( i18n( "female" )); 710 mGenderBox->insertItem ( i18n( "female" ));
711 mGenderBox->insertItem ( i18n( "male" )); 711 mGenderBox->insertItem ( i18n( "male" ));
712 connect( mGenderBox, SIGNAL( activated ( const QString & ) ), 712 connect( mGenderBox, SIGNAL( activated ( const QString & ) ),
713 SLOT( textChanged( const QString& ) ) ); 713 SLOT( textChanged( const QString& ) ) );
714 label->setBuddy( mGenderBox ); 714 label->setBuddy( mGenderBox );
715 layout->addWidget( mGenderBox, iii, 2 ); 715 layout->addWidget( mGenderBox, iii, 2 );
716 ++iii; 716 ++iii;
717 // Build the layout and add to the tab widget 717 // Build the layout and add to the tab widget
718 layout->activate(); // required 718 layout->activate(); // required
719 719
720 mTabWidget->addTab( tab2, i18n( "&Details" ) ); 720 mTabWidget->addTab( tab2, i18n( "&Details" ) );
721} 721}
722 722
723void AddresseeEditorWidget::setupTab2_1() 723void AddresseeEditorWidget::setupTab2_1()
724{ 724{
725 // This is the Details tab 725 // This is the Details tab
726 QWidget *tab2_2 = new QWidget( mTabWidget ); 726 QWidget *tab2_2 = new QWidget( mTabWidget );
727 727
728 QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 ); 728 QGridLayout *layout = new QGridLayout( tab2_2, 1, 2 );
729 layout->setMargin( KDialogBase::marginHintSmall() ); 729 layout->setMargin( KDialogBase::marginHintSmall() );
730 layout->setSpacing( KDialogBase::spacingHintSmall() ); 730 layout->setSpacing( KDialogBase::spacingHintSmall() );
731 731
732 QLabel *label; 732 QLabel *label;
733 KSeparator* bar; 733 KSeparator* bar;
734 734
735/*US 735/*US
736 /////////////////////// 736 ///////////////////////
737 // Office info 737 // Office info
738 738
739 // Department 739 // Department
740 label = new QLabel( tab2 ); 740 label = new QLabel( tab2 );
741//US loadIcon call is ambiguous. Add one more parameter 741//US loadIcon call is ambiguous. Add one more parameter
742//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) ); 742//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop ) );
743 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) ); 743 label->setPixmap( KGlobal::iconLoader()->loadIcon( "folder", KIcon::Desktop, 0 ) );
744 layout->addMultiCellWidget( label, 0, 1, 0, 0 ); 744 layout->addMultiCellWidget( label, 0, 1, 0, 0 );
745 745
746 label = new QLabel( i18n( "Department:" ), tab2 ); 746 label = new QLabel( i18n( "Department:" ), tab2 );
747 layout->addWidget( label, 0, 1 ); 747 layout->addWidget( label, 0, 1 );
748 mDepartmentEdit = new KLineEdit( tab2 ); 748 mDepartmentEdit = new KLineEdit( tab2 );
749 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ), 749 connect( mDepartmentEdit, SIGNAL( textChanged( const QString& ) ),
750 SLOT( textChanged( const QString& ) ) ); 750 SLOT( textChanged( const QString& ) ) );
751 label->setBuddy( mDepartmentEdit ); 751 label->setBuddy( mDepartmentEdit );
752 layout->addWidget( mDepartmentEdit, 0, 2 ); 752 layout->addWidget( mDepartmentEdit, 0, 2 );
753 753
754 label = new QLabel( i18n( "Office:" ), tab2 ); 754 label = new QLabel( i18n( "Office:" ), tab2 );
755 layout->addWidget( label, 1, 1 ); 755 layout->addWidget( label, 1, 1 );
756 mOfficeEdit = new KLineEdit( tab2 ); 756 mOfficeEdit = new KLineEdit( tab2 );
757 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ), 757 connect( mOfficeEdit, SIGNAL( textChanged( const QString& ) ),
758 SLOT( textChanged( const QString& ) ) ); 758 SLOT( textChanged( const QString& ) ) );
759 label->setBuddy( mOfficeEdit ); 759 label->setBuddy( mOfficeEdit );
760 layout->addWidget( mOfficeEdit, 1, 2 ); 760 layout->addWidget( mOfficeEdit, 1, 2 );
761 761
762 label = new QLabel( i18n( "Profession:" ), tab2 ); 762 label = new QLabel( i18n( "Profession:" ), tab2 );
763 layout->addWidget( label, 2, 1 ); 763 layout->addWidget( label, 2, 1 );
764 mProfessionEdit = new KLineEdit( tab2 ); 764 mProfessionEdit = new KLineEdit( tab2 );
765 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ), 765 connect( mProfessionEdit, SIGNAL( textChanged( const QString& ) ),
766 SLOT( textChanged( const QString& ) ) ); 766 SLOT( textChanged( const QString& ) ) );
767 label->setBuddy( mProfessionEdit ); 767 label->setBuddy( mProfessionEdit );
768 layout->addWidget( mProfessionEdit, 2, 2 ); 768 layout->addWidget( mProfessionEdit, 2, 2 );
769 769
770 label = new QLabel( i18n( "Manager\'s name:" ), tab2 ); 770 label = new QLabel( i18n( "Manager\'s name:" ), tab2 );
771 layout->addWidget( label, 0, 3 ); 771 layout->addWidget( label, 0, 3 );
772 mManagerEdit = new KLineEdit( tab2 ); 772 mManagerEdit = new KLineEdit( tab2 );
773 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ), 773 connect( mManagerEdit, SIGNAL( textChanged( const QString& ) ),
774 SLOT( textChanged( const QString& ) ) ); 774 SLOT( textChanged( const QString& ) ) );
775 label->setBuddy( mManagerEdit ); 775 label->setBuddy( mManagerEdit );
776 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 ); 776 layout->addMultiCellWidget( mManagerEdit, 0, 0, 4, 5 );
777 777
778 label = new QLabel( i18n( "Assistant's name:" ), tab2 ); 778 label = new QLabel( i18n( "Assistant's name:" ), tab2 );
779 layout->addWidget( label, 1, 3 ); 779 layout->addWidget( label, 1, 3 );
780 mAssistantEdit = new KLineEdit( tab2 ); 780 mAssistantEdit = new KLineEdit( tab2 );
781 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ), 781 connect( mAssistantEdit, SIGNAL( textChanged( const QString& ) ),
782 SLOT( textChanged( const QString& ) ) ); 782 SLOT( textChanged( const QString& ) ) );
783 label->setBuddy( mAssistantEdit ); 783 label->setBuddy( mAssistantEdit );
784 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 ); 784 layout->addMultiCellWidget( mAssistantEdit, 1, 1, 4, 5 );
785 785
786 bar = new KSeparator( KSeparator::HLine, tab2 ); 786 bar = new KSeparator( KSeparator::HLine, tab2 );
787 layout->addMultiCellWidget( bar, 3, 3, 0, 5 ); 787 layout->addMultiCellWidget( bar, 3, 3, 0, 5 );
788 788
789 ///////////////////////////////////////////////// 789 /////////////////////////////////////////////////
790 // Personal info 790 // Personal info
791 791
792 label = new QLabel( tab2 ); 792 label = new QLabel( tab2 );
793//US loadIcon call is ambiguous. Add one more parameter 793//US loadIcon call is ambiguous. Add one more parameter
794//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) ); 794//US label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop ) );
795 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) ); 795 label->setPixmap( KGlobal::iconLoader()->loadIcon( "personal", KIcon::Desktop, 0 ) );
796 layout->addMultiCellWidget( label, 4, 5, 0, 0 ); 796 layout->addMultiCellWidget( label, 4, 5, 0, 0 );
797 797
798 label = new QLabel( i18n( "Nick name:" ), tab2 ); 798 label = new QLabel( i18n( "Nick name:" ), tab2 );
799 layout->addWidget( label, 4, 1 ); 799 layout->addWidget( label, 4, 1 );
800 mNicknameEdit = new KLineEdit( tab2 ); 800 mNicknameEdit = new KLineEdit( tab2 );
801 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ), 801 connect( mNicknameEdit, SIGNAL( textChanged( const QString& ) ),
802 SLOT( textChanged( const QString& ) ) ); 802 SLOT( textChanged( const QString& ) ) );
803 label->setBuddy( mNicknameEdit ); 803 label->setBuddy( mNicknameEdit );
804 layout->addWidget( mNicknameEdit, 4, 2 ); 804 layout->addWidget( mNicknameEdit, 4, 2 );
805 805
806 label = new QLabel( i18n( "Spouse's name:" ), tab2 ); 806 label = new QLabel( i18n( "Spouse's name:" ), tab2 );
807 layout->addWidget( label, 5, 1 ); 807 layout->addWidget( label, 5, 1 );
808 mSpouseEdit = new KLineEdit( tab2 ); 808 mSpouseEdit = new KLineEdit( tab2 );
809 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ), 809 connect( mSpouseEdit, SIGNAL( textChanged( const QString& ) ),
810 SLOT( textChanged( const QString& ) ) ); 810 SLOT( textChanged( const QString& ) ) );
811 label->setBuddy( mSpouseEdit ); 811 label->setBuddy( mSpouseEdit );
812 layout->addWidget( mSpouseEdit, 5, 2 ); 812 layout->addWidget( mSpouseEdit, 5, 2 );
813 813
814 label = new QLabel( i18n( "Birthday:" ), tab2 ); 814 label = new QLabel( i18n( "Birthday:" ), tab2 );
815 layout->addWidget( label, 4, 3 ); 815 layout->addWidget( label, 4, 3 );
816 mBirthdayPicker = new KDateEdit( tab2 ); 816 mBirthdayPicker = new KDateEdit( tab2 );
817 mBirthdayPicker->setHandleInvalid( true ); 817 mBirthdayPicker->setHandleInvalid( true );
818 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ), 818 connect( mBirthdayPicker, SIGNAL( dateChanged( QDate ) ),
819 SLOT( dateChanged( QDate ) ) ); 819 SLOT( dateChanged( QDate ) ) );
820 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ), 820 connect( mBirthdayPicker, SIGNAL( invalidDateEntered() ),
821 SLOT( invalidDate() ) ); 821 SLOT( invalidDate() ) );
822 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ), 822 connect( mBirthdayPicker, SIGNAL( textChanged( const QString& ) ),
823 SLOT( emitModified() ) ); 823 SLOT( emitModified() ) );
824 label->setBuddy( mBirthdayPicker ); 824 label->setBuddy( mBirthdayPicker );
825 layout->addWidget( mBirthdayPicker, 4, 4 ); 825 layout->addWidget( mBirthdayPicker, 4, 4 );
826 826
827 label = new QLabel( i18n( "Anniversary:" ), tab2 ); 827 label = new QLabel( i18n( "Anniversary:" ), tab2 );
828 layout->addWidget( label, 5, 3 ); 828 layout->addWidget( label, 5, 3 );
829 mAnniversaryPicker = new KDateEdit( tab2 ); 829 mAnniversaryPicker = new KDateEdit( tab2 );
830 mAnniversaryPicker->setHandleInvalid( true ); 830 mAnniversaryPicker->setHandleInvalid( true );
831 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ), 831 connect( mAnniversaryPicker, SIGNAL( dateChanged( QDate ) ),
832 SLOT( dateChanged( QDate ) ) ); 832 SLOT( dateChanged( QDate ) ) );
833 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ), 833 connect( mAnniversaryPicker, SIGNAL( invalidDateEntered() ),
834 SLOT( invalidDate() ) ); 834 SLOT( invalidDate() ) );
835 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ), 835 connect( mAnniversaryPicker, SIGNAL( textChanged( const QString& ) ),
836 SLOT( emitModified() ) ); 836 SLOT( emitModified() ) );
837 label->setBuddy( mAnniversaryPicker ); 837 label->setBuddy( mAnniversaryPicker );
838 layout->addWidget( mAnniversaryPicker, 5, 4 ); 838 layout->addWidget( mAnniversaryPicker, 5, 4 );
839 839
840 bar = new KSeparator( KSeparator::HLine, tab2 ); 840 bar = new KSeparator( KSeparator::HLine, tab2 );
841 layout->addMultiCellWidget( bar, 6, 6, 0, 5 ); 841 layout->addMultiCellWidget( bar, 6, 6, 0, 5 );
842*/ 842*/
843 ////////////////////////////////////// 843 //////////////////////////////////////
844 // Notes 844 // Notes
845 label = new QLabel( i18n( "Note:" ), tab2_2 ); 845 label = new QLabel( i18n( "Note:" ), tab2_2 );
846 label->setAlignment( Qt::AlignTop | Qt::AlignLeft ); 846 label->setAlignment( Qt::AlignTop | Qt::AlignLeft );
847//US layout->addWidget( label, 7, 0 ); 847//US layout->addWidget( label, 7, 0 );
848 layout->addWidget( label, 0, 0 ); 848 layout->addWidget( label, 0, 0 );
849#ifndef KAB_EMBEDDED 849#ifndef KAB_EMBEDDED
850 mNoteEdit = new QTextEdit( tab2_2 ); 850 mNoteEdit = new QTextEdit( tab2_2 );
851 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth ); 851 mNoteEdit->setWordWrap( QTextEdit::WidgetWidth );
852 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 852 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
853#else //KAB_EMBEDDED 853#else //KAB_EMBEDDED
854 mNoteEdit = new QMultiLineEdit( tab2_2 ); 854 mNoteEdit = new QMultiLineEdit( tab2_2 );
855 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth ); 855 mNoteEdit->setWordWrap( QMultiLineEdit::WidgetWidth );
856 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() ); 856 mNoteEdit->setMinimumSize( mNoteEdit->sizeHint() );
857#endif //KAB_EMBEDDED 857#endif //KAB_EMBEDDED
858 858
859 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) ); 859 connect( mNoteEdit, SIGNAL( textChanged() ), SLOT( emitModified() ) );
860 label->setBuddy( mNoteEdit ); 860 label->setBuddy( mNoteEdit );
861//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 ); 861//US layout->addMultiCellWidget( mNoteEdit, 7, 7, 1, 5 );
862 layout->addWidget( mNoteEdit, 1, 0); 862 layout->addWidget( mNoteEdit, 1, 0);
863 863
864 // Build the layout and add to the tab widget 864 // Build the layout and add to the tab widget
865 layout->activate(); // required 865 layout->activate(); // required
866 866
867 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) ); 867 mTabWidget->addTab( tab2_2, i18n( "&Notes" ) );
868} 868}
869 869
870 870
871 871
872void AddresseeEditorWidget::setupTab3() 872void AddresseeEditorWidget::setupTab3()
873{ 873{
874 // This is the Misc tab 874 // This is the Misc tab
875 QWidget *tab3 = new QWidget( mTabWidget ); 875 QWidget *tab3 = new QWidget( mTabWidget );
876 876
877 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 877 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
878 layout->setMargin( KDialogBase::marginHintSmall() ); 878 layout->setMargin( KDialogBase::marginHintSmall() );
879 layout->setSpacing( KDialogBase::spacingHintSmall() ); 879 layout->setSpacing( KDialogBase::spacingHintSmall() );
880//US layout->setColStretch( 2, 1 ); 880//US layout->setColStretch( 2, 1 );
881 881
882 ////////////////////////////////////// 882 //////////////////////////////////////
883 // Geo 883 // Geo
884 mGeoWidget = new GeoWidget( tab3 ); 884 mGeoWidget = new GeoWidget( tab3 );
885 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 885 // mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
886 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 886 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
887 layout->addWidget( mGeoWidget, 0, 0 ); 887 layout->addWidget( mGeoWidget, 0, 0 );
888/*US 888/*US
889 ////////////////////////////////////// 889 //////////////////////////////////////
890 // Sound 890 // Sound
891#ifndef KAB_EMBEDDED 891#ifndef KAB_EMBEDDED
892 mSoundWidget = new SoundWidget( tab3 ); 892 mSoundWidget = new SoundWidget( tab3 );
893 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 893 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
894 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 894 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
895 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 895 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
896#else //KAB_EMBEDDED 896#else //KAB_EMBEDDED
897qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 897qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
898#endif //KAB_EMBEDDED 898#endif //KAB_EMBEDDED
899 899
900 ////////////////////////////////////// 900 //////////////////////////////////////
901 // Images 901 // Images
902 mImageWidget = new ImageWidget( tab3 ); 902 mImageWidget = new ImageWidget( tab3 );
903 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 903 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
904 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 904 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
905 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop ); 905 layout->addWidget( mImageWidget, 1, 0, Qt::AlignTop );
906*/ 906*/
907//US 907//US
908/* 908/*
909 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 ); 909 KSeparator* bar = new KSeparator( KSeparator::HLine, tab3 );
910 layout->addMultiCellWidget( bar, 1, 1, 0, 0 ); 910 layout->addMultiCellWidget( bar, 1, 1, 0, 0 );
911*/ 911*/
912 ////////////////////////////////////// 912 //////////////////////////////////////
913 // Keys 913 // Keys
914 mKeyWidget = new KeyWidget( tab3 ); 914 mKeyWidget = new KeyWidget( tab3 );
915 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 915 //mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
916 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 916 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
917//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 917//US layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
918 layout->addWidget( mKeyWidget, 1, 0 ); 918 layout->addWidget( mKeyWidget, 1, 0 );
919 919
920 mTabWidget->addTab( tab3, i18n( "&Misc" ) ); 920 mTabWidget->addTab( tab3, i18n( "&Misc" ) );
921} 921}
922 922
923void AddresseeEditorWidget::setupTab3_1() 923void AddresseeEditorWidget::setupTab3_1()
924{ 924{
925 // This is the Misc tab 925 // This is the Misc tab
926 QWidget *tab3 = new QWidget( mTabWidget ); 926 QWidget *tab3 = new QWidget( mTabWidget );
927 927
928//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 ); 928//US QGridLayout *layout = new QGridLayout( tab3, 2, 3 );
929 QGridLayout *layout = new QGridLayout( tab3, 1, 1 ); 929 QGridLayout *layout = new QGridLayout( tab3, 1, 1 );
930 layout->setMargin( KDialogBase::marginHint() ); 930 layout->setMargin( KDialogBase::marginHint() );
931 layout->setSpacing( KDialogBase::spacingHint() ); 931 layout->setSpacing( KDialogBase::spacingHint() );
932//US layout->setColStretch( 2, 1 ); 932//US layout->setColStretch( 2, 1 );
933 933
934/*US 934/*US
935 ////////////////////////////////////// 935 //////////////////////////////////////
936 // Geo 936 // Geo
937 mGeoWidget = new GeoWidget( tab3 ); 937 mGeoWidget = new GeoWidget( tab3 );
938 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() ); 938 mGeoWidget->setMinimumSize( mGeoWidget->sizeHint() );
939 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 939 connect( mGeoWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
940 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop ); 940 layout->addWidget( mGeoWidget, 0, 0, Qt::AlignTop );
941*/ 941*/
942 ////////////////////////////////////// 942 //////////////////////////////////////
943 // Sound 943 // Sound
944#ifndef KAB_EMBEDDED 944#ifndef KAB_EMBEDDED
945 mSoundWidget = new SoundWidget( tab3 ); 945 mSoundWidget = new SoundWidget( tab3 );
946 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() ); 946 mSoundWidget->setMinimumSize( mSoundWidget->sizeHint() );
947 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 947 connect( mSoundWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
948 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop ); 948 layout->addWidget( mSoundWidget, 0, 1, Qt::AlignTop );
949#else //KAB_EMBEDDED 949#else //KAB_EMBEDDED
950//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed"); 950//US qDebug("AddresseeEditorWidget::setupTab2 sound part is not supported = has to be changed");
951#endif //KAB_EMBEDDED 951#endif //KAB_EMBEDDED
952 952
953 ////////////////////////////////////// 953 //////////////////////////////////////
954 // Images 954 // Images
955 mImageWidget = new ImageWidget( tab3 ); 955 mImageWidget = new ImageWidget( tab3 );
956 mImageWidget->setMinimumSize( mImageWidget->sizeHint() ); 956 mImageWidget->setMinimumSize( mImageWidget->sizeHint() );
957 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 957 connect( mImageWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
958 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop ); 958 layout->addWidget( mImageWidget, 0, 0, Qt::AlignTop );
959/*US 959/*US
960 ////////////////////////////////////// 960 //////////////////////////////////////
961 // Keys 961 // Keys
962 mKeyWidget = new KeyWidget( tab3 ); 962 mKeyWidget = new KeyWidget( tab3 );
963 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() ); 963 mKeyWidget->setMinimumSize( mKeyWidget->sizeHint() );
964 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) ); 964 connect( mKeyWidget, SIGNAL( changed() ), SLOT( emitModified() ) );
965 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop ); 965 layout->addWidget( mKeyWidget, 1, 1, Qt::AlignTop );
966*/ 966*/
967 mTabWidget->addTab( tab3, i18n( "&Images" ) ); 967 mTabWidget->addTab( tab3, i18n( "&Images" ) );
968} 968}
969 969
970 970
971void AddresseeEditorWidget::load() 971void AddresseeEditorWidget::load()
972{ 972{
973 973
974 // Block signals in case anything tries to emit modified 974 // Block signals in case anything tries to emit modified
975 // CS: This doesn't seem to work. 975 // CS: This doesn't seem to work.
976 bool block = signalsBlocked(); 976 bool block = signalsBlocked();
977 blockSignals( true ); 977 blockSignals( true );
978 mBlockSignals = true; // used for internal signal blocking 978 mBlockSignals = true; // used for internal signal blocking
979 979
980 mNameEdit->setText( mAddressee.assembledName() ); 980 mNameEdit->setText( mAddressee.assembledName() );
981 981
982 if ( mAddressee.formattedName().isEmpty() ) { 982 if ( mAddressee.formattedName().isEmpty() ) {
983//US KConfig config( "kaddressbookrc" ); 983//US KConfig config( "kaddressbookrc" );
984 KConfig config( locateLocal("config", "kaddressbookrc") ); 984 KConfig config( locateLocal("config", "kabcrc") );
985 config.setGroup( "General" ); 985 config.setGroup( "General" );
986 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 ); 986 mFormattedNameType = config.readNumEntry( "FormattedNameType", 1 );
987 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 987 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
988 } else { 988 } else {;
989 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) ) 989 if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::SimpleName ) )
990 mFormattedNameType = NameEditDialog::SimpleName; 990 mFormattedNameType = NameEditDialog::SimpleName;
991 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) ) 991 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::FullName ) )
992 mFormattedNameType = NameEditDialog::FullName; 992 mFormattedNameType = NameEditDialog::FullName;
993 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) ) 993 else if ( mAddressee.formattedName() == NameEditDialog::formattedName( mAddressee, NameEditDialog::ReverseName ) )
994 mFormattedNameType = NameEditDialog::ReverseName; 994 mFormattedNameType = NameEditDialog::ReverseName;
995 else 995 else
996 mFormattedNameType = NameEditDialog::CustomName; 996 mFormattedNameType = NameEditDialog::CustomName;
997 } 997 }
998 998
999 mFormattedNameLabel->setText( mAddressee.formattedName() ); 999 mFormattedNameLabel->setText( mAddressee.formattedName() );
1000 1000
1001 mRoleEdit->setText( mAddressee.role() ); 1001 mRoleEdit->setText( mAddressee.role() );
1002 mOrgEdit->setText( mAddressee.organization() ); 1002 mOrgEdit->setText( mAddressee.organization() );
1003 1003
1004//US mURLEdit->setURL( mAddressee.url().url() ); 1004//US mURLEdit->setURL( mAddressee.url().url() );
1005 mURLEdit->setText( mAddressee.url().prettyURL() ); 1005 mURLEdit->setText( mAddressee.url().prettyURL() );
1006//US?? mURLEdit->home( false ); 1006//US?? mURLEdit->home( false );
1007 1007
1008 // mNoteEdit->setText( mAddressee.note() ); 1008 // mNoteEdit->setText( mAddressee.note() );
1009 mNoteEdit->setText( mAddressee.note() ); 1009 mNoteEdit->setText( mAddressee.note() );
1010 mEmailWidget->setEmails( mAddressee.emails() ); 1010 mEmailWidget->setEmails( mAddressee.emails() );
1011 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() ); 1011 mPhoneEditWidget->setPhoneNumbers( mAddressee.phoneNumbers() );
1012 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() ); 1012 mAddressEditWidget->setAddresses( mAddressee, mAddressee.addresses() );
1013 mBirthdayPicker->setDate( mAddressee.birthday().date() ); 1013 mBirthdayPicker->setDate( mAddressee.birthday().date() );
1014 1014
1015//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom( 1015//US mAnniversaryPicker->setDate( QDate::fromString( mAddressee.custom(
1016//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) ); 1016//US "KADDRESSBOOK", "X-Anniversary" ), Qt::ISODate) );
1017 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1017 QDate dt = KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1018 "%Y-%m-%d"); // = Qt::ISODate 1018 "%Y-%m-%d"); // = Qt::ISODate
1019 mAnniversaryPicker->setDate( dt ); 1019 mAnniversaryPicker->setDate( dt );
1020 1020
1021 1021
1022 mNicknameEdit->setText( mAddressee.nickName() ); 1022 mNicknameEdit->setText( mAddressee.nickName() );
1023 mCategoryEdit->setText( mAddressee.categories().join( "," ) ); 1023 mCategoryEdit->setText( mAddressee.categories().join( "," ) );
1024 1024
1025 mGeoWidget->setGeo( mAddressee.geo() ); 1025 mGeoWidget->setGeo( mAddressee.geo() );
1026 mImageWidget->setPhoto( mAddressee.photo() ); 1026 mImageWidget->setPhoto( mAddressee.photo() );
1027 mImageWidget->setLogo( mAddressee.logo() ); 1027 mImageWidget->setLogo( mAddressee.logo() );
1028 mKeyWidget->setKeys( mAddressee.keys() ); 1028 mKeyWidget->setKeys( mAddressee.keys() );
1029 mSecrecyWidget->setSecrecy( mAddressee.secrecy() ); 1029 mSecrecyWidget->setSecrecy( mAddressee.secrecy() );
1030#ifndef KAB_EMBEDDED 1030#ifndef KAB_EMBEDDED
1031 mSoundWidget->setSound( mAddressee.sound() ); 1031 mSoundWidget->setSound( mAddressee.sound() );
1032#else //KAB_EMBEDDED 1032#else //KAB_EMBEDDED
1033//US qDebug("AddresseeEditorWidget::load has to be changed 2"); 1033//US qDebug("AddresseeEditorWidget::load has to be changed 2");
1034#endif //KAB_EMBEDDED 1034#endif //KAB_EMBEDDED
1035 1035
1036 // Load customs 1036 // Load customs
1037 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) ); 1037 mIMAddressEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ) );
1038 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) ); 1038 mSpouseEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ) );
1039 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) ); 1039 mChildEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Children" ) );
1040 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) ); 1040 mManagerEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ) );
1041 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) ); 1041 mAssistantEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ) );
1042 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) ); 1042 mDepartmentEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Department" ) );
1043 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) ); 1043 mOfficeEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Office" ) );
1044 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) ); 1044 mProfessionEdit->setText( mAddressee.custom( "KADDRESSBOOK", "X-Profession" ) );
1045 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 1045 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
1046 if ( gen == "female" ) 1046 if ( gen == "female" )
1047 mGenderBox->setCurrentItem ( 1 ); 1047 mGenderBox->setCurrentItem ( 1 );
1048 else if ( gen == "male" ) 1048 else if ( gen == "male" )
1049 mGenderBox->setCurrentItem ( 2 ); 1049 mGenderBox->setCurrentItem ( 2 );
1050 else 1050 else
1051 mGenderBox->setCurrentItem ( 0 ); 1051 mGenderBox->setCurrentItem ( 0 );
1052 blockSignals( block ); 1052 blockSignals( block );
1053 mBlockSignals = false; 1053 mBlockSignals = false;
1054 1054
1055 mDirty = false; 1055 mDirty = false;
1056} 1056}
1057 1057
1058void AddresseeEditorWidget::save() 1058void AddresseeEditorWidget::save()
1059{ 1059{
1060 if ( !dirty() ) { 1060 if ( !dirty() ) {
1061 return; 1061 return;
1062 } 1062 }
1063 1063
1064 mAddressee.setRevision( QDateTime::currentDateTime() ); 1064 mAddressee.setRevision( QDateTime::currentDateTime() );
1065 1065
1066 mAddressee.setRole( mRoleEdit->text() ); 1066 mAddressee.setRole( mRoleEdit->text() );
1067 mAddressee.setOrganization( mOrgEdit->text() ); 1067 mAddressee.setOrganization( mOrgEdit->text() );
1068 mAddressee.setUrl( KURL( mURLEdit->text() ) ); 1068 mAddressee.setUrl( KURL( mURLEdit->text() ) );
1069 mAddressee.setNote( mNoteEdit->text() ); 1069 mAddressee.setNote( mNoteEdit->text() );
1070 if ( mBirthdayPicker->inputIsValid() ) { 1070 if ( mBirthdayPicker->inputIsValid() ) {
1071 QDate da = mBirthdayPicker->date(); 1071 QDate da = mBirthdayPicker->date();
1072 if ( da > QDate::currentDate() ) 1072 if ( da > QDate::currentDate() )
1073 da.setYMD(da.year()-100, da.month(), da.day() ); 1073 da.setYMD(da.year()-100, da.month(), da.day() );
1074 mAddressee.setBirthday( QDateTime( da ) ); 1074 mAddressee.setBirthday( QDateTime( da ) );
1075 //qDebug("bday %s ",da.toString().latin1()); 1075 //qDebug("bday %s ",da.toString().latin1());
1076 } 1076 }
1077 else { 1077 else {
1078 mAddressee.setBirthday( QDateTime() ); 1078 mAddressee.setBirthday( QDateTime() );
1079 mBirthdayPicker->clear(); 1079 mBirthdayPicker->clear();
1080 } 1080 }
1081 mAddressee.setNickName( mNicknameEdit->text() ); 1081 mAddressee.setNickName( mNicknameEdit->text() );
1082 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) ); 1082 mAddressee.setCategories( QStringList::split( ",", mCategoryEdit->text() ) );
1083 1083
1084 mAddressee.setGeo( mGeoWidget->geo() ); 1084 mAddressee.setGeo( mGeoWidget->geo() );
1085 mAddressee.setPhoto( mImageWidget->photo() ); 1085 mAddressee.setPhoto( mImageWidget->photo() );
1086 mAddressee.setLogo( mImageWidget->logo() ); 1086 mAddressee.setLogo( mImageWidget->logo() );
1087 mAddressee.setKeys( mKeyWidget->keys() ); 1087 mAddressee.setKeys( mKeyWidget->keys() );
1088#ifndef KAB_EMBEDDED 1088#ifndef KAB_EMBEDDED
1089 mAddressee.setSound( mSoundWidget->sound() ); 1089 mAddressee.setSound( mSoundWidget->sound() );
1090#else //KAB_EMBEDDED 1090#else //KAB_EMBEDDED
1091//US qDebug("AddresseeEditorWidget::save sound not supported"); 1091//US qDebug("AddresseeEditorWidget::save sound not supported");
1092#endif //KAB_EMBEDDED 1092#endif //KAB_EMBEDDED
1093 mAddressee.setSecrecy( mSecrecyWidget->secrecy() ); 1093 mAddressee.setSecrecy( mSecrecyWidget->secrecy() );
1094 1094
1095 // save custom fields 1095 // save custom fields
1096 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() ); 1096 mAddressee.insertCustom( "KADDRESSBOOK", "X-IMAddress", mIMAddressEdit->text() );
1097 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() ); 1097 mAddressee.insertCustom( "KADDRESSBOOK", "X-SpousesName", mSpouseEdit->text() );
1098 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() ); 1098 mAddressee.insertCustom( "KADDRESSBOOK", "X-Children", mChildEdit->text() );
1099 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() ); 1099 mAddressee.insertCustom( "KADDRESSBOOK", "X-ManagersName", mManagerEdit->text() );
1100 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() ); 1100 mAddressee.insertCustom( "KADDRESSBOOK", "X-AssistantsName", mAssistantEdit->text() );
1101 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() ); 1101 mAddressee.insertCustom( "KADDRESSBOOK", "X-Department", mDepartmentEdit->text() );
1102 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() ); 1102 mAddressee.insertCustom( "KADDRESSBOOK", "X-Office", mOfficeEdit->text() );
1103 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() ); 1103 mAddressee.insertCustom( "KADDRESSBOOK", "X-Profession", mProfessionEdit->text() );
1104 if ( mAnniversaryPicker->inputIsValid() ) { 1104 if ( mAnniversaryPicker->inputIsValid() ) {
1105 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate); 1105 QString dt = KGlobal::locale()->formatDate(mAnniversaryPicker->date(), true, KLocale::ISODate);
1106 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); 1106 mAddressee.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt);
1107 } 1107 }
1108 else { 1108 else {
1109 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" ); 1109 mAddressee.removeCustom( "KADDRESSBOOK", "X-Anniversary" );
1110 mAnniversaryPicker->clear(); 1110 mAnniversaryPicker->clear();
1111 } 1111 }
1112 int gen = mGenderBox->currentItem (); 1112 int gen = mGenderBox->currentItem ();
1113 if ( gen == 1 ) 1113 if ( gen == 1 )
1114 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female"); 1114 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "female");
1115 else if ( gen == 2 ) 1115 else if ( gen == 2 )
1116 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male"); 1116 mAddressee.insertCustom( "KADDRESSBOOK", "X-Gender", "male");
1117 else 1117 else
1118 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" ); 1118 mAddressee.removeCustom( "KADDRESSBOOK", "X-Gender" );
1119 1119
1120 // Save the email addresses 1120 // Save the email addresses
1121 QStringList emails = mAddressee.emails(); 1121 QStringList emails = mAddressee.emails();
1122 QStringList::Iterator iter; 1122 QStringList::Iterator iter;
1123 for ( iter = emails.begin(); iter != emails.end(); ++iter ) 1123 for ( iter = emails.begin(); iter != emails.end(); ++iter )
1124 mAddressee.removeEmail( *iter ); 1124 mAddressee.removeEmail( *iter );
1125 1125
1126 emails = mEmailWidget->emails(); 1126 emails = mEmailWidget->emails();
1127 bool first = true; 1127 bool first = true;
1128 for ( iter = emails.begin(); iter != emails.end(); ++iter ) { 1128 for ( iter = emails.begin(); iter != emails.end(); ++iter ) {
1129 mAddressee.insertEmail( *iter, first ); 1129 mAddressee.insertEmail( *iter, first );
1130 first = false; 1130 first = false;
1131 } 1131 }
1132 1132
1133 // Save the phone numbers 1133 // Save the phone numbers
1134 KABC::PhoneNumber::List phoneNumbers; 1134 KABC::PhoneNumber::List phoneNumbers;
1135 KABC::PhoneNumber::List::Iterator phoneIter; 1135 KABC::PhoneNumber::List::Iterator phoneIter;
1136 phoneNumbers = mAddressee.phoneNumbers(); 1136 phoneNumbers = mAddressee.phoneNumbers();
1137 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1137 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1138 ++phoneIter ) 1138 ++phoneIter )
1139 mAddressee.removePhoneNumber( *phoneIter ); 1139 mAddressee.removePhoneNumber( *phoneIter );
1140 1140
1141 phoneNumbers = mPhoneEditWidget->phoneNumbers(); 1141 phoneNumbers = mPhoneEditWidget->phoneNumbers();
1142 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end(); 1142 for ( phoneIter = phoneNumbers.begin(); phoneIter != phoneNumbers.end();
1143 ++phoneIter ) 1143 ++phoneIter )
1144 mAddressee.insertPhoneNumber( *phoneIter ); 1144 mAddressee.insertPhoneNumber( *phoneIter );
1145 1145
1146 // Save the addresses 1146 // Save the addresses
1147 KABC::Address::List addresses; 1147 KABC::Address::List addresses;
1148 KABC::Address::List::Iterator addressIter; 1148 KABC::Address::List::Iterator addressIter;
1149 addresses = mAddressee.addresses(); 1149 addresses = mAddressee.addresses();
1150 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1150 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1151 ++addressIter ) 1151 ++addressIter )
1152 mAddressee.removeAddress( *addressIter ); 1152 mAddressee.removeAddress( *addressIter );
1153 1153
1154 addresses = mAddressEditWidget->addresses(); 1154 addresses = mAddressEditWidget->addresses();
1155 for ( addressIter = addresses.begin(); addressIter != addresses.end(); 1155 for ( addressIter = addresses.begin(); addressIter != addresses.end();
1156 ++addressIter ) 1156 ++addressIter )
1157 mAddressee.insertAddress( *addressIter ); 1157 mAddressee.insertAddress( *addressIter );
1158 mDirty = false; 1158 mDirty = false;
1159} 1159}
1160 1160
1161bool AddresseeEditorWidget::dirty() 1161bool AddresseeEditorWidget::dirty()
1162{ 1162{
1163 1163
1164 if ( ! mDirty ) { 1164 if ( ! mDirty ) {
1165 if ( mBirthdayPicker->inputIsValid() ) { 1165 if ( mBirthdayPicker->inputIsValid() ) {
1166 QDate da = mBirthdayPicker->date(); 1166 QDate da = mBirthdayPicker->date();
1167 if ( !(da == mAddressee.birthday().date())) 1167 if ( !(da == mAddressee.birthday().date()))
1168 mDirty = true; 1168 mDirty = true;
1169 } 1169 }
1170 else { 1170 else {
1171 mBirthdayPicker->clear(); 1171 mBirthdayPicker->clear();
1172 } 1172 }
1173 if ( mAnniversaryPicker->inputIsValid() ) { 1173 if ( mAnniversaryPicker->inputIsValid() ) {
1174 QDate da = mAnniversaryPicker->date(); 1174 QDate da = mAnniversaryPicker->date();
1175 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ), 1175 if ( da != KGlobal::locale()->readDate( mAddressee.custom("KADDRESSBOOK", "X-Anniversary" ),
1176 "%Y-%m-%d")) 1176 "%Y-%m-%d"))
1177 mDirty = true; 1177 mDirty = true;
1178 } 1178 }
1179 else { 1179 else {
1180 mAnniversaryPicker->clear(); 1180 mAnniversaryPicker->clear();
1181 } 1181 }
1182 } 1182 }
1183 return mDirty; 1183 return mDirty;
1184} 1184}
1185 1185
1186void AddresseeEditorWidget::nameTextChanged( const QString &text ) 1186void AddresseeEditorWidget::nameTextChanged( const QString &text )
1187{ 1187{
1188 if ( mBlockSignals )
1189 return;
1188 // use the addressee class to parse the name for us 1190 // use the addressee class to parse the name for us
1189 mAConfig->setUid( mAddressee.uid() ); 1191 mAConfig->setUid( mAddressee.uid() );
1190 if ( mAConfig->automaticNameParsing() ) { 1192 if ( mAConfig->automaticNameParsing() ) {
1191 if ( !mAddressee.formattedName().isEmpty() ) { 1193 if ( !mAddressee.formattedName().isEmpty() ) {
1192 QString fn = mAddressee.formattedName(); 1194 QString fn = mAddressee.formattedName();
1193 mAddressee.setNameFromString( text ); 1195 mAddressee.setNameFromString( text );
1194 mAddressee.setFormattedName( fn ); 1196 mAddressee.setFormattedName( fn );
1195 } else { 1197 } else {
1196 // use extra addressee to avoid a formatted name assignment 1198 // use extra addressee to avoid a formatted name assignment
1197 Addressee addr; 1199 Addressee addr;
1198 addr.setNameFromString( text ); 1200 addr.setNameFromString( text );
1199 mAddressee.setPrefix( addr.prefix() ); 1201 mAddressee.setPrefix( addr.prefix() );
1200 mAddressee.setGivenName( addr.givenName() ); 1202 mAddressee.setGivenName( addr.givenName() );
1201 mAddressee.setAdditionalName( addr.additionalName() ); 1203 mAddressee.setAdditionalName( addr.additionalName() );
1202 mAddressee.setFamilyName( addr.familyName() ); 1204 mAddressee.setFamilyName( addr.familyName() );
1203 mAddressee.setSuffix( addr.suffix() ); 1205 mAddressee.setSuffix( addr.suffix() );
1204 } 1206 }
1205 } 1207 }
1206 1208
1207 nameBoxChanged(); 1209 nameBoxChanged();
1208 1210
1209 emitModified(); 1211 emitModified();
1210} 1212}
1211 1213
1212void AddresseeEditorWidget::nameBoxChanged() 1214void AddresseeEditorWidget::nameBoxChanged()
1213{ 1215{
1214 KABC::Addressee addr; 1216 KABC::Addressee addr;
1215 mAConfig->setUid( mAddressee.uid() ); 1217 mAConfig->setUid( mAddressee.uid() );
1216 if ( mAConfig->automaticNameParsing() ) { 1218 if ( mAConfig->automaticNameParsing() ) {
1217 addr.setNameFromString( mNameEdit->text() ); 1219 addr.setNameFromString( mNameEdit->text() );
1218 mNameLabel->hide(); 1220 mNameLabel->hide();
1219 mNameEdit->show(); 1221 mNameEdit->show();
1220 } else { 1222 } else {
1221 addr = mAddressee; 1223 addr = mAddressee;
1222 mNameEdit->hide(); 1224 mNameEdit->hide();
1223 mNameLabel->setText( mNameEdit->text() ); 1225 mNameLabel->setText( mNameEdit->text() );
1224 mNameLabel->show(); 1226 mNameLabel->show();
1225 } 1227 }
1226 1228
1227 if ( mFormattedNameType != NameEditDialog::CustomName ) { 1229 if ( mFormattedNameType != NameEditDialog::CustomName ) {
1228 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1230 mFormattedNameLabel->setText( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1229 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) ); 1231 mAddressee.setFormattedName( NameEditDialog::formattedName( mAddressee, mFormattedNameType ) );
1230 } 1232 }
1231} 1233}
1232 1234
1233void AddresseeEditorWidget::nameButtonClicked() 1235void AddresseeEditorWidget::nameButtonClicked()
1234{ 1236{
1235 // show the name dialog. 1237 // show the name dialog.
1236 NameEditDialog dialog( mAddressee, mFormattedNameType, this ); 1238 NameEditDialog dialog( mAddressee, mFormattedNameType, this );
1237 1239
1238 if ( KApplication::execDialog( &dialog) ) { 1240 if ( KApplication::execDialog( &dialog) ) {
1239 if ( dialog.changed() ) { 1241 if ( dialog.changed() ) {
1240 mAddressee.setFamilyName( dialog.familyName() ); 1242 mAddressee.setFamilyName( dialog.familyName() );
1241 mAddressee.setGivenName( dialog.givenName() ); 1243 mAddressee.setGivenName( dialog.givenName() );
1242 mAddressee.setPrefix( dialog.prefix() ); 1244 mAddressee.setPrefix( dialog.prefix() );
1243 mAddressee.setSuffix( dialog.suffix() ); 1245 mAddressee.setSuffix( dialog.suffix() );
1244 mAddressee.setAdditionalName( dialog.additionalName() ); 1246 mAddressee.setAdditionalName( dialog.additionalName() );
1245 mFormattedNameType = dialog.formattedNameType(); 1247 mFormattedNameType = dialog.formattedNameType();
1246 if ( mFormattedNameType == NameEditDialog::CustomName ) { 1248 if ( mFormattedNameType == NameEditDialog::CustomName ) {
1247 mFormattedNameLabel->setText( dialog.customFormattedName() ); 1249 mFormattedNameLabel->setText( dialog.customFormattedName() );
1248 mAddressee.setFormattedName( dialog.customFormattedName() ); 1250 mAddressee.setFormattedName( dialog.customFormattedName() );
1249 } 1251 }
1250 // Update the name edit. 1252 // Update the name edit.
1251 bool block = mNameEdit->signalsBlocked(); 1253 bool block = mNameEdit->signalsBlocked();
1252 mNameEdit->blockSignals( true ); 1254 mNameEdit->blockSignals( true );
1253 mNameEdit->setText( mAddressee.assembledName() ); 1255 mNameEdit->setText( mAddressee.assembledName() );
1254 mNameEdit->blockSignals( block ); 1256 mNameEdit->blockSignals( block );
1255 1257
1256 // Update the combo box. 1258 // Update the combo box.
1257 nameBoxChanged(); 1259 nameBoxChanged();
1258 1260
1259 emitModified(); 1261 emitModified();
1260 } 1262 }
1261 } 1263 }
1262} 1264}
1263 1265
1264void AddresseeEditorWidget::categoryButtonClicked() 1266void AddresseeEditorWidget::categoryButtonClicked()
1265{ 1267{
1266 // Show the category dialog 1268 // Show the category dialog
1267 if ( mCategoryDialog == 0 ) { 1269 if ( mCategoryDialog == 0 ) {
1268 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this ); 1270 mCategoryDialog = new KPIM::CategorySelectDialog( KABPrefs::instance(), this );
1269 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ), 1271 connect( mCategoryDialog, SIGNAL( categoriesSelected( const QStringList& ) ),
1270 SLOT(categoriesSelected( const QStringList& ) ) ); 1272 SLOT(categoriesSelected( const QStringList& ) ) );
1271 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) ); 1273 connect( mCategoryDialog, SIGNAL( editCategories() ), SLOT( editCategories() ) );
1272 } 1274 }
1273 1275
1274 mCategoryDialog->setCategories(); 1276 mCategoryDialog->setCategories();
1275 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) ); 1277 mCategoryDialog->setSelected( QStringList::split( ",", mCategoryEdit->text() ) );
1276 mCategoryDialog->show(); 1278 mCategoryDialog->show();
1277 mCategoryDialog->raise(); 1279 mCategoryDialog->raise();
1278} 1280}
1279 1281
1280void AddresseeEditorWidget::categoriesSelected( const QStringList &list ) 1282void AddresseeEditorWidget::categoriesSelected( const QStringList &list )
1281{ 1283{
1282 mCategoryEdit->setText( list.join( "," ) ); 1284 mCategoryEdit->setText( list.join( "," ) );
1283} 1285}
1284 1286
1285void AddresseeEditorWidget::editCategories() 1287void AddresseeEditorWidget::editCategories()
1286{ 1288{
1287 if ( mCategoryEditDialog == 0 ) { 1289 if ( mCategoryEditDialog == 0 ) {
1288 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this ); 1290 mCategoryEditDialog = new KPIM::CategoryEditDialog( KABPrefs::instance(), this );
1289 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ), 1291 connect( mCategoryEditDialog, SIGNAL( categoryConfigChanged() ),
1290 SLOT( categoryButtonClicked() ) ); 1292 SLOT( categoryButtonClicked() ) );
1291 } 1293 }
1292 1294
1293 mCategoryEditDialog->show(); 1295 mCategoryEditDialog->show();
1294 mCategoryEditDialog->raise(); 1296 mCategoryEditDialog->raise();
1295} 1297}
1296 1298
1297void AddresseeEditorWidget::emitModified() 1299void AddresseeEditorWidget::emitModified()
1298{ 1300{
1299 mDirty = true; 1301 mDirty = true;
1300 1302
1301 KABC::Addressee::List list; 1303 KABC::Addressee::List list;
1302 1304
1303 if ( mIsExtension && !mBlockSignals ) { 1305 if ( mIsExtension && !mBlockSignals ) {
1304 save(); 1306 save();
1305 list.append( mAddressee ); 1307 list.append( mAddressee );
1306 } 1308 }
1307 1309
1308 emit modified( list ); 1310 emit modified( list );
1309} 1311}
1310 1312
1311void AddresseeEditorWidget::dateChanged( QDate ) 1313void AddresseeEditorWidget::dateChanged( QDate )
1312{ 1314{
1313 emitModified(); 1315 emitModified();
1314} 1316}
1315 1317
1316//US invalid dates are handdled by the KDateEdit widget itself 1318//US invalid dates are handdled by the KDateEdit widget itself
1317void AddresseeEditorWidget::invalidDate() 1319void AddresseeEditorWidget::invalidDate()
1318{ 1320{
1319 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) ); 1321 KMessageBox::sorry( this, i18n( "You must specify a valid date" ) );
1320} 1322}
1321 1323
1322 1324
1323void AddresseeEditorWidget::pageChanged( QWidget *wdg ) 1325void AddresseeEditorWidget::pageChanged( QWidget *wdg )
1324{ 1326{
1325#ifndef KAB_EMBEDDED 1327#ifndef KAB_EMBEDDED
1326 if ( wdg ) 1328 if ( wdg )
1327 KAcceleratorManager::manage( wdg ); 1329 KAcceleratorManager::manage( wdg );
1328#else //KAB_EMBEDDED 1330#else //KAB_EMBEDDED
1329//US 1331//US
1330#endif //KAB_EMBEDDED 1332#endif //KAB_EMBEDDED
1331 1333
1332} 1334}
1333 1335
1334QString AddresseeEditorWidget::title() const 1336QString AddresseeEditorWidget::title() const
1335{ 1337{
1336 return i18n( "Contact Editor" ); 1338 return i18n( "Contact Editor" );
1337} 1339}
1338 1340
1339QString AddresseeEditorWidget::identifier() const 1341QString AddresseeEditorWidget::identifier() const
1340{ 1342{
1341 return i18n( "contact_editor" ); 1343 return i18n( "contact_editor" );
1342} 1344}
1343 1345
1344#ifndef KAB_EMBEDDED 1346#ifndef KAB_EMBEDDED
1345#include "addresseeeditorwidget.moc" 1347#include "addresseeeditorwidget.moc"
1346#endif //KAB_EMBEDDED 1348#endif //KAB_EMBEDDED
diff --git a/kaddressbook/extensionmanager.cpp b/kaddressbook/extensionmanager.cpp
index 98561dc..efbdf17 100644
--- a/kaddressbook/extensionmanager.cpp
+++ b/kaddressbook/extensionmanager.cpp
@@ -1,248 +1,249 @@
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#include <qlayout.h> 23#include <qlayout.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <kactionclasses.h> 25#include <kactionclasses.h>
26#include <kconfig.h> 26#include <kconfig.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <klocale.h> 28#include <klocale.h>
29 29
30#ifndef KAB_EMBEDDED 30#ifndef KAB_EMBEDDED
31#include <ktrader.h> 31#include <ktrader.h>
32#else //KAB_EMBEDDED 32#else //KAB_EMBEDDED
33#include <features/mergewidget.h> 33#include <features/mergewidget.h>
34#include <features/distributionlistwidget.h> 34#include <features/distributionlistwidget.h>
35#endif //KAB_EMBEDDED 35#endif //KAB_EMBEDDED
36 36
37#include "addresseeeditorwidget.h" 37#include "addresseeeditorwidget.h"
38#include "kabcore.h" 38#include "kabcore.h"
39#include "kabprefs.h" 39#include "kabprefs.h"
40 40
41#include "extensionmanager.h" 41#include "extensionmanager.h"
42 42
43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent, 43ExtensionManager::ExtensionManager( KABCore *core, QWidget *parent,
44 const char *name ) 44 const char *name )
45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 ) 45 : QScrollView( parent, name ), mCore( core ), mCurrentExtensionWidget( 0 )
46{ 46{
47#ifdef KAB_EMBEDDED 47#ifdef KAB_EMBEDDED
48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 48//US QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
49 QWidget *settingsmenu = (QWidget*)mCore->getSettingsMenu(); 49 QWidget *settingsmenu = (QWidget*)mCore->getSettingsMenu();
50#endif //KAB_EMBEDDED 50#endif //KAB_EMBEDDED
51 51
52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0, 52 mActionExtensions = new KSelectAction( i18n( "Show Extension Bar" ), 0,
53 mCore->actionCollection(), 53 mCore->actionCollection(),
54 "options_show_extensions" ); 54 "options_show_extensions" );
55 55
56 mActionExtensions->plug( settingsmenu ); 56 mActionExtensions->plug( settingsmenu );
57 57
58 connect( mActionExtensions, SIGNAL( activated( int ) ), 58 connect( mActionExtensions, SIGNAL( activated( int ) ),
59 SLOT( setActiveExtension( int ) ) ); 59 SLOT( setActiveExtension( int ) ) );
60 mWidgetBox = new QWidget( viewport() ); 60 mWidgetBox = new QWidget( viewport() );
61 new QHBoxLayout (mWidgetBox );
61 addChild( mWidgetBox ); 62 addChild( mWidgetBox );
62 setResizePolicy(AutoOneFit); 63 setResizePolicy(AutoOneFit);
63 createExtensionWidgets(); 64 createExtensionWidgets();
64 hide(); 65 hide();
65} 66}
66 67
67ExtensionManager::~ExtensionManager() 68ExtensionManager::~ExtensionManager()
68{ 69{
69} 70}
70 71
71void ExtensionManager::restoreSettings() 72void ExtensionManager::restoreSettings()
72{ 73{
73 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension ); 74 mActionExtensions->setCurrentItem( KABPrefs::instance()->mCurrentExtension );
74 int i = 1; 75 int i = 1;
75 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 ); 76 mCurrentExtensionWidget = mExtensionWidgetList.at( i-1 );
76 while ( mCurrentExtensionWidget ) { 77 while ( mCurrentExtensionWidget ) {
77 if( i != KABPrefs::instance()->mCurrentExtension ) 78 if( i != KABPrefs::instance()->mCurrentExtension )
78 mCurrentExtensionWidget->hide(); 79 mCurrentExtensionWidget->hide();
79 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 ); 80 mCurrentExtensionWidget = mExtensionWidgetList.at( ++i-1 );
80 81
81 } 82 }
82 setActiveExtension( mActionExtensions->currentItem() ); 83 setActiveExtension( mActionExtensions->currentItem() );
83} 84}
84 85
85void ExtensionManager::saveSettings() 86void ExtensionManager::saveSettings()
86{ 87{
87 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem(); 88 KABPrefs::instance()->mCurrentExtension = mActionExtensions->currentItem();
88} 89}
89 90
90void ExtensionManager::reconfigure() 91void ExtensionManager::reconfigure()
91{ 92{
92 saveSettings(); 93 saveSettings();
93 createExtensionWidgets(); 94 createExtensionWidgets();
94 restoreSettings(); 95 restoreSettings();
95} 96}
96 97
97bool ExtensionManager::isQuickEditVisible() const 98bool ExtensionManager::isQuickEditVisible() const
98{ 99{
99 return ( mCurrentExtensionWidget && 100 return ( mCurrentExtensionWidget &&
100 mCurrentExtensionWidget->identifier() == "contact_editor" ); 101 mCurrentExtensionWidget->identifier() == "contact_editor" );
101} 102}
102 103
103void ExtensionManager::setSelectionChanged() 104void ExtensionManager::setSelectionChanged()
104{ 105{
105 if ( mCurrentExtensionWidget ) 106 if ( mCurrentExtensionWidget )
106 mCurrentExtensionWidget->contactsSelectionChanged(); 107 mCurrentExtensionWidget->contactsSelectionChanged();
107} 108}
108 109
109void ExtensionManager::setActiveExtension( int id ) 110void ExtensionManager::setActiveExtension( int id )
110{ 111{
111 //qDebug("+++++++++++++++++++ExtensionManager::setActiveExtension %d ", id); 112 //qDebug("+++++++++++++++++++ExtensionManager::setActiveExtension %d ", id);
112 if ( id == 0 ) { 113 if ( id == 0 ) {
113 hide(); 114 hide();
114 mCurrentExtensionWidget = 0; 115 mCurrentExtensionWidget = 0;
115#ifndef DESKTOP_VERSION 116#ifndef DESKTOP_VERSION
116//US our screen is so small, that we better hide the detailscreen, just in case. 117//US our screen is so small, that we better hide the detailscreen, just in case.
117//US mCore->setDetailsToState( ); 118//US mCore->setDetailsToState( );
118#endif //KAB_EMBEDDED 119#endif //KAB_EMBEDDED
119 } else if ( id > 0 ) { 120 } else if ( id > 0 ) {
120 if ( mCurrentExtensionWidget ) 121 if ( mCurrentExtensionWidget )
121 mCurrentExtensionWidget->hide(); 122 mCurrentExtensionWidget->hide();
122 123
123 mCurrentExtensionWidget = mExtensionWidgetList.at( id - 1 ); 124 mCurrentExtensionWidget = mExtensionWidgetList.at( id - 1 );
124 125
125 if ( mCurrentExtensionWidget ) { 126 if ( mCurrentExtensionWidget ) {
126#ifndef DESKTOP_VERSION 127#ifndef DESKTOP_VERSION
127//US our screen is so small, that we better hide the detailscreen, just in case. 128//US our screen is so small, that we better hide the detailscreen, just in case.
128//US mCore->setDetailsVisible( false ); 129//US mCore->setDetailsVisible( false );
129#endif //KAB_EMBEDDED 130#endif //KAB_EMBEDDED
130 show(); 131 show();
131 mWidgetBox->show(); 132 mWidgetBox->show();
132 mCurrentExtensionWidget->show(); 133 mCurrentExtensionWidget->show();
133 } else { 134 } else {
134 hide(); 135 hide();
135 mCurrentExtensionWidget = 0; 136 mCurrentExtensionWidget = 0;
136#ifndef DESKTOP_VERSION 137#ifndef DESKTOP_VERSION
137//US our screen is so small, that we better hide the detailscreen, just in case. 138//US our screen is so small, that we better hide the detailscreen, just in case.
138//US mCore->setDetailsToState( ); 139//US mCore->setDetailsToState( );
139#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
140 } 141 }
141 } 142 }
142 143
143 emit changedActiveExtension( id ); 144 emit changedActiveExtension( id );
144} 145}
145 146
146void ExtensionManager::createExtensionWidgets() 147void ExtensionManager::createExtensionWidgets()
147{ 148{
148 // clear extension widget list 149 // clear extension widget list
149 mExtensionWidgetList.setAutoDelete( true ); 150 mExtensionWidgetList.setAutoDelete( true );
150 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList ); 151 QPtrListIterator<ExtensionWidget> wdgIt( mExtensionWidgetList );
151 ExtensionWidget *wdg = 0; 152 ExtensionWidget *wdg = 0;
152 while ( ( wdg = wdgIt.current() ) != 0 ) 153 while ( ( wdg = wdgIt.current() ) != 0 )
153 mExtensionWidgetList.remove( wdg ); 154 mExtensionWidgetList.remove( wdg );
154 155
155 mExtensionWidgetList.setAutoDelete( false ); 156 mExtensionWidgetList.setAutoDelete( false );
156 157
157 QStringList extensionNames( i18n( "None" ) ); 158 QStringList extensionNames( i18n( "None" ) );
158 159
159 // add addressee editor as default 160 // add addressee editor as default
160 161
161 QHBoxLayout *hbl = new QHBoxLayout (mWidgetBox ); 162 QHBoxLayout *hbl = (QHBoxLayout *) mWidgetBox->layout();;
162 163
163 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox ); 164 wdg = new AddresseeEditorWidget( mCore, true, mWidgetBox );
164 hbl->addWidget( wdg ); 165 hbl->addWidget( wdg );
165 //wdg->hide(); 166 //wdg->hide();
166 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 167 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
167 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 168 SIGNAL( modified( const KABC::Addressee::List& ) ) );
168 mExtensionWidgetList.append( wdg ); 169 mExtensionWidgetList.append( wdg );
169 extensionNames.append( wdg->title() ); 170 extensionNames.append( wdg->title() );
170 171
171 // load the other extensions 172 // load the other extensions
172 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 173 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
173 174
174#ifndef KAB_EMBEDDED 175#ifndef KAB_EMBEDDED
175 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 176 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
176 KTrader::OfferList::ConstIterator it; 177 KTrader::OfferList::ConstIterator it;
177 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 178 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
178 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 179 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
179 continue; 180 continue;
180 181
181 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() ); 182 KLibFactory *factory = KLibLoader::self()->factory( (*it)->library().latin1() );
182 if ( !factory ) { 183 if ( !factory ) {
183 kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl; 184 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Factory creation failed" << endl;
184 continue; 185 continue;
185 } 186 }
186 187
187 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 188 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
188 189
189 if ( !extensionFactory ) { 190 if ( !extensionFactory ) {
190 kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl; 191 //kdDebug(5720) << "ExtensionManager::loadExtensions(): Cast failed" << endl;
191 continue; 192 continue;
192 } 193 }
193 194
194 if ( !activeExtensions.contains( extensionFactory->identifier() ) ) 195 if ( !activeExtensions.contains( extensionFactory->identifier() ) )
195 continue; 196 continue;
196 197
197 wdg = extensionFactory->extension( mCore, this ); 198 wdg = extensionFactory->extension( mCore, this );
198 if ( wdg ) { 199 if ( wdg ) {
199 //wdg->hide(); 200 //wdg->hide();
200 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 201 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
201 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 202 SIGNAL( modified( const KABC::Addressee::List& ) ) );
202 mExtensionWidgetList.append( wdg ); 203 mExtensionWidgetList.append( wdg );
203 extensionNames.append( wdg->title() ); 204 extensionNames.append( wdg->title() );
204 } 205 }
205 } 206 }
206#else //KAB_EMBEDDED 207#else //KAB_EMBEDDED
207 //load Mergefactory/extension 208 //load Mergefactory/extension
208 ExtensionFactory *extensionFactory = new MergeFactory(); 209 ExtensionFactory *extensionFactory = new MergeFactory();
209 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 210 if ( activeExtensions.contains( extensionFactory->identifier() ) )
210 { 211 {
211 wdg = extensionFactory->extension( mCore, mWidgetBox ); 212 wdg = extensionFactory->extension( mCore, mWidgetBox );
212 if ( wdg ) { 213 if ( wdg ) {
213 hbl->addWidget( wdg ); 214 hbl->addWidget( wdg );
214 //wdg->hide(); 215 //wdg->hide();
215 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 216 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
216 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 217 SIGNAL( modified( const KABC::Addressee::List& ) ) );
217 mExtensionWidgetList.append( wdg ); 218 mExtensionWidgetList.append( wdg );
218 extensionNames.append( wdg->title() ); 219 extensionNames.append( wdg->title() );
219 } 220 }
220 } 221 }
221 222
222 //load DistributionListfactory/extension 223 //load DistributionListfactory/extension
223 extensionFactory = new DistributionListFactory(); 224 extensionFactory = new DistributionListFactory();
224 if (activeExtensions.contains( extensionFactory->identifier() ) ) 225 if (activeExtensions.contains( extensionFactory->identifier() ) )
225 { 226 {
226 wdg = extensionFactory->extension( mCore, mWidgetBox ); 227 wdg = extensionFactory->extension( mCore, mWidgetBox );
227 if ( wdg ) { 228 if ( wdg ) {
228 hbl->addWidget( wdg ); 229 hbl->addWidget( wdg );
229 //wdg->hide(); 230 //wdg->hide();
230 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ), 231 connect( wdg, SIGNAL( modified( const KABC::Addressee::List& ) ),
231 SIGNAL( modified( const KABC::Addressee::List& ) ) ); 232 SIGNAL( modified( const KABC::Addressee::List& ) ) );
232 mExtensionWidgetList.append( wdg ); 233 mExtensionWidgetList.append( wdg );
233 extensionNames.append( wdg->title() ); 234 extensionNames.append( wdg->title() );
234 } 235 }
235 } 236 }
236 237
237 hbl->addStretch(); 238 hbl->addStretch();
238 239
239#endif //KAB_EMBEDDED 240#endif //KAB_EMBEDDED
240 241
241 242
242 mActionExtensions->setItems( extensionNames ); 243 mActionExtensions->setItems( extensionNames );
243 mCurrentExtensionWidget = 0; 244 mCurrentExtensionWidget = 0;
244} 245}
245 246
246#ifndef KAB_EMBEDDED 247#ifndef KAB_EMBEDDED
247#include "extensionmanager.moc" 248#include "extensionmanager.moc"
248#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index b0d04ca..39d2ae4 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -1,205 +1,206 @@
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#include <kconfig.h> 24#include <kconfig.h>
25#include <kconfigbase.h> 25#include <kconfigbase.h>
26#include <kdebug.h> 26#include <kdebug.h>
27 27
28#include "kabprefs.h" 28#include "kabprefs.h"
29 29
30#include "filter.h" 30#include "filter.h"
31 31
32Filter::Filter() 32Filter::Filter()
33 : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ), 33 : mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
34 mInternal( false ) 34 mInternal( false )
35{ 35{
36} 36}
37 37
38Filter::Filter( const QString &name ) 38Filter::Filter( const QString &name )
39 : mName( name ), mMatchRule( Matching ), mEnabled( true ), 39 : mName( name ), mMatchRule( Matching ), mEnabled( true ),
40 mInternal( false ) 40 mInternal( false )
41{ 41{
42} 42}
43 43
44Filter::~Filter() 44Filter::~Filter()
45{ 45{
46} 46}
47 47
48void Filter::setName( const QString &name ) 48void Filter::setName( const QString &name )
49{ 49{
50 mName = name; 50 mName = name;
51} 51}
52 52
53const QString &Filter::name() const 53const QString &Filter::name() const
54{ 54{
55 return mName; 55 return mName;
56} 56}
57 57
58bool Filter::isInternal() const 58bool Filter::isInternal() const
59{ 59{
60 return mInternal; 60 return mInternal;
61} 61}
62 62
63void Filter::apply( KABC::Addressee::List &addresseeList ) 63void Filter::apply( KABC::Addressee::List &addresseeList )
64{ 64{
65 KABC::Addressee::List::Iterator iter; 65 KABC::Addressee::List::Iterator iter;
66 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) { 66 for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) {
67 if ( filterAddressee( *iter ) ) 67 if ( filterAddressee( *iter ) )
68 ++iter; 68 ++iter;
69 else 69 else
70 { 70 {
71#ifndef KAB_EMBEDDED 71#ifndef KAB_EMBEDDED
72 iter = addresseeList.erase( iter ); 72 iter = addresseeList.erase( iter );
73#else //KAB_EMBEDDED 73#else //KAB_EMBEDDED
74 iter = addresseeList.remove( iter ); 74 iter = addresseeList.remove( iter );
75#endif //KAB_EMBEDDED 75#endif //KAB_EMBEDDED
76 } 76 }
77 } 77 }
78} 78}
79 79
80bool Filter::filterAddressee( const KABC::Addressee &a ) 80bool Filter::filterAddressee( const KABC::Addressee &a )
81{ 81{
82 QStringList::Iterator iter; 82 QStringList::Iterator iter;
83 iter = mCategoryList.begin(); 83 iter = mCategoryList.begin();
84 // empty filter always matches 84 // empty filter always matches
85 85
86 if ( iter == mCategoryList.end() ) 86 if ( iter == mCategoryList.end() )
87 return true; 87 return true;
88 88
89 for ( ; iter != mCategoryList.end(); ++iter ) { 89 for ( ; iter != mCategoryList.end(); ++iter ) {
90 if ( a.hasCategory( *iter ) ) 90 if ( a.hasCategory( *iter ) )
91 return ( mMatchRule == Matching ); 91 return ( mMatchRule == Matching );
92 } 92 }
93 93
94 return !( mMatchRule == Matching ); 94 return !( mMatchRule == Matching );
95} 95}
96 96
97void Filter::setEnabled( bool on ) 97void Filter::setEnabled( bool on )
98{ 98{
99 mEnabled = on; 99 mEnabled = on;
100} 100}
101 101
102bool Filter::isEnabled() const 102bool Filter::isEnabled() const
103{ 103{
104 return mEnabled; 104 return mEnabled;
105} 105}
106 106
107void Filter::setCategories( const QStringList &list ) 107void Filter::setCategories( const QStringList &list )
108{ 108{
109 mCategoryList = list; 109 mCategoryList = list;
110} 110}
111 111
112const QStringList &Filter::categories() const 112const QStringList &Filter::categories() const
113{ 113{
114 return mCategoryList; 114 return mCategoryList;
115} 115}
116 116
117void Filter::save( KConfig *config ) 117void Filter::save( KConfig *config )
118{ 118{
119 config->writeEntry( "Name", mName ); 119 config->writeEntry( "Name", mName );
120 config->writeEntry( "Enabled", mEnabled ); 120 config->writeEntry( "Enabled", mEnabled );
121 config->writeEntry( "Categories", mCategoryList ); 121 config->writeEntry( "Categories", mCategoryList );
122 config->writeEntry( "MatchRule", (int)mMatchRule ); 122 config->writeEntry( "MatchRule", (int)mMatchRule );
123} 123}
124 124
125void Filter::restore( KConfig *config ) 125void Filter::restore( KConfig *config )
126{ 126{
127 mName = config->readEntry( "Name", "<internal error>" ); 127 mName = config->readEntry( "Name", "<internal error>" );
128 mEnabled = config->readBoolEntry( "Enabled", true ); 128 mEnabled = config->readBoolEntry( "Enabled", true );
129 mCategoryList = config->readListEntry( "Categories" ); 129 mCategoryList = config->readListEntry( "Categories" );
130 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); 130 mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
131} 131}
132 132
133void Filter::save( KConfig *config, QString baseGroup, Filter::List &list ) 133void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
134{ 134{
135 { 135 {
136 KConfigGroupSaver s( config, baseGroup ); 136 KConfigGroupSaver s( config, baseGroup );
137 137
138 // remove the old filters 138 // remove the old filters
139 uint count = config->readNumEntry( "Count" ); 139 uint count = config->readNumEntry( "Count" );
140 /* // memory access violation here 140 /* // memory access violation here
141 for ( uint i = 0; i < count; ++i ) 141 for ( uint i = 0; i < count; ++i )
142 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 142 config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
143 */ 143 */
144 } 144 }
145 145
146 int index = 0; 146 int index = 0;
147 Filter::List::Iterator iter; 147 Filter::List::Iterator iter;
148 for ( iter = list.begin(); iter != list.end(); ++iter ) { 148 for ( iter = list.begin(); iter != list.end(); ++iter ) {
149 if ( !(*iter).mInternal ) { 149 if ( !(*iter).mInternal ) {
150 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) ); 150 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) );
151 151
152 (*iter).save( config ); 152 (*iter).save( config );
153 index++; 153 index++;
154 } 154 }
155 } 155 }
156 156
157 KConfigGroupSaver s( config, baseGroup ); 157 KConfigGroupSaver s( config, baseGroup );
158 158
159 config->writeEntry( "Count", index ); 159 config->writeEntry( "Count", index );
160 160
161} 161}
162 162
163Filter::List Filter::restore( KConfig *config, QString baseGroup ) 163Filter::List Filter::restore( KConfig *config, QString baseGroup )
164{ 164{
165 Filter::List list; 165 Filter::List list;
166 int count = 0; 166 int count = 0;
167 Filter f; 167 Filter f;
168 168
169 { 169 {
170 KConfigGroupSaver s( config, baseGroup ); 170 KConfigGroupSaver s( config, baseGroup );
171 count = config->readNumEntry( "Count", 0 ); 171 count = config->readNumEntry( "Count", 0 );
172 } 172 }
173 173
174 for ( int i = 0; i < count; i++ ) { 174 for ( int i = 0; i < count; i++ ) {
175 { 175 {
176 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) ); 176 KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
177 f.restore( config ); 177 f.restore( config );
178 } 178 }
179 179
180 list.append( f ); 180 list.append( f );
181 } 181 }
182 182
183 QStringList cats = KABPrefs::instance()->mCustomCategories; 183 if ( list.isEmpty()) {
184 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) { 184 QStringList cats = KABPrefs::instance()->mCustomCategories;
185 Filter filter; 185 for ( QStringList::Iterator it = cats.begin(); it != cats.end(); ++it ) {
186 filter.mName = *it; 186 Filter filter;
187 filter.mEnabled = true; 187 filter.mName = *it;
188 filter.mCategoryList = *it; 188 filter.mEnabled = true;
189 filter.mMatchRule = Matching; 189 filter.mCategoryList = *it;
190 filter.mInternal = true; 190 filter.mMatchRule = Matching;
191 list.append( filter ); 191 filter.mInternal = true;
192 list.append( filter );
193 }
192 } 194 }
193
194 return list; 195 return list;
195} 196}
196 197
197void Filter::setMatchRule( MatchRule rule ) 198void Filter::setMatchRule( MatchRule rule )
198{ 199{
199 mMatchRule = rule; 200 mMatchRule = rule;
200} 201}
201 202
202Filter::MatchRule Filter::matchRule() const 203Filter::MatchRule Filter::matchRule() const
203{ 204{
204 return mMatchRule; 205 return mMatchRule;
205} 206}
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index e14e579..c6288fa 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1,3176 +1,3253 @@
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/*s 24/*s
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include "kabcore.h" 31#include "kabcore.h"
32 32
33#include <stdaddressbook.h> 33#include <stdaddressbook.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kfiledialog.h> 35#include <kfiledialog.h>
36#include <qtimer.h> 36#include <qtimer.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qlineedit.h> 39#include <qlineedit.h>
40#include <qcheckbox.h> 40#include <qcheckbox.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qprogressbar.h> 42#include <qprogressbar.h>
43#include <libkdepim/phoneaccess.h> 43#include <libkdepim/phoneaccess.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <qclipboard.h> 46#include <qclipboard.h>
47#include <qdir.h> 47#include <qdir.h>
48#include <qfile.h> 48#include <qfile.h>
49#include <qapplicaton.h> 49#include <qapplicaton.h>
50#include <qprogressbar.h> 50#include <qprogressbar.h>
51#include <qlayout.h> 51#include <qlayout.h>
52#include <qregexp.h> 52#include <qregexp.h>
53#include <qvbox.h> 53#include <qvbox.h>
54#include <kabc/addresseelist.h> 54#include <kabc/addresseelist.h>
55#include <kabc/errorhandler.h> 55#include <kabc/errorhandler.h>
56#include <kabc/resource.h> 56#include <kabc/resource.h>
57#include <kabc/vcardconverter.h> 57#include <kabc/vcardconverter.h>
58#include <kapplication.h> 58#include <kapplication.h>
59#include <kactionclasses.h> 59#include <kactionclasses.h>
60#include <kcmultidialog.h> 60#include <kcmultidialog.h>
61#include <kdebug.h> 61#include <kdebug.h>
62#include <kdeversion.h> 62#include <kdeversion.h>
63#include <kkeydialog.h> 63#include <kkeydialog.h>
64#include <kmessagebox.h> 64#include <kmessagebox.h>
65#include <kprinter.h> 65#include <kprinter.h>
66#include <kprotocolinfo.h> 66#include <kprotocolinfo.h>
67#include <kresources/selectdialog.h> 67#include <kresources/selectdialog.h>
68#include <kstandarddirs.h> 68#include <kstandarddirs.h>
69#include <ktempfile.h> 69#include <ktempfile.h>
70#include <kxmlguiclient.h> 70#include <kxmlguiclient.h>
71#include <kaboutdata.h> 71#include <kaboutdata.h>
72#include <libkdepim/categoryselectdialog.h> 72#include <libkdepim/categoryselectdialog.h>
73 73
74#include "addresseeutil.h" 74#include "addresseeutil.h"
75#include "addresseeeditordialog.h" 75#include "addresseeeditordialog.h"
76#include "extensionmanager.h" 76#include "extensionmanager.h"
77#include "kstdaction.h" 77#include "kstdaction.h"
78#include "kaddressbookservice.h" 78#include "kaddressbookservice.h"
79#include "ldapsearchdialog.h" 79#include "ldapsearchdialog.h"
80#include "printing/printingwizard.h" 80#include "printing/printingwizard.h"
81#else // KAB_EMBEDDED 81#else // KAB_EMBEDDED
82 82
83#include <kapplication.h> 83#include <kapplication.h>
84#include "KDGanttMinimizeSplitter.h" 84#include "KDGanttMinimizeSplitter.h"
85#include "kaddressbookmain.h" 85#include "kaddressbookmain.h"
86#include "kactioncollection.h" 86#include "kactioncollection.h"
87#include "addresseedialog.h" 87#include "addresseedialog.h"
88//US 88//US
89#include <addresseeview.h> 89#include <addresseeview.h>
90 90
91#include <qapp.h> 91#include <qapp.h>
92#include <qmenubar.h> 92#include <qmenubar.h>
93//#include <qtoolbar.h> 93//#include <qtoolbar.h>
94#include <qmessagebox.h> 94#include <qmessagebox.h>
95#include <kdebug.h> 95#include <kdebug.h>
96#include <kiconloader.h> // needed for SmallIcon 96#include <kiconloader.h> // needed for SmallIcon
97#include <kresources/kcmkresources.h> 97#include <kresources/kcmkresources.h>
98#include <ktoolbar.h> 98#include <ktoolbar.h>
99 99
100 100
101//#include <qlabel.h> 101//#include <qlabel.h>
102 102
103 103
104#ifndef DESKTOP_VERSION 104#ifndef DESKTOP_VERSION
105#include <qpe/ir.h> 105#include <qpe/ir.h>
106#include <qpe/qpemenubar.h> 106#include <qpe/qpemenubar.h>
107#include <qtopia/qcopenvelope_qws.h> 107#include <qtopia/qcopenvelope_qws.h>
108#else 108#else
109 109
110#include <qmenubar.h> 110#include <qmenubar.h>
111#endif 111#endif
112 112
113#endif // KAB_EMBEDDED 113#endif // KAB_EMBEDDED
114#include "kcmconfigs/kcmkabconfig.h" 114#include "kcmconfigs/kcmkabconfig.h"
115#include "kcmconfigs/kcmkdepimconfig.h" 115#include "kcmconfigs/kcmkdepimconfig.h"
116#include "kpimglobalprefs.h" 116#include "kpimglobalprefs.h"
117#include "externalapphandler.h" 117#include "externalapphandler.h"
118#include "xxportselectdialog.h" 118#include "xxportselectdialog.h"
119 119
120 120
121#include <kresources/selectdialog.h> 121#include <kresources/selectdialog.h>
122#include <kmessagebox.h> 122#include <kmessagebox.h>
123 123
124#include <picture.h> 124#include <picture.h>
125#include <resource.h> 125#include <resource.h>
126 126
127//US#include <qsplitter.h> 127//US#include <qsplitter.h>
128#include <qmap.h> 128#include <qmap.h>
129#include <qdir.h> 129#include <qdir.h>
130#include <qfile.h> 130#include <qfile.h>
131#include <qvbox.h> 131#include <qvbox.h>
132#include <qlayout.h> 132#include <qlayout.h>
133#include <qclipboard.h> 133#include <qclipboard.h>
134#include <qtextstream.h> 134#include <qtextstream.h>
135#include <qradiobutton.h> 135#include <qradiobutton.h>
136#include <qbuttongroup.h> 136#include <qbuttongroup.h>
137 137
138#include <libkdepim/categoryselectdialog.h> 138#include <libkdepim/categoryselectdialog.h>
139#include <libkdepim/categoryeditdialog.h> 139#include <libkdepim/categoryeditdialog.h>
140#include <kabc/vcardconverter.h> 140#include <kabc/vcardconverter.h>
141 141
142 142
143#include "addresseeutil.h" 143#include "addresseeutil.h"
144#include "undocmds.h" 144#include "undocmds.h"
145#include "addresseeeditordialog.h" 145#include "addresseeeditordialog.h"
146#include "viewmanager.h" 146#include "viewmanager.h"
147#include "details/detailsviewcontainer.h" 147#include "details/detailsviewcontainer.h"
148#include "kabprefs.h" 148#include "kabprefs.h"
149#include "xxportmanager.h" 149#include "xxportmanager.h"
150#include "incsearchwidget.h" 150#include "incsearchwidget.h"
151#include "jumpbuttonbar.h" 151#include "jumpbuttonbar.h"
152#include "extensionmanager.h" 152#include "extensionmanager.h"
153#include "addresseeconfig.h" 153#include "addresseeconfig.h"
154#include "nameeditdialog.h"
154#include <kcmultidialog.h> 155#include <kcmultidialog.h>
155 156
156#ifdef _WIN32_ 157#ifdef _WIN32_
157 158
158#include "kaimportoldialog.h" 159#include "kaimportoldialog.h"
159#else 160#else
160#include <unistd.h> 161#include <unistd.h>
161#endif 162#endif
162// sync includes 163// sync includes
163#include <libkdepim/ksyncprofile.h> 164#include <libkdepim/ksyncprofile.h>
164#include <libkdepim/ksyncprefsdialog.h> 165#include <libkdepim/ksyncprefsdialog.h>
165 166
166 167
167class KABCatPrefs : public QDialog 168class KABCatPrefs : public QDialog
168{ 169{
169 public: 170 public:
170 KABCatPrefs( QWidget *parent=0, const char *name=0 ) : 171 KABCatPrefs( QWidget *parent=0, const char *name=0 ) :
171 QDialog( parent, name, true ) 172 QDialog( parent, name, true )
172 { 173 {
173 setCaption( i18n("Manage new Categories") ); 174 setCaption( i18n("Manage new Categories") );
174 QVBoxLayout* lay = new QVBoxLayout( this ); 175 QVBoxLayout* lay = new QVBoxLayout( this );
175 lay->setSpacing( 3 ); 176 lay->setSpacing( 3 );
176 lay->setMargin( 3 ); 177 lay->setMargin( 3 );
177 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 178 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\naddressees\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
178 lay->addWidget( lab ); 179 lay->addWidget( lab );
179 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 180 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
180 lay->addWidget( format ); 181 lay->addWidget( format );
181 format->setExclusive ( true ) ; 182 format->setExclusive ( true ) ;
182 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 183 addCatBut = new QRadioButton(i18n("Add to category list"), format );
183 new QRadioButton(i18n("Remove from addressees"), format ); 184 new QRadioButton(i18n("Remove from addressees"), format );
184 addCatBut->setChecked( true ); 185 addCatBut->setChecked( true );
185 QPushButton * ok = new QPushButton( i18n("OK"), this ); 186 QPushButton * ok = new QPushButton( i18n("OK"), this );
186 lay->addWidget( ok ); 187 lay->addWidget( ok );
187 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 188 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
188 lay->addWidget( cancel ); 189 lay->addWidget( cancel );
189 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 190 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
190 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 191 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
191 resize( 200, 200 ); 192 resize( 200, 200 );
192 } 193 }
193 194
194 bool addCat() { return addCatBut->isChecked(); } 195 bool addCat() { return addCatBut->isChecked(); }
195private: 196private:
196 QRadioButton* addCatBut; 197 QRadioButton* addCatBut;
197}; 198};
198 199
200class KABFormatPrefs : public QDialog
201{
202 public:
203 KABFormatPrefs( QWidget *parent=0, const char *name=0 ) :
204 QDialog( parent, name, true )
205 {
206 setCaption( i18n("Set formatted name") );
207 QVBoxLayout* lay = new QVBoxLayout( this );
208 lay->setSpacing( 3 );
209 lay->setMargin( 3 );
210 QLabel * lab = new QLabel( i18n("You can set the formatted name\nfor a list of contacts in one go."), this );
211 lay->addWidget( lab );
212 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Set formatted name to:"), this );
213 lay->addWidget( format );
214 format->setExclusive ( true ) ;
215 simple = new QRadioButton(i18n("Simple: James Bond"), format );
216 full = new QRadioButton(i18n("Full: Mr. James 007 Bond I"), format );
217 reverse = new QRadioButton(i18n("Reverse: Bond, James"), format );
218 company = new QRadioButton(i18n("Organization: MI6"), format );
219 simple->setChecked( true );
220 setCompany = new QCheckBox(i18n("Set formatted name to\norganization, if name empty"), this);
221 lay->addWidget( setCompany );
222 QPushButton * ok = new QPushButton( i18n("Select contact list"), this );
223 lay->addWidget( ok );
224 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
225 lay->addWidget( cancel );
226 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
227 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
228 resize( 200, 200 );
229 }
230public:
231 QRadioButton* simple, *full, *reverse, *company;
232 QCheckBox* setCompany;
233};
234
199 235
200 236
201class KAex2phonePrefs : public QDialog 237class KAex2phonePrefs : public QDialog
202{ 238{
203 public: 239 public:
204 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 240 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
205 QDialog( parent, name, true ) 241 QDialog( parent, name, true )
206 { 242 {
207 setCaption( i18n("Export to phone options") ); 243 setCaption( i18n("Export to phone options") );
208 QVBoxLayout* lay = new QVBoxLayout( this ); 244 QVBoxLayout* lay = new QVBoxLayout( this );
209 lay->setSpacing( 3 ); 245 lay->setSpacing( 3 );
210 lay->setMargin( 3 ); 246 lay->setMargin( 3 );
211 QLabel *lab; 247 QLabel *lab;
212 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 248 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
213 lab->setAlignment (AlignHCenter ); 249 lab->setAlignment (AlignHCenter );
214 QHBox* temphb; 250 QHBox* temphb;
215 temphb = new QHBox( this ); 251 temphb = new QHBox( this );
216 new QLabel( i18n("I/O device: "), temphb ); 252 new QLabel( i18n("I/O device: "), temphb );
217 mPhoneDevice = new QLineEdit( temphb); 253 mPhoneDevice = new QLineEdit( temphb);
218 lay->addWidget( temphb ); 254 lay->addWidget( temphb );
219 temphb = new QHBox( this ); 255 temphb = new QHBox( this );
220 new QLabel( i18n("Connection: "), temphb ); 256 new QLabel( i18n("Connection: "), temphb );
221 mPhoneConnection = new QLineEdit( temphb); 257 mPhoneConnection = new QLineEdit( temphb);
222 lay->addWidget( temphb ); 258 lay->addWidget( temphb );
223 temphb = new QHBox( this ); 259 temphb = new QHBox( this );
224 new QLabel( i18n("Model(opt.): "), temphb ); 260 new QLabel( i18n("Model(opt.): "), temphb );
225 mPhoneModel = new QLineEdit( temphb); 261 mPhoneModel = new QLineEdit( temphb);
226 lay->addWidget( temphb ); 262 lay->addWidget( temphb );
227 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 263 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
228 // lay->addWidget( mWriteToSim ); 264 // lay->addWidget( mWriteToSim );
229 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 265 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
230 lab->setAlignment (AlignHCenter ); 266 lab->setAlignment (AlignHCenter );
231 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 267 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
232 lay->addWidget( ok ); 268 lay->addWidget( ok );
233 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 269 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
234 lay->addWidget( cancel ); 270 lay->addWidget( cancel );
235 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 271 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
236 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 272 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
237 resize( 220, 240 ); 273 resize( 220, 240 );
238 274
239 } 275 }
240 276
241public: 277public:
242 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 278 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
243 QCheckBox* mWriteToSim; 279 QCheckBox* mWriteToSim;
244}; 280};
245 281
246 282
247bool pasteWithNewUid = true; 283bool pasteWithNewUid = true;
248 284
249#ifdef KAB_EMBEDDED 285#ifdef KAB_EMBEDDED
250KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 286KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
251 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 287 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
252 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 288 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
253 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 289 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
254#else //KAB_EMBEDDED 290#else //KAB_EMBEDDED
255KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 291KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
256 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 292 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
257 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 293 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
258 mReadWrite( readWrite ), mModified( false ) 294 mReadWrite( readWrite ), mModified( false )
259#endif //KAB_EMBEDDED 295#endif //KAB_EMBEDDED
260{ 296{
261 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 297 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
262 // syncManager->setBlockSave(false); 298 // syncManager->setBlockSave(false);
263 mMiniSplitter = 0; 299 mMiniSplitter = 0;
264 mExtensionBarSplitter = 0; 300 mExtensionBarSplitter = 0;
265 mIsPart = !parent->inherits( "KAddressBookMain" ); 301 mIsPart = !parent->inherits( "KAddressBookMain" );
266 mAddressBook = KABC::StdAddressBook::self(); 302 mAddressBook = KABC::StdAddressBook::self();
267 KABC::StdAddressBook::setAutomaticSave( false ); 303 KABC::StdAddressBook::setAutomaticSave( false );
268 304
269#ifndef KAB_EMBEDDED 305#ifndef KAB_EMBEDDED
270 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 306 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
271#endif //KAB_EMBEDDED 307#endif //KAB_EMBEDDED
272 308
273 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 309 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
274 SLOT( addressBookChanged() ) ); 310 SLOT( addressBookChanged() ) );
275 311
276#if 0 312#if 0
277 // LP moved to addressbook init method 313 // LP moved to addressbook init method
278 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 314 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
279 "X-Department", "KADDRESSBOOK" ); 315 "X-Department", "KADDRESSBOOK" );
280 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 316 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
281 "X-Profession", "KADDRESSBOOK" ); 317 "X-Profession", "KADDRESSBOOK" );
282 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 318 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
283 "X-AssistantsName", "KADDRESSBOOK" ); 319 "X-AssistantsName", "KADDRESSBOOK" );
284 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 320 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
285 "X-ManagersName", "KADDRESSBOOK" ); 321 "X-ManagersName", "KADDRESSBOOK" );
286 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 322 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
287 "X-SpousesName", "KADDRESSBOOK" ); 323 "X-SpousesName", "KADDRESSBOOK" );
288 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 324 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
289 "X-Office", "KADDRESSBOOK" ); 325 "X-Office", "KADDRESSBOOK" );
290 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 326 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
291 "X-IMAddress", "KADDRESSBOOK" ); 327 "X-IMAddress", "KADDRESSBOOK" );
292 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 328 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
293 "X-Anniversary", "KADDRESSBOOK" ); 329 "X-Anniversary", "KADDRESSBOOK" );
294 330
295 //US added this field to become compatible with Opie/qtopia addressbook 331 //US added this field to become compatible with Opie/qtopia addressbook
296 // values can be "female" or "male" or "". An empty field represents undefined. 332 // values can be "female" or "male" or "". An empty field represents undefined.
297 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 333 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
298 "X-Gender", "KADDRESSBOOK" ); 334 "X-Gender", "KADDRESSBOOK" );
299 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 335 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
300 "X-Children", "KADDRESSBOOK" ); 336 "X-Children", "KADDRESSBOOK" );
301 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 337 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
302 "X-FreeBusyUrl", "KADDRESSBOOK" ); 338 "X-FreeBusyUrl", "KADDRESSBOOK" );
303#endif 339#endif
304 initGUI(); 340 initGUI();
305 341
306 mIncSearchWidget->setFocus(); 342 mIncSearchWidget->setFocus();
307 343
308 344
309 connect( mViewManager, SIGNAL( selected( const QString& ) ), 345 connect( mViewManager, SIGNAL( selected( const QString& ) ),
310 SLOT( setContactSelected( const QString& ) ) ); 346 SLOT( setContactSelected( const QString& ) ) );
311 connect( mViewManager, SIGNAL( executed( const QString& ) ), 347 connect( mViewManager, SIGNAL( executed( const QString& ) ),
312 SLOT( executeContact( const QString& ) ) ); 348 SLOT( executeContact( const QString& ) ) );
313 349
314 connect( mViewManager, SIGNAL( deleteRequest( ) ), 350 connect( mViewManager, SIGNAL( deleteRequest( ) ),
315 SLOT( deleteContacts( ) ) ); 351 SLOT( deleteContacts( ) ) );
316 connect( mViewManager, SIGNAL( modified() ), 352 connect( mViewManager, SIGNAL( modified() ),
317 SLOT( setModified() ) ); 353 SLOT( setModified() ) );
318 354
319 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 355 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
320 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 356 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
321 357
322 connect( mXXPortManager, SIGNAL( modified() ), 358 connect( mXXPortManager, SIGNAL( modified() ),
323 SLOT( setModified() ) ); 359 SLOT( setModified() ) );
324 360
325 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 361 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
326 SLOT( incrementalSearch( const QString& ) ) ); 362 SLOT( incrementalSearch( const QString& ) ) );
327 connect( mIncSearchWidget, SIGNAL( fieldChanged() ), 363 connect( mIncSearchWidget, SIGNAL( fieldChanged() ),
328 mJumpButtonBar, SLOT( recreateButtons() ) ); 364 mJumpButtonBar, SLOT( recreateButtons() ) );
329 365
330 connect( mDetails, SIGNAL( sendEmail( const QString& ) ), 366 connect( mDetails, SIGNAL( sendEmail( const QString& ) ),
331 SLOT( sendMail( const QString& ) ) ); 367 SLOT( sendMail( const QString& ) ) );
332 368
333 369
334 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&))); 370 connect( ExternalAppHandler::instance(), SIGNAL (requestForNameEmailUidList(const QString&, const QString&)),this, SLOT(requestForNameEmailUidList(const QString&, const QString&)));
335 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); 371 connect( ExternalAppHandler::instance(), SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)),this, SLOT(requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
336 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&))); 372 connect( ExternalAppHandler::instance(), SIGNAL (requestForBirthdayList(const QString&, const QString&)),this, SLOT(requestForBirthdayList(const QString&, const QString&)));
337 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle())); 373 connect( ExternalAppHandler::instance(), SIGNAL (nextView()),this, SLOT(setDetailsToggle()));
338 374
339 375
340#ifndef KAB_EMBEDDED 376#ifndef KAB_EMBEDDED
341 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ), 377 connect( mViewManager, SIGNAL( urlDropped( const KURL& ) ),
342 mXXPortManager, SLOT( importVCard( const KURL& ) ) ); 378 mXXPortManager, SLOT( importVCard( const KURL& ) ) );
343 379
344 connect( mDetails, SIGNAL( browse( const QString& ) ), 380 connect( mDetails, SIGNAL( browse( const QString& ) ),
345 SLOT( browse( const QString& ) ) ); 381 SLOT( browse( const QString& ) ) );
346 382
347 383
348 mAddressBookService = new KAddressBookService( this ); 384 mAddressBookService = new KAddressBookService( this );
349 385
350#endif //KAB_EMBEDDED 386#endif //KAB_EMBEDDED
351 387
352 mMessageTimer = new QTimer( this ); 388 mMessageTimer = new QTimer( this );
353 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) ); 389 connect( mMessageTimer, SIGNAL( timeout() ), this, SLOT( setCaptionBack() ) );
354 mEditorDialog = 0; 390 mEditorDialog = 0;
355 createAddresseeEditorDialog( this ); 391 createAddresseeEditorDialog( this );
356 setModified( false ); 392 setModified( false );
357 mBRdisabled = false; 393 mBRdisabled = false;
358#ifndef DESKTOP_VERSION 394#ifndef DESKTOP_VERSION
359 infrared = 0; 395 infrared = 0;
360#endif 396#endif
361 //toggleBeamReceive( ); 397 //toggleBeamReceive( );
362 //mMainWindow->toolBar()->show(); 398 //mMainWindow->toolBar()->show();
363 // we have a toolbar repainting error on the Zaurus when starting KA/Pi 399 // we have a toolbar repainting error on the Zaurus when starting KA/Pi
364 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 400 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
365} 401}
366 402
367void KABCore::updateToolBar() 403void KABCore::updateToolBar()
368{ 404{
369 static int iii = 0; 405 static int iii = 0;
370 ++iii; 406 ++iii;
371 mMainWindow->toolBar()->repaintMe(); 407 mMainWindow->toolBar()->repaintMe();
372 if ( iii < 5 ) 408 if ( iii < 5 )
373 QTimer::singleShot( 10, this , SLOT ( updateToolBar())); 409 QTimer::singleShot( 10, this , SLOT ( updateToolBar()));
374} 410}
375KABCore::~KABCore() 411KABCore::~KABCore()
376{ 412{
377 // save(); 413 // save();
378 //saveSettings(); 414 //saveSettings();
379 //KABPrefs::instance()->writeConfig(); 415 //KABPrefs::instance()->writeConfig();
380 delete AddresseeConfig::instance(); 416 delete AddresseeConfig::instance();
381 mAddressBook = 0; 417 mAddressBook = 0;
382 KABC::StdAddressBook::close(); 418 KABC::StdAddressBook::close();
383 419
384 delete syncManager; 420 delete syncManager;
385#ifndef DESKTOP_VERSION 421#ifndef DESKTOP_VERSION
386 if ( infrared ) 422 if ( infrared )
387 delete infrared; 423 delete infrared;
388#endif 424#endif
389} 425}
390void KABCore::receive( const QCString& cmsg, const QByteArray& data ) 426void KABCore::receive( const QCString& cmsg, const QByteArray& data )
391{ 427{
392 qDebug("KA: QCOP message received: %s ", cmsg.data() ); 428 qDebug("KA: QCOP message received: %s ", cmsg.data() );
393 if ( cmsg == "setDocument(QString)" ) { 429 if ( cmsg == "setDocument(QString)" ) {
394 QDataStream stream( data, IO_ReadOnly ); 430 QDataStream stream( data, IO_ReadOnly );
395 QString fileName; 431 QString fileName;
396 stream >> fileName; 432 stream >> fileName;
397 recieve( fileName ); 433 recieve( fileName );
398 return; 434 return;
399 } 435 }
400} 436}
401void KABCore::toggleBeamReceive( ) 437void KABCore::toggleBeamReceive( )
402{ 438{
403 if ( mBRdisabled ) 439 if ( mBRdisabled )
404 return; 440 return;
405#ifndef DESKTOP_VERSION 441#ifndef DESKTOP_VERSION
406 if ( infrared ) { 442 if ( infrared ) {
407 qDebug("AB disable BeamReceive "); 443 qDebug("AB disable BeamReceive ");
408 delete infrared; 444 delete infrared;
409 infrared = 0; 445 infrared = 0;
410 mActionBR->setChecked(false); 446 mActionBR->setChecked(false);
411 return; 447 return;
412 } 448 }
413 qDebug("AB enable BeamReceive "); 449 qDebug("AB enable BeamReceive ");
414 mActionBR->setChecked(true); 450 mActionBR->setChecked(true);
415 451
416 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ; 452 infrared = new QCopChannel("QPE/Application/addressbook",this, "channelAB" ) ;
417 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& ))); 453 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(receive( const QCString&, const QByteArray& )));
418#endif 454#endif
419} 455}
420 456
421 457
422void KABCore::disableBR(bool b) 458void KABCore::disableBR(bool b)
423{ 459{
424#ifndef DESKTOP_VERSION 460#ifndef DESKTOP_VERSION
425 if ( b ) { 461 if ( b ) {
426 if ( infrared ) { 462 if ( infrared ) {
427 toggleBeamReceive( ); 463 toggleBeamReceive( );
428 } 464 }
429 mBRdisabled = true; 465 mBRdisabled = true;
430 } else { 466 } else {
431 if ( mBRdisabled ) { 467 if ( mBRdisabled ) {
432 mBRdisabled = false; 468 mBRdisabled = false;
433 //toggleBeamReceive( ); 469 //toggleBeamReceive( );
434 } 470 }
435 } 471 }
436#endif 472#endif
437 473
438} 474}
439void KABCore::recieve( QString fn ) 475void KABCore::recieve( QString fn )
440{ 476{
441 //qDebug("KABCore::recieve "); 477 //qDebug("KABCore::recieve ");
442 int count = mAddressBook->importFromFile( fn, true ); 478 int count = mAddressBook->importFromFile( fn, true );
443 if ( count ) 479 if ( count )
444 setModified( true ); 480 setModified( true );
445 mViewManager->refreshView(); 481 mViewManager->refreshView();
446 message(i18n("%1 contact(s) received!").arg( count )); 482 message(i18n("%1 contact(s) received!").arg( count ));
447 topLevelWidget()->showMaximized(); 483 topLevelWidget()->showMaximized();
448 topLevelWidget()->raise(); 484 topLevelWidget()->raise();
449} 485}
450void KABCore::restoreSettings() 486void KABCore::restoreSettings()
451{ 487{
452 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce; 488 mMultipleViewsAtOnce = KABPrefs::instance()->mMultipleViewsAtOnce;
453 489
454 bool state; 490 bool state;
455 491
456 if (mMultipleViewsAtOnce) 492 if (mMultipleViewsAtOnce)
457 state = KABPrefs::instance()->mDetailsPageVisible; 493 state = KABPrefs::instance()->mDetailsPageVisible;
458 else 494 else
459 state = false; 495 state = false;
460 496
461 mActionDetails->setChecked( state ); 497 mActionDetails->setChecked( state );
462 setDetailsVisible( state ); 498 setDetailsVisible( state );
463 499
464 state = KABPrefs::instance()->mJumpButtonBarVisible; 500 state = KABPrefs::instance()->mJumpButtonBarVisible;
465 501
466 mActionJumpBar->setChecked( state ); 502 mActionJumpBar->setChecked( state );
467 setJumpButtonBarVisible( state ); 503 setJumpButtonBarVisible( state );
468/*US 504/*US
469 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter; 505 QValueList<int> splitterSize = KABPrefs::instance()->mDetailsSplitter;
470 if ( splitterSize.count() == 0 ) { 506 if ( splitterSize.count() == 0 ) {
471 splitterSize.append( width() / 2 ); 507 splitterSize.append( width() / 2 );
472 splitterSize.append( width() / 2 ); 508 splitterSize.append( width() / 2 );
473 } 509 }
474 mMiniSplitter->setSizes( splitterSize ); 510 mMiniSplitter->setSizes( splitterSize );
475 if ( mExtensionBarSplitter ) { 511 if ( mExtensionBarSplitter ) {
476 splitterSize = KABPrefs::instance()->mExtensionsSplitter; 512 splitterSize = KABPrefs::instance()->mExtensionsSplitter;
477 if ( splitterSize.count() == 0 ) { 513 if ( splitterSize.count() == 0 ) {
478 splitterSize.append( width() / 2 ); 514 splitterSize.append( width() / 2 );
479 splitterSize.append( width() / 2 ); 515 splitterSize.append( width() / 2 );
480 } 516 }
481 mExtensionBarSplitter->setSizes( splitterSize ); 517 mExtensionBarSplitter->setSizes( splitterSize );
482 518
483 } 519 }
484*/ 520*/
485 mViewManager->restoreSettings(); 521 mViewManager->restoreSettings();
486 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField ); 522 mIncSearchWidget->setCurrentItem( KABPrefs::instance()->mCurrentIncSearchField );
487 mExtensionManager->restoreSettings(); 523 mExtensionManager->restoreSettings();
488#ifdef DESKTOP_VERSION 524#ifdef DESKTOP_VERSION
489 int wid = width(); 525 int wid = width();
490 if ( wid < 10 ) 526 if ( wid < 10 )
491 wid = 400; 527 wid = 400;
492#else 528#else
493 int wid = QApplication::desktop()->width(); 529 int wid = QApplication::desktop()->width();
494 if ( wid < 640 ) 530 if ( wid < 640 )
495 wid = QApplication::desktop()->height(); 531 wid = QApplication::desktop()->height();
496#endif 532#endif
497 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter; 533 QValueList<int> splitterSize;// = KABPrefs::instance()->mDetailsSplitter;
498 if ( true /*splitterSize.count() == 0*/ ) { 534 if ( true /*splitterSize.count() == 0*/ ) {
499 splitterSize.append( wid / 2 ); 535 splitterSize.append( wid / 2 );
500 splitterSize.append( wid / 2 ); 536 splitterSize.append( wid / 2 );
501 } 537 }
502 mMiniSplitter->setSizes( splitterSize ); 538 mMiniSplitter->setSizes( splitterSize );
503 if ( mExtensionBarSplitter ) { 539 if ( mExtensionBarSplitter ) {
504 //splitterSize = KABPrefs::instance()->mExtensionsSplitter; 540 //splitterSize = KABPrefs::instance()->mExtensionsSplitter;
505 if ( true /*splitterSize.count() == 0*/ ) { 541 if ( true /*splitterSize.count() == 0*/ ) {
506 splitterSize.append( wid / 2 ); 542 splitterSize.append( wid / 2 );
507 splitterSize.append( wid / 2 ); 543 splitterSize.append( wid / 2 );
508 } 544 }
509 mExtensionBarSplitter->setSizes( splitterSize ); 545 mExtensionBarSplitter->setSizes( splitterSize );
510 546
511 } 547 }
512 548
513 549
514} 550}
515 551
516void KABCore::saveSettings() 552void KABCore::saveSettings()
517{ 553{
518 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked(); 554 KABPrefs::instance()->mJumpButtonBarVisible = mActionJumpBar->isChecked();
519 if ( mExtensionBarSplitter ) 555 if ( mExtensionBarSplitter )
520 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 556 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
521 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked(); 557 KABPrefs::instance()->mDetailsPageVisible = mActionDetails->isChecked();
522 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes(); 558 KABPrefs::instance()->mDetailsSplitter = mMiniSplitter->sizes();
523#ifndef KAB_EMBEDDED 559#ifndef KAB_EMBEDDED
524 560
525 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes(); 561 KABPrefs::instance()->mExtensionsSplitter = mExtensionBarSplitter->sizes();
526 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes(); 562 KABPrefs::instance()->mDetailsSplitter = mDetailsSplitter->sizes();
527#endif //KAB_EMBEDDED 563#endif //KAB_EMBEDDED
528 mExtensionManager->saveSettings(); 564 mExtensionManager->saveSettings();
529 mViewManager->saveSettings(); 565 mViewManager->saveSettings();
530 566
531 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem(); 567 KABPrefs::instance()->mCurrentIncSearchField = mIncSearchWidget->currentItem();
532} 568}
533 569
534KABC::AddressBook *KABCore::addressBook() const 570KABC::AddressBook *KABCore::addressBook() const
535{ 571{
536 return mAddressBook; 572 return mAddressBook;
537} 573}
538 574
539KConfig *KABCore::config() 575KConfig *KABCore::config()
540{ 576{
541#ifndef KAB_EMBEDDED 577#ifndef KAB_EMBEDDED
542 return KABPrefs::instance()->config(); 578 return KABPrefs::instance()->config();
543#else //KAB_EMBEDDED 579#else //KAB_EMBEDDED
544 return KABPrefs::instance()->getConfig(); 580 return KABPrefs::instance()->getConfig();
545#endif //KAB_EMBEDDED 581#endif //KAB_EMBEDDED
546} 582}
547 583
548KActionCollection *KABCore::actionCollection() const 584KActionCollection *KABCore::actionCollection() const
549{ 585{
550 return mGUIClient->actionCollection(); 586 return mGUIClient->actionCollection();
551} 587}
552 588
553KABC::Field *KABCore::currentSearchField() const 589KABC::Field *KABCore::currentSearchField() const
554{ 590{
555 if (mIncSearchWidget) 591 if (mIncSearchWidget)
556 return mIncSearchWidget->currentField(); 592 return mIncSearchWidget->currentField();
557 else 593 else
558 return 0; 594 return 0;
559} 595}
560 596
561QStringList KABCore::selectedUIDs() const 597QStringList KABCore::selectedUIDs() const
562{ 598{
563 return mViewManager->selectedUids(); 599 return mViewManager->selectedUids();
564} 600}
565 601
566KABC::Resource *KABCore::requestResource( QWidget *parent ) 602KABC::Resource *KABCore::requestResource( QWidget *parent )
567{ 603{
568 QPtrList<KABC::Resource> kabcResources = addressBook()->resources(); 604 QPtrList<KABC::Resource> kabcResources = addressBook()->resources();
569 605
570 QPtrList<KRES::Resource> kresResources; 606 QPtrList<KRES::Resource> kresResources;
571 QPtrListIterator<KABC::Resource> resIt( kabcResources ); 607 QPtrListIterator<KABC::Resource> resIt( kabcResources );
572 KABC::Resource *resource; 608 KABC::Resource *resource;
573 while ( ( resource = resIt.current() ) != 0 ) { 609 while ( ( resource = resIt.current() ) != 0 ) {
574 ++resIt; 610 ++resIt;
575 if ( !resource->readOnly() ) { 611 if ( !resource->readOnly() ) {
576 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 612 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
577 if ( res ) 613 if ( res )
578 kresResources.append( res ); 614 kresResources.append( res );
579 } 615 }
580 } 616 }
581 617
582 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent ); 618 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, parent );
583 return static_cast<KABC::Resource*>( res ); 619 return static_cast<KABC::Resource*>( res );
584} 620}
585 621
586#ifndef KAB_EMBEDDED 622#ifndef KAB_EMBEDDED
587KAboutData *KABCore::createAboutData() 623KAboutData *KABCore::createAboutData()
588#else //KAB_EMBEDDED 624#else //KAB_EMBEDDED
589void KABCore::createAboutData() 625void KABCore::createAboutData()
590#endif //KAB_EMBEDDED 626#endif //KAB_EMBEDDED
591{ 627{
592#ifndef KAB_EMBEDDED 628#ifndef KAB_EMBEDDED
593 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ), 629 KAboutData *about = new KAboutData( "kaddressbook", I18N_NOOP( "KAddressBook" ),
594 "3.1", I18N_NOOP( "The KDE Address Book" ), 630 "3.1", I18N_NOOP( "The KDE Address Book" ),
595 KAboutData::License_GPL_V2, 631 KAboutData::License_GPL_V2,
596 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) ); 632 I18N_NOOP( "(c) 1997-2003, The KDE PIM Team" ) );
597 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" ); 633 about->addAuthor( "Tobias Koenig", I18N_NOOP( "Current maintainer " ), "tokoe@kde.org" );
598 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) ); 634 about->addAuthor( "Don Sanders", I18N_NOOP( "Original author " ) );
599 about->addAuthor( "Cornelius Schumacher", 635 about->addAuthor( "Cornelius Schumacher",
600 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ), 636 I18N_NOOP( "Co-maintainer, libkabc port, CSV import/export " ),
601 "schumacher@kde.org" ); 637 "schumacher@kde.org" );
602 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ), 638 about->addAuthor( "Mike Pilone", I18N_NOOP( "GUI and framework redesign " ),
603 "mpilone@slac.com" ); 639 "mpilone@slac.com" );
604 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) ); 640 about->addAuthor( "Greg Stern", I18N_NOOP( "DCOP interface" ) );
605 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) ); 641 about->addAuthor( "Mark Westcott", I18N_NOOP( "Contact pinning" ) );
606 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ), 642 about->addAuthor( "Michel Boyer de la Giroday", I18N_NOOP( "LDAP Lookup\n" ),
607 "michel@klaralvdalens-datakonsult.se" ); 643 "michel@klaralvdalens-datakonsult.se" );
608 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ), 644 about->addAuthor( "Steffen Hansen", I18N_NOOP( "LDAP Lookup " ),
609 "hansen@kde.org" ); 645 "hansen@kde.org" );
610 646
611 return about; 647 return about;
612#endif //KAB_EMBEDDED 648#endif //KAB_EMBEDDED
613 649
614 QString version; 650 QString version;
615#include <../version> 651#include <../version>
616 QMessageBox::about( this, "About KAddressbook/Pi", 652 QMessageBox::about( this, "About KAddressbook/Pi",
617 "KAddressbook/Platform-independent\n" 653 "KAddressbook/Platform-independent\n"
618 "(KA/Pi) " +version + " - " + 654 "(KA/Pi) " +version + " - " +
619#ifdef DESKTOP_VERSION 655#ifdef DESKTOP_VERSION
620 "Desktop Edition\n" 656 "Desktop Edition\n"
621#else 657#else
622 "PDA-Edition\n" 658 "PDA-Edition\n"
623 "for: Zaurus 5500 / 7x0 / 8x0\n" 659 "for: Zaurus 5500 / 7x0 / 8x0\n"
624#endif 660#endif
625 661
626 "(c) 2004 Ulf Schenk\n" 662 "(c) 2004 Ulf Schenk\n"
627 "(c) 2004 Lutz Rogowski\n" 663 "(c) 2004 Lutz Rogowski\n"
628 "(c) 1997-2003, The KDE PIM Team\n" 664 "(c) 1997-2003, The KDE PIM Team\n"
629 "Tobias Koenig Current maintainer\ntokoe@kde.org\n" 665 "Tobias Koenig Current maintainer\ntokoe@kde.org\n"
630 "Don Sanders Original author\n" 666 "Don Sanders Original author\n"
631 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n" 667 "Cornelius Schumacher Co-maintainer\nschumacher@kde.org\n"
632 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n" 668 "Mike Pilone GUI and framework redesign\nmpilone@slac.com\n"
633 "Greg Stern DCOP interface\n" 669 "Greg Stern DCOP interface\n"
634 "Mark Westcot Contact pinning\n" 670 "Mark Westcot Contact pinning\n"
635 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n" 671 "Michel Boyer de la Giroday LDAP Lookup\n" "michel@klaralvdalens-datakonsult.se\n"
636 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n" 672 "Steffen Hansen LDAP Lookup\nhansen@kde.org\n"
637#ifdef _WIN32_ 673#ifdef _WIN32_
638 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n" 674 "(c) 2004 Lutz Rogowski Import from OL\nrogowski@kde.org\n"
639#endif 675#endif
640 ); 676 );
641} 677}
642 678
643void KABCore::setContactSelected( const QString &uid ) 679void KABCore::setContactSelected( const QString &uid )
644{ 680{
645 KABC::Addressee addr = mAddressBook->findByUid( uid ); 681 KABC::Addressee addr = mAddressBook->findByUid( uid );
646 if ( !mDetails->isHidden() ) 682 if ( !mDetails->isHidden() )
647 mDetails->setAddressee( addr ); 683 mDetails->setAddressee( addr );
648 684
649 if ( !addr.isEmpty() ) { 685 if ( !addr.isEmpty() ) {
650 emit contactSelected( addr.formattedName() ); 686 emit contactSelected( addr.formattedName() );
651 KABC::Picture pic = addr.photo(); 687 KABC::Picture pic = addr.photo();
652 if ( pic.isIntern() ) { 688 if ( pic.isIntern() ) {
653//US emit contactSelected( pic.data() ); 689//US emit contactSelected( pic.data() );
654//US instead use: 690//US instead use:
655 QPixmap px; 691 QPixmap px;
656 if (pic.data().isNull() != true) 692 if (pic.data().isNull() != true)
657 { 693 {
658 px.convertFromImage(pic.data()); 694 px.convertFromImage(pic.data());
659 } 695 }
660 696
661 emit contactSelected( px ); 697 emit contactSelected( px );
662 } 698 }
663 } 699 }
664 700
665 701
666 mExtensionManager->setSelectionChanged(); 702 mExtensionManager->setSelectionChanged();
667 703
668 // update the actions 704 // update the actions
669 bool selected = !uid.isEmpty(); 705 bool selected = !uid.isEmpty();
670 706
671 if ( mReadWrite ) { 707 if ( mReadWrite ) {
672 mActionCut->setEnabled( selected ); 708 mActionCut->setEnabled( selected );
673 mActionPaste->setEnabled( selected ); 709 mActionPaste->setEnabled( selected );
674 } 710 }
675 711
676 mActionCopy->setEnabled( selected ); 712 mActionCopy->setEnabled( selected );
677 mActionDelete->setEnabled( selected ); 713 mActionDelete->setEnabled( selected );
678 mActionEditAddressee->setEnabled( selected ); 714 mActionEditAddressee->setEnabled( selected );
679 mActionMail->setEnabled( selected ); 715 mActionMail->setEnabled( selected );
680 mActionMailVCard->setEnabled( selected ); 716 mActionMailVCard->setEnabled( selected );
681 //if (mActionBeam) 717 //if (mActionBeam)
682 //mActionBeam->setEnabled( selected ); 718 //mActionBeam->setEnabled( selected );
683 mActionWhoAmI->setEnabled( selected ); 719 mActionWhoAmI->setEnabled( selected );
684} 720}
685 721
686void KABCore::sendMail() 722void KABCore::sendMail()
687{ 723{
688 sendMail( mViewManager->selectedEmails().join( ", " ) ); 724 sendMail( mViewManager->selectedEmails().join( ", " ) );
689} 725}
690 726
691void KABCore::sendMail( const QString& emaillist ) 727void KABCore::sendMail( const QString& emaillist )
692{ 728{
693 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... " 729 // the parameter has the form "name1 <abc@aol.com>,name2 <abc@aol.com>;... "
694 if (emaillist.contains(",") > 0) 730 if (emaillist.contains(",") > 0)
695 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null ); 731 ExternalAppHandler::instance()->mailToMultipleContacts( emaillist, QString::null );
696 else 732 else
697 ExternalAppHandler::instance()->mailToOneContact( emaillist ); 733 ExternalAppHandler::instance()->mailToOneContact( emaillist );
698} 734}
699 735
700 736
701 737
702void KABCore::mailVCard() 738void KABCore::mailVCard()
703{ 739{
704 QStringList uids = mViewManager->selectedUids(); 740 QStringList uids = mViewManager->selectedUids();
705 if ( !uids.isEmpty() ) 741 if ( !uids.isEmpty() )
706 mailVCard( uids ); 742 mailVCard( uids );
707} 743}
708 744
709void KABCore::mailVCard( const QStringList& uids ) 745void KABCore::mailVCard( const QStringList& uids )
710{ 746{
711 QStringList urls; 747 QStringList urls;
712 748
713// QString tmpdir = locateLocal("tmp", KGlobal::getAppName()); 749// QString tmpdir = locateLocal("tmp", KGlobal::getAppName());
714 750
715 QString dirName = "/tmp/" + KApplication::randomString( 8 ); 751 QString dirName = "/tmp/" + KApplication::randomString( 8 );
716 752
717 753
718 754
719 QDir().mkdir( dirName, true ); 755 QDir().mkdir( dirName, true );
720 756
721 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 757 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
722 KABC::Addressee a = mAddressBook->findByUid( *it ); 758 KABC::Addressee a = mAddressBook->findByUid( *it );
723 759
724 if ( a.isEmpty() ) 760 if ( a.isEmpty() )
725 continue; 761 continue;
726 762
727 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 763 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
728 764
729 QString fileName = dirName + "/" + name; 765 QString fileName = dirName + "/" + name;
730 766
731 QFile outFile(fileName); 767 QFile outFile(fileName);
732 768
733 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 769 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
734 KABC::VCardConverter converter; 770 KABC::VCardConverter converter;
735 QString vcard; 771 QString vcard;
736 772
737 converter.addresseeToVCard( a, vcard ); 773 converter.addresseeToVCard( a, vcard );
738 774
739 QTextStream t( &outFile ); // use a text stream 775 QTextStream t( &outFile ); // use a text stream
740 t.setEncoding( QTextStream::UnicodeUTF8 ); 776 t.setEncoding( QTextStream::UnicodeUTF8 );
741 t << vcard; 777 t << vcard;
742 778
743 outFile.close(); 779 outFile.close();
744 780
745 urls.append( fileName ); 781 urls.append( fileName );
746 } 782 }
747 } 783 }
748 784
749 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 785 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
750 786
751 787
752/*US 788/*US
753 kapp->invokeMailer( QString::null, QString::null, QString::null, 789 kapp->invokeMailer( QString::null, QString::null, QString::null,
754 QString::null, // subject 790 QString::null, // subject
755 QString::null, // body 791 QString::null, // body
756 QString::null, 792 QString::null,
757 urls ); // attachments 793 urls ); // attachments
758*/ 794*/
759 795
760} 796}
761 797
762/** 798/**
763 Beams the "WhoAmI contact. 799 Beams the "WhoAmI contact.
764*/ 800*/
765void KABCore::beamMySelf() 801void KABCore::beamMySelf()
766{ 802{
767 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 803 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
768 if (!a.isEmpty()) 804 if (!a.isEmpty())
769 { 805 {
770 QStringList uids; 806 QStringList uids;
771 uids << a.uid(); 807 uids << a.uid();
772 808
773 beamVCard(uids); 809 beamVCard(uids);
774 } else { 810 } else {
775 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 811 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
776 812
777 813
778 } 814 }
779} 815}
780void KABCore::updateMainWindow() 816void KABCore::updateMainWindow()
781{ 817{
782 818
783 mMainWindow->showMaximized(); 819 mMainWindow->showMaximized();
784 mMainWindow->update(); 820 mMainWindow->update();
785} 821}
786void KABCore::resizeEvent(QResizeEvent* e ) 822void KABCore::resizeEvent(QResizeEvent* e )
787{ 823{
788 if ( !mMiniSplitter ) 824 if ( !mMiniSplitter )
789 return; 825 return;
790 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 826 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
791 if ( QApplication::desktop()->width() >= 480 ) { 827 if ( QApplication::desktop()->width() >= 480 ) {
792 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 828 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
793 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 829 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
794 mMiniSplitter->setOrientation( Qt::Horizontal); 830 mMiniSplitter->setOrientation( Qt::Horizontal);
795 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 831 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
796 if ( QApplication::desktop()->width() <= 640 ) { 832 if ( QApplication::desktop()->width() <= 640 ) {
797 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 833 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
798 mViewManager->getFilterAction()->setComboWidth( 150 ); 834 mViewManager->getFilterAction()->setComboWidth( 150 );
799 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 835 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
800 } 836 }
801 } 837 }
802 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 838 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
803 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 839 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
804 mMiniSplitter->setOrientation( Qt::Vertical ); 840 mMiniSplitter->setOrientation( Qt::Vertical );
805 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 841 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
806 if ( QApplication::desktop()->width() <= 640 ) { 842 if ( QApplication::desktop()->width() <= 640 ) {
807 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 843 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
808 mMainWindow->showMinimized(); 844 mMainWindow->showMinimized();
809 mViewManager->getFilterAction()->setComboWidth( 0 ); 845 mViewManager->getFilterAction()->setComboWidth( 0 );
810 QTimer::singleShot( 1, this , SLOT ( updateMainWindow())); 846 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
811 } 847 }
812 } 848 }
813 } 849 }
814 } 850 }
815 851
816} 852}
817void KABCore::export2phone() 853void KABCore::export2phone()
818{ 854{
819 855
820 QStringList uids; 856 QStringList uids;
821 XXPortSelectDialog dlg( this, false, this ); 857 XXPortSelectDialog dlg( this, false, this );
822 if ( dlg.exec() ) 858 if ( dlg.exec() )
823 uids = dlg.uids(); 859 uids = dlg.uids();
824 else 860 else
825 return; 861 return;
826 if ( uids.isEmpty() ) 862 if ( uids.isEmpty() )
827 return; 863 return;
828 // qDebug("count %d ", uids.count()); 864 // qDebug("count %d ", uids.count());
829 865
830 KAex2phonePrefs ex2phone; 866 KAex2phonePrefs ex2phone;
831 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 867 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
832 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 868 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
833 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 869 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
834 870
835 if ( !ex2phone.exec() ) { 871 if ( !ex2phone.exec() ) {
836 return; 872 return;
837 } 873 }
838 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 874 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
839 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 875 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
840 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 876 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
841 877
842 878
843 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 879 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
844 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 880 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
845 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 881 KPimGlobalPrefs::instance()->mEx2PhoneModel );
846 882
847 QString fileName = getPhoneFile(); 883 QString fileName = getPhoneFile();
848 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 884 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
849 return; 885 return;
850 886
851 message(i18n("Exporting to phone...")); 887 message(i18n("Exporting to phone..."));
852 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 888 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
853 889
854} 890}
855QString KABCore::getPhoneFile() 891QString KABCore::getPhoneFile()
856{ 892{
857#ifdef DESKTOP_VERSION 893#ifdef DESKTOP_VERSION
858 return locateLocal("tmp", "phonefile.vcf"); 894 return locateLocal("tmp", "phonefile.vcf");
859#else 895#else
860 return "/tmp/phonefile.vcf"; 896 return "/tmp/phonefile.vcf";
861#endif 897#endif
862 898
863} 899}
864void KABCore::writeToPhone( ) 900void KABCore::writeToPhone( )
865{ 901{
866 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 902 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
867 message(i18n("Export to phone finished!")); 903 message(i18n("Export to phone finished!"));
868 else 904 else
869 qDebug(i18n("Error exporting to phone")); 905 qDebug(i18n("Error exporting to phone"));
870} 906}
871void KABCore::beamVCard() 907void KABCore::beamVCard()
872{ 908{
873 QStringList uids; 909 QStringList uids;
874 XXPortSelectDialog dlg( this, false, this ); 910 XXPortSelectDialog dlg( this, false, this );
875 if ( dlg.exec() ) 911 if ( dlg.exec() )
876 uids = dlg.uids(); 912 uids = dlg.uids();
877 else 913 else
878 return; 914 return;
879 if ( uids.isEmpty() ) 915 if ( uids.isEmpty() )
880 return; 916 return;
881 beamVCard( uids ); 917 beamVCard( uids );
882} 918}
883 919
884 920
885void KABCore::beamVCard(const QStringList& uids) 921void KABCore::beamVCard(const QStringList& uids)
886{ 922{
887 923
888 // LR: we should use the /tmp dir on the Zaurus, 924 // LR: we should use the /tmp dir on the Zaurus,
889 // because: /tmp = RAM, (HOME)/kdepim = flash memory 925 // because: /tmp = RAM, (HOME)/kdepim = flash memory
890 926
891#ifdef DESKTOP_VERSION 927#ifdef DESKTOP_VERSION
892 QString fileName = locateLocal("tmp", "kapibeamfile.vcf"); 928 QString fileName = locateLocal("tmp", "kapibeamfile.vcf");
893#else 929#else
894 QString fileName = "/tmp/kapibeamfile.vcf"; 930 QString fileName = "/tmp/kapibeamfile.vcf";
895#endif 931#endif
896 932
897 KABC::VCardConverter converter; 933 KABC::VCardConverter converter;
898 QString description; 934 QString description;
899 QString datastream; 935 QString datastream;
900 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 936 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
901 KABC::Addressee a = mAddressBook->findByUid( *it ); 937 KABC::Addressee a = mAddressBook->findByUid( *it );
902 938
903 if ( a.isEmpty() ) 939 if ( a.isEmpty() )
904 continue; 940 continue;
905 941
906 if (description.isEmpty()) 942 if (description.isEmpty())
907 description = a.formattedName(); 943 description = a.formattedName();
908 944
909 QString vcard; 945 QString vcard;
910 converter.addresseeToVCard( a, vcard ); 946 converter.addresseeToVCard( a, vcard );
911 int start = 0; 947 int start = 0;
912 int next; 948 int next;
913 while ( (next = vcard.find("TYPE=", start) )>= 0 ) { 949 while ( (next = vcard.find("TYPE=", start) )>= 0 ) {
914 int semi = vcard.find(";", next); 950 int semi = vcard.find(";", next);
915 int dopp = vcard.find(":", next); 951 int dopp = vcard.find(":", next);
916 int sep; 952 int sep;
917 if ( semi < dopp && semi >= 0 ) 953 if ( semi < dopp && semi >= 0 )
918 sep = semi ; 954 sep = semi ;
919 else 955 else
920 sep = dopp; 956 sep = dopp;
921 datastream +=vcard.mid( start, next - start); 957 datastream +=vcard.mid( start, next - start);
922 datastream +=vcard.mid( next+5,sep -next -5 ).upper(); 958 datastream +=vcard.mid( next+5,sep -next -5 ).upper();
923 start = sep; 959 start = sep;
924 } 960 }
925 datastream += vcard.mid( start,vcard.length() ); 961 datastream += vcard.mid( start,vcard.length() );
926 } 962 }
927#ifndef DESKTOP_VERSION 963#ifndef DESKTOP_VERSION
928 QFile outFile(fileName); 964 QFile outFile(fileName);
929 if ( outFile.open(IO_WriteOnly) ) { 965 if ( outFile.open(IO_WriteOnly) ) {
930 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" ); 966 datastream.replace ( QRegExp("VERSION:3.0") , "VERSION:2.1" );
931 QTextStream t( &outFile ); // use a text stream 967 QTextStream t( &outFile ); // use a text stream
932 //t.setEncoding( QTextStream::UnicodeUTF8 ); 968 //t.setEncoding( QTextStream::UnicodeUTF8 );
933 t.setEncoding( QTextStream::Latin1 ); 969 t.setEncoding( QTextStream::Latin1 );
934 t <<datastream.latin1(); 970 t <<datastream.latin1();
935 outFile.close(); 971 outFile.close();
936 Ir *ir = new Ir( this ); 972 Ir *ir = new Ir( this );
937 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) ); 973 connect( ir, SIGNAL( done(Ir*) ), this, SLOT( beamDone(Ir*) ) );
938 ir->send( fileName, description, "text/x-vCard" ); 974 ir->send( fileName, description, "text/x-vCard" );
939 } else { 975 } else {
940 qDebug("Error open temp beam file "); 976 qDebug("Error open temp beam file ");
941 return; 977 return;
942 } 978 }
943#endif 979#endif
944 980
945} 981}
946 982
947void KABCore::beamDone( Ir *ir ) 983void KABCore::beamDone( Ir *ir )
948{ 984{
949#ifndef DESKTOP_VERSION 985#ifndef DESKTOP_VERSION
950 delete ir; 986 delete ir;
951#endif 987#endif
952 topLevelWidget()->raise(); 988 topLevelWidget()->raise();
953 message( i18n("Beaming finished!") ); 989 message( i18n("Beaming finished!") );
954} 990}
955 991
956 992
957void KABCore::browse( const QString& url ) 993void KABCore::browse( const QString& url )
958{ 994{
959#ifndef KAB_EMBEDDED 995#ifndef KAB_EMBEDDED
960 kapp->invokeBrowser( url ); 996 kapp->invokeBrowser( url );
961#else //KAB_EMBEDDED 997#else //KAB_EMBEDDED
962 qDebug("KABCore::browse must be fixed"); 998 qDebug("KABCore::browse must be fixed");
963#endif //KAB_EMBEDDED 999#endif //KAB_EMBEDDED
964} 1000}
965 1001
966void KABCore::selectAllContacts() 1002void KABCore::selectAllContacts()
967{ 1003{
968 mViewManager->setSelected( QString::null, true ); 1004 mViewManager->setSelected( QString::null, true );
969} 1005}
970 1006
971void KABCore::deleteContacts() 1007void KABCore::deleteContacts()
972{ 1008{
973 QStringList uidList = mViewManager->selectedUids(); 1009 QStringList uidList = mViewManager->selectedUids();
974 deleteContacts( uidList ); 1010 deleteContacts( uidList );
975} 1011}
976 1012
977void KABCore::deleteContacts( const QStringList &uids ) 1013void KABCore::deleteContacts( const QStringList &uids )
978{ 1014{
979 if ( uids.count() > 0 ) { 1015 if ( uids.count() > 0 ) {
980 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids ); 1016 PwDeleteCommand *command = new PwDeleteCommand( mAddressBook, uids );
981 UndoStack::instance()->push( command ); 1017 UndoStack::instance()->push( command );
982 RedoStack::instance()->clear(); 1018 RedoStack::instance()->clear();
983 1019
984 // now if we deleted anything, refresh 1020 // now if we deleted anything, refresh
985 setContactSelected( QString::null ); 1021 setContactSelected( QString::null );
986 setModified( true ); 1022 setModified( true );
987 } 1023 }
988} 1024}
989 1025
990void KABCore::copyContacts() 1026void KABCore::copyContacts()
991{ 1027{
992 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1028 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
993 1029
994 QString clipText = AddresseeUtil::addresseesToClipboard( addrList ); 1030 QString clipText = AddresseeUtil::addresseesToClipboard( addrList );
995 1031
996 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl; 1032 kdDebug(5720) << "KABCore::copyContacts: " << clipText << endl;
997 1033
998 QClipboard *cb = QApplication::clipboard(); 1034 QClipboard *cb = QApplication::clipboard();
999 cb->setText( clipText ); 1035 cb->setText( clipText );
1000} 1036}
1001 1037
1002void KABCore::cutContacts() 1038void KABCore::cutContacts()
1003{ 1039{
1004 QStringList uidList = mViewManager->selectedUids(); 1040 QStringList uidList = mViewManager->selectedUids();
1005 1041
1006//US if ( uidList.size() > 0 ) { 1042//US if ( uidList.size() > 0 ) {
1007 if ( uidList.count() > 0 ) { 1043 if ( uidList.count() > 0 ) {
1008 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList ); 1044 PwCutCommand *command = new PwCutCommand( mAddressBook, uidList );
1009 UndoStack::instance()->push( command ); 1045 UndoStack::instance()->push( command );
1010 RedoStack::instance()->clear(); 1046 RedoStack::instance()->clear();
1011 1047
1012 setModified( true ); 1048 setModified( true );
1013 } 1049 }
1014} 1050}
1015 1051
1016void KABCore::pasteContacts() 1052void KABCore::pasteContacts()
1017{ 1053{
1018 QClipboard *cb = QApplication::clipboard(); 1054 QClipboard *cb = QApplication::clipboard();
1019 1055
1020 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() ); 1056 KABC::Addressee::List list = AddresseeUtil::clipboardToAddressees( cb->text() );
1021 1057
1022 pasteContacts( list ); 1058 pasteContacts( list );
1023} 1059}
1024 1060
1025void KABCore::pasteContacts( KABC::Addressee::List &list ) 1061void KABCore::pasteContacts( KABC::Addressee::List &list )
1026{ 1062{
1027 KABC::Resource *resource = requestResource( this ); 1063 KABC::Resource *resource = requestResource( this );
1028 KABC::Addressee::List::Iterator it; 1064 KABC::Addressee::List::Iterator it;
1029 for ( it = list.begin(); it != list.end(); ++it ) 1065 for ( it = list.begin(); it != list.end(); ++it )
1030 (*it).setResource( resource ); 1066 (*it).setResource( resource );
1031 1067
1032 PwPasteCommand *command = new PwPasteCommand( this, list ); 1068 PwPasteCommand *command = new PwPasteCommand( this, list );
1033 UndoStack::instance()->push( command ); 1069 UndoStack::instance()->push( command );
1034 RedoStack::instance()->clear(); 1070 RedoStack::instance()->clear();
1035 1071
1036 setModified( true ); 1072 setModified( true );
1037} 1073}
1038 1074
1039void KABCore::setWhoAmI() 1075void KABCore::setWhoAmI()
1040{ 1076{
1041 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1077 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1042 1078
1043 if ( addrList.count() > 1 ) { 1079 if ( addrList.count() > 1 ) {
1044 KMessageBox::sorry( this, i18n( "Please select only one contact." ) ); 1080 KMessageBox::sorry( this, i18n( "Please select only one contact." ) );
1045 return; 1081 return;
1046 } 1082 }
1047 1083
1048 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) ); 1084 QString text( i18n( "<qt>Do you really want to use <b>%1</b> as your new personal contact?</qt>" ) );
1049 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes ) 1085 if ( KMessageBox::questionYesNo( this, text.arg( addrList[ 0 ].assembledName() ) ) == KMessageBox::Yes )
1050 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] ); 1086 static_cast<KABC::StdAddressBook*>( KABC::StdAddressBook::self() )->setWhoAmI( addrList[ 0 ] );
1051} 1087}
1052void KABCore::editCategories() 1088void KABCore::editCategories()
1053{ 1089{
1054 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1090 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1055 dlg.exec(); 1091 dlg.exec();
1056} 1092}
1057void KABCore::setCategories() 1093void KABCore::setCategories()
1058{ 1094{
1059 1095
1060 QStringList uids; 1096 QStringList uids;
1061 XXPortSelectDialog dlgx( this, false, this ); 1097 XXPortSelectDialog dlgx( this, false, this );
1062 if ( dlgx.exec() ) 1098 if ( dlgx.exec() )
1063 uids = dlgx.uids(); 1099 uids = dlgx.uids();
1064 else 1100 else
1065 return; 1101 return;
1066 if ( uids.isEmpty() ) 1102 if ( uids.isEmpty() )
1067 return; 1103 return;
1068 // qDebug("count %d ", uids.count()); 1104 // qDebug("count %d ", uids.count());
1069 1105
1070 1106
1071 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1107 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1072 if ( !dlg.exec() ) { 1108 if ( !dlg.exec() ) {
1073 message( i18n("Setting categories cancelled") ); 1109 message( i18n("Setting categories cancelled") );
1074 return; 1110 return;
1075 } 1111 }
1076 bool merge = false; 1112 bool merge = false;
1077 QString msg = i18n( "Merge with existing categories?" ); 1113 QString msg = i18n( "Merge with existing categories?" );
1078 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1114 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1079 merge = true; 1115 merge = true;
1080 1116
1081 message( i18n("Setting categories ... please wait!") ); 1117 message( i18n("Setting categories ... please wait!") );
1082 QStringList categories = dlg.selectedCategories(); 1118 QStringList categories = dlg.selectedCategories();
1083 1119
1084 //QStringList uids = mViewManager->selectedUids(); 1120 //QStringList uids = mViewManager->selectedUids();
1085 QStringList::Iterator it; 1121 QStringList::Iterator it;
1086 for ( it = uids.begin(); it != uids.end(); ++it ) { 1122 for ( it = uids.begin(); it != uids.end(); ++it ) {
1087 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1123 KABC::Addressee addr = mAddressBook->findByUid( *it );
1088 if ( !addr.isEmpty() ) { 1124 if ( !addr.isEmpty() ) {
1089 if ( !merge ) 1125 if ( !merge )
1090 addr.setCategories( categories ); 1126 addr.setCategories( categories );
1091 else { 1127 else {
1092 QStringList addrCategories = addr.categories(); 1128 QStringList addrCategories = addr.categories();
1093 QStringList::Iterator catIt; 1129 QStringList::Iterator catIt;
1094 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1130 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1095 if ( !addrCategories.contains( *catIt ) ) 1131 if ( !addrCategories.contains( *catIt ) )
1096 addrCategories.append( *catIt ); 1132 addrCategories.append( *catIt );
1097 } 1133 }
1098 addr.setCategories( addrCategories ); 1134 addr.setCategories( addrCategories );
1099 } 1135 }
1100 mAddressBook->insertAddressee( addr ); 1136 mAddressBook->insertAddressee( addr );
1101 } 1137 }
1102 } 1138 }
1103 1139
1104 if ( uids.count() > 0 ) 1140 if ( uids.count() > 0 )
1105 setModified( true ); 1141 setModified( true );
1106 message( i18n("Setting categories completed!") ); 1142 message( i18n("Setting categories completed!") );
1107} 1143}
1108 1144
1109void KABCore::setSearchFields( const KABC::Field::List &fields ) 1145void KABCore::setSearchFields( const KABC::Field::List &fields )
1110{ 1146{
1111 mIncSearchWidget->setFields( fields ); 1147 mIncSearchWidget->setFields( fields );
1112} 1148}
1113 1149
1114void KABCore::incrementalSearch( const QString& text ) 1150void KABCore::incrementalSearch( const QString& text )
1115{ 1151{
1116 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1152 mViewManager->doSearch( text, mIncSearchWidget->currentField() );
1117} 1153}
1118 1154
1119void KABCore::setModified() 1155void KABCore::setModified()
1120{ 1156{
1121 setModified( true ); 1157 setModified( true );
1122} 1158}
1123 1159
1124void KABCore::setModifiedWOrefresh() 1160void KABCore::setModifiedWOrefresh()
1125{ 1161{
1126 // qDebug("KABCore::setModifiedWOrefresh() "); 1162 // qDebug("KABCore::setModifiedWOrefresh() ");
1127 mModified = true; 1163 mModified = true;
1128 mActionSave->setEnabled( mModified ); 1164 mActionSave->setEnabled( mModified );
1129 1165
1130 1166
1131} 1167}
1132void KABCore::setModified( bool modified ) 1168void KABCore::setModified( bool modified )
1133{ 1169{
1134 mModified = modified; 1170 mModified = modified;
1135 mActionSave->setEnabled( mModified ); 1171 mActionSave->setEnabled( mModified );
1136 1172
1137 if ( modified ) 1173 if ( modified )
1138 mJumpButtonBar->recreateButtons(); 1174 mJumpButtonBar->recreateButtons();
1139 1175
1140 mViewManager->refreshView(); 1176 mViewManager->refreshView();
1141 1177
1142} 1178}
1143 1179
1144bool KABCore::modified() const 1180bool KABCore::modified() const
1145{ 1181{
1146 return mModified; 1182 return mModified;
1147} 1183}
1148 1184
1149void KABCore::contactModified( const KABC::Addressee &addr ) 1185void KABCore::contactModified( const KABC::Addressee &addr )
1186{
1187 addrModified( addr );
1188}
1189
1190void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1150{ 1191{
1151 1192
1152 Command *command = 0; 1193 Command *command = 0;
1153 QString uid; 1194 QString uid;
1154 1195
1155 // check if it exists already 1196 // check if it exists already
1156 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1197 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1157 if ( origAddr.isEmpty() ) 1198 if ( origAddr.isEmpty() )
1158 command = new PwNewCommand( mAddressBook, addr ); 1199 command = new PwNewCommand( mAddressBook, addr );
1159 else { 1200 else {
1160 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1201 command = new PwEditCommand( mAddressBook, origAddr, addr );
1161 uid = addr.uid(); 1202 uid = addr.uid();
1162 } 1203 }
1163 1204
1164 UndoStack::instance()->push( command ); 1205 UndoStack::instance()->push( command );
1165 RedoStack::instance()->clear(); 1206 RedoStack::instance()->clear();
1166 mDetails->setAddressee( addr ); 1207 if ( updateDetails )
1208 mDetails->setAddressee( addr );
1167 setModified( true ); 1209 setModified( true );
1168} 1210}
1169 1211
1170void KABCore::newContact() 1212void KABCore::newContact()
1171{ 1213{
1172 1214
1173 1215
1174 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources(); 1216 QPtrList<KABC::Resource> kabcResources = mAddressBook->resources();
1175 1217
1176 QPtrList<KRES::Resource> kresResources; 1218 QPtrList<KRES::Resource> kresResources;
1177 QPtrListIterator<KABC::Resource> it( kabcResources ); 1219 QPtrListIterator<KABC::Resource> it( kabcResources );
1178 KABC::Resource *resource; 1220 KABC::Resource *resource;
1179 while ( ( resource = it.current() ) != 0 ) { 1221 while ( ( resource = it.current() ) != 0 ) {
1180 ++it; 1222 ++it;
1181 if ( !resource->readOnly() ) { 1223 if ( !resource->readOnly() ) {
1182 KRES::Resource *res = static_cast<KRES::Resource*>( resource ); 1224 KRES::Resource *res = static_cast<KRES::Resource*>( resource );
1183 if ( res ) 1225 if ( res )
1184 kresResources.append( res ); 1226 kresResources.append( res );
1185 } 1227 }
1186 } 1228 }
1187 1229
1188 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this ); 1230 KRES::Resource *res = KRES::SelectDialog::getResource( kresResources, this );
1189 resource = static_cast<KABC::Resource*>( res ); 1231 resource = static_cast<KABC::Resource*>( res );
1190 1232
1191 if ( resource ) { 1233 if ( resource ) {
1192 KABC::Addressee addr; 1234 KABC::Addressee addr;
1193 addr.setResource( resource ); 1235 addr.setResource( resource );
1194 mEditorDialog->setAddressee( addr ); 1236 mEditorDialog->setAddressee( addr );
1195 KApplication::execDialog ( mEditorDialog ); 1237 KApplication::execDialog ( mEditorDialog );
1196 1238
1197 } else 1239 } else
1198 return; 1240 return;
1199 1241
1200 // mEditorDict.insert( dialog->addressee().uid(), dialog ); 1242 // mEditorDict.insert( dialog->addressee().uid(), dialog );
1201 1243
1202 1244
1203} 1245}
1204 1246
1205void KABCore::addEmail( QString aStr ) 1247void KABCore::addEmail( QString aStr )
1206{ 1248{
1207#ifndef KAB_EMBEDDED 1249#ifndef KAB_EMBEDDED
1208 QString fullName, email; 1250 QString fullName, email;
1209 1251
1210 KABC::Addressee::parseEmailAddress( aStr, fullName, email ); 1252 KABC::Addressee::parseEmailAddress( aStr, fullName, email );
1211 1253
1212 // Try to lookup the addressee matching the email address 1254 // Try to lookup the addressee matching the email address
1213 bool found = false; 1255 bool found = false;
1214 QStringList emailList; 1256 QStringList emailList;
1215 KABC::AddressBook::Iterator it; 1257 KABC::AddressBook::Iterator it;
1216 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) { 1258 for ( it = mAddressBook->begin(); !found && (it != mAddressBook->end()); ++it ) {
1217 emailList = (*it).emails(); 1259 emailList = (*it).emails();
1218 if ( emailList.contains( email ) > 0 ) { 1260 if ( emailList.contains( email ) > 0 ) {
1219 found = true; 1261 found = true;
1220 (*it).setNameFromString( fullName ); 1262 (*it).setNameFromString( fullName );
1221 editContact( (*it).uid() ); 1263 editContact( (*it).uid() );
1222 } 1264 }
1223 } 1265 }
1224 1266
1225 if ( !found ) { 1267 if ( !found ) {
1226 KABC::Addressee addr; 1268 KABC::Addressee addr;
1227 addr.setNameFromString( fullName ); 1269 addr.setNameFromString( fullName );
1228 addr.insertEmail( email, true ); 1270 addr.insertEmail( email, true );
1229 1271
1230 mAddressBook->insertAddressee( addr ); 1272 mAddressBook->insertAddressee( addr );
1231 mViewManager->refreshView( addr.uid() ); 1273 mViewManager->refreshView( addr.uid() );
1232 editContact( addr.uid() ); 1274 editContact( addr.uid() );
1233 } 1275 }
1234#else //KAB_EMBEDDED 1276#else //KAB_EMBEDDED
1235 qDebug("KABCore::addEmail finsih method"); 1277 qDebug("KABCore::addEmail finsih method");
1236#endif //KAB_EMBEDDED 1278#endif //KAB_EMBEDDED
1237} 1279}
1238 1280
1239void KABCore::importVCard( const KURL &url, bool showPreview ) 1281void KABCore::importVCard( const KURL &url, bool showPreview )
1240{ 1282{
1241 mXXPortManager->importVCard( url, showPreview ); 1283 mXXPortManager->importVCard( url, showPreview );
1242} 1284}
1243void KABCore::importFromOL() 1285void KABCore::importFromOL()
1244{ 1286{
1245#ifdef _WIN32_ 1287#ifdef _WIN32_
1246 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this ); 1288 KAImportOLdialog* idgl = new KAImportOLdialog( i18n("Import Contacts from OL"), mAddressBook, this );
1247 idgl->exec(); 1289 idgl->exec();
1248 KABC::Addressee::List list = idgl->getAddressList(); 1290 KABC::Addressee::List list = idgl->getAddressList();
1249 if ( list.count() > 0 ) { 1291 if ( list.count() > 0 ) {
1250 KABC::Addressee::List listNew; 1292 KABC::Addressee::List listNew;
1251 KABC::Addressee::List listExisting; 1293 KABC::Addressee::List listExisting;
1252 KABC::Addressee::List::Iterator it; 1294 KABC::Addressee::List::Iterator it;
1253 KABC::AddressBook::Iterator iter; 1295 KABC::AddressBook::Iterator iter;
1254 for ( it = list.begin(); it != list.end(); ++it ) { 1296 for ( it = list.begin(); it != list.end(); ++it ) {
1255 if ( mAddressBook->findByUid((*it).uid() ).isEmpty()) 1297 if ( mAddressBook->findByUid((*it).uid() ).isEmpty())
1256 listNew.append( (*it) ); 1298 listNew.append( (*it) );
1257 else 1299 else
1258 listExisting.append( (*it) ); 1300 listExisting.append( (*it) );
1259 } 1301 }
1260 if ( listExisting.count() > 0 ) 1302 if ( listExisting.count() > 0 )
1261 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() )); 1303 KMessageBox::information( this, i18n("%1 contacts not added to addressbook\nbecause they were already in the addressbook!").arg( listExisting.count() ));
1262 if ( listNew.count() > 0 ) { 1304 if ( listNew.count() > 0 ) {
1263 pasteWithNewUid = false; 1305 pasteWithNewUid = false;
1264 pasteContacts( listNew ); 1306 pasteContacts( listNew );
1265 pasteWithNewUid = true; 1307 pasteWithNewUid = true;
1266 } 1308 }
1267 } 1309 }
1268 delete idgl; 1310 delete idgl;
1269#endif 1311#endif
1270} 1312}
1271 1313
1272void KABCore::importVCard( const QString &vCard, bool showPreview ) 1314void KABCore::importVCard( const QString &vCard, bool showPreview )
1273{ 1315{
1274 mXXPortManager->importVCard( vCard, showPreview ); 1316 mXXPortManager->importVCard( vCard, showPreview );
1275} 1317}
1276 1318
1277//US added a second method without defaultparameter 1319//US added a second method without defaultparameter
1278void KABCore::editContact2() { 1320void KABCore::editContact2() {
1279 editContact( QString::null ); 1321 editContact( QString::null );
1280} 1322}
1281 1323
1282void KABCore::editContact( const QString &uid ) 1324void KABCore::editContact( const QString &uid )
1283{ 1325{
1284 1326
1285 if ( mExtensionManager->isQuickEditVisible() ) 1327 if ( mExtensionManager->isQuickEditVisible() )
1286 return; 1328 return;
1287 1329
1288 // First, locate the contact entry 1330 // First, locate the contact entry
1289 QString localUID = uid; 1331 QString localUID = uid;
1290 if ( localUID.isNull() ) { 1332 if ( localUID.isNull() ) {
1291 QStringList uidList = mViewManager->selectedUids(); 1333 QStringList uidList = mViewManager->selectedUids();
1292 if ( uidList.count() > 0 ) 1334 if ( uidList.count() > 0 )
1293 localUID = *( uidList.at( 0 ) ); 1335 localUID = *( uidList.at( 0 ) );
1294 } 1336 }
1295 1337
1296 KABC::Addressee addr = mAddressBook->findByUid( localUID ); 1338 KABC::Addressee addr = mAddressBook->findByUid( localUID );
1297 if ( !addr.isEmpty() ) { 1339 if ( !addr.isEmpty() ) {
1298 mEditorDialog->setAddressee( addr ); 1340 mEditorDialog->setAddressee( addr );
1299 KApplication::execDialog ( mEditorDialog ); 1341 KApplication::execDialog ( mEditorDialog );
1300 } 1342 }
1301} 1343}
1302 1344
1303/** 1345/**
1304 Shows or edits the detail view for the given uid. If the uid is QString::null, 1346 Shows or edits the detail view for the given uid. If the uid is QString::null,
1305 the method will try to find a selected addressee in the view. 1347 the method will try to find a selected addressee in the view.
1306 */ 1348 */
1307void KABCore::executeContact( const QString &uid /*US = QString::null*/ ) 1349void KABCore::executeContact( const QString &uid /*US = QString::null*/ )
1308{ 1350{
1309 if ( mMultipleViewsAtOnce ) 1351 if ( mMultipleViewsAtOnce )
1310 { 1352 {
1311 editContact( uid ); 1353 editContact( uid );
1312 } 1354 }
1313 else 1355 else
1314 { 1356 {
1315 setDetailsVisible( true ); 1357 setDetailsVisible( true );
1316 mActionDetails->setChecked(true); 1358 mActionDetails->setChecked(true);
1317 } 1359 }
1318 1360
1319} 1361}
1320 1362
1321void KABCore::save() 1363void KABCore::save()
1322{ 1364{
1323 if (syncManager->blockSave()) 1365 if (syncManager->blockSave())
1324 return; 1366 return;
1325 if ( !mModified ) 1367 if ( !mModified )
1326 return; 1368 return;
1327 1369
1328 syncManager->setBlockSave(true); 1370 syncManager->setBlockSave(true);
1329 QString text = i18n( "There was an error while attempting to save\n the " 1371 QString text = i18n( "There was an error while attempting to save\n the "
1330 "address book. Please check that some \nother application is " 1372 "address book. Please check that some \nother application is "
1331 "not using it. " ); 1373 "not using it. " );
1332 message(i18n("Saving addressbook ... ")); 1374 message(i18n("Saving addressbook ... "));
1333#ifndef KAB_EMBEDDED 1375#ifndef KAB_EMBEDDED
1334 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook ); 1376 KABC::StdAddressBook *b = dynamic_cast<KABC::StdAddressBook*>( mAddressBook );
1335 if ( !b || !b->save() ) { 1377 if ( !b || !b->save() ) {
1336 KMessageBox::error( this, text, i18n( "Unable to Save" ) ); 1378 KMessageBox::error( this, text, i18n( "Unable to Save" ) );
1337 } 1379 }
1338#else //KAB_EMBEDDED 1380#else //KAB_EMBEDDED
1339 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook ); 1381 KABC::StdAddressBook *b = (KABC::StdAddressBook*)( mAddressBook );
1340 if ( !b || !b->save() ) { 1382 if ( !b || !b->save() ) {
1341 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok")); 1383 QMessageBox::critical( this, i18n( "Unable to Save" ), text, i18n("Ok"));
1342 } 1384 }
1343#endif //KAB_EMBEDDED 1385#endif //KAB_EMBEDDED
1344 1386
1345 message(i18n("Addressbook saved!")); 1387 message(i18n("Addressbook saved!"));
1346 setModified( false ); 1388 setModified( false );
1347 syncManager->setBlockSave(false); 1389 syncManager->setBlockSave(false);
1348} 1390}
1349 1391
1350 1392
1351void KABCore::undo() 1393void KABCore::undo()
1352{ 1394{
1353 UndoStack::instance()->undo(); 1395 UndoStack::instance()->undo();
1354 1396
1355 // Refresh the view 1397 // Refresh the view
1356 mViewManager->refreshView(); 1398 mViewManager->refreshView();
1357} 1399}
1358 1400
1359void KABCore::redo() 1401void KABCore::redo()
1360{ 1402{
1361 RedoStack::instance()->redo(); 1403 RedoStack::instance()->redo();
1362 1404
1363 // Refresh the view 1405 // Refresh the view
1364 mViewManager->refreshView(); 1406 mViewManager->refreshView();
1365} 1407}
1366 1408
1367void KABCore::setJumpButtonBarVisible( bool visible ) 1409void KABCore::setJumpButtonBarVisible( bool visible )
1368{ 1410{
1369 if (mMultipleViewsAtOnce) 1411 if (mMultipleViewsAtOnce)
1370 { 1412 {
1371 if ( visible ) 1413 if ( visible )
1372 mJumpButtonBar->show(); 1414 mJumpButtonBar->show();
1373 else 1415 else
1374 mJumpButtonBar->hide(); 1416 mJumpButtonBar->hide();
1375 } 1417 }
1376 else 1418 else
1377 { 1419 {
1378 // show the jumpbar only if "the details are hidden" == "viewmanager are shown" 1420 // show the jumpbar only if "the details are hidden" == "viewmanager are shown"
1379 if (mViewManager->isVisible()) 1421 if (mViewManager->isVisible())
1380 { 1422 {
1381 if ( visible ) 1423 if ( visible )
1382 mJumpButtonBar->show(); 1424 mJumpButtonBar->show();
1383 else 1425 else
1384 mJumpButtonBar->hide(); 1426 mJumpButtonBar->hide();
1385 } 1427 }
1386 else 1428 else
1387 { 1429 {
1388 mJumpButtonBar->hide(); 1430 mJumpButtonBar->hide();
1389 } 1431 }
1390 } 1432 }
1391} 1433}
1392 1434
1393 1435
1394void KABCore::setDetailsToState() 1436void KABCore::setDetailsToState()
1395{ 1437{
1396 setDetailsVisible( mActionDetails->isChecked() ); 1438 setDetailsVisible( mActionDetails->isChecked() );
1397} 1439}
1398void KABCore::setDetailsToggle() 1440void KABCore::setDetailsToggle()
1399{ 1441{
1400 mActionDetails->setChecked( !mActionDetails->isChecked() ); 1442 mActionDetails->setChecked( !mActionDetails->isChecked() );
1401 setDetailsToState(); 1443 setDetailsToState();
1402} 1444}
1403 1445
1404 1446
1405 1447
1406void KABCore::setDetailsVisible( bool visible ) 1448void KABCore::setDetailsVisible( bool visible )
1407{ 1449{
1408 if (visible && mDetails->isHidden()) 1450 if (visible && mDetails->isHidden())
1409 { 1451 {
1410 KABC::Addressee::List addrList = mViewManager->selectedAddressees(); 1452 KABC::Addressee::List addrList = mViewManager->selectedAddressees();
1411 if ( addrList.count() > 0 ) 1453 if ( addrList.count() > 0 )
1412 mDetails->setAddressee( addrList[ 0 ] ); 1454 mDetails->setAddressee( addrList[ 0 ] );
1413 } 1455 }
1414 1456
1415 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between 1457 // mMultipleViewsAtOnce=false: mDetails is always visible. But we switch between
1416 // the listview and the detailview. We do that by changing the splitbar size. 1458 // the listview and the detailview. We do that by changing the splitbar size.
1417 if (mMultipleViewsAtOnce) 1459 if (mMultipleViewsAtOnce)
1418 { 1460 {
1419 if ( visible ) 1461 if ( visible )
1420 mDetails->show(); 1462 mDetails->show();
1421 else 1463 else
1422 mDetails->hide(); 1464 mDetails->hide();
1423 } 1465 }
1424 else 1466 else
1425 { 1467 {
1426 if ( visible ) { 1468 if ( visible ) {
1427 mViewManager->hide(); 1469 mViewManager->hide();
1428 mDetails->show(); 1470 mDetails->show();
1429 mIncSearchWidget->setFocus(); 1471 mIncSearchWidget->setFocus();
1430 } 1472 }
1431 else { 1473 else {
1432 mViewManager->show(); 1474 mViewManager->show();
1433 mDetails->hide(); 1475 mDetails->hide();
1434 mViewManager->setFocusAV(); 1476 mViewManager->setFocusAV();
1435 } 1477 }
1436 setJumpButtonBarVisible( !visible ); 1478 setJumpButtonBarVisible( !visible );
1437 } 1479 }
1438 1480
1439} 1481}
1440 1482
1441void KABCore::extensionChanged( int id ) 1483void KABCore::extensionChanged( int id )
1442{ 1484{
1443 //change the details view only for non desktop systems 1485 //change the details view only for non desktop systems
1444#ifndef DESKTOP_VERSION 1486#ifndef DESKTOP_VERSION
1445 1487
1446 if (id == 0) 1488 if (id == 0)
1447 { 1489 {
1448 //the user disabled the extension. 1490 //the user disabled the extension.
1449 1491
1450 if (mMultipleViewsAtOnce) 1492 if (mMultipleViewsAtOnce)
1451 { // enable detailsview again 1493 { // enable detailsview again
1452 setDetailsVisible( true ); 1494 setDetailsVisible( true );
1453 mActionDetails->setChecked( true ); 1495 mActionDetails->setChecked( true );
1454 } 1496 }
1455 else 1497 else
1456 { //go back to the listview 1498 { //go back to the listview
1457 setDetailsVisible( false ); 1499 setDetailsVisible( false );
1458 mActionDetails->setChecked( false ); 1500 mActionDetails->setChecked( false );
1459 mActionDetails->setEnabled(true); 1501 mActionDetails->setEnabled(true);
1460 } 1502 }
1461 1503
1462 } 1504 }
1463 else 1505 else
1464 { 1506 {
1465 //the user enabled the extension. 1507 //the user enabled the extension.
1466 setDetailsVisible( false ); 1508 setDetailsVisible( false );
1467 mActionDetails->setChecked( false ); 1509 mActionDetails->setChecked( false );
1468 1510
1469 if (!mMultipleViewsAtOnce) 1511 if (!mMultipleViewsAtOnce)
1470 { 1512 {
1471 mActionDetails->setEnabled(false); 1513 mActionDetails->setEnabled(false);
1472 } 1514 }
1473 1515
1474 mExtensionManager->setSelectionChanged(); 1516 mExtensionManager->setSelectionChanged();
1475 1517
1476 } 1518 }
1477 1519
1478#endif// DESKTOP_VERSION 1520#endif// DESKTOP_VERSION
1479 1521
1480} 1522}
1481 1523
1482 1524
1483void KABCore::extensionModified( const KABC::Addressee::List &list ) 1525void KABCore::extensionModified( const KABC::Addressee::List &list )
1484{ 1526{
1485 1527
1486 if ( list.count() != 0 ) { 1528 if ( list.count() != 0 ) {
1487 KABC::Addressee::List::ConstIterator it; 1529 KABC::Addressee::List::ConstIterator it;
1488 for ( it = list.begin(); it != list.end(); ++it ) 1530 for ( it = list.begin(); it != list.end(); ++it )
1489 mAddressBook->insertAddressee( *it ); 1531 mAddressBook->insertAddressee( *it );
1490 if ( list.count() > 1 ) 1532 if ( list.count() > 1 )
1491 setModified(); 1533 setModified();
1492 else 1534 else
1493 setModifiedWOrefresh(); 1535 setModifiedWOrefresh();
1494 } 1536 }
1495 if ( list.count() == 0 ) 1537 if ( list.count() == 0 )
1496 mViewManager->refreshView(); 1538 mViewManager->refreshView();
1497 else 1539 else
1498 mViewManager->refreshView( list[ 0 ].uid() ); 1540 mViewManager->refreshView( list[ 0 ].uid() );
1499 1541
1500 1542
1501 1543
1502} 1544}
1503 1545
1504QString KABCore::getNameByPhone( const QString &phone ) 1546QString KABCore::getNameByPhone( const QString &phone )
1505{ 1547{
1506#ifndef KAB_EMBEDDED 1548#ifndef KAB_EMBEDDED
1507 QRegExp r( "[/*/-/ ]" ); 1549 QRegExp r( "[/*/-/ ]" );
1508 QString localPhone( phone ); 1550 QString localPhone( phone );
1509 1551
1510 bool found = false; 1552 bool found = false;
1511 QString ownerName = ""; 1553 QString ownerName = "";
1512 KABC::AddressBook::Iterator iter; 1554 KABC::AddressBook::Iterator iter;
1513 KABC::PhoneNumber::List::Iterator phoneIter; 1555 KABC::PhoneNumber::List::Iterator phoneIter;
1514 KABC::PhoneNumber::List phoneList; 1556 KABC::PhoneNumber::List phoneList;
1515 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) { 1557 for ( iter = mAddressBook->begin(); !found && ( iter != mAddressBook->end() ); ++iter ) {
1516 phoneList = (*iter).phoneNumbers(); 1558 phoneList = (*iter).phoneNumbers();
1517 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() ); 1559 for ( phoneIter = phoneList.begin(); !found && ( phoneIter != phoneList.end() );
1518 ++phoneIter) { 1560 ++phoneIter) {
1519 // Get rid of separator chars so just the numbers are compared. 1561 // Get rid of separator chars so just the numbers are compared.
1520 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) { 1562 if ( (*phoneIter).number().replace( r, "" ) == localPhone.replace( r, "" ) ) {
1521 ownerName = (*iter).formattedName(); 1563 ownerName = (*iter).formattedName();
1522 found = true; 1564 found = true;
1523 } 1565 }
1524 } 1566 }
1525 } 1567 }
1526 1568
1527 return ownerName; 1569 return ownerName;
1528#else //KAB_EMBEDDED 1570#else //KAB_EMBEDDED
1529 qDebug("KABCore::getNameByPhone finsih method"); 1571 qDebug("KABCore::getNameByPhone finsih method");
1530 return ""; 1572 return "";
1531#endif //KAB_EMBEDDED 1573#endif //KAB_EMBEDDED
1532 1574
1533} 1575}
1534 1576
1535void KABCore::openConfigDialog() 1577void KABCore::openConfigDialog()
1536{ 1578{
1537 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); 1579 KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true );
1538 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); 1580 KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" );
1539 ConfigureDialog->addModule(kabcfg ); 1581 ConfigureDialog->addModule(kabcfg );
1540 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); 1582 KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" );
1541 ConfigureDialog->addModule(kdelibcfg ); 1583 ConfigureDialog->addModule(kdelibcfg );
1542 1584
1543 connect( ConfigureDialog, SIGNAL( applyClicked() ), 1585 connect( ConfigureDialog, SIGNAL( applyClicked() ),
1544 this, SLOT( configurationChanged() ) ); 1586 this, SLOT( configurationChanged() ) );
1545 connect( ConfigureDialog, SIGNAL( okClicked() ), 1587 connect( ConfigureDialog, SIGNAL( okClicked() ),
1546 this, SLOT( configurationChanged() ) ); 1588 this, SLOT( configurationChanged() ) );
1547 saveSettings(); 1589 saveSettings();
1548#ifndef DESKTOP_VERSION 1590#ifndef DESKTOP_VERSION
1549 ConfigureDialog->showMaximized(); 1591 ConfigureDialog->showMaximized();
1550#endif 1592#endif
1551 if ( ConfigureDialog->exec() ) 1593 if ( ConfigureDialog->exec() )
1552 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); 1594 KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") );
1553 delete ConfigureDialog; 1595 delete ConfigureDialog;
1554} 1596}
1555 1597
1556void KABCore::openLDAPDialog() 1598void KABCore::openLDAPDialog()
1557{ 1599{
1558#ifndef KAB_EMBEDDED 1600#ifndef KAB_EMBEDDED
1559 if ( !mLdapSearchDialog ) { 1601 if ( !mLdapSearchDialog ) {
1560 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1602 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1561 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1603 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1562 SLOT( refreshView() ) ); 1604 SLOT( refreshView() ) );
1563 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1605 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1564 SLOT( setModified() ) ); 1606 SLOT( setModified() ) );
1565 } else 1607 } else
1566 mLdapSearchDialog->restoreSettings(); 1608 mLdapSearchDialog->restoreSettings();
1567 1609
1568 if ( mLdapSearchDialog->isOK() ) 1610 if ( mLdapSearchDialog->isOK() )
1569 mLdapSearchDialog->exec(); 1611 mLdapSearchDialog->exec();
1570#else //KAB_EMBEDDED 1612#else //KAB_EMBEDDED
1571 qDebug("KABCore::openLDAPDialog() finsih method"); 1613 qDebug("KABCore::openLDAPDialog() finsih method");
1572#endif //KAB_EMBEDDED 1614#endif //KAB_EMBEDDED
1573} 1615}
1574 1616
1575void KABCore::print() 1617void KABCore::print()
1576{ 1618{
1577#ifndef KAB_EMBEDDED 1619#ifndef KAB_EMBEDDED
1578 KPrinter printer; 1620 KPrinter printer;
1579 if ( !printer.setup( this ) ) 1621 if ( !printer.setup( this ) )
1580 return; 1622 return;
1581 1623
1582 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1624 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1583 mViewManager->selectedUids(), this ); 1625 mViewManager->selectedUids(), this );
1584 1626
1585 wizard.exec(); 1627 wizard.exec();
1586#else //KAB_EMBEDDED 1628#else //KAB_EMBEDDED
1587 qDebug("KABCore::print() finsih method"); 1629 qDebug("KABCore::print() finsih method");
1588#endif //KAB_EMBEDDED 1630#endif //KAB_EMBEDDED
1589 1631
1590} 1632}
1591 1633
1592 1634
1593void KABCore::addGUIClient( KXMLGUIClient *client ) 1635void KABCore::addGUIClient( KXMLGUIClient *client )
1594{ 1636{
1595 if ( mGUIClient ) 1637 if ( mGUIClient )
1596 mGUIClient->insertChildClient( client ); 1638 mGUIClient->insertChildClient( client );
1597 else 1639 else
1598 KMessageBox::error( this, "no KXMLGUICLient"); 1640 KMessageBox::error( this, "no KXMLGUICLient");
1599} 1641}
1600 1642
1601 1643
1602void KABCore::configurationChanged() 1644void KABCore::configurationChanged()
1603{ 1645{
1604 mExtensionManager->reconfigure(); 1646 mExtensionManager->reconfigure();
1605} 1647}
1606 1648
1607void KABCore::addressBookChanged() 1649void KABCore::addressBookChanged()
1608{ 1650{
1609/*US 1651/*US
1610 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1652 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1611 while ( it.current() ) { 1653 while ( it.current() ) {
1612 if ( it.current()->dirty() ) { 1654 if ( it.current()->dirty() ) {
1613 QString text = i18n( "Data has been changed externally. Unsaved " 1655 QString text = i18n( "Data has been changed externally. Unsaved "
1614 "changes will be lost." ); 1656 "changes will be lost." );
1615 KMessageBox::information( this, text ); 1657 KMessageBox::information( this, text );
1616 } 1658 }
1617 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1659 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1618 ++it; 1660 ++it;
1619 } 1661 }
1620*/ 1662*/
1621 if (mEditorDialog) 1663 if (mEditorDialog)
1622 { 1664 {
1623 if (mEditorDialog->dirty()) 1665 if (mEditorDialog->dirty())
1624 { 1666 {
1625 QString text = i18n( "Data has been changed externally. Unsaved " 1667 QString text = i18n( "Data has been changed externally. Unsaved "
1626 "changes will be lost." ); 1668 "changes will be lost." );
1627 KMessageBox::information( this, text ); 1669 KMessageBox::information( this, text );
1628 } 1670 }
1629 QString currentuid = mEditorDialog->addressee().uid(); 1671 QString currentuid = mEditorDialog->addressee().uid();
1630 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1672 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1631 } 1673 }
1632 mViewManager->refreshView(); 1674 mViewManager->refreshView();
1633 1675
1634 1676
1635} 1677}
1636 1678
1637AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1679AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1638 const char *name ) 1680 const char *name )
1639{ 1681{
1640 1682
1641 if ( mEditorDialog == 0 ) { 1683 if ( mEditorDialog == 0 ) {
1642 mEditorDialog = new AddresseeEditorDialog( this, parent, 1684 mEditorDialog = new AddresseeEditorDialog( this, parent,
1643 name ? name : "editorDialog" ); 1685 name ? name : "editorDialog" );
1644 1686
1645 1687
1646 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1688 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1647 SLOT( contactModified( const KABC::Addressee& ) ) ); 1689 SLOT( contactModified( const KABC::Addressee& ) ) );
1648 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1690 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1649 // SLOT( slotEditorDestroyed( const QString& ) ) ; 1691 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1650 } 1692 }
1651 1693
1652 return mEditorDialog; 1694 return mEditorDialog;
1653} 1695}
1654 1696
1655void KABCore::slotEditorDestroyed( const QString &uid ) 1697void KABCore::slotEditorDestroyed( const QString &uid )
1656{ 1698{
1657 //mEditorDict.remove( uid ); 1699 //mEditorDict.remove( uid );
1658} 1700}
1659 1701
1660void KABCore::initGUI() 1702void KABCore::initGUI()
1661{ 1703{
1662#ifndef KAB_EMBEDDED 1704#ifndef KAB_EMBEDDED
1663 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1705 QHBoxLayout *topLayout = new QHBoxLayout( this );
1664 topLayout->setSpacing( KDialogBase::spacingHint() ); 1706 topLayout->setSpacing( KDialogBase::spacingHint() );
1665 1707
1666 mExtensionBarSplitter = new QSplitter( this ); 1708 mExtensionBarSplitter = new QSplitter( this );
1667 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1709 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1668 1710
1669 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1711 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1670 1712
1671 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1713 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1672 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1714 mIncSearchWidget = new IncSearchWidget( viewSpace );
1673 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1715 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1674 SLOT( incrementalSearch( const QString& ) ) ); 1716 SLOT( incrementalSearch( const QString& ) ) );
1675 1717
1676 mViewManager = new ViewManager( this, viewSpace ); 1718 mViewManager = new ViewManager( this, viewSpace );
1677 viewSpace->setStretchFactor( mViewManager, 1 ); 1719 viewSpace->setStretchFactor( mViewManager, 1 );
1678 1720
1679 mDetails = new ViewContainer( mDetailsSplitter ); 1721 mDetails = new ViewContainer( mDetailsSplitter );
1680 1722
1681 mJumpButtonBar = new JumpButtonBar( this, this ); 1723 mJumpButtonBar = new JumpButtonBar( this, this );
1682 1724
1683 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1725 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1684 1726
1685 topLayout->addWidget( mExtensionBarSplitter ); 1727 topLayout->addWidget( mExtensionBarSplitter );
1686 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1728 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1687 topLayout->addWidget( mJumpButtonBar ); 1729 topLayout->addWidget( mJumpButtonBar );
1688 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1730 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1689 1731
1690 mXXPortManager = new XXPortManager( this, this ); 1732 mXXPortManager = new XXPortManager( this, this );
1691 1733
1692#else //KAB_EMBEDDED 1734#else //KAB_EMBEDDED
1693 //US initialize viewMenu before settingup viewmanager. 1735 //US initialize viewMenu before settingup viewmanager.
1694 // Viewmanager needs this menu to plugin submenues. 1736 // Viewmanager needs this menu to plugin submenues.
1695 viewMenu = new QPopupMenu( this ); 1737 viewMenu = new QPopupMenu( this );
1696 settingsMenu = new QPopupMenu( this ); 1738 settingsMenu = new QPopupMenu( this );
1697 //filterMenu = new QPopupMenu( this ); 1739 //filterMenu = new QPopupMenu( this );
1698 ImportMenu = new QPopupMenu( this ); 1740 ImportMenu = new QPopupMenu( this );
1699 ExportMenu = new QPopupMenu( this ); 1741 ExportMenu = new QPopupMenu( this );
1700 syncMenu = new QPopupMenu( this ); 1742 syncMenu = new QPopupMenu( this );
1701 changeMenu= new QPopupMenu( this ); 1743 changeMenu= new QPopupMenu( this );
1702 beamMenu= new QPopupMenu( this ); 1744 beamMenu= new QPopupMenu( this );
1703 1745
1704//US since we have no splitter for the embedded system, setup 1746//US since we have no splitter for the embedded system, setup
1705// a layout with two frames. One left and one right. 1747// a layout with two frames. One left and one right.
1706 1748
1707 QBoxLayout *topLayout; 1749 QBoxLayout *topLayout;
1708 1750
1709 // = new QHBoxLayout( this ); 1751 // = new QHBoxLayout( this );
1710// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1752// QBoxLayout *topLayout = (QBoxLayout*)layout();
1711 1753
1712// QWidget *mainBox = new QWidget( this ); 1754// QWidget *mainBox = new QWidget( this );
1713// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1755// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1714 1756
1715#ifdef DESKTOP_VERSION 1757#ifdef DESKTOP_VERSION
1716 topLayout = new QHBoxLayout( this ); 1758 topLayout = new QHBoxLayout( this );
1717 1759
1718 1760
1719 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1761 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1720 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1762 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1721 1763
1722 topLayout->addWidget(mMiniSplitter ); 1764 topLayout->addWidget(mMiniSplitter );
1723 1765
1724 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1766 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1725 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1767 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1726 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1768 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1727 mDetails = new ViewContainer( mMiniSplitter ); 1769 mDetails = new ViewContainer( mMiniSplitter );
1728 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1770 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1729#else 1771#else
1730 if ( QApplication::desktop()->width() > 480 ) { 1772 if ( QApplication::desktop()->width() > 480 ) {
1731 topLayout = new QHBoxLayout( this ); 1773 topLayout = new QHBoxLayout( this );
1732 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1774 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1733 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1775 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1734 } else { 1776 } else {
1735 1777
1736 topLayout = new QHBoxLayout( this ); 1778 topLayout = new QHBoxLayout( this );
1737 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1779 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1738 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1780 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1739 } 1781 }
1740 1782
1741 topLayout->addWidget(mMiniSplitter ); 1783 topLayout->addWidget(mMiniSplitter );
1742 mViewManager = new ViewManager( this, mMiniSplitter ); 1784 mViewManager = new ViewManager( this, mMiniSplitter );
1743 mDetails = new ViewContainer( mMiniSplitter ); 1785 mDetails = new ViewContainer( mMiniSplitter );
1744 1786
1745 1787
1746 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1788 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
1747#endif 1789#endif
1748 //eh->hide(); 1790 //eh->hide();
1749 // topLayout->addWidget(mExtensionManager ); 1791 // topLayout->addWidget(mExtensionManager );
1750 1792
1751 1793
1752/*US 1794/*US
1753#ifndef KAB_NOSPLITTER 1795#ifndef KAB_NOSPLITTER
1754 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1796 QHBoxLayout *topLayout = new QHBoxLayout( this );
1755//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1797//US topLayout->setSpacing( KDialogBase::spacingHint() );
1756 topLayout->setSpacing( 10 ); 1798 topLayout->setSpacing( 10 );
1757 1799
1758 mDetailsSplitter = new QSplitter( this ); 1800 mDetailsSplitter = new QSplitter( this );
1759 1801
1760 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1802 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1761 1803
1762 mViewManager = new ViewManager( this, viewSpace ); 1804 mViewManager = new ViewManager( this, viewSpace );
1763 viewSpace->setStretchFactor( mViewManager, 1 ); 1805 viewSpace->setStretchFactor( mViewManager, 1 );
1764 1806
1765 mDetails = new ViewContainer( mDetailsSplitter ); 1807 mDetails = new ViewContainer( mDetailsSplitter );
1766 1808
1767 topLayout->addWidget( mDetailsSplitter ); 1809 topLayout->addWidget( mDetailsSplitter );
1768 topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1810 topLayout->setStretchFactor( mDetailsSplitter, 100 );
1769#else //KAB_NOSPLITTER 1811#else //KAB_NOSPLITTER
1770 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1812 QHBoxLayout *topLayout = new QHBoxLayout( this );
1771//US topLayout->setSpacing( KDialogBase::spacingHint() ); 1813//US topLayout->setSpacing( KDialogBase::spacingHint() );
1772 topLayout->setSpacing( 10 ); 1814 topLayout->setSpacing( 10 );
1773 1815
1774// mDetailsSplitter = new QSplitter( this ); 1816// mDetailsSplitter = new QSplitter( this );
1775 1817
1776 QVBox *viewSpace = new QVBox( this ); 1818 QVBox *viewSpace = new QVBox( this );
1777 1819
1778 mViewManager = new ViewManager( this, viewSpace ); 1820 mViewManager = new ViewManager( this, viewSpace );
1779 viewSpace->setStretchFactor( mViewManager, 1 ); 1821 viewSpace->setStretchFactor( mViewManager, 1 );
1780 1822
1781 mDetails = new ViewContainer( this ); 1823 mDetails = new ViewContainer( this );
1782 1824
1783 topLayout->addWidget( viewSpace ); 1825 topLayout->addWidget( viewSpace );
1784// topLayout->setStretchFactor( mDetailsSplitter, 100 ); 1826// topLayout->setStretchFactor( mDetailsSplitter, 100 );
1785 topLayout->addWidget( mDetails ); 1827 topLayout->addWidget( mDetails );
1786#endif //KAB_NOSPLITTER 1828#endif //KAB_NOSPLITTER
1787*/ 1829*/
1788 1830
1789 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 1831 syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
1790 syncManager->setBlockSave(false); 1832 syncManager->setBlockSave(false);
1791 1833
1792 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 1834 connect(syncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
1793 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 1835 connect(syncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
1794 QString sync_file = sentSyncFile(); 1836 QString sync_file = sentSyncFile();
1795 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1()); 1837 qDebug("KABCore::initGUI()::setting tmp sync file to:%s ",sync_file.latin1());
1796 syncManager->setDefaultFileName( sync_file ); 1838 syncManager->setDefaultFileName( sync_file );
1797 //connect(syncManager , SIGNAL( ), this, SLOT( ) ); 1839 //connect(syncManager , SIGNAL( ), this, SLOT( ) );
1798 1840
1799#endif //KAB_EMBEDDED 1841#endif //KAB_EMBEDDED
1800 initActions(); 1842 initActions();
1801 1843
1802#ifdef KAB_EMBEDDED 1844#ifdef KAB_EMBEDDED
1803 addActionsManually(); 1845 addActionsManually();
1804 //US make sure the export and import menues are initialized before creating the xxPortManager. 1846 //US make sure the export and import menues are initialized before creating the xxPortManager.
1805 mXXPortManager = new XXPortManager( this, this ); 1847 mXXPortManager = new XXPortManager( this, this );
1806 1848
1807 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() ); 1849 // LR mIncSearchWidget = new IncSearchWidget( mMainWindow->getIconToolBar() );
1808 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget); 1850 //mMainWindow->toolBar()->insertWidget(-1, 4, mIncSearchWidget);
1809 // mActionQuit->plug ( mMainWindow->toolBar()); 1851 // mActionQuit->plug ( mMainWindow->toolBar());
1810 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() ); 1852 //mIncSearchWidget = new IncSearchWidget( mMainWindow->toolBar() );
1811 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget); 1853 //mMainWindow->toolBar()->insertWidget(-1, 0, mIncSearchWidget);
1812 // mIncSearchWidget->hide(); 1854 // mIncSearchWidget->hide();
1813 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1855 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1814 SLOT( incrementalSearch( const QString& ) ) ); 1856 SLOT( incrementalSearch( const QString& ) ) );
1815 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) ); 1857 connect( mIncSearchWidget, SIGNAL( scrollUP() ),mViewManager, SLOT( scrollUP() ) );
1816 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) ); 1858 connect( mIncSearchWidget, SIGNAL( scrollDOWN() ),mViewManager, SLOT( scrollDOWN() ) );
1817 1859
1818 mJumpButtonBar = new JumpButtonBar( this, this ); 1860 mJumpButtonBar = new JumpButtonBar( this, this );
1819 1861
1820 topLayout->addWidget( mJumpButtonBar ); 1862 topLayout->addWidget( mJumpButtonBar );
1821//US topLayout->setStretchFactor( mJumpButtonBar, 10 ); 1863//US topLayout->setStretchFactor( mJumpButtonBar, 10 );
1822 1864
1823// mMainWindow->getIconToolBar()->raise(); 1865// mMainWindow->getIconToolBar()->raise();
1824 1866
1825#endif //KAB_EMBEDDED 1867#endif //KAB_EMBEDDED
1826 1868
1827} 1869}
1828void KABCore::initActions() 1870void KABCore::initActions()
1829{ 1871{
1830//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 1872//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
1831 1873
1832#ifndef KAB_EMBEDDED 1874#ifndef KAB_EMBEDDED
1833 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 1875 connect( QApplication::clipboard(), SIGNAL( dataChanged() ),
1834 SLOT( clipboardDataChanged() ) ); 1876 SLOT( clipboardDataChanged() ) );
1835#endif //KAB_EMBEDDED 1877#endif //KAB_EMBEDDED
1836 1878
1837 // file menu 1879 // file menu
1838 if ( mIsPart ) { 1880 if ( mIsPart ) {
1839 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this, 1881 mActionMail = new KAction( i18n( "&Mail" ), "mail_generic", 0, this,
1840 SLOT( sendMail() ), actionCollection(), 1882 SLOT( sendMail() ), actionCollection(),
1841 "kaddressbook_mail" ); 1883 "kaddressbook_mail" );
1842 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this, 1884 mActionPrint = new KAction( i18n( "&Print" ), "fileprint", CTRL + Key_P, this,
1843 SLOT( print() ), actionCollection(), "kaddressbook_print" ); 1885 SLOT( print() ), actionCollection(), "kaddressbook_print" );
1844 1886
1845 } else { 1887 } else {
1846 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() ); 1888 mActionMail = KStdAction::mail( this, SLOT( sendMail() ), actionCollection() );
1847 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() ); 1889 mActionPrint = KStdAction::print( this, SLOT( print() ), actionCollection() );
1848 } 1890 }
1849 1891
1850 1892
1851 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this, 1893 mActionSave = new KAction( i18n( "&Save" ), "filesave", CTRL+Key_S, this,
1852 SLOT( save() ), actionCollection(), "file_sync" ); 1894 SLOT( save() ), actionCollection(), "file_sync" );
1853 1895
1854 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this, 1896 mActionNewContact = new KAction( i18n( "&New Contact..." ), "filenew", CTRL+Key_N, this,
1855 SLOT( newContact() ), actionCollection(), "file_new_contact" ); 1897 SLOT( newContact() ), actionCollection(), "file_new_contact" );
1856 1898
1857 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0, 1899 mActionMailVCard = new KAction(i18n("Mail &vCard..."), "mail_post_to", 0,
1858 this, SLOT( mailVCard() ), 1900 this, SLOT( mailVCard() ),
1859 actionCollection(), "file_mail_vcard"); 1901 actionCollection(), "file_mail_vcard");
1860 1902
1861 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this, 1903 mActionExport2phone = new KAction( i18n( "Export to phone" ), "ex2phone", 0, this,
1862 SLOT( export2phone() ), actionCollection(), 1904 SLOT( export2phone() ), actionCollection(),
1863 "kaddressbook_ex2phone" ); 1905 "kaddressbook_ex2phone" );
1864 1906
1865 mActionBeamVCard = 0; 1907 mActionBeamVCard = 0;
1866 mActionBeam = 0; 1908 mActionBeam = 0;
1867 1909
1868#ifndef DESKTOP_VERSION 1910#ifndef DESKTOP_VERSION
1869 if ( Ir::supported() ) { 1911 if ( Ir::supported() ) {
1870 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this, 1912 mActionBeamVCard = new KAction( i18n( "Beam v&Card(s)..." ), "beam", 0, this,
1871 SLOT( beamVCard() ), actionCollection(), 1913 SLOT( beamVCard() ), actionCollection(),
1872 "kaddressbook_beam_vcard" ); 1914 "kaddressbook_beam_vcard" );
1873 1915
1874 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this, 1916 mActionBeam = new KAction( i18n( "&Beam personal vCard" ), "beam", 0, this,
1875 SLOT( beamMySelf() ), actionCollection(), 1917 SLOT( beamMySelf() ), actionCollection(),
1876 "kaddressbook_beam_myself" ); 1918 "kaddressbook_beam_myself" );
1877 } 1919 }
1878#endif 1920#endif
1879 1921
1880 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0, 1922 mActionEditAddressee = new KAction( i18n( "&Edit Contact..." ), "edit", 0,
1881 this, SLOT( editContact2() ), 1923 this, SLOT( editContact2() ),
1882 actionCollection(), "file_properties" ); 1924 actionCollection(), "file_properties" );
1883 1925
1884#ifdef KAB_EMBEDDED 1926#ifdef KAB_EMBEDDED
1885 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() ); 1927 // mActionQuit = KStdAction::quit( mMainWindow, SLOT( exit() ), actionCollection() );
1886 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0, 1928 mActionQuit = new KAction( i18n( "&Exit" ), "exit", 0,
1887 mMainWindow, SLOT( exit() ), 1929 mMainWindow, SLOT( exit() ),
1888 actionCollection(), "quit" ); 1930 actionCollection(), "quit" );
1889#endif //KAB_EMBEDDED 1931#endif //KAB_EMBEDDED
1890 1932
1891 // edit menu 1933 // edit menu
1892 if ( mIsPart ) { 1934 if ( mIsPart ) {
1893 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this, 1935 mActionCopy = new KAction( i18n( "&Copy" ), "editcopy", CTRL + Key_C, this,
1894 SLOT( copyContacts() ), actionCollection(), 1936 SLOT( copyContacts() ), actionCollection(),
1895 "kaddressbook_copy" ); 1937 "kaddressbook_copy" );
1896 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this, 1938 mActionCut = new KAction( i18n( "Cu&t" ), "editcut", CTRL + Key_X, this,
1897 SLOT( cutContacts() ), actionCollection(), 1939 SLOT( cutContacts() ), actionCollection(),
1898 "kaddressbook_cut" ); 1940 "kaddressbook_cut" );
1899 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this, 1941 mActionPaste = new KAction( i18n( "&Paste" ), "editpaste", CTRL + Key_V, this,
1900 SLOT( pasteContacts() ), actionCollection(), 1942 SLOT( pasteContacts() ), actionCollection(),
1901 "kaddressbook_paste" ); 1943 "kaddressbook_paste" );
1902 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this, 1944 mActionSelectAll = new KAction( i18n( "Select &All" ), CTRL + Key_A, this,
1903 SLOT( selectAllContacts() ), actionCollection(), 1945 SLOT( selectAllContacts() ), actionCollection(),
1904 "kaddressbook_select_all" ); 1946 "kaddressbook_select_all" );
1905 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this, 1947 mActionUndo = new KAction( i18n( "&Undo" ), "undo", CTRL + Key_Z, this,
1906 SLOT( undo() ), actionCollection(), 1948 SLOT( undo() ), actionCollection(),
1907 "kaddressbook_undo" ); 1949 "kaddressbook_undo" );
1908 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z, 1950 mActionRedo = new KAction( i18n( "Re&do" ), "redo", CTRL + SHIFT + Key_Z,
1909 this, SLOT( redo() ), actionCollection(), 1951 this, SLOT( redo() ), actionCollection(),
1910 "kaddressbook_redo" ); 1952 "kaddressbook_redo" );
1911 } else { 1953 } else {
1912 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() ); 1954 mActionCopy = KStdAction::copy( this, SLOT( copyContacts() ), actionCollection() );
1913 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() ); 1955 mActionCut = KStdAction::cut( this, SLOT( cutContacts() ), actionCollection() );
1914 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() ); 1956 mActionPaste = KStdAction::paste( this, SLOT( pasteContacts() ), actionCollection() );
1915 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() ); 1957 mActionSelectAll = KStdAction::selectAll( this, SLOT( selectAllContacts() ), actionCollection() );
1916 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() ); 1958 mActionUndo = KStdAction::undo( this, SLOT( undo() ), actionCollection() );
1917 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() ); 1959 mActionRedo = KStdAction::redo( this, SLOT( redo() ), actionCollection() );
1918 } 1960 }
1919 1961
1920 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete", 1962 mActionDelete = new KAction( i18n( "&Delete Contact" ), "editdelete",
1921 Key_Delete, this, SLOT( deleteContacts() ), 1963 Key_Delete, this, SLOT( deleteContacts() ),
1922 actionCollection(), "edit_delete" ); 1964 actionCollection(), "edit_delete" );
1923 1965
1924 mActionUndo->setEnabled( false ); 1966 mActionUndo->setEnabled( false );
1925 mActionRedo->setEnabled( false ); 1967 mActionRedo->setEnabled( false );
1926 1968
1927 // settings menu 1969 // settings menu
1928#ifdef KAB_EMBEDDED 1970#ifdef KAB_EMBEDDED
1929//US special menuentry to configure the addressbook resources. On KDE 1971//US special menuentry to configure the addressbook resources. On KDE
1930// you do that through the control center !!! 1972// you do that through the control center !!!
1931 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this, 1973 mActionConfigResources = new KAction( i18n( "Configure &Resources..." ), "configure_resources", 0, this,
1932 SLOT( configureResources() ), actionCollection(), 1974 SLOT( configureResources() ), actionCollection(),
1933 "kaddressbook_configure_resources" ); 1975 "kaddressbook_configure_resources" );
1934#endif //KAB_EMBEDDED 1976#endif //KAB_EMBEDDED
1935 1977
1936 if ( mIsPart ) { 1978 if ( mIsPart ) {
1937 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this, 1979 mActionConfigKAddressbook = new KAction( i18n( "&Configure KAddressBook..." ), "configure", 0, this,
1938 SLOT( openConfigDialog() ), actionCollection(), 1980 SLOT( openConfigDialog() ), actionCollection(),
1939 "kaddressbook_configure" ); 1981 "kaddressbook_configure" );
1940 1982
1941 //US not implemented yet 1983 //US not implemented yet
1942 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0, 1984 //mActionConfigShortcuts = new KAction( i18n( "Configure S&hortcuts..." ), "configure_shortcuts", 0,
1943 // this, SLOT( configureKeyBindings() ), actionCollection(), 1985 // this, SLOT( configureKeyBindings() ), actionCollection(),
1944 // "kaddressbook_configure_shortcuts" ); 1986 // "kaddressbook_configure_shortcuts" );
1945#ifdef KAB_EMBEDDED 1987#ifdef KAB_EMBEDDED
1946 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() ); 1988 mActionConfigureToolbars = KStdAction::configureToolbars( this, SLOT( mMainWindow->configureToolbars() ), actionCollection() );
1947 mActionConfigureToolbars->setEnabled( false ); 1989 mActionConfigureToolbars->setEnabled( false );
1948#endif //KAB_EMBEDDED 1990#endif //KAB_EMBEDDED
1949 1991
1950 } else { 1992 } else {
1951 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() ); 1993 mActionConfigKAddressbook = KStdAction::preferences( this, SLOT( openConfigDialog() ), actionCollection() );
1952 1994
1953 //US not implemented yet 1995 //US not implemented yet
1954 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() ); 1996 //mActionKeyBindings = KStdAction::keyBindings( this, SLOT( configureKeyBindings() ), actionCollection() );
1955 } 1997 }
1956 1998
1957 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0, 1999 mActionJumpBar = new KToggleAction( i18n( "Show Jump Bar" ), 0, 0,
1958 actionCollection(), "options_show_jump_bar" ); 2000 actionCollection(), "options_show_jump_bar" );
1959 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) ); 2001 connect( mActionJumpBar, SIGNAL( toggled( bool ) ), SLOT( setJumpButtonBarVisible( bool ) ) );
1960 2002
1961 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0, 2003 mActionDetails = new KToggleAction( i18n( "Show Details" ), "listview", 0,
1962 actionCollection(), "options_show_details" ); 2004 actionCollection(), "options_show_details" );
1963 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) ); 2005 connect( mActionDetails, SIGNAL( toggled( bool ) ), SLOT( setDetailsVisible( bool ) ) );
1964 2006
1965 2007
1966 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this, 2008 mActionBR = new KToggleAction( i18n( "Beam receive enabled" ), "beam", 0, this,
1967 SLOT( toggleBeamReceive() ), actionCollection(), 2009 SLOT( toggleBeamReceive() ), actionCollection(),
1968 "kaddressbook_beam_rec" ); 2010 "kaddressbook_beam_rec" );
1969 2011
1970 2012
1971 // misc 2013 // misc
1972 // only enable LDAP lookup if we can handle the protocol 2014 // only enable LDAP lookup if we can handle the protocol
1973#ifndef KAB_EMBEDDED 2015#ifndef KAB_EMBEDDED
1974 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) { 2016 if ( KProtocolInfo::isKnownProtocol( KURL( "ldap://localhost" ) ) ) {
1975 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0, 2017 new KAction( i18n( "&Lookup Addresses in Directory" ), "find", 0,
1976 this, SLOT( openLDAPDialog() ), actionCollection(), 2018 this, SLOT( openLDAPDialog() ), actionCollection(),
1977 "ldap_lookup" ); 2019 "ldap_lookup" );
1978 } 2020 }
1979#else //KAB_EMBEDDED 2021#else //KAB_EMBEDDED
1980 //qDebug("KABCore::initActions() LDAP has to be implemented"); 2022 //qDebug("KABCore::initActions() LDAP has to be implemented");
1981#endif //KAB_EMBEDDED 2023#endif //KAB_EMBEDDED
1982 2024
1983 2025
1984 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this, 2026 mActionWhoAmI = new KAction( i18n( "Set Who Am I" ), "personal", 0, this,
1985 SLOT( setWhoAmI() ), actionCollection(), 2027 SLOT( setWhoAmI() ), actionCollection(),
1986 "set_personal" ); 2028 "set_personal" );
1987 2029
1988 2030
1989 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this, 2031 mActionCategories = new KAction( i18n( "Set Categories" ), 0, this,
1990 SLOT( setCategories() ), actionCollection(), 2032 SLOT( setCategories() ), actionCollection(),
1991 "edit_set_categories" ); 2033 "edit_set_categories" );
1992 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this, 2034 mActionEditCategories = new KAction( i18n( "Edit Categories" ), 0, this,
1993 SLOT( editCategories() ), actionCollection(), 2035 SLOT( editCategories() ), actionCollection(),
1994 "edit__categories" ); 2036 "edit__categories" );
1995 2037
1996 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this, 2038 mActionRemoveVoice = new KAction( i18n( "Remove \"voice\"..." ), 0, this,
1997 SLOT( removeVoice() ), actionCollection(), 2039 SLOT( removeVoice() ), actionCollection(),
1998 "remove_voice" ); 2040 "remove_voice" );
2041 mActionSetFormattedName = new KAction( i18n( "Set formatted name..." ), 0, this,
2042 SLOT( setFormattedName() ), actionCollection(),
2043 "set_formatted" );
1999 2044
2000 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this, 2045 mActionManageCategories= new KAction( i18n( "Manage new categories..." ), 0, this,
2001 SLOT( manageCategories() ), actionCollection(), 2046 SLOT( manageCategories() ), actionCollection(),
2002 "remove_voice" ); 2047 "remove_voice" );
2003 2048
2004 2049
2005 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this, 2050 mActionImportOL = new KAction( i18n( "Import from Outlook..." ), 0, this,
2006 SLOT( importFromOL() ), actionCollection(), 2051 SLOT( importFromOL() ), actionCollection(),
2007 "import_OL" ); 2052 "import_OL" );
2008#ifdef KAB_EMBEDDED 2053#ifdef KAB_EMBEDDED
2009 mActionLicence = new KAction( i18n( "Licence" ), 0, 2054 mActionLicence = new KAction( i18n( "Licence" ), 0,
2010 this, SLOT( showLicence() ), actionCollection(), 2055 this, SLOT( showLicence() ), actionCollection(),
2011 "licence_about_data" ); 2056 "licence_about_data" );
2012 mActionFaq = new KAction( i18n( "Faq" ), 0, 2057 mActionFaq = new KAction( i18n( "Faq" ), 0,
2013 this, SLOT( faq() ), actionCollection(), 2058 this, SLOT( faq() ), actionCollection(),
2014 "faq_about_data" ); 2059 "faq_about_data" );
2015 mActionWN = new KAction( i18n( "What's New?" ), 0, 2060 mActionWN = new KAction( i18n( "What's New?" ), 0,
2016 this, SLOT( whatsnew() ), actionCollection(), 2061 this, SLOT( whatsnew() ), actionCollection(),
2017 "wn" ); 2062 "wn" );
2018 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0, 2063 mActionSyncHowto = new KAction( i18n( "Sync HowTo" ), 0,
2019 this, SLOT( synchowto() ), actionCollection(), 2064 this, SLOT( synchowto() ), actionCollection(),
2020 "sync" ); 2065 "sync" );
2021 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0, 2066 mActionKdeSyncHowto = new KAction( i18n( "Kde Sync HowTo" ), 0,
2022 this, SLOT( kdesynchowto() ), actionCollection(), 2067 this, SLOT( kdesynchowto() ), actionCollection(),
2023 "kdesync" ); 2068 "kdesync" );
2024 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0, 2069 mActionMultiSyncHowto = new KAction( i18n( "Multi Sync HowTo" ), 0,
2025 this, SLOT( multisynchowto() ), actionCollection(), 2070 this, SLOT( multisynchowto() ), actionCollection(),
2026 "multisync" ); 2071 "multisync" );
2027 2072
2028 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0, 2073 mActionAboutKAddressbook = new KAction( i18n( "&About KAddressBook" ), "kaddressbook2", 0,
2029 this, SLOT( createAboutData() ), actionCollection(), 2074 this, SLOT( createAboutData() ), actionCollection(),
2030 "kaddressbook_about_data" ); 2075 "kaddressbook_about_data" );
2031#endif //KAB_EMBEDDED 2076#endif //KAB_EMBEDDED
2032 2077
2033 clipboardDataChanged(); 2078 clipboardDataChanged();
2034 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2079 connect( UndoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2035 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) ); 2080 connect( RedoStack::instance(), SIGNAL( changed() ), SLOT( updateActionMenu() ) );
2036} 2081}
2037 2082
2038//US we need this function, to plug all actions into the correct menues. 2083//US we need this function, to plug all actions into the correct menues.
2039// KDE uses a XML format to plug the actions, but we work her without this overhead. 2084// KDE uses a XML format to plug the actions, but we work her without this overhead.
2040void KABCore::addActionsManually() 2085void KABCore::addActionsManually()
2041{ 2086{
2042//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart); 2087//US qDebug("KABCore::initActions(): mIsPart %i", mIsPart);
2043 2088
2044#ifdef KAB_EMBEDDED 2089#ifdef KAB_EMBEDDED
2045 QPopupMenu *fileMenu = new QPopupMenu( this ); 2090 QPopupMenu *fileMenu = new QPopupMenu( this );
2046 QPopupMenu *editMenu = new QPopupMenu( this ); 2091 QPopupMenu *editMenu = new QPopupMenu( this );
2047 QPopupMenu *helpMenu = new QPopupMenu( this ); 2092 QPopupMenu *helpMenu = new QPopupMenu( this );
2048 2093
2049 KToolBar* tb = mMainWindow->toolBar(); 2094 KToolBar* tb = mMainWindow->toolBar();
2050 2095
2051#ifndef DESKTOP_VERSION 2096#ifndef DESKTOP_VERSION
2052 if ( KABPrefs::instance()->mFullMenuBarVisible ) { 2097 if ( KABPrefs::instance()->mFullMenuBarVisible ) {
2053#endif 2098#endif
2054 QMenuBar* mb = mMainWindow->menuBar(); 2099 QMenuBar* mb = mMainWindow->menuBar();
2055 2100
2056 //US setup menubar. 2101 //US setup menubar.
2057 //Disable the following block if you do not want to have a menubar. 2102 //Disable the following block if you do not want to have a menubar.
2058 mb->insertItem( i18n("&File"), fileMenu ); 2103 mb->insertItem( i18n("&File"), fileMenu );
2059 mb->insertItem( i18n("&Edit"), editMenu ); 2104 mb->insertItem( i18n("&Edit"), editMenu );
2060 mb->insertItem( i18n("&View"), viewMenu ); 2105 mb->insertItem( i18n("&View"), viewMenu );
2061 mb->insertItem( i18n("&Settings"), settingsMenu ); 2106 mb->insertItem( i18n("&Settings"), settingsMenu );
2062 mb->insertItem( i18n("Synchronize"), syncMenu ); 2107 mb->insertItem( i18n("Synchronize"), syncMenu );
2063 //mb->insertItem( i18n("&Change"), changeMenu ); 2108 //mb->insertItem( i18n("&Change"), changeMenu );
2064 mb->insertItem( i18n("&Help"), helpMenu ); 2109 mb->insertItem( i18n("&Help"), helpMenu );
2065 mIncSearchWidget = new IncSearchWidget( tb ); 2110 mIncSearchWidget = new IncSearchWidget( tb );
2066 // tb->insertWidget(-1, 0, mIncSearchWidget); 2111 // tb->insertWidget(-1, 0, mIncSearchWidget);
2067#ifndef DESKTOP_VERSION 2112#ifndef DESKTOP_VERSION
2068 } else { 2113 } else {
2069 //US setup toolbar 2114 //US setup toolbar
2070 QPEMenuBar *menuBarTB = new QPEMenuBar( tb ); 2115 QPEMenuBar *menuBarTB = new QPEMenuBar( tb );
2071 QPopupMenu *popupBarTB = new QPopupMenu( this ); 2116 QPopupMenu *popupBarTB = new QPopupMenu( this );
2072 menuBarTB->insertItem( "ME", popupBarTB); 2117 menuBarTB->insertItem( "ME", popupBarTB);
2073 tb->insertWidget(-1, 0, menuBarTB); 2118 tb->insertWidget(-1, 0, menuBarTB);
2074 mIncSearchWidget = new IncSearchWidget( tb ); 2119 mIncSearchWidget = new IncSearchWidget( tb );
2075 2120
2076 tb->enableMoving(false); 2121 tb->enableMoving(false);
2077 popupBarTB->insertItem( i18n("&File"), fileMenu ); 2122 popupBarTB->insertItem( i18n("&File"), fileMenu );
2078 popupBarTB->insertItem( i18n("&Edit"), editMenu ); 2123 popupBarTB->insertItem( i18n("&Edit"), editMenu );
2079 popupBarTB->insertItem( i18n("&View"), viewMenu ); 2124 popupBarTB->insertItem( i18n("&View"), viewMenu );
2080 popupBarTB->insertItem( i18n("&Settings"), settingsMenu ); 2125 popupBarTB->insertItem( i18n("&Settings"), settingsMenu );
2081 popupBarTB->insertItem( i18n("Synchronize"), syncMenu ); 2126 popupBarTB->insertItem( i18n("Synchronize"), syncMenu );
2082 mViewManager->getFilterAction()->plug ( popupBarTB); 2127 mViewManager->getFilterAction()->plug ( popupBarTB);
2083 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu ); 2128 //popupBarTB->insertItem( i18n("&Change selected"), changeMenu );
2084 popupBarTB->insertItem( i18n("&Help"), helpMenu ); 2129 popupBarTB->insertItem( i18n("&Help"), helpMenu );
2085 if (QApplication::desktop()->width() > 320 ) { 2130 if (QApplication::desktop()->width() > 320 ) {
2086 // mViewManager->getFilterAction()->plug ( tb); 2131 // mViewManager->getFilterAction()->plug ( tb);
2087 } 2132 }
2088 } 2133 }
2089#endif 2134#endif
2090 // mActionQuit->plug ( mMainWindow->toolBar()); 2135 // mActionQuit->plug ( mMainWindow->toolBar());
2091 2136
2092 2137
2093 2138
2094 //US Now connect the actions with the menue entries. 2139 //US Now connect the actions with the menue entries.
2095 mActionPrint->plug( fileMenu ); 2140 mActionPrint->plug( fileMenu );
2096 mActionMail->plug( fileMenu ); 2141 mActionMail->plug( fileMenu );
2097 fileMenu->insertSeparator(); 2142 fileMenu->insertSeparator();
2098 2143
2099 mActionNewContact->plug( fileMenu ); 2144 mActionNewContact->plug( fileMenu );
2100 mActionNewContact->plug( tb ); 2145 mActionNewContact->plug( tb );
2101 2146
2102 mActionEditAddressee->plug( fileMenu ); 2147 mActionEditAddressee->plug( fileMenu );
2103 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) || 2148 // if ((KGlobal::getDesktopSize() > KGlobal::Small ) ||
2104 // (!KABPrefs::instance()->mMultipleViewsAtOnce )) 2149 // (!KABPrefs::instance()->mMultipleViewsAtOnce ))
2105 mActionEditAddressee->plug( tb ); 2150 mActionEditAddressee->plug( tb );
2106 2151
2107 fileMenu->insertSeparator(); 2152 fileMenu->insertSeparator();
2108 mActionSave->plug( fileMenu ); 2153 mActionSave->plug( fileMenu );
2109 fileMenu->insertItem( "&Import", ImportMenu ); 2154 fileMenu->insertItem( "&Import", ImportMenu );
2110 fileMenu->insertItem( "&Export", ExportMenu ); 2155 fileMenu->insertItem( "&Export", ExportMenu );
2111 fileMenu->insertItem( i18n("&Change"), changeMenu ); 2156 fileMenu->insertItem( i18n("&Change"), changeMenu );
2112#ifndef DESKTOP_VERSION 2157#ifndef DESKTOP_VERSION
2113 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu ); 2158 if ( Ir::supported() ) fileMenu->insertItem( i18n("&Beam"), beamMenu );
2114#endif 2159#endif
2115 2160
2116 fileMenu->insertSeparator(); 2161 fileMenu->insertSeparator();
2117 mActionMailVCard->plug( fileMenu ); 2162 mActionMailVCard->plug( fileMenu );
2118#ifndef DESKTOP_VERSION 2163#ifndef DESKTOP_VERSION
2119 if ( Ir::supported() ) mActionBR->plug( beamMenu ); 2164 if ( Ir::supported() ) mActionBR->plug( beamMenu );
2120 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu ); 2165 if ( Ir::supported() ) mActionBeamVCard->plug( beamMenu );
2121 if ( Ir::supported() ) mActionBeam->plug( beamMenu ); 2166 if ( Ir::supported() ) mActionBeam->plug( beamMenu );
2122#endif 2167#endif
2123 fileMenu->insertSeparator(); 2168 fileMenu->insertSeparator();
2124 mActionQuit->plug( fileMenu ); 2169 mActionQuit->plug( fileMenu );
2125#ifdef _WIN32_ 2170#ifdef _WIN32_
2126 mActionImportOL->plug( ImportMenu ); 2171 mActionImportOL->plug( ImportMenu );
2127#endif 2172#endif
2128 // edit menu 2173 // edit menu
2129 mActionUndo->plug( editMenu ); 2174 mActionUndo->plug( editMenu );
2130 mActionRedo->plug( editMenu ); 2175 mActionRedo->plug( editMenu );
2131 editMenu->insertSeparator(); 2176 editMenu->insertSeparator();
2132 mActionCut->plug( editMenu ); 2177 mActionCut->plug( editMenu );
2133 mActionCopy->plug( editMenu ); 2178 mActionCopy->plug( editMenu );
2134 mActionPaste->plug( editMenu ); 2179 mActionPaste->plug( editMenu );
2135 mActionDelete->plug( editMenu ); 2180 mActionDelete->plug( editMenu );
2136 editMenu->insertSeparator(); 2181 editMenu->insertSeparator();
2137 mActionSelectAll->plug( editMenu ); 2182 mActionSelectAll->plug( editMenu );
2138 2183
2184 mActionSetFormattedName->plug( changeMenu );
2139 mActionRemoveVoice->plug( changeMenu ); 2185 mActionRemoveVoice->plug( changeMenu );
2140 // settings menu 2186 // settings menu
2141//US special menuentry to configure the addressbook resources. On KDE 2187//US special menuentry to configure the addressbook resources. On KDE
2142// you do that through the control center !!! 2188// you do that through the control center !!!
2143 mActionConfigResources->plug( settingsMenu ); 2189 mActionConfigResources->plug( settingsMenu );
2144 settingsMenu->insertSeparator(); 2190 settingsMenu->insertSeparator();
2145 2191
2146 mActionConfigKAddressbook->plug( settingsMenu ); 2192 mActionConfigKAddressbook->plug( settingsMenu );
2147 2193
2148 if ( mIsPart ) { 2194 if ( mIsPart ) {
2149 //US not implemented yet 2195 //US not implemented yet
2150 //mActionConfigShortcuts->plug( settingsMenu ); 2196 //mActionConfigShortcuts->plug( settingsMenu );
2151 //mActionConfigureToolbars->plug( settingsMenu ); 2197 //mActionConfigureToolbars->plug( settingsMenu );
2152 2198
2153 } else { 2199 } else {
2154 //US not implemented yet 2200 //US not implemented yet
2155 //mActionKeyBindings->plug( settingsMenu ); 2201 //mActionKeyBindings->plug( settingsMenu );
2156 } 2202 }
2157 2203
2158 settingsMenu->insertSeparator(); 2204 settingsMenu->insertSeparator();
2159 2205
2160 mActionJumpBar->plug( settingsMenu ); 2206 mActionJumpBar->plug( settingsMenu );
2161 mActionDetails->plug( settingsMenu ); 2207 mActionDetails->plug( settingsMenu );
2162 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop ) 2208 //if (!KABPrefs::instance()->mMultipleViewsAtOnce || KGlobal::getDesktopSize() == KGlobal::Desktop )
2163 mActionDetails->plug( tb ); 2209 mActionDetails->plug( tb );
2164 settingsMenu->insertSeparator(); 2210 settingsMenu->insertSeparator();
2165#ifndef DESKTOP_VERSION 2211#ifndef DESKTOP_VERSION
2166 if ( Ir::supported() ) mActionBR->plug(settingsMenu ); 2212 if ( Ir::supported() ) mActionBR->plug(settingsMenu );
2167#endif 2213#endif
2168 settingsMenu->insertSeparator(); 2214 settingsMenu->insertSeparator();
2169 2215
2170 mActionWhoAmI->plug( settingsMenu ); 2216 mActionWhoAmI->plug( settingsMenu );
2171 mActionEditCategories->plug( settingsMenu ); 2217 mActionEditCategories->plug( settingsMenu );
2172 mActionEditCategories->plug( changeMenu ); 2218 mActionEditCategories->plug( changeMenu );
2173 mActionCategories->plug( changeMenu ); 2219 mActionCategories->plug( changeMenu );
2174 mActionManageCategories->plug( changeMenu ); 2220 mActionManageCategories->plug( changeMenu );
2175 2221
2176 mActionCategories->plug( settingsMenu ); 2222 mActionCategories->plug( settingsMenu );
2177 mActionManageCategories->plug( settingsMenu ); 2223 mActionManageCategories->plug( settingsMenu );
2178 2224
2179 2225
2180 mActionWN->plug( helpMenu ); 2226 mActionWN->plug( helpMenu );
2181 mActionSyncHowto->plug( helpMenu ); 2227 mActionSyncHowto->plug( helpMenu );
2182 mActionKdeSyncHowto->plug( helpMenu ); 2228 mActionKdeSyncHowto->plug( helpMenu );
2183 mActionMultiSyncHowto->plug( helpMenu ); 2229 mActionMultiSyncHowto->plug( helpMenu );
2184 mActionFaq->plug( helpMenu ); 2230 mActionFaq->plug( helpMenu );
2185 mActionLicence->plug( helpMenu ); 2231 mActionLicence->plug( helpMenu );
2186 mActionAboutKAddressbook->plug( helpMenu ); 2232 mActionAboutKAddressbook->plug( helpMenu );
2187 2233
2188 if (KGlobal::getDesktopSize() > KGlobal::Small ) { 2234 if (KGlobal::getDesktopSize() > KGlobal::Small ) {
2189 2235
2190 mActionSave->plug( tb ); 2236 mActionSave->plug( tb );
2191 mViewManager->getFilterAction()->plug ( tb); 2237 mViewManager->getFilterAction()->plug ( tb);
2192 //LR hide filteraction on started in 480x640 2238 //LR hide filteraction on started in 480x640
2193 if (QApplication::desktop()->width() == 480 ) { 2239 if (QApplication::desktop()->width() == 480 ) {
2194 mViewManager->getFilterAction()->setComboWidth( 0 ); 2240 mViewManager->getFilterAction()->setComboWidth( 0 );
2195 } 2241 }
2196 mActionUndo->plug( tb ); 2242 mActionUndo->plug( tb );
2197 mActionDelete->plug( tb ); 2243 mActionDelete->plug( tb );
2198 mActionRedo->plug( tb ); 2244 mActionRedo->plug( tb );
2199 } else { 2245 } else {
2200 mActionSave->plug( tb ); 2246 mActionSave->plug( tb );
2201 tb->enableMoving(false); 2247 tb->enableMoving(false);
2202 } 2248 }
2203 //mActionQuit->plug ( tb ); 2249 //mActionQuit->plug ( tb );
2204 // tb->insertWidget(-1, 0, mIncSearchWidget, 6); 2250 // tb->insertWidget(-1, 0, mIncSearchWidget, 6);
2205 2251
2206 //US link the searchwidget first to this. 2252 //US link the searchwidget first to this.
2207 // The real linkage to the toolbar happens later. 2253 // The real linkage to the toolbar happens later.
2208//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE); 2254//US mIncSearchWidget->reparent(tb, 0, QPoint(50,0), TRUE);
2209//US tb->insertItem( mIncSearchWidget ); 2255//US tb->insertItem( mIncSearchWidget );
2210/*US 2256/*US
2211 mIncSearchWidget = new IncSearchWidget( tb ); 2257 mIncSearchWidget = new IncSearchWidget( tb );
2212 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 2258 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
2213 SLOT( incrementalSearch( const QString& ) ) ); 2259 SLOT( incrementalSearch( const QString& ) ) );
2214 2260
2215 mJumpButtonBar = new JumpButtonBar( this, this ); 2261 mJumpButtonBar = new JumpButtonBar( this, this );
2216 2262
2217//US topLayout->addWidget( mJumpButtonBar ); 2263//US topLayout->addWidget( mJumpButtonBar );
2218 this->layout()->add( mJumpButtonBar ); 2264 this->layout()->add( mJumpButtonBar );
2219*/ 2265*/
2220 2266
2221#endif //KAB_EMBEDDED 2267#endif //KAB_EMBEDDED
2222 2268
2223 mActionExport2phone->plug( ExportMenu ); 2269 mActionExport2phone->plug( ExportMenu );
2224 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) ); 2270 connect ( syncMenu, SIGNAL( activated ( int ) ), syncManager, SLOT (slotSyncMenu( int ) ) );
2225 syncManager->fillSyncMenu(); 2271 syncManager->fillSyncMenu();
2226 2272
2227} 2273}
2228void KABCore::showLicence() 2274void KABCore::showLicence()
2229{ 2275{
2230 KApplication::showLicence(); 2276 KApplication::showLicence();
2231} 2277}
2232 2278
2233void KABCore::manageCategories( ) 2279void KABCore::manageCategories( )
2234{ 2280{
2235 KABCatPrefs* cp = new KABCatPrefs(); 2281 KABCatPrefs* cp = new KABCatPrefs();
2236 cp->show(); 2282 cp->show();
2237 int w =cp->sizeHint().width() ; 2283 int w =cp->sizeHint().width() ;
2238 int h = cp->sizeHint().height() ; 2284 int h = cp->sizeHint().height() ;
2239 int dw = QApplication::desktop()->width(); 2285 int dw = QApplication::desktop()->width();
2240 int dh = QApplication::desktop()->height(); 2286 int dh = QApplication::desktop()->height();
2241 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2287 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2242 if ( !cp->exec() ) { 2288 if ( !cp->exec() ) {
2243 delete cp; 2289 delete cp;
2244 return; 2290 return;
2245 } 2291 }
2246 int count = 0; 2292 int count = 0;
2247 message( i18n("Please wait, processing categories...")); 2293 message( i18n("Please wait, processing categories..."));
2248 if ( cp->addCat() ) { 2294 if ( cp->addCat() ) {
2249 KABC::AddressBook::Iterator it; 2295 KABC::AddressBook::Iterator it;
2250 QStringList catList = KABPrefs::instance()->mCustomCategories; 2296 QStringList catList = KABPrefs::instance()->mCustomCategories;
2251 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2297 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2252 QStringList catIncList = (*it).categories(); 2298 QStringList catIncList = (*it).categories();
2253 int i; 2299 int i;
2254 for( i = 0; i< catIncList.count(); ++i ) { 2300 for( i = 0; i< catIncList.count(); ++i ) {
2255 if ( !catList.contains (catIncList[i])) { 2301 if ( !catList.contains (catIncList[i])) {
2256 catList.append( catIncList[i] ); 2302 catList.append( catIncList[i] );
2257 //qDebug("add cat %s ", catIncList[i].latin1()); 2303 //qDebug("add cat %s ", catIncList[i].latin1());
2258 ++count; 2304 ++count;
2259 } 2305 }
2260 } 2306 }
2261 } 2307 }
2262 catList.sort(); 2308 catList.sort();
2263 KABPrefs::instance()->mCustomCategories = catList; 2309 KABPrefs::instance()->mCustomCategories = catList;
2264 KABPrefs::instance()->writeConfig(); 2310 KABPrefs::instance()->writeConfig();
2265 message(QString::number( count )+ i18n(" categories added to list! ")); 2311 message(QString::number( count )+ i18n(" categories added to list! "));
2266 } else { 2312 } else {
2267 QStringList catList = KABPrefs::instance()->mCustomCategories; 2313 QStringList catList = KABPrefs::instance()->mCustomCategories;
2268 QStringList catIncList; 2314 QStringList catIncList;
2269 QStringList newCatList; 2315 QStringList newCatList;
2270 KABC::AddressBook::Iterator it; 2316 KABC::AddressBook::Iterator it;
2271 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2317 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2272 QStringList catIncList = (*it).categories(); 2318 QStringList catIncList = (*it).categories();
2273 int i; 2319 int i;
2274 if ( catIncList.count() ) { 2320 if ( catIncList.count() ) {
2275 newCatList.clear(); 2321 newCatList.clear();
2276 for( i = 0; i< catIncList.count(); ++i ) { 2322 for( i = 0; i< catIncList.count(); ++i ) {
2277 if ( catList.contains (catIncList[i])) { 2323 if ( catList.contains (catIncList[i])) {
2278 newCatList.append( catIncList[i] ); 2324 newCatList.append( catIncList[i] );
2279 } 2325 }
2280 } 2326 }
2281 newCatList.sort(); 2327 newCatList.sort();
2282 (*it).setCategories( newCatList ); 2328 (*it).setCategories( newCatList );
2283 mAddressBook->insertAddressee( (*it) ); 2329 mAddressBook->insertAddressee( (*it) );
2284 } 2330 }
2285 } 2331 }
2286 setModified( true ); 2332 setModified( true );
2287 mViewManager->refreshView(); 2333 mViewManager->refreshView();
2288 message( i18n("Removing categories done!")); 2334 message( i18n("Removing categories done!"));
2289 } 2335 }
2290 delete cp; 2336 delete cp;
2291} 2337}
2292void KABCore::removeVoice() 2338void KABCore::removeVoice()
2293{ 2339{
2294 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 ) 2340 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 )
2295 return; 2341 return;
2296 KABC::Addressee::List list; 2342 KABC::Addressee::List list;
2297 XXPortSelectDialog dlg( this, false, this ); 2343 XXPortSelectDialog dlg( this, false, this );
2298 if ( dlg.exec() ) 2344 if ( dlg.exec() )
2299 list = dlg.contacts(); 2345 list = dlg.contacts();
2300 else 2346 else
2301 return; 2347 return;
2302 KABC::Addressee::List::Iterator it; 2348 KABC::Addressee::List::Iterator it;
2303 for ( it = list.begin(); it != list.end(); ++it ) { 2349 for ( it = list.begin(); it != list.end(); ++it ) {
2304 if ( (*it).removeVoice() ) 2350 if ( (*it).removeVoice() )
2305 contactModified((*it) ); 2351 addrModified((*it), false );
2306 } 2352 }
2307} 2353}
2308 2354
2309 2355void KABCore::setFormattedName()
2356{
2357 KABFormatPrefs setpref;
2358 if ( !setpref.exec() ) {
2359 return;
2360 }
2361 KABC::Addressee::List list;
2362 XXPortSelectDialog dlg( this, false, this );
2363 if ( dlg.exec() )
2364 list = dlg.contacts();
2365 else
2366 return;
2367 KABC::Addressee::List::Iterator it;
2368 for ( it = list.begin(); it != list.end(); ++it ) {
2369 QString fName;
2370 if ( setpref.simple->isChecked() )
2371 fName = NameEditDialog::formattedName( (*it), NameEditDialog::SimpleName );
2372 else if ( setpref.full->isChecked() )
2373 fName = NameEditDialog::formattedName( (*it), NameEditDialog::FullName );
2374 else if ( setpref.reverse->isChecked() )
2375 fName = NameEditDialog::formattedName( (*it), NameEditDialog::ReverseName );
2376 else
2377 fName = (*it).organization();
2378 if ( setpref.setCompany->isChecked() )
2379 if ( fName.isEmpty() || fName =="," )
2380 fName = (*it).organization();
2381 (*it).setFormattedName( fName );
2382 addrModified((*it),false );
2383 }
2384 Addressee add;
2385 mDetails->setAddressee( add );
2386}
2310 2387
2311void KABCore::clipboardDataChanged() 2388void KABCore::clipboardDataChanged()
2312{ 2389{
2313 2390
2314 if ( mReadWrite ) 2391 if ( mReadWrite )
2315 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() ); 2392 mActionPaste->setEnabled( !QApplication::clipboard()->text().isEmpty() );
2316 2393
2317} 2394}
2318 2395
2319void KABCore::updateActionMenu() 2396void KABCore::updateActionMenu()
2320{ 2397{
2321 UndoStack *undo = UndoStack::instance(); 2398 UndoStack *undo = UndoStack::instance();
2322 RedoStack *redo = RedoStack::instance(); 2399 RedoStack *redo = RedoStack::instance();
2323 2400
2324 if ( undo->isEmpty() ) 2401 if ( undo->isEmpty() )
2325 mActionUndo->setText( i18n( "Undo" ) ); 2402 mActionUndo->setText( i18n( "Undo" ) );
2326 else 2403 else
2327 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) ); 2404 mActionUndo->setText( i18n( "Undo %1" ).arg( undo->top()->name() ) );
2328 2405
2329 mActionUndo->setEnabled( !undo->isEmpty() ); 2406 mActionUndo->setEnabled( !undo->isEmpty() );
2330 2407
2331 if ( !redo->top() ) 2408 if ( !redo->top() )
2332 mActionRedo->setText( i18n( "Redo" ) ); 2409 mActionRedo->setText( i18n( "Redo" ) );
2333 else 2410 else
2334 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) ); 2411 mActionRedo->setText( i18n( "Redo %1" ).arg( redo->top()->name() ) );
2335 2412
2336 mActionRedo->setEnabled( !redo->isEmpty() ); 2413 mActionRedo->setEnabled( !redo->isEmpty() );
2337} 2414}
2338 2415
2339void KABCore::configureKeyBindings() 2416void KABCore::configureKeyBindings()
2340{ 2417{
2341#ifndef KAB_EMBEDDED 2418#ifndef KAB_EMBEDDED
2342 KKeyDialog::configure( actionCollection(), true ); 2419 KKeyDialog::configure( actionCollection(), true );
2343#else //KAB_EMBEDDED 2420#else //KAB_EMBEDDED
2344 qDebug("KABCore::configureKeyBindings() not implemented"); 2421 qDebug("KABCore::configureKeyBindings() not implemented");
2345#endif //KAB_EMBEDDED 2422#endif //KAB_EMBEDDED
2346} 2423}
2347 2424
2348#ifdef KAB_EMBEDDED 2425#ifdef KAB_EMBEDDED
2349void KABCore::configureResources() 2426void KABCore::configureResources()
2350{ 2427{
2351 KRES::KCMKResources dlg( this, "" , 0 ); 2428 KRES::KCMKResources dlg( this, "" , 0 );
2352 2429
2353 if ( !dlg.exec() ) 2430 if ( !dlg.exec() )
2354 return; 2431 return;
2355 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") ); 2432 KMessageBox::information( this, i18n("Please restart to get the \nchanged resources (re)loaded!\n") );
2356} 2433}
2357#endif //KAB_EMBEDDED 2434#endif //KAB_EMBEDDED
2358 2435
2359 2436
2360/* this method will be called through the QCop interface from Ko/Pi to select addresses 2437/* this method will be called through the QCop interface from Ko/Pi to select addresses
2361 * for the attendees list of an event. 2438 * for the attendees list of an event.
2362 */ 2439 */
2363void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid) 2440void KABCore::requestForNameEmailUidList(const QString& sourceChannel, const QString& uid)
2364{ 2441{
2365 QStringList nameList; 2442 QStringList nameList;
2366 QStringList emailList; 2443 QStringList emailList;
2367 QStringList uidList; 2444 QStringList uidList;
2368 2445
2369 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); 2446 KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this);
2370 uint i=0; 2447 uint i=0;
2371 for (i=0; i < list.count(); i++) 2448 for (i=0; i < list.count(); i++)
2372 { 2449 {
2373 nameList.append(list[i].realName()); 2450 nameList.append(list[i].realName());
2374 emailList.append(list[i].preferredEmail()); 2451 emailList.append(list[i].preferredEmail());
2375 uidList.append(list[i].uid()); 2452 uidList.append(list[i].uid());
2376 } 2453 }
2377 2454
2378 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList); 2455 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI(sourceChannel, uid, nameList, emailList, uidList);
2379 2456
2380} 2457}
2381 2458
2382/* this method will be called through the QCop interface from Ko/Pi to select birthdays 2459/* this method will be called through the QCop interface from Ko/Pi to select birthdays
2383 * to put them into the calendar. 2460 * to put them into the calendar.
2384 */ 2461 */
2385void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid) 2462void KABCore::requestForBirthdayList(const QString& sourceChannel, const QString& uid)
2386{ 2463{
2387 // qDebug("KABCore::requestForBirthdayList"); 2464 // qDebug("KABCore::requestForBirthdayList");
2388 QStringList birthdayList; 2465 QStringList birthdayList;
2389 QStringList anniversaryList; 2466 QStringList anniversaryList;
2390 QStringList realNameList; 2467 QStringList realNameList;
2391 QStringList preferredEmailList; 2468 QStringList preferredEmailList;
2392 QStringList assembledNameList; 2469 QStringList assembledNameList;
2393 QStringList uidList; 2470 QStringList uidList;
2394 2471
2395 KABC::AddressBook::Iterator it; 2472 KABC::AddressBook::Iterator it;
2396 2473
2397 int count = 0; 2474 int count = 0;
2398 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 2475 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
2399 ++count; 2476 ++count;
2400 } 2477 }
2401 QProgressBar bar(count,0 ); 2478 QProgressBar bar(count,0 );
2402 int w = 300; 2479 int w = 300;
2403 if ( QApplication::desktop()->width() < 320 ) 2480 if ( QApplication::desktop()->width() < 320 )
2404 w = 220; 2481 w = 220;
2405 int h = bar.sizeHint().height() ; 2482 int h = bar.sizeHint().height() ;
2406 int dw = QApplication::desktop()->width(); 2483 int dw = QApplication::desktop()->width();
2407 int dh = QApplication::desktop()->height(); 2484 int dh = QApplication::desktop()->height();
2408 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2485 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2409 bar.show(); 2486 bar.show();
2410 bar.setCaption (i18n("Collecting birthdays - close to abort!") ); 2487 bar.setCaption (i18n("Collecting birthdays - close to abort!") );
2411 qApp->processEvents(); 2488 qApp->processEvents();
2412 2489
2413 QDate bday; 2490 QDate bday;
2414 QString anni; 2491 QString anni;
2415 QString formattedbday; 2492 QString formattedbday;
2416 2493
2417 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) 2494 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it )
2418 { 2495 {
2419 if ( ! bar.isVisible() ) 2496 if ( ! bar.isVisible() )
2420 return; 2497 return;
2421 bar.setProgress( count++ ); 2498 bar.setProgress( count++ );
2422 qApp->processEvents(); 2499 qApp->processEvents();
2423 bday = (*it).birthday().date(); 2500 bday = (*it).birthday().date();
2424 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" ); 2501 anni = (*it).custom("KADDRESSBOOK", "X-Anniversary" );
2425 2502
2426 if ( bday.isValid() || !anni.isEmpty()) 2503 if ( bday.isValid() || !anni.isEmpty())
2427 { 2504 {
2428 if (bday.isValid()) 2505 if (bday.isValid())
2429 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate); 2506 formattedbday = KGlobal::locale()->formatDate(bday, true, KLocale::ISODate);
2430 else 2507 else
2431 formattedbday = "NOTVALID"; 2508 formattedbday = "NOTVALID";
2432 if (anni.isEmpty()) 2509 if (anni.isEmpty())
2433 anni = "INVALID"; 2510 anni = "INVALID";
2434 2511
2435 birthdayList.append(formattedbday); 2512 birthdayList.append(formattedbday);
2436 anniversaryList.append(anni); //should be ISODate 2513 anniversaryList.append(anni); //should be ISODate
2437 realNameList.append((*it).realName()); 2514 realNameList.append((*it).realName());
2438 preferredEmailList.append((*it).preferredEmail()); 2515 preferredEmailList.append((*it).preferredEmail());
2439 assembledNameList.append((*it).assembledName()); 2516 assembledNameList.append((*it).assembledName());
2440 uidList.append((*it).uid()); 2517 uidList.append((*it).uid());
2441 2518
2442 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() ); 2519 //qDebug("found birthday in KA/Pi: %s,%s,%s,%s: %s, %s", (*it).realName().latin1(), (*it).preferredEmail().latin1(), (*it).assembledName().latin1(), (*it).uid().latin1(), formattedbday.latin1(), anni.latin1() );
2443 } 2520 }
2444 } 2521 }
2445 2522
2446 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList); 2523 bool res = ExternalAppHandler::instance()->returnBirthdayListFromKAPI(sourceChannel, uid, birthdayList, anniversaryList, realNameList, preferredEmailList, assembledNameList, uidList);
2447 2524
2448} 2525}
2449 2526
2450/* this method will be called through the QCop interface from other apps to show details of a contact. 2527/* this method will be called through the QCop interface from other apps to show details of a contact.
2451 */ 2528 */
2452void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid) 2529void KABCore::requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
2453{ 2530{
2454 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1()); 2531 //qDebug("KABCore::requestForDetails %s %s %s %s %s", sourceChannel.latin1(), sessionuid.latin1(), name.latin1(), email.latin1(), uid.latin1());
2455 2532
2456 QString foundUid = QString::null; 2533 QString foundUid = QString::null;
2457 if ( ! uid.isEmpty() ) { 2534 if ( ! uid.isEmpty() ) {
2458 Addressee adrr = mAddressBook->findByUid( uid ); 2535 Addressee adrr = mAddressBook->findByUid( uid );
2459 if ( !adrr.isEmpty() ) { 2536 if ( !adrr.isEmpty() ) {
2460 foundUid = uid; 2537 foundUid = uid;
2461 } 2538 }
2462 if ( email == "sendbacklist" ) { 2539 if ( email == "sendbacklist" ) {
2463 //qDebug("ssssssssssssssssssssssend "); 2540 //qDebug("ssssssssssssssssssssssend ");
2464 QStringList nameList; 2541 QStringList nameList;
2465 QStringList emailList; 2542 QStringList emailList;
2466 QStringList uidList; 2543 QStringList uidList;
2467 nameList.append(adrr.realName()); 2544 nameList.append(adrr.realName());
2468 emailList = adrr.emails(); 2545 emailList = adrr.emails();
2469 uidList.append( adrr.preferredEmail()); 2546 uidList.append( adrr.preferredEmail());
2470 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList); 2547 bool res = ExternalAppHandler::instance()->returnNameEmailUidListFromKAPI("QPE/Application/ompi", uid, nameList, emailList, uidList);
2471 return; 2548 return;
2472 } 2549 }
2473 2550
2474 } 2551 }
2475 2552
2476 if ( email == "sendbacklist" ) 2553 if ( email == "sendbacklist" )
2477 return; 2554 return;
2478 if (foundUid.isEmpty()) 2555 if (foundUid.isEmpty())
2479 { 2556 {
2480 //find the uid of the person first 2557 //find the uid of the person first
2481 Addressee::List namelist; 2558 Addressee::List namelist;
2482 Addressee::List emaillist; 2559 Addressee::List emaillist;
2483 2560
2484 if (!name.isEmpty()) 2561 if (!name.isEmpty())
2485 namelist = mAddressBook->findByName( name ); 2562 namelist = mAddressBook->findByName( name );
2486 2563
2487 if (!email.isEmpty()) 2564 if (!email.isEmpty())
2488 emaillist = mAddressBook->findByEmail( email ); 2565 emaillist = mAddressBook->findByEmail( email );
2489 //qDebug("count %d %d ", namelist.count(),emaillist.count() ); 2566 //qDebug("count %d %d ", namelist.count(),emaillist.count() );
2490 //check if we have a match in Namelist and Emaillist 2567 //check if we have a match in Namelist and Emaillist
2491 if ((namelist.count() == 0) && (emaillist.count() > 0)) { 2568 if ((namelist.count() == 0) && (emaillist.count() > 0)) {
2492 foundUid = emaillist[0].uid(); 2569 foundUid = emaillist[0].uid();
2493 } 2570 }
2494 else if ((namelist.count() > 0) && (emaillist.count() == 0)) 2571 else if ((namelist.count() > 0) && (emaillist.count() == 0))
2495 foundUid = namelist[0].uid(); 2572 foundUid = namelist[0].uid();
2496 else 2573 else
2497 { 2574 {
2498 for (int i = 0; i < namelist.count(); i++) 2575 for (int i = 0; i < namelist.count(); i++)
2499 { 2576 {
2500 for (int j = 0; j < emaillist.count(); j++) 2577 for (int j = 0; j < emaillist.count(); j++)
2501 { 2578 {
2502 if (namelist[i] == emaillist[j]) 2579 if (namelist[i] == emaillist[j])
2503 { 2580 {
2504 foundUid = namelist[i].uid(); 2581 foundUid = namelist[i].uid();
2505 } 2582 }
2506 } 2583 }
2507 } 2584 }
2508 } 2585 }
2509 } 2586 }
2510 else 2587 else
2511 { 2588 {
2512 foundUid = uid; 2589 foundUid = uid;
2513 } 2590 }
2514 2591
2515 if (!foundUid.isEmpty()) 2592 if (!foundUid.isEmpty())
2516 { 2593 {
2517 2594
2518 // raise Ka/Pi if it is in the background 2595 // raise Ka/Pi if it is in the background
2519#ifndef DESKTOP_VERSION 2596#ifndef DESKTOP_VERSION
2520#ifndef KORG_NODCOP 2597#ifndef KORG_NODCOP
2521 //QCopEnvelope e("QPE/Application/kapi", "raise()"); 2598 //QCopEnvelope e("QPE/Application/kapi", "raise()");
2522#endif 2599#endif
2523#endif 2600#endif
2524 2601
2525 mMainWindow->showMaximized(); 2602 mMainWindow->showMaximized();
2526 mMainWindow-> raise(); 2603 mMainWindow-> raise();
2527 2604
2528 mViewManager->setSelected( "", false); 2605 mViewManager->setSelected( "", false);
2529 mViewManager->refreshView( "" ); 2606 mViewManager->refreshView( "" );
2530 mViewManager->setSelected( foundUid, true ); 2607 mViewManager->setSelected( foundUid, true );
2531 mViewManager->refreshView( foundUid ); 2608 mViewManager->refreshView( foundUid );
2532 2609
2533 if ( !mMultipleViewsAtOnce ) 2610 if ( !mMultipleViewsAtOnce )
2534 { 2611 {
2535 setDetailsVisible( true ); 2612 setDetailsVisible( true );
2536 mActionDetails->setChecked(true); 2613 mActionDetails->setChecked(true);
2537 } 2614 }
2538 } 2615 }
2539} 2616}
2540 2617
2541void KABCore::whatsnew() 2618void KABCore::whatsnew()
2542{ 2619{
2543 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 2620 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
2544} 2621}
2545void KABCore::synchowto() 2622void KABCore::synchowto()
2546{ 2623{
2547 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 2624 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
2548} 2625}
2549void KABCore::kdesynchowto() 2626void KABCore::kdesynchowto()
2550{ 2627{
2551 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 2628 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
2552} 2629}
2553void KABCore::multisynchowto() 2630void KABCore::multisynchowto()
2554{ 2631{
2555 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 2632 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
2556} 2633}
2557void KABCore::faq() 2634void KABCore::faq()
2558{ 2635{
2559 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" ); 2636 KApplication::showFile( "KA/Pi FAQ", "kdepim/kaddressbook/kapiFAQ.txt" );
2560} 2637}
2561 2638
2562#include <libkcal/syncdefines.h> 2639#include <libkcal/syncdefines.h>
2563 2640
2564KABC::Addressee KABCore::getLastSyncAddressee() 2641KABC::Addressee KABCore::getLastSyncAddressee()
2565{ 2642{
2566 Addressee lse; 2643 Addressee lse;
2567 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2644 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2568 2645
2569 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 2646 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
2570 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2647 lse = mAddressBook->findByUid( "last-syncAddressee-"+mCurrentSyncDevice );
2571 if (lse.isEmpty()) { 2648 if (lse.isEmpty()) {
2572 qDebug("Creating new last-syncAddressee "); 2649 qDebug("Creating new last-syncAddressee ");
2573 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice ); 2650 lse.setUid( "last-syncAddressee-"+mCurrentSyncDevice );
2574 QString sum = ""; 2651 QString sum = "";
2575 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 2652 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
2576 sum = "E: "; 2653 sum = "E: ";
2577 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event")); 2654 lse.setFamilyName("!"+sum+mCurrentSyncDevice + i18n(" - sync event"));
2578 lse.setRevision( mLastAddressbookSync ); 2655 lse.setRevision( mLastAddressbookSync );
2579 lse.setCategories( i18n("SyncEvent") ); 2656 lse.setCategories( i18n("SyncEvent") );
2580 mAddressBook->insertAddressee( lse ); 2657 mAddressBook->insertAddressee( lse );
2581 } 2658 }
2582 return lse; 2659 return lse;
2583} 2660}
2584int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ) 2661int KABCore::takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full )
2585{ 2662{
2586 2663
2587 //void setZaurusId(int id); 2664 //void setZaurusId(int id);
2588 // int zaurusId() const; 2665 // int zaurusId() const;
2589 // void setZaurusUid(int id); 2666 // void setZaurusUid(int id);
2590 // int zaurusUid() const; 2667 // int zaurusUid() const;
2591 // void setZaurusStat(int id); 2668 // void setZaurusStat(int id);
2592 // int zaurusStat() const; 2669 // int zaurusStat() const;
2593 // 0 equal 2670 // 0 equal
2594 // 1 take local 2671 // 1 take local
2595 // 2 take remote 2672 // 2 take remote
2596 // 3 cancel 2673 // 3 cancel
2597 QDateTime lastSync = mLastAddressbookSync; 2674 QDateTime lastSync = mLastAddressbookSync;
2598 QDateTime localMod = local->revision(); 2675 QDateTime localMod = local->revision();
2599 QDateTime remoteMod = remote->revision(); 2676 QDateTime remoteMod = remote->revision();
2600 2677
2601 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2678 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2602 2679
2603 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2680 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2604 bool remCh, locCh; 2681 bool remCh, locCh;
2605 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 2682 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
2606 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 2683 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
2607 locCh = ( localMod > mLastAddressbookSync ); 2684 locCh = ( localMod > mLastAddressbookSync );
2608 if ( !remCh && ! locCh ) { 2685 if ( !remCh && ! locCh ) {
2609 //qDebug("both not changed "); 2686 //qDebug("both not changed ");
2610 lastSync = localMod.addDays(1); 2687 lastSync = localMod.addDays(1);
2611 if ( mode <= SYNC_PREF_ASK ) 2688 if ( mode <= SYNC_PREF_ASK )
2612 return 0; 2689 return 0;
2613 } else { 2690 } else {
2614 if ( locCh ) { 2691 if ( locCh ) {
2615 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1()); 2692 //qDebug("loc changed %s %s", localMod.toString().latin1(), mLastAddressbookSync.toString().latin1());
2616 lastSync = localMod.addDays( -1 ); 2693 lastSync = localMod.addDays( -1 );
2617 if ( !remCh ) 2694 if ( !remCh )
2618 remoteMod =( lastSync.addDays( -1 ) ); 2695 remoteMod =( lastSync.addDays( -1 ) );
2619 } else { 2696 } else {
2620 //qDebug(" not loc changed "); 2697 //qDebug(" not loc changed ");
2621 lastSync = localMod.addDays( 1 ); 2698 lastSync = localMod.addDays( 1 );
2622 if ( remCh ) { 2699 if ( remCh ) {
2623 //qDebug("rem changed "); 2700 //qDebug("rem changed ");
2624 remoteMod =( lastSync.addDays( 1 ) ); 2701 remoteMod =( lastSync.addDays( 1 ) );
2625 } 2702 }
2626 2703
2627 } 2704 }
2628 } 2705 }
2629 full = true; 2706 full = true;
2630 if ( mode < SYNC_PREF_ASK ) 2707 if ( mode < SYNC_PREF_ASK )
2631 mode = SYNC_PREF_ASK; 2708 mode = SYNC_PREF_ASK;
2632 } else { 2709 } else {
2633 if ( localMod == remoteMod ) 2710 if ( localMod == remoteMod )
2634 return 0; 2711 return 0;
2635 2712
2636 } 2713 }
2637 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec()); 2714 //qDebug("%s %s --- %d %d", localMod.toString().latin1() , remoteMod.toString().latin1(), localMod.time().msec(), remoteMod.time().msec());
2638 //qDebug("lastsync %s ", lastSync.toString().latin1() ); 2715 //qDebug("lastsync %s ", lastSync.toString().latin1() );
2639 //full = true; //debug only 2716 //full = true; //debug only
2640 if ( full ) { 2717 if ( full ) {
2641 bool equ = ( (*local) == (*remote) ); 2718 bool equ = ( (*local) == (*remote) );
2642 if ( equ ) { 2719 if ( equ ) {
2643 //qDebug("equal "); 2720 //qDebug("equal ");
2644 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2721 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2645 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 2722 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
2646 } 2723 }
2647 if ( mode < SYNC_PREF_FORCE_LOCAL ) 2724 if ( mode < SYNC_PREF_FORCE_LOCAL )
2648 return 0; 2725 return 0;
2649 2726
2650 }//else //debug only 2727 }//else //debug only
2651 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 2728 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
2652 } 2729 }
2653 int result; 2730 int result;
2654 bool localIsNew; 2731 bool localIsNew;
2655 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() ); 2732 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
2656 2733
2657 if ( full && mode < SYNC_PREF_NEWEST ) 2734 if ( full && mode < SYNC_PREF_NEWEST )
2658 mode = SYNC_PREF_ASK; 2735 mode = SYNC_PREF_ASK;
2659 2736
2660 switch( mode ) { 2737 switch( mode ) {
2661 case SYNC_PREF_LOCAL: 2738 case SYNC_PREF_LOCAL:
2662 if ( lastSync > remoteMod ) 2739 if ( lastSync > remoteMod )
2663 return 1; 2740 return 1;
2664 if ( lastSync > localMod ) 2741 if ( lastSync > localMod )
2665 return 2; 2742 return 2;
2666 return 1; 2743 return 1;
2667 break; 2744 break;
2668 case SYNC_PREF_REMOTE: 2745 case SYNC_PREF_REMOTE:
2669 if ( lastSync > remoteMod ) 2746 if ( lastSync > remoteMod )
2670 return 1; 2747 return 1;
2671 if ( lastSync > localMod ) 2748 if ( lastSync > localMod )
2672 return 2; 2749 return 2;
2673 return 2; 2750 return 2;
2674 break; 2751 break;
2675 case SYNC_PREF_NEWEST: 2752 case SYNC_PREF_NEWEST:
2676 if ( localMod > remoteMod ) 2753 if ( localMod > remoteMod )
2677 return 1; 2754 return 1;
2678 else 2755 else
2679 return 2; 2756 return 2;
2680 break; 2757 break;
2681 case SYNC_PREF_ASK: 2758 case SYNC_PREF_ASK:
2682 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 2759 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
2683 if ( lastSync > remoteMod ) 2760 if ( lastSync > remoteMod )
2684 return 1; 2761 return 1;
2685 if ( lastSync > localMod ) 2762 if ( lastSync > localMod )
2686 return 2; 2763 return 2;
2687 localIsNew = localMod >= remoteMod; 2764 localIsNew = localMod >= remoteMod;
2688 //qDebug("conflict! ************************************** "); 2765 //qDebug("conflict! ************************************** ");
2689 { 2766 {
2690 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this ); 2767 KPIM::AddresseeChooser acd ( *local,*remote, localIsNew , this );
2691 result = acd.executeD(localIsNew); 2768 result = acd.executeD(localIsNew);
2692 return result; 2769 return result;
2693 } 2770 }
2694 break; 2771 break;
2695 case SYNC_PREF_FORCE_LOCAL: 2772 case SYNC_PREF_FORCE_LOCAL:
2696 return 1; 2773 return 1;
2697 break; 2774 break;
2698 case SYNC_PREF_FORCE_REMOTE: 2775 case SYNC_PREF_FORCE_REMOTE:
2699 return 2; 2776 return 2;
2700 break; 2777 break;
2701 2778
2702 default: 2779 default:
2703 // SYNC_PREF_TAKE_BOTH not implemented 2780 // SYNC_PREF_TAKE_BOTH not implemented
2704 break; 2781 break;
2705 } 2782 }
2706 return 0; 2783 return 0;
2707} 2784}
2708 2785
2709 2786
2710bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode) 2787bool KABCore::synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode)
2711{ 2788{
2712 bool syncOK = true; 2789 bool syncOK = true;
2713 int addedAddressee = 0; 2790 int addedAddressee = 0;
2714 int addedAddresseeR = 0; 2791 int addedAddresseeR = 0;
2715 int deletedAddresseeR = 0; 2792 int deletedAddresseeR = 0;
2716 int deletedAddresseeL = 0; 2793 int deletedAddresseeL = 0;
2717 int changedLocal = 0; 2794 int changedLocal = 0;
2718 int changedRemote = 0; 2795 int changedRemote = 0;
2719 2796
2720 QString mCurrentSyncName = syncManager->getCurrentSyncName(); 2797 QString mCurrentSyncName = syncManager->getCurrentSyncName();
2721 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 2798 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
2722 2799
2723 //QPtrList<Addressee> el = local->rawAddressees(); 2800 //QPtrList<Addressee> el = local->rawAddressees();
2724 Addressee addresseeR; 2801 Addressee addresseeR;
2725 QString uid; 2802 QString uid;
2726 int take; 2803 int take;
2727 Addressee addresseeL; 2804 Addressee addresseeL;
2728 Addressee addresseeRSync; 2805 Addressee addresseeRSync;
2729 Addressee addresseeLSync; 2806 Addressee addresseeLSync;
2730 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees(); 2807 // KABC::Addressee::List addresseeRSyncSharp = remote->getExternLastSyncAddressees();
2731 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees(); 2808 //KABC::Addressee::List addresseeLSyncSharp = local->getExternLastSyncAddressees();
2732 bool fullDateRange = false; 2809 bool fullDateRange = false;
2733 local->resetTempSyncStat(); 2810 local->resetTempSyncStat();
2734 mLastAddressbookSync = QDateTime::currentDateTime(); 2811 mLastAddressbookSync = QDateTime::currentDateTime();
2735 if ( syncManager->syncWithDesktop() ) { 2812 if ( syncManager->syncWithDesktop() ) {
2736 // remote->removeSyncInfo( QString());//remove all info 2813 // remote->removeSyncInfo( QString());//remove all info
2737 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 2814 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
2738 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent; 2815 mLastAddressbookSync = KSyncManager::mRequestedSyncEvent;
2739 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() ); 2816 qDebug("using extern time for calendar sync: %s ", mLastAddressbookSync.toString().latin1() );
2740 } else { 2817 } else {
2741 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 2818 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
2742 } 2819 }
2743 } 2820 }
2744 QDateTime modifiedCalendar = mLastAddressbookSync; 2821 QDateTime modifiedCalendar = mLastAddressbookSync;
2745 addresseeLSync = getLastSyncAddressee(); 2822 addresseeLSync = getLastSyncAddressee();
2746 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1()); 2823 qDebug("Last Sync %s ", addresseeLSync.revision().toString().latin1());
2747 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName ); 2824 addresseeR = remote->findByUid("last-syncAddressee-"+mCurrentSyncName );
2748 if ( !addresseeR.isEmpty() ) { 2825 if ( !addresseeR.isEmpty() ) {
2749 addresseeRSync = addresseeR; 2826 addresseeRSync = addresseeR;
2750 remote->removeAddressee(addresseeR ); 2827 remote->removeAddressee(addresseeR );
2751 2828
2752 } else { 2829 } else {
2753 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2754 addresseeRSync = addresseeLSync ; 2831 addresseeRSync = addresseeLSync ;
2755 } else { 2832 } else {
2756 //qDebug("FULLDATE 1"); 2833 //qDebug("FULLDATE 1");
2757 fullDateRange = true; 2834 fullDateRange = true;
2758 Addressee newAdd; 2835 Addressee newAdd;
2759 addresseeRSync = newAdd; 2836 addresseeRSync = newAdd;
2760 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee")); 2837 addresseeRSync.setFamilyName(mCurrentSyncName + i18n(" - sync addressee"));
2761 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName ); 2838 addresseeRSync.setUid("last-syncAddressee-"+mCurrentSyncName );
2762 addresseeRSync.setRevision( mLastAddressbookSync ); 2839 addresseeRSync.setRevision( mLastAddressbookSync );
2763 addresseeRSync.setCategories( i18n("SyncAddressee") ); 2840 addresseeRSync.setCategories( i18n("SyncAddressee") );
2764 } 2841 }
2765 } 2842 }
2766 if ( addresseeLSync.revision() == mLastAddressbookSync ) { 2843 if ( addresseeLSync.revision() == mLastAddressbookSync ) {
2767 // qDebug("FULLDATE 2"); 2844 // qDebug("FULLDATE 2");
2768 fullDateRange = true; 2845 fullDateRange = true;
2769 } 2846 }
2770 if ( ! fullDateRange ) { 2847 if ( ! fullDateRange ) {
2771 if ( addresseeLSync.revision() != addresseeRSync.revision() ) { 2848 if ( addresseeLSync.revision() != addresseeRSync.revision() ) {
2772 2849
2773 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() ); 2850 // qDebug("set fulldate to true %s %s" ,addresseeLSync->dtStart().toString().latin1(), addresseeRSync->dtStart().toString().latin1() );
2774 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec()); 2851 //qDebug("%d %d %d %d ", addresseeLSync->dtStart().time().second(), addresseeLSync->dtStart().time().msec() , addresseeRSync->dtStart().time().second(), addresseeRSync->dtStart().time().msec());
2775 fullDateRange = true; 2852 fullDateRange = true;
2776 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() ); 2853 //qDebug("FULLDATE 3 %s %s", addresseeLSync.revision().toString().latin1() , addresseeRSync.revision().toString().latin1() );
2777 } 2854 }
2778 } 2855 }
2779 // fullDateRange = true; // debug only! 2856 // fullDateRange = true; // debug only!
2780 if ( fullDateRange ) 2857 if ( fullDateRange )
2781 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365); 2858 mLastAddressbookSync = QDateTime::currentDateTime().addDays( -100*365);
2782 else 2859 else
2783 mLastAddressbookSync = addresseeLSync.revision(); 2860 mLastAddressbookSync = addresseeLSync.revision();
2784 // for resyncing if own file has changed 2861 // for resyncing if own file has changed
2785 // PENDING fixme later when implemented 2862 // PENDING fixme later when implemented
2786#if 0 2863#if 0
2787 if ( mCurrentSyncDevice == "deleteaftersync" ) { 2864 if ( mCurrentSyncDevice == "deleteaftersync" ) {
2788 mLastAddressbookSync = loadedFileVersion; 2865 mLastAddressbookSync = loadedFileVersion;
2789 qDebug("setting mLastAddressbookSync "); 2866 qDebug("setting mLastAddressbookSync ");
2790 } 2867 }
2791#endif 2868#endif
2792 2869
2793 //qDebug("*************************** "); 2870 //qDebug("*************************** ");
2794 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() ); 2871 // qDebug("mLastAddressbookSync %s ",mLastAddressbookSync.toString().latin1() );
2795 QStringList er = remote->uidList(); 2872 QStringList er = remote->uidList();
2796 Addressee inR ;//= er.first(); 2873 Addressee inR ;//= er.first();
2797 Addressee inL; 2874 Addressee inL;
2798 2875
2799 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count()); 2876 syncManager->showProgressBar(0, i18n("Syncing - close to abort!"), er.count());
2800 2877
2801 int modulo = (er.count()/10)+1; 2878 int modulo = (er.count()/10)+1;
2802 int incCounter = 0; 2879 int incCounter = 0;
2803 while ( incCounter < er.count()) { 2880 while ( incCounter < er.count()) {
2804 if (syncManager->isProgressBarCanceled()) 2881 if (syncManager->isProgressBarCanceled())
2805 return false; 2882 return false;
2806 if ( incCounter % modulo == 0 ) 2883 if ( incCounter % modulo == 0 )
2807 syncManager->showProgressBar(incCounter); 2884 syncManager->showProgressBar(incCounter);
2808 2885
2809 uid = er[ incCounter ]; 2886 uid = er[ incCounter ];
2810 bool skipIncidence = false; 2887 bool skipIncidence = false;
2811 if ( uid.left(19) == QString("last-syncAddressee-") ) 2888 if ( uid.left(19) == QString("last-syncAddressee-") )
2812 skipIncidence = true; 2889 skipIncidence = true;
2813 QString idS,OidS; 2890 QString idS,OidS;
2814 qApp->processEvents(); 2891 qApp->processEvents();
2815 if ( !skipIncidence ) { 2892 if ( !skipIncidence ) {
2816 inL = local->findByUid( uid ); 2893 inL = local->findByUid( uid );
2817 inR = remote->findByUid( uid ); 2894 inR = remote->findByUid( uid );
2818 //inL.setResource( 0 ); 2895 //inL.setResource( 0 );
2819 //inR.setResource( 0 ); 2896 //inR.setResource( 0 );
2820 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars 2897 if ( !inL.isEmpty() ) { // maybe conflict - same uid in both calendars
2821 if ( !inL.resource() || inL.resource()->includeInSync() ) { 2898 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2822 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) { 2899 if ( (take = takeAddressee( &inL, &inR, mode, fullDateRange )) ) {
2823 //qDebug("take %d %s ", take, inL.summary().latin1()); 2900 //qDebug("take %d %s ", take, inL.summary().latin1());
2824 if ( take == 3 ) 2901 if ( take == 3 )
2825 return false; 2902 return false;
2826 if ( take == 1 ) {// take local ********************** 2903 if ( take == 1 ) {// take local **********************
2827 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2904 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2828 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2905 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2829 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2906 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2830 local->insertAddressee( inL, false ); 2907 local->insertAddressee( inL, false );
2831 idS = inR.externalUID(); 2908 idS = inR.externalUID();
2832 OidS = inR.originalExternalUID(); 2909 OidS = inR.originalExternalUID();
2833 } 2910 }
2834 else 2911 else
2835 idS = inR.IDStr(); 2912 idS = inR.IDStr();
2836 remote->removeAddressee( inR ); 2913 remote->removeAddressee( inR );
2837 inR = inL; 2914 inR = inL;
2838 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 2915 inR.setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
2839 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2916 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2840 inR.setOriginalExternalUID( OidS ); 2917 inR.setOriginalExternalUID( OidS );
2841 inR.setExternalUID( idS ); 2918 inR.setExternalUID( idS );
2842 if ( syncManager->syncWithDesktop() ) { 2919 if ( syncManager->syncWithDesktop() ) {
2843 inR.setIDStr("changed" ); 2920 inR.setIDStr("changed" );
2844 } 2921 }
2845 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" ); 2922 //inR.insertCustom( "KADDRESSBOOK", "X-KDESYNC","changed" );
2846 } else { 2923 } else {
2847 inR.setIDStr( idS ); 2924 inR.setIDStr( idS );
2848 } 2925 }
2849 inR.setResource( 0 ); 2926 inR.setResource( 0 );
2850 remote->insertAddressee( inR , false); 2927 remote->insertAddressee( inR , false);
2851 ++changedRemote; 2928 ++changedRemote;
2852 } else { // take == 2 take remote ********************** 2929 } else { // take == 2 take remote **********************
2853 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2930 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2854 if ( inR.revision().date().year() < 2004 ) 2931 if ( inR.revision().date().year() < 2004 )
2855 inR.setRevision( modifiedCalendar ); 2932 inR.setRevision( modifiedCalendar );
2856 } 2933 }
2857 idS = inL.IDStr(); 2934 idS = inL.IDStr();
2858 local->removeAddressee( inL ); 2935 local->removeAddressee( inL );
2859 inL = inR; 2936 inL = inR;
2860 inL.setIDStr( idS ); 2937 inL.setIDStr( idS );
2861 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2938 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2862 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2939 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2863 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2940 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2864 } 2941 }
2865 inL.setResource( 0 ); 2942 inL.setResource( 0 );
2866 local->insertAddressee( inL , false ); 2943 local->insertAddressee( inL , false );
2867 ++changedLocal; 2944 ++changedLocal;
2868 } 2945 }
2869 } 2946 }
2870 } 2947 }
2871 } else { // no conflict ********** add or delete remote 2948 } else { // no conflict ********** add or delete remote
2872 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 2949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2873 QString des = addresseeLSync.note(); 2950 QString des = addresseeLSync.note();
2874 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 2951 if ( des.find( inR.getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
2875 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 2952 inR.setTempSyncStat( SYNC_TEMPSTATE_DELETE );
2876 remote->insertAddressee( inR, false ); 2953 remote->insertAddressee( inR, false );
2877 ++deletedAddresseeR; 2954 ++deletedAddresseeR;
2878 } else { 2955 } else {
2879 inR.setRevision( modifiedCalendar ); 2956 inR.setRevision( modifiedCalendar );
2880 remote->insertAddressee( inR, false ); 2957 remote->insertAddressee( inR, false );
2881 inL = inR; 2958 inL = inR;
2882 inL.setIDStr( ":" ); 2959 inL.setIDStr( ":" );
2883 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) ); 2960 inL.setCsum( mCurrentSyncDevice, inR.getCsum(mCurrentSyncDevice) );
2884 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) ); 2961 inL.setID( mCurrentSyncDevice, inR.getID(mCurrentSyncDevice) );
2885 inL.setResource( 0 ); 2962 inL.setResource( 0 );
2886 local->insertAddressee( inL , false); 2963 local->insertAddressee( inL , false);
2887 ++addedAddressee; 2964 ++addedAddressee;
2888 } 2965 }
2889 } else { 2966 } else {
2890 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) { 2967 if ( inR.revision() > mLastAddressbookSync || mode == 5 ) {
2891 inR.setRevision( modifiedCalendar ); 2968 inR.setRevision( modifiedCalendar );
2892 remote->insertAddressee( inR, false ); 2969 remote->insertAddressee( inR, false );
2893 inR.setResource( 0 ); 2970 inR.setResource( 0 );
2894 local->insertAddressee( inR, false ); 2971 local->insertAddressee( inR, false );
2895 ++addedAddressee; 2972 ++addedAddressee;
2896 } else { 2973 } else {
2897 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR); 2974 // pending checkExternSyncAddressee(addresseeRSyncSharp, inR);
2898 remote->removeAddressee( inR ); 2975 remote->removeAddressee( inR );
2899 ++deletedAddresseeR; 2976 ++deletedAddresseeR;
2900 } 2977 }
2901 } 2978 }
2902 } 2979 }
2903 } 2980 }
2904 ++incCounter; 2981 ++incCounter;
2905 } 2982 }
2906 er.clear(); 2983 er.clear();
2907 QStringList el = local->uidList(); 2984 QStringList el = local->uidList();
2908 modulo = (el.count()/10)+1; 2985 modulo = (el.count()/10)+1;
2909 2986
2910 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count()); 2987 syncManager->showProgressBar(0, i18n("Add / remove addressees"), el.count());
2911 incCounter = 0; 2988 incCounter = 0;
2912 while ( incCounter < el.count()) { 2989 while ( incCounter < el.count()) {
2913 qApp->processEvents(); 2990 qApp->processEvents();
2914 if (syncManager->isProgressBarCanceled()) 2991 if (syncManager->isProgressBarCanceled())
2915 return false; 2992 return false;
2916 if ( incCounter % modulo == 0 ) 2993 if ( incCounter % modulo == 0 )
2917 syncManager->showProgressBar(incCounter); 2994 syncManager->showProgressBar(incCounter);
2918 uid = el[ incCounter ]; 2995 uid = el[ incCounter ];
2919 bool skipIncidence = false; 2996 bool skipIncidence = false;
2920 if ( uid.left(19) == QString("last-syncAddressee-") ) 2997 if ( uid.left(19) == QString("last-syncAddressee-") )
2921 skipIncidence = true; 2998 skipIncidence = true;
2922 if ( !skipIncidence ) { 2999 if ( !skipIncidence ) {
2923 inL = local->findByUid( uid ); 3000 inL = local->findByUid( uid );
2924 if ( !inL.resource() || inL.resource()->includeInSync() ) { 3001 if ( !inL.resource() || inL.resource()->includeInSync() ) {
2925 inR = remote->findByUid( uid ); 3002 inR = remote->findByUid( uid );
2926 if ( inR.isEmpty() ) { // no conflict ********** add or delete local 3003 if ( inR.isEmpty() ) { // no conflict ********** add or delete local
2927 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 3004 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
2928 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 3005 if ( !inL.getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
2929 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3006 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2930 local->removeAddressee( inL ); 3007 local->removeAddressee( inL );
2931 ++deletedAddresseeL; 3008 ++deletedAddresseeL;
2932 } else { 3009 } else {
2933 if ( ! syncManager->mWriteBackExistingOnly ) { 3010 if ( ! syncManager->mWriteBackExistingOnly ) {
2934 inL.removeID(mCurrentSyncDevice ); 3011 inL.removeID(mCurrentSyncDevice );
2935 ++addedAddresseeR; 3012 ++addedAddresseeR;
2936 inL.setRevision( modifiedCalendar ); 3013 inL.setRevision( modifiedCalendar );
2937 local->insertAddressee( inL, false ); 3014 local->insertAddressee( inL, false );
2938 inR = inL; 3015 inR = inL;
2939 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL ); 3016 inR.setTempSyncStat( SYNC_TEMPSTATE_ADDED_EXTERNAL );
2940 inR.setResource( 0 ); 3017 inR.setResource( 0 );
2941 remote->insertAddressee( inR, false ); 3018 remote->insertAddressee( inR, false );
2942 } 3019 }
2943 } 3020 }
2944 } else { 3021 } else {
2945 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) { 3022 if ( inL.revision() < mLastAddressbookSync && mode != 4 ) {
2946 //qDebug("data %s ", inL.revision().toString().latin1()); 3023 //qDebug("data %s ", inL.revision().toString().latin1());
2947 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL); 3024 // pending checkExternSyncAddressee(addresseeLSyncSharp, inL);
2948 local->removeAddressee( inL ); 3025 local->removeAddressee( inL );
2949 ++deletedAddresseeL; 3026 ++deletedAddresseeL;
2950 } else { 3027 } else {
2951 if ( ! syncManager->mWriteBackExistingOnly ) { 3028 if ( ! syncManager->mWriteBackExistingOnly ) {
2952 ++addedAddresseeR; 3029 ++addedAddresseeR;
2953 inL.setRevision( modifiedCalendar ); 3030 inL.setRevision( modifiedCalendar );
2954 local->insertAddressee( inL, false ); 3031 local->insertAddressee( inL, false );
2955 inR = inL; 3032 inR = inL;
2956 inR.setIDStr( ":" ); 3033 inR.setIDStr( ":" );
2957 inR.setResource( 0 ); 3034 inR.setResource( 0 );
2958 remote->insertAddressee( inR, false ); 3035 remote->insertAddressee( inR, false );
2959 } 3036 }
2960 } 3037 }
2961 } 3038 }
2962 } 3039 }
2963 } 3040 }
2964 } 3041 }
2965 ++incCounter; 3042 ++incCounter;
2966 } 3043 }
2967 el.clear(); 3044 el.clear();
2968 syncManager->hideProgressBar(); 3045 syncManager->hideProgressBar();
2969 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 ); 3046 mLastAddressbookSync = QDateTime::currentDateTime().addSecs( 1 );
2970 // get rid of micro seconds 3047 // get rid of micro seconds
2971 QTime t = mLastAddressbookSync.time(); 3048 QTime t = mLastAddressbookSync.time();
2972 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 3049 mLastAddressbookSync.setTime( QTime (t.hour (), t.minute (), t.second () ) );
2973 addresseeLSync.setRevision( mLastAddressbookSync ); 3050 addresseeLSync.setRevision( mLastAddressbookSync );
2974 addresseeRSync.setRevision( mLastAddressbookSync ); 3051 addresseeRSync.setRevision( mLastAddressbookSync );
2975 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ; 3052 addresseeRSync.setRole( i18n("!Remote from: ")+mCurrentSyncName ) ;
2976 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName ); 3053 addresseeLSync.setRole(i18n("!Local from: ") + mCurrentSyncName );
2977 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ; 3054 addresseeRSync.setGivenName( i18n("!DO NOT EDIT!") ) ;
2978 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") ); 3055 addresseeLSync.setGivenName(i18n("!DO NOT EDIT!") );
2979 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ; 3056 addresseeRSync.setOrganization( "!"+mLastAddressbookSync.toString() ) ;
2980 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() ); 3057 addresseeLSync.setOrganization("!"+ mLastAddressbookSync.toString() );
2981 addresseeRSync.setNote( "" ) ; 3058 addresseeRSync.setNote( "" ) ;
2982 addresseeLSync.setNote( "" ); 3059 addresseeLSync.setNote( "" );
2983 3060
2984 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 3061 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
2985 remote->insertAddressee( addresseeRSync, false ); 3062 remote->insertAddressee( addresseeRSync, false );
2986 local->insertAddressee( addresseeLSync, false ); 3063 local->insertAddressee( addresseeLSync, false );
2987 QString mes; 3064 QString mes;
2988 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR ); 3065 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedAddressee, addedAddresseeR, changedLocal, changedRemote, deletedAddresseeL, deletedAddresseeR );
2989 qDebug( mes ); 3066 qDebug( mes );
2990 mes = i18n("Local addressbook changed!\n") +mes; 3067 mes = i18n("Local addressbook changed!\n") +mes;
2991 if ( syncManager->mShowSyncSummary ) { 3068 if ( syncManager->mShowSyncSummary ) {
2992 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 3069 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
2993 i18n("KA/Pi Synchronization"),i18n("Write back"))) { 3070 i18n("KA/Pi Synchronization"),i18n("Write back"))) {
2994 qDebug("cancelled "); 3071 qDebug("cancelled ");
2995 return false; 3072 return false;
2996 } 3073 }
2997 } 3074 }
2998 return syncOK; 3075 return syncOK;
2999} 3076}
3000 3077
3001 3078
3002//this is a overwritten callbackmethods from the syncinterface 3079//this is a overwritten callbackmethods from the syncinterface
3003bool KABCore::sync(KSyncManager* manager, QString filename, int mode) 3080bool KABCore::sync(KSyncManager* manager, QString filename, int mode)
3004{ 3081{
3005 3082
3006 //pending prepare addresseeview for output 3083 //pending prepare addresseeview for output
3007 //pending detect, if remote file has REV field. if not switch to external sync 3084 //pending detect, if remote file has REV field. if not switch to external sync
3008 mGlobalSyncMode = SYNC_MODE_NORMAL; 3085 mGlobalSyncMode = SYNC_MODE_NORMAL;
3009 if ( manager != syncManager ) 3086 if ( manager != syncManager )
3010 qDebug("KABCore::sync:: ERROR! :: manager != syncManager "); 3087 qDebug("KABCore::sync:: ERROR! :: manager != syncManager ");
3011 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3088 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3012 3089
3013 AddressBook abLocal(filename,"syncContact"); 3090 AddressBook abLocal(filename,"syncContact");
3014 bool syncOK = false; 3091 bool syncOK = false;
3015 if ( abLocal.load() ) { 3092 if ( abLocal.load() ) {
3016 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode ); 3093 qDebug("AB loaded %s,sync mode %d",filename.latin1(), mode );
3017 bool external = false; 3094 bool external = false;
3018 bool isXML = false; 3095 bool isXML = false;
3019 if ( filename.right(4) == ".xml") { 3096 if ( filename.right(4) == ".xml") {
3020 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3097 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3021 isXML = true; 3098 isXML = true;
3022 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3099 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3023 } else { 3100 } else {
3024 external = !manager->mIsKapiFile; 3101 external = !manager->mIsKapiFile;
3025 if ( external ) { 3102 if ( external ) {
3026 qDebug("Setting vcf mode to external "); 3103 qDebug("Setting vcf mode to external ");
3027 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3104 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3028 AddressBook::Iterator it; 3105 AddressBook::Iterator it;
3029 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3106 for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3030 (*it).setID( mCurrentSyncDevice, (*it).uid() ); 3107 (*it).setID( mCurrentSyncDevice, (*it).uid() );
3031 (*it).computeCsum( mCurrentSyncDevice ); 3108 (*it).computeCsum( mCurrentSyncDevice );
3032 } 3109 }
3033 } 3110 }
3034 } 3111 }
3035 //AddressBook::Iterator it; 3112 //AddressBook::Iterator it;
3036 //QStringList vcards; 3113 //QStringList vcards;
3037 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) { 3114 //for ( it = abLocal.begin(); it != abLocal.end(); ++it ) {
3038 // qDebug("Name %s ", (*it).familyName().latin1()); 3115 // qDebug("Name %s ", (*it).familyName().latin1());
3039 //} 3116 //}
3040 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode ); 3117 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, mode );
3041 if ( syncOK ) { 3118 if ( syncOK ) {
3042 if ( syncManager->mWriteBackFile ) 3119 if ( syncManager->mWriteBackFile )
3043 { 3120 {
3044 if ( external ) 3121 if ( external )
3045 abLocal.removeSyncAddressees( !isXML); 3122 abLocal.removeSyncAddressees( !isXML);
3046 qDebug("Saving remote AB "); 3123 qDebug("Saving remote AB ");
3047 if ( ! abLocal.saveAB()) 3124 if ( ! abLocal.saveAB())
3048 qDebug("Error writing back AB to file "); 3125 qDebug("Error writing back AB to file ");
3049 if ( external ) { 3126 if ( external ) {
3050 // afterwrite processing 3127 // afterwrite processing
3051 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML); 3128 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice ,isXML);
3052 } 3129 }
3053 } 3130 }
3054 } 3131 }
3055 setModified(); 3132 setModified();
3056 3133
3057 } 3134 }
3058 abLocal.removeResources(); 3135 abLocal.removeResources();
3059 if ( syncOK ) 3136 if ( syncOK )
3060 mViewManager->refreshView(); 3137 mViewManager->refreshView();
3061 return syncOK; 3138 return syncOK;
3062 3139
3063} 3140}
3064void KABCore::removeSyncInfo( QString syncProfile) 3141void KABCore::removeSyncInfo( QString syncProfile)
3065{ 3142{
3066 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1()); 3143 qDebug("AB:removeSyncInfo for profile %s ", syncProfile.latin1());
3067 mAddressBook->removeSyncInfo( syncProfile ); 3144 mAddressBook->removeSyncInfo( syncProfile );
3068 setModified(); 3145 setModified();
3069} 3146}
3070 3147
3071 3148
3072//this is a overwritten callbackmethods from the syncinterface 3149//this is a overwritten callbackmethods from the syncinterface
3073bool KABCore::syncExternal(KSyncManager* manager, QString resource) 3150bool KABCore::syncExternal(KSyncManager* manager, QString resource)
3074{ 3151{
3075 if ( resource == "phone" ) 3152 if ( resource == "phone" )
3076 return syncPhone(); 3153 return syncPhone();
3077 disableBR( true ); 3154 disableBR( true );
3078 if ( manager != syncManager ) 3155 if ( manager != syncManager )
3079 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager "); 3156 qDebug("KABCore::syncExternal:: ERROR! :: manager != syncManager ");
3080 QString mCurrentSyncDevice = manager->getCurrentSyncDevice(); 3157 QString mCurrentSyncDevice = manager->getCurrentSyncDevice();
3081 3158
3082 AddressBook abLocal( resource,"syncContact"); 3159 AddressBook abLocal( resource,"syncContact");
3083 bool syncOK = false; 3160 bool syncOK = false;
3084 if ( abLocal.load() ) { 3161 if ( abLocal.load() ) {
3085 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3162 qDebug("AB sharp loaded ,sync device %s",mCurrentSyncDevice.latin1());
3086 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3163 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3087 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false ); 3164 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, false );
3088 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3165 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3089 if ( syncOK ) { 3166 if ( syncOK ) {
3090 if ( syncManager->mWriteBackFile ) { 3167 if ( syncManager->mWriteBackFile ) {
3091 abLocal.removeSyncAddressees( false ); 3168 abLocal.removeSyncAddressees( false );
3092 abLocal.saveAB(); 3169 abLocal.saveAB();
3093 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3170 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3094 } 3171 }
3095 } else 3172 } else
3096 message( i18n("Sync cancelled or failed.") ); 3173 message( i18n("Sync cancelled or failed.") );
3097 setModified(); 3174 setModified();
3098 } 3175 }
3099 abLocal.removeResources(); 3176 abLocal.removeResources();
3100 if ( syncOK ) 3177 if ( syncOK )
3101 mViewManager->refreshView(); 3178 mViewManager->refreshView();
3102 disableBR( false ); 3179 disableBR( false );
3103 return syncOK; 3180 return syncOK;
3104 3181
3105} 3182}
3106void KABCore::message( QString m ) 3183void KABCore::message( QString m )
3107{ 3184{
3108 topLevelWidget()->setCaption( m ); 3185 topLevelWidget()->setCaption( m );
3109 mMessageTimer->start( 15000, true ); 3186 mMessageTimer->start( 15000, true );
3110} 3187}
3111bool KABCore::syncPhone() 3188bool KABCore::syncPhone()
3112{ 3189{
3113 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice(); 3190 QString mCurrentSyncDevice = syncManager->getCurrentSyncDevice();
3114 QString fileName = getPhoneFile(); 3191 QString fileName = getPhoneFile();
3115 if ( !PhoneAccess::readFromPhone( fileName) ) { 3192 if ( !PhoneAccess::readFromPhone( fileName) ) {
3116 message(i18n("Phone access failed!")); 3193 message(i18n("Phone access failed!"));
3117 return false; 3194 return false;
3118 } 3195 }
3119 AddressBook abLocal( fileName,"syncContact"); 3196 AddressBook abLocal( fileName,"syncContact");
3120 bool syncOK = false; 3197 bool syncOK = false;
3121 { 3198 {
3122 abLocal.importFromFile( fileName ); 3199 abLocal.importFromFile( fileName );
3123 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1()); 3200 qDebug("AB phone loaded ,sync device %s",mCurrentSyncDevice.latin1());
3124 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 3201 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
3125 abLocal.preparePhoneSync( mCurrentSyncDevice, true ); 3202 abLocal.preparePhoneSync( mCurrentSyncDevice, true );
3126 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true ); 3203 abLocal.preExternSync( mAddressBook ,mCurrentSyncDevice, true );
3127 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs ); 3204 syncOK = synchronizeAddressbooks( mAddressBook, &abLocal, syncManager->mSyncAlgoPrefs );
3128 if ( syncOK ) { 3205 if ( syncOK ) {
3129 if ( syncManager->mWriteBackFile ) { 3206 if ( syncManager->mWriteBackFile ) {
3130 abLocal.removeSyncAddressees( true ); 3207 abLocal.removeSyncAddressees( true );
3131 abLocal.saveABphone( fileName ); 3208 abLocal.saveABphone( fileName );
3132 abLocal.findNewExtIds( fileName, mCurrentSyncDevice ); 3209 abLocal.findNewExtIds( fileName, mCurrentSyncDevice );
3133 //abLocal.preparePhoneSync( mCurrentSyncDevice, false ); 3210 //abLocal.preparePhoneSync( mCurrentSyncDevice, false );
3134 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true ); 3211 abLocal.postExternSync( mAddressBook,mCurrentSyncDevice, true );
3135 } 3212 }
3136 } 3213 }
3137 setModified(); 3214 setModified();
3138 } 3215 }
3139 abLocal.removeResources(); 3216 abLocal.removeResources();
3140 if ( syncOK ) 3217 if ( syncOK )
3141 mViewManager->refreshView(); 3218 mViewManager->refreshView();
3142 return syncOK; 3219 return syncOK;
3143} 3220}
3144void KABCore::getFile( bool success ) 3221void KABCore::getFile( bool success )
3145{ 3222{
3146 if ( ! success ) { 3223 if ( ! success ) {
3147 message( i18n("Error receiving file. Nothing changed!") ); 3224 message( i18n("Error receiving file. Nothing changed!") );
3148 return; 3225 return;
3149 } 3226 }
3150 int count = mAddressBook->importFromFile( sentSyncFile() , false, true ); 3227 int count = mAddressBook->importFromFile( sentSyncFile() , false, true );
3151 if ( count ) 3228 if ( count )
3152 setModified( true ); 3229 setModified( true );
3153 message( i18n("Pi-Sync successful!") ); 3230 message( i18n("Pi-Sync successful!") );
3154 mViewManager->refreshView(); 3231 mViewManager->refreshView();
3155} 3232}
3156void KABCore::syncFileRequest() 3233void KABCore::syncFileRequest()
3157{ 3234{
3158 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) { 3235 if ( KABPrefs::instance()->mPassiveSyncWithDesktop ) {
3159 syncManager->slotSyncMenu( 999 ); 3236 syncManager->slotSyncMenu( 999 );
3160 } 3237 }
3161 mAddressBook->export2File( sentSyncFile() ); 3238 mAddressBook->export2File( sentSyncFile() );
3162} 3239}
3163QString KABCore::sentSyncFile() 3240QString KABCore::sentSyncFile()
3164{ 3241{
3165#ifdef DESKTOP_VERSION 3242#ifdef DESKTOP_VERSION
3166 return locateLocal( "tmp", "copysyncab.vcf" ); 3243 return locateLocal( "tmp", "copysyncab.vcf" );
3167#else 3244#else
3168 return QString( "/tmp/copysyncab.vcf" ); 3245 return QString( "/tmp/copysyncab.vcf" );
3169#endif 3246#endif
3170} 3247}
3171 3248
3172void KABCore::setCaptionBack() 3249void KABCore::setCaptionBack()
3173{ 3250{
3174 mMessageTimer->stop(); 3251 mMessageTimer->stop();
3175 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") ); 3252 topLevelWidget()->setCaption( i18n("KAddressbook/Pi") );
3176} 3253}
diff --git a/kaddressbook/kabcore.h b/kaddressbook/kabcore.h
index 85ffbdb..0d5891e 100644
--- a/kaddressbook/kabcore.h
+++ b/kaddressbook/kabcore.h
@@ -1,515 +1,518 @@
1/* 1/*
2 This file is part of KAddressbook. 2 This file is part of KAddressbook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCORE_H 24#ifndef KABCORE_H
25#define KABCORE_H 25#define KABCORE_H
26 26
27#include <kabc/field.h> 27#include <kabc/field.h>
28 28
29#ifndef KAB_EMBEDDED 29#ifndef KAB_EMBEDDED
30#endif //KAB_EMBEDDED 30#endif //KAB_EMBEDDED
31#include <qdict.h> 31#include <qdict.h>
32#include <qtimer.h> 32#include <qtimer.h>
33 33
34#include <qwidget.h> 34#include <qwidget.h>
35#include <qpopupmenu.h> 35#include <qpopupmenu.h>
36#include <ksyncmanager.h> 36#include <ksyncmanager.h>
37#ifndef DESKTOP_VERSION 37#ifndef DESKTOP_VERSION
38#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
39#endif 39#endif
40 40
41namespace KABC { 41namespace KABC {
42class AddressBook; 42class AddressBook;
43} 43}
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46class KAboutData; 46class KAboutData;
47class KConfig; 47class KConfig;
48 48
49class KAddressBookService; 49class KAddressBookService;
50class LDAPSearchDialog; 50class LDAPSearchDialog;
51#else //KAB_EMBEDDED 51#else //KAB_EMBEDDED
52class KAddressBookMain; 52class KAddressBookMain;
53//US class QAction; 53//US class QAction;
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55class KCMultiDialog; 55class KCMultiDialog;
56class KXMLGUIClient; 56class KXMLGUIClient;
57class ExtensionManager; 57class ExtensionManager;
58class XXPortManager; 58class XXPortManager;
59class JumpButtonBar; 59class JumpButtonBar;
60class IncSearchWidget; 60class IncSearchWidget;
61class KDGanttMinimizeSplitter; 61class KDGanttMinimizeSplitter;
62class KAction; 62class KAction;
63class KActionCollection; 63class KActionCollection;
64class KToggleAction; 64class KToggleAction;
65class KSyncProfile; 65class KSyncProfile;
66 66
67class QAction; 67class QAction;
68class QMenuBar; 68class QMenuBar;
69class QSplitter; 69class QSplitter;
70class ViewContainer; 70class ViewContainer;
71class ViewManager; 71class ViewManager;
72class AddresseeEditorDialog; 72class AddresseeEditorDialog;
73class Ir; 73class Ir;
74 74
75class KABCore : public QWidget, public KSyncInterface 75class KABCore : public QWidget, public KSyncInterface
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 78
79 public: 79 public:
80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 ); 80 KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name = 0 );
81 81
82 82
83 ~KABCore(); 83 ~KABCore();
84 84
85 85
86#ifdef KAB_EMBEDDED 86#ifdef KAB_EMBEDDED
87 //US added functionality 87 //US added functionality
88 QPopupMenu* getViewMenu() {return viewMenu;} 88 QPopupMenu* getViewMenu() {return viewMenu;}
89 QPopupMenu* getFilterMenu() {return filterMenu;} 89 QPopupMenu* getFilterMenu() {return filterMenu;}
90 QPopupMenu* getSettingsMenu() {return settingsMenu;} 90 QPopupMenu* getSettingsMenu() {return settingsMenu;}
91 void addActionsManually(); 91 void addActionsManually();
92#endif //KAB_EMBEDDED 92#endif //KAB_EMBEDDED
93 /** 93 /**
94 Restores the global settings. 94 Restores the global settings.
95 */ 95 */
96 void restoreSettings(); 96 void restoreSettings();
97 97
98 98
99 99
100 /** 100 /**
101 Returns a pointer to the StdAddressBook of the application. 101 Returns a pointer to the StdAddressBook of the application.
102 */ 102 */
103 KABC::AddressBook *addressBook() const; 103 KABC::AddressBook *addressBook() const;
104 104
105 /** 105 /**
106 Returns a pointer to the KConfig object of the application. 106 Returns a pointer to the KConfig object of the application.
107 */ 107 */
108 static KConfig *config(); 108 static KConfig *config();
109 109
110 /** 110 /**
111 Returns a pointer to the global KActionCollection object. So 111 Returns a pointer to the global KActionCollection object. So
112 other classes can register their actions easily. 112 other classes can register their actions easily.
113 */ 113 */
114 KActionCollection *actionCollection() const; 114 KActionCollection *actionCollection() const;
115 115
116 /** 116 /**
117 Returns the current search field of the Incremental Search Widget. 117 Returns the current search field of the Incremental Search Widget.
118 */ 118 */
119 KABC::Field *currentSearchField() const; 119 KABC::Field *currentSearchField() const;
120 120
121 /** 121 /**
122 Returns the uid list of the currently selected contacts. 122 Returns the uid list of the currently selected contacts.
123 */ 123 */
124 QStringList selectedUIDs() const; 124 QStringList selectedUIDs() const;
125 125
126 /** 126 /**
127 Displays the ResourceSelectDialog and returns the selected 127 Displays the ResourceSelectDialog and returns the selected
128 resource or a null pointer if no resource was selected by 128 resource or a null pointer if no resource was selected by
129 the user. 129 the user.
130 */ 130 */
131 KABC::Resource *requestResource( QWidget *parent ); 131 KABC::Resource *requestResource( QWidget *parent );
132 132
133#ifndef KAB_EMBEDDED 133#ifndef KAB_EMBEDDED
134 static KAboutData *createAboutData(); 134 static KAboutData *createAboutData();
135#endif //KAB_EMBEDDED 135#endif //KAB_EMBEDDED
136 136
137#ifdef KAB_EMBEDDED 137#ifdef KAB_EMBEDDED
138 inline QPopupMenu* getImportMenu() { return ImportMenu;} 138 inline QPopupMenu* getImportMenu() { return ImportMenu;}
139 inline QPopupMenu* getExportMenu() { return ExportMenu;} 139 inline QPopupMenu* getExportMenu() { return ExportMenu;}
140#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
141 141
142 public slots: 142 public slots:
143#ifdef KAB_EMBEDDED 143#ifdef KAB_EMBEDDED
144 void createAboutData(); 144 void createAboutData();
145#endif //KAB_EMBEDDED 145#endif //KAB_EMBEDDED
146 void setDetailsToggle(); 146 void setDetailsToggle();
147 147
148 void showLicence(); 148 void showLicence();
149 void faq(); 149 void faq();
150 void whatsnew() ; 150 void whatsnew() ;
151 void synchowto() ; 151 void synchowto() ;
152 void multisynchowto() ; 152 void multisynchowto() ;
153 void kdesynchowto() ; 153 void kdesynchowto() ;
154 void writeToPhone(); 154 void writeToPhone();
155 155
156 /** 156 /**
157 Is called whenever a contact is selected in the view. 157 Is called whenever a contact is selected in the view.
158 */ 158 */
159 void setContactSelected( const QString &uid ); 159 void setContactSelected( const QString &uid );
160 160
161 /** 161 /**
162 Opens the preferred mail composer with all selected contacts as 162 Opens the preferred mail composer with all selected contacts as
163 arguments. 163 arguments.
164 */ 164 */
165 void sendMail(); 165 void sendMail();
166 166
167 /** 167 /**
168 Opens the preferred mail composer with the given contacts as 168 Opens the preferred mail composer with the given contacts as
169 arguments. 169 arguments.
170 */ 170 */
171 void sendMail( const QString& email ); 171 void sendMail( const QString& email );
172 172
173 173
174 void mailVCard(); 174 void mailVCard();
175 void mailVCard(const QStringList& uids); 175 void mailVCard(const QStringList& uids);
176 176
177 /** 177 /**
178 Beams the "WhoAmI contact. 178 Beams the "WhoAmI contact.
179 */ 179 */
180 void beamMySelf(); 180 void beamMySelf();
181 181
182 void beamVCard(); 182 void beamVCard();
183 void export2phone(); 183 void export2phone();
184 void beamVCard(const QStringList& uids); 184 void beamVCard(const QStringList& uids);
185 void beamDone( Ir *ir ); 185 void beamDone( Ir *ir );
186 186
187 187
188 /** 188 /**
189 Starts the preferred web browser with the given URL as argument. 189 Starts the preferred web browser with the given URL as argument.
190 */ 190 */
191 void browse( const QString& url ); 191 void browse( const QString& url );
192 192
193 /** 193 /**
194 Select all contacts in the view. 194 Select all contacts in the view.
195 */ 195 */
196 void selectAllContacts(); 196 void selectAllContacts();
197 197
198 /** 198 /**
199 Deletes all selected contacts from the address book. 199 Deletes all selected contacts from the address book.
200 */ 200 */
201 void deleteContacts(); 201 void deleteContacts();
202 202
203 /** 203 /**
204 Deletes given contacts from the address book. 204 Deletes given contacts from the address book.
205 205
206 @param uids The uids of the contacts, which shall be deleted. 206 @param uids The uids of the contacts, which shall be deleted.
207 */ 207 */
208 void deleteContacts( const QStringList &uids ); 208 void deleteContacts( const QStringList &uids );
209 209
210 /** 210 /**
211 Copys the selected contacts into clipboard for later pasting. 211 Copys the selected contacts into clipboard for later pasting.
212 */ 212 */
213 void copyContacts(); 213 void copyContacts();
214 214
215 /** 215 /**
216 Cuts the selected contacts and stores them for later pasting. 216 Cuts the selected contacts and stores them for later pasting.
217 */ 217 */
218 void cutContacts(); 218 void cutContacts();
219 219
220 /** 220 /**
221 Paste contacts from clipboard into the address book. 221 Paste contacts from clipboard into the address book.
222 */ 222 */
223 void pasteContacts(); 223 void pasteContacts();
224 224
225 /** 225 /**
226 Paste given contacts into the address book. 226 Paste given contacts into the address book.
227 227
228 @param list The list of addressee, which shall be pasted. 228 @param list The list of addressee, which shall be pasted.
229 */ 229 */
230 void pasteContacts( KABC::Addressee::List &list ); 230 void pasteContacts( KABC::Addressee::List &list );
231 231
232 /** 232 /**
233 Sets the whoAmI contact, that is used by many other programs to 233 Sets the whoAmI contact, that is used by many other programs to
234 get personal information about the current user. 234 get personal information about the current user.
235 */ 235 */
236 void setWhoAmI(); 236 void setWhoAmI();
237 237
238 /** 238 /**
239 Displays the category dialog and applies the result to all 239 Displays the category dialog and applies the result to all
240 selected contacts. 240 selected contacts.
241 */ 241 */
242 void setCategories(); 242 void setCategories();
243 void manageCategories(); 243 void manageCategories();
244 void editCategories(); 244 void editCategories();
245 245
246 /** 246 /**
247 Sets the field list of the Incremental Search Widget. 247 Sets the field list of the Incremental Search Widget.
248 */ 248 */
249 void setSearchFields( const KABC::Field::List &fields ); 249 void setSearchFields( const KABC::Field::List &fields );
250 250
251 /** 251 /**
252 Search with the current search field for a contact, that matches 252 Search with the current search field for a contact, that matches
253 the given text, and selects it in the view. 253 the given text, and selects it in the view.
254 */ 254 */
255 void incrementalSearch( const QString& text ); 255 void incrementalSearch( const QString& text );
256 256
257 /** 257 /**
258 Marks the address book as modified. 258 Marks the address book as modified.
259 */ 259 */
260 void setModified(); 260 void setModified();
261 /** 261 /**
262 Marks the address book as modified without refreshing the view. 262 Marks the address book as modified without refreshing the view.
263 */ 263 */
264 void setModifiedWOrefresh(); 264 void setModifiedWOrefresh();
265 265
266 /** 266 /**
267 Marks the address book as modified concerning the argument. 267 Marks the address book as modified concerning the argument.
268 */ 268 */
269 void setModified( bool modified ); 269 void setModified( bool modified );
270 270
271 /** 271 /**
272 Returns whether the address book is modified. 272 Returns whether the address book is modified.
273 */ 273 */
274 bool modified() const; 274 bool modified() const;
275 275
276 /** 276 /**
277 Called whenever an contact is modified in the contact editor 277 Called whenever an contact is modified in the contact editor
278 dialog or the quick edit. 278 dialog or the quick edit.
279 */ 279 */
280 void contactModified( const KABC::Addressee &addr ); 280 void contactModified( const KABC::Addressee &addr );
281 void addrModified( const KABC::Addressee &addr, bool updateDetails = true );
281 282
282 /** 283 /**
283 DCOP METHODS. 284 DCOP METHODS.
284 */ 285 */
285 void addEmail( QString addr ); 286 void addEmail( QString addr );
286 void importVCard( const KURL& url, bool showPreview ); 287 void importVCard( const KURL& url, bool showPreview );
287 void importVCard( const QString& vCard, bool showPreview ); 288 void importVCard( const QString& vCard, bool showPreview );
288 void newContact(); 289 void newContact();
289 QString getNameByPhone( const QString& phone ); 290 QString getNameByPhone( const QString& phone );
290 /** 291 /**
291 END DCOP METHODS 292 END DCOP METHODS
292 */ 293 */
293 294
294 /** 295 /**
295 Saves the contents of the AddressBook back to disk. 296 Saves the contents of the AddressBook back to disk.
296 */ 297 */
297 void save(); 298 void save();
298 299
299 /** 300 /**
300 Undos the last command using the undo stack. 301 Undos the last command using the undo stack.
301 */ 302 */
302 void undo(); 303 void undo();
303 304
304 /** 305 /**
305 Redos the last command that was undone, using the redo stack. 306 Redos the last command that was undone, using the redo stack.
306 */ 307 */
307 void redo(); 308 void redo();
308 309
309 /** 310 /**
310 Shows the edit dialog for the given uid. If the uid is QString::null, 311 Shows the edit dialog for the given uid. If the uid is QString::null,
311 the method will try to find a selected addressee in the view. 312 the method will try to find a selected addressee in the view.
312 */ 313 */
313 void editContact( const QString &uid /*US = QString::null*/ ); 314 void editContact( const QString &uid /*US = QString::null*/ );
314//US added a second method without defaultparameter 315//US added a second method without defaultparameter
315 void editContact2(); 316 void editContact2();
316 317
317 /** 318 /**
318 Shows or edits the detail view for the given uid. If the uid is QString::null, 319 Shows or edits the detail view for the given uid. If the uid is QString::null,
319 the method will try to find a selected addressee in the view. 320 the method will try to find a selected addressee in the view.
320 */ 321 */
321 void executeContact( const QString &uid /*US = QString::null*/ ); 322 void executeContact( const QString &uid /*US = QString::null*/ );
322 323
323 /** 324 /**
324 Launches the configuration dialog. 325 Launches the configuration dialog.
325 */ 326 */
326 void openConfigDialog(); 327 void openConfigDialog();
327 328
328 /** 329 /**
329 Launches the ldap search dialog. 330 Launches the ldap search dialog.
330 */ 331 */
331 void openLDAPDialog(); 332 void openLDAPDialog();
332 333
333 /** 334 /**
334 Creates a KAddressBookPrinter, which will display the print 335 Creates a KAddressBookPrinter, which will display the print
335 dialog and do the printing. 336 dialog and do the printing.
336 */ 337 */
337 void print(); 338 void print();
338 339
339 /** 340 /**
340 Registers a new GUI client, so plugins can register its actions. 341 Registers a new GUI client, so plugins can register its actions.
341 */ 342 */
342 void addGUIClient( KXMLGUIClient *client ); 343 void addGUIClient( KXMLGUIClient *client );
343 344
344 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid); 345 void requestForNameEmailUidList(const QString& sourceChannel, const QString& sessionuid);
345 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid); 346 void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
346 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid); 347 void requestForBirthdayList(const QString& sourceChannel, const QString& sessionuid);
347 348
348 349
349 signals: 350 signals:
350 void contactSelected( const QString &name ); 351 void contactSelected( const QString &name );
351 void contactSelected( const QPixmap &pixmap ); 352 void contactSelected( const QPixmap &pixmap );
352 public slots: 353 public slots:
353 void recieve(QString cmsg ); 354 void recieve(QString cmsg );
354 void getFile( bool success ); 355 void getFile( bool success );
355 void syncFileRequest(); 356 void syncFileRequest();
356 void setDetailsVisible( bool visible ); 357 void setDetailsVisible( bool visible );
357 void setDetailsToState(); 358 void setDetailsToState();
358 359
359 void saveSettings(); 360 void saveSettings();
360 361
361 private slots: 362 private slots:
362 void updateToolBar(); 363 void updateToolBar();
363 void updateMainWindow(); 364 void updateMainWindow();
364 void receive( const QCString& cmsg, const QByteArray& data ); 365 void receive( const QCString& cmsg, const QByteArray& data );
365 void toggleBeamReceive( ); 366 void toggleBeamReceive( );
366 void disableBR(bool); 367 void disableBR(bool);
367 void setJumpButtonBarVisible( bool visible ); 368 void setJumpButtonBarVisible( bool visible );
368 void setCaptionBack(); 369 void setCaptionBack();
369 void importFromOL(); 370 void importFromOL();
370 void extensionModified( const KABC::Addressee::List &list ); 371 void extensionModified( const KABC::Addressee::List &list );
371 void extensionChanged( int id ); 372 void extensionChanged( int id );
372 void clipboardDataChanged(); 373 void clipboardDataChanged();
373 void updateActionMenu(); 374 void updateActionMenu();
374 void configureKeyBindings(); 375 void configureKeyBindings();
375 void removeVoice(); 376 void removeVoice();
377 void setFormattedName();
376#ifdef KAB_EMBEDDED 378#ifdef KAB_EMBEDDED
377 void configureResources(); 379 void configureResources();
378#endif //KAB_EMBEDDED 380#endif //KAB_EMBEDDED
379 381
380 void slotEditorDestroyed( const QString &uid ); 382 void slotEditorDestroyed( const QString &uid );
381 void configurationChanged(); 383 void configurationChanged();
382 void addressBookChanged(); 384 void addressBookChanged();
383 385
384 private: 386 private:
385 void resizeEvent(QResizeEvent* e ); 387 void resizeEvent(QResizeEvent* e );
386 bool mBRdisabled; 388 bool mBRdisabled;
387#ifndef DESKTOP_VERSION 389#ifndef DESKTOP_VERSION
388 QCopChannel* infrared; 390 QCopChannel* infrared;
389#endif 391#endif
390 QTimer *mMessageTimer; 392 QTimer *mMessageTimer;
391 void initGUI(); 393 void initGUI();
392 void initActions(); 394 void initActions();
393 QString getPhoneFile(); 395 QString getPhoneFile();
394 396
395 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent, 397 AddresseeEditorDialog *createAddresseeEditorDialog( QWidget *parent,
396 const char *name = 0 ); 398 const char *name = 0 );
397 399
398 KXMLGUIClient *mGUIClient; 400 KXMLGUIClient *mGUIClient;
399 401
400 KABC::AddressBook *mAddressBook; 402 KABC::AddressBook *mAddressBook;
401 403
402 ViewManager *mViewManager; 404 ViewManager *mViewManager;
403 // QSplitter *mDetailsSplitter; 405 // QSplitter *mDetailsSplitter;
404 KDGanttMinimizeSplitter *mExtensionBarSplitter; 406 KDGanttMinimizeSplitter *mExtensionBarSplitter;
405 ViewContainer *mDetails; 407 ViewContainer *mDetails;
406 KDGanttMinimizeSplitter* mMiniSplitter; 408 KDGanttMinimizeSplitter* mMiniSplitter;
407 XXPortManager *mXXPortManager; 409 XXPortManager *mXXPortManager;
408 JumpButtonBar *mJumpButtonBar; 410 JumpButtonBar *mJumpButtonBar;
409 IncSearchWidget *mIncSearchWidget; 411 IncSearchWidget *mIncSearchWidget;
410 ExtensionManager *mExtensionManager; 412 ExtensionManager *mExtensionManager;
411 413
412 KCMultiDialog *mConfigureDialog; 414 KCMultiDialog *mConfigureDialog;
413 415
414#ifndef KAB_EMBEDDED 416#ifndef KAB_EMBEDDED
415 LDAPSearchDialog *mLdapSearchDialog; 417 LDAPSearchDialog *mLdapSearchDialog;
416#endif //KAB_EMBEDDED 418#endif //KAB_EMBEDDED
417 // QDict<AddresseeEditorDialog> mEditorDict; 419 // QDict<AddresseeEditorDialog> mEditorDict;
418 AddresseeEditorDialog *mEditorDialog; 420 AddresseeEditorDialog *mEditorDialog;
419 bool mReadWrite; 421 bool mReadWrite;
420 bool mModified; 422 bool mModified;
421 bool mIsPart; 423 bool mIsPart;
422 bool mMultipleViewsAtOnce; 424 bool mMultipleViewsAtOnce;
423 425
424 426
425 //US file menu 427 //US file menu
426 KAction *mActionMail; 428 KAction *mActionMail;
427 KAction *mActionBeam; 429 KAction *mActionBeam;
428 KToggleAction *mActionBR; 430 KToggleAction *mActionBR;
429 KAction *mActionExport2phone; 431 KAction *mActionExport2phone;
430 KAction* mActionPrint; 432 KAction* mActionPrint;
431 KAction* mActionNewContact; 433 KAction* mActionNewContact;
432 KAction *mActionSave; 434 KAction *mActionSave;
433 KAction *mActionEditAddressee; 435 KAction *mActionEditAddressee;
434 KAction *mActionMailVCard; 436 KAction *mActionMailVCard;
435 KAction *mActionBeamVCard; 437 KAction *mActionBeamVCard;
436 438
437 KAction *mActionQuit; 439 KAction *mActionQuit;
438 440
439 //US edit menu 441 //US edit menu
440 KAction *mActionCopy; 442 KAction *mActionCopy;
441 KAction *mActionCut; 443 KAction *mActionCut;
442 KAction *mActionPaste; 444 KAction *mActionPaste;
443 KAction *mActionSelectAll; 445 KAction *mActionSelectAll;
444 KAction *mActionUndo; 446 KAction *mActionUndo;
445 KAction *mActionRedo; 447 KAction *mActionRedo;
446 KAction *mActionDelete; 448 KAction *mActionDelete;
447 449
448 //US settings menu 450 //US settings menu
449 KAction *mActionConfigResources; 451 KAction *mActionConfigResources;
450 KAction *mActionConfigKAddressbook; 452 KAction *mActionConfigKAddressbook;
451 KAction *mActionConfigShortcuts; 453 KAction *mActionConfigShortcuts;
452 KAction *mActionConfigureToolbars; 454 KAction *mActionConfigureToolbars;
453 KAction *mActionKeyBindings; 455 KAction *mActionKeyBindings;
454 KToggleAction *mActionJumpBar; 456 KToggleAction *mActionJumpBar;
455 KToggleAction *mActionDetails; 457 KToggleAction *mActionDetails;
456 KAction *mActionWhoAmI; 458 KAction *mActionWhoAmI;
457 KAction *mActionCategories; 459 KAction *mActionCategories;
458 KAction *mActionEditCategories; 460 KAction *mActionEditCategories;
459 KAction *mActionManageCategories; 461 KAction *mActionManageCategories;
460 KAction *mActionAboutKAddressbook; 462 KAction *mActionAboutKAddressbook;
461 KAction *mActionLicence; 463 KAction *mActionLicence;
462 KAction *mActionFaq; 464 KAction *mActionFaq;
463 KAction *mActionWN; 465 KAction *mActionWN;
464 KAction *mActionSyncHowto; 466 KAction *mActionSyncHowto;
465 KAction *mActionKdeSyncHowto; 467 KAction *mActionKdeSyncHowto;
466 KAction *mActionMultiSyncHowto; 468 KAction *mActionMultiSyncHowto;
467 469
468 KAction *mActionDeleteView; 470 KAction *mActionDeleteView;
469 471
470 QPopupMenu *viewMenu; 472 QPopupMenu *viewMenu;
471 QPopupMenu *filterMenu; 473 QPopupMenu *filterMenu;
472 QPopupMenu *settingsMenu; 474 QPopupMenu *settingsMenu;
473 QPopupMenu *changeMenu; 475 QPopupMenu *changeMenu;
474 QPopupMenu *beamMenu; 476 QPopupMenu *beamMenu;
475//US QAction *mActionSave; 477//US QAction *mActionSave;
476 QPopupMenu *ImportMenu; 478 QPopupMenu *ImportMenu;
477 QPopupMenu *ExportMenu; 479 QPopupMenu *ExportMenu;
478 //LR additional methods 480 //LR additional methods
479 KAction *mActionRemoveVoice; 481 KAction *mActionRemoveVoice;
482 KAction *mActionSetFormattedName;
480 KAction * mActionImportOL; 483 KAction * mActionImportOL;
481 484
482#ifndef KAB_EMBEDDED 485#ifndef KAB_EMBEDDED
483 KAddressBookService *mAddressBookService; 486 KAddressBookService *mAddressBookService;
484#endif //KAB_EMBEDDED 487#endif //KAB_EMBEDDED
485 488
486 class KABCorePrivate; 489 class KABCorePrivate;
487 KABCorePrivate *d; 490 KABCorePrivate *d;
488 //US bool mBlockSaveFlag; 491 //US bool mBlockSaveFlag;
489 492
490#ifdef KAB_EMBEDDED 493#ifdef KAB_EMBEDDED
491 KAddressBookMain *mMainWindow; // should be the same like mGUIClient 494 KAddressBookMain *mMainWindow; // should be the same like mGUIClient
492#endif //KAB_EMBEDDED 495#endif //KAB_EMBEDDED
493 496
494 //this are the overwritten callbackmethods from the syncinterface 497 //this are the overwritten callbackmethods from the syncinterface
495 virtual bool sync(KSyncManager* manager, QString filename, int mode); 498 virtual bool sync(KSyncManager* manager, QString filename, int mode);
496 virtual bool syncExternal(KSyncManager* manager, QString resource); 499 virtual bool syncExternal(KSyncManager* manager, QString resource);
497 virtual void removeSyncInfo( QString syncProfile); 500 virtual void removeSyncInfo( QString syncProfile);
498 bool syncPhone(); 501 bool syncPhone();
499 void message( QString m ); 502 void message( QString m );
500 503
501 // LR ******************************* 504 // LR *******************************
502 // sync stuff! 505 // sync stuff!
503 QString sentSyncFile(); 506 QString sentSyncFile();
504 QPopupMenu *syncMenu; 507 QPopupMenu *syncMenu;
505 KSyncManager* syncManager; 508 KSyncManager* syncManager;
506 int mGlobalSyncMode; 509 int mGlobalSyncMode;
507 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode); 510 bool synchronizeAddressbooks( KABC::AddressBook* local, KABC::AddressBook* remote,int mode);
508 KABC::Addressee getLastSyncAddressee(); 511 KABC::Addressee getLastSyncAddressee();
509 QDateTime mLastAddressbookSync; 512 QDateTime mLastAddressbookSync;
510 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full ); 513 int takeAddressee( KABC::Addressee* local, KABC::Addressee* remote, int mode , bool full );
511 // ********************* 514 // *********************
512 515
513}; 516};
514 517
515#endif 518#endif
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index db123da..a2095d4 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,155 +1,155 @@
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#include <qtextstream.h> 28#include <qtextstream.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qregexp.h> 30#include <qregexp.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#include <libkdepim/kpimglobalprefs.h> 32#include <libkdepim/kpimglobalprefs.h>
33 33
34#include <kconfig.h> 34#include <kconfig.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kstaticdeleter.h> 36#include <kstaticdeleter.h>
37//US#include <kdebug.h> // defines kdDebug() 37//US#include <kdebug.h> // defines kdDebug()
38 38
39#include "kabprefs.h" 39#include "kabprefs.h"
40 40
41#ifdef DESKTOP_VERSION 41#ifdef DESKTOP_VERSION
42#include <qapplication.h> 42#include <qapplication.h>
43#endif 43#endif
44 44
45KABPrefs *KABPrefs::sInstance = 0; 45KABPrefs *KABPrefs::sInstance = 0;
46static KStaticDeleter<KABPrefs> staticDeleterAB; 46static KStaticDeleter<KABPrefs> staticDeleterAB;
47 47
48KABPrefs::KABPrefs() 48KABPrefs::KABPrefs()
49 : KPimPrefs("kaddressbookrc") 49 : KPimPrefs("kaddressbookrc")
50{ 50{
51 mDetailsFont = QFont("helvetica",12); 51 mDetailsFont = QFont("helvetica",12);
52 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
54 54
55 KPrefs::setCurrentGroup( "General" ); 55 KPrefs::setCurrentGroup( "General" );
56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 56 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 57 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
58 58
59#ifdef KAB_EMBEDDED 59#ifdef KAB_EMBEDDED
60 addItemBool("AskForQuit",&mAskForQuit,true); 60 addItemBool("AskForQuit",&mAskForQuit,true);
61 addItemBool("ToolBarHor",&mToolBarHor, true ); 61 addItemBool("ToolBarHor",&mToolBarHor, true );
62 addItemBool("ToolBarUp",&mToolBarUp, false ); 62 addItemBool("ToolBarUp",&mToolBarUp, false );
63 addItemBool("SearchWithReturn",&mSearchWithReturn, true ); 63 addItemBool("SearchWithReturn",&mSearchWithReturn, false );
64 addItemFont("DetailsFont",&mDetailsFont); 64 addItemFont("DetailsFont",&mDetailsFont);
65 65
66 66
67#endif //KAB_EMBEDDED 67#endif //KAB_EMBEDDED
68 68
69 KPrefs::setCurrentGroup( "MainWindow" ); 69 KPrefs::setCurrentGroup( "MainWindow" );
70 bool m_visible = false; 70 bool m_visible = false;
71#ifdef DESKTOP_VERSION 71#ifdef DESKTOP_VERSION
72 m_visible = true; 72 m_visible = true;
73#endif 73#endif
74 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); 74 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
75 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 75 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
76 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 76 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
77 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 77 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
78 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 78 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
79 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 79 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
80 80
81 81
82 KPrefs::setCurrentGroup( "Extensions_General" ); 82 KPrefs::setCurrentGroup( "Extensions_General" );
83 QStringList defaultExtensions; 83 QStringList defaultExtensions;
84 defaultExtensions << "merge"; 84 defaultExtensions << "merge";
85 defaultExtensions << "distribution_list_editor"; 85 defaultExtensions << "distribution_list_editor";
86 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 86 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
87 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 87 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
88 88
89 KPrefs::setCurrentGroup( "Views" ); 89 KPrefs::setCurrentGroup( "Views" );
90 QString defaultView = i18n( "Default Table View" ); 90 QString defaultView = i18n( "Default Table View" );
91 addItemString( "CurrentView", &mCurrentView, defaultView ); 91 addItemString( "CurrentView", &mCurrentView, defaultView );
92 addItemStringList( "ViewNames", &mViewNames, defaultView ); 92 addItemStringList( "ViewNames", &mViewNames, defaultView );
93 93
94 KPrefs::setCurrentGroup( "Filters" ); 94 KPrefs::setCurrentGroup( "Filters" );
95 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 95 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
96 96
97} 97}
98 98
99KABPrefs::~KABPrefs() 99KABPrefs::~KABPrefs()
100{ 100{
101 //qDebug("KABPrefs::~KABPrefs() "); 101 //qDebug("KABPrefs::~KABPrefs() ");
102 if (sInstance == this) 102 if (sInstance == this)
103 sInstance = staticDeleterAB.setObject(0); 103 sInstance = staticDeleterAB.setObject(0);
104} 104}
105 105
106KABPrefs *KABPrefs::instance() 106KABPrefs *KABPrefs::instance()
107{ 107{
108 if ( !sInstance ) { 108 if ( !sInstance ) {
109#ifdef KAB_EMBEDDED 109#ifdef KAB_EMBEDDED
110 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 110 sInstance = staticDeleterAB.setObject( new KABPrefs() );
111#else //KAB_EMBEDDED 111#else //KAB_EMBEDDED
112 //US the following line has changed ???. Why 112 //US the following line has changed ???. Why
113 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 113 staticDeleterAB.setObject( sInstance, new KABPrefs() );
114#endif //KAB_EMBEDDED 114#endif //KAB_EMBEDDED
115 sInstance->readConfig(); 115 sInstance->readConfig();
116 } 116 }
117 117
118 return sInstance; 118 return sInstance;
119} 119}
120 120
121void KABPrefs::setCategoryDefaults() 121void KABPrefs::setCategoryDefaults()
122{ 122{
123 mCustomCategories.clear(); 123 mCustomCategories.clear();
124 124
125 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 125 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
126 << i18n( "Customer" ) << i18n( "Friend" ); 126 << i18n( "Customer" ) << i18n( "Friend" );
127} 127}
128 128
129 // US introduce a nonconst way to return the config object. 129 // US introduce a nonconst way to return the config object.
130KConfig* KABPrefs::getConfig() 130KConfig* KABPrefs::getConfig()
131{ 131{
132 return config(); 132 return config();
133} 133}
134void KABPrefs::usrReadConfig() 134void KABPrefs::usrReadConfig()
135{ 135{
136 KPimPrefs::usrReadConfig(); 136 KPimPrefs::usrReadConfig();
137} 137}
138 138
139 139
140/*US 140/*US
141void KABPrefs::usrSetDefaults() 141void KABPrefs::usrSetDefaults()
142{ 142{
143 KPimPrefs::usrSetDefaults(); 143 KPimPrefs::usrSetDefaults();
144} 144}
145 145
146void KABPrefs::usrReadConfig() 146void KABPrefs::usrReadConfig()
147{ 147{
148 KPimPrefs::usrReadConfig(); 148 KPimPrefs::usrReadConfig();
149} 149}
150 150
151void KABPrefs::usrWriteConfig() 151void KABPrefs::usrWriteConfig()
152{ 152{
153 KPimPrefs::usrWriteConfig(); 153 KPimPrefs::usrWriteConfig();
154} 154}
155*/ 155*/
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index eb5bdd9..168d39e 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,243 +1,238 @@
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 <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <kbuttonbox.h> 31#include <kbuttonbox.h>
32#include <kcombobox.h> 32#include <kcombobox.h>
33#include <kconfig.h> 33#include <kconfig.h>
34#include <kdialog.h> 34#include <kdialog.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <klineedit.h> 37#include <klineedit.h>
38#include <kstandarddirs.h> 38#include <kstandarddirs.h>
39 39
40#include "addresseewidget.h" 40#include "addresseewidget.h"
41 41
42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
43 const char *name ) 43 const char *name )
44 : QWidget( parent, name ) 44 : QWidget( parent, name )
45{ 45{
46 if (KGlobal::getOrientation() == KGlobal::Portrait) 46 if (KGlobal::getOrientation() == KGlobal::Portrait)
47 { 47 {
48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(),
49 KDialog::spacingHintSmall() ); 49 KDialog::spacingHintSmall() );
50 50
51 QLabel *label = new QLabel( i18n( title ), this ); 51 QLabel *label = new QLabel( i18n( title ), this );
52 layout->addWidget( label, 0, 1 ); 52 layout->addWidget( label, 0, 1 );
53 53
54 mBox = new QListBox( this ); 54 mBox = new QListBox( this );
55 mBox->setMaximumSize(70, 70); 55 mBox->setMaximumSize(70, 70);
56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
57 57
58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
61 bbox->layout(); 61 bbox->layout();
62 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 62 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
63 63
64 mEdit = new KLineEdit( this ); 64 mEdit = new KLineEdit( this );
65 layout->addWidget( mEdit, 1, 1 ); 65 layout->addWidget( mEdit, 1, 1 );
66 //mEdit->setMinimumWidth(50); 66 //mEdit->setMinimumWidth(50);
67 67
68// layout->addWidget( group ); 68// layout->addWidget( group );
69 69
70 } 70 }
71 else 71 else
72 { 72 {
73 QHBoxLayout *layout = new QHBoxLayout( this ); 73 QHBoxLayout *layout = new QHBoxLayout( this );
74 74
75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this );
76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2,
77 KDialog::spacingHint() ); 77 KDialog::spacingHint() );
78 78
79 mBox = new QListBox( group ); 79 mBox = new QListBox( group );
80 80
81 groupLayout->addWidget( mBox, 0, 0 ); 81 groupLayout->addWidget( mBox, 0, 0 );
82 82
83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
86 bbox->layout(); 86 bbox->layout();
87 groupLayout->addWidget( bbox, 0, 1 ); 87 groupLayout->addWidget( bbox, 0, 1 );
88 88
89 mEdit = new KLineEdit( group ); 89 mEdit = new KLineEdit( group );
90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
91 91
92 layout->addWidget( group ); 92 layout->addWidget( group );
93 93
94 } 94 }
95 95
96 mAddButton->setEnabled( false ); 96 mAddButton->setEnabled( false );
97 mRemoveButton->setEnabled( false ); 97 mRemoveButton->setEnabled( false );
98 98
99 99
100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ),
101 SLOT( selectionChanged( QListBoxItem* ) ) ); 101 SLOT( selectionChanged( QListBoxItem* ) ) );
102 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 102 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
103 SLOT( textChanged( const QString& ) ) ); 103 SLOT( textChanged( const QString& ) ) );
104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
105 105
106} 106}
107 107
108NamePartWidget::~NamePartWidget() 108NamePartWidget::~NamePartWidget()
109{ 109{
110} 110}
111 111
112void NamePartWidget::setNameParts( const QStringList &list ) 112void NamePartWidget::setNameParts( const QStringList &list )
113{ 113{
114 mBox->clear(); 114 mBox->clear();
115 mBox->insertStringList( list ); 115 mBox->insertStringList( list );
116} 116}
117 117
118QStringList NamePartWidget::nameParts() const 118QStringList NamePartWidget::nameParts() const
119{ 119{
120 QStringList parts; 120 QStringList parts;
121 for ( uint i = 0; i < mBox->count(); ++i ) 121 for ( uint i = 0; i < mBox->count(); ++i )
122 parts.append( mBox->text( i ) ); 122 parts.append( mBox->text( i ) );
123 123
124 return parts; 124 return parts;
125} 125}
126 126
127void NamePartWidget::add() 127void NamePartWidget::add()
128{ 128{
129 if ( !mEdit->text().isEmpty() ) { 129 if ( !mEdit->text().isEmpty() ) {
130 mBox->insertItem( mEdit->text() ); 130 mBox->insertItem( mEdit->text() );
131 emit modified(); 131 emit modified();
132 } 132 }
133 133
134 mEdit->setText( "" ); 134 mEdit->setText( "" );
135} 135}
136 136
137void NamePartWidget::remove() 137void NamePartWidget::remove()
138{ 138{
139 mBox->removeItem( mBox->currentItem() ); 139 mBox->removeItem( mBox->currentItem() );
140 if ( mBox->count() == 0 ) 140 if ( mBox->count() == 0 )
141 selectionChanged( 0 ); 141 selectionChanged( 0 );
142 142
143 emit modified(); 143 emit modified();
144} 144}
145 145
146void NamePartWidget::selectionChanged( QListBoxItem *item ) 146void NamePartWidget::selectionChanged( QListBoxItem *item )
147{ 147{
148 mRemoveButton->setEnabled( item != 0 ); 148 mRemoveButton->setEnabled( item != 0 );
149} 149}
150 150
151void NamePartWidget::textChanged( const QString& text ) 151void NamePartWidget::textChanged( const QString& text )
152{ 152{
153 mAddButton->setEnabled( !text.isEmpty() ); 153 mAddButton->setEnabled( !text.isEmpty() );
154} 154}
155 155
156 156
157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
158 : QWidget( parent, name ) 158 : QWidget( parent, name )
159{ 159{
160 QGridLayout *layout; 160 QGridLayout *layout;
161 161
162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
165 QString dfn; 165 QString dfn;
166 if (QApplication::desktop()->width() > 320 ) 166 if (QApplication::desktop()->width() > 320 )
167 dfn = i18n( "Default formatted name:" ); 167 dfn = i18n( "Default formatted name:" );
168 else 168 else
169 dfn = i18n( "Def. formatted name:" ); 169 dfn = i18n( "Def. formatted name:" );
170 170
171 QLabel *label = new QLabel( dfn, this ); 171 QLabel *label = new QLabel( dfn, this );
172 172
173 mFormattedNameCombo = new KComboBox( this ); 173 mFormattedNameCombo = new KComboBox( this );
174 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 174 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
178 178
179 if (KGlobal::getOrientation() == KGlobal::Portrait) 179 if (KGlobal::getOrientation() == KGlobal::Portrait)
180 { 180 {
181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(),
182 KDialog::spacingHintSmall() ); 182 KDialog::spacingHintSmall() );
183 183
184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
187 layout->addWidget( label, 3, 0 ); 187 layout->addWidget( label, 3, 0 );
188 layout->addWidget( mFormattedNameCombo, 3, 1 ); 188 layout->addWidget( mFormattedNameCombo, 3, 1 );
189 189
190 } 190 }
191 else 191 else
192 { 192 {
193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
194 KDialog::spacingHint() ); 194 KDialog::spacingHint() );
195 195
196 layout->addWidget( mPrefix, 0, 0 ); 196 layout->addWidget( mPrefix, 0, 0 );
197 layout->addWidget( mInclusion, 0, 1 ); 197 layout->addWidget( mInclusion, 0, 1 );
198 layout->addWidget( mSuffix, 0, 2 ); 198 layout->addWidget( mSuffix, 0, 2 );
199 layout->addWidget( label, 1, 0 ); 199 layout->addWidget( label, 1, 0 );
200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
201 } 201 }
202 202
203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
207} 207}
208 208
209AddresseeWidget::~AddresseeWidget() 209AddresseeWidget::~AddresseeWidget()
210{ 210{
211} 211}
212 212
213void AddresseeWidget::restoreSettings() 213void AddresseeWidget::restoreSettings()
214{ 214{
215 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
216 config.setGroup( "General" ); 216 config.setGroup( "General" );
217 217
218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
221 221 mFormattedNameCombo->setCurrentItem( config.readNumEntry( "FormattedNameType", 1 ) );
222 KConfig cfg( locateLocal("config","kaddressbookrc") );
223 cfg.setGroup( "General" );
224 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) );
225} 222}
226 223
227void AddresseeWidget::saveSettings() 224void AddresseeWidget::saveSettings()
228{ 225{
226 qDebug("AddresseeWidget::saveSettings() ");
229 KConfig config( locateLocal("config","kabcrc") ); 227 KConfig config( locateLocal("config","kabcrc") );
230 config.setGroup( "General" ); 228 config.setGroup( "General" );
231 229
232 config.writeEntry( "Prefixes", mPrefix->nameParts() ); 230 config.writeEntry( "Prefixes", mPrefix->nameParts() );
233 config.writeEntry( "Inclusions", mInclusion->nameParts() ); 231 config.writeEntry( "Inclusions", mInclusion->nameParts() );
234 config.writeEntry( "Suffixes", mSuffix->nameParts() ); 232 config.writeEntry( "Suffixes", mSuffix->nameParts() );
235 233 config.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
236 KConfig cfg( locateLocal("config","kaddressbookrc") );
237 cfg.setGroup( "General" );
238 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
239} 234}
240 235
241#ifndef KAB_EMBEDDED 236#ifndef KAB_EMBEDDED
242#include "addresseewidget.moc" 237#include "addresseewidget.moc"
243#endif //KAB_EMBEDDED 238#endif //KAB_EMBEDDED
diff --git a/kaddressbook/nameeditdialog.cpp b/kaddressbook/nameeditdialog.cpp
index 8213c2b..f5dba0f 100644
--- a/kaddressbook/nameeditdialog.cpp
+++ b/kaddressbook/nameeditdialog.cpp
@@ -1,293 +1,295 @@
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#include <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qcheckbox.h> 30#include <qcheckbox.h>
31#include <qstring.h> 31#include <qstring.h>
32 32
33#ifndef KAB_EMBEDDED 33#ifndef KAB_EMBEDDED
34#include <kaccelmanager.h> 34#include <kaccelmanager.h>
35#else //KAB_EMBEDDED 35#else //KAB_EMBEDDED
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37#endif //KAB_EMBEDDED 37#endif //KAB_EMBEDDED
38 38
39#include <kapplication.h> 39#include <kapplication.h>
40#include <kbuttonbox.h> 40#include <kbuttonbox.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <klineedit.h> 42#include <klineedit.h>
43#include <klistview.h> 43#include <klistview.h>
44#include <kcombobox.h> 44#include <kcombobox.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kglobal.h> 46#include <kglobal.h>
47#include <kdebug.h> 47#include <kdebug.h>
48#include <kiconloader.h> 48#include <kiconloader.h>
49#include <kmessagebox.h> 49#include <kmessagebox.h>
50 50
51#include "nameeditdialog.h" 51#include "nameeditdialog.h"
52 52
53NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type, 53NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type,
54 QWidget *parent, const char *name ) 54 QWidget *parent, const char *name )
55 : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel, 55 : KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel,
56 Ok, parent, name, true ) 56 Ok, parent, name, true )
57{ 57{
58 58
59 QWidget *page = plainPage(); 59 QWidget *page = plainPage();
60 QGridLayout *layout = new QGridLayout( page, 5, 3 ); 60 QGridLayout *layout = new QGridLayout( page, 5, 3 );
61 layout->setSpacing( spacingHint() ); 61 layout->setSpacing( spacingHint() );
62 layout->addColSpacing( 2, 100 ); 62 layout->addColSpacing( 2, 100 );
63 QLabel *label; 63 QLabel *label;
64 64
65 label = new QLabel( i18n( "Honorific prefixes:" ), page ); 65 label = new QLabel( i18n( "Honorific prefixes:" ), page );
66 layout->addWidget( label, 0, 0 ); 66 layout->addWidget( label, 0, 0 );
67 mPrefixCombo = new KComboBox( page ); 67 mPrefixCombo = new KComboBox( page );
68 mPrefixCombo->setDuplicatesEnabled( false ); 68 mPrefixCombo->setDuplicatesEnabled( false );
69 mPrefixCombo->setEditable( true ); 69 mPrefixCombo->setEditable( true );
70 label->setBuddy( mPrefixCombo ); 70 label->setBuddy( mPrefixCombo );
71 layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 ); 71 layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 );
72 72
73 label = new QLabel( i18n( "Given name:" ), page ); 73 label = new QLabel( i18n( "Given name:" ), page );
74 layout->addWidget( label, 1, 0 ); 74 layout->addWidget( label, 1, 0 );
75 mGivenNameEdit = new KLineEdit( page ); 75 mGivenNameEdit = new KLineEdit( page );
76 label->setBuddy( mGivenNameEdit ); 76 label->setBuddy( mGivenNameEdit );
77 layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 ); 77 layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 );
78 78
79 label = new QLabel( i18n( "Additional names:" ), page ); 79 label = new QLabel( i18n( "Additional names:" ), page );
80 layout->addWidget( label, 2, 0 ); 80 layout->addWidget( label, 2, 0 );
81 mAdditionalNameEdit = new KLineEdit( page ); 81 mAdditionalNameEdit = new KLineEdit( page );
82 label->setBuddy( mAdditionalNameEdit ); 82 label->setBuddy( mAdditionalNameEdit );
83 layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 ); 83 layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 );
84 84
85 label = new QLabel( i18n( "Family names:" ), page ); 85 label = new QLabel( i18n( "Family names:" ), page );
86 layout->addWidget( label, 3, 0 ); 86 layout->addWidget( label, 3, 0 );
87 mFamilyNameEdit = new KLineEdit( page ); 87 mFamilyNameEdit = new KLineEdit( page );
88 label->setBuddy( mFamilyNameEdit ); 88 label->setBuddy( mFamilyNameEdit );
89 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 ); 89 layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 );
90 90
91 label = new QLabel( i18n( "Honorific suffixes:" ), page ); 91 label = new QLabel( i18n( "Honorific suffixes:" ), page );
92 layout->addWidget( label, 4, 0 ); 92 layout->addWidget( label, 4, 0 );
93 mSuffixCombo = new KComboBox( page ); 93 mSuffixCombo = new KComboBox( page );
94 mSuffixCombo->setDuplicatesEnabled( false ); 94 mSuffixCombo->setDuplicatesEnabled( false );
95 mSuffixCombo->setEditable( true ); 95 mSuffixCombo->setEditable( true );
96 label->setBuddy( mSuffixCombo ); 96 label->setBuddy( mSuffixCombo );
97 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 ); 97 layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 );
98 98
99 mFormattedNameCombo = new KComboBox( page ); 99 mFormattedNameCombo = new KComboBox( page );
100 mFormattedNameCombo->setMaximumWidth(100); 100 mFormattedNameCombo->setMaximumWidth(100);
101 101
102 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 ); 102 layout->addMultiCellWidget( mFormattedNameCombo, 5, 5, 0, 0 );
103 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) ); 103 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) );
104 104
105 mFormattedNameEdit = new KLineEdit( page ); 105 mFormattedNameEdit = new KLineEdit( page );
106 mFormattedNameEdit->setEnabled( type == CustomName ); 106 mFormattedNameEdit->setEnabled( type == CustomName );
107 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 ); 107 layout->addMultiCellWidget( mFormattedNameEdit, 5, 5, 1, 2 );
108 108
109 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page ); 109 mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page );
110 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) ); 110 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) );
111 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) ); 111 connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) );
112 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 ); 112 layout->addMultiCellWidget( mParseBox, 6, 6, 0, 2 );
113 113
114 // Fill in the values 114 // Fill in the values
115 mFamilyNameEdit->setText( addr.familyName() ); 115 mFamilyNameEdit->setText( addr.familyName() );
116 mGivenNameEdit->setText( addr.givenName() ); 116 mGivenNameEdit->setText( addr.givenName() );
117 mAdditionalNameEdit->setText( addr.additionalName() ); 117 mAdditionalNameEdit->setText( addr.additionalName() );
118 mFormattedNameEdit->setText( addr.formattedName() ); 118 mFormattedNameEdit->setText( addr.formattedName() );
119 119
120 // Prefix and suffix combos 120 // Prefix and suffix combos
121//US KConfig config( "kabcrc" ); 121//US KConfig config( "kabcrc" );
122 KConfig config( locateLocal("config", "kabcrc") ); 122 KConfig config( locateLocal("config", "kabcrc") );
123 config.setGroup( "General" ); 123 config.setGroup( "General" );
124 124
125 QStringList sTitle; 125 QStringList sTitle;
126 sTitle += i18n( "Dr." ); 126 sTitle += i18n( "Dr." );
127 sTitle += i18n( "Miss" ); 127 sTitle += i18n( "Miss" );
128 sTitle += i18n( "Mr." ); 128 sTitle += i18n( "Mr." );
129 sTitle += i18n( "Mrs." ); 129 sTitle += i18n( "Mrs." );
130 sTitle += i18n( "Ms." ); 130 sTitle += i18n( "Ms." );
131 sTitle += i18n( "Prof." ); 131 sTitle += i18n( "Prof." );
132 sTitle += config.readListEntry( "Prefixes" ); 132 sTitle += config.readListEntry( "Prefixes" );
133 sTitle.sort(); 133 sTitle.sort();
134 134
135 QStringList sSuffix; 135 QStringList sSuffix;
136 sSuffix += i18n( "I" ); 136 sSuffix += i18n( "I" );
137 sSuffix += i18n( "II" ); 137 sSuffix += i18n( "II" );
138 sSuffix += i18n( "III" ); 138 sSuffix += i18n( "III" );
139 sSuffix += i18n( "Jr." ); 139 sSuffix += i18n( "Jr." );
140 sSuffix += i18n( "Sr." ); 140 sSuffix += i18n( "Sr." );
141 sSuffix += config.readListEntry( "Suffixes" ); 141 sSuffix += config.readListEntry( "Suffixes" );
142 sSuffix.sort(); 142 sSuffix.sort();
143 143
144 mPrefixCombo->insertStringList( sTitle ); 144 mPrefixCombo->insertStringList( sTitle );
145 mSuffixCombo->insertStringList( sSuffix ); 145 mSuffixCombo->insertStringList( sSuffix );
146 146
147#ifndef KAB_EMBEDDED 147#ifndef KAB_EMBEDDED
148 mPrefixCombo->setCurrentText( addr.prefix() ); 148 mPrefixCombo->setCurrentText( addr.prefix() );
149 mSuffixCombo->setCurrentText( addr.suffix() ); 149 mSuffixCombo->setCurrentText( addr.suffix() );
150#else //KAB_EMBEDDED 150#else //KAB_EMBEDDED
151 mPrefixCombo->setEditText( addr.prefix() ); 151 mPrefixCombo->setEditText( addr.prefix() );
152 mSuffixCombo->setEditText( addr.suffix() ); 152 mSuffixCombo->setEditText( addr.suffix() );
153#endif //KAB_EMBEDDED 153#endif //KAB_EMBEDDED
154 154
155 AddresseeConfig::instance()->setUid( addr.uid() ); 155 AddresseeConfig::instance()->setUid( addr.uid() );
156 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() ); 156 mParseBox->setChecked( AddresseeConfig::instance()->automaticNameParsing() );
157 157
158#ifndef KAB_EMBEDDED 158#ifndef KAB_EMBEDDED
159 KAcceleratorManager::manage( this ); 159 KAcceleratorManager::manage( this );
160#endif //KAB_EMBEDDED 160#endif //KAB_EMBEDDED
161 161
162 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 162 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
163 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 163 connect( mPrefixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
164 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 164 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
165 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 165 connect( mGivenNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
166 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 166 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
167 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 167 connect( mAdditionalNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
168 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 168 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
169 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 169 connect( mFamilyNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
170 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 170 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
171 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) ); 171 connect( mSuffixCombo, SIGNAL( textChanged( const QString& ) ), SLOT( updateTypeCombo() ) );
172 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) ); 172 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( modified() ) );
173 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) ); 173 connect( mFormattedNameEdit, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
174 174
175 updateTypeCombo(); 175 updateTypeCombo();
176 mFormattedNameCombo->setCurrentItem( type ); 176 mFormattedNameCombo->setCurrentItem( type );
177 177
178 178
179 mChanged = false; 179 mChanged = false;
180} 180}
181 181
182NameEditDialog::~NameEditDialog() 182NameEditDialog::~NameEditDialog()
183{ 183{
184} 184}
185 185
186QString NameEditDialog::familyName() const 186QString NameEditDialog::familyName() const
187{ 187{
188 return mFamilyNameEdit->text(); 188 return mFamilyNameEdit->text();
189} 189}
190 190
191QString NameEditDialog::givenName() const 191QString NameEditDialog::givenName() const
192{ 192{
193 return mGivenNameEdit->text(); 193 return mGivenNameEdit->text();
194} 194}
195 195
196QString NameEditDialog::prefix() const 196QString NameEditDialog::prefix() const
197{ 197{
198 return mPrefixCombo->currentText(); 198 return mPrefixCombo->currentText();
199} 199}
200 200
201QString NameEditDialog::suffix() const 201QString NameEditDialog::suffix() const
202{ 202{
203 return mSuffixCombo->currentText(); 203 return mSuffixCombo->currentText();
204} 204}
205 205
206QString NameEditDialog::additionalName() const 206QString NameEditDialog::additionalName() const
207{ 207{
208 return mAdditionalNameEdit->text(); 208 return mAdditionalNameEdit->text();
209} 209}
210 210
211QString NameEditDialog::customFormattedName() const 211QString NameEditDialog::customFormattedName() const
212{ 212{
213 return mFormattedNameEdit->text(); 213 return mFormattedNameEdit->text();
214} 214}
215 215
216int NameEditDialog::formattedNameType() const 216int NameEditDialog::formattedNameType() const
217{ 217{
218 return mFormattedNameCombo->currentItem(); 218 return mFormattedNameCombo->currentItem();
219} 219}
220 220
221bool NameEditDialog::changed() const 221bool NameEditDialog::changed() const
222{ 222{
223 return mChanged; 223 return mChanged;
224} 224}
225 225
226QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type ) 226QString NameEditDialog::formattedName( const KABC::Addressee &addr, int type )
227{ 227{
228 QString retval;
228 switch ( type ) { 229 switch ( type ) {
229 case SimpleName: 230 case SimpleName:
230 return addr.givenName() + " " + addr.familyName(); 231 retval = addr.givenName() + " " + addr.familyName();
231 break; 232 break;
232 case FullName: 233 case FullName:
233 return addr.prefix() + " " + addr.givenName() + " " + 234 retval =addr.prefix() + " " + addr.givenName() + " " +
234 addr.additionalName() + " " + addr.familyName() + " " + 235 addr.additionalName() + " " + addr.familyName() + " " +
235 addr.suffix(); 236 addr.suffix();
236 break; 237 break;
237 case ReverseName: 238 case ReverseName:
238 return addr.familyName() + ", " + addr.givenName(); 239 retval = addr.familyName() + ", " + addr.givenName();
239 break; 240 break;
240 default: 241 default:
241 return ""; 242 return "";
242 break; 243 break;
243 } 244 }
245 return retval.stripWhiteSpace ();
244} 246}
245 247
246void NameEditDialog::parseBoxChanged( bool value ) 248void NameEditDialog::parseBoxChanged( bool value )
247{ 249{
248 //AddresseeConfig::instance()->setUid( addr.uid() ); 250 //AddresseeConfig::instance()->setUid( addr.uid() );
249 AddresseeConfig::instance()->setAutomaticNameParsing( value ); 251 AddresseeConfig::instance()->setAutomaticNameParsing( value );
250} 252}
251 253
252void NameEditDialog::typeChanged( int pos ) 254void NameEditDialog::typeChanged( int pos )
253{ 255{
254 mFormattedNameEdit->setEnabled( pos == 0 ); 256 mFormattedNameEdit->setEnabled( pos == 0 );
255} 257}
256 258
257void NameEditDialog::modified() 259void NameEditDialog::modified()
258{ 260{
259 mChanged = true; 261 mChanged = true;
260} 262}
261 263
262void NameEditDialog::updateTypeCombo() 264void NameEditDialog::updateTypeCombo()
263{ 265{
264 KABC::Addressee addr; 266 KABC::Addressee addr;
265 addr.setPrefix( mPrefixCombo->currentText() ); 267 addr.setPrefix( mPrefixCombo->currentText() );
266 addr.setGivenName( mGivenNameEdit->text() ); 268 addr.setGivenName( mGivenNameEdit->text() );
267 addr.setAdditionalName( mAdditionalNameEdit->text() ); 269 addr.setAdditionalName( mAdditionalNameEdit->text() );
268 addr.setFamilyName( mFamilyNameEdit->text() ); 270 addr.setFamilyName( mFamilyNameEdit->text() );
269 addr.setSuffix( mSuffixCombo->currentText() ); 271 addr.setSuffix( mSuffixCombo->currentText() );
270 272
271 int pos = mFormattedNameCombo->currentItem(); 273 int pos = mFormattedNameCombo->currentItem();
272 274
273 mFormattedNameCombo->clear(); 275 mFormattedNameCombo->clear();
274 mFormattedNameCombo->insertItem( i18n( "Custom" ) ); 276 mFormattedNameCombo->insertItem( i18n( "Custom" ) );
275 mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) ); 277 mFormattedNameCombo->insertItem( formattedName( addr, SimpleName ) );
276 mFormattedNameCombo->insertItem( formattedName( addr, FullName ) ); 278 mFormattedNameCombo->insertItem( formattedName( addr, FullName ) );
277 mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) ); 279 mFormattedNameCombo->insertItem( formattedName( addr, ReverseName ) );
278 280
279 mFormattedNameCombo->setCurrentItem( pos ); 281 mFormattedNameCombo->setCurrentItem( pos );
280} 282}
281 283
282void NameEditDialog::slotHelp() 284void NameEditDialog::slotHelp()
283{ 285{
284#ifndef KAB_EMBEDDED 286#ifndef KAB_EMBEDDED
285 kapp->invokeHelp( "managing-contacts-automatic-nameparsing" ); 287 kapp->invokeHelp( "managing-contacts-automatic-nameparsing" );
286#else //KAB_EMBEDDED 288#else //KAB_EMBEDDED
287qDebug("NameEditDialog::slotHelp Help is not supported yet"); 289qDebug("NameEditDialog::slotHelp Help is not supported yet");
288#endif //KAB_EMBEDDED 290#endif //KAB_EMBEDDED
289} 291}
290 292
291#ifndef KAB_EMBEDDED 293#ifndef KAB_EMBEDDED
292#include "nameeditdialog.moc" 294#include "nameeditdialog.moc"
293#endif //KAB_EMBEDDED 295#endif //KAB_EMBEDDED