Fixed camp settings saving. Added about messagebox. Methods IGridForm::handleNewRecord and IGridForm::handleEditRecord are virtual now.

master
Josef Rokos 8 years ago
parent d5ead1b187
commit cd4d58749a

@ -178,3 +178,13 @@ void MainWindow::on_actionCountry_register_triggered()
} }
} }
void MainWindow::on_actionAbout_Qt_triggered()
{
QMessageBox::aboutQt(this);
}
void MainWindow::on_actionAbout_triggered()
{
QMessageBox::about(this, tr("About prodejna"), tr("Modular cash register software under GPL license.\n(C) 2015 - 2017 Josef Rokos, Zdenek Jonák"));
}

@ -39,6 +39,10 @@ private slots:
void on_actionCountry_register_triggered(); void on_actionCountry_register_triggered();
void on_actionAbout_Qt_triggered();
void on_actionAbout_triggered();
private: private:
Ui::MainWindow *ui; Ui::MainWindow *ui;
LoginDialog *m_loginDialog; LoginDialog *m_loginDialog;

@ -60,7 +60,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1000</width> <width>1000</width>
<height>20</height> <height>25</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
@ -79,8 +79,16 @@
<addaction name="actionPost_register"/> <addaction name="actionPost_register"/>
<addaction name="actionCountry_register"/> <addaction name="actionCountry_register"/>
</widget> </widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
<string>Help</string>
</property>
<addaction name="actionAbout"/>
<addaction name="actionAbout_Qt"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuRegisters"/> <addaction name="menuRegisters"/>
<addaction name="menuHelp"/>
</widget> </widget>
<widget class="QToolBar" name="mainToolBar"> <widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea"> <attribute name="toolBarArea">
@ -126,12 +134,22 @@
</action> </action>
<action name="actionPost_register"> <action name="actionPost_register">
<property name="text"> <property name="text">
<string>Post register</string> <string>&amp;Post register</string>
</property> </property>
</action> </action>
<action name="actionCountry_register"> <action name="actionCountry_register">
<property name="text"> <property name="text">
<string>Country register</string> <string>&amp;Country register</string>
</property>
</action>
<action name="actionAbout">
<property name="text">
<string>About</string>
</property>
</action>
<action name="actionAbout_Qt">
<property name="text">
<string>About Qt</string>
</property> </property>
</action> </action>
</widget> </widget>

@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>CampForm</class> <class>CampForm</class>
<widget class="QWidget" name="CampForm"> <widget class="QWidget" name="CampForm">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>462</width>
<height>300</height> <height>403</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
</widget> </widget>
<pixmapfunction/> <resources/>
<connections/> <connections/>
</ui> </ui>

@ -4,6 +4,7 @@
#include <settingsservice.h> #include <settingsservice.h>
#include <QScroller> #include <QScroller>
#include <QMessageBox>
CampSettingsForm::CampSettingsForm(QWidget *parent) : CampSettingsForm::CampSettingsForm(QWidget *parent) :
FormBinder<CampSettings>(parent), FormBinder<CampSettings>(parent),
@ -58,13 +59,47 @@ bool CampSettingsForm::saveRecord()
Service<PersonPrice> personSrv; Service<PersonPrice> personSrv;
Service<Sale> saleSrv; Service<Sale> saleSrv;
bool ret = true;
connect(&personSrv, &IService::dbErrorDelete, [&ret, this](QString){
QMessageBox::critical(this, tr("Cannot delete"), tr("Price already used"));
ret = false;
});
foreach (PersonPricePtr p, personSrv.all()) { foreach (PersonPricePtr p, personSrv.all()) {
personSrv.erase(p); bool found = false;
foreach (PersonPricePtr price, m_personPriceModel->list()) {
if (price->id() == p->id())
{
found = true;
break;
}
}
if (!found)
{
personSrv.erase(p);
}
} }
foreach (PersonPricePtr p, m_personPriceModel->list()) { foreach (PersonPricePtr p, m_personPriceModel->list()) {
personSrv.save(p); bool found = false;
foreach (PersonPricePtr price, personSrv.all()) {
if (price->id() == p->id())
{
found = true;
break;
}
}
if (!found)
{
personSrv.save(p);
}
else
{
personSrv.update(p);
}
} }
foreach (SalePtr s, saleSrv.all()) { foreach (SalePtr s, saleSrv.all()) {
@ -75,7 +110,7 @@ bool CampSettingsForm::saveRecord()
saleSrv.save(s); saleSrv.save(s);
} }
return true; return ret;
} }
void CampSettingsForm::loadEntity() void CampSettingsForm::loadEntity()

@ -173,7 +173,7 @@ private slots:
// IGridForm interface // IGridForm interface
protected: protected:
void handleNewRecord() override virtual void handleNewRecord() override
{ {
if (m_form == NULL) if (m_form == NULL)
{ {
@ -186,7 +186,7 @@ protected:
m_formHandler->showForm(m_form); m_formHandler->showForm(m_form);
} }
void handleEditRecord() override virtual void handleEditRecord() override
{ {
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0) if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)
{ {

Loading…
Cancel
Save