mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-24 08:50:10 -05:00
Fixed sort of uploads and downloads by progress.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3603 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
22b74c8e63
commit
26491f4b73
@ -71,6 +71,22 @@ Q_DECLARE_METATYPE(FileProgressInfo)
|
|||||||
|
|
||||||
DetailsDialog *TransfersDialog::detailsdlg = NULL;
|
DetailsDialog *TransfersDialog::detailsdlg = NULL;
|
||||||
|
|
||||||
|
class ProgressItem : public QStandardItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressItem() : QStandardItem() {}
|
||||||
|
|
||||||
|
virtual bool operator<(const QStandardItem &other) const
|
||||||
|
{
|
||||||
|
const int role = model() ? model()->sortRole() : Qt::DisplayRole;
|
||||||
|
|
||||||
|
FileProgressInfo l = data(role).value<FileProgressInfo>();
|
||||||
|
FileProgressInfo r = other.data(role).value<FileProgressInfo>();
|
||||||
|
|
||||||
|
return l < r;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
TransfersDialog::TransfersDialog(QWidget *parent)
|
TransfersDialog::TransfersDialog(QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent)
|
: RsAutoUpdatePage(1000,parent)
|
||||||
@ -139,11 +155,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
_header->resizeSection ( PRIORITY, 100 );
|
_header->resizeSection ( PRIORITY, 100 );
|
||||||
_header->resizeSection ( REMAINING, 100 );
|
_header->resizeSection ( REMAINING, 100 );
|
||||||
|
|
||||||
connect(_header, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorDwl(int, Qt::SortOrder)));
|
|
||||||
|
|
||||||
// set default column and sort order for download
|
// set default column and sort order for download
|
||||||
_sortColDwl = 0;
|
ui.downloadList->sortByColumn(NAME, Qt::AscendingOrder);
|
||||||
_sortOrderDwl = Qt::AscendingOrder;
|
|
||||||
|
|
||||||
// Set Upload list model
|
// Set Upload list model
|
||||||
ULListModel = new QStandardItemModel(0,8);
|
ULListModel = new QStandardItemModel(0,8);
|
||||||
@ -190,11 +203,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
|||||||
upheader->resizeSection ( USTATUS, 100 );
|
upheader->resizeSection ( USTATUS, 100 );
|
||||||
upheader->resizeSection ( USERNAME, 120 );
|
upheader->resizeSection ( USERNAME, 120 );
|
||||||
|
|
||||||
connect(upheader, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSortIndicatorUpl(int, Qt::SortOrder)));
|
|
||||||
|
|
||||||
// set default column and sort order for upload
|
// set default column and sort order for upload
|
||||||
_sortColUpl = 0;
|
ui.uploadsList->sortByColumn(UNAME, Qt::AscendingOrder);
|
||||||
_sortOrderUpl = Qt::AscendingOrder;
|
|
||||||
|
|
||||||
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
|
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
|
||||||
ui.fileTransferInfoWidget->setWidget(ftiw);
|
ui.fileTransferInfoWidget->setWidget(ftiw);
|
||||||
@ -498,6 +508,9 @@ int TransfersDialog::addItem(const QString&, const QString& name, const QString&
|
|||||||
{
|
{
|
||||||
row = rowCount;
|
row = rowCount;
|
||||||
DLListModel->insertRow(row);
|
DLListModel->insertRow(row);
|
||||||
|
|
||||||
|
// change progress column to own class for sorting
|
||||||
|
DLListModel->setItem(row, PROGRESS, new ProgressItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant(name));
|
||||||
@ -578,7 +591,7 @@ int TransfersDialog::addPeerToItem(int row, const QString& name, const QString&
|
|||||||
QStandardItem *i2 = new QStandardItem();
|
QStandardItem *i2 = new QStandardItem();
|
||||||
QStandardItem *i3 = new QStandardItem();
|
QStandardItem *i3 = new QStandardItem();
|
||||||
QStandardItem *i4 = new QStandardItem();
|
QStandardItem *i4 = new QStandardItem();
|
||||||
QStandardItem *i5 = new QStandardItem();
|
QStandardItem *i5 = new ProgressItem();
|
||||||
QStandardItem *i6 = new QStandardItem();
|
QStandardItem *i6 = new QStandardItem();
|
||||||
QStandardItem *i7 = new QStandardItem();
|
QStandardItem *i7 = new QStandardItem();
|
||||||
QStandardItem *i8 = new QStandardItem();
|
QStandardItem *i8 = new QStandardItem();
|
||||||
@ -676,6 +689,9 @@ int TransfersDialog::addUploadItem( const QString&, const QString& name, const Q
|
|||||||
{
|
{
|
||||||
row = ULListModel->rowCount();
|
row = ULListModel->rowCount();
|
||||||
ULListModel->insertRow(row);
|
ULListModel->insertRow(row);
|
||||||
|
|
||||||
|
// change progress column to own class for sorting
|
||||||
|
ULListModel->setItem(row, UPROGRESS, new ProgressItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole);
|
||||||
@ -714,12 +730,11 @@ void TransfersDialog::updateDisplay()
|
|||||||
|
|
||||||
static void QListDelete (const QList <QStandardItem*> &List)
|
static void QListDelete (const QList <QStandardItem*> &List)
|
||||||
{
|
{
|
||||||
qDeleteAll (List.begin (), List.end ());
|
qDeleteAll (List);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::insertTransfers()
|
void TransfersDialog::insertTransfers()
|
||||||
{
|
{
|
||||||
ui.downloadList->sortByColumn(_sortColDwl, _sortOrderDwl);
|
|
||||||
/* disable for performance issues, enable after insert all transfers */
|
/* disable for performance issues, enable after insert all transfers */
|
||||||
ui.downloadList->setSortingEnabled(false);
|
ui.downloadList->setSortingEnabled(false);
|
||||||
|
|
||||||
@ -869,7 +884,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
ui.downloadList->setSortingEnabled(true);
|
ui.downloadList->setSortingEnabled(true);
|
||||||
|
|
||||||
ui.uploadsList->sortByColumn(_sortColUpl, _sortOrderUpl);
|
ui.uploadsList->setSortingEnabled(false);
|
||||||
|
|
||||||
// Now show upload hashes
|
// Now show upload hashes
|
||||||
//
|
//
|
||||||
@ -962,7 +977,7 @@ void TransfersDialog::insertTransfers()
|
|||||||
removeIndex++;
|
removeIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.uploadsList->setSortingEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TransfersDialog::getPeerName(const std::string& id) const
|
QString TransfersDialog::getPeerName(const std::string& id) const
|
||||||
@ -1461,17 +1476,6 @@ void TransfersDialog::clearcompleted()
|
|||||||
rsFiles->FileClearCompleted();
|
rsFiles->FileClearCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransfersDialog::saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order)
|
|
||||||
{
|
|
||||||
_sortColDwl = logicalIndex;;
|
|
||||||
_sortOrderDwl = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TransfersDialog::saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order)
|
|
||||||
{
|
|
||||||
_sortColUpl = logicalIndex;;
|
|
||||||
_sortOrderUpl = order;
|
|
||||||
}
|
|
||||||
void TransfersDialog::showFileDetails()
|
void TransfersDialog::showFileDetails()
|
||||||
{
|
{
|
||||||
std::string file_hash ;
|
std::string file_hash ;
|
||||||
|
@ -98,10 +98,6 @@ private slots:
|
|||||||
void chunkRandom();
|
void chunkRandom();
|
||||||
void chunkStreaming();
|
void chunkStreaming();
|
||||||
|
|
||||||
/** save sort indicators for next transfers display */
|
|
||||||
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
|
|
||||||
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
|
|
||||||
|
|
||||||
void showDetailsDialog();
|
void showDetailsDialog();
|
||||||
void updateDetailsDialog();
|
void updateDetailsDialog();
|
||||||
|
|
||||||
@ -120,9 +116,6 @@ private:
|
|||||||
DLListDelegate *DLDelegate;
|
DLListDelegate *DLDelegate;
|
||||||
ULListDelegate *ULDelegate;
|
ULListDelegate *ULDelegate;
|
||||||
|
|
||||||
int _sortColDwl, _sortColUpl;
|
|
||||||
Qt::SortOrder _sortOrderDwl, _sortOrderUpl;
|
|
||||||
|
|
||||||
/** Create the actions on the tray menu or menubar */
|
/** Create the actions on the tray menu or menubar */
|
||||||
void createActions();
|
void createActions();
|
||||||
|
|
||||||
|
@ -28,6 +28,11 @@
|
|||||||
#include <retroshare/rstypes.h>
|
#include <retroshare/rstypes.h>
|
||||||
#include "xprogressbar.h"
|
#include "xprogressbar.h"
|
||||||
|
|
||||||
|
bool FileProgressInfo::operator<(const FileProgressInfo &other) const
|
||||||
|
{
|
||||||
|
return progress < other.progress;
|
||||||
|
}
|
||||||
|
|
||||||
xProgressBar::xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex)
|
xProgressBar::xProgressBar(const FileProgressInfo& pinfo,QRect rect, QPainter *painter, int schemaIndex)
|
||||||
: _pinfo(pinfo)
|
: _pinfo(pinfo)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,8 @@ class FileProgressInfo
|
|||||||
CompressedChunkMap cmap ;
|
CompressedChunkMap cmap ;
|
||||||
float progress ;
|
float progress ;
|
||||||
uint32_t nb_chunks ;
|
uint32_t nb_chunks ;
|
||||||
|
|
||||||
|
bool operator<(const FileProgressInfo &other) const;
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
class xProgressBar : public QObject
|
class xProgressBar : public QObject
|
||||||
|
Loading…
x
Reference in New Issue
Block a user