code refacturing
This commit is contained in:
parent
1d3125fbdc
commit
e69e601133
2 changed files with 15 additions and 13 deletions
|
@ -27,13 +27,10 @@ MainWindow::MainWindow()
|
||||||
ui_.basketView->setModel(model);
|
ui_.basketView->setModel(model);
|
||||||
ui_.basketView->setColumnHidden(0, true); // hide the uuid
|
ui_.basketView->setColumnHidden(0, true); // hide the uuid
|
||||||
|
|
||||||
SaleModel* saleModel = new SaleModel(getMarketplace(), ui_.salesView);
|
|
||||||
ui_.salesView->setModel(saleModel);
|
|
||||||
ui_.salesView->setColumnHidden(2, true);
|
|
||||||
ui_.salesView->resizeColumnToContents(0);
|
|
||||||
|
|
||||||
setWindowTitle("KIMA2 - Kasse Nr. " + QSettings().value("global/cashPointNo").toString());
|
setWindowTitle("KIMA2 - Kasse Nr. " + QSettings().value("global/cashPointNo").toString());
|
||||||
|
|
||||||
|
setSaleModel();
|
||||||
|
|
||||||
connect(ui_.actionQuit, &QAction::triggered, qApp, QApplication::quit);
|
connect(ui_.actionQuit, &QAction::triggered, qApp, QApplication::quit);
|
||||||
connect(ui_.actionEditSeller, &QAction::triggered, this,
|
connect(ui_.actionEditSeller, &QAction::triggered, this,
|
||||||
&MainWindow::onActionEditSellerTriggered);
|
&MainWindow::onActionEditSellerTriggered);
|
||||||
|
@ -42,21 +39,22 @@ MainWindow::MainWindow()
|
||||||
connect(ui_.paidButton, &QPushButton::clicked, this, &MainWindow::onPaidButtonTriggered);
|
connect(ui_.paidButton, &QPushButton::clicked, this, &MainWindow::onPaidButtonTriggered);
|
||||||
connect(ui_.basketView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
connect(ui_.basketView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||||
&MainWindow::onBasketViewSelectionChanged);
|
&MainWindow::onBasketViewSelectionChanged);
|
||||||
connect(ui_.salesView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
|
||||||
&MainWindow::onSalesViewSelectionChanged);
|
|
||||||
connect(ui_.cancelArticleButton, &QPushButton::clicked, this,
|
connect(ui_.cancelArticleButton, &QPushButton::clicked, this,
|
||||||
&MainWindow::onCancelArticleButtonClicked);
|
&MainWindow::onCancelArticleButtonClicked);
|
||||||
connect(ui_.cancelSaleButton, &QPushButton::clicked, this,
|
connect(ui_.cancelSaleButton, &QPushButton::clicked, this,
|
||||||
&MainWindow::onCancelSaleButtonClicked);
|
&MainWindow::onCancelSaleButtonClicked);
|
||||||
connect(ui_.cancelAllArticlesButton, &QPushButton::clicked, this,
|
connect(ui_.cancelAllArticlesButton, &QPushButton::clicked, this,
|
||||||
&MainWindow::onCancelAllArticlesButtonClicked);
|
&MainWindow::onCancelAllArticlesButtonClicked);
|
||||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
|
||||||
static_cast<SaleModel*>(ui_.salesView->model()), &SaleModel::onBasketDataChanged);
|
|
||||||
connect(ui_.aboutQtAction, &QAction::triggered, this, &MainWindow::onAboutQt);
|
connect(ui_.aboutQtAction, &QAction::triggered, this, &MainWindow::onAboutQt);
|
||||||
connect(ui_.aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
|
connect(ui_.aboutAction, &QAction::triggered, this, &MainWindow::onAbout);
|
||||||
connect(ui_.reportAction, &QAction::triggered, this, [=]() { ReportDialog(this).exec(); });
|
connect(ui_.reportAction, &QAction::triggered, this, [=]() { ReportDialog(this).exec(); });
|
||||||
connect(ui_.configAction, &QAction::triggered, this, [=]() {
|
connect(ui_.configAction, &QAction::triggered, this, [=]() {
|
||||||
SettingsDialog(this).exec();
|
int result = SettingsDialog(this).exec();
|
||||||
|
if (result == QDialog::Accepted) {
|
||||||
|
delete ui_.salesView->model();
|
||||||
|
marketplace_->loadFromDb();
|
||||||
|
setSaleModel();
|
||||||
|
}
|
||||||
this->setWindowTitle("KIMA2 - Kasse Nr. " +
|
this->setWindowTitle("KIMA2 - Kasse Nr. " +
|
||||||
QSettings().value("global/cashPointNo").toString());
|
QSettings().value("global/cashPointNo").toString());
|
||||||
});
|
});
|
||||||
|
@ -67,8 +65,7 @@ void MainWindow::onActionEditSellerTriggered()
|
||||||
auto dialog = std::make_unique<SellerDialog>(this);
|
auto dialog = std::make_unique<SellerDialog>(this);
|
||||||
int retCode = dialog->exec();
|
int retCode = dialog->exec();
|
||||||
|
|
||||||
auto oldModel = ui_.salesView->model();
|
delete ui_.salesView->model();
|
||||||
ui_.salesView->setModel(nullptr);
|
|
||||||
|
|
||||||
if (retCode == QDialog::Accepted) {
|
if (retCode == QDialog::Accepted) {
|
||||||
marketplace_->sortSellers();
|
marketplace_->sortSellers();
|
||||||
|
@ -81,8 +78,12 @@ void MainWindow::onActionEditSellerTriggered()
|
||||||
STATUSBAR_TIMEOUT);
|
STATUSBAR_TIMEOUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSaleModel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setSaleModel()
|
||||||
|
{
|
||||||
ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView));
|
ui_.salesView->setModel(new SaleModel(getMarketplace(), ui_.salesView));
|
||||||
delete oldModel;
|
|
||||||
ui_.salesView->setColumnHidden(2, true);
|
ui_.salesView->setColumnHidden(2, true);
|
||||||
ui_.salesView->resizeColumnToContents(0);
|
ui_.salesView->resizeColumnToContents(0);
|
||||||
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
connect(static_cast<BasketModel*>(ui_.basketView->model()), &BasketModel::basketDataChanged,
|
||||||
|
|
|
@ -32,6 +32,7 @@ class MainWindow : public QMainWindow
|
||||||
void onActionEditSellerTriggered();
|
void onActionEditSellerTriggered();
|
||||||
void onSellerNoEditCheckSellerNo();
|
void onSellerNoEditCheckSellerNo();
|
||||||
void onPaidButtonTriggered();
|
void onPaidButtonTriggered();
|
||||||
|
void setSaleModel();
|
||||||
|
|
||||||
Ui::MainWindow ui_;
|
Ui::MainWindow ui_;
|
||||||
std::unique_ptr<Marketplace> marketplace_;
|
std::unique_ptr<Marketplace> marketplace_;
|
||||||
|
|
Loading…
Reference in a new issue