[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7560 - gnunet-qt/src/plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7560 - gnunet-qt/src/plugins/fs |
Date: |
Thu, 14 Aug 2008 14:52:59 -0600 (MDT) |
Author: durner
Date: 2008-08-14 14:52:59 -0600 (Thu, 14 Aug 2008)
New Revision: 7560
Modified:
gnunet-qt/src/plugins/fs/fs-search-result.ui
gnunet-qt/src/plugins/fs/fs-search.cc
gnunet-qt/src/plugins/fs/fs-search.h
Log:
"Copy URI" menu for search results
Modified: gnunet-qt/src/plugins/fs/fs-search-result.ui
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search-result.ui 2008-08-14 20:07:48 UTC
(rev 7559)
+++ gnunet-qt/src/plugins/fs/fs-search-result.ui 2008-08-14 20:52:59 UTC
(rev 7560)
@@ -153,6 +153,11 @@
<string>Download</string>
</property>
</action>
+ <action name="actionCopy_URI" >
+ <property name="text" >
+ <string>Copy URI</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="../../../pixmaps/pixmaps.qrc" />
Modified: gnunet-qt/src/plugins/fs/fs-search.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.cc 2008-08-14 20:07:48 UTC (rev
7559)
+++ gnunet-qt/src/plugins/fs/fs-search.cc 2008-08-14 20:52:59 UTC (rev
7560)
@@ -26,6 +26,7 @@
#include <QHeaderView>
#include <QMenu>
+#include <QClipboard>
#include <extractor.h>
#include "gnunet_qt_common.h"
@@ -35,19 +36,21 @@
GFSSearch::GFSSearch(class GFSPlugin *fs, QTabWidget *tab) : QWidget()
{
QHeaderView *header;
-
+
setupUi(this);
header = treeResults->header();
header->setContextMenuPolicy(Qt::CustomContextMenu);
treeResults->setUniformRowHeights(false);
+ treeResults->addAction(actionCopy_URI);
treeResults->addAction(actionDownload);
treeResults->setEditTriggers(QAbstractItemView::NoEditTriggers);
this->tab = tab;
this->fs = fs;
-
+
connect(pbClose, SIGNAL(clicked(bool)), this, SLOT(closeClicked()));
connect(pbDownload, SIGNAL(clicked(bool)), this, SLOT(downloadClicked()));
+ connect(actionCopy_URI, SIGNAL(triggered()), this, SLOT(copyURI()));
connect(actionDownload, SIGNAL(triggered()), this, SLOT(downloadClicked()));
connect(header, SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(headerRightClicked(const QPoint &)));
@@ -65,25 +68,53 @@
QModelIndexList allSel;
GPersistentModelIndexList uniqSel;
QModelIndexList::iterator it;
-
+
/* Every column is treated as separate selection */
allSel = treeResults->selectionModel()->selectedIndexes();
for (it = allSel.begin(); it != allSel.end(); it++)
{
QModelIndex &idx = *it;
-
+
if (idx.column() == 0)
uniqSel.append(idx);
}
-
+
emit download(m, uri, uniqSel, spinAnon->value(), cbRecursive->isChecked());
}
+void GFSSearch::copyURI()
+{
+ QModelIndexList allSel;
+ GPersistentModelIndexList uniqSel;
+ QModelIndexList::iterator it;
+ QString strUris;
+
+ /* Every column is treated as separate selection */
+ allSel = treeResults->selectionModel()->selectedIndexes();
+ for (it = allSel.begin(); it != allSel.end(); it++)
+ {
+ QModelIndex &idx = *it;
+
+ if (idx.column() == MODEL_IDX(SEARCH_URI_COLUMN))
+ {
+ if (strUris != "")
+#if defined(Q_WS_WIN)
+ strUris += "\r\n";
+#else
+ strUris += "\n";
+#endif
+ strUris += idx.model()->data(idx).toString();
+ }
+ }
+
+ QApplication::clipboard()->setText(strUris);
+}
+
void GFSSearch::resultExpanded(const QModelIndex &index)
{
QModelIndex idx;
GItemModel *model;
-
+
model = (GItemModel *) index.model();
model->lock();
if (model->data(index, Qt::UserRole) != RESULT_DOWNLOADED)
@@ -92,16 +123,16 @@
if (model->data(idx) == "application/gnunet-directory")
{
GPersistentModelIndexList list;
-
+
list.append(index);
-
+
model->unlock();
emit download(m, uri, list, spinAnon->value(), false);
-
+
return;
}
}
-
+
model->unlock();
}
@@ -124,7 +155,7 @@
action = menu->addAction(strTitle);
action->setCheckable(true);
action->setData(QVariant(nr));
-
+
if (!treeResults->header()->isSectionHidden(MODEL_IDX(nr)))
action->setChecked(true);
}
@@ -133,35 +164,35 @@
{
EXTRACTOR_KeywordType typeItem;
QAction *item;
-
+
QMenu *menu = new QMenu(treeResults->header());
menu->move(pos);
-
+
typeItem = EXTRACTOR_getHighestKeywordTypeNumber();
while(typeItem >= (EXTRACTOR_KeywordType) 0)
{
QString strItem = metaTypeName(typeItem);
-
+
if (strItem != "")
addColumn(menu, strItem, typeItem);
-
+
typeItem = (EXTRACTOR_KeywordType) ((int) typeItem - 1);
}
-
+
// add availability and relevance
addColumn(menu, tr("Ranking"), SEARCH_RANK_COLUMN);
-
+
item = menu->exec();
if (item)
{
setColHidden(item->data().toInt(), !item->isChecked());
-
+
// kludge: hiding rows causes recalculation of row heights.
// This is necessary because we calculate the height for visible columns
only.
treeResults->setRowHidden(0, QModelIndex(), true);
treeResults->setRowHidden(0, QModelIndex(), false);
}
-
+
delete menu;
}
@@ -177,20 +208,20 @@
GIntList cols;
EXTRACTOR_KeywordType maxType;
int typeIdx;
-
+
maxType = EXTRACTOR_getHighestKeywordTypeNumber();
m->setColumnCount(SEARCH_MAX_COLUMN + 1);
for (typeIdx = 0; typeIdx <= maxType; typeIdx++)
{
GString label;
-
+
label = metaTypeName(MODEL_IDX(typeIdx));
label.proper();
-
+
m->setHeaderData(typeIdx, Qt::Horizontal, label, Qt::DisplayRole);
}
m->setHeaderData(SEARCH_RANK_COLUMN, Qt::Horizontal, tr("Ranking"),
Qt::DisplayRole);
-
+
// get columns to be displayed
// FIXME
cols.append(EXTRACTOR_FILENAME);
@@ -198,7 +229,7 @@
cols.append(EXTRACTOR_MIMETYPE);
cols.append(EXTRACTOR_THUMBNAIL_DATA);
cols.append(SEARCH_RANK_COLUMN);
-
+
for (colIdx = 0; colIdx < m->columnCount(); colIdx++)
setColHidden(MODEL_IDX(colIdx), !cols.contains(colIdx));
treeResults->setColumnWidth(0, 200);
@@ -210,14 +241,14 @@
void GFSSearch::setModel(GItemModel *model)
{
QByteArray data;
-
+
m = model;
treeResults->setModel(model->abstractItemModel());
connect(model, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this,
SLOT(resultInserted()));
setupColumns();
-
+
resultInserted();
}
Modified: gnunet-qt/src/plugins/fs/fs-search.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.h 2008-08-14 20:07:48 UTC (rev
7559)
+++ gnunet-qt/src/plugins/fs/fs-search.h 2008-08-14 20:52:59 UTC (rev
7560)
@@ -38,7 +38,7 @@
class GFSSearch : public QWidget, protected Ui::ResultWnd
{
Q_OBJECT
-
+
public:
GFSSearch(class GFSPlugin *fs, QTabWidget *tab);
void clear();
@@ -46,7 +46,7 @@
void setItemDelegate(QAbstractItemDelegate *itemDelegate);
void setUri(GFSEcrsUri &uri);
GItemModel *model();
-
+
signals:
void closeSearchWnd(GFSEcrsUri &uri);
void download(GItemModel *model, GFSEcrsUri &uri,
@@ -57,13 +57,14 @@
GFSEcrsUri uri;
QTabWidget *tab;
GItemModel *m;
-
+
void setColHidden(int col, bool hidden);
void setupColumns();
void addColumn(QMenu *menu, QString strTitle, int nr);
protected slots:
void closeClicked();
void downloadClicked();
+ void copyURI();
void headerRightClicked(const QPoint &pos);
void resultInserted();
void resultExpanded(const QModelIndex &index);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7560 - gnunet-qt/src/plugins/fs,
gnunet <=