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.
*/
#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