refs #485, further removed global setup traits from classes with read only

Use global setup from sGui/sApp
This commit is contained in:
Klaus Basan
2016-03-01 01:49:59 +01:00
committed by Mathew Sutcliffe
parent 30b5e5dade
commit aa96731143
20 changed files with 22 additions and 48 deletions

View File

@@ -51,7 +51,7 @@ namespace BlackCore
if (pw.isEmpty()) { msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "No password")); }
if (!msgs.isEmpty()) { return msgs; }
CUrl url(this->m_setup.get().dbLoginServiceUrl());
const CUrl url(sApp->getGlobalSetup().dbLoginServiceUrl());
QString msg;
if (!CNetworkUtils::canConnect(url, msg))
{
@@ -62,7 +62,7 @@ namespace BlackCore
QUrlQuery params;
params.addQueryItem("username", un);
params.addQueryItem("password", pw);
if (m_setup.get().dbDebugFlag()) { CNetworkUtils::addDebugFlag(params); }
if (sApp->getGlobalSetup().dbDebugFlag()) { CNetworkUtils::addDebugFlag(params); }
QString query = params.toString();
const QNetworkRequest request(CNetworkUtils::getNetworkRequest(url, CNetworkUtils::PostUrlEncoded));
@@ -74,7 +74,7 @@ namespace BlackCore
void CDatabaseAuthenticationService::logoff()
{
CUrl url(this->m_setup.get().dbLoginServiceUrl());
CUrl url(sApp->getGlobalSetup().dbLoginServiceUrl());
url.setQuery("logoff=true");
QNetworkRequest request(CNetworkUtils::getNetworkRequest(url));
sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse });

View File

@@ -59,7 +59,6 @@ namespace BlackCore
void ps_userChanged();
private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
BlackMisc::CData<BlackCore::Data::AuthenticatedDbUser> m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged};
bool m_shutdown = false;
};

View File

@@ -51,7 +51,7 @@ namespace BlackCore
CNetworkUtils::ignoreSslVerification(request);
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType, this);
multiPart->append(CNetworkUtils::getJsonTextMultipart(models.toDatabaseJson()));
if (m_setup.get().dbDebugFlag())
if (sApp->getGlobalSetup().dbDebugFlag())
{
multiPart->append(CNetworkUtils::getMultipartWithDebugFlag());
}

View File

@@ -47,7 +47,6 @@ namespace BlackCore
void ps_postResponse(QNetworkReply *nwReplyPtr);
private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< data cache
BlackMisc::Network::CUrl m_modelPublishUrl;
QNetworkReply *m_pendingReply = nullptr;
bool m_shutdown = false;

View File

@@ -45,7 +45,7 @@ namespace BlackCore
{
this->threadAssertCheck();
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
QUrl url(m_setup.get().vatsimBookingsUrl());
const QUrl url(sApp->getGlobalSetup().vatsimBookingsUrl());
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimBookingReader::ps_parseBookings});

View File

@@ -54,9 +54,6 @@ namespace BlackCore
//! Do reading
void ps_read();
private:
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
};
}

View File

@@ -158,9 +158,9 @@ namespace BlackCore
// round robin for load balancing
// remark: Don't use QThread to run network operations in the background
// see http://qt-project.org/doc/qt-4.7/qnetworkaccessmanager.html
QUrl url(m_setup.get().vatsimDataFileUrls().getRandomUrl());
if (url.isEmpty()) { return; }
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing application");
const QUrl url(sApp->getGlobalSetup().vatsimDataFileUrls().getRandomUrl());
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
}

View File

@@ -128,7 +128,6 @@ namespace BlackCore
BlackMisc::Aviation::CAtcStationList m_atcStations;
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
QMap<BlackMisc::Aviation::CCallsign, BlackMisc::Network::CVoiceCapabilities> m_voiceCapabilities;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
//! Split line and assign values to their corresponding attribute names
static const QMap<QString, QString> clientPartsToMap(const QString &currentLine, const QStringList &clientSectionAttributes);

View File

@@ -466,7 +466,7 @@ namespace BlackCore
void CWebDataServices::initWriters()
{
this->m_databaseWriter = new CDatabaseWriter(
m_setup.get().dbRootDirectoryUrl(),
sApp->getGlobalSetup().dbRootDirectoryUrl(),
this);
}

View File

@@ -281,7 +281,6 @@ namespace BlackCore
CWebReaderFlags::WebReader m_readerFlags = CWebReaderFlags::WebReaderFlag::None; //!< which readers are available
CWebReaderFlags::DbReaderHint m_dbHint = CWebReaderFlags::NoHint; //!< how to read DB data
bool m_initialRead = false; //!< Initial read conducted
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CWebDataServices::ps_setupChanged}; //!< setup cache
// for reading XML and VATSIM data files
CVatsimBookingReader *m_vatsimBookingReader = nullptr;

View File

@@ -10,6 +10,7 @@
#include "dblogincomponent.h"
#include "ui_dblogincomponent.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/guiapplication.h"
#include "blackmisc/verify.h"
#include "blackmisc/network/url.h"
#include "blackmisc/logmessage.h"
@@ -28,7 +29,11 @@ namespace BlackGui
{
ui->setupUi(this);
this->setModeLogin(true);
this->ps_setupChanged();
CUrl url(sGui->getGlobalSetup().dbHomePageUrl());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
connect(ui->pb_Login, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLoginClicked);
connect(ui->pb_Logoff, &QPushButton::clicked, this, &CDbLoginComponent::ps_onLogoffClicked);
@@ -89,15 +94,6 @@ namespace BlackGui
}
}
void CDbLoginComponent::ps_setupChanged()
{
CUrl url(m_setup.get().dbHomePageUrl());
ui->lbl_SwiftDB->setText("<a href=\"" + url.getFullUrl() + "\">swift DB@" + url.getHost() + "</a>");
ui->lbl_SwiftDB->setTextFormat(Qt::RichText);
ui->lbl_SwiftDB->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SwiftDB->setOpenExternalLinks(true);
}
void CDbLoginComponent::setModeLogin(bool modeLogin)
{
this->ui->fr_Login->setVisible(modeLogin);

View File

@@ -39,9 +39,8 @@ namespace BlackGui
~CDbLoginComponent();
private:
QScopedPointer<Ui::CDbLoginComponent> ui;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CDbLoginComponent::ps_setupChanged}; //!< data cache
BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
QScopedPointer<Ui::CDbLoginComponent> ui;
BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service
//! Overlay messages
void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs);
@@ -59,8 +58,6 @@ namespace BlackGui
//! User authentication completed
void ps_AuthenticationFinished(const BlackMisc::Network::CAuthenticatedUser &user, const BlackMisc::CStatusMessageList &status);
//! Setup changed
void ps_setupChanged();
};
} // ns
} // ns

View File

@@ -108,7 +108,7 @@ namespace BlackGui
// add a testserver when no servers can be loaded
if (otherServers.isEmpty() && (sGui->isRunningInDeveloperEnvironment() || CProject::isBetaTest()))
{
otherServers.push_back(m_setup.get().fsdTestServersPlusHardcodedServers());
otherServers.push_back(sGui->getGlobalSetup().fsdTestServersPlusHardcodedServers());
CLogMessage(this).info("Added servers for testing");
}
this->ui->cbp_OtherServers->setServers(otherServers);

View File

@@ -143,7 +143,6 @@ namespace BlackGui
const int LogoffIntervalSeconds = 10;
QTimer *m_logoffCountdownTimer { nullptr };
BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_otherTrafficNetworkServers { this, &CLoginComponent::ps_reloadSettings };
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
};
} // namespace

View File

@@ -55,7 +55,7 @@ namespace BlackGui
// this is debug/bootstrap feature we can continue to test when something goes wrong
if (serverList.isEmpty() && (CProject::isBetaTest() || sGui->isRunningInDeveloperEnvironment()))
{
serverList.push_back(m_setup.get().fsdTestServersPlusHardcodedServers());
serverList.push_back(sGui->getGlobalSetup().fsdTestServersPlusHardcodedServers());
this->ui->tvp_Servers->updateContainer(serverList);
}
}

View File

@@ -50,7 +50,6 @@ namespace BlackGui
private:
QScopedPointer<Ui::CSettingsNetworkServersComponent> ui;
BlackMisc::CSetting<BlackCore::Settings::Network::TrafficServers> m_trafficNetworkServers { this, &CSettingsNetworkServersComponent::ps_reloadSettings };
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this}; //!< setup cache
};
} // ns
} // ns

View File

@@ -63,9 +63,6 @@ private slots:
//! Menu clicked
void ps_onMenuClicked();
//! Setup has been changed
void ps_setupChanged();
private:
void init();
void initLogDisplay();
@@ -79,7 +76,6 @@ private:
QScopedPointer<Ui::CSwiftData> ui;
BlackGui::CManagedStatusBar m_statusBar;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup {this, &CSwiftData::ps_setupChanged}; //!< setup cache
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this }; //!< download / version data
};

View File

@@ -105,7 +105,7 @@ void CSwiftData::ps_onMenuClicked()
}
else if (sender == this->ui->menu_JsonBootstrapTemplate)
{
QString json(m_setup.get().toJsonString());
QString json(sApp->getGlobalSetup().toJsonString());
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(json);
this->displayConsole();
}
@@ -123,7 +123,7 @@ void CSwiftData::ps_onMenuClicked()
}
else if (sender == this->ui->menu_InternalsSetup)
{
QString setup(this->m_setup.get().convertToQString("\n", true));
QString setup(sApp->getGlobalSetup().convertToQString("\n", true));
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(setup);
this->displayConsole();
}
@@ -135,11 +135,6 @@ void CSwiftData::ps_onMenuClicked()
}
}
void CSwiftData::ps_setupChanged()
{
CLogMessage(this).debug() << "Setup changed";
}
void CSwiftData::initDynamicMenus()
{
Q_ASSERT_X(this->ui->menu_InfoAreas, Q_FUNC_INFO, "missing info areas");

View File

@@ -134,7 +134,7 @@ void CSwiftLauncher::initStyleSheet()
void CSwiftLauncher::displayLatestNews()
{
#ifndef Q_CC_MINGW
CFailoverUrlList newsUrls(this->m_setup.get().swiftLatestNewsUrls());
CFailoverUrlList newsUrls(sGui->getGlobalSetup().swiftLatestNewsUrls());
QUrl newUrl(newsUrls.obtainNextWorkingUrl());
Q_UNUSED(newUrl);
@@ -343,7 +343,7 @@ void CSwiftLauncher::ps_startButtonPressed()
}
else if (sender == this->ui->tb_Database)
{
CUrl homePage(this->m_setup.get().dbHomePageUrl());
const CUrl homePage(sApp->getGlobalSetup().dbHomePageUrl());
QDesktopServices::openUrl(homePage);
}
}

View File

@@ -60,7 +60,6 @@ protected:
private:
QScopedPointer<Ui::CSwiftLauncher> ui;
BlackMisc::CData<BlackCore::Data::GlobalSetup> m_setup { this, &CSwiftLauncher::ps_changedCache }; //!< setup cache
BlackMisc::CData<BlackCore::Data::UpdateInfo> m_updateInfo { this, &CSwiftLauncher::ps_changedCache }; //!< version cache
QString m_executable;
QStringList m_executableArgs;