From f1b7a3eee5ac630be3a91e79589c5d6bea0fa45e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 16 Dec 2012 16:10:43 +0000 Subject: [PATCH] fixed display of ongoing chunks git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5994 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/xprogressbar.cpp | 61 ++++++++++++++----------- retroshare-gui/src/gui/xprogressbar.h | 1 + 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/xprogressbar.cpp b/retroshare-gui/src/gui/xprogressbar.cpp index 822c724bb..be5512b5b 100644 --- a/retroshare-gui/src/gui/xprogressbar.cpp +++ b/retroshare-gui/src/gui/xprogressbar.cpp @@ -184,6 +184,39 @@ void xProgressBar::setColor() } } +void xProgressBar::overPaintSelectedChunks(const std::vector& chunks,const QColor& gradColor_a1,const QColor& gradColor_a2, int width,uint32_t ss) const +{ + QLinearGradient linearGrad(rect.x(), rect.y(), rect.x(), rect.y() + rect.height() - 1); + + linearGrad.setColorAt(0.00, gradColor_a1); + linearGrad.setColorAt(0.16, gradColor_a2); + linearGrad.setColorAt(1.00, gradColor_a1); + + painter->setBrush(linearGrad); + + std::cerr << "painting chunks: " ; + for(uint32_t i=0;i chunks[i-1]+1) + { + int nb_consecutive_chunks = chunks[i-1] - last_i + 1 ; + + painter->drawRect(rect.x() + hSpan+(int)rint(last_i*width/(float)ss), rect.y() + vSpan, (int)ceil(nb_consecutive_chunks*width/(float)ss), rect.height() - 1 - vSpan * 2); + last_i = chunks[i] ; + } + int nb_consecutive_chunks = chunks.back() - last_i + 1 ; + painter->drawRect(rect.x() + hSpan+(int)rint(last_i*width/(float)ss), rect.y() + vSpan, (int)ceil(nb_consecutive_chunks*width/(float)ss), rect.height() - 1 - vSpan * 2); +} + void xProgressBar::paint() { // paint the progressBar background @@ -225,32 +258,8 @@ void xProgressBar::paint() i += j ; } - { - QColor gradColor_a1, gradColor_a2 ; - gradColor_a1.setRgb(170, 20, 9); - gradColor_a2.setRgb(223, 121,123); - linearGrad.setColorAt(0.00, gradColor_a1); - linearGrad.setColorAt(0.16, gradColor_a2); - linearGrad.setColorAt(1.00, gradColor_a1); - painter->setBrush(linearGrad); - - for(uint32_t i=0;i<_pinfo.chunks_in_progress.size();++i) - painter->drawRect(rect.x() + hSpan+(int)rint(_pinfo.chunks_in_progress[i]*width/(float)ss), rect.y() + vSpan, (int)ceil(1.0f*width/(float)ss), rect.height() - 1 - vSpan * 2); - } - - { - - QColor gradColor_a1, gradColor_a2 ; - gradColor_a1.setRgb(186, 143, 0); - gradColor_a2.setRgb(223, 196, 61); - linearGrad.setColorAt(0.00, gradColor_a1); - linearGrad.setColorAt(0.16, gradColor_a2); - linearGrad.setColorAt(1.00, gradColor_a1); - painter->setBrush(linearGrad); - - for(uint32_t i=0;i<_pinfo.chunks_in_checking.size();++i) - painter->drawRect(rect.x() + hSpan+(int)rint(_pinfo.chunks_in_checking[i]*width/(float)ss), rect.y() + vSpan, (int)ceil(1.0f*width/(float)ss), rect.height() - 1 - vSpan * 2); - } + overPaintSelectedChunks( _pinfo.chunks_in_progress , QColor(170, 20,9), QColor(223,121,123), width,ss) ; + overPaintSelectedChunks( _pinfo.chunks_in_checking , QColor(186,143,0), QColor(223,196, 61), width,ss) ; } else { diff --git a/retroshare-gui/src/gui/xprogressbar.h b/retroshare-gui/src/gui/xprogressbar.h index 307e7e1a4..ce576400a 100644 --- a/retroshare-gui/src/gui/xprogressbar.h +++ b/retroshare-gui/src/gui/xprogressbar.h @@ -83,6 +83,7 @@ Q_OBJECT void paint(); + void overPaintSelectedChunks(const std::vector& chunks,const QColor& gradColor_a1,const QColor& gradColor_a2, int width,uint32_t ss) const ; void setColorSchema(const int value); void setDisplayText(const bool display); void setVerticalSpan(const int value);