2024-08-18 13:57:57 +03:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "./ui_mainwindow.h"
|
2024-08-19 02:35:16 +03:00
|
|
|
#include "check/check.h"
|
2024-08-24 00:45:47 +03:00
|
|
|
#include "goods/goods.h"
|
|
|
|
#include "outputdialog.h"
|
2024-08-20 02:38:40 +03:00
|
|
|
#include "settings.h"
|
2024-08-19 02:35:16 +03:00
|
|
|
#include <iostream>
|
2024-08-18 13:57:57 +03:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2024-08-19 02:35:16 +03:00
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
2024-08-18 13:57:57 +03:00
|
|
|
ui->setupUi(this);
|
2024-08-19 02:35:16 +03:00
|
|
|
this->setupStoresList();
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow() { delete ui; }
|
|
|
|
|
|
|
|
void MainWindow::setupStoresList() {
|
|
|
|
// Make file format that is a regeeex which parse check, load these files
|
|
|
|
// here
|
|
|
|
parser = *(new Parser());
|
2024-08-24 00:45:47 +03:00
|
|
|
|
|
|
|
std::vector<std::string> modules_names = parser.search_modules();
|
|
|
|
|
|
|
|
for (std::string name : modules_names) {
|
2024-08-30 05:03:32 +03:00
|
|
|
StoreModule m(name);
|
2024-08-24 00:45:47 +03:00
|
|
|
std::wstring module_name = m.get_name();
|
|
|
|
|
|
|
|
QString s = QString::fromStdWString(module_name);
|
|
|
|
ui->storeType->addItem(s);
|
|
|
|
}
|
|
|
|
|
2024-08-20 02:38:40 +03:00
|
|
|
#ifdef DEBUG
|
2024-08-19 02:35:16 +03:00
|
|
|
for (auto module : parser.search_modules()) {
|
2024-08-20 02:38:40 +03:00
|
|
|
std::cout << "Module: " << module << std::endl;
|
2024-08-19 02:35:16 +03:00
|
|
|
}
|
2024-08-20 02:38:40 +03:00
|
|
|
#endif
|
2024-08-19 02:35:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_checkType_currentIndexChanged(int index) {
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
ui->checkInfo->setVisible(true);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ui->checkInfo->setVisible(false);
|
|
|
|
break;
|
|
|
|
}
|
2024-08-18 13:57:57 +03:00
|
|
|
}
|
|
|
|
|
2024-08-19 02:35:16 +03:00
|
|
|
void MainWindow::on_parseButton_clicked() {
|
2024-08-20 02:38:40 +03:00
|
|
|
QString s(ui->checkContent->toPlainText());
|
|
|
|
std::wstring check_plaintext = s.toStdWString();
|
|
|
|
parser.set_module(parser.search_modules()[0]);
|
|
|
|
|
|
|
|
std::vector<Goods> c = parser.parse(check_plaintext);
|
|
|
|
|
2024-08-24 00:45:47 +03:00
|
|
|
if (c.size() == 0) {
|
|
|
|
std::cerr << "An error has occured. Check was matched incorrectly. Vector sizes are different" << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-20 02:38:40 +03:00
|
|
|
Check check;
|
|
|
|
|
|
|
|
for (auto g : c) {
|
|
|
|
check.add_goods(g);
|
|
|
|
}
|
2024-08-24 00:45:47 +03:00
|
|
|
|
|
|
|
OutputDialog *d = new OutputDialog(this, check);
|
2024-08-30 05:03:32 +03:00
|
|
|
d->show();
|
2024-08-24 00:45:47 +03:00
|
|
|
d->exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_storeType_currentIndexChanged(int index) {
|
|
|
|
std::string module = parser.search_modules()[index];
|
|
|
|
parser.set_module(module);
|
2024-08-18 13:57:57 +03:00
|
|
|
}
|