starting work on export module, added check trimming
This commit is contained in:
parent
2715272ebf
commit
ddf906fbbc
|
@ -43,6 +43,7 @@ else()
|
||||||
parser/parser.h parser/parser.cpp
|
parser/parser.h parser/parser.cpp
|
||||||
parser/module.h parser/module.cpp
|
parser/module.h parser/module.cpp
|
||||||
settings.h
|
settings.h
|
||||||
|
outputdialog.h outputdialog.cpp outputdialog.ui
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!DOCTYPE QtCreatorProject>
|
||||||
<!-- Written by QtCreator 14.0.0, 2024-08-20T00:01:53. -->
|
<!-- Written by QtCreator 14.0.0, 2024-08-21T19:24:51. -->
|
||||||
<qtcreator>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<variable>EnvironmentId</variable>
|
||||||
|
@ -102,13 +102,13 @@
|
||||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Debug
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Debug
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_GENERATOR:STRING=Ninja
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Debug</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Debug</value>
|
||||||
|
@ -159,13 +159,13 @@
|
||||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=Release
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=Release
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_GENERATOR:STRING=Ninja
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Release</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Release</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
@ -213,13 +213,13 @@
|
||||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_GENERATOR:STRING=Ninja
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-RelWithDebInfo</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-RelWithDebInfo</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
@ -267,13 +267,13 @@
|
||||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_GENERATOR:STRING=Ninja
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
||||||
<value type="int" key="EnableQmlDebugging">0</value>
|
<value type="int" key="EnableQmlDebugging">0</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Profile</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-Profile</value>
|
||||||
|
@ -322,13 +322,13 @@
|
||||||
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
<value type="int" key="CMake.Configure.BaseEnvironment">2</value>
|
||||||
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
<value type="bool" key="CMake.Configure.ClearSystemEnvironment">false</value>
|
||||||
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
<valuelist type="QVariantList" key="CMake.Configure.UserEnvironmentChanges"/>
|
||||||
<value type="QString" key="CMake.Initial.Parameters">-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
<value type="QString" key="CMake.Initial.Parameters">-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
|
||||||
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
|
||||||
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
|
||||||
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel
|
|
||||||
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
|
||||||
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
|
||||||
-DCMAKE_GENERATOR:STRING=Ninja
|
-DCMAKE_GENERATOR:STRING=Ninja
|
||||||
|
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
|
||||||
|
-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}
|
||||||
|
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
|
||||||
|
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
|
||||||
|
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
|
||||||
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake</value>
|
||||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-MinSizeRel</value>
|
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/leca/projects/qt/checks-parser/build/Desktop-MinSizeRel</value>
|
||||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include "../goods/goods.h"
|
#include "../goods/goods.h"
|
||||||
|
|
||||||
Check::Check() {}
|
Check::Check() {}
|
||||||
|
|
||||||
void Check::add_goods(Goods goods) { this->goods.push_back(goods); }
|
void Check::add_goods(Goods goods) { this->goods.push_back(goods); }
|
||||||
|
|
||||||
double Check::calculae_total_price() {
|
double Check::calculae_total_price() {
|
||||||
double total = 0.0;
|
double total = 0.0;
|
||||||
|
|
||||||
|
@ -12,3 +14,7 @@ double Check::calculae_total_price() {
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Goods>& Check::get_goods() {
|
||||||
|
return goods;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,8 @@ public:
|
||||||
void add_goods(Goods);
|
void add_goods(Goods);
|
||||||
|
|
||||||
double calculae_total_price();
|
double calculae_total_price();
|
||||||
|
|
||||||
|
std::vector<Goods>& get_goods();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHECK_H
|
#endif // CHECK_H
|
||||||
|
|
1
main.cpp
1
main.cpp
|
@ -6,5 +6,6 @@ int main(int argc, char *argv[]) {
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
#include "goods/goods.h"
|
|
||||||
#include "check/check.h"
|
#include "check/check.h"
|
||||||
|
#include "goods/goods.h"
|
||||||
|
#include "outputdialog.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
@ -17,6 +18,17 @@ void MainWindow::setupStoresList() {
|
||||||
// Make file format that is a regeeex which parse check, load these files
|
// Make file format that is a regeeex which parse check, load these files
|
||||||
// here
|
// here
|
||||||
parser = *(new Parser());
|
parser = *(new Parser());
|
||||||
|
|
||||||
|
std::vector<std::string> modules_names = parser.search_modules();
|
||||||
|
|
||||||
|
for (std::string name : modules_names) {
|
||||||
|
Module m(name);
|
||||||
|
std::wstring module_name = m.get_name();
|
||||||
|
|
||||||
|
QString s = QString::fromStdWString(module_name);
|
||||||
|
ui->storeType->addItem(s);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
for (auto module : parser.search_modules()) {
|
for (auto module : parser.search_modules()) {
|
||||||
std::cout << "Module: " << module << std::endl;
|
std::cout << "Module: " << module << std::endl;
|
||||||
|
@ -42,9 +54,22 @@ void MainWindow::on_parseButton_clicked() {
|
||||||
|
|
||||||
std::vector<Goods> c = parser.parse(check_plaintext);
|
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;
|
Check check;
|
||||||
|
|
||||||
for (auto g : c) {
|
for (auto g : c) {
|
||||||
check.add_goods(g);
|
check.add_goods(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OutputDialog *d = new OutputDialog(this, check);
|
||||||
|
d->exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_storeType_currentIndexChanged(int index) {
|
||||||
|
std::string module = parser.search_modules()[index];
|
||||||
|
parser.set_module(module);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ class MainWindow : public QMainWindow {
|
||||||
Parser parser;
|
Parser parser;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
void setupStoresList();
|
void setupStoresList();
|
||||||
|
@ -29,6 +30,8 @@ private slots:
|
||||||
|
|
||||||
void on_parseButton_clicked();
|
void on_parseButton_clicked();
|
||||||
|
|
||||||
|
void on_storeType_currentIndexChanged(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>827</width>
|
<width>817</width>
|
||||||
<height>680</height>
|
<height>659</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -23,21 +23,6 @@
|
||||||
<height>31</height>
|
<height>31</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Pyaterochka (Пятёрочка)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Perekrestok (Перекрёсток)</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>FixPrice</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="storeTypeLabel">
|
<widget class="QLabel" name="storeTypeLabel">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
|
@ -58,7 +43,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>90</y>
|
<y>90</y>
|
||||||
<width>801</width>
|
<width>801</width>
|
||||||
<height>551</height>
|
<height>511</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QLabel" name="checkContentLabel">
|
<widget class="QLabel" name="checkContentLabel">
|
||||||
|
@ -140,7 +125,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>827</width>
|
<width>817</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name":"Магнит",
|
||||||
|
"goods_name_regex": "([\\(\\)\\%\\*a-zA-Z0-9\u0401\u0451\u0410-\u044f \\.\\-\/]{17,100})",
|
||||||
|
"goods_price_regex": "[0-9]{0,4}[^%]\\.[0-9]{2} ",
|
||||||
|
"goods_quantity_regex": "([0-9]{0,4}[^%]\\.[0-9]{3} )|(\t\\d )",
|
||||||
|
"check_start_regex": "",
|
||||||
|
"check_end_regex":""
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
{
|
{
|
||||||
"name":"Пятёрочка",
|
"name":"Пятёрочка",
|
||||||
"goods_name_regex": "([0-9]+ \t[\\%\\*a-zA-Z0-9\u0401\u0451\u0410-\u044f \\.\\-\/]{10,100})",
|
"goods_name_regex": "([\\(\\)\\%\\*a-zA-Z0-9\u0401\u0451\u0410-\u044f \\.\\-\/]{17,100})",
|
||||||
"goods_price_regex": "[0-9]{0,4}[^%]\\.[0-9]{2} ",
|
"goods_price_regex": "[0-9]{0,4}[^%]\\.[0-9]{2} ",
|
||||||
"goods_quantity_regex": "([0-9]{0,4}[^%]\\.[0-9]{3} )|(\t\\d )"
|
"goods_quantity_regex": "([0-9]{0,4}[^%]\\.[0-9]{3} )|(\t\\d )",
|
||||||
|
"check_start_regex": "КАССОВЫЙ ЧЕК\nприход",
|
||||||
|
"check_end_regex": "Итог\\:.{0,3}[0-9]{0,6}\\.[0-9]{2}"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#include "outputdialog.h"
|
||||||
|
#include "ui_outputdialog.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <QMainWindow>
|
||||||
|
#include "check/check.h"
|
||||||
|
|
||||||
|
OutputDialog::OutputDialog(QWidget *parent, Check check)
|
||||||
|
: QDialog(parent), ui(new Ui::OutputDialog) {
|
||||||
|
ui->setupUi(this);
|
||||||
|
for (auto goods : check.get_goods()) {
|
||||||
|
std::cout << "From dialog:" << goods.get_name() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputDialog::~OutputDialog() { delete ui; }
|
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef OUTPUTDIALOG_H
|
||||||
|
#define OUTPUTDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "check/check.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class OutputDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class OutputDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit OutputDialog(QWidget *parent = nullptr, Check = Check());
|
||||||
|
~OutputDialog();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::OutputDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OUTPUTDIALOG_H
|
|
@ -0,0 +1,171 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>OutputDialog</class>
|
||||||
|
<widget class="QDialog" name="OutputDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>602</width>
|
||||||
|
<height>436</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>410</x>
|
||||||
|
<y>390</y>
|
||||||
|
<width>166</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QComboBox" name="formatSelect">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>60</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>261</width>
|
||||||
|
<height>26</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>ods</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>csv</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>xlsx (Not implemented)</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="formatLabel">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>45</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Format</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>50</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>191</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Columns</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="gridLayoutWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>20</y>
|
||||||
|
<width>441</width>
|
||||||
|
<height>171</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox_3"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QSpinBox" name="spinBox_2"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="priceCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Price</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QCheckBox" name="netWeightCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Net weight</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QCheckBox" name="quantityCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Quantity</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QCheckBox" name="nameCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Name</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QSpinBox" name="spinBox_4"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>OutputDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>OutputDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -1,12 +1,12 @@
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "../settings.h"
|
#include "../settings.h"
|
||||||
|
#include <codecvt>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <locale>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <locale>
|
|
||||||
#include <codecvt>
|
|
||||||
|
|
||||||
std::string to_utf8(std::wstring wide_string) {
|
std::string to_utf8(std::wstring wide_string) {
|
||||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
static std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
||||||
|
@ -28,11 +28,17 @@ Module::Module(std::string path) {
|
||||||
this->goods_name_regex = from_utf8(settings["goods_name_regex"]);
|
this->goods_name_regex = from_utf8(settings["goods_name_regex"]);
|
||||||
this->goods_price_regex = from_utf8(settings["goods_price_regex"]);
|
this->goods_price_regex = from_utf8(settings["goods_price_regex"]);
|
||||||
this->goods_quantity_regex = from_utf8(settings["goods_quantity_regex"]);
|
this->goods_quantity_regex = from_utf8(settings["goods_quantity_regex"]);
|
||||||
|
this->check_start_regex = from_utf8(settings["check_start_regex"]);
|
||||||
|
this->check_end_regex = from_utf8(settings["check_end_regex"]);
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::wcout << "Name: " << this->name << std::endl;
|
std::wcout << "Name: " << this->name << std::endl;
|
||||||
std::wcout << "Goods name regex: " << this->goods_name_regex << std::endl;
|
std::wcout << "Goods name regex: " << this->goods_name_regex << std::endl;
|
||||||
std::wcout << "Goods price regex: " << this->goods_price_regex << std::endl;
|
std::wcout << "Goods price regex: " << this->goods_price_regex << std::endl;
|
||||||
std::wcout << "Goods quantity regex: " << this->goods_quantity_regex << std::endl;
|
std::wcout << "Goods quantity regex: " << this->goods_quantity_regex
|
||||||
|
<< std::endl;
|
||||||
|
std::wcout << "Check start regex: " << this->check_start_regex << std::endl;
|
||||||
|
std::wcout << "Check end regex: " << this->check_end_regex << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,30 +46,61 @@ std::vector<std::string> Module::parse_name(std::wstring str) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::wregex r(this->goods_name_regex, std::regex::collate);
|
std::wregex r(this->goods_name_regex, std::regex::collate);
|
||||||
|
|
||||||
for (std::wsregex_iterator it {str.begin(), str.end(), r}, end {}; it != end; it ++) {
|
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||||
|
it++) {
|
||||||
result.push_back(to_utf8(it->str()));
|
result.push_back(to_utf8(it->str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Module::parse_price(std::wstring str) {
|
std::vector<std::string> Module::parse_price(std::wstring str) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::wregex r(this->goods_price_regex, std::regex::collate);
|
std::wregex r(this->goods_price_regex, std::regex::collate);
|
||||||
|
|
||||||
for (std::wsregex_iterator it {str.begin(), str.end(), r}, end {}; it != end; it ++) {
|
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||||
|
it++) {
|
||||||
result.push_back(to_utf8(it->str()));
|
result.push_back(to_utf8(it->str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> Module::parse_quantity(std::wstring str) {
|
std::vector<std::string> Module::parse_quantity(std::wstring str) {
|
||||||
std::vector<std::string> result;
|
std::vector<std::string> result;
|
||||||
std::wregex r(this->goods_quantity_regex, std::regex::collate);
|
std::wregex r(this->goods_quantity_regex, std::regex::collate);
|
||||||
|
|
||||||
for (std::wsregex_iterator it {str.begin(), str.end(), r}, end {}; it != end; it ++) {
|
for (std::wsregex_iterator it{str.begin(), str.end(), r}, end{}; it != end;
|
||||||
|
it++) {
|
||||||
result.push_back(to_utf8(it->str()));
|
result.push_back(to_utf8(it->str()));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring Module::trim_check(std::wstring& check) {
|
||||||
|
unsigned int start_pos;
|
||||||
|
unsigned int end_pos;
|
||||||
|
|
||||||
|
std::wregex start_regex(this->check_start_regex, std::regex::collate);
|
||||||
|
std::wregex end_regex(this->check_end_regex, std::regex::collate);
|
||||||
|
|
||||||
|
for (std::wsregex_iterator it{check.begin(), check.end(), start_regex}, end{};
|
||||||
|
it != end; it++) {
|
||||||
|
start_pos = it->position() + it->str().size();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
check = check.substr(start_pos, check.size());
|
||||||
|
|
||||||
|
for (std::wsregex_iterator it{check.begin(), check.end(), end_regex}, end{};
|
||||||
|
it != end; it++) {
|
||||||
|
end_pos = it->position() - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
check = check.substr(0, end_pos);
|
||||||
|
|
||||||
|
return check;
|
||||||
|
}
|
||||||
|
|
||||||
std::wstring Module::get_name() { return this->name; }
|
std::wstring Module::get_name() { return this->name; }
|
||||||
|
|
|
@ -10,6 +10,8 @@ class Module {
|
||||||
std::wstring goods_name_regex;
|
std::wstring goods_name_regex;
|
||||||
std::wstring goods_price_regex;
|
std::wstring goods_price_regex;
|
||||||
std::wstring goods_quantity_regex;
|
std::wstring goods_quantity_regex;
|
||||||
|
std::wstring check_start_regex;
|
||||||
|
std::wstring check_end_regex;
|
||||||
public:
|
public:
|
||||||
Module(std::string);
|
Module(std::string);
|
||||||
Module();
|
Module();
|
||||||
|
@ -17,6 +19,8 @@ public:
|
||||||
std::vector<std::string> parse_name(std::wstring);
|
std::vector<std::string> parse_name(std::wstring);
|
||||||
std::vector<std::string> parse_price(std::wstring);
|
std::vector<std::string> parse_price(std::wstring);
|
||||||
std::vector<std::string> parse_quantity(std::wstring);
|
std::vector<std::string> parse_quantity(std::wstring);
|
||||||
|
std::wstring trim_check(std::wstring&);
|
||||||
|
|
||||||
|
|
||||||
std::wstring get_name();
|
std::wstring get_name();
|
||||||
};
|
};
|
||||||
|
|
|
@ -27,11 +27,13 @@ std::vector<std::string> Parser::search_modules() {
|
||||||
return modules_files;
|
return modules_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Parser::set_module(std::string path) { module = *(new Module(path)); }
|
void Parser::set_module(std::string path) { module = Module(path); }
|
||||||
|
|
||||||
std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
|
std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
|
||||||
std::vector<Goods> result;
|
std::vector<Goods> result;
|
||||||
|
|
||||||
|
module.trim_check(check_plaintext);
|
||||||
|
|
||||||
std::vector<std::string> goods_names = module.parse_name(check_plaintext);
|
std::vector<std::string> goods_names = module.parse_name(check_plaintext);
|
||||||
std::vector<std::string> goods_prices = module.parse_price(check_plaintext);
|
std::vector<std::string> goods_prices = module.parse_price(check_plaintext);
|
||||||
std::vector<std::string> goods_quantities =
|
std::vector<std::string> goods_quantities =
|
||||||
|
@ -42,7 +44,7 @@ std::vector<Goods> Parser::parse(std::wstring check_plaintext) {
|
||||||
if (goods_names.size() != goods_prices.size() ||
|
if (goods_names.size() != goods_prices.size() ||
|
||||||
goods_names.size() != goods_quantities.size() ||
|
goods_names.size() != goods_quantities.size() ||
|
||||||
goods_prices.size() != goods_quantities.size()) {
|
goods_prices.size() != goods_quantities.size()) {
|
||||||
std::cerr << "An error has occured. Check was matched incorrectly. Vector sizes are different" << std::endl;
|
//Error. Amount of names, prices or quantities are not equal. That means, that some regex(es) has mismatched.
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
short goods_amount = goods_names.size();
|
short goods_amount = goods_names.size();
|
||||||
|
|
Loading…
Reference in New Issue