mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Ref T489, download progress for model component
* using COverlayMessagesFrame * onEntityDownloadProgress displaying progress
This commit is contained in:
committed by
Mat Sutcliffe
parent
fefeeac33b
commit
a908c03e93
@@ -7,12 +7,12 @@
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "blackcore/application.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackgui/components/dbmodelcomponent.h"
|
||||
#include "blackgui/filters/aircraftmodelfilterbar.h"
|
||||
#include "blackgui/guiapplication.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/viewbase.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
@@ -34,16 +34,20 @@ namespace BlackGui
|
||||
namespace Components
|
||||
{
|
||||
CDbModelComponent::CDbModelComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
COverlayMessagesFrame(parent),
|
||||
CDbMappingComponentAware(parent),
|
||||
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);
|
||||
this->setViewWithIndicator(ui->tvp_AircraftModel);
|
||||
ui->tvp_AircraftModel->setAircraftModelMode(CAircraftModelListModel::Database);
|
||||
ui->tvp_AircraftModel->menuAddItems(CAircraftModelView::MenuStashing);
|
||||
ui->tvp_AircraftModel->menuAddItems(CViewBaseNonTemplate::MenuCopy);
|
||||
ui->tvp_AircraftModel->menuRemoveItems(CAircraftModelView::MenuHighlightStashed); // not supported here
|
||||
|
||||
connect(ui->tvp_AircraftModel, &CAircraftModelView::requestNewBackendData, this, &CDbModelComponent::onReload);
|
||||
connect(ui->tvp_AircraftModel, &CAircraftModelView::requestStash, this, &CDbModelComponent::requestStash);
|
||||
connect(sGui, &CGuiApplication::styleSheetsChanged, this, &CDbModelComponent::onStyleSheetChanged, Qt::QueuedConnection);
|
||||
@@ -53,6 +57,7 @@ namespace BlackGui
|
||||
ui->tvp_AircraftModel->allowDragDrop(true, false);
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -101,5 +106,11 @@ namespace BlackGui
|
||||
// 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
|
||||
|
||||
@@ -12,15 +12,15 @@
|
||||
#ifndef BLACKUI_COMPONENTS_DBMODELCOMPONENT_H
|
||||
#define BLACKUI_COMPONENTS_DBMODELCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||
#include "blackgui/enableforviewbasedindicator.h"
|
||||
#include "blackgui/overlaymessagesframe.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
|
||||
#include <QFrame>
|
||||
#include <QObject>
|
||||
#include <QScopedPointer>
|
||||
|
||||
@@ -33,10 +33,10 @@ namespace BlackGui
|
||||
* Database models. Those are the models loaaded from the DB.
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDbModelComponent :
|
||||
public QFrame,
|
||||
public COverlayMessagesFrame,
|
||||
public CDbMappingComponentAware,
|
||||
public CEnableForDockWidgetInfoArea,
|
||||
public BlackGui::CEnableForViewBasedIndicator
|
||||
public CEnableForViewBasedIndicator
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -53,14 +53,13 @@ namespace BlackGui
|
||||
//! Models loaded?
|
||||
bool hasModels() const;
|
||||
|
||||
//! Load new data
|
||||
void requestUpdatedData();
|
||||
|
||||
signals:
|
||||
//! Request to stash the selected models
|
||||
void requestStash(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
|
||||
public:
|
||||
//! Load new data
|
||||
void requestUpdatedData();
|
||||
|
||||
private:
|
||||
//! Models have been read
|
||||
void onModelsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
@@ -71,6 +70,9 @@ namespace BlackGui
|
||||
//! Style sheet changed
|
||||
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:
|
||||
QScopedPointer<Ui::CDbModelComponent> ui;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user