From c4a5577ffb9c32a8bfabe05c3f7b4a4b402ebd63 Mon Sep 17 00:00:00 2001 From: alexandrut Date: Sun, 21 Feb 2010 13:38:27 +0000 Subject: [PATCH] search result filtering git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2383 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/SearchDialog.cpp | 23 +++++++++++++++++++---- retroshare-gui/src/gui/SearchDialog.h | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index ef5ddc2c9..88d5a58a3 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -129,7 +129,8 @@ SearchDialog::SearchDialog(QWidget *parent) connect ( ui.searchSummaryWidget, SIGNAL( currentItemChanged ( QTreeWidgetItem *, QTreeWidgetItem * ) ), this, SLOT( selectSearchResults( void ) ) ); - connect(ui.FileTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboIndexChanged(int))); + //connect(ui.FileTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboIndexChanged(int))); + connect(ui.FileTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(selectSearchResults(int))); /* hide the Tree +/- */ ui.searchResultWidget -> setRootIsDecorated( true ); @@ -833,6 +834,7 @@ void SearchDialog::insertDirectory(const std::string &txt, qulonglong searchId, ui.searchSummaryWidget->setCurrentItem(item2); } + selectSearchResults(); // TODO: check for duplicate directories } @@ -1086,8 +1088,13 @@ void SearchDialog::resultsToTree(std::string txt,qulonglong searchId, const std: ui.searchResultWidget->setSortingEnabled(true); } -void SearchDialog::selectSearchResults() +void SearchDialog::selectSearchResults(int index) { + index = (index == -1)?ui.FileTypeComboBox->currentIndex():index; + QString alltypes = FileTypeExtensionMap->value(index); + QStringList types = alltypes.split(" "); + + /* highlight this search in summary window */ QTreeWidgetItem *ci = ui.searchSummaryWidget->currentItem(); if (!ci) @@ -1107,8 +1114,15 @@ void SearchDialog::selectSearchResults() /* get item */ QTreeWidgetItem *ti = ui.searchResultWidget->topLevelItem(i); if (ti->text(SR_SEARCH_ID_COL) == searchId) - { - ti->setHidden(false); + { + if (index == FILETYPE_IDX_ANY) + ti->setHidden(false); + else if (index == FILETYPE_IDX_DIRECTORY && ti->text(SR_HASH_COL).isEmpty()) + ti->setHidden(false); + else if (types.contains(QFileInfo(ti->text(SR_NAME_COL)).suffix(), Qt::CaseInsensitive)) + ti->setHidden(false); + else + ti->setHidden(true); } else { @@ -1246,6 +1260,7 @@ void SearchDialog::togglereset() } +// not in use for the moment void SearchDialog::onComboIndexChanged(int index) { if (!FileTypeExtensionMap->contains(index) && index != FILETYPE_IDX_DIRECTORY) diff --git a/retroshare-gui/src/gui/SearchDialog.h b/retroshare-gui/src/gui/SearchDialog.h index 35c6d02a3..294e605c2 100644 --- a/retroshare-gui/src/gui/SearchDialog.h +++ b/retroshare-gui/src/gui/SearchDialog.h @@ -83,7 +83,7 @@ private slots: /** perform the advanced search */ void advancedSearch(Expression*); - void selectSearchResults(); + void selectSearchResults(int index = -1); void clearKeyword();