From a99ac8d3f483d8a839ea3c4e0f400eaa64338acd Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 3 Aug 2011 20:52:18 +0200 Subject: [PATCH] show last few transactions on overview page --- src/qt/forms/overviewpage.ui | 204 ++++++++++++++++++++---------- src/qt/guiutil.cpp | 6 +- src/qt/guiutil.h | 2 + src/qt/overviewpage.cpp | 98 +++++++++++++- src/qt/overviewpage.h | 3 + src/qt/res/icons/tx_inout.png | Bin 631 -> 2442 bytes src/qt/res/icons/tx_input.png | Bin 594 -> 2152 bytes src/qt/res/icons/tx_mined.png | Bin 754 -> 3287 bytes src/qt/res/icons/tx_output.png | Bin 593 -> 2129 bytes src/qt/transactionfilterproxy.cpp | 20 ++- src/qt/transactionfilterproxy.h | 5 + src/qt/transactiontablemodel.cpp | 4 + src/qt/transactiontablemodel.h | 2 + 13 files changed, 268 insertions(+), 76 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index d8362a7b2..cc67fae53 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -13,82 +13,146 @@ Form - + - - - QFrame::StyledPanel - - - QFrame::Raised - - - - QFormLayout::AllNonFixedFieldsGrow - - - 12 - - - 12 - - - - - Balance: + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + QFormLayout::AllNonFixedFieldsGrow - - - - - - 123.456 BTC + + 12 - - - - - - Number of transactions: + + 12 - - - - - - 0 - - - - - - - Unconfirmed: - - - - - - - 0 BTC - - - - - + + + + Balance: + + + + + + + 123.456 BTC + + + + + + + Number of transactions: + + + + + + + 0 + + + + + + + Unconfirmed: + + + + + + + 0 BTC + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Wallet</span></p></body></html> + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + - - - Qt::Vertical - - - - 20 - 40 - - - + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + <b>Recent transactions</b> + + + + + + + QFrame::NoFrame + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 308a6ba9b..ece069072 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -11,7 +11,11 @@ QString GUIUtil::DateTimeStr(qint64 nTime) { - QDateTime date = QDateTime::fromTime_t((qint32)nTime); + return DateTimeStr(QDateTime::fromTime_t((qint32)nTime)); +} + +QString GUIUtil::DateTimeStr(const QDateTime &date) +{ return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm"); } diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 26a1a0371..fb5c575ab 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -7,12 +7,14 @@ QT_BEGIN_NAMESPACE class QFont; class QLineEdit; class QWidget; +class QDateTime; QT_END_NAMESPACE class GUIUtil { public: static QString DateTimeStr(qint64 nTime); + static QString DateTimeStr(const QDateTime &datetime); // Render bitcoin addresses in monospace font static QFont bitcoinAddressFont(); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c04bbf600..f79e1f3e9 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -4,14 +4,87 @@ #include "walletmodel.h" #include "bitcoinunits.h" #include "optionsmodel.h" +#include "transactiontablemodel.h" +#include "transactionfilterproxy.h" +#include "guiutil.h" +#include "guiconstants.h" #include +#include +#include + +#define DECORATION_SIZE 64 +class TxViewDelegate : public QItemDelegate +{ + //Q_OBJECT +public: + TxViewDelegate(): QItemDelegate(), unit(BitcoinUnits::BTC) + { + + } + + inline void paint(QPainter *painter, const QStyleOptionViewItem &option, + const QModelIndex &index ) const + { + //QItemDelegate::paint(painter, option, index); + painter->save(); + + QIcon icon = qvariant_cast(index.data(Qt::DecorationRole)); + QRect mainRect = option.rect; + QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE)); + int xspace = DECORATION_SIZE + 8; + int ypad = 6; + int halfheight = (mainRect.height() - 2*ypad)/2; + QRect amountRect(mainRect.left() + xspace, mainRect.top()+ypad, mainRect.width() - xspace, halfheight); + QRect addressRect(mainRect.left() + xspace, mainRect.top()+ypad+halfheight, mainRect.width() - xspace, halfheight); + icon.paint(painter, decorationRect); + + QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); + QString address = index.data(Qt::DisplayRole).toString(); + qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); + bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); + QVariant value = index.data(Qt::ForegroundRole); + QColor foreground = option.palette.color(QPalette::Text); + if(qVariantCanConvert(value)) + { + foreground = qvariant_cast(value); + } + + painter->setPen(foreground); + painter->drawText(addressRect, Qt::AlignLeft|Qt::AlignVCenter, address); + + if(amount < 0) + { + foreground = COLOR_NEGATIVE; + } + else + { + foreground = option.palette.color(QPalette::Text); + } + painter->setPen(foreground); + QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true); + if(!confirmed) + { + amountText = QString("[") + amountText + QString("]"); + } + painter->drawText(amountRect, Qt::AlignRight|Qt::AlignVCenter, amountText); + + painter->setPen(option.palette.color(QPalette::Text)); + painter->drawText(amountRect, Qt::AlignLeft|Qt::AlignVCenter, GUIUtil::DateTimeStr(date)); + + painter->restore(); + } + + int unit; + +}; OverviewPage::OverviewPage(QWidget *parent) : QWidget(parent), ui(new Ui::OverviewPage), currentBalance(-1), - currentUnconfirmedBalance(-1) + currentUnconfirmedBalance(-1), + txdelegate(new TxViewDelegate()) { ui->setupUi(this); @@ -27,9 +100,11 @@ OverviewPage::OverviewPage(QWidget *parent) : ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet")); - // Overview page should show: - // Last received transaction(s) - // Last sent transaction(s) + // Recent transactions + ui->listTransactions->setStyleSheet("background:transparent"); + ui->listTransactions->setItemDelegate(txdelegate); + ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); + ui->listTransactions->setSelectionMode(QAbstractItemView::NoSelection); } OverviewPage::~OverviewPage() @@ -55,6 +130,18 @@ void OverviewPage::setModel(WalletModel *model) { this->model = model; + // Set up transaction list + + TransactionFilterProxy *filter = new TransactionFilterProxy(); + filter->setSourceModel(model->getTransactionTableModel()); + filter->setLimit(3); + filter->setDynamicSortFilter(true); + filter->setSortRole(Qt::EditRole); + filter->sort(TransactionTableModel::Status, Qt::DescendingOrder); + + ui->listTransactions->setModel(filter); + ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress); + // Keep up to date with wallet setBalance(model->getBalance(), model->getUnconfirmedBalance()); connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64))); @@ -69,4 +156,7 @@ void OverviewPage::displayUnitChanged() { if(currentBalance != -1) setBalance(currentBalance, currentUnconfirmedBalance); + + txdelegate->unit = model->getOptionsModel()->getDisplayUnit(); + ui->listTransactions->update(); } diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index c54dda323..2abddf16a 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -7,6 +7,7 @@ namespace Ui { class OverviewPage; } class WalletModel; +class TxViewDelegate; class OverviewPage : public QWidget { @@ -28,6 +29,8 @@ private: qint64 currentBalance; qint64 currentUnconfirmedBalance; + TxViewDelegate *txdelegate; + private slots: void displayUnitChanged(); }; diff --git a/src/qt/res/icons/tx_inout.png b/src/qt/res/icons/tx_inout.png index ff6bb1c5c3ed6049f5cbde02b95d53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z%vftv*4mT#d_LLfbS_9*41K10z22E}xqR$b0FsA8`9m(3dy>s&zeYyKajp!9!{tt= z^9sO<1CwWlMn>$;1QZUT5O=`#S3lq8az2QUrb zd`!~r5c53(mrA8A$z<|K_}ob{@&QR;WBdsK3o!uE2kwuY>h<~$k{2Dv`6THofD@Ta zW?s^4yWM_C@*&CVwOZ}gcz^@r7Isi)M~Xm06@?4E(5q1 z;syYolYABg!MAXX3nY&M*a6^6x7*!YtyY65QOp?gCJ2Hx08;>x0IVb%_8RpZ(fx5S z5N=|l(U^|M<7XwE1CSy)Cutjij{x3DdJJHxP$;~{?9oqqrT002ovPDHLkV1g4|{sRC2 diff --git a/src/qt/res/icons/tx_input.png b/src/qt/res/icons/tx_input.png index 1673d06ad33a333b0a7c6652a30c4e420e933dc2..0f5fea3a8456c73a27c2f0f3d01b3bc96aee389d 100644 GIT binary patch delta 2116 zcmV-K2)p;v1n3YUiBL{Q4GJ0x0000DNk~Le0000$0000$2nGNE0IF$m-jN|13kPBV z00&|LIC`1ekwzzf2jxjbK~#90?VDX}n^zgff6uXvo2hHn6f(N0odAiIvW~7|2)Y5G z+K@Vx)b$#;U=w8^<)(3(6@j1^kw~1f-b>gA+Cs{ekdCqg5_wVz6p6`gNax-IE9YCwOB|xhK zXf?M4XmtRs=9U1h4xrWC^aA+3I!GpyD}eRJnDwfW7;U#}(iVa6&{5`+UCV zH*em2wF!QIYvM|POeS-W<2c(yc@Iit5_sNPJFKe1;c)n^d8=y<0VJ7BK5C5l z4$wJY0l4HOFl?QlfcnpIJ=5Rtc4^&s%GP$=|Q zul}k#LCNKEBf!VKI-V~|ea^Rl`+(1Q^*3V}Or=tPpXGi0@KrpJN~Juv`I=XU z3yCr2>z;j7q(xP?d3CsusA}^BNG6jTMC2~74y(8foTb={UjUpY`~O%bley1}gXvDt z=ktBB!R@ge@FH+nM9!(|MQiOv$8p~2?(UwbG>k^0X3d&49l>C5g{rOq?gZAU>LWDR z_c)G!b3ZWBNLi>5Kvf^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I=c;Ts|nQPt|Td#iXsLq3+LUq{`SrOPA|i4O#W!PSoAtOeGV?ij2F+JV~v-z-IQ6gNn- zs`{#koHoXcSZhZ@q0s9M1>=E+1*k+OaEFu8et^x6cRjCcys- uH~oK%+!CPG0koQ10<=1SR&&z}@IL@$IgAVID((Oa0000w z00Gzm`dp@Rkwzzf0nbT9K~y-6rBgj`6G0GtZ~YO7fRF~T6e&QF;>1T`nbwjKg&X^f zu#xEC58Ra$F6e;90!q4+*s^>Ql1mFAB!l9DjuaFDCq$$|$fSsU_b9lFE(f9UNTZ$I zH}m$*td^26kD0lu0i>hA^SrYpYXH_HtxC#}+?F&Z`Oda~?F|5b$)zOpdcAd$bpR*- zbJ;G*=hbTU=@Ei%x4UAD8OP29;4^?RNlVg&7`8v1PM7QT`oUof#+a*Nd|-^ZmC0m2 zmdoXzQ9`rXyqnMGFOqx$U@?_SO66@_p5r+80lXZIMs}f4*p{^6 z`~F^Xh>?PStvKMi?n3~N0c=htlbeIV;FU2Zko0Ic9KL9^S~~!cmb4Vs{ECVjjYcY$ z%Uut*r%B!b-~*Te@Mp8x5`djZK{UW~5kb4%_DSAz9A{6`14&M)RJtT-#kTEd$rd7l z^Kn3b2IIJ{yK7n28A+WGI+ozF=Xu`%d?5Kg2!aV{Nvl{aULn~GbABLUX=BW05Cr=G z76Ie{*ph6L0Dx!>?RAoXlF;dNPGz&%+mh}8SR=VA=>&l90JbE(0kB@H)jlN&An9Mu je!stP40gmh?|1$UznkNWsZd()00000NkvXXu0mjfabo$j diff --git a/src/qt/res/icons/tx_mined.png b/src/qt/res/icons/tx_mined.png index a336868e8a89b553996f84ad63fba5aba551db06..613f30fecc041468d7ff766236dc509d815f7aab 100644 GIT binary patch delta 3260 zcmV;t3`6ts1=krNiBL{Q4GJ0x0000DNk~Le0000$0000$2nGNE0IF$m-jN|13kPBV z00&|LIC`1ekwzzf3{*)(K~#90?OSVfTvZkR_RY*>GR=b~Z63Co#A%30im#=0;R6d& zpb}zJz2{DWl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Gzm`dp@Rkwzzf0nSN8K~y-6rIWjh6Hye#zwd6$=pwiVRyVM)V39(0x6o3-LJ?A! zxse_G6Rh%REW{$M7Q&d?Cf!0dWRjJD2tmX`5o--tEN1c11QAV4Rr_firTIcA}30GUJyf?$PY89+hOhNKfD4<(IBzP8qXz5{TqT}nc?+ij8b0G#?y zv9BbbxUT!?2%yvHtQ%v-DVqR%0x%|dQPNtN#9)juTd_Vf#$0n8XT@4u zu-0C8T{jl@IA(b?8r`f^Dp&pjNN&ga=TfQks#q-kOtQ2M6;8uh;8WCEWtBD~Tkx08B|ftJP|EGLp{3vA^d5q9|G;c?rN0 z$)&hx27m)#GXo%5;JJB#X0y2mV6WHf?MPZ54u|haz94zu_x*=y!1;Lq0OminAmount = minimum; invalidateFilter(); } + +void TransactionFilterProxy::setLimit(int limit) +{ + this->limitRows = limit; +} + +int TransactionFilterProxy::rowCount(const QModelIndex &parent) const +{ + if(limitRows != -1) + { + return std::min(QSortFilterProxyModel::rowCount(parent), limitRows); + } + else + { + return QSortFilterProxyModel::rowCount(parent); + } +} diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index a44c9c4df..4dd2a8e5c 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -26,6 +26,10 @@ public: void setTypeFilter(quint32 modes); void setMinAmount(qint64 minimum); + // Set maximum number of rows returned, -1 if unlimited + void setLimit(int limit); + + int rowCount(const QModelIndex &parent = QModelIndex()) const; protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; @@ -35,6 +39,7 @@ private: QString addrPrefix; quint32 typeFilter; qint64 minAmount; + int limitRows; signals: diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 1606df9f5..458341c0f 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -578,6 +578,10 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const { return llabs(rec->credit + rec->debit); } + else if (role == AmountRole) + { + return rec->credit + rec->debit; + } else if (role == TxIDRole) { return QString::fromStdString(rec->getTxID()); diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index 71b064411..0daa5f6aa 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -39,6 +39,8 @@ public: LabelRole, // Absolute net amount of transaction, for filtering AbsoluteAmountRole, + // Net amount of transaction + AmountRole, // Unique identifier TxIDRole, // Is transaction confirmed?