From a7f2b2ba3f13ceb60376802f4a31e104153839e8 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Tue, 17 Feb 2015 03:00:37 +0100 Subject: At first, I was thinking "I just have to go to the selection file, and change that GSList* with a std::list, then resolve the few problems" So, i tried that. And I will continue tomorrow, and the days after, on and on. (bzr r13922.1.1) --- src/selection-describer.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src/selection-describer.cpp') diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index f7814fd57..0625c4002 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -40,14 +40,14 @@ #include "sp-spiral.h" // Returns a list of terms for the items to be used in the statusbar -char* collect_terms (GSList *items) +char* collect_terms (const SelContainer &items) { GSList *check = NULL; std::stringstream ss; bool first = true; - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast(i->data)); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -61,12 +61,12 @@ char* collect_terms (GSList *items) } // Returns the number of terms in the list -static int count_terms (GSList *items) +static int count_terms (const SelContainer &items) { GSList *check = NULL; int count=0; - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast(i->data)); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast(*iter)); if (item) { const char *term = item->displayName(); if (term != NULL && g_slist_find (check, term) == NULL) { @@ -79,11 +79,11 @@ static int count_terms (GSList *items) } // Returns the number of filtered items in the list -static int count_filtered (GSList *items) +static int count_filtered (const SelContainer &items) { int count=0; - for (GSList *i = items; i != NULL; i = i->next) { - SPItem *item = dynamic_cast(reinterpret_cast((i->data))); + for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + SPItem *item = dynamic_cast(reinterpret_cast((*iter))); if (item) { count += item->isFiltered(); } @@ -122,12 +122,12 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - GSList const *items = selection->itemList(); + SelContainer const items = selection->itemList(); - if (!items) { // no items + if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); } else { - SPItem *item = dynamic_cast(reinterpret_cast(items->data)); + SPItem *item = dynamic_cast(reinterpret_cast(items.front())); g_assert(item != NULL); SPObject *layer = selection->layers()->layerForObject(item); SPObject *root = selection->layers()->currentRoot(); @@ -188,7 +188,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free (layer_name); g_free (parent_name); - if (!items->next) { // one item + if (items.size()==1) { // one item char *item_desc = item->detailedDescription(); bool isUse = dynamic_cast(item) != NULL; @@ -228,9 +228,9 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select g_free(item_desc); } else { // multiple items - int objcount = g_slist_length((GSList *)items); - char *terms = collect_terms ((GSList *)items); - int n_terms = count_terms((GSList *)items); + int objcount = items.size(); + char *terms = collect_terms (items); + int n_terms = count_terms(items); gchar *objects_str = g_strdup_printf(ngettext( "%i objects selected of type %s", @@ -241,7 +241,7 @@ void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *select // indicate all, some, or none filtered gchar *filt_str = NULL; - int n_filt = count_filtered((GSList *)items); //all filtered + int n_filt = count_filtered(items); //all filtered if (n_filt) { filt_str = g_strdup_printf(ngettext("; %d filtered object ", "; %d filtered objects ", n_filt), n_filt); -- cgit v1.2.3