From 6806ec53fb57e1eee97eb0112a83f9a4083c8d91 Mon Sep 17 00:00:00 2001 From: markuspg Date: Wed, 12 Oct 2016 00:46:14 +0200 Subject: [PATCH] Fully implemented manual receipts printing --- src/Lib/receipts_handler.cpp | 8 ++++---- src/Lib/receipts_handler.h | 2 +- src/mainwindow.cpp | 14 ++++++++++++++ src/mainwindow.h | 7 +++++++ src/manualprintingsetup.cpp | 12 ++++++------ src/manualprintingsetup.h | 9 ++++++--- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Lib/receipts_handler.cpp b/src/Lib/receipts_handler.cpp index 2582daa..d702b6a 100644 --- a/src/Lib/receipts_handler.cpp +++ b/src/Lib/receipts_handler.cpp @@ -54,12 +54,12 @@ lc::ReceiptsHandler::ReceiptsHandler( const QString &argZTreeDataTargetPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const QString &argLatexHeaderName, - const QString * const argDateString, QObject *argParent ) : + const QString &argDateString, QObject *argParent ) : QObject{ argParent }, anonymousReceiptsPlaceholder{ argAnonymousReceiptsPlaceholder }, - dateString{ *argDateString }, - expectedPaymentFileName{ *argDateString + ".pay" }, - expectedPaymentFilePath{ argZTreeDataTargetPath + "/" + *argDateString + ".pay" }, + dateString{ argDateString }, + expectedPaymentFileName{ argDateString + ".pay" }, + expectedPaymentFilePath{ argZTreeDataTargetPath + "/" + argDateString + ".pay" }, latexHeaderName{ argLatexHeaderName }, paymentFile{ expectedPaymentFilePath }, printReceiptsForLocalClients{ argPrintReceiptsForLocalClients }, diff --git a/src/Lib/receipts_handler.h b/src/Lib/receipts_handler.h index eb0b1b3..68b0841 100644 --- a/src/Lib/receipts_handler.h +++ b/src/Lib/receipts_handler.h @@ -54,7 +54,7 @@ public: bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const QString &argLatexHeaderName, - const QString * const argDateString, QObject *argParent = nullptr ); + const QString &argDateString, QObject *argParent = nullptr ); signals: void PrintingFinished(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1822203..90a34ee 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -425,6 +425,8 @@ void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() { manPrint->show(); connect( manPrint, SIGNAL( destroyed( QObject* ) ), manPrint, SLOT( deleteLater() ) ); + connect( manPrint, &ManualPrintingSetup::RequestReceiptsHandler, + this, &MainWindow::StartReceiptsHandler ); } void lc::MainWindow::on_PBRunzLeaf_clicked() { @@ -673,6 +675,18 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers startProc.startDetached( settings->tasksetCmd, arguments ); } +void lc::MainWindow::StartReceiptsHandler( QString argzTreeDataTargetPath, + bool argReceiptsForLocalClients, + QString argAnonymousReceiptsPlaceholder, + QString argLatexHeaderName, QString argDateString) { + ReceiptsHandler *recHand = new ReceiptsHandler{ argzTreeDataTargetPath, + argReceiptsForLocalClients, + argAnonymousReceiptsPlaceholder, + argLatexHeaderName, argDateString, this }; + connect( recHand, &ReceiptsHandler::PrintingFinished, + recHand, &ReceiptsHandler::deleteLater ); +} + void lc::MainWindow::UpdateClientsTableView() { for ( auto s : *valid_items ) { state_t state = static_cast< Client* >( s->data( Qt::UserRole ).value() )->GetClientState(); diff --git a/src/mainwindow.h b/src/mainwindow.h index b3de70c..e2c0518 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -109,6 +109,13 @@ private: QButtonGroup *userChooseButtonGroup = nullptr; //! Used to group the radio buttons choosing which user shall be used for administrative client actions Ui::MainWindow *ui = nullptr; //! Pointer storing all GUI items QVector *valid_items = nullptr; //! Stores all valid Client instances displayed by the table view, its main use is as iterable object for 'update_clients_table_view()' + +private slots: + void StartReceiptsHandler( QString argzTreeDataTargetPath, + bool argReceiptsForLocalClients, + QString argAnonymousReceiptsPlaceholder, + QString argLatexHeaderName, + QString argDateString ); }; } diff --git a/src/manualprintingsetup.cpp b/src/manualprintingsetup.cpp index 800dc53..e1aed9a 100644 --- a/src/manualprintingsetup.cpp +++ b/src/manualprintingsetup.cpp @@ -64,11 +64,11 @@ void lc::ManualPrintingSetup::on_PBSelectFile_clicked() { if ( fileDialog.exec() ) { ui->PBSelectFile->setStyleSheet( "" ); const QString tmpFileName{ fileDialog.selectedFiles().at( 0 ) }; - const QString dateString{ tmpFileName.split( '/', QString::KeepEmptyParts, - Qt::CaseInsensitive ).last() + dateString = tmpFileName.split( '/', QString::KeepEmptyParts, + Qt::CaseInsensitive ).last() .split( '.', QString::KeepEmptyParts, - Qt::CaseInsensitive ).first() }; - QString workPath{ tmpFileName }; + Qt::CaseInsensitive ).first(); + workPath = tmpFileName; workPath.truncate( workPath.lastIndexOf( '/' ) ); } } @@ -91,9 +91,9 @@ void lc::ManualPrintingSetup::on_PBPrint_clicked() { anonymousReceiptsPlaceholder = ui->CBReplaceParticipantNames->currentText(); } - emit RequestReceiptsHandler( ui->ChBReceiptsForLocalClients->isChecked(), + emit RequestReceiptsHandler( workPath, ui->ChBReceiptsForLocalClients->isChecked(), anonymousReceiptsPlaceholder, - ui->CBReceiptsHeader->currentText() ); + ui->CBReceiptsHeader->currentText(), dateString ); this->deleteLater(); } diff --git a/src/manualprintingsetup.h b/src/manualprintingsetup.h index e0d5f58..beec904 100644 --- a/src/manualprintingsetup.h +++ b/src/manualprintingsetup.h @@ -36,13 +36,16 @@ public: ~ManualPrintingSetup(); signals: - void RequestReceiptsHandler( bool argReceiptsForLocalClients, + void RequestReceiptsHandler( QString argzTreeDataTargetPath, + bool argReceiptsForLocalClients, QString argAnonymousReceiptsPlaceholder, - QString argLatexHeaderName ); + QString argLatexHeaderName, + QString argDateString ); private: - QString filePath; + QString dateString; Ui::ManualPrintingSetup *ui = nullptr; + QString workPath; private slots: void on_CBReceiptsHeader_activated( int argIndex );