Got rid of the 'debugMessagesTextEdit' cruft

remotes/origin/HEAD
markuspg 8 years ago
parent 53236522a2
commit 7569d9e75d

@ -19,12 +19,14 @@
#include <memory>
#include <QDebug>
#include "client.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::Client::Client( QPlainTextEdit *argDebugMessagesTextEdit, QString *argIP, QString *argMAC,
lc::Client::Client( QString *argIP, QString *argMAC,
QString *argName, unsigned short int argXPosition,
unsigned short int argYPosition ):
ip{ *argIP },
@ -32,7 +34,6 @@ lc::Client::Client( QPlainTextEdit *argDebugMessagesTextEdit, QString *argIP, QS
name{ *argName },
xPosition{ argXPosition },
yPosition{ argYPosition },
debugMessagesTextEdit{ argDebugMessagesTextEdit },
protectedCycles{ 0 }
{
qRegisterMetaType< state_t >( "STATE" );
@ -55,9 +56,9 @@ lc::Client::Client( QPlainTextEdit *argDebugMessagesTextEdit, QString *argIP, QS
pingTimer->start( 3000 );
}
debugMessagesTextEdit->appendPlainText( tr ( "[DEBUG] Created client %1\n\tMac: %2\tIP: %3\n\tPosition: %4x%5" )
.arg( name ).arg( mac ).arg( ip ).arg( QString::number( xPosition ) )
.arg( QString::number( yPosition ) ) );
qDebug() << "Created client" << name << "with MAC" << mac << "and IP" << ip
<< "at position" << QString{ QString::number( xPosition ) + "x"
+ QString::number( yPosition ) };
}
lc::Client::~Client() {
@ -84,7 +85,7 @@ void lc::Client::BeamFile( const QString &argFileToBeam, const QString * const a
beamFileProcess.setProcessEnvironment( env );
beamFileProcess.startDetached( settings->scpCmd, arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->scpCmd + " " + arguments.join( " " ) );
qDebug() << settings->scpCmd << arguments.join( " " );
}
void lc::Client::Boot( const QString &argNetworkBroadcastAddress ) {
@ -97,8 +98,7 @@ void lc::Client::Boot( const QString &argNetworkBroadcastAddress ) {
wakeonlanProcess.startDetached( settings->wakeonlanCmd, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->wakeonlanCmd
+ " " + arguments.join( " " ) );
qDebug() << settings->wakeonlanCmd << arguments.join( " " );
pingTimer->start( 3000 );
@ -119,7 +119,7 @@ void lc::Client::DeactiveScreensaver( const QString &argPublickeyPathUser,
deactiveScreensaverProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText("[DEBUG] " + settings->sshCmd + " " + arguments.join(" "));
qDebug() << settings->sshCmd << arguments.join( " " );
}
// void Client::display_ping_string(QString *ping_string) {
@ -135,7 +135,7 @@ void lc::Client::GotStatusChanged( state_t argState ) {
return;
}
state = argState;
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + name + " status changed to: " + QString::number( ( int )argState ) );
qDebug() << name << "status changed to:" << static_cast< unsigned short int >( argState );
}
void lc::Client::KillZLeaf( const QString &argPublickeyPathUser,
@ -151,7 +151,7 @@ void lc::Client::KillZLeaf( const QString &argPublickeyPathUser,
killZLeafProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->sshCmd + " " + arguments.join( " " ) );
qDebug() << settings->sshCmd << arguments.join( " " );
// Restart the ping_timer, because it is stopped when a zLeaf is started
pingTimer->start( 3000 );
@ -167,7 +167,7 @@ void lc::Client::OpenFilesystem( const QString * const argUserToBeUsed ) {
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
openFilesystemProcess.setProcessEnvironment( env );
openFilesystemProcess.startDetached( settings->fileMngr, arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->fileMngr + " " + arguments.join( " " ) );
qDebug() << settings->fileMngr << arguments.join( " " );
}
void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot,
@ -206,8 +206,7 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
openTerminalProcess.setProcessEnvironment( env );
openTerminalProcess.startDetached( settings->termEmulCmd, *arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->termEmulCmd
+ " " + arguments->join(" "));
qDebug() << settings->termEmulCmd << arguments->join( " " );
delete arguments;
}
}
@ -228,7 +227,7 @@ void lc::Client::SetStateToZLEAF_RUNNING( QString argClientIP ) {
// Inform the ClientPinger instance, that zLeaf is now running
pinger->setStateToZLEAF_RUNNING();
this->GotStatusChanged( state_t::ZLEAF_RUNNING );
debugMessagesTextEdit->appendPlainText( "[DEBUG] Client '" + name + "' got 'ZLEAF_RUNNING' signal." );
qDebug() << "Client" << name << "got 'ZLEAF_RUNNING' signal.";
}
}
@ -242,7 +241,7 @@ void lc::Client::ShowDesktop() {
showDesktopProcess.startDetached( settings->vncViewer, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->vncViewer + " " + arguments.join( " " ) );
qDebug() << settings->vncViewer << arguments.join( " " );
}
void lc::Client::Shutdown( const QString &argPublickeyPathUser, const QString &argUserNameOnClients ) {
@ -259,7 +258,7 @@ void lc::Client::Shutdown( const QString &argPublickeyPathUser, const QString &a
shutdownProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->sshCmd + " " + arguments.join( " " ) );
qDebug() << settings->sshCmd << arguments.join( " " );
// This additional 'ping_timer' start is needed for the case that the clients are shut down without prior closing of zLeaves
pingTimer->start( 3000 );
@ -312,7 +311,7 @@ void lc::Client::StartZLeaf( const QString &argPublickeyPathUser,
startZLeafProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + settings->sshCmd + " " + arguments.join( " " ) );
qDebug() << settings->sshCmd << arguments.join( " " );
}
delete messageBoxRunningZLeafFound;
}

@ -61,7 +61,7 @@ public:
@param argYPosition The client's y coordinate in the lab
@param argSettingsItems A QVector storing many needed data QStrings
*/
Client( QPlainTextEdit *argDebugMessagesTextEditPtr, QString *argIP, QString *argMAC,
Client( QString *argIP, QString *argMAC,
QString *argName, unsigned short int argXPosition, unsigned short int argYPosition );
//! Client's destructor
~Client();
@ -132,7 +132,6 @@ public:
unsigned short int argPort, const QString * const argFakeName = nullptr );
private:
QPlainTextEdit * const debugMessagesTextEdit = nullptr;
unsigned short int protectedCycles;
ClientPinger *pinger = nullptr;
QThread pingerThread;

@ -17,16 +17,16 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QDebug>
#include <QErrorMessage>
#include <QFile>
#include <QTextStream>
#include "lablib.h"
lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent ) :
lc::Lablib::Lablib( QObject *argParent ) :
QObject{ argParent },
clientIPsToClientsMap{ new QMap< QString, Client* > },
debugMessagesTextEdit{ argDebugMessagesTextEdit },
labSettings{ "Economic Laboratory", "Labcontrol", this },
occupiedPorts{ new QVector< int > },
sessionsModel{ new SessionsModel{ this } }
@ -77,9 +77,7 @@ lc::Lablib::~Lablib () {
bool lc::Lablib::CheckIfUserIsAdmin() const {
for ( const auto &s : adminUsers ) {
if ( s == settings->localUserName ) {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] User '%1' has administrative"
" rights." )
.arg( settings->localUserName ) );
qDebug() << "User" << settings->localUserName << "has administrative rights.";
return true;
}
}
@ -97,12 +95,11 @@ void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
.arg( settings->lcInstDir ), QMessageBox::Ok };
messageBox.exec();
installedLaTeXHeaders = new QStringList{ "None found" };
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No LaTeX headers could be found in '%1'." )
.arg( settings->lcInstDir ) );
qDebug() << "No LaTeX headers could be found in" << settings->lcInstDir;
} else {
installedLaTeXHeaders = new QStringList{ laTeXDirectory.entryList() };
installedLaTeXHeaders->replaceInStrings( "_header.tex", "" );
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] LaTeX headers: %1" ).arg( installedLaTeXHeaders->join( " / " ) ) );
qDebug() << "LaTeX headers:" << installedLaTeXHeaders->join( " / " );
}
}
}
@ -115,7 +112,7 @@ void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections )
}
}
else
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Netstat status query failed." ) );
qDebug() << "Netstat status query failed.";
delete argActiveZLeafConnections;
}
@ -130,11 +127,11 @@ void lc::Lablib::ReadSettings() {
QMessageBox messageBox{ QMessageBox::Information, tr( "'admin_users' not set" ),
tr( "The 'admin_users' variable was not set. No users will be able to conduct administrative tasks." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'admin_users' was not set. No permission for administrative tasks." ) );
qDebug() << "'admin_users' was not set. No permission for administrative tasks.";
} else {
adminUsers = labSettings.value( "admin_users", "" ).toString()
.split( '|', QString::SkipEmptyParts, Qt::CaseInsensitive );
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'admin_users': %1").arg( adminUsers.join(" / ") ) );
qDebug() << "'adminUsers':" << adminUsers.join( " / " );
}
// Read the port the ClientHelpNotificationServer shall listen on
@ -143,35 +140,41 @@ void lc::Lablib::ReadSettings() {
QMessageBox messageBox{ QMessageBox::Information, tr( "The ClientHelpNotificationServer will be deactivated" ),
tr( "The 'client_help_server_port' variable was not set or set to zero. The ClientHelpNotificationServer will be deactivated. Clients' help requests will be ignored by the server." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] The ClientHelpNotificationServer will be deactivated since 'client_help_server_port' was not set or set to zero." ) );
qDebug() << "The ClientHelpNotificationServer will be deactivated since"
" 'client_help_server_port' was not set or set to zero.";
} else {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'client_help_server_port': %1" ).arg( QString::number( clientHelpNotificationServerPort ) ) );
qDebug() << "'clientHelpNotificationServerPort':" << clientHelpNotificationServerPort;
}
// Read the default receipt index for the 'CBReceipts' combobox
if ( !labSettings.contains( "default_receipt_index" ) ) {
QMessageBox messageBox(QMessageBox::Information, tr( "'default_receipt_index' not set" ), tr( "The 'default_receipt_index' variable was not set. It will default to '0'." ) );
QMessageBox messageBox{ QMessageBox::Information, tr( "'default_receipt_index' not set" ),
tr( "The 'default_receipt_index' variable was not set."
" It will default to '0'." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'default_receipt_index' was not set. It will default to '0'." ) );
qDebug() << "'default_receipt_index' was not set. It will default to '0'.";
}
defaultReceiptIndex = labSettings.value( "default_receipt_index", 0 ).toInt();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'default_receipt_index': %1").arg( QString::number( defaultReceiptIndex ) ) );
qDebug() << "'defaultReceiptIndex':" << defaultReceiptIndex;
// Read the initial port number
if ( !labSettings.contains( "initial_port" ) ) {
QMessageBox messageBox{ QMessageBox::Information, tr( "'initial_port' not set" ),
tr( "The 'initial_port' variable was not set. Labcontrol will default to port 7000 for new zTree instances." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'initial_port' was not set. Labcontrol will default to port 7000 for new zTree instances." ) );
qDebug() << "'initial_port' was not set."
" Labcontrol will default to port 7000 for new zTree instances.";
}
chosenZTreePort = labSettings.value( "initial_port", 7000 ).toInt();
debugMessagesTextEdit->appendPlainText( tr("[DEBUG] 'initial_port': %1" ).arg( QString::number( chosenZTreePort ) ) );
qDebug() << "'initial_port':" << chosenZTreePort;
// Get a list of available webcams in the lab
if ( !labSettings.contains( "webcams" ) ) {
QMessageBox messageBox{ QMessageBox::Information, tr( "'webcams' not set" ), tr( "The 'webcams' variable was not set. No stationary webcams will be available." ) };
QMessageBox messageBox{ QMessageBox::Information, tr( "'webcams' not set" ),
tr( "The 'webcams' variable was not set."
" No stationary webcams will be available." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'webcams' was not set. No stationary webcams will be available." ) );
qDebug() << "'webcams' was not set. No stationary webcams will be available.";
}
// Get the client quantity to check the value lists for clients creation for correct length
@ -180,12 +183,13 @@ void lc::Lablib::ReadSettings() {
QMessageBox messageBox{ QMessageBox::Information, tr( "'client_quantity' not set" ),
tr( "The 'client_quantity' variable was not set. The client quantity will be guessed by the amount of client ips set in 'client_ips'." ) };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'client_quantity' was not set. The client quantity will be guessed by the amount of client IPs set in 'client_ips'." ) );
qDebug() << "'client_quantity' was not set. The client quantity will be guessed"
" by the amount of client IPs set in 'client_ips'.";
clientQuantity = labSettings.value( "client_ips", "" ).toString().split( '/', QString::SkipEmptyParts, Qt::CaseSensitive ).length();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'client_quantity': %1" ).arg( QString::number( clientQuantity ) ) );
qDebug() << "'clientQuantity':" << clientQuantity;
} else {
clientQuantity = labSettings.value( "client_quantity" ).toInt();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] 'client_quantity': %1" ).arg( QString::number( clientQuantity ) ) );
qDebug() << "'clientQuantity':" << clientQuantity;
}
// Create all the clients in the lab
@ -196,7 +200,7 @@ void lc::Lablib::ReadSettings() {
messageBox.exec();
return;
}
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Client IPs: %1").arg( clientIPs.join( " / " ) ) );
qDebug() << "Client IPs:" << clientIPs.join( " / " );
QStringList clientMACs = labSettings.value( "client_macs" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive );
if ( clientMACs.length() != clientQuantity ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client mac quantity" ),
@ -204,7 +208,7 @@ void lc::Lablib::ReadSettings() {
messageBox.exec();
return;
}
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Client MACs: %1").arg( clientMACs.join( " / " ) ) );
qDebug() << "Client MACs:" << clientMACs.join( " / " );
QStringList clientNames = labSettings.value( "client_names" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive );
if ( clientNames.length() != clientQuantity ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client name quantity" ),
@ -212,7 +216,7 @@ void lc::Lablib::ReadSettings() {
messageBox.exec();
return;
}
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Client names: %1" ).arg( clientNames.join( " / " ) ) );
qDebug() << "Client names:" << clientNames.join( " / " );
QStringList clientXPositions = labSettings.value( "client_xpos" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive );
if ( clientXPositions.length() != clientQuantity ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client x positions quantity" ),
@ -220,7 +224,7 @@ void lc::Lablib::ReadSettings() {
messageBox.exec();
return;
}
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] client_xpos: %1" ).arg( clientXPositions.join( " / " ) ) );
qDebug() << "clientXPositions:" << clientXPositions.join( " / " );
QStringList clientYPositions = labSettings.value( "client_ypos" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseSensitive );
if ( clientYPositions.length() != clientQuantity ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "Wrong client y positions quantity" ),
@ -228,11 +232,11 @@ void lc::Lablib::ReadSettings() {
messageBox.exec();
return;
}
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] client_ypos: %1" ).arg( clientYPositions.join( " / " ) ) );
qDebug() << "clientYPositions:" << clientYPositions.join( " / " );
clients = new QVector< Client* >;
for ( int i = 0; i < clientQuantity; i++ ) {
clients->append( new Client{ debugMessagesTextEdit, &clientIPs[ i ], &clientMACs[ i ],
clients->append( new Client{ &clientIPs[ i ], &clientMACs[ i ],
&clientNames[ i ], clientXPositions[ i ].toUShort(),
clientYPositions[ i ].toUShort() } );
@ -241,31 +245,29 @@ void lc::Lablib::ReadSettings() {
// Get the address of the Client instance in RAM for display
const void *clientPointerAddress = static_cast< const void* >( ( *clientIPsToClientsMap )[ clients->last()->ip ] );
QString clientPointerAddressString;
QTextStream clientPointerAddressStream ( &clientPointerAddressString );
clientPointerAddressStream << clientPointerAddress;
// Connect the 'Client' instance to the 'ZLEAF_RUNNING(QString client_ip)' signal
connect( this, &Lablib::ZLEAF_RUNNING,
clients->last(), &Client::SetStateToZLEAF_RUNNING );
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Added '%1' to 'client_ips_to_clients_map': '%2'" ).arg( clients->last()->name ).arg( clientPointerAddressString ) );
qDebug() << "Added" << clients->last()->name
<< "to 'clientIPsToClientsMap':" << clientPointerAddress;
}
}
void lc::Lablib::SetChosenZTreeDataTargetPath( const QString &argZTreeDataTargetPath ) {
chosenZTreeDataTargetPath = argZTreeDataTargetPath;
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] chosen_zTree_data_target_path set to: '%1'" ).arg( chosenZTreeDataTargetPath ) );
qDebug() << "'chosenZTreeDataTargetPath' set to:" << chosenZTreeDataTargetPath;
}
void lc::Lablib::SetChosenZTreePort( const int &argPort ) {
chosenZTreePort = argPort;
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] chosen_zTree_port set to: '%1'" ).arg( QString::number( chosenZTreePort ) ) );
qDebug() << "'chosenZTreePort' set to:" << chosenZTreePort;
}
void lc::Lablib::SetPrintReceiptsForLocalClients( const bool &argPrintReceiptsForLocalClients ) {
PrintReceiptsForLocalClients = argPrintReceiptsForLocalClients;
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] Set print_receipts_for_local_clients to : '%1'" ).arg( QString::number( PrintReceiptsForLocalClients ) ) );
qDebug() << "Set 'PrintReceiptsForLocalClients' to:" << PrintReceiptsForLocalClients;
}
void lc::Lablib::ShowOrsee() {
@ -277,7 +279,7 @@ void lc::Lablib::ShowOrsee() {
showOrseeProcess.startDetached( program, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1 %2" ).arg( program ).arg( arguments.join( " " ) ) );
qDebug() << program << arguments.join( " " );
}
void lc::Lablib::ShowPreprints() {
@ -290,7 +292,7 @@ void lc::Lablib::ShowPreprints() {
showPreprintsProcess.startDetached( program, arguments );
// Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1 %2" ).arg( program ).arg( arguments.join( " " ) ) );
qDebug() << program << arguments.join( " " );
}
void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
@ -325,7 +327,7 @@ void lc::Lablib::StartNewZTreeInstance( QString argDataTargetPath, int argPort,
}
}
try {
sessionsModel->push_back( new Session{ debugMessagesTextEdit, argDataTargetPath,
sessionsModel->push_back( new Session{ argDataTargetPath,
argPort, argzTreeVersion,
argReceiptsForLocalClients,
argAnonReceiptPlaceholder,

@ -57,12 +57,11 @@ class Lablib : public QObject
{
Q_OBJECT
public:
/** Lablib's constructor
*
* @param argDebugMessagesTextEdit A pointer to the debug messages text edit for verbose output
* @param argParent This 'lcLablib' instance's parent QObject
/*!
* \brief Lablib's constructor
* \param[in] argParent This 'lcLablib' instance's parent QObject
*/
Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent = nullptr );
Lablib( QObject *argParent = nullptr );
/** Lablib's destructor
*/
~Lablib();
@ -149,7 +148,6 @@ private:
unsigned short int clientHelpNotificationServerPort = 0; //! The port the help requests shall be received on
QMap< QString, Client* > * clientIPsToClientsMap = nullptr; //! A map container storing ip-client pairs
QVector<Client*> *clients = nullptr; //! A QVector storing pointers to all Client instances
QPlainTextEdit *debugMessagesTextEdit = nullptr; //! This stores a pointer to the text edit in the debug tab to be able to write to it
int defaultReceiptIndex = 0; //! Stores the index of the LaTeX header to be displayed by default
QStringList *installedLaTeXHeaders = nullptr;
QSettings labSettings;

@ -19,20 +19,20 @@
#include <memory>
#include <QDebug>
#include "receipts_handler.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath,
lc::ReceiptsHandler::ReceiptsHandler( const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName,
QObject *argParent ) :
QObject{ argParent },
anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } },
debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ new QString{ argLatexHeaderName } },
printReceiptsForLocalClients{ new bool { argPrintReceiptsForLocalClients } },
timer{ new QTimer{ this } },
@ -44,7 +44,7 @@ lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
dateString = new QString{ currentDate.toString( "yyMMdd_hhmm" ) };
expectedPaymentFileName = QString{ *dateString + ".pay" };
expectedPaymentFilePath = QString{ *zTreeDataTargetPath + "/" + *dateString + ".pay" };
debugMessagesTextEdit->appendPlainText( "[DEBUG] Expected payment file name is: " + expectedPaymentFilePath );
qDebug() << "Expected payment file name is:" << expectedPaymentFilePath;
// Create a new file object representing the payment file
paymentFile = new QFile( expectedPaymentFilePath );
@ -55,8 +55,7 @@ lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
timer->start( 2000 );
}
lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath,
lc::ReceiptsHandler::ReceiptsHandler( const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName,
@ -64,14 +63,13 @@ lc::ReceiptsHandler::ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit,
QObject{ argParent },
anonymousReceiptsPlaceholder{ new QString{ argAnonymousReceiptsPlaceholder } },
dateString{ new QString{ *argDateString } },
debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ new QString{ argLatexHeaderName } },
printReceiptsForLocalClients{ new bool { argPrintReceiptsForLocalClients } },
zTreeDataTargetPath{ new QString{ argZTreeDataTargetPath } }
{
expectedPaymentFileName = QString{ *dateString + ".pay" };
expectedPaymentFilePath = QString{ *zTreeDataTargetPath + "/" + *argDateString + ".pay" };
debugMessagesTextEdit->appendPlainText( "[DEBUG] Expected payment file name is: " + expectedPaymentFilePath );
qDebug() << "Expected payment file name is:" << expectedPaymentFilePath;
// Create a new file object representing the payment file
paymentFile = new QFile( expectedPaymentFilePath );
@ -92,7 +90,7 @@ lc::ReceiptsHandler::~ReceiptsHandler() {
void lc::ReceiptsHandler::PrintReceipts() {
// If the payment file exists, print it
if ( paymentFile->exists() ) {
debugMessagesTextEdit->appendPlainText( "[DEBUG] The payment file has been created and will be printed" );
qDebug() << "The payment file has been created and will be printed";
if ( timer ) {
timer->stop();
}
@ -106,7 +104,7 @@ void lc::ReceiptsHandler::CreateReceiptsFromPaymentFile() {
QVector<QString> *rawParticipantsData = nullptr;
rawParticipantsData = GetParticipantsDataFromPaymentFile();
for ( int i = 0; i < rawParticipantsData->size(); i++ ) {
debugMessagesTextEdit->appendPlainText( "[DEBUG] Payment file line " + QString::number( i ) + ":\t" + rawParticipantsData->at( i ) );
qDebug() << "Payment file line" << QString::number( i ) << ":\t" << rawParticipantsData->at( i );
}
// Extract the data of the participant's whose receipts shall be printed
@ -118,9 +116,9 @@ void lc::ReceiptsHandler::CreateReceiptsFromPaymentFile() {
for ( QVector<QString>::iterator it = rawParticipantsData->begin(); it != rawParticipantsData->end() - 1; ++it ) {
// Split the lines containing the participants' data into their inidivual parts
QStringList temp_participant_data = it->split('\t', QString::KeepEmptyParts);
debugMessagesTextEdit->appendPlainText( temp_participant_data.join( " - " ) );
qDebug() << temp_participant_data.join( " - " );
if ( !( *printReceiptsForLocalClients ) && temp_participant_data.at( 3 ).contains( "local" ) ) {
debugMessagesTextEdit->appendPlainText( "Receipt for local client '" + temp_participant_data.at( 1 ) + "' will not be printed." );
qDebug() << "Receipt for local client" << temp_participant_data.at( 1 ) << "will not be printed.";
}
else {
// Create a new struct instance for participant data and fill it
@ -188,11 +186,11 @@ void lc::ReceiptsHandler::CreateReceiptsFromPaymentFile() {
// Append LaTeX ending
latexText->append( "\\end{document}" );
debugMessagesTextEdit->appendPlainText( *latexText );
qDebug() << *latexText;
// Create the tex file
QFile *texFile = new QFile( *zTreeDataTargetPath + "/" + *dateString + ".tex" );
debugMessagesTextEdit->appendPlainText( "[DEBUG] Tex file '" + texFile->fileName() + "' will be created for receipts printing." );
qDebug() << "Tex file" << texFile->fileName() << "will be created for receipts printing.";
// Clean up any already existing files
if ( texFile->exists() ) {
if ( !texFile->remove() ) {
@ -233,7 +231,7 @@ void lc::ReceiptsHandler::DeleteReceiptsPrinterInstance() {
receiptsPrinter->wait();
delete receiptsPrinter;
receiptsPrinter = nullptr;
debugMessagesTextEdit->appendPlainText( "[DEBUG] Deleted ReceiptsPrinter instance." );
qDebug() << "Deleted 'ReceiptsPrinter' instance.";
emit PrintingFinished();
}
@ -294,13 +292,13 @@ QString *lc::ReceiptsHandler::LoadLatexHeader() {
void lc::ReceiptsHandler::MakeReceiptsAnonymous( QVector<paymentEntry_t*> *argDataVector, bool argAlsoAnonymizeClients ) {
if ( !argAlsoAnonymizeClients ) {
debugMessagesTextEdit->appendPlainText( "[DEBUG] Names are made anonymous" );
qDebug() << "Names are made anonymous";
for ( QVector< paymentEntry_t* >::iterator it = argDataVector->begin(); it != argDataVector->end(); ++it ) {
( *it )->name = QString{ *anonymousReceiptsPlaceholder };
}
}
else {
debugMessagesTextEdit->appendPlainText( "[DEBUG] Clients and names are made anonymous" );
qDebug() << "Clients and names are made anonymous";
for ( QVector< paymentEntry_t* >::iterator it = argDataVector->begin(); it != argDataVector->end(); ++it ) {
( *it )->name = QString{ *anonymousReceiptsPlaceholder };
( *it )->computer = QString{ "\\hspace{1cm}" };

@ -46,11 +46,11 @@ class ReceiptsHandler : public QObject {
Q_OBJECT
public:
explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath,
explicit ReceiptsHandler( const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName, QObject *argParent = nullptr );
explicit ReceiptsHandler( QPlainTextEdit *argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath,
explicit ReceiptsHandler( const QString &argZTreeDataTargetPath,
const bool &argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName,
@ -79,7 +79,6 @@ private:
const QString * const anonymousReceiptsPlaceholder; //! Placeholder which shall be inserted for participant names if anonymous printing is desired (QString != "")
QString *dateString = nullptr;
QPlainTextEdit * const debugMessagesTextEdit = nullptr; //! A pointer to the programs debug_messages_text_edit to be able to emit debugging messages
QString expectedPaymentFileName; //! The name of the expected payment file
QString expectedPaymentFilePath; //! The path of the expected payment file
const QString * const latexHeaderName; //! The name of the chosen LaTeX header template

@ -19,19 +19,19 @@
#include <memory>
#include <QDebug>
#include "session.h"
#include "settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::Session::Session( QPlainTextEdit * const argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int argZTreePort,
lc::Session::Session( const QString &argZTreeDataTargetPath, const int argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients,
const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName ):
zTreePort{ argZTreePort },
anonymousReceiptsPlaceholder{ argAnonymousReceiptsPlaceholder },
debugMessagesTextEdit{ argDebugMessagesTextEdit },
latexHeaderName{ argLatexHeaderName },
printReceiptsForLocalClients{ argPrintReceiptsForLocalClients },
zTreeDataTargetPath{ argZTreeDataTargetPath },
@ -77,19 +77,18 @@ void lc::Session::InitializeClasses() {
throw lcDataTargetPathCreationFailed{};
}
zTreeDataTargetPath.append( "/" + date_string + "-" + QString::number( zTreePort ) );
debugMessagesTextEdit->appendPlainText( "[DEBUG] New session's chosen_zTree_data_target_path: " + zTreeDataTargetPath );
qDebug() << "New session's chosen_zTree_data_target_path:" << zTreeDataTargetPath;
zTreeInstance = new ZTree{ debugMessagesTextEdit, zTreeDataTargetPath,
zTreePort, zTreeVersionPath };
zTreeInstance = new ZTree{ zTreeDataTargetPath, zTreePort, zTreeVersionPath };
// Only create a 'Receipts_Handler' instance, if all neccessary variables were set
if ( latexHeaderName != "None found" && !settings->dvipsCmd.isEmpty()
&& !settings->latexCmd.isEmpty() ) {
receiptsHandler = new ReceiptsHandler{ debugMessagesTextEdit, zTreeDataTargetPath,
receiptsHandler = new ReceiptsHandler{ zTreeDataTargetPath,
printReceiptsForLocalClients,
anonymousReceiptsPlaceholder,
latexHeaderName };
} else {
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No ReceiptsHandler instance was created." ) );
qDebug() << "No 'ReceiptsHandler' instance was created.";
}
}
@ -105,7 +104,7 @@ void lc::Session::RenameWindow() {
renameZTreeWindowProcess.setProcessEnvironment( env );
renameZTreeWindowProcess.startDetached( settings->wmctrlCmd, arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] Renamed window" );
qDebug() << "Renamed window";
// emit session_started();
}

@ -38,7 +38,7 @@ class Session : public QObject {
public:
const int zTreePort = 7000; //! The port this session's zTree instance is running on
Session( QPlainTextEdit * const argDebugMessagesTextEdit, const QString &argZTreeDataTargetPath, const int argZTreePort,
Session( const QString &argZTreeDataTargetPath, const int argZTreePort,
const QString &argZTreeVersionPath, bool argPrintReceiptsForLocalClients, const QString &argAnonymousReceiptsPlaceholder,
const QString &argLatexHeaderName );
~Session();
@ -65,7 +65,6 @@ private slots:
private:
const QString anonymousReceiptsPlaceholder; //! Placeholder which shall be inserted for participant names if anonymous printing is desired (QString != "")
QPlainTextEdit * const debugMessagesTextEdit = nullptr; //! A pointer to the programs debugMessagesTextEdit to be able to emit debugging messages
const QString latexHeaderName; //! The name of the chosen LaTeX header
const bool printReceiptsForLocalClients = true; //! True if receipts shall be printed for local clients
ReceiptsHandler *receiptsHandler = nullptr; //! For automatic creation and printing of the receipts

@ -19,13 +19,14 @@
#include <memory>
#include <QDebug>
#include "settings.h"
#include "ztree.h"
extern std::unique_ptr< lc::Settings > settings;
lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int &argZTreePort,
lc::ZTree::ZTree( const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath ) {
QString program{ settings->tasksetCmd };
QStringList arguments{ QStringList{} << "0x00000001" << settings->wineCmd
@ -45,7 +46,7 @@ lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
this, SLOT( ZTreeInstanceClosed() ) );
// Output message via the debug messages tab
argDebugMessagesTextEdit->appendPlainText( "[DEBUG] " + program + " " + arguments.join( " " ) );
qDebug() << program << arguments.join( " " );
}
void lc::ZTree::ZTreeInstanceClosed() {

@ -36,8 +36,7 @@ class ZTree: public QObject {
Q_OBJECT
public:
ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath,
ZTree( const QString &argZTreeDataTargetPath,
const int &argZTreePort, const QString &argZTreeVersionPath );
signals:

@ -20,6 +20,7 @@
#include <memory>
#include <QtGlobal>
#include <QDebug>
#include <QInputDialog>
#include "mainwindow.h"
@ -33,7 +34,7 @@ lc::MainWindow::MainWindow( QWidget *argParent ) :
ui{ new Ui::MainWindow }
{
ui->setupUi( this );
lablib = new Lablib{ ui->PTEDebugMessages, this };
lablib = new Lablib{ this };
LoadIconPixmaps();
@ -62,8 +63,7 @@ bool lc::MainWindow::CheckIfUserIsAdmin() {
return false;
}
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] The user's name is %1." )
.arg( settings->localUserName ) );
qDebug() << "The user's name is:" << settings->localUserName;
return lablib->CheckIfUserIsAdmin();
}
@ -254,11 +254,11 @@ void lc::MainWindow::on_PBChooseFile_clicked() {
if(file_dialog->exec()) {
ui->LEFilePath->setText(file_dialog->selectedFiles().at(0));
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] Chose file '%1' for beaming." ).arg( ui->LEFilePath->text() ) );
qDebug() << "Chose file" << ui->LEFilePath->text() << "for beaming.";
}
else {
ui->LEFilePath->setText( tr( "File choosing cancelled" ) );
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] File choosing cancelled" ) );
qDebug() << "File choosing cancelled";
}
delete file_dialog;
}
@ -308,7 +308,7 @@ void lc::MainWindow::on_PBExecute_clicked() {
// and execute it
if ( executeOnEveryClient ) {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] Executing command '%1' on every client." ).arg( command ) );
qDebug() << "Executing command" << command << "on every client.";
for ( auto s: *clients ) {
if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) {
s->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), pkeyPathUser,
@ -316,7 +316,7 @@ void lc::MainWindow::on_PBExecute_clicked() {
}
}
} else {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] Executing command '%1' only on chosen clients." ).arg( command ) );
qDebug() << "Executing command" << command << "only on chosen clients.";
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
@ -342,7 +342,7 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
local_zLeaves_are_running = false;
// Output message via the debug messages tab
ui->PTEDebugMessages->appendPlainText( "[DEBUG] " + program );
qDebug() << program;
}
void lc::MainWindow::on_PBKillzLeaf_clicked() {
@ -429,7 +429,7 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() {
++numberOfSelectedClients;
}
}
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] %1 clients are selected.").arg( QString::number( numberOfSelectedClients ) ) );
qDebug() << numberOfSelectedClients << "clients are selected.";
if ( numberOfSelectedClients > 1 ) {
QMessageBox messageBox{ QMessageBox::Information, tr( "Too many clients selected" ), tr( "There are too many clients selected in the table view on the left. Please select only one." ), QMessageBox::Ok, this };
messageBox.exec();
@ -511,7 +511,7 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
local_zLeaves_are_running = true;
// Output message via the debug messages tab
ui->PTEDebugMessages->appendPlainText( "[DEBUG] " + program + " " + arguments.join( " " ) );
qDebug() << program << arguments.join( " " );
}
delete messageBox;
}
@ -538,7 +538,7 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() {
}
void lc::MainWindow::on_PBStartzTree_clicked() {
SessionStarter *sessionStarter = new SessionStarter{ lablib, ui->PTEDebugMessages, this };
SessionStarter *sessionStarter = new SessionStarter{ lablib, this };
sessionStarter->setWindowFlags( Qt::Window );
sessionStarter->show();
connect( sessionStarter, &SessionStarter::SessionRequested,
@ -598,7 +598,7 @@ void lc::MainWindow::on_PBViewDesktop_clicked() {
void lc::MainWindow::on_RBUseLocalUser_toggled(bool checked) {
if ( checked ) {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] RBUseLocalUser got toggled." ) );
qDebug() << "'RBUseLocalUser' got toggled.";
}
}

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>740</height>
<height>864</height>
</rect>
</property>
<property name="windowTitle">
@ -447,20 +447,6 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="TDebugMessages">
<attribute name="title">
<string>Debug messages</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPlainTextEdit" name="PTEDebugMessages">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="TInfo">
<property name="layoutDirection">
<enum>Qt::RightToLeft</enum>

@ -19,15 +19,16 @@
#include <memory>
#include <QDebug>
#include "sessionstarter.h"
#include "ui_sessionstarter.h"
#include "Lib/settings.h"
extern std::unique_ptr< lc::Settings > settings;
lc::SessionStarter::SessionStarter( Lablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit, QWidget *parent ) :
lc::SessionStarter::SessionStarter( Lablib *argLablib, QWidget *parent ) :
QWidget{ parent },
debugMessagesTextEdit { argDebugMessagesTextEdit },
lablib{ argLablib },
ui{ new Ui::SessionStarter }
{
@ -131,7 +132,8 @@ void lc::SessionStarter::SetupWidgets() {
if ( laTeXHeaders->length() - 1 < lablib->GetDefaultReceiptIndex() ) {
QMessageBox::information( this, tr( "'default_receipt_index' to high" ),
tr( "'default_receipt_index' was set to big. The combo box containing the receipt templates will default to the first entry." ) );
debugMessagesTextEdit->appendPlainText( tr("'default_receipt_index' was set to big. The combo box containing the receipt templates will default to the first entry." ) );
qDebug() << "'default_receipt_index' was set to big."
" The combo box containing the receipt templates will default to the first entry.";
ui->CBReceiptsHeader->setCurrentIndex( 0 );
} else {
ui->CBReceiptsHeader->setCurrentIndex( lablib->GetDefaultReceiptIndex() );

@ -35,8 +35,7 @@ class SessionStarter : public QWidget {
Q_OBJECT
public:
explicit SessionStarter( Lablib *argLablib, QPlainTextEdit *argDebugMessagesTextEdit,
QWidget *parent = nullptr );
explicit SessionStarter( Lablib *argLablib, QWidget *parent = nullptr );
~SessionStarter();
//! This gets thrown as an exception if this class is created even if it shouldn't
@ -49,7 +48,6 @@ signals:
QString argChosenLatexHeader );
private:
QPlainTextEdit * const debugMessagesTextEdit = nullptr;
Lablib * const lablib = nullptr;
Ui::SessionStarter *ui = nullptr;

Loading…
Cancel
Save