PIVX Core  5.6.99
P2P Digital Currency
furabstractlistitemdelegate.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019 The PIVX Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
6 
8  QAbstractItemDelegate(parent), rowHeight(_rowHeight), row(_row){}
9 
10 void FurAbstractListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
11  const QModelIndex &index ) const
12 {
13  painter->save();
14 
15  // Status
16  bool isStateSelected = option.state & QStyle::State_Selected;
17  bool isStateHovered = option.state & QStyle::State_MouseOver;
18 
19  QRect selectedRect = option.rect;
20  selectedRect.setLeft(0);
21  painter->fillRect(selectedRect, this->row->rectColor(isStateHovered, isStateSelected));
22 
23  painter->translate(option.rect.topLeft());
24  QWidget *row = this->row->createHolder(index.row());
25  row->setStyleSheet(qobject_cast<QWidget*>(parent())->styleSheet());
26  this->row->init(row, index, isStateHovered, isStateSelected);
27  row->setAttribute(Qt::WA_DontShowOnScreen, true);
28  row->setGeometry(option.rect);
29  row->resize(option.rect.width(),option.rect.height());
30  row->render(painter, QPoint(), QRegion(), QWidget::DrawChildren );
31 
32  painter->restore();
33 }
34 
36  return this->row;
37 }
38 
39 QSize FurAbstractListItemDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const
40 {
41  return QSize(rowHeight, rowHeight);
42 }
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
FurAbstractListItemDelegate(int _rowHeight, FurListRow<> *_row, QObject *parent=nullptr)
virtual void init(T, const QModelIndex &, bool isHovered, bool isSelected) const
Definition: furlistrow.h:22
virtual QColor rectColor(bool isHovered, bool isSelected)
Definition: furlistrow.h:26
virtual T createHolder(int)
Definition: furlistrow.h:18