show last few transactions on overview page
@ -13,82 +13,146 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QFrame" name="frame">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="frameShape">
|
<item>
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<widget class="QFrame" name="frame">
|
||||||
</property>
|
<property name="frameShape">
|
||||||
<property name="frameShadow">
|
<enum>QFrame::StyledPanel</enum>
|
||||||
<enum>QFrame::Raised</enum>
|
</property>
|
||||||
</property>
|
<property name="frameShadow">
|
||||||
<layout class="QFormLayout" name="formLayout_2">
|
<enum>QFrame::Raised</enum>
|
||||||
<property name="fieldGrowthPolicy">
|
</property>
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
<layout class="QFormLayout" name="formLayout_2">
|
||||||
</property>
|
<property name="fieldGrowthPolicy">
|
||||||
<property name="horizontalSpacing">
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
<number>12</number>
|
|
||||||
</property>
|
|
||||||
<property name="verticalSpacing">
|
|
||||||
<number>12</number>
|
|
||||||
</property>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Balance:</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="horizontalSpacing">
|
||||||
</item>
|
<number>12</number>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="labelBalance">
|
|
||||||
<property name="text">
|
|
||||||
<string>123.456 BTC</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="verticalSpacing">
|
||||||
</item>
|
<number>12</number>
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Number of transactions:</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<item row="2" column="0">
|
||||||
</item>
|
<widget class="QLabel" name="label">
|
||||||
<item row="2" column="1">
|
<property name="text">
|
||||||
<widget class="QLabel" name="labelNumTransactions">
|
<string>Balance:</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>0</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="2" column="1">
|
||||||
</item>
|
<widget class="QLabel" name="labelBalance">
|
||||||
<item row="1" column="0">
|
<property name="text">
|
||||||
<widget class="QLabel" name="label_3">
|
<string>123.456 BTC</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Unconfirmed:</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="4" column="0">
|
||||||
</item>
|
<widget class="QLabel" name="label_2">
|
||||||
<item row="1" column="1">
|
<property name="text">
|
||||||
<widget class="QLabel" name="labelUnconfirmed">
|
<string>Number of transactions:</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>0 BTC</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="4" column="1">
|
||||||
</item>
|
<widget class="QLabel" name="labelNumTransactions">
|
||||||
</layout>
|
<property name="text">
|
||||||
</widget>
|
<string>0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Unconfirmed:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="labelUnconfirmed">
|
||||||
|
<property name="text">
|
||||||
|
<string>0 BTC</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string><!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></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<property name="orientation">
|
<item>
|
||||||
<enum>Qt::Vertical</enum>
|
<widget class="QFrame" name="frame_2">
|
||||||
</property>
|
<property name="frameShape">
|
||||||
<property name="sizeHint" stdset="0">
|
<enum>QFrame::StyledPanel</enum>
|
||||||
<size>
|
</property>
|
||||||
<width>20</width>
|
<property name="frameShadow">
|
||||||
<height>40</height>
|
<enum>QFrame::Raised</enum>
|
||||||
</size>
|
</property>
|
||||||
</property>
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
</spacer>
|
<item>
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string><b>Recent transactions</b></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QListView" name="listTransactions">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -11,7 +11,11 @@
|
|||||||
|
|
||||||
QString GUIUtil::DateTimeStr(qint64 nTime)
|
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");
|
return date.date().toString(Qt::SystemLocaleShortDate) + QString(" ") + date.toString("hh:mm");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,14 @@ QT_BEGIN_NAMESPACE
|
|||||||
class QFont;
|
class QFont;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
class QDateTime;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class GUIUtil
|
class GUIUtil
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static QString DateTimeStr(qint64 nTime);
|
static QString DateTimeStr(qint64 nTime);
|
||||||
|
static QString DateTimeStr(const QDateTime &datetime);
|
||||||
|
|
||||||
// Render bitcoin addresses in monospace font
|
// Render bitcoin addresses in monospace font
|
||||||
static QFont bitcoinAddressFont();
|
static QFont bitcoinAddressFont();
|
||||||
|
@ -4,14 +4,87 @@
|
|||||||
#include "walletmodel.h"
|
#include "walletmodel.h"
|
||||||
#include "bitcoinunits.h"
|
#include "bitcoinunits.h"
|
||||||
#include "optionsmodel.h"
|
#include "optionsmodel.h"
|
||||||
|
#include "transactiontablemodel.h"
|
||||||
|
#include "transactionfilterproxy.h"
|
||||||
|
#include "guiutil.h"
|
||||||
|
#include "guiconstants.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QItemDelegate>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
#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<QIcon>(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<QColor>(value))
|
||||||
|
{
|
||||||
|
foreground = qvariant_cast<QColor>(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) :
|
OverviewPage::OverviewPage(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::OverviewPage),
|
ui(new Ui::OverviewPage),
|
||||||
currentBalance(-1),
|
currentBalance(-1),
|
||||||
currentUnconfirmedBalance(-1)
|
currentUnconfirmedBalance(-1),
|
||||||
|
txdelegate(new TxViewDelegate())
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
@ -27,9 +100,11 @@ OverviewPage::OverviewPage(QWidget *parent) :
|
|||||||
|
|
||||||
ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet"));
|
ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet"));
|
||||||
|
|
||||||
// Overview page should show:
|
// Recent transactions
|
||||||
// Last received transaction(s)
|
ui->listTransactions->setStyleSheet("background:transparent");
|
||||||
// Last sent transaction(s)
|
ui->listTransactions->setItemDelegate(txdelegate);
|
||||||
|
ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
|
||||||
|
ui->listTransactions->setSelectionMode(QAbstractItemView::NoSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
OverviewPage::~OverviewPage()
|
OverviewPage::~OverviewPage()
|
||||||
@ -55,6 +130,18 @@ void OverviewPage::setModel(WalletModel *model)
|
|||||||
{
|
{
|
||||||
this->model = 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
|
// Keep up to date with wallet
|
||||||
setBalance(model->getBalance(), model->getUnconfirmedBalance());
|
setBalance(model->getBalance(), model->getUnconfirmedBalance());
|
||||||
connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64)));
|
connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64)));
|
||||||
@ -69,4 +156,7 @@ void OverviewPage::displayUnitChanged()
|
|||||||
{
|
{
|
||||||
if(currentBalance != -1)
|
if(currentBalance != -1)
|
||||||
setBalance(currentBalance, currentUnconfirmedBalance);
|
setBalance(currentBalance, currentUnconfirmedBalance);
|
||||||
|
|
||||||
|
txdelegate->unit = model->getOptionsModel()->getDisplayUnit();
|
||||||
|
ui->listTransactions->update();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ namespace Ui {
|
|||||||
class OverviewPage;
|
class OverviewPage;
|
||||||
}
|
}
|
||||||
class WalletModel;
|
class WalletModel;
|
||||||
|
class TxViewDelegate;
|
||||||
|
|
||||||
class OverviewPage : public QWidget
|
class OverviewPage : public QWidget
|
||||||
{
|
{
|
||||||
@ -28,6 +29,8 @@ private:
|
|||||||
qint64 currentBalance;
|
qint64 currentBalance;
|
||||||
qint64 currentUnconfirmedBalance;
|
qint64 currentUnconfirmedBalance;
|
||||||
|
|
||||||
|
TxViewDelegate *txdelegate;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void displayUnitChanged();
|
void displayUnitChanged();
|
||||||
};
|
};
|
||||||
|
Before Width: | Height: | Size: 631 B After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 754 B After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 2.1 KiB |
@ -15,7 +15,8 @@ TransactionFilterProxy::TransactionFilterProxy(QObject *parent) :
|
|||||||
dateTo(MAX_DATE),
|
dateTo(MAX_DATE),
|
||||||
addrPrefix(),
|
addrPrefix(),
|
||||||
typeFilter(ALL_TYPES),
|
typeFilter(ALL_TYPES),
|
||||||
minAmount(0)
|
minAmount(0),
|
||||||
|
limitRows(-1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,3 +66,20 @@ void TransactionFilterProxy::setMinAmount(qint64 minimum)
|
|||||||
this->minAmount = minimum;
|
this->minAmount = minimum;
|
||||||
invalidateFilter();
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -26,6 +26,10 @@ public:
|
|||||||
void setTypeFilter(quint32 modes);
|
void setTypeFilter(quint32 modes);
|
||||||
void setMinAmount(qint64 minimum);
|
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:
|
protected:
|
||||||
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
|
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
|
||||||
|
|
||||||
@ -35,6 +39,7 @@ private:
|
|||||||
QString addrPrefix;
|
QString addrPrefix;
|
||||||
quint32 typeFilter;
|
quint32 typeFilter;
|
||||||
qint64 minAmount;
|
qint64 minAmount;
|
||||||
|
int limitRows;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -578,6 +578,10 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const
|
|||||||
{
|
{
|
||||||
return llabs(rec->credit + rec->debit);
|
return llabs(rec->credit + rec->debit);
|
||||||
}
|
}
|
||||||
|
else if (role == AmountRole)
|
||||||
|
{
|
||||||
|
return rec->credit + rec->debit;
|
||||||
|
}
|
||||||
else if (role == TxIDRole)
|
else if (role == TxIDRole)
|
||||||
{
|
{
|
||||||
return QString::fromStdString(rec->getTxID());
|
return QString::fromStdString(rec->getTxID());
|
||||||
|
@ -39,6 +39,8 @@ public:
|
|||||||
LabelRole,
|
LabelRole,
|
||||||
// Absolute net amount of transaction, for filtering
|
// Absolute net amount of transaction, for filtering
|
||||||
AbsoluteAmountRole,
|
AbsoluteAmountRole,
|
||||||
|
// Net amount of transaction
|
||||||
|
AmountRole,
|
||||||
// Unique identifier
|
// Unique identifier
|
||||||
TxIDRole,
|
TxIDRole,
|
||||||
// Is transaction confirmed?
|
// Is transaction confirmed?
|
||||||
|