summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-11 22:40:15 (UTC)
committer zautrix <zautrix>2004-09-11 22:40:15 (UTC)
commita040c9d56282dae396b02627fafb602e44323837 (patch) (unidiff)
tree9ee997f51e46a1ae6ab5aeaab709f1b8e138f3df
parent53dda80aaab72d7efdbed8a206dc1fa64fed10ee (diff)
downloadkdepimpi-a040c9d56282dae396b02627fafb602e44323837.zip
kdepimpi-a040c9d56282dae396b02627fafb602e44323837.tar.gz
kdepimpi-a040c9d56282dae396b02627fafb602e44323837.tar.bz2
Added configure for search
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp19
-rw-r--r--kaddressbook/incsearchwidget.h1
-rw-r--r--kaddressbook/kabcore.cpp2
-rw-r--r--kaddressbook/kabprefs.cpp2
-rw-r--r--kaddressbook/kabprefs.h1
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp6
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h2
-rw-r--r--kaddressbook/views/kaddressbooktableview.cpp2
8 files changed, 28 insertions, 7 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 2ffa357..3533427 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,150 +1,161 @@
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#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28 28
29#include <kdialog.h> 29#include <kdialog.h>
30#include <klineedit.h> 30#include <klineedit.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kglobal.h>
34#include "kabprefs.h"
33 35
34#include "incsearchwidget.h" 36#include "incsearchwidget.h"
35 37
36IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
37 : QWidget( parent, name ) 39 : QWidget( parent, name )
38{ 40{
39#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
40//US setCaption( i18n( "Incremental Search" ) ); 42//US setCaption( i18n( "Incremental Search" ) );
41#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
42 44
43 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
44 46
45#ifdef DESKTOP_VERSION 47#ifdef DESKTOP_VERSION
46 QLabel *label = new QLabel( i18n( "Search:" ), this ); 48 QLabel *label = new QLabel( i18n( "Search:" ), this );
47 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
48 layout->addWidget( label ); 50 layout->addWidget( label );
49#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
50 52
51 mSearchText = new KLineEdit( this ); 53 mSearchText = new KLineEdit( this );
52 layout->addWidget( mSearchText ); 54 layout->addWidget( mSearchText );
53// #ifdef KAB_EMBEDDED 55// #ifdef KAB_EMBEDDED
54// if (KGlobal::getOrientation() == KGlobal::Portrait) 56// if (KGlobal::getOrientation() == KGlobal::Portrait)
55// mSearchText->setMaximumWidth(30); 57// mSearchText->setMaximumWidth(30);
56// #endif //KAB_EMBEDDED 58// #endif //KAB_EMBEDDED
57 59
58 60
59 mFieldCombo = new QComboBox( false, this ); 61 mFieldCombo = new QComboBox( false, this );
60 layout->addWidget( mFieldCombo ); 62 layout->addWidget( mFieldCombo );
61 mFieldCombo->setMaximumHeight( 34 ); 63 mFieldCombo->setMaximumHeight( 34 );
62 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 64 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
63 65
64// #ifndef KAB_EMBEDDED 66// #ifndef KAB_EMBEDDED
65// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 67// resize( QSize(420, 50).expandedTo( sizeHint() ) );
66// #else //KAB_EMBEDDED 68// #else //KAB_EMBEDDED
67// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 69// resize( QSize(30, 10).expandedTo( sizeHint() ) );
68// #endif //KAB_EMBEDDED 70// #endif //KAB_EMBEDDED
69 71
70#ifdef DESKTOP_VERSION 72
71 // for performance reasons, we do a search on the pda only after return is pressed 73 // for performance reasons, we do a search on the pda only after return is pressed
72 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 74 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
73 SLOT( announceDoSearch() ) ); 75 SLOT( announceDoSearch2() ) );
74 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 76 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
75 SLOT( announceDoSearch() ) ); 77 SLOT( announceDoSearch2() ) );
76#endif 78
77 connect( mSearchText, SIGNAL( returnPressed() ), 79 connect( mSearchText, SIGNAL( returnPressed() ),
78 SLOT( announceDoSearch() ) ); 80 SLOT( announceDoSearch() ) );
79 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 81 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
80 SLOT( announceFieldChanged() ) ); 82 SLOT( announceFieldChanged() ) );
81 83
82 setFocusProxy( mSearchText ); 84 setFocusProxy( mSearchText );
83} 85}
84 86
85IncSearchWidget::~IncSearchWidget() 87IncSearchWidget::~IncSearchWidget()
86{ 88{
87 89
88} 90}
91void IncSearchWidget::announceDoSearch2()
92{
93 if ( KABPrefs::instance()->mSearchWithReturn )
94 return;
95 emit doSearch( mSearchText->text() );
96 //qDebug("emit dosreach ");
97}
89 98
90void IncSearchWidget::announceDoSearch() 99void IncSearchWidget::announceDoSearch()
91{ 100{
101
92 emit doSearch( mSearchText->text() ); 102 emit doSearch( mSearchText->text() );
103 // qDebug("emit dosreach ");
93} 104}
94 105
95void IncSearchWidget::announceFieldChanged() 106void IncSearchWidget::announceFieldChanged()
96{ 107{
97 emit fieldChanged(); 108 emit fieldChanged();
98} 109}
99 110
100void IncSearchWidget::setFields( const KABC::Field::List &list ) 111void IncSearchWidget::setFields( const KABC::Field::List &list )
101{ 112{
102 113
103 mFieldCombo->clear(); 114 mFieldCombo->clear();
104 mFieldCombo->insertItem( i18n( "All Fields" ) ); 115 mFieldCombo->insertItem( i18n( "All Fields" ) );
105 QFontMetrics fm ( mFieldCombo->font() ); 116 QFontMetrics fm ( mFieldCombo->font() );
106 int wid = fm.width(i18n( "All Fields" ) ); 117 int wid = fm.width(i18n( "All Fields" ) );
107 int max = wid; 118 int max = wid;
108 119
109 KABC::Field::List::ConstIterator it; 120 KABC::Field::List::ConstIterator it;
110 for ( it = list.begin(); it != list.end(); ++it ) { 121 for ( it = list.begin(); it != list.end(); ++it ) {
111 mFieldCombo->insertItem( (*it)->label() ); 122 mFieldCombo->insertItem( (*it)->label() );
112 // wid = fm.width((*it)->label() ); 123 // wid = fm.width((*it)->label() );
113 //if ( wid > max ) 124 //if ( wid > max )
114 // max = wid; 125 // max = wid;
115 } 126 }
116 127
117 mFieldList = list; 128 mFieldList = list;
118 129
119 announceDoSearch(); 130 announceDoSearch();
120 announceFieldChanged(); 131 announceFieldChanged();
121 mFieldCombo->setMaximumWidth( wid+60 ); 132 mFieldCombo->setMaximumWidth( wid+60 );
122} 133}
123 134
124KABC::Field::List IncSearchWidget::fields() const 135KABC::Field::List IncSearchWidget::fields() const
125{ 136{
126 return mFieldList; 137 return mFieldList;
127} 138}
128 139
129KABC::Field *IncSearchWidget::currentField()const 140KABC::Field *IncSearchWidget::currentField()const
130{ 141{
131 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 142 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
132 return 0; // for error or 'use all fields' 143 return 0; // for error or 'use all fields'
133 else 144 else
134 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 145 return mFieldList[ mFieldCombo->currentItem() - 1 ];
135} 146}
136 147
137void IncSearchWidget::setCurrentItem( int pos ) 148void IncSearchWidget::setCurrentItem( int pos )
138{ 149{
139 mFieldCombo->setCurrentItem( pos ); 150 mFieldCombo->setCurrentItem( pos );
140 announceFieldChanged(); 151 announceFieldChanged();
141} 152}
142 153
143int IncSearchWidget::currentItem() const 154int IncSearchWidget::currentItem() const
144{ 155{
145 156
146 return mFieldCombo->currentItem(); 157 return mFieldCombo->currentItem();
147} 158}
148#ifndef KAB_EMBEDDED 159#ifndef KAB_EMBEDDED
149#include "incsearchwidget.moc" 160#include "incsearchwidget.moc"
150#endif //KAB_EMBEDDED 161#endif //KAB_EMBEDDED
diff --git a/kaddressbook/incsearchwidget.h b/kaddressbook/incsearchwidget.h
index 09fb8ac..5c95438 100644
--- a/kaddressbook/incsearchwidget.h
+++ b/kaddressbook/incsearchwidget.h
@@ -1,73 +1,74 @@
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 49
50 signals: 50 signals:
51 /** 51 /**
52 This signal is emmited whenever the text in the input 52 This signal is emmited whenever the text in the input
53 widget is changed. You can get the sorting field by 53 widget is changed. You can get the sorting field by
54 @ref currentField. 54 @ref currentField.
55 */ 55 */
56 void doSearch( const QString& text ); 56 void doSearch( const QString& text );
57 57
58 /** 58 /**
59 This signal is emmited whenever the search field changes. 59 This signal is emmited whenever the search field changes.
60 */ 60 */
61 void fieldChanged(); 61 void fieldChanged();
62 62
63 private slots: 63 private slots:
64 void announceDoSearch(); 64 void announceDoSearch();
65 void announceDoSearch2();
65 void announceFieldChanged(); 66 void announceFieldChanged();
66 67
67 private: 68 private:
68 QComboBox* mFieldCombo; 69 QComboBox* mFieldCombo;
69 KLineEdit* mSearchText; 70 KLineEdit* mSearchText;
70 KABC::Field::List mFieldList; 71 KABC::Field::List mFieldList;
71}; 72};
72 73
73#endif 74#endif
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp
index bbf8e1b..f0a49f8 100644
--- a/kaddressbook/kabcore.cpp
+++ b/kaddressbook/kabcore.cpp
@@ -1292,193 +1292,193 @@ void KABCore::openConfigDialog()
1292} 1292}
1293 1293
1294void KABCore::openLDAPDialog() 1294void KABCore::openLDAPDialog()
1295{ 1295{
1296#ifndef KAB_EMBEDDED 1296#ifndef KAB_EMBEDDED
1297 if ( !mLdapSearchDialog ) { 1297 if ( !mLdapSearchDialog ) {
1298 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this ); 1298 mLdapSearchDialog = new LDAPSearchDialog( mAddressBook, this );
1299 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager, 1299 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), mViewManager,
1300 SLOT( refreshView() ) ); 1300 SLOT( refreshView() ) );
1301 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this, 1301 connect( mLdapSearchDialog, SIGNAL( addresseesAdded() ), this,
1302 SLOT( setModified() ) ); 1302 SLOT( setModified() ) );
1303 } else 1303 } else
1304 mLdapSearchDialog->restoreSettings(); 1304 mLdapSearchDialog->restoreSettings();
1305 1305
1306 if ( mLdapSearchDialog->isOK() ) 1306 if ( mLdapSearchDialog->isOK() )
1307 mLdapSearchDialog->exec(); 1307 mLdapSearchDialog->exec();
1308#else //KAB_EMBEDDED 1308#else //KAB_EMBEDDED
1309 qDebug("KABCore::openLDAPDialog() finsih method"); 1309 qDebug("KABCore::openLDAPDialog() finsih method");
1310#endif //KAB_EMBEDDED 1310#endif //KAB_EMBEDDED
1311} 1311}
1312 1312
1313void KABCore::print() 1313void KABCore::print()
1314{ 1314{
1315#ifndef KAB_EMBEDDED 1315#ifndef KAB_EMBEDDED
1316 KPrinter printer; 1316 KPrinter printer;
1317 if ( !printer.setup( this ) ) 1317 if ( !printer.setup( this ) )
1318 return; 1318 return;
1319 1319
1320 KABPrinting::PrintingWizard wizard( &printer, mAddressBook, 1320 KABPrinting::PrintingWizard wizard( &printer, mAddressBook,
1321 mViewManager->selectedUids(), this ); 1321 mViewManager->selectedUids(), this );
1322 1322
1323 wizard.exec(); 1323 wizard.exec();
1324#else //KAB_EMBEDDED 1324#else //KAB_EMBEDDED
1325 qDebug("KABCore::print() finsih method"); 1325 qDebug("KABCore::print() finsih method");
1326#endif //KAB_EMBEDDED 1326#endif //KAB_EMBEDDED
1327 1327
1328} 1328}
1329 1329
1330 1330
1331void KABCore::addGUIClient( KXMLGUIClient *client ) 1331void KABCore::addGUIClient( KXMLGUIClient *client )
1332{ 1332{
1333 if ( mGUIClient ) 1333 if ( mGUIClient )
1334 mGUIClient->insertChildClient( client ); 1334 mGUIClient->insertChildClient( client );
1335 else 1335 else
1336 KMessageBox::error( this, "no KXMLGUICLient"); 1336 KMessageBox::error( this, "no KXMLGUICLient");
1337} 1337}
1338 1338
1339 1339
1340void KABCore::configurationChanged() 1340void KABCore::configurationChanged()
1341{ 1341{
1342 mExtensionManager->reconfigure(); 1342 mExtensionManager->reconfigure();
1343} 1343}
1344 1344
1345void KABCore::addressBookChanged() 1345void KABCore::addressBookChanged()
1346{ 1346{
1347/*US 1347/*US
1348 QDictIterator<AddresseeEditorDialog> it( mEditorDict ); 1348 QDictIterator<AddresseeEditorDialog> it( mEditorDict );
1349 while ( it.current() ) { 1349 while ( it.current() ) {
1350 if ( it.current()->dirty() ) { 1350 if ( it.current()->dirty() ) {
1351 QString text = i18n( "Data has been changed externally. Unsaved " 1351 QString text = i18n( "Data has been changed externally. Unsaved "
1352 "changes will be lost." ); 1352 "changes will be lost." );
1353 KMessageBox::information( this, text ); 1353 KMessageBox::information( this, text );
1354 } 1354 }
1355 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) ); 1355 it.current()->setAddressee( mAddressBook->findByUid( it.currentKey() ) );
1356 ++it; 1356 ++it;
1357 } 1357 }
1358*/ 1358*/
1359 if (mEditorDialog) 1359 if (mEditorDialog)
1360 { 1360 {
1361 if (mEditorDialog->dirty()) 1361 if (mEditorDialog->dirty())
1362 { 1362 {
1363 QString text = i18n( "Data has been changed externally. Unsaved " 1363 QString text = i18n( "Data has been changed externally. Unsaved "
1364 "changes will be lost." ); 1364 "changes will be lost." );
1365 KMessageBox::information( this, text ); 1365 KMessageBox::information( this, text );
1366 } 1366 }
1367 QString currentuid = mEditorDialog->addressee().uid(); 1367 QString currentuid = mEditorDialog->addressee().uid();
1368 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) ); 1368 mEditorDialog->setAddressee( mAddressBook->findByUid( currentuid ) );
1369 } 1369 }
1370 mViewManager->refreshView(); 1370 mViewManager->refreshView();
1371// mDetails->refreshView(); 1371// mDetails->refreshView();
1372 1372
1373 1373
1374} 1374}
1375 1375
1376AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent, 1376AddresseeEditorDialog *KABCore::createAddresseeEditorDialog( QWidget *parent,
1377 const char *name ) 1377 const char *name )
1378{ 1378{
1379 1379
1380 if ( mEditorDialog == 0 ) { 1380 if ( mEditorDialog == 0 ) {
1381 mEditorDialog = new AddresseeEditorDialog( this, parent, 1381 mEditorDialog = new AddresseeEditorDialog( this, parent,
1382 name ? name : "editorDialog" ); 1382 name ? name : "editorDialog" );
1383 1383
1384 1384
1385 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ), 1385 connect( mEditorDialog, SIGNAL( contactModified( const KABC::Addressee& ) ),
1386 SLOT( contactModified( const KABC::Addressee& ) ) ); 1386 SLOT( contactModified( const KABC::Addressee& ) ) );
1387 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ), 1387 //connect( mEditorDialog, SIGNAL( editorDestroyed( const QString& ) ),
1388 // SLOT( slotEditorDestroyed( const QString& ) ) ); 1388 // SLOT( slotEditorDestroyed( const QString& ) ) ;
1389 } 1389 }
1390 1390
1391 return mEditorDialog; 1391 return mEditorDialog;
1392} 1392}
1393 1393
1394void KABCore::slotEditorDestroyed( const QString &uid ) 1394void KABCore::slotEditorDestroyed( const QString &uid )
1395{ 1395{
1396 //mEditorDict.remove( uid ); 1396 //mEditorDict.remove( uid );
1397} 1397}
1398 1398
1399void KABCore::initGUI() 1399void KABCore::initGUI()
1400{ 1400{
1401#ifndef KAB_EMBEDDED 1401#ifndef KAB_EMBEDDED
1402 QHBoxLayout *topLayout = new QHBoxLayout( this ); 1402 QHBoxLayout *topLayout = new QHBoxLayout( this );
1403 topLayout->setSpacing( KDialogBase::spacingHint() ); 1403 topLayout->setSpacing( KDialogBase::spacingHint() );
1404 1404
1405 mExtensionBarSplitter = new QSplitter( this ); 1405 mExtensionBarSplitter = new QSplitter( this );
1406 mExtensionBarSplitter->setOrientation( Qt::Vertical ); 1406 mExtensionBarSplitter->setOrientation( Qt::Vertical );
1407 1407
1408 mDetailsSplitter = new QSplitter( mExtensionBarSplitter ); 1408 mDetailsSplitter = new QSplitter( mExtensionBarSplitter );
1409 1409
1410 QVBox *viewSpace = new QVBox( mDetailsSplitter ); 1410 QVBox *viewSpace = new QVBox( mDetailsSplitter );
1411 mIncSearchWidget = new IncSearchWidget( viewSpace ); 1411 mIncSearchWidget = new IncSearchWidget( viewSpace );
1412 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ), 1412 connect( mIncSearchWidget, SIGNAL( doSearch( const QString& ) ),
1413 SLOT( incrementalSearch( const QString& ) ) ); 1413 SLOT( incrementalSearch( const QString& ) ) );
1414 1414
1415 mViewManager = new ViewManager( this, viewSpace ); 1415 mViewManager = new ViewManager( this, viewSpace );
1416 viewSpace->setStretchFactor( mViewManager, 1 ); 1416 viewSpace->setStretchFactor( mViewManager, 1 );
1417 1417
1418 mDetails = new ViewContainer( mDetailsSplitter ); 1418 mDetails = new ViewContainer( mDetailsSplitter );
1419 1419
1420 mJumpButtonBar = new JumpButtonBar( this, this ); 1420 mJumpButtonBar = new JumpButtonBar( this, this );
1421 1421
1422 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1422 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1423 1423
1424 topLayout->addWidget( mExtensionBarSplitter ); 1424 topLayout->addWidget( mExtensionBarSplitter );
1425 topLayout->setStretchFactor( mExtensionBarSplitter, 100 ); 1425 topLayout->setStretchFactor( mExtensionBarSplitter, 100 );
1426 topLayout->addWidget( mJumpButtonBar ); 1426 topLayout->addWidget( mJumpButtonBar );
1427 topLayout->setStretchFactor( mJumpButtonBar, 1 ); 1427 topLayout->setStretchFactor( mJumpButtonBar, 1 );
1428 1428
1429 mXXPortManager = new XXPortManager( this, this ); 1429 mXXPortManager = new XXPortManager( this, this );
1430 1430
1431#else //KAB_EMBEDDED 1431#else //KAB_EMBEDDED
1432 //US initialize viewMenu before settingup viewmanager. 1432 //US initialize viewMenu before settingup viewmanager.
1433 // Viewmanager needs this menu to plugin submenues. 1433 // Viewmanager needs this menu to plugin submenues.
1434 viewMenu = new QPopupMenu( this ); 1434 viewMenu = new QPopupMenu( this );
1435 settingsMenu = new QPopupMenu( this ); 1435 settingsMenu = new QPopupMenu( this );
1436 //filterMenu = new QPopupMenu( this ); 1436 //filterMenu = new QPopupMenu( this );
1437 ImportMenu = new QPopupMenu( this ); 1437 ImportMenu = new QPopupMenu( this );
1438 ExportMenu = new QPopupMenu( this ); 1438 ExportMenu = new QPopupMenu( this );
1439 1439
1440 changeMenu= new QPopupMenu( this ); 1440 changeMenu= new QPopupMenu( this );
1441 1441
1442//US since we have no splitter for the embedded system, setup 1442//US since we have no splitter for the embedded system, setup
1443// a layout with two frames. One left and one right. 1443// a layout with two frames. One left and one right.
1444 1444
1445 QBoxLayout *topLayout; 1445 QBoxLayout *topLayout;
1446 1446
1447 // = new QHBoxLayout( this ); 1447 // = new QHBoxLayout( this );
1448// QBoxLayout *topLayout = (QBoxLayout*)layout(); 1448// QBoxLayout *topLayout = (QBoxLayout*)layout();
1449 1449
1450// QWidget *mainBox = new QWidget( this ); 1450// QWidget *mainBox = new QWidget( this );
1451// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox); 1451// QBoxLayout * mainBoxLayout = new QHBoxLayout(mainBox);
1452 1452
1453#ifdef DESKTOP_VERSION 1453#ifdef DESKTOP_VERSION
1454 topLayout = new QHBoxLayout( this ); 1454 topLayout = new QHBoxLayout( this );
1455 1455
1456 1456
1457 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1457 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1458 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1458 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1459 1459
1460 topLayout->addWidget(mMiniSplitter ); 1460 topLayout->addWidget(mMiniSplitter );
1461 1461
1462 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter ); 1462 mExtensionBarSplitter = new KDGanttMinimizeSplitter( Qt::Vertical,mMiniSplitter );
1463 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1463 mExtensionBarSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1464 mViewManager = new ViewManager( this, mExtensionBarSplitter ); 1464 mViewManager = new ViewManager( this, mExtensionBarSplitter );
1465 mDetails = new ViewContainer( mMiniSplitter ); 1465 mDetails = new ViewContainer( mMiniSplitter );
1466 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter ); 1466 mExtensionManager = new ExtensionManager( this, mExtensionBarSplitter );
1467#else 1467#else
1468 if ( QApplication::desktop()->width() > 480 ) { 1468 if ( QApplication::desktop()->width() > 480 ) {
1469 topLayout = new QHBoxLayout( this ); 1469 topLayout = new QHBoxLayout( this );
1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 1470 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 1471 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
1472 } else { 1472 } else {
1473 1473
1474 topLayout = new QHBoxLayout( this ); 1474 topLayout = new QHBoxLayout( this );
1475 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this); 1475 mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Vertical, this);
1476 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down ); 1476 mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Down );
1477 } 1477 }
1478 1478
1479 topLayout->addWidget(mMiniSplitter ); 1479 topLayout->addWidget(mMiniSplitter );
1480 mViewManager = new ViewManager( this, mMiniSplitter ); 1480 mViewManager = new ViewManager( this, mMiniSplitter );
1481 mDetails = new ViewContainer( mMiniSplitter ); 1481 mDetails = new ViewContainer( mMiniSplitter );
1482 1482
1483 1483
1484 mExtensionManager = new ExtensionManager( this, mMiniSplitter ); 1484 mExtensionManager = new ExtensionManager( this, mMiniSplitter );
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 2425158..552c933 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,130 +1,132 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,true); 50 addItemBool("AskForQuit",&mAskForQuit,true);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 addItemBool("SearchWithReturn",&mSearchWithReturn, true );
54
53 55
54#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
55 57
56 KPrefs::setCurrentGroup( "MainWindow" ); 58 KPrefs::setCurrentGroup( "MainWindow" );
57 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 59 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
58 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 60 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
59 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 61 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
60 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 62 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
61 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true ); 63 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
62 64
63 65
64 KPrefs::setCurrentGroup( "Extensions_General" ); 66 KPrefs::setCurrentGroup( "Extensions_General" );
65 QStringList defaultExtensions; 67 QStringList defaultExtensions;
66 defaultExtensions << "merge"; 68 defaultExtensions << "merge";
67 defaultExtensions << "distribution_list_editor"; 69 defaultExtensions << "distribution_list_editor";
68 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 70 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
69 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 71 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
70 72
71 KPrefs::setCurrentGroup( "Views" ); 73 KPrefs::setCurrentGroup( "Views" );
72 QString defaultView = i18n( "Default Table View" ); 74 QString defaultView = i18n( "Default Table View" );
73 addItemString( "CurrentView", &mCurrentView, defaultView ); 75 addItemString( "CurrentView", &mCurrentView, defaultView );
74 addItemStringList( "ViewNames", &mViewNames, defaultView ); 76 addItemStringList( "ViewNames", &mViewNames, defaultView );
75 77
76 KPrefs::setCurrentGroup( "Filters" ); 78 KPrefs::setCurrentGroup( "Filters" );
77 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 79 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
78 80
79} 81}
80 82
81KABPrefs::~KABPrefs() 83KABPrefs::~KABPrefs()
82{ 84{
83} 85}
84 86
85KABPrefs *KABPrefs::instance() 87KABPrefs *KABPrefs::instance()
86{ 88{
87 if ( !sInstance ) { 89 if ( !sInstance ) {
88#ifdef KAB_EMBEDDED 90#ifdef KAB_EMBEDDED
89 sInstance = staticDeleter.setObject( new KABPrefs() ); 91 sInstance = staticDeleter.setObject( new KABPrefs() );
90#else //KAB_EMBEDDED 92#else //KAB_EMBEDDED
91 //US the following line has changed ???. Why 93 //US the following line has changed ???. Why
92 staticDeleter.setObject( sInstance, new KABPrefs() ); 94 staticDeleter.setObject( sInstance, new KABPrefs() );
93#endif //KAB_EMBEDDED 95#endif //KAB_EMBEDDED
94 sInstance->readConfig(); 96 sInstance->readConfig();
95 } 97 }
96 98
97 return sInstance; 99 return sInstance;
98} 100}
99 101
100void KABPrefs::setCategoryDefaults() 102void KABPrefs::setCategoryDefaults()
101{ 103{
102 mCustomCategories.clear(); 104 mCustomCategories.clear();
103 105
104 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 106 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
105 << i18n( "Customer" ) << i18n( "Friend" ); 107 << i18n( "Customer" ) << i18n( "Friend" );
106} 108}
107 109
108 // US introduce a nonconst way to return the config object. 110 // US introduce a nonconst way to return the config object.
109KConfig* KABPrefs::getConfig() 111KConfig* KABPrefs::getConfig()
110{ 112{
111 return config(); 113 return config();
112} 114}
113 115
114 116
115/*US 117/*US
116void KABPrefs::usrSetDefaults() 118void KABPrefs::usrSetDefaults()
117{ 119{
118 KPimPrefs::usrSetDefaults(); 120 KPimPrefs::usrSetDefaults();
119} 121}
120 122
121void KABPrefs::usrReadConfig() 123void KABPrefs::usrReadConfig()
122{ 124{
123 KPimPrefs::usrReadConfig(); 125 KPimPrefs::usrReadConfig();
124} 126}
125 127
126void KABPrefs::usrWriteConfig() 128void KABPrefs::usrWriteConfig()
127{ 129{
128 KPimPrefs::usrWriteConfig(); 130 KPimPrefs::usrWriteConfig();
129} 131}
130*/ 132*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 03e529f..e4f359c 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,91 +1,92 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABPREFS_H 24#ifndef KABPREFS_H
25#define KABPREFS_H 25#define KABPREFS_H
26 26
27#include <qstringlist.h> 27#include <qstringlist.h>
28 28
29#include <libkdepim/kpimprefs.h> 29#include <libkdepim/kpimprefs.h>
30 30
31class KConfig; 31class KConfig;
32 32
33class KABPrefs : public KPimPrefs 33class KABPrefs : public KPimPrefs
34{ 34{
35 public: 35 public:
36 virtual ~KABPrefs(); 36 virtual ~KABPrefs();
37 37
38 static KABPrefs *instance(); 38 static KABPrefs *instance();
39 39
40 // General 40 // General
41 bool mHonorSingleClick; 41 bool mHonorSingleClick;
42 bool mAutomaticNameParsing; 42 bool mAutomaticNameParsing;
43 int mCurrentIncSearchField; 43 int mCurrentIncSearchField;
44 44
45#ifdef KAB_EMBEDDED 45#ifdef KAB_EMBEDDED
46 // US introduce a nonconst way to return the config object. 46 // US introduce a nonconst way to return the config object.
47 KConfig* getConfig(); 47 KConfig* getConfig();
48 48
49 bool mToolBarHor; 49 bool mToolBarHor;
50 bool mToolBarUp; 50 bool mToolBarUp;
51 bool mAskForQuit; 51 bool mAskForQuit;
52 52
53 53
54 /** Set preferences to default values */ 54 /** Set preferences to default values */
55// void usrSetDefaults(); 55// void usrSetDefaults();
56 56
57 /** Read preferences from config file */ 57 /** Read preferences from config file */
58// void usrReadConfig(); 58// void usrReadConfig();
59 59
60 /** Write preferences to config file */ 60 /** Write preferences to config file */
61// void usrWriteConfig(); 61// void usrWriteConfig();
62#endif //KAB_EMBEDDED 62#endif //KAB_EMBEDDED
63 63
64 64
65 // GUI 65 // GUI
66 bool mJumpButtonBarVisible; 66 bool mJumpButtonBarVisible;
67 bool mDetailsPageVisible; 67 bool mDetailsPageVisible;
68 bool mMultipleViewsAtOnce; 68 bool mMultipleViewsAtOnce;
69 bool mSearchWithReturn;
69 QValueList<int> mExtensionsSplitter; 70 QValueList<int> mExtensionsSplitter;
70 QValueList<int> mDetailsSplitter; 71 QValueList<int> mDetailsSplitter;
71 72
72 // Extensions stuff 73 // Extensions stuff
73 int mCurrentExtension; 74 int mCurrentExtension;
74 QStringList mActiveExtensions; 75 QStringList mActiveExtensions;
75 76
76 // Views stuff 77 // Views stuff
77 QString mCurrentView; 78 QString mCurrentView;
78 QStringList mViewNames; 79 QStringList mViewNames;
79 80
80 // Filter 81 // Filter
81 int mCurrentFilter; 82 int mCurrentFilter;
82 83
83 void setCategoryDefaults(); 84 void setCategoryDefaults();
84 85
85 private: 86 private:
86 KABPrefs(); 87 KABPrefs();
87 88
88 static KABPrefs *sInstance; 89 static KABPrefs *sInstance;
89}; 90};
90 91
91#endif 92#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index 3a2ccbb..0c3a199 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -13,298 +13,304 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 30#include <qcombobox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qlabel.h> 32#include <qlabel.h>
33#include <qfile.h> 33#include <qfile.h>
34#include <qvbox.h> 34#include <qvbox.h>
35 35
36#include <kconfig.h> 36#include <kconfig.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <kdialog.h> 38#include <kdialog.h>
39#include <klistview.h> 39#include <klistview.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kglobal.h> 41#include <kglobal.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44 44
45#ifndef KAB_EMBEDDED 45#ifndef KAB_EMBEDDED
46#include <ktrader.h> 46#include <ktrader.h>
47#else // KAB_EMBEDDED 47#else // KAB_EMBEDDED
48#include <mergewidget.h> 48#include <mergewidget.h>
49#include <distributionlistwidget.h> 49#include <distributionlistwidget.h>
50#endif // KAB_EMBEDDED 50#endif // KAB_EMBEDDED
51 51
52#include "addresseewidget.h" 52#include "addresseewidget.h"
53#include "extensionconfigdialog.h" 53#include "extensionconfigdialog.h"
54#include "extensionwidget.h" 54#include "extensionwidget.h"
55#include "kabprefs.h" 55#include "kabprefs.h"
56 56
57#include "kabconfigwidget.h" 57#include "kabconfigwidget.h"
58 58
59class ExtensionItem : public QCheckListItem 59class ExtensionItem : public QCheckListItem
60{ 60{
61 public: 61 public:
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( QWidget *parent, const char *name ) 88KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
89 : QWidget( parent, name ) 89 : QWidget( 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 //general groupbox 101 //general groupbox
102 QVBox *vBox = new QVBox( generalPage, "qvbox" ); 102 QVBox *vBox = new QVBox( generalPage, "qvbox" );
103 QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" ); 103 QVBoxLayout *boxLayout = new QVBoxLayout( vBox->layout(), -1, "qvboxlayout" );
104 boxLayout->setAlignment( Qt::AlignTop ); 104 boxLayout->setAlignment( Qt::AlignTop );
105 boxLayout->setMargin(KDialog::marginHintSmall() ); 105 boxLayout->setMargin(KDialog::marginHintSmall() );
106 vBox->layout()->setMargin(KDialog::marginHintSmall()) ; 106 vBox->layout()->setMargin(KDialog::marginHintSmall()) ;
107 vBox->layout()->setSpacing(KDialog::spacingHintSmall()); 107 vBox->layout()->setSpacing(KDialog::spacingHintSmall());
108 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 108 boxLayout->setSpacing( KDialog::spacingHintSmall() );
109 mSearchReturnBox = new QCheckBox( i18n( "Search only after <return> key pressed" ), vBox, "mreturn" );
110 boxLayout->addWidget( mSearchReturnBox );
109 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" ); 111 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), vBox, "msingle" );
110 boxLayout->addWidget( mViewsSingleClickBox ); 112 boxLayout->addWidget( mViewsSingleClickBox );
111 113
112 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" ); 114 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), vBox, "mparse" );
113 boxLayout->addWidget( mNameParsing ); 115 boxLayout->addWidget( mNameParsing );
114 116
115 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" ); 117 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), vBox, "mdisplay" );
116 boxLayout->addWidget( mMultipleViewsAtOnce ); 118 boxLayout->addWidget( mMultipleViewsAtOnce );
117 119
118 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" ); 120 mAskForQuit = new QCheckBox( i18n( "Ask for quit when closing Ka/Pi" ), vBox, "mquit" );
119 boxLayout->addWidget( mAskForQuit ); 121 boxLayout->addWidget( mAskForQuit );
120 122
121 layout->addWidget( vBox ); 123 layout->addWidget( vBox );
122 124
123 tabWidget->addTab( generalPage, i18n( "General" ) ); 125 tabWidget->addTab( generalPage, i18n( "General" ) );
124 126
125 // Extension page 127 // Extension page
126 QWidget *extensionPage = new QWidget( this ); 128 QWidget *extensionPage = new QWidget( this );
127 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(), 129 QVBoxLayout *extensionLayout = new QVBoxLayout( extensionPage, KDialog::marginHintSmall(),
128 KDialog::spacingHintSmall() ); 130 KDialog::spacingHintSmall() );
129 131
130 //extensions groupbox 132 //extensions groupbox
131 133
132 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage ); 134 QGroupBox* groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), extensionPage );
133 boxLayout = new QVBoxLayout( groupBox->layout() ); 135 boxLayout = new QVBoxLayout( groupBox->layout() );
134 boxLayout->setAlignment( Qt::AlignTop ); 136 boxLayout->setAlignment( Qt::AlignTop );
135 boxLayout->setMargin(KDialog::marginHintSmall()); 137 boxLayout->setMargin(KDialog::marginHintSmall());
136 boxLayout->setSpacing(KDialog::spacingHintSmall()); 138 boxLayout->setSpacing(KDialog::spacingHintSmall());
137 groupBox->layout()->setMargin(1) ; 139 groupBox->layout()->setMargin(1) ;
138 groupBox->layout()->setSpacing(0); 140 groupBox->layout()->setSpacing(0);
139 mExtensionView = new KListView( groupBox ); 141 mExtensionView = new KListView( groupBox );
140 mExtensionView->setAllColumnsShowFocus( true ); 142 mExtensionView->setAllColumnsShowFocus( true );
141 mExtensionView->addColumn( i18n( "Name" ) ); 143 mExtensionView->addColumn( i18n( "Name" ) );
142 mExtensionView->addColumn( i18n( "Description" ) ); 144 mExtensionView->addColumn( i18n( "Description" ) );
143 mExtensionView->setMaximumHeight(80); 145 mExtensionView->setMaximumHeight(80);
144 146
145 boxLayout->addWidget( mExtensionView ); 147 boxLayout->addWidget( mExtensionView );
146 148
147 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 149 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
148 mConfigureButton->setEnabled( false ); 150 mConfigureButton->setEnabled( false );
149 boxLayout->addWidget( mConfigureButton ); 151 boxLayout->addWidget( mConfigureButton );
150 152
151 extensionLayout->addWidget( groupBox ); 153 extensionLayout->addWidget( groupBox );
152 154
153 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 155 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
154 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 156 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
157 connect( mSearchReturnBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
155 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 158 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
156 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 159 connect( mAskForQuit, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
157 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 160 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
158 SLOT( selectionChanged( QListViewItem* ) ) ); 161 SLOT( selectionChanged( QListViewItem* ) ) );
159 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 162 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
160 SLOT( itemClicked( QListViewItem* ) ) ); 163 SLOT( itemClicked( QListViewItem* ) ) );
161 connect( mConfigureButton, SIGNAL( clicked() ), 164 connect( mConfigureButton, SIGNAL( clicked() ),
162 SLOT( configureExtension() ) ); 165 SLOT( configureExtension() ) );
163 166
164 tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); 167 tabWidget->addTab( extensionPage, i18n( "Extensions" ) );
165 168
166 // Addressee page 169 // Addressee page
167 mAddresseeWidget = new AddresseeWidget( this ); 170 mAddresseeWidget = new AddresseeWidget( this );
168 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 171 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
169 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 172 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
170 173
171} 174}
172 175
173 176
174void KABConfigWidget::restoreSettings(KABPrefs* prefs) 177void KABConfigWidget::restoreSettings(KABPrefs* prefs)
175{ 178{
176//US prefs was KABPrefs::instance() before 179//US prefs was KABPrefs::instance() before
177 180
178 bool blocked = signalsBlocked(); 181 bool blocked = signalsBlocked();
179 blockSignals( true ); 182 blockSignals( true );
180 183
181 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 184 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
182 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 185 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
186 mSearchReturnBox->setChecked( prefs->mSearchWithReturn );
183 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); 187 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
184 mAskForQuit->setChecked( prefs->mAskForQuit ); 188 mAskForQuit->setChecked( prefs->mAskForQuit );
185 189
186 mAddresseeWidget->restoreSettings(); 190 mAddresseeWidget->restoreSettings();
187 191
188 restoreExtensionSettings(); 192 restoreExtensionSettings();
189 193
190 blockSignals( blocked ); 194 blockSignals( blocked );
191 195
192 emit changed( false ); 196 emit changed( false );
193} 197}
194 198
195void KABConfigWidget::saveSettings(KABPrefs* prefs) 199void KABConfigWidget::saveSettings(KABPrefs* prefs)
196{ 200{
197 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 201 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
198 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 202 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
203 prefs->mSearchWithReturn = mSearchReturnBox->isChecked();
199 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); 204 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
200 prefs->mAskForQuit = mAskForQuit->isChecked(); 205 prefs->mAskForQuit = mAskForQuit->isChecked();
201 206
202 mAddresseeWidget->saveSettings(); 207 mAddresseeWidget->saveSettings();
203 208
204 saveExtensionSettings(); 209 saveExtensionSettings();
205 KABPrefs::instance()->writeConfig(); 210 KABPrefs::instance()->writeConfig();
206 211
207 emit changed( false ); 212 emit changed( false );
208} 213}
209 214
210void KABConfigWidget::defaults(KABPrefs* prefs) 215void KABConfigWidget::defaults(KABPrefs* prefs)
211{ 216{
212 mNameParsing->setChecked( true ); 217 mNameParsing->setChecked( true );
213 mViewsSingleClickBox->setChecked( false ); 218 mViewsSingleClickBox->setChecked( false );
214 mMultipleViewsAtOnce->setChecked( true ); 219 mMultipleViewsAtOnce->setChecked( true );
220 mSearchReturnBox->setChecked( true );
215 mAskForQuit->setChecked (true); 221 mAskForQuit->setChecked (true);
216 222
217 emit changed( true ); 223 emit changed( true );
218} 224}
219 225
220void KABConfigWidget::modified() 226void KABConfigWidget::modified()
221{ 227{
222 emit changed( true ); 228 emit changed( true );
223} 229}
224 230
225void KABConfigWidget::restoreExtensionSettings() 231void KABConfigWidget::restoreExtensionSettings()
226{ 232{
227 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 233 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
228 234
229 mExtensionView->clear(); 235 mExtensionView->clear();
230 236
231#ifndef KAB_EMBEDDED 237#ifndef KAB_EMBEDDED
232 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 238 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
233 KTrader::OfferList::ConstIterator it; 239 KTrader::OfferList::ConstIterator it;
234 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 240 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
235 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 241 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
236 continue; 242 continue;
237 243
238 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 244 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
239 item->setService( *it ); 245 item->setService( *it );
240 if ( activeExtensions.contains( item->factory()->identifier() ) ) 246 if ( activeExtensions.contains( item->factory()->identifier() ) )
241 item->setOn( true ); 247 item->setOn( true );
242 } 248 }
243#else //KAB_EMBEDDED 249#else //KAB_EMBEDDED
244 ExtensionFactory *extensionFactory = new MergeFactory(); 250 ExtensionFactory *extensionFactory = new MergeFactory();
245 251
246 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 252 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
247 253
248 item->setFactory( extensionFactory ); 254 item->setFactory( extensionFactory );
249 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 255 if ( activeExtensions.contains( extensionFactory->identifier() ) )
250 item->setOn( true ); 256 item->setOn( true );
251 257
252 258
253 259
254 extensionFactory = new DistributionListFactory(); 260 extensionFactory = new DistributionListFactory();
255 261
256 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 262 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
257 263
258 item->setFactory( extensionFactory ); 264 item->setFactory( extensionFactory );
259 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 265 if ( activeExtensions.contains( extensionFactory->identifier() ) )
260 item->setOn( true ); 266 item->setOn( true );
261 267
262 268
263#endif //KAB_EMBEDDED 269#endif //KAB_EMBEDDED
264 270
265} 271}
266 272
267void KABConfigWidget::saveExtensionSettings() 273void KABConfigWidget::saveExtensionSettings()
268{ 274{
269 QStringList activeExtensions; 275 QStringList activeExtensions;
270 276
271 QPtrList<QListViewItem> list; 277 QPtrList<QListViewItem> list;
272 QListViewItemIterator it( mExtensionView ); 278 QListViewItemIterator it( mExtensionView );
273 while ( it.current() ) { 279 while ( it.current() ) {
274 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 280 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
275 if ( item ) { 281 if ( item ) {
276 if ( item->isOn() ) 282 if ( item->isOn() )
277 activeExtensions.append( item->factory()->identifier() ); 283 activeExtensions.append( item->factory()->identifier() );
278 } 284 }
279 ++it; 285 ++it;
280 } 286 }
281 287
282 KABPrefs::instance()->mActiveExtensions = activeExtensions; 288 KABPrefs::instance()->mActiveExtensions = activeExtensions;
283} 289}
284 290
285void KABConfigWidget::configureExtension() 291void KABConfigWidget::configureExtension()
286{ 292{
287 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 293 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
288 if ( !item ) 294 if ( !item )
289 return; 295 return;
290 296
291#ifndef KAB_EMBEDDED 297#ifndef KAB_EMBEDDED
292 KConfig config( "kaddressbookrc" ); 298 KConfig config( "kaddressbookrc" );
293#else //KAB_EMBEDDED 299#else //KAB_EMBEDDED
294 KConfig config( locateLocal("config", "kaddressbookrc") ); 300 KConfig config( locateLocal("config", "kaddressbookrc") );
295#endif //KAB_EMBEDDED 301#endif //KAB_EMBEDDED
296 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 302 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
297 303
298 ExtensionConfigDialog dlg( item->factory(), &config, this ); 304 ExtensionConfigDialog dlg( item->factory(), &config, this );
299 dlg.exec(); 305 dlg.exec();
300 306
301 config.sync(); 307 config.sync();
302} 308}
303 309
304void KABConfigWidget::selectionChanged( QListViewItem *i ) 310void KABConfigWidget::selectionChanged( QListViewItem *i )
305{ 311{
306 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 312 ExtensionItem *item = static_cast<ExtensionItem*>( i );
307 if ( !item ) 313 if ( !item )
308 return; 314 return;
309 315
310 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 316 mConfigureButton->setEnabled( item->configWidgetAvailable() );
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 831efc1..6cd4223 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,79 +1,79 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
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 QWidget 39class KABConfigWidget : public QWidget
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KABConfigWidget( QWidget *parent, const char *name = 0 ); 44 KABConfigWidget( QWidget *parent, const char *name = 0 );
45 45
46 void restoreSettings(KABPrefs* prefs); 46 void restoreSettings(KABPrefs* prefs);
47 void saveSettings(KABPrefs* prefs); 47 void saveSettings(KABPrefs* prefs);
48 void defaults(KABPrefs* prefs); 48 void defaults(KABPrefs* prefs);
49 49
50 signals: 50 signals:
51 void changed( bool ); 51 void changed( bool );
52 52
53 public slots: 53 public slots:
54 void modified(); 54 void modified();
55 55
56 56
57 57
58 private slots: 58 private slots:
59 void configureExtension(); 59 void configureExtension();
60 void selectionChanged( QListViewItem* ); 60 void selectionChanged( QListViewItem* );
61 void itemClicked( QListViewItem* ); 61 void itemClicked( QListViewItem* );
62 62
63 private: 63 private:
64 void restoreExtensionSettings(); 64 void restoreExtensionSettings();
65 void saveExtensionSettings(); 65 void saveExtensionSettings();
66 66
67 KListView *mExtensionView; 67 KListView *mExtensionView;
68 68 QCheckBox *mSearchReturnBox;
69 QCheckBox *mNameParsing; 69 QCheckBox *mNameParsing;
70 QCheckBox *mViewsSingleClickBox; 70 QCheckBox *mViewsSingleClickBox;
71 QCheckBox *mMultipleViewsAtOnce; 71 QCheckBox *mMultipleViewsAtOnce;
72 QCheckBox *mAskForQuit; 72 QCheckBox *mAskForQuit;
73 73
74 QPushButton *mConfigureButton; 74 QPushButton *mConfigureButton;
75 75
76 AddresseeWidget *mAddresseeWidget; 76 AddresseeWidget *mAddresseeWidget;
77}; 77};
78 78
79#endif 79#endif
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp
index 12f7c27..63ad0ed 100644
--- a/kaddressbook/views/kaddressbooktableview.cpp
+++ b/kaddressbook/views/kaddressbooktableview.cpp
@@ -57,193 +57,193 @@ void KAddressBookTableView::reconstructListView()
57 { 57 {
58 disconnect(mListView, SIGNAL(selectionChanged()), 58 disconnect(mListView, SIGNAL(selectionChanged()),
59 this, SLOT(addresseeSelected())); 59 this, SLOT(addresseeSelected()));
60 disconnect(mListView, SIGNAL(executed(QListViewItem*)), 60 disconnect(mListView, SIGNAL(executed(QListViewItem*)),
61 this, SLOT(addresseeExecuted(QListViewItem*))); 61 this, SLOT(addresseeExecuted(QListViewItem*)));
62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 62 disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
63 this, SLOT(addresseeExecuted(QListViewItem*))); 63 this, SLOT(addresseeExecuted(QListViewItem*)));
64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this, 64 disconnect(mListView, SIGNAL(startAddresseeDrag()), this,
65 SIGNAL(startDrag())); 65 SIGNAL(startDrag()));
66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), 66 disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)),
67 this, SLOT(addresseeExecuted(QListViewItem*))); 67 this, SLOT(addresseeExecuted(QListViewItem*)));
68 68
69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 69 disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
70 SIGNAL(dropped(QDropEvent*))); 70 SIGNAL(dropped(QDropEvent*)));
71 delete mListView; 71 delete mListView;
72 } 72 }
73 73
74 mListView = new ContactListView( this, addressBook(), viewWidget() ); 74 mListView = new ContactListView( this, addressBook(), viewWidget() );
75 75
76 // Add the columns 76 // Add the columns
77 KABC::Field::List fieldList = fields(); 77 KABC::Field::List fieldList = fields();
78 KABC::Field::List::ConstIterator it; 78 KABC::Field::List::ConstIterator it;
79 79
80 int c = 0; 80 int c = 0;
81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) { 81 for( it = fieldList.begin(); it != fieldList.end(); ++it ) {
82 mListView->addColumn( (*it)->label() ); 82 mListView->addColumn( (*it)->label() );
83 mListView->setColumnWidthMode(c++, QListView::Manual); 83 mListView->setColumnWidthMode(c++, QListView::Manual);
84//US 84//US
85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1()); 85 // qDebug("KAddressBookTableView::reconstructListView: field %s", (*it)->label().latin1());
86 } 86 }
87 87
88 connect(mListView, SIGNAL(selectionChanged()), 88 connect(mListView, SIGNAL(selectionChanged()),
89 this, SLOT(addresseeSelected())); 89 this, SLOT(addresseeSelected()));
90 connect(mListView, SIGNAL(startAddresseeDrag()), this, 90 connect(mListView, SIGNAL(startAddresseeDrag()), this,
91 SIGNAL(startDrag())); 91 SIGNAL(startDrag()));
92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, 92 connect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this,
93 SIGNAL(dropped(QDropEvent*))); 93 SIGNAL(dropped(QDropEvent*)));
94 94
95 if (KABPrefs::instance()->mHonorSingleClick) 95 if (KABPrefs::instance()->mHonorSingleClick)
96 connect(mListView, SIGNAL(executed(QListViewItem*)), 96 connect(mListView, SIGNAL(executed(QListViewItem*)),
97 this, SLOT(addresseeExecuted(QListViewItem*))); 97 this, SLOT(addresseeExecuted(QListViewItem*)));
98 else 98 else
99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)), 99 connect(mListView, SIGNAL(doubleClicked(QListViewItem*)),
100 this, SLOT(addresseeExecuted(QListViewItem*))); 100 this, SLOT(addresseeExecuted(QListViewItem*)));
101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)), 101 connect(mListView, SIGNAL(returnPressed(QListViewItem*)),
102 this, SLOT(addresseeExecuted(QListViewItem*))); 102 this, SLOT(addresseeExecuted(QListViewItem*)));
103 connect(mListView, SIGNAL(signalDelete()), 103 connect(mListView, SIGNAL(signalDelete()),
104 this, SLOT(addresseeDeleted())); 104 this, SLOT(addresseeDeleted()));
105 105
106//US performceimprovement. Refresh is done from the outside 106//US performceimprovement. Refresh is done from the outside
107//US refresh(); 107//US refresh();
108 108
109 mListView->setSorting( 0, true ); 109 mListView->setSorting( 0, true );
110 mainLayout->addWidget( mListView ); 110 mainLayout->addWidget( mListView );
111 mainLayout->activate(); 111 mainLayout->activate();
112 mListView->show(); 112 mListView->show();
113} 113}
114 114
115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) 115void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field )
116{ 116{
117 mListView->clear(); 117 mListView->clear();
118 if ( s.isEmpty() || s == "*" ) { 118 if ( s.isEmpty() || s == "*" ) {
119 refresh(); 119 refresh();
120 return; 120 return;
121 } 121 }
122 QString pattern = s.lower()+"*"; 122 QString pattern = s.lower()+"*";
123 QRegExp re; 123 QRegExp re;
124 re.setWildcard(true); // most people understand these better. 124 re.setWildcard(true); // most people understand these better.
125 re.setCaseSensitive(false); 125 re.setCaseSensitive(false);
126 re.setPattern( pattern ); 126 re.setPattern( pattern );
127 if (!re.isValid()) 127 if (!re.isValid())
128 return; 128 return;
129 KABC::Addressee::List addresseeList = addressees(); 129 KABC::Addressee::List addresseeList = addressees();
130 KABC::Addressee::List::Iterator it; 130 KABC::Addressee::List::Iterator it;
131 if ( field ) { 131 if ( field ) {
132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 132 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
133#if QT_VERSION >= 300 133#if QT_VERSION >= 300
134 if (re.search(field->value( *it ).lower()) != -1) 134 if (re.search(field->value( *it ).lower()) != -1)
135#else 135#else
136 if (re.match(field->value( *it ).lower()) != -1) 136 if (re.match(field->value( *it ).lower()) != -1)
137#endif 137#endif
138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 138 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
139 139
140 } 140 }
141 } else { 141 } else {
142 KABC::Field::List fieldList = fields(); 142 KABC::Field::List fieldList = fields();
143 KABC::Field::List::ConstIterator fieldIt; 143 KABC::Field::List::ConstIterator fieldIt;
144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) { 144 for (it = addresseeList.begin(); it != addresseeList.end(); ++it ) {
145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { 145 for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) {
146#if QT_VERSION >= 300 146#if QT_VERSION >= 300
147 if (re.search((*fieldIt)->value( *it ).lower()) != -1) 147 if (re.search((*fieldIt)->value( *it ).lower()) != -1)
148#else 148#else
149 if (re.match((*fieldIt)->value( *it ).lower()) != -1) 149 if (re.match((*fieldIt)->value( *it ).lower()) != -1)
150#endif 150#endif
151 { 151 {
152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); 152 ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields());
153 continue; 153 break;
154 } 154 }
155 } 155 }
156 } 156 }
157 } 157 }
158 // Sometimes the background pixmap gets messed up when we add lots 158 // Sometimes the background pixmap gets messed up when we add lots
159 // of items. 159 // of items.
160 mListView->repaint(); 160 mListView->repaint();
161 emit selected(QString::null); 161 emit selected(QString::null);
162 162
163} 163}
164void KAddressBookTableView::writeConfig(KConfig *config) 164void KAddressBookTableView::writeConfig(KConfig *config)
165{ 165{
166 KAddressBookView::writeConfig(config); 166 KAddressBookView::writeConfig(config);
167 167
168 mListView->saveLayout(config, config->group()); 168 mListView->saveLayout(config, config->group());
169} 169}
170 170
171void KAddressBookTableView::readConfig(KConfig *config) 171void KAddressBookTableView::readConfig(KConfig *config)
172{ 172{
173 KAddressBookView::readConfig( config ); 173 KAddressBookView::readConfig( config );
174 // The config could have changed the fields, so we need to reconstruct 174 // The config could have changed the fields, so we need to reconstruct
175 // the listview. 175 // the listview.
176 reconstructListView(); 176 reconstructListView();
177 177
178 // costum colors? 178 // costum colors?
179 if ( config->readBoolEntry( "EnableCustomColors", false ) ) 179 if ( config->readBoolEntry( "EnableCustomColors", false ) )
180 { 180 {
181 QPalette p( mListView->palette() ); 181 QPalette p( mListView->palette() );
182 QColor c = p.color(QPalette::Normal, QColorGroup::Base ); 182 QColor c = p.color(QPalette::Normal, QColorGroup::Base );
183 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) ); 183 p.setColor( QPalette::Normal, QColorGroup::Base, config->readColorEntry( "BackgroundColor", &c ) );
184 c = p.color(QPalette::Normal, QColorGroup::Text ); 184 c = p.color(QPalette::Normal, QColorGroup::Text );
185 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) ); 185 p.setColor( QPalette::Normal, QColorGroup::Text, config->readColorEntry( "TextColor", &c ) );
186 c = p.color(QPalette::Normal, QColorGroup::Button ); 186 c = p.color(QPalette::Normal, QColorGroup::Button );
187 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) ); 187 p.setColor( QPalette::Normal, QColorGroup::Button, config->readColorEntry( "HeaderColor", &c ) );
188 c = p.color(QPalette::Normal, QColorGroup::ButtonText ); 188 c = p.color(QPalette::Normal, QColorGroup::ButtonText );
189 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) ); 189 p.setColor( QPalette::Normal, QColorGroup::ButtonText, config->readColorEntry( "HeaderTextColor", &c ) );
190 c = p.color(QPalette::Normal, QColorGroup::Highlight ); 190 c = p.color(QPalette::Normal, QColorGroup::Highlight );
191 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) ); 191 p.setColor( QPalette::Normal, QColorGroup::Highlight, config->readColorEntry( "HighlightColor", &c ) );
192 c = p.color(QPalette::Normal, QColorGroup::HighlightedText ); 192 c = p.color(QPalette::Normal, QColorGroup::HighlightedText );
193 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) ); 193 p.setColor( QPalette::Normal, QColorGroup::HighlightedText, config->readColorEntry( "HighlightedTextColor", &c ) );
194#ifndef KAB_EMBEDDED 194#ifndef KAB_EMBEDDED
195 c = KGlobalSettings::alternateBackgroundColor(); 195 c = KGlobalSettings::alternateBackgroundColor();
196#else //KAB_EMBEDDED 196#else //KAB_EMBEDDED
197 c = QColor(240, 240, 240); 197 c = QColor(240, 240, 240);
198#endif //KAB_EMBEDDED 198#endif //KAB_EMBEDDED
199 c = config->readColorEntry ("AlternatingBackgroundColor", &c); 199 c = config->readColorEntry ("AlternatingBackgroundColor", &c);
200 mListView->setAlternateColor(c); 200 mListView->setAlternateColor(c);
201 201
202 202
203 //US mListView->viewport()->setPalette( p ); 203 //US mListView->viewport()->setPalette( p );
204 mListView->setPalette( p ); 204 mListView->setPalette( p );
205 } 205 }
206 else 206 else
207 { 207 {
208 // needed if turned off during a session. 208 // needed if turned off during a session.
209 //US mListView->viewport()->setPalette( mListView->palette() ); 209 //US mListView->viewport()->setPalette( mListView->palette() );
210 mListView->setPalette( mListView->palette() ); 210 mListView->setPalette( mListView->palette() );
211 } 211 }
212 212
213 //custom fonts? 213 //custom fonts?
214 QFont f( font() ); 214 QFont f( font() );
215 if ( config->readBoolEntry( "EnableCustomFonts", false ) ) 215 if ( config->readBoolEntry( "EnableCustomFonts", false ) )
216 { 216 {
217 mListView->setFont( config->readFontEntry( "TextFont", &f) ); 217 mListView->setFont( config->readFontEntry( "TextFont", &f) );
218 f.setBold( true ); 218 f.setBold( true );
219 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) ); 219 //US mListView->setHeaderFont( config->readFontEntry( "HeaderFont", &f ) );
220 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) ); 220 mListView->header()->setFont( config->readFontEntry( "HeaderFont", &f ) );
221 } 221 }
222 else 222 else
223 { 223 {
224 mListView->setFont( f ); 224 mListView->setFont( f );
225 f.setBold( true ); 225 f.setBold( true );
226 //US mListView->setHeaderFont( f ); 226 //US mListView->setHeaderFont( f );
227 mListView->header()->setFont( f ); 227 mListView->header()->setFont( f );
228 } 228 }
229 229
230 230
231 231
232 232
233 233
234 // Set the list view options 234 // Set the list view options
235 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground", 235 mListView->setAlternateBackgroundEnabled(config->readBoolEntry("ABackground",
236 true)); 236 true));
237 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false)); 237 mListView->setSingleLineEnabled(config->readBoolEntry("SingleLine", false));
238 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true)); 238 mListView->setToolTipsEnabled(config->readBoolEntry("ToolTips", true));
239 239
240 if (config->readBoolEntry("Background", false)) 240 if (config->readBoolEntry("Background", false))
241 mListView->setBackgroundPixmap(config->readEntry("BackgroundName")); 241 mListView->setBackgroundPixmap(config->readEntry("BackgroundName"));
242 242
243 // Restore the layout of the listview 243 // Restore the layout of the listview
244 mListView->restoreLayout(config, config->group()); 244 mListView->restoreLayout(config, config->group());
245} 245}
246 246
247void KAddressBookTableView::refresh(QString uid) 247void KAddressBookTableView::refresh(QString uid)
248{ 248{
249 // For now just repopulate. In reality this method should 249 // For now just repopulate. In reality this method should