Compare commits

..

No commits in common. '529f7f6e7d790d3a008d2e9573236b71c9e62f7e' and '30e6180c8229815ed77f2c42fb0180107d993888' have entirely different histories.

2
.gitignore vendored

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

9
.gitmodules vendored

@ -1,9 +0,0 @@
[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

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

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

1
3rdparty/QxOrm vendored

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

1
3rdparty/qdecimal vendored

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

@ -1,17 +0,0 @@
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)

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

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

@ -0,0 +1,18 @@
#ifndef ACCGRID_H
#define ACCGRID_H
#include <core.h>
#include "data/person.h"
#include "accommodation-odb.hxx"
class AccGrid : public GridForm<Person>
{
Q_OBJECT
public:
explicit AccGrid(QWidget *parent = NULL);
~AccGrid();
};
#endif // ACCGRID_H

@ -0,0 +1,41 @@
#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;
}
*/

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

@ -0,0 +1,20 @@
{
"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" : []
}

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

@ -0,0 +1,12 @@
#ifndef ACCOMMODATION_GLOBAL_H
#define ACCOMMODATION_GLOBAL_H
#include <QtCore/qglobal.h>
#if defined(ACCOMMODATION_LIBRARY)
# define ACCOMMODATIONSHARED_EXPORT Q_DECL_EXPORT
#else
# define ACCOMMODATIONSHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // ACCOMMODATION_GLOBAL_H

@ -0,0 +1,28 @@
#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();
}

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

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

@ -0,0 +1,34 @@
#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);
}

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

@ -0,0 +1,62 @@
<?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>

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

@ -0,0 +1,58 @@
#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;
}

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

@ -0,0 +1,49 @@
#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);
}
}

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

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

After

Width:  |  Height:  |  Size: 1.1 KiB

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

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

@ -1,53 +0,0 @@
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
public:
QIcon pluginIcon() override;
QTranslator *translator() override;
virtual QIcon pluginIcon();
QTranslator *translator();
};

@ -0,0 +1,54 @@
#-------------------------------------------------
#
# 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,7 +2,6 @@
#define ADDRESSBOOK_GLOBAL_H
#include <QtCore/qglobal.h>
#include <QxOrm.h>
#if defined(ADDRESSBOOK_LIBRARY)
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_EXPORT
@ -10,12 +9,4 @@
# define ADDRESSBOOKSHARED_EXPORT Q_DECL_IMPORT
#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

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

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

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

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

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

@ -1,26 +1,5 @@
#include <data/countrydata.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)
:ComboItem(parent)
{
@ -117,12 +96,12 @@ void AddressbookData::setAddressZipCode(const QString &addressZipCode)
{
m_addressZipCode = addressZipCode;
}
long AddressbookData::id() const
int AddressbookData::id() const
{
return m_id;
}
void AddressbookData::setId(long id)
void AddressbookData::setId(int id)
{
m_id = id;
}
@ -143,7 +122,7 @@ void AddressbookData::setCountry(const QSharedPointer<QObject> &country)
bool AddressbookData::eq(ComboItem *other)
{
AddressbookData *adb = qobject_cast<AddressbookData*>(other);
return adb != nullptr && adb->id() == this->id();
return adb != NULL && adb->id() == this->id();
}
QString AddressbookData::toString()
@ -151,8 +130,4 @@ QString AddressbookData::toString()
return m_lastName + " " + m_firstName + ", " + m_addressStreet + " " + m_addressHouseNumber + ", " + m_addressCity;
}
QStringList AddressbookData::eagerLoad() {
return { "country" };
}

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

@ -1,38 +0,0 @@
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
)

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

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

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

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

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

@ -16,7 +16,6 @@
}
#navigation QToolButton {
background-color: dimgray;
color: white;
font-weight: bold;
min-width: 90px;
@ -24,9 +23,5 @@
}
#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));;
}
#dashboard QLabel {
color: black;
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));
}

@ -1,83 +0,0 @@
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
public:
explicit AddServiceDialog(AccServicePtr service, QWidget *parent = nullptr);
~AddServiceDialog() override;
explicit AddServiceDialog(AccServicePtr service, QWidget *parent = 0);
~AddServiceDialog();
QString description();
QDecDouble price();

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

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

@ -0,0 +1,110 @@
#-------------------------------------------------
#
# 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,7 +2,6 @@
#define CAMP_GLOBAL_H
#include <QtCore/qglobal.h>
#include <QxOrm.h>
#if defined(CAMP_LIBRARY)
# define CAMPSHARED_EXPORT Q_DECL_EXPORT
@ -10,12 +9,4 @@
# define CAMPSHARED_EXPORT Q_DECL_IMPORT
#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

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

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

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

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

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

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

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

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

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

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

@ -1,26 +1,6 @@
#include "addressitem.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)
{
m_id = 0;
@ -30,12 +10,12 @@ AddressItem::AddressItem(QObject *parent) : QObject(parent)
m_totalPrice = 0;
}
long AddressItem::id() const
int AddressItem::id() const
{
return m_id;
}
void AddressItem::setId(long id)
void AddressItem::setId(int id)
{
m_id = id;
}
@ -80,12 +60,12 @@ void AddressItem::setPrice(QDecDouble price)
m_price = FROM_DEC(price);
}
QSharedPointer<CampData> AddressItem::campData() const
QWeakPointer<CampData> AddressItem::campData() const
{
return m_campData;
}
void AddressItem::setCampData(const QSharedPointer<CampData> &campData)
void AddressItem::setCampData(const QWeakPointer<CampData> &campData)
{
m_campData = campData;
}

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

@ -1,35 +1,6 @@
#include "campdata.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)
{
m_id = 0;
@ -41,12 +12,12 @@ CampData::CampData(QObject *parent) : QObject(parent)
m_onVoucher = false;
}
long CampData::id() const
int CampData::id() const
{
return m_id;
}
void CampData::setId(long id)
void CampData::setId(int id)
{
m_id = id;
}
@ -101,42 +72,42 @@ void CampData::setOwnerAddress(const QString &ownerAddress)
m_ownerAddress = ownerAddress;
}
QList<ServiceItemPtr> CampData::services() const
QOdbList<ServiceItemPtr> CampData::services() const
{
return m_services;
}
void CampData::setServices(const QList<QSharedPointer<ServiceItem> > &services)
void CampData::setServices(const QOdbList<QSharedPointer<ServiceItem> > &services)
{
m_services = services;
}
void CampData::addServiceItem(const ServiceItemPtr& serviceItem)
void CampData::addServiceItem(ServiceItemPtr serviceItem)
{
m_services.append(serviceItem);
}
void CampData::removeServiceItem(const ServiceItemPtr& serviceItem)
void CampData::removeServiceItem(ServiceItemPtr serviceItem)
{
m_services.removeOne(serviceItem);
}
QList<AddressItemPtr> CampData::people() const
QOdbList<AddressItemPtr> CampData::people() const
{
return m_people;
}
void CampData::setPeople(const QList<AddressItemPtr> &people)
void CampData::setPeople(const QOdbList<AddressItemPtr> &people)
{
m_people = people;
}
void CampData::addPerson(const AddressItemPtr& person)
void CampData::addPerson(AddressItemPtr person)
{
m_people.append(person);
}
void CampData::removePerson(const AddressItemPtr& person)
void CampData::removePerson(AddressItemPtr person)
{
m_people.removeOne(person);
}

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

@ -1,20 +1,6 @@
#include "personprice.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)
{
m_id = 0;
@ -24,12 +10,12 @@ PersonPrice::PersonPrice(QObject *parent) : QObject(parent)
m_active = true;
}
long PersonPrice::id() const
int PersonPrice::id() const
{
return m_id;
}
void PersonPrice::setId(long id)
void PersonPrice::setId(int id)
{
m_id = id;
}

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

@ -1,18 +1,6 @@
#include "sale.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)
{
m_id = 0;
@ -20,12 +8,12 @@ Sale::Sale(QObject *parent) : ComboItem(parent)
m_fixed = false;
}
long Sale::id() const
int Sale::id() const
{
return m_id;
}
void Sale::setId(long id)
void Sale::setId(int id)
{
m_id = id;
}

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

@ -1,26 +1,6 @@
#include "serviceitem.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)
{
m_id = 0;
@ -28,16 +8,15 @@ ServiceItem::ServiceItem(QObject *parent) : QObject(parent)
m_sale = 0;
m_price = 0;
m_totalPrice = 0;
m_fullPrice = 0;
m_type = AccService::OTHER;
}
long ServiceItem::id() const
int ServiceItem::id() const
{
return m_id;
}
void ServiceItem::setId(long id)
void ServiceItem::setId(int id)
{
m_id = id;
}

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

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

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

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

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

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

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

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

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

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

@ -0,0 +1,61 @@
#-------------------------------------------------
#
# 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,11 +10,3 @@
#endif
#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 <combodata.h>
#include <settingsservice.h>
#include <settings/commoditysettings.h>
#include <helper.h>
#include <QSharedPointer>
#include <QList>
#include "data/commoditytypedata.h"
#include "settings/commoditysettings.h"
CommodityForm::CommodityForm(QWidget *parent) :
AutoForm<CommodityData>(parent),

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

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

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

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

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

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

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

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

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

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

@ -1,30 +1,19 @@
#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)
:ComboItem(parent)
{
m_id = 0;
}
long CommodityTypeData::id() const
int CommodityTypeData::id() const
{
return m_id;
}
void CommodityTypeData::setId(long id)
void CommodityTypeData::setId(int id)
{
m_id = id;
}
QString CommodityTypeData::name() const
{
return m_name;
@ -39,7 +28,7 @@ bool CommodityTypeData::eq(ComboItem *other)
{
CommodityTypeData* ct = qobject_cast<CommodityTypeData *> (other);
return ct != nullptr && this->id() == ct->id() ;
return ct != NULL && this->id() == ct->id() ;
}
QString CommodityTypeData::toString()

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

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