当前位置: 首页>>代码示例>>C++>>正文


C++ KLibFactory::inherits方法代码示例

本文整理汇总了C++中KLibFactory::inherits方法的典型用法代码示例。如果您正苦于以下问题:C++ KLibFactory::inherits方法的具体用法?C++ KLibFactory::inherits怎么用?C++ KLibFactory::inherits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KLibFactory的用法示例。


在下文中一共展示了KLibFactory::inherits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createSyncPlugin

int SyncTaskListItem::createSyncPlugin(bool state)
{
    int ret = 0;

    if (syncPlugin != NULL) {
        syncPlugin->unInit();
        delete syncPlugin;
        syncPlugin = NULL;
    }

    if (state) {
        KTrader::OfferList offers;

        QString library = getPreferedLibrary();
        QString offer = getPreferedOffer();

        if (library.isEmpty()) {
            offers = getOffers();
            if (offers.begin() != offers.end()) {
                KService::Ptr service = *offers.begin();
                library = service->library();
                offer = service->name();
            }
        }

        if (!library.isEmpty()) {
            kdDebug(2120) << i18n("Name:") << " " << offer << "; "
            << i18n("Library:") << " " << library << endl;
            KLibFactory *factory = KLibLoader::self()->factory(library.ascii());
            if (!factory) {
                QString errorMessage = KLibLoader::self()->lastErrorMessage();
                kdDebug(2120) << i18n("There was an error:") << " " << offer << errorMessage <<
                    endl;
                ret = ERROR_NOFACTORY;
            } else {
                if (factory->inherits("RakiSyncFactory")) {
                    RakiSyncFactory *syncFactory =
                        static_cast<RakiSyncFactory*> (factory);
                    syncPlugin = static_cast<RakiSyncPlugin*>
                                 (syncFactory->create());
                    syncPlugin->init(rra, this, pdaName, this->listView(), offer);
                    syncFactory->callme(); // Fake call to link correct.
                } else {
                    kdDebug(2120) << i18n("Library no Raki-Plugin") << endl;
                    ret = ERROR_WRONGLIBRARYTYPE;
                }
            }
        } else {
            ret = ERROR_NOSYNCHRONIZER;
        }
    }

    switch(ret) {
    case ERROR_NOSYNCHRONIZER:
        KMessageBox::information(this->listView(), "<p>" + i18n("No Synchronizer found for") + " <b>" +
                QString(rra->getTypeForId(objectType)->name2) + "</b></p>", QString(rra->getTypeForId(objectType)->name2) + pdaName);
        this->setOn(false);
        this->makePersistent();
        break;
    case ERROR_WRONGLIBRARYTYPE:
        KMessageBox::error(this->listView(), "<p>" + i18n("Wrong library type for") +" <b>" +
                QString(rra->getTypeForId(objectType)->name2) + "</b></p>", QString(rra->getTypeForId(objectType)->name2) + pdaName);
        this->setOn(false);
        this->makePersistent();
        break;
    case ERROR_NOFACTORY:
        KMessageBox::error(this->listView(), "<p>" + i18n("Wrong library type for") + " <b>" +
                QString(rra->getTypeForId(objectType)->name2) + "</b></p>", QString(rra->getTypeForId(objectType)->name2) + pdaName);
        this->setOn(false);
        this->makePersistent();
        break;
    }

    return ret;
}
开发者ID:asmblur,项目名称:SynCE,代码行数:75,代码来源:synctasklistitem.cpp


注:本文中的KLibFactory::inherits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。