Permalink
Browse files

Add total to transaction page

Change columns name Address to Address/Label
  • Loading branch information...
Tranz5 committed Sep 26, 2014
1 parent 348e9b1 commit c8ba5b7f3a3ec2f3f1b6b9f8f5d5e393541c5d38
@@ -31,7 +31,9 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime();
QString address = index.data(TransactionTableModel::AddressRole).toString();
QString label = index.data(TransactionTableModel::LabelRole).toString();
qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong());
qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong();
qint64 abs_amount = llabs(amount);
int status = index.data(TransactionTableModel::StatusRole).toInt();
if(!showInactive && (status == TransactionStatus::Conflicted || status == TransactionStatus::NotAccepted))
@@ -42,34 +44,40 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &
return false;
if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive))
return false;
if(amount < minAmount)
if(abs_amount < minAmount)
return false;
totalAmount += amount;
return true;
}
void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime &to)
{
this->dateFrom = from;
this->dateTo = to;
totalAmount = 0;
invalidateFilter();
}
void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix)
{
this->addrPrefix = addrPrefix;
totalAmount = 0;
invalidateFilter();
}
void TransactionFilterProxy::setTypeFilter(quint32 modes)
{
this->typeFilter = modes;
totalAmount = 0;
invalidateFilter();
}
void TransactionFilterProxy::setMinAmount(qint64 minimum)
{
this->minAmount = minimum;
totalAmount = 0;
invalidateFilter();
}
@@ -35,6 +35,8 @@ class TransactionFilterProxy : public QSortFilterProxyModel
void setShowInactive(bool showInactive);
int rowCount(const QModelIndex &parent = QModelIndex()) const;
qint64 getTotalAmount() const { return totalAmount; }
protected:
bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const;
@@ -45,6 +47,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel
quint32 typeFilter;
qint64 minAmount;
int limitRows;
mutable qint64 totalAmount;
bool showInactive;
signals:
@@ -227,7 +227,7 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren
walletModel(parent),
priv(new TransactionTablePriv(wallet, this))
{
columns << QString() << tr("Date") << tr("Type") << tr("Address") << tr("Amount");
columns << QString() << tr("Date") << tr("Type") << tr("Address/Label") << tr("Amount");
priv->refreshWallet();
@@ -194,6 +194,9 @@ void TransactionView::setModel(WalletModel *model)
#endif
transactionView->horizontalHeader()->resizeSection(
TransactionTableModel::Amount, 100);
transactionProxyModel->setMinAmount(0);
updateTotalAmount();
}
}
@@ -202,7 +205,7 @@ void TransactionView::chooseDate(int idx)
if(!transactionProxyModel)
return;
QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false);
enableDateRangeWidget(false);
switch(dateWidget->itemData(idx).toInt())
{
case All:
@@ -239,10 +242,11 @@ void TransactionView::chooseDate(int idx)
TransactionFilterProxy::MAX_DATE);
break;
case Range:
dateRangeWidget->setVisible(true);
enableDateRangeWidget(true);
dateRangeChanged();
break;
}
updateTotalAmount();
}
void TransactionView::chooseType(int idx)
@@ -251,13 +255,17 @@ void TransactionView::chooseType(int idx)
return;
transactionProxyModel->setTypeFilter(
typeWidget->itemData(idx).toInt());
updateTotalAmount();
}
void TransactionView::changedPrefix(const QString &prefix)
{
if(!transactionProxyModel)
return;
transactionProxyModel->setAddressPrefix(prefix);
updateTotalAmount();
}
void TransactionView::changedAmount(const QString &amount)
@@ -273,6 +281,14 @@ void TransactionView::changedAmount(const QString &amount)
{
transactionProxyModel->setMinAmount(0);
}
updateTotalAmount();
}
void TransactionView::updateTotalAmount()
{
QString str = BitcoinUnits::format(BitcoinUnits::BTC, transactionProxyModel->getTotalAmount());
totalAmountWidget->setText(str);
}
void TransactionView::exportClicked()
@@ -404,6 +420,12 @@ void TransactionView::showBroswer()
emit blockBrowserSignal(transactionId);
}
void TransactionView::enableDateRangeWidget(bool enable)
{
dateFrom->setEnabled(enable);
dateTo->setEnabled(enable);
}
QWidget *TransactionView::createDateRangeWidget()
{
dateRangeWidget = new QFrame();
@@ -430,8 +452,14 @@ QWidget *TransactionView::createDateRangeWidget()
layout->addWidget(dateTo);
layout->addStretch();
layout->addWidget(new QLabel(tr("Total:")));
totalAmountWidget = new QLabel(this);
totalAmountWidget->setText("0");
totalAmountWidget->setFixedWidth(100);
layout->addWidget(totalAmountWidget);
// Hide by default
dateRangeWidget->setVisible(false);
enableDateRangeWidget(false);
// Notify on change
connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged()));
@@ -447,6 +475,7 @@ void TransactionView::dateRangeChanged()
transactionProxyModel->setDateRange(
QDateTime(dateFrom->date()),
QDateTime(dateTo->date()).addDays(1));
updateTotalAmount();
}
void TransactionView::focusTransaction(const QModelIndex &idx)
@@ -14,6 +14,7 @@ class QModelIndex;
class QMenu;
class QFrame;
class QDateTimeEdit;
class QLabel;
QT_END_NAMESPACE
/** Widget showing the transaction list for a wallet, including a filter row.
@@ -48,6 +49,8 @@ class TransactionView : public QWidget
QComboBox *typeWidget;
QLineEdit *addressWidget;
QLineEdit *amountWidget;
QLabel *totalAmountWidgetLabel;
QLabel *totalAmountWidget;
QMenu *contextMenu;
@@ -57,6 +60,10 @@ class TransactionView : public QWidget
QWidget *createDateRangeWidget();
private:
void updateTotalAmount();
void enableDateRangeWidget(bool enable);
private slots:
void contextualMenu(const QPoint &);
void dateRangeChanged();

0 comments on commit c8ba5b7

Please sign in to comment.