From 02786d0524f0cdf3e46dfa228cf88d3beb131e6b Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 18 Feb 2010 22:30:36 +0000 Subject: [PATCH] restored proper display of source chunks git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2360 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/DLListDelegate.cpp | 36 +++++++++++--------- retroshare-gui/src/gui/TransfersDialog.cpp | 39 ++++++---------------- retroshare-gui/src/gui/TransfersDialog.h | 2 +- 3 files changed, 31 insertions(+), 46 deletions(-) diff --git a/retroshare-gui/src/gui/DLListDelegate.cpp b/retroshare-gui/src/gui/DLListDelegate.cpp index 269e7c6d9..39c225114 100644 --- a/retroshare-gui/src/gui/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/DLListDelegate.cpp @@ -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()).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() ; - 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;idrawText(option.rect, Qt::AlignCenter, newopt.text); break; diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index 74f4b8336..8fb172d29 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -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_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