summaryrefslogtreecommitdiffabout
path: root/kaddressbook/kcmconfigs
Unidiff
Diffstat (limited to 'kaddressbook/kcmconfigs') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/kcmconfigs/addresseewidget.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kaddressbook/kcmconfigs/addresseewidget.cpp b/kaddressbook/kcmconfigs/addresseewidget.cpp
index f84b2ba..eb5bdd9 100644
--- a/kaddressbook/kcmconfigs/addresseewidget.cpp
+++ b/kaddressbook/kcmconfigs/addresseewidget.cpp
@@ -1,220 +1,221 @@
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 30
30#include <kbuttonbox.h> 31#include <kbuttonbox.h>
31#include <kcombobox.h> 32#include <kcombobox.h>
32#include <kconfig.h> 33#include <kconfig.h>
33#include <kdialog.h> 34#include <kdialog.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kglobal.h> 36#include <kglobal.h>
36#include <klineedit.h> 37#include <klineedit.h>
37#include <kstandarddirs.h> 38#include <kstandarddirs.h>
38 39
39#include "addresseewidget.h" 40#include "addresseewidget.h"
40 41
41NamePartWidget::NamePartWidget( const QString &title, QWidget *parent, 42NamePartWidget::NamePartWidget( const QString &title, QWidget *parent,
42 const char *name ) 43 const char *name )
43 : QWidget( parent, name ) 44 : QWidget( parent, name )
44{ 45{
45 if (KGlobal::getOrientation() == KGlobal::Portrait) 46 if (KGlobal::getOrientation() == KGlobal::Portrait)
46 { 47 {
47 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(), 48 QGridLayout* layout = new QGridLayout( this, 1, 1, KDialog::marginHintSmall(),
48 KDialog::spacingHintSmall() ); 49 KDialog::spacingHintSmall() );
49 50
50 QLabel *label = new QLabel( i18n( title ), this ); 51 QLabel *label = new QLabel( i18n( title ), this );
51 layout->addWidget( label, 0, 1 ); 52 layout->addWidget( label, 0, 1 );
52 53
53 mBox = new QListBox( this ); 54 mBox = new QListBox( this );
54 mBox->setMaximumSize(70, 70); 55 mBox->setMaximumSize(70, 70);
55 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 ); 56 layout->addMultiCellWidget( mBox, 0, 1, 0, 0 );
56 57
57 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical ); 58 KButtonBox *bbox = new KButtonBox( this, Qt::Vertical );
58 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 59 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
59 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) ); 60 mRemoveButton = bbox->addButton( i18n( "Rem" ), this, SLOT( remove() ) );
60 bbox->layout(); 61 bbox->layout();
61 layout->addMultiCellWidget( bbox, 0, 1, 2,2); 62 layout->addMultiCellWidget( bbox, 0, 1, 2,2);
62 63
63 mEdit = new KLineEdit( this ); 64 mEdit = new KLineEdit( this );
64 layout->addWidget( mEdit, 1, 1 ); 65 layout->addWidget( mEdit, 1, 1 );
65 //mEdit->setMinimumWidth(50); 66 //mEdit->setMinimumWidth(50);
66 67
67// layout->addWidget( group ); 68// layout->addWidget( group );
68 69
69 } 70 }
70 else 71 else
71 { 72 {
72 QHBoxLayout *layout = new QHBoxLayout( this ); 73 QHBoxLayout *layout = new QHBoxLayout( this );
73 74
74 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this ); 75 QGroupBox *group = new QGroupBox( 0, Qt::Vertical, title, this );
75 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2, 76 QGridLayout *groupLayout = new QGridLayout( group->layout(), 2, 2,
76 KDialog::spacingHint() ); 77 KDialog::spacingHint() );
77 78
78 mBox = new QListBox( group ); 79 mBox = new QListBox( group );
79 80
80 groupLayout->addWidget( mBox, 0, 0 ); 81 groupLayout->addWidget( mBox, 0, 0 );
81 82
82 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical ); 83 KButtonBox *bbox = new KButtonBox( group, Qt::Vertical );
83 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) ); 84 mAddButton = bbox->addButton( i18n( "Add" ), this, SLOT( add() ) );
84 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) ); 85 mRemoveButton = bbox->addButton( i18n( "Remove" ), this, SLOT( remove() ) );
85 bbox->layout(); 86 bbox->layout();
86 groupLayout->addWidget( bbox, 0, 1 ); 87 groupLayout->addWidget( bbox, 0, 1 );
87 88
88 mEdit = new KLineEdit( group ); 89 mEdit = new KLineEdit( group );
89 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 ); 90 groupLayout->addMultiCellWidget( mEdit, 1, 1, 0, 1 );
90 91
91 layout->addWidget( group ); 92 layout->addWidget( group );
92 93
93 } 94 }
94 95
95 mAddButton->setEnabled( false ); 96 mAddButton->setEnabled( false );
96 mRemoveButton->setEnabled( false ); 97 mRemoveButton->setEnabled( false );
97 98
98 99
99 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ), 100 connect( mBox, SIGNAL( selectionChanged( QListBoxItem* ) ),
100 SLOT( selectionChanged( QListBoxItem* ) ) ); 101 SLOT( selectionChanged( QListBoxItem* ) ) );
101 connect( mEdit, SIGNAL( textChanged( const QString& ) ), 102 connect( mEdit, SIGNAL( textChanged( const QString& ) ),
102 SLOT( textChanged( const QString& ) ) ); 103 SLOT( textChanged( const QString& ) ) );
103 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) ); 104 connect( mEdit, SIGNAL( returnPressed() ), SLOT( add() ) );
104 105
105} 106}
106 107
107NamePartWidget::~NamePartWidget() 108NamePartWidget::~NamePartWidget()
108{ 109{
109} 110}
110 111
111void NamePartWidget::setNameParts( const QStringList &list ) 112void NamePartWidget::setNameParts( const QStringList &list )
112{ 113{
113 mBox->clear(); 114 mBox->clear();
114 mBox->insertStringList( list ); 115 mBox->insertStringList( list );
115} 116}
116 117
117QStringList NamePartWidget::nameParts() const 118QStringList NamePartWidget::nameParts() const
118{ 119{
119 QStringList parts; 120 QStringList parts;
120 for ( uint i = 0; i < mBox->count(); ++i ) 121 for ( uint i = 0; i < mBox->count(); ++i )
121 parts.append( mBox->text( i ) ); 122 parts.append( mBox->text( i ) );
122 123
123 return parts; 124 return parts;
124} 125}
125 126
126void NamePartWidget::add() 127void NamePartWidget::add()
127{ 128{
128 if ( !mEdit->text().isEmpty() ) { 129 if ( !mEdit->text().isEmpty() ) {
129 mBox->insertItem( mEdit->text() ); 130 mBox->insertItem( mEdit->text() );
130 emit modified(); 131 emit modified();
131 } 132 }
132 133
133 mEdit->setText( "" ); 134 mEdit->setText( "" );
134} 135}
135 136
136void NamePartWidget::remove() 137void NamePartWidget::remove()
137{ 138{
138 mBox->removeItem( mBox->currentItem() ); 139 mBox->removeItem( mBox->currentItem() );
139 if ( mBox->count() == 0 ) 140 if ( mBox->count() == 0 )
140 selectionChanged( 0 ); 141 selectionChanged( 0 );
141 142
142 emit modified(); 143 emit modified();
143} 144}
144 145
145void NamePartWidget::selectionChanged( QListBoxItem *item ) 146void NamePartWidget::selectionChanged( QListBoxItem *item )
146{ 147{
147 mRemoveButton->setEnabled( item != 0 ); 148 mRemoveButton->setEnabled( item != 0 );
148} 149}
149 150
150void NamePartWidget::textChanged( const QString& text ) 151void NamePartWidget::textChanged( const QString& text )
151{ 152{
152 mAddButton->setEnabled( !text.isEmpty() ); 153 mAddButton->setEnabled( !text.isEmpty() );
153} 154}
154 155
155 156
156AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name ) 157AddresseeWidget::AddresseeWidget( QWidget *parent, const char *name )
157 : QWidget( parent, name ) 158 : QWidget( parent, name )
158{ 159{
159 QGridLayout *layout; 160 QGridLayout *layout;
160 161
161 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this ); 162 mPrefix = new NamePartWidget( i18n( "Prefixes" ), this );
162 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this ); 163 mInclusion = new NamePartWidget( i18n( "Inclusions" ), this );
163 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this ); 164 mSuffix = new NamePartWidget( i18n( "Suffixes" ), this );
164 QString dfn; 165 QString dfn;
165 if (QApplication::desktop()->width() > 320 ) 166 if (QApplication::desktop()->width() > 320 )
166 dfn = i18n( "Default formatted name:" ); 167 dfn = i18n( "Default formatted name:" );
167 else 168 else
168 dfn = i18n( "Def. formatted name:" ); 169 dfn = i18n( "Def. formatted name:" );
169 170
170 QLabel *label = new QLabel( dfn, this ); 171 QLabel *label = new QLabel( dfn, this );
171 172
172 mFormattedNameCombo = new KComboBox( this ); 173 mFormattedNameCombo = new KComboBox( this );
173 mFormattedNameCombo->insertItem( i18n( "Empty" ) ); 174 mFormattedNameCombo->insertItem( i18n( "Empty" ) );
174 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) ); 175 mFormattedNameCombo->insertItem( i18n( "Simple Name" ) );
175 mFormattedNameCombo->insertItem( i18n( "Full Name" ) ); 176 mFormattedNameCombo->insertItem( i18n( "Full Name" ) );
176 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) ); 177 mFormattedNameCombo->insertItem( i18n( "Reverse Name" ) );
177 178
178 if (KGlobal::getOrientation() == KGlobal::Portrait) 179 if (KGlobal::getOrientation() == KGlobal::Portrait)
179 { 180 {
180 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(), 181 layout = new QGridLayout( this, 4, 2, KDialog::marginHintSmall(),
181 KDialog::spacingHintSmall() ); 182 KDialog::spacingHintSmall() );
182 183
183 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 ); 184 layout->addMultiCellWidget( mPrefix, 0, 0, 0, 1 );
184 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 ); 185 layout->addMultiCellWidget( mInclusion, 1, 1, 0, 1 );
185 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 ); 186 layout->addMultiCellWidget( mSuffix, 2, 2, 0, 1 );
186 layout->addWidget( label, 3, 0 ); 187 layout->addWidget( label, 3, 0 );
187 layout->addWidget( mFormattedNameCombo, 3, 1 ); 188 layout->addWidget( mFormattedNameCombo, 3, 1 );
188 189
189 } 190 }
190 else 191 else
191 { 192 {
192 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(), 193 layout = new QGridLayout( this, 2, 3, KDialog::marginHint(),
193 KDialog::spacingHint() ); 194 KDialog::spacingHint() );
194 195
195 layout->addWidget( mPrefix, 0, 0 ); 196 layout->addWidget( mPrefix, 0, 0 );
196 layout->addWidget( mInclusion, 0, 1 ); 197 layout->addWidget( mInclusion, 0, 1 );
197 layout->addWidget( mSuffix, 0, 2 ); 198 layout->addWidget( mSuffix, 0, 2 );
198 layout->addWidget( label, 1, 0 ); 199 layout->addWidget( label, 1, 0 );
199 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 ); 200 layout->addMultiCellWidget( mFormattedNameCombo, 1, 1, 1, 2 );
200 } 201 }
201 202
202 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) ); 203 connect( mPrefix, SIGNAL( modified() ), SIGNAL( modified() ) );
203 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) ); 204 connect( mInclusion, SIGNAL( modified() ), SIGNAL( modified() ) );
204 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) ); 205 connect( mSuffix, SIGNAL( modified() ), SIGNAL( modified() ) );
205 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) ); 206 connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SIGNAL( modified() ) );
206} 207}
207 208
208AddresseeWidget::~AddresseeWidget() 209AddresseeWidget::~AddresseeWidget()
209{ 210{
210} 211}
211 212
212void AddresseeWidget::restoreSettings() 213void AddresseeWidget::restoreSettings()
213{ 214{
214 KConfig config( locateLocal("config", "kabcrc") ); 215 KConfig config( locateLocal("config", "kabcrc") );
215 config.setGroup( "General" ); 216 config.setGroup( "General" );
216 217
217 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) ); 218 mPrefix->setNameParts( config.readListEntry( "Prefixes" ) );
218 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) ); 219 mInclusion->setNameParts( config.readListEntry( "Inclusions" ) );
219 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) ); 220 mSuffix->setNameParts( config.readListEntry( "Suffixes" ) );
220 221