diff --git a/CMakeLists.txt b/CMakeLists.txt index f523a58..6cf61f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,7 +95,6 @@ if( MINGW ) ${MINGW_PATH}/libwinpthread-1.dll ${MINGW_PATH}/libsqlite3-0.dll ${MINGW_PATH}/libusb-1.0.dll - ${MINGW_PATH}/libxlnt.dll ${MINGW_PATH}/libicuuc71.dll ${MINGW_PATH}/libicuin71.dll ${MINGW_PATH}/libicudt71.dll diff --git a/misc/PKGBUILD b/misc/PKGBUILD index a1dd6bb..3da552c 100644 --- a/misc/PKGBUILD +++ b/misc/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc="A small cash point program for children's things markets (German only)" arch=('i686' 'x86_64') url="http://www.rustysoft.de/software/kima2" license=('custom') -depends=('glibc' 'libusb' 'qt6-base' 'sqlite3' 'xlnt') +depends=('glibc' 'libusb' 'qt6-base' 'sqlite3') makedepends=('boost>=1.62') source=(git+https://git.rustysoft.de/martin/kima2) sha256sums=('SKIP') diff --git a/misc/kima2.spec b/misc/kima2.spec index 0c3feff..2c586a8 100644 --- a/misc/kima2.spec +++ b/misc/kima2.spec @@ -13,7 +13,6 @@ BuildRequires: boost-date-time BuildRequires: sqlite-devel BuildRequires: libusb-devel BuildRequires: qt5-qtdeclarative-devel -#BuildRequires: pkgconfig(xlnt) #BuildRequires: pkgconfig(pthreads) %description diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 90b6fbc..8aa1e2c 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -9,14 +9,6 @@ find_package(Threads REQUIRED) find_package(fmt) - -if (MINGW) - find_package(XLNT REQUIRED STATIC) -else (MINGW) - find_package(PkgConfig REQUIRED) - pkg_check_modules(XLNT REQUIRED xlnt>=1.3) -endif (MINGW) - set(CORE_SOURCES database.cpp entity.cpp @@ -26,7 +18,6 @@ set(CORE_SOURCES article.cpp sale.cpp marketplace.cpp - excelreader.cpp csvreader.cpp jsonutil.cpp utils.cpp diff --git a/src/core/excelreader.cpp b/src/core/excelreader.cpp deleted file mode 100644 index f2d9372..0000000 --- a/src/core/excelreader.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "excelreader.h" -#include "utils.h" - -#include -#include - -namespace fs = std::filesystem; - -std::size_t ExcelReader::readSellersFromFile(const fs::path &filePath, Marketplace *market) -{ - xlnt::workbook wb; - std::ifstream mystream(filePath, std::ios::binary); - if (!mystream.is_open()) { - throw std::runtime_error("Could not open Excel file"); - } - wb.load(mystream); - - for (auto &seller : market->getSellers()) { - seller->setState(Seller::State::DELETE); - } - - market->storeToDb(true); - auto ws = wb.sheet_by_index(0); - - for (auto row : ws.rows(true)) { - // Skip the row if the first value is not a number (= seller no) - if (row[0].data_type() != xlnt::cell::type::number) { - continue; - } - - auto seller = std::make_unique(); - seller->setSellerNo(row[0].value()); - seller->setNumArticlesOffered(row[1].value()); - - // If both, first name and last name, are empty, use N. N. - // Else, use the real values. - if (row[2].value().empty() && row[3].value().empty()) { - seller->setFirstName("N."); - seller->setLastName("N."); - } else { - std::string firstName = row[2].value(); - seller->setFirstName(trim(firstName)); - std::string lastName = row[3].value(); - seller->setLastName(trim(lastName)); - } - - market->getSellers().push_back(std::move(seller)); - } - - // Add one additional seller "RESERVE RESERVE" - auto seller = std::make_unique(); - seller->setSellerNo(market->getNextSellerNo()); - seller->setFirstName("RESERVE"); - seller->setLastName("RESERVE"); - market->getSellers().push_back(std::move(seller)); - - // If there was no special seller "Sonderkonto" in import data, then create one - auto specialSeller = market->findSellerWithSellerNo(0); - if (!specialSeller) { - auto seller = std::make_unique(); - seller->setSellerNo(0); - seller->setLastName("Sonderkonto"); - seller->setFirstName("Sonderkonto"); - seller->setNumArticlesOffered(0); - market->getSellers().push_back(std::move(seller)); - } - - market->sortSellers(); - market->storeToDb(); - - return market->getSellers().size() - 1; // minus 1 because we don't count the "special" seller -} diff --git a/src/core/excelreader.h b/src/core/excelreader.h deleted file mode 100644 index 1d2eefd..0000000 --- a/src/core/excelreader.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef EXCEL_READER_H -#define EXCEL_READER_H - -#include "marketplace.h" -#include "seller.h" - -#include -#include -#include -#include - -class ExcelReader -{ -public: - static std::size_t readSellersFromFile(const std::filesystem::path &filePath, - Marketplace *market); -}; - -#endif \ No newline at end of file diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 526fe1b..3563d6e 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -137,8 +136,8 @@ MainWindow::MainWindow() this->setWindowTitle("KIMA2 - Kasse Nr. " + QSettings().value("global/cashPointNo").toString()); }); - connect(m_ui.importSellerExcelAction, &QAction::triggered, this, - &MainWindow::onImportSellerExcelActionTriggered); + connect(m_ui.importSellerAction, &QAction::triggered, this, + &MainWindow::onImportSellerActionTriggered); connect(m_ui.importSellerJsonAction, &QAction::triggered, this, &MainWindow::onImportSellerJsonActionTriggered); connect(m_ui.exportSellerJsonAction, &QAction::triggered, this, @@ -345,7 +344,8 @@ void MainWindow::onCancelArticleButtonClicked([[maybe_unused]] bool checked) m_ui.basketView->model()->removeRow(iter->row()); } - m_ui.basketSumLabel->setText(m_marketplace->getBasketSumAsString().c_str()); // Update basket sum + m_ui.basketSumLabel->setText( + m_marketplace->getBasketSumAsString().c_str()); // Update basket sum m_ui.sellerNoEdit->setFocus(); } @@ -428,7 +428,8 @@ void MainWindow::onCancelAllArticlesButtonClicked([[maybe_unused]] bool checked) dynamic_cast(m_ui.basketView->model())->cancelSale(); - m_ui.basketSumLabel->setText(m_marketplace->getBasketSumAsString().c_str()); // Update basket sum + m_ui.basketSumLabel->setText( + m_marketplace->getBasketSumAsString().c_str()); // Update basket sum m_ui.sellerNoEdit->setFocus(); } @@ -445,7 +446,7 @@ void MainWindow::onAbout() ">info@rustysoft.de>

"); } -void MainWindow::onImportSellerExcelActionTriggered() +void MainWindow::onImportSellerActionTriggered() { if (!m_marketplace->getSales().empty()) { QMessageBox(QMessageBox::Icon::Information, "Import nicht möglich", @@ -455,9 +456,9 @@ void MainWindow::onImportSellerExcelActionTriggered() return; } - auto filename = QFileDialog::getOpenFileName( - this, "Verkäufer importieren", QString(), - "Alle unterstützte Dateien (*.xlsx *.csv);;Excel Dateien (*.xlsx);;CSV Dateien (*.csv)"); + auto filename = + QFileDialog::getOpenFileName(this, "Verkäufer importieren", QString(), + "Alle unterstützte Dateien (*.csv);;CSV Dateien (*.csv)"); if (filename.isEmpty()) return; @@ -469,27 +470,13 @@ void MainWindow::onImportSellerExcelActionTriggered() #endif std::size_t numImported{}; - if (case_insensitive_match(filePath.extension().string(), std::string(".xlsx"))) { - try { - numImported = ExcelReader::readSellersFromFile(filePath, m_marketplace.get()); - } catch (const std::exception &e) { - QMessageBox(QMessageBox::Icon::Critical, "Fehler beim Importieren", - "Beim Import aus der Excel-Datei ist ein Fehler aufgetreten. " - "Sie könnten ggf. versuchen, die Daten aus einer .csv Datei zu imporieren.", - QMessageBox::StandardButton::Ok, this) - .exec(); - std::cerr << e.what() << std::endl; - return; - } - } else { - numImported = CsvReader::readSellersFromFile(filePath, m_marketplace.get()); - } + numImported = CsvReader::readSellersFromFile(filePath, m_marketplace.get()); updateStatLabel(); using namespace std::string_literals; std::ostringstream msg; - msg << "Aus der Excel/CSV-Datei wurden "s << std::to_string(numImported) + msg << "Aus der CSV-Datei wurden "s << std::to_string(numImported) << " Verkäufer importiert."; QMessageBox(QMessageBox::Icon::Information, "Verkäufer erfolgreich importiert", msg.str().c_str(), QMessageBox::StandardButton::Ok, this) diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 1fba01a..39f8c37 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -39,7 +39,7 @@ class MainWindow : public QMainWindow void checkSellerNo(bool ctrlPressed = false); void onPaidButtonTriggered(); void onGivenSpinBoxValueChanged(double value); - void onImportSellerExcelActionTriggered(); + void onImportSellerActionTriggered(); void onImportSellerJsonActionTriggered(); void onExportSellerJsonActionTriggered(); void onExportSalesJsonActionTriggered(); diff --git a/src/gui/mainwindow.ui b/src/gui/mainwindow.ui index a77a297..d409caa 100644 --- a/src/gui/mainwindow.ui +++ b/src/gui/mainwindow.ui @@ -423,7 +423,7 @@ drucken
0 0 817 - 30 + 24 @@ -444,7 +444,7 @@ drucken Importieren - + @@ -513,9 +513,9 @@ drucken Exportieren für andere Kasse (JSON) - + - Aus Excel/CSV-Datei (initial) + Aus CSV-Datei (initial)