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 CMergeWithVPilotMenu(this));
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 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 CApplyDbDataMenu(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
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);
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->addFilterDialog();
@@ -328,6 +328,11 @@ namespace BlackGui
return ui->comp_StashAircraft->getStashedModels();
}
bool CDbMappingComponent::hasStashedModels() const
{
return !this->getStashedModels().isEmpty();
}
QStringList CDbMappingComponent::getStashedModelStrings() const
{
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()
{
this->m_autoFilterInDbViews = !this->m_autoFilterInDbViews;
@@ -912,11 +924,11 @@ namespace BlackGui
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)
{}
void CDbMappingComponent::CModelStashToolsMenu::customMenu(CMenuActions &menuActions)
void CDbMappingComponent::CStashToolsMenu::customMenu(CMenuActions &menuActions)
{
CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
@@ -929,10 +941,6 @@ namespace BlackGui
this->m_stashFiltering->setCheckable(true);
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_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())
@@ -942,26 +950,31 @@ namespace BlackGui
}
else if (mapComp->currentTabIndex() == CDbMappingComponent::TabStash)
{
this->addRemoveDbModels(menuActions);
this->addStashViewSpecificMenus(menuActions);
}
this->nestedCustomMenu(menuActions);
}
void CDbMappingComponent::CModelStashToolsMenu::addRemoveDbModels(CMenuActions &menuActions)
void CDbMappingComponent::CStashToolsMenu::addStashViewSpecificMenus(CMenuActions &menuActions)
{
CDbMappingComponent *mapComp = mappingComponent();
Q_ASSERT_X(mapComp, Q_FUNC_INFO, "no mapping component");
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
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});
// 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());
}

View File

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

View File

@@ -319,7 +319,8 @@ namespace BlackGui
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "No web services");
const CAircraftModelList models(getSelectedOrAllModels());
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?
if (msgs.isEmpty())
@@ -423,7 +424,30 @@ namespace BlackGui
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()
{
const QObject *sender = QObject::sender();

View File

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

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>860</width>
<width>910</width>
<height>222</height>
</rect>
</property>
@@ -47,7 +47,111 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="hl_StashHandling">
<layout class="QGridLayout" name="gl_StashHandling">
<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>
<property name="horizontalSpacing">
<number>4</number>
</property>
<item row="0" column="10">
<widget class="QPushButton" name="pb_Livery">
<property name="text">
<string> &amp;4: Livery</string>
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QPushButton" name="pb_AirlineIcao">
<property name="toolTip">
<string>Airline ICAO</string>
</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>
@@ -60,44 +164,6 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pb_Unstash">
<property name="text">
<string>Unstash</string>
</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">
@@ -109,45 +175,19 @@
</widget>
</item>
<item>
<widget class="Line" name="line_Sep2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<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>
<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">
<property name="text">
<string> &amp;4: Livery</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_AirlineIcao">
<property name="text">
<string> &amp;5: Airline ICAO</string>
</property>
</layout>
</widget>
</item>
</layout>
@@ -169,6 +209,7 @@
<tabstop>pb_RemoveInvalid</tabstop>
<tabstop>pb_Publish</tabstop>
<tabstop>cb_SelectedOnly</tabstop>
<tabstop>cb_ChangedOnly</tabstop>
<tabstop>pb_Model</tabstop>
<tabstop>pb_Distributor</tabstop>
<tabstop>pb_AircraftIcao</tabstop>