fill basket

This commit is contained in:
Martin Brodbeck 2018-07-21 19:24:56 +02:00
parent f315cc81a6
commit 8b534e1229
9 changed files with 62 additions and 18 deletions

View file

@ -11,10 +11,9 @@ find_package(Qt5Widgets CONFIG REQUIRED)
set(GUI_SOURCES
kima2.cpp
mainwindow.cpp
mainwindow.ui
sellerdialog.cpp
sellerdialog.ui
sellermodel.cpp
pricedialog.cpp
)
add_executable(kima2 ${GUI_SOURCES})

View file

@ -1,6 +1,7 @@
#include "mainwindow.h"
#include "sellerdialog.h"
#include "pricedialog.h"
#include <regex>
@ -58,8 +59,16 @@ void MainWindow::on_sellerNoEdit_checkSellerNo()
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
if (seller) {
std::cout << "!!! Seller gefunden: " << seller->getFirstName() << "\n";
// TODO: Dialog für Preiseingabe anzeigen
// TODO: Warenkorb füllen
PriceDialog priceDialog(this);
auto dialogResult = priceDialog.exec();
if (dialogResult == QDialog::Accepted)
{
int price = priceDialog.getPrice();
auto article = std::make_unique<Article>(price);
article->setSeller(seller);
std::cout << "!!! Neuer Artikel: " << article->getPrice() << "Cent \n";
marketplace_->addArticleToBasket(std::move(article));
}
}
ui_.sellerNoEdit->clear();

12
src/gui/pricedialog.cpp Normal file
View file

@ -0,0 +1,12 @@
#include "pricedialog.h"
PriceDialog::PriceDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f)
{
ui_.setupUi(this);
ui_.priceSpinBox->setFocus();
}
int PriceDialog::getPrice() const
{
return static_cast<int>(ui_.priceSpinBox->value() * 100);
}

23
src/gui/pricedialog.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef PRICE_DIALOG_H
#define PRICE_DIALOG_H
#include "ui_pricedialog.h"
#include <QDialog>
class PriceDialog : public QDialog
{
Q_OBJECT
public:
PriceDialog(QWidget* parent = nullptr,
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
int getPrice() const;
private:
void on_model_duplicateSellerNo(const QString& message);
//virtual void accept() override;
Ui::PriceDialog ui_;
};
#endif

View file

@ -1,15 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>priceDialog</class>
<widget class="QDialog" name="priceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>311</width>
<height>114</height>
</rect>
</property>
<class>PriceDialog</class>
<widget class="QDialog" name="PriceDialog">
<property name="windowTitle">
<string>Artikelpreis</string>
</property>
@ -65,7 +57,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>priceDialog</receiver>
<receiver>PriceDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@ -81,7 +73,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>priceDialog</receiver>
<receiver>PriceDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">