From 7cd9ca9f097d4e203cecc05f005fb9fdf9dcffb4 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 6 Oct 2013 12:09:36 +0000 Subject: [PATCH] Added proper sorting of DL files according to sources (Patch from Phenom) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6805 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp | 9 +++++++++ .../src/gui/FileTransfer/TransfersDialog.cpp | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp index 71b9774c8..d34a03c92 100644 --- a/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/FileTransfer/DLListDelegate.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "DLListDelegate.h" @@ -186,6 +187,14 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignCenter, newopt.text); break; + case COLUMN_SOURCES: + { + double dblValue = index.data().toDouble(); + + temp = dblValue!=0 ? QString("%1 (%2)").arg((int)dblValue).arg((int)((fmod(dblValue,1)*1000)+0.5)) : ""; + painter->drawText(option.rect, Qt::AlignCenter, temp); + } + break; case COLUMN_DOWNLOADTIME: downloadtime = index.data().toLongLong(); minutes = downloadtime / 60; diff --git a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp index dacaa0782..f0e7bad5d 100644 --- a/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/FileTransfer/TransfersDialog.cpp @@ -39,6 +39,7 @@ #include #include +#include #include "TransfersDialog.h" #include @@ -1051,8 +1052,8 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::mapsetData(DLListModel->index(row, COLUMN_SOURCES), QVariant(sources)); + float fltSources = active + (float)fileInfo.peers.size()/1000; + DLListModel->setData(DLListModel->index(row, COLUMN_SOURCES), fltSources); // This is not optimal, but we deal with a small number of elements. The reverse order is really important, // because rows after the deleted rows change positions ! @@ -2019,7 +2020,10 @@ qlonglong TransfersDialog::getPath(int row, QStandardItemModel *model) QString TransfersDialog::getSources(int row, QStandardItemModel *model) { - return model->data(model->index(row, COLUMN_SOURCES), Qt::DisplayRole).toString(); + double dblValue = model->data(model->index(row, COLUMN_SOURCES), Qt::DisplayRole).toDouble(); + QString temp = QString("%1 (%2)").arg((int)dblValue).arg((int)((fmod(dblValue,1)*1000)+0.5)); + + return temp; } void TransfersDialog::openCollection()