Ref T489, download progress for model component

* using COverlayMessagesFrame
* onEntityDownloadProgress displaying progress
This commit is contained in:
Klaus Basan
2018-12-28 01:05:39 +01:00
committed by Mat Sutcliffe
parent fefeeac33b
commit a908c03e93
2 changed files with 25 additions and 12 deletions

View File

@@ -7,12 +7,12 @@
* contained in the LICENSE file. * contained in the LICENSE file.
*/ */
#include "blackcore/application.h"
#include "blackcore/webdataservices.h"
#include "blackgui/components/dbmodelcomponent.h" #include "blackgui/components/dbmodelcomponent.h"
#include "blackgui/filters/aircraftmodelfilterbar.h" #include "blackgui/filters/aircraftmodelfilterbar.h"
#include "blackgui/guiapplication.h"
#include "blackgui/models/aircraftmodellistmodel.h" #include "blackgui/models/aircraftmodellistmodel.h"
#include "blackgui/guiapplication.h"
#include "blackcore/application.h"
#include "blackcore/webdataservices.h"
#include "blackgui/views/aircraftmodelview.h" #include "blackgui/views/aircraftmodelview.h"
#include "blackgui/views/viewbase.h" #include "blackgui/views/viewbase.h"
#include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/aircraftmodel.h"
@@ -34,16 +34,20 @@ namespace BlackGui
namespace Components namespace Components
{ {
CDbModelComponent::CDbModelComponent(QWidget *parent) : CDbModelComponent::CDbModelComponent(QWidget *parent) :
QFrame(parent), COverlayMessagesFrame(parent),
CDbMappingComponentAware(parent), CDbMappingComponentAware(parent),
ui(new Ui::CDbModelComponent) ui(new Ui::CDbModelComponent)
{ {
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
Q_ASSERT_X(sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web services");
ui->setupUi(this); ui->setupUi(this);
this->setViewWithIndicator(ui->tvp_AircraftModel); this->setViewWithIndicator(ui->tvp_AircraftModel);
ui->tvp_AircraftModel->setAircraftModelMode(CAircraftModelListModel::Database); ui->tvp_AircraftModel->setAircraftModelMode(CAircraftModelListModel::Database);
ui->tvp_AircraftModel->menuAddItems(CAircraftModelView::MenuStashing); ui->tvp_AircraftModel->menuAddItems(CAircraftModelView::MenuStashing);
ui->tvp_AircraftModel->menuAddItems(CViewBaseNonTemplate::MenuCopy); ui->tvp_AircraftModel->menuAddItems(CViewBaseNonTemplate::MenuCopy);
ui->tvp_AircraftModel->menuRemoveItems(CAircraftModelView::MenuHighlightStashed); // not supported here ui->tvp_AircraftModel->menuRemoveItems(CAircraftModelView::MenuHighlightStashed); // not supported here
connect(ui->tvp_AircraftModel, &CAircraftModelView::requestNewBackendData, this, &CDbModelComponent::onReload); connect(ui->tvp_AircraftModel, &CAircraftModelView::requestNewBackendData, this, &CDbModelComponent::onReload);
connect(ui->tvp_AircraftModel, &CAircraftModelView::requestStash, this, &CDbModelComponent::requestStash); connect(ui->tvp_AircraftModel, &CAircraftModelView::requestStash, this, &CDbModelComponent::requestStash);
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDbModelComponent::onStyleSheetChanged, Qt::QueuedConnection); connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDbModelComponent::onStyleSheetChanged, Qt::QueuedConnection);
@@ -53,6 +57,7 @@ namespace BlackGui
ui->tvp_AircraftModel->allowDragDrop(true, false); ui->tvp_AircraftModel->allowDragDrop(true, false);
connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbModelComponent::onModelsRead); connect(sApp->getWebDataServices(), &CWebDataServices::dataRead, this, &CDbModelComponent::onModelsRead);
connect(sGui->getWebDataServices(), &CWebDataServices::entityDownloadProgress, this, &CDbModelComponent::onEntityDownloadProgress, Qt::QueuedConnection);
this->onModelsRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getModelsCount()); this->onModelsRead(CEntityFlags::ModelEntity, CEntityFlags::ReadFinished, sApp->getWebDataServices()->getModelsCount());
} }
@@ -101,5 +106,11 @@ namespace BlackGui
// code goes here // code goes here
} }
void CDbModelComponent::onEntityDownloadProgress(CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url)
{
if (CEntityFlags::ModelEntity != entity) { return; }
this->showDownloadProgress(progress, current, max, url, 5000);
Q_UNUSED(logId);
}
} // ns } // ns
} // ns } // ns

View File

@@ -12,15 +12,15 @@
#ifndef BLACKUI_COMPONENTS_DBMODELCOMPONENT_H #ifndef BLACKUI_COMPONENTS_DBMODELCOMPONENT_H
#define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H #define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H
#include "blackgui/blackguiexport.h"
#include "blackgui/components/dbmappingcomponentaware.h" #include "blackgui/components/dbmappingcomponentaware.h"
#include "blackgui/components/enablefordockwidgetinfoarea.h" #include "blackgui/components/enablefordockwidgetinfoarea.h"
#include "blackgui/enableforviewbasedindicator.h" #include "blackgui/enableforviewbasedindicator.h"
#include "blackgui/overlaymessagesframe.h"
#include "blackgui/blackguiexport.h"
#include "blackmisc/network/entityflags.h" #include "blackmisc/network/entityflags.h"
#include "blackmisc/simulation/aircraftmodel.h" #include "blackmisc/simulation/aircraftmodel.h"
#include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/aircraftmodellist.h"
#include <QFrame>
#include <QObject> #include <QObject>
#include <QScopedPointer> #include <QScopedPointer>
@@ -33,10 +33,10 @@ namespace BlackGui
* Database models. Those are the models loaaded from the DB. * Database models. Those are the models loaaded from the DB.
*/ */
class BLACKGUI_EXPORT CDbModelComponent : class BLACKGUI_EXPORT CDbModelComponent :
public QFrame, public COverlayMessagesFrame,
public CDbMappingComponentAware, public CDbMappingComponentAware,
public CEnableForDockWidgetInfoArea, public CEnableForDockWidgetInfoArea,
public BlackGui::CEnableForViewBasedIndicator public CEnableForViewBasedIndicator
{ {
Q_OBJECT Q_OBJECT
@@ -53,14 +53,13 @@ namespace BlackGui
//! Models loaded? //! Models loaded?
bool hasModels() const; bool hasModels() const;
//! Load new data
void requestUpdatedData();
signals: signals:
//! Request to stash the selected models //! Request to stash the selected models
void requestStash(const BlackMisc::Simulation::CAircraftModelList &models); void requestStash(const BlackMisc::Simulation::CAircraftModelList &models);
public:
//! Load new data
void requestUpdatedData();
private: private:
//! Models have been read //! Models have been read
void onModelsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count); void onModelsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
@@ -71,6 +70,9 @@ namespace BlackGui
//! Style sheet changed //! Style sheet changed
void onStyleSheetChanged(); void onStyleSheetChanged();
//! Download progress for an entity
void onEntityDownloadProgress(BlackMisc::Network::CEntityFlags::Entity entity, int logId, int progress, qint64 current, qint64 max, const QUrl &url);
private: private:
QScopedPointer<Ui::CDbModelComponent> ui; QScopedPointer<Ui::CDbModelComponent> ui;
}; };