Build system changed to Cmake, ORM changed to QxORM, Qt6 compatibility.
This commit is contained in:
@@ -0,0 +1,168 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
project(core)
|
||||
|
||||
include(../3rdparty/QxOrm/QxOrm.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
|
||||
find_package(Qt6 COMPONENTS
|
||||
Core
|
||||
Gui
|
||||
Widgets
|
||||
PrintSupport
|
||||
Sql
|
||||
Qml
|
||||
REQUIRED)
|
||||
|
||||
add_library(core SHARED
|
||||
main.cpp
|
||||
autoform.h
|
||||
autotablemodel.h
|
||||
columndialog.cpp
|
||||
columndialog.h
|
||||
columndialog.ui
|
||||
combodata.cpp
|
||||
combodata.h
|
||||
context.h
|
||||
context.cpp
|
||||
core.h
|
||||
core_global.h
|
||||
coreplugin.cpp
|
||||
coreplugin.h
|
||||
csvimporter.cpp
|
||||
csvimporter.h
|
||||
defaultformhandler.cpp
|
||||
defaultformhandler.h
|
||||
define.h
|
||||
emptystringvalidator.cpp
|
||||
emptystringvalidator.h
|
||||
enums.h
|
||||
exprevaluator.cpp
|
||||
exprevaluator.h
|
||||
filterdialog.cpp
|
||||
filterdialog.h
|
||||
filterdialog.ui
|
||||
filterui.cpp
|
||||
filterui.h
|
||||
filterui.ui
|
||||
formbinder.h
|
||||
formdialog.cpp
|
||||
formdialog.h
|
||||
formdialog.ui
|
||||
gridform.h
|
||||
gridform.ui
|
||||
helper.cpp
|
||||
helper.h
|
||||
idashboardwidget.h
|
||||
iform.cpp
|
||||
iform.h
|
||||
igridform.cpp
|
||||
igridform.h
|
||||
iimporter.h
|
||||
iimportprogress.h
|
||||
imetadataplugin.cpp
|
||||
imetadataplugin.h
|
||||
importdialog.cpp
|
||||
importdialog.h
|
||||
importdialog.ui
|
||||
importprogress.cpp
|
||||
importprogress.h
|
||||
importprogress.ui
|
||||
iplugin.h
|
||||
iservice.cpp
|
||||
iservice.h
|
||||
itablemodel.cpp
|
||||
itablemodel.h
|
||||
ivalidator.h
|
||||
numberseriesservice.cpp
|
||||
numberseriesservice.h
|
||||
objectbinder.cpp
|
||||
objectbinder.h
|
||||
permissionevaluator.cpp
|
||||
permissionevaluator.h
|
||||
permissionservice.cpp
|
||||
permissionservice.h
|
||||
rc.qrc
|
||||
samestringvalidator.cpp
|
||||
samestringvalidator.h
|
||||
savefilterdialog.cpp
|
||||
savefilterdialog.h
|
||||
savefilterdialog.ui
|
||||
seasonservice.cpp
|
||||
seasonservice.h
|
||||
settingsform.cpp
|
||||
settingsform.h
|
||||
settingsform.ui
|
||||
settingsservice.cpp
|
||||
settingsservice.h
|
||||
data/comboitem.cpp
|
||||
data/comboitem.h
|
||||
data/core-data.h
|
||||
data/numberseries.cpp
|
||||
data/numberseries.h
|
||||
data/permission.cpp
|
||||
data/permission.h
|
||||
data/role.cpp
|
||||
data/role.h
|
||||
data/season.cpp
|
||||
data/season.h
|
||||
data/system.cpp
|
||||
data/system.h
|
||||
data/user.cpp
|
||||
data/user.h
|
||||
roles/roles.cpp
|
||||
roles/roles.h
|
||||
roles/rolesform.cpp
|
||||
roles/rolesform.h
|
||||
roles/rolesform.ui
|
||||
roles/rolestablemodel.cpp
|
||||
roles/rolestablemodel.h
|
||||
roles/rolesui.cpp
|
||||
roles/rolesui.h
|
||||
settings/globalsettings.cpp
|
||||
settings/globalsettings.h
|
||||
settings/globalsettingsform.cpp
|
||||
settings/globalsettingsform.h
|
||||
settings/globalsettingsform.ui
|
||||
settings/seasonnamedialog.cpp
|
||||
settings/seasonnamedialog.h
|
||||
settings/seasonnamedialog.ui
|
||||
users/tablemodel.cpp
|
||||
users/tablemodel.h
|
||||
users/userform.cpp
|
||||
users/userform.h
|
||||
users/userform.ui
|
||||
users/users.cpp
|
||||
users/users.h
|
||||
users/usersui.cpp
|
||||
users/usersui.h
|
||||
reporting/report.cpp
|
||||
reporting/report.h
|
||||
reporting/reportdialog.cpp
|
||||
reporting/reportdialog.h
|
||||
reporting/reportdialog.ui
|
||||
reporting/reportviewer.cpp
|
||||
reporting/reportviewer.h
|
||||
reporting/reportviewer.ui
|
||||
reporting/variablefiller.cpp
|
||||
reporting/variablefiller.h)
|
||||
|
||||
target_compile_definitions(core PRIVATE -DCORE_LIBRARY)
|
||||
|
||||
include_directories(../3rdparty/qdecimal/src ../3rdparty/LimeReport/include ../3rdparty/QxOrm/include)
|
||||
|
||||
target_link_libraries(core
|
||||
Qt::Core
|
||||
Qt::Gui
|
||||
Qt::Widgets
|
||||
Qt::PrintSupport
|
||||
Qt::Sql
|
||||
Qt::Qml
|
||||
qdecimal
|
||||
decnumber
|
||||
limereport-qt6
|
||||
QxOrm
|
||||
)
|
||||
+8
-8
@@ -16,13 +16,13 @@ template <class T>
|
||||
class AutoForm : public FormBinder<T>
|
||||
{
|
||||
public:
|
||||
explicit AutoForm(QWidget *parent = 0) {
|
||||
explicit AutoForm(QWidget *parent = nullptr) {
|
||||
this->setParent(parent);
|
||||
m_serviceConnected = false;
|
||||
m_saved = false;
|
||||
}
|
||||
|
||||
virtual ~AutoForm() { }
|
||||
virtual ~AutoForm() = default;
|
||||
|
||||
void setNewRec(bool isNew) {
|
||||
this->m_newRec = isNew;
|
||||
@@ -37,11 +37,11 @@ public slots:
|
||||
|
||||
if (!m_serviceConnected)
|
||||
{
|
||||
this->connect(service(), &IService::dbError, [this](QString msg) {
|
||||
this->connect(service(), &IService::dbError, [this](const QString& msg) {
|
||||
QMessageBox::critical(this, this->tr("Database error"), msg.toStdString().c_str());
|
||||
m_saved = false;
|
||||
});
|
||||
this->connect(service(), &IService::permissionDenied, [this](QString permission) {
|
||||
this->connect(service(), &IService::permissionDenied, [this](const QString& permission) {
|
||||
if (permission != PERM_DELETE) {
|
||||
QMessageBox::critical(this, this->tr("Permission denied"), permission.toStdString().c_str());
|
||||
m_saved = false;
|
||||
@@ -73,15 +73,15 @@ public slots:
|
||||
private:
|
||||
Service<T> *service() {
|
||||
IPlugin *plugin = Context::instance().plugin(this->pluginId());
|
||||
if (plugin == NULL) {
|
||||
if (plugin == nullptr) {
|
||||
Q_ASSERT(false);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Service<T> *service = plugin->service<T>();
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
Q_ASSERT(false);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return service;
|
||||
|
||||
+16
-18
@@ -8,8 +8,6 @@
|
||||
#include <QDebug>
|
||||
#include <QDecDouble.hh>
|
||||
|
||||
#include "../qdecimal/src/QDecDouble.hh"
|
||||
|
||||
#include "define.h"
|
||||
#include "core_global.h"
|
||||
#include "exprevaluator.h"
|
||||
@@ -21,25 +19,25 @@ class AutoTableModel : public ITableModel
|
||||
{
|
||||
|
||||
public:
|
||||
explicit AutoTableModel(QObject *parent = NULL)
|
||||
explicit AutoTableModel(QObject *parent = nullptr)
|
||||
:ITableModel(parent)
|
||||
{
|
||||
filtered = false;
|
||||
m_checkboxSelect = false;
|
||||
}
|
||||
|
||||
virtual ~AutoTableModel() {}
|
||||
~AutoTableModel() override = default;
|
||||
|
||||
// QAbstractItemModel interface
|
||||
public:
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const
|
||||
[[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
return m_list.size();
|
||||
}
|
||||
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const
|
||||
[[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
@@ -50,7 +48,7 @@ public:
|
||||
return colCount;
|
||||
}
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const
|
||||
[[nodiscard]] QVariant data(const QModelIndex &index, int role) const override
|
||||
{
|
||||
if (index.column() == 0 && m_checkboxSelect)
|
||||
{
|
||||
@@ -89,11 +87,11 @@ public:
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if (dispData.canConvert<QDecDouble>()
|
||||
|| dispData.type() == QVariant::Date
|
||||
|| dispData.type() == QVariant::Time
|
||||
|| dispData.type() == QVariant::DateTime
|
||||
|| dispData.type() == QVariant::Int
|
||||
|| dispData.type() == QVariant::Double)
|
||||
|| dispData.typeId() == QMetaType::QDate
|
||||
|| dispData.typeId() == QMetaType::QTime
|
||||
|| dispData.typeId() == QMetaType::QDateTime
|
||||
|| dispData.typeId() == QMetaType::Int
|
||||
|| dispData.typeId() == QMetaType::Double)
|
||||
{
|
||||
return Qt::AlignRight;
|
||||
}
|
||||
@@ -105,7 +103,7 @@ public:
|
||||
return dispData;
|
||||
}
|
||||
|
||||
return QVariant::Invalid;
|
||||
return {};
|
||||
}
|
||||
|
||||
QList<QSharedPointer<T> > list()
|
||||
@@ -113,7 +111,7 @@ public:
|
||||
return m_list;
|
||||
}
|
||||
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const
|
||||
[[nodiscard]] QVariant headerData(int section, Qt::Orientation orientation, int role) const override
|
||||
{
|
||||
if (role != Qt::DisplayRole) {
|
||||
return QVariant();
|
||||
@@ -141,7 +139,7 @@ public:
|
||||
return QVariant(section + 1);
|
||||
}
|
||||
|
||||
virtual void sort(int column, Qt::SortOrder order) {
|
||||
void sort(int column, Qt::SortOrder order) override {
|
||||
if (m_list.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -153,9 +151,9 @@ public:
|
||||
|
||||
std::sort(ALL(m_list), [prop, order](QSharedPointer<T> entA, QSharedPointer<T> entB) -> bool {
|
||||
if (order == Qt::DescendingOrder) {
|
||||
return ((QObject*)entA.data())->property(prop) < ((QObject*)entB.data())->property(prop);
|
||||
return QVariant::compare(((QObject*)entA.data())->property(prop), ((QObject*)entB.data())->property(prop)) == QPartialOrdering::Less;
|
||||
} else {
|
||||
return ((QObject*)entB.data())->property(prop) < ((QObject*)entA.data())->property(prop);
|
||||
return QVariant::compare(((QObject*)entB.data())->property(prop), ((QObject*)entA.data())->property(prop)) == QPartialOrdering::Less;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -276,7 +274,7 @@ private:
|
||||
|
||||
// QAbstractItemModel interface
|
||||
public:
|
||||
virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override
|
||||
{
|
||||
if (role == Qt::EditRole)
|
||||
{
|
||||
|
||||
+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)
|
||||
{
|
||||
|
||||
+2
-8
@@ -11,12 +11,8 @@
|
||||
|
||||
#include "define.h"
|
||||
#include "core_global.h"
|
||||
#include "transaction.h"
|
||||
#include "data/core-data.h"
|
||||
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/session.hxx>
|
||||
|
||||
class IPlugin;
|
||||
|
||||
class CORESHARED_EXPORT Context
|
||||
@@ -28,7 +24,7 @@ public:
|
||||
IPlugin *plugin(const QString &pluginId);
|
||||
void loadPlugins();
|
||||
void openDb(const QString &path);
|
||||
odb::database *db() { return m_db; }
|
||||
void* db() { return nullptr; }
|
||||
QSettings *settings() { return m_settings; }
|
||||
bool dbOpened() { return m_dbOpened; }
|
||||
void destroy();
|
||||
@@ -37,7 +33,7 @@ public:
|
||||
QSharedPointer<User> currentUser() const;
|
||||
void setCurrentUser(const QSharedPointer<User> ¤tUser);
|
||||
|
||||
odb::session &session();
|
||||
//odb::session &session();
|
||||
|
||||
SeasonPtr currentSeason() const;
|
||||
void setCurrentSeason(const SeasonPtr ¤tSeason);
|
||||
@@ -47,10 +43,8 @@ public:
|
||||
private:
|
||||
Context();
|
||||
QList<IPlugin*> m_plugins;
|
||||
odb::database *m_db;
|
||||
QSettings *m_settings;
|
||||
bool m_dbOpened;
|
||||
odb::session m_session;
|
||||
QSharedPointer<User> m_currentUser;
|
||||
SeasonPtr m_currentSeason;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "context.h"
|
||||
#include "iplugin.h"
|
||||
#include "imetadataplugin.h"
|
||||
#include "transaction.h"
|
||||
#include "gridform.h"
|
||||
#include "permissionservice.h"
|
||||
#include "combodata.h"
|
||||
|
||||
-220
@@ -1,220 +0,0 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-10-28T15:25:33
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
#iconset: https://www.iconfinder.com/iconsets/snipicons
|
||||
|
||||
QT += widgets sql printsupport
|
||||
|
||||
TARGET = core
|
||||
TEMPLATE = lib
|
||||
|
||||
DEFINES += CORE_LIBRARY \
|
||||
_GLIBCXX_USE_CXX11_ABI=1
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
SOURCES += \
|
||||
data/user.cpp \
|
||||
context.cpp \
|
||||
imetadataplugin.cpp \
|
||||
transaction.cpp \
|
||||
emptystringvalidator.cpp \
|
||||
data/role.cpp \
|
||||
data/permission.cpp \
|
||||
coreplugin.cpp \
|
||||
igridform.cpp \
|
||||
defaultformhandler.cpp \
|
||||
formdialog.cpp \
|
||||
iform.cpp \
|
||||
users/users.cpp \
|
||||
users/usersui.cpp \
|
||||
users/tablemodel.cpp \
|
||||
users/userform.cpp \
|
||||
columndialog.cpp \
|
||||
roles/rolestablemodel.cpp \
|
||||
roles/roles.cpp \
|
||||
roles/rolesui.cpp \
|
||||
roles/rolesform.cpp \
|
||||
permissionservice.cpp \
|
||||
filterui.cpp \
|
||||
exprevaluator.cpp \
|
||||
samestringvalidator.cpp \
|
||||
savefilterdialog.cpp \
|
||||
filterdialog.cpp \
|
||||
itablemodel.cpp \
|
||||
iservice.cpp \
|
||||
combodata.cpp \
|
||||
data/comboitem.cpp \
|
||||
settingsservice.cpp \
|
||||
data/system.cpp \
|
||||
settings/globalsettings.cpp \
|
||||
settingsform.cpp \
|
||||
settings/globalsettingsform.cpp \
|
||||
permissionevaluator.cpp \
|
||||
objectbinder.cpp \
|
||||
data/numberseries.cpp \
|
||||
data/season.cpp \
|
||||
seasonservice.cpp \
|
||||
numberseriesservice.cpp \
|
||||
settings/seasonnamedialog.cpp \
|
||||
reporting/report.cpp \
|
||||
reporting/reportviewer.cpp \
|
||||
reporting/reportdialog.cpp \
|
||||
csvimporter.cpp \
|
||||
importdialog.cpp \
|
||||
importprogress.cpp \
|
||||
reporting/variablefiller.cpp \
|
||||
helper.cpp
|
||||
|
||||
HEADERS += core.h\
|
||||
core_global.h \
|
||||
iplugin.h \
|
||||
service.h \
|
||||
data/user.h \
|
||||
context.h \
|
||||
imetadataplugin.h \
|
||||
autotablemodel.h \
|
||||
autoform.h \
|
||||
transaction.h \
|
||||
ivalidator.h \
|
||||
emptystringvalidator.h \
|
||||
data/role.h \
|
||||
data/permission.h \
|
||||
data/core-data.h \
|
||||
coreplugin.h \
|
||||
define.h \
|
||||
gridform.h \
|
||||
igridform.h \
|
||||
defaultformhandler.h \
|
||||
formdialog.h \
|
||||
iform.h \
|
||||
users/users.h \
|
||||
users/usersui.h \
|
||||
users/tablemodel.h \
|
||||
users/userform.h \
|
||||
columndialog.h \
|
||||
roles/rolestablemodel.h \
|
||||
roles/roles.h \
|
||||
roles/rolesui.h \
|
||||
roles/rolesform.h \
|
||||
permissionservice.h \
|
||||
filterui.h \
|
||||
exprevaluator.h \
|
||||
samestringvalidator.h \
|
||||
savefilterdialog.h \
|
||||
filterdialog.h \
|
||||
itablemodel.h \
|
||||
data/core_global.h \
|
||||
iservice.h \
|
||||
combodata.h \
|
||||
data/comboitem.h \
|
||||
settingsservice.h \
|
||||
data/system.h \
|
||||
enums.h \
|
||||
settings/globalsettings.h \
|
||||
settingsform.h \
|
||||
settings/globalsettingsform.h \
|
||||
formbinder.h \
|
||||
permissionevaluator.h \
|
||||
objectbinder.h \
|
||||
data/numberseries.h \
|
||||
data/season.h \
|
||||
seasonservice.h \
|
||||
numberseriesservice.h \
|
||||
settings/seasonnamedialog.h \
|
||||
reporting/report.h \
|
||||
reporting/reportviewer.h \
|
||||
reporting/reportdialog.h \
|
||||
iimporter.h \
|
||||
csvimporter.h \
|
||||
iimportprogress.h \
|
||||
importdialog.h \
|
||||
importprogress.h \
|
||||
reporting/variablefiller.h \
|
||||
helper.h \
|
||||
idashboardwidget.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
QMAKE_CXXFLAGS += -Wno-unknown-pragmas
|
||||
}
|
||||
|
||||
win32 {
|
||||
QMAKE_CXXFLAGS += -wd4995 -wd4068
|
||||
}
|
||||
|
||||
ODB_FILES = core/data/core-data.h
|
||||
H_DIR = $$PWD/data/*.h
|
||||
include(../odb.pri)
|
||||
|
||||
RESOURCES += \
|
||||
rc.qrc
|
||||
|
||||
DISTFILES += \
|
||||
metaData.json
|
||||
|
||||
FORMS += \
|
||||
gridform.ui \
|
||||
formdialog.ui \
|
||||
users/userform.ui \
|
||||
columndialog.ui \
|
||||
roles/rolesform.ui \
|
||||
filterui.ui \
|
||||
savefilterdialog.ui \
|
||||
filterdialog.ui \
|
||||
settingsform.ui \
|
||||
settings/globalsettingsform.ui \
|
||||
settings/seasonnamedialog.ui \
|
||||
reporting/reportviewer.ui \
|
||||
reporting/reportdialog.ui \
|
||||
importdialog.ui \
|
||||
importprogress.ui
|
||||
|
||||
OTHER_FILES += \
|
||||
users/metaData.json \
|
||||
roles/metaData.json
|
||||
|
||||
CONFIG(debug, release|debug):DEFINES += _DEBUG
|
||||
|
||||
win32:CONFIG(release, debug|release):DEFINES += PLUGIN_ROOT=\\\"/plugins\\\"
|
||||
else:unix:CONFIG(release, debug|release):DEFINES += PLUGIN_ROOT=\\\"/usr/lib/prodejna/plugins\\\"
|
||||
|
||||
win32:CONFIG(release, debug|release):DEFINES += REPORT_ROOT=\\\"/reports\\\"
|
||||
else:unix:CONFIG(release, debug|release):DEFINES += REPORT_ROOT=\\\"/usr/share/prodejna/reports\\\"
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
|
||||
INCLUDEPATH += $$PWD/../qdecimal/src
|
||||
INCLUDEPATH += $$PWD/../qdecimal/decnumber
|
||||
|
||||
unix{
|
||||
ARCH_TYPE = unix
|
||||
macx{
|
||||
ARCH_TYPE = macx
|
||||
}
|
||||
linux{
|
||||
!contains(QT_ARCH, x86_64){
|
||||
ARCH_TYPE = linux32
|
||||
}else{
|
||||
ARCH_TYPE = linux64
|
||||
}
|
||||
}
|
||||
}
|
||||
win32 {
|
||||
ARCH_TYPE = win32
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/release/lib/ -llimereport
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/ -llimereport
|
||||
else:unix: LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/ -llimereport
|
||||
|
||||
INCLUDEPATH += $$PWD/../../LimeReport/include
|
||||
DEPENDPATH += $$PWD/../../LimeReport/include
|
||||
|
||||
TRANSLATIONS = translations/core_cs_CZ.ts
|
||||
@@ -2,6 +2,7 @@
|
||||
#define CORE_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QxOrm.h>
|
||||
|
||||
#if defined(CORE_LIBRARY)
|
||||
# define CORESHARED_EXPORT Q_DECL_EXPORT
|
||||
@@ -9,4 +10,12 @@
|
||||
# define CORESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#ifdef CORE_LIBRARY
|
||||
#define QX_REGISTER_HPP_CORE QX_REGISTER_HPP_EXPORT_DLL
|
||||
#define QX_REGISTER_CPP_CORE QX_REGISTER_CPP_EXPORT_DLL
|
||||
#else // CORE_LIBRARY
|
||||
#define QX_REGISTER_HPP_CORE QX_REGISTER_HPP_IMPORT_DLL
|
||||
#define QX_REGISTER_CPP_CORE QX_REGISTER_CPP_IMPORT_DLL
|
||||
#endif
|
||||
|
||||
#endif // CORE_GLOBAL_H
|
||||
|
||||
+2
-6
@@ -16,14 +16,10 @@ CorePlugin::CorePlugin()
|
||||
f.close();
|
||||
}
|
||||
|
||||
CorePlugin::~CorePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
void CorePlugin::initServiceUi()
|
||||
{
|
||||
m_service = NULL;
|
||||
m_ui = NULL;
|
||||
m_service = nullptr;
|
||||
m_ui = nullptr;
|
||||
m_settingsUi = new GlobalSettingsForm();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -7,11 +7,11 @@ class CorePlugin : public IMetaDataPlugin
|
||||
{
|
||||
public:
|
||||
CorePlugin();
|
||||
~CorePlugin();
|
||||
~CorePlugin() override = default;
|
||||
|
||||
// IMetaDataPlugin interface
|
||||
protected:
|
||||
virtual void initServiceUi();
|
||||
void initServiceUi() override;
|
||||
|
||||
// IPlugin interface
|
||||
public:
|
||||
|
||||
@@ -35,7 +35,7 @@ QSharedPointer<QObject> CsvImporter::nextRecord()
|
||||
|
||||
QObject *entity = m_metaObject->newInstance();
|
||||
|
||||
if (entity == NULL || m_currentRec > recordCount())
|
||||
if (entity == nullptr || m_currentRec > recordCount())
|
||||
{
|
||||
++m_currentRec;
|
||||
return QSharedPointer<QObject>();
|
||||
|
||||
+5
-5
@@ -10,14 +10,14 @@ class CORESHARED_EXPORT CsvImporter : public QObject, public IImporter
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CsvImporter(const QMetaObject *metaObject, QObject *parent = NULL);
|
||||
explicit CsvImporter(const QMetaObject *metaObject, QObject *parent = nullptr);
|
||||
|
||||
// IImporter interface
|
||||
public:
|
||||
void setImportFile(const QString &fileName);
|
||||
int recordCount();
|
||||
QSharedPointer<QObject> nextRecord();
|
||||
bool isError();
|
||||
void setImportFile(const QString &fileName) override;
|
||||
int recordCount() override;
|
||||
QSharedPointer<QObject> nextRecord() override;
|
||||
bool isError() override;
|
||||
|
||||
void setSeparator(const QString &separator);
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
#include "comboitem.h"
|
||||
|
||||
QX_REGISTER_CPP_CORE(ComboItem)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<ComboItem>&) {
|
||||
}
|
||||
}
|
||||
|
||||
ComboItem::ComboItem(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef COMBOITEM_H
|
||||
#define COMBOITEM_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
#include <QSharedPointer>
|
||||
#include <QVariant>
|
||||
#include <QObject>
|
||||
@@ -18,4 +18,6 @@ public:
|
||||
virtual QString toString() = 0;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_CORE(ComboItem, QObject, 0)
|
||||
|
||||
#endif // COMBOITEM_H
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef CORE_GLOBAL_H
|
||||
#define CORE_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(CORE_LIBRARY)
|
||||
# define CORESHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define CORESHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // CORE_GLOBAL_H
|
||||
@@ -2,18 +2,32 @@
|
||||
#include "../context.h"
|
||||
#include "../iplugin.h"
|
||||
|
||||
QX_REGISTER_CPP_CORE(NumberSeries)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<NumberSeries>& t) {
|
||||
t.setName("NumberSeries");
|
||||
t.id(&NumberSeries::m_id, "id");
|
||||
t.data(&NumberSeries::m_prefix, "prefix");
|
||||
t.data(&NumberSeries::m_lastNumber, "lastNumber");
|
||||
t.data(&NumberSeries::m_pluginId, "pluginId");
|
||||
|
||||
t.relationManyToOne(&NumberSeries::m_season, "season");
|
||||
}
|
||||
}
|
||||
|
||||
NumberSeries::NumberSeries(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_id = 0;
|
||||
m_lastNumber = 0;
|
||||
}
|
||||
|
||||
int NumberSeries::id() const
|
||||
long NumberSeries::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void NumberSeries::setId(int id)
|
||||
void NumberSeries::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
@@ -71,5 +85,9 @@ QString NumberSeries::seasonName() const
|
||||
QString NumberSeries::pluginName() const
|
||||
{
|
||||
IPlugin *plugin = Context::instance().plugin(m_pluginId);
|
||||
return plugin != NULL ? plugin->pluginName() : "";
|
||||
return plugin != nullptr ? plugin->pluginName() : "";
|
||||
}
|
||||
|
||||
QStringList NumberSeries::eagerLoad() {
|
||||
return { "season" };
|
||||
}
|
||||
@@ -3,16 +3,17 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QStringList>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <QxOrm.h>
|
||||
|
||||
#include "season.h"
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT NumberSeries : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QX_REGISTER_FRIEND_CLASS(NumberSeries)
|
||||
Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
|
||||
Q_PROPERTY(int lastNumber READ lastNumber WRITE setLastNumber)
|
||||
Q_PROPERTY(QString pluginName READ pluginName)
|
||||
@@ -20,8 +21,8 @@ class CORESHARED_EXPORT NumberSeries : public QObject
|
||||
public:
|
||||
explicit NumberSeries(QObject *parent = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString prefix() const;
|
||||
void setPrefix(const QString &prefix);
|
||||
@@ -39,11 +40,10 @@ public:
|
||||
|
||||
QString pluginName() const;
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
Q_INVOKABLE QStringList eagerLoad();
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
private:
|
||||
long m_id;
|
||||
QString m_prefix;
|
||||
int m_lastNumber;
|
||||
QString m_pluginId;
|
||||
@@ -52,4 +52,6 @@ private:
|
||||
|
||||
typedef QSharedPointer<NumberSeries> NumberSeriesPtr;
|
||||
|
||||
QX_REGISTER_HPP_CORE(NumberSeries, QObject, 0)
|
||||
|
||||
#endif // NUMBERSERIES_H
|
||||
|
||||
@@ -1,15 +1,31 @@
|
||||
#include "permission.h"
|
||||
|
||||
QX_REGISTER_CPP_CORE(Permission)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<Permission>& t) {
|
||||
t.setName("Permission");
|
||||
t.id(&Permission::m_id, "id");
|
||||
t.data(&Permission::m_pluginId, "pluginId");
|
||||
t.data(&Permission::m_permissionName, "permissionName");
|
||||
t.data(&Permission::m_lastModDate, "lastModDate");
|
||||
t.data(&Permission::m_createDate, "createDate");
|
||||
t.data(&Permission::m_active, "active");
|
||||
|
||||
t.relationManyToMany(&Permission::m_listRoles, "object_id_fk", "Role_listPermissions", "value", "object_id");
|
||||
}
|
||||
}
|
||||
|
||||
Permission::Permission(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
int Permission::id() const
|
||||
long Permission::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Permission::setId(int id)
|
||||
void Permission::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
@@ -58,12 +74,12 @@ void Permission::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
QList<QWeakPointer<Role> > Permission::listRoles() const
|
||||
QList<QSharedPointer<Role> > Permission::listRoles() const
|
||||
{
|
||||
return m_listRoles;
|
||||
}
|
||||
|
||||
void Permission::setListRoles(const QList<QWeakPointer<Role> > &listRoles)
|
||||
void Permission::setListRoles(const QList<QSharedPointer<Role> > &listRoles)
|
||||
{
|
||||
m_listRoles = listRoles;
|
||||
}
|
||||
|
||||
+12
-15
@@ -2,30 +2,29 @@
|
||||
#define PERMISSION_H
|
||||
|
||||
#include "core-data.h"
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QWeakPointer>
|
||||
#include <QDateTime>
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/qt/list.hxx>
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT Permission : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(Permission)
|
||||
Q_PROPERTY(QString pluginId READ pluginId WRITE setPluginId)
|
||||
Q_PROPERTY(QString permissionName READ permissionName WRITE setPermissionName)
|
||||
Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate)
|
||||
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
|
||||
Q_PROPERTY(bool active READ active WRITE setActive)
|
||||
public:
|
||||
explicit Permission(QObject *parent = 0);
|
||||
explicit Permission(QObject *parent = nullptr);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString pluginId() const;
|
||||
void setPluginId(const QString &pluginId);
|
||||
@@ -42,24 +41,22 @@ public:
|
||||
bool active() const;
|
||||
void setActive(bool active);
|
||||
|
||||
QList<QWeakPointer<Role> > listRoles() const;
|
||||
void setListRoles(const QList<QWeakPointer<Role> > &listRoles);
|
||||
QList<QSharedPointer<Role>> listRoles() const;
|
||||
void setListRoles(const QList<QSharedPointer<Role>> &listRoles);
|
||||
|
||||
void addRole(QSharedPointer<Role> role);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id;
|
||||
QString m_pluginId;
|
||||
QString m_permissionName;
|
||||
QDateTime m_lastModDate;
|
||||
QDateTime m_createDate;
|
||||
bool m_active;
|
||||
#pragma db value_not_null inverse(m_listPermissions)
|
||||
QOdbList<QWeakPointer<Role> > m_listRoles;
|
||||
QList<QSharedPointer<Role>> m_listRoles;
|
||||
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_CORE(Permission, QObject, 0)
|
||||
|
||||
#endif // PERMISSION_H
|
||||
|
||||
+21
-4
@@ -1,15 +1,32 @@
|
||||
#include "role.h"
|
||||
|
||||
QX_REGISTER_CPP_CORE(Role)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<Role>& t) {
|
||||
t.setName("Role");
|
||||
t.id(&Role::m_id, "id");
|
||||
t.data(&Role::m_name, "name");
|
||||
t.data(&Role::m_lastModDate, "lastModDate");
|
||||
t.data(&Role::m_createDate, "createDate");
|
||||
t.data(&Role::m_active, "active");
|
||||
|
||||
t.relationManyToMany(&Role::m_listPermissions, "object_id_fk", "Role_listPermissions", "object_id", "value");
|
||||
t.relationManyToMany(&Role::m_listUsers, "value_fk", "User_listRoles", "value", "object_id");
|
||||
}
|
||||
}
|
||||
|
||||
Role::Role(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
int Role::id() const
|
||||
|
||||
long Role::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Role::setId(int id)
|
||||
void Role::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
@@ -49,12 +66,12 @@ void Role::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
QList<QWeakPointer<User> > Role::listUsers() const
|
||||
QList<QSharedPointer<User> > Role::listUsers() const
|
||||
{
|
||||
return m_listUsers;
|
||||
}
|
||||
|
||||
void Role::setListUsers(const QList<QWeakPointer<User> > &listUsers)
|
||||
void Role::setListUsers(const QList<QSharedPointer<User> > &listUsers)
|
||||
{
|
||||
m_listUsers = listUsers;
|
||||
}
|
||||
|
||||
+12
-16
@@ -2,20 +2,19 @@
|
||||
#define ROLE_H
|
||||
|
||||
#include "core-data.h"
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QWeakPointer>
|
||||
#include <QDateTime>
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/qt/list.hxx>
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT Role : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(Role)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QDateTime lastModDate READ lastModDate WRITE setLastModDate)
|
||||
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
|
||||
@@ -23,8 +22,8 @@ class CORESHARED_EXPORT Role : public QObject
|
||||
public:
|
||||
explicit Role(QObject *parent = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
@@ -38,8 +37,8 @@ public:
|
||||
bool active() const;
|
||||
void setActive(bool active);
|
||||
|
||||
QList<QWeakPointer<User> > listUsers() const;
|
||||
void setListUsers(const QList<QWeakPointer<User> > &listUsers);
|
||||
QList<QSharedPointer<User> > listUsers() const;
|
||||
void setListUsers(const QList<QSharedPointer<User> > &listUsers);
|
||||
|
||||
QList<QSharedPointer<Permission> > listPermissions() const;
|
||||
void setListPermissions(const QList<QSharedPointer<Permission> > &listPermissions);
|
||||
@@ -48,18 +47,15 @@ public:
|
||||
void clearPermissions();
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id;
|
||||
QString m_name;
|
||||
QDateTime m_lastModDate;
|
||||
QDateTime m_createDate;
|
||||
bool m_active;
|
||||
#pragma db value_not_null inverse(m_listRoles)
|
||||
QOdbList<QWeakPointer<User> > m_listUsers;
|
||||
#pragma db value_not_null
|
||||
QOdbList<QSharedPointer<Permission> > m_listPermissions;
|
||||
QList<QSharedPointer<User> > m_listUsers;
|
||||
QList<QSharedPointer<Permission> > m_listPermissions;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_CORE(Role, QObject, 0)
|
||||
|
||||
#endif // ROLE_H
|
||||
|
||||
+15
-2
@@ -1,5 +1,18 @@
|
||||
#include "season.h"
|
||||
|
||||
QX_REGISTER_CPP_CORE(Season)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<Season> & t)
|
||||
{
|
||||
t.setName("Season");
|
||||
t.id(& Season::m_id, "id");
|
||||
t.data(& Season::m_name, "name");
|
||||
t.data(& Season::m_validFrom, "validFrom");
|
||||
t.data(& Season::m_validTo, "validTo");
|
||||
t.data(& Season::m_active, "active");
|
||||
}}
|
||||
|
||||
Season::Season(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
@@ -47,12 +60,12 @@ void Season::setActive(bool active)
|
||||
m_active = active;
|
||||
}
|
||||
|
||||
int Season::id() const
|
||||
long Season::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Season::setId(int id)
|
||||
void Season::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
+10
-11
@@ -1,24 +1,23 @@
|
||||
#ifndef SEASON_H
|
||||
#define SEASON_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QDate>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT Season : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
QX_REGISTER_FRIEND_CLASS(Season)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QDate validFrom READ validFrom WRITE setValidFrom)
|
||||
Q_PROPERTY(QDate validTo READ validTo WRITE setValidTo)
|
||||
Q_PROPERTY(bool active READ active WRITE setActive)
|
||||
|
||||
public:
|
||||
explicit Season(QObject *parent = 0);
|
||||
explicit Season(QObject *parent = nullptr);
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &name);
|
||||
@@ -32,14 +31,11 @@ public:
|
||||
bool active() const;
|
||||
void setActive(bool active);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id;
|
||||
QString m_name;
|
||||
QDate m_validFrom;
|
||||
QDate m_validTo;
|
||||
@@ -48,4 +44,7 @@ private:
|
||||
|
||||
typedef QSharedPointer<Season> SeasonPtr;
|
||||
|
||||
QX_REGISTER_HPP_CORE(Season, QObject, 0)
|
||||
|
||||
|
||||
#endif // SEASON_H
|
||||
|
||||
+15
-2
@@ -1,4 +1,17 @@
|
||||
#include "system.h"
|
||||
#include <QxOrm_Impl.h>
|
||||
|
||||
QX_REGISTER_CPP_CORE(System)
|
||||
|
||||
namespace qx {
|
||||
template <> void register_class(QxClass<System> & t)
|
||||
{
|
||||
t.setName("system");
|
||||
t.id(& System::m_id, "id");
|
||||
t.data(& System::m_pluginId, "pluginId");
|
||||
t.data(& System::m_schemaVersion, "schemaVersion");
|
||||
t.data(& System::m_settings, "settings");
|
||||
}}
|
||||
|
||||
System::System()
|
||||
{
|
||||
@@ -10,12 +23,12 @@ System::~System()
|
||||
|
||||
}
|
||||
|
||||
int System::id() const
|
||||
long System::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void System::setId(int id)
|
||||
void System::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
+7
-10
@@ -1,20 +1,18 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
#include <QString>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT System
|
||||
{
|
||||
QX_REGISTER_FRIEND_CLASS(System)
|
||||
public:
|
||||
System();
|
||||
virtual ~System();
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString pluginId() const;
|
||||
|
||||
@@ -24,13 +22,12 @@ public:
|
||||
void setSettings(const QString &settings);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id;
|
||||
QString m_pluginId;
|
||||
QString m_schemaVersion;
|
||||
QString m_settings;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_CORE(System, qx::trait::no_base_class_defined, 0);
|
||||
|
||||
#endif // SYSTEM_H
|
||||
|
||||
+19
-4
@@ -1,14 +1,29 @@
|
||||
#include "user.h"
|
||||
|
||||
User::User()
|
||||
{
|
||||
QX_REGISTER_CPP_CORE(User)
|
||||
|
||||
namespace qx {
|
||||
template<> void register_class(QxClass<User>& t) {
|
||||
t.setName("User");
|
||||
t.id(&User::m_id, "id");
|
||||
t.data(&User::m_login, "login");
|
||||
t.data(&User::m_password, "password");
|
||||
t.data(&User::m_name, "name");
|
||||
t.data(&User::m_lastModDate, "lastModDate");
|
||||
t.data(&User::m_createDate, "createDate");
|
||||
t.data(&User::m_active, "active");
|
||||
t.data(&User::m_isAdmin, "isAdmin");
|
||||
|
||||
t.relationManyToMany(&User::m_listRoles, "object_id_fk", "User_listRoles", "object_id", "value");
|
||||
}
|
||||
}
|
||||
int User::id() const
|
||||
|
||||
long User::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void User::setId(int id)
|
||||
void User::setId(long id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
+10
-14
@@ -2,20 +2,19 @@
|
||||
#define USER_H
|
||||
|
||||
#include "core-data.h"
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QList>
|
||||
#include <QDateTime>
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/qt/list.hxx>
|
||||
|
||||
#pragma db object
|
||||
class CORESHARED_EXPORT User : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QX_REGISTER_FRIEND_CLASS(User)
|
||||
Q_PROPERTY(QString login READ login WRITE setLogin)
|
||||
Q_PROPERTY(QString password READ password WRITE setPassword)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
@@ -25,11 +24,10 @@ class CORESHARED_EXPORT User : public QObject
|
||||
Q_PROPERTY(QDateTime createDate READ createDate WRITE setCreateDate)
|
||||
|
||||
public:
|
||||
User();
|
||||
User() = default;
|
||||
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
long id() const;
|
||||
void setId(long id);
|
||||
|
||||
QString login() const;
|
||||
void setLogin(const QString &login);
|
||||
@@ -61,10 +59,7 @@ public:
|
||||
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
long m_id;
|
||||
QString m_login;
|
||||
QString m_password;
|
||||
QString m_name;
|
||||
@@ -72,8 +67,9 @@ private:
|
||||
QDateTime m_createDate;
|
||||
bool m_active;
|
||||
bool m_isAdmin;
|
||||
#pragma db value_not_null
|
||||
QOdbList<QSharedPointer<Role> > m_listRoles;
|
||||
QList<QSharedPointer<Role> > m_listRoles;
|
||||
};
|
||||
|
||||
QX_REGISTER_HPP_CORE(User, QObject, 0)
|
||||
|
||||
#endif // USER_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "defaultformhandler.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QScreen>
|
||||
#include <QRect>
|
||||
|
||||
DefaultFormHandler::DefaultFormHandler()
|
||||
@@ -19,7 +19,12 @@ void DefaultFormHandler::showForm(IForm *formWidget)
|
||||
formWidget->onShow();
|
||||
m_dialog->setForm(formWidget);
|
||||
m_dialog->setModal(true);
|
||||
m_dialog->move(QApplication::desktop()->screen()->rect().center() - m_dialog->rect().center());
|
||||
auto screen = m_dialog->screen();
|
||||
|
||||
if (screen) {
|
||||
m_dialog->move(screen->availableGeometry().center() - m_dialog->rect().center());
|
||||
}
|
||||
|
||||
m_dialog->show();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
class CORESHARED_EXPORT IFormHandler
|
||||
{
|
||||
public:
|
||||
IFormHandler() {}
|
||||
virtual ~IFormHandler() {}
|
||||
IFormHandler() = default;
|
||||
virtual ~IFormHandler() = default;
|
||||
|
||||
virtual void showForm(IForm *formWidget) = 0;
|
||||
};
|
||||
@@ -19,7 +19,7 @@ class CORESHARED_EXPORT DefaultFormHandler : public IFormHandler
|
||||
{
|
||||
public:
|
||||
DefaultFormHandler();
|
||||
virtual ~DefaultFormHandler();
|
||||
~DefaultFormHandler() override;
|
||||
|
||||
private:
|
||||
FormDialog *m_dialog;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
|
||||
#define DEC_MULTIPLE 100
|
||||
#define TO_DEC(num) (QDecDouble(num) / QDecDouble(DEC_MULTIPLE))
|
||||
#define FROM_DEC(num) (num * QDecDouble(DEC_MULTIPLE)).toInt32()
|
||||
#define FROM_DEC(num) (num * QDecDouble(DEC_MULTIPLE)).toDouble()
|
||||
|
||||
#ifndef PLUGIN_ROOT
|
||||
#ifdef _WIN32
|
||||
|
||||
+4
-5
@@ -8,8 +8,6 @@ class CORESHARED_EXPORT Enums : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_ENUMS(VatType)
|
||||
Q_ENUMS(Rounding)
|
||||
public:
|
||||
|
||||
enum VatType
|
||||
@@ -28,9 +26,10 @@ public:
|
||||
R_MATH
|
||||
};
|
||||
|
||||
Enums()
|
||||
{
|
||||
}
|
||||
Q_ENUM(VatType)
|
||||
Q_ENUM(Rounding)
|
||||
|
||||
Enums() = default;
|
||||
|
||||
};
|
||||
#endif // ENUMS_H
|
||||
|
||||
+10
-4
@@ -19,10 +19,16 @@ ExprEvaluator::ExprEvaluator()
|
||||
const QMap<QString, std::function<bool(QVariant, QVariant)> > ExprEvaluator::m_operations = {
|
||||
{ "==", [](QVariant left, QVariant right) { return left == right; }},
|
||||
{ "!=", [](QVariant left, QVariant right) { return left != right; }},
|
||||
{ "<", [](QVariant left, QVariant right) { return left < right; }},
|
||||
{ "<=", [](QVariant left, QVariant right) { return left <= right; }},
|
||||
{ ">", [](QVariant left, QVariant right) { return left > right; }},
|
||||
{ ">=", [](QVariant left, QVariant right) { return left >= right; }},
|
||||
{ "<", [](QVariant left, QVariant right) { return QVariant::compare(left, right) == QPartialOrdering::Less; }},
|
||||
{ "<=", [](QVariant left, QVariant right) {
|
||||
auto res = QVariant::compare(left, right);
|
||||
return res == QPartialOrdering::Less || res == QPartialOrdering::Equivalent;
|
||||
}},
|
||||
{ ">", [](QVariant left, QVariant right) { return QVariant::compare(left, right) == QPartialOrdering::Greater; }},
|
||||
{ ">=", [](QVariant left, QVariant right) {
|
||||
auto res = QVariant::compare(left, right);
|
||||
return res == QPartialOrdering::Greater || res == QPartialOrdering::Equivalent;
|
||||
}},
|
||||
{ "%", [](QVariant left, QVariant right) { return left.toString().contains(right.toString()); }},
|
||||
|
||||
{ "||", [](QVariant left, QVariant right) { return left.toBool() || right.toBool(); }},
|
||||
|
||||
+8
-8
@@ -185,31 +185,31 @@ void FilterUi::propertyChanged(int row, QComboBox *oper, int index)
|
||||
|
||||
oper->clear();
|
||||
|
||||
switch (this->m_entity->metaObject()->property(index + 1).type()) {
|
||||
case QVariant::Bool:
|
||||
switch (this->m_entity->metaObject()->property(index + 1).typeId()) {
|
||||
case QMetaType::Bool:
|
||||
oper->addItems(QStringList() << "==" << "!=");
|
||||
cellWidget = new QComboBox(this);
|
||||
qobject_cast<QComboBox*>(cellWidget)->addItem("true", 1);
|
||||
qobject_cast<QComboBox*>(cellWidget)->addItem("false", 0);
|
||||
break;
|
||||
case QVariant::String:
|
||||
case QMetaType::QString:
|
||||
oper->addItems(QStringList() << "==" << "%" << "!=" << "<" << "<=" << ">" << ">=");
|
||||
cellWidget = new QLineEdit(this);
|
||||
break;
|
||||
case QVariant::Int:
|
||||
case QMetaType::Int:
|
||||
oper->addItems(QStringList() << "==" << "!=" << "<" << "<=" << ">" << ">=");
|
||||
cellWidget = new QSpinBox(this);
|
||||
break;
|
||||
case QVariant::Double:
|
||||
case QMetaType::Double:
|
||||
oper->addItems(QStringList() << "==" << "!=" << "<" << "<=" << ">" << ">=");
|
||||
cellWidget = new QDoubleSpinBox(this);
|
||||
break;
|
||||
case QVariant::Date:
|
||||
case QMetaType::QDate:
|
||||
oper->addItems(QStringList() << "==" << "!=" << "<" << "<=" << ">" << ">=");
|
||||
cellWidget = new QDateEdit(this);
|
||||
qobject_cast<QDateEdit*>(cellWidget)->setCalendarPopup(true);
|
||||
break;
|
||||
case QVariant::DateTime:
|
||||
case QMetaType::QDateTime:
|
||||
oper->addItems(QStringList() << "==" << "!=" << "<" << "<=" << ">" << ">=");
|
||||
cellWidget = new QDateTimeEdit(this);
|
||||
qobject_cast<QDateTimeEdit*>(cellWidget)->setCalendarPopup(true);
|
||||
@@ -220,7 +220,7 @@ void FilterUi::propertyChanged(int row, QComboBox *oper, int index)
|
||||
break;
|
||||
}
|
||||
|
||||
if (cellWidget != NULL)
|
||||
if (cellWidget != nullptr)
|
||||
{
|
||||
ui->tableWidget->setCellWidget(row, 3, cellWidget);
|
||||
}
|
||||
|
||||
+3
-5
@@ -13,22 +13,20 @@
|
||||
#include "iform.h"
|
||||
#include "objectbinder.h"
|
||||
|
||||
#include "../qdecimal/src/QDecDouble.hh"
|
||||
#include <QDecDouble.hh>
|
||||
|
||||
template<class T>
|
||||
class FormBinder : public IForm
|
||||
{
|
||||
public:
|
||||
|
||||
explicit FormBinder(QWidget *parent = NULL) : IForm(parent) {
|
||||
explicit FormBinder(QWidget *parent = nullptr) : IForm(parent) {
|
||||
connect(&m_binder, &ObjectBinder::validationError, [this](QString msg){
|
||||
emit this->validationError(msg);
|
||||
});
|
||||
}
|
||||
|
||||
virtual ~FormBinder() {
|
||||
|
||||
}
|
||||
~FormBinder() override = default;
|
||||
|
||||
void registerBinding(QWidget *widget) {
|
||||
m_binder.registerBinding(widget);
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ private slots:
|
||||
|
||||
// QDialog interface
|
||||
public slots:
|
||||
void accept();
|
||||
void accept() override;
|
||||
|
||||
// QDialog interface
|
||||
public slots:
|
||||
|
||||
+15
-13
@@ -6,7 +6,7 @@
|
||||
#include <QHeaderView>
|
||||
#include <QLayout>
|
||||
#include <QToolButton>
|
||||
#include <QDesktopWidget>
|
||||
//#include <QDesktopWidget>
|
||||
|
||||
#include "autoform.h"
|
||||
#include "autotablemodel.h"
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
filterWidget()->layout()->addWidget(m_filterUi);
|
||||
}
|
||||
|
||||
virtual ~GridForm()
|
||||
~GridForm() override
|
||||
{
|
||||
if (m_form != NULL && m_form->parent() == NULL)
|
||||
{
|
||||
@@ -84,13 +84,13 @@ public:
|
||||
m_formHandler = handler;
|
||||
}
|
||||
|
||||
virtual void setTranslations(const QMap<QString, QString> &translations) {
|
||||
void setTranslations(const QMap<QString, QString> &translations) override {
|
||||
Q_ASSERT(m_tableModel != NULL);
|
||||
m_tableModel->setTranslations(translations);
|
||||
}
|
||||
|
||||
public slots:
|
||||
bool fillData() {
|
||||
bool fillData() override {
|
||||
if (m_tableModel == NULL) {
|
||||
Q_ASSERT(false);
|
||||
return false;
|
||||
@@ -131,13 +131,13 @@ private:
|
||||
|
||||
Service<T> *service() {
|
||||
IPlugin *plugin = Context::instance().plugin(pluginId());
|
||||
if (plugin == NULL) {
|
||||
if (plugin == nullptr) {
|
||||
Q_ASSERT(false);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Service<T> *service = plugin->service<T>();
|
||||
if (service == NULL) {
|
||||
if (service == nullptr) {
|
||||
Q_ASSERT(false);
|
||||
return NULL;
|
||||
}
|
||||
@@ -176,14 +176,14 @@ private slots:
|
||||
|
||||
// IGridForm interface
|
||||
protected:
|
||||
virtual void handleNewRecord() override
|
||||
void handleNewRecord() override
|
||||
{
|
||||
if (!checkPermAdd())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_form == NULL)
|
||||
if (m_form == nullptr)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
@@ -194,20 +194,22 @@ protected:
|
||||
m_formHandler->showForm(m_form);
|
||||
}
|
||||
|
||||
virtual void handleEditRecord() override
|
||||
void handleEditRecord() override
|
||||
{
|
||||
if (!checkPermEdit())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)
|
||||
if (m_form == nullptr || m_tableModel == nullptr || tableView()->currentIndex().row() < 0)
|
||||
{
|
||||
Q_ASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
form()->setEntity(m_tableModel->itemFromIndex(tableView()->currentIndex()));
|
||||
auto entity = m_tableModel->itemFromIndex(tableView()->currentIndex());
|
||||
service()->load(entity);
|
||||
form()->setEntity(entity);
|
||||
form()->setNewRec(false);
|
||||
m_formHandler->showForm(m_form);
|
||||
}
|
||||
@@ -278,7 +280,7 @@ protected:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int currentRecordId()
|
||||
int currentRecordId() override
|
||||
{
|
||||
if (tableView()->currentIndex().isValid())
|
||||
{
|
||||
@@ -340,7 +342,7 @@ protected:
|
||||
importer.setSeparator(dlg->separator());
|
||||
|
||||
ImportProgress *progress = new ImportProgress();
|
||||
progress->move(QApplication::desktop()->screen()->rect().center() - progress->rect().center());
|
||||
//progress->move(QApplication::desktop()->screen()->rect().center() - progress->rect().center());
|
||||
progress->setWindowModality(Qt::ApplicationModal);
|
||||
progress->show();
|
||||
|
||||
|
||||
@@ -5,10 +5,6 @@ IForm::IForm(QWidget *parent) : QWidget(parent)
|
||||
m_newRec = false;
|
||||
}
|
||||
|
||||
IForm::~IForm()
|
||||
{
|
||||
}
|
||||
|
||||
QString IForm::pluginId() const
|
||||
{
|
||||
return m_pluginId;
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class CORESHARED_EXPORT IForm : public QWidget
|
||||
|
||||
public:
|
||||
explicit IForm(QWidget *parent = 0);
|
||||
virtual ~IForm();
|
||||
~IForm() override = default;
|
||||
|
||||
QString pluginId() const;
|
||||
void setPluginId(const QString &pluginId);
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ IGridForm::IGridForm(QWidget *parent) :
|
||||
ui->filterWidget->setVisible(false);
|
||||
m_contextMenu = new QMenu(this);
|
||||
m_contextMenu->addAction(ui->actionSelectColumns);
|
||||
m_form = NULL;
|
||||
m_form = nullptr;
|
||||
|
||||
m_columnDialog = new ColumnDialog(this);
|
||||
connect(m_columnDialog, SIGNAL(accepted()), this, SLOT(columnsAccepted()));
|
||||
@@ -29,7 +29,7 @@ IGridForm::IGridForm(QWidget *parent) :
|
||||
|
||||
IGridForm::~IGridForm()
|
||||
{
|
||||
if (m_varFiller != NULL)
|
||||
if (m_varFiller != nullptr)
|
||||
{
|
||||
delete m_varFiller;
|
||||
}
|
||||
|
||||
+4
-4
@@ -24,8 +24,8 @@ class CORESHARED_EXPORT IGridForm : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit IGridForm(QWidget *parent = 0);
|
||||
virtual ~IGridForm();
|
||||
explicit IGridForm(QWidget *parent = nullptr);
|
||||
~IGridForm() override;
|
||||
|
||||
void setPluginId(const QString &pluginId);
|
||||
QString pluginId();
|
||||
@@ -71,14 +71,14 @@ private slots:
|
||||
|
||||
private:
|
||||
QString m_pluginId;
|
||||
IFormHandler *m_formHandler;
|
||||
//IFormHandler *m_formHandler;
|
||||
Ui::GridForm *ui;
|
||||
QMenu *m_contextMenu;
|
||||
ColumnDialog *m_columnDialog;
|
||||
VariableFiller *m_varFiller;
|
||||
|
||||
protected:
|
||||
FilterUi *m_filterUi;
|
||||
FilterUi *m_filterUi{nullptr};
|
||||
IForm *m_form;
|
||||
};
|
||||
|
||||
|
||||
+67
-11
@@ -12,8 +12,8 @@
|
||||
|
||||
IMetaDataPlugin::IMetaDataPlugin()
|
||||
{
|
||||
m_service = NULL;
|
||||
m_ui = NULL;
|
||||
m_service = nullptr;
|
||||
m_ui = nullptr;
|
||||
}
|
||||
|
||||
IMetaDataPlugin::~IMetaDataPlugin()
|
||||
@@ -83,18 +83,18 @@ void IMetaDataPlugin::parseMetaData(const QJsonObject &metaData)
|
||||
return;
|
||||
}
|
||||
|
||||
m_name = parseLocaleText(data.toObject()["name"].toObject());
|
||||
m_description = parseLocaleText(data.toObject()["description"].toObject());
|
||||
m_id = data.toObject()["id"].toString();
|
||||
m_schemaVersion = data.toObject()["schemaVersion"].toInt();
|
||||
auto metaBase = loadBaseMetaData(metaData);
|
||||
|
||||
foreach (QJsonValue schVal, data.toObject()["sql"].toArray()) {
|
||||
m_schemas.append(schVal.toString());
|
||||
if (!metaBase) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QJsonValue depVal, data.toObject()["dependecies"].toArray()) {
|
||||
m_dependsOn.append(depVal.toString());
|
||||
}
|
||||
m_name = metaBase->getName();
|
||||
m_description = metaBase->getDescription();
|
||||
m_id = metaBase->getId();
|
||||
m_schemaVersion = metaBase->getSchemaVersion();
|
||||
m_schemas = metaBase->getSchemas();
|
||||
m_dependsOn = metaBase->getDependsOn();
|
||||
|
||||
QJsonValue trVal = data.toObject()["translations"];
|
||||
QString locale = QLocale::system().name();
|
||||
@@ -165,3 +165,59 @@ void IMetaDataPlugin::addReportsFromJson(const QJsonValue &repArray)
|
||||
}
|
||||
}
|
||||
|
||||
MetaDataPtr IMetaDataPlugin::loadBaseMetaData(const QJsonObject& metaData) {
|
||||
qDebug() << metaData;
|
||||
|
||||
QJsonValue data = metaData["MetaData"];
|
||||
if (!data.isObject()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
QStringList schemas;
|
||||
for (const QJsonValue& schVal : data.toObject()["sql"].toArray()) {
|
||||
schemas.append(schVal.toString());
|
||||
}
|
||||
|
||||
QStringList dependsOn;
|
||||
for (const QJsonValue& depVal : data.toObject().value("dependencies").toArray()) {
|
||||
dependsOn.append(depVal.toString());
|
||||
}
|
||||
|
||||
return MetaDataPtr::create(
|
||||
parseLocaleText(data.toObject()["name"].toObject()),
|
||||
data.toObject()["id"].toString(),
|
||||
parseLocaleText(data.toObject()["description"].toObject()),
|
||||
data.toObject()["schemaVersion"].toInt(),
|
||||
schemas,
|
||||
dependsOn);
|
||||
}
|
||||
|
||||
MetaData::MetaData(const QString &mName, const QString &mId, const QString &mDescription, int mSchemaVersion,
|
||||
const QStringList &mSchemas, const QStringList &mDependsOn)
|
||||
: m_name(mName), m_id(mId), m_description(mDescription), m_schemaVersion(mSchemaVersion),
|
||||
m_schemas(mSchemas), m_dependsOn(mDependsOn) {}
|
||||
|
||||
const QString& MetaData::getName() const {
|
||||
return m_name;
|
||||
}
|
||||
|
||||
const QString& MetaData::getId() const {
|
||||
return m_id;
|
||||
}
|
||||
|
||||
const QString& MetaData::getDescription() const {
|
||||
return m_description;
|
||||
}
|
||||
|
||||
int MetaData::getSchemaVersion() const {
|
||||
return m_schemaVersion;
|
||||
}
|
||||
|
||||
const QStringList& MetaData::getSchemas() const {
|
||||
return m_schemas;
|
||||
}
|
||||
|
||||
const QStringList& MetaData::getDependsOn() const {
|
||||
return m_dependsOn;
|
||||
}
|
||||
|
||||
|
||||
+40
-10
@@ -6,23 +6,53 @@
|
||||
#include "core_global.h"
|
||||
#include "iplugin.h"
|
||||
|
||||
class MetaData {
|
||||
public:
|
||||
MetaData(const QString& mName, const QString& mId, const QString& mDescription, int mSchemaVersion,
|
||||
const QStringList& mSchemas, const QStringList& mDependsOn);
|
||||
|
||||
[[nodiscard]] const QString& getName() const;
|
||||
|
||||
[[nodiscard]] const QString& getId() const;
|
||||
|
||||
[[nodiscard]] const QString& getDescription() const;
|
||||
|
||||
[[nodiscard]] int getSchemaVersion() const;
|
||||
|
||||
[[nodiscard]] const QStringList& getSchemas() const;
|
||||
|
||||
[[nodiscard]] const QStringList& getDependsOn() const;
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_id;
|
||||
QString m_description;
|
||||
int m_schemaVersion;
|
||||
QStringList m_schemas;
|
||||
QStringList m_dependsOn;
|
||||
};
|
||||
|
||||
using MetaDataPtr = QSharedPointer<MetaData>;
|
||||
|
||||
class CORESHARED_EXPORT IMetaDataPlugin : public IPlugin
|
||||
{
|
||||
public:
|
||||
IMetaDataPlugin();
|
||||
virtual ~IMetaDataPlugin();
|
||||
~IMetaDataPlugin() override;
|
||||
|
||||
// IPlugin interface
|
||||
public:
|
||||
virtual QString pluginName();
|
||||
virtual QString pluginId();
|
||||
virtual QString pluginDescription();
|
||||
virtual int schemaVersion();
|
||||
virtual QStringList schemas();
|
||||
virtual QStringList dependsOn();
|
||||
virtual ReportList reports();
|
||||
QString pluginName() override;
|
||||
QString pluginId() override;
|
||||
QString pluginDescription() override;
|
||||
int schemaVersion() override;
|
||||
QStringList schemas() override;
|
||||
QStringList dependsOn() override;
|
||||
ReportList reports() override;
|
||||
|
||||
virtual void init(const QJsonObject &metaData);
|
||||
void init(const QJsonObject &metaData) override;
|
||||
|
||||
static MetaDataPtr loadBaseMetaData(const QJsonObject &metaData);
|
||||
|
||||
protected:
|
||||
virtual void initServiceUi() = 0;
|
||||
@@ -37,7 +67,7 @@ private:
|
||||
QStringList m_dependsOn;
|
||||
ReportList m_reports;
|
||||
|
||||
QString parseLocaleText(const QJsonObject &object);
|
||||
static QString parseLocaleText(const QJsonObject &object);
|
||||
void addCustomReports();
|
||||
void addReportsFromJson(const QJsonValue &repArray);
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
//#include <QDesktopWidget>
|
||||
|
||||
ImportDialog::ImportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ class CORESHARED_EXPORT ImportDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportDialog(QWidget *parent = 0);
|
||||
~ImportDialog();
|
||||
explicit ImportDialog(QWidget *parent = nullptr);
|
||||
~ImportDialog() override;
|
||||
|
||||
QString fileName();
|
||||
QString separator();
|
||||
|
||||
@@ -7,13 +7,16 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>454</width>
|
||||
<height>115</height>
|
||||
<height>117</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import data</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
||||
@@ -15,8 +15,8 @@ class CORESHARED_EXPORT ImportProgress : public QWidget, public IImportProgress
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ImportProgress(QWidget *parent = 0);
|
||||
~ImportProgress();
|
||||
explicit ImportProgress(QWidget *parent = nullptr);
|
||||
~ImportProgress() override;
|
||||
|
||||
private slots:
|
||||
void on_btnCancel_clicked();
|
||||
@@ -27,8 +27,8 @@ private:
|
||||
|
||||
// IImportProgress interface
|
||||
public:
|
||||
void updateProgress(int currentPos);
|
||||
bool terminate();
|
||||
void updateProgress(int currentPos) override;
|
||||
bool terminate() override;
|
||||
};
|
||||
|
||||
#endif // IMPORTPROGRESS_H
|
||||
|
||||
+23
-23
@@ -18,24 +18,18 @@ class IPlugin
|
||||
{
|
||||
|
||||
public:
|
||||
IPlugin() {
|
||||
m_ui = NULL;
|
||||
m_service = NULL;
|
||||
m_settingsUi = NULL;
|
||||
}
|
||||
IPlugin() = default;
|
||||
|
||||
virtual ~IPlugin() {
|
||||
if (m_service != NULL)
|
||||
{
|
||||
delete m_service;
|
||||
}
|
||||
delete m_service;
|
||||
delete m_translator;
|
||||
|
||||
if (m_ui != NULL && m_ui->parent() == NULL)
|
||||
if (m_ui != nullptr && m_ui->parent() == nullptr)
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
if (m_settingsUi != NULL && m_settingsUi->parent() == NULL)
|
||||
if (m_settingsUi != nullptr && m_settingsUi->parent() == nullptr)
|
||||
{
|
||||
delete m_settingsUi;
|
||||
}
|
||||
@@ -56,18 +50,18 @@ public:
|
||||
if (!permEv.hasPermission(pluginId(), PERM_READ))
|
||||
{
|
||||
QMessageBox::critical(m_ui, QObject::tr("Permission denied"), QObject::tr("You don't have permission to open this plugin."));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IGridForm *form = qobject_cast<IGridForm*>(m_ui);
|
||||
bool filled = true;
|
||||
|
||||
if (form != NULL)
|
||||
if (form != nullptr)
|
||||
{
|
||||
filled = form->fillData();
|
||||
}
|
||||
|
||||
return filled ? m_ui : NULL;
|
||||
return filled ? m_ui : nullptr;
|
||||
}
|
||||
|
||||
QList<QFrame*> dasboardWidgets() {
|
||||
@@ -88,24 +82,30 @@ public:
|
||||
}
|
||||
|
||||
virtual bool showIcon() { return true; }
|
||||
virtual QTranslator* translator() { return NULL; }
|
||||
virtual QIcon pluginIcon() { return QIcon(); }
|
||||
virtual QTranslator* translator() { return nullptr; }
|
||||
virtual QIcon pluginIcon() { return {}; }
|
||||
QMap<QString, QString> translations() { return m_translations; }
|
||||
|
||||
virtual bool hasNumberSeries() { return false; }
|
||||
virtual QString numberSeriesPrefix() { return ""; }
|
||||
|
||||
protected:
|
||||
QTranslator* translatorFrom(QString fileName) {
|
||||
QTranslator *trans = new QTranslator();
|
||||
trans->load(fileName + QLocale::system().name());
|
||||
QTranslator* translatorFrom(const QString& fileName) {
|
||||
if (!m_translator) {
|
||||
m_translator = new QTranslator();
|
||||
|
||||
return trans;
|
||||
if (!m_translator->load(fileName + QLocale::system().name())) {
|
||||
qDebug() << "Cannot load translation";
|
||||
}
|
||||
}
|
||||
|
||||
return m_translator;
|
||||
}
|
||||
|
||||
QWidget *m_ui;
|
||||
QWidget *m_settingsUi;
|
||||
IService *m_service;
|
||||
QTranslator* m_translator{nullptr};
|
||||
QWidget *m_ui {nullptr};
|
||||
QWidget *m_settingsUi {nullptr};
|
||||
IService *m_service {nullptr};
|
||||
QMap<QString, QString> m_translations;
|
||||
QList<QFrame*> m_dashboardWidgets;
|
||||
};
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ class CORESHARED_EXPORT ITableModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ITableModel(QObject *parent = NULL);
|
||||
explicit ITableModel(QObject *parent = nullptr);
|
||||
|
||||
protected:
|
||||
virtual void handleFilter(const QString &filter) = 0;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public:
|
||||
m_errMessage = errMessage;
|
||||
}
|
||||
|
||||
virtual ~IValidator() {}
|
||||
virtual ~IValidator() = default;
|
||||
|
||||
virtual bool validate() = 0;
|
||||
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
#include "numberseriesservice.h"
|
||||
#include "seasonservice.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
NumberSeriesService::NumberSeriesService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::forPluginAndSeason(QString pluginId, QSharedPointer<Season> season)
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::forPluginAndSeason(const QString& pluginId, const QSharedPointer<Season>& season)
|
||||
{
|
||||
QList<QSharedPointer<NumberSeries> > series = all(QString("pluginId = '%1' AND season = %2").arg(pluginId, QString::number(season->id())));
|
||||
|
||||
if (!series.isEmpty())
|
||||
{
|
||||
load(series[0]);
|
||||
return series[0];
|
||||
}
|
||||
|
||||
return QSharedPointer<NumberSeries>();
|
||||
return {};
|
||||
}
|
||||
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::forPlugin(QString pluginId)
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::forPlugin(const QString& pluginId)
|
||||
{
|
||||
SeasonService sesSrv;
|
||||
QSharedPointer<Season> currentSeason = sesSrv.active();
|
||||
@@ -29,34 +24,32 @@ QSharedPointer<NumberSeries> NumberSeriesService::forPlugin(QString pluginId)
|
||||
return forPluginAndSeason(pluginId, currentSeason);
|
||||
}
|
||||
|
||||
return QSharedPointer<NumberSeries>();
|
||||
return {};
|
||||
}
|
||||
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::nextForPlugin(QString pluginId)
|
||||
QSharedPointer<NumberSeries> NumberSeriesService::nextForPlugin(const QString& pluginId, qx::QxSession* pSession/* = nullptr*/)
|
||||
{
|
||||
QSharedPointer<NumberSeries> numSer = forPlugin(pluginId);
|
||||
|
||||
if (numSer.isNull())
|
||||
{
|
||||
return QSharedPointer<NumberSeries>();
|
||||
return {};
|
||||
}
|
||||
|
||||
numSer->setLastNumber(numSer->lastNumber() + 1);
|
||||
update(numSer);
|
||||
update(numSer, pSession);
|
||||
|
||||
return numSer;
|
||||
}
|
||||
|
||||
QList<QSharedPointer<NumberSeries> > NumberSeriesService::allForSeason(QSharedPointer<Season> season)
|
||||
QList<QSharedPointer<NumberSeries> > NumberSeriesService::allForSeason(const QSharedPointer<Season>& season)
|
||||
{
|
||||
return all(QString("season = %1").arg(QString::number(season->id())));
|
||||
}
|
||||
|
||||
QString NumberSeriesService::nextStrForPlugin(QString pluginId)
|
||||
QString NumberSeriesService::nextStrForPlugin(const QString& pluginId, qx::QxSession* pSession)
|
||||
{
|
||||
NumberSeriesPtr numSer = nextForPlugin(pluginId);
|
||||
QString numSerStr;
|
||||
numSerStr.sprintf("%s%05d", numSer->prefix().toStdString().c_str(), numSer->lastNumber());
|
||||
NumberSeriesPtr numSer = nextForPlugin(pluginId, pSession);
|
||||
|
||||
return numSerStr;
|
||||
return QString("%1%2").arg(numSer->prefix()).arg(numSer->lastNumber(), 5, 10, QLatin1Char('0'));
|
||||
}
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
class CORESHARED_EXPORT NumberSeriesService : public Service<NumberSeries>
|
||||
{
|
||||
public:
|
||||
NumberSeriesService();
|
||||
NumberSeriesService() = default;
|
||||
|
||||
QSharedPointer<NumberSeries> forPluginAndSeason(QString pluginId, QSharedPointer<Season> season);
|
||||
QSharedPointer<NumberSeries> forPlugin(QString pluginId);
|
||||
QSharedPointer<NumberSeries> nextForPlugin(QString pluginId);
|
||||
QList<QSharedPointer<NumberSeries> > allForSeason(QSharedPointer<Season> season);
|
||||
QString nextStrForPlugin(QString pluginId);
|
||||
QSharedPointer<NumberSeries> forPluginAndSeason(const QString& pluginId, const QSharedPointer<Season>& season);
|
||||
QSharedPointer<NumberSeries> forPlugin(const QString& pluginId);
|
||||
QSharedPointer<NumberSeries> nextForPlugin(const QString& pluginId, qx::QxSession* pSession = nullptr);
|
||||
QList<QSharedPointer<NumberSeries> > allForSeason(const QSharedPointer<Season>& season);
|
||||
QString nextStrForPlugin(const QString& pluginId, qx::QxSession* pSession = nullptr);
|
||||
};
|
||||
|
||||
#endif // NUMBERSERIESSERVICE_H
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
ObjectBinder::ObjectBinder(QObject *parent)
|
||||
:QObject(parent)
|
||||
{
|
||||
m_data = NULL;
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
void ObjectBinder::registerBinding(QWidget *widget) {
|
||||
@@ -18,7 +18,7 @@ void ObjectBinder::registerBinding(QComboBox *combo, const QList<ComboData> &val
|
||||
}
|
||||
|
||||
void ObjectBinder::registerValidator(IValidator *validator) {
|
||||
m_validators.append(validator);
|
||||
m_validators.append(QSharedPointer<IValidator>(validator));
|
||||
}
|
||||
|
||||
void ObjectBinder::setData(QObject *data)
|
||||
@@ -49,6 +49,8 @@ void ObjectBinder::bindToUi() {
|
||||
ComboData data = m_bindCombos[combo][i];
|
||||
combo->addItem(data.label(), data.index());
|
||||
|
||||
qDebug() << data.index();
|
||||
|
||||
if (data.index().canConvert<QObject*>()) {
|
||||
ComboItem* ci = qobject_cast<ComboItem*>(data.index().value<QObject*>());
|
||||
ComboItem* ciField = qobject_cast<ComboItem*>(field.value<QObject*>());
|
||||
@@ -56,7 +58,10 @@ void ObjectBinder::bindToUi() {
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
else if (field == data.index()) {
|
||||
else if (field.canConvert<int>() && data.index().canConvert<int>()
|
||||
&& field.toInt() == data.index().toInt()) {
|
||||
idx = i;
|
||||
} else if (field == data.index()) {
|
||||
idx = i;
|
||||
}
|
||||
}
|
||||
@@ -66,7 +71,7 @@ void ObjectBinder::bindToUi() {
|
||||
}
|
||||
|
||||
bool ObjectBinder::bindToData() {
|
||||
foreach (IValidator *val, m_validators) {
|
||||
for (const auto& val : m_validators) {
|
||||
if (!val->validate()) {
|
||||
emit validationError(val->errMessage());
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@
|
||||
#include <QComboBox>
|
||||
#include <QObject>
|
||||
#include <QMetaProperty>
|
||||
#include <QSharedPointer>
|
||||
#include "ivalidator.h"
|
||||
#include "combodata.h"
|
||||
#include "core_global.h"
|
||||
@@ -30,7 +31,7 @@ signals:
|
||||
private:
|
||||
QList<QWidget*> m_bindWidgets;
|
||||
QHash<QComboBox*, QList<ComboData> > m_bindCombos;
|
||||
QList<IValidator*> m_validators;
|
||||
QList<QSharedPointer<IValidator>> m_validators;
|
||||
QObject *m_data;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ PermissionEvaluator::PermissionEvaluator(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
PermissionEvaluator::~PermissionEvaluator()
|
||||
{
|
||||
}
|
||||
|
||||
bool PermissionEvaluator::hasPermission(const QString &pluginId, const QString &permission)
|
||||
{
|
||||
if (!Context::instance().currentUser()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Context::instance().currentUser()->isAdmin())
|
||||
{
|
||||
return true;
|
||||
@@ -24,7 +24,7 @@ bool PermissionEvaluator::hasPermission(const QString &pluginId, const QString &
|
||||
bool ret;
|
||||
QList<QSharedPointer<Role> > roles = Context::instance().currentUser()->listRoles();
|
||||
|
||||
ret = std::find_if(ALL(roles), [&pluginId, &permission](QSharedPointer<Role> role) -> bool {
|
||||
ret = std::find_if(ALL(roles), [&pluginId, &permission](const QSharedPointer<Role>& role) -> bool {
|
||||
foreach (QSharedPointer<Permission> perm, role->listPermissions()) {
|
||||
if (perm->pluginId() == pluginId && perm->permissionName() == permission) {
|
||||
return true;
|
||||
|
||||
@@ -11,8 +11,8 @@ class CORESHARED_EXPORT PermissionEvaluator : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PermissionEvaluator(QObject *parent = NULL);
|
||||
~PermissionEvaluator();
|
||||
explicit PermissionEvaluator(QObject *parent = nullptr);
|
||||
~PermissionEvaluator() override = default;
|
||||
|
||||
bool hasPermission(const QString &pluginId, const QString &permission);
|
||||
|
||||
|
||||
+26
-32
@@ -1,21 +1,9 @@
|
||||
#include "core-odb.hxx"
|
||||
#include "permissionservice.h"
|
||||
#include <QCryptographicHash>
|
||||
|
||||
typedef odb::query<Permission> permQuery;
|
||||
typedef odb::result<Permission> permResult;
|
||||
|
||||
PermissionService::PermissionService()
|
||||
{
|
||||
}
|
||||
|
||||
PermissionService::~PermissionService()
|
||||
{
|
||||
}
|
||||
|
||||
QList<QSharedPointer<Permission> > PermissionService::forPlugin(const QString &pluginId)
|
||||
{
|
||||
Transaction tr;
|
||||
/*Transaction tr;
|
||||
odb::database *db = Context::instance().db();
|
||||
permQuery q(permQuery::pluginId == pluginId);
|
||||
permResult result = db->query<Permission>(q);
|
||||
@@ -27,18 +15,25 @@ QList<QSharedPointer<Permission> > PermissionService::forPlugin(const QString &p
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
return ret;
|
||||
return ret;*/
|
||||
return {};
|
||||
}
|
||||
|
||||
QSharedPointer<Permission> PermissionService::forNameAndPlugin(const QString &name, const QString &pluginId)
|
||||
{
|
||||
Transaction tr;
|
||||
odb::database *db = Context::instance().db();
|
||||
permQuery q(permQuery::pluginId == pluginId && permQuery::permissionName == name);
|
||||
QSharedPointer<Permission> p = db->query_one<Permission>(q);
|
||||
qx::QxSqlQuery q;
|
||||
q.where("permissionName").isEqualTo(name)
|
||||
.and_("pluginId").isEqualTo(pluginId);
|
||||
|
||||
tr.commit();
|
||||
return p;
|
||||
QList<QSharedPointer<Permission>> ret;
|
||||
auto err = qx::dao::fetch_by_query(q, ret);
|
||||
|
||||
if (err.isValid()) {
|
||||
qDebug() << err.text();
|
||||
// ToDo - log error
|
||||
}
|
||||
|
||||
return ret.count() > 0 ? ret[0] : QSharedPointer<Permission>();
|
||||
}
|
||||
|
||||
bool PermissionService::checkLogin(const QString &login, const QString &password)
|
||||
@@ -55,21 +50,22 @@ bool PermissionService::checkLogin(const QString &login, const QString &password
|
||||
|
||||
QSharedPointer<User> PermissionService::loadUser(const QString &login)
|
||||
{
|
||||
odb::database *db = Context::instance().db();
|
||||
Service<User> srvUser;
|
||||
auto admin = srvUser.all("login = '" + login + "'");
|
||||
|
||||
Transaction tr;
|
||||
return db->query_one<User>("login = " + odb::query<User>::_ref(login));
|
||||
if (admin.count() == 1) {
|
||||
return admin[0];
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
void PermissionService::checkForAdmin()
|
||||
{
|
||||
odb::database *db = Context::instance().db();
|
||||
Service<User> srvUser;
|
||||
auto admUser = srvUser.all("isAdmin = 1");
|
||||
|
||||
Transaction tr;
|
||||
odb::query<User> q(odb::query<User>::isAdmin == true);
|
||||
odb::result<User> r = db->query<User>(q);
|
||||
|
||||
if (r.empty())
|
||||
if (admUser.isEmpty())
|
||||
{
|
||||
QSharedPointer<User> admin(new User);
|
||||
admin->setLogin("admin");
|
||||
@@ -78,10 +74,8 @@ void PermissionService::checkForAdmin()
|
||||
admin->setPassword(encryptPassword("admin"));
|
||||
admin->setActive(true);
|
||||
|
||||
db->persist(admin);
|
||||
srvUser.save(admin);
|
||||
}
|
||||
|
||||
tr.commit();
|
||||
}
|
||||
|
||||
QString PermissionService::encryptPassword(const QString &plainPasswd)
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include "service.h"
|
||||
#include "data/core-data.h"
|
||||
#include "core_global.h"
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/query.hxx>
|
||||
#include <odb/result.hxx>
|
||||
|
||||
#include <QList>
|
||||
#include <QSharedPointer>
|
||||
@@ -16,8 +12,8 @@
|
||||
class CORESHARED_EXPORT PermissionService : public Service<Permission>
|
||||
{
|
||||
public:
|
||||
PermissionService();
|
||||
~PermissionService();
|
||||
PermissionService() = default;
|
||||
~PermissionService() override = default;
|
||||
|
||||
QList<QSharedPointer<Permission> > forPlugin(const QString &pluginId);
|
||||
QSharedPointer<Permission> forNameAndPlugin(const QString &name, const QString &pluginId);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../context.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QPrinter>
|
||||
#include <LimeReport>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "report.h"
|
||||
#include "core_global.h"
|
||||
#include "../core_global.h"
|
||||
|
||||
namespace Ui {
|
||||
class ReportViewer;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#ifndef ROLES_H
|
||||
#define ROLES_H
|
||||
|
||||
#include "imetadataplugin.h"
|
||||
#include "../imetadataplugin.h"
|
||||
|
||||
class Roles : public IMetaDataPlugin
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "rolesform.h"
|
||||
#include "ui_rolesform.h"
|
||||
#include "iplugin.h"
|
||||
#include "permissionservice.h"
|
||||
#include "../iplugin.h"
|
||||
#include "../permissionservice.h"
|
||||
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#define ROLESFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "autoform.h"
|
||||
#include "data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
#include "../autoform.h"
|
||||
#include "../data/core-data.h"
|
||||
|
||||
namespace Ui {
|
||||
class RolesForm;
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>542</width>
|
||||
<height>270</height>
|
||||
<width>556</width>
|
||||
<height>291</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#ifndef ROLESTABLEMODEL_H
|
||||
#define ROLESTABLEMODEL_H
|
||||
|
||||
#include "autotablemodel.h"
|
||||
#include "data/core-data.h"
|
||||
#include "../autotablemodel.h"
|
||||
#include "../data/core-data.h"
|
||||
|
||||
class RolesTableModel : public AutoTableModel<Role>
|
||||
{
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#ifndef ROLESUI_H
|
||||
#define ROLESUI_H
|
||||
|
||||
#include "gridform.h"
|
||||
#include "data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
#include "../gridform.h"
|
||||
#include "../data/core-data.h"
|
||||
|
||||
class RolesUi : public GridForm<Role>
|
||||
{
|
||||
|
||||
+5
-14
@@ -1,12 +1,5 @@
|
||||
#include "seasonservice.h"
|
||||
|
||||
#include "core-odb.hxx"
|
||||
|
||||
SeasonService::SeasonService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QSharedPointer<Season> SeasonService::active()
|
||||
{
|
||||
QList<QSharedPointer<Season> > seasons = all("active = 1");
|
||||
@@ -15,20 +8,18 @@ QSharedPointer<Season> SeasonService::active()
|
||||
return seasons[0];
|
||||
}
|
||||
|
||||
return QSharedPointer<Season>();
|
||||
return {};
|
||||
}
|
||||
|
||||
void SeasonService::activate(QSharedPointer<Season> season)
|
||||
void SeasonService::activate(const QSharedPointer<Season>& season)
|
||||
{
|
||||
Transaction tx;
|
||||
qx::QxSession session;
|
||||
|
||||
foreach (QSharedPointer<Season> ses, all()) {
|
||||
ses->setActive(false);
|
||||
update(ses);
|
||||
update(ses, &session);
|
||||
}
|
||||
|
||||
season->setActive(true);
|
||||
update(season);
|
||||
|
||||
tx.commit();
|
||||
update(season, &session);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@
|
||||
class CORESHARED_EXPORT SeasonService : public Service<Season>
|
||||
{
|
||||
public:
|
||||
SeasonService();
|
||||
SeasonService() = default;
|
||||
QSharedPointer<Season> active();
|
||||
void activate(QSharedPointer<Season> season);
|
||||
void activate(const QSharedPointer<Season>& season);
|
||||
};
|
||||
|
||||
#endif // SEASONSERVICE_H
|
||||
|
||||
+86
-125
@@ -7,11 +7,6 @@
|
||||
#include <QEventLoop>
|
||||
#include <QApplication>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/transaction.hxx>
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/result.hxx>
|
||||
|
||||
#include "core_global.h"
|
||||
#include "context.h"
|
||||
#include "iservice.h"
|
||||
@@ -19,195 +14,158 @@
|
||||
#include "iimporter.h"
|
||||
#include "iimportprogress.h"
|
||||
|
||||
#include "transaction.h"
|
||||
|
||||
template<class T>
|
||||
class Service : public IService
|
||||
{
|
||||
public:
|
||||
explicit Service(QObject *parent = NULL) :IService(parent) { }
|
||||
explicit Service(QObject *parent = nullptr) :IService(parent) { }
|
||||
|
||||
explicit Service(const QString &pluginId) {
|
||||
m_pluginId = pluginId;
|
||||
}
|
||||
|
||||
QList<QSharedPointer<T> > all(const QString &where = "", const QString &order = "") {
|
||||
QList<QSharedPointer<T> > all(const QString &where = "") {
|
||||
QList<QSharedPointer<T> > ret;
|
||||
|
||||
if (!checkPermission(PERM_READ)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
QScopedPointer<T> entity(new T());
|
||||
auto qEntity = dynamic_cast<QObject*>(entity.data());
|
||||
|
||||
Q_ASSERT(db);
|
||||
QStringList relations;
|
||||
QString sWhere = where.isEmpty() ? "" : "WHERE " + where;
|
||||
QSqlError err;
|
||||
|
||||
Transaction tx;
|
||||
|
||||
try
|
||||
if (qEntity
|
||||
&& QMetaObject::invokeMethod(qEntity, "eagerLoad", Qt::DirectConnection, Q_RETURN_ARG(QStringList, relations))
|
||||
&& !relations.isEmpty())
|
||||
{
|
||||
odb::result<T> res;
|
||||
QString ord = defaultSort();
|
||||
|
||||
if (!order.isEmpty())
|
||||
{
|
||||
ord = order;
|
||||
}
|
||||
|
||||
if (where.isEmpty() && ord.isEmpty())
|
||||
{
|
||||
res = db->template query<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString cond;
|
||||
|
||||
if (where.isEmpty())
|
||||
{
|
||||
cond = "1 ORDER BY " + ord;
|
||||
}
|
||||
else
|
||||
{
|
||||
cond = where;
|
||||
if (!ord.isEmpty())
|
||||
{
|
||||
cond += "ORDER BY " + ord;
|
||||
}
|
||||
}
|
||||
|
||||
res = db->template query<T>(cond.toStdString());
|
||||
}
|
||||
|
||||
for (typename odb::result<T>::iterator it = res.begin(); it != res.end(); it++) {
|
||||
ret.append(it.load());
|
||||
}
|
||||
|
||||
tx.commit();
|
||||
err = qx::dao::fetch_by_query_with_relation(relations, sWhere, ret);
|
||||
}
|
||||
catch (const odb::exception &ex)
|
||||
{
|
||||
emit dbError(ex.what());
|
||||
else {
|
||||
err = qx::dao::fetch_by_query(sWhere, ret);
|
||||
}
|
||||
|
||||
if (!err.isValid()) {
|
||||
return ret;
|
||||
} else {
|
||||
qDebug() << err.text();
|
||||
emit dbError(err.text());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void save(QSharedPointer<T> entity) {
|
||||
void save(QSharedPointer<T> entity, qx::QxSession* pSession = nullptr) {
|
||||
if (!checkPermission(PERM_ADD)) {
|
||||
return;
|
||||
}
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
QScopedPointer<qx::QxSession> ptrSession;
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
if (pSession == nullptr) {
|
||||
ptrSession.reset(new qx::QxSession());
|
||||
pSession = ptrSession.data();
|
||||
}
|
||||
|
||||
addDateAndUser(entity, true);
|
||||
*pSession += qx::dao::insert_with_all_relation(entity, pSession->database());
|
||||
|
||||
try
|
||||
{
|
||||
db->persist(entity);
|
||||
tx.commit();
|
||||
}
|
||||
catch (const odb::exception &ex)
|
||||
{
|
||||
emit dbError(ex.what());
|
||||
emit dbErrorUpdate(ex.what());
|
||||
if (!pSession->isValid()) {
|
||||
qDebug() << pSession->firstError().text();
|
||||
emit dbError(pSession->firstError().text());
|
||||
emit dbErrorInsert(pSession->firstError().text());
|
||||
return;
|
||||
}
|
||||
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void update(QSharedPointer<T> entity) {
|
||||
void update(QSharedPointer<T> entity, qx::QxSession* pSession = nullptr) {
|
||||
if (!checkPermission(PERM_EDIT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
QScopedPointer<qx::QxSession> ptrSession;
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
if (pSession == nullptr) {
|
||||
ptrSession.reset(new qx::QxSession());
|
||||
pSession = ptrSession.data();
|
||||
}
|
||||
|
||||
addDateAndUser(entity, false);
|
||||
|
||||
try
|
||||
{
|
||||
db->update(entity);
|
||||
tx.commit();
|
||||
}
|
||||
catch (const odb::exception &ex)
|
||||
{
|
||||
emit dbError(ex.what());
|
||||
emit dbErrorInsert(ex.what());
|
||||
*pSession += qx::dao::update_with_all_relation(entity, pSession->database());
|
||||
|
||||
if (!pSession->isValid()) {
|
||||
emit dbError(pSession->firstError().text());
|
||||
emit dbErrorUpdate(pSession->firstError().text());
|
||||
return;
|
||||
}
|
||||
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
QSharedPointer<T> loadById(int id) {
|
||||
QSharedPointer<T> loadById(long id) {
|
||||
QSharedPointer<T> entity;
|
||||
|
||||
/*if (!checkPermission(PERM_READ)) {
|
||||
if (!checkPermission(PERM_READ)) {
|
||||
return entity;
|
||||
}*/
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
|
||||
try
|
||||
{
|
||||
entity = db->template load<T>(id);
|
||||
tx.commit();
|
||||
}
|
||||
catch (const odb::exception &ex)
|
||||
{
|
||||
emit dbError(ex.what());
|
||||
emit dbErrorRead(ex.what());
|
||||
|
||||
entity = QSharedPointer<T>(new T);
|
||||
entity->setId(id);
|
||||
auto err = qx::dao::fetch_by_id_with_all_relation(entity);
|
||||
|
||||
if (err.isValid()) {
|
||||
emit dbError(err.text());
|
||||
emit dbErrorRead(err.text());
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
void load(QSharedPointer<T>& entity) {
|
||||
if (!checkPermission(PERM_READ)) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto err = qx::dao::fetch_by_id_with_all_relation(entity);
|
||||
|
||||
if (err.isValid()) {
|
||||
emit dbError(err.text());
|
||||
emit dbErrorRead(err.text());
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<T> reload(int id) {
|
||||
odb::database *db = Context::instance().db();
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Context::instance().session().cache_erase<T>(*db, id);
|
||||
return loadById(id);
|
||||
}
|
||||
|
||||
void erase(QSharedPointer<T> entity) {
|
||||
void erase(QSharedPointer<T> entity, qx::QxSession* pSession = nullptr) {
|
||||
if (!checkPermission(PERM_DELETE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
odb::database *db = Context::instance().db();
|
||||
QScopedPointer<qx::QxSession> ptrSession;
|
||||
|
||||
Q_ASSERT(db);
|
||||
|
||||
Transaction tx;
|
||||
|
||||
try
|
||||
{
|
||||
db->erase(entity);
|
||||
tx.commit();
|
||||
if (pSession == nullptr) {
|
||||
ptrSession.reset(new qx::QxSession());
|
||||
pSession = ptrSession.data();
|
||||
}
|
||||
catch (const odb::exception &ex)
|
||||
{
|
||||
emit dbError(ex.what());
|
||||
emit dbErrorDelete(ex.what());
|
||||
|
||||
*pSession += qx::dao::delete_by_id(entity);
|
||||
|
||||
if (!pSession->isValid()) {
|
||||
qDebug() << pSession->firstError().text();
|
||||
emit dbError(pSession->firstError().text());
|
||||
emit dbErrorDelete(pSession->firstError().text());
|
||||
}
|
||||
}
|
||||
|
||||
bool importData(IImporter *importer, IImportProgress *progress = NULL) {
|
||||
bool importData(IImporter *importer, IImportProgress *progress = nullptr) {
|
||||
int count = importer->recordCount();
|
||||
|
||||
if (importer->isError()) {
|
||||
@@ -232,12 +190,12 @@ public:
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
if (progress != NULL && progress->terminate())
|
||||
if (progress != nullptr && progress->terminate())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (progress != NULL)
|
||||
if (progress != nullptr)
|
||||
{
|
||||
progress->updateProgress(i * 100 / count);
|
||||
}
|
||||
@@ -262,16 +220,19 @@ protected:
|
||||
void addDateAndUser(QSharedPointer<T> entity, bool creating) {
|
||||
|
||||
T *inner = entity.data();
|
||||
QObject *obj = dynamic_cast<QObject*>(inner);
|
||||
auto *obj = dynamic_cast<QObject*>(inner);
|
||||
|
||||
if (obj == NULL)
|
||||
if (obj == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (creating)
|
||||
{
|
||||
obj->setProperty("createdBy", Context::instance().currentUser()->login());
|
||||
if (!Context::instance().currentUser().isNull()) {
|
||||
obj->setProperty("createdBy", Context::instance().currentUser()->login());
|
||||
}
|
||||
|
||||
obj->setProperty("created", QDateTime::currentDateTime());
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "globalsettings.h"
|
||||
#include <define.h>
|
||||
#include "../define.h"
|
||||
|
||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "../settingsservice.h"
|
||||
#include "../seasonservice.h"
|
||||
#include "../numberseriesservice.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
|
||||
FormBinder<GlobalSettings>(parent),
|
||||
@@ -45,10 +44,16 @@ GlobalSettingsForm::~GlobalSettingsForm()
|
||||
|
||||
void GlobalSettingsForm::loadSeasons()
|
||||
{
|
||||
ui->season->clear();
|
||||
SeasonService srv;
|
||||
m_seasons = srv.all();
|
||||
|
||||
fillSeasons();
|
||||
}
|
||||
|
||||
|
||||
void GlobalSettingsForm::fillSeasons() {
|
||||
ui->season->clear();
|
||||
|
||||
foreach (SeasonPtr season, m_seasons) {
|
||||
ui->season->addItem(season->name());
|
||||
|
||||
@@ -76,10 +81,18 @@ bool GlobalSettingsForm::saveRecord()
|
||||
SeasonService srvSeason;
|
||||
NumberSeriesService srvNumSer;
|
||||
|
||||
foreach (NumberSeriesPtr numSer, m_seriesModel->list()) {
|
||||
srvNumSer.update(numSer);
|
||||
}
|
||||
|
||||
foreach (SeasonPtr season, m_seasons) {
|
||||
srvSeason.update(season);
|
||||
}
|
||||
|
||||
SeasonPtr selSeason = m_seasons[ui->season->currentIndex()];
|
||||
if (selSeason->id() != Context::instance().currentSeason()->id())
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Switch season"), tr("Realy switch active season?")) == QMessageBox::Yes)
|
||||
if (QMessageBox::question(this, tr("Switch season"), tr("Really switch active season?")) == QMessageBox::Yes)
|
||||
{
|
||||
srvSeason.activate(selSeason);
|
||||
Context::instance().setCurrentSeason(selSeason);
|
||||
@@ -90,14 +103,6 @@ bool GlobalSettingsForm::saveRecord()
|
||||
}
|
||||
}
|
||||
|
||||
foreach (SeasonPtr season, m_seasons) {
|
||||
srvSeason.update(season);
|
||||
}
|
||||
|
||||
foreach (NumberSeriesPtr numSer, m_seriesModel->list()) {
|
||||
srvNumSer.update(numSer);
|
||||
}
|
||||
|
||||
bindToData();
|
||||
SettingsService srv("CORE");
|
||||
srv.saveSettings(entity());
|
||||
@@ -141,13 +146,13 @@ void GlobalSettingsForm::on_btnEditName_clicked()
|
||||
dialog->show();
|
||||
|
||||
connect(dialog, &QDialog::accepted, [this](){
|
||||
this->loadSeasons();
|
||||
this->fillSeasons();
|
||||
});
|
||||
}
|
||||
|
||||
void GlobalSettingsForm::on_btnNew_clicked()
|
||||
{
|
||||
if (QMessageBox::question(this, tr("New season"), tr("Realy create new season and switch to it?")) == QMessageBox::Yes)
|
||||
if (QMessageBox::question(this, tr("New season"), tr("Really create new season and switch to it?")) == QMessageBox::Yes)
|
||||
{
|
||||
SeasonPtr newSeason = SeasonPtr(new Season);
|
||||
SeasonNameDialog *dialog = new SeasonNameDialog(newSeason, this);
|
||||
@@ -177,3 +182,4 @@ void GlobalSettingsForm::on_pushButton_clicked()
|
||||
ui->lblLogo->setPixmap(QPixmap(logoPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ private:
|
||||
QList<SeasonPtr> m_seasons;
|
||||
|
||||
void loadSeasons();
|
||||
void fillSeasons();
|
||||
void loadNumSeries();
|
||||
|
||||
// IForm interface
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>759</width>
|
||||
<height>630</height>
|
||||
<height>640</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -39,6 +39,9 @@
|
||||
<string>Contact</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "seasonnamedialog.h"
|
||||
#include "ui_seasonnamedialog.h"
|
||||
|
||||
SeasonNameDialog::SeasonNameDialog(SeasonPtr season, QWidget *parent) :
|
||||
SeasonNameDialog::SeasonNameDialog(const SeasonPtr& season, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SeasonNameDialog)
|
||||
{
|
||||
|
||||
@@ -15,8 +15,8 @@ class SeasonNameDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SeasonNameDialog(SeasonPtr season, QWidget *parent = 0);
|
||||
~SeasonNameDialog();
|
||||
explicit SeasonNameDialog(const SeasonPtr& season, QWidget *parent = 0);
|
||||
~SeasonNameDialog() override;
|
||||
|
||||
private:
|
||||
Ui::SeasonNameDialog *ui;
|
||||
@@ -24,7 +24,7 @@ private:
|
||||
|
||||
// QDialog interface
|
||||
public slots:
|
||||
void accept();
|
||||
void accept() override;
|
||||
};
|
||||
|
||||
#endif // SEASONNAMEDIALOG_H
|
||||
|
||||
@@ -15,12 +15,12 @@ SettingsForm::SettingsForm(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
foreach (IPlugin *plugin, Context::instance().plugins()) {
|
||||
if (plugin->settingsUi() != NULL)
|
||||
if (plugin->settingsUi() != nullptr)
|
||||
{
|
||||
SettingsService srv(plugin->pluginId());
|
||||
IForm *tab = qobject_cast<IForm*>(plugin->settingsUi());
|
||||
|
||||
if (tab != NULL)
|
||||
if (tab != nullptr)
|
||||
{
|
||||
tab->loadEntity();
|
||||
ui->tabWidget->addTab(tab, QIcon(), plugin->settingsTabLabel());
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
#include "settingsservice.h"
|
||||
|
||||
#include "core-odb.hxx"
|
||||
|
||||
#include <odb/core.hxx>
|
||||
#include <odb/result.hxx>
|
||||
|
||||
SettingsService::SettingsService(QObject *parent)
|
||||
:IService(parent)
|
||||
{
|
||||
|
||||
@@ -8,21 +8,21 @@ Transaction::Transaction()
|
||||
{
|
||||
if (!Transaction::m_inTransaction)
|
||||
{
|
||||
m_tr = new odb::transaction(Context::instance().db()->begin());
|
||||
//m_tr = new odb::transaction(Context::instance().db()->begin());
|
||||
#ifdef _DEBUG
|
||||
m_tr->tracer(odb::stderr_tracer);
|
||||
//m_tr->tracer(odb::stderr_tracer);
|
||||
#endif
|
||||
Transaction::m_inTransaction = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_tr = NULL;
|
||||
m_tr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction::~Transaction()
|
||||
{
|
||||
if (m_tr != NULL)
|
||||
if (m_tr != nullptr)
|
||||
{
|
||||
delete m_tr;
|
||||
Transaction::m_inTransaction = false;
|
||||
@@ -31,9 +31,9 @@ Transaction::~Transaction()
|
||||
|
||||
void Transaction::commit()
|
||||
{
|
||||
if (m_tr != NULL)
|
||||
if (m_tr != nullptr)
|
||||
{
|
||||
m_tr->commit();
|
||||
//m_tr->commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
#ifndef TRANSACTION_H
|
||||
#define TRANSACTION_H
|
||||
|
||||
#include <odb/database.hxx>
|
||||
#include <odb/transaction.hxx>
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
class CORESHARED_EXPORT Transaction
|
||||
{
|
||||
public:
|
||||
Transaction();
|
||||
~Transaction();
|
||||
|
||||
void commit();
|
||||
|
||||
private:
|
||||
odb::transaction *m_tr;
|
||||
static bool m_inTransaction;
|
||||
};
|
||||
|
||||
#endif // TRANSACTION_H
|
||||
@@ -1,9 +1,8 @@
|
||||
#ifndef TABLEMODEL_H
|
||||
#define TABLEMODEL_H
|
||||
|
||||
#include "autotablemodel.h"
|
||||
#include "../autotablemodel.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
class UsersTableModel : public AutoTableModel<User>
|
||||
{
|
||||
|
||||
@@ -20,14 +20,10 @@ UserForm::UserForm(QWidget *parent) :
|
||||
registerBinding(ui->name);
|
||||
registerBinding(ui->isAdmin);
|
||||
registerBinding(ui->active);
|
||||
EmptyStringValidator * esv_login = new EmptyStringValidator(ui->login,"Enter Login Name");
|
||||
registerValidator(esv_login);
|
||||
EmptyStringValidator * esv_password = new EmptyStringValidator(ui->password,"Enter Password");
|
||||
registerValidator(esv_password);
|
||||
EmptyStringValidator * esv_name = new EmptyStringValidator(ui->name,"Enter Name");
|
||||
registerValidator(esv_name);
|
||||
SameStringValidator * ssv_password = new SameStringValidator(ui->password,ui->retypePassword,"Passwords doesen't match");
|
||||
registerValidator(ssv_password);
|
||||
registerValidator(new EmptyStringValidator(ui->login,"Enter Login Name"));
|
||||
registerValidator(new EmptyStringValidator(ui->password,"Enter Password"));
|
||||
registerValidator(new EmptyStringValidator(ui->name,"Enter Name"));
|
||||
registerValidator(new SameStringValidator(ui->password,ui->retypePassword,"Passwords doesen't match"));
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +48,7 @@ void UserForm::bindOtherToUi()
|
||||
ti = new QTableWidgetItem;
|
||||
ti->setText(r->name());
|
||||
ti->setCheckState(it == roles.end() ? Qt::Unchecked : Qt::Checked);
|
||||
ti->setData(Qt::UserRole,r->id());
|
||||
ti->setData(Qt::UserRole, (qlonglong)r->id());
|
||||
ui->tableWidget->setItem(i,0,ti);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,8 @@
|
||||
#define USERFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "autoform.h"
|
||||
#include "../autoform.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
namespace Ui {
|
||||
class UserForm;
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#ifndef USERS_H
|
||||
#define USERS_H
|
||||
#include "imetadataplugin.h"
|
||||
#include "../imetadataplugin.h"
|
||||
#include "userform.h"
|
||||
#include "usersui.h"
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
#ifndef USERSUI_H
|
||||
#define USERSUI_H
|
||||
|
||||
#include "gridform.h"
|
||||
#include "../gridform.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
class UsersUi : public GridForm<User>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user