From f78e5da41e760e56ed5419a93a779b22542f489d Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 1 Jul 2013 21:03:20 +0000 Subject: [PATCH] consistent renaming of columns in transfers tab and display of last time file has been written (Patch from Phenom) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6471 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/DLListDelegate.cpp | 16 +- retroshare-gui/src/gui/DLListDelegate.h | 24 ++- retroshare-gui/src/gui/TransfersDialog.cpp | 239 ++++++++++++--------- retroshare-gui/src/gui/TransfersDialog.h | 1 + retroshare-gui/src/gui/ULListDelegate.cpp | 16 +- retroshare-gui/src/gui/ULListDelegate.h | 20 +- 6 files changed, 173 insertions(+), 143 deletions(-) diff --git a/retroshare-gui/src/gui/DLListDelegate.cpp b/retroshare-gui/src/gui/DLListDelegate.cpp index 8da2c0190..66c8d8ff6 100644 --- a/retroshare-gui/src/gui/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/DLListDelegate.cpp @@ -72,7 +72,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } // draw the background color if not the progress column or if progress is not displayed - if(index.column() != PROGRESS) { + if(index.column() != COLUMN_PROGRESS) { if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) { if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) { cg = QPalette::Inactive; @@ -86,7 +86,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } } switch(index.column()) { - case SIZE: + case COLUMN_SIZE: fileSize = index.data().toLongLong(); if(fileSize <= 0){ temp = ""; @@ -105,7 +105,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case REMAINING: + case COLUMN_REMAINING: remaining = index.data().toLongLong(); if(remaining <= 0){ temp = ""; @@ -124,7 +124,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case COMPLETED: + case COLUMN_COMPLETED: completed = index.data().toLongLong(); if(completed <= 0){ temp = ""; @@ -143,7 +143,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case DLSPEED: + case COLUMN_DLSPEED: dlspeed = index.data().toDouble(); if (dlspeed <= 0) { temp = ""; @@ -154,7 +154,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case PROGRESS: + case COLUMN_PROGRESS: { // create a xProgressBar FileProgressInfo pinfo = index.data().value() ; @@ -183,7 +183,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignCenter, newopt.text); break; - case DOWNLOADTIME: + case COLUMN_DOWNLOADTIME: downloadtime = index.data().toLongLong(); minutes = downloadtime / 60; seconds = downloadtime % 60; @@ -203,7 +203,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti temp = "" ; painter->drawText(option.rect, Qt::AlignCenter, temp); break; - case NAME: + case COLUMN_NAME: // decoration value = index.data(Qt::DecorationRole); temp = index.data().toString(); diff --git a/retroshare-gui/src/gui/DLListDelegate.h b/retroshare-gui/src/gui/DLListDelegate.h index 0e69f70cf..bf9f55c67 100644 --- a/retroshare-gui/src/gui/DLListDelegate.h +++ b/retroshare-gui/src/gui/DLListDelegate.h @@ -27,17 +27,19 @@ // Defines for download list list columns -#define NAME 0 -#define SIZE 1 -#define COMPLETED 2 -#define DLSPEED 3 -#define PROGRESS 4 -#define SOURCES 5 -#define STATUS 6 -#define PRIORITY 7 -#define REMAINING 8 -#define DOWNLOADTIME 9 -#define ID 10 +#define COLUMN_NAME 0 +#define COLUMN_SIZE 1 +#define COLUMN_COMPLETED 2 +#define COLUMN_DLSPEED 3 +#define COLUMN_PROGRESS 4 +#define COLUMN_SOURCES 5 +#define COLUMN_STATUS 6 +#define COLUMN_PRIORITY 7 +#define COLUMN_REMAINING 8 +#define COLUMN_DOWNLOADTIME 9 +#define COLUMN_ID 10 +#define COLUMN_LASTDL 11 +#define COLUMN_COUNT 12 #define MAX_CHAR_TMP 128 diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index 6d2414f88..2ffc8f5b7 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -110,8 +111,8 @@ public: return QStandardItem::operator<(other); } - QStandardItem *myName = myParent->child(index().row(), NAME); - QStandardItem *otherName = otherParent->child(other.index().row(), NAME); + QStandardItem *myName = myParent->child(index().row(), COLUMN_NAME); + QStandardItem *otherName = otherParent->child(other.index().row(), COLUMN_NAME); if (header == NULL || header->sortIndicatorOrder() == Qt::AscendingOrder) { /* Ascending */ @@ -187,20 +188,21 @@ TransfersDialog::TransfersDialog(QWidget *parent) connect( ui.downloadList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downloadListCustomPopupMenu( QPoint ) ) ); // Set Download list model - DLListModel = new QStandardItemModel(0,ID + 1); - DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: file name")); - DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); - DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", "")); - DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed")); - DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded")); - DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources")); - DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status")); - DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Speed / Queue position")); - DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining")); - DLListModel->setHeaderData(DOWNLOADTIME, Qt::Horizontal, tr("Download time", "i.e: Estimated Time of Arrival / Time left")); - DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID")); + DLListModel = new QStandardItemModel(0,COLUMN_COUNT); + DLListModel->setHeaderData(COLUMN_NAME, Qt::Horizontal, tr("Name", "i.e: file name")); + DLListModel->setHeaderData(COLUMN_SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); + DLListModel->setHeaderData(COLUMN_COMPLETED, Qt::Horizontal, tr("Completed", "")); + DLListModel->setHeaderData(COLUMN_DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed")); + DLListModel->setHeaderData(COLUMN_PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded")); + DLListModel->setHeaderData(COLUMN_SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources")); + DLListModel->setHeaderData(COLUMN_STATUS, Qt::Horizontal, tr("Status")); + DLListModel->setHeaderData(COLUMN_PRIORITY, Qt::Horizontal, tr("Speed / Queue position")); + DLListModel->setHeaderData(COLUMN_REMAINING, Qt::Horizontal, tr("Remaining")); + DLListModel->setHeaderData(COLUMN_DOWNLOADTIME, Qt::Horizontal, tr("Download time", "i.e: Estimated Time of Arrival / Time left")); + DLListModel->setHeaderData(COLUMN_ID, Qt::Horizontal, tr("Core-ID")); + DLListModel->setHeaderData(COLUMN_LASTDL, Qt::Horizontal, tr("Last Time Seen", "i.e: Last Time Receiced Data")); ui.downloadList->setModel(DLListModel); - ui.downloadList->hideColumn(ID); + //ui.downloadList->hideColumn(ID); DLDelegate = new DLListDelegate(); ui.downloadList->setItemDelegate(DLDelegate); @@ -223,42 +225,49 @@ TransfersDialog::TransfersDialog(QWidget *parent) /* Set header resize modes and initial section sizes Downloads TreeView*/ QHeaderView * _header = ui.downloadList->header () ; - _header->setResizeMode (NAME, QHeaderView::Interactive); - _header->setResizeMode (SIZE, QHeaderView::Interactive); - _header->setResizeMode (COMPLETED, QHeaderView::Interactive); - _header->setResizeMode (DLSPEED, QHeaderView::Interactive); - _header->setResizeMode (PROGRESS, QHeaderView::Interactive); - _header->setResizeMode (SOURCES, QHeaderView::Interactive); - _header->setResizeMode (STATUS, QHeaderView::Interactive); - _header->setResizeMode (PRIORITY, QHeaderView::Interactive); - _header->setResizeMode (REMAINING, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_NAME, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_SIZE, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_COMPLETED, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_DLSPEED, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_PROGRESS, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_SOURCES, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_STATUS, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_PRIORITY, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_REMAINING, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_DOWNLOADTIME, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_ID, QHeaderView::Interactive); + _header->setResizeMode (COLUMN_LASTDL, QHeaderView::Interactive); - _header->resizeSection ( NAME, 170 ); - _header->resizeSection ( SIZE, 70 ); - _header->resizeSection ( COMPLETED, 75 ); - _header->resizeSection ( DLSPEED, 75 ); - _header->resizeSection ( PROGRESS, 170 ); - _header->resizeSection ( SOURCES, 90 ); - _header->resizeSection ( STATUS, 100 ); - _header->resizeSection ( PRIORITY, 100 ); - _header->resizeSection ( REMAINING, 100 ); + _header->resizeSection ( COLUMN_NAME, 170 ); + _header->resizeSection ( COLUMN_SIZE, 70 ); + _header->resizeSection ( COLUMN_COMPLETED, 75 ); + _header->resizeSection ( COLUMN_DLSPEED, 75 ); + _header->resizeSection ( COLUMN_PROGRESS, 170 ); + _header->resizeSection ( COLUMN_SOURCES, 90 ); + _header->resizeSection ( COLUMN_STATUS, 100 ); + _header->resizeSection ( COLUMN_PRIORITY, 100 ); + _header->resizeSection ( COLUMN_REMAINING, 100 ); + _header->resizeSection ( COLUMN_DOWNLOADTIME, 100 ); + _header->resizeSection ( COLUMN_ID, 100 ); + _header->resizeSection ( COLUMN_LASTDL, 100 ); // set default column and sort order for download - ui.downloadList->sortByColumn(NAME, Qt::AscendingOrder); + ui.downloadList->sortByColumn(COLUMN_NAME, Qt::AscendingOrder); // Set Upload list model - ULListModel = new QStandardItemModel(0,8); - ULListModel->setHeaderData(UNAME, Qt::Horizontal, tr("Name", "i.e: file name")); - ULListModel->setHeaderData(USIZE, Qt::Horizontal, tr("Size", "i.e: file size")); - ULListModel->setHeaderData(USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name")); - ULListModel->setHeaderData(UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded")); - ULListModel->setHeaderData(ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed")); - ULListModel->setHeaderData(USTATUS, Qt::Horizontal, tr("Status")); - ULListModel->setHeaderData(UTRANSFERRED, Qt::Horizontal, tr("Transferred", "")); - ULListModel->setHeaderData(UHASH, Qt::Horizontal, tr("Hash", "")); + ULListModel = new QStandardItemModel(0,COLUMN_UCOUNT); + ULListModel->setHeaderData(COLUMN_UNAME, Qt::Horizontal, tr("Name", "i.e: file name")); + ULListModel->setHeaderData(COLUMN_USIZE, Qt::Horizontal, tr("Size", "i.e: file size")); + ULListModel->setHeaderData(COLUMN_USERNAME, Qt::Horizontal, tr("Peer", "i.e: user name")); + ULListModel->setHeaderData(COLUMN_UPROGRESS, Qt::Horizontal, tr("Progress", "i.e: % uploaded")); + ULListModel->setHeaderData(COLUMN_ULSPEED, Qt::Horizontal, tr("Speed", "i.e: upload speed")); + ULListModel->setHeaderData(COLUMN_USTATUS, Qt::Horizontal, tr("Status")); + ULListModel->setHeaderData(COLUMN_UTRANSFERRED, Qt::Horizontal, tr("Transferred", "")); + ULListModel->setHeaderData(COLUMN_UHASH, Qt::Horizontal, tr("Hash", "")); + ULListModel->setHeaderData(COLUMN_UUSERID, Qt::Horizontal, tr("UserID", "")); ui.uploadsList->setModel(ULListModel); - ULListModel->insertColumn(UUSERID); - ui.uploadsList->hideColumn(UUSERID); + //ULListModel->insertColumn(COLUMN_UUSERID); + //ui.uploadsList->hideColumn(COLUMN_UUSERID); ULDelegate = new ULListDelegate(); ui.uploadsList->setItemDelegate(ULDelegate); @@ -275,24 +284,24 @@ TransfersDialog::TransfersDialog(QWidget *parent) /* Set header resize modes and initial section sizes Uploads TreeView*/ QHeaderView * upheader = ui.uploadsList->header () ; - upheader->setResizeMode (UNAME, QHeaderView::Interactive); - upheader->setResizeMode (USIZE, QHeaderView::Interactive); - upheader->setResizeMode (UTRANSFERRED, QHeaderView::Interactive); - upheader->setResizeMode (ULSPEED, QHeaderView::Interactive); - upheader->setResizeMode (UPROGRESS, QHeaderView::Interactive); - upheader->setResizeMode (USTATUS, QHeaderView::Interactive); - upheader->setResizeMode (USERNAME, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_UNAME, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_USIZE, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_UTRANSFERRED, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_ULSPEED, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_UPROGRESS, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_USTATUS, QHeaderView::Interactive); + upheader->setResizeMode (COLUMN_USERNAME, QHeaderView::Interactive); - upheader->resizeSection ( UNAME, 190 ); - upheader->resizeSection ( USIZE, 70 ); - upheader->resizeSection ( UTRANSFERRED, 75 ); - upheader->resizeSection ( ULSPEED, 75 ); - upheader->resizeSection ( UPROGRESS, 170 ); - upheader->resizeSection ( USTATUS, 100 ); - upheader->resizeSection ( USERNAME, 120 ); + upheader->resizeSection ( COLUMN_UNAME, 190 ); + upheader->resizeSection ( COLUMN_USIZE, 70 ); + upheader->resizeSection ( COLUMN_UTRANSFERRED, 75 ); + upheader->resizeSection ( COLUMN_ULSPEED, 75 ); + upheader->resizeSection ( COLUMN_UPROGRESS, 170 ); + upheader->resizeSection ( COLUMN_USTATUS, 100 ); + upheader->resizeSection ( COLUMN_USERNAME, 120 ); // set default column and sort order for upload - ui.uploadsList->sortByColumn(UNAME, Qt::AscendingOrder); + ui.uploadsList->sortByColumn(COLUMN_UNAME, Qt::AscendingOrder); // FileTransferInfoWidget *ftiw = new FileTransferInfoWidget(); // ui.fileTransferInfoWidget->setWidget(ftiw); @@ -742,6 +751,18 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::mapgetPartialsDirectory().c_str()), QString::fromUtf8(fileInfo.hash.c_str())); + } + /*Get Last Access on File */ + if (file.exists()) { + strLastDL= file.lastModified().toString("yyyy-MM-dd_hh:mm:ss"); + } FileChunksInfo fcinfo; if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo)) { @@ -777,26 +798,27 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::mapinsertRow(row); // change progress column to own class for sorting - DLListModel->setItem(row, PROGRESS, new ProgressItem(NULL)); - DLListModel->setItem(row, PRIORITY, new PriorityItem(NULL)); + DLListModel->setItem(row, COLUMN_PROGRESS, new ProgressItem(NULL)); + DLListModel->setItem(row, COLUMN_PRIORITY, new PriorityItem(NULL)); - DLListModel->setData(DLListModel->index(row, SIZE), QVariant((qlonglong) fileInfo.size)); - DLListModel->setData(DLListModel->index(row, ID), fileHash); + DLListModel->setData(DLListModel->index(row, COLUMN_SIZE), QVariant((qlonglong) fileInfo.size)); + DLListModel->setData(DLListModel->index(row, COLUMN_ID), fileHash); } QString fileName = QString::fromUtf8(fileInfo.fname.c_str()); - DLListModel->setData(DLListModel->index(row, NAME), fileName); - DLListModel->setData(DLListModel->index(row, NAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole); + DLListModel->setData(DLListModel->index(row, COLUMN_NAME), fileName); + DLListModel->setData(DLListModel->index(row, COLUMN_NAME), FilesDefs::getIconFromFilename(fileName), Qt::DecorationRole); - DLListModel->setData(DLListModel->index(row, COMPLETED), QVariant((qlonglong)completed)); - DLListModel->setData(DLListModel->index(row, DLSPEED), QVariant((double)fileDlspeed)); - DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant::fromValue(pinfo)); - DLListModel->setData(DLListModel->index(row, STATUS), QVariant(status)); - DLListModel->setData(DLListModel->index(row, PRIORITY), QVariant(priority)); - DLListModel->setData(DLListModel->index(row, REMAINING), QVariant((qlonglong)remaining)); - DLListModel->setData(DLListModel->index(row, DOWNLOADTIME), QVariant((qlonglong)downloadtime)); + DLListModel->setData(DLListModel->index(row, COLUMN_COMPLETED), QVariant((qlonglong)completed)); + DLListModel->setData(DLListModel->index(row, COLUMN_DLSPEED), QVariant((double)fileDlspeed)); + DLListModel->setData(DLListModel->index(row, COLUMN_PROGRESS), QVariant::fromValue(pinfo)); + DLListModel->setData(DLListModel->index(row, COLUMN_STATUS), QVariant(status)); + DLListModel->setData(DLListModel->index(row, COLUMN_PRIORITY), QVariant(priority)); + DLListModel->setData(DLListModel->index(row, COLUMN_REMAINING), QVariant((qlonglong)remaining)); + DLListModel->setData(DLListModel->index(row, COLUMN_DOWNLOADTIME), QVariant((qlonglong)downloadtime)); + DLListModel->setData(DLListModel->index(row, COLUMN_LASTDL), QVariant(strLastDL)); - DLListModel->item(row,STATUS)->setToolTip(tooltip); + DLListModel->item(row,COLUMN_STATUS)->setToolTip(tooltip); QStandardItem *dlItem = DLListModel->item(row); @@ -839,7 +861,7 @@ int TransfersDialog::addItem(int row, const FileInfo &fileInfo, const std::mapsetData(DLListModel->index(row, SOURCES), QVariant(sources)); + DLListModel->setData(DLListModel->index(row, COLUMN_SOURCES), QVariant(sources)); // 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 ! @@ -860,7 +882,7 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c int count = 0; QStandardItem *childId = NULL; - for (count = 0; (childId = dlItem->child(count, ID)) != NULL; ++count) { + for (count = 0; (childId = dlItem->child(count, COLUMN_ID)) != NULL; ++count) { if (childId->data(Qt::DisplayRole).toString() == coreID) { childRow = count; break; @@ -920,11 +942,11 @@ int TransfersDialog::addPeerToItem(QStandardItem *dlItem, const QString& name, c childRow = dlItem->rowCount() - 1; } else { // just update the child (peer) - dlItem->child(childRow, DLSPEED)->setData(QVariant((double)dlspeed), Qt::DisplayRole); - dlItem->child(childRow, PROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole); + dlItem->child(childRow, COLUMN_DLSPEED)->setData(QVariant((double)dlspeed), Qt::DisplayRole); + dlItem->child(childRow, COLUMN_PROGRESS)->setData(QVariant::fromValue(peerInfo), Qt::DisplayRole); - si1 = dlItem->child(childRow,NAME); - si7 = dlItem->child(childRow, STATUS); + si1 = dlItem->child(childRow,COLUMN_NAME); + si7 = dlItem->child(childRow, COLUMN_STATUS); } switch (status) { @@ -965,7 +987,7 @@ int TransfersDialog::addUploadItem( const QString&, const QString& name, const Q // int row ; for(row=0;rowrowCount();++row) - if(ULListModel->item(row,UUSERID)->data(Qt::EditRole).toString() == peer_id && ULListModel->item(row,UHASH)->data(Qt::EditRole).toString() == coreID) + if(ULListModel->item(row,COLUMN_UUSERID)->data(Qt::EditRole).toString() == peer_id && ULListModel->item(row,COLUMN_UHASH)->data(Qt::EditRole).toString() == coreID) break ; if(row >= ULListModel->rowCount() ) @@ -974,21 +996,21 @@ int TransfersDialog::addUploadItem( const QString&, const QString& name, const Q ULListModel->insertRow(row); // change progress column to own class for sorting - ULListModel->setItem(row, UPROGRESS, new ProgressItem(NULL)); + ULListModel->setItem(row, COLUMN_UPROGRESS, new ProgressItem(NULL)); - ULListModel->setData(ULListModel->index(row, UNAME), QVariant((QString)" "+name), Qt::DisplayRole); - ULListModel->setData(ULListModel->index(row, USERNAME), QVariant((QString)source)); - ULListModel->setData(ULListModel->index(row, UHASH), QVariant((QString)coreID)); - ULListModel->setData(ULListModel->index(row, UUSERID), QVariant((QString)peer_id)); + ULListModel->setData(ULListModel->index(row, COLUMN_UNAME), QVariant((QString)" "+name), Qt::DisplayRole); + ULListModel->setData(ULListModel->index(row, COLUMN_USERNAME), QVariant((QString)source)); + ULListModel->setData(ULListModel->index(row, COLUMN_UHASH), QVariant((QString)coreID)); + ULListModel->setData(ULListModel->index(row, COLUMN_UUSERID), QVariant((QString)peer_id)); - ULListModel->setData(ULListModel->index(row,UNAME), FilesDefs::getIconFromFilename(name), Qt::DecorationRole); + ULListModel->setData(ULListModel->index(row,COLUMN_UNAME), FilesDefs::getIconFromFilename(name), Qt::DecorationRole); } - ULListModel->setData(ULListModel->index(row, USIZE), QVariant((qlonglong)fileSize)); - ULListModel->setData(ULListModel->index(row, UTRANSFERRED), QVariant((qlonglong)completed)); - ULListModel->setData(ULListModel->index(row, ULSPEED), QVariant((double)dlspeed)); - ULListModel->setData(ULListModel->index(row, UPROGRESS), QVariant::fromValue(pinfo)); - ULListModel->setData(ULListModel->index(row, USTATUS), QVariant((QString)status)); + ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize)); + ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant((qlonglong)completed)); + ULListModel->setData(ULListModel->index(row, COLUMN_ULSPEED), QVariant((double)dlspeed)); + ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(pinfo)); + ULListModel->setData(ULListModel->index(row, COLUMN_USTATUS), QVariant((QString)status)); return row; } @@ -1028,7 +1050,7 @@ void TransfersDialog::insertTransfers() std::set::iterator hashIt; for (row = 0; row < rowCount; ) { - std::string hash = DLListModel->item(row, ID)->data(Qt::DisplayRole).toString().toStdString(); + std::string hash = DLListModel->item(row, COLUMN_ID)->data(Qt::DisplayRole).toString().toStdString(); hashIt = hashs.find(hash); if (hashIt == hashs.end()) { @@ -1168,8 +1190,8 @@ void TransfersDialog::insertTransfers() rowCount = ULListModel->rowCount(); while (removeIndex < rowCount) { - std::string hash = ULListModel->item(removeIndex, UHASH)->data(Qt::EditRole).toString().toStdString(); - std::string peer = ULListModel->item(removeIndex, UUSERID)->data(Qt::EditRole).toString().toStdString(); + std::string hash = ULListModel->item(removeIndex, COLUMN_UHASH)->data(Qt::EditRole).toString().toStdString(); + std::string peer = ULListModel->item(removeIndex, COLUMN_UUSERID)->data(Qt::EditRole).toString().toStdString(); if(used_hashes.find(hash + peer) == used_hashes.end()) { ULListModel->removeRow(removeIndex); @@ -1339,7 +1361,7 @@ void TransfersDialog::getSelectedItems(std::set *ids, std::set /* if transfered file or it's peers are selected control it*/ if (isParentSelected || isChildSelected) { if (ids) { - QStandardItem *id = DLListModel->item(i, ID); + QStandardItem *id = DLListModel->item(i, COLUMN_ID); ids->insert(id->data(Qt::DisplayRole).toString().toStdString()); } if (rows) { @@ -1671,55 +1693,60 @@ return 0.0 ; double TransfersDialog::getSpeed(int row, QStandardItemModel *model) { - return model->data(model->index(row, DLSPEED), Qt::DisplayRole).toDouble(); + return model->data(model->index(row, COLUMN_DLSPEED), Qt::DisplayRole).toDouble(); } QString TransfersDialog::getFileName(int row, QStandardItemModel *model) { - return model->data(model->index(row, NAME), Qt::DisplayRole).toString(); + return model->data(model->index(row, COLUMN_NAME), Qt::DisplayRole).toString(); } QString TransfersDialog::getStatus(int row, QStandardItemModel *model) { - return model->data(model->index(row, STATUS), Qt::DisplayRole).toString(); + return model->data(model->index(row, COLUMN_STATUS), Qt::DisplayRole).toString(); } QString TransfersDialog::getID(int row, QStandardItemModel *model) { - return model->data(model->index(row, ID), Qt::DisplayRole).toString().left(40); // gets only the "hash" part of the name + return model->data(model->index(row, COLUMN_ID), Qt::DisplayRole).toString().left(40); // gets only the "hash" part of the name } QString TransfersDialog::getPriority(int row, QStandardItemModel *model) { - return model->data(model->index(row, PRIORITY), Qt::DisplayRole).toString(); + return model->data(model->index(row, COLUMN_PRIORITY), Qt::DisplayRole).toString(); } qlonglong TransfersDialog::getFileSize(int row, QStandardItemModel *model) { bool ok = false; - return model->data(model->index(row, SIZE), Qt::DisplayRole).toULongLong(&ok); + return model->data(model->index(row, COLUMN_SIZE), Qt::DisplayRole).toULongLong(&ok); } qlonglong TransfersDialog::getTransfered(int row, QStandardItemModel *model) { bool ok = false; - return model->data(model->index(row, COMPLETED), Qt::DisplayRole).toULongLong(&ok); + return model->data(model->index(row, COLUMN_COMPLETED), Qt::DisplayRole).toULongLong(&ok); } qlonglong TransfersDialog::getRemainingTime(int row, QStandardItemModel *model) { bool ok = false; - return model->data(model->index(row, REMAINING), Qt::DisplayRole).toULongLong(&ok); + return model->data(model->index(row, COLUMN_REMAINING), Qt::DisplayRole).toULongLong(&ok); } qlonglong TransfersDialog::getDownloadTime(int row, QStandardItemModel *model) { - return model->data(model->index(row, DOWNLOADTIME), Qt::DisplayRole).toULongLong(); + return model->data(model->index(row, COLUMN_DOWNLOADTIME), Qt::DisplayRole).toULongLong(); +} + +qlonglong TransfersDialog::getLastDL(int row, QStandardItemModel *model) +{ + return model->data(model->index(row, COLUMN_LASTDL), Qt::DisplayRole).toULongLong(); } QString TransfersDialog::getSources(int row, QStandardItemModel *model) { - return model->data(model->index(row, SOURCES), Qt::DisplayRole).toString(); + return model->data(model->index(row, COLUMN_SOURCES), Qt::DisplayRole).toString(); } void TransfersDialog::openCollection() diff --git a/retroshare-gui/src/gui/TransfersDialog.h b/retroshare-gui/src/gui/TransfersDialog.h index b7755eb37..29e3ad3ff 100644 --- a/retroshare-gui/src/gui/TransfersDialog.h +++ b/retroshare-gui/src/gui/TransfersDialog.h @@ -213,6 +213,7 @@ public slots: qlonglong getTransfered(int row, QStandardItemModel *model); qlonglong getRemainingTime(int row, QStandardItemModel *model); qlonglong getDownloadTime(int row, QStandardItemModel *model); + qlonglong getLastDL(int row, QStandardItemModel *model); QString getSources(int row, QStandardItemModel *model); }; diff --git a/retroshare-gui/src/gui/ULListDelegate.cpp b/retroshare-gui/src/gui/ULListDelegate.cpp index 7d416819f..e3de93e70 100644 --- a/retroshare-gui/src/gui/ULListDelegate.cpp +++ b/retroshare-gui/src/gui/ULListDelegate.cpp @@ -65,7 +65,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } // draw the background color - if(index.column() != UPROGRESS) { + if(index.column() != COLUMN_UPROGRESS) { if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) { if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) { cg = QPalette::Inactive; @@ -79,7 +79,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } } switch(index.column()) { - case USIZE: + case COLUMN_USIZE: fileSize = index.data().toLongLong(); if(fileSize <= 0){ temp = ""; @@ -98,7 +98,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case UTRANSFERRED: + case COLUMN_UTRANSFERRED: transferred = index.data().toLongLong(); if(transferred <= 0){ temp = ""; @@ -117,7 +117,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case ULSPEED: + case COLUMN_ULSPEED: ulspeed = index.data().toDouble(); if (ulspeed <= 0) { temp = ""; @@ -128,7 +128,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignRight, temp); break; - case UPROGRESS: + case COLUMN_UPROGRESS: { FileProgressInfo pinfo = index.data().value() ; @@ -136,7 +136,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti painter->save() ; xProgressBar progressBar(pinfo,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value) - QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), UNAME).data().toString().toStdString())).suffix();; + QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();; if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb") progressBar.setColorSchema( 9); else @@ -150,7 +150,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect, Qt::AlignCenter, newopt.text); break; - case UNAME: + case COLUMN_UNAME: // decoration value = index.data(Qt::DecorationRole); pixmap = qvariant_cast(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off); @@ -161,7 +161,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti } painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, index.data().toString()); break; - case USTATUS: + case COLUMN_USTATUS: painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignCenter, index.data().toString()); break; default: diff --git a/retroshare-gui/src/gui/ULListDelegate.h b/retroshare-gui/src/gui/ULListDelegate.h index a5960b9e2..f6cf637a9 100644 --- a/retroshare-gui/src/gui/ULListDelegate.h +++ b/retroshare-gui/src/gui/ULListDelegate.h @@ -25,16 +25,16 @@ #include // Defines for upload list list columns -#define UNAME 0 -#define USIZE 1 -#define UTRANSFERRED 2 -#define ULSPEED 3 -#define UPROGRESS 4 -#define USTATUS 5 -#define USERNAME 6 -#define UHASH 7 -#define UUSERID 8 - +#define COLUMN_UNAME 0 +#define COLUMN_USIZE 1 +#define COLUMN_UTRANSFERRED 2 +#define COLUMN_ULSPEED 3 +#define COLUMN_UPROGRESS 4 +#define COLUMN_USTATUS 5 +#define COLUMN_USERNAME 6 +#define COLUMN_UHASH 7 +#define COLUMN_UUSERID 8 +#define COLUMN_UCOUNT 9 #define MAX_CHAR_TMP 128