Skip to content

Commit

Permalink
Revert "gui: Alternate row background based on txid"
Browse files Browse the repository at this point in the history
This reverts commit 264f9c4d4f7c1aeb3e89eedddcd88e47e8bba938.

This was included in ElementsProject#569
which received no review, and is a backport of upstream PR
bitcoin/bitcoin#12578 which was
later closed. It leaks memory which is causing CI to fail.
  • Loading branch information
apoelstra committed Dec 16, 2020
1 parent f2886b2 commit 1af4e96
Showing 1 changed file with 1 addition and 34 deletions.
35 changes: 1 addition & 34 deletions src/qt/transactionview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,16 @@
#include <QDoubleValidator>
#include <QHBoxLayout>
#include <QHeaderView>
#include <QItemDelegate>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QPainter>
#include <QPoint>
#include <QScrollBar>
#include <QTableView>
#include <QTimer>
#include <QUrl>
#include <QVBoxLayout>

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)
{
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1af4e96

Please sign in to comment.