-rw-r--r-- | kaddressbook/kcmconfigs/addresseewidget.cpp | 236 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/addresseewidget.h | 87 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/extensionconfigdialog.cpp | 59 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/extensionconfigdialog.h | 48 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 357 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 72 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.cpp | 86 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.h | 53 |
8 files changed, 998 insertions, 0 deletions
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp new file mode 100644 index 0000000..0f3c353 --- a/dev/null +++ b/kaddressbook/kcmconfigs/addresseewidget.cpp | |||
@@ -0,0 +1,236 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qgroupbox.h> | ||
25 | #include <qlabel.h> | ||
26 | #include <qlayout.h> | ||
27 | #include <qlistbox.h> | ||
28 | #include <qpushbutton.h> | ||
29 | |||
30 | #include <kbuttonbox.h> | ||
31 | #include <kcombobox.h> | ||
32 | #include <kconfig.h> | ||
33 | #include <kdialog.h> | ||
34 | #include <klocale.h> | ||
35 | #include <kglobal.h> | ||
36 | #include <klineedit.h> | ||
37 | #include <kstandarddirs.h> | ||
38 | |||
39 | #include "addresseewidget.h" | ||
40 | |||
41 | NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, | ||
42 | const char *name ) | ||
43 | : QWidget( parent, name ) | ||
44 | { | ||
45 | if (KGlobal::getOrientation() == KGlobal::Portrait) | ||
46 | { | ||
47 | QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), | ||
48 | KDialog::spacingHintSmall() ); | ||
49 | |||
50 | QLabel *label = new QLabel( i18n( title ), this ); | ||
51 | layout->addWidget( label, 0, 1 ); | ||
52 | |||
53 | mBox = new QListBox( this ); | ||
54 | mBox->setMaximumSize(70, 70); | ||
55 | layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); | ||
56 | |||
57 | KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); | ||
58 | mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); | ||
59 | mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); | ||
60 | bbox->layout(); | ||
61 | layout->addMultiCellWidget( bbox, 0, 2, 2,2); | ||
62 | |||
63 | mEdit = new KLineEdit( this ); | ||
64 | layout->addWidget( mEdit, 1, 1 ); | ||
65 | //mEdit->setMinimumWidth(50); | ||
66 | |||
67 | // layout->addWidget( group ); | ||
68 | |||
69 | } | ||
70 | else | ||
71 | { | ||
72 | QHBoxLayout *layout = new QHBoxLayout( this ); | ||
73 | |||
74 | QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); | ||
75 | QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, | ||
76 | KDialog::spacingHint() ); | ||
77 | |||
78 | mBox = new QListBox( group ); | ||
79 | |||
80 | groupLayout->addWidget( mBox, 0, 0 ); | ||
81 | |||
82 | KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); | ||
83 | mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); | ||
84 | mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); | ||
85 | bbox->layout(); | ||
86 | groupLayout->addWidget( bbox, 0, 1 ); | ||
87 | |||
88 | mEdit = new KLineEdit( group ); | ||
89 | groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); | ||
90 | |||
91 | layout->addWidget( group ); | ||
92 | |||
93 | } | ||
94 | |||
95 | mAddButton->setEnabled( false ); | ||
96 | mRemoveButton->setEnabled( false ); | ||
97 | |||
98 | |||
99 | connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), | ||
100 | SLOT( selectionChanged( QListBoxItem* ) ) ); | ||
101 | connect( mEdit, SIGNAL( textChanged( const QString& ) ), | ||
102 | SLOT( textChanged( const QString& ) ) ); | ||
103 | connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); | ||
104 | |||
105 | } | ||
106 | |||
107 | NamePartWidget::~NamePartWidget() | ||
108 | { | ||
109 | } | ||
110 | |||
111 | void NamePartWidget::setNameParts( const QStringList &list ) | ||
112 | { | ||
113 | mBox->clear(); | ||
114 | mBox->insertStringList( list ); | ||
115 | } | ||
116 | |||
117 | QStringList NamePartWidget::nameParts() const | ||
118 | { | ||
119 | QStringList parts; | ||
120 | for ( uint i = 0; i < mBox->count(); ++i ) | ||
121 | parts.append( mBox->text( i ) ); | ||
122 | |||
123 | return parts; | ||
124 | } | ||
125 | |||
126 | void NamePartWidget::add() | ||
127 | { | ||
128 | if ( !mEdit->text().isEmpty() ) { | ||
129 | mBox->insertItem( mEdit->text() ); | ||
130 | emit modified(); | ||
131 | } | ||
132 | |||
133 | mEdit->setText( "" ); | ||
134 | } | ||
135 | |||
136 | void NamePartWidget::remove() | ||
137 | { | ||
138 | mBox->removeItem( mBox->currentItem() ); | ||
139 | if ( mBox->count() == 0 ) | ||
140 | selectionChanged( 0 ); | ||
141 | |||
142 | emit modified(); | ||
143 | } | ||
144 | |||
145 | void NamePartWidget::selectionChanged( QListBoxItem *item ) | ||
146 | { | ||
147 | mRemoveButton->setEnabled( item != 0 ); | ||
148 | } | ||
149 | |||
150 | void NamePartWidget::textChanged( const QString& text ) | ||
151 | { | ||
152 | mAddButton->setEnabled( !text.isEmpty() ); | ||
153 | } | ||
154 | |||
155 | |||
156 | AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) | ||
157 | : QWidget( parent, name ) | ||
158 | { | ||
159 | QGridLayout *layout; | ||
160 | |||
161 | mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); | ||
162 | mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); | ||
163 | mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); | ||
164 | QLabel *label = new QLabel( i18n( "Default formatted name:" ), this ); | ||
165 | |||
166 | mFormattedNameCombo = new KComboBox( this ); | ||
167 | mFormattedNameCombo->insertItem( i18n( "Empty" ) ); | ||
168 | mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); | ||
169 | mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); | ||
170 | mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); | ||
171 | |||
172 | if (KGlobal::getOrientation() == KGlobal::Portrait) | ||
173 | { | ||
174 | layout = new QGridLayout( this, 4, 2, KDialog::marginHint(), | ||
175 | KDialog::spacingHint() ); | ||
176 | |||
177 | layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); | ||
178 | layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); | ||
179 | layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); | ||
180 | layout->addWidget( label, 3, 0 ); | ||
181 | layout->addWidget( mFormattedNameCombo, 3, 1 ); | ||
182 | |||
183 | } | ||
184 | else | ||
185 | { | ||
186 | layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), | ||
187 | KDialog::spacingHint() ); | ||
188 | |||
189 | layout->addWidget( mPrefix, 0, 0 ); | ||
190 | layout->addWidget( mInclusion, 0, 1 ); | ||
191 | layout->addWidget( mSuffix, 0, 2 ); | ||
192 | layout->addWidget( label, 1, 0 ); | ||
193 | layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); | ||
194 | } | ||
195 | |||
196 | connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); | ||
197 | connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); | ||
198 | connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); | ||
199 | connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); | ||
200 | } | ||
201 | |||
202 | AddresseeWidget::~AddresseeWidget() | ||
203 | { | ||
204 | } | ||
205 | |||
206 | void AddresseeWidget::restoreSettings() | ||
207 | { | ||
208 | KConfig config( locateLocal("config", "kabcrc") ); | ||
209 | config.setGroup( "General" ); | ||
210 | |||
211 | mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); | ||
212 | mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); | ||
213 | mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); | ||
214 | |||
215 | KConfig cfg( locateLocal("config","kaddressbookrc") ); | ||
216 | cfg.setGroup( "General" ); | ||
217 | mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) ); | ||
218 | } | ||
219 | |||
220 | void AddresseeWidget::saveSettings() | ||
221 | { | ||
222 | KConfig config( locateLocal("config","kabcrc") ); | ||
223 | config.setGroup( "General" ); | ||
224 | |||
225 | config.writeEntry( "Prefixes", mPrefix->nameParts() ); | ||
226 | config.writeEntry( "Inclusions", mInclusion->nameParts() ); | ||
227 | config.writeEntry( "Suffixes", mSuffix->nameParts() ); | ||
228 | |||
229 | KConfig cfg( locateLocal("config","kaddressbookrc") ); | ||
230 | cfg.setGroup( "General" ); | ||
231 | cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() ); | ||
232 | } | ||
233 | |||
234 | #ifndef KAB_EMBEDDED | ||
235 | #include "addresseewidget.moc" | ||
236 | #endif //KAB_EMBEDDED | ||
diff --git a/kaddressbook/kcmconfigs/addresseewidget.h b/kaddressbook/kcmconfigs/addresseewidget.h new file mode 100644 index 0000000..09330c8 --- a/dev/null +++ b/kaddressbook/kcmconfigs/addresseewidget.h | |||
@@ -0,0 +1,87 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #ifndef ADDRESSEEWIDGET_H | ||
25 | #define ADDRESSEEWIDGET_H | ||
26 | |||
27 | #include <qwidget.h> | ||
28 | |||
29 | class KComboBox; | ||
30 | class KLineEdit; | ||
31 | |||
32 | class QListBox; | ||
33 | class QListBoxItem; | ||
34 | class QPushButton; | ||
35 | |||
36 | class NamePartWidget : public QWidget | ||
37 | { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | NamePartWidget( const QString &title, QWidget *parent, | ||
42 | const char *name = 0 ); | ||
43 | ~NamePartWidget(); | ||
44 | |||
45 | void setNameParts( const QStringList &list ); | ||
46 | QStringList nameParts() const; | ||
47 | |||
48 | signals: | ||
49 | void modified(); | ||
50 | |||
51 | private slots: | ||
52 | void add(); | ||
53 | void remove(); | ||
54 | |||
55 | void selectionChanged( QListBoxItem* ); | ||
56 | void textChanged( const QString& ); | ||
57 | |||
58 | private: | ||
59 | KLineEdit *mEdit; | ||
60 | |||
61 | QListBox *mBox; | ||
62 | QPushButton *mAddButton; | ||
63 | QPushButton *mRemoveButton; | ||
64 | }; | ||
65 | |||
66 | class AddresseeWidget : public QWidget | ||
67 | { | ||
68 | Q_OBJECT | ||
69 | |||
70 | public: | ||
71 | AddresseeWidget( QWidget *parent, const char *name = 0 ); | ||
72 | ~AddresseeWidget(); | ||
73 | |||
74 | void restoreSettings(); | ||
75 | void saveSettings(); | ||
76 | |||
77 | signals: | ||
78 | void modified(); | ||
79 | |||
80 | private: | ||
81 | KComboBox *mFormattedNameCombo; | ||
82 | NamePartWidget *mPrefix; | ||
83 | NamePartWidget *mInclusion; | ||
84 | NamePartWidget *mSuffix; | ||
85 | }; | ||
86 | |||
87 | #endif | ||
diff --git a/kaddressbook/kcmconfigs/extensionconfigdialog.cpp b/kaddressbook/kcmconfigs/extensionconfigdialog.cpp new file mode 100644 index 0000000..e87b000 --- a/dev/null +++ b/kaddressbook/kcmconfigs/extensionconfigdialog.cpp | |||
@@ -0,0 +1,59 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qlayout.h> | ||
25 | |||
26 | #include <klocale.h> | ||
27 | |||
28 | #include "configurewidget.h" | ||
29 | |||
30 | #include "extensionconfigdialog.h" | ||
31 | |||
32 | ExtensionConfigDialog::ExtensionConfigDialog( ExtensionFactory *factory, KConfig *config, | ||
33 | QWidget *parent, const char *name ) | ||
34 | : KDialogBase( Plain, i18n( "Extension Settings" ), Ok | Cancel, Ok, parent, | ||
35 | name, true, true ), mWidget( 0 ), mConfig( config ) | ||
36 | { | ||
37 | QFrame *page = plainPage(); | ||
38 | QGridLayout *layout = new QGridLayout( page, 1, 1, marginHint(), spacingHint() ); | ||
39 | |||
40 | mWidget = factory->configureWidget( page, "ExtensionConfigWidget" ); | ||
41 | layout->addWidget( mWidget, 0, 0 ); | ||
42 | |||
43 | mWidget->restoreSettings( mConfig ); | ||
44 | } | ||
45 | |||
46 | ExtensionConfigDialog::~ExtensionConfigDialog() | ||
47 | { | ||
48 | } | ||
49 | |||
50 | void ExtensionConfigDialog::slotOk() | ||
51 | { | ||
52 | mWidget->saveSettings( mConfig ); | ||
53 | |||
54 | KDialogBase::slotOk(); | ||
55 | } | ||
56 | |||
57 | #ifndef KAB_EMBEDDED | ||
58 | #include "extensionconfigdialog.moc" | ||
59 | #endif //KAB_EMBEDDED | ||
diff --git a/kaddressbook/kcmconfigs/extensionconfigdialog.h b/kaddressbook/kcmconfigs/extensionconfigdialog.h new file mode 100644 index 0000000..5a92034 --- a/dev/null +++ b/kaddressbook/kcmconfigs/extensionconfigdialog.h | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #ifndef EXTENSIONCONFIGDIALOG_H | ||
25 | #define EXTENSIONCONFIGDIALOG_H | ||
26 | |||
27 | #include <kdialogbase.h> | ||
28 | |||
29 | #include "extensionwidget.h" | ||
30 | |||
31 | class ExtensionConfigDialog : public KDialogBase | ||
32 | { | ||
33 | Q_OBJECT | ||
34 | |||
35 | public: | ||
36 | ExtensionConfigDialog( ExtensionFactory *factory, KConfig *config, | ||
37 | QWidget *parent, const char *name = 0 ); | ||
38 | ~ExtensionConfigDialog(); | ||
39 | |||
40 | protected slots: | ||
41 | void slotOk(); | ||
42 | |||
43 | private: | ||
44 | ConfigureWidget *mWidget; | ||
45 | KConfig *mConfig; | ||
46 | }; | ||
47 | |||
48 | #endif | ||
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp new file mode 100644 index 0000000..7b3e5c6 --- a/dev/null +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp | |||
@@ -0,0 +1,357 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qcheckbox.h> | ||
25 | #include <qframe.h> | ||
26 | #include <qgroupbox.h> | ||
27 | #include <qlayout.h> | ||
28 | #include <qpushbutton.h> | ||
29 | #include <qtabwidget.h> | ||
30 | |||
31 | #include <kconfig.h> | ||
32 | #include <kdebug.h> | ||
33 | #include <kdialog.h> | ||
34 | #include <klistview.h> | ||
35 | #include <klocale.h> | ||
36 | #include <kglobal.h> | ||
37 | #include <kmessagebox.h> | ||
38 | #include <kstandarddirs.h> | ||
39 | |||
40 | #ifndef KAB_EMBEDDED | ||
41 | #include <ktrader.h> | ||
42 | #else // KAB_EMBEDDED | ||
43 | #include <mergewidget.h> | ||
44 | #include <distributionlistwidget.h> | ||
45 | #endif // KAB_EMBEDDED | ||
46 | |||
47 | #include "addresseewidget.h" | ||
48 | #include "extensionconfigdialog.h" | ||
49 | #include "extensionwidget.h" | ||
50 | #include "kabprefs.h" | ||
51 | |||
52 | #include "kabconfigwidget.h" | ||
53 | |||
54 | class ExtensionItem : public QCheckListItem | ||
55 | { | ||
56 | public: | ||
57 | |||
58 | #ifndef KAB_EMBEDDED | ||
59 | ExtensionItem( QListView *parent, const QString &text ); | ||
60 | void setService( const KService::Ptr &ptr ); | ||
61 | #else //KAB_EMBEDDED | ||
62 | ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ); | ||
63 | void setFactory( ExtensionFactory* fac ); | ||
64 | #endif //KAB_EMBEDDED | ||
65 | |||
66 | bool configWidgetAvailable() const; | ||
67 | ExtensionFactory *factory() const; | ||
68 | |||
69 | virtual QString text( int column ) const; | ||
70 | |||
71 | private: | ||
72 | #ifndef KAB_EMBEDDED | ||
73 | KService::Ptr mPtr; | ||
74 | #else //KAB_EMBEDDED | ||
75 | ExtensionFactory* mFactory; | ||
76 | QString mName; | ||
77 | QString mComment; | ||
78 | |||
79 | #endif //KAB_EMBEDDED | ||
80 | |||
81 | }; | ||
82 | |||
83 | KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) | ||
84 | : QWidget( parent, name ) | ||
85 | { | ||
86 | QVBoxLayout *topLayout = new QVBoxLayout( this, 0, | ||
87 | KDialog::spacingHint() ); | ||
88 | |||
89 | QTabWidget *tabWidget = new QTabWidget( this ); | ||
90 | topLayout->addWidget( tabWidget ); | ||
91 | |||
92 | // General page | ||
93 | QWidget *generalPage = new QWidget( this ); | ||
94 | QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHint(), | ||
95 | KDialog::spacingHint() ); | ||
96 | |||
97 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); | ||
98 | QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); | ||
99 | boxLayout->setAlignment( Qt::AlignTop ); | ||
100 | |||
101 | mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); | ||
102 | boxLayout->addWidget( mViewsSingleClickBox ); | ||
103 | |||
104 | mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); | ||
105 | boxLayout->addWidget( mNameParsing ); | ||
106 | |||
107 | layout->addWidget( groupBox ); | ||
108 | |||
109 | groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); | ||
110 | boxLayout = new QVBoxLayout( groupBox->layout() ); | ||
111 | boxLayout->setAlignment( Qt::AlignTop ); | ||
112 | |||
113 | mExtensionView = new KListView( groupBox ); | ||
114 | mExtensionView->setAllColumnsShowFocus( true ); | ||
115 | mExtensionView->addColumn( i18n( "Name" ) ); | ||
116 | mExtensionView->addColumn( i18n( "Description" ) ); | ||
117 | mExtensionView->setMaximumHeight(80); | ||
118 | |||
119 | boxLayout->addWidget( mExtensionView ); | ||
120 | |||
121 | mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); | ||
122 | mConfigureButton->setEnabled( false ); | ||
123 | boxLayout->addWidget( mConfigureButton ); | ||
124 | |||
125 | layout->addWidget( groupBox ); | ||
126 | |||
127 | connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
128 | connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); | ||
129 | connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), | ||
130 | SLOT( selectionChanged( QListViewItem* ) ) ); | ||
131 | connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), | ||
132 | SLOT( itemClicked( QListViewItem* ) ) ); | ||
133 | connect( mConfigureButton, SIGNAL( clicked() ), | ||
134 | SLOT( configureExtension() ) ); | ||
135 | |||
136 | tabWidget->addTab( generalPage, i18n( "General" ) ); | ||
137 | |||
138 | // Addressee page | ||
139 | mAddresseeWidget = new AddresseeWidget( this ); | ||
140 | tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); | ||
141 | connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); | ||
142 | } | ||
143 | |||
144 | void KABConfigWidget::restoreSettings() | ||
145 | { | ||
146 | bool blocked = signalsBlocked(); | ||
147 | blockSignals( true ); | ||
148 | |||
149 | mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); | ||
150 | mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); | ||
151 | mAddresseeWidget->restoreSettings(); | ||
152 | |||
153 | restoreExtensionSettings(); | ||
154 | |||
155 | blockSignals( blocked ); | ||
156 | |||
157 | emit changed( false ); | ||
158 | } | ||
159 | |||
160 | void KABConfigWidget::saveSettings() | ||
161 | { | ||
162 | KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); | ||
163 | KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); | ||
164 | mAddresseeWidget->saveSettings(); | ||
165 | |||
166 | saveExtensionSettings(); | ||
167 | KABPrefs::instance()->writeConfig(); | ||
168 | |||
169 | emit changed( false ); | ||
170 | } | ||
171 | |||
172 | void KABConfigWidget::defaults() | ||
173 | { | ||
174 | mNameParsing->setChecked( true ); | ||
175 | mViewsSingleClickBox->setChecked( false ); | ||
176 | |||
177 | emit changed( true ); | ||
178 | } | ||
179 | |||
180 | void KABConfigWidget::modified() | ||
181 | { | ||
182 | emit changed( true ); | ||
183 | } | ||
184 | |||
185 | void KABConfigWidget::restoreExtensionSettings() | ||
186 | { | ||
187 | QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; | ||
188 | |||
189 | mExtensionView->clear(); | ||
190 | |||
191 | #ifndef KAB_EMBEDDED | ||
192 | KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); | ||
193 | KTrader::OfferList::ConstIterator it; | ||
194 | for ( it = plugins.begin(); it != plugins.end(); ++it ) { | ||
195 | if ( !(*it)->hasServiceType( "KAddressBook/Extension" ) ) | ||
196 | continue; | ||
197 | |||
198 | ExtensionItem *item = new ExtensionItem( mExtensionView, (*it)->name() ); | ||
199 | item->setService( *it ); | ||
200 | if ( activeExtensions.contains( item->factory()->identifier() ) ) | ||
201 | item->setOn( true ); | ||
202 | } | ||
203 | #else //KAB_EMBEDDED | ||
204 | ExtensionFactory *extensionFactory = new MergeFactory(); | ||
205 | |||
206 | ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); | ||
207 | |||
208 | item->setFactory( extensionFactory ); | ||
209 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | ||
210 | item->setOn( true ); | ||
211 | |||
212 | |||
213 | |||
214 | extensionFactory = new DistributionListFactory(); | ||
215 | |||
216 | item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); | ||
217 | |||
218 | item->setFactory( extensionFactory ); | ||
219 | if ( activeExtensions.contains( extensionFactory->identifier() ) ) | ||
220 | item->setOn( true ); | ||
221 | |||
222 | |||
223 | #endif //KAB_EMBEDDED | ||
224 | |||
225 | } | ||
226 | |||
227 | void KABConfigWidget::saveExtensionSettings() | ||
228 | { | ||
229 | QStringList activeExtensions; | ||
230 | |||
231 | QPtrList<QListViewItem> list; | ||
232 | QListViewItemIterator it( mExtensionView ); | ||
233 | while ( it.current() ) { | ||
234 | ExtensionItem *item = static_cast<ExtensionItem*>( it.current() ); | ||
235 | if ( item ) { | ||
236 | if ( item->isOn() ) | ||
237 | activeExtensions.append( item->factory()->identifier() ); | ||
238 | } | ||
239 | ++it; | ||
240 | } | ||
241 | |||
242 | KABPrefs::instance()->mActiveExtensions = activeExtensions; | ||
243 | } | ||
244 | |||
245 | void KABConfigWidget::configureExtension() | ||
246 | { | ||
247 | ExtensionItem *item = static_cast<ExtensionItem*>( mExtensionView->currentItem() ); | ||
248 | if ( !item ) | ||
249 | return; | ||
250 | |||
251 | #ifndef KAB_EMBEDDED | ||
252 | KConfig config( "kaddressbookrc" ); | ||
253 | #else //KAB_EMBEDDED | ||
254 | KConfig config( locateLocal("config", "kaddressbookrc") ); | ||
255 | #endif //KAB_EMBEDDED | ||
256 | config.setGroup( QString( "Extensions_%1" ).arg( item->factory()->identifier() ) ); | ||
257 | |||
258 | ExtensionConfigDialog dlg( item->factory(), &config, this ); | ||
259 | dlg.exec(); | ||
260 | |||
261 | config.sync(); | ||
262 | } | ||
263 | |||
264 | void KABConfigWidget::selectionChanged( QListViewItem *i ) | ||
265 | { | ||
266 | ExtensionItem *item = static_cast<ExtensionItem*>( i ); | ||
267 | if ( !item ) | ||
268 | return; | ||
269 | |||
270 | mConfigureButton->setEnabled( item->configWidgetAvailable() ); | ||
271 | } | ||
272 | |||
273 | void KABConfigWidget::itemClicked( QListViewItem *item ) | ||
274 | { | ||
275 | if ( item != 0 ) | ||
276 | modified(); | ||
277 | } | ||
278 | |||
279 | #ifndef KAB_EMBEDDED | ||
280 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text ) | ||
281 | : QCheckListItem( parent, text, CheckBox ) | ||
282 | { | ||
283 | } | ||
284 | |||
285 | void ExtensionItem::setService( const KService::Ptr &ptr ) | ||
286 | { | ||
287 | mPtr = ptr; | ||
288 | } | ||
289 | #else //KAB_EMBEDDED | ||
290 | ExtensionItem::ExtensionItem( QListView *parent, const QString &text, const QString &name, const QString &comment ) | ||
291 | : QCheckListItem( parent, text, CheckBox ) | ||
292 | { | ||
293 | mName = name; | ||
294 | mComment = comment; | ||
295 | } | ||
296 | |||
297 | |||
298 | void ExtensionItem::setFactory( ExtensionFactory* fac ) | ||
299 | { | ||
300 | mFactory = fac; | ||
301 | } | ||
302 | #endif //KAB_EMBEDDED | ||
303 | |||
304 | bool ExtensionItem::configWidgetAvailable() const | ||
305 | { | ||
306 | #ifndef KAB_EMBEDDED | ||
307 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | ||
308 | if ( !factory ) | ||
309 | return false; | ||
310 | |||
311 | ExtensionFactory *extensionFactory = static_cast<ExtensionFactory*>( factory ); | ||
312 | if ( !extensionFactory ) | ||
313 | return false; | ||
314 | |||
315 | return extensionFactory->configureWidgetAvailable(); | ||
316 | #else //KAB_EMBEDDED | ||
317 | return mFactory->configureWidgetAvailable(); | ||
318 | #endif //KAB_EMBEDDED | ||
319 | |||
320 | } | ||
321 | |||
322 | ExtensionFactory *ExtensionItem::factory() const | ||
323 | { | ||
324 | #ifndef KAB_EMBEDDED | ||
325 | KLibFactory *factory = KLibLoader::self()->factory( mPtr->library().latin1() ); | ||
326 | if ( !factory ) | ||
327 | return 0; | ||
328 | |||
329 | return static_cast<ExtensionFactory*>( factory ); | ||
330 | #else //KAB_EMBEDDED | ||
331 | return mFactory; | ||
332 | #endif //KAB_EMBEDDED | ||
333 | } | ||
334 | |||
335 | QString ExtensionItem::text( int column ) const | ||
336 | { | ||
337 | #ifndef KAB_EMBEDDED | ||
338 | if ( column == 0 ) | ||
339 | return mPtr->name(); | ||
340 | else if ( column == 1 ) | ||
341 | return mPtr->comment(); | ||
342 | else | ||
343 | return QString::null; | ||
344 | #else //KAB_EMBEDDED | ||
345 | if ( column == 0 ) | ||
346 | return mName; | ||
347 | else if ( column == 1 ) | ||
348 | return mComment; | ||
349 | else | ||
350 | return QString::null; | ||
351 | #endif //KAB_EMBEDDED | ||
352 | } | ||
353 | |||
354 | #ifndef KAB_EMBEDDED | ||
355 | #include "kabconfigwidget.moc" | ||
356 | #endif //KAB_EMBEDDED | ||
357 | |||
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h new file mode 100644 index 0000000..0f36d9e --- a/dev/null +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #ifndef KABCONFIGWIDGET_H | ||
25 | #define KABCONFIGWIDGET_H | ||
26 | |||
27 | #include <qwidget.h> | ||
28 | |||
29 | class QCheckBox; | ||
30 | class QListViewItem; | ||
31 | class QPushButton; | ||
32 | |||
33 | class KListView; | ||
34 | |||
35 | class AddresseeWidget; | ||
36 | |||
37 | class KABConfigWidget : public QWidget | ||
38 | { | ||
39 | Q_OBJECT | ||
40 | |||
41 | public: | ||
42 | KABConfigWidget( QWidget *parent, const char *name = 0 ); | ||
43 | |||
44 | void restoreSettings(); | ||
45 | void saveSettings(); | ||
46 | void defaults(); | ||
47 | |||
48 | signals: | ||
49 | void changed( bool ); | ||
50 | |||
51 | public slots: | ||
52 | void modified(); | ||
53 | |||
54 | private slots: | ||
55 | void configureExtension(); | ||
56 | void selectionChanged( QListViewItem* ); | ||
57 | void itemClicked( QListViewItem* ); | ||
58 | |||
59 | private: | ||
60 | void restoreExtensionSettings(); | ||
61 | void saveExtensionSettings(); | ||
62 | |||
63 | KListView *mExtensionView; | ||
64 | |||
65 | QCheckBox *mNameParsing; | ||
66 | QCheckBox *mViewsSingleClickBox; | ||
67 | QPushButton *mConfigureButton; | ||
68 | |||
69 | AddresseeWidget *mAddresseeWidget; | ||
70 | }; | ||
71 | |||
72 | #endif | ||
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp new file mode 100644 index 0000000..791a940 --- a/dev/null +++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qlayout.h> | ||
25 | |||
26 | #ifndef KAB_EMBEDDED | ||
27 | #include <kaboutdata.h> | ||
28 | #endif //KAB_EMBEDDED | ||
29 | #include <kdebug.h> | ||
30 | #include <klocale.h> | ||
31 | |||
32 | #include "kabconfigwidget.h" | ||
33 | |||
34 | #include "kcmkabconfig.h" | ||
35 | |||
36 | extern "C" | ||
37 | { | ||
38 | KCModule *create_kabconfig( QWidget *parent, const char * ) { | ||
39 | return new KCMKabConfig( parent, "kcmkabconfig" ); | ||
40 | } | ||
41 | } | ||
42 | |||
43 | KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) | ||
44 | : KCModule( parent, name ) | ||
45 | { | ||
46 | QVBoxLayout *layout = new QVBoxLayout( this ); | ||
47 | mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); | ||
48 | layout->addWidget( mConfigWidget ); | ||
49 | |||
50 | connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); | ||
51 | load(); | ||
52 | } | ||
53 | |||
54 | void KCMKabConfig::load() | ||
55 | { | ||
56 | mConfigWidget->restoreSettings(); | ||
57 | } | ||
58 | |||
59 | void KCMKabConfig::save() | ||
60 | { | ||
61 | mConfigWidget->saveSettings(); | ||
62 | } | ||
63 | |||
64 | void KCMKabConfig::defaults() | ||
65 | { | ||
66 | mConfigWidget->defaults(); | ||
67 | } | ||
68 | |||
69 | #ifndef KAB_EMBEDDED | ||
70 | const KAboutData* KCMKabConfig::aboutData() const | ||
71 | { | ||
72 | KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), | ||
73 | I18N_NOOP( "KAddressBook Configure Dialog" ), | ||
74 | 0, 0, KAboutData::License_GPL, | ||
75 | I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); | ||
76 | |||
77 | about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); | ||
78 | |||
79 | return about; | ||
80 | |||
81 | } | ||
82 | #endif //KAB_EMBEDDED | ||
83 | |||
84 | #ifndef KAB_EMBEDDED | ||
85 | #include "kcmkabconfig.moc" | ||
86 | #endif //KAB_EMBEDDED | ||
diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.h b/kaddressbook/kcmconfigs/kcmkabconfig.h new file mode 100644 index 0000000..be345b8 --- a/dev/null +++ b/kaddressbook/kcmconfigs/kcmkabconfig.h | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | This file is part of KAddressBook. | ||
3 | Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> | ||
4 | |||
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 | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #ifndef KCMKABCONFIG_H | ||
25 | #define KCMKABCONFIG_H | ||
26 | |||
27 | #include <kcmodule.h> | ||
28 | |||
29 | class KABConfigWidget; | ||
30 | |||
31 | #ifndef KAB_EMBEDDED | ||
32 | class KAboutData; | ||
33 | #endif //KAB_EMBEDDED | ||
34 | |||
35 | class KCMKabConfig : public KCModule | ||
36 | { | ||
37 | Q_OBJECT | ||
38 | |||
39 | public: | ||
40 | KCMKabConfig( QWidget *parent = 0, const char *name = 0 ); | ||
41 | |||
42 | virtual void load(); | ||
43 | virtual void save(); | ||
44 | virtual void defaults(); | ||
45 | #ifndef KAB_EMBEDDED | ||
46 | virtual const KAboutData* aboutData() const; | ||
47 | #endif //KAB_EMBEDDED | ||
48 | |||
49 | private: | ||
50 | KABConfigWidget *mConfigWidget; | ||
51 | }; | ||
52 | |||
53 | #endif | ||