#include #include #include #include "context.h" #include "iplugin.h" #include Context &Context::instance() { static Context ctx; return ctx; } QList Context::plugins() { return m_plugins; } void Context::loadPlugins() { QDir pluginsDir(qApp->applicationDirPath() + "/../plugins"); foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so")) { QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName)); QObject *p = pluginLoader.instance(); if (p != NULL) { IPlugin *plugin = qobject_cast(p); if (plugin != NULL) { plugin->init(); m_plugins.append(plugin); } } } } void Context::openDb(const QString &path) { if (m_db != NULL) { delete m_db; } m_db = new odb::sqlite::database(path.toStdString()); } Context::Context() { m_db = NULL; }