Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 5c360b9d93
Fetching contributors…

Cannot retrieve contributors at this time

766 lines (668 sloc) 23.559 kB
/**
* c-project - a digital registry.
* Copyright (c) 2010, Nycholas de Oliveira e Oliveira <nycholas@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the Nycholas de Oliveira e Oliveira nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "coupon.h"
CouponForm::CouponForm(CouponModel *model, QDialog *parent) :
QDialog(parent) {
setupUi(this);
couponModel = model;
statusTimer = new QTimer(this);
actStatusTimer = new QTimer(this);
actCreateModels();
actCreateViews();
actCouponCreateModels();
actCouponCreateViews();
actCreateActions();
createActions();
actUpdateModels();
actCouponCreateActions();
actCreateSearchAdvanceWidget();
actCouponUpdateModels();
actCouponUpdateWidgets();
actUpdateWidgets();
updateWidgets();
}
CouponForm::~CouponForm(void) {
}
void CouponForm::timerStatusAction(void) {
actStatusLabel->hide();
actStatusLabel->setText("");
}
void CouponForm::nextAction(void) {
qDebug() << "next";
QSqlQuery query = couponModel->query();
if (!query.next())
return;
int idCol = query.record().indexOf("id");
if (query.next()) {
couponModel->setId(query.value(idCol).toInt());
qDebug() << "next>>" << couponModel->getId();
}
select();
int begin = couponModel->begin();
int sizeAll = couponModel->count();
int size = couponModel->query().size();
nextPushButton->setEnabled(begin > 0);
previousPushButton->setEnabled(sizeAll > (size + begin));
}
void CouponForm::previousAction(void) {
qDebug() << "pre";
QSqlQuery query = couponModel->query();
if (!query.previous())
return;
int idCol = query.record().indexOf("id");
if (query.next()) {
couponModel->setId(query.value(idCol).toInt());
qDebug() << "pre>>" << couponModel->getId();
}
select();
int begin = couponModel->begin();
int sizeAll = couponModel->count();
int size = couponModel->query().size();
nextPushButton->setEnabled(begin > 0);
previousPushButton->setEnabled(sizeAll > (size + begin));
}
void CouponForm::saveAction(void) {
if (!save()) {
errorStatus(qApp->tr("Failure trying to register the record."));
} else {
if (couponModel->getId() > 0) {
emit formChanged();
emit sendStatus(QString(qApp->tr(
"The coupon \"%1\" was changed successfully.")).arg(
couponModel->getName()), 0);
} else {
emit formAdded();
emit sendStatus(QString(qApp->tr(
"The coupon \"%1\" was added successfully.")).arg(
couponModel->getName()), 0);
}
couponModel->setId(0);
updateModels();
updateForms();
close();
}
}
void CouponForm::saveAndContinueSavingAction(void) {
if (!save()) {
errorStatus(qApp->tr("Failure trying to register the record."));
} else {
if (couponModel->getId() > 0) {
emit formChanged();
okStatus(QString(qApp->tr(
"The coupon \"%1\" was changed successfully.")).arg(
couponModel->getName()));
} else {
emit formAdded();
okStatus(QString(qApp->tr(
"The coupon \"%1\" was added successfully.")).arg(
couponModel->getName()));
}
couponModel->setId(0);
updateModels();
updateForms();
}
}
void CouponForm::removeAction(void) {
QMessageBox msgBox;
msgBox.setText(qApp->tr("Are you sure?"));
msgBox.setInformativeText(QString(qApp->tr(
"Are you sure you want to delete the selected coupon objects?\n"
"All of the following objects and their related items will be "
"deleted:\n\nCoupon: %1\n").arg(couponModel->getName())));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No
| QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Cancel) {
updateModels();
updateForms();
close();
return;
} else if (ret == QMessageBox::No)
return;
if (!remove()) {
errorStatus(qApp->tr("Fails to remove the record."));
} else {
QMessageBox::information(0, qApp->tr("Coupon deleted"), QString(
qApp->tr("Successfully deleted %1 coupon.")).arg("1"),
QMessageBox::Ok);
emit
formDeleted();
emit
sendStatus(
QString(qApp->tr("Successfully deleted %1 coupon.")).arg("1"),
0);
couponModel->setId(0);
updateModels();
updateForms();
close();
}
}
void CouponForm::cancelAction(void) {
close();
}
void CouponForm::createActions(void) {
connect(statusTimer, SIGNAL(timeout()), this, SLOT(timerStatusAction()));
connect(nextPushButton, SIGNAL(released()), this, SLOT(nextAction()));
connect(previousPushButton, SIGNAL(released()), this,
SLOT(previousAction()));
connect(savePushButton, SIGNAL(released()), this, SLOT(saveAction()));
connect(saveAndContinueSavingPushButton, SIGNAL(released()), this, SLOT(
saveAndContinueSavingAction()));
connect(removePushButton, SIGNAL(released()), this, SLOT(removeAction()));
connect(cancelPushButton, SIGNAL(released()), this, SLOT(cancelAction()));
}
void CouponForm::updateWidgets(void) {
updateForms();
actStatusLabel->hide();
}
void CouponForm::updateModels(void) {
couponModel = new CouponModel(couponModel->getId(), this);
int begin = couponModel->begin();
int sizeAll = couponModel->count();
int size = couponModel->query().size();
nextPushButton->setEnabled(begin > 0);
previousPushButton->setEnabled(sizeAll > (size + begin));
}
void CouponForm::updateForms(void) {
clear();
focusDefault();
if (couponModel->getId() > 0) {
select();
titleLabel->setText(qApp->tr("Change Coupon"));
couponGroupBox->setTitle(qApp->tr("&Coupon details"));
savePushButton->setText(qApp->tr("&Update"));
saveAndContinueSavingPushButton->setText(qApp->tr(
"Update and &continue saving"));
removePushButton->show();
} else {
titleLabel->setText(qApp->tr("Add Coupon"));
couponGroupBox->setTitle(qApp->tr("&Coupon details"));
savePushButton->setText(qApp->tr("&Save"));
saveAndContinueSavingPushButton->setText(qApp->tr(
"Save and &continue saving"));
removePushButton->hide();
}
nextPushButton->hide();
previousPushButton->hide();
savePushButton->setDefault(true);
}
void CouponForm::select(void) {
CouponModel::selectById(couponModel->getId(), couponModel);
nameLineEdit->setText(couponModel->getName());
descriptionTextEdit->setText(couponModel->getDescription());
isActiveCheckBox->setChecked(couponModel->getIsActive());
}
bool CouponForm::save(void) {
couponModel->setName(nameLineEdit->text());
couponModel->setDescription(descriptionTextEdit->toPlainText());
couponModel->setDateJoined(QDateTime::currentDateTime());
couponModel->setIsActive(isActiveCheckBox->isChecked() ? 1 : 0);
return couponModel->save();
}
bool CouponForm::remove(void) {
return couponModel->remove();
}
void CouponForm::clear(void) {
nameLineEdit->clear();
descriptionTextEdit->clear();
isActiveCheckBox->setChecked(true);
}
void CouponForm::focusDefault(void) {
nameLineEdit->setFocus();
}
void CouponForm::timerStatus(void) {
statusTimer->start(3000);
}
void CouponForm::okStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: green; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid green;");
actStatusLabel->show();
timerStatus();
}
void CouponForm::infoStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: blue; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid blue;");
actStatusLabel->show();
timerStatus();
}
void CouponForm::alertStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: yellow; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid yellow;");
actStatusLabel->show();
timerStatus();
}
void CouponForm::errorStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: red; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid red;");
actStatusLabel->show();
timerStatus();
}
/**
* act
*/
void CouponForm::actTimerStatusAction(void) {
actStatusLabel->hide();
actStatusLabel->setText("");
}
void CouponForm::actNewAction(void) {
actModel->setId(0);
ActForm *form = new ActForm(actModel);
connect(form, SIGNAL(formAdded()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formChanged()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formDeleted()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(sendStatus(const QString &, int)), this,
SLOT(actUpdateStatus(const QString &, int)));
form->show();
}
void CouponForm::actActivateAction(void) {
QModelIndex index = actTableView->currentIndex();
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actModel->record(index.row());
int id = record.value(act_id).toInt();
ActModel *m = new ActModel(0, this);
ActModel::selectById(id, m);
m->setDateChanged(QDateTime::currentDateTime());
m->setIsActive(1);
if (!m->status()) {
actErrorStatus(qApp->tr("Failure trying to register the record."));
return;
}
actOkStatus(qApp->tr("Successfully changed act."));
actUpdateModels();
}
void CouponForm::actDesactivateAction(void) {
QModelIndex index = actTableView->currentIndex();
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actModel->record(index.row());
int id = record.value(act_id).toInt();
ActModel *m = new ActModel(0, this);
ActModel::selectById(id, m);
m->setDateChanged(QDateTime::currentDateTime());
m->setIsActive(0);
if (!m->status()) {
actErrorStatus(qApp->tr("Failure trying to register the record."));
return;
}
actOkStatus(qApp->tr("Successfully changed act."));
actUpdateModels();
}
void CouponForm::actRemoveAction(void) {
QModelIndex index = actTableView->currentIndex();
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actModel->record(index.row());
int id = record.value(act_id).toInt();
QString name = record.value(act_name).toString();
QMessageBox msgBox;
msgBox.setText("Are you sure?");
msgBox.setInformativeText(QString(qApp->tr(
"Are you sure you want to delete the selected act objects?\n"
"All of the following objects and their related items will be "
"deleted:\n\nCouponForm: %1\n").arg(name)));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No
| QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Cancel) {
return;
} else if (ret == QMessageBox::No)
return;
ActModel *m = new ActModel(0, this);
ActModel::selectById(id, m);
if (!m->remove()) {
actErrorStatus(qApp->tr("Fails to remove the record."));
return;
}
actOkStatus(qApp->tr("Successfully deleted act."));
actUpdateModels();
}
void CouponForm::actCreateSearchAdvanceWidget(void) {
actSearch = new ActSearch(actModel);
connect(actSearch, SIGNAL(formSearched()), this, SLOT(
actUpdateSearchForm()));
connect(actSearch, SIGNAL(formSearchClose()), this, SLOT(
actUpdateSearchFormClose()));
}
void CouponForm::actSearchAdvancedAction(void) {
if (!actSearch->isVisible()) {
actSearch->show();
actSearch->raise();
actSearch->activateWindow();
} else {
actSearch->hide();
}
}
void CouponForm::actSearchTextChangedAction() {
QString text = searchLineEdit->text();
if (text.isEmpty() || text.isNull()) {
actModel->setF("");
} else {
actModel->setF(QString("name LIKE '%1\%'").arg(text));
}
actModel->setBegin(0);
actUpdateModels();
}
void CouponForm::actCloseAction(void) {
close();
}
void CouponForm::actSelectedItemViewAction(const QModelIndex &index) {
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actModel->record(index.row());
int id = record.value(act_id).toInt();
actModel->setId(id);
ActForm *form = new ActForm(actModel);
connect(form, SIGNAL(formAdded()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formChanged()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formDeleted()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(sendStatus(const QString &, int)), this,
SLOT(actUpdateStatus(const QString &, int)));
form->show();
}
void CouponForm::actLastestAction(void) {
actModel->setBegin(0);
actUpdateModels();
}
void CouponForm::actNextAction(void) {
actModel->setBegin(actModel->begin() - actModel->limit());
actUpdateModels();
}
void CouponForm::actPreviousAction(void) {
actModel->setBegin(actModel->begin() + actModel->limit());
actUpdateModels();
}
void CouponForm::actOldestAction(void) {
int count = actModel->count();
int limit = actModel->limit();
actModel->setBegin((limit * count / limit) - limit);
actUpdateModels();
}
void CouponForm::actCreateModels(void) {
actModel = new ActModel(0, this);
actModel->setTable("admin_register_act");
actModel->setHeaderData(act_id, Qt::Horizontal, qApp->tr("Id"));
actModel->setHeaderData(act_name, Qt::Horizontal, qApp->tr("Name"));
actModel->setHeaderData(act_description, Qt::Horizontal, qApp->tr(
"Description"));
actModel->setHeaderData(act_value, Qt::Horizontal, qApp->tr("Value"));
actModel->setSort(act_id, Qt::DescendingOrder);
}
void CouponForm::actCreateViews(void) {
actTableView->setModel(actModel);
actTableView->setItemDelegate(new QSqlRelationalDelegate(actTableView));
actTableView->setSelectionMode(QAbstractItemView::SingleSelection);
actTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
actTableView->setColumnHidden(act_dateJoined, true);
actTableView->setColumnHidden(act_dateChanged, true);
actTableView->setColumnHidden(act_isActive, true);
actTableView->resizeColumnsToContents();
actTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
QHeaderView *header = actTableView->horizontalHeader();
header->setStretchLastSection(true);
connect(header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this,
SLOT(actUpdateModels()));
}
void CouponForm::actCreateActions(void) {
connect(statusTimer, SIGNAL(timeout()), this, SLOT(actTimerStatusAction()));
connect(newPushButton, SIGNAL(released()), this, SLOT(actNewAction()));
connect(activatePushButton, SIGNAL(released()), this,
SLOT(actActivateAction()));
connect(deactivatePushButton, SIGNAL(released()), this, SLOT(
actDesactivateAction()));
connect(removePushButton, SIGNAL(released()), this, SLOT(actRemoveAction()));
connect(searchAdvancedPushButton, SIGNAL(released()), this, SLOT(
actSearchAdvancedAction()));
connect(searchLineEdit, SIGNAL(returnPressed()), this, SLOT(
actSearchTextChangedAction()));
//connect(closePushButton, SIGNAL(released()), this, SLOT(actCloseAction()));
connect(actTableView, SIGNAL(activated(const QModelIndex &)), this,
SLOT(actSelectedItemViewAction(const QModelIndex &)));
connect(latestPushButton, SIGNAL(released()), this,
SLOT(actLastestAction()));
connect(nextPushButton, SIGNAL(released()), this, SLOT(actNextAction()));
connect(previousPushButton, SIGNAL(released()), this,
SLOT(actPreviousAction()));
connect(oldestPushButton, SIGNAL(released()), this, SLOT(actOldestAction()));
}
void CouponForm::actUpdateWidgets(void) {
if (actModel->query().size() > 0) {
activatePushButton->hide();
deactivatePushButton->hide();
removePushButton->show();
} else {
activatePushButton->hide();
deactivatePushButton->hide();
removePushButton->hide();
}
actTableView->setTabKeyNavigation(true);
actStatusLabel->hide();
double values = ActCouponModel::sumActValue(couponModel->getId());
sumValuesNumberLabel->setText(
QString("").sprintf("R$ %.2f", values).replace(".", ","));
}
void CouponForm::actUpdateModels(void) {
actModel->paginator();
qDebug() << "Query:" << actModel->query().lastQuery();
int begin = actModel->begin();
int limit = actModel->limit();
int sizeAll = actModel->count();
int size = actModel->query().size();
statusActTableViewLabel->setText(
sizeAll > 1 ? QString(qApp->tr("%1 acts")).arg(sizeAll) : QString(
qApp->tr("%1 act")).arg(sizeAll));
statusPaginationLabel->setText(QString(qApp->tr(
"<b>%1</b> - <b>%2</b> de <b>%3</b>")).arg(begin).arg(limit).arg(
sizeAll));
latestPushButton->setEnabled(begin > 0);
nextPushButton->setEnabled(begin > 0);
previousPushButton->setEnabled(sizeAll > (size + begin));
oldestPushButton->setEnabled(sizeAll > (size + begin));
actUpdateWidgets();
actCouponUpdateModels();
actCouponUpdateWidgets();
}
void CouponForm::actTimerStatus(void) {
actStatusTimer->start(3000);
}
void CouponForm::actOkStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: green; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid green;");
actStatusLabel->show();
actTimerStatus();
}
void CouponForm::actInfoStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: blue; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid blue;");
actStatusLabel->show();
actTimerStatus();
}
void CouponForm::actAlertStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: yellow; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid yellow;");
actStatusLabel->show();
actTimerStatus();
}
void CouponForm::actErrorStatus(const QString &msg) {
actStatusLabel->setText(msg);
actStatusLabel->setStyleSheet("color: red; background-color: white;"
"margin: 2px; padding: 3px; border: 1px solid red;");
actStatusLabel->show();
actTimerStatus();
}
void CouponForm::actUpdateSearchForm(void) {
searchLineEdit->clear();
actUpdateModels();
}
void CouponForm::actUpdateSearchFormClose(void) {
searchLineEdit->clear();
actUpdateModels();
}
void CouponForm::actUpdateStatus(const QString &msg, int code) {
switch (code) {
case 0:
actOkStatus(msg);
break;
case 1:
actInfoStatus(msg);
break;
case 2:
actAlertStatus(msg);
break;
case 3:
actErrorStatus(msg);
break;
default:
actOkStatus(msg);
break;
}
}
void CouponForm::actCouponChooseAction(void) {
if (!save())
return;
QModelIndex index = actTableView->currentIndex();
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actModel->record(index.row());
int id = record.value(act_id).toInt();
actCouponModel->setActId(id);
actCouponModel->setCouponId(couponModel->getId());
if (!actCouponModel->save()) {
actErrorStatus(qApp->tr("Failure trying to register the record."));
}
actCouponUpdateModels();
}
void CouponForm::actCouponClearActivateAction(void) {
if (!save())
return;
QModelIndex index = actCouponTableView->currentIndex();
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actCouponModel->record(index.row());
int id = record.value(actcoupon_id).toInt();
actCouponModel->setId(id);
if (!actCouponModel->remove()) {
actErrorStatus(qApp->tr("Fails to remove the record."));
}
actCouponUpdateModels();
}
void CouponForm::actCouponSelectedItemViewAction(const QModelIndex &index) {
if (!index.isValid()) {
actInfoStatus(qApp->tr("Please select an item to edit."));
return;
}
QSqlRecord record = actCouponModel->record(index.row());
int id = record.value(actcoupon_id).toInt();
ActCouponModel::selectById(id, actCouponModel);
actModel->setId(actCouponModel->getActId());
ActForm *form = new ActForm(actModel);
connect(form, SIGNAL(formAdded()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formChanged()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(formDeleted()), this, SLOT(actUpdateModels()));
connect(form, SIGNAL(sendStatus(const QString &, int)), this,
SLOT(actUpdateStatus(const QString &, int)));
form->show();
}
void CouponForm::actCouponCreateModels(void) {
actCouponModel = new ActCouponModel(0, this);
actCouponModel->setTable("admin_register_act_coupon");
actCouponModel->setRelation(actcoupon_actId, QSqlRelation(
"admin_register_act", "id", "name"));
actCouponModel->setHeaderData(actcoupon_id, Qt::Horizontal, qApp->tr("Id"));
actCouponModel->setHeaderData(actcoupon_actId, Qt::Horizontal, qApp->tr(
"Act"));
actCouponModel->setSort(actcoupon_id, Qt::DescendingOrder);
}
void CouponForm::actCouponCreateViews(void) {
actCouponTableView->setModel(actCouponModel);
actCouponTableView->setItemDelegate(new QSqlRelationalDelegate(
actCouponTableView));
actCouponTableView->setSelectionMode(QAbstractItemView::SingleSelection);
actCouponTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
actCouponTableView->setColumnHidden(actcoupon_couponId, true);
actCouponTableView->resizeColumnsToContents();
actCouponTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
QHeaderView *header = actCouponTableView->horizontalHeader();
header->setStretchLastSection(true);
connect(header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this,
SLOT(actCouponUpdateModels()));
}
void CouponForm::actCouponCreateActions(void) {
connect(choosePushButton, SIGNAL(released()), this,
SLOT(actCouponChooseAction()));
connect(clearPushButton, SIGNAL(released()), this,
SLOT(actCouponClearActivateAction()));
connect(actCouponTableView, SIGNAL(activated(const QModelIndex &)), this,
SLOT(actCouponSelectedItemViewAction(const QModelIndex &)));
}
void CouponForm::actCouponUpdateWidgets(void) {
if (actModel->query().size() > 0) {
choosePushButton->setEnabled(true);
} else {
choosePushButton->setEnabled(false);
}
if (actCouponModel->query().size() > 0) {
clearPushButton->setEnabled(true);
} else {
clearPushButton->setEnabled(false);
}
actCouponTableView->setTabKeyNavigation(true);
double values = ActCouponModel::sumActValue(couponModel->getId());
sumValuesNumberLabel->setText(
QString("").sprintf("R$ %.2f", values).replace(".", ","));
}
void CouponForm::actCouponUpdateModels(void) {
actCouponModel->setFilter(QString("admin_register_coupon_id = %1").arg(
couponModel->getId()));
actCouponModel->select();
qDebug() << "Query:" << actCouponModel->query().lastQuery();
actCouponUpdateWidgets();
}
Jump to Line
Something went wrong with that request. Please try again.