7 #include "GeometryModel.h" 8 #include "GeometryWindow.h" 12 const int NO_HIGHLIGHTED_ROW = -1;
15 m_rowToBeHighlighted (NO_HIGHLIGHTED_ROW)
19 GeometryModel::~GeometryModel()
31 if ((role == Qt::BackgroundRole) &&
32 !m_pointIdentifier.isEmpty () &&
33 (index.row () == m_rowToBeHighlighted)) {
36 return QVariant (QColor (230, 230, 230));
40 return QStandardItemModel::data (index, role);
43 int GeometryModel::rowToBeHighlighted ()
const 45 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::rowToBeHighlighted" 46 <<
" rows=" << rowCount()
47 <<
" cols=" << columnCount();
49 for (
int row = 0; row < rowCount(); row++) {
52 QModelIndex indexPointIdentifier = index (row,
54 QVariant var = QStandardItemModel::data (indexPointIdentifier, Qt::DisplayRole);
56 QString pointIdentifierGot = var.toString();
57 if (pointIdentifierGot == m_pointIdentifier) {
66 return NO_HIGHLIGHTED_ROW;
71 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::setCurrentPointIdentifier" 72 <<
" rows=" << rowCount()
73 <<
" cols=" << columnCount()
74 <<
" identifier=" << pointIdentifier.toLatin1().data();
76 m_pointIdentifier = pointIdentifier;
79 if (!m_pointIdentifier.isEmpty ()) {
82 m_rowToBeHighlighted = rowToBeHighlighted();
83 rowTransitioned = m_rowToBeHighlighted;
88 rowTransitioned = m_rowToBeHighlighted;
89 m_rowToBeHighlighted = NO_HIGHLIGHTED_ROW;
93 QModelIndex indexTopLeft = createIndex (rowTransitioned, 0);
94 QModelIndex indexBottomRight = createIndex (rowTransitioned, columnCount() - 1);
97 roles << Qt::BackgroundRole;
99 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.