mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
corrected issue in display of download/upload progress
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2192 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
163ed040be
commit
c2fdbe177d
@ -150,18 +150,15 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
{
|
||||
// create a xProgressBar
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
xProgressBar progressBar(pinfo.cmap,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||
|
||||
xProgressBar progressBar(pinfo,option.rect, painter); // the 3rd param is the color schema (0 is the default value)
|
||||
if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE)
|
||||
{
|
||||
progressBar.setDisplayText(true); // should display % text?
|
||||
progressBar.setValue(pinfo.progress); // set the progress value
|
||||
progressBar.setColorSchema(0) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
progressBar.setDisplayText(false); // should display % text?
|
||||
progressBar.setValue(pinfo.progress); // set the progress value
|
||||
progressBar.setColorSchema(1) ;
|
||||
}
|
||||
progressBar.setVerticalSpan(1);
|
||||
|
@ -824,12 +824,7 @@ void TransfersDialog::insertTransfers()
|
||||
pinfo.cmap = fcinfo.chunks ;
|
||||
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
||||
pinfo.progress = completed*100.0/info.size ;
|
||||
|
||||
// std::cerr << "Converting fcinfo to compressed chunk map. Chunks=" << fcinfo.chunks.size() << std::endl ;
|
||||
// std::cerr << "map data = " ;
|
||||
// for(uint k=0;k<cmap._map.size();++k)
|
||||
// std::cout << (void*)cmap._map[k] ;
|
||||
// std::cout << std::endl ;
|
||||
pinfo.nb_chunks = fcinfo.chunks.size() ;
|
||||
|
||||
int addedRow = addItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, priority, completed, remaining);
|
||||
|
||||
@ -899,6 +894,7 @@ void TransfersDialog::insertTransfers()
|
||||
pinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
|
||||
pinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId] ;
|
||||
pinfo.progress = 0.0 ; // we don't display completion for sources.
|
||||
pinfo.nb_chunks = fcinfo.chunks.size() ;
|
||||
|
||||
if (!addPeerToItem(addedRow, symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining))
|
||||
continue;
|
||||
@ -951,6 +947,7 @@ void TransfersDialog::insertTransfers()
|
||||
|
||||
FileProgressInfo pinfo ;
|
||||
pinfo.progress = 0.0 ;
|
||||
pinfo.nb_chunks = 0 ;
|
||||
|
||||
addItem("", name, coreId, fileSize, pinfo, dlspeed, sources, status, priority, completed, remaining);
|
||||
|
||||
@ -1036,6 +1033,7 @@ void TransfersDialog::insertTransfers()
|
||||
++nb_chunks ;
|
||||
|
||||
uint32_t filled_chunks = pinfo.cmap.filledChunks(nb_chunks) ;
|
||||
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:nb_chunks ;
|
||||
|
||||
if(filled_chunks > 1)
|
||||
{
|
||||
@ -1087,6 +1085,7 @@ void TransfersDialog::insertTransfers()
|
||||
pinfo.progress = progress ;
|
||||
pinfo.cmap = CompressedChunkMap() ;
|
||||
pinfo.type = FileProgressInfo::DOWNLOAD_LINE ;
|
||||
pinfo.nb_chunks = 0 ;
|
||||
|
||||
addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining);
|
||||
ulCount++;
|
||||
|
@ -130,7 +130,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
|
||||
|
||||
// create a xProgressBar
|
||||
xProgressBar progressBar(pinfo.cmap,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value)
|
||||
xProgressBar progressBar(pinfo,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value)
|
||||
|
||||
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), UNAME).data().toString().toStdString())).suffix();;
|
||||
if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb")
|
||||
@ -139,7 +139,6 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
||||
progressBar.setColorSchema( 8);
|
||||
|
||||
progressBar.setDisplayText(true); // should display % text?
|
||||
progressBar.setValue(pinfo.progress); // set the progress value
|
||||
progressBar.setVerticalSpan(1);
|
||||
progressBar.paint(); // paint the progress bar
|
||||
}
|
||||
|
@ -28,14 +28,13 @@
|
||||
#include <rsiface/rstypes.h>
|
||||
#include "xprogressbar.h"
|
||||
|
||||
xProgressBar::xProgressBar(const CompressedChunkMap& cmap,QRect rect, QPainter *painter, int schemaIndex)
|
||||
: _cmap(cmap)
|
||||
xProgressBar::xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex)
|
||||
: _pinfo(pinfo)
|
||||
{
|
||||
// assign internal data
|
||||
this->schemaIndex = schemaIndex;
|
||||
this->rect = rect;
|
||||
this->painter = painter;
|
||||
this->progressValue = 0.00;
|
||||
// set the progress bar colors
|
||||
setColor();
|
||||
// configure span
|
||||
@ -194,28 +193,28 @@ void xProgressBar::paint()
|
||||
|
||||
painter->setBrush(linearGrad);
|
||||
|
||||
uint32_t ss = _cmap._map.size()*32 ;
|
||||
uint32_t ss = _pinfo.nb_chunks ;
|
||||
|
||||
if(ss > 1) // for small files we use a more progressive display
|
||||
for(int i=0;i<ss;++i)
|
||||
{
|
||||
int j=0 ;
|
||||
while(i+j<ss && _cmap[i+j])
|
||||
++j ;
|
||||
|
||||
if(j>0)
|
||||
for(int i=0;i<ss;++i)
|
||||
{
|
||||
float o = std::min(1.0f,j/(float)ss*width) ;
|
||||
painter->setOpacity(o) ;
|
||||
painter->drawRect(rect.x() + hSpan+(int)rint(i*width/(float)ss), rect.y() + vSpan, (int)ceil(j*width/(float)ss), rect.height() - 1 - vSpan * 2);
|
||||
}
|
||||
int j=0 ;
|
||||
while(i+j<ss && _pinfo.cmap[i+j])
|
||||
++j ;
|
||||
|
||||
i += j ;
|
||||
}
|
||||
if(j>0)
|
||||
{
|
||||
float o = std::min(1.0f,j/(float)ss*width) ;
|
||||
painter->setOpacity(o) ;
|
||||
painter->drawRect(rect.x() + hSpan+(int)rint(i*width/(float)ss), rect.y() + vSpan, (int)ceil(j*width/(float)ss), rect.height() - 1 - vSpan * 2);
|
||||
}
|
||||
|
||||
i += j ;
|
||||
}
|
||||
else
|
||||
{
|
||||
// calculate progress value
|
||||
int preWidth = static_cast<int>((rect.width() - 1 - hSpan)*(progressValue/100));
|
||||
int preWidth = static_cast<int>((rect.width() - 1 - hSpan)*(_pinfo.progress/100));
|
||||
int progressWidth = rect.width() - preWidth;
|
||||
if (progressWidth == rect.width() - hSpan) return;
|
||||
|
||||
@ -231,7 +230,7 @@ void xProgressBar::paint()
|
||||
{
|
||||
QLocale locale;
|
||||
painter->setPen(textColor);
|
||||
painter->drawText(rect, Qt::AlignCenter, locale.toString(progressValue, 'f', 2) + "%");
|
||||
painter->drawText(rect, Qt::AlignCenter, locale.toString(_pinfo.progress, 'f', 2) + "%");
|
||||
}
|
||||
}
|
||||
|
||||
@ -242,11 +241,6 @@ void xProgressBar::setColorSchema(const int value)
|
||||
setColor();
|
||||
}
|
||||
|
||||
void xProgressBar::setValue(const float value)
|
||||
{
|
||||
progressValue = value < 0 ? 0 : value > 100 ? 100 : value;
|
||||
}
|
||||
|
||||
void xProgressBar::setDisplayText(const bool display)
|
||||
{
|
||||
displayText = display;
|
||||
|
@ -44,6 +44,7 @@ class FileProgressInfo
|
||||
LineType type ;
|
||||
CompressedChunkMap cmap ;
|
||||
float progress ;
|
||||
uint32_t nb_chunks ;
|
||||
};
|
||||
//
|
||||
class xProgressBar : public QObject
|
||||
@ -51,7 +52,7 @@ class xProgressBar : public QObject
|
||||
Q_OBJECT
|
||||
private:
|
||||
// progress vlues
|
||||
float progressValue;
|
||||
uint32_t _nb_chunks ;
|
||||
int schemaIndex;
|
||||
bool displayText;
|
||||
int vSpan;
|
||||
@ -70,13 +71,13 @@ Q_OBJECT
|
||||
// configure the color
|
||||
void setColor();
|
||||
|
||||
const CompressedChunkMap& _cmap ;
|
||||
const FileProgressInfo& _pinfo ;
|
||||
public:
|
||||
xProgressBar(const CompressedChunkMap& cmap,QRect rect, QPainter *painter, int schemaIndex = 0);
|
||||
xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex = 0);
|
||||
|
||||
void paint();
|
||||
|
||||
void setColorSchema(const int value);
|
||||
void setValue(const float value);
|
||||
void setDisplayText(const bool display);
|
||||
void setVerticalSpan(const int value);
|
||||
void setHorizontalSpan(const int value);
|
||||
|
Loading…
Reference in New Issue
Block a user