本文整理汇总了C++中kabc::AddressBook::loadingHasFinished方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook::loadingHasFinished方法的具体用法?C++ AddressBook::loadingHasFinished怎么用?C++ AddressBook::loadingHasFinished使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::AddressBook
的用法示例。
在下文中一共展示了AddressBook::loadingHasFinished方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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");
}
}
示例2: 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;
}
示例3: addEmail
//-----------------------------------------------------------------------------
void KAddrBookExternal::addEmail(const QString &addr, QWidget *parent)
{
QString email;
QString name;
KABC::Addressee::parseEmailAddress(addr, name, email);
KABC::AddressBook *ab = KABC::StdAddressBook::self(true);
ab->setErrorHandler(new KABC::GuiErrorHandler(parent));
// 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.isEmpty())
{
KABC::Addressee a;
a.setNameFromString(name);
a.insertEmail(email, true);
{
KConfig config("kaddressbookrc");
config.setGroup("General");
int type = config.readNumEntry("FormattedNameType", 1);
QString name;
switch(type)
{
case 1:
name = a.givenName() + " " + a.familyName();
break;
case 2:
name = a.assembledName();
break;
case 3:
name = a.familyName() + ", " + a.givenName();
break;
case 4:
name = a.familyName() + " " + a.givenName();
break;
case 5:
name = a.organization();
break;
default:
name = "";
break;
}
name.simplifyWhiteSpace();
a.setFormattedName(name);
}
if(KAddrBookExternal::addAddressee(a))
{
QString text = i18n("<qt>The email address <b>%1</b> was added to your "
"addressbook; you can add more information to this "
"entry by opening the addressbook.</qt>").arg(addr);
KMessageBox::information(parent, text, QString::null, "addedtokabc");
}
}
else
{
QString text = i18n("<qt>The email address <b>%1</b> is already in your "
"addressbook.</qt>").arg(addr);
KMessageBox::information(parent, text, QString::null,
"alreadyInAddressBook");
}
ab->setErrorHandler(0);
}