summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kcmconfigs
Unidiff
Diffstat (limited to 'kaddressbook/kcmconfigs') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index eb5bdd9..168d39e 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,243 +1,238 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qgroupbox.h> 24#include <qgroupbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlistbox.h> 27#include <qlistbox.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <kbuttonbox.h> 31#include <kbuttonbox.h>
32#include <kcombobox.h> 32#include <kcombobox.h>
33#include <kconfig.h> 33#include <kconfig.h>
34#include <kdialog.h> 34#include <kdialog.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <klineedit.h> 37#include <klineedit.h>
38#include <kstandarddirs.h> 38#include <kstandarddirs.h>
39 39
40#include "addresseewidget.h" 40#include "addresseewidget.h"
41 41
42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
43 const char *name ) 43 const char *name )
44 : QWidget( parent, name ) 44 : QWidget( parent, name )
45{ 45{
46 if (KGlobal::getOrientation() == KGlobal::Portrait) 46 if (KGlobal::getOrientation() == KGlobal::Portrait)
47 { 47 {
48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(),
49 KDialog::spacingHintSmall() ); 49 KDialog::spacingHintSmall() );
50 50
51 QLabel *label = new QLabel( i18n( title ), this ); 51 QLabel *label = new QLabel( i18n( title ), this );
52 layout->addWidget( label, 0, 1 ); 52 layout->addWidget( label, 0, 1 );
53 53
54 mBox = new QListBox( this ); 54 mBox = new QListBox( this );
55 mBox->setMaximumSize(70, 70); 55 mBox->setMaximumSize(70, 70);
56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
57 57
58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
61 bbox->layout(); 61 bbox->layout();
62 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 62 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
63 63
64 mEdit = new KLineEdit( this ); 64 mEdit = new KLineEdit( this );
65 layout->addWidget( mEdit, 1, 1 ); 65 layout->addWidget( mEdit, 1, 1 );
66 //mEdit->setMinimumWidth(50); 66 //mEdit->setMinimumWidth(50);
67 67
68// layout->addWidget( group ); 68// layout->addWidget( group );
69 69
70 } 70 }
71 else 71 else
72 { 72 {
73 QHBoxLayout *layout = new QHBoxLayout( this ); 73 QHBoxLayout *layout = new QHBoxLayout( this );
74 74
75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this );
76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2,
77 KDialog::spacingHint() ); 77 KDialog::spacingHint() );
78 78
79 mBox = new QListBox( group ); 79 mBox = new QListBox( group );
80 80
81 groupLayout->addWidget( mBox, 0, 0 ); 81 groupLayout->addWidget( mBox, 0, 0 );
82 82
83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
86 bbox->layout(); 86 bbox->layout();
87 groupLayout->addWidget( bbox, 0, 1 ); 87 groupLayout->addWidget( bbox, 0, 1 );
88 88
89 mEdit = new KLineEdit( group ); 89 mEdit = new KLineEdit( group );
90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
91 91
92 layout->addWidget( group ); 92 layout->addWidget( group );
93 93
94 } 94 }
95 95
96 mAddButton->setEnabled( false ); 96 mAddButton->setEnabled( false );
97 mRemoveButton->setEnabled( false ); 97 mRemoveButton->setEnabled( false );
98 98
99 99
100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ),
101 SLOT( selectionChanged( QListBoxItem* ) ) ); 101 SLOT( selectionChanged( QListBoxItem* ) ) );
102 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 102 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
103 SLOT( textChanged( const QString& ) ) ); 103 SLOT( textChanged( const QString& ) ) );
104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
105 105
106} 106}
107 107
108NamePartWidget::~NamePartWidget() 108NamePartWidget::~NamePartWidget()
109{ 109{
110} 110}
111 111
112void NamePartWidget::setNameParts( const QStringList &list ) 112void NamePartWidget::setNameParts( const QStringList &list )
113{ 113{
114 mBox->clear(); 114 mBox->clear();
115 mBox->insertStringList( list ); 115 mBox->insertStringList( list );
116} 116}
117 117
118QStringList NamePartWidget::nameParts() const 118QStringList NamePartWidget::nameParts() const
119{ 119{
120 QStringList parts; 120 QStringList parts;
121 for ( uint i = 0; i < mBox->count(); ++i ) 121 for ( uint i = 0; i < mBox->count(); ++i )
122 parts.append( mBox->text( i ) ); 122 parts.append( mBox->text( i ) );
123 123
124 return parts; 124 return parts;
125} 125}
126 126
127void NamePartWidget::add() 127void NamePartWidget::add()
128{ 128{
129 if ( !mEdit->text().isEmpty() ) { 129 if ( !mEdit->text().isEmpty() ) {
130 mBox->insertItem( mEdit->text() ); 130 mBox->insertItem( mEdit->text() );
131 emit modified(); 131 emit modified();
132 } 132 }
133 133
134 mEdit->setText( "" ); 134 mEdit->setText( "" );
135} 135}
136 136
137void NamePartWidget::remove() 137void NamePartWidget::remove()
138{ 138{
139 mBox->removeItem( mBox->currentItem() ); 139 mBox->removeItem( mBox->currentItem() );
140 if ( mBox->count() == 0 ) 140 if ( mBox->count() == 0 )
141 selectionChanged( 0 ); 141 selectionChanged( 0 );
142 142
143 emit modified(); 143 emit modified();
144} 144}
145 145
146void NamePartWidget::selectionChanged( QListBoxItem *item ) 146void NamePartWidget::selectionChanged( QListBoxItem *item )
147{ 147{
148 mRemoveButton->setEnabled( item != 0 ); 148 mRemoveButton->setEnabled( item != 0 );
149} 149}
150 150
151void NamePartWidget::textChanged( const QString& text ) 151void NamePartWidget::textChanged( const QString& text )
152{ 152{
153 mAddButton->setEnabled( !text.isEmpty() ); 153 mAddButton->setEnabled( !text.isEmpty() );
154} 154}
155 155
156 156
157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
158 : QWidget( parent, name ) 158 : QWidget( parent, name )
159{ 159{
160 QGridLayout *layout; 160 QGridLayout *layout;
161 161
162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
165 QString dfn; 165 QString dfn;
166 if (QApplication::desktop()->width() > 320 ) 166 if (QApplication::desktop()->width() > 320 )
167 dfn = i18n( "Default formatted name:" ); 167 dfn = i18n( "Default formatted name:" );
168 else 168 else
169 dfn = i18n( "Def. formatted name:" ); 169 dfn = i18n( "Def. formatted name:" );
170 170
171 QLabel *label = new QLabel( dfn, this ); 171 QLabel *label = new QLabel( dfn, this );
172 172
173 mFormattedNameCombo = new KComboBox( this ); 173 mFormattedNameCombo = new KComboBox( this );
174 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 174 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
178 178
179 if (KGlobal::getOrientation() == KGlobal::Portrait) 179 if (KGlobal::getOrientation() == KGlobal::Portrait)
180 { 180 {
181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(),
182 KDialog::spacingHintSmall() ); 182 KDialog::spacingHintSmall() );
183 183
184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
187 layout->addWidget( label, 3, 0 ); 187 layout->addWidget( label, 3, 0 );
188 layout->addWidget( mFormattedNameCombo, 3, 1 ); 188 layout->addWidget( mFormattedNameCombo, 3, 1 );
189 189
190 } 190 }
191 else 191 else
192 { 192 {
193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
194 KDialog::spacingHint() ); 194 KDialog::spacingHint() );
195 195
196 layout->addWidget( mPrefix, 0, 0 ); 196 layout->addWidget( mPrefix, 0, 0 );
197 layout->addWidget( mInclusion, 0, 1 ); 197 layout->addWidget( mInclusion, 0, 1 );
198 layout->addWidget( mSuffix, 0, 2 ); 198 layout->addWidget( mSuffix, 0, 2 );
199 layout->addWidget( label, 1, 0 ); 199 layout->addWidget( label, 1, 0 );
200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
201 } 201 }
202 202
203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
207} 207}
208 208
209AddresseeWidget::~AddresseeWidget() 209AddresseeWidget::~AddresseeWidget()
210{ 210{
211} 211}
212 212
213void AddresseeWidget::restoreSettings() 213void AddresseeWidget::restoreSettings()
214{ 214{
215 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
216 config.setGroup( "General" ); 216 config.setGroup( "General" );
217 217
218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
221 221 mFormattedNameCombo->setCurrentItem( config.readNumEntry( "FormattedNameType", 1 ) );
222 KConfig cfg( locateLocal("config","kaddressbookrc") );
223 cfg.setGroup( "General" );
224 mFormattedNameCombo->setCurrentItem( cfg.readNumEntry( "FormattedNameType", 1 ) );
225} 222}
226 223
227void AddresseeWidget::saveSettings() 224void AddresseeWidget::saveSettings()
228{ 225{
226 qDebug("AddresseeWidget::saveSettings() ");
229 KConfig config( locateLocal("config","kabcrc") ); 227 KConfig config( locateLocal("config","kabcrc") );
230 config.setGroup( "General" ); 228 config.setGroup( "General" );
231 229
232 config.writeEntry( "Prefixes", mPrefix->nameParts() ); 230 config.writeEntry( "Prefixes", mPrefix->nameParts() );
233 config.writeEntry( "Inclusions", mInclusion->nameParts() ); 231 config.writeEntry( "Inclusions", mInclusion->nameParts() );
234 config.writeEntry( "Suffixes", mSuffix->nameParts() ); 232 config.writeEntry( "Suffixes", mSuffix->nameParts() );
235 233 config.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
236 KConfig cfg( locateLocal("config","kaddressbookrc") );
237 cfg.setGroup( "General" );
238 cfg.writeEntry( "FormattedNameType", mFormattedNameCombo->currentItem() );
239} 234}
240 235
241#ifndef KAB_EMBEDDED 236#ifndef KAB_EMBEDDED
242#include "addresseewidget.moc" 237#include "addresseewidget.moc"
243#endif //KAB_EMBEDDED 238#endif //KAB_EMBEDDED