-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:
alexandrut 2009-05-20 22:06:20 +00:00
parent 4694ff22d5
commit 3d37a0c242
2 changed files with 236 additions and 175 deletions

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -72,35 +72,37 @@ TransfersDialog::TransfersDialog(QWidget *parent)
ui.downloadList->hideColumn(ID); ui.downloadList->hideColumn(ID);
DLDelegate = new DLListDelegate(); DLDelegate = new DLListDelegate();
ui.downloadList->setItemDelegate(DLDelegate); ui.downloadList->setItemDelegate(DLDelegate);
ui.downloadList->setAutoScroll(false) ; ui.downloadList->setAutoScroll(false) ;
//Selection Setup //Selection Setup
selection = ui.downloadList->selectionModel(); selection = ui.downloadList->selectionModel();
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 () ;
_header->setResizeMode (NAME, QHeaderView::Interactive); _header->setResizeMode (NAME, QHeaderView::Interactive);
_header->setResizeMode (SIZE, QHeaderView::Interactive); _header->setResizeMode (SIZE, QHeaderView::Interactive);
_header->setResizeMode (COMPLETED, QHeaderView::Interactive); _header->setResizeMode (COMPLETED, QHeaderView::Interactive);
_header->setResizeMode (DLSPEED, QHeaderView::Interactive); _header->setResizeMode (DLSPEED, QHeaderView::Interactive);
_header->setResizeMode (PROGRESS, QHeaderView::Interactive); _header->setResizeMode (PROGRESS, QHeaderView::Interactive);
_header->setResizeMode (SOURCES, QHeaderView::Interactive); _header->setResizeMode (SOURCES, QHeaderView::Interactive);
_header->setResizeMode (STATUS, QHeaderView::Interactive); _header->setResizeMode (STATUS, QHeaderView::Interactive);
_header->setResizeMode (REMAINING, QHeaderView::Interactive); _header->setResizeMode (REMAINING, QHeaderView::Interactive);
_header->resizeSection ( NAME, 170 ); _header->resizeSection ( NAME, 170 );
_header->resizeSection ( SIZE, 70 ); _header->resizeSection ( SIZE, 70 );
_header->resizeSection ( COMPLETED, 75 ); _header->resizeSection ( COMPLETED, 75 );
_header->resizeSection ( DLSPEED, 75 ); _header->resizeSection ( DLSPEED, 75 );
_header->resizeSection ( PROGRESS, 170 ); _header->resizeSection ( PROGRESS, 170 );
_header->resizeSection ( SOURCES, 90 ); _header->resizeSection ( SOURCES, 90 );
_header->resizeSection ( STATUS, 100 ); _header->resizeSection ( STATUS, 100 );
_header->resizeSection ( REMAINING, 100 ); _header->resizeSection ( REMAINING, 100 );
// Set Upload list model // Set Upload list model
ULListModel = new QStandardItemModel(0,7); ULListModel = new QStandardItemModel(0,7);
ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name")); ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name"));
@ -113,13 +115,16 @@ TransfersDialog::TransfersDialog(QWidget *parent)
ui.uploadsList->setModel(ULListModel); ui.uploadsList->setModel(ULListModel);
ULDelegate = new ULListDelegate(); ULDelegate = new ULListDelegate();
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();
/* Set header resize modes and initial section sizes Uploads TreeView*/ /* Set header resize modes and initial section sizes Uploads TreeView*/
// QHeaderView * upheader = ui.uploadsList->header () ; // QHeaderView * upheader = ui.uploadsList->header () ;
// upheader->setResizeMode (0, QHeaderView::Interactive); /*Name */ // upheader->setResizeMode (0, QHeaderView::Interactive); /*Name */
@ -129,7 +134,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
// upheader->setResizeMode (4, QHeaderView::Interactive); /*Speed */ // upheader->setResizeMode (4, QHeaderView::Interactive); /*Speed */
// upheader->setResizeMode (5, QHeaderView::Interactive); /*Status*/ // upheader->setResizeMode (5, QHeaderView::Interactive); /*Status*/
// upheader->setResizeMode (6, QHeaderView::Interactive); /*Transferred*/ // upheader->setResizeMode (6, QHeaderView::Interactive); /*Transferred*/
// //
// upheader->resizeSection ( 0, 100 ); /*Name */ // upheader->resizeSection ( 0, 100 ); /*Name */
// upheader->resizeSection ( 1, 75 ); /*Size */ // upheader->resizeSection ( 1, 75 ); /*Size */
// upheader->resizeSection ( 2, 100 ); /*User Name*/ // upheader->resizeSection ( 2, 100 ); /*User Name*/
@ -164,8 +169,8 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
//showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr( "Details..." ), this ); //showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr( "Details..." ), this );
//connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) ); //connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) );
/* check which item is selected /* check which item is selected
* - if it is completed - play should appear in menu * - if it is completed - play should appear in menu
*/ */
std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl; std::cerr << "TransfersDialog::downloadListCostumPopupMenu()" << std::endl;
@ -193,13 +198,13 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this ); cancelAct = new QAction(QIcon(IMAGE_CANCEL), tr( "Cancel" ), this );
connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) ); connect( cancelAct , SIGNAL( triggered() ), this, SLOT( cancel() ) );
copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this ); copylinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Copy retroshare Link" ), this );
connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) ); connect( copylinkAct , SIGNAL( triggered() ), this, SLOT( copyLink() ) );
pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this ); pastelinkAct = new QAction(QIcon(IMAGE_PASTELINK), tr( "Paste retroshare Link" ), this );
connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) ); connect( pastelinkAct , SIGNAL( triggered() ), this, SLOT( pasteLink() ) );
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this ); clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) ); connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
@ -208,7 +213,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
{ {
contextMnu.addAction(playAct); contextMnu.addAction(playAct);
} }
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction( cancelAct); contextMnu.addAction( cancelAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -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());
@ -364,30 +405,55 @@ void TransfersDialog::insertTransfers()
{ {
QString symbol, name, sources, status, coreId; QString symbol, name, sources, status, coreId;
qlonglong fileSize, completed, remaining; qlonglong fileSize, completed, remaining;
double progress, dlspeed; double progress, dlspeed;
/* 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);
} }
}
//remove all Items QStandardItem *parent = DLListModel->item(i);
for(int i = DLListModel->rowCount(); i >= 0; 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
for(int i = DLListModel->rowCount(); i >= 0; i--)
{ {
delItem(i); delItem(i);
} }
for(int i = ULListModel->rowCount(); i >= 0; i--) for(int i = ULListModel->rowCount(); i >= 0; i--)
{ {
delUploadItem(i); delUploadItem(i);
} }
/* get the download and upload lists */ /* get the download and upload lists */
std::list<std::string> downHashes; std::list<std::string> downHashes;
@ -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;
}
if (info.downloadStatus == FT_STATE_COMPLETE) switch (info.downloadStatus) {
{ case FT_STATE_FAILED:
status = tr("Complete"); status = tr("Failed"); break;
} case FT_STATE_OKAY:
status = tr("Okay"); break;
dlspeed = pit->tfRate * 1024.0; case FT_STATE_WAITING:
fileSize = info.size; status = tr("Waiting"); break;
completed = info.transfered; case FT_STATE_DOWNLOADING:
progress = info.transfered * 100.0 / info.size; status = tr("Downloading"); break;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); case FT_STATE_COMPLETE:
status = tr("Complete"); break;
addItem(symbol, name, coreId, fileSize, progress, default:
dlspeed, sources, status, completed, remaining); status = tr("Unknown"); break;
}
/* if found in selectedIds -> select again */ completed = info.transfered;
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
{
selection->select(DLListModel->index(dlCount, 0),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
} int addedRow = addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining);
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) /* if found in selectedIds -> select again */
{ if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) {
case FT_STATE_FAILED: selection->select(DLListModel->index(dlCount, 0),
status = tr("Failed"); QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
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;
}
dlspeed = info.tfRate * 1024.0; /* expand last expanded items */
fileSize = info.size; if (expandedIds.end() != std::find(expandedIds.begin(), expandedIds.end(), info.hash)) {
completed = info.transfered; QStandardItem *item = DLListModel->item(dlCount);
progress = info.transfered * 100.0 / info.size; QModelIndex index = DLListModel->indexFromItem(item);
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); ui.downloadList->setExpanded(index, true);
}
addItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining);
/* if found in selectedIds -> select again */ dlCount++;
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash))
{ /* continue to next download item if no peers to add */
selection->select(DLListModel->index(dlCount, 0), if (!info.peers.size()) continue;
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
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 = "";
if (info.downloadStatus == FT_STATE_COMPLETE) {
status = tr("Complete");
} else {
status = tr("Unknown");
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;
}
}
completed = info.transfered;
remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0);
if (!addPeerToItem(addedRow, symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining))
continue;
/* if peers found in selectedIds, select again */
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++)
{ {
@ -533,10 +593,10 @@ void TransfersDialog::insertTransfers()
switch(pit->status) switch(pit->status)
{ {
case FT_STATE_FAILED: case FT_STATE_FAILED:
status = tr("Failed"); status = tr("Failed");
break; break;
case FT_STATE_OKAY: case FT_STATE_OKAY:
status = tr("Okay"); status = tr("Okay");
break; break;
case FT_STATE_WAITING: case FT_STATE_WAITING:
@ -545,25 +605,25 @@ void TransfersDialog::insertTransfers()
case FT_STATE_DOWNLOADING: case FT_STATE_DOWNLOADING:
status = tr("Uploading"); status = tr("Uploading");
break; break;
case FT_STATE_COMPLETE: case FT_STATE_COMPLETE:
default: default:
status = tr("Complete"); status = tr("Complete");
break; break;
} }
// if (info.downloadStatus == FT_STATE_COMPLETE) // if (info.downloadStatus == FT_STATE_COMPLETE)
// { // {
// status = "Complete"; // status = "Complete";
// } // }
dlspeed = pit->tfRate * 1024.0; dlspeed = pit->tfRate * 1024.0;
fileSize = info.size; fileSize = info.size;
completed = info.transfered; completed = info.transfered;
progress = info.transfered * 100.0 / info.size; progress = info.transfered * 100.0 / info.size;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
addUploadItem(symbol, name, coreId, fileSize, progress, addUploadItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining); dlspeed, sources, status, completed, remaining);
ulCount++; ulCount++;
} }
@ -577,10 +637,10 @@ void TransfersDialog::insertTransfers()
switch(info.downloadStatus) switch(info.downloadStatus)
{ {
case FT_STATE_FAILED: case FT_STATE_FAILED:
status = tr("Failed"); status = tr("Failed");
break; break;
case FT_STATE_OKAY: case FT_STATE_OKAY:
status = tr("Okay"); status = tr("Okay");
break; break;
case FT_STATE_WAITING: case FT_STATE_WAITING:
@ -589,11 +649,11 @@ void TransfersDialog::insertTransfers()
case FT_STATE_DOWNLOADING: case FT_STATE_DOWNLOADING:
status = tr("Uploading"); status = tr("Uploading");
break; break;
case FT_STATE_COMPLETE: case FT_STATE_COMPLETE:
default: default:
status = tr("Complete"); status = tr("Complete");
break; break;
} }
dlspeed = info.tfRate * 1024.0; dlspeed = info.tfRate * 1024.0;
@ -601,8 +661,8 @@ void TransfersDialog::insertTransfers()
completed = info.transfered; completed = info.transfered;
progress = info.transfered * 100.0 / info.size; progress = info.transfered * 100.0 / info.size;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
addUploadItem(symbol, name, coreId, fileSize, progress, addUploadItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining); dlspeed, sources, status, completed, remaining);
ulCount++; ulCount++;
} }
@ -617,11 +677,11 @@ void TransfersDialog::cancel()
if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok)
{ {
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();
QString qname = getFileName(i, DLListModel); QString qname = getFileName(i, DLListModel);
@ -633,7 +693,7 @@ void TransfersDialog::cancel()
} }
} }
} }
else else
return; return;
@ -692,7 +752,7 @@ void TransfersDialog::pasteLink()
QVector<RetroShareLinkData> linkList; QVector<RetroShareLinkData> linkList;
analyzer.getFileInformation (linkList); analyzer.getFileInformation (linkList);
std::list<std::string> srcIds; std::list<std::string> srcIds;
for (int i = 0, n = linkList.size (); i < n; ++i) for (int i = 0, n = linkList.size (); i < n; ++i)

View file

@ -15,7 +15,7 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
@ -46,12 +46,12 @@ class TransfersDialog : public MainPage
TransfersDialog(QWidget *parent = 0); TransfersDialog(QWidget *parent = 0);
/** Default Destructor */ /** Default Destructor */
~TransfersDialog(); ~TransfersDialog();
virtual void keyPressEvent(QKeyEvent *) ; virtual void keyPressEvent(QKeyEvent *) ;
public slots: public slots:
void insertTransfers(); void insertTransfers();
void handleDownloadRequest(const QString& url); void handleDownloadRequest(const QString& url);
private slots: private slots:
@ -62,8 +62,8 @@ class TransfersDialog : public MainPage
void cancel(); void cancel();
/** removes finished Downloads**/ /** removes finished Downloads**/
void clearcompleted(); void clearcompleted();
void playSelectedTransfer(); void playSelectedTransfer();
void copyLink(); void copyLink();
void pasteLink(); void pasteLink();
@ -104,7 +104,8 @@ class TransfersDialog : public MainPage
Ui::TransfersDialog ui; Ui::TransfersDialog ui;
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);