refs #743, adjusted mapping component

* use cross simulator dialog (auto simulator stashing)
* added/use utility functions
This commit is contained in:
Klaus Basan
2016-10-02 23:54:38 +02:00
committed by Mathew Sutcliffe
parent be94da0048
commit 501bea0960
2 changed files with 75 additions and 24 deletions

View File

@@ -9,6 +9,7 @@
#include "blackcore/webdataservices.h" #include "blackcore/webdataservices.h"
#include "blackgui/components/dbautostashingcomponent.h" #include "blackgui/components/dbautostashingcomponent.h"
#include "blackgui/components/dbautosimulatorstashingcomponent.h"
#include "blackgui/components/dbmappingcomponent.h" #include "blackgui/components/dbmappingcomponent.h"
#include "blackgui/components/dbmodelmappingmodifycomponent.h" #include "blackgui/components/dbmodelmappingmodifycomponent.h"
#include "blackgui/components/dbownmodelscomponent.h" #include "blackgui/components/dbownmodelscomponent.h"
@@ -69,6 +70,7 @@ namespace BlackGui
COverlayMessagesFrame(parent), COverlayMessagesFrame(parent),
ui(new Ui::CDbMappingComponent), ui(new Ui::CDbMappingComponent),
m_autoStashDialog(new CDbAutoStashingComponent(this)), m_autoStashDialog(new CDbAutoStashingComponent(this)),
m_autoSimulatorDialog(new CDbAutoSimulatorStashingComponent(this)),
m_modelModifyDialog(new CDbModelMappingModifyComponent(this)) m_modelModifyDialog(new CDbModelMappingModifyComponent(this))
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -173,8 +175,7 @@ namespace BlackGui
{ {
// create / restore tab // create / restore tab
ui->tw_ModelsToBeMapped->addTab(ui->tab_VPilot, tabName); ui->tw_ModelsToBeMapped->addTab(ui->tab_VPilot, tabName);
this->ps_onVPilotDataChanged( this->ps_onVPilotDataChanged(ui->tvp_AircraftModelsForVPilot->rowCount(),
ui->tvp_AircraftModelsForVPilot->rowCount(),
ui->tvp_AircraftModelsForVPilot->hasFilter()); ui->tvp_AircraftModelsForVPilot->hasFilter());
} }
else else
@@ -385,6 +386,11 @@ namespace BlackGui
this->m_autoStashDialog->exec(); this->m_autoStashDialog->exec();
} }
void CDbMappingComponent::ps_displayAutoSimulatorStashingDialog()
{
this->m_autoSimulatorDialog->exec();
}
void CDbMappingComponent::ps_removeDbModelsFromView() void CDbMappingComponent::ps_removeDbModelsFromView()
{ {
const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings()); const QStringList modelStrings(sGui->getWebDataServices()->getModelStrings());
@@ -556,19 +562,24 @@ namespace BlackGui
void CDbMappingComponent::ps_onStashedModelsChangedDigest() void CDbMappingComponent::ps_onStashedModelsChangedDigest()
{ {
const bool hlvp = ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModelStrings(); const bool highlightVPilot = ui->tvp_AircraftModelsForVPilot->derivedModel()->highlightModelStrings();
const bool hlom = ui->comp_OwnAircraftModels->view()->derivedModel()->highlightModelStrings(); const bool highlightOwnModels = ui->comp_OwnAircraftModels->view()->derivedModel()->highlightModelStrings();
const bool highlight = hlom || hlvp; const bool highlightModelSet = ui->comp_OwnModelSet->view()->derivedModel()->highlightModelStrings();
const bool highlight = highlightOwnModels || highlightModelSet || highlightVPilot;
if (!highlight) { return; } if (!highlight) { return; }
const QStringList stashedModels(ui->comp_StashAircraft->getStashedModelStrings()); const QStringList stashedModels(ui->comp_StashAircraft->getStashedModelStrings());
if (hlvp) if (highlightVPilot)
{ {
ui->tvp_AircraftModelsForVPilot->derivedModel()->setHighlightModelStrings(stashedModels); ui->tvp_AircraftModelsForVPilot->derivedModel()->setHighlightModelStrings(stashedModels);
} }
if (hlom) if (highlightOwnModels)
{ {
ui->comp_OwnAircraftModels->view()->derivedModel()->setHighlightModelStrings(stashedModels); ui->comp_OwnAircraftModels->view()->derivedModel()->setHighlightModelStrings(stashedModels);
} }
if (highlightModelSet)
{
ui->comp_OwnModelSet->view()->derivedModel()->setHighlightModelStrings(stashedModels);
}
} }
void CDbMappingComponent::ps_tabIndexChanged(int index) void CDbMappingComponent::ps_tabIndexChanged(int index)
@@ -577,21 +588,29 @@ namespace BlackGui
switch (ti) switch (ti)
{ {
case CDbMappingComponent::TabOwnModelSet: case CDbMappingComponent::TabOwnModelSet:
{
ui->frp_Editors->setVisible(true); ui->frp_Editors->setVisible(true);
ui->editor_Model->setVisible(true); ui->editor_Model->setVisible(true);
this->resizeForSelect(); this->resizeForSelect();
}
break; break;
case CDbMappingComponent::TabModelMatcher: case CDbMappingComponent::TabModelMatcher:
{
ui->editor_Model->setVisible(false); ui->editor_Model->setVisible(false);
ui->frp_Editors->setVisible(false); ui->frp_Editors->setVisible(false);
this->resizeForSelect(); this->resizeForSelect();
}
break; break;
case CDbMappingComponent::TabVPilot: case CDbMappingComponent::TabVPilot:
{
// fall thru intended // fall thru intended
this->formatVPilotView(); this->formatVPilotView();
}
default: default:
{
ui->frp_Editors->setVisible(true); ui->frp_Editors->setVisible(true);
ui->editor_Model->setVisible(true); ui->editor_Model->setVisible(true);
}
break; break;
} }
emit this->tabIndexChanged(index); emit this->tabIndexChanged(index);
@@ -610,7 +629,7 @@ namespace BlackGui
Q_UNUSED(withFilter); Q_UNUSED(withFilter);
const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot); const int i = ui->tw_ModelsToBeMapped->indexOf(ui->tab_VPilot);
QString o = ui->tw_ModelsToBeMapped->tabText(i); QString o = ui->tw_ModelsToBeMapped->tabText(i);
QString f = ui->tvp_AircraftModelsForVPilot->hasFilter() ? "F" : ""; const QString f = ui->tvp_AircraftModelsForVPilot->hasFilter() ? "F" : "";
o = CGuiUtility::replaceTabCountValue(o, ui->tvp_AircraftModelsForVPilot->rowCount()) + f; o = CGuiUtility::replaceTabCountValue(o, ui->tvp_AircraftModelsForVPilot->rowCount()) + f;
ui->tw_ModelsToBeMapped->setTabText(i, o); ui->tw_ModelsToBeMapped->setTabText(i, o);
} }
@@ -658,7 +677,7 @@ namespace BlackGui
if (!ui->comp_OwnAircraftModels->view()->hasSelection()) { return; } if (!ui->comp_OwnAircraftModels->view()->hasSelection()) { return; }
const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator()); const CSimulatorInfo sim(ui->comp_OwnAircraftModels->getOwnModelsSimulator());
if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator()) { return; } if (!sim.isSingleSimulator() || !sim.isMicrosoftOrPrepare3DSimulator()) { return; }
CAircraftModelList ownModels(getOwnSelectedModels()); // subset CAircraftModelList ownModels(this->getOwnSelectedModels()); // subset
if (ownModels.isEmpty()) { return; } if (ownModels.isEmpty()) { return; }
ui->comp_OwnAircraftModels->view()->showLoadIndicator(); ui->comp_OwnAircraftModels->view()->showLoadIndicator();
CAircraftModelUtilities::mergeWithVPilotData(ownModels, this->m_vPilotReader.getAsModelsFromCache(), true); CAircraftModelUtilities::mergeWithVPilotData(ownModels, this->m_vPilotReader.getAsModelsFromCache(), true);
@@ -786,6 +805,11 @@ namespace BlackGui
return ui->comp_OwnAircraftModels->getOwnModels(); return ui->comp_OwnAircraftModels->getOwnModels();
} }
CAircraftModelList CDbMappingComponent::getOwnCachedModels(const CSimulatorInfo &simulator) const
{
return ui->comp_OwnAircraftModels->getOwnCachedModels(simulator);
}
CAircraftModelList CDbMappingComponent::getOwnSelectedModels() const CAircraftModelList CDbMappingComponent::getOwnSelectedModels() const
{ {
return ui->comp_OwnAircraftModels->getOwnSelectedModels(); return ui->comp_OwnAircraftModels->getOwnSelectedModels();
@@ -811,6 +835,16 @@ namespace BlackGui
return ui->comp_OwnAircraftModels->getOwnModelsCount(); return ui->comp_OwnAircraftModels->getOwnModelsCount();
} }
QString CDbMappingComponent::getOwnModelsInfoString() const
{
return ui->comp_OwnAircraftModels->getInfoString();
}
QString CDbMappingComponent::getOwnModelsInfoStringFsFamily() const
{
return ui->comp_OwnAircraftModels->getInfoStringFsFamily();
}
void CDbMappingComponent::setOwnModelSetSimulator(const CSimulatorInfo &simulator) void CDbMappingComponent::setOwnModelSetSimulator(const CSimulatorInfo &simulator)
{ {
Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator"); Q_ASSERT_X(simulator.isSingleSimulator(), Q_FUNC_INFO, "Need single simulator");
@@ -883,10 +917,11 @@ namespace BlackGui
this->m_stashFiltering->setChecked(mapComp->m_autoFilterInDbViews); this->m_stashFiltering->setChecked(mapComp->m_autoFilterInDbViews);
// Currently disabled as the same effect can be realized by filtering than // Currently disabled as the same effect can be realized by filtering than
//! \todo remove if not needed in the long term (added 2016-Sep)
// this->addRemoveDbModels(menuActions); // this->addRemoveDbModels(menuActions);
//! \todo remove if not needed in the long term (added 2016-Sep)
this->m_autoStashing = menuActions.addAction(this->m_autoStashing, CIcons::appDbStash16(), "Auto stashing", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog }); this->m_autoStashing = menuActions.addAction(this->m_autoStashing, CIcons::appDbStash16(), "Auto stashing", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_displayAutoStashingDialog });
this->m_autoSimulatorStashing = menuActions.addAction(this->m_autoSimulatorStashing, CIcons::appDbStash16(), "Cross simulator updating (FSX-P3D-FS9)", CMenuAction::pathStash(), this, { mapComp, &CDbMappingComponent::ps_displayAutoSimulatorStashingDialog });
if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted()) if (mapComp->m_autoStashDialog && mapComp->m_autoStashDialog->isCompleted())
{ {
menuActions.addAction(CIcons::appDbStash16(), "Last auto stash run", CMenuAction::pathStash(), nullptr, { mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults }); menuActions.addAction(CIcons::appDbStash16(), "Last auto stash run", CMenuAction::pathStash(), nullptr, { mapComp->m_autoStashDialog.data(), &CDbAutoStashingComponent::showLastResults });

View File

@@ -58,6 +58,7 @@ namespace BlackGui
namespace Components namespace Components
{ {
class CDbAutoStashingComponent; class CDbAutoStashingComponent;
class CDbAutoSimulatorStashingComponent;
class CDbModelMappingModifyComponent; class CDbModelMappingModifyComponent;
/*! /*!
@@ -132,6 +133,9 @@ namespace BlackGui
//! Own models //! Own models
BlackMisc::Simulation::CAircraftModelList getOwnModels() const; BlackMisc::Simulation::CAircraftModelList getOwnModels() const;
//! Own cached models
BlackMisc::Simulation::CAircraftModelList getOwnCachedModels(const BlackMisc::Simulation::CSimulatorInfo &simulator) const;
//! Own selected models //! Own selected models
BlackMisc::Simulation::CAircraftModelList getOwnSelectedModels() const; BlackMisc::Simulation::CAircraftModelList getOwnSelectedModels() const;
@@ -146,6 +150,12 @@ namespace BlackGui
//! Number of own models //! Number of own models
int getOwnModelsCount() const; int getOwnModelsCount() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoString
QString getOwnModelsInfoString() const;
//! \copydoc BlackMisc::Simulation::Data::CModelCaches::getInfoStringFsFamily
QString getOwnModelsInfoStringFsFamily() const;
//! @} //! @}
// ---------------- own model set ----------------- // ---------------- own model set -----------------
@@ -261,6 +271,9 @@ namespace BlackGui
//! Display auto stashing dialog //! Display auto stashing dialog
void ps_displayAutoStashingDialog(); void ps_displayAutoStashingDialog();
//! Display auto simulator stashing dialog
void ps_displayAutoSimulatorStashingDialog();
//! Remove DB models from current view //! Remove DB models from current view
void ps_removeDbModelsFromView(); void ps_removeDbModelsFromView();
@@ -291,6 +304,7 @@ namespace BlackGui
private: private:
QScopedPointer<Ui::CDbMappingComponent> ui; QScopedPointer<Ui::CDbMappingComponent> ui;
QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing QScopedPointer<CDbAutoStashingComponent> m_autoStashDialog; //!< dialog auto stashing
QScopedPointer<CDbAutoSimulatorStashingComponent> m_autoSimulatorDialog; //!< dialog auto simulator update
QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog; //!< dialog when modifying models QScopedPointer<CDbModelMappingModifyComponent> m_modelModifyDialog; //!< dialog when modifying models
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
BlackMisc::CData<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this }; BlackMisc::CData<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this };
@@ -342,6 +356,7 @@ namespace BlackGui
//! Menu for tools: //! Menu for tools:
//! -# removing DB models from current view and //! -# removing DB models from current view and
//! -# for auto stashing //! -# for auto stashing
//! -# automatically updating simulators (FSX, FS9, P3D family)
//! -# toggle auto filtering //! -# toggle auto filtering
//! \note This is a specific menu for that very component //! \note This is a specific menu for that very component
class CModelStashToolsMenu : public BlackGui::Menus::IMenuDelegate class CModelStashToolsMenu : public BlackGui::Menus::IMenuDelegate
@@ -361,6 +376,7 @@ namespace BlackGui
void addRemoveDbModels(Menus::CMenuActions &menuActions); void addRemoveDbModels(Menus::CMenuActions &menuActions);
QAction *m_autoStashing = nullptr; QAction *m_autoStashing = nullptr;
QAction *m_autoSimulatorStashing = nullptr;
QAction *m_stashFiltering = nullptr; QAction *m_stashFiltering = nullptr;
}; };