Skip to content

Commit

Permalink
TableItemDelegate: add default paintItem() implementation
Browse files Browse the repository at this point in the history
so MultiLineEditDelegate doesn't have to implement it just for calling the base class
implementation QStyledItemDelegate::paint() (which raised a clazy error)
  • Loading branch information
ronso0 committed Jul 23, 2023
1 parent 7685dd1 commit 125f971
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
5 changes: 3 additions & 2 deletions src/library/bpmdelegate.h
Expand Up @@ -13,8 +13,9 @@ class BPMDelegate : public TableItemDelegate {
explicit BPMDelegate(QTableView* pTableView);
virtual ~BPMDelegate();

void paintItem(QPainter* painter, const QStyleOptionViewItem& option,
const QModelIndex& index) const;
void paintItem(QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const override;

private:
QTableView* m_pTableView;
Expand Down
9 changes: 0 additions & 9 deletions src/library/multilineeditdelegate.cpp
Expand Up @@ -119,12 +119,3 @@ void MultiLineEditDelegate::commitAndCloseEditor() {
emit commitData(pEditor);
emit closeEditor(pEditor);
}

void MultiLineEditDelegate::paintItem(
QPainter* pPainter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const {
// Paint the item the default way, i.e. ellipsis after horizontal overflow
// and first linebreak
QStyledItemDelegate::paint(pPainter, option, index);
}
5 changes: 0 additions & 5 deletions src/library/multilineeditdelegate.h
Expand Up @@ -34,11 +34,6 @@ class MultiLineEditDelegate : public TableItemDelegate {
const QStyleOptionViewItem& option,
const QModelIndex& index) const override;

void paintItem(
QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const override;

private slots:
void commitAndCloseEditor();

Expand Down
7 changes: 7 additions & 0 deletions src/library/tableitemdelegate.cpp
Expand Up @@ -73,3 +73,10 @@ void TableItemDelegate::paintItemBackground(
const auto bgBrush = qvariant_cast<QBrush>(bgValue);
painter->fillRect(option.rect, bgBrush);
}

void TableItemDelegate::paintItem(
QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const {
QStyledItemDelegate::paint(painter, option, index);
}
2 changes: 1 addition & 1 deletion src/library/tableitemdelegate.h
Expand Up @@ -18,7 +18,7 @@ class TableItemDelegate : public QStyledItemDelegate {
virtual void paintItem(
QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index) const = 0;
const QModelIndex& index) const;

protected:
static void paintItemBackground(
Expand Down

0 comments on commit 125f971

Please sign in to comment.