mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
- implemented a visualisation for currently handled chunks, availability maps, and transfer info
- implemented transfer protocol for chunk availability maps between peers (not enabled yet though) - suppressed rsiface directory from retroshare-gui - moved notifyqt.{h,cpp} to gui/ next moves: - send availability maps to clients; - connect turtle search to unfinished files; - test multisource download with unfinished files. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1939 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1a86871556
commit
f4a2eaecce
19 changed files with 622 additions and 747 deletions
|
@ -20,11 +20,23 @@
|
|||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <math.h>
|
||||
#include <QStylePainter>
|
||||
#include <QDebug>
|
||||
#include <rsiface/rsfiles.h>
|
||||
#include <rsiface/rstypes.h>
|
||||
#include "FileTransferInfoWidget.h"
|
||||
|
||||
// Variables to decide of display behaviour. Should be adapted to window size.
|
||||
//
|
||||
static const int chunk_square_size = 13 ;
|
||||
static const int text_height = 10 ; // should be set according to the font size
|
||||
static const int block_sep = 3 ; // separator between blocks
|
||||
static const int ch_num_size = 50 ; // size of field for chunk number
|
||||
static const int availability_map_size_X = 400 ;// length of availability bar
|
||||
static const int availability_map_size_Y = 20 ; // height of availability bar
|
||||
static const int tab_size = 200 ;// size between tabulated entries
|
||||
|
||||
FileTransferInfoWidget::FileTransferInfoWidget(QWidget * parent, Qt::WFlags f )
|
||||
{
|
||||
QRect TaskGraphRect = geometry();
|
||||
|
@ -63,10 +75,10 @@ void FileTransferInfoWidget::updateDisplay()
|
|||
uint32_t blockSize = info.chunk_size ;
|
||||
int blocks = info.chunks.size() ;
|
||||
|
||||
int columns = maxWidth/13;
|
||||
y = blocks/columns*13;
|
||||
x = blocks%columns*13;
|
||||
maxHeight = y+15;
|
||||
int columns = maxWidth/chunk_square_size;
|
||||
y = blocks/columns*chunk_square_size;
|
||||
x = blocks%columns*chunk_square_size;
|
||||
maxHeight = y+150+info.active_chunks.size()*(block_sep+text_height); // warning: this should be computed from the different size parameter and the number of objects drawn, otherwise the last objects to be displayed will be truncated.
|
||||
pixmap = QPixmap(size());
|
||||
pixmap.fill(this, 0, 0);
|
||||
pixmap = QPixmap(maxWidth, maxHeight);
|
||||
|
@ -101,12 +113,19 @@ void FileTransferInfoWidget::draw(const FileChunksInfo& info,QPainter *painter)
|
|||
if (fileSize%blockSize == 0) blocks--;
|
||||
QRectF source(0.0, 0.0, 12.0, 12.0);
|
||||
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
y += text_height ;
|
||||
painter->drawText(0,y,tr("Chunk map:")) ;
|
||||
y += block_sep ;
|
||||
|
||||
// draw the chunk map
|
||||
//
|
||||
for (int i=0;i<blocks;i++)
|
||||
{
|
||||
if (x > maxWidth - 13)
|
||||
if (x > maxWidth - chunk_square_size)
|
||||
{
|
||||
x = 0;
|
||||
y += 13;
|
||||
y += chunk_square_size;
|
||||
}
|
||||
QRectF target(x, y, 12.0, 12.0);
|
||||
|
||||
|
@ -122,8 +141,88 @@ void FileTransferInfoWidget::draw(const FileChunksInfo& info,QPainter *painter)
|
|||
break ;
|
||||
default: ;
|
||||
}
|
||||
x += 13;
|
||||
x += chunk_square_size;
|
||||
}
|
||||
y += chunk_square_size ;
|
||||
|
||||
// draw the currently downloaded chunks
|
||||
//
|
||||
painter->setPen(QColor::fromRgb(70,70,70)) ;
|
||||
painter->drawLine(0,y,maxWidth,y) ;
|
||||
|
||||
uint32_t sizeX = 100 ;
|
||||
uint32_t sizeY = 10 ;
|
||||
y += block_sep ;
|
||||
y += text_height ;
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
painter->drawText(0,y,tr("Active chunks:")) ;
|
||||
y += block_sep ;
|
||||
|
||||
for(uint i=0;i<info.active_chunks.size();++i)
|
||||
{
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
painter->drawText(5,y+text_height,QString::number(info.active_chunks[i].first)) ;
|
||||
|
||||
uint32_t s = (uint32_t)rint(sizeX*(info.chunk_size - info.active_chunks[i].second)/(float)info.chunk_size) ;
|
||||
|
||||
painter->fillRect(ch_num_size,y,s,sizeY,QColor::fromHsv(200,200,255)) ;
|
||||
painter->fillRect(ch_num_size+s,y,sizeX-s,sizeY,QColor::fromHsv(200,50,255)) ;
|
||||
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
float percent = (info.chunk_size - info.active_chunks[i].second)*100.0/info.chunk_size ;
|
||||
|
||||
painter->drawText(sizeX+55,y+text_height,QString::number(percent,'g',2) + " %") ;
|
||||
|
||||
y += sizeY+block_sep ;
|
||||
}
|
||||
|
||||
// draw the availability map
|
||||
//
|
||||
painter->setPen(QColor::fromRgb(70,70,70)) ;
|
||||
painter->drawLine(0,y,maxWidth,y) ;
|
||||
|
||||
y += block_sep ;
|
||||
y += text_height ;
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" sources")+")") ;
|
||||
y += block_sep ;
|
||||
|
||||
int nb_chunks = info.file_size/info.chunk_size + !(info.file_size % info.chunk_size);
|
||||
|
||||
for(uint i=0;i<availability_map_size_X;++i)
|
||||
{
|
||||
int nb_src = 0 ;
|
||||
int chunk_num = (int)floor(i/float(availability_map_size_X)*(nb_chunks-1)) ;
|
||||
|
||||
for(uint j=0;j<info.compressed_peer_availability_maps.size();++j)
|
||||
nb_src += (bool)(COMPRESSED_MAP_READ(info.compressed_peer_availability_maps[j].second, chunk_num)) ;
|
||||
|
||||
painter->setPen(QColor::fromHsv(200,50*nb_src,200)) ; // the more sources, the more saturated
|
||||
painter->drawLine(i,y,i,y+availability_map_size_Y) ;
|
||||
}
|
||||
|
||||
y += block_sep + availability_map_size_Y ;
|
||||
painter->setPen(QColor::fromRgb(70,70,70)) ;
|
||||
painter->drawLine(0,y,maxWidth,y) ;
|
||||
y += block_sep ;
|
||||
|
||||
// various info:
|
||||
//
|
||||
|
||||
painter->setPen(QColor::fromRgb(0,0,0)) ;
|
||||
y += text_height ; painter->drawText(0,y,tr("File info:")) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("File size: ")) ; painter->drawText(tab_size,y,QString::number(info.file_size)) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("Chunk size: ")) ; painter->drawText(tab_size,y,QString::number(info.chunk_size)) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("Number of chunks: ")) ; painter->drawText(tab_size,y,QString::number(info.chunks.size())) ;
|
||||
y += block_sep ;
|
||||
y += text_height ; painter->drawText(20,y,tr("Number of sources: ")) ; painter->drawText(tab_size,y,QString::number(info.compressed_peer_availability_maps.size())) ;
|
||||
y += text_height ;
|
||||
y += block_sep ;
|
||||
|
||||
maxHeight = y+15;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue