diff --git a/retroshare-gui/src/gui/DLListDelegate.cpp b/retroshare-gui/src/gui/DLListDelegate.cpp index d8ca34354..9596d2758 100644 --- a/retroshare-gui/src/gui/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/DLListDelegate.cpp @@ -150,18 +150,15 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti { // create a xProgressBar FileProgressInfo pinfo = index.data().value() ; - 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); diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index 4e27a530c..f1cd08cec 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -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;kpeerId] ; 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++; diff --git a/retroshare-gui/src/gui/ULListDelegate.cpp b/retroshare-gui/src/gui/ULListDelegate.cpp index 79789d7e0..4c51c5b07 100644 --- a/retroshare-gui/src/gui/ULListDelegate.cpp +++ b/retroshare-gui/src/gui/ULListDelegate.cpp @@ -130,7 +130,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti FileProgressInfo pinfo = index.data().value() ; // 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 } diff --git a/retroshare-gui/src/gui/xprogressbar.cpp b/retroshare-gui/src/gui/xprogressbar.cpp index e5c2af495..da4b5cefc 100644 --- a/retroshare-gui/src/gui/xprogressbar.cpp +++ b/retroshare-gui/src/gui/xprogressbar.cpp @@ -28,14 +28,13 @@ #include #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;i0) + for(int i=0;isetOpacity(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+j0) + { + 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((rect.width() - 1 - hSpan)*(progressValue/100)); + int preWidth = static_cast((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; diff --git a/retroshare-gui/src/gui/xprogressbar.h b/retroshare-gui/src/gui/xprogressbar.h index 9f8d5cda4..80ef3c30b 100644 --- a/retroshare-gui/src/gui/xprogressbar.h +++ b/retroshare-gui/src/gui/xprogressbar.h @@ -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);