Compare commits

..

4 Commits

2
.gitignore vendored

@ -0,0 +1,2 @@
cmake*
build

9
.gitmodules vendored

@ -0,0 +1,9 @@
[submodule "3rdparty/qdecimal"]
path = 3rdparty/qdecimal
url = https://github.com/semihc/qdecimal.git
[submodule "3rdparty/QxOrm"]
path = 3rdparty/QxOrm
url = https://github.com/PepaRokos/QxOrm.git
[submodule "3rdparty/LimeReport"]
path = 3rdparty/LimeReport
url = https://github.com/PepaRokos/LimeReport.git

@ -0,0 +1,3 @@
add_subdirectory(qdecimal)
add_subdirectory(QxOrm)
add_subdirectory(LimeReport)

@ -0,0 +1 @@
Subproject commit b1bfd131ad3a9a107c176b4661a47eee54dfd481

1
3rdparty/QxOrm vendored

@ -0,0 +1 @@
Subproject commit 975c3b5ad3e02e3a257f28ff81071da0a17a1e64

1
3rdparty/qdecimal vendored

@ -0,0 +1 @@
Subproject commit 31d650e0e61acdef1f5b2c23b6daf26ea409c22c

@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.24)
project(prodejna-root)
add_subdirectory(3rdparty/qdecimal)
add_subdirectory(3rdparty/QxOrm)
add_subdirectory(3rdparty/LimeReport)
add_subdirectory(core)
add_subdirectory(application)
add_subdirectory(countryregister)
add_subdirectory(addressbook)
add_subdirectory(postregister)
add_subdirectory(services)
add_subdirectory(shop)
add_subdirectory(commodity)
add_subdirectory(camp)

@ -1,14 +0,0 @@
#include "accform.h"
#include "ui_accform.h"
AccForm::AccForm(QWidget *parent) :
QWidget(parent),
ui(new Ui::AccForm)
{
ui->setupUi(this);
}
AccForm::~AccForm()
{
delete ui;
}

@ -1,14 +0,0 @@
#include "accgrid.h"
#include "tablemodel.h"
AccGrid::AccGrid(QWidget *parent) :
GridForm<Person>(parent)
{
setTableModel(new TableModel());
}
AccGrid::~AccGrid()
{
}

@ -1,18 +0,0 @@
#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

@ -1,41 +0,0 @@
#include <context.h>
#include "accommodation.h"
#include <QDebug>
#include "data/person.h"
#include "accommodationservice.h"
#include "accgrid.h"
#include "acform.h"
Accommodation::Accommodation()
{
}
void Accommodation::initServiceUi()
{
AccGrid *grid = new AccGrid();
AcForm *form = new AcForm();
grid->setForm(form);
AccommodationService *service = new AccommodationService();
m_service = service;
m_ui = grid;
}
QIcon Accommodation::pluginIcon()
{
return QIcon(":/icons/accPlugin.svg");
}
/*
QWidget *Accommodation::ui()
{
QWidget *ui = IPlugin::ui();
AccGrid *form = qobject_cast<AccGrid*>(ui);
form->fillData();
return ui;
}
*/

@ -1,37 +0,0 @@
#ifndef ACCOMMODATION_H
#define ACCOMMODATION_H
#include "accommodation_global.h"
#include <core.h>
#include <QObject>
#include <QtPlugin>
class ACCOMMODATIONSHARED_EXPORT Accommodation : public QObject, IMetaDataPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID PluginInterface_iid FILE "accommodation.json")
Q_INTERFACES(IPlugin)
public:
Accommodation();
// QString pluginName() Q_DECL_OVERRIDE;
// void init(const QJsonObject &metaData) Q_DECL_OVERRIDE;
// QString pluginId() Q_DECL_OVERRIDE;
protected:
void initServiceUi() Q_DECL_OVERRIDE;
// IPlugin interface
public:
//QWidget *ui();
// IPlugin interface
public:
virtual QIcon pluginIcon();
};
#endif // ACCOMMODATION_H

@ -1,20 +0,0 @@
{
"id" : "ACCOMMODATION",
"name" : {
"default" : "Accommodation",
"CZ" : "Kemp"
},
"descriptoin" : {
"default" : "",
"CZ" : ""
},
"schemaVersion" : 1,
"sql" : [
"CREATE TABLE \"Person\" (
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
\"firstName\" TEXT NULL,
\"lastName\" TEXT NULL);"
],
"dependencies" : []
}

@ -1,46 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-28T15:27:14
#
#-------------------------------------------------
QT += widgets sql
TARGET = accommodation
TEMPLATE = lib
DEFINES += ACCOMMODATION_LIBRARY
SOURCES += accommodation.cpp \
data/person.cpp \
accommodationservice.cpp \
tablemodel.cpp \
acform.cpp \
accgrid.cpp \
data/address.cpp
HEADERS += accommodation.h\
accommodation_global.h \
data/person.h \
accommodationservice.h \
tablemodel.h \
acform.h \
accgrid.h \
data/address.h \
data/accommodation-data.h
include(../config_plugin.pri)
OTHER_FILES += \
accommodation.json
FORMS += \
acform.ui
ODB_FILES = accommodation/data/accommodation-data.h
H_DIR = $$PWD/data/*.h
include(../odb.pri)
RESOURCES += \
accrc.qrc

@ -1,12 +0,0 @@
#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

@ -1,28 +0,0 @@
#include "accommodationservice.h"
#include <odb/database.hxx>
#include <odb/transaction.hxx>
#include "accommodation-odb.hxx"
AccommodationService::AccommodationService()
:Service<Person>("ACCOMMODATION")
{
}
AccommodationService::~AccommodationService()
{
}
void AccommodationService::pokus(QSharedPointer<Person> entity)
{
odb::database *db = Context::instance().db();
//odb::transaction tr(db->begin());
Transaction tr;
this->all();
db->persist(entity);
tr.commit();
}

@ -1,19 +0,0 @@
#ifndef ACCOMMODATIONSERVICE_H
#define ACCOMMODATIONSERVICE_H
#include "data/person.h"
#include <core.h>
#include "accommodation_global.h"
#include "accommodation-odb.hxx"
class ACCOMMODATIONSHARED_EXPORT AccommodationService : public Service<Person>
{
public:
AccommodationService();
~AccommodationService();
void pokus(QSharedPointer<Person> entity);
};
#endif // ACCOMMODATIONSERVICE_H

@ -1,5 +0,0 @@
<RCC>
<qresource prefix="/">
<file>icons/accPlugin.svg</file>
</qresource>
</RCC>

@ -1,34 +0,0 @@
#include "acform.h"
#include "ui_acform.h"
#include <QList>
#include <settingsservice.h>
#include <settings/globalsettings.h>
#include "accommodation-odb.hxx"
AcForm::AcForm(QWidget *parent) :
AutoForm<Person>(parent),
ui(new Ui::AcForm)
{
ui->setupUi(this);
registerBinding(ui->firstName);
registerBinding(ui->lastName);
}
AcForm::~AcForm()
{
delete ui;
}
void AcForm::registerCombos()
{
QList<ComboData> cbData;
Service<Address> srv;
foreach (QSharedPointer<Address> adr, srv.all()) {
cbData.append(ComboData(adr));
}
registerBinding(ui->address, cbData);
}

@ -1,30 +0,0 @@
#ifndef ACFORM_H
#define ACFORM_H
#include <QWidget>
#include <autoform.h>
#include "data/person.h"
#include "accommodation-odb.hxx"
namespace Ui {
class AcForm;
}
class AcForm : public AutoForm<Person>
{
Q_OBJECT
public:
explicit AcForm(QWidget *parent = 0);
~AcForm();
private:
Ui::AcForm *ui;
// AutoForm interface
protected:
virtual void registerCombos();
};
#endif // ACFORM_H

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AcForm</class>
<widget class="QWidget" name="AcForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>833</width>
<height>536</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLineEdit" name="firstName">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>191</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLineEdit" name="lastName">
<property name="geometry">
<rect>
<x>90</x>
<y>110</y>
<width>191</width>
<height>20</height>
</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 class="QComboBox" name="address">
<property name="geometry">
<rect>
<x>110</x>
<y>170</y>
<width>191</width>
<height>22</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

@ -1,8 +0,0 @@
#ifndef ACCOMMODATIONDATA_H
#define ACCOMMODATIONDATA_H
#include "address.h"
#include "person.h"
#endif // ACCOMMODATIONDATA_H

@ -1,58 +0,0 @@
#include "address.h"
Address::Address(QObject *parent) : ComboItem(parent)
{
}
Address::~Address()
{
}
QString Address::city() const
{
return m_city;
}
void Address::setCity(const QString &city)
{
m_city = city;
}
QString Address::street() const
{
return m_street;
}
void Address::setStreet(const QString &street)
{
m_street = street;
}
QString Address::houseNumber() const
{
return m_houseNumber;
}
void Address::setHouseNumber(const QString &houseNumber)
{
m_houseNumber = houseNumber;
}
int Address::id() const
{
return m_id;
}
void Address::setId(int id)
{
m_id = id;
}
bool Address::eq(ComboItem *other)
{
Address *addr = qobject_cast<Address*>(other);
return addr != NULL && m_id == addr->id();
}
QString Address::toString()
{
return m_street + ", " + m_houseNumber + ", " + m_city;
}

@ -1,55 +0,0 @@
#ifndef ADDRESS_H
#define ADDRESS_H
#include <QObject>
#include <QString>
#include <data/comboitem.h>
#include <odb/core.hxx>
#pragma db object
class Address : public ComboItem
{
Q_OBJECT
Q_PROPERTY(QString city READ city WRITE setCity)
Q_PROPERTY(QString street READ street WRITE setStreet)
Q_PROPERTY(QString houseNumber READ houseNumber WRITE setHouseNumber)
public:
explicit Address(QObject *parent = 0);
~Address();
QString city() const;
void setCity(const QString &city);
QString street() const;
void setStreet(const QString &street);
QString houseNumber() const;
void setHouseNumber(const QString &houseNumber);
int id() const;
void setId(int id);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString m_city;
QString m_street;
QString m_houseNumber;
signals:
public slots:
// ComboItem interface
public:
virtual bool eq(ComboItem *other);
virtual QString toString();
};
#endif // ADDRESS_H

@ -1,49 +0,0 @@
#include <data/comboitem.h>
#include "person.h"
Person::Person()
{
}
int Person::id() const
{
return m_id;
}
void Person::setId(int value)
{
m_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;
}
QSharedPointer<QObject> Person::address() const
{
return m_address;
}
void Person::setAddress(const QSharedPointer<QObject> &address)
{
if (qobject_cast<Address*>(address.data()) != NULL)
{
m_address = qSharedPointerDynamicCast<Address, QObject>(address);
}
}

@ -1,44 +0,0 @@
#ifndef PERSON_H
#define PERSON_H
#include <QObject>
#include <QString>
#include "address.h"
#include <odb/core.hxx>
#pragma db object
class Person : public QObject
{
Q_OBJECT
Q_PROPERTY(QString firstName READ getFirstName WRITE setFirstName)
Q_PROPERTY(QString lastName READ getLastName WRITE setLastName)
Q_PROPERTY(QSharedPointer<QObject> address READ address WRITE setAddress)
public:
Person();
int id() const;
void setId(int value);
QString getFirstName() const;
void setFirstName(const QString &value);
QString getLastName() const;
void setLastName(const QString &value);
QSharedPointer<QObject> address() const;
void setAddress(const QSharedPointer<QObject> &address);
private:
friend class odb::access;
#pragma db id auto
int m_id;
QString firstName;
QString lastName;
QSharedPointer<Address> m_address;
};
#endif // PERSON_H

@ -1,7 +0,0 @@
<?xml version="1.0" ?><svg clip-rule="evenodd" fill-rule="evenodd" image-rendering="optimizeQuality" shape-rendering="geometricPrecision" text-rendering="geometricPrecision" viewBox="0 0 5000 5000" xmlns="http://www.w3.org/2000/svg"><defs><style type="text/css"><![CDATA[
.str1 {stroke:#434242;stroke-width:100}
.str0 {stroke:#434242;stroke-width:300;stroke-linecap:round}
.fil0 {fill:none}
.fil1 {fill:#434242}
.fil2 {fill:url(#id0)}
]]></style><linearGradient gradientUnits="userSpaceOnUse" id="id0" x1="2500.01" x2="2500.01" y1="4260.19" y2="1474.81"><stop offset="0" stop-color="#008BFF"/><stop offset="1" stop-color="#0af"/></linearGradient></defs><g id="Layer_x0020_1"><path class="fil0 str0" d="M300 2000l2050-1600c100-50 200-50 300 0l2050 1500"/><path class="fil1" d="M3500 1022l600 439v-861c0-55-45-100-100-100h-400c-55 0-100 45-100 100v422z"/><path class="fil2 str1" d="M899 4700h901v-1500c0-110 90-200 200-200h900c110 0 200 90 200 200v1500h1001c165 0 300-135 300-300l-1-2000-1776-1328c-33-26-79-37-124-36s-92 14-127 40l-1773 1324-1 2000c0 165 135 300 300 300z"/></g></svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

@ -1,8 +0,0 @@
#include "tablemodel.h"
TableModel::TableModel(QObject *parent)
:AutoTableModel<Person>(parent)
{
}

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

@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.24)
project(addressbook)
include(../3rdparty/QxOrm/QxOrm.cmake)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ../plugins)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)
add_library(addressbook SHARED
addressbook.cpp
addressbook.h
addressbookrc.qrc
addressbook_global.h
addressbookform.cpp
addressbookform.h
addressbookform.ui
addressbookgrid.cpp
addressbookgrid.h
addressbookservice.cpp
addressbookservice.h
addressbooktablemodel.cpp
addressbooktablemodel.h
data/addressbookdata.cpp
data/addressbookdata.h)
target_compile_definitions(addressbook PRIVATE -DADDRESSBOOK_LIBRARY)
include_directories(../core)
include_directories(../countryregister)
target_link_libraries(addressbook
Qt::Core
Qt::Gui
Qt::Widgets
qdecimal
decnumber
QxOrm
core
countryregister
)
install(TARGETS addressbook
LIBRARY DESTINATION ../plugins)

@ -26,8 +26,8 @@ protected:
// IPlugin interface // IPlugin interface
public: public:
virtual QIcon pluginIcon(); QIcon pluginIcon() override;
QTranslator *translator(); QTranslator *translator() override;
}; };

@ -1,54 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2016-02-09T21:27:28
#
#-------------------------------------------------
QT += widgets sql
QT -= gui
TARGET = addressbook
TEMPLATE = lib
DEFINES += ADDRESSBOOK_LIBRARY
SOURCES += addressbook.cpp \
data/addressbookdata.cpp \
addressbookform.cpp \
addressbookgrid.cpp \
addressbooktablemodel.cpp \
addressbookservice.cpp
HEADERS += addressbook.h\
addressbook_global.h \
data/addressbookdata.h \
addressbookform.h \
addressbookgrid.h \
addressbooktablemodel.h \
addressbookservice.h
include(../config_plugin.pri)
ODB_FILES = addressbook/data/addressbookdata.h
H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../countryregister/data
include(../odb.pri)
OTHER_FILES += \
addressbook.json
FORMS += \
addressbookform.ui
RESOURCES += \
addressbookrc.qrc
TRANSLATIONS = translations/addressbook_cs_CZ.ts
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister
INCLUDEPATH += $$PWD/../countryregister/data
INCLUDEPATH += $$PWD/../countryregister

@ -2,6 +2,7 @@
#define ADDRESSBOOK_GLOBAL_H #define ADDRESSBOOK_GLOBAL_H
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QxOrm.h>
#if defined(ADDRESSBOOK_LIBRARY) #if defined(ADDRESSBOOK_LIBRARY)
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT # define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
@ -9,4 +10,12 @@
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT # define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
#endif #endif
#ifdef ADDRESSBOOK_LIBRARY
#define QX_REGISTER_HPP_ADDR QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_ADDR QX_REGISTER_CPP_EXPORT_DLL
#else // ADDRESSBOOK_LIBRARY
#define QX_REGISTER_HPP_ADDR QX_REGISTER_HPP_IMPORT_DLL
#define QX_REGISTER_CPP_ADDR QX_REGISTER_CPP_IMPORT_DLL
#endif
#endif // ADDRESSBOOK_GLOBAL_H #endif // ADDRESSBOOK_GLOBAL_H

@ -1,6 +1,7 @@
#include <data/countrydata.h>
#include "addressbookform.h" #include "addressbookform.h"
#include "ui_addressbookform.h" #include "ui_addressbookform.h"
#include <countrydata.h> #include <data/countrydata.h>
AddressbookForm::AddressbookForm(QWidget *parent) : AddressbookForm::AddressbookForm(QWidget *parent) :
AutoForm<AddressbookData>(parent), AutoForm<AddressbookData>(parent),

@ -4,7 +4,6 @@
#include <QWidget> #include <QWidget>
#include <autoform.h> #include <autoform.h>
#include "data/addressbookdata.h" #include "data/addressbookdata.h"
#include "addressbook-odb.hxx"
namespace Ui { namespace Ui {
class AddressbookForm; class AddressbookForm;
@ -16,14 +15,14 @@ class AddressbookForm : public AutoForm<AddressbookData>
public: public:
explicit AddressbookForm(QWidget *parent = 0); explicit AddressbookForm(QWidget *parent = 0);
~AddressbookForm(); ~AddressbookForm() override;
private: private:
Ui::AddressbookForm *ui; Ui::AddressbookForm *ui;
// FormBinder interface // FormBinder interface
protected: protected:
void registerCombos(); void registerCombos() override;
}; };

@ -6,14 +6,17 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>610</width> <width>624</width>
<height>407</height> <height>363</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">

@ -3,7 +3,6 @@
#include <core.h> #include <core.h>
#include "data/addressbookdata.h" #include "data/addressbookdata.h"
#include "addressbook-odb.hxx"
class AddressbookGrid : public GridForm<AddressbookData> class AddressbookGrid : public GridForm<AddressbookData>
{ {

@ -1,6 +1,5 @@
#include <service.h> #include <service.h>
#include "addressbookservice.h" #include "addressbookservice.h"
#include "addressbook-odb.hxx"
AddressBookService::AddressBookService() AddressBookService::AddressBookService()
{ {
@ -24,7 +23,7 @@ AddressbookDataPtr AddressBookService::copyAddress(AddressbookDataPtr address)
newAddress->setAddressHouseNumber(address->addressHouseNumber()); newAddress->setAddressHouseNumber(address->addressHouseNumber());
newAddress->setAddressZipCode(address->addressZipCode()); newAddress->setAddressZipCode(address->addressZipCode());
newAddress->setAddressCity(address->addressCity()); newAddress->setAddressCity(address->addressCity());
newAddress->setCountry(address->country()); //newAddress->setCountry(address->country());
return newAddress; return newAddress;
} }

@ -1,5 +1,26 @@
#include <data/countrydata.h>
#include "addressbookdata.h" #include "addressbookdata.h"
QX_REGISTER_CPP_ADDR(AddressbookData)
namespace qx {
template<> void register_class(QxClass<AddressbookData>& t) {
t.setName("AddressbookData");
t.id(&AddressbookData::m_id, "id");
t.data(&AddressbookData::m_title, "title");
t.data(&AddressbookData::m_firstName, "firstName");
t.data(&AddressbookData::m_lastName, "lastName");
t.data(&AddressbookData::m_birthDate, "birthDate");
t.data(&AddressbookData::m_idCardNumber, "idCardNumber");
t.data(&AddressbookData::m_ztp, "ztp");
t.data(&AddressbookData::m_addressCity, "addressCity");
t.data(&AddressbookData::m_addressHouseNumber, "addressHouseNumber");
t.data(&AddressbookData::m_addressZipCode, "addressZipCode");
t.relationManyToOne(&AddressbookData::m_country, "country");
}
}
AddressbookData::AddressbookData(QObject * parent) AddressbookData::AddressbookData(QObject * parent)
:ComboItem(parent) :ComboItem(parent)
{ {
@ -96,12 +117,12 @@ void AddressbookData::setAddressZipCode(const QString &addressZipCode)
{ {
m_addressZipCode = addressZipCode; m_addressZipCode = addressZipCode;
} }
int AddressbookData::id() const long AddressbookData::id() const
{ {
return m_id; return m_id;
} }
void AddressbookData::setId(int id) void AddressbookData::setId(long id)
{ {
m_id = id; m_id = id;
} }
@ -122,7 +143,7 @@ void AddressbookData::setCountry(const QSharedPointer<QObject> &country)
bool AddressbookData::eq(ComboItem *other) bool AddressbookData::eq(ComboItem *other)
{ {
AddressbookData *adb = qobject_cast<AddressbookData*>(other); AddressbookData *adb = qobject_cast<AddressbookData*>(other);
return adb != NULL && adb->id() == this->id(); return adb != nullptr && adb->id() == this->id();
} }
QString AddressbookData::toString() QString AddressbookData::toString()
@ -130,4 +151,8 @@ QString AddressbookData::toString()
return m_lastName + " " + m_firstName + ", " + m_addressStreet + " " + m_addressHouseNumber + ", " + m_addressCity; return m_lastName + " " + m_firstName + ", " + m_addressStreet + " " + m_addressHouseNumber + ", " + m_addressCity;
} }
QStringList AddressbookData::eagerLoad() {
return { "country" };
}

@ -1,26 +1,22 @@
#ifndef ADDRESSBOOKDATA_H #ifndef ADDRESSBOOKDATA_H
#define ADDRESSBOOKDATA_H #define ADDRESSBOOKDATA_H
#include "../addressbook_global.h"
#include <data/comboitem.h>
#include <data/countrydata.h>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QDate> #include <QDate>
#include <odb/core.hxx>
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QSharedPointer> #include <QSharedPointer>
#include <data/comboitem.h> #include <QxOrm.h>
#include <countrydata.h>
#if defined(ADDRESSBOOK_LIBRARY)
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
#else
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
#endif
#pragma db object
class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(AddressbookData)
Q_PROPERTY(QString title READ title WRITE setTitle) Q_PROPERTY(QString title READ title WRITE setTitle)
Q_PROPERTY(QString firstName READ firstName WRITE setFirstName) Q_PROPERTY(QString firstName READ firstName WRITE setFirstName)
Q_PROPERTY(QString lastName READ lastName WRITE setLastName) Q_PROPERTY(QString lastName READ lastName WRITE setLastName)
@ -35,6 +31,7 @@ class ADDRESSBOOKSHARED_EXPORT AddressbookData : public ComboItem
public: public:
AddressbookData(QObject *parent = 0); AddressbookData(QObject *parent = 0);
QString title() const; QString title() const;
void setTitle(const QString &title); void setTitle(const QString &title);
@ -65,16 +62,16 @@ public:
QString addressZipCode() const; QString addressZipCode() const;
void setAddressZipCode(const QString &addressZipCode); void setAddressZipCode(const QString &addressZipCode);
int id() const; long id() const;
void setId(int id); void setId(long id);
QSharedPointer<QObject> country() const; QSharedPointer<QObject> country() const;
void setCountry(const QSharedPointer<QObject> &country); void setCountry(const QSharedPointer<QObject> &country);
Q_INVOKABLE QStringList eagerLoad();
private: private:
friend class odb::access; long m_id{0};
#pragma db id auto
int m_id;
QString m_title; QString m_title;
QString m_firstName; QString m_firstName;
QString m_lastName; QString m_lastName;
@ -89,10 +86,12 @@ private:
// ComboItem interface // ComboItem interface
public: public:
virtual bool eq(ComboItem *other); bool eq(ComboItem *other) override;
virtual QString toString(); QString toString() override;
}; };
typedef QSharedPointer<AddressbookData> AddressbookDataPtr; typedef QSharedPointer<AddressbookData> AddressbookDataPtr;
QX_REGISTER_HPP_ADDR(AddressbookData, ComboItem, 0)
#endif // ADDRESSBOOKDATA_H #endif // ADDRESSBOOKDATA_H

@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.24)
project(prodejna)
include(../3rdparty/QxOrm/QxOrm.cmake)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
Sql
REQUIRED)
include_directories(../core)
add_executable(prodejna
main.cpp
appRc.qrc
application.cpp
application.h
logindialog.cpp
logindialog.h
logindialog.ui
mainwindow.cpp
mainwindow.h
mainwindow.ui)
target_link_libraries(prodejna
Qt::Core
Qt::Gui
Qt::Widgets
Qt::Sql
core
)

@ -1,92 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2015-10-28T15:23:55
#
#-------------------------------------------------
QT += core gui sql
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = prodejna
TEMPLATE = app
DEFINES += _GLIBCXX_USE_CXX11_ABI=1
CONFIG += c++11
include(../config_odb.pri)
win32 {
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/libodb-2.4.0
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/libodb-qt-2.4.0
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/libodb-sqlite-2.4.0
INCLUDEPATH += $$ODB_INCLUDE_PREFIX/sqlite
RC_FILE = shop.rc
}
SOURCES += main.cpp\
mainwindow.cpp \
logindialog.cpp \
application.cpp
HEADERS += mainwindow.h \
logindialog.h \
application.h
FORMS += mainwindow.ui \
logindialog.ui
unix{
ARCH_TYPE = unix
macx{
ARCH_TYPE = macx
}
linux{
!contains(QT_ARCH, x86_64){
ARCH_TYPE = linux32
}else{
ARCH_TYPE = linux64
}
}
}
unix {
QMAKE_CXXFLAGS += -Wno-unknown-pragmas
CONFIG(debug, debug|release) {
LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/ -llimereport -lQtZint
#QMAKE_CXXFLAGS += -Wl,-rpath-link,$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/debug/lib/
} else {
LIBS += -L$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/release/lib/ -llimereport -lQtZint
#QMAKE_CXXFLAGS += -Wl,-rpath-link,$$PWD/../../LimeReport/build/$${QT_VERSION}/$${ARCH_TYPE}/release/lib/
}
}
win32 {
QMAKE_CXXFLAGS += -wd4995 -wd4068
}
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
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
else:unix: LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
INCLUDEPATH += $$PWD/../qdecimal/src
INCLUDEPATH += $$PWD/../qdecimal/decnumber
RESOURCES += \
appRc.qrc
TRANSLATIONS = translations/prodejna_cs_CZ.ts
DISTFILES += \
shop.rc

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>408</width> <width>427</width>
<height>220</height> <height>260</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -64,6 +64,9 @@
<item> <item>
<widget class="QWidget" name="widget_2" native="true"> <widget class="QWidget" name="widget_2" native="true">
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="text"> <property name="text">

@ -1,6 +1,7 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QApplication>
#include <QDesktopWidget> //#include <QDesktopWidget>
#include <QSharedPointer>
#include <QTranslator> #include <QTranslator>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QMessageBox> #include <QMessageBox>
@ -17,7 +18,7 @@ int main(int argc, char *argv[])
if (!a.lock()) if (!a.lock())
{ {
QMessageBox::warning(NULL, "Prodejna is running", "Prodejna is allready running. Only one instance can be started."); QMessageBox::warning(nullptr, "Prodejna is running", "Prodejna is allready running. Only one instance can be started.");
return -42; return -42;
} }
@ -34,16 +35,19 @@ int main(int argc, char *argv[])
#endif #endif
QTranslator qtTranslator; QTranslator qtTranslator;
qtTranslator.load("qt_" + QLocale::system().name(), if (qtTranslator.load("qt_" + QLocale::system().name(),
QLibraryInfo::location(QLibraryInfo::TranslationsPath)); QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
qDebug() << "Cannot load translation";
}
a.installTranslator(&qtTranslator); a.installTranslator(&qtTranslator);
QTranslator myappTranslator; QTranslator myappTranslator;
myappTranslator.load(":/translations/prodejna_" + QLocale::system().name()); if (myappTranslator.load(":/translations/prodejna_" + QLocale::system().name())) {
qDebug() << "Cannot load translation";
}
a.installTranslator(&myappTranslator); a.installTranslator(&myappTranslator);
MainWindow w; MainWindow w;
w.move(QApplication::desktop()->screen()->rect().center() - w.rect().center());
w.showMaximized(); w.showMaximized();
return a.exec(); return a.exec();

@ -8,6 +8,7 @@
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QFileDialog> #include <QFileDialog>
#include <QDebug> #include <QDebug>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -61,11 +62,7 @@ MainWindow::MainWindow(QWidget *parent) :
} }
((QVBoxLayout*)ui->navigation->layout())->addStretch(1); ((QVBoxLayout*)ui->navigation->layout())->addStretch(1);
if (Context::instance().db() != NULL)
{
ui->navigation->setEnabled(true); ui->navigation->setEnabled(true);
}
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -89,7 +86,7 @@ void MainWindow::openPlugin()
void MainWindow::on_actionOpen_database_triggered() void MainWindow::on_actionOpen_database_triggered()
{ {
closaAllTabs(); closeAllTabs();
closeDashboard(); closeDashboard();
QString dbFile = QFileDialog::getOpenFileName(this, "Open Database", "", "Database Files (*.db)"); QString dbFile = QFileDialog::getOpenFileName(this, "Open Database", "", "Database Files (*.db)");
@ -116,7 +113,7 @@ void MainWindow::on_tabWidget_tabCloseRequested(int index)
void MainWindow::on_actionLogin_triggered() void MainWindow::on_actionLogin_triggered()
{ {
closaAllTabs(); closeAllTabs();
closeDashboard(); closeDashboard();
QSharedPointer<User> u; QSharedPointer<User> u;
@ -128,7 +125,7 @@ void MainWindow::on_actionLogin_triggered()
void MainWindow::showEvent(QShowEvent *evt) void MainWindow::showEvent(QShowEvent *evt)
{ {
QWidget::showEvent(evt); QWidget::showEvent(evt);
if (Context::instance().db() != NULL && Context::instance().currentUser().data() == NULL) if (Context::instance().dbOpened() && Context::instance().currentUser().data() == nullptr)
{ {
m_loginDialog->show(); m_loginDialog->show();
} }
@ -150,7 +147,7 @@ void MainWindow::on_actionPost_register_triggered()
{ {
IPlugin *plugZipCodes = Context::instance().plugin("POSTREGISTER"); IPlugin *plugZipCodes = Context::instance().plugin("POSTREGISTER");
if (plugZipCodes != NULL) if (plugZipCodes != nullptr)
{ {
openPlugin(plugZipCodes); openPlugin(plugZipCodes);
} }
@ -160,6 +157,9 @@ void MainWindow::openPlugin(IPlugin *plugin)
{ {
ui->tabWidget->setVisible(true); ui->tabWidget->setVisible(true);
ui->dashboard->setVisible(false); ui->dashboard->setVisible(false);
#ifdef Q_OS_MAC
ui->tabWidget->setStyleSheet("QTabBar::tab { width: 150px; }");
#endif
for (int i = 0; i < ui->tabWidget->count(); i++) { for (int i = 0; i < ui->tabWidget->count(); i++) {
if (ui->tabWidget->widget(i)->objectName() == plugin->pluginId()) { if (ui->tabWidget->widget(i)->objectName() == plugin->pluginId()) {
@ -168,7 +168,7 @@ void MainWindow::openPlugin(IPlugin *plugin)
} }
} }
if (plugin->ui() != NULL) if (plugin->ui() != nullptr)
{ {
ui->tabWidget->addTab(plugin->ui(), plugin->pluginIcon(), plugin->pluginName()); ui->tabWidget->addTab(plugin->ui(), plugin->pluginIcon(), plugin->pluginName());
ui->tabWidget->widget(ui->tabWidget->count() - 1)->setObjectName(plugin->pluginId()); ui->tabWidget->widget(ui->tabWidget->count() - 1)->setObjectName(plugin->pluginId());
@ -180,7 +180,7 @@ void MainWindow::on_actionCountry_register_triggered()
{ {
IPlugin *plugCountryReg = Context::instance().plugin("COUNTRYREGISTER"); IPlugin *plugCountryReg = Context::instance().plugin("COUNTRYREGISTER");
if (plugCountryReg != NULL) if (plugCountryReg != nullptr)
{ {
openPlugin(plugCountryReg); openPlugin(plugCountryReg);
} }
@ -236,7 +236,7 @@ void MainWindow::refreshDashboard()
} }
} }
void MainWindow::closaAllTabs() void MainWindow::closeAllTabs()
{ {
ui->tabWidget->setVisible(false); ui->tabWidget->setVisible(false);
ui->dashboard->setVisible(true); ui->dashboard->setVisible(true);

@ -53,11 +53,11 @@ private:
void closeDashboard(); void closeDashboard();
void openDashboard(); void openDashboard();
void refreshDashboard(); void refreshDashboard();
void closaAllTabs(); void closeAllTabs();
// QWidget interface // QWidget interface
protected: protected:
void showEvent(QShowEvent *evt); void showEvent(QShowEvent *evt) override;
void closeEvent(QCloseEvent *evt) override; void closeEvent(QCloseEvent *evt) override;
}; };

@ -137,7 +137,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1000</width> <width>1000</width>
<height>20</height> <height>42</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">

@ -16,6 +16,7 @@
} }
#navigation QToolButton { #navigation QToolButton {
background-color: dimgray;
color: white; color: white;
font-weight: bold; font-weight: bold;
min-width: 90px; min-width: 90px;
@ -23,5 +24,9 @@
} }
#dashboard { #dashboard {
background-color: qlineargradient(spread:pad, x1:0.507, y1:1, x2:0.518, y2:0.291, stop:0 rgba(83, 145, 169, 255), stop:1 rgba(255, 255, 255, 255)); background-color: qlineargradient(spread:pad, x1:0.507, y1:1, x2:0.518, y2:0.291, stop:0 rgba(83, 145, 169, 255), stop:1 rgba(255, 255, 255, 255));;
}
#dashboard QLabel {
color: black;
} }

@ -0,0 +1,83 @@
cmake_minimum_required(VERSION 3.24)
project(camp)
include(../3rdparty/QxOrm/QxOrm.cmake)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ../plugins)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)
add_library(camp SHARED
addservicedialog.cpp
addservicedialog.h
addservicedialog.ui
camp.cpp
camp.h
camp_global.h
campform.cpp
campform.h
campform.ui
campgrid.cpp
campgrid.h
camprc.qrc
campseller.cpp
campseller.h
campservice.cpp
campservice.h
campshopitem.cpp
campshopitem.h
campwizard.cpp
campwizard.h
campwizard.ui
detailwidget.cpp
detailwidget.h
detailwidget.ui
data/addressitem.cpp
data/addressitem.h
data/camp-data.h
data/campdata.cpp
data/campdata.h
data/personprice.cpp
data/personprice.h
data/sale.cpp
data/sale.h
data/serviceitem.cpp
data/serviceitem.h
settings/campsettings.cpp
settings/campsettings.h
settings/campsettingsform.cpp
settings/campsettingsform.h
settings/campsettingsform.ui)
target_compile_definitions(camp PRIVATE -DCAMP_LIBRARY)
include_directories(../core)
include_directories(../countryregister
../addressbook
../services
../shop)
target_link_libraries(camp
Qt::Core
Qt::Gui
Qt::Widgets
qdecimal
decnumber
QxOrm
core
addressbook
services
shop
)
install(TARGETS addressbook
LIBRARY DESTINATION ../plugins)

@ -14,8 +14,8 @@ class AddServiceDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit AddServiceDialog(AccServicePtr service, QWidget *parent = 0); explicit AddServiceDialog(AccServicePtr service, QWidget *parent = nullptr);
~AddServiceDialog(); ~AddServiceDialog() override;
QString description(); QString description();
QDecDouble price(); QDecDouble price();

@ -5,10 +5,6 @@
#include "campservice.h" #include "campservice.h"
#include "settings/campsettingsform.h" #include "settings/campsettingsform.h"
Camp::Camp()
{
}
void Camp::initServiceUi() void Camp::initServiceUi()
{ {
m_service = new CampService(); m_service = new CampService();

@ -14,16 +14,16 @@ class CAMPSHARED_EXPORT Camp : public QObject, IMetaDataPlugin
Q_INTERFACES(IPlugin) Q_INTERFACES(IPlugin)
public: public:
Camp(); Camp() = default;
protected: protected:
void initServiceUi() Q_DECL_OVERRIDE; void initServiceUi() Q_DECL_OVERRIDE;
// IPlugin interface // IPlugin interface
public: public:
virtual QIcon pluginIcon(); QIcon pluginIcon() override;
QTranslator *translator(); QTranslator *translator() override;
bool hasNumberSeries(); bool hasNumberSeries() override;
}; };
#endif // CAMP_H #endif // CAMP_H

@ -1,110 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-04-19T09:20:32
#
#-------------------------------------------------
QT += widgets sql
TARGET = camp
TEMPLATE = lib
DEFINES += CAMP_LIBRARY
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += camp.cpp \
data/campdata.cpp \
data/addressitem.cpp \
data/serviceitem.cpp \
campgrid.cpp \
campform.cpp \
data/sale.cpp \
settings/campsettingsform.cpp \
data/personprice.cpp \
settings/campsettings.cpp \
campwizard.cpp \
campservice.cpp \
addservicedialog.cpp \
campshopitem.cpp \
campseller.cpp \
detailwidget.cpp
HEADERS += camp.h\
camp_global.h \
data/campdata.h \
data/addressitem.h \
data/serviceitem.h \
data/camp-data.h \
campgrid.h \
campform.h \
data/sale.h \
settings/campsettingsform.h \
data/personprice.h \
settings/campsettings.h \
campwizard.h \
campservice.h \
addservicedialog.h \
campshopitem.h \
campseller.h \
detailwidget.h
include(../config_plugin.pri)
ODB_FILES = camp/data/camp-data.h
H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../shop -I $$PWD/../addressbook/data -I $$PWD/../countryregister/data -I $$PWD/../services/data
include(../odb.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lshop
INCLUDEPATH += $$PWD/../shop
DEPENDPATH += $$PWD/../shop
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -laddressbook
INCLUDEPATH += $$PWD/../addressbook
INCLUDEPATH += $$PWD/../addressbook/data
DEPENDPATH += $$PWD/../addressbook
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lcountryregister
INCLUDEPATH += $$PWD/../countryregister/data
INCLUDEPATH += $$PWD/../countryregister
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lservices
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lservices
INCLUDEPATH += $$PWD/../services
INCLUDEPATH += $$PWD/../services/data
DEPENDPATH += $$PWD/../services
TRANSLATIONS = translations/camp_cs_CZ.ts
DISTFILES += \
camp.json
RESOURCES += \
camprc.qrc
FORMS += \
campform.ui \
settings/campsettingsform.ui \
campwizard.ui \
addservicedialog.ui \
detailwidget.ui

@ -2,6 +2,7 @@
#define CAMP_GLOBAL_H #define CAMP_GLOBAL_H
#include <QtCore/qglobal.h> #include <QtCore/qglobal.h>
#include <QxOrm.h>
#if defined(CAMP_LIBRARY) #if defined(CAMP_LIBRARY)
# define CAMPSHARED_EXPORT Q_DECL_EXPORT # define CAMPSHARED_EXPORT Q_DECL_EXPORT
@ -9,4 +10,12 @@
# define CAMPSHARED_EXPORT Q_DECL_IMPORT # define CAMPSHARED_EXPORT Q_DECL_IMPORT
#endif #endif
#ifdef CAMP_LIBRARY
#define QX_REGISTER_HPP_CAMP QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_CAMP QX_REGISTER_CPP_EXPORT_DLL
#else // CAMP_LIBRARY
#define QX_REGISTER_HPP_CAMP QX_REGISTER_HPP_IMPORT_DLL
#define QX_REGISTER_CPP_CAMP QX_REGISTER_CPP_IMPORT_DLL
#endif
#endif // CAMP_GLOBAL_H #endif // CAMP_GLOBAL_H

@ -4,7 +4,6 @@
#include <QWidget> #include <QWidget>
#include <core.h> #include <core.h>
#include "data/camp-data.h" #include "data/camp-data.h"
#include "camp-odb.hxx"
namespace Ui { namespace Ui {
class CampForm; class CampForm;
@ -15,8 +14,8 @@ class CampForm : public AutoForm<CampData>
Q_OBJECT Q_OBJECT
public: public:
explicit CampForm(QWidget *parent = 0); explicit CampForm(QWidget *parent = nullptr);
~CampForm(); ~CampForm() override;
private: private:
Ui::CampForm *ui; Ui::CampForm *ui;

@ -13,7 +13,7 @@ CampGrid::CampGrid(QWidget *parent) : GridForm<CampData>(parent)
QHBoxLayout *tbLayout = qobject_cast<QHBoxLayout*>(this->toolbar()->layout()); QHBoxLayout *tbLayout = qobject_cast<QHBoxLayout*>(this->toolbar()->layout());
if (tbLayout != NULL) if (tbLayout != nullptr)
{ {
QToolButton *btnImport = new QToolButton(this->toolbar()); QToolButton *btnImport = new QToolButton(this->toolbar());
btnImport->setIcon(QIcon(":/icons/pay.svg")); btnImport->setIcon(QIcon(":/icons/pay.svg"));
@ -76,8 +76,10 @@ void CampGrid::handleEditRecord()
return; return;
} }
if (data->people().isEmpty() || data->services().isEmpty()) {
CampService srv; CampService srv;
srv.loadItems(data); srv.load(data);
}
CampWizard *wizard = new CampWizard(); CampWizard *wizard = new CampWizard();
wizard->setAttribute(Qt::WA_DeleteOnClose); wizard->setAttribute(Qt::WA_DeleteOnClose);
@ -99,10 +101,10 @@ void CampGrid::doDelete(CampDataPtr entity)
} }
CampService srv; CampService srv;
srv.eraseCamp(entity); srv.erase(entity);
} }
void CampGrid::addToVoucher(CampDataPtr data) void CampGrid::addToVoucher(const CampDataPtr& data)
{ {
if (data->onVoucher()) if (data->onVoucher())
{ {
@ -143,7 +145,7 @@ void CampGrid::addToVoucher(CampDataPtr data)
data->setOnVoucher(false); data->setOnVoucher(false);
srvCamp.update(data); srvCamp.update(data);
voucher->clearItems(); voucher->clearItems();
shopSrv.eraseVoucher(voucher); shopSrv.erase(voucher);
}); });
} }
@ -151,7 +153,8 @@ void CampGrid::currentIndexChanged(const QModelIndex &current)
{ {
if (current.isValid()) if (current.isValid())
{ {
m_detail->setData(currentEntity()); auto current = currentEntity();
m_detail->setData(current);
} }
} }

@ -3,7 +3,6 @@
#include <core.h> #include <core.h>
#include "data/camp-data.h" #include "data/camp-data.h"
#include "camp-odb.hxx"
#include "detailwidget.h" #include "detailwidget.h"
@ -11,29 +10,29 @@ class CampGrid : public GridForm<CampData>
{ {
Q_OBJECT Q_OBJECT
public: public:
CampGrid(QWidget *parent = NULL); explicit CampGrid(QWidget *parent = nullptr);
// IGridForm interface // IGridForm interface
protected: protected:
void handleNewRecord(); void handleNewRecord() override;
void handleEditRecord(); void handleEditRecord() override;
// GridForm interface // GridForm interface
protected: protected:
void doDelete(CampDataPtr entity); void doDelete(CampDataPtr entity) override;
private: private:
void addToVoucher(CampDataPtr data); void addToVoucher(const CampDataPtr& data);
DetailWidget *m_detail; DetailWidget *m_detail;
// IGridForm interface // IGridForm interface
protected: protected:
void currentIndexChanged(const QModelIndex &current); void currentIndexChanged(const QModelIndex &current) override;
// GridForm interface // GridForm interface
protected: protected:
virtual QList<CampDataPtr> listForGrid() override; QList<CampDataPtr> listForGrid() override;
}; };
#endif // CAMPGRID_H #endif // CAMPGRID_H

@ -7,11 +7,11 @@ class CampSeller : public ISeller
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CampSeller(QObject *parent = 0); explicit CampSeller(QObject *parent = nullptr);
// ISeller interface // ISeller interface
public: public:
void prepareItem(); void prepareItem() override;
}; };
#endif // CAMPSELLER_H #endif // CAMPSELLER_H

@ -4,7 +4,7 @@
#include <numberseriesservice.h> #include <numberseriesservice.h>
#include "campshopitem.h" #include "campshopitem.h"
#include "campseller.h" #include "campseller.h"
#include <math.h> #include <cmath>
#ifdef _WIN32 #ifdef _WIN32
double round(double value) { return value < 0 ? -std::floor(0.5 - value) : std::floor(0.5 + value); } double round(double value) { return value < 0 ? -std::floor(0.5 - value) : std::floor(0.5 + value); }
@ -16,7 +16,7 @@ CampService::CampService()
m_seller = new CampSeller(this); m_seller = new CampSeller(this);
} }
void CampService::addPerson(CampDataPtr data, AddressbookDataPtr address) void CampService::addPerson(const CampDataPtr& data, const AddressbookDataPtr& address)
{ {
AddressItemPtr addrItem(new AddressItem); AddressItemPtr addrItem(new AddressItem);
@ -34,7 +34,7 @@ void CampService::addPerson(CampDataPtr data, AddressbookDataPtr address)
data->addPerson(addrItem); data->addPerson(addrItem);
} }
void CampService::addService(CampDataPtr data, AccServicePtr service) void CampService::addService(const CampDataPtr& data, const AccServicePtr& service)
{ {
ServiceItemPtr serviceItem(new ServiceItem); ServiceItemPtr serviceItem(new ServiceItem);
@ -47,14 +47,14 @@ void CampService::addService(CampDataPtr data, AccServicePtr service)
data->addServiceItem(serviceItem); data->addServiceItem(serviceItem);
} }
void CampService::addService(CampDataPtr data, AccServicePtr service, QDecDouble price, QString description) void CampService::addService(CampDataPtr data, AccServicePtr service, QDecDouble price, const QString& description)
{ {
ServiceItemPtr item = addServiceInt(data, service); ServiceItemPtr item = addServiceInt(data, service);
item->setPrice(price); item->setPrice(price);
item->setDescription(description); item->setDescription(description);
} }
void CampService::setOwner(CampDataPtr data, AddressItemPtr person) void CampService::setOwner(const CampDataPtr& data, const AddressItemPtr& person)
{ {
foreach (AddressItemPtr p, data->people()) { foreach (AddressItemPtr p, data->people()) {
p->setOwner(false); p->setOwner(false);
@ -76,7 +76,7 @@ CampDataPtr CampService::create()
return data; return data;
} }
void CampService::calculate(CampDataPtr data) void CampService::calculate(const CampDataPtr& data)
{ {
SettingsService srv("CAMP"); SettingsService srv("CAMP");
m_settings = srv.loadSettings<CampSettings>(); m_settings = srv.loadSettings<CampSettings>();
@ -86,7 +86,7 @@ void CampService::calculate(CampDataPtr data)
calcPrice(data); calcPrice(data);
} }
void CampService::saveCamp(CampDataPtr data) void CampService::saveCamp(const CampDataPtr& data)
{ {
if (!checkPermission(PERM_ADD)) if (!checkPermission(PERM_ADD))
{ {
@ -97,39 +97,16 @@ void CampService::saveCamp(CampDataPtr data)
SeasonPtr season = seasonSrv.active(); SeasonPtr season = seasonSrv.active();
data->setSeason(season); data->setSeason(season);
Transaction tr; qx::QxSession session;
try
{
odb::database *db = Context::instance().db();
NumberSeriesService numSrv; NumberSeriesService numSrv;
data->setNumSer(numSrv.nextStrForPlugin("CAMP")); data->setNumSer(numSrv.nextStrForPlugin("CAMP", &session));
addDateAndUser(data, true); addDateAndUser(data, true);
save(data, &session);
db->persist(data);
foreach (ServiceItemPtr item, data->services()) {
item->setCampData(data.toWeakRef());
db->persist(item);
}
foreach (AddressItemPtr item, data->people()) {
item->setCampData(data.toWeakRef());
db->persist(item);
}
tr.commit();
}
catch (const odb::exception &ex)
{
emit dbError(ex.what());
emit dbErrorInsert(ex.what());
return;
}
} }
void CampService::updateCamp(CampDataPtr data) /*void CampService::updateCamp(CampDataPtr data)
{ {
if (!checkPermission(PERM_EDIT)) if (!checkPermission(PERM_EDIT))
{ {
@ -166,9 +143,9 @@ void CampService::updateCamp(CampDataPtr data)
emit dbErrorUpdate(ex.what()); emit dbErrorUpdate(ex.what());
return; return;
} }
} }*/
void CampService::eraseCamp(CampDataPtr data) /*void CampService::eraseCamp(CampDataPtr data)
{ {
if (!checkPermission(PERM_DELETE)) if (!checkPermission(PERM_DELETE))
{ {
@ -193,16 +170,16 @@ void CampService::eraseCamp(CampDataPtr data)
emit dbErrorDelete(ex.what()); emit dbErrorDelete(ex.what());
return; return;
} }
} }*/
void CampService::loadItems(CampDataPtr data) /*void CampService::loadItems(CampDataPtr data)
{ {
Service<AddressItem> srv; Service<AddressItem> srv;
data->setPeople(srv.all(QString("campData = %1").arg(data->id()))); data->setPeople(srv.all(QString("campData = %1").arg(data->id())));
Service<ServiceItem> srvService; Service<ServiceItem> srvService;
data->setServices(srvService.all(QString("campData = %1").arg(data->id()))); data->setServices(srvService.all(QString("campData = %1").arg(data->id())));
} }*/
QList<CampDataPtr> CampService::allForSeason() QList<CampDataPtr> CampService::allForSeason()
{ {
@ -278,7 +255,7 @@ void CampService::calcPeople(CampDataPtr data)
} }
} }
void CampService::calcServices(CampDataPtr data) void CampService::calcServices(const CampDataPtr& data)
{ {
QDecDouble sale = data->sale(); QDecDouble sale = data->sale();
bool fixedSale = data->fixedSale(); bool fixedSale = data->fixedSale();
@ -301,7 +278,7 @@ void CampService::calcServices(CampDataPtr data)
} }
} }
void CampService::calcPrice(CampDataPtr data) void CampService::calcPrice(const CampDataPtr& data)
{ {
QDecDouble totalPrice(0); QDecDouble totalPrice(0);
QDecDouble sale(0); QDecDouble sale(0);
@ -340,7 +317,7 @@ void CampService::calcPrice(CampDataPtr data)
data->setTotalSale(sale); data->setTotalSale(sale);
} }
void CampService::addAccFee(CampDataPtr data, AddressItemPtr item, int startAge, int endAge, int days) void CampService::addAccFee(const CampDataPtr& data, const AddressItemPtr& item, int startAge, int endAge, int days)
{ {
if (item->adbItem()->ztp()) if (item->adbItem()->ztp())
{ {
@ -380,24 +357,23 @@ void CampService::addAccFee(CampDataPtr data, AddressItemPtr item, int startAge,
} }
} }
QList<ShopItemPtr> CampService::shopItems() QList<IShopItemPtr> CampService::shopItems()
{ {
CampShopItemPtr item(new CampShopItem); CampShopItemPtr item(new CampShopItem);
QList<ShopItemPtr> items; QList<IShopItemPtr> items;
items.append(item); items.append(item);
return items; return items;
} }
ShopItemPtr CampService::shopItem(int ) IShopItemPtr CampService::shopItem(int )
{ {
return CampShopItemPtr(new CampShopItem); return CampShopItemPtr(new CampShopItem);
} }
void CampService::addedToVoucher(int itemId, int countAdded) void CampService::addedToVoucher(int itemId, int countAdded)
{ {
Transaction tx;
CampDataPtr data = loadById(itemId); CampDataPtr data = loadById(itemId);
if (countAdded > 0) if (countAdded > 0)
@ -410,7 +386,6 @@ void CampService::addedToVoucher(int itemId, int countAdded)
} }
this->update(data); this->update(data);
tx.commit();
} }
ISeller *CampService::seller() ISeller *CampService::seller()
@ -418,7 +393,7 @@ ISeller *CampService::seller()
return m_seller; return m_seller;
} }
ServiceItemPtr CampService::addServiceInt(CampDataPtr data, AccServicePtr service) ServiceItemPtr CampService::addServiceInt(const CampDataPtr& data, const AccServicePtr& service)
{ {
ServiceItemPtr serviceItem(new ServiceItem); ServiceItemPtr serviceItem(new ServiceItem);

@ -2,45 +2,44 @@
#define CAMPSERVICE_H #define CAMPSERVICE_H
#include <core.h> #include <core.h>
#include <addressbookdata.h> #include <data/addressbookdata.h>
#include <accservice.h> #include <data/accservice.h>
#include <isellableservice.h> #include <isellableservice.h>
#include "data/camp-data.h" #include "data/camp-data.h"
#include "settings/campsettings.h" #include "settings/campsettings.h"
#include "camp-odb.hxx"
class CampService : public Service<CampData>, public ISellableService class CampService : public Service<CampData>, public ISellableService
{ {
public: public:
CampService(); CampService();
void addPerson(CampDataPtr data, AddressbookDataPtr address); void addPerson(const CampDataPtr& data, const AddressbookDataPtr& address);
void addService(CampDataPtr data, AccServicePtr service); void addService(const CampDataPtr& data, const AccServicePtr& service);
void addService(CampDataPtr data, AccServicePtr service, QDecDouble price, QString description); void addService(CampDataPtr data, AccServicePtr service, QDecDouble price, const QString& description);
void setOwner(CampDataPtr data, AddressItemPtr person); void setOwner(const CampDataPtr& data, const AddressItemPtr& person);
CampDataPtr create(); CampDataPtr create();
void calculate(CampDataPtr data); void calculate(const CampDataPtr& data);
void saveCamp(CampDataPtr data); void saveCamp(const CampDataPtr& data);
void updateCamp(CampDataPtr data); //void updateCamp(CampDataPtr data);
void eraseCamp(CampDataPtr data); //void eraseCamp(CampDataPtr data);
void loadItems(CampDataPtr data); //void loadItems(CampDataPtr data);
QList<CampDataPtr> allForSeason(); QList<CampDataPtr> allForSeason();
private: private:
ServiceItemPtr addServiceInt(CampDataPtr data, AccServicePtr service); ServiceItemPtr addServiceInt(const CampDataPtr& data, const AccServicePtr& service);
void calcPeople(CampDataPtr data); void calcPeople(CampDataPtr data);
void calcServices(CampDataPtr data); void calcServices(const CampDataPtr& data);
void calcPrice(CampDataPtr data); void calcPrice(const CampDataPtr& data);
void addAccFee(CampDataPtr data, AddressItemPtr item, int startAge, int endAge, int days); void addAccFee(const CampDataPtr& data, const AddressItemPtr& item, int startAge, int endAge, int days);
CampSettingsPtr m_settings; CampSettingsPtr m_settings;
ISeller *m_seller; ISeller *m_seller;
// ISellableService interface // ISellableService interface
public: public:
QList<ShopItemPtr> shopItems(); QList<IShopItemPtr> shopItems() override;
ShopItemPtr shopItem(int itemId); IShopItemPtr shopItem(int itemId) override;
void addedToVoucher(int itemId, int countAdded); void addedToVoucher(int itemId, int countAdded) override;
ISeller *seller(); ISeller *seller() override;
}; };
#endif // CAMPSERVICE_H #endif // CAMPSERVICE_H

@ -1,8 +1,9 @@
#include "campshopitem.h" #include "campshopitem.h"
CampShopItem::CampShopItem(QObject *parent) CampShopItem::CampShopItem(QObject *parent)
:ShopItem(parent) :IShopItem(parent)
{ {
m_id = 0;
m_unitPrice = QDecDouble(0); m_unitPrice = QDecDouble(0);
m_vatType = Enums::NONE; m_vatType = Enums::NONE;
} }
@ -47,12 +48,12 @@ void CampShopItem::setVatType(const Enums::VatType &vatType)
m_vatType = vatType; m_vatType = vatType;
} }
int CampShopItem::id() long CampShopItem::id()
{ {
return m_id; return m_id;
} }
void CampShopItem::setId(int id) void CampShopItem::setId(long id)
{ {
m_id = id; m_id = id;
} }

@ -3,30 +3,30 @@
#include <shopitem.h> #include <shopitem.h>
class CampShopItem : public ShopItem class CampShopItem : public IShopItem
{ {
public: public:
CampShopItem(QObject *parent = 0); explicit CampShopItem(QObject *parent = nullptr);
// IShopItem interface // IShopItem interface
public: public:
int id(); long id() override;
QString name(); QString name() override;
QString shortName(); QString shortName() override;
QDecDouble unitPrice(); QDecDouble unitPrice() override;
Enums::VatType vatType(); Enums::VatType vatType() override;
QString pluginId(); QString pluginId() override;
// ShopItem interface // ShopItem interface
public: public:
QString code(); QString code() override;
void setUnitPrice(const QDecDouble &unitPrice); void setUnitPrice(const QDecDouble &unitPrice);
void setVatType(const Enums::VatType &vatType); void setVatType(const Enums::VatType &vatType);
void setId(int id); void setId(long id);
private: private:
int m_id; long m_id;
QDecDouble m_unitPrice; QDecDouble m_unitPrice;
Enums::VatType m_vatType; Enums::VatType m_vatType;
}; };

@ -5,7 +5,7 @@
#include <core.h> #include <core.h>
#include <addressbookservice.h> #include <addressbookservice.h>
#include <accservice.h> #include <data/accservice.h>
#include <reporting/reportviewer.h> #include <reporting/reportviewer.h>
#include <QScroller> #include <QScroller>
@ -129,7 +129,7 @@ CampWizard::CampWizard(QWidget *parent) :
Service<AddressbookData> addrSrv; Service<AddressbookData> addrSrv;
m_addrHelperBinder = new ObjectBinder(this); m_addrHelperBinder = new ObjectBinder(this);
m_addrHelperBinder->registerBinding(ui->address, ComboData::createComboData(addrSrv.all("", "lastName, firstName"))); m_addrHelperBinder->registerBinding(ui->address, ComboData::createComboData(addrSrv.all("")));
m_addrHelperBinder->setData(m_addrHelper); m_addrHelperBinder->setData(m_addrHelper);
m_addressBinder = new ObjectBinder(this); m_addressBinder = new ObjectBinder(this);
@ -437,7 +437,7 @@ void CampWizard::accept()
} }
else else
{ {
srv.updateCamp(m_data); srv.update(m_data);
} }
if (success) if (success)
@ -472,7 +472,7 @@ void CampWizard::on_btnPrint_clicked()
} }
else else
{ {
srv.updateCamp(m_data); srv.update(m_data);
} }
if(!success) if(!success)

@ -14,7 +14,7 @@ class AddressHelper : public QObject
Q_PROPERTY(QSharedPointer<QObject> address READ address WRITE setAddress) Q_PROPERTY(QSharedPointer<QObject> address READ address WRITE setAddress)
public: public:
AddressHelper(QObject *parent = NULL); explicit AddressHelper(QObject *parent = nullptr);
QSharedPointer<QObject> address() const; QSharedPointer<QObject> address() const;
void setAddress(const QSharedPointer<QObject> &address); void setAddress(const QSharedPointer<QObject> &address);
@ -36,7 +36,7 @@ class SaleHelper : public QObject
Q_PROPERTY(QSharedPointer<QObject> sale READ sale WRITE setSale NOTIFY saleChanged) Q_PROPERTY(QSharedPointer<QObject> sale READ sale WRITE setSale NOTIFY saleChanged)
public: public:
SaleHelper(QObject *parent = NULL); explicit SaleHelper(QObject *parent = nullptr);
SalePtr salePtr() const; SalePtr salePtr() const;
void setSalePtr(const SalePtr &sale); void setSalePtr(const SalePtr &sale);
@ -60,8 +60,8 @@ class CampWizard : public QWizard
Q_OBJECT Q_OBJECT
public: public:
explicit CampWizard(QWidget *parent = 0); explicit CampWizard(QWidget *parent = nullptr);
~CampWizard(); ~CampWizard() override;
void setData(const CampDataPtr &data); void setData(const CampDataPtr &data);
void setNewRecord(bool newRecord); void setNewRecord(bool newRecord);
@ -109,10 +109,10 @@ private:
// QWizard interface // QWizard interface
public: public:
bool validateCurrentPage(); bool validateCurrentPage() override;
public slots: public slots:
void accept(); void accept() override;
}; };
#endif // CAMPWIZARD_H #endif // CAMPWIZARD_H

@ -1,6 +1,26 @@
#include "addressitem.h" #include "addressitem.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_CAMP(AddressItem)
namespace qx {
template<> void register_class(QxClass<AddressItem>& t) {
t.setName("AddressItem");
t.id(&AddressItem::m_id, "id");
t.data(&AddressItem::m_firstName, "firstName");
t.data(&AddressItem::m_lastName, "lastName");
t.data(&AddressItem::m_address, "address");
t.data(&AddressItem::m_price, "price");
t.data(&AddressItem::m_owner, "owner");
t.data(&AddressItem::m_sale, "sale");
t.data(&AddressItem::m_totalPrice, "totalPrice");
t.relationManyToOne(&AddressItem::m_adbItem, "adbItem");
t.relationManyToOne(&AddressItem::m_campData, "campData");
t.relationManyToOne(&AddressItem::m_personPrice, "personPrice");
}
}
AddressItem::AddressItem(QObject *parent) : QObject(parent) AddressItem::AddressItem(QObject *parent) : QObject(parent)
{ {
m_id = 0; m_id = 0;
@ -10,12 +30,12 @@ AddressItem::AddressItem(QObject *parent) : QObject(parent)
m_totalPrice = 0; m_totalPrice = 0;
} }
int AddressItem::id() const long AddressItem::id() const
{ {
return m_id; return m_id;
} }
void AddressItem::setId(int id) void AddressItem::setId(long id)
{ {
m_id = id; m_id = id;
} }
@ -60,12 +80,12 @@ void AddressItem::setPrice(QDecDouble price)
m_price = FROM_DEC(price); m_price = FROM_DEC(price);
} }
QWeakPointer<CampData> AddressItem::campData() const QSharedPointer<CampData> AddressItem::campData() const
{ {
return m_campData; return m_campData;
} }
void AddressItem::setCampData(const QWeakPointer<CampData> &campData) void AddressItem::setCampData(const QSharedPointer<CampData> &campData)
{ {
m_campData = campData; m_campData = campData;
} }

@ -6,16 +6,17 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QWeakPointer> #include <QWeakPointer>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <odb/core.hxx> #include <data/addressbookdata.h>
#include <addressbookdata.h> #include "../camp_global.h"
class CampData; class CampData;
#pragma db object
class AddressItem : public QObject class AddressItem : public QObject
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(AddressItem)
Q_PROPERTY(QString firstName READ firstName WRITE setFirstName) Q_PROPERTY(QString firstName READ firstName WRITE setFirstName)
Q_PROPERTY(QString lastName READ lastName WRITE setLastName) Q_PROPERTY(QString lastName READ lastName WRITE setLastName)
Q_PROPERTY(QString address READ address WRITE setAddress) Q_PROPERTY(QString address READ address WRITE setAddress)
@ -27,8 +28,8 @@ class AddressItem : public QObject
public: public:
explicit AddressItem(QObject *parent = 0); explicit AddressItem(QObject *parent = 0);
int id() const; long id() const;
void setId(int id); void setId(long id);
QString firstName() const; QString firstName() const;
void setFirstName(const QString &firstName); void setFirstName(const QString &firstName);
@ -42,8 +43,8 @@ public:
QDecDouble price() const; QDecDouble price() const;
void setPrice(QDecDouble price); void setPrice(QDecDouble price);
QWeakPointer<CampData> campData() const; QSharedPointer<CampData> campData() const;
void setCampData(const QWeakPointer<CampData> &campData); void setCampData(const QSharedPointer<CampData> &campData);
PersonPricePtr personPrice() const; PersonPricePtr personPrice() const;
void setPersonPrice(const PersonPricePtr &personPrice); void setPersonPrice(const PersonPricePtr &personPrice);
@ -61,9 +62,7 @@ public:
void setSale(QDecDouble sale); void setSale(QDecDouble sale);
private: private:
friend class odb::access; long m_id;
#pragma db id auto
int m_id;
QString m_firstName; QString m_firstName;
QString m_lastName; QString m_lastName;
QString m_address; QString m_address;
@ -71,10 +70,11 @@ private:
int m_price; int m_price;
int m_totalPrice; int m_totalPrice;
int m_sale; int m_sale;
#pragma db not_null CampDataPtr m_campData;
QWeakPointer<CampData> m_campData;
PersonPricePtr m_personPrice; PersonPricePtr m_personPrice;
bool m_owner; bool m_owner;
}; };
QX_REGISTER_HPP_CAMP(AddressItem, QObject, 0)
#endif // ADDRESSITEM_H #endif // ADDRESSITEM_H

@ -1,6 +1,35 @@
#include "campdata.h" #include "campdata.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_CAMP(CampData)
namespace qx {
template<> void register_class(QxClass<CampData>& t) {
t.setName("CampData");
t.id(&CampData::m_id, "id");
t.data(&CampData::m_numSer, "numSer");
t.data(&CampData::m_start, "start");
t.data(&CampData::m_end, "end");
t.data(&CampData::m_ownerFirstame, "ownerFirstame");
t.data(&CampData::m_ownerLastname, "ownerLastname");
t.data(&CampData::m_ownerAddress, "ownerAddress");
t.data(&CampData::m_totalPrice, "totalPrice");
t.data(&CampData::m_sale, "sale");
t.data(&CampData::m_fixedSale, "fixedSale");
t.data(&CampData::m_fullPrice, "fullPrice");
t.data(&CampData::m_totalSale, "totalSale");
t.data(&CampData::m_onVoucher, "onVoucher");
t.data(&CampData::m_createdBy, "createdBy");
t.data(&CampData::m_created, "created");
t.data(&CampData::m_updatedBy, "updatedBy");
t.data(&CampData::m_updated, "updated");
t.relationManyToOne(&CampData::m_season, "season");
t.relationOneToMany(&CampData::m_people, "people", "campData");
t.relationOneToMany(&CampData::m_services, "services", "campData");
}
}
CampData::CampData(QObject *parent) : QObject(parent) CampData::CampData(QObject *parent) : QObject(parent)
{ {
m_id = 0; m_id = 0;
@ -12,12 +41,12 @@ CampData::CampData(QObject *parent) : QObject(parent)
m_onVoucher = false; m_onVoucher = false;
} }
int CampData::id() const long CampData::id() const
{ {
return m_id; return m_id;
} }
void CampData::setId(int id) void CampData::setId(long id)
{ {
m_id = id; m_id = id;
} }
@ -72,42 +101,42 @@ void CampData::setOwnerAddress(const QString &ownerAddress)
m_ownerAddress = ownerAddress; m_ownerAddress = ownerAddress;
} }
QOdbList<ServiceItemPtr> CampData::services() const QList<ServiceItemPtr> CampData::services() const
{ {
return m_services; return m_services;
} }
void CampData::setServices(const QOdbList<QSharedPointer<ServiceItem> > &services) void CampData::setServices(const QList<QSharedPointer<ServiceItem> > &services)
{ {
m_services = services; m_services = services;
} }
void CampData::addServiceItem(ServiceItemPtr serviceItem) void CampData::addServiceItem(const ServiceItemPtr& serviceItem)
{ {
m_services.append(serviceItem); m_services.append(serviceItem);
} }
void CampData::removeServiceItem(ServiceItemPtr serviceItem) void CampData::removeServiceItem(const ServiceItemPtr& serviceItem)
{ {
m_services.removeOne(serviceItem); m_services.removeOne(serviceItem);
} }
QOdbList<AddressItemPtr> CampData::people() const QList<AddressItemPtr> CampData::people() const
{ {
return m_people; return m_people;
} }
void CampData::setPeople(const QOdbList<AddressItemPtr> &people) void CampData::setPeople(const QList<AddressItemPtr> &people)
{ {
m_people = people; m_people = people;
} }
void CampData::addPerson(AddressItemPtr person) void CampData::addPerson(const AddressItemPtr& person)
{ {
m_people.append(person); m_people.append(person);
} }
void CampData::removePerson(AddressItemPtr person) void CampData::removePerson(const AddressItemPtr& person)
{ {
m_people.removeOne(person); m_people.removeOne(person);
} }

@ -5,15 +5,15 @@
#include <QObject> #include <QObject>
#include <QDate> #include <QDate>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <odb/core.hxx>
#include <odb/qt/list.hxx>
#include <data/season.h> #include <data/season.h>
#pragma db object #include "../camp_global.h"
class CampData : public QObject class CampData : public QObject
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(CampData)
Q_PROPERTY(QString numSer READ numSer WRITE setNumSer) Q_PROPERTY(QString numSer READ numSer WRITE setNumSer)
Q_PROPERTY(QDate start READ start WRITE setStart) Q_PROPERTY(QDate start READ start WRITE setStart)
Q_PROPERTY(QDate end READ end WRITE setEnd) Q_PROPERTY(QDate end READ end WRITE setEnd)
@ -31,10 +31,10 @@ class CampData : public QObject
Q_PROPERTY(QDateTime updated READ updated WRITE setUpdated) Q_PROPERTY(QDateTime updated READ updated WRITE setUpdated)
public: public:
explicit CampData(QObject *parent = 0); explicit CampData(QObject *parent = nullptr);
int id() const; long id() const;
void setId(int id); void setId(long id);
QDate start() const; QDate start() const;
void setStart(const QDate &start); void setStart(const QDate &start);
@ -51,15 +51,15 @@ public:
QString ownerAddress() const; QString ownerAddress() const;
void setOwnerAddress(const QString &ownerAddress); void setOwnerAddress(const QString &ownerAddress);
QOdbList<QSharedPointer<ServiceItem> > services() const; QList<ServiceItemPtr> services() const;
void setServices(const QOdbList<QSharedPointer<ServiceItem> > &services); void setServices(const QList<ServiceItemPtr> &services);
void addServiceItem(ServiceItemPtr serviceItem); void addServiceItem(const ServiceItemPtr& serviceItem);
void removeServiceItem(ServiceItemPtr serviceItem); void removeServiceItem(const ServiceItemPtr& serviceItem);
QOdbList<AddressItemPtr> people() const; QList<AddressItemPtr> people() const;
void setPeople(const QOdbList<AddressItemPtr> &people); void setPeople(const QList<AddressItemPtr> &people);
void addPerson(AddressItemPtr person); void addPerson(const AddressItemPtr& person);
void removePerson(AddressItemPtr person); void removePerson(const AddressItemPtr& person);
QDecDouble totalPrice() const; QDecDouble totalPrice() const;
void setTotalPrice(QDecDouble totalPrice); void setTotalPrice(QDecDouble totalPrice);
@ -98,19 +98,15 @@ public:
void setUpdated(const QDateTime &updated); void setUpdated(const QDateTime &updated);
private: private:
friend class odb::access; long m_id;
#pragma db id auto
int m_id;
QString m_numSer; QString m_numSer;
QDate m_start; QDate m_start;
QDate m_end; QDate m_end;
QString m_ownerFirstame; QString m_ownerFirstame;
QString m_ownerLastname; QString m_ownerLastname;
QString m_ownerAddress; QString m_ownerAddress;
#pragma db value_not_null inverse(m_campData) QList<ServiceItemPtr> m_services;
QOdbList<ServiceItemPtr> m_services; QList<AddressItemPtr> m_people;
#pragma db value_not_null inverse(m_campData)
QOdbList<AddressItemPtr> m_people;
int m_fullPrice; int m_fullPrice;
int m_totalPrice; int m_totalPrice;
int m_sale; int m_sale;
@ -124,4 +120,6 @@ private:
QDateTime m_updated; QDateTime m_updated;
}; };
QX_REGISTER_HPP_CAMP(CampData, QObject, 0)
#endif // CAMPDATA_H #endif // CAMPDATA_H

@ -1,6 +1,20 @@
#include "personprice.h" #include "personprice.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_CAMP(PersonPrice)
namespace qx {
template<> void register_class(QxClass<PersonPrice>& t) {
t.setName("PersonPrice");
t.id(&PersonPrice::m_id, "id");
t.data(&PersonPrice::m_description, "description");
t.data(&PersonPrice::m_fromAge, "fromAge");
t.data(&PersonPrice::m_toAge, "toAge");
t.data(&PersonPrice::m_price, "price");
t.data(&PersonPrice::m_active, "active");
}
}
PersonPrice::PersonPrice(QObject *parent) : QObject(parent) PersonPrice::PersonPrice(QObject *parent) : QObject(parent)
{ {
m_id = 0; m_id = 0;
@ -10,12 +24,12 @@ PersonPrice::PersonPrice(QObject *parent) : QObject(parent)
m_active = true; m_active = true;
} }
int PersonPrice::id() const long PersonPrice::id() const
{ {
return m_id; return m_id;
} }
void PersonPrice::setId(int id) void PersonPrice::setId(long id)
{ {
m_id = id; m_id = id;
} }

@ -3,12 +3,14 @@
#include <QObject> #include <QObject>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <odb/core.hxx>
#pragma db object #include "../camp_global.h"
class PersonPrice : public QObject class PersonPrice : public QObject
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(PersonPrice)
Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(int fromAge READ fromAge WRITE setFromAge) Q_PROPERTY(int fromAge READ fromAge WRITE setFromAge)
Q_PROPERTY(int toAge READ toAge WRITE setToAge) Q_PROPERTY(int toAge READ toAge WRITE setToAge)
@ -18,8 +20,8 @@ class PersonPrice : public QObject
public: public:
explicit PersonPrice(QObject *parent = 0); explicit PersonPrice(QObject *parent = 0);
int id() const; long id() const;
void setId(int id); void setId(long id);
QString description() const; QString description() const;
void setDescription(const QString &description); void setDescription(const QString &description);
@ -37,9 +39,7 @@ public:
void setActive(bool active); void setActive(bool active);
private: private:
friend class odb::access; long m_id;
#pragma db id auto
int m_id;
QString m_description; QString m_description;
int m_fromAge; int m_fromAge;
int m_toAge; int m_toAge;
@ -47,4 +47,6 @@ private:
bool m_active; bool m_active;
}; };
QX_REGISTER_HPP_CAMP(PersonPrice, QObject, 0)
#endif // PERSONPRICE_H #endif // PERSONPRICE_H

@ -1,6 +1,18 @@
#include "sale.h" #include "sale.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_CAMP(Sale)
namespace qx {
template<> void register_class(QxClass<Sale>& t) {
t.setName("Sale");
t.id(&Sale::m_id, "id");
t.data(&Sale::m_sale, "sale");
t.data(&Sale::m_fixed, "fixed");
t.data(&Sale::m_description, "description");
}
}
Sale::Sale(QObject *parent) : ComboItem(parent) Sale::Sale(QObject *parent) : ComboItem(parent)
{ {
m_id = 0; m_id = 0;
@ -8,12 +20,12 @@ Sale::Sale(QObject *parent) : ComboItem(parent)
m_fixed = false; m_fixed = false;
} }
int Sale::id() const long Sale::id() const
{ {
return m_id; return m_id;
} }
void Sale::setId(int id) void Sale::setId(long id)
{ {
m_id = id; m_id = id;
} }

@ -2,23 +2,25 @@
#define SALE_H #define SALE_H
#include <QObject> #include <QObject>
#include <odb/core.hxx>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <combodata.h> #include <combodata.h>
#pragma db object #include "../camp_global.h"
class Sale : public ComboItem class Sale : public ComboItem
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(Sale)
Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString description READ description WRITE setDescription)
Q_PROPERTY(QDecDouble sale READ sale WRITE setSale) Q_PROPERTY(QDecDouble sale READ sale WRITE setSale)
Q_PROPERTY(bool fixed READ fixed WRITE setFixed) Q_PROPERTY(bool fixed READ fixed WRITE setFixed)
public: public:
explicit Sale(QObject *parent = 0); explicit Sale(QObject *parent = nullptr);
int id() const; long id() const;
void setId(int id); void setId(long id);
QDecDouble sale() const; QDecDouble sale() const;
void setSale(QDecDouble sale); void setSale(QDecDouble sale);
@ -30,17 +32,17 @@ public:
void setDescription(const QString &description); void setDescription(const QString &description);
private: private:
friend class odb::access; long m_id;
#pragma db id auto
int m_id;
QString m_description; QString m_description;
int m_sale; int m_sale;
bool m_fixed; bool m_fixed;
// ComboItem interface // ComboItem interface
public: public:
bool eq(ComboItem *other); bool eq(ComboItem *other) override;
QString toString(); QString toString() override;
}; };
QX_REGISTER_HPP_CAMP(Sale, ComboItem, 0)
#endif // SALE_H #endif // SALE_H

@ -1,6 +1,26 @@
#include "serviceitem.h" #include "serviceitem.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_CAMP(ServiceItem)
namespace qx {
template<> void register_class(QxClass<ServiceItem>& t) {
t.setName("ServiceItem");
t.id(&ServiceItem::m_id, "id");
t.data(&ServiceItem::m_name, "name");
t.data(&ServiceItem::m_code, "code");
t.data(&ServiceItem::m_price, "price");
t.data(&ServiceItem::m_salePossible, "salePossible");
t.data(&ServiceItem::m_type, "type");
t.data(&ServiceItem::m_sale, "sale");
t.data(&ServiceItem::m_description, "description");
t.data(&ServiceItem::m_totalPrice, "totalPrice");
t.data(&ServiceItem::m_fullPrice, "fullPrice");
t.relationManyToOne(&ServiceItem::m_campData, "campData");
}
}
ServiceItem::ServiceItem(QObject *parent) : QObject(parent) ServiceItem::ServiceItem(QObject *parent) : QObject(parent)
{ {
m_id = 0; m_id = 0;
@ -8,15 +28,16 @@ ServiceItem::ServiceItem(QObject *parent) : QObject(parent)
m_sale = 0; m_sale = 0;
m_price = 0; m_price = 0;
m_totalPrice = 0; m_totalPrice = 0;
m_fullPrice = 0;
m_type = AccService::OTHER; m_type = AccService::OTHER;
} }
int ServiceItem::id() const long ServiceItem::id() const
{ {
return m_id; return m_id;
} }
void ServiceItem::setId(int id) void ServiceItem::setId(long id)
{ {
m_id = id; m_id = id;
} }

@ -6,16 +6,17 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QWeakPointer> #include <QWeakPointer>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <data/accservice.h>
#include <odb/core.hxx> #include "../camp_global.h"
#include <accservice.h>
class CampData; class CampData;
#pragma db object
class ServiceItem : public QObject class ServiceItem : public QObject
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(ServiceItem)
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString code READ code WRITE setCode) Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString description READ description WRITE setDescription)
@ -27,10 +28,10 @@ class ServiceItem : public QObject
Q_ENUMS(AccService::ServiceType) Q_ENUMS(AccService::ServiceType)
public: public:
explicit ServiceItem(QObject *parent = 0); explicit ServiceItem(QObject *parent = nullptr);
int id() const; long id() const;
void setId(int id); void setId(long id);
QString name() const; QString name() const;
void setName(const QString &name); void setName(const QString &name);
@ -63,9 +64,7 @@ public:
void setFullPrice(QDecDouble fullPrice); void setFullPrice(QDecDouble fullPrice);
private: private:
friend class odb::access; long m_id;
#pragma db id auto
int m_id;
QString m_name; QString m_name;
QString m_code; QString m_code;
QString m_description; QString m_description;
@ -75,8 +74,9 @@ private:
int m_sale; int m_sale;
bool m_salePossible; bool m_salePossible;
AccService::ServiceType m_type; AccService::ServiceType m_type;
#pragma db not_null CampDataPtr m_campData;
QWeakPointer<CampData> m_campData;
}; };
QX_REGISTER_HPP_CAMP(ServiceItem, QObject, 0)
#endif // SREVICEITEM_H #endif // SREVICEITEM_H

@ -40,10 +40,12 @@ DetailWidget::~DetailWidget()
delete ui; delete ui;
} }
void DetailWidget::setData(const CampDataPtr &data) void DetailWidget::setData(CampDataPtr &data)
{ {
if (data->people().isEmpty() || data->services().isEmpty()) {
CampService srv; CampService srv;
srv.loadItems(data); srv.load(data);
}
m_peopleModel->setData(data->people()); m_peopleModel->setData(data->people());
m_servicesModel->setData(data->services()); m_servicesModel->setData(data->services());

@ -14,10 +14,10 @@ class DetailWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit DetailWidget(QWidget *parent = 0); explicit DetailWidget(QWidget *parent = nullptr);
~DetailWidget(); ~DetailWidget() override;
void setData(const CampDataPtr &data); void setData(CampDataPtr &data);
private: private:
Ui::DetailWidget *ui; Ui::DetailWidget *ui;

@ -8,6 +8,8 @@ CampSettings::CampSettings(QObject *parent) : QObject(parent)
m_rounding = Enums::R_MATH; m_rounding = Enums::R_MATH;
m_decimalPlaces = 0; m_decimalPlaces = 0;
m_vatType = Enums::NONE; m_vatType = Enums::NONE;
m_accFeeStartAge = 0;
m_accFeeEndAge = 0;
} }
QDecDouble CampSettings::accFee() const QDecDouble CampSettings::accFee() const

@ -18,7 +18,7 @@ class CampSettings : public QObject
Q_PROPERTY(QString accFeeText READ accFeeText WRITE setAccFeeText) Q_PROPERTY(QString accFeeText READ accFeeText WRITE setAccFeeText)
public: public:
explicit CampSettings(QObject *parent = 0); explicit CampSettings(QObject *parent = nullptr);
QDecDouble accFee() const; QDecDouble accFee() const;
void setAccFee(QDecDouble accFee); void setAccFee(QDecDouble accFee);

@ -1,10 +1,10 @@
#include "camp-odb.hxx"
#include "campsettingsform.h" #include "campsettingsform.h"
#include "ui_campsettingsform.h" #include "ui_campsettingsform.h"
#include <settingsservice.h> #include <settingsservice.h>
#include <QScroller> #include <QScroller>
#include <QMessageBox> #include <QMessageBox>
#include <QHeaderView>
CampSettingsForm::CampSettingsForm(QWidget *parent) : CampSettingsForm::CampSettingsForm(QWidget *parent) :
FormBinder<CampSettings>(parent), FormBinder<CampSettings>(parent),

@ -5,7 +5,7 @@
#include <QList> #include <QList>
#include "campsettings.h" #include "campsettings.h"
#include "data/camp-data.h" #include "../data/camp-data.h"
#include <formbinder.h> #include <formbinder.h>
#include <autotablemodel.h> #include <autotablemodel.h>
@ -18,16 +18,16 @@ class CampSettingsForm : public FormBinder<CampSettings>
Q_OBJECT Q_OBJECT
public: public:
explicit CampSettingsForm(QWidget *parent = 0); explicit CampSettingsForm(QWidget *parent = nullptr);
~CampSettingsForm(); ~CampSettingsForm() override;
// IForm interface // IForm interface
public slots: public slots:
bool saveRecord(); bool saveRecord() override;
// IForm interface // IForm interface
public: public:
void loadEntity(); void loadEntity() override;
private slots: private slots:
void on_btnPriceAdd_clicked(); void on_btnPriceAdd_clicked();

@ -0,0 +1,62 @@
cmake_minimum_required(VERSION 3.24)
project(commodity)
include(../3rdparty/QxOrm/QxOrm.cmake)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ../plugins)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)
add_library(commodity SHARED
commodity.cpp
commodity.h
commodity_global.h
commodityform.cpp
commodityform.h
commodityform.ui
commoditygrid.cpp
commoditygrid.h
commodityrc.qrc
commodityservice.cpp
commodityservice.h
commoditysettingsform.cpp
commoditysettingsform.h
commoditysettingsform.ui
commoditytablemodel.cpp
commoditytablemodel.h
data/commodity-data.h
data/commoditydata.cpp
data/commoditydata.h
data/commoditytypedata.cpp
data/commoditytypedata.h
settings/commoditysettings.cpp
settings/commoditysettings.h
)
target_compile_definitions(commodity PRIVATE -DCOMMODITY_LIBRARY)
include_directories(../core)
include_directories(../shop)
target_link_libraries(commodity
Qt::Core
Qt::Gui
Qt::Widgets
qdecimal
decnumber
QxOrm
core
shop
)
install(TARGETS commodity
LIBRARY DESTINATION ../plugins)

@ -5,18 +5,11 @@
#include "commoditysettingsform.h" #include "commoditysettingsform.h"
#include "commodityservice.h" #include "commodityservice.h"
Commodity::Commodity()
{
}
void Commodity::initServiceUi() void Commodity::initServiceUi()
{ {
CommodityGrid *grid = new CommodityGrid();
CommodityForm *form = new CommodityForm();
m_service = new CommodityService(); m_service = new CommodityService();
m_ui = grid; m_ui = new CommodityGrid();
((CommodityGrid *) m_ui)->setForm(form); ((CommodityGrid *) m_ui)->setForm(new CommodityForm());
m_settingsUi = new CommoditySettingsForm(); m_settingsUi = new CommoditySettingsForm();
} }

@ -14,15 +14,15 @@ class COMMODITYSHARED_EXPORT Commodity : public QObject, IMetaDataPlugin
Q_INTERFACES(IPlugin) Q_INTERFACES(IPlugin)
public: public:
Commodity(); Commodity() = default;
protected: protected:
void initServiceUi() Q_DECL_OVERRIDE; void initServiceUi() Q_DECL_OVERRIDE;
// IPlugin interface // IPlugin interface
public: public:
virtual QIcon pluginIcon(); QIcon pluginIcon() override;
QTranslator *translator(); QTranslator *translator() override;
}; };

@ -29,7 +29,7 @@ CREATE TABLE \"CommodityData\" (
DEFERRABLE INITIALLY DEFERRED);" DEFERRABLE INITIALLY DEFERRED);"
], ],
"dependencies" : [], "dependencies" : [ "SHOP" ],
"translations" : { "translations" : {
"CZ" : { "CZ" : {
"name" : "Název", "name" : "Název",

@ -1,61 +0,0 @@
#-------------------------------------------------
#
# Project created by QtCreator 2016-02-09T21:26:14
#
#-------------------------------------------------
QT += widgets sql
QT -= gui
TARGET = commodity
TEMPLATE = lib
DEFINES += COMMODITY_LIBRARY
SOURCES += commodity.cpp \
data/commoditydata.cpp \
data/commoditytypedata.cpp \
commoditytablemodel.cpp \
commodityform.cpp \
commoditygrid.cpp \
commoditysettingsform.cpp \
commodityservice.cpp \
settings/commoditysettings.cpp
HEADERS += commodity.h\
commodity_global.h \
data/commoditydata.h \
data/commoditytypedata.h \
data/commodity-data.h \
commoditytablemodel.h \
commodityform.h \
commoditygrid.h \
commoditysettingsform.h \
commodityservice.h \
settings/commoditysettings.h
include(../config_plugin.pri)
ODB_FILES = commodity/data/commodity-data.h
H_DIR = $$PWD/data/*.h
ODB_OTHER_INCLUDES = -I $$PWD/../shop
include(../odb.pri)
OTHER_FILES += \
commodity.json
FORMS += \
commodityform.ui \
commoditysettingsform.ui
RESOURCES += \
commodityrc.qrc
TRANSLATIONS = translations/commodity_cs_CZ.ts
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -lshop
else:unix: LIBS += -L$$OUT_PWD/../plugins/ -lshop
INCLUDEPATH += $$PWD/../shop
DEPENDPATH += $$PWD/../shop

@ -10,3 +10,11 @@
#endif #endif
#endif // COMMODITY_GLOBAL_H #endif // COMMODITY_GLOBAL_H
#ifdef COMMODITY_LIBRARY
#define QX_REGISTER_HPP_COMM QX_REGISTER_HPP_EXPORT_DLL
#define QX_REGISTER_CPP_COMM QX_REGISTER_CPP_EXPORT_DLL
#else // COMMODITY_LIBRARY
#define QX_REGISTER_HPP_COMM QX_REGISTER_HPP_IMPORT_DLL
#define QX_REGISTER_CPP_COMM QX_REGISTER_CPP_IMPORT_DLL
#endif

@ -2,12 +2,12 @@
#include "ui_commodityform.h" #include "ui_commodityform.h"
#include <combodata.h> #include <combodata.h>
#include <settingsservice.h> #include <settingsservice.h>
#include <settings/commoditysettings.h>
#include <helper.h> #include <helper.h>
#include <QSharedPointer> #include <QSharedPointer>
#include <QList> #include <QList>
#include "data/commoditytypedata.h" #include "data/commoditytypedata.h"
#include "settings/commoditysettings.h"
CommodityForm::CommodityForm(QWidget *parent) : CommodityForm::CommodityForm(QWidget *parent) :
AutoForm<CommodityData>(parent), AutoForm<CommodityData>(parent),

@ -4,7 +4,6 @@
#include <QWidget> #include <QWidget>
#include <autoform.h> #include <autoform.h>
#include "data/commoditydata.h" #include "data/commoditydata.h"
#include "commodity-odb.hxx"
namespace Ui { namespace Ui {
class CommodityForm; class CommodityForm;
@ -15,8 +14,8 @@ class CommodityForm : public AutoForm<CommodityData>
Q_OBJECT Q_OBJECT
public: public:
explicit CommodityForm(QWidget *parent = 0); explicit CommodityForm(QWidget *parent = nullptr);
~CommodityForm(); ~CommodityForm() override;
private: private:
Ui::CommodityForm *ui; Ui::CommodityForm *ui;
@ -25,8 +24,8 @@ private:
// FormBinder interface // FormBinder interface
protected: protected:
void registerCombos(); void registerCombos() override;
void onShow(); void onShow() override;
private slots: private slots:
void on_code_textChanged(const QString &text); void on_code_textChanged(const QString &text);
}; };

@ -14,6 +14,9 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">

@ -3,13 +3,13 @@
#include <core.h> #include <core.h>
#include "data/commoditydata.h" #include "data/commoditydata.h"
#include "commodity-odb.hxx"
class CommodityGrid : public GridForm<CommodityData> class CommodityGrid : public GridForm<CommodityData>
{ {
Q_OBJECT Q_OBJECT
public: public:
CommodityGrid(QWidget *parent = NULL); explicit CommodityGrid(QWidget *parent = nullptr);
}; };
#endif // COMMODITYGRID_H #endif // COMMODITYGRID_H

@ -1,18 +1,11 @@
#include "commodityservice.h" #include "commodityservice.h"
#include "commodity-odb.hxx" QList<QSharedPointer<IShopItem> > CommodityService::shopItems()
CommodityService::CommodityService()
{
}
QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
{ {
QList<QSharedPointer<ShopItem> > ret; QList<QSharedPointer<IShopItem> > ret;
foreach (QSharedPointer<CommodityData> data, all()) { foreach (QSharedPointer<CommodityData> data, all()) {
ret.append(qSharedPointerDynamicCast<ShopItem, CommodityData>(data)); ret.append(qSharedPointerDynamicCast<IShopItem, CommodityData>(data));
} }
return ret; return ret;
@ -30,15 +23,15 @@ void CommodityService::addedToVoucher(int itemId, int countAdded)
update(commodity); update(commodity);
} }
ShopItemPtr CommodityService::shopItem(int itemId) IShopItemPtr CommodityService::shopItem(int itemId)
{ {
CommodityDataPtr item = this->loadById(itemId); CommodityDataPtr item = this->loadById(itemId);
return qSharedPointerDynamicCast<ShopItem, CommodityData>(item); return qSharedPointerDynamicCast<IShopItem, CommodityData>(item);
} }
ISeller *CommodityService::seller() ISeller *CommodityService::seller()
{ {
return NULL; return nullptr;
} }
QString CommodityService::defaultSort() QString CommodityService::defaultSort()

@ -8,13 +8,13 @@
class CommodityService : public Service<CommodityData>, public ISellableService class CommodityService : public Service<CommodityData>, public ISellableService
{ {
public: public:
CommodityService(); CommodityService() = default;
// ISellableService interface // ISellableService interface
public: public:
QList<ShopItemPtr> shopItems() override; QList<IShopItemPtr> shopItems() override;
void addedToVoucher(int itemId, int countAdded) override; void addedToVoucher(int itemId, int countAdded) override;
virtual ShopItemPtr shopItem(int itemId) override; IShopItemPtr shopItem(int itemId) override;
ISeller *seller() override; ISeller *seller() override;
QString defaultSort() override; QString defaultSort() override;
}; };

@ -1,8 +1,8 @@
#include "commoditysettingsform.h" #include "commoditysettingsform.h"
#include "ui_commoditysettingsform.h" #include "ui_commoditysettingsform.h"
#include <QHeaderView>
#include <service.h> #include <service.h>
#include <settingsservice.h> #include <settingsservice.h>
#include "commodity-odb.hxx"
CommoditySettingsForm::CommoditySettingsForm(QWidget *parent) : CommoditySettingsForm::CommoditySettingsForm(QWidget *parent) :
FormBinder<CommoditySettings>(parent), FormBinder<CommoditySettings>(parent),

@ -16,8 +16,8 @@ class CommoditySettingsForm : public FormBinder<CommoditySettings>
Q_OBJECT Q_OBJECT
public: public:
explicit CommoditySettingsForm(QWidget *parent = 0); explicit CommoditySettingsForm(QWidget *parent = nullptr);
~CommoditySettingsForm(); ~CommoditySettingsForm() override;
private: private:
Ui::CommoditySettingsForm *ui; Ui::CommoditySettingsForm *ui;
@ -26,10 +26,10 @@ private:
// IForm interface // IForm interface
public: public:
void loadEntity(); void loadEntity() override;
public slots: public slots:
bool saveRecord(); bool saveRecord() override;
private slots: private slots:
void on_addCommodityType_clicked(); void on_addCommodityType_clicked();
void on_delCommodityType_clicked(); void on_delCommodityType_clicked();

@ -7,7 +7,7 @@ class CommodityTableModel : public AutoTableModel<CommodityData>
{ {
Q_OBJECT Q_OBJECT
public: public:
CommodityTableModel(QObject *parent= NULL); explicit CommodityTableModel(QObject *parent= nullptr);
}; };
#endif // COMMODITYTABLEMODEL_H #endif // COMMODITYTABLEMODEL_H

@ -1,22 +1,40 @@
#include "commoditydata.h" #include "commoditydata.h"
#include <define.h> #include <define.h>
QX_REGISTER_CPP_COMM(CommodityData)
namespace qx {
template<> void register_class(QxClass<CommodityData>& t) {
t.setName("CommodityData");
t.id(&CommodityData::m_id, "id");
t.data(&CommodityData::m_name, "name");
t.data(&CommodityData::m_shortName, "shortName");
t.data(&CommodityData::m_code, "code");
t.data(&CommodityData::m_price, "price");
t.data(&CommodityData::m_vat, "vat");
t.data(&CommodityData::m_count, "count");
t.relationManyToOne(&CommodityData::m_type, "type");
}
}
CommodityData::CommodityData(QObject *parent) CommodityData::CommodityData(QObject *parent)
:ShopItem(parent) :IShopItem(parent)
{ {
m_count = 0; m_count = 0;
m_price = 0; m_price = 0;
m_vat = Enums::NONE; m_vat = Enums::NONE;
} }
int CommodityData::id() long CommodityData::id()
{ {
return m_id; return m_id;
} }
void CommodityData::setId(int id) void CommodityData::setId(long id)
{ {
m_id = id; m_id = id;
} }
QString CommodityData::name() QString CommodityData::name()
{ {
return m_name; return m_name;
@ -26,6 +44,7 @@ void CommodityData::setName(const QString &name)
{ {
m_name = name; m_name = name;
} }
QString CommodityData::shortName() QString CommodityData::shortName()
{ {
return m_shortName; return m_shortName;
@ -35,6 +54,7 @@ void CommodityData::setShortName(const QString &shortName)
{ {
m_shortName = shortName; m_shortName = shortName;
} }
QString CommodityData::code() const QString CommodityData::code() const
{ {
return m_code; return m_code;
@ -44,6 +64,7 @@ void CommodityData::setCode(const QString &code)
{ {
m_code = code; m_code = code;
} }
QSharedPointer<QObject> CommodityData::type() const QSharedPointer<QObject> CommodityData::type() const
{ {
return m_type; return m_type;
@ -51,7 +72,7 @@ QSharedPointer<QObject> CommodityData::type() const
void CommodityData::setType(const QSharedPointer<QObject> &type) void CommodityData::setType(const QSharedPointer<QObject> &type)
{ {
if (qobject_cast<CommodityTypeData*>(type.data()) != NULL) { if (qobject_cast<CommodityTypeData*>(type.data()) != nullptr) {
m_type = qSharedPointerDynamicCast<CommodityTypeData, QObject>(type); m_type = qSharedPointerDynamicCast<CommodityTypeData, QObject>(type);
} }
} }
@ -98,6 +119,10 @@ QString CommodityData::pluginId()
return "COMMODITY"; return "COMMODITY";
} }
QStringList CommodityData::eagerLoad() {
return { "type" };
}

@ -3,17 +3,20 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <odb/core.hxx>
#include "commoditytypedata.h" #include "commoditytypedata.h"
#include <shopitem.h> #include <shopitem.h>
#include <QDecDouble.hh> #include <QDecDouble.hh>
#include <QSharedDataPointer> #include <QSharedDataPointer>
#include <enums.h> #include <enums.h>
#include "../commodity_global.h"
#pragma db object #pragma db object
class CommodityData : public ShopItem class CommodityData : public IShopItem
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(CommodityData)
Q_PROPERTY(QString code READ code WRITE setCode) Q_PROPERTY(QString code READ code WRITE setCode)
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
Q_PROPERTY(QString shortName READ shortName WRITE setShortName) Q_PROPERTY(QString shortName READ shortName WRITE setShortName)
@ -23,10 +26,10 @@ class CommodityData : public ShopItem
Q_PROPERTY(int count READ count WRITE setCount) Q_PROPERTY(int count READ count WRITE setCount)
public: public:
CommodityData(QObject *parent = 0); explicit CommodityData(QObject *parent = nullptr);
int id() override; long id() override;
void setId(int id); void setId(long id);
QString name() override; QString name() override;
void setName(const QString &name); void setName(const QString &name);
@ -49,10 +52,10 @@ public:
int count() const; int count() const;
void setCount(int count); void setCount(int count);
Q_INVOKABLE QStringList eagerLoad();
private: private:
friend class odb::access; long m_id{0};
#pragma db id auto
int m_id;
QString m_name; QString m_name;
QString m_shortName; QString m_shortName;
QString m_code; QString m_code;
@ -66,8 +69,11 @@ public:
QDecDouble unitPrice() override; QDecDouble unitPrice() override;
Enums::VatType vatType() override; Enums::VatType vatType() override;
QString pluginId() override; QString pluginId() override;
}; };
typedef QSharedPointer<CommodityData> CommodityDataPtr; typedef QSharedPointer<CommodityData> CommodityDataPtr;
QX_REGISTER_HPP_COMM(CommodityData, IShopItem, 0)
#endif // COMMODITYDATA_H #endif // COMMODITYDATA_H

@ -1,19 +1,30 @@
#include "commoditytypedata.h" #include "commoditytypedata.h"
QX_REGISTER_CPP_COMM(CommodityTypeData)
namespace qx {
template<> void register_class(QxClass<CommodityTypeData>& t) {
t.setName("CommodityTypeData");
t.id(&CommodityTypeData::m_id, "id");
t.data(&CommodityTypeData::m_name, "name");
}
}
CommodityTypeData::CommodityTypeData(QObject *parent) CommodityTypeData::CommodityTypeData(QObject *parent)
:ComboItem(parent) :ComboItem(parent)
{ {
m_id = 0; m_id = 0;
} }
int CommodityTypeData::id() const long CommodityTypeData::id() const
{ {
return m_id; return m_id;
} }
void CommodityTypeData::setId(int id) void CommodityTypeData::setId(long id)
{ {
m_id = id; m_id = id;
} }
QString CommodityTypeData::name() const QString CommodityTypeData::name() const
{ {
return m_name; return m_name;
@ -28,7 +39,7 @@ bool CommodityTypeData::eq(ComboItem *other)
{ {
CommodityTypeData* ct = qobject_cast<CommodityTypeData *> (other); CommodityTypeData* ct = qobject_cast<CommodityTypeData *> (other);
return ct != NULL && this->id() == ct->id() ; return ct != nullptr && this->id() == ct->id() ;
} }
QString CommodityTypeData::toString() QString CommodityTypeData::toString()

@ -3,34 +3,35 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <odb/core.hxx>
#include <data/comboitem.h> #include <data/comboitem.h>
#include "../commodity_global.h"
#pragma db object
class CommodityTypeData :public ComboItem class CommodityTypeData :public ComboItem
{ {
Q_OBJECT Q_OBJECT
QX_REGISTER_FRIEND_CLASS(CommodityTypeData)
Q_PROPERTY(QString name READ name WRITE setName) Q_PROPERTY(QString name READ name WRITE setName)
public: public:
CommodityTypeData(QObject *parent = 0); explicit CommodityTypeData(QObject *parent = nullptr);
int id() const; long id() const;
void setId(int id); void setId(long id);
QString name() const; QString name() const;
void setName(const QString &name); void setName(const QString &name);
private: private:
friend class odb::access; long m_id{0};
#pragma db id auto
int m_id;
QString m_name; QString m_name;
// ComboItem interface // ComboItem interface
public: public:
bool eq(ComboItem *other); bool eq(ComboItem *other) override;
QString toString(); QString toString() override;
}; };
QX_REGISTER_HPP_COMM(CommodityTypeData, ComboItem, 0)
#endif // COMMODITYTYPEDATA_H #endif // COMMODITYTYPEDATA_H

@ -1,4 +0,0 @@
win32 {
LIB_PATH = d:/prac/qt/lib
ODB_INCLUDE_PREFIX = d:/prac/odb
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save