summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/distributionlisteditor.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/kabc/distributionlisteditor.cpp b/kabc/distributionlisteditor.cpp
index 569dc96..8b485d8 100644
--- a/kabc/distributionlisteditor.cpp
+++ b/kabc/distributionlisteditor.cpp
@@ -26,27 +26,25 @@
26#include <qbuttongroup.h> 26#include <qbuttongroup.h>
27#include <qradiobutton.h> 27#include <qradiobutton.h>
28 28
29#include <klocale.h> 29#include <klocale.h>
30#include <kdebug.h> 30#include <kdebug.h>
31 31
32#include "addressbook.h" 32#include "addressbook.h"
33#include "addresseedialog.h" 33#include "addresseedialog.h"
34#include "distributionlist.h" 34#include "distributionlist.h"
35 35
36#include "distributionlisteditor.h" 36#include "distributionlisteditor.h"
37 37
38#ifndef KAB_EMBEDDED 38//US #include "distributionlisteditor.moc"
39#include "distributionlisteditor.moc"
40#endif //KAB_EMBEDDED
41 39
42using namespace KABC; 40using namespace KABC;
43 41
44EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString &current, 42EmailSelectDialog::EmailSelectDialog( const QStringList &emails, const QString &current,
45 QWidget *parent ) : 43 QWidget *parent ) :
46 KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok, 44 KDialogBase( KDialogBase::Plain, i18n("Select Email Address"), Ok, Ok,
47 parent ) 45 parent )
48{ 46{
49 QFrame *topFrame = plainPage(); 47 QFrame *topFrame = plainPage();
50 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 48 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
51 49
52 mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"), 50 mButtonGroup = new QButtonGroup( 1, Horizontal, i18n("Email Addresses"),
@@ -176,29 +174,26 @@ DistributionListEditor::DistributionListEditor( AddressBook *addressBook, QWidge
176} 174}
177 175
178DistributionListEditor::~DistributionListEditor() 176DistributionListEditor::~DistributionListEditor()
179{ 177{
180 kdDebug(5700) << "~DistributionListEditor()" << endl; 178 kdDebug(5700) << "~DistributionListEditor()" << endl;
181 179
182 mManager->save(); 180 mManager->save();
183 delete mManager; 181 delete mManager;
184} 182}
185 183
186void DistributionListEditor::slotSelectionEntryViewChanged() 184void DistributionListEditor::slotSelectionEntryViewChanged()
187{ 185{
188#ifndef KAB_EMBEDDED 186//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
189 EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
190#else //KAB_EMBEDDED
191 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 187 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
192#endif //KAB_EMBEDDED
193 bool state = (entryItem != 0L); 188 bool state = (entryItem != 0L);
194 189
195 changeEmailButton->setEnabled(state); 190 changeEmailButton->setEnabled(state);
196 removeEntryButton->setEnabled(state); 191 removeEntryButton->setEnabled(state);
197} 192}
198 193
199void DistributionListEditor::newList() 194void DistributionListEditor::newList()
200{ 195{
201 bool ok = false; 196 bool ok = false;
202 QString name = QInputDialog::getText( i18n("New Distribution List"), 197 QString name = QInputDialog::getText( i18n("New Distribution List"),
203 i18n("Please enter name:"), 198 i18n("Please enter name:"),
204 QLineEdit::Normal, QString::null, &ok, 199 QLineEdit::Normal, QString::null, &ok,
@@ -214,101 +209,91 @@ void DistributionListEditor::newList()
214 209
215void DistributionListEditor::removeList() 210void DistributionListEditor::removeList()
216{ 211{
217 delete mManager->list( mNameCombo->currentText() ); 212 delete mManager->list( mNameCombo->currentText() );
218 mNameCombo->removeItem( mNameCombo->currentItem() ); 213 mNameCombo->removeItem( mNameCombo->currentItem() );
219 removeButton->setEnabled(!mManager->listNames().isEmpty()); 214 removeButton->setEnabled(!mManager->listNames().isEmpty());
220 addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty()); 215 addEntryButton->setEnabled( !mNameCombo->currentText().isEmpty());
221 updateEntryView(); 216 updateEntryView();
222} 217}
223 218
224void DistributionListEditor::addEntry() 219void DistributionListEditor::addEntry()
225{ 220{
226#ifndef KAB_EMBEDDED 221/*US
227 AddresseeItem *addresseeItem = 222 AddresseeItem *addresseeItem =
228 dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() ); 223 dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
229#else //KAB_EMBEDDED 224*/
230 AddresseeItem *addresseeItem = 225 AddresseeItem *addresseeItem =
231 (AddresseeItem *)( mAddresseeView->selectedItem() ); 226 (AddresseeItem *)( mAddresseeView->selectedItem() );
232#endif //KAB_EMBEDDED
233 227
234 228
235 if( !addresseeItem ) { 229 if( !addresseeItem ) {
236 kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl; 230 kdDebug(5700) << "DLE::addEntry(): No addressee selected." << endl;
237 return; 231 return;
238 } 232 }
239 233
240 DistributionList *list = mManager->list( mNameCombo->currentText() ); 234 DistributionList *list = mManager->list( mNameCombo->currentText() );
241 if ( !list ) { 235 if ( !list ) {
242 kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl; 236 kdDebug(5700) << "DLE::addEntry(): No dist list '" << mNameCombo->currentText() << "'" << endl;
243 return; 237 return;
244 } 238 }
245 239
246 list->insertEntry( addresseeItem->addressee() ); 240 list->insertEntry( addresseeItem->addressee() );
247 updateEntryView(); 241 updateEntryView();
248 slotSelectionAddresseeViewChanged(); 242 slotSelectionAddresseeViewChanged();
249} 243}
250 244
251void DistributionListEditor::removeEntry() 245void DistributionListEditor::removeEntry()
252{ 246{
253 DistributionList *list = mManager->list( mNameCombo->currentText() ); 247 DistributionList *list = mManager->list( mNameCombo->currentText() );
254 if ( !list ) return; 248 if ( !list ) return;
255 249
256#ifndef KAB_EMBEDDED 250//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
257 EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
258#else //KAB_EMBEDDED
259 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 251 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
260#endif //KAB_EMBEDDED
261 if ( !entryItem ) return; 252 if ( !entryItem ) return;
262 253
263 list->removeEntry( entryItem->addressee(), entryItem->email() ); 254 list->removeEntry( entryItem->addressee(), entryItem->email() );
264 delete entryItem; 255 delete entryItem;
265} 256}
266 257
267void DistributionListEditor::changeEmail() 258void DistributionListEditor::changeEmail()
268{ 259{
269 DistributionList *list = mManager->list( mNameCombo->currentText() ); 260 DistributionList *list = mManager->list( mNameCombo->currentText() );
270 if ( !list ) return; 261 if ( !list ) return;
271 262
272#ifndef KAB_EMBEDDED 263//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
273 EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
274#else //KAB_EMBEDDED
275 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 264 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
276#endif //KAB_EMBEDDED
277 if ( !entryItem ) return; 265 if ( !entryItem ) return;
278 266
279 QString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(), 267 QString email = EmailSelectDialog::getEmail( entryItem->addressee().emails(),
280 entryItem->email(), this ); 268 entryItem->email(), this );
281 list->removeEntry( entryItem->addressee(), entryItem->email() ); 269 list->removeEntry( entryItem->addressee(), entryItem->email() );
282 list->insertEntry( entryItem->addressee(), email ); 270 list->insertEntry( entryItem->addressee(), email );
283 271
284 updateEntryView(); 272 updateEntryView();
285} 273}
286 274
287void DistributionListEditor::updateEntryView() 275void DistributionListEditor::updateEntryView()
288{ 276{
289 DistributionList *list = mManager->list( mNameCombo->currentText() ); 277 DistributionList *list = mManager->list( mNameCombo->currentText() );
290 if ( !list ) return; 278 if ( !list ) return;
291 279
292 mEntryView->clear(); 280 mEntryView->clear();
293 DistributionList::Entry::List entries = list->entries(); 281 DistributionList::Entry::List entries = list->entries();
294 DistributionList::Entry::List::ConstIterator it; 282 DistributionList::Entry::List::ConstIterator it;
295 for( it = entries.begin(); it != entries.end(); ++it ) { 283 for( it = entries.begin(); it != entries.end(); ++it ) {
296 new EditEntryItem( mEntryView, (*it).addressee, (*it).email ); 284 new EditEntryItem( mEntryView, (*it).addressee, (*it).email );
297 } 285 }
298#ifndef KAB_EMBEDDED 286//US EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
299 EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
300#else //KAB_EMBEDDED
301 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() ); 287 EditEntryItem *entryItem = (EditEntryItem *)( mEntryView->selectedItem() );
302#endif //KAB_EMBEDDED
303 bool state = (entryItem != 0L); 288 bool state = (entryItem != 0L);
304 289
305 changeEmailButton->setEnabled(state); 290 changeEmailButton->setEnabled(state);
306 removeEntryButton->setEnabled(state); 291 removeEntryButton->setEnabled(state);
307} 292}
308 293
309void DistributionListEditor::updateAddresseeView() 294void DistributionListEditor::updateAddresseeView()
310{ 295{
311 mAddresseeView->clear(); 296 mAddresseeView->clear();
312 297
313 AddressBook::Iterator it; 298 AddressBook::Iterator it;
314 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { 299 for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) {
@@ -316,20 +301,17 @@ void DistributionListEditor::updateAddresseeView()
316 } 301 }
317} 302}
318 303
319void DistributionListEditor::updateNameCombo() 304void DistributionListEditor::updateNameCombo()
320{ 305{
321 mNameCombo->insertStringList( mManager->listNames() ); 306 mNameCombo->insertStringList( mManager->listNames() );
322 307
323 updateEntryView(); 308 updateEntryView();
324} 309}
325 310
326void DistributionListEditor::slotSelectionAddresseeViewChanged() 311void DistributionListEditor::slotSelectionAddresseeViewChanged()
327{ 312{
328#ifndef KAB_EMBEDDED 313//US AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
329 AddresseeItem *addresseeItem = dynamic_cast<AddresseeItem *>( mAddresseeView->selectedItem() );
330#else //KAB_EMBEDDED
331 AddresseeItem *addresseeItem = (AddresseeItem *)( mAddresseeView->selectedItem() ); 314 AddresseeItem *addresseeItem = (AddresseeItem *)( mAddresseeView->selectedItem() );
332#endif //KAB_EMBEDDED
333 bool state = (addresseeItem != 0L); 315 bool state = (addresseeItem != 0L);
334 addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty()); 316 addEntryButton->setEnabled( state && !mNameCombo->currentText().isEmpty());
335} 317}