[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7464 - gnunet-qt/src/plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7464 - gnunet-qt/src/plugins/fs |
Date: |
Sat, 19 Jul 2008 05:05:47 -0600 (MDT) |
Author: durner
Date: 2008-07-19 05:05:47 -0600 (Sat, 19 Jul 2008)
New Revision: 7464
Added:
gnunet-qt/src/plugins/fs/fs-open-uri.cc
gnunet-qt/src/plugins/fs/fs-open-uri.h
gnunet-qt/src/plugins/fs/fs-open-uri.ui
Modified:
gnunet-qt/src/plugins/fs/Makefile.am
gnunet-qt/src/plugins/fs/downloadController.cc
gnunet-qt/src/plugins/fs/fs.cc
gnunet-qt/src/plugins/fs/fs.h
Log:
"open uri" function for CHK uris
Modified: gnunet-qt/src/plugins/fs/Makefile.am
===================================================================
--- gnunet-qt/src/plugins/fs/Makefile.am 2008-07-19 10:58:53 UTC (rev
7463)
+++ gnunet-qt/src/plugins/fs/Makefile.am 2008-07-19 11:05:47 UTC (rev
7464)
@@ -12,6 +12,7 @@
downloadItemDelegate.cc \
fshelper.cc \
fs.cc \
+ fs-open-uri.cc \
fs-search.cc \
searchSummaryController.cc \
searchSummaryModel.cc \
@@ -26,6 +27,7 @@
downloadItemDelegate.h \
fshelper.h \
fs.h \
+ fs-open-uri.h \
fs-search.h \
searchSummaryController.h \
searchSummaryModel.h \
@@ -42,6 +44,7 @@
moc_downloadItemDelegate.cpp \
moc_fshelper.cpp \
moc_fs.cpp \
+ moc_fs-open-uri.cpp \
moc_fs-search.cpp \
moc_searchSummaryController.cpp \
moc_searchSummaryModel.cpp \
@@ -51,6 +54,7 @@
moc_searchController.cpp \
moc_searchItemDelegate.cpp \
ui_fs.h \
+ ui_fs-open-uri.h \
ui_fs-search-result.h \
ui_fs-upload.h \
ui_textEditor.h
@@ -58,6 +62,7 @@
downloadController.cc: ui_fs.h
downloadController.cc: ui_fs-search-result.h
downloadController.cc: ui_fs-upload.h
+downloadController.cc: ui_fs-open-uri.h
libgnunetqtmodule_fs_la_LIBADD = \
$(top_builddir)/src/common/libgnunetqt_common.la
@@ -67,6 +72,7 @@
EXTRA_DIST = \
fs.ui \
+ fs-open-uri.ui \
fs-search-result.ui \
fs-upload.ui \
textEditor.ui
Modified: gnunet-qt/src/plugins/fs/downloadController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/downloadController.cc 2008-07-19 10:58:53 UTC
(rev 7463)
+++ gnunet-qt/src/plugins/fs/downloadController.cc 2008-07-19 11:05:47 UTC
(rev 7464)
@@ -34,10 +34,10 @@
GFSDownloadController::GFSDownloadController(GFSPlugin *fs)
{
QTreeView *view;
-
+
this->fs = fs;
view = fs->downloadView();
-
+
downloadModel.setColumnCount(COL_COUNT);
downloadModel.setHeaderData(COL_FILENAME, Qt::Horizontal, tr("Filename"),
Qt::DisplayRole);
@@ -51,7 +51,7 @@
Qt::DisplayRole);
downloadModel.setHeaderData(COL_DST_PATH, Qt::Horizontal,
tr("Destination path"), Qt::DisplayRole);
-
+
view->setModel(downloadModel.abstractItemModel());
view->setItemDelegate(&delegate);
view->hideColumn(COL_ETA);
@@ -67,7 +67,7 @@
{
QModelIndex item, parent;
double progress;
-
+
// compute progress for this entry
progress = ((double) completed) / total * 100;
if (isnan(progress))
@@ -79,7 +79,7 @@
downloadModel.setData(item, QVariant(progress), Qt::DisplayRole);
item = downloadModel.index(idx->row(), COL_ETA, parent);
downloadModel.setData(item, QVariant(eta), Qt::DisplayRole);
-
+
// compute overall progress for parent items
while(parent.isValid())
{
@@ -87,7 +87,7 @@
double overallProgress = 0;
GNUNET_CronTime overallETA = 0;
QModelIndex progressIdx;
-
+
item = parent.child(children, COL_PROGRESS);
while (item.isValid())
{
@@ -97,16 +97,16 @@
overallETA += downloadModel.data(item).toLongLong();
item = parent.child(children, COL_PROGRESS);
}
-
+
progressIdx = downloadModel.index(parent.row(), COL_PROGRESS,
parent.parent());
downloadModel.setData(progressIdx, QVariant(overallProgress / children),
Qt::DisplayRole);
progressIdx = downloadModel.index(parent.row(), COL_ETA, parent.parent());
downloadModel.setData(progressIdx, QVariant(overallETA), Qt::DisplayRole);
-
+
parent = parent.parent();
}
-
+
downloadModel.unlock();
}
@@ -130,11 +130,11 @@
QString gnDir;
// FIXME: check if download is pending
-
+
// cleanup filename
if (gnPath.endsWith("/") || gnPath.endsWith("\\"))
gnPath = gnPath.left(gnPath.length() - 1);
-
+
path = gnPath.replace("//", "/");
while (path != gnPath)
{
@@ -155,26 +155,26 @@
gnPath = path;
path = gnPath.replace("..", ".");
}
-
+
// generate name if needed
if (name == "")
name = uri.toString().left(16);
GNUNETQT_ASSERT(name != "");
-
+
if (destPath == "")
- {
+ {
char *dir;
-
+
GNUNET_GC_get_configuration_value_filename(fs->config(), "FS",
"INCOMINGDIR",
"$HOME/gnunet-downloads/", &dir);
destPath = dir;
}
-
+
path = destPath + QDir::separator() + gnPath + QDir::separator() + name;
-
+
GNUNET_FSUI_download_start(fs->context(), anonymity, recursive, uri.uri(),
meta.meta(),
path.toCString(), parentSearch, NULL /* FIXME */);
-
+
downloadList.insert(uri, searchIdx);
}
@@ -187,40 +187,40 @@
QStandardItem *item, *parentItem;
QString displayPath;
unsigned long long size;
-
+
displayPath = QFileInfo(name).fileName();
if (displayPath == "")
displayPath = QDir(name).dirName();
-
+
downloadModel.lock();
-
+
if (parent)
parentItem = downloadModel.itemFromIndex(downloadModel.index(parent->row(),
parent->column(), parent->parent()));
else
parentItem = downloadModel.invisibleRootItem();
-
+
item = new QStandardItem(displayPath);
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 = GNUNET_ECRS_uri_get_file_size(fi->uri);
tmpIdx = downloadModel.index(item->index().row(), COL_SIZE);
downloadModel.setData(tmpIdx, QVariant(GString::fromByteSize(size)),
Qt::DisplayRole);
-
+
idx = new QPersistentModelIndex(item->index());
downloadModel.unlock();
setProgress(idx, completed, total, (GNUNET_CronTime) -1);
-
+
state(idx, (total != completed) ? GNUNET_FSUI_download_started :
GNUNET_FSUI_download_completed);
-
+
return idx;
}
@@ -236,7 +236,7 @@
GFSDownloadList::iterator it;
it = downloadList.find(uri);
- if (it != downloadList.end())
+ if (it != downloadList.end() && it->isValid())
fs->searchController()->downloadCompleted(*it, file);
state(idx, GNUNET_FSUI_download_completed);
}
@@ -244,11 +244,11 @@
void GFSDownloadController::state(QPersistentModelIndex *idx,
GNUNET_FSUI_EventType type)
{
QModelIndex index;
-
+
downloadModel.lock();
-
+
index = downloadModel.index(idx->row(), COL_STATUS, idx->parent());
-
+
downloadModel.setData(index, QVariant(fs->fsuiState(type)), Qt::DisplayRole);
if (type == GNUNET_FSUI_download_stopped)
downloadModel.removeRow(idx->row());
@@ -256,7 +256,7 @@
downloadModel.setData(index,
QVariant(type == GNUNET_FSUI_download_completed || type ==
GNUNET_FSUI_download_aborted),
Qt::UserRole);
-
+
downloadModel.unlock();
}
@@ -264,25 +264,25 @@
{
int row = 0;
QModelIndex idx;
-
+
downloadModel.lock();
-
+
idx = downloadModel.index(0, COL_STATUS);
-
+
while(idx.isValid())
{
if (downloadModel.data(idx, Qt::UserRole).toInt() == 1)
{
QStandardItem *item;
-
+
item = downloadModel.item(idx.row());
GNUNET_FSUI_download_stop((struct GNUNET_FSUI_DownloadList *)
- item->data(Qt::UserRole).value<void *>());
+ item->data(Qt::UserRole).value<void *>());
}
else
idx = downloadModel.index(++row, COL_STATUS);
}
-
+
downloadModel.unlock();
}
Added: gnunet-qt/src/plugins/fs/fs-open-uri.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs-open-uri.cc (rev 0)
+++ gnunet-qt/src/plugins/fs/fs-open-uri.cc 2008-07-19 11:05:47 UTC (rev
7464)
@@ -0,0 +1,27 @@
+/*
+ This file is part of gnunet-qt.
+ (C) 2008 Nils Durner (and other contributing authors)
+
+ gnunet-qt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ gnunet-qt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#include "fs-open-uri.h"
+
+GFSOpenURIDialog::GFSOpenURIDialog(QWidget *parent) : QDialog(parent)
+{
+ setupUi(this);
+}
+
Added: gnunet-qt/src/plugins/fs/fs-open-uri.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs-open-uri.h (rev 0)
+++ gnunet-qt/src/plugins/fs/fs-open-uri.h 2008-07-19 11:05:47 UTC (rev
7464)
@@ -0,0 +1,35 @@
+/*
+ This file is part of gnunet-qt.
+ (C) 2008 Nils Durner (and other contributing authors)
+
+ gnunet-qt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ gnunet-qt is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef GFSOPENURIDIALOG_H_
+#define GFSOPENURIDIALOG_H_
+
+#include <QDialog>
+#include "ui_fs-open-uri.h"
+
+class GFSOpenURIDialog: public QDialog, public Ui::dlgOpenURI
+{
+ Q_OBJECT
+
+public:
+ GFSOpenURIDialog(QWidget *parent = NULL);
+};
+
+#endif /* GFSOPENURIDIALOG_H_ */
Added: gnunet-qt/src/plugins/fs/fs-open-uri.ui
===================================================================
--- gnunet-qt/src/plugins/fs/fs-open-uri.ui (rev 0)
+++ gnunet-qt/src/plugins/fs/fs-open-uri.ui 2008-07-19 11:05:47 UTC (rev
7464)
@@ -0,0 +1,193 @@
+<ui version="4.0" >
+ <class>dlgOpenURI</class>
+ <widget class="QDialog" name="dlgOpenURI" >
+ <property name="windowModality" >
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>513</width>
+ <height>245</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Open URI</string>
+ </property>
+ <property name="windowIcon" >
+ <iconset resource="../../../pixmaps/pixmaps.qrc" >
+
<normaloff>:/pixmaps/gnunet-logo-small.png</normaloff>:/pixmaps/gnunet-logo-small.png</iconset>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QLabel" name="label" >
+ <property name="text" >
+ <string>Paste GNUnet URI:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="uriInput" >
+ <property name="statusTip" >
+ <string>Paste the GNUnet URI to download here. URIs identify content
in a unique way and start with "gnunet://".</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <widget class="QLabel" name="label_3" >
+ <property name="text" >
+ <string>File / Directory name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="file" />
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>20</width>
+ <height>5</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QLabel" name="label_2" >
+ <property name="text" >
+ <string>download with anonymity:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="anon" >
+ <property name="maximum" >
+ <number>2000000</number>
+ </property>
+ <property name="value" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="recursive" >
+ <property name="text" >
+ <string>recursively</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2" >
+ <property name="orientation" >
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType" >
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>10</width>
+ <height>15</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons" >
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="../../../pixmaps/pixmaps.qrc" />
+ </resources>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>dlgOpenURI</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>dlgOpenURI</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel" >
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel" >
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc 2008-07-19 10:58:53 UTC (rev 7463)
+++ gnunet-qt/src/plugins/fs/fs.cc 2008-07-19 11:05:47 UTC (rev 7464)
@@ -41,6 +41,7 @@
#include "fs.h"
#include "fs-search.h"
#include "ecrsuri.h"
+#include "fs-open-uri.h"
#include "searchController.h"
#include "downloadController.h"
@@ -165,6 +166,20 @@
cfg = params->config;
ectx = params->errorContext;
+ // Menu
+ GMenuAction action;
+ GMenuStruct::iterator itMenu;
+
+ action.name = "gnunet-qt::fs::openURI";
+ action.text = tr("Open &URI");
+ action.receiver = this;
+ action.receiverSlot = SLOT(openURI());
+ action.action = &actionOpenURI;
+
+ for (itMenu = params->menu->begin(); itMenu != params->menu->end(); itMenu++)
+ if (itMenu->name == "gnunet-qt::core::file")
+ itMenu->actions.push_front(action);
+
// FS tab
connect(pbSearch, SIGNAL(clicked(bool)), this, SLOT(searchClicked()));
connect(cmbSearchFor->lineEdit(), SIGNAL(returnPressed()), this,
SLOT(searchClicked()));
@@ -222,6 +237,30 @@
delete downloadCntrl;
}
+void GFSPlugin::openURI()
+{
+ GFSOpenURIDialog *dialog;
+ QPersistentModelIndex idx;
+ QString uri;
+ GFSEcrsUri ecrsUri;
+ GFSEcrsMetaData md;
+
+ dialog = new GFSOpenURIDialog(this);
+ if (dialog->exec() == QDialog::Accepted)
+ {
+ QPixmap icon;
+
+ uri = dialog->uriInput->toPlainText();
+ ecrsUri = uri;
+ downloadCntrl->start(idx, NULL, ecrsUri,
+ md, "", dialog->file->text(), "", dialog->anon->value(),
+ dialog->recursive->isChecked());
+
+ icon.load(":/pixmaps/download.png");
+ emit setStatusText(icon, tr("Download of \"%0\"
queued.").arg(ecrsUri.toString().left(16)));
+ }
+}
+
void GFSPlugin::openDownloadClicked()
{
QModelIndexList sel;
@@ -479,11 +518,6 @@
downloadCntrl->cancel(*itCancel);
}
-void GFSPlugin::openURIClicked()
-{
-
-}
-
void GFSPlugin::clearULClicked()
{
uploadCntrl->clear();
Modified: gnunet-qt/src/plugins/fs/fs.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs.h 2008-07-19 10:58:53 UTC (rev 7463)
+++ gnunet-qt/src/plugins/fs/fs.h 2008-07-19 11:05:47 UTC (rev 7464)
@@ -74,6 +74,7 @@
int anonymity, bool recurse);
protected:
+ QAction *actionOpenURI;
class GFSSearchController *searchCntrl;
class GFSUploadController *uploadCntrl;
class GFSDownloadController *downloadCntrl;
@@ -88,6 +89,7 @@
int setNetworkStatus(const QPixmap &icon, const QString strStatus);
protected slots:
+ void openURI();
void searchClicked();
void chooseClicked();
void uploadClicked();
@@ -95,7 +97,6 @@
void cancelDLClicked();
void clearULClicked();
void openDownloadClicked();
- void openURIClicked();
};
#endif /*FS_H_*/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7464 - gnunet-qt/src/plugins/fs,
gnunet <=