Added base classes for plugin UI.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#include "accgrid.h"
|
||||
|
||||
#include "tablemodel.h"
|
||||
|
||||
AccGrid::AccGrid(QWidget *parent) :
|
||||
GridForm<Person>(parent)
|
||||
{
|
||||
setTableModel(new TableModel());
|
||||
}
|
||||
|
||||
AccGrid::~AccGrid()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef ACCGRID_H
|
||||
#define ACCGRID_H
|
||||
|
||||
#include <core.h>
|
||||
#include "data/person.h"
|
||||
|
||||
#include "accommodation-odb.hxx"
|
||||
|
||||
class AccGrid : public GridForm<Person>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AccGrid(QWidget *parent = NULL);
|
||||
~AccGrid();
|
||||
};
|
||||
|
||||
#endif // ACCGRID_H
|
||||
@@ -2,45 +2,36 @@
|
||||
|
||||
#include "accommodation.h"
|
||||
#include <QDebug>
|
||||
#include "accommodationform.h"
|
||||
|
||||
#include "data/person.h"
|
||||
#include "accommodationservice.h"
|
||||
|
||||
#include "accgrid.h"
|
||||
#include "acform.h"
|
||||
|
||||
Accommodation::Accommodation()
|
||||
{
|
||||
}
|
||||
|
||||
void Accommodation::initServiceUi()
|
||||
{
|
||||
m_ui = new AccommodationForm();
|
||||
AccGrid *grid = new AccGrid();
|
||||
AcForm *form = new AcForm();
|
||||
|
||||
grid->setForm(form);
|
||||
grid->setPluginId(pluginId());
|
||||
AccommodationService *service = new AccommodationService();
|
||||
service->setPluginId(pluginId());
|
||||
m_service = service;
|
||||
m_ui = grid;
|
||||
}
|
||||
|
||||
QWidget *Accommodation::ui()
|
||||
{
|
||||
QWidget *ui = IPlugin::ui();
|
||||
AccommodationForm *form = qobject_cast<AccommodationForm*>(ui);
|
||||
AccGrid *form = qobject_cast<AccGrid*>(ui);
|
||||
|
||||
form->fillGrid();
|
||||
form->fillData();
|
||||
|
||||
return ui;
|
||||
}
|
||||
|
||||
/*
|
||||
QString Accommodation::pluginName()
|
||||
{
|
||||
return "Ubytovani";
|
||||
}
|
||||
|
||||
void Accommodation::init(const QJsonObject &metaData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString Accommodation::pluginId()
|
||||
{
|
||||
return "ACCOMMODATION";
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -12,21 +12,19 @@ TEMPLATE = lib
|
||||
DEFINES += ACCOMMODATION_LIBRARY
|
||||
|
||||
SOURCES += accommodation.cpp \
|
||||
accommodationform.cpp \
|
||||
data/person.cpp \
|
||||
dialog.cpp \
|
||||
accommodationservice.cpp \
|
||||
tablemodel.cpp \
|
||||
acform.cpp
|
||||
acform.cpp \
|
||||
accgrid.cpp
|
||||
|
||||
HEADERS += accommodation.h\
|
||||
accommodation_global.h \
|
||||
accommodationform.h \
|
||||
data/person.h \
|
||||
dialog.h \
|
||||
accommodationservice.h \
|
||||
tablemodel.h \
|
||||
acform.h
|
||||
acform.h \
|
||||
accgrid.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
@@ -48,8 +46,6 @@ OTHER_FILES += \
|
||||
accommodation.json
|
||||
|
||||
FORMS += \
|
||||
accommodationform.ui \
|
||||
dialog.ui \
|
||||
acform.ui
|
||||
|
||||
ODB_FILES = accommodation/data/person.h
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#include "accommodationform.h"
|
||||
#include "ui_accommodationform.h"
|
||||
|
||||
#include <core.h>
|
||||
#include <autotablemodel.h>
|
||||
|
||||
#include "dialog.h"
|
||||
#include "data/person.h"
|
||||
|
||||
#include "tablemodel.h"
|
||||
|
||||
#include "accommodation-odb.hxx"
|
||||
|
||||
AccommodationForm::AccommodationForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AccommodationForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
AccommodationForm::~AccommodationForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AccommodationForm::fillGrid()
|
||||
{
|
||||
Service<Person> service;
|
||||
TableModel *model = qobject_cast<TableModel*>(ui->tableView->model());
|
||||
|
||||
if (model == NULL) {
|
||||
model = new TableModel();
|
||||
}
|
||||
|
||||
model->setData(service.all());
|
||||
ui->tableView->setModel(model);
|
||||
}
|
||||
|
||||
void AccommodationForm::on_pushButton_clicked()
|
||||
{
|
||||
Dialog *d = new Dialog();
|
||||
if (ui->tableView->model()->rowCount() > 0)
|
||||
{
|
||||
d->setData(((TableModel*)ui->tableView->model())->itemFromIndex(ui->tableView->currentIndex()));
|
||||
}
|
||||
d->open();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef ACCOMMODATIONFORM_H
|
||||
#define ACCOMMODATIONFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class AccommodationForm;
|
||||
}
|
||||
|
||||
class AccommodationForm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AccommodationForm(QWidget *parent = 0);
|
||||
~AccommodationForm();
|
||||
|
||||
void fillGrid();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::AccommodationForm *ui;
|
||||
};
|
||||
|
||||
#endif // ACCOMMODATIONFORM_H
|
||||
@@ -1,41 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AccommodationForm</class>
|
||||
<widget class="QWidget" name="AccommodationForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>828</width>
|
||||
<height>548</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView">
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::SingleSelection</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+15
-2
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>833</width>
|
||||
<height>536</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -33,6 +33,19 @@
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>610</x>
|
||||
<y>410</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
#include "dialog.h"
|
||||
#include "ui_dialog.h"
|
||||
|
||||
#include <core.h>
|
||||
|
||||
#include "data/person.h"
|
||||
#include "accommodationservice.h"
|
||||
|
||||
#include "acform.h"
|
||||
|
||||
#include "accommodation-odb.hxx"
|
||||
|
||||
Dialog::Dialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Dialog::setData(QSharedPointer<Person> data)
|
||||
{
|
||||
m_data = data;
|
||||
|
||||
AcForm *form = new AcForm(this);
|
||||
form->setEntity(data);
|
||||
ui->verticalLayout->addWidget(form);
|
||||
}
|
||||
|
||||
void Dialog::on_buttonBox_accepted()
|
||||
{
|
||||
IPlugin *plugin = Context::instance().plugins().at(0);
|
||||
QSharedPointer<Person> p(new Person());
|
||||
|
||||
p->setFirstName(ui->lineEdit->text());
|
||||
p->setLastName(ui->lineEdit_2->text());
|
||||
|
||||
AccommodationService *service = (AccommodationService*)plugin->service<Person>();
|
||||
service->pokus(p);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "data/person.h"
|
||||
|
||||
namespace Ui {
|
||||
class Dialog;
|
||||
}
|
||||
|
||||
class Dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = 0);
|
||||
~Dialog();
|
||||
|
||||
void setData(QSharedPointer<Person> data);
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::Dialog *ui;
|
||||
QSharedPointer<Person> m_data;
|
||||
};
|
||||
|
||||
#endif // DIALOG_H
|
||||
@@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Dialog</class>
|
||||
<widget class="QDialog" name="Dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>544</width>
|
||||
<height>444</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>340</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>40</y>
|
||||
<width>113</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>90</y>
|
||||
<width>113</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
<y>130</y>
|
||||
<width>421</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout"/>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user