aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJanne Pulkkinen <jannepulk@gmail.com>2011-09-10 12:43:45 +0300
committerWladimir J. van der Laan <laanwj@gmail.com>2011-09-11 10:29:29 +0200
commit78b3bf56f7804f3eb1b7cf8b189c5d567be7ca60 (patch)
tree92bce2d9cd303d04a05b0e3ed97d65ec12e1a32d /src
parent9b9e2f1748c8d6df4ecf7a8710bf8dadb3e200aa (diff)
The synchronization progress bar now compares the amount of total blocks to amount of blocks downloaded at application start-up. Could be probably implemented better.
Diffstat (limited to 'src')
-rw-r--r--src/qt/bitcoingui.cpp5
-rw-r--r--src/qt/clientmodel.cpp8
-rw-r--r--src/qt/clientmodel.h3
3 files changed, 14 insertions, 2 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index 0c9f778ff6..7943684eef 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -345,6 +345,7 @@ void BitcoinGUI::setNumConnections(int count)
void BitcoinGUI::setNumBlocks(int count)
{
+ int initTotal = clientModel->getNumBlocksAtStartup();
int total = clientModel->getTotalBlocksEstimate();
QString tooltip;
@@ -352,8 +353,8 @@ void BitcoinGUI::setNumBlocks(int count)
{
progressBarLabel->setVisible(true);
progressBar->setVisible(true);
- progressBar->setMaximum(total);
- progressBar->setValue(count);
+ progressBar->setMaximum(total - initTotal);
+ progressBar->setValue(count - initTotal);
tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
}
else
diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp
index d307473102..08abaa6b49 100644
--- a/src/qt/clientmodel.cpp
+++ b/src/qt/clientmodel.cpp
@@ -18,6 +18,8 @@ ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) :
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(MODEL_UPDATE_DELAY);
+
+ numBlocksAtStartup = -1;
}
int ClientModel::getNumConnections() const
@@ -30,6 +32,12 @@ int ClientModel::getNumBlocks() const
return nBestHeight;
}
+int ClientModel::getNumBlocksAtStartup()
+{
+ if (numBlocksAtStartup == -1) numBlocksAtStartup = getNumBlocks();
+ return numBlocksAtStartup;
+}
+
QDateTime ClientModel::getLastBlockDate() const
{
return QDateTime::fromTime_t(pindexBest->GetBlockTime());
diff --git a/src/qt/clientmodel.h b/src/qt/clientmodel.h
index 15387056c8..8605fb93ab 100644
--- a/src/qt/clientmodel.h
+++ b/src/qt/clientmodel.h
@@ -23,6 +23,7 @@ public:
int getNumConnections() const;
int getNumBlocks() const;
+ int getNumBlocksAtStartup();
QDateTime getLastBlockDate() const;
@@ -41,6 +42,8 @@ private:
int cachedNumConnections;
int cachedNumBlocks;
+ int numBlocksAtStartup;
+
signals:
void numConnectionsChanged(int count);
void numBlocksChanged(int count);