summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp24
-rw-r--r--kaddressbook/incsearchwidget.h1
-rw-r--r--kaddressbook/kabcore.cpp37
-rw-r--r--kaddressbook/kabprefs.cpp2
-rw-r--r--kaddressbook/kabprefs.h2
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp15
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h2
-rw-r--r--kaddressbook/viewmanager.cpp4
8 files changed, 65 insertions, 22 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index dd2121a..cd198c4 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -53,116 +53,122 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
53 mSearchText = new KLineEdit( this ); 53 mSearchText = new KLineEdit( this );
54 layout->addWidget( mSearchText ); 54 layout->addWidget( mSearchText );
55// #ifdef KAB_EMBEDDED 55// #ifdef KAB_EMBEDDED
56// if (KGlobal::getOrientation() == KGlobal::Portrait) 56// if (KGlobal::getOrientation() == KGlobal::Portrait)
57// mSearchText->setMaximumWidth(30); 57// mSearchText->setMaximumWidth(30);
58// #endif //KAB_EMBEDDED 58// #endif //KAB_EMBEDDED
59 //mSearchText->setMaximumWidth(60); 59 //mSearchText->setMaximumWidth(60);
60 60
61 61
62 mFieldCombo = new QComboBox( false, this ); 62 mFieldCombo = new QComboBox( false, this );
63 layout->addWidget( mFieldCombo ); 63 layout->addWidget( mFieldCombo );
64 mFieldCombo->setMaximumHeight( 34 ); 64 mFieldCombo->setMaximumHeight( 34 );
65 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 65 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
66 66
67// #ifndef KAB_EMBEDDED 67// #ifndef KAB_EMBEDDED
68// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 68// resize( QSize(420, 50).expandedTo( sizeHint() ) );
69// #else //KAB_EMBEDDED 69// #else //KAB_EMBEDDED
70// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 70// resize( QSize(30, 10).expandedTo( sizeHint() ) );
71// #endif //KAB_EMBEDDED 71// #endif //KAB_EMBEDDED
72 72
73 73
74 // for performance reasons, we do a search on the pda only after return is pressed 74 // for performance reasons, we do a search on the pda only after return is pressed
75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
76 SLOT( announceDoSearch2() ) ); 76 SLOT( announceDoSearch2() ) );
77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
78 SLOT( announceDoSearch2() ) ); 78 SLOT( announceDoSearch2() ) );
79 79
80 connect( mSearchText, SIGNAL( returnPressed() ), 80 connect( mSearchText, SIGNAL( returnPressed() ),
81 SLOT( announceDoSearch() ) ); 81 SLOT( announceDoSearch() ) );
82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
83 SLOT( announceFieldChanged() ) ); 83 SLOT( announceFieldChanged() ) );
84 84
85 85
86 86
87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
89 89
90 90
91 setFocusProxy( mSearchText ); 91 setFocusProxy( mSearchText );
92} 92}
93 93
94IncSearchWidget::~IncSearchWidget() 94IncSearchWidget::~IncSearchWidget()
95{ 95{
96 96
97} 97}
98void IncSearchWidget::announceDoSearch2() 98void IncSearchWidget::announceDoSearch2()
99{ 99{
100 if ( KABPrefs::instance()->mSearchWithReturn ) 100 if ( KABPrefs::instance()->mSearchWithReturn )
101 return; 101 return;
102 emit doSearch( mSearchText->text() ); 102 emit doSearch( mSearchText->text() );
103 //qDebug("emit dosreach "); 103 //qDebug("emit dosreach ");
104} 104}
105 105
106void IncSearchWidget::announceDoSearch() 106void IncSearchWidget::announceDoSearch()
107{ 107{
108 108
109 emit doSearch( mSearchText->text() ); 109 emit doSearch( mSearchText->text() );
110 // qDebug("emit dosreach "); 110 // qDebug("emit dosreach ");
111} 111}
112 112
113void IncSearchWidget::announceFieldChanged() 113void IncSearchWidget::announceFieldChanged()
114{ 114{
115 emit fieldChanged(); 115 emit fieldChanged();
116} 116}
117 117void IncSearchWidget::setSize()
118{
119 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
120 mFieldCombo->setMaximumWidth( 40 );
121 mSearchText->setMaximumWidth( 30 );
122 } else {
123 QFontMetrics fm ( mFieldCombo->font() );
124 int wid = fm.width(i18n( "All Fields" ) );
125 int max = wid;
126 mFieldCombo->setMaximumWidth( wid+60 );
127 mSearchText->setMaximumWidth( 1024 );
128 }
129}
118void IncSearchWidget::setFields( const KABC::Field::List &list ) 130void IncSearchWidget::setFields( const KABC::Field::List &list )
119{ 131{
120 132
121 mFieldCombo->clear(); 133 mFieldCombo->clear();
122 mFieldCombo->insertItem( i18n( "All Fields" ) ); 134 mFieldCombo->insertItem( i18n( "All Fields" ) );
123 QFontMetrics fm ( mFieldCombo->font() ); 135
124 int wid = fm.width(i18n( "All Fields" ) );
125 int max = wid;
126
127 KABC::Field::List::ConstIterator it; 136 KABC::Field::List::ConstIterator it;
128 for ( it = list.begin(); it != list.end(); ++it ) { 137 for ( it = list.begin(); it != list.end(); ++it ) {
129 mFieldCombo->insertItem( (*it)->label() ); 138 mFieldCombo->insertItem( (*it)->label() );
130 // wid = fm.width((*it)->label() );
131 //if ( wid > max )
132 // max = wid;
133 } 139 }
134 140
135 mFieldList = list; 141 mFieldList = list;
136 142
137 announceDoSearch(); 143 announceDoSearch();
138 announceFieldChanged(); 144 announceFieldChanged();
139 mFieldCombo->setMaximumWidth( wid+60 ); 145 setSize();
140} 146}
141 147
142KABC::Field::List IncSearchWidget::fields() const 148KABC::Field::List IncSearchWidget::fields() const
143{ 149{
144 return mFieldList; 150 return mFieldList;
145} 151}
146 152
147KABC::Field *IncSearchWidget::currentField()const 153KABC::Field *IncSearchWidget::currentField()const
148{ 154{
149 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 155 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
150 return 0; // for error or 'use all fields' 156 return 0; // for error or 'use all fields'
151 else 157 else
152 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 158 return mFieldList[ mFieldCombo->currentItem() - 1 ];
153} 159}
154 160
155void IncSearchWidget::setCurrentItem( int pos ) 161void IncSearchWidget::setCurrentItem( int pos )
156{ 162{
157 mFieldCombo->setCurrentItem( pos ); 163 mFieldCombo->setCurrentItem( pos );
158 announceFieldChanged(); 164 announceFieldChanged();
159} 165}
160 166
161int IncSearchWidget::currentItem() const 167int IncSearchWidget::currentItem() const
162{ 168{
163 169
164 return mFieldCombo->currentItem(); 170 return mFieldCombo->currentItem();
165} 171}
166#ifndef KAB_EMBEDDED 172#ifndef KAB_EMBEDDED
167#include "incsearchwidget.moc" 173#include "incsearchwidget.moc"
168#endif //KAB_EMBEDDED 174#endif //KAB_EMBEDDED
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h
index 1546a51..cae55cd 100644
--- a/kaddressbook/incsearchwidget.h
+++ b/kaddressbook/incsearchwidget.h
@@ -1,76 +1,77 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 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 INCSEARCHWIDGET_H 24#ifndef INCSEARCHWIDGET_H
25#define INCSEARCHWIDGET_H 25#define INCSEARCHWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29#include <kabc/field.h> 29#include <kabc/field.h>
30 30
31class QComboBox; 31class QComboBox;
32class KLineEdit; 32class KLineEdit;
33 33
34class IncSearchWidget : public QWidget 34class IncSearchWidget : public QWidget
35{ 35{
36 Q_OBJECT 36 Q_OBJECT
37 37
38 public: 38 public:
39 IncSearchWidget( QWidget *parent, const char *name = 0 ); 39 IncSearchWidget( QWidget *parent, const char *name = 0 );
40 ~IncSearchWidget(); 40 ~IncSearchWidget();
41 41
42 void setFields( const KABC::Field::List &list ); 42 void setFields( const KABC::Field::List &list );
43 KABC::Field::List fields() const; 43 KABC::Field::List fields() const;
44 44
45 KABC::Field *currentField() const; 45 KABC::Field *currentField() const;
46 46
47 void setCurrentItem( int pos ); 47 void setCurrentItem( int pos );
48 int currentItem() const; 48 int currentItem() const;
49 void setSize();
49 50
50 signals: 51 signals:
51 void scrollUP(); 52 void scrollUP();
52 void scrollDOWN(); 53 void scrollDOWN();
53 /** 54 /**
54 This signal is emmited whenever the text in the input 55 This signal is emmited whenever the text in the input
55 widget is changed. You can get the sorting field by 56 widget is changed. You can get the sorting field by
56 @ref currentField. 57 @ref currentField.
57 */ 58 */
58 void doSearch( const QString& text ); 59 void doSearch( const QString& text );
59 60
60 /** 61 /**
61 This signal is emmited whenever the search field changes. 62 This signal is emmited whenever the search field changes.
62 */ 63 */
63 void fieldChanged(); 64 void fieldChanged();
64 65
65 private slots: 66 private slots:
66 void announceDoSearch(); 67 void announceDoSearch();
67 void announceDoSearch2(); 68 void announceDoSearch2();
68 void announceFieldChanged(); 69 void announceFieldChanged();
69 70
70 private: 71 private:
71 QComboBox* mFieldCombo; 72 QComboBox* mFieldCombo;
72 KLineEdit* mSearchText; 73 KLineEdit* mSearchText;
73 KABC::Field::List mFieldList; 74 KABC::Field::List mFieldList;
74}; 75};
75 76
76#endif 77#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index 59aa5a5..09d8523 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -237,128 +237,129 @@ public:
237 237
238 238
239class KAex2phonePrefs : public QDialog 239class KAex2phonePrefs : public QDialog
240{ 240{
241 public: 241 public:
242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 242 KAex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
243 QDialog( parent, name, true ) 243 QDialog( parent, name, true )
244 { 244 {
245 setCaption( i18n("Export to phone options") ); 245 setCaption( i18n("Export to phone options") );
246 QVBoxLayout* lay = new QVBoxLayout( this ); 246 QVBoxLayout* lay = new QVBoxLayout( this );
247 lay->setSpacing( 3 ); 247 lay->setSpacing( 3 );
248 lay->setMargin( 3 ); 248 lay->setMargin( 3 );
249 QLabel *lab; 249 QLabel *lab;
250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 250 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
251 lab->setAlignment (AlignHCenter ); 251 lab->setAlignment (AlignHCenter );
252 QHBox* temphb; 252 QHBox* temphb;
253 temphb = new QHBox( this ); 253 temphb = new QHBox( this );
254 new QLabel( i18n("I/O device: "), temphb ); 254 new QLabel( i18n("I/O device: "), temphb );
255 mPhoneDevice = new QLineEdit( temphb); 255 mPhoneDevice = new QLineEdit( temphb);
256 lay->addWidget( temphb ); 256 lay->addWidget( temphb );
257 temphb = new QHBox( this ); 257 temphb = new QHBox( this );
258 new QLabel( i18n("Connection: "), temphb ); 258 new QLabel( i18n("Connection: "), temphb );
259 mPhoneConnection = new QLineEdit( temphb); 259 mPhoneConnection = new QLineEdit( temphb);
260 lay->addWidget( temphb ); 260 lay->addWidget( temphb );
261 temphb = new QHBox( this ); 261 temphb = new QHBox( this );
262 new QLabel( i18n("Model(opt.): "), temphb ); 262 new QLabel( i18n("Model(opt.): "), temphb );
263 mPhoneModel = new QLineEdit( temphb); 263 mPhoneModel = new QLineEdit( temphb);
264 lay->addWidget( temphb ); 264 lay->addWidget( temphb );
265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this ); 265 // mWriteToSim = new QCheckBox( i18n("Write Contacts to SIM card\n(if not, write to phone memory)"), this );
266 // lay->addWidget( mWriteToSim ); 266 // lay->addWidget( mWriteToSim );
267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) ); 267 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ncontact data on phone!"), this ) );
268 lab->setAlignment (AlignHCenter); 268 lab->setAlignment (AlignHCenter);
269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 269 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
270 lay->addWidget( ok ); 270 lay->addWidget( ok );
271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 271 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
272 lay->addWidget( cancel ); 272 lay->addWidget( cancel );
273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 273 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 274 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
275 resize( 220, 240 ); 275 resize( 220, 240 );
276 276
277 } 277 }
278 278
279public: 279public:
280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 280 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
281 QCheckBox* mWriteToSim; 281 QCheckBox* mWriteToSim;
282}; 282};
283 283
284 284
285bool pasteWithNewUid = true; 285bool pasteWithNewUid = true;
286 286
287#ifdef KAB_EMBEDDED 287#ifdef KAB_EMBEDDED
288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name ) 288KABCore::KABCore( KAddressBookMain *client, bool readWrite, QWidget *parent, const char *name )
289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 289 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/ 290 mExtensionManager( 0 ),mConfigureDialog( 0 ),/*US mLdapSearchDialog( 0 ),*/
291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client) 291 mReadWrite( readWrite ), mModified( false ), mMainWindow(client)
292#else //KAB_EMBEDDED 292#else //KAB_EMBEDDED
293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name ) 293KABCore::KABCore( KXMLGUIClient *client, bool readWrite, QWidget *parent, const char *name )
294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ), 294 : QWidget( parent, name ), KSyncInterface(), mGUIClient( client ), mViewManager( 0 ),
295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ), 295 mExtensionManager( 0 ), mConfigureDialog( 0 ), mLdapSearchDialog( 0 ),
296 mReadWrite( readWrite ), mModified( false ) 296 mReadWrite( readWrite ), mModified( false )
297#endif //KAB_EMBEDDED 297#endif //KAB_EMBEDDED
298{ 298{
299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu); 299 // syncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)this, KSyncManager::KAPI, KABPrefs::instance(), syncMenu);
300 // syncManager->setBlockSave(false); 300 // syncManager->setBlockSave(false);
301 mIncSearchWidget = 0;
301 mMiniSplitter = 0; 302 mMiniSplitter = 0;
302 mExtensionBarSplitter = 0; 303 mExtensionBarSplitter = 0;
303 mIsPart = !parent->inherits( "KAddressBookMain" ); 304 mIsPart = !parent->inherits( "KAddressBookMain" );
304 mAddressBook = KABC::StdAddressBook::self(); 305 mAddressBook = KABC::StdAddressBook::self();
305 KABC::StdAddressBook::setAutomaticSave( false ); 306 KABC::StdAddressBook::setAutomaticSave( false );
306 307
307#ifndef KAB_EMBEDDED 308#ifndef KAB_EMBEDDED
308 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler ); 309 mAddressBook->setErrorHandler( new KABC::GUIErrorHandler );
309#endif //KAB_EMBEDDED 310#endif //KAB_EMBEDDED
310 311
311 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ), 312 connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
312 SLOT( addressBookChanged() ) ); 313 SLOT( addressBookChanged() ) );
313 314
314#if 0 315#if 0
315 // LP moved to addressbook init method 316 // LP moved to addressbook init method
316 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization, 317 mAddressBook->addCustomField( i18n( "Department" ), KABC::Field::Organization,
317 "X-Department", "KADDRESSBOOK" ); 318 "X-Department", "KADDRESSBOOK" );
318 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization, 319 mAddressBook->addCustomField( i18n( "Profession" ), KABC::Field::Organization,
319 "X-Profession", "KADDRESSBOOK" ); 320 "X-Profession", "KADDRESSBOOK" );
320 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization, 321 mAddressBook->addCustomField( i18n( "Assistant's Name" ), KABC::Field::Organization,
321 "X-AssistantsName", "KADDRESSBOOK" ); 322 "X-AssistantsName", "KADDRESSBOOK" );
322 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization, 323 mAddressBook->addCustomField( i18n( "Manager's Name" ), KABC::Field::Organization,
323 "X-ManagersName", "KADDRESSBOOK" ); 324 "X-ManagersName", "KADDRESSBOOK" );
324 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal, 325 mAddressBook->addCustomField( i18n( "Spouse's Name" ), KABC::Field::Personal,
325 "X-SpousesName", "KADDRESSBOOK" ); 326 "X-SpousesName", "KADDRESSBOOK" );
326 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal, 327 mAddressBook->addCustomField( i18n( "Office" ), KABC::Field::Personal,
327 "X-Office", "KADDRESSBOOK" ); 328 "X-Office", "KADDRESSBOOK" );
328 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal, 329 mAddressBook->addCustomField( i18n( "IM Address" ), KABC::Field::Personal,
329 "X-IMAddress", "KADDRESSBOOK" ); 330 "X-IMAddress", "KADDRESSBOOK" );
330 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal, 331 mAddressBook->addCustomField( i18n( "Anniversary" ), KABC::Field::Personal,
331 "X-Anniversary", "KADDRESSBOOK" ); 332 "X-Anniversary", "KADDRESSBOOK" );
332 333
333 //US added this field to become compatible with Opie/qtopia addressbook 334 //US added this field to become compatible with Opie/qtopia addressbook
334 // values can be "female" or "male" or "". An empty field represents undefined. 335 // values can be "female" or "male" or "". An empty field represents undefined.
335 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal, 336 mAddressBook->addCustomField( i18n( "Gender" ), KABC::Field::Personal,
336 "X-Gender", "KADDRESSBOOK" ); 337 "X-Gender", "KADDRESSBOOK" );
337 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal, 338 mAddressBook->addCustomField( i18n( "Children" ), KABC::Field::Personal,
338 "X-Children", "KADDRESSBOOK" ); 339 "X-Children", "KADDRESSBOOK" );
339 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal, 340 mAddressBook->addCustomField( i18n( "FreeBusyUrl" ), KABC::Field::Personal,
340 "X-FreeBusyUrl", "KADDRESSBOOK" ); 341 "X-FreeBusyUrl", "KADDRESSBOOK" );
341#endif 342#endif
342 initGUI(); 343 initGUI();
343 344
344 mIncSearchWidget->setFocus(); 345 mIncSearchWidget->setFocus();
345 346
346 347
347 connect( mViewManager, SIGNAL( selected( const QString& ) ), 348 connect( mViewManager, SIGNAL( selected( const QString& ) ),
348 SLOT( setContactSelected( const QString& ) ) ); 349 SLOT( setContactSelected( const QString& ) ) );
349 connect( mViewManager, SIGNAL( executed( const QString& ) ), 350 connect( mViewManager, SIGNAL( executed( const QString& ) ),
350 SLOT( executeContact( const QString& ) ) ); 351 SLOT( executeContact( const QString& ) ) );
351 352
352 connect( mViewManager, SIGNAL( deleteRequest( ) ), 353 connect( mViewManager, SIGNAL( deleteRequest( ) ),
353 SLOT( deleteContacts( ) ) ); 354 SLOT( deleteContacts( ) ) );
354 connect( mViewManager, SIGNAL( modified() ), 355 connect( mViewManager, SIGNAL( modified() ),
355 SLOT( setModified() ) ); 356 SLOT( setModified() ) );
356 357
357 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) ); 358 connect( mExtensionManager, SIGNAL( modified( const KABC::Addressee::List& ) ), this, SLOT( extensionModified( const KABC::Addressee::List& ) ) );
358 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) ); 359 connect( mExtensionManager, SIGNAL( changedActiveExtension( int ) ), this, SLOT( extensionChanged( int ) ) );
359 360
360 connect( mXXPortManager, SIGNAL( modified() ), 361 connect( mXXPortManager, SIGNAL( modified() ),
361 SLOT( setModified() ) ); 362 SLOT( setModified() ) );
362 363
363 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ), 364 connect( mJumpButtonBar, SIGNAL( jumpToLetter( const QString& ) ),
364 SLOT( incrementalSearch( const QString& ) ) ); 365 SLOT( incrementalSearch( const QString& ) ) );
@@ -758,158 +759,166 @@ void KABCore::mailVCard( const QStringList& uids )
758 759
759 QDir().mkdir( dirName, true ); 760 QDir().mkdir( dirName, true );
760 761
761 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) { 762 for( QStringList::ConstIterator it = uids.begin(); it != uids.end(); ++it ) {
762 KABC::Addressee a = mAddressBook->findByUid( *it ); 763 KABC::Addressee a = mAddressBook->findByUid( *it );
763 764
764 if ( a.isEmpty() ) 765 if ( a.isEmpty() )
765 continue; 766 continue;
766 767
767 QString name = a.givenName() + "_" + a.familyName() + ".vcf"; 768 QString name = a.givenName() + "_" + a.familyName() + ".vcf";
768 769
769 QString fileName = dirName + "/" + name; 770 QString fileName = dirName + "/" + name;
770 771
771 QFile outFile(fileName); 772 QFile outFile(fileName);
772 773
773 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully 774 if ( outFile.open(IO_WriteOnly) ) { // file opened successfully
774 KABC::VCardConverter converter; 775 KABC::VCardConverter converter;
775 QString vcard; 776 QString vcard;
776 777
777 converter.addresseeToVCard( a, vcard ); 778 converter.addresseeToVCard( a, vcard );
778 779
779 QTextStream t( &outFile ); // use a text stream 780 QTextStream t( &outFile ); // use a text stream
780 t.setEncoding( QTextStream::UnicodeUTF8 ); 781 t.setEncoding( QTextStream::UnicodeUTF8 );
781 t << vcard; 782 t << vcard;
782 783
783 outFile.close(); 784 outFile.close();
784 785
785 urls.append( fileName ); 786 urls.append( fileName );
786 } 787 }
787 } 788 }
788 789
789 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") ); 790 bool result = ExternalAppHandler::instance()->mailToMultipleContacts( QString::null, urls.join(", ") );
790 791
791 792
792/*US 793/*US
793 kapp->invokeMailer( QString::null, QString::null, QString::null, 794 kapp->invokeMailer( QString::null, QString::null, QString::null,
794 QString::null, // subject 795 QString::null, // subject
795 QString::null, // body 796 QString::null, // body
796 QString::null, 797 QString::null,
797 urls ); // attachments 798 urls ); // attachments
798*/ 799*/
799 800
800} 801}
801 802
802/** 803/**
803 Beams the "WhoAmI contact. 804 Beams the "WhoAmI contact.
804*/ 805*/
805void KABCore::beamMySelf() 806void KABCore::beamMySelf()
806{ 807{
807 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI(); 808 KABC::Addressee a = KABC::StdAddressBook::self()->whoAmI();
808 if (!a.isEmpty()) 809 if (!a.isEmpty())
809 { 810 {
810 QStringList uids; 811 QStringList uids;
811 uids << a.uid(); 812 uids << a.uid();
812 813
813 beamVCard(uids); 814 beamVCard(uids);
814 } else { 815 } else {
815 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) ); 816 KMessageBox::information( this, i18n( "Your personal contact is\nnot set! Please select it\nand set it with menu:\nSettings - Set Who Am I\n" ) );
816 817
817 818
818 } 819 }
819} 820}
820void KABCore::updateMainWindow() 821void KABCore::updateMainWindow()
821{ 822{
822
823 mMainWindow->showMaximized(); 823 mMainWindow->showMaximized();
824 mMainWindow->update(); 824 mMainWindow->update();
825} 825}
826void KABCore::resizeEvent(QResizeEvent* e ) 826void KABCore::resizeEvent(QResizeEvent* e )
827{ 827{
828 if ( !mMiniSplitter ) 828 if ( !mMiniSplitter )
829 return; 829 return;
830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) "); 830 //qDebug("KABCore::resizeEvent(QResizeEvent* e ) ");
831 if ( QApplication::desktop()->width() >= 480 ) { 831 if ( QApplication::desktop()->width() >= 480 ) {
832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480 832 if (QApplication::desktop()->width() == 640 ) { // e.g. 640x480
833 if ( mMiniSplitter->orientation() == Qt::Vertical ) { 833 if ( mMiniSplitter->orientation() == Qt::Vertical ) {
834 mMiniSplitter->setOrientation( Qt::Horizontal); 834 mMiniSplitter->setOrientation( Qt::Horizontal);
835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 835 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
836 if ( QApplication::desktop()->width() <= 640 ) {
837 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
838 mViewManager->getFilterAction()->setComboWidth( 150 );
839 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
840 }
841 } 836 }
837 if ( QApplication::desktop()->width() <= 640 ) {
838 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
839 mViewManager->getFilterAction()->setComboWidth( 150 );
840 if ( mIncSearchWidget )
841 mIncSearchWidget->setSize();
842 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
843 }
844
842 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640 845 } else if (QApplication::desktop()->width() == 480 ){// e.g. 480x640
843 if ( mMiniSplitter->orientation() == Qt::Horizontal ) { 846 if ( mMiniSplitter->orientation() == Qt::Horizontal ) {
844 mMiniSplitter->setOrientation( Qt::Vertical ); 847 mMiniSplitter->setOrientation( Qt::Vertical );
845 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 848 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
846 if ( QApplication::desktop()->width() <= 640 ) { 849 }
847 //mMainWindow->setMaximumSize( QApplication::desktop()->size() ); 850 if ( QApplication::desktop()->width() <= 640 ) {
848 mMainWindow->showMinimized(); 851 //mMainWindow->setMaximumSize( QApplication::desktop()->size() );
852 mMainWindow->showMinimized();
853 if ( KABPrefs::instance()->mHideSearchOnSwitch ) {
854 if ( mIncSearchWidget ) {
855 mIncSearchWidget->setSize();
856 }
857 } else {
849 mViewManager->getFilterAction()->setComboWidth( 0 ); 858 mViewManager->getFilterAction()->setComboWidth( 0 );
850 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
851 } 859 }
860 QTimer::singleShot( 1, this , SLOT ( updateMainWindow()));
852 } 861 }
853 } 862 }
854 } 863 }
855 864
856} 865}
857void KABCore::export2phone() 866void KABCore::export2phone()
858{ 867{
859 868
860 QStringList uids; 869 QStringList uids;
861 XXPortSelectDialog dlg( this, false, this ); 870 XXPortSelectDialog dlg( this, false, this );
862 if ( dlg.exec() ) 871 if ( dlg.exec() )
863 uids = dlg.uids(); 872 uids = dlg.uids();
864 else 873 else
865 return; 874 return;
866 if ( uids.isEmpty() ) 875 if ( uids.isEmpty() )
867 return; 876 return;
868 // qDebug("count %d ", uids.count()); 877 // qDebug("count %d ", uids.count());
869 878
870 KAex2phonePrefs ex2phone; 879 KAex2phonePrefs ex2phone;
871 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 880 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
872 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 881 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
873 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 882 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
874 883
875 if ( !ex2phone.exec() ) { 884 if ( !ex2phone.exec() ) {
876 return; 885 return;
877 } 886 }
878 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 887 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
879 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 888 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
880 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 889 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
881 890
882 891
883 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 892 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
884 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 893 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
885 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 894 KPimGlobalPrefs::instance()->mEx2PhoneModel );
886 895
887 QString fileName = getPhoneFile(); 896 QString fileName = getPhoneFile();
888 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) ) 897 if ( ! mAddressBook->export2PhoneFormat( uids ,fileName ) )
889 return; 898 return;
890 899
891 message(i18n("Exporting to phone...")); 900 message(i18n("Exporting to phone..."));
892 QTimer::singleShot( 1, this , SLOT ( writeToPhone())); 901 QTimer::singleShot( 1, this , SLOT ( writeToPhone()));
893 902
894} 903}
895QString KABCore::getPhoneFile() 904QString KABCore::getPhoneFile()
896{ 905{
897#ifdef DESKTOP_VERSION 906#ifdef DESKTOP_VERSION
898 return locateLocal("tmp", "phonefile.vcf"); 907 return locateLocal("tmp", "phonefile.vcf");
899#else 908#else
900 return "/tmp/phonefile.vcf"; 909 return "/tmp/phonefile.vcf";
901#endif 910#endif
902 911
903} 912}
904void KABCore::writeToPhone( ) 913void KABCore::writeToPhone( )
905{ 914{
906 if ( PhoneAccess::writeToPhone( getPhoneFile() ) ) 915 if ( PhoneAccess::writeToPhone( getPhoneFile() ) )
907 message(i18n("Export to phone finished!")); 916 message(i18n("Export to phone finished!"));
908 else 917 else
909 qDebug(i18n("KA: Error exporting to phone")); 918 qDebug(i18n("KA: Error exporting to phone"));
910} 919}
911void KABCore::beamVCard() 920void KABCore::beamVCard()
912{ 921{
913 QStringList uids; 922 QStringList uids;
914 XXPortSelectDialog dlg( this, false, this ); 923 XXPortSelectDialog dlg( this, false, this );
915 if ( dlg.exec() ) 924 if ( dlg.exec() )
@@ -1092,129 +1101,135 @@ void KABCore::setWhoAmI()
1092void KABCore::editCategories() 1101void KABCore::editCategories()
1093{ 1102{
1094 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true ); 1103 KPIM::CategoryEditDialog dlg ( KABPrefs::instance(), this, "", true );
1095 dlg.exec(); 1104 dlg.exec();
1096} 1105}
1097void KABCore::setCategories() 1106void KABCore::setCategories()
1098{ 1107{
1099 1108
1100 QStringList uids; 1109 QStringList uids;
1101 XXPortSelectDialog dlgx( this, false, this ); 1110 XXPortSelectDialog dlgx( this, false, this );
1102 if ( dlgx.exec() ) 1111 if ( dlgx.exec() )
1103 uids = dlgx.uids(); 1112 uids = dlgx.uids();
1104 else 1113 else
1105 return; 1114 return;
1106 if ( uids.isEmpty() ) 1115 if ( uids.isEmpty() )
1107 return; 1116 return;
1108 // qDebug("count %d ", uids.count()); 1117 // qDebug("count %d ", uids.count());
1109 1118
1110 1119
1111 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true ); 1120 KPIM::CategorySelectDialog dlg( KABPrefs::instance(), this, "", true );
1112 if ( !dlg.exec() ) { 1121 if ( !dlg.exec() ) {
1113 message( i18n("Setting categories cancelled") ); 1122 message( i18n("Setting categories cancelled") );
1114 return; 1123 return;
1115 } 1124 }
1116 bool merge = false; 1125 bool merge = false;
1117 QString msg = i18n( "Merge with existing categories?" ); 1126 QString msg = i18n( "Merge with existing categories?" );
1118 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes ) 1127 if ( KMessageBox::questionYesNo( this, msg ) == KMessageBox::Yes )
1119 merge = true; 1128 merge = true;
1120 1129
1121 message( i18n("Setting categories ... please wait!") ); 1130 message( i18n("Setting categories ... please wait!") );
1122 QStringList categories = dlg.selectedCategories(); 1131 QStringList categories = dlg.selectedCategories();
1123 1132
1124 //QStringList uids = mViewManager->selectedUids(); 1133 //QStringList uids = mViewManager->selectedUids();
1125 QStringList::Iterator it; 1134 QStringList::Iterator it;
1126 for ( it = uids.begin(); it != uids.end(); ++it ) { 1135 for ( it = uids.begin(); it != uids.end(); ++it ) {
1127 KABC::Addressee addr = mAddressBook->findByUid( *it ); 1136 KABC::Addressee addr = mAddressBook->findByUid( *it );
1128 if ( !addr.isEmpty() ) { 1137 if ( !addr.isEmpty() ) {
1129 if ( !merge ) 1138 if ( !merge )
1130 addr.setCategories( categories ); 1139 addr.setCategories( categories );
1131 else { 1140 else {
1132 QStringList addrCategories = addr.categories(); 1141 QStringList addrCategories = addr.categories();
1133 QStringList::Iterator catIt; 1142 QStringList::Iterator catIt;
1134 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) { 1143 for ( catIt = categories.begin(); catIt != categories.end(); ++catIt ) {
1135 if ( !addrCategories.contains( *catIt ) ) 1144 if ( !addrCategories.contains( *catIt ) )
1136 addrCategories.append( *catIt ); 1145 addrCategories.append( *catIt );
1137 } 1146 }
1138 addr.setCategories( addrCategories ); 1147 addr.setCategories( addrCategories );
1139 } 1148 }
1140 mAddressBook->insertAddressee( addr ); 1149 mAddressBook->insertAddressee( addr );
1141 } 1150 }
1142 } 1151 }
1143 1152
1144 if ( uids.count() > 0 ) 1153 if ( uids.count() > 0 )
1145 setModified( true ); 1154 setModified( true );
1146 message( i18n("Setting categories completed!") ); 1155 message( i18n("Setting categories completed!") );
1147} 1156}
1148 1157
1149void KABCore::setSearchFields( const KABC::Field::List &fields ) 1158void KABCore::setSearchFields( const KABC::Field::List &fields )
1150{ 1159{
1151 mIncSearchWidget->setFields( fields ); 1160 mIncSearchWidget->setFields( fields );
1152} 1161}
1153 1162
1154void KABCore::incrementalSearch( const QString& text ) 1163void KABCore::incrementalSearch( const QString& text )
1155{ 1164{
1156 mViewManager->doSearch( text, mIncSearchWidget->currentField() ); 1165 QString stext;
1166 if ( KABPrefs::instance()->mAutoSearchWithWildcard ) {
1167 stext = "*" + text;
1168 } else {
1169 stext = text;
1170 }
1171 mViewManager->doSearch( stext, mIncSearchWidget->currentField() );
1157} 1172}
1158 1173
1159void KABCore::setModified() 1174void KABCore::setModified()
1160{ 1175{
1161 setModified( true ); 1176 setModified( true );
1162} 1177}
1163 1178
1164void KABCore::setModifiedWOrefresh() 1179void KABCore::setModifiedWOrefresh()
1165{ 1180{
1166 // qDebug("KABCore::setModifiedWOrefresh() "); 1181 // qDebug("KABCore::setModifiedWOrefresh() ");
1167 mModified = true; 1182 mModified = true;
1168 mActionSave->setEnabled( mModified ); 1183 mActionSave->setEnabled( mModified );
1169 1184
1170 1185
1171} 1186}
1172void KABCore::setModified( bool modified ) 1187void KABCore::setModified( bool modified )
1173{ 1188{
1174 mModified = modified; 1189 mModified = modified;
1175 mActionSave->setEnabled( mModified ); 1190 mActionSave->setEnabled( mModified );
1176 1191
1177 if ( modified ) 1192 if ( modified )
1178 mJumpButtonBar->recreateButtons(); 1193 mJumpButtonBar->recreateButtons();
1179 1194
1180 mViewManager->refreshView(); 1195 mViewManager->refreshView();
1181 1196
1182} 1197}
1183 1198
1184bool KABCore::modified() const 1199bool KABCore::modified() const
1185{ 1200{
1186 return mModified; 1201 return mModified;
1187} 1202}
1188 1203
1189void KABCore::contactModified( const KABC::Addressee &addr ) 1204void KABCore::contactModified( const KABC::Addressee &addr )
1190{ 1205{
1191 addrModified( addr ); 1206 addrModified( addr );
1192#if 0 // debug only 1207#if 0 // debug only
1193 KABC::Addressee ad = addr; 1208 KABC::Addressee ad = addr;
1194 ad.computeCsum( "123"); 1209 ad.computeCsum( "123");
1195#endif 1210#endif
1196} 1211}
1197 1212
1198void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails ) 1213void KABCore::addrModified( const KABC::Addressee &addr ,bool updateDetails )
1199{ 1214{
1200 1215
1201 Command *command = 0; 1216 Command *command = 0;
1202 QString uid; 1217 QString uid;
1203 1218
1204 // check if it exists already 1219 // check if it exists already
1205 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() ); 1220 KABC::Addressee origAddr = mAddressBook->findByUid( addr.uid() );
1206 if ( origAddr.isEmpty() ) 1221 if ( origAddr.isEmpty() )
1207 command = new PwNewCommand( mAddressBook, addr ); 1222 command = new PwNewCommand( mAddressBook, addr );
1208 else { 1223 else {
1209 command = new PwEditCommand( mAddressBook, origAddr, addr ); 1224 command = new PwEditCommand( mAddressBook, origAddr, addr );
1210 uid = addr.uid(); 1225 uid = addr.uid();
1211 } 1226 }
1212 1227
1213 UndoStack::instance()->push( command ); 1228 UndoStack::instance()->push( command );
1214 RedoStack::instance()->clear(); 1229 RedoStack::instance()->clear();
1215 if ( updateDetails ) 1230 if ( updateDetails )
1216 mDetails->setAddressee( addr ); 1231 mDetails->setAddressee( addr );
1217 setModified( true ); 1232 setModified( true );
1218} 1233}
1219 1234
1220void KABCore::newContact() 1235void KABCore::newContact()
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index b96d28a..ea254b7 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,126 +1,128 @@
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#include <kglobalsettings.h> 37#include <kglobalsettings.h>
38//US#include <kdebug.h> // defines kdDebug() 38//US#include <kdebug.h> // defines kdDebug()
39 39
40#include "kabprefs.h" 40#include "kabprefs.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43#include <qapplication.h> 43#include <qapplication.h>
44#endif 44#endif
45 45
46KABPrefs *KABPrefs::sInstance = 0; 46KABPrefs *KABPrefs::sInstance = 0;
47static KStaticDeleter<KABPrefs> staticDeleterAB; 47static KStaticDeleter<KABPrefs> staticDeleterAB;
48 48
49KABPrefs::KABPrefs() 49KABPrefs::KABPrefs()
50 : KPimPrefs("kaddressbookrc") 50 : KPimPrefs("kaddressbookrc")
51{ 51{
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#ifdef KAB_EMBEDDED 58#ifdef KAB_EMBEDDED
59 addItemBool("AskForQuit",&mAskForQuit,true); 59 addItemBool("AskForQuit",&mAskForQuit,true);
60 addItemBool("ToolBarHor",&mToolBarHor, true ); 60 addItemBool("ToolBarHor",&mToolBarHor, true );
61 addItemBool("ToolBarUp",&mToolBarUp, false ); 61 addItemBool("ToolBarUp",&mToolBarUp, false );
62 addItemBool("SearchWithReturn",&mSearchWithReturn, false ); 62 addItemBool("SearchWithReturn",&mSearchWithReturn, false );
63 addItemBool("AutoSearchWithWildcard",&mAutoSearchWithWildcard, false );
64 addItemBool("HideSearchOnSwitch",&mHideSearchOnSwitch, false );
63 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont()); 65 addItemFont("DetailsFont",&mDetailsFont,KGlobalSettings::generalFont());
64 66
65 67
66#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
67 69
68 KPrefs::setCurrentGroup( "MainWindow" ); 70 KPrefs::setCurrentGroup( "MainWindow" );
69 bool m_visible = false; 71 bool m_visible = false;
70#ifdef DESKTOP_VERSION 72#ifdef DESKTOP_VERSION
71 m_visible = true; 73 m_visible = true;
72#endif 74#endif
73 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible ); 75 addItemBool( "FullMenuBarVisible", &mFullMenuBarVisible, m_visible );
74 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 76 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
75 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 77 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
76 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 78 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
77 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 79 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
78 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 80 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
79 81
80 82
81 KPrefs::setCurrentGroup( "Extensions_General" ); 83 KPrefs::setCurrentGroup( "Extensions_General" );
82 QStringList defaultExtensions; 84 QStringList defaultExtensions;
83 defaultExtensions << "merge"; 85 defaultExtensions << "merge";
84 defaultExtensions << "distribution_list_editor"; 86 defaultExtensions << "distribution_list_editor";
85 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 87 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
86 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 88 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
87 89
88 KPrefs::setCurrentGroup( "Views" ); 90 KPrefs::setCurrentGroup( "Views" );
89 QString defaultView = i18n( "Default Table View" ); 91 QString defaultView = i18n( "Default Table View" );
90 addItemString( "CurrentView", &mCurrentView, defaultView ); 92 addItemString( "CurrentView", &mCurrentView, defaultView );
91 addItemStringList( "ViewNames", &mViewNames, defaultView ); 93 addItemStringList( "ViewNames", &mViewNames, defaultView );
92 94
93 KPrefs::setCurrentGroup( "Filters" ); 95 KPrefs::setCurrentGroup( "Filters" );
94 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 96 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
95 97
96} 98}
97 99
98KABPrefs::~KABPrefs() 100KABPrefs::~KABPrefs()
99{ 101{
100 //qDebug("KABPrefs::~KABPrefs() "); 102 //qDebug("KABPrefs::~KABPrefs() ");
101 if (sInstance == this) 103 if (sInstance == this)
102 sInstance = staticDeleterAB.setObject(0); 104 sInstance = staticDeleterAB.setObject(0);
103} 105}
104 106
105KABPrefs *KABPrefs::instance() 107KABPrefs *KABPrefs::instance()
106{ 108{
107 if ( !sInstance ) { 109 if ( !sInstance ) {
108#ifdef KAB_EMBEDDED 110#ifdef KAB_EMBEDDED
109 sInstance = staticDeleterAB.setObject( new KABPrefs() ); 111 sInstance = staticDeleterAB.setObject( new KABPrefs() );
110#else //KAB_EMBEDDED 112#else //KAB_EMBEDDED
111 //US the following line has changed ???. Why 113 //US the following line has changed ???. Why
112 staticDeleterAB.setObject( sInstance, new KABPrefs() ); 114 staticDeleterAB.setObject( sInstance, new KABPrefs() );
113#endif //KAB_EMBEDDED 115#endif //KAB_EMBEDDED
114 sInstance->readConfig(); 116 sInstance->readConfig();
115 } 117 }
116 118
117 return sInstance; 119 return sInstance;
118} 120}
119 121
120void KABPrefs::setCategoryDefaults() 122void KABPrefs::setCategoryDefaults()
121{ 123{
122 mCustomCategories.clear(); 124 mCustomCategories.clear();
123 125
124 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 126 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
125 << i18n( "Customer" ) << i18n( "Friend" ); 127 << i18n( "Customer" ) << i18n( "Friend" );
126} 128}
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 1e3b48f..2bb173d 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -9,88 +9,90 @@
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qdict.h> 28#include <qdict.h>
29 29
30#include <libkdepim/kpimprefs.h> 30#include <libkdepim/kpimprefs.h>
31 31
32class KConfig; 32class KConfig;
33 33
34class KABPrefs : public KPimPrefs 34class KABPrefs : public KPimPrefs
35{ 35{
36 public: 36 public:
37 virtual ~KABPrefs(); 37 virtual ~KABPrefs();
38 38
39 static KABPrefs *instance(); 39 static KABPrefs *instance();
40 40
41 // General 41 // General
42 bool mHonorSingleClick; 42 bool mHonorSingleClick;
43 bool mAutomaticNameParsing; 43 bool mAutomaticNameParsing;
44 int mCurrentIncSearchField; 44 int mCurrentIncSearchField;
45 45
46#ifdef KAB_EMBEDDED 46#ifdef KAB_EMBEDDED
47 // US introduce a nonconst way to return the config object. 47 // US introduce a nonconst way to return the config object.
48 KConfig* getConfig(); 48 KConfig* getConfig();
49 49
50 bool mToolBarHor; 50 bool mToolBarHor;
51 bool mToolBarUp; 51 bool mToolBarUp;
52 bool mAskForQuit; 52 bool mAskForQuit;
53 53
54 54
55 /** Set preferences to default values */ 55 /** Set preferences to default values */
56// void usrSetDefaults(); 56// void usrSetDefaults();
57 57
58 /** Read preferences from config file */ 58 /** Read preferences from config file */
59// void usrReadConfig(); 59// void usrReadConfig();
60 60
61 /** Write preferences to config file */ 61 /** Write preferences to config file */
62// void usrWriteConfig(); 62// void usrWriteConfig();
63#endif //KAB_EMBEDDED 63#endif //KAB_EMBEDDED
64 void usrReadConfig(); 64 void usrReadConfig();
65 65
66 66
67 // GUI 67 // GUI
68 bool mFullMenuBarVisible; 68 bool mFullMenuBarVisible;
69 bool mJumpButtonBarVisible; 69 bool mJumpButtonBarVisible;
70 bool mDetailsPageVisible; 70 bool mDetailsPageVisible;
71 bool mMultipleViewsAtOnce; 71 bool mMultipleViewsAtOnce;
72 bool mSearchWithReturn; 72 bool mSearchWithReturn;
73 bool mAutoSearchWithWildcard;
74 bool mHideSearchOnSwitch;
73 QValueList<int> mExtensionsSplitter; 75 QValueList<int> mExtensionsSplitter;
74 QValueList<int> mDetailsSplitter; 76 QValueList<int> mDetailsSplitter;
75 77
76 // Extensions stuff 78 // Extensions stuff
77 int mCurrentExtension; 79 int mCurrentExtension;
78 QStringList mActiveExtensions; 80 QStringList mActiveExtensions;
79 81
80 // Views stuff 82 // Views stuff
81 QString mCurrentView; 83 QString mCurrentView;
82 QStringList mViewNames; 84 QStringList mViewNames;
83 85
84 // Filter 86 // Filter
85 int mCurrentFilter; 87 int mCurrentFilter;
86 88
87 void setCategoryDefaults(); 89 void setCategoryDefaults();
88 QFont mDetailsFont; 90 QFont mDetailsFont;
89 91
90 private: 92 private:
91 KABPrefs(); 93 KABPrefs();
92 94
93 static KABPrefs *sInstance; 95 static KABPrefs *sInstance;
94}; 96};
95 97
96#endif 98#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 3ad2f74..986c9b8 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -62,222 +62,237 @@ class ExtensionItem : public QCheckListItem
62 62
63#ifndef KAB_EMBEDDED 63#ifndef KAB_EMBEDDED
64 ExtensionItem( QListView *parent, const QString &text ); 64 ExtensionItem( QListView *parent, const QString &text );
65 void setService( const KService::Ptr &ptr ); 65 void setService( const KService::Ptr &ptr );
66#else //KAB_EMBEDDED 66#else //KAB_EMBEDDED
67 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 67 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
68 void setFactory( ExtensionFactory* fac ); 68 void setFactory( ExtensionFactory* fac );
69#endif //KAB_EMBEDDED 69#endif //KAB_EMBEDDED
70 70
71 bool configWidgetAvailable() const; 71 bool configWidgetAvailable() const;
72 ExtensionFactory *factory() const; 72 ExtensionFactory *factory() const;
73 73
74 virtual QString text( int column ) const; 74 virtual QString text( int column ) const;
75 75
76 private: 76 private:
77#ifndef KAB_EMBEDDED 77#ifndef KAB_EMBEDDED
78 KService::Ptr mPtr; 78 KService::Ptr mPtr;
79#else //KAB_EMBEDDED 79#else //KAB_EMBEDDED
80 ExtensionFactory* mFactory; 80 ExtensionFactory* mFactory;
81 QString mName; 81 QString mName;
82 QString mComment; 82 QString mComment;
83 83
84#endif //KAB_EMBEDDED 84#endif //KAB_EMBEDDED
85 85
86}; 86};
87 87
88KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) 88KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name )
89 : KPrefsWidget( prefs, parent, name ) 89 : KPrefsWidget( prefs, parent, name )
90{ 90{
91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 91 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
92 KDialog::spacingHint() ); 92 KDialog::spacingHint() );
93 93
94 QTabWidget *tabWidget = new QTabWidget( this ); 94 QTabWidget *tabWidget = new QTabWidget( this );
95 topLayout->addWidget( tabWidget ); 95 topLayout->addWidget( tabWidget );
96 96
97 // General page 97 // General page
98 QWidget *generalPage = new QWidget( this ); 98 QWidget *generalPage = new QWidget( this );
99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 99 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
100 KDialog::spacingHintSmall() ); 100 KDialog::spacingHintSmall() );
101 101
102 102
103 QWidget *hBox = new QWidget( generalPage, "qhbox" ); 103 QWidget *hBox = new QWidget( generalPage, "qhbox" );
104 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox); 104 QHBoxLayout *hboxLayout = new QHBoxLayout( hBox);
105 KPrefsWidFont *detailsFont = 105 KPrefsWidFont *detailsFont =
106 addWidFont(i18n("phone:123"),i18n("Details view font"), 106 addWidFont(i18n("phone:123"),i18n("Details view font"),
107 &(KABPrefs::instance()->mDetailsFont),hBox); 107 &(KABPrefs::instance()->mDetailsFont),hBox);
108 hboxLayout->addWidget(detailsFont->label()); 108 hboxLayout->addWidget(detailsFont->label());
109 hboxLayout->addWidget(detailsFont->preview()); 109 hboxLayout->addWidget(detailsFont->preview());
110 hboxLayout->addWidget(detailsFont->button()); 110 hboxLayout->addWidget(detailsFont->button());
111 hboxLayout->setMargin(KDialog::marginHintSmall() ); 111 hboxLayout->setMargin(KDialog::marginHintSmall() );
112 hboxLayout->setSpacing(KDialog::spacingHintSmall()); 112 hboxLayout->setSpacing(KDialog::spacingHintSmall());
113 //hBox->setBackgroundColor( black); 113 //hBox->setBackgroundColor( black);
114 layout->addWidget( hBox ); 114 layout->addWidget( hBox );
115 115
116 //general groupbox 116 //general groupbox
117 QWidget *vBox = new QWidget( generalPage, "qvbox" ); 117 QWidget *vBox = new QWidget( generalPage, "qvbox" );
118 QVBoxLayout *boxLayout = new QVBoxLayout( vBox ); 118 QVBoxLayout *boxLayout = new QVBoxLayout( vBox );
119 boxLayout->setAlignment( Qt::AlignTop ); 119 boxLayout->setAlignment( Qt::AlignTop );
120 boxLayout->setMargin(KDialog::marginHintSmall() ); 120 boxLayout->setMargin(KDialog::marginHintSmall() );
121 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 121 boxLayout->setSpacing( KDialog::spacingHintSmall() );
122 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" ); 122 mMenuBarBox = new QCheckBox( i18n( "Full Menu bar (restart)" ), vBox, "mremenuturn" );
123 boxLayout->addWidget( mMenuBarBox ); 123 boxLayout->addWidget( mMenuBarBox );
124 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" ); 124 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
125 boxLayout->addWidget( mSearchReturnBox ); 125 boxLayout->addWidget( mSearchReturnBox );
126 mAutoSearchWithWildcardBox = new QCheckBox( i18n( "Search with '*' prefix (wildcard)" ), vBox, "mwildcard" );
127 boxLayout->addWidget( mAutoSearchWithWildcardBox);
128 mHideSearchOnSwitchBox = new QCheckBox( i18n( "Shrink searchfield in portrait view" ), vBox, "mswitch" );
129 boxLayout->addWidget( mHideSearchOnSwitchBox );
130
131#ifdef DESKTOP_VERSION
132 mHideSearchOnSwitchBox->hide();
133#endif
126 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); 134 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" );
127 boxLayout->addWidget( mViewsSingleClickBox ); 135 boxLayout->addWidget( mViewsSingleClickBox );
128 136
129 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); 137 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" );
130 boxLayout->addWidget( mNameParsing ); 138 boxLayout->addWidget( mNameParsing );
131 139
132 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); 140 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
133 boxLayout->addWidget( mMultipleViewsAtOnce ); 141 boxLayout->addWidget( mMultipleViewsAtOnce );
134 142
135 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); 143 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" );
136 boxLayout->addWidget( mAskForQuit ); 144 boxLayout->addWidget( mAskForQuit );
137 145
138 layout->addWidget( vBox ); 146 layout->addWidget( vBox );
139 147
140 tabWidget->addTab( generalPage, i18n( "General" ) ); 148 tabWidget->addTab( generalPage, i18n( "General" ) );
141 149
142 // Extension page 150 // Extension page
143 QWidget *extensionPage = new QWidget( this ); 151 QWidget *extensionPage = new QWidget( this );
144 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), 152 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(),
145 KDialog::spacingHintSmall() ); 153 KDialog::spacingHintSmall() );
146 154
147 //extensions groupbox 155 //extensions groupbox
148 156
149 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); 157 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
150 boxLayout = new QVBoxLayout( groupBox->layout() ); 158 boxLayout = new QVBoxLayout( groupBox->layout() );
151 boxLayout->setAlignment( Qt::AlignTop ); 159 boxLayout->setAlignment( Qt::AlignTop );
152 boxLayout->setMargin(KDialog::marginHintSmall()); 160 boxLayout->setMargin(KDialog::marginHintSmall());
153 boxLayout->setSpacing(KDialog::spacingHintSmall()); 161 boxLayout->setSpacing(KDialog::spacingHintSmall());
154 groupBox->layout()->setMargin(1) ; 162 groupBox->layout()->setMargin(1) ;
155 groupBox->layout()->setSpacing(0); 163 groupBox->layout()->setSpacing(0);
156 mExtensionView = new KListView( groupBox ); 164 mExtensionView = new KListView( groupBox );
157 mExtensionView->setAllColumnsShowFocus( true ); 165 mExtensionView->setAllColumnsShowFocus( true );
158 mExtensionView->addColumn( i18n( "Name" ) ); 166 mExtensionView->addColumn( i18n( "Name" ) );
159 mExtensionView->addColumn( i18n( "Description" ) ); 167 mExtensionView->addColumn( i18n( "Description" ) );
160 //mExtensionView->setMaximumHeight(80); 168 //mExtensionView->setMaximumHeight(80);
161 169
162 boxLayout->addWidget( mExtensionView ); 170 boxLayout->addWidget( mExtensionView );
163 171
164 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 172 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
165 mConfigureButton->setEnabled( false ); 173 mConfigureButton->setEnabled( false );
166 boxLayout->addWidget( mConfigureButton ); 174 boxLayout->addWidget( mConfigureButton );
167 175
168 extensionLayout->addWidget( groupBox ); 176 extensionLayout->addWidget( groupBox );
169 177
170 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 178 connect( mMenuBarBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
171 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 179 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
172 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 180 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
173 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 181 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
182 connect( mAutoSearchWithWildcardBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
183 connect( mHideSearchOnSwitchBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
174 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 184 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
175 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 185 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
176 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 186 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
177 SLOT( selectionChanged( QListViewItem* ) ) ); 187 SLOT( selectionChanged( QListViewItem* ) ) );
178 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 188 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
179 SLOT( itemClicked( QListViewItem* ) ) ); 189 SLOT( itemClicked( QListViewItem* ) ) );
180 connect( mConfigureButton, SIGNAL( clicked() ), 190 connect( mConfigureButton, SIGNAL( clicked() ),
181 SLOT( configureExtension() ) ); 191 SLOT( configureExtension() ) );
182 192
183 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 193 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
184 194
185 // Addressee page 195 // Addressee page
186 mAddresseeWidget = new AddresseeWidget( this ); 196 mAddresseeWidget = new AddresseeWidget( this );
187 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 197 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
188 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 198 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
189 199
190} 200}
191 201
192void KABConfigWidget::usrReadConfig() 202void KABConfigWidget::usrReadConfig()
193{ 203{
194 KABPrefs* prefs = KABPrefs::instance(); 204 KABPrefs* prefs = KABPrefs::instance();
195 205
196 bool blocked = signalsBlocked(); 206 bool blocked = signalsBlocked();
197 blockSignals( true ); 207 blockSignals( true );
198 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible); 208 mMenuBarBox->setChecked( prefs->mFullMenuBarVisible);
199 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 209 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
200 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 210 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
201 mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); 211 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
212 mAutoSearchWithWildcardBox->setChecked( prefs->mAutoSearchWithWildcard );
213 mHideSearchOnSwitchBox->setChecked( prefs->mHideSearchOnSwitch );
202 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 214 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
203 mAskForQuit->setChecked( prefs->mAskForQuit ); 215 mAskForQuit->setChecked( prefs->mAskForQuit );
204 216
205 mAddresseeWidget->restoreSettings(); 217 mAddresseeWidget->restoreSettings();
206 218
207 restoreExtensionSettings(); 219 restoreExtensionSettings();
208 220
209 blockSignals( blocked ); 221 blockSignals( blocked );
210 222
211} 223}
212 224
213void KABConfigWidget::usrWriteConfig() 225void KABConfigWidget::usrWriteConfig()
214{ 226{
215 KABPrefs* prefs = KABPrefs::instance(); 227 KABPrefs* prefs = KABPrefs::instance();
216 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked(); 228 prefs->mFullMenuBarVisible = mMenuBarBox->isChecked();
217 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 229 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
218 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 230 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
219 prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); 231 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
232 prefs->mAutoSearchWithWildcard = mAutoSearchWithWildcardBox->isChecked();
233 prefs->mHideSearchOnSwitch = mHideSearchOnSwitchBox->isChecked();
234
220 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 235 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
221 prefs->mAskForQuit = mAskForQuit->isChecked(); 236 prefs->mAskForQuit = mAskForQuit->isChecked();
222 237
223 mAddresseeWidget->saveSettings(); 238 mAddresseeWidget->saveSettings();
224 239
225 saveExtensionSettings(); 240 saveExtensionSettings();
226 241
227} 242}
228 243
229void KABConfigWidget::restoreExtensionSettings() 244void KABConfigWidget::restoreExtensionSettings()
230{ 245{
231 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 246 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
232 247
233 mExtensionView->clear(); 248 mExtensionView->clear();
234 249
235#ifndef KAB_EMBEDDED 250#ifndef KAB_EMBEDDED
236 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 251 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
237 KTrader::OfferList::ConstIterator it; 252 KTrader::OfferList::ConstIterator it;
238 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 253 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
239 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 254 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
240 continue; 255 continue;
241 256
242 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 257 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
243 item->setService( *it ); 258 item->setService( *it );
244 if ( activeExtensions.contains( item->factory()->identifier() ) ) 259 if ( activeExtensions.contains( item->factory()->identifier() ) )
245 item->setOn( true ); 260 item->setOn( true );
246 } 261 }
247#else //KAB_EMBEDDED 262#else //KAB_EMBEDDED
248 ExtensionFactory *extensionFactory = new MergeFactory(); 263 ExtensionFactory *extensionFactory = new MergeFactory();
249 264
250 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 265 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
251 266
252 item->setFactory( extensionFactory ); 267 item->setFactory( extensionFactory );
253 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 268 if ( activeExtensions.contains( extensionFactory->identifier() ) )
254 item->setOn( true ); 269 item->setOn( true );
255 270
256 271
257 272
258 extensionFactory = new DistributionListFactory(); 273 extensionFactory = new DistributionListFactory();
259 274
260 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 275 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
261 276
262 item->setFactory( extensionFactory ); 277 item->setFactory( extensionFactory );
263 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 278 if ( activeExtensions.contains( extensionFactory->identifier() ) )
264 item->setOn( true ); 279 item->setOn( true );
265 280
266 281
267#endif //KAB_EMBEDDED 282#endif //KAB_EMBEDDED
268 283
269} 284}
270 285
271void KABConfigWidget::saveExtensionSettings() 286void KABConfigWidget::saveExtensionSettings()
272{ 287{
273 QStringList activeExtensions; 288 QStringList activeExtensions;
274 289
275 QPtrList<QListViewItem> list; 290 QPtrList<QListViewItem> list;
276 QListViewItemIterator it( mExtensionView ); 291 QListViewItemIterator it( mExtensionView );
277 while ( it.current() ) { 292 while ( it.current() ) {
278 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 293 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
279 if ( item ) { 294 if ( item ) {
280 if ( item->isOn() ) 295 if ( item->isOn() )
281 activeExtensions.append( item->factory()->identifier() ); 296 activeExtensions.append( item->factory()->identifier() );
282 } 297 }
283 ++it; 298 ++it;
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 08d71b4..a172e97 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -3,73 +3,75 @@
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <kprefswidget.h> 27#include <kprefswidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
32class QComboBox; 32class QComboBox;
33class QLineEdit; 33class QLineEdit;
34class KListView; 34class KListView;
35class KABPrefs; 35class KABPrefs;
36 36
37class AddresseeWidget; 37class AddresseeWidget;
38 38
39class KABConfigWidget : public KPrefsWidget 39class KABConfigWidget : public KPrefsWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); 44 KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 );
45 45
46 protected: 46 protected:
47 /** Implement this to read custom configuration widgets. */ 47 /** Implement this to read custom configuration widgets. */
48 virtual void usrReadConfig(); 48 virtual void usrReadConfig();
49 /** Implement this to write custom configuration widgets. */ 49 /** Implement this to write custom configuration widgets. */
50 virtual void usrWriteConfig(); 50 virtual void usrWriteConfig();
51 51
52 52
53 53
54 private slots: 54 private slots:
55 void configureExtension(); 55 void configureExtension();
56 void selectionChanged( QListViewItem* ); 56 void selectionChanged( QListViewItem* );
57 void itemClicked( QListViewItem* ); 57 void itemClicked( QListViewItem* );
58 58
59 private: 59 private:
60 void restoreExtensionSettings(); 60 void restoreExtensionSettings();
61 void saveExtensionSettings(); 61 void saveExtensionSettings();
62 62
63 KListView *mExtensionView; 63 KListView *mExtensionView;
64 QCheckBox *mSearchReturnBox; 64 QCheckBox *mSearchReturnBox;
65 QCheckBox *mNameParsing; 65 QCheckBox *mNameParsing;
66 QCheckBox *mViewsSingleClickBox; 66 QCheckBox *mViewsSingleClickBox;
67 QCheckBox *mAutoSearchWithWildcardBox;
68 QCheckBox *mHideSearchOnSwitchBox;
67 QCheckBox *mMultipleViewsAtOnce; 69 QCheckBox *mMultipleViewsAtOnce;
68 QCheckBox *mAskForQuit; 70 QCheckBox *mAskForQuit;
69 QCheckBox *mMenuBarBox; 71 QCheckBox *mMenuBarBox;
70 QPushButton *mConfigureButton; 72 QPushButton *mConfigureButton;
71 73
72 AddresseeWidget *mAddresseeWidget; 74 AddresseeWidget *mAddresseeWidget;
73}; 75};
74 76
75#endif 77#endif
diff --git a/kaddressbook/viewmanager.cpp b/kaddressbook/viewmanager.cpp
index 04759a7..c2b1bb0 100644
--- a/kaddressbook/viewmanager.cpp
+++ b/kaddressbook/viewmanager.cpp
@@ -47,129 +47,129 @@ $Id$
47#include "views/kaddressbooktableview.h" 47#include "views/kaddressbooktableview.h"
48#include "views/kaddressbookcardview.h" 48#include "views/kaddressbookcardview.h"
49#include "kaddressbookview.h" 49#include "kaddressbookview.h"
50 50
51#include <qaction.h> 51#include <qaction.h>
52#include <qmessagebox.h> 52#include <qmessagebox.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54#include <kconfigbase.h> 54#include <kconfigbase.h>
55 55
56#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
57 57
58 58
59#include <kdebug.h> 59#include <kdebug.h>
60#include <kactionclasses.h> 60#include <kactionclasses.h>
61 61
62#include <qlayout.h> 62#include <qlayout.h>
63#include <qapplication.h> 63#include <qapplication.h>
64#include <qwidgetstack.h> 64#include <qwidgetstack.h>
65 65
66#include <kabc/addressbook.h> 66#include <kabc/addressbook.h>
67#include "filtereditdialog.h" 67#include "filtereditdialog.h"
68#include "addviewdialog.h" 68#include "addviewdialog.h"
69#include "kabcore.h" 69#include "kabcore.h"
70#include "kabprefs.h" 70#include "kabprefs.h"
71#include "viewmanager.h" 71#include "viewmanager.h"
72 72
73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name ) 73ViewManager::ViewManager( KABCore *core, QWidget *parent, const char *name )
74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 ) 74 : QWidget( parent, name ), mCore( core ), mActiveView( 0 )
75{ 75{
76 initGUI(); 76 initGUI();
77 initActions(); 77 initActions();
78 78
79 mViewDict.setAutoDelete( true ); 79 mViewDict.setAutoDelete( true );
80 80
81 createViewFactories(); 81 createViewFactories();
82} 82}
83 83
84ViewManager::~ViewManager() 84ViewManager::~ViewManager()
85{ 85{
86 unloadViews(); 86 unloadViews();
87 mViewFactoryDict.clear(); 87 mViewFactoryDict.clear();
88} 88}
89void ViewManager::scrollUP() 89void ViewManager::scrollUP()
90{ 90{
91 if ( mActiveView ) 91 if ( mActiveView )
92 mActiveView->scrollUP(); 92 mActiveView->scrollUP();
93} 93}
94void ViewManager::scrollDOWN() 94void ViewManager::scrollDOWN()
95{ 95{
96 if ( mActiveView ) 96 if ( mActiveView )
97 mActiveView->scrollDOWN(); 97 mActiveView->scrollDOWN();
98} 98}
99void ViewManager::restoreSettings() 99void ViewManager::restoreSettings()
100{ 100{
101 mViewNameList = KABPrefs::instance()->mViewNames; 101 mViewNameList = KABPrefs::instance()->mViewNames;
102 QString activeViewName = KABPrefs::instance()->mCurrentView; 102 QString activeViewName = KABPrefs::instance()->mCurrentView;
103 103
104 mActionSelectView->setItems( mViewNameList ); 104 mActionSelectView->setItems( mViewNameList );
105 105
106 // Filter 106 // Filter
107 mFilterList = Filter::restore( mCore->config(), "Filter" ); 107 mFilterList = Filter::restore( mCore->config(), "Filter" );
108 mActionSelectFilter->setItems( filterNames() ); 108 mActionSelectFilter->setItems( filterNames() );
109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter ); 109 mActionSelectFilter->setCurrentItem( KABPrefs::instance()->mCurrentFilter );
110 int cw = 150; 110 int cw = 150;
111 if (QApplication::desktop()->width() == 480 ) 111 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
112 cw = 0; 112 cw = 0;
113 mActionSelectFilter->setComboWidth( cw ); 113 mActionSelectFilter->setComboWidth( cw );
114 // Tell the views to reread their config, since they may have 114 // Tell the views to reread their config, since they may have
115 // been modified by global settings 115 // been modified by global settings
116 QString _oldgroup = mCore->config()->group(); 116 QString _oldgroup = mCore->config()->group();
117 117
118 QDictIterator<KAddressBookView> it( mViewDict ); 118 QDictIterator<KAddressBookView> it( mViewDict );
119 for ( it.toFirst(); it.current(); ++it ) { 119 for ( it.toFirst(); it.current(); ++it ) {
120 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 120 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
121 it.current()->readConfig( mCore->config() ); 121 it.current()->readConfig( mCore->config() );
122 } 122 }
123 setActiveView( activeViewName ); 123 setActiveView( activeViewName );
124 124
125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 ); 125 mActionDeleteView->setEnabled( mViewNameList.count() > 1 );
126} 126}
127 127
128void ViewManager::saveSettings() 128void ViewManager::saveSettings()
129{ 129{
130 QString _oldgroup = mCore->config()->group(); 130 QString _oldgroup = mCore->config()->group();
131 131
132 QDictIterator<KAddressBookView> it( mViewDict ); 132 QDictIterator<KAddressBookView> it( mViewDict );
133 for ( it.toFirst(); it.current(); ++it ) { 133 for ( it.toFirst(); it.current(); ++it ) {
134 KConfigGroupSaver saver( mCore->config(), it.currentKey() ); 134 KConfigGroupSaver saver( mCore->config(), it.currentKey() );
135#ifdef DESKTOP_VERSION 135#ifdef DESKTOP_VERSION
136 (*it)->writeConfig( mCore->config() ); 136 (*it)->writeConfig( mCore->config() );
137#else 137#else
138 (*it).writeConfig( mCore->config() ); 138 (*it).writeConfig( mCore->config() );
139#endif 139#endif
140 } 140 }
141 141
142 Filter::save( mCore->config(), "Filter", mFilterList ); 142 Filter::save( mCore->config(), "Filter", mFilterList );
143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem(); 143 KABPrefs::instance()->mCurrentFilter = mActionSelectFilter->currentItem();
144 144
145 // write the view name list 145 // write the view name list
146 KABPrefs::instance()->mViewNames = mViewNameList; 146 KABPrefs::instance()->mViewNames = mViewNameList;
147 KABPrefs::instance()->mCurrentView = mActiveView->caption(); 147 KABPrefs::instance()->mCurrentView = mActiveView->caption();
148 148
149} 149}
150 150
151QStringList ViewManager::selectedUids() const 151QStringList ViewManager::selectedUids() const
152{ 152{
153 if ( mActiveView ) 153 if ( mActiveView )
154 return mActiveView->selectedUids(); 154 return mActiveView->selectedUids();
155 else 155 else
156 return QStringList(); 156 return QStringList();
157} 157}
158 158
159QStringList ViewManager::selectedEmails() const 159QStringList ViewManager::selectedEmails() const
160{ 160{
161 if ( mActiveView ) 161 if ( mActiveView )
162 return mActiveView->selectedEmails(); 162 return mActiveView->selectedEmails();
163 else 163 else
164 return QStringList(); 164 return QStringList();
165} 165}
166 166
167KABC::Addressee::List ViewManager::selectedAddressees() const 167KABC::Addressee::List ViewManager::selectedAddressees() const
168{ 168{
169 KABC::Addressee::List list; 169 KABC::Addressee::List list;
170 if ( mActiveView ) { 170 if ( mActiveView ) {
171 QStringList uids = mActiveView->selectedUids(); 171 QStringList uids = mActiveView->selectedUids();
172 QStringList::Iterator it; 172 QStringList::Iterator it;
173 for ( it = uids.begin(); it != uids.end(); ++it ) { 173 for ( it = uids.begin(); it != uids.end(); ++it ) {
174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it ); 174 KABC::Addressee addr = mCore->addressBook()->findByUid( *it );
175 if ( !addr.isEmpty() ) 175 if ( !addr.isEmpty() )
@@ -543,129 +543,129 @@ void ViewManager::startDrag()
543 KABC::Addressee::List addrList; 543 KABC::Addressee::List addrList;
544 QStringList uidList = selectedUids(); 544 QStringList uidList = selectedUids();
545 QStringList::Iterator iter; 545 QStringList::Iterator iter;
546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter ) 546 for ( iter = uidList.begin(); iter != uidList.end(); ++iter )
547 addrList.append( mCore->addressBook()->findByUid( *iter ) ); 547 addrList.append( mCore->addressBook()->findByUid( *iter ) );
548 548
549 KMultipleDrag *drag = new KMultipleDrag( this ); 549 KMultipleDrag *drag = new KMultipleDrag( this );
550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) ); 550 drag->addDragObject( new QTextDrag( AddresseeUtil::addresseesToClipboard(addrList), this ) );
551 KABC::Addressee::List::Iterator it; 551 KABC::Addressee::List::Iterator it;
552 QStringList vcards; 552 QStringList vcards;
553 for ( it = addrList.begin(); it != addrList.end(); ++it ) { 553 for ( it = addrList.begin(); it != addrList.end(); ++it ) {
554 QString vcard = QString::null; 554 QString vcard = QString::null;
555 KABC::VCardConverter converter; 555 KABC::VCardConverter converter;
556 if ( converter.addresseeToVCard( *it, vcard ) ) 556 if ( converter.addresseeToVCard( *it, vcard ) )
557 vcards.append( vcard ); 557 vcards.append( vcard );
558 } 558 }
559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) ); 559 drag->addDragObject( new KVCardDrag( vcards.join( "\r\n" ), this ) );
560 560
561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) ); 561 drag->setPixmap( KGlobal::iconLoader()->loadIcon( "vcard", KIcon::Desktop ) );
562 drag->dragCopy(); 562 drag->dragCopy();
563 563
564#else //KAB_EMBEDDED 564#else //KAB_EMBEDDED
565qDebug("ViewManager::startDrag() has to be changed!!" ); 565qDebug("ViewManager::startDrag() has to be changed!!" );
566#endif //KAB_EMBEDDED 566#endif //KAB_EMBEDDED
567 567
568} 568}
569void ViewManager::doSearch( const QString& s,KABC::Field *field ) 569void ViewManager::doSearch( const QString& s,KABC::Field *field )
570{ 570{
571 if ( mActiveView ) 571 if ( mActiveView )
572 mActiveView->doSearch( s, field ); 572 mActiveView->doSearch( s, field );
573 573
574} 574}
575void ViewManager::setActiveFilter( int index ) 575void ViewManager::setActiveFilter( int index )
576{ 576{
577 Filter currentFilter; 577 Filter currentFilter;
578 578
579 if ( ( index - 1 ) < 0 ) 579 if ( ( index - 1 ) < 0 )
580 currentFilter = Filter(); 580 currentFilter = Filter();
581 else 581 else
582 currentFilter = mFilterList[ index - 1 ]; 582 currentFilter = mFilterList[ index - 1 ];
583 583
584 // Check if we have a view. Since the filter combo is created before 584 // Check if we have a view. Since the filter combo is created before
585 // the view, this slot could be called before there is a valid view. 585 // the view, this slot could be called before there is a valid view.
586 if ( mActiveView ) { 586 if ( mActiveView ) {
587 mActiveView->setFilter( currentFilter ); 587 mActiveView->setFilter( currentFilter );
588 mActiveView->refresh(); 588 mActiveView->refresh();
589 emit selected( QString::null ); 589 emit selected( QString::null );
590 } 590 }
591} 591}
592 592
593void ViewManager::configureFilters() 593void ViewManager::configureFilters()
594{ 594{
595 FilterDialog dlg( this ); 595 FilterDialog dlg( this );
596 596
597 dlg.setFilters( mFilterList ); 597 dlg.setFilters( mFilterList );
598 598
599 if ( dlg.exec() ) 599 if ( dlg.exec() )
600 mFilterList = dlg.filters(); 600 mFilterList = dlg.filters();
601 601
602 uint pos = mActionSelectFilter->currentItem(); 602 uint pos = mActionSelectFilter->currentItem();
603 mActionSelectFilter->setItems( filterNames() ); 603 mActionSelectFilter->setItems( filterNames() );
604 mActionSelectFilter->setCurrentItem( pos ); 604 mActionSelectFilter->setCurrentItem( pos );
605 setActiveFilter( pos ); 605 setActiveFilter( pos );
606 int cw = 150; 606 int cw = 150;
607 if (QApplication::desktop()->width() == 480 ) 607 if (QApplication::desktop()->width() == 480 && !KABPrefs::instance()->mHideSearchOnSwitch)
608 cw = 0; 608 cw = 0;
609 mActionSelectFilter->setComboWidth( cw ); 609 mActionSelectFilter->setComboWidth( cw );
610 saveSettings(); 610 saveSettings();
611} 611}
612 612
613QStringList ViewManager::filterNames() const 613QStringList ViewManager::filterNames() const
614{ 614{
615 QStringList names( i18n( "No Filter" ) ); 615 QStringList names( i18n( "No Filter" ) );
616 616
617 Filter::List::ConstIterator it; 617 Filter::List::ConstIterator it;
618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 618 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
619 names.append( (*it).name() ); 619 names.append( (*it).name() );
620 620
621 return names; 621 return names;
622} 622}
623Filter ViewManager::getFilterByName( const QString &name ) const 623Filter ViewManager::getFilterByName( const QString &name ) const
624{ 624{
625 Filter::List::ConstIterator it; 625 Filter::List::ConstIterator it;
626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it ) 626 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it )
627 if ( name == (*it).name() ) 627 if ( name == (*it).name() )
628 return (*it); 628 return (*it);
629 629
630 return Filter(); 630 return Filter();
631} 631}
632 632
633int ViewManager::filterPosition( const QString &name ) const 633int ViewManager::filterPosition( const QString &name ) const
634{ 634{
635 int pos = 0; 635 int pos = 0;
636 636
637 Filter::List::ConstIterator it; 637 Filter::List::ConstIterator it;
638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos ) 638 for ( it = mFilterList.begin(); it != mFilterList.end(); ++it, ++pos )
639 if ( name == (*it).name() ) 639 if ( name == (*it).name() )
640 return pos + 1; 640 return pos + 1;
641 641
642 return 0; 642 return 0;
643} 643}
644 644
645void ViewManager::initActions() 645void ViewManager::initActions()
646{ 646{
647//US <ActionList name="view_loadedviews"/> 647//US <ActionList name="view_loadedviews"/>
648//US <Separator/> 648//US <Separator/>
649 649
650#ifdef KAB_EMBEDDED 650#ifdef KAB_EMBEDDED
651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu(); 651 QPopupMenu *viewmenu = (QPopupMenu*)mCore->getViewMenu();
652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu(); 652 QPopupMenu *settingsmenu = (QPopupMenu*)mCore->getSettingsMenu();
653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu(); 653 QPopupMenu *filtermenu = (QPopupMenu*)mCore->getFilterMenu();
654#endif //KAB_EMBEDDED 654#endif //KAB_EMBEDDED
655 655
656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" ); 656 mActionSelectView = new KSelectAction( i18n( "Select View" ), 0, mCore->actionCollection(), "select_view" );
657#if KDE_VERSION >= 309 657#if KDE_VERSION >= 309
658 mActionSelectView->setMenuAccelsEnabled( false ); 658 mActionSelectView->setMenuAccelsEnabled( false );
659#endif 659#endif
660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ), 660 connect( mActionSelectView, SIGNAL( activated( const QString& ) ),
661 SLOT( selectView( const QString& ) ) ); 661 SLOT( selectView( const QString& ) ) );
662 662
663 663
664#ifdef KAB_EMBEDDED 664#ifdef KAB_EMBEDDED
665 mActionSelectView->plug(viewmenu); 665 mActionSelectView->plug(viewmenu);
666 viewmenu->insertSeparator(); 666 viewmenu->insertSeparator();
667#endif //KAB_EMBEDDED 667#endif //KAB_EMBEDDED
668 668
669 KAction *action; 669 KAction *action;
670 670
671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this, 671 action = new KAction( i18n( "Modify View..." ), "configure", 0, this,