restructure libs
This commit is contained in:
parent
ec0b7cbf0d
commit
e89728846c
19 changed files with 79 additions and 67 deletions
|
@ -29,11 +29,11 @@ set(CORE_SOURCES
|
||||||
add_library(core STATIC ${CORE_SOURCES})
|
add_library(core STATIC ${CORE_SOURCES})
|
||||||
target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/csv-parser/include)
|
target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/csv-parser/include)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(core PRIVATE printer Boost::boost Boost::date_time sqlite3 nlohmann_json::nlohmann_json ${XLNT_LIBRARY} csv)
|
target_link_libraries(core PRIVATE Boost::boost Boost::date_time sqlite3 nlohmann_json::nlohmann_json ${XLNT_LIBRARY} csv)
|
||||||
target_link_libraries(core PRIVATE bcrypt)
|
target_link_libraries(core PRIVATE bcrypt)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(core PRIVATE printer Boost::boost Boost::date_time sqlite3 nlohmann_json::nlohmann_json ${XLNT_LIBRARIES} csv)
|
target_link_libraries(core PRIVATE Boost::boost Boost::date_time sqlite3 nlohmann_json::nlohmann_json ${XLNT_LIBRARIES} csv)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/csv-parser)
|
#target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/csv-parser)
|
||||||
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
|
|
|
@ -21,31 +21,6 @@ std::string formatCentAsEuroString(const int cent, int width)
|
||||||
return currStream.str();
|
return currStream.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& device,
|
|
||||||
const std::string& endpoint)
|
|
||||||
{
|
|
||||||
if (device.empty()) {
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
PrinterDevice printerDevice;
|
|
||||||
std::string delimiter = ":";
|
|
||||||
try {
|
|
||||||
printerDevice.idVendor = std::stoi(device.substr(0, device.find(delimiter)), 0, 16);
|
|
||||||
printerDevice.idProduct = std::stoi(device.substr(device.find(delimiter) + 1), 0, 16);
|
|
||||||
if (endpoint.empty()) {
|
|
||||||
printerDevice.endpoint = 0x03;
|
|
||||||
} else {
|
|
||||||
printerDevice.endpoint = std::stoi(endpoint, 0, 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (std::exception& ex) {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
return printerDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string& ltrim(std::string& str, const std::string& chars)
|
std::string& ltrim(std::string& str, const std::string& chars)
|
||||||
{
|
{
|
||||||
str.erase(0, str.find_first_not_of(chars));
|
str.erase(0, str.find_first_not_of(chars));
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
#ifndef UTILS_H
|
#ifndef CORE_UTILS_H
|
||||||
#define UTILS_H
|
#define CORE_UTILS_H
|
||||||
|
|
||||||
#include "posprinter.h"
|
|
||||||
|
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
std::string formatCentAsEuroString(const int cent, int width = 10);
|
std::string formatCentAsEuroString(const int cent, int width = 10);
|
||||||
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& vendor,
|
|
||||||
const std::string& endpoint);
|
|
||||||
std::string& ltrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
std::string& ltrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
||||||
std::string& rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
std::string& rtrim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
||||||
std::string& trim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
std::string& trim(std::string& str, const std::string& chars = "\t\n\v\f\r ");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef BASKET_MODEL_H
|
#ifndef BASKET_MODEL_H
|
||||||
#define BASKET_MODEL_H
|
#define BASKET_MODEL_H
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
|
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
#include "basketmodel.h"
|
#include "basketmodel.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "jsonutil.h"
|
|
||||||
#include "pricedialog.h"
|
#include "pricedialog.h"
|
||||||
#include "reportdialog.h"
|
#include "reportdialog.h"
|
||||||
#include "salemodel.h"
|
#include "salemodel.h"
|
||||||
#include "sellerdialog.h"
|
#include "sellerdialog.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
|
|
||||||
#include <utils.h>
|
#include <core/csvreader.h>
|
||||||
|
#include <core/excelreader.h>
|
||||||
#include <csvreader.h>
|
#include <core/jsonutil.h>
|
||||||
#include <excelreader.h>
|
#include <core/utils.h>
|
||||||
#include <posprinter.h>
|
#include <printer/posprinter.h>
|
||||||
|
#include <printer/utils.h>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QtGui/QCloseEvent>
|
#include <QtGui/QCloseEvent>
|
||||||
|
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <posprinter.h>
|
#include <core/utils.h>
|
||||||
#include <utils.h>
|
#include <printer/posprinter.h>
|
||||||
|
#include <printer/utils.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "reportmodel.h"
|
#include "reportmodel.h"
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef REPORT_MODEL_H
|
#ifndef REPORT_MODEL_H
|
||||||
#define REPORT_MODEL_H
|
#define REPORT_MODEL_H
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "salemodel.h"
|
#include "salemodel.h"
|
||||||
|
|
||||||
#include <article.h>
|
#include <core/article.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SALEMODEL_H
|
#ifndef SALEMODEL_H
|
||||||
#define SALEMODEL_H
|
#define SALEMODEL_H
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef SELLER_MODEL_H
|
#ifndef SELLER_MODEL_H
|
||||||
#define SELLER_MODEL_H
|
#define SELLER_MODEL_H
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <database.h>
|
#include <core/database.h>
|
||||||
#include <posprinter.h>
|
#include <printer/posprinter.h>
|
||||||
#include <utils.h>
|
#include <printer/utils.h>
|
||||||
|
#include <core/utils.h>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "ui_settingsdialog.h"
|
#include "ui_settingsdialog.h"
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ endif()
|
||||||
|
|
||||||
set(PRINTER_SOURCES
|
set(PRINTER_SOURCES
|
||||||
posprinter.cpp
|
posprinter.cpp
|
||||||
|
utils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(printer STATIC ${PRINTER_SOURCES})
|
add_library(printer STATIC ${PRINTER_SOURCES})
|
||||||
|
@ -19,4 +20,4 @@ if(WIN32)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(printer core ${LibUSB_LIBRARIES})
|
target_link_libraries(printer core ${LibUSB_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "posprinter.h"
|
#include "posprinter.h"
|
||||||
|
|
||||||
#include <marketplace.h>
|
#include <core/marketplace.h>
|
||||||
|
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef POS_PRINTER_H
|
#ifndef POS_PRINTER_H
|
||||||
#define POS_PRINTER_H
|
#define POS_PRINTER_H
|
||||||
|
|
||||||
#include <sale.h>
|
#include <core/sale.h>
|
||||||
#include <seller.h>
|
#include <core/seller.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
26
src/printer/utils.cpp
Normal file
26
src/printer/utils.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& device,
|
||||||
|
const std::string& endpoint)
|
||||||
|
{
|
||||||
|
if (device.empty()) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrinterDevice printerDevice;
|
||||||
|
std::string delimiter = ":";
|
||||||
|
try {
|
||||||
|
printerDevice.idVendor = std::stoi(device.substr(0, device.find(delimiter)), 0, 16);
|
||||||
|
printerDevice.idProduct = std::stoi(device.substr(device.find(delimiter) + 1), 0, 16);
|
||||||
|
if (endpoint.empty()) {
|
||||||
|
printerDevice.endpoint = 0x03;
|
||||||
|
} else {
|
||||||
|
printerDevice.endpoint = std::stoi(endpoint, 0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (std::exception& ex) {
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return printerDevice;
|
||||||
|
}
|
12
src/printer/utils.h
Normal file
12
src/printer/utils.h
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef PRINTER_UTILS_H
|
||||||
|
#define PRINTER_UTILS_H
|
||||||
|
|
||||||
|
#include "posprinter.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
std::optional<PrinterDevice> convertToPosPrinterDevice(const std::string& vendor,
|
||||||
|
const std::string& endpoint);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue