summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Unidiff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kabprefs.cpp2
-rw-r--r--kaddressbook/kabprefs.h1
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.cpp9
-rw-r--r--kaddressbook/kcmconfigs/kabconfigwidget.h2
4 files changed, 13 insertions, 1 deletions
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 0c192dd..03c5e76 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -1,128 +1,130 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 3 Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24//US#ifdef KAB_EMBEDDED 24//US#ifdef KAB_EMBEDDED
25//#include <qstring.h> 25//#include <qstring.h>
26//#endif //KAB_EMBEDDED 26//#endif //KAB_EMBEDDED
27 27
28 28
29#include <kconfig.h> 29#include <kconfig.h>
30#include <klocale.h> 30#include <klocale.h>
31#include <kstaticdeleter.h> 31#include <kstaticdeleter.h>
32//US#include <kdebug.h> // defines kdDebug() 32//US#include <kdebug.h> // defines kdDebug()
33 33
34#include "kabprefs.h" 34#include "kabprefs.h"
35 35
36KABPrefs *KABPrefs::sInstance = 0; 36KABPrefs *KABPrefs::sInstance = 0;
37static KStaticDeleter<KABPrefs> staticDeleter; 37static KStaticDeleter<KABPrefs> staticDeleter;
38 38
39KABPrefs::KABPrefs() 39KABPrefs::KABPrefs()
40 : KPimPrefs("kaddressbookrc") 40 : KPimPrefs("kaddressbookrc")
41{ 41{
42 KPrefs::setCurrentGroup( "Views" ); 42 KPrefs::setCurrentGroup( "Views" );
43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 43 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
44 44
45 KPrefs::setCurrentGroup( "General" ); 45 KPrefs::setCurrentGroup( "General" );
46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); 46 addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true );
47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); 47 addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 );
48 48
49#ifdef KAB_EMBEDDED 49#ifdef KAB_EMBEDDED
50 addItemBool("AskForQuit",&mAskForQuit,false); 50 addItemBool("AskForQuit",&mAskForQuit,false);
51 addItemBool("ToolBarHor",&mToolBarHor, true ); 51 addItemBool("ToolBarHor",&mToolBarHor, true );
52 addItemBool("ToolBarUp",&mToolBarUp, false ); 52 addItemBool("ToolBarUp",&mToolBarUp, false );
53 53
54#endif //KAB_EMBEDDED 54#endif //KAB_EMBEDDED
55 55
56 KPrefs::setCurrentGroup( "MainWindow" ); 56 KPrefs::setCurrentGroup( "MainWindow" );
57 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false ); 57 addItemBool( "JumpButtonBarVisible", &mJumpButtonBarVisible, false );
58 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true ); 58 addItemBool( "DetailsPageVisible", &mDetailsPageVisible, true );
59 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter ); 59 addItemIntList( "ExtensionsSplitter", &mExtensionsSplitter );
60 addItemIntList( "DetailsSplitter", &mDetailsSplitter ); 60 addItemIntList( "DetailsSplitter", &mDetailsSplitter );
61 addItemBool( "MultipleViewsAtOnce", &mMultipleViewsAtOnce, true );
62
61 63
62 KPrefs::setCurrentGroup( "Extensions_General" ); 64 KPrefs::setCurrentGroup( "Extensions_General" );
63 QStringList defaultExtensions; 65 QStringList defaultExtensions;
64 defaultExtensions << "merge"; 66 defaultExtensions << "merge";
65 defaultExtensions << "distribution_list_editor"; 67 defaultExtensions << "distribution_list_editor";
66 addItemInt( "CurrentExtension", &mCurrentExtension, 0 ); 68 addItemInt( "CurrentExtension", &mCurrentExtension, 0 );
67 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions ); 69 addItemStringList( "ActiveExtensions", &mActiveExtensions, defaultExtensions );
68 70
69 KPrefs::setCurrentGroup( "Views" ); 71 KPrefs::setCurrentGroup( "Views" );
70 QString defaultView = i18n( "Default Table View" ); 72 QString defaultView = i18n( "Default Table View" );
71 addItemString( "CurrentView", &mCurrentView, defaultView ); 73 addItemString( "CurrentView", &mCurrentView, defaultView );
72 addItemStringList( "ViewNames", &mViewNames, defaultView ); 74 addItemStringList( "ViewNames", &mViewNames, defaultView );
73 75
74 KPrefs::setCurrentGroup( "Filters" ); 76 KPrefs::setCurrentGroup( "Filters" );
75 addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); 77 addItemInt( "CurrentFilter", &mCurrentFilter, 0 );
76 78
77} 79}
78 80
79KABPrefs::~KABPrefs() 81KABPrefs::~KABPrefs()
80{ 82{
81} 83}
82 84
83KABPrefs *KABPrefs::instance() 85KABPrefs *KABPrefs::instance()
84{ 86{
85 if ( !sInstance ) { 87 if ( !sInstance ) {
86#ifdef KAB_EMBEDDED 88#ifdef KAB_EMBEDDED
87 sInstance = staticDeleter.setObject( new KABPrefs() ); 89 sInstance = staticDeleter.setObject( new KABPrefs() );
88#else //KAB_EMBEDDED 90#else //KAB_EMBEDDED
89 //US the following line has changed ???. Why 91 //US the following line has changed ???. Why
90 staticDeleter.setObject( sInstance, new KABPrefs() ); 92 staticDeleter.setObject( sInstance, new KABPrefs() );
91#endif //KAB_EMBEDDED 93#endif //KAB_EMBEDDED
92 sInstance->readConfig(); 94 sInstance->readConfig();
93 } 95 }
94 96
95 return sInstance; 97 return sInstance;
96} 98}
97 99
98void KABPrefs::setCategoryDefaults() 100void KABPrefs::setCategoryDefaults()
99{ 101{
100 mCustomCategories.clear(); 102 mCustomCategories.clear();
101 103
102 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" ) 104 mCustomCategories << i18n( "Business" ) << i18n( "Family" ) << i18n( "School" )
103 << i18n( "Customer" ) << i18n( "Friend" ); 105 << i18n( "Customer" ) << i18n( "Friend" );
104} 106}
105 107
106 // US introduce a nonconst way to return the config object. 108 // US introduce a nonconst way to return the config object.
107KConfig* KABPrefs::getConfig() 109KConfig* KABPrefs::getConfig()
108{ 110{
109 return config(); 111 return config();
110} 112}
111 113
112 114
113/*US 115/*US
114void KABPrefs::usrSetDefaults() 116void KABPrefs::usrSetDefaults()
115{ 117{
116 KPimPrefs::usrSetDefaults(); 118 KPimPrefs::usrSetDefaults();
117} 119}
118 120
119void KABPrefs::usrReadConfig() 121void KABPrefs::usrReadConfig()
120{ 122{
121 KPimPrefs::usrReadConfig(); 123 KPimPrefs::usrReadConfig();
122} 124}
123 125
124void KABPrefs::usrWriteConfig() 126void KABPrefs::usrWriteConfig()
125{ 127{
126 KPimPrefs::usrWriteConfig(); 128 KPimPrefs::usrWriteConfig();
127} 129}
128*/ 130*/
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 8f149ac..03e529f 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -1,90 +1,91 @@
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 QValueList<int> mExtensionsSplitter; 69 QValueList<int> mExtensionsSplitter;
69 QValueList<int> mDetailsSplitter; 70 QValueList<int> mDetailsSplitter;
70 71
71 // Extensions stuff 72 // Extensions stuff
72 int mCurrentExtension; 73 int mCurrentExtension;
73 QStringList mActiveExtensions; 74 QStringList mActiveExtensions;
74 75
75 // Views stuff 76 // Views stuff
76 QString mCurrentView; 77 QString mCurrentView;
77 QStringList mViewNames; 78 QStringList mViewNames;
78 79
79 // Filter 80 // Filter
80 int mCurrentFilter; 81 int mCurrentFilter;
81 82
82 void setCategoryDefaults(); 83 void setCategoryDefaults();
83 84
84 private: 85 private:
85 KABPrefs(); 86 KABPrefs();
86 87
87 static KABPrefs *sInstance; 88 static KABPrefs *sInstance;
88}; 89};
89 90
90#endif 91#endif
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
index b5309c0..31ab7b5 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp
@@ -1,376 +1,383 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qcheckbox.h> 24#include <qcheckbox.h>
25#include <qframe.h> 25#include <qframe.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qtabwidget.h> 29#include <qtabwidget.h>
30#include <qcombobox.h> 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 34
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <kdialog.h> 37#include <kdialog.h>
38#include <klistview.h> 38#include <klistview.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kmessagebox.h> 41#include <kmessagebox.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43 43
44#ifndef KAB_EMBEDDED 44#ifndef KAB_EMBEDDED
45#include <ktrader.h> 45#include <ktrader.h>
46#else // KAB_EMBEDDED 46#else // KAB_EMBEDDED
47#include <mergewidget.h> 47#include <mergewidget.h>
48#include <distributionlistwidget.h> 48#include <distributionlistwidget.h>
49#endif // KAB_EMBEDDED 49#endif // KAB_EMBEDDED
50 50
51#include "addresseewidget.h" 51#include "addresseewidget.h"
52#include "extensionconfigdialog.h" 52#include "extensionconfigdialog.h"
53#include "extensionwidget.h" 53#include "extensionwidget.h"
54#include "kabprefs.h" 54#include "kabprefs.h"
55 55
56#include "kabconfigwidget.h" 56#include "kabconfigwidget.h"
57 57
58class ExtensionItem : public QCheckListItem 58class ExtensionItem : public QCheckListItem
59{ 59{
60 public: 60 public:
61 61
62#ifndef KAB_EMBEDDED 62#ifndef KAB_EMBEDDED
63 ExtensionItem( QListView *parent, const QString &text ); 63 ExtensionItem( QListView *parent, const QString &text );
64 void setService( const KService::Ptr &ptr ); 64 void setService( const KService::Ptr &ptr );
65#else //KAB_EMBEDDED 65#else //KAB_EMBEDDED
66 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); 66 ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment );
67 void setFactory( ExtensionFactory* fac ); 67 void setFactory( ExtensionFactory* fac );
68#endif //KAB_EMBEDDED 68#endif //KAB_EMBEDDED
69 69
70 bool configWidgetAvailable() const; 70 bool configWidgetAvailable() const;
71 ExtensionFactory *factory() const; 71 ExtensionFactory *factory() const;
72 72
73 virtual QString text( int column ) const; 73 virtual QString text( int column ) const;
74 74
75 private: 75 private:
76#ifndef KAB_EMBEDDED 76#ifndef KAB_EMBEDDED
77 KService::Ptr mPtr; 77 KService::Ptr mPtr;
78#else //KAB_EMBEDDED 78#else //KAB_EMBEDDED
79 ExtensionFactory* mFactory; 79 ExtensionFactory* mFactory;
80 QString mName; 80 QString mName;
81 QString mComment; 81 QString mComment;
82 82
83#endif //KAB_EMBEDDED 83#endif //KAB_EMBEDDED
84 84
85}; 85};
86 86
87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 87KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
88 : QWidget( parent, name ) 88 : QWidget( parent, name )
89{ 89{
90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
91 KDialog::spacingHint() ); 91 KDialog::spacingHint() );
92 92
93 QTabWidget *tabWidget = new QTabWidget( this ); 93 QTabWidget *tabWidget = new QTabWidget( this );
94 topLayout->addWidget( tabWidget ); 94 topLayout->addWidget( tabWidget );
95 95
96 // General page 96 // General page
97 QWidget *generalPage = new QWidget( this ); 97 QWidget *generalPage = new QWidget( this );
98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), 98 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(),
99 KDialog::spacingHintSmall() ); 99 KDialog::spacingHintSmall() );
100 //general groupbox 100 //general groupbox
101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); 101 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); 102 QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
103 boxLayout->setAlignment( Qt::AlignTop ); 103 boxLayout->setAlignment( Qt::AlignTop );
104 boxLayout->setMargin(KDialog::marginHintSmall() ); 104 boxLayout->setMargin(KDialog::marginHintSmall() );
105 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; 105 groupBox->layout()->setMargin(KDialog::marginHintSmall()) ;
106 groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); 106 groupBox->layout()->setSpacing(KDialog::spacingHintSmall());
107 boxLayout->setSpacing( KDialog::spacingHintSmall() ); 107 boxLayout->setSpacing( KDialog::spacingHintSmall() );
108 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); 108 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
109 boxLayout->addWidget( mViewsSingleClickBox ); 109 boxLayout->addWidget( mViewsSingleClickBox );
110 110
111 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); 111 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
112 boxLayout->addWidget( mNameParsing ); 112 boxLayout->addWidget( mNameParsing );
113 113
114 mMultipleViewsAtOnce = new QCheckBox( i18n( "Display List and Details at once (restart)" ), groupBox, "mdisplay" );
115 boxLayout->addWidget( mMultipleViewsAtOnce );
116
114 layout->addWidget( groupBox ); 117 layout->addWidget( groupBox );
115 118
116 119
117 //extensions groupbox 120 //extensions groupbox
118 121
119 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); 122 groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions (restart)" ), generalPage );
120 boxLayout = new QVBoxLayout( groupBox->layout() ); 123 boxLayout = new QVBoxLayout( groupBox->layout() );
121 boxLayout->setAlignment( Qt::AlignTop ); 124 boxLayout->setAlignment( Qt::AlignTop );
122 boxLayout->setMargin(KDialog::marginHintSmall()); 125 boxLayout->setMargin(KDialog::marginHintSmall());
123 boxLayout->setSpacing(KDialog::spacingHintSmall()); 126 boxLayout->setSpacing(KDialog::spacingHintSmall());
124 groupBox->layout()->setMargin(1) ; 127 groupBox->layout()->setMargin(1) ;
125 groupBox->layout()->setSpacing(0); 128 groupBox->layout()->setSpacing(0);
126 mExtensionView = new KListView( groupBox ); 129 mExtensionView = new KListView( groupBox );
127 mExtensionView->setAllColumnsShowFocus( true ); 130 mExtensionView->setAllColumnsShowFocus( true );
128 mExtensionView->addColumn( i18n( "Name" ) ); 131 mExtensionView->addColumn( i18n( "Name" ) );
129 mExtensionView->addColumn( i18n( "Description" ) ); 132 mExtensionView->addColumn( i18n( "Description" ) );
130 mExtensionView->setMaximumHeight(80); 133 mExtensionView->setMaximumHeight(80);
131 134
132 boxLayout->addWidget( mExtensionView ); 135 boxLayout->addWidget( mExtensionView );
133 136
134 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); 137 mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox );
135 mConfigureButton->setEnabled( false ); 138 mConfigureButton->setEnabled( false );
136 boxLayout->addWidget( mConfigureButton ); 139 boxLayout->addWidget( mConfigureButton );
137 140
138 layout->addWidget( groupBox ); 141 layout->addWidget( groupBox );
139 142
140 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 143 connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
141 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); 144 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
145 connect( mMultipleViewsAtOnce, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) );
142 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), 146 connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ),
143 SLOT( selectionChanged( QListViewItem* ) ) ); 147 SLOT( selectionChanged( QListViewItem* ) ) );
144 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), 148 connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ),
145 SLOT( itemClicked( QListViewItem* ) ) ); 149 SLOT( itemClicked( QListViewItem* ) ) );
146 connect( mConfigureButton, SIGNAL( clicked() ), 150 connect( mConfigureButton, SIGNAL( clicked() ),
147 SLOT( configureExtension() ) ); 151 SLOT( configureExtension() ) );
148 152
149 tabWidget->addTab( generalPage, i18n( "General" ) ); 153 tabWidget->addTab( generalPage, i18n( "General" ) );
150 154
151 // Addressee page 155 // Addressee page
152 mAddresseeWidget = new AddresseeWidget( this ); 156 mAddresseeWidget = new AddresseeWidget( this );
153 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); 157 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
154 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); 158 connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) );
155 159
156} 160}
157 161
158 162
159void KABConfigWidget::restoreSettings(KABPrefs* prefs) 163void KABConfigWidget::restoreSettings(KABPrefs* prefs)
160{ 164{
161//US prefs was KABPrefs::instance() before 165//US prefs was KABPrefs::instance() before
162 166
163 bool blocked = signalsBlocked(); 167 bool blocked = signalsBlocked();
164 blockSignals( true ); 168 blockSignals( true );
165 169
166 mNameParsing->setChecked( prefs->mAutomaticNameParsing ); 170 mNameParsing->setChecked( prefs->mAutomaticNameParsing );
167 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); 171 mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick );
172 mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce );
168 173
169 mAddresseeWidget->restoreSettings(); 174 mAddresseeWidget->restoreSettings();
170 175
171 restoreExtensionSettings(); 176 restoreExtensionSettings();
172 177
173 blockSignals( blocked ); 178 blockSignals( blocked );
174 179
175 emit changed( false ); 180 emit changed( false );
176} 181}
177 182
178void KABConfigWidget::saveSettings(KABPrefs* prefs) 183void KABConfigWidget::saveSettings(KABPrefs* prefs)
179{ 184{
180 prefs->mAutomaticNameParsing = mNameParsing->isChecked(); 185 prefs->mAutomaticNameParsing = mNameParsing->isChecked();
181 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); 186 prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked();
187 prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked();
182 188
183 mAddresseeWidget->saveSettings(); 189 mAddresseeWidget->saveSettings();
184 190
185 saveExtensionSettings(); 191 saveExtensionSettings();
186 KABPrefs::instance()->writeConfig(); 192 KABPrefs::instance()->writeConfig();
187 193
188 emit changed( false ); 194 emit changed( false );
189} 195}
190 196
191void KABConfigWidget::defaults(KABPrefs* prefs) 197void KABConfigWidget::defaults(KABPrefs* prefs)
192{ 198{
193 mNameParsing->setChecked( true ); 199 mNameParsing->setChecked( true );
194 mViewsSingleClickBox->setChecked( false ); 200 mViewsSingleClickBox->setChecked( false );
201 mMultipleViewsAtOnce->setChecked( true );
195 202
196 emit changed( true ); 203 emit changed( true );
197} 204}
198 205
199void KABConfigWidget::modified() 206void KABConfigWidget::modified()
200{ 207{
201 emit changed( true ); 208 emit changed( true );
202} 209}
203 210
204void KABConfigWidget::restoreExtensionSettings() 211void KABConfigWidget::restoreExtensionSettings()
205{ 212{
206 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; 213 QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions;
207 214
208 mExtensionView->clear(); 215 mExtensionView->clear();
209 216
210#ifndef KAB_EMBEDDED 217#ifndef KAB_EMBEDDED
211 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); 218 KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" );
212 KTrader::OfferList::ConstIterator it; 219 KTrader::OfferList::ConstIterator it;
213 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 220 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
214 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) 221 if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) )
215 continue; 222 continue;
216 223
217 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); 224 ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() );
218 item->setService( *it ); 225 item->setService( *it );
219 if ( activeExtensions.contains( item->factory()->identifier() ) ) 226 if ( activeExtensions.contains( item->factory()->identifier() ) )
220 item->setOn( true ); 227 item->setOn( true );
221 } 228 }
222#else //KAB_EMBEDDED 229#else //KAB_EMBEDDED
223 ExtensionFactory *extensionFactory = new MergeFactory(); 230 ExtensionFactory *extensionFactory = new MergeFactory();
224 231
225 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); 232 ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts");
226 233
227 item->setFactory( extensionFactory ); 234 item->setFactory( extensionFactory );
228 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 235 if ( activeExtensions.contains( extensionFactory->identifier() ) )
229 item->setOn( true ); 236 item->setOn( true );
230 237
231 238
232 239
233 extensionFactory = new DistributionListFactory(); 240 extensionFactory = new DistributionListFactory();
234 241
235 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); 242 item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists");
236 243
237 item->setFactory( extensionFactory ); 244 item->setFactory( extensionFactory );
238 if ( activeExtensions.contains( extensionFactory->identifier() ) ) 245 if ( activeExtensions.contains( extensionFactory->identifier() ) )
239 item->setOn( true ); 246 item->setOn( true );
240 247
241 248
242#endif //KAB_EMBEDDED 249#endif //KAB_EMBEDDED
243 250
244} 251}
245 252
246void KABConfigWidget::saveExtensionSettings() 253void KABConfigWidget::saveExtensionSettings()
247{ 254{
248 QStringList activeExtensions; 255 QStringList activeExtensions;
249 256
250 QPtrList<QListViewItem> list; 257 QPtrList<QListViewItem> list;
251 QListViewItemIterator it( mExtensionView ); 258 QListViewItemIterator it( mExtensionView );
252 while ( it.current() ) { 259 while ( it.current() ) {
253 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); 260 ExtensionItem *item = static_cast<ExtensionItem*>( it.current() );
254 if ( item ) { 261 if ( item ) {
255 if ( item->isOn() ) 262 if ( item->isOn() )
256 activeExtensions.append( item->factory()->identifier() ); 263 activeExtensions.append( item->factory()->identifier() );
257 } 264 }
258 ++it; 265 ++it;
259 } 266 }
260 267
261 KABPrefs::instance()->mActiveExtensions = activeExtensions; 268 KABPrefs::instance()->mActiveExtensions = activeExtensions;
262} 269}
263 270
264void KABConfigWidget::configureExtension() 271void KABConfigWidget::configureExtension()
265{ 272{
266 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); 273 ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() );
267 if ( !item ) 274 if ( !item )
268 return; 275 return;
269 276
270#ifndef KAB_EMBEDDED 277#ifndef KAB_EMBEDDED
271 KConfig config( "kaddressbookrc" ); 278 KConfig config( "kaddressbookrc" );
272#else //KAB_EMBEDDED 279#else //KAB_EMBEDDED
273 KConfig config( locateLocal("config", "kaddressbookrc") ); 280 KConfig config( locateLocal("config", "kaddressbookrc") );
274#endif //KAB_EMBEDDED 281#endif //KAB_EMBEDDED
275 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); 282 config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) );
276 283
277 ExtensionConfigDialog dlg( item->factory(), &config, this ); 284 ExtensionConfigDialog dlg( item->factory(), &config, this );
278 dlg.exec(); 285 dlg.exec();
279 286
280 config.sync(); 287 config.sync();
281} 288}
282 289
283void KABConfigWidget::selectionChanged( QListViewItem *i ) 290void KABConfigWidget::selectionChanged( QListViewItem *i )
284{ 291{
285 ExtensionItem *item = static_cast<ExtensionItem*>( i ); 292 ExtensionItem *item = static_cast<ExtensionItem*>( i );
286 if ( !item ) 293 if ( !item )
287 return; 294 return;
288 295
289 mConfigureButton->setEnabled( item->configWidgetAvailable() ); 296 mConfigureButton->setEnabled( item->configWidgetAvailable() );
290} 297}
291 298
292void KABConfigWidget::itemClicked( QListViewItem *item ) 299void KABConfigWidget::itemClicked( QListViewItem *item )
293{ 300{
294 if ( item != 0 ) 301 if ( item != 0 )
295 modified(); 302 modified();
296} 303}
297 304
298#ifndef KAB_EMBEDDED 305#ifndef KAB_EMBEDDED
299ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) 306ExtensionItem::ExtensionItem( QListView *parent, const QString &text )
300 : QCheckListItem( parent, text, CheckBox ) 307 : QCheckListItem( parent, text, CheckBox )
301{ 308{
302} 309}
303 310
304void ExtensionItem::setService( const KService::Ptr &ptr ) 311void ExtensionItem::setService( const KService::Ptr &ptr )
305{ 312{
306 mPtr = ptr; 313 mPtr = ptr;
307} 314}
308#else //KAB_EMBEDDED 315#else //KAB_EMBEDDED
309ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) 316ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment )
310 : QCheckListItem( parent, text, CheckBox ) 317 : QCheckListItem( parent, text, CheckBox )
311{ 318{
312 mName = name; 319 mName = name;
313 mComment = comment; 320 mComment = comment;
314} 321}
315 322
316 323
317void ExtensionItem::setFactory( ExtensionFactory* fac ) 324void ExtensionItem::setFactory( ExtensionFactory* fac )
318{ 325{
319 mFactory = fac; 326 mFactory = fac;
320} 327}
321#endif //KAB_EMBEDDED 328#endif //KAB_EMBEDDED
322 329
323bool ExtensionItem::configWidgetAvailable() const 330bool ExtensionItem::configWidgetAvailable() const
324{ 331{
325#ifndef KAB_EMBEDDED 332#ifndef KAB_EMBEDDED
326 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 333 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
327 if ( !factory ) 334 if ( !factory )
328 return false; 335 return false;
329 336
330 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); 337 ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory );
331 if ( !extensionFactory ) 338 if ( !extensionFactory )
332 return false; 339 return false;
333 340
334 return extensionFactory->configureWidgetAvailable(); 341 return extensionFactory->configureWidgetAvailable();
335#else //KAB_EMBEDDED 342#else //KAB_EMBEDDED
336 return mFactory->configureWidgetAvailable(); 343 return mFactory->configureWidgetAvailable();
337#endif //KAB_EMBEDDED 344#endif //KAB_EMBEDDED
338 345
339} 346}
340 347
341ExtensionFactory *ExtensionItem::factory() const 348ExtensionFactory *ExtensionItem::factory() const
342{ 349{
343#ifndef KAB_EMBEDDED 350#ifndef KAB_EMBEDDED
344 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); 351 KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() );
345 if ( !factory ) 352 if ( !factory )
346 return 0; 353 return 0;
347 354
348 return static_cast<ExtensionFactory*>( factory ); 355 return static_cast<ExtensionFactory*>( factory );
349#else //KAB_EMBEDDED 356#else //KAB_EMBEDDED
350 return mFactory; 357 return mFactory;
351#endif //KAB_EMBEDDED 358#endif //KAB_EMBEDDED
352} 359}
353 360
354QString ExtensionItem::text( int column ) const 361QString ExtensionItem::text( int column ) const
355{ 362{
356#ifndef KAB_EMBEDDED 363#ifndef KAB_EMBEDDED
357 if ( column == 0 ) 364 if ( column == 0 )
358 return mPtr->name(); 365 return mPtr->name();
359 else if ( column == 1 ) 366 else if ( column == 1 )
360 return mPtr->comment(); 367 return mPtr->comment();
361 else 368 else
362 return QString::null; 369 return QString::null;
363#else //KAB_EMBEDDED 370#else //KAB_EMBEDDED
364 if ( column == 0 ) 371 if ( column == 0 )
365 return mName; 372 return mName;
366 else if ( column == 1 ) 373 else if ( column == 1 )
367 return mComment; 374 return mComment;
368 else 375 else
369 return QString::null; 376 return QString::null;
370#endif //KAB_EMBEDDED 377#endif //KAB_EMBEDDED
371} 378}
372 379
373#ifndef KAB_EMBEDDED 380#ifndef KAB_EMBEDDED
374#include "kabconfigwidget.moc" 381#include "kabconfigwidget.moc"
375#endif //KAB_EMBEDDED 382#endif //KAB_EMBEDDED
376 383
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h
index 8c0c436..2928495 100644
--- a/kaddressbook/kcmconfigs/kabconfigwidget.h
+++ b/kaddressbook/kcmconfigs/kabconfigwidget.h
@@ -1,76 +1,78 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#ifndef KABCONFIGWIDGET_H 24#ifndef KABCONFIGWIDGET_H
25#define KABCONFIGWIDGET_H 25#define KABCONFIGWIDGET_H
26 26
27#include <qwidget.h> 27#include <qwidget.h>
28 28
29class QCheckBox; 29class QCheckBox;
30class QListViewItem; 30class QListViewItem;
31class QPushButton; 31class QPushButton;
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
69 QCheckBox *mNameParsing; 69 QCheckBox *mNameParsing;
70 QCheckBox *mViewsSingleClickBox; 70 QCheckBox *mViewsSingleClickBox;
71 QCheckBox *mMultipleViewsAtOnce;
72
71 QPushButton *mConfigureButton; 73 QPushButton *mConfigureButton;
72 74
73 AddresseeWidget *mAddresseeWidget; 75 AddresseeWidget *mAddresseeWidget;
74}; 76};
75 77
76#endif 78#endif