remade text type switch as tabview

This commit is contained in:
leca 2024-10-22 13:18:19 +03:00
parent 4bf7638f6a
commit 02e4465075
12 changed files with 157 additions and 228 deletions

View File

@ -47,7 +47,7 @@ else()
outputdialog.h outputdialog.cpp outputdialog.ui outputdialog.h outputdialog.cpp outputdialog.ui
output/output_options.h output/output_options.cpp output/output_options.h output/output_options.cpp
ofd/ofd.h ofd/ofd.cpp ofd/ofd.h ofd/ofd.cpp
ofd/module.h ofd/module.cpp
utils/utils.h utils/utils.cpp utils/utils.h utils/utils.cpp
image/checkimage.h image/checkimage.cpp image/checkimage.h image/checkimage.cpp
net/net.h net/net.cpp net/net.h net/net.cpp
@ -92,4 +92,7 @@ include_directories("/usr/include/opencv4")
target_link_libraries(checks-parser PRIVATE -ltesseract) target_link_libraries(checks-parser PRIVATE -ltesseract)
target_link_libraries(checks-parser PRIVATE -lcurl) target_link_libraries(checks-parser PRIVATE -lcurl)
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) pkg_search_module(opencv REQUIRED IMPORTED_TARGET opencv)
target_link_libraries(checks-parser PRIVATE PkgConfig::opencv)
# target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
# target_link_libraries(checks-parser PRIVATE -lopencv)

View File

@ -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.1, 2024-10-05T17:58:40. --> <!-- Written by QtCreator 14.0.2, 2024-10-18T01:45:27. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
@ -102,14 +102,14 @@
<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">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_BUILD_TYPE:STRING=Debug
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</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>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@ -159,14 +159,14 @@
<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">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_BUILD_TYPE:STRING=Release
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</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">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@ -213,14 +213,14 @@
<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">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</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">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
@ -267,14 +267,14 @@
<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">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</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>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
@ -322,14 +322,14 @@
<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">-DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG} <value type="QString" key="CMake.Initial.Parameters">-DCMAKE_GENERATOR:STRING=Ninja
-DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable} -DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake
-DCMAKE_BUILD_TYPE:STRING=MinSizeRel -DCMAKE_BUILD_TYPE:STRING=MinSizeRel
-DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C} -DCMAKE_C_COMPILER:FILEPATH=%{Compiler:Executable:C}
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}
-DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx} -DCMAKE_CXX_COMPILER:FILEPATH=%{Compiler:Executable:Cxx}
-DCMAKE_GENERATOR:STRING=Ninja -DQT_QMAKE_EXECUTABLE:FILEPATH=%{Qt:qmakeExecutable}
-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH=%{BuildConfig:BuildDirectory:NativeFilePath}/.qtc/package-manager/auto-setup.cmake -DCMAKE_CXX_FLAGS_INIT:STRING=%{Qt:QML_DEBUG_FLAG}</value>
-DCMAKE_PREFIX_PATH:PATH=%{Qt:QT_INSTALL_PREFIX}</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">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">

BIN
captcha.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -21,17 +21,17 @@ int main(int argc, char *argv[]) {
OFD ofd; OFD ofd;
Net n; Net n;
std::vector<std::string> ofd_updates = ofd.check_updates(); // std::vector<std::string> ofd_updates = ofd.check_updates();
for (const std::string &update : ofd_updates) { // for (const std::string &update : ofd_updates) {
std::cout << "Downloading " // std::cout << "Downloading "
<< s.get_setting("ofds_modules_url") + update << " to " // << s.get_setting("ofds_modules_url") + update << " to "
<< get_path_relative_to_home(s.get_setting("ofds_modules_dir") + // << get_path_relative_to_home(s.get_setting("ofds_modules_dir") +
"/" + update) // "/" + update)
<< std::endl; // << std::endl;
n.get_file(s.get_setting("ofds_modules_url") + "/" + update, // n.get_file(s.get_setting("ofds_modules_url") + "/" + update,
get_path_relative_to_home(s.get_setting("ofds_modules_dir") + // get_path_relative_to_home(s.get_setting("ofds_modules_dir") +
"/" + update)); // "/" + update));
} // }
Parser p; Parser p;
std::vector<std::string> stores_updates = p.check_updates();\ std::vector<std::string> stores_updates = p.check_updates();\

View File

@ -36,9 +36,9 @@ void MainWindow::setupStoresList() {
#endif #endif
} }
void MainWindow::on_checkType_currentIndexChanged(int index) { // void MainWindow::on_checkType_currentIndexChanged(int index) {
ui->inputHolder->setCurrentIndex(index); // ui->inputHolder->setCurrentIndex(index);
} // }
void MainWindow::on_parseButton_clicked() { void MainWindow::on_parseButton_clicked() {
QString s; QString s;
@ -82,7 +82,7 @@ void MainWindow::on_chooseImageButton_clicked() {
std::cout << filename.toStdString() << std::endl; std::cout << filename.toStdString() << std::endl;
// this->options.set_path(filename.toStdString()); // this->options.set_path(filename.toStdString());
std::string new_text = "Path to export: " + filename.toStdString(); std::string new_text = "Selected: " + filename.toStdString();
ui->pathLabel->setText(QString::fromStdString(new_text)); ui->pathLabel->setText(QString::fromStdString(new_text));
CheckImage i(filename.toStdString()); CheckImage i(filename.toStdString());

View File

@ -25,7 +25,7 @@ public:
Check get_check(); Check get_check();
private slots: private slots:
void on_checkType_currentIndexChanged(int index); // void on_checkType_currentIndexChanged(int index);
void on_parseButton_clicked(); void on_parseButton_clicked();

View File

@ -70,95 +70,6 @@
</property> </property>
</item> </item>
</widget> </widget>
<widget class="QStackedWidget" name="inputHolder">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>501</width>
<height>471</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page_5">
<widget class="QLabel" name="checkContentLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>101</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Check content</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContent">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>431</width>
<height>401</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="page_6">
<widget class="QLabel" name="pathLabel">
<property name="geometry">
<rect>
<x>110</x>
<y>20</y>
<width>381</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Path to image: </string>
</property>
</widget>
<widget class="QPushButton" name="chooseImageButton">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>10</x>
<y>50</y>
<width>571</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Here is recognised check text. Please, edit it if something's wrong:</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContentFromImage">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>471</width>
<height>371</height>
</rect>
</property>
</widget>
</widget>
</widget>
<widget class="QPushButton" name="parseButton"> <widget class="QPushButton" name="parseButton">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@ -185,6 +96,106 @@
<string>Preferences</string> <string>Preferences</string>
</property> </property>
</widget> </widget>
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>80</y>
<width>601</width>
<height>471</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="Text">
<attribute name="title">
<string>Text</string>
</attribute>
<widget class="QLabel" name="checkContentLabel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>101</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Check content</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContent">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>431</width>
<height>241</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="OCR">
<attribute name="title">
<string>OCR</string>
</attribute>
<widget class="QPushButton" name="chooseImageButton">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>Choose</string>
</property>
</widget>
<widget class="QPlainTextEdit" name="checkContentFromImage">
<property name="geometry">
<rect>
<x>0</x>
<y>60</y>
<width>471</width>
<height>231</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="pathLabel">
<property name="geometry">
<rect>
<x>100</x>
<y>0</y>
<width>381</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Path to image: </string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>0</x>
<y>30</y>
<width>571</width>
<height>18</height>
</rect>
</property>
<property name="text">
<string>Here is recognised check text. Please, edit it if something's wrong:</string>
</property>
</widget>
</widget>
<widget class="QWidget" name="OFD">
<attribute name="title">
<string>OFD</string>
</attribute>
</widget>
</widget>
</widget> </widget>
<widget class="QMenuBar" name="menubar"> <widget class="QMenuBar" name="menubar">
<property name="geometry"> <property name="geometry">

2
ofd.desc Normal file
View File

@ -0,0 +1,2 @@
1. curl -X GET https://check.ofd.ru/api/captcha/common/img
2. curl 'https://check.ofd.ru/Document/FetchReceiptFromFns' -H 'content-type: application/json;charset=UTF-8' --data-raw '{"TotalSum":52344,"FnNumber":"7281440701327430","ReceiptOperationType":"1","DocNumber":"25955","DocFiscalSign":"2518183888","Captcha":"INSERT SOLVED CAPTCHA","DocDateTime":"2024-08-16T19:36:00.000Z"}'

View File

@ -1,18 +0,0 @@
#ifndef OFD_MODULE_H
#define OFD_MODULE_H
#include <string>
class OFDModule {
std::string path;
std::wstring name;
std::wstring url;
public:
OFDModule(std::string);
OFDModule();
std::wstring get_name();
std::wstring get_url();
};
#endif // OFDMODULE_H

View File

@ -1,67 +1,3 @@
#include "ofd.h" #include "ofd.h"
#include "../utils/utils.h"
#include <filesystem>
#include <iostream>
#include <string>
#include <vector>
#include "../net/net.h"
#include "../settings/settings.h"
OFD::OFD() {} OFD::OFD() {}
OFD::OFD(std::string path) { this->module = OFDModule(path); };
std::vector<std::string> OFD::search_ofds() {
Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json"));
std::vector<std::string> result{};
std::string path = get_path_relative_to_home(s.get_setting("ods_modules_dir"));
std::filesystem::directory_entry modules_dir(path);
if (!modules_dir.exists()) {
std::filesystem::create_directories(path);
std::cout << "No modules directory found. Created one at " << path
<< std::endl;
std::cout << "Please, download modules to that directory from my git."
<< std::endl;
}
for (auto file : std::filesystem::directory_iterator(path)) {
result.push_back(file.path());
}
return result;
}
void OFD::set_module(std::string path) { this->module = OFDModule(path); }
std::string OFD::get_check_data(std::string fn, std::string fd,
std::string fp) {
//TODO
return "";
}
std::vector<std::string> OFD::check_updates() {
Settings s(get_path_relative_to_home(".local/share/checks_parser/settings.json"));
std::string path = get_path_relative_to_home(s.get_setting("ofds_modules_dir"));
std::vector<std::string> to_download;
std::vector<std::string> stored_modules;
for (const auto& file : std::filesystem::directory_iterator(path)) {
if (!file.is_regular_file()) continue;
stored_modules.push_back(file.path().filename());
std::cout << "Detected OFD module" << file.path().filename() << std::endl;
}
Net n;
std::vector<std::string> remote_modules = n.get_all_modules(s.get_setting("ofds_modules_url"));
for (const std::string& module : remote_modules) {
if (!vector_contains_element(stored_modules, module)) {
to_download.push_back(module);
std::cout << "I need to download OFD module " << module << std::endl;
}
}
return to_download;
}

View File

@ -2,22 +2,12 @@
#define OFD_H #define OFD_H
#include <string> #include <string>
#include <vector>
#include "module.h"
class OFD { class OFD {
OFDModule module;
public: public:
OFD(); OFD();
OFD(std::string); void ask_captcha();
std::string request_and_parse_check(long fiscal_number, long fiscal_document, long fiscal_sign, std::string datetime, double total, std::string captcha);
std::vector<std::string> search_ofds();
void set_module(std::string);
std::string get_check_data(std::string fn, std::string fd, std::string fp);
std::vector<std::string> check_updates();
}; };
#endif // OFD_H #endif // OFD_H

View File

@ -3,6 +3,12 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <filesystem>
#include <iostream>
#include <string>
#include <vector>
#include "../net/net.h"
#include "../settings/settings.h"
enum class ColumnType { enum class ColumnType {
goods_name, goods_name,
@ -18,7 +24,6 @@ struct Column { // Example:
unsigned int position; // "0" <-- 0 = "A", 1 = "B", etc.. column letter in unsigned int position; // "0" <-- 0 = "A", 1 = "B", etc.. column letter in
// table processor (i.e. excel or libreoffice) // table processor (i.e. excel or libreoffice)
} typedef Column; } typedef Column;
enum class OutputFormat { csv, ods, xlsx, plaintext } typedef OutputFormat; enum class OutputFormat { csv, ods, xlsx, plaintext } typedef OutputFormat;
class OutputOptions { class OutputOptions {