Skip to content

Commit 34318e3

Browse files
committed
GUI: introduce AbstractTableView::getCellColor
1 parent 728f0ea commit 34318e3

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/gui/Src/BasicView/AbstractStdTable.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
240240
}
241241
}
242242
painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text);
243-
text = "";
243+
text.clear();
244244
}
245245
else if(mHighlightText.length() && text.contains(mHighlightText, Qt::CaseInsensitive)) // TODO: case sensitive + regex highlighting
246246
{
@@ -261,7 +261,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
261261
//create rich text list
262262
RichTextPainter::CustomRichText_t curRichText;
263263
curRichText.flags = RichTextPainter::FlagColor;
264-
curRichText.textColor = mTextColor;
264+
curRichText.textColor = getCellColor(rowBase + rowOffset, col);
265265
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
266266
RichTextPainter::List richText;
267267
foreach(QString str, split)
@@ -273,7 +273,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
273273

274274
//paint the rich text
275275
RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, richText, mFontMetrics);
276-
text = "";
276+
text.clear();
277277
}
278278
return text;
279279
}

src/gui/Src/BasicView/AbstractTableView.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ void AbstractTableView::updateFonts()
140140
mHeader.height = mFontMetrics->height() + 4;
141141
}
142142

143+
QColor AbstractTableView::getCellColor(int r, int c)
144+
{
145+
Q_UNUSED(r);
146+
Q_UNUSED(c);
147+
return mTextColor;
148+
}
149+
143150
void AbstractTableView::invalidateCachedFont()
144151
{
145152
delete mFontMetrics;
@@ -310,7 +317,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
310317

311318
if(wStr.length())
312319
{
313-
wPainter.setPen(mTextColor);
320+
wPainter.setPen(getCellColor(mTableOffset + i, j));
314321
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
315322
}
316323
}

src/gui/Src/BasicView/AbstractTableView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class AbstractTableView : public QAbstractScrollArea, public ActionHelper<Abstra
5353

5454
// Pure Virtual Methods
5555
virtual QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) = 0;
56+
virtual QColor getCellColor(int r, int c);
5657

5758
// Painting Stuff
5859
void paintEvent(QPaintEvent* event) override;

0 commit comments

Comments
 (0)