7 #include "GeometryModel.h" 8 #include "GeometryWindow.h" 11 const int NO_HIGHLIGHTED_ROW = -1;
14 m_rowToBeHighlighted (NO_HIGHLIGHTED_ROW)
18 GeometryModel::~GeometryModel()
30 if ((role == Qt::BackgroundRole) &&
31 !m_pointIdentifier.isEmpty () &&
32 (index.row () == m_rowToBeHighlighted)) {
35 return QVariant (QColor (230, 230, 230));
39 return QStandardItemModel::data (index, role);
42 int GeometryModel::rowToBeHighlighted ()
const 44 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::rowToBeHighlighted" 45 <<
" rows=" << rowCount()
46 <<
" cols=" << columnCount();
48 for (
int row = 0; row < rowCount(); row++) {
51 QModelIndex indexPointIdentifier = index (row,
53 QVariant var = QStandardItemModel::data (indexPointIdentifier, Qt::DisplayRole);
55 QString pointIdentifierGot = var.toString();
56 if (pointIdentifierGot == m_pointIdentifier) {
65 return NO_HIGHLIGHTED_ROW;
70 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::setCurrentPointIdentifier" 71 <<
" rows=" << rowCount()
72 <<
" cols=" << columnCount()
73 <<
" identifier=" << pointIdentifier.toLatin1().data();
75 m_pointIdentifier = pointIdentifier;
78 if (!m_pointIdentifier.isEmpty ()) {
81 m_rowToBeHighlighted = rowToBeHighlighted();
82 rowTransitioned = m_rowToBeHighlighted;
87 rowTransitioned = m_rowToBeHighlighted;
88 m_rowToBeHighlighted = NO_HIGHLIGHTED_ROW;
92 QModelIndex indexTopLeft = createIndex (rowTransitioned, 0);
93 QModelIndex indexBottomRight = createIndex (rowTransitioned, columnCount() - 1);
96 roles << Qt::BackgroundRole;
98 emit dataChanged (indexTopLeft,
void setCurrentPointIdentifier(const QString &pointIdentifier)
Set the point identifier to be highlighted. Value is empty for no highlighting.
virtual QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Override for special processing.
static int columnBodyPointIdentifiers()
Hidden column that has the point identifiers.
GeometryModel()
Single constructor.