Implemented base functionality for commodity grid on shop form.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "commodityform.h"
|
||||
#include "commoditygrid.h"
|
||||
#include "commoditysettingsform.h"
|
||||
#include "commodityservice.h"
|
||||
|
||||
Commodity::Commodity()
|
||||
{
|
||||
@@ -13,7 +14,7 @@ void Commodity::initServiceUi()
|
||||
CommodityGrid *grid = new CommodityGrid();
|
||||
CommodityForm *form = new CommodityForm();
|
||||
|
||||
m_service = new Service<CommodityData>;
|
||||
m_service = new CommodityService();
|
||||
m_ui = grid;
|
||||
((CommodityGrid *) m_ui)->setForm(form);
|
||||
m_settingsUi = new CommoditySettingsForm();
|
||||
|
||||
+12
-2
@@ -20,7 +20,8 @@ SOURCES += commodity.cpp \
|
||||
commoditytablemodel.cpp \
|
||||
commodityform.cpp \
|
||||
commoditygrid.cpp \
|
||||
commoditysettingsform.cpp
|
||||
commoditysettingsform.cpp \
|
||||
commodityservice.cpp
|
||||
|
||||
HEADERS += commodity.h\
|
||||
commodity_global.h \
|
||||
@@ -30,7 +31,8 @@ HEADERS += commodity.h\
|
||||
commoditytablemodel.h \
|
||||
commodityform.h \
|
||||
commoditygrid.h \
|
||||
commoditysettingsform.h
|
||||
commoditysettingsform.h \
|
||||
commodityservice.h
|
||||
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
@@ -53,6 +55,7 @@ DESTDIR = ../plugins
|
||||
|
||||
ODB_FILES = commodity/data/commodity-data.h
|
||||
H_DIR = $$PWD/data/*.h
|
||||
ODB_OTHER_INCLUDES = -I $$PWD/../shop
|
||||
include(../odb.pri)
|
||||
|
||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../qdecimal/lib/ -lqdecimal -ldecnumber
|
||||
@@ -73,3 +76,10 @@ FORMS += \
|
||||
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
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "commodityservice.h"
|
||||
|
||||
#include "commodity-odb.hxx"
|
||||
|
||||
CommodityService::CommodityService()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QList<QSharedPointer<ShopItem> > CommodityService::shopItems()
|
||||
{
|
||||
QList<QSharedPointer<ShopItem> > ret;
|
||||
|
||||
foreach (QSharedPointer<CommodityData> data, all()) {
|
||||
ret.append(qSharedPointerDynamicCast<ShopItem, CommodityData>(data));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef COMMODITYSERVICE_H
|
||||
#define COMMODITYSERVICE_H
|
||||
|
||||
#include <service.h>
|
||||
#include <isellableservice.h>
|
||||
#include "data/commodity-data.h"
|
||||
|
||||
class CommodityService : public Service<CommodityData>, public ISellableService
|
||||
{
|
||||
public:
|
||||
CommodityService();
|
||||
|
||||
// ISellableService interface
|
||||
public:
|
||||
QList<QSharedPointer<ShopItem> > shopItems() override;
|
||||
};
|
||||
|
||||
#endif // COMMODITYSERVICE_H
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <define.h>
|
||||
|
||||
CommodityData::CommodityData(QObject *parent)
|
||||
:QObject(parent)
|
||||
:ShopItem(parent)
|
||||
{
|
||||
m_count = 0;
|
||||
m_price = 0;
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
#include <QString>
|
||||
#include <odb/core.hxx>
|
||||
#include "commoditytypedata.h"
|
||||
#include <shopitem.h>
|
||||
#include <QDecDouble.hh>
|
||||
#include <QSharedDataPointer>
|
||||
#include <enums.h>
|
||||
|
||||
#pragma db object
|
||||
class CommodityData : public QObject
|
||||
class CommodityData : public ShopItem
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
|
||||
Reference in New Issue
Block a user