mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 10:15:38 +08:00
Ref T189, context menu "Clear highlighting" only if there are highlighted rows
* added customMenu in template * added hasHighlightedRows
This commit is contained in:
@@ -221,5 +221,9 @@ namespace BlackGui
|
||||
this->m_highlightStrings.clear();
|
||||
COrderableListModelDbObjects::clearHighlighting();
|
||||
}
|
||||
bool CAircraftModelListModel::hasHighlightedRows() const
|
||||
{
|
||||
return !m_highlightStrings.isEmpty();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -71,9 +71,12 @@ namespace BlackGui
|
||||
//! The highlight color
|
||||
void setHighlightModelStringsColor(const QBrush &brush) { m_highlightColor = brush; }
|
||||
|
||||
//! \copydoc CListModelBase::clearHighlighting
|
||||
//! \copydoc CListModelBaseNonTemplate::clearHighlighting
|
||||
virtual void clearHighlighting() override;
|
||||
|
||||
//! \copydoc CListModelBaseNonTemplate::hasHighlightedRows
|
||||
virtual bool hasHighlightedRows() const override;
|
||||
|
||||
//! Model strings
|
||||
QStringList getModelStrings(bool sort) const;
|
||||
|
||||
|
||||
@@ -210,6 +210,12 @@ namespace BlackGui
|
||||
// can be overridden to delete highlighting
|
||||
}
|
||||
|
||||
bool CListModelBaseNonTemplate::hasHighlightedRows() const
|
||||
{
|
||||
return false;
|
||||
// can be overridden to enable highlighting based operations
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::emitDataChanged(int startRowIndex, int endRowIndex)
|
||||
{
|
||||
BLACK_VERIFY_X(startRowIndex <= endRowIndex, Q_FUNC_INFO, "check rows");
|
||||
|
||||
@@ -114,6 +114,9 @@ namespace BlackGui
|
||||
//! Remove all highlighting
|
||||
virtual void clearHighlighting();
|
||||
|
||||
//! Has highlighted rows?
|
||||
virtual bool hasHighlightedRows() const;
|
||||
|
||||
//! Drop actions
|
||||
void setDropActions(Qt::DropActions dropActions) { this->m_dropActions = dropActions; }
|
||||
|
||||
|
||||
@@ -430,9 +430,6 @@ namespace BlackGui
|
||||
actionInteractiveResize->setChecked(autoResize);
|
||||
actionInteractiveResize->setEnabled(enabled);
|
||||
connect(actionInteractiveResize, &QAction::toggled, this, &CViewBaseNonTemplate::ps_toggleResizeMode);
|
||||
|
||||
// Clear highlighting
|
||||
menuActions.addAction(CIcons::refresh16(), "Clear highlighting", CMenuAction::pathViewClearHighlighting(), nullptr , { this, &CViewBaseNonTemplate::clearHighlighting });
|
||||
}
|
||||
|
||||
void CViewBaseNonTemplate::resizeEvent(QResizeEvent *event)
|
||||
@@ -1422,6 +1419,18 @@ namespace BlackGui
|
||||
Q_UNUSED(data);
|
||||
}
|
||||
|
||||
template<class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::customMenu(CMenuActions &menuActions)
|
||||
{
|
||||
CViewBaseNonTemplate::customMenu(menuActions);
|
||||
|
||||
// Clear highlighting
|
||||
if (this->derivedModel()->hasHighlightedRows())
|
||||
{
|
||||
menuActions.addAction(CIcons::refresh16(), "Clear highlighting", CMenuAction::pathViewClearHighlighting(), nullptr , { this, &CViewBaseNonTemplate::clearHighlighting });
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
CStatusMessage CViewBase<ModelClass, ContainerType, ObjectType>::ps_loadJson()
|
||||
{
|
||||
|
||||
@@ -706,6 +706,9 @@ namespace BlackGui
|
||||
//! \remark I cannot use a signal with a template parameter, so this functions serves as callback
|
||||
virtual void jsonLoadedAndModelUpdated(const ContainerType &data);
|
||||
|
||||
//! \copydoc CViewBaseNonTemplate::customMenu
|
||||
virtual void customMenu(BlackGui::Menus::CMenuActions &menuActions) override;
|
||||
|
||||
// --------------------------------------------- SLOTS start here -----------------------------------------
|
||||
|
||||
//! \name Slot overrides from base class
|
||||
|
||||
Reference in New Issue
Block a user