mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-13 07:35:41 +08:00
refs #577, allow to assign editor values to a bunch of models by context menu
This commit is contained in:
@@ -68,6 +68,7 @@ namespace BlackGui
|
|||||||
|
|
||||||
this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
|
this->ui->tw_ModelsToBeMapped->setTabIcon(TabStash, CIcons::appDbStash16());
|
||||||
this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
|
this->ui->tw_ModelsToBeMapped->setTabIcon(TabOwnModels, CIcons::appModels16());
|
||||||
|
this->ui->comp_StashAircraft->getView()->setCustomMenu(new CApplyDbDataMenu(this));
|
||||||
|
|
||||||
// vPilot
|
// vPilot
|
||||||
this->initVPilotLoading();
|
this->initVPilotLoading();
|
||||||
@@ -342,6 +343,55 @@ namespace BlackGui
|
|||||||
this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews;
|
this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::ps_applyDbData()
|
||||||
|
{
|
||||||
|
QAction *sender = qobject_cast<QAction *>(this->sender());
|
||||||
|
if (!sender) { return; }
|
||||||
|
QString cn(sender->data().toString());
|
||||||
|
if (cn.isEmpty()) { return; }
|
||||||
|
if (this->ui->comp_StashAircraft->getView()->selectedRowCount() < 1) { return; }
|
||||||
|
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
if (CLivery().getClassName() == cn)
|
||||||
|
{
|
||||||
|
msgs = this->ui->editor_Livery->validate(true);
|
||||||
|
if (!msgs.hasErrorMessages())
|
||||||
|
{
|
||||||
|
this->ui->comp_StashAircraft->applyToSelected(this->ui->editor_Livery->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CDistributor().getClassName() == cn)
|
||||||
|
{
|
||||||
|
msgs = this->ui->editor_Distributor->validate();
|
||||||
|
if (!msgs.hasErrorMessages())
|
||||||
|
{
|
||||||
|
this->ui->comp_StashAircraft->applyToSelected(this->ui->editor_Distributor->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CAircraftIcaoCode().getClassName() == cn)
|
||||||
|
{
|
||||||
|
msgs = this->ui->editor_AircraftIcao->validate();
|
||||||
|
if (!msgs.hasErrorMessages())
|
||||||
|
{
|
||||||
|
this->ui->comp_StashAircraft->applyToSelected(this->ui->editor_AircraftIcao->getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (CAirlineIcaoCode().getClassName() == cn)
|
||||||
|
{
|
||||||
|
msgs = this->ui->editor_Livery->validateAirlineIcao();
|
||||||
|
if (!msgs.hasErrorMessages())
|
||||||
|
{
|
||||||
|
this->ui->comp_StashAircraft->applyToSelected(this->ui->editor_Livery->getValueAirlineIcao());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// errors if any
|
||||||
|
if (msgs.hasErrorMessages())
|
||||||
|
{
|
||||||
|
this->showMessages(msgs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CDbMappingComponent::resizeForSelect()
|
void CDbMappingComponent::resizeForSelect()
|
||||||
{
|
{
|
||||||
int h = this->height();
|
int h = this->height();
|
||||||
@@ -698,7 +748,7 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// auto filter in DB views
|
// auto filter in DB views
|
||||||
QAction *a = menu.addAction(CIcons::filter16(), "Auto filtering (DB views)", mapComp, SLOT(ps_toggleAutoFiltering()));
|
QAction *a = menu.addAction(CIcons::filter16(), "Auto filtering in DB views (on/off)", mapComp, SLOT(ps_toggleAutoFiltering()));
|
||||||
a->setCheckable(true);
|
a->setCheckable(true);
|
||||||
a->setChecked(mapComp->m_autoFilterInDbViews);
|
a->setChecked(mapComp->m_autoFilterInDbViews);
|
||||||
}
|
}
|
||||||
@@ -710,5 +760,36 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
return qobject_cast<CDbMappingComponent *>(this->parent());
|
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDbMappingComponent::CApplyDbDataMenu::customMenu(QMenu &menu) const
|
||||||
|
{
|
||||||
|
CDbMappingComponent *mapComp = mappingComponent();
|
||||||
|
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
|
||||||
|
|
||||||
|
if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash && mapComp->currentModelView()->hasSelection())
|
||||||
|
{
|
||||||
|
// stash view and selection
|
||||||
|
QMenu *subMenu = menu.addMenu(CIcons::database16(), "Apply DB data (to selected)");
|
||||||
|
QAction *a = nullptr;
|
||||||
|
|
||||||
|
a = subMenu->addAction(CIcons::appAircraftIcao16(), "Current aircraft ICAO", mapComp, SLOT(ps_applyDbData()));
|
||||||
|
a->setData(CAircraftIcaoCode().getClassName());
|
||||||
|
|
||||||
|
a = subMenu->addAction(CIcons::appDistributors16(), "Current distributor", mapComp, SLOT(ps_applyDbData()));
|
||||||
|
a->setData(CDistributor().getClassName());
|
||||||
|
|
||||||
|
a = subMenu->addAction(CIcons::appLiveries16(), "Current livery", mapComp, SLOT(ps_applyDbData()));
|
||||||
|
a->setData(CLivery().getClassName());
|
||||||
|
|
||||||
|
// a = subMenu->addAction(CIcons::appAirlineIcao16(), "Current airline ICAO", mapComp, SLOT(ps_applyDbData()));
|
||||||
|
// a->setData(CAirlineIcaoCode().getClassName());
|
||||||
|
}
|
||||||
|
this->nestedCustomMenu(menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
CDbMappingComponent *CDbMappingComponent::CApplyDbDataMenu::mappingComponent() const
|
||||||
|
{
|
||||||
|
return qobject_cast<CDbMappingComponent *>(this->parent());
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ namespace BlackGui
|
|||||||
//! Request to filter by distributor
|
//! Request to filter by distributor
|
||||||
void filterByDistributor(const BlackMisc::Simulation::CDistributor &distributor);
|
void filterByDistributor(const BlackMisc::Simulation::CDistributor &distributor);
|
||||||
|
|
||||||
//! Request latest (incrementall) data from backend
|
//! Request latest (incremental) data from backend
|
||||||
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
|
void requestUpdatedData(BlackMisc::Network::CEntityFlags::Entity entities);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
@@ -199,6 +199,9 @@ namespace BlackGui
|
|||||||
//! Toggle auto filtering
|
//! Toggle auto filtering
|
||||||
void ps_toggleAutoFiltering();
|
void ps_toggleAutoFiltering();
|
||||||
|
|
||||||
|
//! Apply current DB data from form
|
||||||
|
void ps_applyDbData();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CDbMappingComponent> ui;
|
QScopedPointer<Ui::CDbMappingComponent> ui;
|
||||||
QScopedArrayPointer<CDbAutoStashingComponent> m_autostashDialog { new CDbAutoStashingComponent(this) };
|
QScopedArrayPointer<CDbAutoStashingComponent> m_autostashDialog { new CDbAutoStashingComponent(this) };
|
||||||
@@ -260,6 +263,7 @@ namespace BlackGui
|
|||||||
//! Menu for tools:
|
//! Menu for tools:
|
||||||
//! 1) removing DB models from current view and
|
//! 1) removing DB models from current view and
|
||||||
//! 2) for auto stashing
|
//! 2) for auto stashing
|
||||||
|
//! 3) toggle auto filtering
|
||||||
//! \note This is a specific menu for that very component
|
//! \note This is a specific menu for that very component
|
||||||
class CModelStashTools : public BlackGui::IMenuDelegate
|
class CModelStashTools : public BlackGui::IMenuDelegate
|
||||||
{
|
{
|
||||||
@@ -276,6 +280,23 @@ namespace BlackGui
|
|||||||
//! Mapping component
|
//! Mapping component
|
||||||
CDbMappingComponent *mappingComponent() const;
|
CDbMappingComponent *mappingComponent() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//! Apply DB data to selected models
|
||||||
|
class CApplyDbDataMenu : public BlackGui::IMenuDelegate
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
CApplyDbDataMenu(CDbMappingComponent *mappingComponent, bool separator = true) :
|
||||||
|
BlackGui::IMenuDelegate(mappingComponent, separator)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//! \copydoc IMenuDelegate::customMenu
|
||||||
|
virtual void customMenu(QMenu &menu) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Mapping component
|
||||||
|
CDbMappingComponent *mappingComponent() const;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -59,6 +59,11 @@ namespace BlackGui
|
|||||||
return livery;
|
return livery;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAirlineIcaoCode CLiveryForm::getValueAirlineIcao() const
|
||||||
|
{
|
||||||
|
return this->ui->editor_AirlineIcao->getValue();
|
||||||
|
}
|
||||||
|
|
||||||
void CLiveryForm::setValue(const CLivery &livery)
|
void CLiveryForm::setValue(const CLivery &livery)
|
||||||
{
|
{
|
||||||
this->ui->livery_Selector->setLivery(livery);
|
this->ui->livery_Selector->setLivery(livery);
|
||||||
@@ -88,6 +93,11 @@ namespace BlackGui
|
|||||||
return msgs;
|
return msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CStatusMessageList CLiveryForm::validateAirlineIcao() const
|
||||||
|
{
|
||||||
|
return this->ui->editor_AirlineIcao->validate();
|
||||||
|
}
|
||||||
|
|
||||||
void CLiveryForm::allowDrop(bool allowDrop)
|
void CLiveryForm::allowDrop(bool allowDrop)
|
||||||
{
|
{
|
||||||
this->ui->drop_DropData->allowDrop(allowDrop);
|
this->ui->drop_DropData->allowDrop(allowDrop);
|
||||||
|
|||||||
@@ -45,9 +45,15 @@ namespace BlackGui
|
|||||||
//! Value
|
//! Value
|
||||||
BlackMisc::Aviation::CLivery getValue() const;
|
BlackMisc::Aviation::CLivery getValue() const;
|
||||||
|
|
||||||
|
//! Embedded ariline
|
||||||
|
BlackMisc::Aviation::CAirlineIcaoCode getValueAirlineIcao() const;
|
||||||
|
|
||||||
//! Validate, empty list means OK
|
//! Validate, empty list means OK
|
||||||
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
|
BlackMisc::CStatusMessageList validate(bool withNestedForms) const;
|
||||||
|
|
||||||
|
//! Validate airline ICAO code only
|
||||||
|
BlackMisc::CStatusMessageList validateAirlineIcao() const;
|
||||||
|
|
||||||
//! Allow to drop
|
//! Allow to drop
|
||||||
void allowDrop(bool allowDrop);
|
void allowDrop(bool allowDrop);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user