Ref T117, check equal models before publishing

* checkbox, check can be disabled
* context menu to display changed attributes in popup
This commit is contained in:
Klaus Basan
2017-08-10 11:50:48 +02:00
committed by Mathew Sutcliffe
parent 5a67276fbb
commit 991cc3463d
5 changed files with 197 additions and 109 deletions

View File

@@ -85,15 +85,15 @@ namespace BlackGui
ui->comp_OwnAircraftModels->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_OwnAircraftModels->view(), this, true)); ui->comp_OwnAircraftModels->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_OwnAircraftModels->view(), this, true));
ui->comp_OwnAircraftModels->view()->setCustomMenu(new CMergeWithVPilotMenu(this)); ui->comp_OwnAircraftModels->view()->setCustomMenu(new CMergeWithVPilotMenu(this));
ui->comp_OwnAircraftModels->view()->setCustomMenu(new COwnModelSetMenu(this, true)); ui->comp_OwnAircraftModels->view()->setCustomMenu(new COwnModelSetMenu(this, true));
ui->comp_OwnAircraftModels->view()->setCustomMenu(new CModelStashToolsMenu(this, false)); ui->comp_OwnAircraftModels->view()->setCustomMenu(new CStashToolsMenu(this, false));
ui->comp_OwnModelSet->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_OwnModelSet->view(), this, true)); ui->comp_OwnModelSet->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_OwnModelSet->view(), this, true));
ui->comp_OwnModelSet->view()->setCustomMenu(new CModelStashToolsMenu(this, true)); ui->comp_OwnModelSet->view()->setCustomMenu(new CStashToolsMenu(this, true));
ui->comp_StashAircraft->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_StashAircraft->view(), this, true)); ui->comp_StashAircraft->view()->setCustomMenu(new CShowSimulatorFileMenu(ui->comp_StashAircraft->view(), this, true));
ui->comp_StashAircraft->view()->setCustomMenu(new CApplyDbDataMenu(this, true)); ui->comp_StashAircraft->view()->setCustomMenu(new CApplyDbDataMenu(this, true));
ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this, true)); ui->comp_StashAircraft->view()->setCustomMenu(new COwnModelSetMenu(this, true));
ui->comp_StashAircraft->view()->setCustomMenu(new CModelStashToolsMenu(this, false)); ui->comp_StashAircraft->view()->setCustomMenu(new CStashToolsMenu(this, false));
// connects // connects
connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::ps_stashCurrentModel); connect(ui->editor_ModelMapping, &CModelMappingForm::requestStash, this, &CDbMappingComponent::ps_stashCurrentModel);
@@ -161,7 +161,7 @@ namespace BlackGui
connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestUpdate, this, &CDbMappingComponent::ps_requestVPilotDataUpdate); connect(ui->tvp_AircraftModelsForVPilot, &CAircraftModelView::requestUpdate, this, &CDbMappingComponent::ps_requestVPilotDataUpdate);
ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true)); ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CMappingVPilotMenu(this, true));
ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CModelStashToolsMenu(this, false)); ui->tvp_AircraftModelsForVPilot->setCustomMenu(new CStashToolsMenu(this, false));
ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true); ui->tvp_AircraftModelsForVPilot->setDisplayAutomatically(true);
ui->tvp_AircraftModelsForVPilot->addFilterDialog(); ui->tvp_AircraftModelsForVPilot->addFilterDialog();
@@ -328,6 +328,11 @@ namespace BlackGui
return ui->comp_StashAircraft->getStashedModels(); return ui->comp_StashAircraft->getStashedModels();
} }
bool CDbMappingComponent::hasStashedModels() const
{
return !this->getStashedModels().isEmpty();
}
QStringList CDbMappingComponent::getStashedModelStrings() const QStringList CDbMappingComponent::getStashedModelStrings() const
{ {
return ui->comp_StashAircraft->getStashedModelStrings(); return ui->comp_StashAircraft->getStashedModelStrings();
@@ -422,6 +427,13 @@ namespace BlackGui
} }
} }
void CDbMappingComponent::ps_showChangedAttributes()
{
if (!this->hasStashedModels()) { return; }
if (this->currentTabIndex() != TabStash) { return; }
ui->comp_StashAircraft->showChangedAttributes();
}
void CDbMappingComponent::ps_toggleAutoFiltering() void CDbMappingComponent::ps_toggleAutoFiltering()
{ {
this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews; this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews;
@@ -912,11 +924,11 @@ namespace BlackGui
return qobject_cast<CDbMappingComponent *>(this->parent()); return qobject_cast<CDbMappingComponent *>(this->parent());
} }
CDbMappingComponent::CModelStashToolsMenu::CModelStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator) : CDbMappingComponent::CStashToolsMenu::CStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator) :
BlackGui::Menus::IMenuDelegate(mappingComponent, separator) BlackGui::Menus::IMenuDelegate(mappingComponent, separator)
{} {}
void CDbMappingComponent::CModelStashToolsMenu::customMenu(CMenuActions &menuActions) void CDbMappingComponent::CStashToolsMenu::customMenu(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = mappingComponent(); CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
@@ -929,10 +941,6 @@ namespace BlackGui
this->m_stashFiltering->setCheckable(true); this->m_stashFiltering->setCheckable(true);
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
// this->addRemoveDbModels(menuActions);
// 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 }); 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())
@@ -942,26 +950,31 @@ namespace BlackGui
} }
else if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash) else if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash)
{ {
this->addRemoveDbModels(menuActions); this->addStashViewSpecificMenus(menuActions);
} }
this->nestedCustomMenu(menuActions); this->nestedCustomMenu(menuActions);
} }
void CDbMappingComponent::CModelStashToolsMenu::addRemoveDbModels(CMenuActions &menuActions) void CDbMappingComponent::CStashToolsMenu::addStashViewSpecificMenus(CMenuActions &menuActions)
{ {
CDbMappingComponent *mapComp = mappingComponent(); CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component"); Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
const int dbModels = sGui->getWebDataServices()->getModelsCount(); const int dbModels = sGui->getWebDataServices()->getModelsCount();
if (dbModels > 0) if (dbModels > 0 && mapComp->hasStashedModels())
{ {
menuActions.addMenu(CIcons::appDbStash16(), "Stash", CMenuAction::pathStash());
// we have keys and data by which we could delete them from view // we have keys and data by which we could delete them from view
const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from '" + mapComp->currentTabText() + "'"); const QString msgDelete("Delete " + QString::number(dbModels) + " DB model(s) from '" + mapComp->currentTabText() + "'");
menuActions.addAction(CIcons::delete16(), msgDelete, CMenuAction::pathStash(), nullptr, { mapComp, &CDbMappingComponent::ps_removeDbModelsFromView}); menuActions.addAction(CIcons::delete16(), msgDelete, CMenuAction::pathStash(), nullptr, { mapComp, &CDbMappingComponent::ps_removeDbModelsFromView});
// attribute info
menuActions.addAction(CIcons::info16(), "Show changed attributes", CMenuAction::pathStash(), nullptr, { mapComp, &CDbMappingComponent::ps_showChangedAttributes});
} }
} }
CDbMappingComponent *CDbMappingComponent::CModelStashToolsMenu::mappingComponent() const CDbMappingComponent *CDbMappingComponent::CStashToolsMenu::mappingComponent() const
{ {
return qobject_cast<CDbMappingComponent *>(this->parent()); return qobject_cast<CDbMappingComponent *>(this->parent());
} }

View File

@@ -87,7 +87,7 @@ namespace BlackGui
explicit CDbMappingComponent(QWidget *parent = nullptr); explicit CDbMappingComponent(QWidget *parent = nullptr);
//! Destructor //! Destructor
~CDbMappingComponent(); virtual ~CDbMappingComponent();
//! Graceful shutdown //! Graceful shutdown
void gracefulShutdown(); void gracefulShutdown();
@@ -124,6 +124,9 @@ namespace BlackGui
//! Stashed models //! Stashed models
const BlackMisc::Simulation::CAircraftModelList &getStashedModels() const; const BlackMisc::Simulation::CAircraftModelList &getStashedModels() const;
//! Any stashed models?
bool hasStashedModels() const;
//! Stashed model strings //! Stashed model strings
QStringList getStashedModelStrings() const; QStringList getStashedModelStrings() const;
//! @} //! @}
@@ -279,6 +282,9 @@ namespace BlackGui
//! Remove DB models from current view //! Remove DB models from current view
void ps_removeDbModelsFromView(); void ps_removeDbModelsFromView();
//! Show changed attributes of stashed
void ps_showChangedAttributes();
//! Toggle auto filtering //! Toggle auto filtering
void ps_toggleAutoFiltering(); void ps_toggleAutoFiltering();
@@ -311,10 +317,10 @@ namespace BlackGui
BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules
BlackMisc::CDigestSignal m_dsStashedModelsChanged { this, &CDbMappingComponent::ps_digestStashedModelsChanged, &CDbMappingComponent::ps_onStashedModelsChangedDigest, 750, 25 }; BlackMisc::CDigestSignal m_dsStashedModelsChanged { this, &CDbMappingComponent::ps_digestStashedModelsChanged, &CDbMappingComponent::ps_onStashedModelsChangedDigest, 750, 25 };
BlackMisc::CData<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this }; BlackMisc::CData<BlackCore::Data::TAuthenticatedDbUser> m_swiftDbUser { this };
const bool vPilotSupport = true; //!< vPilot support const bool vPilotSupport = true; //!< vPilot support (will be removed in future)
bool m_vPilot1stInit = true; //!< vPilot extensions initaliazed? bool m_vPilot1stInit = true; //!< vPilot extensions initalized?
bool m_vPilotEnabled = false; //!< use vPilot extensions bool m_vPilotEnabled = false; //!< use vPilot extensions
bool m_vPilotFormatted = false; //!< vPilot fomratted (workaround) bool m_vPilotFormatted = false; //!< vPilot formatted (workaround)
bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model
//! Init vPilot if rights and suitable //! Init vPilot if rights and suitable
@@ -355,17 +361,18 @@ namespace BlackGui
QAction *m_menuAction = nullptr; QAction *m_menuAction = nullptr;
}; };
//! Menu for tools: //! Menu for stashing related tools:
//! -# removing DB models from current view and //! -# removing DB models from stash view
//! -# for auto stashing //! -# for auto stashing
//! -# automatically updating simulators (FSX, FS9, P3D family) //! -# cross simulator updating (FSX, FS9, P3D family)
//! -# toggle auto filtering //! -# toggle stash auto filtering
//! \note This is a specific menu for that very component //! -# show changed attributes
class CModelStashToolsMenu : public BlackGui::Menus::IMenuDelegate //! \note This is a specific menu for the CDbMappingComponent component
class CStashToolsMenu : public BlackGui::Menus::IMenuDelegate
{ {
public: public:
//! Constructor //! Constructor
CModelStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator = true); CStashToolsMenu(CDbMappingComponent *mappingComponent, bool separator = true);
//! \copydoc IMenuDelegate::customMenu //! \copydoc IMenuDelegate::customMenu
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override; virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
@@ -375,7 +382,7 @@ namespace BlackGui
CDbMappingComponent *mappingComponent() const; CDbMappingComponent *mappingComponent() const;
//! Removel models existing in DB //! Removel models existing in DB
void addRemoveDbModels(Menus::CMenuActions &menuActions); void addStashViewSpecificMenus(Menus::CMenuActions &menuActions);
QAction *m_autoStashing = nullptr; QAction *m_autoStashing = nullptr;
QAction *m_autoSimulatorStashing = nullptr; QAction *m_autoSimulatorStashing = nullptr;

View File

@@ -319,7 +319,8 @@ namespace BlackGui
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "No web services"); Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "No web services");
const CAircraftModelList models(getSelectedOrAllModels()); const CAircraftModelList models(getSelectedOrAllModels());
if (models.isEmpty()) { return CStatusMessageList(); } if (models.isEmpty()) { return CStatusMessageList(); }
const CStatusMessageList msgs(sGui->getWebDataServices()->validateForPublishing(models, validModels, invalidModels)); const bool ignoreEqual = ui->cb_ChangedOnly->isChecked();
const CStatusMessageList msgs(sGui->getWebDataServices()->validateForPublishing(models, ignoreEqual, validModels, invalidModels));
// OK? // OK?
if (msgs.isEmpty()) if (msgs.isEmpty())
@@ -423,7 +424,30 @@ namespace BlackGui
return stashModel; return stashModel;
} }
void CDbStashComponent::showChangedAttributes()
{ {
if (!sGui || !sGui->hasWebDataServices()) { return; }
if (sGui->isShuttingDown()) { return; }
const CAircraftModelList models = ui->tvp_StashAircraftModels->selectedObjects();
if (models.isEmpty()) { return; }
CStatusMessageList msgs;
for (const CAircraftModel &model : models)
{
CStatusMessageList modelMsgs;
const bool equal = sGui->getWebDataServices()->isDbModelEqualForPublishing(model, &modelMsgs);
if (equal)
{
msgs.push_back(CStatusMessage(this).info("Model '%1' has no change values") << model.getModelStringAndDbKey());
}
else
{
msgs.push_back(modelMsgs);
}
}
this->showMessages(msgs);
}
void CDbStashComponent::ps_copyOverValuesToSelectedModels() void CDbStashComponent::ps_copyOverValuesToSelectedModels()
{ {
const QObject *sender = QObject::sender(); const QObject *sender = QObject::sender();

View File

@@ -118,6 +118,9 @@ namespace BlackGui
//! Consolidate with other available data //! Consolidate with other available data
BlackMisc::Simulation::CAircraftModel consolidateModel(const BlackMisc::Simulation::CAircraftModel &model) const; BlackMisc::Simulation::CAircraftModel consolidateModel(const BlackMisc::Simulation::CAircraftModel &model) const;
//! Show changed attributes of selected models
void showChangedAttributes();
public slots: public slots:
//! Stash given model (includes validation and consolidation with DB data) //! Stash given model (includes validation and consolidation with DB data)
BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false, bool consolidateWithDbData = true); BlackMisc::CStatusMessage stashModel(const BlackMisc::Simulation::CAircraftModel &model, bool replace = false, bool consolidateWithDbData = true);

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>860</width> <width>910</width>
<height>222</height> <height>222</height>
</rect> </rect>
</property> </property>
@@ -47,7 +47,7 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QHBoxLayout" name="hl_StashHandling"> <layout class="QGridLayout" name="gl_StashHandling">
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
@@ -60,94 +60,134 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <property name="horizontalSpacing">
<widget class="QPushButton" name="pb_Unstash"> <number>4</number>
<property name="text"> </property>
<string>Unstash</string> <item row="0" column="10">
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_Sep1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Validate">
<property name="text">
<string>Validate</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_RemoveInvalid">
<property name="toolTip">
<string>Remove invalid models</string>
</property>
<property name="text">
<string>Rem. invalid</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Publish">
<property name="text">
<string>Publish</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_SelectedOnly">
<property name="toolTip">
<string>selected models only</string>
</property>
<property name="text">
<string>selected</string>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_Sep2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Model">
<property name="text">
<string>&amp;1: Model</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Distributor">
<property name="text">
<string> &amp;2: Distributor</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_AircraftIcao">
<property name="text">
<string> &amp;3: Aircraft ICAO</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_Livery"> <widget class="QPushButton" name="pb_Livery">
<property name="text"> <property name="text">
<string> &amp;4: Livery</string> <string> &amp;4: Livery</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="11">
<widget class="QPushButton" name="pb_AirlineIcao"> <widget class="QPushButton" name="pb_AirlineIcao">
<property name="text"> <property name="toolTip">
<string> &amp;5: Airline ICAO</string> <string>Airline ICAO</string>
</property> </property>
<property name="text">
<string> &amp;5: Airline</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="pb_Unstash">
<property name="text">
<string>Unstash</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_Validate">
<property name="text">
<string>Validate</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pb_Publish">
<property name="text">
<string>Publish</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QPushButton" name="pb_Model">
<property name="text">
<string>&amp;1: Model</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QPushButton" name="pb_Distributor">
<property name="text">
<string> &amp;2: Distributor </string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="Line" name="line_Sep1">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pb_RemoveInvalid">
<property name="toolTip">
<string>Remove invalid models</string>
</property>
<property name="text">
<string> Rem. invalid </string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="Line" name="line_Sep2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QPushButton" name="pb_AircraftIcao">
<property name="toolTip">
<string>Aircraft ICAO</string>
</property>
<property name="text">
<string> &amp;3: Aircraft</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QWidget" name="wi_CheckBoxes" native="true">
<layout class="QHBoxLayout" name="hl_CheckBoxes">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="cb_SelectedOnly">
<property name="toolTip">
<string>selected models only</string>
</property>
<property name="text">
<string>selected</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cb_ChangedOnly">
<property name="toolTip">
<string>changed only</string>
</property>
<property name="text">
<string>chg.only</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -169,6 +209,7 @@
<tabstop>pb_RemoveInvalid</tabstop> <tabstop>pb_RemoveInvalid</tabstop>
<tabstop>pb_Publish</tabstop> <tabstop>pb_Publish</tabstop>
<tabstop>cb_SelectedOnly</tabstop> <tabstop>cb_SelectedOnly</tabstop>
<tabstop>cb_ChangedOnly</tabstop>
<tabstop>pb_Model</tabstop> <tabstop>pb_Model</tabstop>
<tabstop>pb_Distributor</tabstop> <tabstop>pb_Distributor</tabstop>
<tabstop>pb_AircraftIcao</tabstop> <tabstop>pb_AircraftIcao</tabstop>