7 #include "GeometryModel.h"
8 #include "GeometryWindow.h"
12 const int NO_HIGHLIGHTED_ROW = -1;
15 m_rowToBeHighlighted (NO_HIGHLIGHTED_ROW)
19 GeometryModel::~GeometryModel()
25 const int HEADER_OFFSET = 1;
26 const int NUM_LEGEND_ROWS_UNSPANNED = 2;
34 if ((role == Qt::BackgroundRole) &&
35 !m_pointIdentifier.isEmpty () &&
36 (index.row () == m_rowToBeHighlighted)) {
39 return QVariant (QColor (230, 230, 230));
42 bool ambiguousSegment = ((role == Qt::BackgroundRole) &&
43 (m_ambiguousRows.contains (index.row () - HEADER_OFFSET)));
44 bool ambiguousFootnote = ((role == Qt::BackgroundRole) &&
45 (m_ambiguousRows.size () > 0) &&
46 (index.row () >= rowCount () - NUM_LEGEND_ROWS_UNSPANNED));
47 if (ambiguousSegment || ambiguousFootnote) {
50 return QVariant (QColor (255, 0, 0, 50));
54 return QStandardItemModel::data (index, role);
57 int GeometryModel::rowToBeHighlighted ()
const
59 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::rowToBeHighlighted"
60 <<
" rows=" << rowCount()
61 <<
" cols=" << columnCount();
63 for (
int row = 0; row < rowCount(); row++) {
66 QModelIndex indexPointIdentifier = index (row,
68 QVariant var = QStandardItemModel::data (indexPointIdentifier, Qt::DisplayRole);
70 QString pointIdentifierGot = var.toString();
71 if (pointIdentifierGot == m_pointIdentifier) {
80 return NO_HIGHLIGHTED_ROW;
85 LOG4CPP_INFO_S ((*mainCat)) <<
"GeometryModel::setCurrentPointIdentifier"
86 <<
" rows=" << rowCount()
87 <<
" cols=" << columnCount()
88 <<
" identifier=" << pointIdentifier.toLatin1().data();
90 m_pointIdentifier = pointIdentifier;
93 if (!m_pointIdentifier.isEmpty ()) {
96 m_rowToBeHighlighted = rowToBeHighlighted();
97 rowTransitioned = m_rowToBeHighlighted;
102 rowTransitioned = m_rowToBeHighlighted;
103 m_rowToBeHighlighted = NO_HIGHLIGHTED_ROW;
107 QModelIndex indexTopLeft = createIndex (rowTransitioned, 0);
108 QModelIndex indexBottomRight = createIndex (rowTransitioned, columnCount() - 1);
111 roles << Qt::BackgroundRole;
113 emit dataChanged (indexTopLeft,
121 m_ambiguousRows.clear ();
122 for (
int i = 0; i < isPotentialExportAmbiguity.size (); i++) {
123 if (isPotentialExportAmbiguity.at (i)) {
124 m_ambiguousRows [i] =
true;
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.
void setPotentialExportAmbiguity(const QVector< bool > &isPotentialExportAmbiguity)
Remember which rows could have ambiguities during export - these will be highlighted.
GeometryModel()
Single constructor.