← Back to team overview

linuxdcpp-team team mailing list archive

[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 3221: Allow expanding merged search results

 

------------------------------------------------------------
revno: 3221
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sat 2013-03-16 15:40:25 +0100
message:
  Allow expanding merged search results
modified:
  changelog.txt
  dcpp/SettingsManager.cpp
  dcpp/SettingsManager.h
  dwt/src/widgets/TableTree.cpp
  dwt/test/TableTreeTest.cpp
  help/window_search.html
  win32/SearchFrame.cpp
  win32/SearchFrame.h


--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk

Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt	2013-03-11 17:34:35 +0000
+++ changelog.txt	2013-03-16 14:40:25 +0000
@@ -1,4 +1,5 @@
 * Rotate the icon while DC++ is loading (poy)
+* [L#243727] Allow expanding merged search results (poy)
 
 -- 0.811 2013-03-04 --
 * Fix status bar parts when the window is too small (poy)

=== modified file 'dcpp/SettingsManager.cpp'
--- dcpp/SettingsManager.cpp	2013-02-12 19:16:15 +0000
+++ dcpp/SettingsManager.cpp	2013-03-16 14:40:25 +0000
@@ -94,7 +94,7 @@
 	"MagnetRegister", "MinimizeToTray", "NoAwayMsgToBots", "NoIpOverride", "OpenUserCmdHelp",
 	"OwnerDrawnMenus", "PopupBotPms", "PopupHubPms", "PopupPMs", "PopunderFilelist", "PopunderPm",
 	"LowestPrio", "PromptPassword", "QueueFrameShowTree", "RequireTLS", "SearchFilterShared",
-	"SearchMerge", "SearchOnlyFreeSlots", "SegmentedDL", "SendBloom", "SendUnknownCommands",
+	"SearchOnlyFreeSlots", "SegmentedDL", "SendBloom", "SendUnknownCommands",
 	"SFVCheck", "ShareHidden", "ShowJoins", "ShowMenuBar", "ShowStatusbar", "ShowToolbar",
 	"ShowTransferview", "SkipZeroByte", "SocksResolve", "SortFavUsersFirst",
 	"StatusInChat", "TimeDependentThrottle", "TimeStamps",
@@ -307,7 +307,6 @@
 	setDefault(CONFIRM_USER_REMOVAL, true);
 	setDefault(CONFIRM_ITEM_REMOVAL, true);
 	setDefault(CONFIRM_ADLS_REMOVAL, true);
-	setDefault(SEARCH_MERGE, true);
 	setDefault(TOOLBAR_SIZE, 20);
 	setDefault(TAB_WIDTH, 150);
 	setDefault(TAB_STYLE, TAB_STYLE_OD | TAB_STYLE_BROWSER);

=== modified file 'dcpp/SettingsManager.h'
--- dcpp/SettingsManager.h	2013-01-18 21:28:38 +0000
+++ dcpp/SettingsManager.h	2013-03-16 14:40:25 +0000
@@ -131,7 +131,7 @@
 		MAGNET_REGISTER, MINIMIZE_TRAY, NO_AWAYMSG_TO_BOTS, NO_IP_OVERRIDE, OPEN_USER_CMD_HELP,
 		OWNER_DRAWN_MENUS, POPUP_BOT_PMS, POPUP_HUB_PMS, POPUP_PMS, POPUNDER_FILELIST, POPUNDER_PM,
 		PRIO_LOWEST, PROMPT_PASSWORD, QUEUEFRAME_SHOW_TREE, REQUIRE_TLS, SEARCH_FILTER_SHARED,
-		SEARCH_MERGE, SEARCH_ONLY_FREE_SLOTS, SEGMENTED_DL, SEND_BLOOM, SEND_UNKNOWN_COMMANDS,
+		SEARCH_ONLY_FREE_SLOTS, SEGMENTED_DL, SEND_BLOOM, SEND_UNKNOWN_COMMANDS,
 		SFV_CHECK, SHARE_HIDDEN, SHOW_JOINS, SHOW_MENU_BAR, SHOW_STATUSBAR, SHOW_TOOLBAR,
 		SHOW_TRANSFERVIEW, SKIP_ZERO_BYTE, SOCKS_RESOLVE, SORT_FAVUSERS_FIRST,
 		STATUS_IN_CHAT, TIME_DEPENDENT_THROTTLE, TIME_STAMPS,

=== modified file 'dwt/src/widgets/TableTree.cpp'
--- dwt/src/widgets/TableTree.cpp	2013-03-16 13:25:11 +0000
+++ dwt/src/widgets/TableTree.cpp	2013-03-16 14:40:25 +0000
@@ -279,6 +279,7 @@
 
 	auto parent = items.find(param);
 	if(parent != items.end()) {
+		collapse(param);
 		for(auto child: parent->second.children) {
 			children.erase(child);
 		}

=== modified file 'dwt/test/TableTreeTest.cpp'
--- dwt/test/TableTreeTest.cpp	2013-03-16 13:25:11 +0000
+++ dwt/test/TableTreeTest.cpp	2013-03-16 14:40:25 +0000
@@ -9,7 +9,7 @@
 const size_t COLUMNS = 3;
 const size_t ROWS = 100;
 
-const size_t PARENT = 0;
+const size_t PARENT = 2;
 const size_t CHILDREN = 10;
 
 const auto IMAGE_SIZE = 32;

=== modified file 'help/window_search.html'
--- help/window_search.html	2013-03-06 20:01:11 +0000
+++ help/window_search.html	2013-03-16 14:40:25 +0000
@@ -27,6 +27,10 @@
 matched for possible other queued files if the <a href="settings_queue.html#automatchqueue">Automatically match queue for search hits</a>
 setting is enabled. Activating that option can generate lots of filelist traffic when large amount of new sources are found for queued files.</p>
 
+<p>Search results with identical hashes are grouped under the same entry. A merged entry can be
+expanded using the +/- glyphs on the left or with left/right keys were one to want to peek at the
+various results received for the same file.</p>
+
 <p>If you often get too few search results or no results at all, refer to the <a href="faq_nosearch.html">Search troubleshooting FAQ</a>.</p>
 
 <h2>Search options (left)</h2>
@@ -51,12 +55,6 @@
   <dd cshelp="IDH_SEARCH_SLOTS">Filter away files depending on the user's free slots.</dd>
   <dt>Hide files already in share</dt>
   <dd cshelp="IDH_SEARCH_SHARE">Filter away files that are already in share.</dd>
-  <dt>Merge results for the same file</dt>
-  <dd cshelp="IDH_SEARCH_MERGE">
-  If checked (default), when multiple search results are received for the same file (same TTH
-  root), these search results will be merged into 1 entry.<br/>
-  If unchecked, each search result will have its own entry in the search results list.
-  </dd>
   <dt>Hubs</dt>
   <dd cshelp="IDH_SEARCH_HUBS">Search only selected hubs.</dd>
 </dl>

=== modified file 'win32/SearchFrame.cpp'
--- win32/SearchFrame.cpp	2013-01-30 14:58:41 +0000
+++ win32/SearchFrame.cpp	2013-03-16 14:40:25 +0000
@@ -31,6 +31,7 @@
 #include <dwt/widgets/FolderDialog.h>
 #include <dwt/widgets/Grid.h>
 #include <dwt/widgets/SplitterContainer.h>
+#include <dwt/widgets/TableTree.h>
 
 #include "HoldRedraw.h"
 #include "resource.h"
@@ -120,7 +121,6 @@
 fileType(0),
 onlyFree(SETTING(SEARCH_ONLY_FREE_SLOTS)),
 hideShared(SETTING(SEARCH_FILTER_SHARED)),
-merge(SETTING(SEARCH_MERGE)),
 hubs(0),
 results(0),
 filter(resultsColumns, COLUMN_LAST, [this] { updateList(); }),
@@ -208,7 +208,7 @@
 		}
 
 		gs.caption = T_("Search options");
-		cur = options->addChild(gs)->addChild(Grid::Seed(3, 1));
+		cur = options->addChild(gs)->addChild(Grid::Seed(2, 1));
 
 		CheckBox::Seed cs = WinUtil::Seeds::checkBox;
 		
@@ -224,12 +224,6 @@
 		box->setChecked(hideShared);
 		box->onClicked([this, box] { hideShared = box->getChecked(); });
 
-		cs.caption = T_("Merge results for the same file");
-		box = cur->addChild(cs);
-		box->setHelpId(IDH_SEARCH_MERGE);
-		box->setChecked(merge);
-		box->onClicked([this, box] { merge = box->getChecked(); });
-
 		gs.caption = T_("Hubs");
 		group = options->addChild(gs);
 		group->setHelpId(IDH_SEARCH_HUBS);
@@ -467,7 +461,7 @@
 	}
 }
 
-SearchFrame::SearchInfo::SearchInfo(const SearchResultPtr& aSR) {
+SearchFrame::SearchInfo::SearchInfo(const SearchResultPtr& aSR) : parent(nullptr) {
 	srs.push_back(aSR);
 	update();
 }
@@ -560,14 +554,12 @@
 		return;
 	}
 
-	SearchInfo* si = nullptr;
+	SearchInfo* parent = nullptr;
 
 	// Check previous search results for dupes
-	for(auto i = searchResults.begin(), iend = searchResults.end(); !si && i != iend; ++i) {
-		auto& si2 = *i;
-
-		for(auto& j: si2.srs) {
-			auto& sr2 = *j;
+	for(auto& si2: searchResults) {
+		for(auto& psr2: si2.srs) {
+			auto& sr2 = *psr2;
 
 			bool sameUser = sr.getUser() == sr2.getUser();
 			if(sameUser && sr.getFile() == sr2.getFile()) {
@@ -578,25 +570,29 @@
 					return; // dupe
 				}
 
-				if(merge) {
-					si2.srs.push_back(psr);
-					si2.update();
-					si = &si2;
-				}
+				si2.srs.push_back(psr);
+				si2.update();
+				parent = &si2;
 				break;
 			}
 		}
+		if(parent) {
+			break;
+		}
 	}
 
-	if(!si) {
-		searchResults.emplace_back(psr);
-		si = &searchResults.back();
-	}
+	searchResults.emplace_back(psr);
+	auto si = &searchResults.back();
+	si->parent = parent;
 
 	auto i = results->find(si);
 	if(filter.empty() || filter.match(filter.prepare(), [this, si](int column) { return Text::fromT(si->getText(column)); })) {
 		if(i == -1) {
-			results->insert(si);
+			if(parent) {
+				results->insertChild(reinterpret_cast<LPARAM>(parent), reinterpret_cast<LPARAM>(si));
+			} else {
+				results->insert(si);
+			}
 		} else {
 			results->update(i);
 		}
@@ -618,7 +614,11 @@
 	results->clear();
 	for(; i != searchResults.end(); ++i) {
 		if(filter.empty() || filter.match(filterPrep, filterInfoF)) {
-			results->insert(&*i);
+			if(i->parent) {
+				results->insertChild(reinterpret_cast<LPARAM>(i->parent), reinterpret_cast<LPARAM>(&*i));
+			} else {
+				results->insert(&*i);
+			}
 		}
 	}
 
@@ -753,7 +753,7 @@
 		auto data = results->getData(i);
 		results->erase(i);
 		if(data) {
-			searchResults.remove_if([data](const SearchInfo& si) { return &si == data; });
+			searchResults.remove_if([data](const SearchInfo& si) { return &si == data || si.parent == data; });
 		}
 	}
 
@@ -904,8 +904,6 @@
 		SettingsManager::getInstance()->set(SettingsManager::SEARCH_ONLY_FREE_SLOTS, onlyFree);
 	if(hideShared != SETTING(SEARCH_FILTER_SHARED))
 		SettingsManager::getInstance()->set(SettingsManager::SEARCH_FILTER_SHARED, hideShared);
-	if(merge != SETTING(SEARCH_MERGE))
-		SettingsManager::getInstance()->set(SettingsManager::SEARCH_MERGE, merge);
 	if(initialType == SearchManager::TYPE_ANY) {
 		string text = Text::fromT(fileType->getText());
 		if(text != SETTING(LAST_SEARCH_TYPE))

=== modified file 'win32/SearchFrame.h'
--- win32/SearchFrame.h	2013-01-18 21:28:38 +0000
+++ win32/SearchFrame.h	2013-03-16 14:40:25 +0000
@@ -132,6 +132,7 @@
 		void update();
 
 		SearchResultList srs;
+		SearchInfo* parent;
 
 		tstring columns[COLUMN_LAST];
 	};
@@ -175,13 +176,12 @@
 
 	bool onlyFree;
 	bool hideShared;
-	bool merge;
 
 	typedef TypedTable<HubInfo> WidgetHubs;
 	typedef WidgetHubs* WidgetHubsPtr;
 	WidgetHubsPtr hubs;
 
-	typedef TypedTable<SearchInfo, false> WidgetResults;
+	typedef TypedTable<SearchInfo, false, dwt::TableTree> WidgetResults;
 	typedef WidgetResults* WidgetResultsPtr;
 	WidgetResultsPtr results;
 
@@ -209,7 +209,6 @@
 	void handlePurgeClicked();
 	void handleSlotsClicked();
 	void handleHideSharedClicked();
-	void handleMergeClicked();
 	LRESULT handleHubItemChanged(WPARAM wParam, LPARAM lParam);
 	bool handleKeyDown(int c);
 	bool handleContextMenu(dwt::ScreenCoordinate pt);