1 #include "clientmodel.h"
2 #include "guiconstants.h"
3 #include "optionsmodel.h"
4 #include "addresstablemodel.h"
5 #include "transactiontablemodel.h"
11 ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
12 QObject(parent), optionsModel(optionsModel),
13 cachedNumConnections(0), cachedNumBlocks(0)
15 numBlocksAtStartup = -1;
18 int ClientModel::getNumConnections() const
23 int ClientModel::getNumBlocks() const
28 int ClientModel::getNumBlocksAtStartup()
30 if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks();
31 return numBlocksAtStartup;
34 QDateTime ClientModel::getLastBlockDate() const
36 return QDateTime::fromTime_t(pindexBest->GetBlockTime());
39 void ClientModel::update()
41 int newNumConnections = getNumConnections();
42 int newNumBlocks = getNumBlocks();
43 QString newStatusBar = getStatusBarWarnings();
45 if(cachedNumConnections != newNumConnections)
46 emit numConnectionsChanged(newNumConnections);
47 if(cachedNumBlocks != newNumBlocks || cachedStatusBar != newStatusBar)
49 // Simply emit a numBlocksChanged for now in case the status message changes,
50 // so that the view updates the status bar.
51 // TODO: It should send a notification.
52 // (However, this might generate looped notifications and needs to be thought through and tested carefully)
53 // error(tr("Network Alert"), newStatusBar);
54 emit numBlocksChanged(newNumBlocks);
57 cachedNumConnections = newNumConnections;
58 cachedNumBlocks = newNumBlocks;
59 cachedStatusBar = newStatusBar;
62 bool ClientModel::isTestNet() const
67 bool ClientModel::inInitialBlockDownload() const
69 return IsInitialBlockDownload();
72 int ClientModel::getNumBlocksOfPeers() const
74 return GetNumBlocksOfPeers();
77 QString ClientModel::getStatusBarWarnings() const
79 return QString::fromStdString(GetWarnings("statusbar"));
82 OptionsModel *ClientModel::getOptionsModel()
87 QString ClientModel::formatFullVersion() const
89 return QString::fromStdString(FormatFullVersion());
92 QString ClientModel::formatBuildDate() const
94 return QString::fromStdString(CLIENT_DATE);