Added support for settings
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
#include "globalsettings.h"
|
||||
|
||||
GlobalSettings::GlobalSettings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString GlobalSettings::firmName() const
|
||||
{
|
||||
return m_firmName;
|
||||
}
|
||||
|
||||
void GlobalSettings::setFirmName(const QString &firmName)
|
||||
{
|
||||
m_firmName = firmName;
|
||||
}
|
||||
|
||||
QString GlobalSettings::street() const
|
||||
{
|
||||
return m_street;
|
||||
}
|
||||
|
||||
void GlobalSettings::setStreet(const QString &street)
|
||||
{
|
||||
m_street = street;
|
||||
}
|
||||
|
||||
QString GlobalSettings::houseNumber() const
|
||||
{
|
||||
return m_houseNumber;
|
||||
}
|
||||
|
||||
void GlobalSettings::setHouseNumber(const QString &houseNumber)
|
||||
{
|
||||
m_houseNumber = houseNumber;
|
||||
}
|
||||
|
||||
QString GlobalSettings::zipCode() const
|
||||
{
|
||||
return m_zipCode;
|
||||
}
|
||||
|
||||
void GlobalSettings::setZipCode(const QString &zipCode)
|
||||
{
|
||||
m_zipCode = zipCode;
|
||||
}
|
||||
|
||||
QString GlobalSettings::city() const
|
||||
{
|
||||
return m_city;
|
||||
}
|
||||
|
||||
void GlobalSettings::setCity(const QString &city)
|
||||
{
|
||||
m_city = city;
|
||||
}
|
||||
|
||||
int GlobalSettings::ic() const
|
||||
{
|
||||
return m_ic;
|
||||
}
|
||||
|
||||
void GlobalSettings::setIc(int IC)
|
||||
{
|
||||
m_ic = IC;
|
||||
}
|
||||
|
||||
QString GlobalSettings::dic() const
|
||||
{
|
||||
return m_dic;
|
||||
}
|
||||
|
||||
void GlobalSettings::setDic(const QString &dic)
|
||||
{
|
||||
m_dic = dic;
|
||||
}
|
||||
|
||||
bool GlobalSettings::vatPayer() const
|
||||
{
|
||||
return m_vatPayer;
|
||||
}
|
||||
|
||||
void GlobalSettings::setVatPayer(bool vatPayer)
|
||||
{
|
||||
m_vatPayer = vatPayer;
|
||||
}
|
||||
|
||||
QString GlobalSettings::logoPath() const
|
||||
{
|
||||
return m_logoPath;
|
||||
}
|
||||
|
||||
void GlobalSettings::setLogoPath(const QString &logoPath)
|
||||
{
|
||||
m_logoPath = logoPath;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
#ifndef GLOBALSETTINGS_H
|
||||
#define GLOBALSETTINGS_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class GlobalSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString firmName READ firmName WRITE setFirmName)
|
||||
Q_PROPERTY(QString street READ street WRITE setStreet)
|
||||
Q_PROPERTY(QString houseNumber READ houseNumber WRITE setHouseNumber)
|
||||
Q_PROPERTY(QString zipCode READ zipCode WRITE setZipCode)
|
||||
Q_PROPERTY(QString city READ city WRITE setCity)
|
||||
Q_PROPERTY(int ic READ ic WRITE setIc)
|
||||
Q_PROPERTY(QString dic READ dic WRITE setDic)
|
||||
Q_PROPERTY(bool vatPayer READ vatPayer WRITE setVatPayer)
|
||||
Q_PROPERTY(QString logoPath READ logoPath WRITE setLogoPath)
|
||||
public:
|
||||
explicit GlobalSettings(QObject *parent = 0);
|
||||
|
||||
QString firmName() const;
|
||||
void setFirmName(const QString &firmName);
|
||||
|
||||
QString street() const;
|
||||
void setStreet(const QString &street);
|
||||
|
||||
QString houseNumber() const;
|
||||
void setHouseNumber(const QString &houseNumber);
|
||||
|
||||
QString zipCode() const;
|
||||
void setZipCode(const QString &zipCode);
|
||||
|
||||
QString city() const;
|
||||
void setCity(const QString &city);
|
||||
|
||||
int ic() const;
|
||||
void setIc(int ic);
|
||||
|
||||
QString dic() const;
|
||||
void setDic(const QString &dic);
|
||||
|
||||
bool vatPayer() const;
|
||||
void setVatPayer(bool vatPayer);
|
||||
|
||||
QString logoPath() const;
|
||||
void setLogoPath(const QString &logoPath);
|
||||
|
||||
private:
|
||||
QString m_firmName;
|
||||
QString m_street;
|
||||
QString m_houseNumber;
|
||||
QString m_zipCode;
|
||||
QString m_city;
|
||||
int m_ic;
|
||||
QString m_dic;
|
||||
bool m_vatPayer;
|
||||
QString m_logoPath;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // GLOBALSETTINGS_H
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "globalsettingsform.h"
|
||||
#include "ui_globalsettingsform.h"
|
||||
|
||||
#include "globalsettings.h"
|
||||
#include "../settingsservice.h"
|
||||
|
||||
GlobalSettingsForm::GlobalSettingsForm(QWidget *parent) :
|
||||
FormBinder<GlobalSettings>(parent),
|
||||
ui(new Ui::GlobalSettingsForm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
registerBinding(ui->firmName);
|
||||
registerBinding(ui->street);
|
||||
registerBinding(ui->houseNumber);
|
||||
registerBinding(ui->zipCode);
|
||||
registerBinding(ui->city);
|
||||
registerBinding(ui->ic);
|
||||
registerBinding(ui->vatPayer);
|
||||
registerBinding(ui->dic);
|
||||
}
|
||||
|
||||
GlobalSettingsForm::~GlobalSettingsForm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool GlobalSettingsForm::saveRecord()
|
||||
{
|
||||
bindToData();
|
||||
SettingsService srv("CORE");
|
||||
srv.saveSettings(entity());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GlobalSettingsForm::loadEntity()
|
||||
{
|
||||
SettingsService srv("CORE");
|
||||
QSharedPointer<GlobalSettings> settings = srv.loadSettings<GlobalSettings>();
|
||||
setEntity(settings);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#ifndef GLOBALSETTINGSFORM_H
|
||||
#define GLOBALSETTINGSFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "../formbinder.h"
|
||||
#include "globalsettings.h"
|
||||
|
||||
namespace Ui {
|
||||
class GlobalSettingsForm;
|
||||
}
|
||||
|
||||
class GlobalSettingsForm : public FormBinder<GlobalSettings>
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GlobalSettingsForm(QWidget *parent = 0);
|
||||
~GlobalSettingsForm();
|
||||
|
||||
private:
|
||||
Ui::GlobalSettingsForm *ui;
|
||||
|
||||
// IForm interface
|
||||
public slots:
|
||||
bool saveRecord() override;
|
||||
|
||||
// IForm interface
|
||||
public:
|
||||
void loadEntity() override;
|
||||
};
|
||||
|
||||
#endif // GLOBALSETTINGSFORM_H
|
||||
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GlobalSettingsForm</class>
|
||||
<widget class="QWidget" name="GlobalSettingsForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>422</width>
|
||||
<height>323</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Company info</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>IC</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="ic"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>VAT number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="dic"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="vatPayer">
|
||||
<property name="text">
|
||||
<string>VAT payer</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Contact</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Firm Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="firmName"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Street</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="street"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>House Number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="houseNumber"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>City</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="city"/>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>ZIP code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="zipCode"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="title">
|
||||
<string>Logo</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Logo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Select file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user