linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01864
[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 382: Show the filename when grouping by TTH in search
------------------------------------------------------------
revno: 382
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Sat 2010-09-04 16:34:43 -0500
message:
Show the filename when grouping by TTH in search
modified:
Changelog.txt
linux/search.cc
linux/search.hh
--
lp:linuxdcpp
https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk
Your team LinuxDC++ Team is subscribed to branch lp:linuxdcpp.
To unsubscribe from this branch go to https://code.launchpad.net/~linuxdcpp-team/linuxdcpp/trunk/+edit-subscription
=== modified file 'Changelog.txt'
--- Changelog.txt 2010-08-27 01:41:14 +0000
+++ Changelog.txt 2010-09-04 21:34:43 +0000
@@ -55,6 +55,7 @@
[2010-08-05] lp#337576: Don't show partial finished downloads. (thanks Bart Vullings)
[2010-08-08] Added a case-insensitive substring search for nick list. (Steven)
[2010-08-26] Added Ctrl+F4 to close a tab. (thanks Bart Vullings)
+[2010-09-04] Show the filename when grouping by TTH in search. (Steven)
*** 1.0.3 2009-02-01 ***
[2008-08-10] lp#256236: Fixed a crash on startup when using auto-open options.
=== modified file 'linux/search.cc'
--- linux/search.cc 2010-03-15 20:46:38 +0000
+++ linux/search.cc 2010-09-04 21:34:43 +0000
@@ -97,7 +97,6 @@
resultView.insertHiddenColumn("Hub URL", G_TYPE_STRING);
resultView.insertHiddenColumn("CID", G_TYPE_STRING);
resultView.insertHiddenColumn("Shared", G_TYPE_BOOLEAN);
- resultView.insertHiddenColumn("Grouping String", G_TYPE_STRING);
resultView.insertHiddenColumn("Free Slots", G_TYPE_INT);
resultView.finalize();
resultStore = gtk_tree_store_newv(resultView.getColCount(), resultView.getGTypes());
@@ -486,10 +485,8 @@
// Check that it's not a duplicate and find parent for grouping
GtkTreeIter iter;
GtkTreeIter parent;
- GtkTreeIter child;
GtkTreeModel *m = GTK_TREE_MODEL(resultStore);
bool foundParent = FALSE;
- bool createParent = FALSE;
vector<SearchResultPtr> &existingResults = results[result->getUser()->getCID().toBase32()];
for (vector<SearchResultPtr>::iterator it = existingResults.begin(); it != existingResults.end(); it++)
@@ -508,43 +505,26 @@
string groupColumn = getGroupingColumn(groupBy);
string groupStr = resultMap[groupColumn];
gboolean valid = gtk_tree_model_get_iter_first(m, &iter);
+
while (valid && groupBy != NOGROUPING && !foundParent && !groupStr.empty())
{
- if (resultView.getString(&iter, "Grouping String", m) == groupStr)
+ // Found a row which matches the grouping criteria
+ if (resultView.getString(&iter, groupColumn, m) == groupStr)
{
- // Parent row
+ // Group the row under the existing parent row
if (gtk_tree_model_iter_has_child(m, &iter))
{
parent = iter;
- foundParent = TRUE;
}
- // If two rows that match the grouping criteria
- // are found, group them under a new parent row
- else if (!foundParent)
+ else // Group the rows under a new parent row
{
- child = iter;
- createParent = TRUE;
- foundParent = TRUE;
+ parent = createParentRow_gui(&iter, groupStr);
}
+
+ foundParent = TRUE;
}
- valid = WulforUtil::getNextIter_gui(m, &iter);
- }
-
- // Move top level row to be under newly created grouping parent.
- // This needs to be done outside of the loop so that we don't modify the
- // tree until after the duplication check.
- if (createParent)
- {
- // Insert the new parent row
- gtk_tree_store_insert_with_values(resultStore, &parent, NULL, -1,
- resultView.col("Icon"), GTK_STOCK_DND_MULTIPLE,
- resultView.col("Grouping String"), groupStr.c_str(),
- -1);
-
- // Move the row to be a child of the new parent
- WulforUtil::copyRow_gui(resultStore, &child, &parent);
- gtk_tree_store_remove(resultStore, &child);
+ valid = WulforUtil::getNextIter_gui(m, &iter, FALSE, FALSE);
}
// Have to use insert with values since appending would cause searchFilterFunc to be
@@ -568,7 +548,6 @@
resultView.col("Hub URL"), resultMap["Hub URL"].c_str(),
resultView.col("CID"), resultMap["CID"].c_str(),
resultView.col("Shared"), Util::toInt(resultMap["Shared"]),
- resultView.col("Grouping String"), groupStr.c_str(),
resultView.col("Free Slots"), Util::toInt(resultMap["Free Slots"]),
-1);
@@ -582,15 +561,41 @@
setBold_gui();
}
+/*
+ * Move top level row to be under a newly created grouping parent.
+ */
+GtkTreeIter Search::createParentRow_gui(GtkTreeIter *child, const string &groupStr, gint position /* = -1 */)
+{
+ GtkTreeIter parent;
+ GroupType groupBy = (GroupType)gtk_combo_box_get_active(GTK_COMBO_BOX(getWidget("comboboxGroupBy")));
+ string filename = groupStr;
+
+ // As a special case, use the first child's filename for TTH grouping
+ if (groupBy == TTH)
+ filename = resultView.getString(child, "Filename", GTK_TREE_MODEL(resultStore));
+
+ // Insert the new parent row
+ gtk_tree_store_insert_with_values(resultStore, &parent, NULL, position,
+ resultView.col("Icon"), GTK_STOCK_DND_MULTIPLE,
+ resultView.col("Filename"), filename.c_str(),
+ -1);
+
+ // Move the row to be a child of the new parent
+ GtkTreeIter newChild = WulforUtil::copyRow_gui(resultStore, child, &parent);
+ gtk_tree_store_remove(resultStore, child);
+ *child = newChild;
+
+ return parent;
+}
+
void Search::updateParentRow_gui(GtkTreeIter *parent, GtkTreeIter *child)
{
// Let's make sure we really have children...
gint children = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(resultStore), parent);
dcassert(children != 0);
- string groupStr = resultView.getString(parent, "Grouping String", GTK_TREE_MODEL(resultStore));
- string groupDesc = "[" + Util::toString(children) + "] " + groupStr;
- gtk_tree_store_set(resultStore, parent, resultView.col("Filename"), groupDesc.c_str(), -1);
+ string users = Util::toString(children) + _(" user(s)");
+ gtk_tree_store_set(resultStore, parent, resultView.col("Nick"), users.c_str(), -1);
if (child == NULL)
return;
@@ -607,6 +612,11 @@
case FILEPATH:
WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Path"));
break;
+ case CONNECTION:
+ WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Connection"));
+ break;
+ case TTH: // Copy size as well since files with the same TTH should have the same size
+ WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("TTH"));
case SIZE:
{
WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Exact Size"));
@@ -614,12 +624,6 @@
WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Real Size"));
break;
}
- case CONNECTION:
- WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Connection"));
- break;
- case TTH:
- WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("TTH"));
- break;
case NICK:
WulforUtil::copyValue_gui(resultStore, child, parent, resultView.col("Nick"));
break;
@@ -707,30 +711,19 @@
else // Insert as a child under the grouping parent
{
GtkTreeIter parent = mapIter->second;
- GtkTreeIter groupParent = mapIter->second;
// If this is the first child to be appended, create a new parent row.
- if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(resultStore), &groupParent))
+ if (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(resultStore), &parent))
{
- gtk_tree_store_insert_with_values(resultStore, &parent, NULL, position,
- resultView.col("Icon"), GTK_STOCK_DND_MULTIPLE,
- resultView.col("Grouping String"), groupStr.c_str(),
- -1);
-
- // Move the previously top-level row to be under the new parent
- GtkTreeIter child = WulforUtil::copyRow_gui(resultStore, &groupParent, &parent);
- gtk_tree_store_set(resultStore, &child, resultView.col("Grouping String"), groupStr.c_str(), -1);
- gtk_tree_store_remove(resultStore, &groupParent);
- updateParentRow_gui(&parent, &child);
-
+ GtkTreeIter child = parent;
+ parent = createParentRow_gui(&child, groupStr, position);
mapIter->second = parent;
}
// Insert the row as a child
GtkTreeIter child = WulforUtil::copyRow_gui(resultStore, &iter, &parent);
- gtk_tree_store_set(resultStore, &child, resultView.col("Grouping String"), groupStr.c_str(), -1);
valid = gtk_tree_store_remove(resultStore, &iter);
- updateParentRow_gui(&parent);
+ updateParentRow_gui(&parent, &child);
}
}
}
=== modified file 'linux/search.hh'
--- linux/search.hh 2009-11-02 03:16:59 +0000
+++ linux/search.hh 2010-09-04 21:34:43 +0000
@@ -69,6 +69,7 @@
void setStatus_gui(std::string statusBar, std::string text);
void search_gui();
void addResult_gui(const dcpp::SearchResultPtr result);
+ GtkTreeIter createParentRow_gui(GtkTreeIter *child, const std::string &groupStr, gint position = -1);
void updateParentRow_gui(GtkTreeIter *parent, GtkTreeIter *child = NULL);
void ungroup_gui();
void regroup_gui();