summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/distributionlisteditor.cpp4
-rw-r--r--kaddressbook/tr.h2
-rw-r--r--korganizer/tr.h2
3 files changed, 8 insertions, 0 deletions
diff --git a/kabc/distributionlisteditor.cpp b/kabc/distributionlisteditor.cpp
index bad1efc..9f5840b 100644
--- a/kabc/distributionlisteditor.cpp
+++ b/kabc/distributionlisteditor.cpp
@@ -1,318 +1,322 @@
1/* 1/*
2 This file is part of libkabc. 2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library 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 GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qlistview.h> 21#include <qlistview.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qpushbutton.h> 23#include <qpushbutton.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#ifdef DESKTOP_VERSION
25#include <qinputdialog.h> 26#include <qinputdialog.h>
27#else
28#include <qtcompat/qinputdialog.h>
29#endif
26#include <qbuttongroup.h> 30#include <qbuttongroup.h>
27#include <qradiobutton.h> 31#include <qradiobutton.h>
28 32
29#include <klocale.h> 33#include <klocale.h>
30#include <kdebug.h> 34#include <kdebug.h>
31 35
32#include "addressbook.h" 36#include "addressbook.h"
33#include "addresseedialog.h" 37#include "addresseedialog.h"
34#include "distributionlist.h" 38#include "distributionlist.h"
35 39
36#include "distributionlisteditor.h" 40#include "distributionlisteditor.h"
37 41
38//US #include "distributionlisteditor.moc" 42//US #include "distributionlisteditor.moc"
39 43
40using namespace KABC; 44using namespace KABC;
41 45
42EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString &current, 46EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString &current,
43 QWidget *parent ) : 47 QWidget *parent ) :
44 KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, 48 KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok,
45 parent ) 49 parent )
46{ 50{
47 QFrame *topFrame = plainPage(); 51 QFrame *topFrame = plainPage();
48 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 52 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
49 53
50 mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), 54 mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"),
51 topFrame ); 55 topFrame );
52 topLayout->addWidget( mButtonGroup ); 56 topLayout->addWidget( mButtonGroup );
53 57
54 QStringList::ConstIterator it; 58 QStringList::ConstIterator it;
55 for( it = emails.begin(); it != emails.end(); ++it ) { 59 for( it = emails.begin(); it != emails.end(); ++it ) {
56 QRadioButton *button = new QRadioButton( *it, mButtonGroup ); 60 QRadioButton *button = new QRadioButton( *it, mButtonGroup );
57 if ( (*it) == current ) { 61 if ( (*it) == current ) {
58 button->setDown( true ); 62 button->setDown( true );
59 } 63 }
60 } 64 }
61} 65}
62 66
63QString EmailSelectDialog::selected() 67QString EmailSelectDialog::selected()
64{ 68{
65 QButton *button = mButtonGroup->selected(); 69 QButton *button = mButtonGroup->selected();
66 if ( button ) return button->text(); 70 if ( button ) return button->text();
67 return QString::null; 71 return QString::null;
68} 72}
69 73
70QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current, 74QString EmailSelectDialog::getEmail( const QStringList &emails, const QString &current,
71 QWidget *parent ) 75 QWidget *parent )
72{ 76{
73 77
74 EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent ); 78 EmailSelectDialog *dlg = new EmailSelectDialog( emails, current, parent );
75 dlg->exec(); 79 dlg->exec();
76 80
77 QString result = dlg->selected(); 81 QString result = dlg->selected();
78 82
79 delete dlg; 83 delete dlg;
80 84
81 return result; 85 return result;
82} 86}
83 87
84class EditEntryItem : public QListViewItem 88class EditEntryItem : public QListViewItem
85{ 89{
86 public: 90 public:
87 EditEntryItem( QListView *parent, const Addressee &addressee, 91 EditEntryItem( QListView *parent, const Addressee &addressee,
88 const QString &email=QString::null ) : 92 const QString &email=QString::null ) :
89 QListViewItem( parent ), 93 QListViewItem( parent ),
90 mAddressee( addressee ), 94 mAddressee( addressee ),
91 mEmail( email ) 95 mEmail( email )
92 { 96 {
93 setText( 0, addressee.realName() ); 97 setText( 0, addressee.realName() );
94 if( email.isEmpty() ) { 98 if( email.isEmpty() ) {
95 setText( 1, addressee.preferredEmail() ); 99 setText( 1, addressee.preferredEmail() );
96 setText( 2, i18n("Yes") ); 100 setText( 2, i18n("Yes") );
97 } else { 101 } else {
98 setText( 1, email ); 102 setText( 1, email );
99 setText( 2, i18n("No") ); 103 setText( 2, i18n("No") );
100 } 104 }
101 } 105 }
102 106
103 Addressee addressee() const 107 Addressee addressee() const
104 { 108 {
105 return mAddressee; 109 return mAddressee;
106 } 110 }
107 111
108 QString email() const 112 QString email() const
109 { 113 {
110 return mEmail; 114 return mEmail;
111 } 115 }
112 116
113 private: 117 private:
114 Addressee mAddressee; 118 Addressee mAddressee;
115 QString mEmail; 119 QString mEmail;
116}; 120};
117 121
118DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidget *parent) : 122DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidget *parent) :
119 QWidget( parent ), 123 QWidget( parent ),
120 mAddressBook( addressBook ) 124 mAddressBook( addressBook )
121{ 125{
122 kdDebug(5700) << "DistributionListEditor()" << endl; 126 kdDebug(5700) << "DistributionListEditor()" << endl;
123 127
124 QBoxLayout *topLayout = new QVBoxLayout( this ); 128 QBoxLayout *topLayout = new QVBoxLayout( this );
125 topLayout->setMargin( KDialog::marginHint() ); 129 topLayout->setMargin( KDialog::marginHint() );
126 topLayout->setSpacing( KDialog::spacingHint() ); 130 topLayout->setSpacing( KDialog::spacingHint() );
127 131
128 QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ; 132 QBoxLayout *nameLayout = new QHBoxLayout( topLayout) ;
129 133
130 mNameCombo = new QComboBox( this ); 134 mNameCombo = new QComboBox( this );
131 nameLayout->addWidget( mNameCombo ); 135 nameLayout->addWidget( mNameCombo );
132 connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) ); 136 connect( mNameCombo, SIGNAL( activated( int ) ), SLOT( updateEntryView() ) );
133 137
134 newButton = new QPushButton( i18n("New List"), this ); 138 newButton = new QPushButton( i18n("New List"), this );
135 nameLayout->addWidget( newButton ); 139 nameLayout->addWidget( newButton );
136 connect( newButton, SIGNAL( clicked() ), SLOT( newList() ) ); 140 connect( newButton, SIGNAL( clicked() ), SLOT( newList() ) );
137 141
138 removeButton = new QPushButton( i18n("Remove List"), this ); 142 removeButton = new QPushButton( i18n("Remove List"), this );
139 nameLayout->addWidget( removeButton ); 143 nameLayout->addWidget( removeButton );
140 connect( removeButton, SIGNAL( clicked() ), SLOT( removeList() ) ); 144 connect( removeButton, SIGNAL( clicked() ), SLOT( removeList() ) );
141 145
142 mEntryView = new QListView( this ); 146 mEntryView = new QListView( this );
143 mEntryView->addColumn( i18n("Name") ); 147 mEntryView->addColumn( i18n("Name") );
144 mEntryView->addColumn( i18n("Email") ); 148 mEntryView->addColumn( i18n("Email") );
145 mEntryView->addColumn( i18n("Use Preferred") ); 149 mEntryView->addColumn( i18n("Use Preferred") );
146 topLayout->addWidget( mEntryView ); 150 topLayout->addWidget( mEntryView );
147 connect(mEntryView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionEntryViewChanged())); 151 connect(mEntryView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionEntryViewChanged()));
148 152
149 changeEmailButton = new QPushButton( i18n("Change Email"), this ); 153 changeEmailButton = new QPushButton( i18n("Change Email"), this );
150 topLayout->addWidget( changeEmailButton ); 154 topLayout->addWidget( changeEmailButton );
151 connect( changeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) ); 155 connect( changeEmailButton, SIGNAL( clicked() ), SLOT( changeEmail() ) );
152 156
153 removeEntryButton = new QPushButton( i18n("Remove Entry"), this ); 157 removeEntryButton = new QPushButton( i18n("Remove Entry"), this );
154 topLayout->addWidget( removeEntryButton ); 158 topLayout->addWidget( removeEntryButton );
155 connect( removeEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) ); 159 connect( removeEntryButton, SIGNAL( clicked() ), SLOT( removeEntry() ) );
156 160
157 addEntryButton = new QPushButton( i18n("Add Entry"), this ); 161 addEntryButton = new QPushButton( i18n("Add Entry"), this );
158 topLayout->addWidget( addEntryButton ); 162 topLayout->addWidget( addEntryButton );
159 connect( addEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) ); 163 connect( addEntryButton, SIGNAL( clicked() ), SLOT( addEntry() ) );
160 164
161 mAddresseeView = new QListView( this ); 165 mAddresseeView = new QListView( this );
162 mAddresseeView->addColumn( i18n("Name") ); 166 mAddresseeView->addColumn( i18n("Name") );
163 mAddresseeView->addColumn( i18n("Preferred Email") ); 167 mAddresseeView->addColumn( i18n("Preferred Email") );
164 topLayout->addWidget( mAddresseeView ); 168 topLayout->addWidget( mAddresseeView );
165 169
166 170
167 connect(mAddresseeView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionAddresseeViewChanged())); 171 connect(mAddresseeView,SIGNAL(selectionChanged ()),this, SLOT(slotSelectionAddresseeViewChanged()));
168 172
169 mManager = new DistributionListManager( mAddressBook ); 173 mManager = new DistributionListManager( mAddressBook );
170 mManager->load(); 174 mManager->load();
171 175
172 updateAddresseeView(); 176 updateAddresseeView();
173 updateNameCombo(); 177 updateNameCombo();
174 removeButton->setEnabled(!mManager->listNames().isEmpty()); 178 removeButton->setEnabled(!mManager->listNames().isEmpty());
175} 179}
176 180
177DistributionListEditor::~DistributionListEditor() 181DistributionListEditor::~DistributionListEditor()
178{ 182{
179 kdDebug(5700) << "~DistributionListEditor()" << endl; 183 kdDebug(5700) << "~DistributionListEditor()" << endl;
180 184
181 mManager->save(); 185 mManager->save();
182 delete mManager; 186 delete mManager;
183} 187}
184 188
185void DistributionListEditor::slotSelectionEntryViewChanged() 189void DistributionListEditor::slotSelectionEntryViewChanged()
186{ 190{
187//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); 191//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
188 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 192 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
189 bool state = (entryItem != 0L); 193 bool state = (entryItem != 0L);
190 194
191 changeEmailButton->setEnabled(state); 195 changeEmailButton->setEnabled(state);
192 removeEntryButton->setEnabled(state); 196 removeEntryButton->setEnabled(state);
193} 197}
194 198
195void DistributionListEditor::newList() 199void DistributionListEditor::newList()
196{ 200{
197 bool ok = false; 201 bool ok = false;
198 QString name = QInputDialog::getText( i18n("New Distribution List"), 202 QString name = QInputDialog::getText( i18n("New Distribution List"),
199 i18n("Please enter name:"), 203 i18n("Please enter name:"),
200 QLineEdit::Normal, QString::null, &ok, 204 QLineEdit::Normal, QString::null, &ok,
201 this ); 205 this );
202 if ( !ok || name.isEmpty() ) return; 206 if ( !ok || name.isEmpty() ) return;
203 207
204 new DistributionList( mManager, name ); 208 new DistributionList( mManager, name );
205 209
206 mNameCombo->insertItem( name ); 210 mNameCombo->insertItem( name );
207 removeButton->setEnabled(true); 211 removeButton->setEnabled(true);
208 updateEntryView(); 212 updateEntryView();
209} 213}
210 214
211void DistributionListEditor::removeList() 215void DistributionListEditor::removeList()
212{ 216{
213 delete mManager->list( mNameCombo->currentText() ); 217 delete mManager->list( mNameCombo->currentText() );
214 mNameCombo->removeItem( mNameCombo->currentItem() ); 218 mNameCombo->removeItem( mNameCombo->currentItem() );
215 removeButton->setEnabled(!mManager->listNames().isEmpty()); 219 removeButton->setEnabled(!mManager->listNames().isEmpty());
216 addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty()); 220 addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty());
217 updateEntryView(); 221 updateEntryView();
218} 222}
219 223
220void DistributionListEditor::addEntry() 224void DistributionListEditor::addEntry()
221{ 225{
222/*US 226/*US
223 AddresseeItem *addresseeItem = 227 AddresseeItem *addresseeItem =
224 dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); 228 dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
225*/ 229*/
226 AddresseeItem *addresseeItem = 230 AddresseeItem *addresseeItem =
227 (AddresseeItem *)( mAddresseeView->selectedItem() ); 231 (AddresseeItem *)( mAddresseeView->selectedItem() );
228 232
229 233
230 if( !addresseeItem ) { 234 if( !addresseeItem ) {
231 kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl; 235 kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl;
232 return; 236 return;
233 } 237 }
234 238
235 DistributionList *list = mManager->list( mNameCombo->currentText() ); 239 DistributionList *list = mManager->list( mNameCombo->currentText() );
236 if ( !list ) { 240 if ( !list ) {
237 kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl; 241 kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl;
238 return; 242 return;
239 } 243 }
240 244
241 list->insertEntry( addresseeItem->addressee() ); 245 list->insertEntry( addresseeItem->addressee() );
242 updateEntryView(); 246 updateEntryView();
243 slotSelectionAddresseeViewChanged(); 247 slotSelectionAddresseeViewChanged();
244} 248}
245 249
246void DistributionListEditor::removeEntry() 250void DistributionListEditor::removeEntry()
247{ 251{
248 DistributionList *list = mManager->list( mNameCombo->currentText() ); 252 DistributionList *list = mManager->list( mNameCombo->currentText() );
249 if ( !list ) return; 253 if ( !list ) return;
250 254
251//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); 255//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
252 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 256 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
253 if ( !entryItem ) return; 257 if ( !entryItem ) return;
254 258
255 list->removeEntry( entryItem->addressee(), entryItem->email() ); 259 list->removeEntry( entryItem->addressee(), entryItem->email() );
256 delete entryItem; 260 delete entryItem;
257} 261}
258 262
259void DistributionListEditor::changeEmail() 263void DistributionListEditor::changeEmail()
260{ 264{
261 DistributionList *list = mManager->list( mNameCombo->currentText() ); 265 DistributionList *list = mManager->list( mNameCombo->currentText() );
262 if ( !list ) return; 266 if ( !list ) return;
263 267
264//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); 268//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
265 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 269 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
266 if ( !entryItem ) return; 270 if ( !entryItem ) return;
267 271
268 QString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(), 272 QString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(),
269 entryItem->email(), this ); 273 entryItem->email(), this );
270 list->removeEntry( entryItem->addressee(), entryItem->email() ); 274 list->removeEntry( entryItem->addressee(), entryItem->email() );
271 list->insertEntry( entryItem->addressee(), email ); 275 list->insertEntry( entryItem->addressee(), email );
272 276
273 updateEntryView(); 277 updateEntryView();
274} 278}
275 279
276void DistributionListEditor::updateEntryView() 280void DistributionListEditor::updateEntryView()
277{ 281{
278 DistributionList *list = mManager->list( mNameCombo->currentText() ); 282 DistributionList *list = mManager->list( mNameCombo->currentText() );
279 if ( !list ) return; 283 if ( !list ) return;
280 284
281 mEntryView->clear(); 285 mEntryView->clear();
282 DistributionList::Entry::List entries = list->entries(); 286 DistributionList::Entry::List entries = list->entries();
283 DistributionList::Entry::List::ConstIterator it; 287 DistributionList::Entry::List::ConstIterator it;
284 for( it = entries.begin(); it != entries.end(); ++it ) { 288 for( it = entries.begin(); it != entries.end(); ++it ) {
285 new EditEntryItem( mEntryView, (*it).addressee, (*it).email ); 289 new EditEntryItem( mEntryView, (*it).addressee, (*it).email );
286 } 290 }
287//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() ); 291//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
288 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 292 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
289 bool state = (entryItem != 0L); 293 bool state = (entryItem != 0L);
290 294
291 changeEmailButton->setEnabled(state); 295 changeEmailButton->setEnabled(state);
292 removeEntryButton->setEnabled(state); 296 removeEntryButton->setEnabled(state);
293} 297}
294 298
295void DistributionListEditor::updateAddresseeView() 299void DistributionListEditor::updateAddresseeView()
296{ 300{
297 mAddresseeView->clear(); 301 mAddresseeView->clear();
298 302
299 AddressBook::Iterator it; 303 AddressBook::Iterator it;
300 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 304 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
301 new AddresseeItem( mAddresseeView, *it ); 305 new AddresseeItem( mAddresseeView, *it );
302 } 306 }
303} 307}
304 308
305void DistributionListEditor::updateNameCombo() 309void DistributionListEditor::updateNameCombo()
306{ 310{
307 mNameCombo->insertStringList( mManager->listNames() ); 311 mNameCombo->insertStringList( mManager->listNames() );
308 312
309 updateEntryView(); 313 updateEntryView();
310} 314}
311 315
312void DistributionListEditor::slotSelectionAddresseeViewChanged() 316void DistributionListEditor::slotSelectionAddresseeViewChanged()
313{ 317{
314//US AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); 318//US AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
315 AddresseeItem *addresseeItem = (AddresseeItem *)( mAddresseeView->selectedItem() ); 319 AddresseeItem *addresseeItem = (AddresseeItem *)( mAddresseeView->selectedItem() );
316 bool state = (addresseeItem != 0L); 320 bool state = (addresseeItem != 0L);
317 addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty()); 321 addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty());
318} 322}
diff --git a/kaddressbook/tr.h b/kaddressbook/tr.h
new file mode 100644
index 0000000..981e2c1
--- a/dev/null
+++ b/kaddressbook/tr.h
@@ -0,0 +1,2 @@
1#include <klocale.h>
2#define tr i18n
diff --git a/korganizer/tr.h b/korganizer/tr.h
new file mode 100644
index 0000000..981e2c1
--- a/dev/null
+++ b/korganizer/tr.h
@@ -0,0 +1,2 @@
1#include <klocale.h>
2#define tr i18n