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
This commit is contained in:
csoler 2013-10-06 12:09:36 +00:00
parent f3f7a40ad7
commit 7cd9ca9f09
2 changed files with 16 additions and 3 deletions

View File

@ -27,6 +27,7 @@
#include <QApplication>
#include <QDateTime>
#include <limits>
#include <math.h>
#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;

View File

@ -39,6 +39,7 @@
#include <algorithm>
#include <limits>
#include <math.h>
#include "TransfersDialog.h"
#include <gui/RetroShareLink.h>
@ -1051,8 +1052,8 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::map<s
}
}
QString sources = QString("%1 (%2)").arg(active).arg(fileInfo.peers.size());
DLListModel->setData(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()