2011-05-22 15:19:43 +00:00
|
|
|
#include "clientmodel.h"
|
2011-05-28 18:32:19 +00:00
|
|
|
#include "guiconstants.h"
|
2011-05-31 20:24:53 +00:00
|
|
|
#include "optionsmodel.h"
|
2011-06-03 19:03:20 +00:00
|
|
|
#include "addresstablemodel.h"
|
2011-06-05 14:03:29 +00:00
|
|
|
#include "transactiontablemodel.h"
|
2011-05-22 15:19:43 +00:00
|
|
|
|
2011-06-26 17:23:24 +00:00
|
|
|
#include "headers.h"
|
|
|
|
|
2011-05-22 15:19:43 +00:00
|
|
|
#include <QTimer>
|
2011-07-08 16:05:10 +00:00
|
|
|
#include <QDateTime>
|
2011-05-22 15:19:43 +00:00
|
|
|
|
2011-06-26 17:23:24 +00:00
|
|
|
ClientModel::ClientModel(CWallet *wallet, QObject *parent) :
|
2011-06-30 16:05:29 +00:00
|
|
|
QObject(parent), wallet(wallet), optionsModel(0)
|
2011-05-22 15:19:43 +00:00
|
|
|
{
|
2011-06-18 09:53:25 +00:00
|
|
|
// Until signal notifications is built into the bitcoin core,
|
|
|
|
// simply update everything after polling using a timer.
|
2011-05-22 15:19:43 +00:00
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
|
|
|
timer->start(MODEL_UPDATE_DELAY);
|
2011-05-31 20:24:53 +00:00
|
|
|
|
2011-06-26 17:23:24 +00:00
|
|
|
optionsModel = new OptionsModel(wallet, this);
|
2011-05-22 15:19:43 +00:00
|
|
|
}
|
|
|
|
|
2011-06-18 11:13:48 +00:00
|
|
|
int ClientModel::getNumConnections() const
|
2011-05-22 15:19:43 +00:00
|
|
|
{
|
|
|
|
return vNodes.size();
|
|
|
|
}
|
|
|
|
|
2011-06-18 11:13:48 +00:00
|
|
|
int ClientModel::getNumBlocks() const
|
2011-05-22 15:19:43 +00:00
|
|
|
{
|
|
|
|
return nBestHeight;
|
|
|
|
}
|
|
|
|
|
2011-07-08 16:05:10 +00:00
|
|
|
QDateTime ClientModel::getLastBlockDate() const
|
|
|
|
{
|
|
|
|
return QDateTime::fromTime_t(pindexBest->GetBlockTime());
|
|
|
|
}
|
|
|
|
|
2011-05-22 15:19:43 +00:00
|
|
|
void ClientModel::update()
|
|
|
|
{
|
2011-06-18 09:53:25 +00:00
|
|
|
// Plainly emit all signals for now. To be more efficient this should check
|
2011-06-21 18:34:43 +00:00
|
|
|
// whether the values actually changed first, although it'd be even better if these
|
|
|
|
// were events coming in from the bitcoin core.
|
2011-05-22 15:19:43 +00:00
|
|
|
emit numConnectionsChanged(getNumConnections());
|
|
|
|
emit numBlocksChanged(getNumBlocks());
|
2011-05-30 18:20:12 +00:00
|
|
|
}
|
|
|
|
|
2011-06-30 17:14:42 +00:00
|
|
|
bool ClientModel::isTestNet() const
|
|
|
|
{
|
|
|
|
return fTestNet;
|
|
|
|
}
|
|
|
|
|
2011-06-18 11:13:48 +00:00
|
|
|
bool ClientModel::inInitialBlockDownload() const
|
|
|
|
{
|
|
|
|
return IsInitialBlockDownload();
|
|
|
|
}
|
|
|
|
|
2011-06-18 19:25:38 +00:00
|
|
|
int ClientModel::getTotalBlocksEstimate() const
|
|
|
|
{
|
|
|
|
return GetTotalBlocksEstimate();
|
|
|
|
}
|
|
|
|
|
2011-05-31 20:24:53 +00:00
|
|
|
OptionsModel *ClientModel::getOptionsModel()
|
|
|
|
{
|
2011-06-03 19:03:20 +00:00
|
|
|
return optionsModel;
|
|
|
|
}
|
|
|
|
|
2011-07-01 15:06:36 +00:00
|
|
|
QString ClientModel::formatFullVersion() const
|
|
|
|
{
|
|
|
|
return QString::fromStdString(FormatFullVersion());
|
|
|
|
}
|