mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #568, improved validation and handling
* invalid models can be highlighted on stash * selection mode can be toggled between single/multi selection (where applicable) * color for highlighting can be set * finetuning of menus
This commit is contained in:
@@ -125,6 +125,22 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CAircraftModelListModel::setHighlightModelStrings(const QStringList &modelStrings)
|
||||
{
|
||||
this->beginResetModel();
|
||||
m_highlightStrings = modelStrings;
|
||||
this->endResetModel();
|
||||
}
|
||||
|
||||
void CAircraftModelListModel::setHighlightModelStrings(bool highlightModelStrings)
|
||||
{
|
||||
if (m_highlightModelStrings == highlightModelStrings) { return; }
|
||||
|
||||
this->beginResetModel();
|
||||
m_highlightModelStrings = highlightModelStrings;
|
||||
this->endResetModel();
|
||||
}
|
||||
|
||||
QStringList CAircraftModelListModel::getModelStrings(bool sort) const
|
||||
{
|
||||
if (this->isEmpty()) { return QStringList(); }
|
||||
@@ -143,15 +159,14 @@ namespace BlackGui
|
||||
QVariant CAircraftModelListModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role != Qt::BackgroundRole) { return CListModelDbObjects::data(index, role); }
|
||||
bool ms = highlightGivenModelStrings() && !m_highlightStrings.isEmpty();
|
||||
bool ms = highlightModelStrings() && !m_highlightStrings.isEmpty();
|
||||
if (!ms) { return CListModelDbObjects::data(index, role); }
|
||||
|
||||
CAircraftModel model(this->at(index));
|
||||
// highlight stashed first
|
||||
if (m_highlightStrings.contains(model.getModelString(), Qt::CaseInsensitive))
|
||||
{
|
||||
static const QBrush b(Qt::yellow);
|
||||
return b;
|
||||
return this->m_highlightColor;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include <QStringList>
|
||||
#include <QAbstractItemModel>
|
||||
#include <QBrush>
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
@@ -52,13 +53,16 @@ namespace BlackGui
|
||||
AircraftModelMode getModelMode() const { return m_mode; }
|
||||
|
||||
//! Highlight models
|
||||
bool highlightGivenModelStrings() const { return m_highlightModelStrings; }
|
||||
void setHighlightModelStrings(const QStringList &modelStrings = QStringList());
|
||||
|
||||
//! Highlight models
|
||||
void setHighlightModelsStrings(const QStringList &modelStrings = QStringList()) { m_highlightStrings = modelStrings; }
|
||||
bool highlightModelStrings() const { return m_highlightModelStrings; }
|
||||
|
||||
//! Highlight models
|
||||
void setHighlightModelsStrings(bool highlightModelStrings) { m_highlightModelStrings = highlightModelStrings; }
|
||||
void setHighlightModelStrings(bool highlightModelStrings);
|
||||
|
||||
//! The highlight color
|
||||
void setHighlightModelStringsColor(const QBrush &brush) { m_highlightColor = brush; }
|
||||
|
||||
//! Model strings
|
||||
QStringList getModelStrings(bool sort) const;
|
||||
@@ -70,9 +74,10 @@ namespace BlackGui
|
||||
virtual QVariant data(const QModelIndex &index, int role) const override;
|
||||
|
||||
private:
|
||||
AircraftModelMode m_mode = NotSet; //!< current mode
|
||||
bool m_highlightModelStrings = false; //!< highlight in in model strings
|
||||
QStringList m_highlightStrings; //!< model strings to highlight
|
||||
AircraftModelMode m_mode = NotSet; //!< current mode
|
||||
bool m_highlightModelStrings = false; //!< highlight in in model strings
|
||||
QStringList m_highlightStrings; //!< model strings to highlight
|
||||
QBrush m_highlightColor{Qt::yellow}; //!< how to highlight
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user