[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4705 - gnunet-qt/src/plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4705 - gnunet-qt/src/plugins/fs |
Date: |
Sun, 25 Mar 2007 13:51:30 -0600 (MDT) |
Author: durner
Date: 2007-03-25 13:51:30 -0600 (Sun, 25 Mar 2007)
New Revision: 4705
Modified:
gnunet-qt/src/plugins/fs/downloadController.cc
gnunet-qt/src/plugins/fs/downloadController.h
Log:
use constants as column indexes
Modified: gnunet-qt/src/plugins/fs/downloadController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.cc 2007-03-25 19:33:52 UTC
(rev 4704)
+++ gnunet-qt/src/plugins/fs/downloadController.cc 2007-03-25 19:51:30 UTC
(rev 4705)
@@ -39,16 +39,21 @@
view = fs->downloadView();
downloadModel.setColumnCount(5);
- downloadModel.setHeaderData(0, Qt::Horizontal, tr("Filename"),
Qt::DisplayRole);
- downloadModel.setHeaderData(1, Qt::Horizontal, tr("Progress"),
Qt::DisplayRole);
- downloadModel.setHeaderData(2, Qt::Horizontal, tr("Status"),
Qt::DisplayRole);
- downloadModel.setHeaderData(3, Qt::Horizontal, tr("ETA"), Qt::DisplayRole);
- downloadModel.setHeaderData(4, Qt::Horizontal, tr("Destination path"),
Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_FILENAME, Qt::Horizontal, tr("Filename"),
+ Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_PROGRESS, Qt::Horizontal, tr("Progress"),
+ Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_STATUS, Qt::Horizontal, tr("Status"),
+ Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_ETA, Qt::Horizontal, tr("ETA"),
+ Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_DST_PATH, Qt::Horizontal,
+ tr("Destination path"), Qt::DisplayRole);
view->setModel(&downloadModel);
view->setItemDelegate(&delegate);
- view->hideColumn(3);
- view->hideColumn(4);
+ view->hideColumn(COL_ETA);
+ view->hideColumn(COL_DST_PATH);
}
GFSDownloadController::~GFSDownloadController()
@@ -67,9 +72,9 @@
progress = 0;
parent = idx->parent();
- item = downloadModel.index(idx->row(), 1, parent);
+ item = downloadModel.index(idx->row(), COL_PROGRESS, parent);
downloadModel.setData(item, QVariant(progress), Qt::DisplayRole);
- item = downloadModel.index(idx->row(), 3, parent);
+ item = downloadModel.index(idx->row(), COL_ETA, parent);
downloadModel.setData(item, QVariant(eta), Qt::DisplayRole);
// compute overall progress for parent items
@@ -80,20 +85,20 @@
cron_t overallETA = 0;
QModelIndex progressIdx;
- item = parent.child(children, 1);
+ item = parent.child(children, COL_PROGRESS);
while (item.isValid())
{
children++;
overallProgress += downloadModel.data(item).toDouble();
- item = parent.child(children, 3);
+ item = parent.child(children, COL_ETA);
overallETA += downloadModel.data(item).toLongLong();
- item = parent.child(children, 1);
+ item = parent.child(children, COL_PROGRESS);
}
- progressIdx = downloadModel.index(parent.row(), 1, parent.parent());
+ progressIdx = downloadModel.index(parent.row(), COL_PROGRESS,
parent.parent());
downloadModel.setData(progressIdx, QVariant(overallProgress / children),
Qt::DisplayRole);
- progressIdx = downloadModel.index(parent.row(), 3, parent.parent());
+ progressIdx = downloadModel.index(parent.row(), COL_ETA, parent.parent());
downloadModel.setData(progressIdx, QVariant(overallETA), Qt::DisplayRole);
parent = parent.parent();
@@ -192,7 +197,7 @@
item->setData(QVariant::fromValue((void *) handle), Qt::UserRole);
parentItem->appendRow(item);
- tmpIdx = downloadModel.index(item->index().row(), 4);
+ tmpIdx = downloadModel.index(item->index().row(), COL_DST_PATH);
downloadModel.setData(tmpIdx, QVariant(name), Qt::DisplayRole);
idx = new QPersistentModelIndex(item->index());
@@ -222,7 +227,7 @@
void GFSDownloadController::state(QPersistentModelIndex *idx, FSUI_EventType
type)
{
- QModelIndex index = downloadModel.index(idx->row(), 2, idx->parent());
+ QModelIndex index = downloadModel.index(idx->row(), COL_STATUS,
idx->parent());
downloadModel.setData(index, QVariant(fs->fsuiState(type)), Qt::DisplayRole);
if (type == FSUI_download_stopped)
@@ -236,7 +241,7 @@
void GFSDownloadController::clear()
{
int row = 0;
- QModelIndex idx = downloadModel.index(0, 2);
+ QModelIndex idx = downloadModel.index(0, COL_STATUS);
while(idx.isValid())
{
@@ -249,7 +254,7 @@
item->data(Qt::UserRole).value<void *>());
}
else
- idx = downloadModel.index(++row, 2);
+ idx = downloadModel.index(++row, COL_STATUS);
}
}
Modified: gnunet-qt/src/plugins/fs/downloadController.h
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.h 2007-03-25 19:33:52 UTC
(rev 4704)
+++ gnunet-qt/src/plugins/fs/downloadController.h 2007-03-25 19:51:30 UTC
(rev 4705)
@@ -75,6 +75,12 @@
QAbstractItemModel *model();
protected:
typedef QMap<GFSEcrsUri, QPersistentModelIndex> GFSDownloadList;
+
+ static const int COL_FILENAME = 0;
+ static const int COL_PROGRESS = 1;
+ static const int COL_STATUS = 2;
+ static const int COL_ETA = 3;
+ static const int COL_DST_PATH = 4;
GFSPlugin *fs;
QStandardItemModel downloadModel;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4705 - gnunet-qt/src/plugins/fs,
gnunet <=