Skip to content

Commit

Permalink
(cleanup) StarEditor: re-arrange paint steps (StarRating has a Painte…
Browse files Browse the repository at this point in the history
…rScope)
  • Loading branch information
ronso0 committed Jan 20, 2024
1 parent ab2d9b6 commit 923abdf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/library/stardelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ void StarDelegate::paintItem(
QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const {
// let the editor do the painting if this cell is currently being edited
// Let the editor do the painting if this cell is currently being edited.
// Note: if required, the focus border will be drawn by the editor.
if (index == m_currentEditedCellIndex) {
return;
}
Expand Down
12 changes: 5 additions & 7 deletions src/library/stareditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ void StarEditor::paintEvent(QPaintEvent*) {
style->drawControl(QStyle::CE_ItemViewItem, &m_styleOption, &painter, m_pTableView);
}

// Draw a border if the color cell has focus
if (m_styleOption.state & QStyle::State_Selected) {
// QPainterScope in drawBorder() and shift down?
TableItemDelegate::drawBorder(&painter, m_pFocusBorderColor, m_styleOption.rect);
}

// Starrating scales the painter so do this after painting the border.
// Set the palette appropriately based on whether the row is selected or
// not. We also have to check if it is inactive or not and use the
// appropriate ColorGroup.
Expand All @@ -89,6 +82,11 @@ void StarEditor::paintEvent(QPaintEvent*) {
}

m_starRating.paint(&painter, m_styleOption.rect);

// Draw a border if the color cell is selected
if (m_styleOption.state & QStyle::State_Selected) {
TableItemDelegate::drawBorder(&painter, m_pFocusBorderColor, m_styleOption.rect);
}
}

bool StarEditor::eventFilter(QObject* obj, QEvent* event) {
Expand Down
1 change: 1 addition & 0 deletions src/library/starrating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void StarRating::paint(QPainter* painter, const QRect& rect) const {
PainterScope painterScope(painter);
// Assume the painter is configured with the right brush.
painter->setRenderHint(QPainter::Antialiasing, true);
// Don't draw outlines, only fill the polygons
painter->setPen(Qt::NoPen);

// Center vertically inside the table cell, and also center horizontally
Expand Down

0 comments on commit 923abdf

Please sign in to comment.