priority column added in transfers dialog

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1522 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
alexandrut 2009-08-11 20:27:59 +00:00
parent 2807a778e8
commit 3083165767
3 changed files with 41 additions and 33 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.
****************************************************************/ ****************************************************************/
@ -34,8 +34,9 @@
#define PROGRESS 4 #define PROGRESS 4
#define SOURCES 5 #define SOURCES 5
#define STATUS 6 #define STATUS 6
#define REMAINING 7 #define PRIORITY 7
#define ID 8 #define REMAINING 8
#define ID 9
#define MAX_CHAR_TMP 128 #define MAX_CHAR_TMP 128

View File

@ -78,7 +78,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
connect( ui.downloadList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downloadListCostumPopupMenu( QPoint ) ) ); connect( ui.downloadList, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downloadListCostumPopupMenu( QPoint ) ) );
// Set Download list model // Set Download list model
DLListModel = new QStandardItemModel(0,9); DLListModel = new QStandardItemModel(0,ID + 1);
DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: file name")); DLListModel->setHeaderData(NAME, Qt::Horizontal, tr("Name", "i.e: file name"));
DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size"));
DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", "")); DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", ""));
@ -86,6 +86,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded")); DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources")); DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources"));
DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status")); DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status"));
DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Priority"));
DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left")); DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left"));
DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID")); DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID"));
ui.downloadList->setModel(DLListModel); ui.downloadList->setModel(DLListModel);
@ -112,6 +113,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
_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 (PRIORITY, QHeaderView::Interactive);
_header->setResizeMode (REMAINING, QHeaderView::Interactive); _header->setResizeMode (REMAINING, QHeaderView::Interactive);
_header->resizeSection ( NAME, 170 ); _header->resizeSection ( NAME, 170 );
@ -121,6 +123,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
_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 ( PRIORITY, 100 );
_header->resizeSection ( REMAINING, 100 ); _header->resizeSection ( REMAINING, 100 );
// Set Upload list model // Set Upload list model
@ -352,7 +355,8 @@ TransfersDialog::~TransfersDialog()
int TransfersDialog::addItem(QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed, QString sources, QString status, qlonglong completed, qlonglong remaining) int TransfersDialog::addItem(QString symbol, QString name, QString coreID, qlonglong fileSize, double progress, double dlspeed,
QString sources, QString status, QString priority, qlonglong completed, qlonglong remaining)
{ {
int row; int row;
QString sl; QString sl;
@ -370,6 +374,7 @@ int TransfersDialog::addItem(QString symbol, QString name, QString coreID, qlong
DLListModel->setData(DLListModel->index(row, PROGRESS), QVariant((double)progress)); 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, PRIORITY), QVariant((QString)priority));
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));
@ -445,8 +450,9 @@ bool TransfersDialog::addPeerToItem(int row, QString symbol, QString name, QStri
QStandardItem *i5 = new QStandardItem(); i5->setData(QVariant((double)progress), 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 *i6 = new QStandardItem(); i6->setData(QVariant((QString)sources), Qt::DisplayRole);
QStandardItem *i7 = new QStandardItem(); i7->setData(QVariant((QString)status), 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 *i8 = new QStandardItem(); i8->setData(QVariant((QString)tr("")), Qt::DisplayRole); // blank field for priority
QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant((QString)coreID), Qt::DisplayRole); QStandardItem *i9 = new QStandardItem(); i9->setData(QVariant((qlonglong)remaining), Qt::DisplayRole);
QStandardItem *i10 = new QStandardItem(); i10->setData(QVariant((QString)coreID), Qt::DisplayRole);
/* set status icon in the name field */ /* set status icon in the name field */
if (status == "Downloading") { if (status == "Downloading") {
@ -471,6 +477,7 @@ bool TransfersDialog::addPeerToItem(int row, QString symbol, QString name, QStri
items.append(i7); items.append(i7);
items.append(i8); items.append(i8);
items.append(i9); items.append(i9);
items.append(i10);
dlItem->appendRow(items); dlItem->appendRow(items);
@ -536,6 +543,9 @@ void TransfersDialog::editItem(int row, int column, QVariant data)
case STATUS: case STATUS:
DLListModel->setData(DLListModel->index(row, STATUS), data); DLListModel->setData(DLListModel->index(row, STATUS), data);
break; break;
case PRIORITY:
DLListModel->setData(DLListModel->index(row, PRIORITY), data);
break;
case COMPLETED: case COMPLETED:
DLListModel->setData(DLListModel->index(row, COMPLETED), data); DLListModel->setData(DLListModel->index(row, COMPLETED), data);
break; break;
@ -551,7 +561,7 @@ void TransfersDialog::editItem(int row, int column, QVariant data)
/* get the list of Transfers from the RsIface. **/ /* get the list of Transfers from the RsIface. **/
void TransfersDialog::insertTransfers() void TransfersDialog::insertTransfers()
{ {
QString symbol, name, sources, status, coreId; QString symbol, name, sources, status, priority, coreId;
qlonglong fileSize, completed, remaining; qlonglong fileSize, completed, remaining;
double progress, dlspeed; double progress, dlspeed;
@ -653,14 +663,15 @@ void TransfersDialog::insertTransfers()
status = tr("Unknown"); break; status = tr("Unknown"); break;
} }
priority = ""; /* for already downloading files */
completed = info.transfered; completed = info.transfered;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
int addedRow = addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining); int addedRow = addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, priority, completed, remaining);
/* if found in selectedIds -> select again */ /* if found in selectedIds -> select again */
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) { if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) {
selection->select(DLListModel->index(dlCount, 0), selection->select(DLListModel->index(dlCount, NAME),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
} }
@ -743,36 +754,32 @@ void TransfersDialog::insertTransfers()
dlspeed = 0; dlspeed = 0;
sources = ""; sources = "";
completed = 0; completed = 0;
status = tr("Queued");
remaining = 0; remaining = 0;
int priority = dit->priority;
QString spriority;
switch (dit->priority) { switch (dit->priority) {
case 0: case 0:
spriority = tr("Low"); priority = tr("Low");
break; break;
case 1: case 1:
spriority = tr("Normal"); priority = tr("Normal");
break; break;
case 2: case 2:
spriority = tr("High"); priority = tr("High");
break; break;
case 3: case 3:
spriority = tr("Auto"); priority = tr("Auto");
break; break;
default: default:
spriority = tr(""); priority = tr("Auto");
break; break;
} }
status = tr("Queued [") + spriority + tr("]"); addItem("", name, coreId, fileSize, progress, dlspeed, sources, status, priority, completed, remaining);
addItem("", name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining);
/* if found in selectedIds -> select again */ /* if found in selectedIds -> select again */
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), dit->hash)) { if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), dit->hash)) {
selection->select(DLListModel->index(dlCount, 0), selection->select(DLListModel->index(dlCount, NAME),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
} }

View File

@ -146,7 +146,7 @@ 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, QString priority, 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); 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);