From 1b69a65b004a68325561aa7a69be0e1b8eac57b5 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sun, 27 Nov 2016 01:59:00 +0100 Subject: [PATCH] refs #787, support for shared files in load component Display component in swift pilot client (under settings) --- .../components/dbloadoverviewcomponent.cpp | 95 ++++++++++++--- .../components/dbloadoverviewcomponent.h | 19 ++- src/blackgui/components/settingscomponent.cpp | 2 + src/blackgui/components/settingscomponent.h | 1 + src/blackgui/components/settingscomponent.ui | 112 ++++++++++++++++-- 5 files changed, 199 insertions(+), 30 deletions(-) diff --git a/src/blackgui/components/dbloadoverviewcomponent.cpp b/src/blackgui/components/dbloadoverviewcomponent.cpp index f2f2a6d95..2f76b0ec8 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.cpp +++ b/src/blackgui/components/dbloadoverviewcomponent.cpp @@ -12,6 +12,7 @@ #include "blackcore/webdataservices.h" #include "blackgui/guiapplication.h" +#include "blackmisc/network/networkutils.h" using namespace BlackGui; using namespace BlackCore; @@ -39,13 +40,22 @@ namespace BlackGui ui->lbl_SharedUrls->setTextInteractionFlags(Qt::TextBrowserInteraction); ui->lbl_SharedUrls->setOpenExternalLinks(true); - connect(ui->tb_ReloadAircraft, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadAirlines, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadAirports, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadCountries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadLiveries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); - connect(ui->tb_ReloadDistributors, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); + connect(ui->tb_DbReloadAircraft, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadAirlines, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadAirports, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadCountries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadLiveries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + connect(ui->tb_DbReloadDistributors, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed); + + connect(ui->tb_SharedReloadAircraft, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadAirlines, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadAirports, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadCountries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadLiveries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(ui->tb_SharedReloadDistributors, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshSharedPressed); + connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadOverviewComponent::ps_dataLoaded); } @@ -57,6 +67,30 @@ namespace BlackGui this->ps_setValues(); } + void CDbLoadOverviewComponent::setVisibleDbRefreshButtons(bool visible) + { + ui->lbl_DbRefresh->setVisible(visible); + ui->tb_DbReloadAircraft->setVisible(visible); + ui->tb_DbReloadAirlines->setVisible(visible); + ui->tb_DbReloadAirports->setVisible(visible); + ui->tb_DbReloadCountries->setVisible(visible); + ui->tb_DbReloadLiveries->setVisible(visible); + ui->tb_DbReloadModels->setVisible(visible); + ui->tb_DbReloadDistributors->setVisible(visible); + } + + void CDbLoadOverviewComponent::setVisibleSharedRefreshButtons(bool visible) + { + ui->lbl_SharedRefresh->setVisible(visible); + ui->tb_SharedReloadAircraft->setVisible(visible); + ui->tb_SharedReloadAirlines->setVisible(visible); + ui->tb_SharedReloadAirports->setVisible(visible); + ui->tb_SharedReloadCountries->setVisible(visible); + ui->tb_SharedReloadLiveries->setVisible(visible); + ui->tb_SharedReloadModels->setVisible(visible); + ui->tb_SharedReloadDistributors->setVisible(visible); + } + void CDbLoadOverviewComponent::ps_setValues() { if (!sGui) { return; } @@ -103,23 +137,29 @@ namespace BlackGui ui->le_DistributorsSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::DistributorEntity)); // DB URL - const QString dbUrlHtml("%2"); + static const QString imgOk(":/diagona/icons/diagona/icons/tick.png"); + static const QString imgFailed(":/diagona/icons/diagona/icons/cross-script.png"); + const QString dbUrlHtml("  %3"); QString url = sGui->getGlobalSetup().getDbHomePageUrl().getFullUrl(); - ui->lbl_DatabaseUrl->setText(dbUrlHtml.arg(url, url)); + bool canConnect = CNetworkUtils::canConnect(sGui->getGlobalSetup().getDbHomePageUrl()); + ui->lbl_DatabaseUrl->setText(dbUrlHtml.arg(canConnect ? imgOk : imgFailed, url, url)); ui->lbl_DatabaseUrl->setToolTip(url); // Shared URLs const CUrlList sharedUrls(sGui->getGlobalSetup().getSwiftSharedUrls()); - const QString sharedUrlHtml("%2"); + const QString tableHtml("%1
"); + const QString rowHtml(" %2"); + const QString urlLinkHtml("%2"); - QString sharedUrlsHtml; + QString allRowsHtml; for (const CUrl &sharedUrl : sharedUrls) { - sharedUrlsHtml += sharedUrlHtml.arg(sharedUrl.getFullUrl(), sharedUrl.getHost()); - sharedUrlsHtml += " "; + canConnect = CNetworkUtils::canConnect(sharedUrl); + allRowsHtml += rowHtml.arg(canConnect ? imgOk : imgFailed, urlLinkHtml.arg(sharedUrl.getFullUrl(), sharedUrl.getHost())); } - ui->lbl_SharedUrls->setText(sharedUrlsHtml.trimmed()); - ui->lbl_SharedUrls->setToolTip(sharedUrls.toQString()); + ui->lbl_SharedUrls->setText(tableHtml.arg(allRowsHtml.trimmed())); + ui->lbl_SharedUrls->setToolTip(sGui->getWebDataServices()->getDbReaderCurrentSharedDbDataUrl().toQString()); + ui->lbl_SharedUrls->setMinimumHeight(10 + (18 * sharedUrls.size())); // Indicator if (this->m_loadIndicator) { this->m_loadIndicator->stopAnimation(); } @@ -182,20 +222,37 @@ namespace BlackGui sGui->getWebDataServices()->admitDbCaches(CEntityFlags::AllDbEntities); } - void CDbLoadOverviewComponent::ps_reloadPressed() + void CDbLoadOverviewComponent::ps_refreshDbPressed() { if (this->m_reloading) { return; } - QObject *sender = QObject::sender(); - CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName()); + const QObject *sender = QObject::sender(); + const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName()); // DB entities - CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerReloadFromDb(entity); + const CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(entity); if (triggeredEntity == CEntityFlags::NoEntity) { return; } this->m_reloading = true; this->showLoading(); // shared files ts sGui->getWebDataServices()->triggerLoadingOfSharedFilesHeaders(entity); + sGui->getWebDataServices()->triggerReadOfInfoObjects(); + } + + void CDbLoadOverviewComponent::ps_refreshSharedPressed() + { + if (this->m_reloading) { return; } + const QObject *sender = QObject::sender(); + const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName()); + + // DB entities + const CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(entity, true); + if (triggeredEntity == CEntityFlags::NoEntity) { return; } + this->m_reloading = true; + this->showLoading(); + + // shared files ts + sGui->getWebDataServices()->triggerReadOfInfoObjects(); } void CDbLoadOverviewComponent::ps_dataLoaded(CEntityFlags::Entity entity, CEntityFlags::ReadState state, int number) diff --git a/src/blackgui/components/dbloadoverviewcomponent.h b/src/blackgui/components/dbloadoverviewcomponent.h index 7fc1618ba..bcc725d8c 100644 --- a/src/blackgui/components/dbloadoverviewcomponent.h +++ b/src/blackgui/components/dbloadoverviewcomponent.h @@ -40,10 +40,22 @@ namespace BlackGui //! Initialize void display(); + //! Visible DB refresh buttons + void setVisibleDbRefreshButtons(bool visible); + + //! Visible shared refresh buttons + void setVisibleSharedRefreshButtons(bool visible); + + signals: + //! Trigger GUI update + //! \private + void ps_triggerDigestGuiUpdate(); + private: QScopedPointer ui; BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed bool m_reloading = false; + BlackMisc::CDigestSignal m_dsTriggerGuiUpdate { this, &CDbLoadOverviewComponent::ps_triggerDigestGuiUpdate, &CDbLoadOverviewComponent::ps_setValues, 750, 4 }; //! Show loading void showLoading(); @@ -73,8 +85,11 @@ namespace BlackGui static void admitCaches(); private slots: - //! Reload - void ps_reloadPressed(); + //! Refresh directly from DB + void ps_refreshDbPressed(); + + //! Refresh directly from DB + void ps_refreshSharedPressed(); //! Init the value panel void ps_setValues(); diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index 7a4d2e5cb..310cb3f00 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -55,6 +55,7 @@ namespace BlackGui connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_Simulator, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_SimulatorBasics, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); + connect(ui->pb_DataLoadAndCaches, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_SimulatorMessages, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); } @@ -87,6 +88,7 @@ namespace BlackGui if (sender == ui->pb_Servers) { this->setCurrentIndex(SettingTabServers); return; } if (sender == ui->pb_Simulator) { this->setCurrentIndex(SettingTabSimulator); return; } if (sender == ui->pb_SimulatorBasics) { this->setCurrentIndex(SettingTabSimulatorBasics); return; } + if (sender == ui->pb_DataLoadAndCaches) { this->setCurrentIndex(SettingTabDataAndCaches); return; } if (sender == ui->pb_SimulatorMessages) { this->setCurrentIndex(SettingTabSimulatorMessages); return; } this->setCurrentIndex(SettingTabOverview); } diff --git a/src/blackgui/components/settingscomponent.h b/src/blackgui/components/settingscomponent.h index cc491b056..66881e92a 100644 --- a/src/blackgui/components/settingscomponent.h +++ b/src/blackgui/components/settingscomponent.h @@ -45,6 +45,7 @@ namespace BlackGui SettingTabSimulatorMessages, SettingTabGui, SettingTabHotkeys, + SettingTabDataAndCaches, SettingTabAdvanced }; diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index 636b206db..ad1c51f82 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -83,13 +83,20 @@ - + Advanced + + + + Data load and caches + + + @@ -406,7 +413,7 @@ Hotkeys - + 2 @@ -430,21 +437,102 @@ 0 - - QFrame::StyledPanel - - - QFrame::Raised - + + + Data and caches + + + + 2 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + true + + + + + 0 + 0 + 479 + 198 + + + + + 2 + + + 1 + + + 1 + + + 1 + + + 1 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + Advanced - + + + 2 + + + 1 + + + 1 + + + 1 + + + 1 + @@ -459,6 +547,12 @@ + + BlackGui::Components::CDbLoadOverviewComponent + QFrame +
blackgui/components/dbloadoverviewcomponent.h
+ 1 +
BlackGui::Components::CSettingsSimulatorBasicsComponent QFrame