[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r4713 - in gnunet-qt/src: common include plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r4713 - in gnunet-qt/src: common include plugins/fs |
Date: |
Sun, 25 Mar 2007 14:45:59 -0600 (MDT) |
Author: durner
Date: 2007-03-25 14:45:58 -0600 (Sun, 25 Mar 2007)
New Revision: 4713
Modified:
gnunet-qt/src/common/gstring.cc
gnunet-qt/src/include/gnunet_qt_common.h
gnunet-qt/src/plugins/fs/downloadController.cc
gnunet-qt/src/plugins/fs/downloadController.h
gnunet-qt/src/plugins/fs/downloadItemDelegate.cc
gnunet-qt/src/plugins/fs/fs.cc
Log:
show download size
Modified: gnunet-qt/src/common/gstring.cc
===================================================================
--- gnunet-qt/src/common/gstring.cc 2007-03-25 20:45:38 UTC (rev 4712)
+++ gnunet-qt/src/common/gstring.cc 2007-03-25 20:45:58 UTC (rev 4713)
@@ -140,4 +140,25 @@
return cstr = strdup(bytes.data());
}
+GString GString::fromByteSize(qlonglong size)
+{
+ GString ret;
+ char *sz;
+
+ sz = (char *) malloc(14);
+ if (size >= 1000000000)
+ snprintf(sz, 13, "%.2f %s", size / 1000000000.0,
qPrintable(QObject::tr("GB")));
+ else if (size >= 1000000)
+ snprintf(sz, 13, "%.2f %s", size / 1000000.0,
qPrintable(QObject::tr("MB")));
+ else if (size >= 1000)
+ snprintf(sz, 13, "%.2f %s", size / 1000.0, qPrintable(QObject::tr("KB")));
+ else
+ snprintf(sz, 13, "%.2f %s", (double) size,
qPrintable(QObject::tr("Bytes")));
+
+ ret = sz;
+ ::free(sz);
+
+ return ret;
+}
+
/* end of gstring.cc */
Modified: gnunet-qt/src/include/gnunet_qt_common.h
===================================================================
--- gnunet-qt/src/include/gnunet_qt_common.h 2007-03-25 20:45:38 UTC (rev
4712)
+++ gnunet-qt/src/include/gnunet_qt_common.h 2007-03-25 20:45:58 UTC (rev
4713)
@@ -101,6 +101,8 @@
* @brief Return the content as UTF-8 encoded C string
*/
char *toUtf8CStr();
+
+ static GString fromByteSize(qlonglong size);
protected:
char *cstr;
};
Modified: gnunet-qt/src/plugins/fs/downloadController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.cc 2007-03-25 20:45:38 UTC
(rev 4712)
+++ gnunet-qt/src/plugins/fs/downloadController.cc 2007-03-25 20:45:58 UTC
(rev 4713)
@@ -38,9 +38,11 @@
this->fs = fs;
view = fs->downloadView();
- downloadModel.setColumnCount(5);
+ downloadModel.setColumnCount(COL_COUNT);
downloadModel.setHeaderData(COL_FILENAME, Qt::Horizontal, tr("Filename"),
Qt::DisplayRole);
+ downloadModel.setHeaderData(COL_SIZE, Qt::Horizontal, tr("Size"),
+ Qt::DisplayRole);
downloadModel.setHeaderData(COL_PROGRESS, Qt::Horizontal, tr("Progress"),
Qt::DisplayRole);
downloadModel.setHeaderData(COL_STATUS, Qt::Horizontal, tr("Status"),
@@ -174,13 +176,14 @@
}
QPersistentModelIndex *GFSDownloadController::started(struct FSUI_DownloadList
*handle,
- QPersistentModelIndex *parent, QString name, unsigned long long total,
+ QPersistentModelIndex *parent, const ECRS_FileInfo *fi, QString name,
unsigned long long total,
unsigned long long completed)
{
QModelIndex tmpIdx;
QPersistentModelIndex *idx;
QStandardItem *item, *parentItem;
QString displayPath;
+ unsigned long long size;
displayPath = QFileInfo(name).fileName();
if (displayPath == "")
@@ -193,13 +196,18 @@
parentItem = downloadModel.invisibleRootItem();
item = new QStandardItem(displayPath);
- item->setColumnCount(5);
+ item->setColumnCount(COL_COUNT);
item->setData(QVariant::fromValue((void *) handle), Qt::UserRole);
parentItem->appendRow(item);
tmpIdx = downloadModel.index(item->index().row(), COL_DST_PATH);
downloadModel.setData(tmpIdx, QVariant(name), Qt::DisplayRole);
+ size = ECRS_fileSize(fi->uri);
+ tmpIdx = downloadModel.index(item->index().row(), COL_SIZE);
+ downloadModel.setData(tmpIdx, QVariant(GString::fromByteSize(size)),
+ Qt::DisplayRole);
+
idx = new QPersistentModelIndex(item->index());
setProgress(idx, completed, total, (cron_t) -1);
Modified: gnunet-qt/src/plugins/fs/downloadController.h
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.h 2007-03-25 20:45:38 UTC
(rev 4712)
+++ gnunet-qt/src/plugins/fs/downloadController.h 2007-03-25 20:45:58 UTC
(rev 4713)
@@ -38,6 +38,9 @@
Q_OBJECT
public:
+ typedef enum {COL_FILENAME, COL_SIZE, COL_PROGRESS, COL_STATUS, COL_ETA,
+ COL_DST_PATH, COL_COUNT} GDownloadCols;
+
GFSDownloadController(GFSPlugin *fs);
virtual ~GFSDownloadController();
@@ -58,8 +61,8 @@
QString destPath, int anonymity, bool recursive);
QPersistentModelIndex *started(struct FSUI_DownloadList *handle,
- QPersistentModelIndex *parent, QString name, unsigned long long total,
- unsigned long long completed);
+ QPersistentModelIndex *parent, const ECRS_FileInfo *fi, QString name,
+ unsigned long long total, unsigned long long completed);
void progress(QPersistentModelIndex *idx, unsigned long long completed,
unsigned long long total, cron_t eta);
@@ -75,8 +78,6 @@
QAbstractItemModel *model();
protected:
typedef QMap<GFSEcrsUri, QPersistentModelIndex> GFSDownloadList;
- typedef enum {COL_FILENAME, COL_PROGRESS, COL_STATUS, COL_ETA,
- COL_DST_PATH} GDownloadCols;
GFSPlugin *fs;
QStandardItemModel downloadModel;
Modified: gnunet-qt/src/plugins/fs/downloadItemDelegate.cc
===================================================================
--- gnunet-qt/src/plugins/fs/downloadItemDelegate.cc 2007-03-25 20:45:38 UTC
(rev 4712)
+++ gnunet-qt/src/plugins/fs/downloadItemDelegate.cc 2007-03-25 20:45:58 UTC
(rev 4713)
@@ -28,6 +28,7 @@
#include <QApplication>
#include <GNUnet/gnunet_util.h>
#include "downloadItemDelegate.h"
+#include "downloadController.h"
QSize GFSDownloadItemDelegate::sizeHint(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
@@ -38,7 +39,7 @@
{
int col = index.column();
- if (col == 1)
+ if (col == GFSDownloadController::COL_PROGRESS)
{
QStyleOptionProgressBarV2 barOptions;
double percentage;
@@ -58,7 +59,7 @@
return;
}
- else if (col == 3)
+ else if (col == GFSDownloadController::COL_ETA)
{
cron_t time = index.model()->data(index).toLongLong();
Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc 2007-03-25 20:45:38 UTC (rev 4712)
+++ gnunet-qt/src/plugins/fs/fs.cc 2007-03-25 20:45:58 UTC (rev 4713)
@@ -100,10 +100,12 @@
case FSUI_download_started:
return downloadCntrl->started(event->data.DownloadStarted.dc.pos,
(QPersistentModelIndex *) event->data.DownloadStarted.dc.pcctx,
+ &event->data.DownloadStarted.fi,
event->data.DownloadStarted.filename,
event->data.DownloadStarted.total, 0);
case FSUI_download_resumed:
return downloadCntrl->started(event->data.DownloadResumed.dc.pos,
(QPersistentModelIndex *) event->data.DownloadResumed.dc.pcctx,
+ &event->data.DownloadResumed.fi,
event->data.DownloadResumed.filename,
event->data.DownloadResumed.total,
event->data.DownloadResumed.completed);
case FSUI_download_progress:
@@ -181,7 +183,7 @@
treeSearches->setColumnWidth(0, 125);
treeSearches->setColumnWidth(1, 80);
treeUploads->setColumnWidth(0, 250);
- treeDownloads->setColumnWidth(0, 250);
+ treeDownloads->setColumnWidth(0, 150);
treeDownloads->setEditTriggers(QAbstractItemView::NoEditTriggers);
treeSearches->setEditTriggers(QAbstractItemView::NoEditTriggers);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r4713 - in gnunet-qt/src: common include plugins/fs,
gnunet <=