mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #735, allow to reset highlighting
(some leftovers of DB object highlighting also deleted)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
2434c7bbe2
commit
b324a26747
@@ -164,14 +164,17 @@ namespace BlackGui
|
||||
//! View resizing
|
||||
static const QString &pathViewResize() { static const QString p("View.14.Resize"); return p; }
|
||||
|
||||
//! View clear highlighting
|
||||
static const QString &pathViewClearHighlighting() { static const QString p("View.15.ClearHighlight"); return p; }
|
||||
|
||||
//! View filter
|
||||
static const QString &pathViewFilter() { static const QString p("View.15.Filter"); return p; }
|
||||
static const QString &pathViewFilter() { static const QString p("View.16.Filter"); return p; }
|
||||
|
||||
//! View update
|
||||
static const QString &pathViewUpdates() { static const QString p("View.16.Updates"); return p; }
|
||||
static const QString &pathViewUpdates() { static const QString p("View.17.Updates"); return p; }
|
||||
|
||||
//! View load/save
|
||||
static const QString &pathViewLoadSave() { static const QString p("View.17.LoadSave"); return p; }
|
||||
static const QString &pathViewLoadSave() { static const QString p("View.18.LoadSave"); return p; }
|
||||
|
||||
// ---- nested dock widgets ----
|
||||
|
||||
|
||||
@@ -197,5 +197,12 @@ namespace BlackGui
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void CAircraftModelListModel::clearHighlighting()
|
||||
{
|
||||
this->m_highlightModelStrings = false;
|
||||
this->m_highlightStrings.clear();
|
||||
COrderableListModelDbObjects::clearHighlighting();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -72,6 +72,9 @@ namespace BlackGui
|
||||
//! The highlight color
|
||||
void setHighlightModelStringsColor(const QBrush &brush) { m_highlightColor = brush; }
|
||||
|
||||
//! \copydoc CListModelBase::clearHighlighting
|
||||
virtual void clearHighlighting() override;
|
||||
|
||||
//! Model strings
|
||||
QStringList getModelStrings(bool sort) const;
|
||||
|
||||
@@ -86,7 +89,7 @@ namespace BlackGui
|
||||
|
||||
private:
|
||||
AircraftModelMode m_mode = NotSet; //!< current mode
|
||||
bool m_highlightModelStrings = false; //!< highlight in in model strings
|
||||
bool m_highlightModelStrings = false; //!< highlight if in m_highlightStrings
|
||||
QStringList m_highlightStrings; //!< model strings to highlight
|
||||
QBrush m_highlightColor{Qt::yellow}; //!< how to highlight
|
||||
};
|
||||
|
||||
@@ -210,6 +210,11 @@ namespace BlackGui
|
||||
emit this->dataChanged(topLeft, bottomRight);
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::clearHighlighting()
|
||||
{
|
||||
// can be overridden to delete highlighting
|
||||
}
|
||||
|
||||
void CListModelBaseNonTemplate::emitDataChanged(int startRowIndex, int endRowIndex)
|
||||
{
|
||||
BLACK_VERIFY_X(startRowIndex <= endRowIndex, Q_FUNC_INFO, "check rows");
|
||||
|
||||
@@ -111,6 +111,9 @@ namespace BlackGui
|
||||
//! Hovered role
|
||||
void setHoveredRow(int row);
|
||||
|
||||
//! Remove all highlighting
|
||||
virtual void clearHighlighting();
|
||||
|
||||
//! Drop actions
|
||||
void setDropActions(Qt::DropActions dropActions) { this->m_dropActions = dropActions; }
|
||||
|
||||
|
||||
@@ -36,18 +36,8 @@ namespace BlackGui
|
||||
QVariant CListModelDbObjects<ObjectType, ContainerType, KeyType, UseCompare>::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::BackgroundRole) { return CListModelBase<ObjectType, ContainerType, UseCompare>::data(index, role); }
|
||||
|
||||
if (isHighlightIndex(index)) { return QBrush(m_highlightColor); }
|
||||
if (!highlightDbData()) { return CListModelBase<ObjectType, ContainerType, UseCompare>::data(index, role); }
|
||||
|
||||
const ObjectType obj(this->at(index));
|
||||
// highlight DB models
|
||||
if (obj.hasValidDbKey())
|
||||
{
|
||||
static const QBrush b(Qt::green);
|
||||
return b;
|
||||
}
|
||||
return QVariant();
|
||||
return CListModelBase<ObjectType, ContainerType, UseCompare>::data(index, role);
|
||||
}
|
||||
|
||||
template <typename ObjectType, typename ContainerType, typename KeyType, bool UseCompare>
|
||||
|
||||
@@ -47,15 +47,19 @@ namespace BlackGui
|
||||
//! Destructor
|
||||
virtual ~CListModelDbObjects() {}
|
||||
|
||||
//! Highlight the DB models
|
||||
bool highlightDbData() const { return m_highlightDbData; }
|
||||
|
||||
//! Highlight the DB models
|
||||
void setHighlightDbData(bool highlightDbData) { m_highlightDbData = highlightDbData; }
|
||||
|
||||
//! Keys to be highlighted
|
||||
void setHighlightDbKeys(const QList<KeyType> &keys) { m_highlightKeys = keys; }
|
||||
|
||||
//! Clear the highlighted keys
|
||||
void clearHighlightingDbKeys() { m_highlightKeys.clear(); }
|
||||
|
||||
//! \copydoc BlackGui::Models::CListModelBaseNonTemplate::clearHighlighting
|
||||
virtual void clearHighlighting() override
|
||||
{
|
||||
this->clearHighlightingDbKeys();
|
||||
CListModelBase<ObjectType, ContainerType, UseCompare>::clearHighlighting();
|
||||
}
|
||||
|
||||
//! Set color for highlighting
|
||||
void setHighlightColor(QColor color) { m_highlightColor = color; }
|
||||
|
||||
@@ -73,12 +77,10 @@ namespace BlackGui
|
||||
CListModelDbObjects(const QString &translationContext, QObject *parent = nullptr);
|
||||
|
||||
private:
|
||||
bool m_highlightDbData = false; //!< highlight if DB data entry (valid key)
|
||||
QList<KeyType> m_highlightKeys; //!< keys to be highlighted
|
||||
QColor m_highlightColor = Qt::green;
|
||||
};
|
||||
|
||||
|
||||
//! List model for DB objects
|
||||
template <typename ObjectType, typename ContainerType, typename KeyType, bool UseCompare = false> class COrderableListModelDbObjects :
|
||||
public CListModelDbObjects<ObjectType, ContainerType, KeyType, UseCompare>
|
||||
|
||||
@@ -357,6 +357,9 @@ 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::showEvent(QShowEvent *event)
|
||||
@@ -957,6 +960,13 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
void CViewBase<ModelClass, ContainerType, ObjectType>::clearHighlighting()
|
||||
{
|
||||
Q_ASSERT(this->m_model);
|
||||
return this->m_model->clearHighlighting();
|
||||
}
|
||||
|
||||
template <class ModelClass, class ContainerType, class ObjectType>
|
||||
int CViewBase<ModelClass, ContainerType, ObjectType>::rowCount() const
|
||||
{
|
||||
|
||||
@@ -309,6 +309,9 @@ namespace BlackGui
|
||||
//! Remove selected rows
|
||||
virtual int removeSelectedRows() = 0;
|
||||
|
||||
//! Clear any highlighted objects
|
||||
virtual void clearHighlighting() = 0;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CViewBaseNonTemplate(QWidget *parent);
|
||||
@@ -543,6 +546,7 @@ namespace BlackGui
|
||||
//! @{
|
||||
virtual int removeSelectedRows() override;
|
||||
virtual void presizeOrFullResizeToContents() override;
|
||||
virtual void clearHighlighting() override;
|
||||
//! @}
|
||||
|
||||
//! \name BlackGui::Views::CViewBaseNonTemplate implementations
|
||||
|
||||
Reference in New Issue
Block a user