rm ingored
This commit is contained in:
137
mainwindow.cpp
137
mainwindow.cpp
@@ -1,137 +0,0 @@
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
#include "check/check.h"
|
||||
#include "goods/goods.h"
|
||||
#include "outputdialog.h"
|
||||
#include "adjustpicturedialog.h"
|
||||
#include "settingsdialog.h"
|
||||
#include <iostream>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include "image/checkimage.h"
|
||||
#include "utils/utils.h"
|
||||
#include <opencv2/objdetect.hpp>
|
||||
#include <opencv2/imgcodecs.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <zbar.h>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
this->setupStoresList();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() { delete ui; }
|
||||
|
||||
void MainWindow::setupStoresList() {
|
||||
parser = *(new Parser());
|
||||
|
||||
std::vector<std::string> modules_names = parser.search_modules();
|
||||
|
||||
for (std::string name : modules_names) {
|
||||
StoreModule m(name);
|
||||
std::wstring module_name = m.get_name();
|
||||
|
||||
QString s = QString::fromStdWString(module_name);
|
||||
ui->storeType->addItem(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
for (auto module : parser.search_modules()) {
|
||||
std::cout << "Module: " << module << std::endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::on_parseButton_clicked() {
|
||||
QString s;
|
||||
switch (ui->checkType->currentIndex()) {
|
||||
case 0:
|
||||
s = ui->checkContent->toPlainText();
|
||||
break;
|
||||
case 1:
|
||||
s = ui->checkContentFromImage->toPlainText();
|
||||
break;
|
||||
}
|
||||
|
||||
std::wstring check_plaintext = s.toStdWString();
|
||||
parser.set_module(parser.search_modules()[0]);
|
||||
|
||||
std::vector<Goods> c = parser.parse(check_plaintext);
|
||||
|
||||
if (c.size() == 0) {
|
||||
std::cerr << "An error has occured. Check was matched incorrectly. Vector sizes are different" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
Check check;
|
||||
|
||||
for (auto& g : c) {
|
||||
check.add_goods(g);
|
||||
}
|
||||
|
||||
OutputDialog d = OutputDialog(this, check);
|
||||
d.show();
|
||||
d.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_storeType_currentIndexChanged(int index) {
|
||||
std::string module = parser.search_modules()[index];
|
||||
parser.set_module(module);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_preferencesButton_clicked() {
|
||||
SettingsDialog s = SettingsDialog();
|
||||
s.show();
|
||||
s.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_chooseImageButton_ofd_clicked() {
|
||||
QString filename = QFileDialog::getOpenFileName();
|
||||
|
||||
std::string new_text = "Selected: " + filename.toStdString();
|
||||
ui->pathLabel_ofd->setText(QString::fromStdString(new_text));
|
||||
|
||||
AdjustPictureDialog dialog = AdjustPictureDialog(this, filename.toStdString());
|
||||
connect(&dialog, &AdjustPictureDialog::decodedData, this, &MainWindow::onDecodedData);
|
||||
dialog.exec();
|
||||
|
||||
ui->picture_ofd->setPixmap(QPixmap(filename));
|
||||
ui->picture_ofd->setScaledContents(true);
|
||||
}
|
||||
|
||||
void MainWindow::onDecodedData(std::string data) {
|
||||
std::string delimiter = "&";
|
||||
std::vector<std::string> dataSplit = split(data, delimiter);
|
||||
|
||||
std::cout << data << std::endl;
|
||||
|
||||
ui->fn_edit->setText(QString::fromStdString(dataSplit[2]));
|
||||
ui->fd_edit->setText(QString::fromStdString(dataSplit[3]));
|
||||
ui->fi_edit->setText(QString::fromStdString(dataSplit[4]));
|
||||
|
||||
QString extractedDateTime = QString::fromStdString(split(dataSplit[0], "=")[1]);
|
||||
QDateTime datetime = QDateTime::fromString(extractedDateTime, "yyyyMMddThhmm");
|
||||
ui->dateTimeEdit->setDateTime(datetime);
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::on_chooseImageButton_ocr_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName();
|
||||
|
||||
std::string new_text = "Selected: " + filename.toStdString();
|
||||
ui->pathLabel_ocr->setText(QString::fromStdString(new_text));
|
||||
|
||||
CheckImage i(filename.toStdString());
|
||||
std::string parsed = i.parse_text();
|
||||
|
||||
ui->picture_ocr->setPixmap(QPixmap(filename));
|
||||
ui->picture_ocr->setScaledContents(true);
|
||||
ui->checkContentFromImage->setPlainText(QString::fromStdString(parsed));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user