Implemented roles module.

print
Zdenek Jonak 9 years ago
parent 37d2371148
commit 7d01751c10

@ -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");

@ -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

@ -2,5 +2,6 @@
<qresource prefix="/">
<file>metaData.json</file>
<file>users/metaData.json</file>
<file>roles/metaData.json</file>
</qresource>
</RCC>

@ -0,0 +1,16 @@
{
"MetaData" : {
"id" : "CORE_ROLES",
"name" : {
"default" : "Core Roles plugin",
"CZ" : "Role"
},
"description" : {
"default" : "",
"CZ" : ""
},
"schemaVersion" : 1,
"sql" : [],
"dependencies" : []
}
}

@ -0,0 +1,24 @@
#include "roles.h"
#include "rolesui.h"
#include "rolesform.h"
#include <QFile>
#include <QJsonDocument>
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<Role>();
m_ui = new RolesUi();
((RolesUi*)m_ui)->setForm(new RolesForm());
}

@ -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

@ -0,0 +1,17 @@
#include "rolesform.h"
#include "ui_rolesform.h"
RolesForm::RolesForm(QWidget *parent) :
AutoForm<Role>(parent),
ui(new Ui::RolesForm)
{
ui->setupUi(this);
registerBinding(ui->active);
registerBinding(ui->name);
}
RolesForm::~RolesForm()
{
delete ui;
}

@ -0,0 +1,25 @@
#ifndef ROLESFORM_H
#define ROLESFORM_H
#include <QWidget>
#include "autoform.h"
#include "data/core-data.h"
#include "core-odb.hxx"
namespace Ui {
class RolesForm;
}
class RolesForm : public AutoForm<Role>
{
Q_OBJECT
public:
explicit RolesForm(QWidget *parent = 0);
~RolesForm();
private:
Ui::RolesForm *ui;
};
#endif // ROLESFORM_H

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>RolesForm</class>
<widget class="QWidget" name="RolesForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>542</width>
<height>388</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="name"/>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="active">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -0,0 +1,6 @@
#include "rolestablemodel.h"
RolesTableModel::RolesTableModel(QObject *parent)
:AutoTableModel<Role>(parent)
{
}

@ -0,0 +1,14 @@
#ifndef ROLESTABLEMODEL_H
#define ROLESTABLEMODEL_H
#include "autotablemodel.h"
#include "data/core-data.h"
class RolesTableModel : public AutoTableModel<Role>
{
Q_OBJECT
public:
explicit RolesTableModel(QObject *parent = NULL);
};
#endif // ROLESTABLEMODEL_H

@ -0,0 +1,12 @@
#include "rolesui.h"
#include "rolestablemodel.h"
RolesUi::RolesUi(QWidget *parent)
:GridForm<Role>(parent)
{
setTableModel(new RolesTableModel());
}
RolesUi::~RolesUi()
{
}

@ -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<Role>
{
Q_OBJECT
public:
explicit RolesUi(QWidget *parent = NULL);
~RolesUi();
};
#endif // ROLESUI_H
Loading…
Cancel
Save