[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r6855 - gnunet-qt/src/plugins/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r6855 - gnunet-qt/src/plugins/fs |
Date: |
Tue, 20 May 2008 15:27:12 -0600 (MDT) |
Author: durner
Date: 2008-05-20 15:27:12 -0600 (Tue, 20 May 2008)
New Revision: 6855
Modified:
gnunet-qt/src/plugins/fs/fs-search.cc
gnunet-qt/src/plugins/fs/fs-search.h
gnunet-qt/src/plugins/fs/fs.cc
gnunet-qt/src/plugins/fs/fshelper.h
gnunet-qt/src/plugins/fs/searchController.cc
gnunet-qt/src/plugins/fs/searchController.h
Log:
search result ranks
Modified: gnunet-qt/src/plugins/fs/fs-search.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.cc 2008-05-20 20:47:58 UTC (rev
6854)
+++ gnunet-qt/src/plugins/fs/fs-search.cc 2008-05-20 21:27:12 UTC (rev
6855)
@@ -105,36 +105,41 @@
treeResults->model()->setHeaderData(col, Qt::Horizontal, QVariant(hidden),
Qt::UserRole);
}
+void GFSSearch::addColumn(QMenu *menu, QString strTitle, int nr)
+{
+ QAction *action;
+
+ action = menu->addAction(strTitle);
+ action->setCheckable(true);
+ action->setData(QVariant(nr));
+
+ if (!treeResults->header()->isSectionHidden(MODEL_IDX(nr)))
+ action->setChecked(true);
+}
+
void GFSSearch::headerRightClicked(const QPoint &pos)
{
EXTRACTOR_KeywordType typeItem;
QAction *item;
- QHeaderView *header;
- header = treeResults->header();
-
QMenu *menu = new QMenu(treeResults->header());
menu->move(pos);
typeItem = EXTRACTOR_getHighestKeywordTypeNumber();
while(typeItem >= (EXTRACTOR_KeywordType) 0)
{
- QAction *action;
QString strItem = metaTypeName(typeItem);
if (strItem != "")
- {
- action = menu->addAction(strItem);
- action->setCheckable(true);
- action->setData(QVariant((int) typeItem));
-
- if (!header->isSectionHidden(MODEL_IDX(typeItem)))
- action->setChecked(true);
- }
+ addColumn(menu, strItem, typeItem);
typeItem = (EXTRACTOR_KeywordType) ((int) typeItem - 1);
}
+ // add availability and relevance
+ addColumn(menu, tr("Availability"), SEARCH_AVAIL_COLUMN);
+ addColumn(menu, tr("Relevance"), SEARCH_RELEVANCE_COLUMN);
+
item = menu->exec();
if (item)
{
@@ -173,6 +178,8 @@
m->setHeaderData(typeIdx, Qt::Horizontal, label, Qt::DisplayRole);
}
+ m->setHeaderData(SEARCH_AVAIL_COLUMN, Qt::Horizontal, tr("Availability"),
Qt::DisplayRole);
+ m->setHeaderData(SEARCH_RELEVANCE_COLUMN, Qt::Horizontal, tr("Relevance"),
Qt::DisplayRole);
// get columns to be displayed
// FIXME
@@ -180,6 +187,8 @@
cols.append(EXTRACTOR_FILE_SIZE);
cols.append(EXTRACTOR_MIMETYPE);
cols.append(EXTRACTOR_THUMBNAIL_DATA);
+ cols.append(SEARCH_AVAIL_COLUMN);
+ cols.append(SEARCH_RELEVANCE_COLUMN);
for (colIdx = 0; colIdx < m->columnCount(); colIdx++)
setColHidden(MODEL_IDX(colIdx), !cols.contains(colIdx));
Modified: gnunet-qt/src/plugins/fs/fs-search.h
===================================================================
--- gnunet-qt/src/plugins/fs/fs-search.h 2008-05-20 20:47:58 UTC (rev
6854)
+++ gnunet-qt/src/plugins/fs/fs-search.h 2008-05-20 21:27:12 UTC (rev
6855)
@@ -60,6 +60,7 @@
void setColHidden(int col, bool hidden);
void setupColumns();
+ void addColumn(QMenu *menu, QString strTitle, int nr);
protected slots:
void closeClicked();
void downloadClicked();
Modified: gnunet-qt/src/plugins/fs/fs.cc
===================================================================
--- gnunet-qt/src/plugins/fs/fs.cc 2008-05-20 20:47:58 UTC (rev 6854)
+++ gnunet-qt/src/plugins/fs/fs.cc 2008-05-20 21:27:12 UTC (rev 6855)
@@ -73,6 +73,11 @@
case GNUNET_FSUI_search_stopped:
searchCntrl->stopped((GFSSearchInfo *)
event->data.SearchStopped.sc.cctx);
break;
+ case GNUNET_FSUI_search_update:
+ searchCntrl->update((GFSSearchInfo *) event->data.SearchUpdate.sc.cctx,
+ &event->data.SearchUpdate.fi,
event->data.SearchUpdate.availability_rank,
+ event->data.SearchUpdate.applicability_rank);
+ break;
case GNUNET_FSUI_upload_started:
return uploadCntrl->started((QPersistentModelIndex *)
event->data.UploadStarted.uc.pcctx,
event->data.UploadStarted.filename, event->data.UploadStarted.total,
0);
Modified: gnunet-qt/src/plugins/fs/fshelper.h
===================================================================
--- gnunet-qt/src/plugins/fs/fshelper.h 2008-05-20 20:47:58 UTC (rev 6854)
+++ gnunet-qt/src/plugins/fs/fshelper.h 2008-05-20 21:27:12 UTC (rev 6855)
@@ -33,7 +33,9 @@
#define SEARCH_URI_COLUMN ((int) EXTRACTOR_getHighestKeywordTypeNumber() + 1)
#define SEARCH_META_COLUMN ((int) EXTRACTOR_getHighestKeywordTypeNumber() + 2)
-#define SEARCH_MAX_COLUMN SEARCH_META_COLUMN
+#define SEARCH_AVAIL_COLUMN ((int) EXTRACTOR_getHighestKeywordTypeNumber() + 3)
+#define SEARCH_RELEVANCE_COLUMN ((int) EXTRACTOR_getHighestKeywordTypeNumber()
+ 4)
+#define SEARCH_MAX_COLUMN SEARCH_RELEVANCE_COLUMN
/* Maps view index 0 ("Filename") to model index 1 (EXTRACTOR_FILENAME).
* We can't use unified indexes because row decorations (branches, +/-)
Modified: gnunet-qt/src/plugins/fs/searchController.cc
===================================================================
--- gnunet-qt/src/plugins/fs/searchController.cc 2008-05-20 20:47:58 UTC
(rev 6854)
+++ gnunet-qt/src/plugins/fs/searchController.cc 2008-05-20 21:27:12 UTC
(rev 6855)
@@ -229,6 +229,34 @@
searchSummaryCntrl->searchState(info->handle, event);
}
+void GFSSearchController::update(GFSSearchInfo *info, const
GNUNET_ECRS_FileInfo *finfo,
+ int avail, unsigned int relevance)
+{
+ QStandardItemModel *model;
+ GFSEcrsUri ecrsUri;
+ QModelIndexList lst;
+ int row;
+
+ model = info->model;
+ ecrsUri = finfo->uri;
+ lst = model->match(model->index(0, SEARCH_URI_COLUMN), Qt::EditRole,
+ ecrsUri.serialized(), 1, Qt::MatchExactly | Qt::MatchCaseSensitive);
+ GNUNET_GE_BREAK_RETURN(fs->errorContext(), lst.count() > 0, );
+
+ row = lst.at(0).row();
+
+ avail *= 10;
+ if (avail > 100)
+ avail = 100;
+ else if (avail < 0)
+ avail = 0;
+
+ model->setData(model->index(row, SEARCH_AVAIL_COLUMN),
+ QString::number(avail) + "%");
+ model->setData(model->index(row, SEARCH_RELEVANCE_COLUMN),
+ QString::number(relevance));
+}
+
void GFSSearchController::closed(GFSEcrsUri &uri)
{
GNUNET_FSUI_SearchList *list = searches[uri];
Modified: gnunet-qt/src/plugins/fs/searchController.h
===================================================================
--- gnunet-qt/src/plugins/fs/searchController.h 2008-05-20 20:47:58 UTC (rev
6854)
+++ gnunet-qt/src/plugins/fs/searchController.h 2008-05-20 21:27:12 UTC (rev
6855)
@@ -59,6 +59,8 @@
void stopped(GFSSearchInfo *info);
void downloadCompleted(QPersistentModelIndex &idx, GString file);
void state(GFSSearchInfo *info, GNUNET_FSUI_EventType event);
+ void update(GFSSearchInfo *info, const GNUNET_ECRS_FileInfo *finfo,
+ int avail, unsigned int relevance);
static void addSearchResult(QStandardItemModel *model, QModelIndex parent,
const GNUNET_ECRS_FileInfo *info);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r6855 - gnunet-qt/src/plugins/fs,
gnunet <=