mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
refs #568, adjusted GUI components
* use incremental updates * use new signatures * handle successfully published models * some custom menus are gone, because they are now part of the specialized views
This commit is contained in:
@@ -10,11 +10,14 @@
|
||||
#include "ui_datainfoareacomponent.h"
|
||||
#include "blackgui/components/logcomponent.h"
|
||||
#include "blackgui/components/datainfoareacomponent.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackGui;
|
||||
using namespace BlackGui::Components;
|
||||
|
||||
@@ -151,5 +154,19 @@ namespace BlackGui
|
||||
return CIcons::empty();
|
||||
}
|
||||
}
|
||||
|
||||
void CDataInfoAreaComponent::requestUpdatedData(CEntityFlags::Entity entity)
|
||||
{
|
||||
bool requested = false;
|
||||
if (entity.testFlag(CEntityFlags::ModelEntity))
|
||||
{
|
||||
this->ui->comp_DbModels->requestUpdatedData();
|
||||
requested = true;
|
||||
}
|
||||
|
||||
// sanity
|
||||
BLACK_VERIFY_X(requested, Q_FUNC_INFO, "Entity not supported");
|
||||
Q_UNUSED(requested);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackGui
|
||||
class CDbCountryComponent;
|
||||
|
||||
/**
|
||||
* Main info area for data entry tool
|
||||
* Info area containing the DB data (models, liveries ...)
|
||||
*/
|
||||
class BLACKGUI_EXPORT CDataInfoAreaComponent :
|
||||
public BlackGui::CInfoArea,
|
||||
@@ -89,6 +89,9 @@ namespace BlackGui
|
||||
//! Load from resource dir
|
||||
bool readDbDataFromResourceDir();
|
||||
|
||||
//! Load new data (based on timestamp, incremental)
|
||||
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entity);
|
||||
|
||||
protected:
|
||||
//! \copydoc CInfoArea::getPreferredSizeWhenFloating
|
||||
virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override;
|
||||
|
||||
@@ -33,6 +33,7 @@ namespace BlackGui
|
||||
|
||||
connect(ui->comp_Mapping, &CDbMappingComponent::filterByLivery, ui->comp_DataInfoArea->getLiveryComponent(), &CDbLiveryComponent::filter);
|
||||
connect(ui->comp_Mapping, &CDbMappingComponent::filterByAircraftIcao, ui->comp_DataInfoArea->getAircraftComponent(), &CDbAircraftIcaoComponent::filter);
|
||||
connect(ui->comp_Mapping, &CDbMappingComponent::requestUpdatedData, ui->comp_DataInfoArea, &CDataInfoAreaComponent::requestUpdatedData);
|
||||
}
|
||||
|
||||
CDataMainInfoAreaComponent::~CDataMainInfoAreaComponent()
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace BlackGui
|
||||
void CDbAircraftIcaoComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::AircraftIcaoEntity);
|
||||
triggerRead(CEntityFlags::AircraftIcaoEntity, QDateTime());
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackGui
|
||||
void CDbAirlineIcaoComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::AirlineIcaoEntity);
|
||||
triggerRead(CEntityFlags::AirlineIcaoEntity, QDateTime());
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace BlackGui
|
||||
void CDbCountryComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::CountryEntity);
|
||||
triggerRead(CEntityFlags::CountryEntity, QDateTime());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace BlackGui
|
||||
void CDbDistributorComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::DistributorEntity);
|
||||
triggerRead(CEntityFlags::DistributorEntity, QDateTime());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace BlackGui
|
||||
void CDbLiveryComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::LiveryEntity);
|
||||
triggerRead(CEntityFlags::LiveryEntity, QDateTime());
|
||||
}
|
||||
|
||||
} // ns
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackMisc::Simulation::FsCommon;
|
||||
using namespace BlackGui;
|
||||
@@ -53,6 +54,7 @@ namespace BlackGui
|
||||
connect(ui->comp_StashAircraft->getView(), &CAircraftModelView::doubleClicked, this, &CDbMappingComponent::ps_onModelRowSelected);
|
||||
connect(ui->comp_StashAircraft->getView(), &CAircraftModelView::requestHandlingOfStashDrop, this, &CDbMappingComponent::ps_handleStashDropRequest);
|
||||
connect(ui->comp_StashAircraft, &CDbStashComponent::stashedModelsChanged, this, &CDbMappingComponent::ps_onStashedModelsChanged);
|
||||
connect(ui->comp_StashAircraft, &CDbStashComponent::modelsSuccessfullyPublished, this, &CDbMappingComponent::ps_onModelsSuccessfullyPublished);
|
||||
|
||||
ui->tvp_OwnAircraftModels->setDisplayAutomatically(true);
|
||||
ui->tvp_OwnAircraftModels->setCustomMenu(new CMappingSimulatorModelMenu(this));
|
||||
@@ -181,9 +183,9 @@ namespace BlackGui
|
||||
switch (tab)
|
||||
{
|
||||
case TabOwnModels:
|
||||
return ui->tvp_OwnAircraftModels->hasModelsToStash();
|
||||
return ui->tvp_OwnAircraftModels->hasSelectedModelsToStash();
|
||||
case TabVPliot:
|
||||
return ui->tvp_AircraftModelsForVPilot->hasModelsToStash();
|
||||
return ui->tvp_AircraftModelsForVPilot->hasSelectedModelsToStash();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -266,12 +268,16 @@ namespace BlackGui
|
||||
{
|
||||
const CAircraftModel model(getAircraftModel());
|
||||
CStatusMessageList msgs(this->validateCurrentModel(true));
|
||||
if (!msgs.hasErrorMessages())
|
||||
{
|
||||
msgs.push_back(
|
||||
this->ui->comp_StashAircraft->stashModel(model, true)
|
||||
);
|
||||
}
|
||||
if (msgs.hasErrorMessages())
|
||||
{
|
||||
this->showMessages(msgs);
|
||||
return;
|
||||
}
|
||||
this->ui->comp_StashAircraft->stashModel(model, true);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::resizeForSelect()
|
||||
@@ -372,6 +378,12 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_onModelsSuccessfullyPublished(const CAircraftModelList &models)
|
||||
{
|
||||
if (models.isEmpty()) { return; }
|
||||
emit this->requestUpdatedData(CEntityFlags::ModelEntity);
|
||||
}
|
||||
|
||||
void CDbMappingComponent::ps_onVPilotCountChanged(int count, bool withFilter)
|
||||
{
|
||||
if (!m_withVPilot) { return; }
|
||||
@@ -434,7 +446,7 @@ namespace BlackGui
|
||||
);
|
||||
if (msgs.hasWarningOrErrorMessages())
|
||||
{
|
||||
// maybe log, popup?
|
||||
this->showMessages(msgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "blackmisc/simulation/aircraftmodelloader.h"
|
||||
#include "blackmisc/simulation/fscommon/vpilotrulesreader.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include "blackmisc/network/entityflags.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
@@ -102,6 +103,9 @@ namespace BlackGui
|
||||
//! Request to filter by distributor
|
||||
void filterByDistributor(const BlackMisc::Simulation::CDistributor &distributor);
|
||||
|
||||
//! Request new data
|
||||
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
|
||||
|
||||
public slots:
|
||||
//! Validate, empty list means OK
|
||||
BlackMisc::CStatusMessageList validateCurrentModel(bool withNestedForms) const;
|
||||
@@ -122,12 +126,15 @@ namespace BlackGui
|
||||
//! Data for vPilot have been loaded
|
||||
void ps_onLoadVPilotDataFinished(bool success);
|
||||
|
||||
//! vPilot cached changed
|
||||
//! vPilot cached models changed
|
||||
void ps_onVPilotCacheChanged();
|
||||
|
||||
//! Stashed models changed
|
||||
void ps_onStashedModelsChanged();
|
||||
|
||||
//! Models have been published successfully
|
||||
void ps_onModelsSuccessfullyPublished(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
|
||||
//! Stash drop request
|
||||
void ps_handleStashDropRequest(const BlackMisc::Aviation::CAirlineIcaoCode &code) const;
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@
|
||||
#include "dbmodelcomponent.h"
|
||||
#include "dbmappingcomponent.h"
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackmisc/simulation/aircraftmodel.h"
|
||||
#include "ui_dbmodelcomponent.h"
|
||||
#include <functional>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackGui::Views;
|
||||
using namespace BlackGui::Models;
|
||||
|
||||
@@ -57,6 +59,17 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CDbModelComponent::requestUpdatedData()
|
||||
{
|
||||
QDateTime ts;
|
||||
if (!this->ui->tvp_AircraftModel->isEmpty())
|
||||
{
|
||||
CAircraftModel model(this->ui->tvp_AircraftModel->container().latestObject());
|
||||
ts = model.getUtcTimestamp();
|
||||
}
|
||||
this->triggerRead(CEntityFlags::ModelEntity, ts);
|
||||
}
|
||||
|
||||
void CDbModelComponent::ps_modelsRead(CEntityFlags::Entity entity, CEntityFlags::ReadState readState, int count)
|
||||
{
|
||||
Q_UNUSED(count);
|
||||
@@ -64,15 +77,15 @@ namespace BlackGui
|
||||
{
|
||||
if (readState == CEntityFlags::ReadFinished || readState == CEntityFlags::ReadFinishedRestricted)
|
||||
{
|
||||
this->ui->tvp_AircraftModel->updateContainer(this->getModels());
|
||||
this->ui->tvp_AircraftModel->updateContainerMaybeAsync(this->getModels());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CDbModelComponent::ps_reload()
|
||||
{
|
||||
if (!hasProvider()) { return; }
|
||||
triggerRead(CEntityFlags::ModelEntity);
|
||||
if (!this->hasProvider()) { return; }
|
||||
this->triggerRead(CEntityFlags::ModelEntity, QDateTime());
|
||||
}
|
||||
|
||||
void CDbModelComponent::ps_onStyleSheetChanged()
|
||||
|
||||
@@ -48,6 +48,13 @@ namespace BlackGui
|
||||
//! Set the provider
|
||||
virtual void setProvider(BlackMisc::Network::IWebDataServicesProvider *webDataReaderProvider) override;
|
||||
|
||||
//! Get latest model if any
|
||||
BlackMisc::Simulation::CAircraftModel getLatestModel() const;
|
||||
|
||||
public slots:
|
||||
//! Load new data
|
||||
void requestUpdatedData();
|
||||
|
||||
private slots:
|
||||
//! Models have been read
|
||||
void ps_modelsRead(BlackMisc::Network::CEntityFlags::Entity entity, BlackMisc::Network::CEntityFlags::ReadState readState, int count);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "ui_dbstashcomponent.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation;
|
||||
@@ -48,7 +47,7 @@ namespace BlackGui
|
||||
connect(this->ui->pb_Livery, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverPartsToSelected);
|
||||
connect(this->ui->pb_Distributor, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverPartsToSelected);
|
||||
|
||||
ui->tvp_StashAircraftModels->setCustomMenu(new CStashModelsMenu(this, true));
|
||||
ui->tvp_StashAircraftModels->menuAddItems(CAircraftModelView::MenuRemoveSelectedRows);
|
||||
this->enableButtonRow();
|
||||
}
|
||||
|
||||
@@ -93,10 +92,6 @@ namespace BlackGui
|
||||
this->ui->tvp_StashAircraftModels->insert(model);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this->showMessage(m);
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -112,6 +107,18 @@ namespace BlackGui
|
||||
return msgs;
|
||||
}
|
||||
|
||||
int CDbStashComponent::unstashModels(QList<int> keys)
|
||||
{
|
||||
if (keys.isEmpty()) { return 0; }
|
||||
return this->ui->tvp_StashAircraftModels->removeDbKeys(keys);
|
||||
}
|
||||
|
||||
int CDbStashComponent::unstashModels(QStringList modelStrings)
|
||||
{
|
||||
if (modelStrings.isEmpty()) { return 0; }
|
||||
return this->ui->tvp_StashAircraftModels->removeModelsWithModelString(modelStrings);
|
||||
}
|
||||
|
||||
const Views::CAircraftModelView *CDbStashComponent::getView() const
|
||||
{
|
||||
return ui->tvp_StashAircraftModels;
|
||||
@@ -208,9 +215,26 @@ namespace BlackGui
|
||||
|
||||
void CDbStashComponent::ps_publishResponse(const CAircraftModelList &publishedModels, const CAircraftModelList &skippedModels, const CStatusMessageList &msgs)
|
||||
{
|
||||
if (!publishedModels.isEmpty())
|
||||
{
|
||||
emit this->modelsSuccessfullyPublished(publishedModels);
|
||||
}
|
||||
|
||||
if (!msgs.isEmpty())
|
||||
{
|
||||
this->showMessages(msgs);
|
||||
if (publishedModels.isEmpty())
|
||||
{
|
||||
this->showMessages(msgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString confirm("Remove %1 published models?");
|
||||
auto lambda = [this, publishedModels]()
|
||||
{
|
||||
this->unstashModels(publishedModels.getModelStrings(false));
|
||||
};
|
||||
this->showMessagesWithConfirmation(msgs, confirm.arg(publishedModels.size()), lambda, QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
|
||||
Q_UNUSED(publishedModels);
|
||||
@@ -319,6 +343,16 @@ namespace BlackGui
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDbStashComponent::showMessagesWithConfirmation(const CStatusMessageList &msgs, const QString &confirmation, std::function<void ()> okLambda, int defaultButton, bool onlyErrors, int timeoutMs)
|
||||
{
|
||||
if (msgs.isEmpty()) { return false; }
|
||||
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
||||
BLACK_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||
if (!this->getMappingComponent()) { return false; }
|
||||
this->getMappingComponent()->showMessagesWithConfirmation(msgs, confirmation, okLambda, defaultButton, timeoutMs);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDbStashComponent::showMessage(const CStatusMessage &msg, int timeoutMs)
|
||||
{
|
||||
if (msg.isEmpty()) { return false; }
|
||||
@@ -327,11 +361,5 @@ namespace BlackGui
|
||||
this->getMappingComponent()->showMessage(msg, timeoutMs);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDbStashComponent::CStashModelsMenu::customMenu(QMenu &menu) const
|
||||
{
|
||||
menu.addAction(CIcons::database16(), "Unstash", this->parent(), SLOT(ps_onUnstashPressed()));
|
||||
nestedCustomMenu(menu);
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||
#include "blackgui/menudelegate.h"
|
||||
#include "blackgui/views/aircraftmodelview.h"
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackmisc/network/webdataservicesprovider.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
@@ -60,6 +61,12 @@ namespace BlackGui
|
||||
//! Stash given models
|
||||
BlackMisc::CStatusMessageList stashModels(const BlackMisc::Simulation::CAircraftModelList &models);
|
||||
|
||||
//! Unstash given models with keys
|
||||
int unstashModels(QList<int> keys);
|
||||
|
||||
//! Unstash given models by model string
|
||||
int unstashModels(QStringList modelStrings);
|
||||
|
||||
//! The embedded view
|
||||
const BlackGui::Views::CAircraftModelView *getView() const;
|
||||
|
||||
@@ -94,6 +101,9 @@ namespace BlackGui
|
||||
//! Stashed models have been changed
|
||||
void stashedModelsChanged();
|
||||
|
||||
//! Models succesfully published
|
||||
void modelsSuccessfullyPublished(const BlackMisc::Simulation::CAircraftModelList &publishedModels);
|
||||
|
||||
private slots:
|
||||
//! Unstash pressed
|
||||
void ps_onUnstashPressed();
|
||||
@@ -121,6 +131,9 @@ namespace BlackGui
|
||||
//! Display messages
|
||||
bool showMessages(const BlackMisc::CStatusMessageList &msgs, bool onlyErrors = false, int timeoutMs = -1);
|
||||
|
||||
//! Display messages with confirmation
|
||||
bool showMessagesWithConfirmation(const BlackMisc::CStatusMessageList &msgs, const QString &confirmation, std::function<void()> okLambda, int defaultButton, bool onlyErrors = false, int timeoutMs = -1);
|
||||
|
||||
//! Display message
|
||||
bool showMessage(const BlackMisc::CStatusMessage &msg, int timeoutMs = -1);
|
||||
|
||||
@@ -138,17 +151,6 @@ namespace BlackGui
|
||||
|
||||
//! Get the selected only models or all models depending on checkbox
|
||||
BlackMisc::Simulation::CAircraftModelList getSelectedOrAllModels() const;
|
||||
|
||||
//! Custom menu for the stashed models
|
||||
class CStashModelsMenu : public BlackGui::IMenuDelegate
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
CStashModelsMenu(CDbStashComponent *parent, bool separatorAtEnd) : IMenuDelegate(parent, separatorAtEnd) {}
|
||||
|
||||
//! \copydoc IMenuDelegate::customMenu
|
||||
virtual void customMenu(QMenu &menu) const override;
|
||||
};
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ui_infobarwebreadersstatuscomponent.h"
|
||||
#include "blackcore/webreaderflags.h"
|
||||
#include "blackmisc/icons.h"
|
||||
#include "blackmisc/verify.h"
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
@@ -93,6 +94,7 @@ namespace BlackGui
|
||||
switch (readState)
|
||||
{
|
||||
case CEntityFlags::ReadFinished:
|
||||
case CEntityFlags::ReadFinishedRestricted:
|
||||
led->setOn(true, blinkTime);
|
||||
break;
|
||||
case CEntityFlags::StartRead:
|
||||
@@ -101,6 +103,9 @@ namespace BlackGui
|
||||
case CEntityFlags::ReadFailed:
|
||||
led->setTriState(2 * blinkTime);
|
||||
break;
|
||||
default:
|
||||
BLACK_VERIFY_X(false, Q_FUNC_INFO, "read state not handled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user