1
0
Fork 0

GUI: introduce AbstractTableView::getCellColor

This commit is contained in:
Duncan Ogilvie 2019-06-18 01:39:09 +02:00
parent 728f0eaa8d
commit 34318e3f7e
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
3 changed files with 12 additions and 4 deletions

View File

@ -240,7 +240,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
} }
} }
painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text); painter->drawText(QRect(x + 4, y, w - 4, h), Qt::AlignVCenter | Qt::AlignLeft, text);
text = ""; text.clear();
} }
else if(mHighlightText.length() && text.contains(mHighlightText, Qt::CaseInsensitive)) // TODO: case sensitive + regex highlighting else if(mHighlightText.length() && text.contains(mHighlightText, Qt::CaseInsensitive)) // TODO: case sensitive + regex highlighting
{ {
@ -261,7 +261,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
//create rich text list //create rich text list
RichTextPainter::CustomRichText_t curRichText; RichTextPainter::CustomRichText_t curRichText;
curRichText.flags = RichTextPainter::FlagColor; curRichText.flags = RichTextPainter::FlagColor;
curRichText.textColor = mTextColor; curRichText.textColor = getCellColor(rowBase + rowOffset, col);
curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor"); curRichText.highlightColor = ConfigColor("SearchListViewHighlightColor");
RichTextPainter::List richText; RichTextPainter::List richText;
foreach(QString str, split) foreach(QString str, split)
@ -273,7 +273,7 @@ QString AbstractStdTable::paintContent(QPainter* painter, dsint rowBase, int row
//paint the rich text //paint the rich text
RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, richText, mFontMetrics); RichTextPainter::paintRichText(painter, x + 1, y, w, h, 4, richText, mFontMetrics);
text = ""; text.clear();
} }
return text; return text;
} }

View File

@ -140,6 +140,13 @@ void AbstractTableView::updateFonts()
mHeader.height = mFontMetrics->height() + 4; mHeader.height = mFontMetrics->height() + 4;
} }
QColor AbstractTableView::getCellColor(int r, int c)
{
Q_UNUSED(r);
Q_UNUSED(c);
return mTextColor;
}
void AbstractTableView::invalidateCachedFont() void AbstractTableView::invalidateCachedFont()
{ {
delete mFontMetrics; delete mFontMetrics;
@ -310,7 +317,7 @@ void AbstractTableView::paintEvent(QPaintEvent* event)
if(wStr.length()) if(wStr.length())
{ {
wPainter.setPen(mTextColor); wPainter.setPen(getCellColor(mTableOffset + i, j));
wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr); wPainter.drawText(QRect(x + 4, y, getColumnWidth(j) - 4, getRowHeight()), Qt::AlignVCenter | Qt::AlignLeft, wStr);
} }
} }

View File

@ -53,6 +53,7 @@ public:
// Pure Virtual Methods // Pure Virtual Methods
virtual QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) = 0; virtual QString paintContent(QPainter* painter, dsint rowBase, int rowOffset, int col, int x, int y, int w, int h) = 0;
virtual QColor getCellColor(int r, int c);
// Painting Stuff // Painting Stuff
void paintEvent(QPaintEvent* event) override; void paintEvent(QPaintEvent* event) override;