mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 19:05:31 +08:00
refs #535, stash component
* allow to drop entities * BLACK_VERIFY * using aware class
This commit is contained in:
@@ -8,8 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dbstashcomponent.h"
|
#include "dbstashcomponent.h"
|
||||||
#include "ui_dbstashcomponent.h"
|
|
||||||
#include "dbmappingcomponent.h"
|
#include "dbmappingcomponent.h"
|
||||||
|
#include "ui_dbstashcomponent.h"
|
||||||
#include "blackgui/views/aircraftmodelview.h"
|
#include "blackgui/views/aircraftmodelview.h"
|
||||||
#include "blackmisc/icons.h"
|
#include "blackmisc/icons.h"
|
||||||
#include "blackmisc/verify.h"
|
#include "blackmisc/verify.h"
|
||||||
@@ -27,14 +27,17 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
CDbStashComponent::CDbStashComponent(QWidget *parent) :
|
CDbStashComponent::CDbStashComponent(QWidget *parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
|
CDbMappingComponentAware(parent),
|
||||||
ui(new Ui::CDbStashComponent)
|
ui(new Ui::CDbStashComponent)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->ui->tvp_StashAircraftModels->setAircraftModelMode(CAircraftModelListModel::StashModel);
|
this->ui->tvp_StashAircraftModels->setAircraftModelMode(CAircraftModelListModel::StashModel);
|
||||||
|
this->ui->tvp_StashAircraftModels->allowDragDropValueObjects(false, true);
|
||||||
|
this->ui->tvp_StashAircraftModels->setImplementedMetaTypeIds();
|
||||||
|
|
||||||
connect(this->ui->pb_Unstash, &QPushButton::pressed, this, &CDbStashComponent::ps_onUnstashPressed);
|
connect(this->ui->pb_Unstash, &QPushButton::pressed, this, &CDbStashComponent::ps_onUnstashPressed);
|
||||||
connect(this->ui->pb_Validate, &QPushButton::pressed, this, &CDbStashComponent::ps_onValidatePressed);
|
connect(this->ui->pb_Validate, &QPushButton::pressed, this, &CDbStashComponent::ps_onValidatePressed);
|
||||||
connect(this->ui->tvp_StashAircraftModels, &CAircraftModelView::modelChanged, this, &CDbStashComponent::stashedModelChanged);
|
connect(this->ui->tvp_StashAircraftModels, &CAircraftModelView::modelChanged, this, &CDbStashComponent::stashedModelsChanged);
|
||||||
|
|
||||||
// copy over buttons
|
// copy over buttons
|
||||||
connect(this->ui->pb_AircraftIcao, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverValues);
|
connect(this->ui->pb_AircraftIcao, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverValues);
|
||||||
@@ -43,14 +46,6 @@ namespace BlackGui
|
|||||||
connect(this->ui->pb_Distributor, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverValues);
|
connect(this->ui->pb_Distributor, &QPushButton::pressed, this, &CDbStashComponent::ps_copyOverValues);
|
||||||
|
|
||||||
ui->tvp_StashAircraftModels->setCustomMenu(new CStashModelsMenu(this, true));
|
ui->tvp_StashAircraftModels->setCustomMenu(new CStashModelsMenu(this, true));
|
||||||
|
|
||||||
|
|
||||||
// set mapping component reference if it is parent
|
|
||||||
CDbMappingComponent *mapping = qobject_cast<CDbMappingComponent *>(parent);
|
|
||||||
if (mapping)
|
|
||||||
{
|
|
||||||
m_mappingComponent = mapping;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CDbStashComponent::~CDbStashComponent()
|
CDbStashComponent::~CDbStashComponent()
|
||||||
@@ -114,6 +109,11 @@ namespace BlackGui
|
|||||||
return this->ui->tvp_StashAircraftModels->derivedModel()->getModelStrings(false);
|
return this->ui->tvp_StashAircraftModels->derivedModel()->getModelStrings(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const CAircraftModelList &CDbStashComponent::getStashedModels() const
|
||||||
|
{
|
||||||
|
return this->ui->tvp_StashAircraftModels->derivedModel()->container();
|
||||||
|
}
|
||||||
|
|
||||||
void CDbStashComponent::applyToSelected(const CLivery &livery, bool acceptWarnings)
|
void CDbStashComponent::applyToSelected(const CLivery &livery, bool acceptWarnings)
|
||||||
{
|
{
|
||||||
if (!this->ui->tvp_StashAircraftModels->hasSelection()) { return; }
|
if (!this->ui->tvp_StashAircraftModels->hasSelection()) { return; }
|
||||||
@@ -172,11 +172,11 @@ namespace BlackGui
|
|||||||
void CDbStashComponent::ps_copyOverValues()
|
void CDbStashComponent::ps_copyOverValues()
|
||||||
{
|
{
|
||||||
QObject *sender = QObject::sender();
|
QObject *sender = QObject::sender();
|
||||||
BLACK_VERIFY_X(this->m_mappingComponent, Q_FUNC_INFO, "missing mapping component");
|
BLACK_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||||
if (!this->m_mappingComponent) { return; }
|
if (!this->getMappingComponent()) { return; }
|
||||||
if (!this->ui->tvp_StashAircraftModels->hasSelection()) { return; }
|
if (!this->ui->tvp_StashAircraftModels->hasSelection()) { return; }
|
||||||
|
|
||||||
CAircraftModel model(this->m_mappingComponent->getAircraftModel());
|
CAircraftModel model(this->getMappingComponent()->getAircraftModel());
|
||||||
if (sender == this->ui->pb_AircraftIcao)
|
if (sender == this->ui->pb_AircraftIcao)
|
||||||
{
|
{
|
||||||
this->applyToSelected(model.getAircraftIcaoCode());
|
this->applyToSelected(model.getAircraftIcaoCode());
|
||||||
@@ -199,18 +199,18 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
if (msgs.isEmpty()) { return false; }
|
if (msgs.isEmpty()) { return false; }
|
||||||
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
if (!msgs.hasErrorMessages() && onlyErrors) { return false; }
|
||||||
BLACK_VERIFY_X(this->m_mappingComponent, Q_FUNC_INFO, "missing mapping component");
|
BLACK_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||||
if (!this->m_mappingComponent) { return false; }
|
if (!this->getMappingComponent()) { return false; }
|
||||||
this->m_mappingComponent->showMessages(msgs);
|
this->getMappingComponent()->showMessages(msgs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDbStashComponent::showMessage(const CStatusMessage &msg)
|
bool CDbStashComponent::showMessage(const CStatusMessage &msg)
|
||||||
{
|
{
|
||||||
if (msg.isEmpty()) { return false; }
|
if (msg.isEmpty()) { return false; }
|
||||||
BLACK_VERIFY_X(this->m_mappingComponent, Q_FUNC_INFO, "missing mapping component");
|
BLACK_VERIFY_X(this->getMappingComponent(), Q_FUNC_INFO, "missing mapping component");
|
||||||
if (!this->m_mappingComponent) { return false; }
|
if (!this->getMappingComponent()) { return false; }
|
||||||
this->m_mappingComponent->showMessage(msg);
|
this->getMappingComponent()->showMessage(msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#define BLACKGUI_COMPONENTS_DBSTASHCOMPONENT_H
|
#define BLACKGUI_COMPONENTS_DBSTASHCOMPONENT_H
|
||||||
|
|
||||||
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
#include "blackgui/components/enablefordockwidgetinfoarea.h"
|
||||||
|
#include "blackgui/components/dbmappingcomponentaware.h"
|
||||||
#include "blackgui/menudelegate.h"
|
#include "blackgui/menudelegate.h"
|
||||||
#include "blackgui/views/aircraftmodelview.h"
|
#include "blackgui/views/aircraftmodelview.h"
|
||||||
#include "blackmisc/network/webdataservicesprovider.h"
|
#include "blackmisc/network/webdataservicesprovider.h"
|
||||||
@@ -26,13 +27,12 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
class CDbMappingComponent;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Stashed objects
|
* Stashed objects
|
||||||
*/
|
*/
|
||||||
class BLACKGUI_EXPORT CDbStashComponent :
|
class BLACKGUI_EXPORT CDbStashComponent :
|
||||||
public QFrame,
|
public QFrame,
|
||||||
|
public CDbMappingComponentAware,
|
||||||
public CEnableForDockWidgetInfoArea,
|
public CEnableForDockWidgetInfoArea,
|
||||||
public BlackMisc::Network::CWebDataServicesAware
|
public BlackMisc::Network::CWebDataServicesAware
|
||||||
{
|
{
|
||||||
@@ -63,15 +63,15 @@ namespace BlackGui
|
|||||||
//! The embedded view
|
//! The embedded view
|
||||||
const BlackGui::Views::CAircraftModelView *getView() const;
|
const BlackGui::Views::CAircraftModelView *getView() const;
|
||||||
|
|
||||||
//! Corresponding mapping component
|
|
||||||
void setMappingComponent(CDbMappingComponent *mappingComponent) { m_mappingComponent = mappingComponent; }
|
|
||||||
|
|
||||||
//! Has stashed models
|
//! Has stashed models
|
||||||
bool hasStashedModels() const;
|
bool hasStashedModels() const;
|
||||||
|
|
||||||
//! Stashed model strings
|
//! Stashed model strings
|
||||||
QStringList getStashedModelStrings() const;
|
QStringList getStashedModelStrings() const;
|
||||||
|
|
||||||
|
//! The stashed models
|
||||||
|
const BlackMisc::Simulation::CAircraftModelList &getStashedModels() const;
|
||||||
|
|
||||||
//! Apply object to select objects
|
//! Apply object to select objects
|
||||||
void applyToSelected(const BlackMisc::Aviation::CLivery &livery, bool acceptWarnings = true);
|
void applyToSelected(const BlackMisc::Aviation::CLivery &livery, bool acceptWarnings = true);
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ namespace BlackGui
|
|||||||
void unstashed(BlackMisc::Simulation::CAircraftModel &model);
|
void unstashed(BlackMisc::Simulation::CAircraftModel &model);
|
||||||
|
|
||||||
//! Stashed models have been changed
|
//! Stashed models have been changed
|
||||||
void stashedModelChanged();
|
void stashedModelsChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//! Unstash pressed
|
//! Unstash pressed
|
||||||
@@ -103,7 +103,6 @@ namespace BlackGui
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbStashComponent> ui;
|
QScopedPointer<Ui::CDbStashComponent> ui;
|
||||||
CDbMappingComponent *m_mappingComponent = nullptr; //!< corresponding mapping component
|
|
||||||
|
|
||||||
//! Display messages
|
//! Display messages
|
||||||
bool showMessages(const BlackMisc::CStatusMessageList &msgs, bool onlyErrors = false);
|
bool showMessages(const BlackMisc::CStatusMessageList &msgs, bool onlyErrors = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user