2011-07-05 22:09:39 +02:00
|
|
|
#include "overviewpage.h"
|
|
|
|
#include "ui_overviewpage.h"
|
|
|
|
|
2011-07-11 20:42:10 +02:00
|
|
|
#include "walletmodel.h"
|
2011-07-25 21:35:45 +02:00
|
|
|
#include "bitcoinunits.h"
|
2011-07-29 14:36:35 +02:00
|
|
|
#include "optionsmodel.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
2011-07-05 22:09:39 +02:00
|
|
|
|
|
|
|
OverviewPage::OverviewPage(QWidget *parent) :
|
|
|
|
QWidget(parent),
|
2011-07-29 14:36:35 +02:00
|
|
|
ui(new Ui::OverviewPage),
|
|
|
|
currentBalance(-1),
|
|
|
|
currentUnconfirmedBalance(-1)
|
2011-07-05 22:09:39 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
// Balance: <balance>
|
|
|
|
ui->labelBalance->setFont(QFont("Monospace", -1, QFont::Bold));
|
|
|
|
ui->labelBalance->setToolTip(tr("Your current balance"));
|
|
|
|
ui->labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
|
|
|
|
|
2011-07-11 20:42:10 +02:00
|
|
|
// Balance: <balance>
|
|
|
|
ui->labelUnconfirmed->setFont(QFont("Monospace", -1, QFont::Bold));
|
|
|
|
ui->labelUnconfirmed->setToolTip(tr("Balance of transactions that have yet to be confirmed"));
|
|
|
|
ui->labelUnconfirmed->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
|
|
|
|
|
|
|
|
ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet"));
|
|
|
|
|
2011-07-05 22:09:39 +02:00
|
|
|
// Overview page should show:
|
|
|
|
// Last received transaction(s)
|
|
|
|
// Last sent transaction(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
OverviewPage::~OverviewPage()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2011-07-11 20:42:10 +02:00
|
|
|
void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance)
|
2011-07-05 22:09:39 +02:00
|
|
|
{
|
2011-07-29 14:36:35 +02:00
|
|
|
int unit = model->getOptionsModel()->getDisplayUnit();
|
|
|
|
currentBalance = balance;
|
|
|
|
currentUnconfirmedBalance = unconfirmedBalance;
|
|
|
|
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
|
|
|
|
ui->labelUnconfirmed->setText(BitcoinUnits::formatWithUnit(unit, unconfirmedBalance));
|
2011-07-05 22:09:39 +02:00
|
|
|
}
|
2011-07-07 10:59:00 +02:00
|
|
|
|
|
|
|
void OverviewPage::setNumTransactions(int count)
|
|
|
|
{
|
|
|
|
ui->labelNumTransactions->setText(QLocale::system().toString(count));
|
|
|
|
}
|
2011-07-11 20:42:10 +02:00
|
|
|
|
|
|
|
void OverviewPage::setModel(WalletModel *model)
|
|
|
|
{
|
|
|
|
this->model = model;
|
|
|
|
|
|
|
|
// Keep up to date with wallet
|
|
|
|
setBalance(model->getBalance(), model->getUnconfirmedBalance());
|
2011-07-14 21:21:17 +02:00
|
|
|
connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64)));
|
2011-07-11 20:42:10 +02:00
|
|
|
|
|
|
|
setNumTransactions(model->getNumTransactions());
|
|
|
|
connect(model, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int)));
|
|
|
|
|
2011-07-29 14:36:35 +02:00
|
|
|
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(displayUnitChanged()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OverviewPage::displayUnitChanged()
|
|
|
|
{
|
|
|
|
if(currentBalance != -1)
|
|
|
|
setBalance(currentBalance, currentUnconfirmedBalance);
|
2011-07-11 20:42:10 +02:00
|
|
|
}
|