1 #include "clientmodel.h"
2 #include "guiconstants.h"
3 #include "optionsmodel.h"
4 #include "addresstablemodel.h"
5 #include "transactiontablemodel.h"
12 ClientModel::ClientModel(CWallet *wallet, QObject *parent) :
13 QObject(parent), wallet(wallet), optionsModel(0),
14 cachedNumConnections(0), cachedNumBlocks(0)
16 // Until signal notifications is built into the bitcoin core,
17 // simply update everything after polling using a timer.
18 QTimer *timer = new QTimer(this);
19 connect(timer, SIGNAL(timeout()), this, SLOT(update()));
20 timer->start(MODEL_UPDATE_DELAY);
22 optionsModel = new OptionsModel(wallet, this);
25 int ClientModel::getNumConnections() const
30 int ClientModel::getNumBlocks() const
35 QDateTime ClientModel::getLastBlockDate() const
37 return QDateTime::fromTime_t(pindexBest->GetBlockTime());
40 void ClientModel::update()
42 int newNumConnections = getNumConnections();
43 int newNumBlocks = getNumBlocks();
45 if(cachedNumConnections != newNumConnections)
46 emit numConnectionsChanged(newNumConnections);
47 if(cachedNumBlocks != newNumBlocks)
48 emit numBlocksChanged(newNumBlocks);
50 cachedNumConnections = newNumConnections;
51 cachedNumBlocks = newNumBlocks;
54 bool ClientModel::isTestNet() const
59 bool ClientModel::inInitialBlockDownload() const
61 return IsInitialBlockDownload();
64 int ClientModel::getTotalBlocksEstimate() const
66 return GetTotalBlocksEstimate();
69 OptionsModel *ClientModel::getOptionsModel()
74 QString ClientModel::formatFullVersion() const
76 return QString::fromStdString(FormatFullVersion());