diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index 817c07b..f449b29 100644 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -27,7 +27,6 @@ lc::Lablib::Lablib( QObject *argParent ) : QObject{ argParent }, labSettings{ "Economic Laboratory", "Labcontrol", this }, - occupiedPorts{ new QVector< int > }, sessionsModel{ new SessionsModel{ this } } { for ( const auto &s : settings->GetClients() ) { @@ -63,7 +62,6 @@ lc::Lablib::~Lablib () { } netstatThread.quit(); netstatThread.wait(); - delete occupiedPorts; } bool lc::Lablib::CheckIfUserIsAdmin() const { @@ -116,12 +114,12 @@ void lc::Lablib::ShowPreprints() { qDebug() << program << arguments.join( " " ); } -void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort, - QString argzTreeVersion, - bool argReceiptsForLocalClients, - QString argAnonReceiptPlaceholder, - QString argChosenLatexHeader ) { - if ( !QDir( argDataTargetPath ).exists() ) { +void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl, + QString argParticipNameReplacement, + bool argPrintLocalReceipts, QString argReceiptsHeader, + QString argzTreeDataTargetPath, quint16 argzTreePort, + QString argzTreeVersion ) { + if ( !QDir( argzTreeDataTargetPath ).exists() ) { QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target path does not exist" ), tr( "Your chosen data target path does not exist." " Do you want it to be created automatically?" ), @@ -136,7 +134,7 @@ void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort, messageBox.exec(); return; } else { - if ( !QDir().mkpath( argDataTargetPath ) ) { + if ( !QDir().mkpath( argzTreeDataTargetPath ) ) { QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could" " not be created" ), tr( "Your chosen data target directory does not exist" @@ -148,19 +146,19 @@ void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort, } } try { - sessionsModel->push_back( new Session{ argDataTargetPath, - argPort, argzTreeVersion, - argReceiptsForLocalClients, - argAnonReceiptPlaceholder, - argChosenLatexHeader } ); - occupiedPorts->append( sessionsModel->back()->zTreePort ); + sessionsModel->push_back( new Session{ argzTreeDataTargetPath, + argzTreePort, argzTreeVersion, + argPrintLocalReceipts, + argParticipNameReplacement, + argReceiptsHeader } ); + occupiedPorts.append( sessionsModel->back()->zTreePort ); } catch ( Session::lcDataTargetPathCreationFailed ) { QMessageBox::information( nullptr, tr( "Chosen data target path could not be created" ), tr( "The path specified by your chosen data target path '%1'" " could not be created. Please check if it is a valid" " location and you have all needed permissions." ) - .arg( argDataTargetPath ) ); + .arg( argzTreeDataTargetPath ) ); } } diff --git a/src/Lib/lablib.h b/src/Lib/lablib.h index 72225c6..865d94c 100644 --- a/src/Lib/lablib.h +++ b/src/Lib/lablib.h @@ -75,7 +75,7 @@ public: * * @return A pointer to a QVector containing all occupied ports */ - QVector *GetOccupiedPorts () const { return occupiedPorts; } + const QVector< quint16 > &GetOccupiedPorts () const { return occupiedPorts; } /** Returns a pointer to the QAbstractTableModel storing the Session instances * * @return A pointer to the QAbstractTableModel storing the Session instances @@ -90,9 +90,10 @@ public: void ShowPreprints(); public slots: - void StartNewZTreeInstance( QString argDataTargetPath, int argPort, QString argzTreeVersion, - bool argReceiptsForLocalClients, QString argAnonReceiptPlaceholder, - QString argChosenLatexHeader ); + void StartNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, + bool argPrintLocalReceipts, QString argReceiptsHeader, + QString argzTreeDataTargetPath, quint16 argzTreePort, + QString argzTreeVersion ); signals: void ZLEAF_RUNNING( QString argClientIP ); @@ -113,7 +114,7 @@ private: NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients QThread netstatThread; QTimer *netstatTimer = nullptr; //! A timer for regular execution of the NetstatAgent instance's request mechanism - QVector< int > *occupiedPorts = nullptr; + QVector< quint16 > occupiedPorts; SessionsModel *sessionsModel = nullptr; //! A derivation from QAbstractTableModel used to store the single Session instances }; diff --git a/src/Lib/session.cpp b/src/Lib/session.cpp index 379b164..5dbf45d 100644 --- a/src/Lib/session.cpp +++ b/src/Lib/session.cpp @@ -26,7 +26,7 @@ extern std::unique_ptr< lc::Settings > settings; -lc::Session::Session( const QString &argZTreeDataTargetPath, const int argZTreePort, +lc::Session::Session( const QString &argZTreeDataTargetPath, const quint16 argZTreePort, const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const QString &argLatexHeaderName ): diff --git a/src/Lib/session.h b/src/Lib/session.h index fe0ced7..a345137 100644 --- a/src/Lib/session.h +++ b/src/Lib/session.h @@ -38,7 +38,7 @@ class Session : public QObject { public: const int zTreePort = 7000; //! The port this session's zTree instance is running on - Session( const QString &argZTreeDataTargetPath, const int argZTreePort, + Session( const QString &argZTreeDataTargetPath, const quint16 argZTreePort, const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder, const QString &argLatexHeaderName ); ~Session(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2e40574..cd12afd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -515,8 +515,8 @@ void lc::MainWindow::on_PBStartSession_clicked() { SessionStarter *sessionStarter = new SessionStarter{ this }; sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->show(); - // connect( sessionStarter, &SessionStarter::SessionRequested, - // lablib, &Lablib::StartNewZTreeInstance ); + connect( sessionStarter, &SessionStarter::RequestNewSession, + lablib, &Lablib::StartNewSession ); connect( sessionStarter, &SessionStarter::destroyed, sessionStarter, &SessionStarter::deleteLater ); // // Show an error message, if no zTree version was chosen yet diff --git a/src/sessionstarter.cpp b/src/sessionstarter.cpp index 540e53f..48982dc 100644 --- a/src/sessionstarter.cpp +++ b/src/sessionstarter.cpp @@ -173,7 +173,7 @@ void lc::SessionStarter::on_PBStartSession_clicked() { } emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder, - ui->ChBPrintAnonymousReceipts->isChecked(), + ui->ChBReceiptsForLocalClients->isChecked(), ui->CBReceiptsHeader->currentText(), ui->CBDataTargetPath->currentText(), static_cast< quint16 >( ui->SBPort->value() ), diff --git a/src/sessionstarter.h b/src/sessionstarter.h index 5ee155e..98653a1 100644 --- a/src/sessionstarter.h +++ b/src/sessionstarter.h @@ -42,7 +42,7 @@ public: signals: void RequestNewDataTargetPath(); void RequestNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, - bool argPrintAnonReceipts, QString argReceiptsHeader, + bool argPrintLocalReceipts, QString argReceiptsHeader, QString argzTreeDataTargetPath, quint16 argzTreePort, QString argzTreeVersion ); diff --git a/src/sessionstarter.ui b/src/sessionstarter.ui index 54bb526..cbbcd5e 100644 --- a/src/sessionstarter.ui +++ b/src/sessionstarter.ui @@ -209,6 +209,21 @@ Please take care that it does not contain any spaces or other special characters + + + + This decides if receipts shall be printed for any z-Leaf instance running locally on the server. + +Warning: If this is disabled no receipts will be printed for ANY participant whose name contains the character string "local"! + + + Print receipts for local clients + + + true + + +