From dd8e82f797f0c34a248837013925344aeab2c877 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Fri, 27 May 2011 21:24:17 +0200 Subject: [PATCH] fix balance display, display number of transactions --- gui/include/bitcoingui.h | 2 +- gui/include/clientmodel.h | 4 ++-- gui/include/transactiontablemodel.h | 2 ++ gui/src/bitcoingui.cpp | 12 +++++++----- gui/src/clientmodel.cpp | 9 +++++++-- gui/src/transactiontablemodel.cpp | 6 ++++++ 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/gui/include/bitcoingui.h b/gui/include/bitcoingui.h index 3b722fcc..80c24a37 100644 --- a/gui/include/bitcoingui.h +++ b/gui/include/bitcoingui.h @@ -52,7 +52,7 @@ private: void createTrayIcon(); public slots: - void setBalance(double balance); + void setBalance(qint64 balance); void setAddress(const QString &address); void setNumConnections(int count); void setNumBlocks(int count); diff --git a/gui/include/clientmodel.h b/gui/include/clientmodel.h index fb1a5ede..a5613e34 100644 --- a/gui/include/clientmodel.h +++ b/gui/include/clientmodel.h @@ -9,14 +9,14 @@ class ClientModel : public QObject public: explicit ClientModel(QObject *parent = 0); - double getBalance(); + qint64 getBalance(); QString getAddress(); int getNumConnections(); int getNumBlocks(); int getNumTransactions(); signals: - void balanceChanged(double balance); + void balanceChanged(qint64 balance); void addressChanged(const QString &address); void numConnectionsChanged(int count); void numBlocksChanged(int count); diff --git a/gui/include/transactiontablemodel.h b/gui/include/transactiontablemodel.h index 2ff3b0cb..1ea749d8 100644 --- a/gui/include/transactiontablemodel.h +++ b/gui/include/transactiontablemodel.h @@ -37,6 +37,8 @@ public: QVariant headerData(int section, Qt::Orientation orientation, int role) const; Qt::ItemFlags flags(const QModelIndex &index) const; QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; +public slots: + void updateWallet(); private: QStringList columns; TransactionTableImpl *impl; diff --git a/gui/src/bitcoingui.cpp b/gui/src/bitcoingui.cpp index d7a71fc5..831bef3f 100644 --- a/gui/src/bitcoingui.cpp +++ b/gui/src/bitcoingui.cpp @@ -11,6 +11,8 @@ #include "aboutdialog.h" #include "clientmodel.h" +#include "main.h" + #include #include #include @@ -268,9 +270,9 @@ void BitcoinGUI::copyClipboardClicked() QApplication::clipboard()->setText(address->text()); } -void BitcoinGUI::setBalance(double balance) +void BitcoinGUI::setBalance(qint64 balance) { - labelBalance->setText(QLocale::system().toString(balance, 8)); + labelBalance->setText(QString::fromStdString(FormatMoney(balance))); } void BitcoinGUI::setAddress(const QString &addr) @@ -280,15 +282,15 @@ void BitcoinGUI::setAddress(const QString &addr) void BitcoinGUI::setNumConnections(int count) { - labelConnections->setText(QLocale::system().toString(count)+" "+tr("connections")); + labelConnections->setText(QLocale::system().toString(count)+" "+tr("connections(s)", "", count)); } void BitcoinGUI::setNumBlocks(int count) { - labelBlocks->setText(QLocale::system().toString(count)+" "+tr("blocks")); + labelBlocks->setText(QLocale::system().toString(count)+" "+tr("block(s)", "", count)); } void BitcoinGUI::setNumTransactions(int count) { - labelTransactions->setText(QLocale::system().toString(count)+" "+tr("transactions")); + labelTransactions->setText(QLocale::system().toString(count)+" "+tr("transaction(s)", "", count)); } diff --git a/gui/src/clientmodel.cpp b/gui/src/clientmodel.cpp index 0f191023..cc52df41 100644 --- a/gui/src/clientmodel.cpp +++ b/gui/src/clientmodel.cpp @@ -17,7 +17,7 @@ ClientModel::ClientModel(QObject *parent) : timer->start(MODEL_UPDATE_DELAY); } -double ClientModel::getBalance() +qint64 ClientModel::getBalance() { return GetBalance(); } @@ -45,7 +45,12 @@ int ClientModel::getNumBlocks() int ClientModel::getNumTransactions() { - return 0; + int numTransactions = 0; + CRITICAL_BLOCK(cs_mapWallet) + { + numTransactions = mapWallet.size(); + } + return numTransactions; } void ClientModel::update() diff --git a/gui/src/transactiontablemodel.cpp b/gui/src/transactiontablemodel.cpp index ffc2472f..900cb6da 100644 --- a/gui/src/transactiontablemodel.cpp +++ b/gui/src/transactiontablemodel.cpp @@ -85,6 +85,12 @@ TransactionTableModel::~TransactionTableModel() delete impl; } +void TransactionTableModel::updateWallet() +{ + beginResetModel(); + impl->updateWallet(); + endResetModel(); +} int TransactionTableModel::rowCount(const QModelIndex &parent) const {