Make it very clear when on testnet (green icon, add [testnet] to title)
[novacoin.git] / src / qt / clientmodel.cpp
1 #include "clientmodel.h"
2 #include "guiconstants.h"
3 #include "optionsmodel.h"
4 #include "addresstablemodel.h"
5 #include "transactiontablemodel.h"
6
7 #include "headers.h"
8
9 #include <QTimer>
10
11 ClientModel::ClientModel(CWallet *wallet, QObject *parent) :
12     QObject(parent), wallet(wallet), optionsModel(0)
13 {
14     // Until signal notifications is built into the bitcoin core,
15     //  simply update everything after polling using a timer.
16     QTimer *timer = new QTimer(this);
17     connect(timer, SIGNAL(timeout()), this, SLOT(update()));
18     timer->start(MODEL_UPDATE_DELAY);
19
20     optionsModel = new OptionsModel(wallet, this);
21 }
22
23 int ClientModel::getNumConnections() const
24 {
25     return vNodes.size();
26 }
27
28 int ClientModel::getNumBlocks() const
29 {
30     return nBestHeight;
31 }
32
33 void ClientModel::update()
34 {
35     // Plainly emit all signals for now. To be more efficient this should check
36     //   whether the values actually changed first, although it'd be even better if these
37     //   were events coming in from the bitcoin core.
38     emit numConnectionsChanged(getNumConnections());
39     emit numBlocksChanged(getNumBlocks());
40 }
41
42 bool ClientModel::isTestNet() const
43 {
44     return fTestNet;
45 }
46
47 bool ClientModel::inInitialBlockDownload() const
48 {
49     return IsInitialBlockDownload();
50 }
51
52 int ClientModel::getTotalBlocksEstimate() const
53 {
54     return GetTotalBlocksEstimate();
55 }
56
57 OptionsModel *ClientModel::getOptionsModel()
58 {
59     return optionsModel;
60 }
61