restored proper display of source chunks

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2360 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-02-18 22:30:36 +00:00
parent dcb130281e
commit 02786d0524
3 changed files with 31 additions and 46 deletions

View File

@ -67,7 +67,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
// draw the background color if not the progress column or if progress is not displayed
if(index.column() != PROGRESS || ((FileProgressInfo)index.data().value<FileProgressInfo>()).nb_chunks == 0) {
if(index.column() != PROGRESS) {
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
cg = QPalette::Inactive;
@ -154,21 +154,25 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
{
// create a xProgressBar
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
if (pinfo.nb_chunks != 0) {
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.setColorSchema(0) ;
}
else
{
progressBar.setDisplayText(false); // should display % text?
progressBar.setColorSchema(1) ;
}
progressBar.setVerticalSpan(1);
progressBar.paint(); // paint the progress bar
}
// std::cerr << "drawing progress info: nb_chunks = " << pinfo.nb_chunks ;
// for(uint i=0;i<pinfo.cmap._map.size();++i)
// std::cerr << pinfo.cmap._map[i] << " " ;
// std::cerr << std::endl ;
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.setColorSchema(0) ;
}
else
{
progressBar.setDisplayText(false); // should display % text?
progressBar.setColorSchema(1) ;
}
progressBar.setVerticalSpan(1);
progressBar.paint(); // paint the progress bar
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;

View File

@ -72,35 +72,8 @@
#define IMAGE_PRIORITYHIGH ":/images/priorityhigh.png"
#define IMAGE_PRIORITYAUTO ":/images/priorityauto.png"
//static const CompressedChunkMap *getMap_tmp()
//{
// static CompressedChunkMap *cmap = NULL ;
//
// if(cmap == NULL)
// {
// cmap = new CompressedChunkMap ; // to be passed as a parameter
// // Initialize the chunkmap with a dummy value, for testing. To be removed...
// cmap->_nb_chunks = 700 ;
// cmap->_map.resize(cmap->_nb_chunks/32+1,0) ;
// cmap->_progress = 0.34 ;
// for(uint i=0;i<10;++i)
// {
// uint32_t start = rand()%cmap->_nb_chunks;
// uint32_t j = std::min((int)cmap->_nb_chunks,(int)start+10+(rand()%5)) ;
//
// for(uint32_t k=start;k<j;++k)
// COMPRESSED_MAP_WRITE(cmap->_map,k,1) ;
// }
//
// std::cerr << "Built cmap = " << (void*)cmap << std::endl ;
// }
// return cmap ;
//}
Q_DECLARE_METATYPE(FileProgressInfo)
/** Constructor */
TransfersDialog::TransfersDialog(QWidget *parent)
: RsAutoUpdatePage(1000,parent)
@ -522,7 +495,7 @@ int TransfersDialog::addItem(const QString& symbol, const QString& name, const Q
return row;
}
bool TransfersDialog::addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status, FileProgressInfo peerInfo)
bool TransfersDialog::addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status, const FileProgressInfo& peerInfo)
{
QStandardItem *dlItem = DLListModel->item(row);
if (!dlItem) return false;
@ -583,6 +556,7 @@ bool TransfersDialog::addPeerToItem(int row, const QString& name, const QString&
//just update the child (peer)
dlItem->child(childRow, DLSPEED)->setData(QVariant((double)dlspeed), Qt::DisplayRole);
dlItem->child(childRow, STATUS)->setData(QVariant((QString)status), Qt::DisplayRole);
dlItem->child(childRow, PROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole);
/* set status icon in the name field */
if (status == "Downloading") {
dlItem->child(childRow, NAME)->setData(QIcon(QString::fromUtf8(":/images/Client0.png")), Qt::DecorationRole);
@ -774,11 +748,18 @@ void TransfersDialog::insertTransfers() {
}
FileProgressInfo peerpinfo ;
peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId];
peerpinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ;
peerpinfo.progress = 0.0 ; // we don't display completion for sources.
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:fcinfo.chunks.size();
// std::cerr << std::endl ;
// std::cerr << "Source " << pit->peerId << " as map " << peerpinfo.cmap._map.size() << " compressed chunks" << std::endl ;
// for(uint j=0;j<peerpinfo.cmap._map.size();++j)
// std::cerr << peerpinfo.cmap._map[j] ;
// std::cerr << std::endl ;
// std::cerr << std::endl ;
addPeerToItem(addedRow, peerName, hashFileAndPeerId, peerDlspeed, status, peerpinfo);
}
}

View File

@ -173,7 +173,7 @@ private:
public slots:
int addItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, const QString& priority, qlonglong completed, qlonglong remaining);
bool addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status, FileProgressInfo peerInfo);
bool addPeerToItem(int row, const QString& name, const QString& coreID, double dlspeed, const QString& status, const FileProgressInfo& peerInfo);
void delItem(int row);
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources, const QString& status, qlonglong completed, qlonglong remaining);