Esempio n. 1
0
void DistributionListEditor::updateEntryView()
{
  DistributionList *list = mManager->list( mNameCombo->currentText() );
  if ( !list ) return;

  mEntryView->clear();
  DistributionList::Entry::List entries = list->entries();
  DistributionList::Entry::List::ConstIterator it;
  for( it = entries.begin(); it != entries.end(); ++it ) {
    new EditEntryItem( mEntryView, (*it).addressee, (*it).email );
  }
   EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
   bool state = (entryItem != 0L);

   changeEmailButton->setEnabled(state);
   removeEntryButton->setEnabled(state);
}
void DistributionListEditorWidget::updateEntryView()
{
    if(mNameCombo->currentText().isEmpty())
    {
        mListLabel->setText(i18n("Selected addressees:"));
    }
    else
    {
        mListLabel->setText(i18n("Selected addresses in '%1':").arg(mNameCombo->currentText()));
    }

    mEntryView->clear();

    DistributionList *list = mManager->list(mNameCombo->currentText());
    if(!list)
    {
        mEditButton->setEnabled(false);
        mRemoveButton->setEnabled(false);
        mChangeEmailButton->setEnabled(false);
        mRemoveEntryButton->setEnabled(false);
        mAddresseeView->setEnabled(false);
        mEntryView->setEnabled(false);
        return;
    }
    else
    {
        mEditButton->setEnabled(true);
        mRemoveButton->setEnabled(true);
        mAddresseeView->setEnabled(true);
        mEntryView->setEnabled(true);
    }

    DistributionList::Entry::List entries = list->entries();
    DistributionList::Entry::List::ConstIterator it;
    for(it = entries.begin(); it != entries.end(); ++it)
    {
        new EntryItem(mEntryView, (*it).addressee, (*it).email);
    }

    EntryItem *entryItem = static_cast< EntryItem * >(mEntryView->selectedItem());
    bool state = entryItem;

    mChangeEmailButton->setEnabled(state);
    mRemoveEntryButton->setEnabled(state);
}
Esempio n. 3
0
bool DistributionListManager::save()
{
  kdDebug(5700) << "DistListManager::save()" << endl;

  KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );

  cfg.deleteGroup( "DistributionLists" );
  cfg.setGroup( "DistributionLists" );
  
  DistributionList *list;
  for( list = mLists.first(); list; list = mLists.next() ) {
    kdDebug(5700) << "  Saving '" << list->name() << "'" << endl;

    QStringList value;
    const DistributionList::Entry::List entries = list->entries();
    DistributionList::Entry::List::ConstIterator it;
    for( it = entries.begin(); it != entries.end(); ++it ) {
      value.append( (*it).addressee.uid() );
      value.append( (*it).email );
    }

    if ( d->mMissingEntries.find( list->name() ) != d->mMissingEntries.end() ) {
      const MissingEntryList missList = d->mMissingEntries[ list->name() ];
      MissingEntryList::ConstIterator missIt;
      for ( missIt = missList.begin(); missIt != missList.end(); ++missIt ) {
        value.append( (*missIt).first );
        value.append( (*missIt).second );
      }
    }

    cfg.writeEntry( list->name(), value );
  }

  cfg.sync();
  
  return true;
}