linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #01870
[Branch ~linuxdcpp-team/linuxdcpp/trunk] Rev 386: Fixed downloading files multiple times when grouping by TTH
------------------------------------------------------------
revno: 386
fixes bug(s): https://launchpad.net/bugs/308683
committer: Steven Sheehy <steven.sheehy@xxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-09-05 01:03:16 -0500
message:
Fixed downloading files multiple times when grouping by TTH
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-09-05 00:43:46 +0000
+++ Changelog.txt 2010-09-05 06:03:16 +0000
@@ -58,6 +58,7 @@
[2010-09-04] Show the filename when grouping by TTH in search. (Steven)
[2010-09-04] Renamed Nick to User for consistency and grammar. (Steven)
[2010-09-04] Show preferences dialog on initial startup. (Steven)
+[2010-09-05] lp#308683: Fixed downloading files multiple times when grouping by TTH. (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-09-05 00:10:54 +0000
+++ linux/search.cc 2010-09-05 06:03:16 +0000
@@ -771,6 +771,51 @@
return column;
}
+void Search::download_gui(const string &target)
+{
+ if (target.empty() || gtk_tree_selection_count_selected_rows(selection) <= 0)
+ return;
+
+ GtkTreeIter iter;
+ GtkTreePath *path;
+ GroupType groupBy = (GroupType)gtk_combo_box_get_active(GTK_COMBO_BOX(getWidget("comboboxGroupBy")));
+ GList *list = gtk_tree_selection_get_selected_rows(selection, NULL);
+ typedef Func6<Search, string, string, string, int64_t, string, string> F6;
+
+ for (GList *i = list; i; i = i->next)
+ {
+ path = (GtkTreePath *)i->data;
+ if (gtk_tree_model_get_iter(sortedFilterModel, &iter, path))
+ {
+ bool parent = gtk_tree_model_iter_has_child(sortedFilterModel, &iter);
+ string filename = resultView.getString(&iter, "Filename");
+
+ do
+ {
+ if (!gtk_tree_model_iter_has_child(sortedFilterModel, &iter))
+ {
+ // User parent filename when grouping by TTH to avoid downloading the same file multiple times
+ if (groupBy != TTH)
+ {
+ filename = resultView.getString(&iter, "Path");
+ filename += resultView.getString(&iter, "Filename");
+ }
+
+ string cid = resultView.getString(&iter, "CID");
+ int64_t size = resultView.getValue<int64_t>(&iter, "Real Size");
+ string tth = resultView.getString(&iter, "TTH");
+ string hubUrl = resultView.getString(&iter, "Hub URL");
+ F6 *func = new F6(this, &Search::download_client, target, cid, filename, size, tth, hubUrl);
+ WulforManager::get()->dispatchClientFunc(func);
+ }
+ }
+ while (parent && WulforUtil::getNextIter_gui(sortedFilterModel, &iter, TRUE, FALSE));
+ }
+ gtk_tree_path_free(path);
+ }
+ g_list_free(list);
+}
+
gboolean Search::onFocusIn_gui(GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
Search *s = (Search *)data;
@@ -959,83 +1004,15 @@
void Search::onDownloadClicked_gui(GtkMenuItem *item, gpointer data)
{
Search *s = (Search *)data;
-
- if (gtk_tree_selection_count_selected_rows(s->selection) > 0)
- {
- GtkTreeIter iter;
- GtkTreePath *path;
- GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);
- string target = SETTING(DOWNLOAD_DIRECTORY);
- typedef Func6<Search, string, string, string, int64_t, string, string> F6;
-
- for (GList *i = list; i; i = i->next)
- {
- path = (GtkTreePath *)i->data;
- if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
- {
- bool parent = gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter);
-
- do
- {
- if (!gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter))
- {
- string cid = s->resultView.getString(&iter, "CID");
- string filename = s->resultView.getString(&iter, "Path");
- filename += s->resultView.getString(&iter, "Filename");
- int64_t size = s->resultView.getValue<int64_t>(&iter, "Real Size");
- string tth = s->resultView.getString(&iter, "TTH");
- string hubUrl = s->resultView.getString(&iter, "Hub URL");
- F6 *func = new F6(s, &Search::download_client, target, cid, filename, size, tth, hubUrl);
- WulforManager::get()->dispatchClientFunc(func);
- }
- }
- while (parent && WulforUtil::getNextIter_gui(s->sortedFilterModel, &iter, TRUE, FALSE));
- }
- gtk_tree_path_free(path);
- }
- g_list_free(list);
- }
+ string target = SETTING(DOWNLOAD_DIRECTORY);
+ s->download_gui(target);
}
void Search::onDownloadFavoriteClicked_gui(GtkMenuItem *item, gpointer data)
{
Search *s = (Search *)data;
string fav = string((gchar *)g_object_get_data(G_OBJECT(item), "fav"));
-
- if (!fav.empty() && gtk_tree_selection_count_selected_rows(s->selection) > 0)
- {
- GtkTreeIter iter;
- GtkTreePath *path;
- GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);
- typedef Func6<Search, string, string, string, int64_t, string, string> F6;
-
- for (GList *i = list; i; i = i->next)
- {
- path = (GtkTreePath *)i->data;
- if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
- {
- bool parent = gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter);
-
- do
- {
- if (!gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter))
- {
- string cid = s->resultView.getString(&iter, "CID");
- string filename = s->resultView.getString(&iter, "Path");
- filename += s->resultView.getString(&iter, "Filename");
- int64_t size = s->resultView.getValue<int64_t>(&iter, "Real Size");
- string tth = s->resultView.getString(&iter, "TTH");
- string hubUrl = s->resultView.getString(&iter, "Hub URL");
- F6 *func = new F6(s, &Search::download_client, fav, cid, filename, size, tth, hubUrl);
- WulforManager::get()->dispatchClientFunc(func);
- }
- }
- while (parent && WulforUtil::getNextIter_gui(s->sortedFilterModel, &iter, TRUE, FALSE));
- }
- gtk_tree_path_free(path);
- }
- g_list_free(list);
- }
+ s->download_gui(fav);
}
void Search::onDownloadToClicked_gui(GtkMenuItem *item, gpointer data)
@@ -1047,10 +1024,9 @@
if (response == GTK_RESPONSE_OK)
{
- int count = gtk_tree_selection_count_selected_rows(s->selection);
gchar *temp = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(s->getWidget("dirChooserDialog")));
- if (temp && count > 0)
+ if (temp)
{
string target = Text::toUtf8(temp);
g_free(temp);
@@ -1058,37 +1034,7 @@
if (target[target.length() - 1] != PATH_SEPARATOR)
target += PATH_SEPARATOR;
- GtkTreeIter iter;
- GtkTreePath *path;
- GList *list = gtk_tree_selection_get_selected_rows(s->selection, NULL);
- typedef Func6<Search, string, string, string, int64_t, string, string> F6;
-
- for (GList *i = list; i; i = i->next)
- {
- path = (GtkTreePath *)i->data;
- if (gtk_tree_model_get_iter(s->sortedFilterModel, &iter, path))
- {
- bool parent = gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter);
-
- do
- {
- if (!gtk_tree_model_iter_has_child(s->sortedFilterModel, &iter))
- {
- string cid = s->resultView.getString(&iter, "CID");
- string filename = s->resultView.getString(&iter, "Path");
- filename += s->resultView.getString(&iter, "Filename");
- int64_t size = s->resultView.getValue<int64_t>(&iter, "Real Size");
- string tth = s->resultView.getString(&iter, "TTH");
- string hubUrl = s->resultView.getString(&iter, "Hub URL");
- F6 *func = new F6(s, &Search::download_client, target, cid, filename, size, tth, hubUrl);
- WulforManager::get()->dispatchClientFunc(func);
- }
- }
- while (parent && WulforUtil::getNextIter_gui(s->sortedFilterModel, &iter, TRUE, FALSE));
- }
- gtk_tree_path_free(path);
- }
- g_list_free(list);
+ s->download_gui(target);
}
}
}
=== modified file 'linux/search.hh'
--- linux/search.hh 2010-09-05 00:10:54 +0000
+++ linux/search.hh 2010-09-05 06:03:16 +0000
@@ -74,6 +74,7 @@
void ungroup_gui();
void regroup_gui();
std::string getGroupingColumn(GroupType groupBy);
+ void download_gui(const std::string &target);
// GUI callbacks
static gboolean onFocusIn_gui(GtkWidget *widget, GdkEventFocus *event, gpointer data);