Made the creation of a new session possible again

remotes/origin/HEAD
markuspg 10 years ago
parent 869ad18f08
commit 60d0efa31f

@ -27,7 +27,6 @@
lc::Lablib::Lablib( QObject *argParent ) : lc::Lablib::Lablib( QObject *argParent ) :
QObject{ argParent }, QObject{ argParent },
labSettings{ "Economic Laboratory", "Labcontrol", this }, labSettings{ "Economic Laboratory", "Labcontrol", this },
occupiedPorts{ new QVector< int > },
sessionsModel{ new SessionsModel{ this } } sessionsModel{ new SessionsModel{ this } }
{ {
for ( const auto &s : settings->GetClients() ) { for ( const auto &s : settings->GetClients() ) {
@ -63,7 +62,6 @@ lc::Lablib::~Lablib () {
} }
netstatThread.quit(); netstatThread.quit();
netstatThread.wait(); netstatThread.wait();
delete occupiedPorts;
} }
bool lc::Lablib::CheckIfUserIsAdmin() const { bool lc::Lablib::CheckIfUserIsAdmin() const {
@ -116,12 +114,12 @@ void lc::Lablib::ShowPreprints() {
qDebug() << program << arguments.join( " " ); qDebug() << program << arguments.join( " " );
} }
void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort, void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
QString argzTreeVersion, QString argParticipNameReplacement,
bool argReceiptsForLocalClients, bool argPrintLocalReceipts, QString argReceiptsHeader,
QString argAnonReceiptPlaceholder, QString argzTreeDataTargetPath, quint16 argzTreePort,
QString argChosenLatexHeader ) { QString argzTreeVersion ) {
if ( !QDir( argDataTargetPath ).exists() ) { if ( !QDir( argzTreeDataTargetPath ).exists() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target path does not exist" ), QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target path does not exist" ),
tr( "Your chosen data target path does not exist." tr( "Your chosen data target path does not exist."
" Do you want it to be created automatically?" ), " Do you want it to be created automatically?" ),
@ -136,7 +134,7 @@ void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
messageBox.exec(); messageBox.exec();
return; return;
} else { } else {
if ( !QDir().mkpath( argDataTargetPath ) ) { if ( !QDir().mkpath( argzTreeDataTargetPath ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could" QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could"
" not be created" ), " not be created" ),
tr( "Your chosen data target directory does not exist" tr( "Your chosen data target directory does not exist"
@ -148,19 +146,19 @@ void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
} }
} }
try { try {
sessionsModel->push_back( new Session{ argDataTargetPath, sessionsModel->push_back( new Session{ argzTreeDataTargetPath,
argPort, argzTreeVersion, argzTreePort, argzTreeVersion,
argReceiptsForLocalClients, argPrintLocalReceipts,
argAnonReceiptPlaceholder, argParticipNameReplacement,
argChosenLatexHeader } ); argReceiptsHeader } );
occupiedPorts->append( sessionsModel->back()->zTreePort ); occupiedPorts.append( sessionsModel->back()->zTreePort );
} }
catch ( Session::lcDataTargetPathCreationFailed ) { catch ( Session::lcDataTargetPathCreationFailed ) {
QMessageBox::information( nullptr, tr( "Chosen data target path could not be created" ), QMessageBox::information( nullptr, tr( "Chosen data target path could not be created" ),
tr( "The path specified by your chosen data target path '%1'" tr( "The path specified by your chosen data target path '%1'"
" could not be created. Please check if it is a valid" " could not be created. Please check if it is a valid"
" location and you have all needed permissions." ) " location and you have all needed permissions." )
.arg( argDataTargetPath ) ); .arg( argzTreeDataTargetPath ) );
} }
} }

@ -75,7 +75,7 @@ public:
* *
* @return A pointer to a QVector<unsigned int> containing all occupied ports * @return A pointer to a QVector<unsigned int> containing all occupied ports
*/ */
QVector<int> *GetOccupiedPorts () const { return occupiedPorts; } const QVector< quint16 > &GetOccupiedPorts () const { return occupiedPorts; }
/** Returns a pointer to the QAbstractTableModel storing the Session instances /** Returns a pointer to the QAbstractTableModel storing the Session instances
* *
* @return 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(); void ShowPreprints();
public slots: public slots:
void StartNewZTreeInstance( QString argDataTargetPath, int argPort, QString argzTreeVersion, void StartNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement,
bool argReceiptsForLocalClients, QString argAnonReceiptPlaceholder, bool argPrintLocalReceipts, QString argReceiptsHeader,
QString argChosenLatexHeader ); QString argzTreeDataTargetPath, quint16 argzTreePort,
QString argzTreeVersion );
signals: signals:
void ZLEAF_RUNNING( QString argClientIP ); void ZLEAF_RUNNING( QString argClientIP );
@ -113,7 +114,7 @@ private:
NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients NetstatAgent *netstatAgent = nullptr; //! Tries to detect active zLeaf connections from the clients
QThread netstatThread; QThread netstatThread;
QTimer *netstatTimer = nullptr; //! A timer for regular execution of the NetstatAgent instance's request mechanism 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 SessionsModel *sessionsModel = nullptr; //! A derivation from QAbstractTableModel used to store the single Session instances
}; };

@ -26,7 +26,7 @@
extern std::unique_ptr< lc::Settings > settings; 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 &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName ): const QString &argLatexHeaderName ):

@ -38,7 +38,7 @@ class Session : public QObject {
public: public:
const int zTreePort = 7000; //! The port this session's zTree instance is running on 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 &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName ); const QString &argLatexHeaderName );
~Session(); ~Session();

@ -515,8 +515,8 @@ void lc::MainWindow::on_PBStartSession_clicked() {
SessionStarter *sessionStarter = new SessionStarter{ this }; SessionStarter *sessionStarter = new SessionStarter{ this };
sessionStarter->setWindowFlags( Qt::Window ); sessionStarter->setWindowFlags( Qt::Window );
sessionStarter->show(); sessionStarter->show();
// connect( sessionStarter, &SessionStarter::SessionRequested, connect( sessionStarter, &SessionStarter::RequestNewSession,
// lablib, &Lablib::StartNewZTreeInstance ); lablib, &Lablib::StartNewSession );
connect( sessionStarter, &SessionStarter::destroyed, connect( sessionStarter, &SessionStarter::destroyed,
sessionStarter, &SessionStarter::deleteLater ); sessionStarter, &SessionStarter::deleteLater );
// // Show an error message, if no zTree version was chosen yet // // Show an error message, if no zTree version was chosen yet

@ -173,7 +173,7 @@ void lc::SessionStarter::on_PBStartSession_clicked() {
} }
emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder, emit RequestNewSession( associatedClients, anonymousReceiptsPlaceholder,
ui->ChBPrintAnonymousReceipts->isChecked(), ui->ChBReceiptsForLocalClients->isChecked(),
ui->CBReceiptsHeader->currentText(), ui->CBReceiptsHeader->currentText(),
ui->CBDataTargetPath->currentText(), ui->CBDataTargetPath->currentText(),
static_cast< quint16 >( ui->SBPort->value() ), static_cast< quint16 >( ui->SBPort->value() ),

@ -42,7 +42,7 @@ public:
signals: signals:
void RequestNewDataTargetPath(); void RequestNewDataTargetPath();
void RequestNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement, void RequestNewSession( QVector< Client* > argAssocCl, QString argParticipNameReplacement,
bool argPrintAnonReceipts, QString argReceiptsHeader, bool argPrintLocalReceipts, QString argReceiptsHeader,
QString argzTreeDataTargetPath, quint16 argzTreePort, QString argzTreeDataTargetPath, quint16 argzTreePort,
QString argzTreeVersion ); QString argzTreeVersion );

@ -209,6 +209,21 @@ Please take care that it does not contain any spaces or other special characters
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="ChBReceiptsForLocalClients">
<property name="toolTip">
<string>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 &quot;local&quot;!</string>
</property>
<property name="text">
<string>Print receipts for local clients</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save