Utilized global accessible 'settings' object in 'Lablib' class

remotes/origin/HEAD
markuspg 8 years ago
parent 2072dc8db2
commit 868458ea42

@ -20,10 +20,10 @@
#include "clienthelpnotificationserver.h"
lc::ClientHelpNotificationServer::ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap,
const QString * const argServerIP, const unsigned short int &argServerPort, QObject *argParent ) :
const QString &argServerIP, const unsigned short int &argServerPort, QObject *argParent ) :
QObject{ argParent },
clientIPsToClientsMap{ argClientIPsToClientsMap },
hostAddress{ *argServerIP },
hostAddress{ argServerIP },
serverPort{ argServerPort }
{
QNetworkConfigurationManager manager;

@ -33,7 +33,7 @@ class ClientHelpNotificationServer : public QObject {
Q_OBJECT
public:
explicit ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap,
const QString * const argServerIP, const unsigned short int &argServerPort, QObject *argParent = nullptr );
const QString &argServerIP, const unsigned short int &argServerPort, QObject *argParent = nullptr );
signals:

@ -42,8 +42,8 @@ lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent
DetectInstalledZTreeVersionsAndLaTeXHeaders();
// Initialize all 'netstat' query mechanisms
if ( ( *settingsItems )[ ( int )settItms_t::NETSTAT_CMD ] ) {
netstatAgent = new NetstatAgent{ ( *settingsItems )[ ( int )settItms_t::NETSTAT_CMD ] };
if ( !settings->netstatCmd.isEmpty() ) {
netstatAgent = new NetstatAgent{ settings->netstatCmd };
netstatAgent->moveToThread( &netstatThread );
connect( &netstatThread, &QThread::finished, netstatAgent, &QObject::deleteLater );
connect( netstatAgent, &NetstatAgent::QueryFinished,
@ -56,8 +56,11 @@ lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent
}
// Initialize the server for client help requests retrieval
if ( clientHelpNotificationServerPort && ( *settingsItems )[ ( int )settItms_t::SERVER_IP ] ) {
clientHelpNotificationServer = new ClientHelpNotificationServer{ clientIPsToClientsMap,( *settingsItems )[ ( int )settItms_t::SERVER_IP ], clientHelpNotificationServerPort, this };
if ( clientHelpNotificationServerPort && !settings->serverIP.isEmpty() ) {
clientHelpNotificationServer = new ClientHelpNotificationServer{ clientIPsToClientsMap,
settings->serverIP,
clientHelpNotificationServerPort,
this };
}
}
@ -86,16 +89,17 @@ lc::Lablib::~Lablib () {
void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
// Detect the installed LaTeX headers
if ( ( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ) {
QDir laTeXDirectory{ *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ], "*header.tex", QDir::Name, QDir::CaseSensitive | QDir::Files | QDir::Readable };
if ( !settings->lcInstDir.isEmpty() ) {
QDir laTeXDirectory{ settings->lcInstDir, "*header.tex", QDir::Name,
QDir::CaseSensitive | QDir::Files | QDir::Readable };
if ( !laTeXDirectory.exists() || laTeXDirectory.entryList().isEmpty() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "No LaTeX headers found" ),
tr( "No LaTeX headers could be found in '%1'. Receipts printing will not work" )
.arg( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ), QMessageBox::Ok };
.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( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ) );
.arg( settings->lcInstDir ) );
} else {
installedLaTeXHeaders = new QStringList{ laTeXDirectory.entryList() };
installedLaTeXHeaders->replaceInStrings( "_header.tex", "" );
@ -104,15 +108,18 @@ void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
}
// Detect the installed zTree versions
if ( ( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ) {
QDir zTreeDirectory{ *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ], "zTree*", QDir::Name, QDir::NoDotAndDotDot | QDir::Dirs | QDir::Readable | QDir::CaseSensitive };
if ( !settings->zTreeInstDir.isEmpty() ) {
QDir zTreeDirectory{ settings->zTreeInstDir, "zTree*", QDir::Name,
QDir::NoDotAndDotDot | QDir::Dirs
| QDir::Readable | QDir::CaseSensitive };
if ( zTreeDirectory.entryList().isEmpty() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "zTree not found" ),
tr( "No zTree installation found in '%1'. Running zTree will not be possible." )
.arg( *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ), QMessageBox::Ok };
.arg( settings->zTreeInstDir ), QMessageBox::Ok };
messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No zTree versions could be found in '%1'." ).arg( *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ) );
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No zTree versions could be found in '%1'." )
.arg( settings->zTreeInstDir ) );
}
else {
InstalledZTreeVersions = new QStringList{ zTreeDirectory.entryList() };
@ -323,8 +330,8 @@ void lc::Lablib::ShowPreprints() {
QProcess showPreprintsProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
showPreprintsProcess.setProcessEnvironment( env );
QString program{ *( *settingsItems )[ ( int )settItms_t::FILE_MANAGER ] };
QStringList arguments{ QStringList{} << *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/preprints" };
QString program{ settings->fileMngr };
QStringList arguments{ QStringList{} << settings->lcInstDir + "/preprints" };
showPreprintsProcess.startDetached( program, arguments );
// Output message via the debug messages tab

@ -19,11 +19,11 @@
#include "netstatagent.h"
lc::NetstatAgent::NetstatAgent( QString *argNetstatCommand, QObject *argParent ) :
lc::NetstatAgent::NetstatAgent( const QString &argNetstatCommand, QObject *argParent ) :
QObject{ argParent },
extractionRegexp{ "\\d+\\.\\d+\\.\\d+\\.\\d+" },
netstatArguments{ QStringList{} << "-anp" << "--tcp" },
netstatCommand{ *argNetstatCommand },
netstatCommand{ argNetstatCommand },
netstatQueryProcess{ this },
searchRegexp{ "\\W(ESTABLISHED|VERBUNDEN)( +)(\\d+)(/ztree.exe)\\W", QRegularExpression::CaseInsensitiveOption }
{

@ -35,7 +35,7 @@ class NetstatAgent : public QObject {
Q_OBJECT
public:
explicit NetstatAgent( QString *argNetstatCommand, QObject *argParent = nullptr );
explicit NetstatAgent( const QString &argNetstatCommand, QObject *argParent = nullptr );
signals:
//! This signal is emitted if the query of the currently active zLeaf connections finished
@ -47,7 +47,7 @@ public slots:
private:
const QRegularExpression extractionRegexp;
const QStringList netstatArguments;
const QString netstatCommand;
const QString &netstatCommand;
QProcess netstatQueryProcess;
const QRegularExpression searchRegexp;
};

Loading…
Cancel
Save