From e56825b3bb914ca9ebb385a1cb04d63e2eec228e Mon Sep 17 00:00:00 2001 From: Andrew Poelstra Date: Sat, 12 Dec 2020 22:00:37 +0000 Subject: [PATCH] Revert "gui: Alternate row background based on txid" This reverts commit 264f9c4d4f7c1aeb3e89eedddcd88e47e8bba938. This was included in https://github.com/ElementsProject/elements/pull/569/ which received no review, and is a backport of upstream PR https://github.com/bitcoin/bitcoin/pull/12578 which was later closed. It leaks memory which is causing CI to fail. --- src/qt/transactionview.cpp | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 2b99cbc92e4..1dfec0a238d 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -26,11 +26,9 @@ #include #include #include -#include #include #include #include -#include #include #include #include @@ -38,37 +36,6 @@ #include #include -class TransactionRecordDelegate : public QItemDelegate -{ - QSortFilterProxyModel* m_proxy; - - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const - { - bool alternate = false; - QVariant previous_hash; - - for (int row = 0; row <= index.row(); ++row) { - QModelIndex sibling = m_proxy->mapToSource(index.sibling(row, 0)); - QVariant hash = sibling.data(TransactionTableModel::TxHashRole); - if (row == 0) { - previous_hash = hash; - } else if (hash != previous_hash) { - alternate = !alternate; - previous_hash = hash; - } - } - - if (alternate) { - painter->fillRect(option.rect, option.palette.alternateBase()); - } - - QItemDelegate::paint(painter, option, index); - } - -public: - TransactionRecordDelegate(QSortFilterProxyModel* proxy) : m_proxy(proxy) {} -}; - TransactionView::TransactionView(const PlatformStyle *platformStyle, QWidget *parent) : QWidget(parent) { @@ -252,7 +219,7 @@ void TransactionView::setModel(WalletModel *_model) transactionView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); transactionView->setModel(transactionProxyModel); - transactionView->setItemDelegate(new TransactionRecordDelegate(transactionProxyModel)); + transactionView->setAlternatingRowColors(true); transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); transactionView->horizontalHeader()->setSortIndicator(TransactionTableModel::Date, Qt::DescendingOrder);