本文整理汇总了C++中kabc::AddressBook类的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook类的具体用法?C++ AddressBook怎么用?C++ AddressBook使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AddressBook类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: AddresseeViewItem
void
AddressesDialog::updateAvailableAddressees()
{
d->ui->mAvailableView->clear();
d->groupDict.clear();
static const QString &personalGroup = KGlobal::staticQString( i18n( "Other Addresses" ) );
d->personal = new AddresseeViewItem( d->ui->mAvailableView, personalGroup );
d->personal->setHidden( true );
d->groupDict.insert( personalGroup, d->personal );
KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
for( KABC::AddressBook::Iterator it = addressBook->begin();
it != addressBook->end(); ++it ) {
addAddresseeToAvailable( *it, d->personal );
}
d->recent = 0;
updateRecentAddresses();
addDistributionLists();
if ( d->personal->childCount() > 0 ) {
d->personal->setHidden( false );
}
checkForSingleAvailableGroup();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:27,代码来源:addressesdialog.cpp
示例2: addVCard
bool KAddrBookExternal::addVCard(const KABC::Addressee &addressee, QWidget *parent)
{
KABC::AddressBook *ab = KABC::StdAddressBook::self(true);
bool inserted = false;
ab->setErrorHandler(new KABC::GuiErrorHandler(parent));
KABC::Addressee::List addressees =
ab->findByEmail(addressee.preferredEmail());
if(addressees.isEmpty())
{
if(KAddrBookExternal::addAddressee(addressee))
{
QString text = i18n("The VCard was added to your addressbook; "
"you can add more information to this "
"entry by opening the addressbook.");
KMessageBox::information(parent, text, QString::null, "addedtokabc");
inserted = true;
}
}
else
{
QString text = i18n("The VCard's primary email address is already in "
"your addressbook; however, you may save the VCard "
"into a file and import it into the addressbook "
"manually.");
KMessageBox::information(parent, text);
inserted = true;
}
ab->setErrorHandler(0);
return inserted;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:34,代码来源:kaddrbook.cpp
示例3: setup
void TestDistrList::setup()
{
// We need a std addressbook
KABC::AddressBook *ab = KABC::StdAddressBook::self();
KABC::StdAddressBook::setAutomaticSave( false );
// and two contacts
KABC::Addressee addr1;
addr1.setName( "addr1" );
addr1.setFormattedName( "addr1" );
addr1.insertEmail( "[email protected]", true );
addr1.insertEmail( "[email protected]" );
ab->insertAddressee( addr1 );
assert( addr1.emails().count() == 2 );
KABC::Addressee addr2;
addr2.setName( "addr2" );
addr2.insertEmail( "[email protected]", true );
addr2.insertEmail( "[email protected]" );
ab->insertAddressee( addr2 );
assert( addr2.emails().count() == 2 );
assert( !ab->findByName( "addr1" ).isEmpty() );
assert( !ab->findByName( "addr2" ).isEmpty() );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:25,代码来源:testdistrlist.cpp
示例4: testNewList
void TestDistrList::testNewList()
{
kDebug() ;
DistributionList dl;
dl.setName( "foo" );
assert( !dl.isEmpty() );
check( "name set", dl.formattedName(), "foo" );
assert( DistributionList::isDistributionList( dl ) );
KABC::AddressBook *ab = KABC::StdAddressBook::self();
ab->insertAddressee( dl );
#if 0 // can't do that until we have KABC::AddressBook::findByFormattedName, or we use setName()
KABC::Addressee::List addrList = ab->findByName( "foo" );
assert( addrList.count() == 1 );
KABC::Addressee addr = addrList.first();
assert( !addr.isEmpty() );
check( "correct name", addr.name(), "foo" );
assert( DistributionList::isDistributionList( addr ) );
#else
KABC::Addressee addr = dl;
#endif
DistributionList dl2 = DistributionList::findByName( ab, "foo" );
assert( !dl2.isEmpty() );
check( "correct name", dl2.formattedName(), "foo" );
assert( DistributionList::isDistributionList( dl2 ) );
// Test the ctor that takes an addressee
DistributionList dl3( addr );
assert( !dl3.isEmpty() );
assert( DistributionList::isDistributionList( dl3 ) );
check( "correct name", dl3.formattedName(), "foo" );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:33,代码来源:testdistrlist.cpp
示例5: testDuplicate
void TestDistrList::testDuplicate()
{
kDebug() ;
// This is a special test for the case where we have a contact and a distr list with the same name
KABC::AddressBook *ab = KABC::StdAddressBook::self();
KABC::Addressee addr;
addr.setName( "foo" );
addr.insertEmail( "[email protected]", true );
ab->insertAddressee( addr );
#if 0 // we need a findByFormattedName
KABC::Addressee::List addrList = ab->findByName( "foo" );
assert( addrList.count() == 2 );
bool a = DistributionList::isDistributionList( addrList.first() );
bool b = DistributionList::isDistributionList( addrList.last() );
// one is a distr list, but not both
assert( a || b );
//
assert( ! ( a && b ) );
#endif
DistributionList dl = DistributionList::findByName( ab, "foo" );
assert( !dl.isEmpty() );
assert( DistributionList::isDistributionList( dl ) );
assert( dl.formattedName() == "foo" );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:27,代码来源:testdistrlist.cpp
示例6: openEmail
//-----------------------------------------------------------------------------
void KAddrBookExternal::openEmail(const QString &addr, QWidget *parent)
{
QString email;
QString name;
KABC::Addressee::parseEmailAddress(addr, name, email);
KABC::AddressBook *ab = KABC::StdAddressBook::self(true);
// force a reload of the address book file so that changes that were made
// by other programs are loaded
ab->asyncLoad();
// if we have to reload the address book then we should also wait until
// it's completely reloaded
#if KDE_IS_VERSION(3,4,89)
// This ugly hack will be removed in 4.0
while(!ab->loadingHasFinished())
{
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
// use sleep here to reduce cpu usage
usleep(100);
}
#endif
KABC::Addressee::List addressees = ab->findByEmail(email);
if(addressees.count() > 0)
{
if(kapp->dcopClient()->isApplicationRegistered("kaddressbook"))
{
//make sure kaddressbook is loaded, otherwise showContactEditor
//won't work as desired, see bug #87233
DCOPRef call("kaddressbook", "kaddressbook");
call.send("newInstance()");
}
else
{
kapp->startServiceByDesktopName("kaddressbook");
}
DCOPRef call("kaddressbook", "KAddressBookIface");
call.send("showContactEditor(QString)", addressees.first().uid());
}
else
{
//TODO: Enable the better message at the next string unfreeze
#if 0
QString text = i18n("<qt>The email address <b>%1</b> cannot be "
"found in your addressbook.</qt>").arg(email);
#else
QString text = email + " " + i18n("is not in address book");
#endif
KMessageBox::information(parent, text, QString::null, "notInAddressBook");
}
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:58,代码来源:kaddrbook.cpp
示例7: testDeleteList
void TestDistrList::testDeleteList()
{
kDebug() ;
KABC::AddressBook *ab = KABC::StdAddressBook::self();
DistributionList dl = DistributionList::findByName( ab, "foo" );
assert( !dl.isEmpty() );
ab->removeAddressee( dl );
dl = DistributionList::findByName( ab, "foo" );
assert( dl.isEmpty() );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:11,代码来源:testdistrlist.cpp
示例8: cleanup
void TestDistrList::cleanup()
{
kDebug() ;
KABC::AddressBook *ab = KABC::StdAddressBook::self();
ab->clear();
KABC::StdAddressBook::close();
QString kdehome = QFile::decodeName( getenv("KDEHOME") );
KUrl urlkdehome;
urlkdehome.setPath( kdehome );
KIO::NetAccess::del( urlkdehome, 0 );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:12,代码来源:testdistrlist.cpp
示例9: slotSelectAddress
/** Select a mail address, using the KabApi */
void TagMailDlg::slotSelectAddress()
{
//Based on KMail
QString addr, email, emailString;
QStringList result;
KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
KABC::AddressBook::Iterator it;
for( it = addressBook->begin(); it != addressBook->end(); ++it ) {
QStringList emails = (*it).emails();
QString n = (*it).prefix() + " " +
(*it).givenName() + " " +
(*it).additionalName() + " " +
(*it).familyName() + " " +
(*it).suffix();
n = n.simplifyWhiteSpace();
for( unsigned int i = 0; i < emails.count(); ++i ) {
if (!emails[i].isEmpty()) {
if (n.isEmpty() || (emails[i].find( "<" ) != -1))
addr = "";
else { /* do we really need quotes around this name ? */
if (n.find(QRegExp("[^ 0-9A-Za-z\\x0080-\\xFFFF]")) != -1)
addr = qConfig.attrValueQuotation + n + qConfig.attrValueQuotation + " ";
else
addr = n + " ";
}
email = emails[i];
if (!addr.isEmpty() && (email.find( "<" ) == -1)
&& (email.find( ">" ) == -1)
&& (email.find( "," ) == -1))
addr += "<" + email + ">";
else
addr += email;
addr.stripWhiteSpace();
result.append( addr );
}
}
}
result.sort();
if ( result.count() > 0 )
{
ListDlg listDlg(result);
listDlg.setCaption(i18n("Select Address"));
if (!listDlg.exec()) return;
emailString = listDlg.getEntry();
lineEmail->setText(emailString);
} else
{
//Actually this may mean also other erros, but the result is the same for us: cannot get the
//e-mail address
KMessageBox::error(this,i18n("No addresses found."));
}
}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:54,代码来源:tagmaildlg.cpp
示例10: core
KAB::Book::Book (Ekiga::ContactCore &_core): core(_core)
{
KABC::AddressBook *kab = KABC::StdAddressBook::self ();
kab->load (); // FIXME: turn async!
for (KABC::AddressBook::Iterator iter = kab->begin ();
iter != kab->end ();
iter++) {
add_contact (ContactPtr (new Contact (core, &(*iter))));
}
}
开发者ID:brownsys,项目名称:pane-ekiga,代码行数:13,代码来源:kab-book.cpp
示例11: addresses
void KabcBridge::addresses(QStringList& result) // includes lists
{
KCursorSaver busy(KBusyPtr::busy()); // loading might take a while
KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
KABC::AddressBook::ConstIterator it;
for( it = addressBook->constBegin(); it != addressBook->constEnd(); ++it ) {
const QStringList emails = (*it).emails();
QString n = (*it).prefix() + ' ' +
(*it).givenName() + ' ' +
(*it).additionalName() + ' ' +
(*it).familyName() + ' ' +
(*it).suffix();
n = n.simplified();
QRegExp needQuotes("[^ 0-9A-Za-z\\x0080-\\xFFFF]");
QString endQuote = "\" ";
QStringList::ConstIterator mit;
QString addr, email;
for ( mit = emails.begin(); mit != emails.end(); ++mit ) {
email = *mit;
if (!email.isEmpty()) {
if (n.isEmpty() || (email.contains( '<' ) ))
addr.clear();
else { // do we really need quotes around this name ?
if (n.contains(needQuotes) )
addr = '"' + n + endQuote;
else
addr = n + ' ';
}
if (!addr.isEmpty() && !(email.contains( '<' ) )
&& !(email.contains( '>' ) )
&& !(email.contains( ',' ) ))
addr += '<' + email + '>';
else
addr += email;
addr = addr.trimmed();
result.append( addr );
}
}
}
result += addressBook->allDistributionListNames();
result.sort();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:48,代码来源:kmaddrbook.cpp
示例12: saveToKABC
void KoRdfFoaF::saveToKABC()
{
Q_D (KoRdfFoaF);
kDebug(30015) << "saving name:" << d->m_name;
#ifdef KDEPIMLIBS_FOUND
KABC::StdAddressBook *ab = static_cast<KABC::StdAddressBook*>
(KABC::StdAddressBook::self());
if (!ab) {
return;
}
KABC::Ticket *ticket = ab->requestSaveTicket();
KABC::Addressee addr = d->toKABC();
ab->insertAddressee(addr);
KABC::AddressBook* pab = ab;
pab->save(ticket);
#endif
}
开发者ID:KDE,项目名称:calligra-history,代码行数:17,代码来源:KoRdfFoaF.cpp
示例13: testInsertEntry
void TestDistrList::testInsertEntry()
{
kDebug() ;
KABC::AddressBook *ab = KABC::StdAddressBook::self();
DistributionList dl = DistributionList::findByName( ab, "foo" );
assert( !dl.isEmpty() );
#if 0 // the usual method
KABC::Addressee addr1 = ab->findByName( "addr1" ).first();
assert( !addr1.isEmpty() );
dl.insertEntry( addr1 );
#else // the kolab-resource method
dl.insertEntry( "addr1" );
#endif
KABC::Addressee addr2 = ab->findByName( "addr2" ).first();
assert( !addr2.isEmpty() );
dl.insertEntry( addr2, "[email protected]" );
// Try inserting it again, should do nothing
dl.insertEntry( addr2, "[email protected]" );
// And insert it with another email address
dl.insertEntry( addr2, "[email protected]" );
// Test entries()
DistributionList::Entry::List entries = dl.entries( ab );
check( "entries count", QString::number( entries.count() ), "3" );
check( "first entry", entries[0].addressee.name(), "addr1" );
check( "first entry", entries[0].email, QString() );
check( "second entry", entries[1].addressee.name(), "addr2" );
check( "second entry", entries[1].email, "[email protected]" );
check( "third entry", entries[2].addressee.name(), "addr2" );
check( "third entry", entries[2].email, "[email protected]" );
// Test emails()
QStringList emails = dl.emails( ab );
kDebug() << emails;
assert( emails.count() == 3 );
check( "first email", emails[0], "addr1 <[email protected]>" );
check( "second email", emails[1], "addr2 <[email protected]>" );
check( "third email", emails[2], "addr2 <[email protected]>" );
// Commit changes to the addressbook !!
ab->insertAddressee( dl );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:46,代码来源:testdistrlist.cpp
示例14: categories
QStringList KabcBridge::categories()
{
KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
KABC::Addressee::List addresses = addressBook->allAddressees();
QStringList allcategories, aux;
for ( KABC::Addressee::List::Iterator it = addresses.begin();
it != addresses.end(); ++it ) {
aux = ( *it ).categories();
for ( QStringList::ConstIterator itAux = aux.constBegin();
itAux != aux.constEnd(); ++itAux ) {
// don't have duplicates in allcategories
if ( !allcategories.contains( *itAux ) )
allcategories += *itAux;
}
}
return allcategories;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:18,代码来源:kmaddrbook.cpp
示例15: testRemoveEntry
void TestDistrList::testRemoveEntry()
{
kDebug() ;
KABC::AddressBook *ab = KABC::StdAddressBook::self();
DistributionList dl = DistributionList::findByName( ab, "foo" );
assert( !dl.isEmpty() );
DistributionList::Entry::List entries = dl.entries( ab );
check( "entries count before removeEntry", QString::number( entries.count() ), "3" );
// Removing an empty entry shouldn't do anything
dl.removeEntry( KABC::Addressee() );
check( "entries count after removing empty entry", QString::number( dl.entries(ab).count() ), "3" );
KABC::Addressee addr1 = ab->findByName( "addr1" ).first();
assert( !addr1.isEmpty() );
// Removing an entry with the wrong email passed, shouldn't do anything
dl.removeEntry( addr1, "[email protected]" );
check( "entries count after removing entry with invalid email", QString::number( dl.entries(ab).count() ), "3" );
// Now remove entry correctly
dl.removeEntry( addr1 );
check( "removeEntry(addr1) worked", QString::number( dl.entries(ab).count() ), "2" );
QStringList emails = dl.emails( ab );
assert( emails.count() == 2 );
check( "first email", emails[0], "addr2 <[email protected]>" );
// Now move on to addr2. First remove with no or a wrong email (nothing should happen)
KABC::Addressee addr2 = ab->findByName( "addr2" ).first();
assert( !addr2.isEmpty() );
dl.removeEntry( addr2 );
check( "entries count after removing entry with no email", QString::number( dl.entries(ab).count() ), "2" );
// Now remove addr2 correctly
dl.removeEntry( addr2, "[email protected]" );
check( "entries count after removing addr2", QString::number( dl.entries(ab).count() ), "1" );
dl.removeEntry( addr2, "[email protected]" );
check( "entries count after removing alternate addr2", QString::number( dl.entries(ab).count() ), "0" );
assert( dl.entries(ab).isEmpty() );
assert( dl.emails(ab).isEmpty() );
assert( DistributionList::isDistributionList( dl ) );
ab->insertAddressee( dl );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:43,代码来源:testdistrlist.cpp
示例16: allAddressee
KABC::Addressee::List
AddressesDialog::allToAddressesNoDuplicates() const
{
KABC::Addressee::List aList = allAddressee( d->toItem );
const QStringList dList = toDistributionLists();
KABC::AddressBook* abook = KABC::StdAddressBook::self( true );
for ( QStringList::ConstIterator it = dList.constBegin(); it != dList.constEnd(); ++it ) {
const KABC::DistributionList *list = abook->findDistributionListByName( *it );
if ( !list )
continue;
const KABC::DistributionList::Entry::List eList = list->entries();
KABC::DistributionList::Entry::List::ConstIterator eit;
for( eit = eList.constBegin(); eit != eList.constEnd(); ++eit ) {
KABC::Addressee a = (*eit).addressee();
if ( !a.preferredEmail().isEmpty() && !aList.contains( a ) ) {
aList.append( a ) ;
}
}
}
return aList;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:21,代码来源:addressesdialog.cpp
示例17: addAddressee
bool KAddrBookExternal::addAddressee(const KABC::Addressee &addr)
{
KABC::AddressBook *addressBook = KABC::StdAddressBook::self(true);
#if KDE_IS_VERSION(3,4,89)
// This ugly hack will be removed in 4.0
while(!addressBook->loadingHasFinished())
{
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
// use sleep here to reduce cpu usage
usleep(100);
}
#endif
// Select a resource
QPtrList<KABC::Resource> kabcResources = addressBook->resources();
QPtrList<KRES::Resource> kresResources;
QPtrListIterator<KABC::Resource> resIt(kabcResources);
KABC::Resource *kabcResource;
while((kabcResource = resIt.current()) != 0)
{
++resIt;
if(!kabcResource->readOnly())
{
KRES::Resource *res = static_cast<KRES::Resource *>(kabcResource);
if(res)
kresResources.append(res);
}
}
kabcResource = static_cast<KABC::Resource *>(KRES::SelectDialog::getResource(kresResources, 0));
KABC::Ticket *ticket = addressBook->requestSaveTicket(kabcResource);
bool saved = false;
if(ticket)
{
KABC::Addressee addressee(addr);
addressee.setResource(kabcResource);
addressBook->insertAddressee(addressee);
saved = addressBook->save(ticket);
if(!saved)
addressBook->releaseSaveTicket(ticket);
}
addressBook->emitAddressBookChanged();
return saved;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:50,代码来源:kaddrbook.cpp
示例18: slotWriteAddressBook
void KABCPersistence::slotWriteAddressBook()
{
//kDebug( 14010 ) ;
KABC::AddressBook* ab = addressBook();
QListIterator<KABC::Resource *> it( d->pendingResources );
while ( it.hasNext() )
{
//kDebug( 14010 ) << "Writing resource " << it.current()->resourceName();
KABC::Ticket *ticket = ab->requestSaveTicket( it.next() );
if ( !ticket )
kWarning( 14010 ) << "WARNING: Resource is locked by other application!";
else
{
if ( !ab->save( ticket ) )
{
kWarning( 14010 ) << "ERROR: Saving failed!";
ab->releaseSaveTicket( ticket );
}
}
//kDebug( 14010 ) << "Finished writing KABC";
}
d->pendingResources.clear();
d->addrBookWritePending = false;
}
开发者ID:Jtalk,项目名称:kopete-fork-xep0136,代码行数:24,代码来源:kabcpersistence.cpp
示例19: CompletionViewItem
CompletionOrderEditor::CompletionOrderEditor(KPIM::LdapSearch *ldapSearch,
QWidget *parent, const char *name)
: KDialogBase(parent, name, true, i18n("Edit Completion Order"), Ok | Cancel, Ok, true),
mConfig("kpimcompletionorder"), mDirty(false)
{
mItems.setAutoDelete(true);
// The first step is to gather all the data, creating CompletionItem objects
QValueList< LdapClient * > ldapClients = ldapSearch->clients();
for(QValueList<LdapClient *>::const_iterator it = ldapClients.begin(); it != ldapClients.end(); ++it)
{
//kdDebug(5300) << "LDAP: host " << (*it)->host() << " weight " << (*it)->completionWeight() << endl;
mItems.append(new LDAPCompletionItem(*it));
}
KABC::AddressBook *addressBook = KABC::StdAddressBook::self(true);
QPtrList<KABC::Resource> resources = addressBook->resources();
for(QPtrListIterator<KABC::Resource> resit(resources); *resit; ++resit)
{
//kdDebug(5300) << "KABC Resource: " << (*resit)->className() << endl;
ResourceABC *res = dynamic_cast<ResourceABC *>(*resit);
if(res) // IMAP KABC resource
{
const QStringList subresources = res->subresources();
for(QStringList::const_iterator it = subresources.begin(); it != subresources.end(); ++it)
{
mItems.append(new KABCImapSubResCompletionItem(res, *it));
}
}
else // non-IMAP KABC resource
{
mItems.append(new SimpleCompletionItem(this, (*resit)->resourceName(),
(*resit)->identifier()));
}
}
#ifndef KDEPIM_NEW_DISTRLISTS // new distr lists are normal contact, so no separate item if using them
// Add an item for distribution lists
mItems.append(new SimpleCompletionItem(this, i18n("Distribution Lists"), "DistributionLists"));
#endif
// Now sort the items, then create the GUI
mItems.sort();
QHBox *page = makeHBoxMainWidget();
mListView = new KListView(page);
mListView->setSorting(-1);
mListView->addColumn(QString::null);
mListView->header()->hide();
for(QPtrListIterator<CompletionItem> compit(mItems); *compit; ++compit)
{
new CompletionViewItem(mListView, *compit);
kdDebug(5300) << " " << (*compit)->label() << " " << (*compit)->completionWeight() << endl;
}
QVBox *upDownBox = new QVBox(page);
mUpButton = new KPushButton(upDownBox, "mUpButton");
mUpButton->setIconSet(BarIconSet("up", KIcon::SizeSmall));
mUpButton->setEnabled(false); // b/c no item is selected yet
mUpButton->setFocusPolicy(StrongFocus);
mDownButton = new KPushButton(upDownBox, "mDownButton");
mDownButton->setIconSet(BarIconSet("down", KIcon::SizeSmall));
mDownButton->setEnabled(false); // b/c no item is selected yet
mDownButton->setFocusPolicy(StrongFocus);
QWidget *spacer = new QWidget(upDownBox);
upDownBox->setStretchFactor(spacer, 100);
connect(mListView, SIGNAL(selectionChanged(QListViewItem *)),
SLOT(slotSelectionChanged(QListViewItem *)));
connect(mUpButton, SIGNAL(clicked()), this, SLOT(slotMoveUp()));
connect(mDownButton, SIGNAL(clicked()), this, SLOT(slotMoveDown()));
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:73,代码来源:completionordereditor.cpp
示例20: QString
void DistributionListDialog::slotUser1()
{
bool isEmpty = true;
KABC::AddressBook *ab = KABC::StdAddressBook::self( true );
for (int i = 0; i < mRecipientsList->topLevelItemCount(); ++i) {
DistributionListItem *item = static_cast<DistributionListItem *>(
mRecipientsList->topLevelItem( i ));
if ( item && item->checkState( 0 ) == Qt::Checked ) {
isEmpty = false;
break;
}
}
if ( isEmpty ) {
KMessageBox::information( this,
i18nc("@info", "There are no recipients in your list. "
"First select some recipients, "
"then try again.") );
return;
}
QString name = mTitleEdit->text();
if ( name.isEmpty() ) {
bool ok = false;
name = KInputDialog::getText( i18nc("@title:window","New Distribution List"),
i18nc("@label:textbox","Please enter name:"), QString(), &ok, this );
if ( !ok || name.isEmpty() )
return;
}
if ( ab->findDistributionListByName( name ) ) {
KMessageBox::information( this,
i18nc( "@info", "<para>Distribution list with the given name <resource>%1</resource> "
"already exists. Please select a different name.</para>", name ) );
return;
}
KABC::DistributionList *dlist = ab->createDistributionList( name );
for (int i = 0; i < mRecipientsList->topLevelItemCount(); ++i) {
DistributionListItem *item = static_cast<DistributionListItem *>(
mRecipientsList->topLevelItem( i ));
if ( item && item->checkState( 0 ) == Qt::Checked ) {
kDebug() << item->addressee().fullEmail() << item->addressee().uid();
if ( item->isTransient() ) {
ab->insertAddressee( item->addressee() );
}
if ( item->email() == item->addressee().preferredEmail() ) {
dlist->insertEntry( item->addressee() );
} else {
dlist->insertEntry( item->addressee(), item->email() );
}
}
}
// let the resource know that the data has changed
KABC::Resource *resource = dlist->resource();
resource->insertDistributionList( dlist );
// save the resource
bool saveError = true;
KABC::Ticket *ticket = ab->requestSaveTicket( resource );
if ( ticket ) {
if ( ab->save( ticket ) ) {
saveError = false;
}
else
ab->releaseSaveTicket( ticket );
}
if ( saveError ) {
kWarning() << "Couldn't save new addresses in the distribution list just created to the address book";
}
close();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:79,代码来源:distributionlistdialog.cpp
注:本文中的kabc::AddressBook类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论