users plugin implementation
parent
30a6f57b19
commit
a6d795ec87
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>metaData.json</file>
|
||||
<file>users/metaData.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -0,0 +1,16 @@
|
||||
{
|
||||
"MetaData" : {
|
||||
"id" : "CORE_USERS",
|
||||
"name" : {
|
||||
"default" : "Core Users plugin",
|
||||
"CZ" : "Uživatelé"
|
||||
},
|
||||
"description" : {
|
||||
"default" : "",
|
||||
"CZ" : ""
|
||||
},
|
||||
"schemaVersion" : 1,
|
||||
"sql" : [],
|
||||
"dependencies" : []
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
#include "tablemodel.h"
|
||||
|
||||
TableModel::TableModel(QObject *parent) :AutoTableModel<User>(parent)
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
#ifndef TABLEMODEL_H
|
||||
#define TABLEMODEL_H
|
||||
|
||||
#include "autotablemodel.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
class TableModel : public AutoTableModel<User>
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TableModel(QObject *parent = NULL);
|
||||
};
|
||||
|
||||
#endif // TABLEMODEL_H
|
@ -0,0 +1,19 @@
|
||||
#include "userform.h"
|
||||
#include "ui_userform.h"
|
||||
|
||||
UserForm::UserForm(QWidget *parent) :
|
||||
AutoForm<User>(parent),
|
||||
ui(new Ui::UserForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
registerBinding(ui->login);
|
||||
registerBinding(ui->password);
|
||||
registerBinding(ui->name);
|
||||
registerBinding(ui->isAdmin);
|
||||
registerBinding(ui->active);
|
||||
}
|
||||
|
||||
UserForm::~UserForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#ifndef USERFORM_H
|
||||
#define USERFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "autoform.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
namespace Ui {
|
||||
class UserForm;
|
||||
}
|
||||
|
||||
class UserForm : public AutoForm<User>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UserForm(QWidget *parent = 0);
|
||||
~UserForm();
|
||||
|
||||
private:
|
||||
Ui::UserForm *ui;
|
||||
};
|
||||
|
||||
#endif // USERFORM_H
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UserForm</class>
|
||||
<widget class="QWidget" name="UserForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</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>Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="login"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="password"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="name"/>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="isAdmin">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Is Admin</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="active">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Active</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,21 @@
|
||||
#include "users.h"
|
||||
#include <QFile>
|
||||
#include <QJsonDocument>
|
||||
|
||||
Users::Users()
|
||||
{
|
||||
Q_INIT_RESOURCE(rc);
|
||||
|
||||
QFile f (":/users/metaData.json");
|
||||
f.open(QIODevice::ReadOnly | QIODevice::Text);
|
||||
QJsonDocument d = QJsonDocument::fromJson(f.readAll());
|
||||
init(d.object());
|
||||
f.close();
|
||||
}
|
||||
|
||||
void Users::initServiceUi()
|
||||
{
|
||||
m_service = new Service<User>;
|
||||
m_ui = new UsersUi;
|
||||
((UsersUi *) m_ui)->setForm(new UserForm);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef USERS_H
|
||||
#define USERS_H
|
||||
#include "imetadataplugin.h"
|
||||
#include "userform.h"
|
||||
#include "usersui.h"
|
||||
|
||||
class Users : public IMetaDataPlugin
|
||||
{
|
||||
public:
|
||||
Users();
|
||||
|
||||
// IMetaDataPlugin interface
|
||||
protected:
|
||||
void initServiceUi();
|
||||
};
|
||||
|
||||
#endif // USERS_H
|
@ -0,0 +1,12 @@
|
||||
#include "usersui.h"
|
||||
#include "tablemodel.h"
|
||||
|
||||
UsersUi::UsersUi(QWidget *parent) :GridForm<User>(parent)
|
||||
{
|
||||
setTableModel(new TableModel);
|
||||
}
|
||||
|
||||
UsersUi::~UsersUi()
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef USERSUI_H
|
||||
#define USERSUI_H
|
||||
|
||||
#include "gridform.h"
|
||||
#include "../data/core-data.h"
|
||||
#include "core-odb.hxx"
|
||||
|
||||
class UsersUi : public GridForm<User>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UsersUi(QWidget *parent = NULL);
|
||||
~UsersUi();
|
||||
};
|
||||
|
||||
#endif // USERSUI_H
|
Loading…
Reference in New Issue