]> Git Repo - VerusCoin.git/blame - src/qt/clientmodel.cpp
Display a "freshness" indicator instead of nr of blocks
[VerusCoin.git] / src / qt / clientmodel.cpp
CommitLineData
18cab09a 1#include "clientmodel.h"
63760fa1 2#include "guiconstants.h"
92f20d53 3#include "optionsmodel.h"
2547f1f7 4#include "addresstablemodel.h"
467c31ea 5#include "transactiontablemodel.h"
18cab09a 6
e8ef3da7
WL
7#include "headers.h"
8
18cab09a 9#include <QTimer>
84c8506e 10#include <QDateTime>
18cab09a 11
e8ef3da7 12ClientModel::ClientModel(CWallet *wallet, QObject *parent) :
ef079e18 13 QObject(parent), wallet(wallet), optionsModel(0)
18cab09a 14{
0f3981be
WL
15 // Until signal notifications is built into the bitcoin core,
16 // simply update everything after polling using a timer.
18cab09a
WL
17 QTimer *timer = new QTimer(this);
18 connect(timer, SIGNAL(timeout()), this, SLOT(update()));
19 timer->start(MODEL_UPDATE_DELAY);
92f20d53 20
e8ef3da7 21 optionsModel = new OptionsModel(wallet, this);
18cab09a
WL
22}
23
7df70c00 24int ClientModel::getNumConnections() const
18cab09a
WL
25{
26 return vNodes.size();
27}
28
7df70c00 29int ClientModel::getNumBlocks() const
18cab09a
WL
30{
31 return nBestHeight;
32}
33
84c8506e
WL
34QDateTime ClientModel::getLastBlockDate() const
35{
36 return QDateTime::fromTime_t(pindexBest->GetBlockTime());
37}
38
18cab09a
WL
39void ClientModel::update()
40{
0f3981be 41 // Plainly emit all signals for now. To be more efficient this should check
b9e80983
WL
42 // whether the values actually changed first, although it'd be even better if these
43 // were events coming in from the bitcoin core.
18cab09a
WL
44 emit numConnectionsChanged(getNumConnections());
45 emit numBlocksChanged(getNumBlocks());
6630c1cb
WL
46}
47
d56c6f31
WL
48bool ClientModel::isTestNet() const
49{
50 return fTestNet;
51}
52
7df70c00
WL
53bool ClientModel::inInitialBlockDownload() const
54{
55 return IsInitialBlockDownload();
56}
57
6cab6635
WL
58int ClientModel::getTotalBlocksEstimate() const
59{
60 return GetTotalBlocksEstimate();
61}
62
92f20d53
WL
63OptionsModel *ClientModel::getOptionsModel()
64{
2547f1f7
WL
65 return optionsModel;
66}
67
0052fe7b
WL
68QString ClientModel::formatFullVersion() const
69{
70 return QString::fromStdString(FormatFullVersion());
71}
This page took 0.035976 seconds and 4 git commands to generate.