This commit is contained in:
Patrick von Reth 2014-02-24 18:10:35 +01:00
parent 65072e2866
commit db954b29d9
2 changed files with 48 additions and 32 deletions

View File

@ -125,11 +125,9 @@ void PluginContainer::updatePluginCache()
QList<PluginContainer*> plugins;
foreach(const SnorePlugin::PluginTypes type,PluginContainer::types())
{
foreach(const QString extention, pluginExtentions())
{
foreach(const QFileInfo &file, pluginDir().entryInfoList(
QStringList(QString("libsnore_%1_*.%2").arg(typeToString(type).toLower(), extention)), QDir::Files))
QStringList(pluginFileFilters(type)), QDir::Files))
{
snoreDebug( SNORE_DEBUG ) << "adding" << file.absoluteFilePath();
QPluginLoader loader(file.absoluteFilePath());
@ -152,7 +150,6 @@ void PluginContainer::updatePluginCache()
snoreDebug( SNORE_DEBUG ) << "added" << info->name() << "to cache";
}
}
}
cache().setValue("version",Version::revision());
cache().setValue("buildtime",Version::buildTime());
cache().setValue("pluginPath",pluginDir().absolutePath());
@ -248,9 +245,8 @@ const QDir &PluginContainer::pluginDir()
foreach(const QString &p, list)
{
QDir dir(p);
foreach(const QString extention, pluginExtentions())
{
if(!dir.entryInfoList(QStringList(QString("libsnore_*.%1").arg(extention))).isEmpty())
if(!dir.entryInfoList(pluginFileFilters()).isEmpty())
{
path = new QDir(dir);
break;
@ -260,7 +256,6 @@ const QDir &PluginContainer::pluginDir()
snoreDebug( SNORE_DEBUG ) << "Possible pluginpath:" << dir.absolutePath() << "does not contain plugins.";
}
}
}
Q_ASSERT_X(path != NULL, Q_FUNC_INFO, "Failed to find a plugin dir");
snoreDebug( SNORE_INFO ) << "PluginPath is :" << path->absolutePath();
}

View File

@ -75,6 +75,27 @@ private:
#endif
return out;
}
static inline const QStringList pluginFileFilters()
{
QStringList out;
foreach(const QString extention, pluginExtentions())
{
out << QString("libsnore_*.%1").arg(extention);
}
return out;
}
static inline const QStringList pluginFileFilters(Snore::SnorePlugin::PluginTypes type)
{
QStringList out;
foreach(const QString extention, pluginExtentions())
{
out << QString("libsnore_%1_*.%2").arg(typeToString(type).toLower(), extention);
}
return out;
}
static inline QSettings &cache()
{
static QSettings *_cache = NULL;