refs #787, support for shared files in load component

Display component in swift pilot client (under settings)
This commit is contained in:
Klaus Basan
2016-11-27 01:59:00 +01:00
parent 49613651a8
commit 1b69a65b00
5 changed files with 199 additions and 30 deletions

View File

@@ -12,6 +12,7 @@
#include "blackcore/webdataservices.h" #include "blackcore/webdataservices.h"
#include "blackgui/guiapplication.h" #include "blackgui/guiapplication.h"
#include "blackmisc/network/networkutils.h"
using namespace BlackGui; using namespace BlackGui;
using namespace BlackCore; using namespace BlackCore;
@@ -39,13 +40,22 @@ namespace BlackGui
ui->lbl_SharedUrls->setTextInteractionFlags(Qt::TextBrowserInteraction); ui->lbl_SharedUrls->setTextInteractionFlags(Qt::TextBrowserInteraction);
ui->lbl_SharedUrls->setOpenExternalLinks(true); ui->lbl_SharedUrls->setOpenExternalLinks(true);
connect(ui->tb_ReloadAircraft, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadAircraft, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadAirlines, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadAirlines, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadAirports, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadAirports, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadCountries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadCountries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadLiveries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadLiveries, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); connect(ui->tb_DbReloadModels, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_refreshDbPressed);
connect(ui->tb_ReloadDistributors, &QToolButton::pressed, this, &CDbLoadOverviewComponent::ps_reloadPressed); 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); connect(sGui->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbLoadOverviewComponent::ps_dataLoaded);
} }
@@ -57,6 +67,30 @@ namespace BlackGui
this->ps_setValues(); 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() void CDbLoadOverviewComponent::ps_setValues()
{ {
if (!sGui) { return; } if (!sGui) { return; }
@@ -103,23 +137,29 @@ namespace BlackGui
ui->le_DistributorsSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::DistributorEntity)); ui->le_DistributorsSharedFileTs->setText(sharedFileTimestampForEntity(CEntityFlags::DistributorEntity));
// DB URL // DB URL
const QString dbUrlHtml("<a href=\"%1\">%2</a>"); static const QString imgOk(":/diagona/icons/diagona/icons/tick.png");
static const QString imgFailed(":/diagona/icons/diagona/icons/cross-script.png");
const QString dbUrlHtml("<img src=\"%1\">&nbsp;&nbsp;<a href=\"%2\">%3</a>");
QString url = sGui->getGlobalSetup().getDbHomePageUrl().getFullUrl(); 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); ui->lbl_DatabaseUrl->setToolTip(url);
// Shared URLs // Shared URLs
const CUrlList sharedUrls(sGui->getGlobalSetup().getSwiftSharedUrls()); const CUrlList sharedUrls(sGui->getGlobalSetup().getSwiftSharedUrls());
const QString sharedUrlHtml("<a href=\"%1\">%2</a>"); const QString tableHtml("<table>%1</table>");
const QString rowHtml("<tr><td><img src=\"%1\">&nbsp;</td><td>%2</td></tr>");
const QString urlLinkHtml("<a href=\"%1\">%2</a>");
QString sharedUrlsHtml; QString allRowsHtml;
for (const CUrl &sharedUrl : sharedUrls) for (const CUrl &sharedUrl : sharedUrls)
{ {
sharedUrlsHtml += sharedUrlHtml.arg(sharedUrl.getFullUrl(), sharedUrl.getHost()); canConnect = CNetworkUtils::canConnect(sharedUrl);
sharedUrlsHtml += " "; allRowsHtml += rowHtml.arg(canConnect ? imgOk : imgFailed, urlLinkHtml.arg(sharedUrl.getFullUrl(), sharedUrl.getHost()));
} }
ui->lbl_SharedUrls->setText(sharedUrlsHtml.trimmed()); ui->lbl_SharedUrls->setText(tableHtml.arg(allRowsHtml.trimmed()));
ui->lbl_SharedUrls->setToolTip(sharedUrls.toQString()); ui->lbl_SharedUrls->setToolTip(sGui->getWebDataServices()->getDbReaderCurrentSharedDbDataUrl().toQString());
ui->lbl_SharedUrls->setMinimumHeight(10 + (18 * sharedUrls.size()));
// Indicator // Indicator
if (this->m_loadIndicator) { this->m_loadIndicator->stopAnimation(); } if (this->m_loadIndicator) { this->m_loadIndicator->stopAnimation(); }
@@ -182,20 +222,37 @@ namespace BlackGui
sGui->getWebDataServices()->admitDbCaches(CEntityFlags::AllDbEntities); sGui->getWebDataServices()->admitDbCaches(CEntityFlags::AllDbEntities);
} }
void CDbLoadOverviewComponent::ps_reloadPressed() void CDbLoadOverviewComponent::ps_refreshDbPressed()
{ {
if (this->m_reloading) { return; } if (this->m_reloading) { return; }
QObject *sender = QObject::sender(); const QObject *sender = QObject::sender();
CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName()); const CEntityFlags::Entity entity = CEntityFlags::singleEntityByName(sender->objectName());
// DB entities // DB entities
CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerReloadFromDb(entity); const CEntityFlags::Entity triggeredEntity = sGui->getWebDataServices()->triggerLoadingDirectlyFromDb(entity);
if (triggeredEntity == CEntityFlags::NoEntity) { return; } if (triggeredEntity == CEntityFlags::NoEntity) { return; }
this->m_reloading = true; this->m_reloading = true;
this->showLoading(); this->showLoading();
// shared files ts // shared files ts
sGui->getWebDataServices()->triggerLoadingOfSharedFilesHeaders(entity); 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) void CDbLoadOverviewComponent::ps_dataLoaded(CEntityFlags::Entity entity, CEntityFlags::ReadState state, int number)

View File

@@ -40,10 +40,22 @@ namespace BlackGui
//! Initialize //! Initialize
void display(); 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: private:
QScopedPointer<Ui::CDbLoadOverviewComponent> ui; QScopedPointer<Ui::CDbLoadOverviewComponent> ui;
BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed BlackGui::CLoadIndicator *m_loadIndicator = nullptr; //!< load indicator if needed
bool m_reloading = false; bool m_reloading = false;
BlackMisc::CDigestSignal m_dsTriggerGuiUpdate { this, &CDbLoadOverviewComponent::ps_triggerDigestGuiUpdate, &CDbLoadOverviewComponent::ps_setValues, 750, 4 };
//! Show loading //! Show loading
void showLoading(); void showLoading();
@@ -73,8 +85,11 @@ namespace BlackGui
static void admitCaches(); static void admitCaches();
private slots: private slots:
//! Reload //! Refresh directly from DB
void ps_reloadPressed(); void ps_refreshDbPressed();
//! Refresh directly from DB
void ps_refreshSharedPressed();
//! Init the value panel //! Init the value panel
void ps_setValues(); void ps_setValues();

View File

@@ -55,6 +55,7 @@ namespace BlackGui
connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked); connect(ui->pb_Servers, &QPushButton::released, this, &CSettingsComponent::ps_overviewButtonClicked);
connect(ui->pb_Simulator, &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_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); 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_Servers) { this->setCurrentIndex(SettingTabServers); return; }
if (sender == ui->pb_Simulator) { this->setCurrentIndex(SettingTabSimulator); return; } if (sender == ui->pb_Simulator) { this->setCurrentIndex(SettingTabSimulator); return; }
if (sender == ui->pb_SimulatorBasics) { this->setCurrentIndex(SettingTabSimulatorBasics); 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; } if (sender == ui->pb_SimulatorMessages) { this->setCurrentIndex(SettingTabSimulatorMessages); return; }
this->setCurrentIndex(SettingTabOverview); this->setCurrentIndex(SettingTabOverview);
} }

View File

@@ -45,6 +45,7 @@ namespace BlackGui
SettingTabSimulatorMessages, SettingTabSimulatorMessages,
SettingTabGui, SettingTabGui,
SettingTabHotkeys, SettingTabHotkeys,
SettingTabDataAndCaches,
SettingTabAdvanced SettingTabAdvanced
}; };

View File

@@ -83,13 +83,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="3" column="1">
<widget class="QPushButton" name="pb_Advanced"> <widget class="QPushButton" name="pb_Advanced">
<property name="text"> <property name="text">
<string>Advanced</string> <string>Advanced</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1">
<widget class="QPushButton" name="pb_DataLoadAndCaches">
<property name="text">
<string>Data load and caches</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tb_SettingsTrafficNetworkServers"> <widget class="QWidget" name="tb_SettingsTrafficNetworkServers">
@@ -406,7 +413,7 @@
<attribute name="title"> <attribute name="title">
<string>Hotkeys</string> <string>Hotkeys</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="vl_SettingsMisc"> <layout class="QVBoxLayout" name="vl_SettingsHotkeys">
<property name="spacing"> <property name="spacing">
<number>2</number> <number>2</number>
</property> </property>
@@ -430,21 +437,102 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tb_DataLoad">
<attribute name="title">
<string>Data and caches</string>
</attribute>
<layout class="QVBoxLayout" name="vl_DataLoad">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QScrollArea" name="sa_DataLoad">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="wi_DataLoadOverview">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<height>198</height>
</rect>
</property>
<layout class="QVBoxLayout" name="vl_DataLoadOverview">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="BlackGui::Components::CDbLoadOverviewComponent" name="comp_DataLoadOverview"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<spacer name="vs_DataLoad">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_SettingsAdvanced"> <widget class="QWidget" name="tb_SettingsAdvanced">
<attribute name="title"> <attribute name="title">
<string>Advanced</string> <string>Advanced</string>
</attribute> </attribute>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="vl_SettingsAdvanced">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item> <item>
<widget class="BlackGui::Components::CSettingsAdvancedComponent" name="comp_SettingsAdvancedComponent"> <widget class="BlackGui::Components::CSettingsAdvancedComponent" name="comp_SettingsAdvancedComponent">
<property name="frameShape"> <property name="frameShape">
@@ -459,6 +547,12 @@
</widget> </widget>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>BlackGui::Components::CDbLoadOverviewComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/dbloadoverviewcomponent.h</header>
<container>1</container>
</customwidget>
<customwidget> <customwidget>
<class>BlackGui::Components::CSettingsSimulatorBasicsComponent</class> <class>BlackGui::Components::CSettingsSimulatorBasicsComponent</class>
<extends>QFrame</extends> <extends>QFrame</extends>