本文整理汇总了C++中QPluginLoader::fileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QPluginLoader::fileName方法的具体用法?C++ QPluginLoader::fileName怎么用?C++ QPluginLoader::fileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPluginLoader
的用法示例。
在下文中一共展示了QPluginLoader::fileName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: documentType
int Global::documentType(const QUrl& document)
{
QMimeType mime = QMimeDatabase{}.mimeTypeForUrl(document);
QList<QPluginLoader*> plugins = KoJsonTrader::self()->query("Calligra/Part", mime.name());
for (int i = 0; i < plugins.count(); i++) {
QPluginLoader* loader = plugins.at(i);
if(loader->fileName().contains("words")) {
return DocumentType::TextDocument;
} else if(loader->fileName().contains("sheets")) {
return DocumentType::Spreadsheet;
} else if(loader->fileName().contains("stage")) {
return DocumentType::Presentation;
}
}
// Since we don't actually have a Calligra plugin that handles these...
if(staticTextTypes.contains(mime.name())) {
return DocumentType::StaticTextDocument;
}
return DocumentType::Unknown;
}
示例2: loadPlugins
void AbstractPluginLoader::loadPlugins(const QRegExp& fileRx, QVector<QString>* errors)
{
Q_D(AbstractPluginLoader);
const QDir pluginsFolder(this->loadingFolder());
QStringList entries(pluginsFolder.entryList(QDir::Files));
foreach (const QString& entry, entries) {
if (fileRx.indexIn(entry) != -1 && ::isLibrary(entry)) {
// Try to load the plugin
#ifdef DEBUG_ABSTRACT_PLUGIN_LOADER
qDebug() << "try to load" << entry;
#endif // DEBUG_ABSTRACT_PLUGIN_LOADER
QPluginLoader* pluginLoader = new QPluginLoader(pluginsFolder.absoluteFilePath(entry));
QObject* plugin = pluginLoader->instance();
// Is the plugin compatible ?
if (this->isPluginCompatible(plugin)) {
d->m_plugins.append(plugin);
d->m_pluginLoaders.append(pluginLoader);
d->m_pluginFilenames.insert(plugin, entry);
}
else {
#ifdef DEBUG_ABSTRACT_PLUGIN_LOADER
qDebug() << " not added";
#endif // DEBUG_ABSTRACT_PLUGIN_LOADER
if (errors != NULL)
//: %1 holds the path to a plugin (DLL)
//: %2 holds an error description
errors->append(QObject::tr("Failed to load plugin (maybe wrong interface) %1 : %2")
.arg(pluginLoader->fileName())
.arg(pluginLoader->errorString()));
pluginLoader->unload();
delete pluginLoader;
} // end if (this->isPluginCompatible(plugin))
} // end if (fileRx.indexIn(entry) != -1)
} // end foreach ()
}
示例3: loadPlugins
void GLWidget::loadPlugins(const QStringList& list) {
QStringList::ConstIterator it = list.constBegin();
while(it != list.constEnd())
{
QString name = *it;
QPluginLoader *loader = new QPluginLoader(name);
if (! loader->load()) {
qDebug() << "Could not load plugin " << name << "\n";
qDebug() << loader->errorString() << "\n";
}
if (loader->isLoaded())
{
qDebug() << "Loaded plugin: " << loader->fileName(); // << endl;
QObject *plugin = loader->instance();
if (plugin)
{
plugins.push_back(loader);
BasicPlugin *plugin = qobject_cast<BasicPlugin *>(loader->instance());
// initialize plugin
if (plugin)
{
plugin->setWidget(this);
plugin->setArgs(mainArgs);
plugin->onPluginLoad();
if (plugin->drawScene()) // overrides drawScene?
drawPlugin = plugin;
}
}
}
else
{
qDebug() << "Load error: " << name << endl;
delete loader;
}
++it;
}
// make sure all plugins know about the latest plugin that overrides drawScene
for (unsigned int i=0; i<plugins.size(); ++i)
{
BasicPlugin *plugin = qobject_cast<BasicPlugin *>(plugins[i]->instance());
if (plugin)
plugin->setDrawPlugin(drawPlugin);
else
{
qDebug() << "Error: the plugin must implement the BasicPlugin interface" << endl <<
" Example: " << endl <<
" Q_INTERFACES(BasicPlugin)" << endl;
}
}
resetCamera();
}
示例4: pluginList
QVariant GameEngine::pluginList()
{
QStringList list;
QPluginLoader* loader;
foreach (loader,m_pluginList) {
QString s = loader->fileName();
s = s.mid(s.lastIndexOf("/")+1);
s = s.left(s.lastIndexOf("."));
s = s.toUpper();
#ifdef Q_WS_MAEMO_5
if (s.contains("LIB")) {
s = s.right(s.length() - (s.indexOf("LIB")+3));
}
#endif
list.append(s);
}
示例5: qCWarning
QObject *PluginLoader::createForName(const QString &name)
{
if (!mPluginInfos.contains(name)) {
qCWarning(AKONADICORE_LOG) << "plugin name \"" << name << "\" is unknown to the plugin loader." << endl;
return 0;
}
PluginMetaData &info = mPluginInfos[name];
//First try to load it staticly
foreach (QObject *plugin, QPluginLoader::staticInstances()) {
if (QLatin1String(plugin->metaObject()->className()) == info.className) {
info.loaded = true;
return plugin;
break;
}
}
if (!info.loaded) {
QPluginLoader *loader = new QPluginLoader(info.library);
if (loader->fileName().isEmpty()) {
qCWarning(AKONADICORE_LOG) << loader->errorString();
delete loader;
return 0;
}
mPluginLoaders.insert(name, loader);
info.loaded = true;
}
QPluginLoader *loader = mPluginLoaders.value(name);
Q_ASSERT(loader);
QObject *object = loader->instance();
if (!object) {
qCWarning(AKONADICORE_LOG) << "unable to load plugin" << info.library << "for plugin name" << name << ".";
qCWarning(AKONADICORE_LOG) << "Error was:\"" << loader->errorString() << "\".";
return 0;
}
return object;
}
示例6: foreach
foreach (const QString &dir, dirsToCheck) {
QVector<KPluginMetaData> metadataList = KPluginLoader::findPlugins(dir,
[=](const KPluginMetaData &data)
{
return data.serviceTypes().contains("artikulate/libsound/backend");
});
foreach (const auto &metadata, metadataList) {
loader.setFileName(metadata.fileName());
qCDebug(LIBSOUND_LOG) << "Load Plugin: " << metadata.name();
if (!loader.load()) {
qCCritical(LIBSOUND_LOG) << "Error while loading plugin: " << metadata.name();
}
KPluginFactory *factory = KPluginLoader(loader.fileName()).factory();
if (!factory) {
qCCritical(LIBSOUND_LOG) << "Could not load plugin:" << metadata.name();
continue;
}
BackendInterface *plugin = factory->create<BackendInterface>(parent, QList< QVariant >());
if (plugin->outputBackend()) {
m_backendList.append(plugin->outputBackend());
}
}