Added edit and pay functionality to camp module.
This commit is contained in:
+31
-2
@@ -195,6 +195,8 @@ CampWizard::CampWizard(QWidget *parent) :
|
||||
ui->tabServices->hideColumn(6);
|
||||
ui->tabServices->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
ui->tabServices->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
|
||||
|
||||
m_newRecord = false;
|
||||
}
|
||||
|
||||
CampWizard::~CampWizard()
|
||||
@@ -212,6 +214,9 @@ void CampWizard::setData(const CampDataPtr &data)
|
||||
|
||||
m_peopleModel->setData(data->people());
|
||||
m_itemsModel->setData(data->services());
|
||||
|
||||
ui->sale_2->setValue(m_data->sale().toDouble());
|
||||
ui->lblSale->setText(m_data->fixedSale() ? tr("Fixed amound") : tr("%"));
|
||||
}
|
||||
|
||||
void CampWizard::on_btnAdd_clicked()
|
||||
@@ -357,6 +362,22 @@ void CampWizard::on_sale_currentIndexChanged(int)
|
||||
applySale();
|
||||
}
|
||||
|
||||
void CampWizard::setNewRecord(bool newRecord)
|
||||
{
|
||||
m_newRecord = newRecord;
|
||||
|
||||
if (newRecord)
|
||||
{
|
||||
ui->wSale->setVisible(false);
|
||||
ui->checkSale->setText(tr("Apply sale"));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->wSale->setVisible(true);
|
||||
ui->checkSale->setText(tr("Change"));
|
||||
}
|
||||
}
|
||||
|
||||
bool CampWizard::validateCurrentPage()
|
||||
{
|
||||
m_dataBinder->bindToData();
|
||||
@@ -385,7 +406,6 @@ bool CampWizard::validateCurrentPage()
|
||||
void CampWizard::accept()
|
||||
{
|
||||
CampService srv;
|
||||
srv.saveCamp(m_data);
|
||||
bool success = true;
|
||||
|
||||
connect(&srv, &IService::dbError, [this, &success](QString msg){
|
||||
@@ -394,10 +414,19 @@ void CampWizard::accept()
|
||||
});
|
||||
|
||||
connect(&srv, &IService::permissionDenied, [this, &success](QString msg){
|
||||
QMessageBox::critical(this, "Permission denied", msg.toStdString().c_str());
|
||||
QMessageBox::critical(this, tr("Permission denied"), msg.toStdString().c_str());
|
||||
success = false;
|
||||
});
|
||||
|
||||
if (m_newRecord)
|
||||
{
|
||||
srv.saveCamp(m_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
srv.updateCamp(m_data);
|
||||
}
|
||||
|
||||
if (success)
|
||||
{
|
||||
QDialog::accept();
|
||||
|
||||
Reference in New Issue
Block a user