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

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

@ -20,10 +20,10 @@
#include "clienthelpnotificationserver.h" #include "clienthelpnotificationserver.h"
lc::ClientHelpNotificationServer::ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap, 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 }, QObject{ argParent },
clientIPsToClientsMap{ argClientIPsToClientsMap }, clientIPsToClientsMap{ argClientIPsToClientsMap },
hostAddress{ *argServerIP }, hostAddress{ argServerIP },
serverPort{ argServerPort } serverPort{ argServerPort }
{ {
QNetworkConfigurationManager manager; QNetworkConfigurationManager manager;

@ -33,7 +33,7 @@ class ClientHelpNotificationServer : public QObject {
Q_OBJECT Q_OBJECT
public: public:
explicit ClientHelpNotificationServer( const QMap< QString, Client* > * const argClientIPsToClientsMap, 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: signals:

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

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

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

Loading…
Cancel
Save