mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-08 14:22:31 -04:00
-when a file is downloaded through different peers, all peers are put together
under a single root line. line is click-able, when collapsed it displays all download peers -sources column shows number of peers as online (offline) -name column for root/peer shows filename/peername git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1261 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4694ff22d5
commit
3d37a0c242
2 changed files with 236 additions and 175 deletions
|
@ -80,6 +80,8 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||||
|
|
||||||
ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
ui.downloadList->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
|
||||||
|
ui.downloadList->setRootIsDecorated(true);
|
||||||
|
|
||||||
|
|
||||||
/* Set header resize modes and initial section sizes Downloads TreeView*/
|
/* Set header resize modes and initial section sizes Downloads TreeView*/
|
||||||
QHeaderView * _header = ui.downloadList->header () ;
|
QHeaderView * _header = ui.downloadList->header () ;
|
||||||
|
@ -115,8 +117,11 @@ TransfersDialog::TransfersDialog(QWidget *parent)
|
||||||
ui.uploadsList->setItemDelegate(ULDelegate);
|
ui.uploadsList->setItemDelegate(ULDelegate);
|
||||||
|
|
||||||
ui.uploadsList->setAutoScroll(false) ;
|
ui.uploadsList->setAutoScroll(false) ;
|
||||||
|
|
||||||
ui.uploadsList->setRootIsDecorated(false);
|
ui.uploadsList->setRootIsDecorated(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Selection Setup
|
//Selection Setup
|
||||||
//selection = ui.uploadsList->selectionModel();
|
//selection = ui.uploadsList->selectionModel();
|
||||||
|
|
||||||
|
@ -279,16 +284,51 @@ int TransfersDialog::addItem(QString symbol, QString name, QString coreID, qlong
|
||||||
//DLListModel->setData(DLListModel->index(row, NAME), QVariant((QIcon)icon), Qt::DecorationRole);
|
//DLListModel->setData(DLListModel->index(row, NAME), QVariant((QIcon)icon), Qt::DecorationRole);
|
||||||
DLListModel->setData(DLListModel->index(row, NAME), QVariant((QString)name), Qt::DisplayRole);
|
DLListModel->setData(DLListModel->index(row, NAME), QVariant((QString)name), Qt::DisplayRole);
|
||||||
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)fileSize));
|
DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong)fileSize));
|
||||||
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)progress));
|
DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed));
|
||||||
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)dlspeed));
|
DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)dlspeed));
|
||||||
|
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)progress));
|
||||||
DLListModel->setData(DLListModel->index(row, SOURCES), QVariant((QString)sources));
|
DLListModel->setData(DLListModel->index(row, SOURCES), QVariant((QString)sources));
|
||||||
DLListModel->setData(DLListModel->index(row, STATUS), QVariant((QString)status));
|
DLListModel->setData(DLListModel->index(row, STATUS), QVariant((QString)status));
|
||||||
DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed));
|
|
||||||
DLListModel->setData(DLListModel->index(row, REMAINING), QVariant((qlonglong)remaining));
|
DLListModel->setData(DLListModel->index(row, REMAINING), QVariant((qlonglong)remaining));
|
||||||
DLListModel->setData(DLListModel->index(row, ID), QVariant((QString)coreID));
|
DLListModel->setData(DLListModel->index(row, ID), QVariant((QString)coreID));
|
||||||
|
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TransfersDialog::addPeerToItem(int row, QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining)
|
||||||
|
{
|
||||||
|
QStandardItem *dlItem = DLListModel->item(row);
|
||||||
|
if (!dlItem) return false;
|
||||||
|
|
||||||
|
//set this false if you want to expand on double click
|
||||||
|
dlItem->setEditable(false);
|
||||||
|
|
||||||
|
QList<QStandardItem *> items;
|
||||||
|
QStandardItem *i1 = new QStandardItem(); i1->setData(QVariant((QString)name), Qt::DisplayRole);
|
||||||
|
QStandardItem *i2 = new QStandardItem(); i2->setData(QVariant((qlonglong)fileSize), Qt::DisplayRole);
|
||||||
|
QStandardItem *i3 = new QStandardItem(); i3->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||||
|
QStandardItem *i4 = new QStandardItem(); i4->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
||||||
|
QStandardItem *i5 = new QStandardItem(); i5->setData(QVariant((double)progress), Qt::DisplayRole);
|
||||||
|
QStandardItem *i6 = new QStandardItem(); i6->setData(QVariant((QString)sources), Qt::DisplayRole);
|
||||||
|
QStandardItem *i7 = new QStandardItem(); i7->setData(QVariant((QString)status), Qt::DisplayRole);
|
||||||
|
QStandardItem *i8 = new QStandardItem(); i8->setData(QVariant((qlonglong)remaining), Qt::DisplayRole);
|
||||||
|
QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant((QString)coreID), Qt::DisplayRole);
|
||||||
|
|
||||||
|
items.append(i1);
|
||||||
|
items.append(i2);
|
||||||
|
items.append(i3);
|
||||||
|
items.append(i4);
|
||||||
|
items.append(i5);
|
||||||
|
items.append(i6);
|
||||||
|
items.append(i7);
|
||||||
|
items.append(i8);
|
||||||
|
items.append(i9);
|
||||||
|
|
||||||
|
dlItem->appendRow(items);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int TransfersDialog::addUploadItem(QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining)
|
int TransfersDialog::addUploadItem(QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining)
|
||||||
{
|
{
|
||||||
|
@ -310,6 +350,7 @@ int TransfersDialog::addUploadItem(QString symbol, QString name, QString coreID,
|
||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TransfersDialog::delItem(int row)
|
void TransfersDialog::delItem(int row)
|
||||||
{
|
{
|
||||||
DLListModel->removeRow(row, QModelIndex());
|
DLListModel->removeRow(row, QModelIndex());
|
||||||
|
@ -370,12 +411,37 @@ void TransfersDialog::insertTransfers()
|
||||||
/* get current selection */
|
/* get current selection */
|
||||||
std::list<std::string> selectedIds;
|
std::list<std::string> selectedIds;
|
||||||
|
|
||||||
for(int i = 0; i <= DLListModel->rowCount(); i++) {
|
for (int i = 0; i < DLListModel->rowCount(); i++) {
|
||||||
if(selection->isRowSelected(i, QModelIndex())) {
|
if (selection->isRowSelected(i, QModelIndex())) {
|
||||||
std::string id = getID(i, DLListModel).toStdString();
|
std::string id = getID(i, DLListModel).toStdString();
|
||||||
selectedIds.push_back(id);
|
selectedIds.push_back(id);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
QStandardItem *parent = DLListModel->item(i);
|
||||||
|
//if (!parent) continue;
|
||||||
|
int childs = parent->rowCount();
|
||||||
|
for (int j = 0; j < childs; j++) {
|
||||||
|
QModelIndex parentIndex = DLListModel->indexFromItem(parent);
|
||||||
|
if (selection->isRowSelected(j, parentIndex)) {
|
||||||
|
QStandardItem *child = parent->child(j, ID);
|
||||||
|
std::string id = child->data(Qt::DisplayRole).toString().toStdString();
|
||||||
|
selectedIds.push_back(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* get expanded donwload items */
|
||||||
|
std::list<std::string> expandedIds;
|
||||||
|
|
||||||
|
for (int i = 0; i < DLListModel->rowCount(); i++) {
|
||||||
|
QStandardItem *item = DLListModel->item(i);
|
||||||
|
QModelIndex index = DLListModel->indexFromItem(item);
|
||||||
|
if (ui.downloadList->isExpanded(index)) {
|
||||||
|
std::string id = getID(i, DLListModel).toStdString();
|
||||||
|
expandedIds.push_back(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//remove all Items
|
//remove all Items
|
||||||
for(int i = DLListModel->rowCount(); i >= 0; i--)
|
for(int i = DLListModel->rowCount(); i >= 0; i--)
|
||||||
|
@ -399,121 +465,115 @@ void TransfersDialog::insertTransfers()
|
||||||
uint32_t dlCount = 0;
|
uint32_t dlCount = 0;
|
||||||
uint32_t ulCount = 0;
|
uint32_t ulCount = 0;
|
||||||
|
|
||||||
std::list<std::string>::iterator it;
|
std::list<std::string>::iterator it;
|
||||||
for(it = downHashes.begin(); it != downHashes.end(); it++)
|
for (it = downHashes.begin(); it != downHashes.end(); it++) {
|
||||||
{
|
FileInfo info;
|
||||||
FileInfo info;
|
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) continue;
|
||||||
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info))
|
//if file transfer is a cache file index file, don't show it
|
||||||
{
|
if (info.flags & CB_CODE_CACHE) continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if file transfer is a cache file index file, don't show it
|
symbol = "";
|
||||||
if (info.flags & CB_CODE_CACHE)
|
name = QString::fromStdString(info.fname);
|
||||||
{
|
coreId = QString::fromStdString(info.hash);
|
||||||
continue;
|
fileSize = info.size;
|
||||||
}
|
progress = (info.transfered * 100.0) / info.size;
|
||||||
|
dlspeed = info.tfRate * 1024.0;
|
||||||
|
|
||||||
std::list<TransferInfo>::iterator pit;
|
/* get number of online peers */
|
||||||
for(pit = info.peers.begin(); pit != info.peers.end(); pit++)
|
int online = 0;
|
||||||
{
|
std::list<TransferInfo>::iterator pit;
|
||||||
symbol = "";
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
||||||
coreId = QString::fromStdString(info.hash);
|
if (rsPeers->isOnline(pit->peerId)) {
|
||||||
name = QString::fromStdString(info.fname);
|
online++;
|
||||||
sources = QString::fromStdString(rsPeers->getPeerName(pit->peerId));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch(pit->status)
|
sources = QString("%1 (%2)").arg(online).arg(info.peers.size() - online);
|
||||||
{
|
|
||||||
case FT_STATE_FAILED:
|
|
||||||
status = tr("Failed");
|
|
||||||
break;
|
|
||||||
case FT_STATE_OKAY:
|
|
||||||
status = tr("Okay");
|
|
||||||
break;
|
|
||||||
case FT_STATE_WAITING:
|
|
||||||
status = tr("Waiting");
|
|
||||||
break;
|
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Downloading");
|
|
||||||
break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
default:
|
|
||||||
status = tr("Complete");
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
switch (info.downloadStatus) {
|
||||||
|
case FT_STATE_FAILED:
|
||||||
|
status = tr("Failed"); break;
|
||||||
|
case FT_STATE_OKAY:
|
||||||
|
status = tr("Okay"); break;
|
||||||
|
case FT_STATE_WAITING:
|
||||||
|
status = tr("Waiting"); break;
|
||||||
|
case FT_STATE_DOWNLOADING:
|
||||||
|
status = tr("Downloading"); break;
|
||||||
|
case FT_STATE_COMPLETE:
|
||||||
|
status = tr("Complete"); break;
|
||||||
|
default:
|
||||||
|
status = tr("Unknown"); break;
|
||||||
|
}
|
||||||
|
|
||||||
if (info.downloadStatus == FT_STATE_COMPLETE)
|
completed = info.transfered;
|
||||||
{
|
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
||||||
status = tr("Complete");
|
|
||||||
}
|
|
||||||
|
|
||||||
dlspeed = pit->tfRate * 1024.0;
|
int addedRow = addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining);
|
||||||
fileSize = info.size;
|
|
||||||
completed = info.transfered;
|
|
||||||
progress = info.transfered * 100.0 / info.size;
|
|
||||||
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
|
||||||
|
|
||||||
addItem(symbol, name, coreId, fileSize, progress,
|
/* if found in selectedIds -> select again */
|
||||||
dlspeed, sources, status, completed, remaining);
|
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) {
|
||||||
|
selection->select(DLListModel->index(dlCount, 0),
|
||||||
|
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
||||||
|
}
|
||||||
|
|
||||||
/* if found in selectedIds -> select again */
|
/* expand last expanded items */
|
||||||
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash))
|
if (expandedIds.end() != std::find(expandedIds.begin(), expandedIds.end(), info.hash)) {
|
||||||
{
|
QStandardItem *item = DLListModel->item(dlCount);
|
||||||
selection->select(DLListModel->index(dlCount, 0),
|
QModelIndex index = DLListModel->indexFromItem(item);
|
||||||
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
ui.downloadList->setExpanded(index, true);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
dlCount++;
|
||||||
dlCount++;
|
|
||||||
}
|
|
||||||
/* alternative ... if no peers there stick it in anyway */
|
|
||||||
if (info.peers.size() == 0)
|
|
||||||
{
|
|
||||||
symbol = "";
|
|
||||||
coreId = QString::fromStdString(info.hash);
|
|
||||||
name = QString::fromStdString(info.fname);
|
|
||||||
sources = tr("Unknown");
|
|
||||||
|
|
||||||
switch(info.downloadStatus)
|
/* continue to next download item if no peers to add */
|
||||||
{
|
if (!info.peers.size()) continue;
|
||||||
case FT_STATE_FAILED:
|
|
||||||
status = tr("Failed");
|
|
||||||
break;
|
|
||||||
case FT_STATE_OKAY:
|
|
||||||
status = tr("Okay");
|
|
||||||
break;
|
|
||||||
case FT_STATE_WAITING:
|
|
||||||
status = tr("Waiting");
|
|
||||||
break;
|
|
||||||
case FT_STATE_DOWNLOADING:
|
|
||||||
status = tr("Downloading");
|
|
||||||
break;
|
|
||||||
case FT_STATE_COMPLETE:
|
|
||||||
default:
|
|
||||||
status = tr("Complete");
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
int dlPeers = 0;
|
||||||
|
for (pit = info.peers.begin(); pit != info.peers.end(); pit++) {
|
||||||
|
symbol = "";
|
||||||
|
name = QString::fromStdString(rsPeers->getPeerName(pit->peerId));
|
||||||
|
//unique combination: fileName + peerName, variant: hash + peerName (too long)
|
||||||
|
coreId = QString::fromStdString(info.fname + rsPeers->getPeerName(pit->peerId));
|
||||||
|
fileSize = info.size;
|
||||||
|
progress = (info.transfered * 100.0) / info.size;
|
||||||
|
dlspeed = pit->tfRate * 1024.0;
|
||||||
|
//sources = QString("rShare v %1").arg(tr("0.4.13a"));//TODO: take it from somewhere
|
||||||
|
sources = "";
|
||||||
|
|
||||||
dlspeed = info.tfRate * 1024.0;
|
if (info.downloadStatus == FT_STATE_COMPLETE) {
|
||||||
fileSize = info.size;
|
status = tr("Complete");
|
||||||
completed = info.transfered;
|
} else {
|
||||||
progress = info.transfered * 100.0 / info.size;
|
status = tr("Unknown");
|
||||||
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
|
switch (pit->status) {
|
||||||
|
case FT_STATE_FAILED:
|
||||||
|
status = tr("Failed"); break;
|
||||||
|
case FT_STATE_OKAY:
|
||||||
|
status = tr("Okay"); break;
|
||||||
|
case FT_STATE_WAITING:
|
||||||
|
status = tr("Waiting"); break;
|
||||||
|
case FT_STATE_DOWNLOADING:
|
||||||
|
status = tr("Downloading"); break;
|
||||||
|
case FT_STATE_COMPLETE:
|
||||||
|
status = tr("Complete"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addItem(symbol, name, coreId, fileSize, progress,
|
completed = info.transfered;
|
||||||
dlspeed, sources, status, completed, remaining);
|
remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0);
|
||||||
|
|
||||||
/* if found in selectedIds -> select again */
|
if (!addPeerToItem(addedRow, symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining))
|
||||||
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash))
|
continue;
|
||||||
{
|
|
||||||
selection->select(DLListModel->index(dlCount, 0),
|
/* if peers found in selectedIds, select again */
|
||||||
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.fname + rsPeers->getPeerName(pit->peerId))) {
|
||||||
|
QStandardItem *dlItem = DLListModel->item(addedRow);
|
||||||
|
QModelIndex childIndex = DLListModel->indexFromItem(dlItem).child(dlPeers, 0);
|
||||||
|
selection->select(childIndex, QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
|
||||||
|
}
|
||||||
|
dlPeers++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
dlCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(it = upHashes.begin(); it != upHashes.end(); it++)
|
for(it = upHashes.begin(); it != upHashes.end(); it++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -105,6 +105,7 @@ class TransfersDialog : public MainPage
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
int addItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||||
|
bool addPeerToItem(int row, QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||||
void delItem(int row);
|
void delItem(int row);
|
||||||
|
|
||||||
int addUploadItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
int addUploadItem(QString symbol, QString name, QString coreID, qlonglong size, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue