本文整理汇总了C++中kabc::AddressBook::resources方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook::resources方法的具体用法?C++ AddressBook::resources怎么用?C++ AddressBook::resources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::AddressBook
的用法示例。
在下文中一共展示了AddressBook::resources方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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()));
}
示例3: testConverter
void TestDistrList::testConverter()
{
kDebug() ;
KABC::AddressBook *ab = KABC::StdAddressBook::self();
QList<KABC::Resource*> resources = ab->resources();
assert( resources.count() == 1 );
DistributionListConverter converter( resources[ 0 ] );
DistributionList pimList;
KABC::DistributionList *kabcList = converter.convertToKABC( pimList );
assert( kabcList != 0 );
assert( kabcList->entries().isEmpty() && kabcList->emails().isEmpty() );
assert( kabcList->identifier().isEmpty() && kabcList->name().isEmpty() );
DistributionList pimList2 = converter.convertFromKABC( kabcList );
assert( pimList2 == pimList );
delete kabcList;
pimList.setName( "pimlist-name" );
pimList.setUid( "pimlist-id" );
kabcList = converter.convertToKABC( pimList );
assert( kabcList != 0 );
assert( kabcList->entries().isEmpty() && kabcList->emails().isEmpty() );
assert( kabcList->identifier() == "pimlist-id" &&
kabcList->name() == "pimlist-name" );
pimList2 = converter.convertFromKABC( kabcList );
assert( pimList2 == pimList );
delete kabcList;
KABC::Addressee addr1 = ab->findByName( "addr1" ).first();
assert( !addr1.isEmpty() );
pimList.insertEntry( addr1 );
kabcList = converter.convertToKABC( pimList );
assert( kabcList != 0 );
assert( kabcList->identifier() == "pimlist-id" &&
kabcList->name() == "pimlist-name" );
assert( kabcList->entries().count() == 1 && kabcList->emails().count() == 1 );
assert( kabcList->entries()[ 0 ].addressee() == addr1 );
pimList2 = converter.convertFromKABC( kabcList );
assert( pimList2 == pimList );
delete kabcList;
KABC::Addressee addr2 = ab->findByName( "addr2" ).first();
assert( !addr2.isEmpty() );
pimList.insertEntry( addr2 );
kabcList = converter.convertToKABC( pimList );
assert( kabcList != 0 );
assert( kabcList->identifier() == "pimlist-id" &&
kabcList->name() == "pimlist-name" );
assert( kabcList->entries().count() == 2 && kabcList->emails().count() == 2 );
assert( kabcList->entries()[ 0 ].addressee() == addr1 );
assert( kabcList->entries()[ 2 ].addressee() == addr2 );
pimList2 = converter.convertFromKABC( kabcList );
assert( pimList2 == pimList );
delete kabcList;
}