Reformat ZTree

remotes/origin/HEAD
markuspg 6 years ago
parent 7f532cbd21
commit 688c1ee3fd

@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Markus Prasser
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
*
* This file is part of Labcontrol.
*
@ -17,14 +17,16 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include <memory>
#include "session.h"
#include "settings.h"
#include <QDir>
#include <memory>
extern std::unique_ptr< lc::Settings > settings;
lc::Session::Session( QVector< Client* > &&argAssocClients,
lc::Session::Session( QVector< Client * > &&argAssocClients,
const QString &argZTreeDataTargetPath, const quint16 argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
@ -54,14 +56,16 @@ lc::Session::Session( QVector< Client* > &&argAssocClients,
}
}
lc::Session::~Session() {
lc::Session::~Session()
{
for ( auto &client : assocClients ) {
client->SetSessionPort( 0 );
client->SetzLeafVersion( "" );
}
}
QVariant lc::Session::GetDataItem( int argIndex ) {
QVariant lc::Session::GetDataItem( int argIndex )
{
switch ( argIndex ) {
case 0:
return QVariant{ zTreeVersionPath.split( '_', QString::KeepEmptyParts, Qt::CaseInsensitive )[ 1 ] };
@ -72,7 +76,8 @@ QVariant lc::Session::GetDataItem( int argIndex ) {
}
}
void lc::Session::InitializeClasses() {
void lc::Session::InitializeClasses()
{
// Create the new data directory
QDir dir{ zTreeDataTargetPath };
QString date_string( QDateTime::currentDateTime().toString( "yyMMdd_hhmm" ) );
@ -87,7 +92,7 @@ void lc::Session::InitializeClasses() {
this, &Session::OnzTreeClosed );
// Only create a 'Receipts_Handler' instance, if all neccessary variables were set
if ( latexHeaderName != "None found" && !settings->dvipsCmd.isEmpty()
&& !settings->latexCmd.isEmpty() ) {
&& !settings->latexCmd.isEmpty() ) {
new ReceiptsHandler{ zTreeDataTargetPath, printReceiptsForLocalClients,
anonymousReceiptsPlaceholder, latexHeaderName, this };
} else {
@ -95,12 +100,14 @@ void lc::Session::InitializeClasses() {
}
}
void lc::Session::OnzTreeClosed( int argExitCode ) {
void lc::Session::OnzTreeClosed( int argExitCode )
{
qDebug() << "z-Tree running on port" << zTreePort << "closed with exit code" << argExitCode;
emit SessionFinished( this );
}
void lc::Session::RenameWindow() {
void lc::Session::RenameWindow()
{
// Example: wmctrl -r <window name> -T <new name>
QStringList arguments;

@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Markus Prasser
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
*
* This file is part of Labcontrol.
*
@ -17,35 +17,35 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include <memory>
#include "settings.h"
#include "ztree.h"
#include <QDebug>
#include <QDir>
#include "settings.h"
#include "ztree.h"
#include <memory>
extern std::unique_ptr< lc::Settings > settings;
extern std::unique_ptr<lc::Settings> settings;
lc::ZTree::ZTree( const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath, QObject *argParent ) :
QObject{ argParent }
lc::ZTree::ZTree(const QString &argZTreeDataTargetPath, const int argZTreePort,
const QString &argZTreeVersionPath, QObject *argParent) :
QObject{argParent}
{
QStringList arguments{ QStringList{} << "-c" << "0" << settings->wineCmd
<< QString{ settings->zTreeInstDir + "/zTree_"
+ argZTreeVersionPath + "/ztree.exe" }
<< "/datadir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/privdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/gsfdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/tempdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/leafdir" << QString{ "Z:/" + argZTreeDataTargetPath }
<< "/channel" << QString::number( argZTreePort - 7000 ) };
QStringList arguments{QStringList{} << "-c" << "0" << settings->wineCmd
<< QString{settings->zTreeInstDir + "/zTree_"
+ argZTreeVersionPath + "/ztree.exe"}
<< "/datadir" << QString{"Z:/" + argZTreeDataTargetPath}
<< "/privdir" << QString{"Z:/" + argZTreeDataTargetPath}
<< "/gsfdir" << QString{"Z:/" + argZTreeDataTargetPath}
<< "/tempdir" << QString{"Z:/" + argZTreeDataTargetPath}
<< "/leafdir" << QString{"Z:/" + argZTreeDataTargetPath}
<< "/channel" << QString::number(argZTreePort - 7000)};
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
zTreeInstance.setProcessEnvironment( env );
zTreeInstance.setWorkingDirectory( QDir::homePath() );
zTreeInstance.start( settings->tasksetCmd, arguments, QIODevice::NotOpen );
connect( &zTreeInstance, SIGNAL( finished( int ) ),
this, SIGNAL( ZTreeClosed( int ) ) );
zTreeInstance.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
zTreeInstance.setWorkingDirectory(QDir::homePath());
zTreeInstance.start(settings->tasksetCmd, arguments, QIODevice::NotOpen);
connect(&zTreeInstance, SIGNAL(finished(int)),
this, SIGNAL(ZTreeClosed(int)));
qDebug() << settings->tasksetCmd << arguments.join( " " );
qDebug() << settings->tasksetCmd << arguments.join(" ");
}

@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 Markus Prasser
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
*
* This file is part of Labcontrol.
*
@ -20,33 +20,32 @@
#ifndef ZTREE_H
#define ZTREE_H
#include <QDir>
#include <QPlainTextEdit>
#include <QProcess>
#include "global.h"
#include <QProcess>
namespace lc {
//! A class to contain running zTree instances.
/*!
This class is element of every session and is used to handle all zTree related data.
*/
class ZTree: public QObject {
class ZTree: public QObject
{
Q_OBJECT
public:
ZTree( const QString &argZTreeDataTargetPath,
const int &argZTreePort, const QString &argZTreeVersionPath,
QObject *argParent = nullptr );
ZTree(const QString &argZTreeDataTargetPath,
const int argZTreePort, const QString &argZTreeVersionPath,
QObject *argParent = nullptr);
signals:
void ZTreeClosed( int argExitCode );
void ZTreeClosed(int argExitCode);
private:
QProcess zTreeInstance;
};
}
} // namespace lc
#endif // ZTREE_H

Loading…
Cancel
Save