Browse Source

Merge pull request #2501 from Diapolo/progress

rework ClientModel::getBlockSource() + BitcoinGUI::setNumBlocks()
0.8
Wladimir J. van der Laan 12 years ago
parent
commit
dc2de757a4
  1. 30
      src/qt/bitcoingui.cpp
  2. 5
      src/qt/clientmodel.cpp
  3. 4
      src/qt/clientmodel.h

30
src/qt/bitcoingui.cpp

@ -506,31 +506,26 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text) // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
statusBar()->clearMessage(); statusBar()->clearMessage();
// don't show / hide progress bar and its label if we have no connection to the network // Acquire current block source
enum BlockSource blockSource = clientModel ? clientModel->getBlockSource() : BLOCK_SOURCE_NONE; enum BlockSource blockSource = clientModel->getBlockSource();
if (blockSource == BLOCK_SOURCE_NONE || (blockSource == BLOCK_SOURCE_NETWORK && clientModel->getNumConnections() == 0))
{
progressBarLabel->setVisible(false);
progressBar->setVisible(false);
return;
}
QString tooltip;
QString importText;
switch (blockSource) { switch (blockSource) {
case BLOCK_SOURCE_NONE:
case BLOCK_SOURCE_NETWORK: case BLOCK_SOURCE_NETWORK:
importText = tr("Synchronizing with network..."); progressBarLabel->setText(tr("Synchronizing with network..."));
break; break;
case BLOCK_SOURCE_DISK: case BLOCK_SOURCE_DISK:
importText = tr("Importing blocks from disk..."); progressBarLabel->setText(tr("Importing blocks from disk..."));
break; break;
case BLOCK_SOURCE_REINDEX: case BLOCK_SOURCE_REINDEX:
importText = tr("Reindexing blocks on disk..."); progressBarLabel->setText(tr("Reindexing blocks on disk..."));
break;
case BLOCK_SOURCE_NONE:
// Case: not Importing, not Reindexing and no network connection
progressBarLabel->setText(tr("No block source available..."));
break;
} }
QString tooltip;
QDateTime lastBlockDate = clientModel->getLastBlockDate(); QDateTime lastBlockDate = clientModel->getLastBlockDate();
QDateTime currentDate = QDateTime::currentDateTime(); QDateTime currentDate = QDateTime::currentDateTime();
int secs = lastBlockDate.secsTo(currentDate); int secs = lastBlockDate.secsTo(currentDate);
@ -572,7 +567,6 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks)
timeBehindText = tr("%n week(s)","",secs/(7*24*60*60)); timeBehindText = tr("%n week(s)","",secs/(7*24*60*60));
} }
progressBarLabel->setText(importText);
progressBarLabel->setVisible(true); progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText)); progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000); progressBar->setMaximum(1000000000);

5
src/qt/clientmodel.cpp

@ -122,9 +122,12 @@ enum BlockSource ClientModel::getBlockSource() const
{ {
if (fReindex) if (fReindex)
return BLOCK_SOURCE_REINDEX; return BLOCK_SOURCE_REINDEX;
if (fImporting) else if (fImporting)
return BLOCK_SOURCE_DISK; return BLOCK_SOURCE_DISK;
else if (getNumConnections() > 0)
return BLOCK_SOURCE_NETWORK; return BLOCK_SOURCE_NETWORK;
return BLOCK_SOURCE_NONE;
} }
int ClientModel::getNumBlocksOfPeers() const int ClientModel::getNumBlocksOfPeers() const

4
src/qt/clientmodel.h

@ -15,9 +15,9 @@ QT_END_NAMESPACE
enum BlockSource { enum BlockSource {
BLOCK_SOURCE_NONE, BLOCK_SOURCE_NONE,
BLOCK_SOURCE_NETWORK, BLOCK_SOURCE_REINDEX,
BLOCK_SOURCE_DISK, BLOCK_SOURCE_DISK,
BLOCK_SOURCE_REINDEX BLOCK_SOURCE_NETWORK
}; };
/** Model for Bitcoin network client. */ /** Model for Bitcoin network client. */

Loading…
Cancel
Save