From 7d01751c10952919262234db33c140c73b9b2135 Mon Sep 17 00:00:00 2001 From: Zdenek Jonak Date: Thu, 10 Dec 2015 22:00:58 +0100 Subject: [PATCH] Implemented roles module. --- core/context.cpp | 2 ++ core/core.pro | 18 ++++++++++++---- core/rc.qrc | 1 + core/roles/metaData.json | 16 ++++++++++++++ core/roles/roles.cpp | 24 +++++++++++++++++++++ core/roles/roles.h | 16 ++++++++++++++ core/roles/rolesform.cpp | 17 +++++++++++++++ core/roles/rolesform.h | 25 ++++++++++++++++++++++ core/roles/rolesform.ui | 38 ++++++++++++++++++++++++++++++++++ core/roles/rolestablemodel.cpp | 6 ++++++ core/roles/rolestablemodel.h | 14 +++++++++++++ core/roles/rolesui.cpp | 12 +++++++++++ core/roles/rolesui.h | 16 ++++++++++++++ 13 files changed, 201 insertions(+), 4 deletions(-) create mode 100644 core/roles/metaData.json create mode 100644 core/roles/roles.cpp create mode 100644 core/roles/roles.h create mode 100644 core/roles/rolesform.cpp create mode 100644 core/roles/rolesform.h create mode 100644 core/roles/rolesform.ui create mode 100644 core/roles/rolestablemodel.cpp create mode 100644 core/roles/rolestablemodel.h create mode 100644 core/roles/rolesui.cpp create mode 100644 core/roles/rolesui.h diff --git a/core/context.cpp b/core/context.cpp index 2660622..1a760b4 100644 --- a/core/context.cpp +++ b/core/context.cpp @@ -12,6 +12,7 @@ #include "core.h" #include "coreplugin.h" #include "users/users.h" +#include "roles/roles.h" Context &Context::instance() { @@ -40,6 +41,7 @@ void Context::loadPlugins() IPlugin *corePlugin = new CorePlugin(); m_plugins.append(corePlugin); m_plugins.append(new Users); + m_plugins.append(new Roles); QDir pluginsDir(qApp->applicationDirPath() + "/../plugins"); diff --git a/core/core.pro b/core/core.pro index ffedd33..fdea287 100644 --- a/core/core.pro +++ b/core/core.pro @@ -28,7 +28,11 @@ SOURCES += \ users/usersui.cpp \ users/tablemodel.cpp \ users/userform.cpp \ - columndialog.cpp + columndialog.cpp \ + roles/rolestablemodel.cpp \ + roles/roles.cpp \ + roles/rolesui.cpp \ + roles/rolesform.cpp HEADERS += core.h\ core_global.h \ @@ -56,7 +60,11 @@ HEADERS += core.h\ users/usersui.h \ users/tablemodel.h \ users/userform.h \ - columndialog.h + columndialog.h \ + roles/rolestablemodel.h \ + roles/roles.h \ + roles/rolesui.h \ + roles/rolesform.h unix { target.path = /usr/lib @@ -84,7 +92,9 @@ FORMS += \ gridform.ui \ formdialog.ui \ users/userform.ui \ - columndialog.ui + columndialog.ui \ + roles/rolesform.ui OTHER_FILES += \ - users/metaData.json + users/metaData.json \ + roles/metaData.json diff --git a/core/rc.qrc b/core/rc.qrc index 68aa197..3bb3eff 100644 --- a/core/rc.qrc +++ b/core/rc.qrc @@ -2,5 +2,6 @@ metaData.json users/metaData.json + roles/metaData.json diff --git a/core/roles/metaData.json b/core/roles/metaData.json new file mode 100644 index 0000000..0a3c398 --- /dev/null +++ b/core/roles/metaData.json @@ -0,0 +1,16 @@ +{ + "MetaData" : { + "id" : "CORE_ROLES", + "name" : { + "default" : "Core Roles plugin", + "CZ" : "Role" + }, + "description" : { + "default" : "", + "CZ" : "" + }, + "schemaVersion" : 1, + "sql" : [], + "dependencies" : [] + } +} diff --git a/core/roles/roles.cpp b/core/roles/roles.cpp new file mode 100644 index 0000000..7e74a5e --- /dev/null +++ b/core/roles/roles.cpp @@ -0,0 +1,24 @@ +#include "roles.h" +#include "rolesui.h" +#include "rolesform.h" + +#include +#include + +Roles::Roles() +{ + Q_INIT_RESOURCE(rc); + + QFile f (":/roles/metaData.json"); + f.open(QIODevice::ReadOnly | QIODevice::Text); + QJsonDocument d = QJsonDocument::fromJson(f.readAll()); + init(d.object()); + f.close(); +} + +void Roles::initServiceUi() +{ + m_service = new Service(); + m_ui = new RolesUi(); + ((RolesUi*)m_ui)->setForm(new RolesForm()); +} diff --git a/core/roles/roles.h b/core/roles/roles.h new file mode 100644 index 0000000..6bdb164 --- /dev/null +++ b/core/roles/roles.h @@ -0,0 +1,16 @@ +#ifndef ROLES_H +#define ROLES_H + +#include "imetadataplugin.h" + +class Roles : public IMetaDataPlugin +{ +public: + Roles(); + + // IMetaDataPlugin interface +protected: + void initServiceUi(); +}; + +#endif // ROLES_H diff --git a/core/roles/rolesform.cpp b/core/roles/rolesform.cpp new file mode 100644 index 0000000..7d6cfb7 --- /dev/null +++ b/core/roles/rolesform.cpp @@ -0,0 +1,17 @@ +#include "rolesform.h" +#include "ui_rolesform.h" + +RolesForm::RolesForm(QWidget *parent) : + AutoForm(parent), + ui(new Ui::RolesForm) +{ + ui->setupUi(this); + + registerBinding(ui->active); + registerBinding(ui->name); +} + +RolesForm::~RolesForm() +{ + delete ui; +} diff --git a/core/roles/rolesform.h b/core/roles/rolesform.h new file mode 100644 index 0000000..c8d6811 --- /dev/null +++ b/core/roles/rolesform.h @@ -0,0 +1,25 @@ +#ifndef ROLESFORM_H +#define ROLESFORM_H + +#include +#include "autoform.h" +#include "data/core-data.h" +#include "core-odb.hxx" + +namespace Ui { +class RolesForm; +} + +class RolesForm : public AutoForm +{ + Q_OBJECT + +public: + explicit RolesForm(QWidget *parent = 0); + ~RolesForm(); + +private: + Ui::RolesForm *ui; +}; + +#endif // ROLESFORM_H diff --git a/core/roles/rolesform.ui b/core/roles/rolesform.ui new file mode 100644 index 0000000..ea50558 --- /dev/null +++ b/core/roles/rolesform.ui @@ -0,0 +1,38 @@ + + + RolesForm + + + + 0 + 0 + 542 + 388 + + + + Form + + + + + + Name + + + + + + + + + + Active + + + + + + + + diff --git a/core/roles/rolestablemodel.cpp b/core/roles/rolestablemodel.cpp new file mode 100644 index 0000000..1280e96 --- /dev/null +++ b/core/roles/rolestablemodel.cpp @@ -0,0 +1,6 @@ +#include "rolestablemodel.h" + +RolesTableModel::RolesTableModel(QObject *parent) + :AutoTableModel(parent) +{ +} diff --git a/core/roles/rolestablemodel.h b/core/roles/rolestablemodel.h new file mode 100644 index 0000000..c3a20a2 --- /dev/null +++ b/core/roles/rolestablemodel.h @@ -0,0 +1,14 @@ +#ifndef ROLESTABLEMODEL_H +#define ROLESTABLEMODEL_H + +#include "autotablemodel.h" +#include "data/core-data.h" + +class RolesTableModel : public AutoTableModel +{ + Q_OBJECT +public: + explicit RolesTableModel(QObject *parent = NULL); +}; + +#endif // ROLESTABLEMODEL_H diff --git a/core/roles/rolesui.cpp b/core/roles/rolesui.cpp new file mode 100644 index 0000000..c278edb --- /dev/null +++ b/core/roles/rolesui.cpp @@ -0,0 +1,12 @@ +#include "rolesui.h" +#include "rolestablemodel.h" + +RolesUi::RolesUi(QWidget *parent) + :GridForm(parent) +{ + setTableModel(new RolesTableModel()); +} + +RolesUi::~RolesUi() +{ +} diff --git a/core/roles/rolesui.h b/core/roles/rolesui.h new file mode 100644 index 0000000..a07d69e --- /dev/null +++ b/core/roles/rolesui.h @@ -0,0 +1,16 @@ +#ifndef ROLESUI_H +#define ROLESUI_H + +#include "gridform.h" +#include "data/core-data.h" +#include "core-odb.hxx" + +class RolesUi : public GridForm +{ + Q_OBJECT +public: + explicit RolesUi(QWidget *parent = NULL); + ~RolesUi(); +}; + +#endif // ROLESUI_H