]> Git Repo - VerusCoin.git/blame - src/qt/clientmodel.cpp
Merge branch 'bugfix_CNBerr_daggy' into bugfix_CNBerr
[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
ee014e5b
WL
12ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
13 QObject(parent), optionsModel(optionsModel),
5df0b03c 14 cachedNumConnections(0), cachedNumBlocks(0)
18cab09a 15{
0f3981be
WL
16 // Until signal notifications is built into the bitcoin core,
17 // simply update everything after polling using a timer.
18cab09a
WL
18 QTimer *timer = new QTimer(this);
19 connect(timer, SIGNAL(timeout()), this, SLOT(update()));
20 timer->start(MODEL_UPDATE_DELAY);
78b3bf56
JP
21
22 numBlocksAtStartup = -1;
18cab09a
WL
23}
24
7df70c00 25int ClientModel::getNumConnections() const
18cab09a
WL
26{
27 return vNodes.size();
28}
29
7df70c00 30int ClientModel::getNumBlocks() const
18cab09a
WL
31{
32 return nBestHeight;
33}
34
78b3bf56
JP
35int ClientModel::getNumBlocksAtStartup()
36{
37 if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks();
38 return numBlocksAtStartup;
39}
40
84c8506e
WL
41QDateTime ClientModel::getLastBlockDate() const
42{
43 return QDateTime::fromTime_t(pindexBest->GetBlockTime());
44}
45
18cab09a
WL
46void ClientModel::update()
47{
5df0b03c
WL
48 int newNumConnections = getNumConnections();
49 int newNumBlocks = getNumBlocks();
50
51 if(cachedNumConnections != newNumConnections)
52 emit numConnectionsChanged(newNumConnections);
53 if(cachedNumBlocks != newNumBlocks)
54 emit numBlocksChanged(newNumBlocks);
55
56 cachedNumConnections = newNumConnections;
57 cachedNumBlocks = newNumBlocks;
6630c1cb
WL
58}
59
d56c6f31
WL
60bool ClientModel::isTestNet() const
61{
62 return fTestNet;
63}
64
7df70c00
WL
65bool ClientModel::inInitialBlockDownload() const
66{
67 return IsInitialBlockDownload();
68}
69
d33cc2b5 70int ClientModel::getNumBlocksOfPeers() const
6cab6635 71{
d33cc2b5 72 return GetNumBlocksOfPeers();
6cab6635
WL
73}
74
92f20d53
WL
75OptionsModel *ClientModel::getOptionsModel()
76{
2547f1f7
WL
77 return optionsModel;
78}
79
0052fe7b
WL
80QString ClientModel::formatFullVersion() const
81{
82 return QString::fromStdString(FormatFullVersion());
83}
This page took 0.05516 seconds and 4 git commands to generate.