Made the creation of a new session possible again

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

@ -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 ) );
}
}

@ -75,7 +75,7 @@ public:
*
* @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
*
* @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
};

@ -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 ):

@ -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();

@ -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

@ -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() ),

@ -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 );

@ -209,6 +209,21 @@ Please take care that it does not contain any spaces or other special characters
</item>
</widget>
</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>
</widget>
</item>

Loading…
Cancel
Save