Compare commits
No commits in common. "74ac9f6299275bced6b9e44c5892d2c47a0d9f94" and "e169f8c07e66f1a25b8f453b1953294fb5aa9337" have entirely different histories.
74ac9f6299
...
e169f8c07e
6 changed files with 11 additions and 62 deletions
8
.vscode/settings.json
vendored
8
.vscode/settings.json
vendored
|
@ -60,12 +60,8 @@
|
||||||
"typeinfo": "cpp",
|
"typeinfo": "cpp",
|
||||||
"utility": "cpp",
|
"utility": "cpp",
|
||||||
"variant": "cpp",
|
"variant": "cpp",
|
||||||
"algorithm": "cpp",
|
"algorithm": "cpp"
|
||||||
"cinttypes": "cpp",
|
|
||||||
"condition_variable": "cpp",
|
|
||||||
"mutex": "cpp"
|
|
||||||
},
|
},
|
||||||
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
|
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
|
||||||
"cmake.configureOnOpen": true,
|
"cmake.configureOnOpen": true
|
||||||
"C_Cpp.configurationWarnings": "Disabled"
|
|
||||||
}
|
}
|
|
@ -42,14 +42,3 @@ int Marketplace::getNumSellersDelete()
|
||||||
}
|
}
|
||||||
|
|
||||||
void Marketplace::sortSellers() { std::sort(sellers_.begin(), sellers_.end()); }
|
void Marketplace::sortSellers() { std::sort(sellers_.begin(), sellers_.end()); }
|
||||||
|
|
||||||
Seller* Marketplace::findSellerWithSellerNo(int sellerNo)
|
|
||||||
{
|
|
||||||
auto iter =
|
|
||||||
std::find_if(sellers_.begin(), sellers_.end(), [sellerNo](const auto& a) {
|
|
||||||
return a->getSellerNo() == sellerNo;
|
|
||||||
});
|
|
||||||
if (iter == sellers_.end())
|
|
||||||
return nullptr;
|
|
||||||
return (*iter).get();
|
|
||||||
}
|
|
|
@ -11,7 +11,6 @@ namespace
|
||||||
{
|
{
|
||||||
using SellersVec = std::vector<std::unique_ptr<Seller>>;
|
using SellersVec = std::vector<std::unique_ptr<Seller>>;
|
||||||
using SalesVec = std::vector<std::unique_ptr<Sale>>;
|
using SalesVec = std::vector<std::unique_ptr<Sale>>;
|
||||||
using BasketVec = std::vector<std::unique_ptr<Sale>>;
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct Basket {
|
struct Basket {
|
||||||
|
@ -27,12 +26,10 @@ class Marketplace
|
||||||
int getNextSellerNo();
|
int getNextSellerNo();
|
||||||
int getNumSellersDelete();
|
int getNumSellersDelete();
|
||||||
void sortSellers();
|
void sortSellers();
|
||||||
Seller* findSellerWithSellerNo(int sellerNo);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SellersVec sellers_;
|
SellersVec sellers_;
|
||||||
SalesVec sales_;
|
SalesVec sales_;
|
||||||
BasketVec basket_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
#include "sellerdialog.h"
|
#include "sellerdialog.h"
|
||||||
|
|
||||||
#include <regex>
|
|
||||||
|
|
||||||
constexpr int STATUSBAR_TIMEOUT = 5000;
|
constexpr int STATUSBAR_TIMEOUT = 5000;
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow()
|
||||||
|
@ -13,8 +11,6 @@ MainWindow::MainWindow()
|
||||||
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::on_actionEditSeller_triggered);
|
&MainWindow::on_actionEditSeller_triggered);
|
||||||
connect(ui_.sellerNoEdit, &QLineEdit::returnPressed, this,
|
|
||||||
&MainWindow::on_sellerNoEdit_checkSellerNo);
|
|
||||||
|
|
||||||
marketplace_ = std::make_unique<Marketplace>();
|
marketplace_ = std::make_unique<Marketplace>();
|
||||||
marketplace_->loadFromDb();
|
marketplace_->loadFromDb();
|
||||||
|
@ -36,31 +32,3 @@ void MainWindow::on_actionEditSeller_triggered()
|
||||||
STATUSBAR_TIMEOUT);
|
STATUSBAR_TIMEOUT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_sellerNoEdit_checkSellerNo()
|
|
||||||
{
|
|
||||||
using std::regex, std::regex_match, std::smatch;
|
|
||||||
|
|
||||||
auto inputText = ui_.sellerNoEdit->text().toStdString();
|
|
||||||
|
|
||||||
if (inputText.empty()) {
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
regex pattern{R"(\d{1,5})"};
|
|
||||||
smatch result;
|
|
||||||
if (!regex_match(inputText, result, pattern)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int sellerNo = std::stoi(result[0]);
|
|
||||||
|
|
||||||
auto seller = marketplace_->findSellerWithSellerNo(sellerNo);
|
|
||||||
if (seller) {
|
|
||||||
std::cout << "!!! Seller gefunden: " << seller->getFirstName() << "\n";
|
|
||||||
// TODO: Dialog für Preiseingabe anzeigen
|
|
||||||
// TODO: Warenkorb füllen
|
|
||||||
}
|
|
||||||
|
|
||||||
ui_.sellerNoEdit->clear();
|
|
||||||
}
|
|
|
@ -19,7 +19,6 @@ class MainWindow : public QMainWindow
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void on_actionEditSeller_triggered();
|
void on_actionEditSeller_triggered();
|
||||||
void on_sellerNoEdit_checkSellerNo();
|
|
||||||
|
|
||||||
Ui::MainWindow ui_;
|
Ui::MainWindow ui_;
|
||||||
std::unique_ptr<Marketplace> marketplace_;
|
std::unique_ptr<Marketplace> marketplace_;
|
||||||
|
|
|
@ -52,10 +52,10 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="sellerNoEdit"/>
|
<widget class="QLineEdit" name="lineEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="paidButton">
|
<widget class="QPushButton" name="pushButton_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Bezahlt!</string>
|
<string>Bezahlt!</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in a new issue