initial commit Base app, core lib, plugin system
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#include <context.h>
|
||||
|
||||
#include "accommodation.h"
|
||||
#include <QDebug>
|
||||
#include "accommodationform.h"
|
||||
|
||||
#include "data/person.h"
|
||||
|
||||
Accommodation::Accommodation()
|
||||
{
|
||||
}
|
||||
|
||||
QString Accommodation::pluginName()
|
||||
{
|
||||
return "Ubytovani";
|
||||
}
|
||||
|
||||
void Accommodation::init()
|
||||
{
|
||||
qDebug() << "init accomodation";
|
||||
m_ui = new AccommodationForm();
|
||||
m_service = new Service<Person>();
|
||||
}
|
||||
|
||||
QString Accommodation::pluginId()
|
||||
{
|
||||
return "ACCOMMODATION";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef ACCOMMODATION_H
|
||||
#define ACCOMMODATION_H
|
||||
|
||||
#include "accommodation_global.h"
|
||||
#include <context.h>
|
||||
#include <iplugin.h>
|
||||
#include <QObject>
|
||||
#include <QtPlugin>
|
||||
|
||||
class ACCOMMODATIONSHARED_EXPORT Accommodation : public QObject, IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID PluginInterface_iid FILE "accommodation.json")
|
||||
Q_INTERFACES(IPlugin)
|
||||
|
||||
public:
|
||||
Accommodation();
|
||||
|
||||
QString pluginName() Q_DECL_OVERRIDE;
|
||||
void init() Q_DECL_OVERRIDE;
|
||||
QString pluginId() Q_DECL_OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
#endif // ACCOMMODATION_H
|
||||
@@ -0,0 +1,48 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2015-10-28T15:27:14
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += widgets
|
||||
|
||||
TARGET = accommodation
|
||||
TEMPLATE = lib
|
||||
|
||||
DEFINES += ACCOMMODATION_LIBRARY
|
||||
|
||||
SOURCES += accommodation.cpp \
|
||||
accommodationform.cpp \
|
||||
data/person.cpp \
|
||||
dialog.cpp
|
||||
|
||||
HEADERS += accommodation.h\
|
||||
accommodation_global.h \
|
||||
accommodationform.h \
|
||||
data/person.h \
|
||||
dialog.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../core/release/ -lcore
|
||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -lcore
|
||||
else:unix: LIBS += -L$$OUT_PWD/../core/ -lcore
|
||||
|
||||
INCLUDEPATH += $$PWD/../core
|
||||
DEPENDPATH += $$PWD/../core
|
||||
|
||||
DESTDIR = ../plugins
|
||||
|
||||
OTHER_FILES += \
|
||||
accommodation.json
|
||||
|
||||
FORMS += \
|
||||
accommodationform.ui \
|
||||
dialog.ui
|
||||
|
||||
ODB_FILES = accommodation/data/person.h
|
||||
H_DIR = $$PWD/data/*.h
|
||||
include(../odb.pri)
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef ACCOMMODATION_GLOBAL_H
|
||||
#define ACCOMMODATION_GLOBAL_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#if defined(ACCOMMODATION_LIBRARY)
|
||||
# define ACCOMMODATIONSHARED_EXPORT Q_DECL_EXPORT
|
||||
#else
|
||||
# define ACCOMMODATIONSHARED_EXPORT Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // ACCOMMODATION_GLOBAL_H
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "accommodationform.h"
|
||||
#include "ui_accommodationform.h"
|
||||
|
||||
#include "dialog.h"
|
||||
|
||||
AccommodationForm::AccommodationForm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AccommodationForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
AccommodationForm::~AccommodationForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AccommodationForm::on_pushButton_clicked()
|
||||
{
|
||||
Dialog d;
|
||||
d.open();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#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();
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::AccommodationForm *ui;
|
||||
};
|
||||
|
||||
#endif // ACCOMMODATIONFORM_H
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "person.h"
|
||||
|
||||
Person::Person()
|
||||
{
|
||||
}
|
||||
int Person::getId() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
void Person::setId(int value)
|
||||
{
|
||||
id = value;
|
||||
}
|
||||
QString Person::getFirstName() const
|
||||
{
|
||||
return firstName;
|
||||
}
|
||||
|
||||
void Person::setFirstName(const QString &value)
|
||||
{
|
||||
firstName = value;
|
||||
}
|
||||
QString Person::getLastName() const
|
||||
{
|
||||
return lastName;
|
||||
}
|
||||
|
||||
void Person::setLastName(const QString &value)
|
||||
{
|
||||
lastName = value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef PERSON_H
|
||||
#define PERSON_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class Person : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Person();
|
||||
|
||||
int getId() const;
|
||||
void setId(int value);
|
||||
|
||||
QString getFirstName() const;
|
||||
void setFirstName(const QString &value);
|
||||
|
||||
QString getLastName() const;
|
||||
void setLastName(const QString &value);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int id;
|
||||
QString firstName;
|
||||
QString lastName;
|
||||
|
||||
};
|
||||
|
||||
#endif // PERSON_H
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "dialog.h"
|
||||
#include "ui_dialog.h"
|
||||
|
||||
#include <context.h>
|
||||
#include <iplugin.h>
|
||||
#include "data/person.h"
|
||||
|
||||
#include "accommodation-odb.hxx"
|
||||
|
||||
Dialog::Dialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::Dialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
Dialog::~Dialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
plugin->service<Person>()->save(p);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef DIALOG_H
|
||||
#define DIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class Dialog;
|
||||
}
|
||||
|
||||
class Dialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Dialog(QWidget *parent = 0);
|
||||
~Dialog();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
||||
private:
|
||||
Ui::Dialog *ui;
|
||||
};
|
||||
|
||||
#endif // DIALOG_H
|
||||
@@ -0,0 +1,88 @@
|
||||
<?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>355</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</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>
|
||||
<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