aboutsummaryrefslogtreecommitdiff
path: root/src/qt/clientmodel.cpp
diff options
context:
space:
mode:
authorRoy Badami <[email protected]>2014-07-07 22:06:21 +0100
committerRoy Badami <[email protected]>2014-07-07 22:06:21 +0100
commit96df327834af3b55918adfac9b3f65adfc960b3a (patch)
tree8bd199df46ea6f39f7094c0e7db2185b4d3f5d6d /src/qt/clientmodel.cpp
parentShow bitcoin quantities with full precision, even in the presence of trailing... (diff)
parentMerge pull request #4480 (diff)
downloaddiscoin-96df327834af3b55918adfac9b3f65adfc960b3a.tar.xz
discoin-96df327834af3b55918adfac9b3f65adfc960b3a.zip
Merge remote-tracking branch 'upstream/master'
Conflicts: src/qt/overviewpage.cpp src/qt/transactiondesc.cpp
Diffstat (limited to 'src/qt/clientmodel.cpp')
-rw-r--r--src/qt/clientmodel.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index 3c0564c20..4c21eb559 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -5,6 +5,7 @@
#include "clientmodel.h"
#include "guiconstants.h"
+#include "peertablemodel.h"
#include "alert.h"
#include "chainparams.h"
@@ -22,11 +23,14 @@
static const int64_t nClientStartupTime = GetTime();
ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
- QObject(parent), optionsModel(optionsModel),
- cachedNumBlocks(0), cachedNumBlocksOfPeers(0),
+ QObject(parent),
+ optionsModel(optionsModel),
+ peerTableModel(0),
+ cachedNumBlocks(0),
cachedReindexing(0), cachedImporting(0),
numBlocksAtStartup(-1), pollTimer(0)
{
+ peerTableModel = new PeerTableModel(this);
pollTimer = new QTimer(this);
connect(pollTimer, SIGNAL(timeout()), this, SLOT(updateTimer()));
pollTimer->start(MODEL_UPDATE_DELAY);
@@ -81,7 +85,7 @@ QDateTime ClientModel::getLastBlockDate() const
if (chainActive.Tip())
return QDateTime::fromTime_t(chainActive.Tip()->GetBlockTime());
else
- return QDateTime::fromTime_t(Params().GenesisBlock().nTime); // Genesis block's time of current network
+ return QDateTime::fromTime_t(Params().GenesisBlock().GetBlockTime()); // Genesis block's time of current network
}
double ClientModel::getVerificationProgress() const
@@ -101,19 +105,16 @@ void ClientModel::updateTimer()
// Some quantities (such as number of blocks) change so fast that we don't want to be notified for each change.
// Periodically check and update with a timer.
int newNumBlocks = getNumBlocks();
- int newNumBlocksOfPeers = getNumBlocksOfPeers();
// check for changed number of blocks we have, number of blocks peers claim to have, reindexing state and importing state
- if (cachedNumBlocks != newNumBlocks || cachedNumBlocksOfPeers != newNumBlocksOfPeers ||
+ if (cachedNumBlocks != newNumBlocks ||
cachedReindexing != fReindex || cachedImporting != fImporting)
{
cachedNumBlocks = newNumBlocks;
- cachedNumBlocksOfPeers = newNumBlocksOfPeers;
cachedReindexing = fReindex;
cachedImporting = fImporting;
- // ensure we return the maximum of newNumBlocksOfPeers and newNumBlocks to not create weird displays in the GUI
- emit numBlocksChanged(newNumBlocks, std::max(newNumBlocksOfPeers, newNumBlocks));
+ emit numBlocksChanged(newNumBlocks);
}
emit bytesChanged(getTotalBytesRecv(), getTotalBytesSent());
@@ -141,14 +142,6 @@ void ClientModel::updateAlert(const QString &hash, int status)
emit alertsChanged(getStatusBarWarnings());
}
-QString ClientModel::getNetworkName() const
-{
- QString netname(QString::fromStdString(Params().DataDir()));
- if(netname.isEmpty())
- netname = "main";
- return netname;
-}
-
bool ClientModel::inInitialBlockDownload() const
{
return IsInitialBlockDownload();
@@ -166,11 +159,6 @@ enum BlockSource ClientModel::getBlockSource() const
return BLOCK_SOURCE_NONE;
}
-int ClientModel::getNumBlocksOfPeers() const
-{
- return GetNumBlocksOfPeers();
-}
-
QString ClientModel::getStatusBarWarnings() const
{
return QString::fromStdString(GetWarnings("statusbar"));
@@ -181,6 +169,11 @@ OptionsModel *ClientModel::getOptionsModel()
return optionsModel;
}
+PeerTableModel *ClientModel::getPeerTableModel()
+{
+ return peerTableModel;
+}
+
QString ClientModel::formatFullVersion() const
{
return QString::fromStdString(FormatFullVersion());
@@ -207,6 +200,14 @@ QString ClientModel::formatClientStartupTime() const
}
// Handlers for core signals
+static void ShowProgress(ClientModel *clientmodel, const std::string &title, int nProgress)
+{
+ // emits signal "showProgress"
+ QMetaObject::invokeMethod(clientmodel, "showProgress", Qt::QueuedConnection,
+ Q_ARG(QString, QString::fromStdString(title)),
+ Q_ARG(int, nProgress));
+}
+
static void NotifyBlocksChanged(ClientModel *clientmodel)
{
// This notification is too frequent. Don't trigger a signal.
@@ -231,6 +232,7 @@ static void NotifyAlertChanged(ClientModel *clientmodel, const uint256 &hash, Ch
void ClientModel::subscribeToCoreSignals()
{
// Connect signals to client
+ uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyBlocksChanged.connect(boost::bind(NotifyBlocksChanged, this));
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, _1, _2));
@@ -239,6 +241,7 @@ void ClientModel::subscribeToCoreSignals()
void ClientModel::unsubscribeFromCoreSignals()
{
// Disconnect signals from client
+ uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this, _1, _2));
uiInterface.NotifyBlocksChanged.disconnect(boost::bind(NotifyBlocksChanged, this));
uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsChanged, this, _1));
uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this, _1, _2));