Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
+51
-29
@@ -8,8 +8,6 @@
|
||||
#include <QDebug>
|
||||
#include <QTranslator>
|
||||
|
||||
#include <odb/sqlite/database.hxx>
|
||||
|
||||
#include "core.h"
|
||||
#include "coreplugin.h"
|
||||
#include "users/users.h"
|
||||
@@ -42,7 +40,7 @@ IPlugin *Context::plugin(const QString &pluginId)
|
||||
return *it;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Context::loadPlugins()
|
||||
@@ -54,13 +52,52 @@ void Context::loadPlugins()
|
||||
|
||||
QDir pluginsDir(qApp->applicationDirPath() + PLUGIN_ROOT);
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QStringList() << "*.so" << "*.dll")) {
|
||||
auto pluginLibs = pluginsDir.entryList(QStringList() << "*.so" << "*.dll" << "*.dylib");
|
||||
QStringList orderedPlugins;
|
||||
QMap<QString, QString> mapIdFiles;
|
||||
QMap<QString, QList<QString>> mapDeps;
|
||||
|
||||
for (auto& libFile : pluginLibs) {
|
||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(libFile));
|
||||
auto metaData = IMetaDataPlugin::loadBaseMetaData(pluginLoader.metaData());
|
||||
mapIdFiles[metaData->getId()] = libFile;
|
||||
|
||||
bool inserted = false;
|
||||
for (auto& dep : metaData->getDependsOn()) {
|
||||
auto index = orderedPlugins.indexOf(mapIdFiles[dep]);
|
||||
|
||||
auto& list = mapDeps[dep];
|
||||
list.append(metaData->getId());
|
||||
|
||||
if (index >= 0 && !orderedPlugins.contains(libFile)) {
|
||||
orderedPlugins.insert(index, libFile);
|
||||
inserted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!inserted) {
|
||||
orderedPlugins.append(libFile);
|
||||
}
|
||||
|
||||
for (const auto& plugin : mapDeps[metaData->getId()]) {
|
||||
auto indexDep = orderedPlugins.indexOf(mapIdFiles[metaData->getId()]);
|
||||
auto indexPlugin = orderedPlugins.indexOf(mapIdFiles[plugin]);
|
||||
|
||||
if (indexPlugin > indexDep) {
|
||||
orderedPlugins.removeAt(indexPlugin);
|
||||
orderedPlugins.insert(indexDep, mapIdFiles[plugin]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const QString& fileName : orderedPlugins) {
|
||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||
QObject *p = pluginLoader.instance();
|
||||
|
||||
if (p != NULL) {
|
||||
if (p != nullptr) {
|
||||
IPlugin *plugin = qobject_cast<IPlugin*>(p);
|
||||
if (plugin != NULL) {
|
||||
if (plugin != nullptr) {
|
||||
m_plugins.append(plugin);
|
||||
plugin->init(pluginLoader.metaData());
|
||||
}
|
||||
@@ -80,16 +117,13 @@ void Context::loadPlugins()
|
||||
|
||||
void Context::openDb(const QString &path)
|
||||
{
|
||||
if (m_db != NULL) {
|
||||
delete m_db;
|
||||
m_solved.clear();
|
||||
m_dbOpened = false;
|
||||
}
|
||||
|
||||
checkDb(path);
|
||||
m_db = new odb::sqlite::database(path.toStdString());
|
||||
auto db = qx::QxSqlDatabase::getSingleton();
|
||||
db->setDriverName("QSQLITE");
|
||||
db->setDatabaseName(path);
|
||||
|
||||
m_settings->setValue("db/path", path);
|
||||
m_dbOpened = true;
|
||||
m_dbOpened = qx::QxSqlDatabase::getDatabase().isOpen();
|
||||
|
||||
checkPermissions();
|
||||
checkSeason();
|
||||
@@ -98,18 +132,6 @@ void Context::openDb(const QString &path)
|
||||
|
||||
void Context::destroy()
|
||||
{
|
||||
if (m_db != NULL)
|
||||
{
|
||||
delete m_db;
|
||||
m_db = NULL;
|
||||
m_dbOpened = false;
|
||||
}
|
||||
|
||||
/*if (m_settings != NULL && m_settings->parent() == NULL)
|
||||
{
|
||||
delete m_settings;
|
||||
}*/
|
||||
|
||||
foreach (IPlugin *plugin, m_plugins)
|
||||
{
|
||||
delete plugin;
|
||||
@@ -124,7 +146,7 @@ QStringList Context::defaultPerms()
|
||||
|
||||
Context::Context()
|
||||
{
|
||||
m_db = NULL;
|
||||
//m_db = NULL;
|
||||
m_settings = new QSettings("itsolved.cz", "prodejna");
|
||||
m_dbOpened = false;
|
||||
}
|
||||
@@ -149,10 +171,10 @@ void Context::setCurrentUser(const QSharedPointer<User> ¤tUser)
|
||||
m_currentUser = currentUser;
|
||||
}
|
||||
|
||||
odb::session &Context::session()
|
||||
/*odb::session &Context::session()
|
||||
{
|
||||
return m_session;
|
||||
}
|
||||
}*/
|
||||
|
||||
void Context::checkDb(const QString &path)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user