Compare commits
4 commits
ad895abd35
...
d13f9d2824
Author | SHA1 | Date | |
---|---|---|---|
d13f9d2824 | |||
2faa2fa019 | |||
fc308c644c | |||
e89728846c |
31 changed files with 152 additions and 81 deletions
6
.gitmodules
vendored
6
.gitmodules
vendored
|
@ -1,9 +1,9 @@
|
|||
[submodule "3rdparty/nlohmann_json"]
|
||||
path = 3rdparty/nlohmann_json
|
||||
path = subprojects/nlohmann_json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
[submodule "3rdparty/singleapplication"]
|
||||
path = 3rdparty/singleapplication
|
||||
path = subprojects/singleapplication/singleapplication.git
|
||||
url = https://github.com/itay-grudev/SingleApplication.git
|
||||
[submodule "3rdparty/csv-parser"]
|
||||
path = 3rdparty/csv-parser
|
||||
path = subprojects/csv-parser
|
||||
url = https://github.com/vincentlaucsb/csv-parser.git
|
||||
|
|
19
meson.build
19
meson.build
|
@ -1,3 +1,20 @@
|
|||
project('kima2', 'cpp')
|
||||
project('kima2', 'cpp', default_options : ['cpp_std=c++17'], version : '1.6.0')
|
||||
|
||||
conf_data = configuration_data()
|
||||
conf_data.set('PROJECT_VERSION', '"' + meson.project_version() + '"')
|
||||
configure_file(output : 'config.h',
|
||||
configuration : conf_data)
|
||||
configuration_inc = include_directories('.')
|
||||
|
||||
cmake = import('cmake')
|
||||
|
||||
#csv = cmake.subproject('csv-parser')
|
||||
#csv_lib = csv.dependency('csv')
|
||||
nlohmann = cmake.subproject('nlohmann_json', cmake_options : ['-DJSON_BuildTests=OFF', '-DCMAKE_BUILD_TYPE=Release'])
|
||||
nlohmann_lib = nlohmann.dependency('nlohmann_json')
|
||||
|
||||
singleapp_proj = subproject('singleapplication')
|
||||
singleapp_lib = singleapp_proj.get_variable('singleapp_lib')
|
||||
singleapp_dep = singleapp_proj.get_variable('singleapp_dep')
|
||||
|
||||
subdir('src')
|
||||
|
|
|
@ -29,11 +29,11 @@ set(CORE_SOURCES
|
|||
add_library(core STATIC ${CORE_SOURCES})
|
||||
target_include_directories(core PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/csv-parser/include)
|
||||
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)
|
||||
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()
|
||||
|
||||
#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}/..)
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#include "utils.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <csv.hpp>
|
||||
#include "../../subprojects/csv-parser/single_include/csv.hpp"
|
||||
//#include <csv.hpp>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
|
|
|
@ -6,4 +6,8 @@ src = ['database.cpp', 'entity.cpp', 'entityint.cpp', 'entityuuid.cpp',
|
|||
'seller.cpp', 'article.cpp', 'sale.cpp', 'marketplace.cpp',
|
||||
'excelreader.cpp', 'csvreader.cpp', 'jsonutil.cpp', 'utils.cpp']
|
||||
|
||||
core_lib = static_library('core', src, dependencies :[boost, xlnt, sqlite])
|
||||
core_inc = include_directories('..')
|
||||
|
||||
core_lib = static_library('core', src, dependencies :[boost, xlnt, sqlite, nlohmann_lib])
|
||||
|
||||
core_dep = declare_dependency(link_with : core_lib, include_directories : core_inc)
|
||||
|
|
|
@ -21,31 +21,6 @@ std::string formatCentAsEuroString(const int cent, int width)
|
|||
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)
|
||||
{
|
||||
str.erase(0, str.find_first_not_of(chars));
|
||||
|
@ -71,4 +46,4 @@ bool case_insensitive_match(std::string s1, std::string s2)
|
|||
if (s1.compare(s2) == 0)
|
||||
return true; // The strings are same
|
||||
return false; // not matched
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
#ifndef UTILS_H
|
||||
#define UTILS_H
|
||||
|
||||
#include "posprinter.h"
|
||||
#ifndef CORE_UTILS_H
|
||||
#define CORE_UTILS_H
|
||||
|
||||
#include <locale>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
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& 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 ");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef BASKET_MODEL_H
|
||||
#define BASKET_MODEL_H
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
|
@ -27,4 +27,4 @@ class BasketModel : public QAbstractTableModel
|
|||
Marketplace* marketplace_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
#include "mainwindow.h"
|
||||
|
||||
#include "basketmodel.h"
|
||||
#include "config.h"
|
||||
#include "jsonutil.h"
|
||||
#include <config.h>
|
||||
#include "pricedialog.h"
|
||||
#include "reportdialog.h"
|
||||
#include "salemodel.h"
|
||||
#include "sellerdialog.h"
|
||||
#include "settingsdialog.h"
|
||||
|
||||
#include <utils.h>
|
||||
|
||||
#include <csvreader.h>
|
||||
#include <excelreader.h>
|
||||
#include <posprinter.h>
|
||||
#include <core/csvreader.h>
|
||||
#include <core/excelreader.h>
|
||||
#include <core/jsonutil.h>
|
||||
#include <core/utils.h>
|
||||
#include <printer/posprinter.h>
|
||||
#include <printer/utils.h>
|
||||
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QtGui/QCloseEvent>
|
||||
|
@ -53,4 +53,4 @@ class MainWindow : public QMainWindow
|
|||
std::unique_ptr<Marketplace> marketplace_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
qt5 = import('qt5')
|
||||
qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'PrintSupport'])
|
||||
qt5_dep = dependency('qt5', modules: ['Core', 'Gui', 'PrintSupport', 'Network'])
|
||||
|
||||
thread_dep = dependency('threads')
|
||||
|
||||
|
||||
src = ['kima2.cpp', 'mainwindow.cpp', 'sellerdialog.cpp', 'sellermodel.cpp',
|
||||
'pricedialog.cpp', 'basketmodel.cpp', 'salemodel.cpp', 'reportdialog.cpp',
|
||||
|
@ -7,9 +10,12 @@ src = ['kima2.cpp', 'mainwindow.cpp', 'sellerdialog.cpp', 'sellermodel.cpp',
|
|||
|
||||
ui = ['mainwindow.ui', 'sellerdialog.ui', 'pricedialog.ui', 'reportdialog.ui', 'settingsdialog.ui']
|
||||
|
||||
processed = qt5.preprocess(moc_headers : ['basketmodel.h', 'mainwindow.h', 'pricedialog.h', 'reportdialog.h', 'sellerdialog.h', 'settingsdialog.h'],
|
||||
processed = qt5.preprocess(moc_headers : ['basketmodel.h', 'mainwindow.h', 'pricedialog.h',
|
||||
'reportdialog.h', 'sellerdialog.h', 'settingsdialog.h',
|
||||
'sellermodel.h', 'salemodel.h'],
|
||||
ui_files : ui,
|
||||
qresources : '../../kima2.qrc',
|
||||
dependencies: qt5_dep)
|
||||
|
||||
kima2 = executable('kima2', sources : [src, processed], dependencies : qt5_dep)
|
||||
kima2 = executable('kima2', sources : [src, processed], dependencies : [qt5_dep, singleapp_dep, core_dep, printer_dep, thread_dep],
|
||||
include_directories : [configuration_inc])
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <posprinter.h>
|
||||
#include <utils.h>
|
||||
#include <core/utils.h>
|
||||
#include <printer/posprinter.h>
|
||||
#include <printer/utils.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "reportmodel.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
|
@ -30,4 +30,4 @@ class ReportDialog : public QDialog
|
|||
std::unique_ptr<ReportModel> model_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef REPORT_MODEL_H
|
||||
#define REPORT_MODEL_H
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
|
@ -20,4 +20,4 @@ class ReportModel : public QAbstractTableModel
|
|||
int maxFeeInCent_{};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "salemodel.h"
|
||||
|
||||
#include <article.h>
|
||||
#include <core/article.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SALEMODEL_H
|
||||
#define SALEMODEL_H
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
|
@ -28,4 +28,4 @@ class SaleModel : public QAbstractItemModel
|
|||
std::unique_ptr<Sale> rootItem{new Sale()};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SELLER_MODEL_H
|
||||
#define SELLER_MODEL_H
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
|
@ -28,4 +28,4 @@ class SellerModel : public QAbstractTableModel
|
|||
Marketplace* marketplace_;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <database.h>
|
||||
#include <posprinter.h>
|
||||
#include <utils.h>
|
||||
#include <core/database.h>
|
||||
#include <printer/posprinter.h>
|
||||
#include <printer/utils.h>
|
||||
#include <core/utils.h>
|
||||
|
||||
#include <exception>
|
||||
#include <stdexcept>
|
||||
|
@ -116,4 +117,4 @@ void SettingsDialog::accept()
|
|||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
|
||||
#include "ui_settingsdialog.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialog(QWidget* parent = nullptr,
|
||||
Qt::WindowFlags f = Qt::WindowTitleHint | Qt::WindowSystemMenuHint);
|
||||
|
@ -21,4 +23,4 @@ class SettingsDialog : public QDialog
|
|||
Marketplace* market_{};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
printer = dependency('printer_dep', fallback : ['printer', 'printer_dep'])
|
||||
|
||||
subdir('core')
|
||||
subdir('printer')
|
||||
subdir('gui')
|
||||
|
|
|
@ -11,6 +11,7 @@ endif()
|
|||
|
||||
set(PRINTER_SOURCES
|
||||
posprinter.cpp
|
||||
utils.cpp
|
||||
)
|
||||
|
||||
add_library(printer STATIC ${PRINTER_SOURCES})
|
||||
|
@ -19,4 +20,4 @@ if(WIN32)
|
|||
else()
|
||||
target_link_libraries(printer core ${LibUSB_LIBRARIES})
|
||||
endif()
|
||||
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(printer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
libusb = dependency('libusb-1.0')
|
||||
|
||||
src = ['posprinter.cpp']
|
||||
src = ['posprinter.cpp', 'utils.cpp']
|
||||
|
||||
printer_lib = static_library('printer', src, dependencies: [libusb])
|
||||
printer_inc = include_directories('..')
|
||||
|
||||
printer_lib = static_library('printer', src, dependencies: [libusb, core_dep])
|
||||
|
||||
printer_dep = declare_dependency(link_with : printer_lib, include_directories : printer_inc)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "posprinter.h"
|
||||
|
||||
#include <marketplace.h>
|
||||
#include <core/marketplace.h>
|
||||
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
|
@ -213,4 +213,4 @@ bool PosPrinter::isValid()
|
|||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef POS_PRINTER_H
|
||||
#define POS_PRINTER_H
|
||||
|
||||
#include <sale.h>
|
||||
#include <seller.h>
|
||||
#include <core/sale.h>
|
||||
#include <core/seller.h>
|
||||
|
||||
#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
|
27
subprojects/singleapplication/meson.build
Normal file
27
subprojects/singleapplication/meson.build
Normal file
|
@ -0,0 +1,27 @@
|
|||
project('singleapplication')
|
||||
|
||||
qt5 = import('qt5')
|
||||
dep_qt5 = dependency('qt5', modules: ['Core', 'Widgets', 'Network'])
|
||||
|
||||
singleapp_inc = include_directories('singleapplication.git')
|
||||
|
||||
singleapp_moc = qt5.preprocess(
|
||||
moc_headers: ['singleapplication.git/singleapplication.h', 'singleapplication.git/singleapplication_p.h'],
|
||||
moc_extra_arguments: ['-DQAPPLICATION_CLASS=QApplication'],
|
||||
dependencies: dep_qt5
|
||||
)
|
||||
|
||||
singleapp_lib = static_library('SingleApplication',
|
||||
['singleapplication.git/singleapplication.cpp', 'singleapplication.git/singleapplication_p.cpp', singleapp_moc],
|
||||
include_directories: singleapp_inc,
|
||||
cpp_args : '-DQAPPLICATION_CLASS=QApplication',
|
||||
dependencies: dep_qt5
|
||||
)
|
||||
|
||||
singleapp_dep = declare_dependency(
|
||||
include_directories: singleapp_inc,
|
||||
link_with: singleapp_lib
|
||||
)
|
||||
|
||||
# On windows, SingleApplication needs to be linked against advapi32. This is
|
||||
# done by adding 'advapi32' to cpp_winlibs, where it should be by default.
|
Loading…
Reference in a new issue