Added settings for Camp module. Changed Camp data model.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "campgrid.h"
|
||||
#include "campform.h"
|
||||
#include "settings/campsettingsform.h"
|
||||
|
||||
Camp::Camp()
|
||||
{
|
||||
@@ -9,8 +10,10 @@ Camp::Camp()
|
||||
|
||||
void Camp::initServiceUi()
|
||||
{
|
||||
m_service = new Service<CampData>();
|
||||
m_ui = new CampGrid();
|
||||
((CampGrid*)m_ui)->setForm(new CampForm());
|
||||
m_settingsUi = new CampSettingsForm();
|
||||
}
|
||||
|
||||
QIcon Camp::pluginIcon()
|
||||
|
||||
+31
-1
@@ -8,16 +8,19 @@
|
||||
"default" : "",
|
||||
"CZ" : ""
|
||||
},
|
||||
"schemaVersion" : 1,
|
||||
"schemaVersion" : 2,
|
||||
"sql" : [
|
||||
"CREATE TABLE \"CampData\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
\"numSer\" TEXT NULL,
|
||||
\"start\" TEXT NULL,
|
||||
\"end\" TEXT NULL,
|
||||
\"ownerFirstame\" TEXT NULL,
|
||||
\"ownerLastname\" TEXT NULL,
|
||||
\"ownerAddress\" TEXT NULL,
|
||||
\"totalPrice\" INTEGER NOT NULL,
|
||||
\"sale\" INTEGER NOT NULL,
|
||||
\"fixedSale\" INTEGER NOT NULL,
|
||||
\"season\" INTEGER NULL,
|
||||
CONSTRAINT \"season_fk\"
|
||||
FOREIGN KEY (\"season\")
|
||||
@@ -29,11 +32,21 @@ CREATE TABLE \"AddressItem\" (
|
||||
\"firstName\" TEXT NULL,
|
||||
\"lastName\" TEXT NULL,
|
||||
\"address\" TEXT NULL,
|
||||
\"adbItem\" INTEGER NULL,
|
||||
\"price\" INTEGER NOT NULL,
|
||||
\"campData\" INTEGER NOT NULL,
|
||||
\"personPrice\" INTEGER NULL,
|
||||
CONSTRAINT \"adbItem_fk\"
|
||||
FOREIGN KEY (\"adbItem\")
|
||||
REFERENCES \"AddressbookData\" (\"id\")
|
||||
DEFERRABLE INITIALLY DEFERRED,
|
||||
CONSTRAINT \"campData_fk\"
|
||||
FOREIGN KEY (\"campData\")
|
||||
REFERENCES \"CampData\" (\"id\")
|
||||
DEFERRABLE INITIALLY DEFERRED,
|
||||
CONSTRAINT \"personPrice_fk\"
|
||||
FOREIGN KEY (\"personPrice\")
|
||||
REFERENCES \"PersonPrice\" (\"id\")
|
||||
DEFERRABLE INITIALLY DEFERRED);
|
||||
|
||||
CREATE TABLE \"ServiceItem\" (
|
||||
@@ -48,7 +61,24 @@ CREATE TABLE \"ServiceItem\" (
|
||||
FOREIGN KEY (\"campData\")
|
||||
REFERENCES \"CampData\" (\"id\")
|
||||
DEFERRABLE INITIALLY DEFERRED);
|
||||
|
||||
CREATE TABLE \"Sale\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
\"sale\" INTEGER NOT NULL,
|
||||
\"fixed\" INTEGER NOT NULL);
|
||||
|
||||
CREATE TABLE \"PersonPrice\" (
|
||||
\"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
\"description\" TEXT NULL,
|
||||
\"fromAge\" INTEGER NOT NULL,
|
||||
\"toAge\" INTEGER NOT NULL,
|
||||
\"price\" INTEGER NOT NULL,
|
||||
\"active\" INTEGER NOT NULL);
|
||||
",
|
||||
|
||||
"ALTER TABLE Sale ADD \"description\" TEXT NULL;
|
||||
"
|
||||
|
||||
],
|
||||
"dependencies" : [ "ADDRESSBOOK", "SHOP", "SERVICES" ],
|
||||
"translations" : {
|
||||
|
||||
+13
-3
@@ -27,7 +27,11 @@ SOURCES += camp.cpp \
|
||||
data/addressitem.cpp \
|
||||
data/serviceitem.cpp \
|
||||
campgrid.cpp \
|
||||
campform.cpp
|
||||
campform.cpp \
|
||||
data/sale.cpp \
|
||||
settings/campsettingsform.cpp \
|
||||
data/personprice.cpp \
|
||||
settings/campsettings.cpp
|
||||
|
||||
HEADERS += camp.h\
|
||||
camp_global.h \
|
||||
@@ -36,7 +40,11 @@ HEADERS += camp.h\
|
||||
data/serviceitem.h \
|
||||
data/camp-data.h \
|
||||
campgrid.h \
|
||||
campform.h
|
||||
campform.h \
|
||||
data/sale.h \
|
||||
settings/campsettingsform.h \
|
||||
data/personprice.h \
|
||||
settings/campsettings.h
|
||||
|
||||
include(../config_plugin.pri)
|
||||
|
||||
@@ -57,6 +65,7 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../plugins/ -laddre
|
||||
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/ -lservices
|
||||
@@ -74,4 +83,5 @@ RESOURCES += \
|
||||
camprc.qrc
|
||||
|
||||
FORMS += \
|
||||
campform.ui
|
||||
campform.ui \
|
||||
settings/campsettingsform.ui
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
|
||||
AddressItem::AddressItem(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
m_id = 0;
|
||||
m_price = 0;
|
||||
}
|
||||
|
||||
int AddressItem::id() const
|
||||
@@ -65,3 +66,23 @@ void AddressItem::setCampData(const QWeakPointer<CampData> &campData)
|
||||
{
|
||||
m_campData = campData;
|
||||
}
|
||||
|
||||
PersonPricePtr AddressItem::personPrice() const
|
||||
{
|
||||
return m_personPrice;
|
||||
}
|
||||
|
||||
void AddressItem::setPersonPrice(const PersonPricePtr &personPrice)
|
||||
{
|
||||
m_personPrice = personPrice;
|
||||
}
|
||||
|
||||
AddressbookDataPtr AddressItem::adbItem() const
|
||||
{
|
||||
return m_adbItem;
|
||||
}
|
||||
|
||||
void AddressItem::setAdbItem(const AddressbookDataPtr &adbItem)
|
||||
{
|
||||
m_adbItem = adbItem;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <QDecDouble.hh>
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#include <addressbookdata.h>
|
||||
|
||||
class CampData;
|
||||
|
||||
#pragma db object
|
||||
@@ -40,6 +42,12 @@ public:
|
||||
QWeakPointer<CampData> campData() const;
|
||||
void setCampData(const QWeakPointer<CampData> &campData);
|
||||
|
||||
PersonPricePtr personPrice() const;
|
||||
void setPersonPrice(const PersonPricePtr &personPrice);
|
||||
|
||||
AddressbookDataPtr adbItem() const;
|
||||
void setAdbItem(const AddressbookDataPtr &adbItem);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
@@ -47,9 +55,11 @@ private:
|
||||
QString m_firstName;
|
||||
QString m_lastName;
|
||||
QString m_address;
|
||||
AddressbookDataPtr m_adbItem;
|
||||
int m_price;
|
||||
#pragma db not_null
|
||||
QWeakPointer<CampData> m_campData;
|
||||
PersonPricePtr m_personPrice;
|
||||
};
|
||||
|
||||
#endif // ADDRESSITEM_H
|
||||
|
||||
@@ -6,13 +6,19 @@
|
||||
class CampData;
|
||||
class AddressItem;
|
||||
class ServiceItem;
|
||||
class Sale;
|
||||
class PersonPrice;
|
||||
|
||||
typedef QSharedPointer<CampData> CampDataPtr;
|
||||
typedef QSharedPointer<ServiceItem> ServiceItemPtr;
|
||||
typedef QSharedPointer<AddressItem> AddressItemPtr;
|
||||
typedef QSharedPointer<Sale> SalePtr;
|
||||
typedef QSharedPointer<PersonPrice> PersonPricePtr;
|
||||
|
||||
#include "campdata.h"
|
||||
#include "addressitem.h"
|
||||
#include "serviceitem.h"
|
||||
#include "sale.h"
|
||||
#include "personprice.h"
|
||||
|
||||
#endif // CAMP_DATA_H
|
||||
|
||||
+34
-1
@@ -3,7 +3,10 @@
|
||||
|
||||
CampData::CampData(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
m_id = 0;
|
||||
m_totalPrice = 0;
|
||||
m_sale = 0;
|
||||
m_ownerFirstame = false;
|
||||
}
|
||||
|
||||
int CampData::id() const
|
||||
@@ -115,3 +118,33 @@ void CampData::setSeason(const SeasonPtr &season)
|
||||
{
|
||||
m_season = season;
|
||||
}
|
||||
|
||||
QDecDouble CampData::sale() const
|
||||
{
|
||||
return TO_DEC(m_sale);
|
||||
}
|
||||
|
||||
void CampData::setSale(QDecDouble sale)
|
||||
{
|
||||
m_sale = FROM_DEC(sale);
|
||||
}
|
||||
|
||||
bool CampData::fixedSale() const
|
||||
{
|
||||
return m_fixedSale;
|
||||
}
|
||||
|
||||
void CampData::setFixedSale(bool fixedSale)
|
||||
{
|
||||
m_fixedSale = fixedSale;
|
||||
}
|
||||
|
||||
QString CampData::numSer() const
|
||||
{
|
||||
return m_numSer;
|
||||
}
|
||||
|
||||
void CampData::setNumSer(const QString &numSer)
|
||||
{
|
||||
m_numSer = numSer;
|
||||
}
|
||||
|
||||
@@ -14,12 +14,15 @@
|
||||
class CampData : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString numSer READ numSer WRITE setNumSer)
|
||||
Q_PROPERTY(QDate start READ start WRITE setStart)
|
||||
Q_PROPERTY(QDate end READ end WRITE setEnd)
|
||||
Q_PROPERTY(QString ownerFirstame READ ownerFirstame WRITE setOwnerFirstame)
|
||||
Q_PROPERTY(QString ownerLastname READ ownerLastname WRITE setOwnerLastname)
|
||||
Q_PROPERTY(QString ownerAddress READ ownerAddress WRITE setOwnerAddress)
|
||||
Q_PROPERTY(QDecDouble totalPrice READ totalPrice WRITE setTotalPrice)
|
||||
Q_PROPERTY(QDecDouble sale READ sale WRITE setSale)
|
||||
Q_PROPERTY(bool fixedSale READ fixedSale WRITE setFixedSale)
|
||||
|
||||
public:
|
||||
explicit CampData(QObject *parent = 0);
|
||||
@@ -56,10 +59,20 @@ public:
|
||||
SeasonPtr season() const;
|
||||
void setSeason(const SeasonPtr &season);
|
||||
|
||||
QDecDouble sale() const;
|
||||
void setSale(QDecDouble sale);
|
||||
|
||||
bool fixedSale() const;
|
||||
void setFixedSale(bool fixedSale);
|
||||
|
||||
QString numSer() const;
|
||||
void setNumSer(const QString &numSer);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_numSer;
|
||||
QDate m_start;
|
||||
QDate m_end;
|
||||
QString m_ownerFirstame;
|
||||
@@ -70,6 +83,8 @@ private:
|
||||
#pragma db value_not_null inverse(m_campData)
|
||||
QOdbList<AddressItemPtr> m_people;
|
||||
int m_totalPrice;
|
||||
int m_sale;
|
||||
bool m_fixedSale;
|
||||
SeasonPtr m_season;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
#include "personprice.h"
|
||||
#include <define.h>
|
||||
|
||||
PersonPrice::PersonPrice(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_id = 0;
|
||||
m_fromAge = 0;
|
||||
m_toAge = 0;
|
||||
m_price = 0;
|
||||
m_active = true;
|
||||
}
|
||||
|
||||
int PersonPrice::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void PersonPrice::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QString PersonPrice::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void PersonPrice::setDescription(const QString &description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
|
||||
int PersonPrice::fromAge() const
|
||||
{
|
||||
return m_fromAge;
|
||||
}
|
||||
|
||||
void PersonPrice::setFromAge(int fromAge)
|
||||
{
|
||||
m_fromAge = fromAge;
|
||||
}
|
||||
|
||||
int PersonPrice::toAge() const
|
||||
{
|
||||
return m_toAge;
|
||||
}
|
||||
|
||||
void PersonPrice::setToAge(int toAge)
|
||||
{
|
||||
m_toAge = toAge;
|
||||
}
|
||||
|
||||
QDecDouble PersonPrice::price() const
|
||||
{
|
||||
return TO_DEC(m_price);
|
||||
}
|
||||
|
||||
void PersonPrice::setPrice(QDecDouble price)
|
||||
{
|
||||
m_price = FROM_DEC(price);
|
||||
}
|
||||
|
||||
bool PersonPrice::active() const
|
||||
{
|
||||
return m_active;
|
||||
}
|
||||
|
||||
void PersonPrice::setActive(bool active)
|
||||
{
|
||||
m_active = active;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#ifndef PERSONPRICE_H
|
||||
#define PERSONPRICE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDecDouble.hh>
|
||||
#include <odb/core.hxx>
|
||||
|
||||
#pragma db object
|
||||
class PersonPrice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString description READ description WRITE setDescription)
|
||||
Q_PROPERTY(int fromAge READ fromAge WRITE setFromAge)
|
||||
Q_PROPERTY(int toAge READ toAge WRITE setToAge)
|
||||
Q_PROPERTY(QDecDouble price READ price WRITE setPrice)
|
||||
Q_PROPERTY(bool active READ active WRITE setActive)
|
||||
|
||||
public:
|
||||
explicit PersonPrice(QObject *parent = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &description);
|
||||
|
||||
int fromAge() const;
|
||||
void setFromAge(int fromAge);
|
||||
|
||||
int toAge() const;
|
||||
void setToAge(int toAge);
|
||||
|
||||
QDecDouble price() const;
|
||||
void setPrice(QDecDouble price);
|
||||
|
||||
bool active() const;
|
||||
void setActive(bool active);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_description;
|
||||
int m_fromAge;
|
||||
int m_toAge;
|
||||
int m_price;
|
||||
bool m_active;
|
||||
};
|
||||
|
||||
#endif // PERSONPRICE_H
|
||||
@@ -0,0 +1,49 @@
|
||||
#include "sale.h"
|
||||
#include <define.h>
|
||||
|
||||
Sale::Sale(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_id = 0;
|
||||
m_sale = 0;
|
||||
m_fixed = false;
|
||||
}
|
||||
|
||||
int Sale::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
void Sale::setId(int id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
||||
QDecDouble Sale::sale() const
|
||||
{
|
||||
return TO_DEC(m_sale);
|
||||
}
|
||||
|
||||
void Sale::setSale(QDecDouble sale)
|
||||
{
|
||||
m_sale = FROM_DEC(sale);
|
||||
}
|
||||
|
||||
bool Sale::fixed() const
|
||||
{
|
||||
return m_fixed;
|
||||
}
|
||||
|
||||
void Sale::setFixed(bool fixed)
|
||||
{
|
||||
m_fixed = fixed;
|
||||
}
|
||||
|
||||
QString Sale::description() const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
void Sale::setDescription(const QString &description)
|
||||
{
|
||||
m_description = description;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef SALE_H
|
||||
#define SALE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <odb/core.hxx>
|
||||
#include <QDecDouble.hh>
|
||||
|
||||
#pragma db object
|
||||
class Sale : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
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 = 0);
|
||||
|
||||
int id() const;
|
||||
void setId(int id);
|
||||
|
||||
QDecDouble sale() const;
|
||||
void setSale(QDecDouble sale);
|
||||
|
||||
bool fixed() const;
|
||||
void setFixed(bool fixed);
|
||||
|
||||
QString description() const;
|
||||
void setDescription(const QString &description);
|
||||
|
||||
private:
|
||||
friend class odb::access;
|
||||
#pragma db id auto
|
||||
int m_id;
|
||||
QString m_description;
|
||||
int m_sale;
|
||||
bool m_fixed;
|
||||
};
|
||||
|
||||
#endif // SALE_H
|
||||
@@ -3,7 +3,10 @@
|
||||
|
||||
ServiceItem::ServiceItem(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
m_id = 0;
|
||||
m_salePossible = false;
|
||||
m_price = 0;
|
||||
m_type = AccService::OTHER;
|
||||
}
|
||||
|
||||
int ServiceItem::id() const
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "campsettings.h"
|
||||
#include <define.h>
|
||||
#include <QDebug>
|
||||
|
||||
CampSettings::CampSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
m_accFee = 0;
|
||||
m_rounding = Enums::R_MATH;
|
||||
m_decimalPlaces = 0;
|
||||
}
|
||||
|
||||
QDecDouble CampSettings::accFee() const
|
||||
{
|
||||
return TO_DEC(m_accFee);
|
||||
}
|
||||
|
||||
void CampSettings::setAccFee(QDecDouble accFee)
|
||||
{
|
||||
m_accFee = FROM_DEC(accFee);
|
||||
}
|
||||
|
||||
Enums::Rounding CampSettings::rounding() const
|
||||
{
|
||||
return m_rounding;
|
||||
}
|
||||
|
||||
void CampSettings::setRounding(const Enums::Rounding &rounding)
|
||||
{
|
||||
m_rounding = rounding;
|
||||
}
|
||||
|
||||
int CampSettings::decimalPlaces() const
|
||||
{
|
||||
return m_decimalPlaces;
|
||||
}
|
||||
|
||||
void CampSettings::setDecimalPlaces(int decimalPlaces)
|
||||
{
|
||||
m_decimalPlaces = decimalPlaces;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
#ifndef CAMPSETTINGS_H
|
||||
#define CAMPSETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <enums.h>
|
||||
#include <QDecDouble.hh>
|
||||
#include <QSharedPointer>
|
||||
|
||||
class CampSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QDecDouble accFee READ accFee WRITE setAccFee)
|
||||
Q_PROPERTY(Enums::Rounding rounding READ rounding WRITE setRounding)
|
||||
Q_PROPERTY(int decimalPlaces READ decimalPlaces WRITE setDecimalPlaces)
|
||||
|
||||
public:
|
||||
explicit CampSettings(QObject *parent = 0);
|
||||
|
||||
QDecDouble accFee() const;
|
||||
void setAccFee(QDecDouble accFee);
|
||||
|
||||
Enums::Rounding rounding() const;
|
||||
void setRounding(const Enums::Rounding &rounding);
|
||||
|
||||
int decimalPlaces() const;
|
||||
void setDecimalPlaces(int decimalPlaces);
|
||||
|
||||
private:
|
||||
int m_accFee;
|
||||
Enums::Rounding m_rounding;
|
||||
int m_decimalPlaces;
|
||||
};
|
||||
|
||||
typedef QSharedPointer<CampSettings> CampSettingsPtr;
|
||||
|
||||
#endif // CAMPSETTINGS_H
|
||||
@@ -0,0 +1,137 @@
|
||||
#include "camp-odb.hxx"
|
||||
#include "campsettingsform.h"
|
||||
#include "ui_campsettingsform.h"
|
||||
|
||||
#include <settingsservice.h>
|
||||
#include <QScroller>
|
||||
|
||||
CampSettingsForm::CampSettingsForm(QWidget *parent) :
|
||||
FormBinder<CampSettings>(parent),
|
||||
ui(new Ui::CampSettingsForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
m_personPriceModel = new AutoTableModel<PersonPrice>();
|
||||
m_personPriceModel->setEditableCols(QList<int>() << 0 << 1 << 2 << 3);
|
||||
m_saleModel = new AutoTableModel<Sale>();
|
||||
m_saleModel->setEditableCols(QList<int>() << 0 << 1 << 2);
|
||||
|
||||
ui->tablePersonPrices->setModel(m_personPriceModel);
|
||||
ui->tableSales->setModel(m_saleModel);
|
||||
|
||||
ui->tablePersonPrices->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tableSales->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
|
||||
QScroller::grabGesture(ui->tablePersonPrices, QScroller::LeftMouseButtonGesture);
|
||||
QScroller::grabGesture(ui->tableSales, QScroller::LeftMouseButtonGesture);
|
||||
|
||||
connect(ui->tablePersonPrices->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](){
|
||||
ui->btnPriceDisable->setEnabled(ui->tablePersonPrices->currentIndex().isValid());
|
||||
ui->btnPriceRemove->setEnabled(ui->tablePersonPrices->currentIndex().isValid());
|
||||
ui->btnPriceDisable->setChecked(m_personPriceModel->itemFromIndex(ui->tablePersonPrices->currentIndex())->active());
|
||||
});
|
||||
|
||||
connect(ui->tableSales->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](){
|
||||
ui->btnSaleRemove->setEnabled(ui->tableSales->currentIndex().isValid());
|
||||
});
|
||||
|
||||
registerBinding(ui->accFee);
|
||||
registerBinding(ui->decimalPlaces);
|
||||
QList<ComboData> roundings ;
|
||||
roundings << ComboData(Enums::R_NONE, tr("None"))
|
||||
<< ComboData(Enums::R_UP, tr("Up"))
|
||||
<< ComboData(Enums::R_DOWN, tr("Down"))
|
||||
<< ComboData(Enums::R_MATH, tr("Mathematic"));
|
||||
registerBinding(ui->rounding, roundings);
|
||||
}
|
||||
|
||||
CampSettingsForm::~CampSettingsForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool CampSettingsForm::saveRecord()
|
||||
{
|
||||
bindToData();
|
||||
SettingsService srv("CAMP");
|
||||
srv.saveSettings(entity());
|
||||
|
||||
Service<PersonPrice> personSrv;
|
||||
Service<Sale> saleSrv;
|
||||
|
||||
foreach (PersonPricePtr p, personSrv.all()) {
|
||||
personSrv.erase(p);
|
||||
}
|
||||
|
||||
foreach (PersonPricePtr p, m_personPriceModel->list()) {
|
||||
personSrv.save(p);
|
||||
}
|
||||
|
||||
foreach (SalePtr s, saleSrv.all()) {
|
||||
saleSrv.erase(s);
|
||||
}
|
||||
|
||||
foreach (SalePtr s, m_saleModel->list()) {
|
||||
saleSrv.save(s);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CampSettingsForm::loadEntity()
|
||||
{
|
||||
SettingsService srv("CAMP");
|
||||
CampSettingsPtr settings = srv.loadSettings<CampSettings>();
|
||||
setEntity(settings);
|
||||
|
||||
Service<PersonPrice> personSrv;
|
||||
Service<Sale> saleSrv;
|
||||
|
||||
m_personPriceModel->setData(personSrv.all());
|
||||
m_saleModel->setData(saleSrv.all());
|
||||
|
||||
ui->btnPriceDisable->setEnabled(false);
|
||||
ui->btnPriceRemove->setEnabled(false);
|
||||
ui->btnSaleRemove->setEnabled(false);
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnPriceAdd_clicked()
|
||||
{
|
||||
PersonPricePtr price(new PersonPrice());
|
||||
m_personPriceModel->addRow(price);
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnSaleAdd_clicked()
|
||||
{
|
||||
SalePtr sale(new Sale());
|
||||
m_saleModel->addRow(sale);
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnPriceRemove_clicked()
|
||||
{
|
||||
m_personPriceModel->removeRowAt(ui->tablePersonPrices->currentIndex());
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnPriceDisable_clicked()
|
||||
{
|
||||
PersonPricePtr price = m_personPriceModel->itemFromIndex(ui->tablePersonPrices->currentIndex());
|
||||
price->setActive(!price->active());
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnPriceFilter_clicked()
|
||||
{
|
||||
Service<PersonPrice> srv;
|
||||
if (ui->btnPriceFilter->isChecked())
|
||||
{
|
||||
m_personPriceModel->setData(srv.all("active = 1"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_personPriceModel->setData(srv.all());
|
||||
}
|
||||
}
|
||||
|
||||
void CampSettingsForm::on_btnSaleRemove_clicked()
|
||||
{
|
||||
m_saleModel->removeRowAt(ui->tableSales->currentIndex());
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
#ifndef CAMPSETTINGSFORM_H
|
||||
#define CAMPSETTINGSFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
|
||||
#include "campsettings.h"
|
||||
#include "data/camp-data.h"
|
||||
#include <formbinder.h>
|
||||
#include <autotablemodel.h>
|
||||
|
||||
namespace Ui {
|
||||
class CampSettingsForm;
|
||||
}
|
||||
|
||||
class CampSettingsForm : public FormBinder<CampSettings>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CampSettingsForm(QWidget *parent = 0);
|
||||
~CampSettingsForm();
|
||||
|
||||
// IForm interface
|
||||
public slots:
|
||||
bool saveRecord();
|
||||
|
||||
// IForm interface
|
||||
public:
|
||||
void loadEntity();
|
||||
|
||||
private slots:
|
||||
void on_btnPriceAdd_clicked();
|
||||
|
||||
void on_btnSaleAdd_clicked();
|
||||
|
||||
void on_btnPriceRemove_clicked();
|
||||
|
||||
void on_btnPriceDisable_clicked();
|
||||
|
||||
void on_btnPriceFilter_clicked();
|
||||
|
||||
void on_btnSaleRemove_clicked();
|
||||
|
||||
private:
|
||||
Ui::CampSettingsForm *ui;
|
||||
AutoTableModel<PersonPrice> *m_personPriceModel;
|
||||
AutoTableModel<Sale> *m_saleModel;
|
||||
};
|
||||
|
||||
#endif // CAMPSETTINGSFORM_H
|
||||
@@ -0,0 +1,282 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CampSettingsForm</class>
|
||||
<widget class="QWidget" name="CampSettingsForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>696</width>
|
||||
<height>489</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Person prices</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPriceAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPriceRemove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/remove.svg</normaloff>:/icons/remove.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPriceDisable">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Deactivate</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/ok.svg</normaloff>:/icons/ok.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnPriceFilter">
|
||||
<property name="toolTip">
|
||||
<string>Filter active</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/filter.svg</normaloff>:/icons/filter.svg</iconset>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tablePersonPrices"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Sales</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_2" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSaleAdd">
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/new.svg</normaloff>:/icons/new.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnSaleRemove">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../core/rc.qrc">
|
||||
<normaloff>:/icons/remove.svg</normaloff>:/icons/remove.svg</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableView" name="tableSales"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Other settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Accommodation fee</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Rounding</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="rounding"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="decimalPlaceslab">
|
||||
<property name="text">
|
||||
<string>Decimal places</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="decimalPlaces">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>100000.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="accFee">
|
||||
<property name="buttonSymbols">
|
||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>99999.990000000005239</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../core/rc.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user