Reformat ZTree

remotes/origin/HEAD
markuspg 8 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. * This file is part of Labcontrol.
* *
@ -17,11 +17,13 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <memory>
#include "session.h" #include "session.h"
#include "settings.h" #include "settings.h"
#include <QDir>
#include <memory>
extern std::unique_ptr< lc::Settings > settings; extern std::unique_ptr< lc::Settings > settings;
lc::Session::Session( QVector< Client * > &&argAssocClients, lc::Session::Session( QVector< Client * > &&argAssocClients,
@ -54,14 +56,16 @@ lc::Session::Session( QVector< Client* > &&argAssocClients,
} }
} }
lc::Session::~Session() { lc::Session::~Session()
{
for ( auto &client : assocClients ) { for ( auto &client : assocClients ) {
client->SetSessionPort( 0 ); client->SetSessionPort( 0 );
client->SetzLeafVersion( "" ); client->SetzLeafVersion( "" );
} }
} }
QVariant lc::Session::GetDataItem( int argIndex ) { QVariant lc::Session::GetDataItem( int argIndex )
{
switch ( argIndex ) { switch ( argIndex ) {
case 0: case 0:
return QVariant{ zTreeVersionPath.split( '_', QString::KeepEmptyParts, Qt::CaseInsensitive )[ 1 ] }; 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 // Create the new data directory
QDir dir{ zTreeDataTargetPath }; QDir dir{ zTreeDataTargetPath };
QString date_string( QDateTime::currentDateTime().toString( "yyMMdd_hhmm" ) ); QString date_string( QDateTime::currentDateTime().toString( "yyMMdd_hhmm" ) );
@ -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; qDebug() << "z-Tree running on port" << zTreePort << "closed with exit code" << argExitCode;
emit SessionFinished( this ); emit SessionFinished( this );
} }
void lc::Session::RenameWindow() { void lc::Session::RenameWindow()
{
// Example: wmctrl -r <window name> -T <new name> // Example: wmctrl -r <window name> -T <new name>
QStringList arguments; QStringList arguments;

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

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

Loading…
Cancel
Save