diff options
Diffstat (limited to 'src/sp-item-group.cpp')
| -rw-r--r-- | src/sp-item-group.cpp | 91 |
1 files changed, 38 insertions, 53 deletions
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index b1ba37de2..e6531c6be 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -171,11 +171,10 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } childflags &= SP_OBJECT_MODIFIED_CASCADE; - - GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); - while (l) { - SPObject *child = SP_OBJECT (l->data); - l = g_slist_remove (l, child); + SelContainer l=this->childList(true, SPObject::ActionUpdate); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT (*i); if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem *item = dynamic_cast<SPItem *>(child); @@ -211,20 +210,16 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { void SPGroup::modified(guint flags) { // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; SPLPEItem::modified(flags); - - SPObject *child; - if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = g_slist_reverse(this->childList(true)); - - while (l) { - child = SP_OBJECT (l->data); - l = g_slist_remove (l, child); + SelContainer l=this->childList(true); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *child = SP_OBJECT (*i); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -296,35 +291,28 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox Geom::OptRect bbox; // TODO CPPIFY: replace this const_cast later - GSList *l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); - - while (l) { - SPObject *o = SP_OBJECT (l->data); - + SelContainer l=const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(o); if (item && !item->isHidden()) { Geom::Affine const ct(item->transform * transform); bbox |= item->bounds(bboxtype, ct); } - - l = g_slist_remove (l, o); } return bbox; } void SPGroup::print(SPPrintContext *ctx) { - GSList *l = g_slist_reverse(this->childList(false)); - - while (l) { - SPObject *o = SP_OBJECT (l->data); - + SelContainer l=this->childList(false); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(o); if (item) { item->invoke_print(ctx); } - - l = g_slist_remove (l, o); } } @@ -372,17 +360,15 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k } void SPGroup::hide (unsigned int key) { - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); - - while (l) { - SPObject *o = SP_OBJECT (l->data); + SelContainer l=this->childList(false, SPObject::ActionShow); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(o); if (item) { item->invoke_hide(key); } - - l = g_slist_remove (l, o); } // SPLPEItem::onHide(key); @@ -401,7 +387,7 @@ void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape: void -sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) +sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) { g_return_if_fail (group != NULL); @@ -560,8 +546,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) } Inkscape::GC::release(repr); - if (children && item) { - *children = g_slist_prepend(*children, item); + if (!children.empty() && item) { + children.push_front(dynamic_cast<SPObject*>(item)); } items = g_slist_remove (items, items->data); @@ -576,19 +562,18 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) * some API for list aspect of SPGroup */ -GSList *sp_item_group_item_list(SPGroup * group) +SelContainer sp_item_group_item_list(SPGroup * group) { - g_return_val_if_fail(group != NULL, NULL); - - GSList *s = NULL; + SelContainer s; + g_return_val_if_fail(group != NULL, s); for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { if ( dynamic_cast<SPItem *>(o) ) { - s = g_slist_prepend(s, o); + s.push_front(o); } } - - return g_slist_reverse (s); + s.reverse(); + return s; } SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) @@ -809,9 +794,10 @@ gint SPGroup::getItemCount() const { void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { Inkscape::DrawingItem *ac = NULL; - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); - while (l) { - SPObject *o = SP_OBJECT (l->data); + SelContainer l=this->childList(false, SPObject::ActionShow); + l.reverse(); + for(SelContainer::const_iterator i=l.begin();i!=l.end();i++){ + SPObject *o = SP_OBJECT (*i); SPItem * child = dynamic_cast<SPItem *>(o); if (child) { ac = child->invoke_show (drawing, key, flags); @@ -819,7 +805,6 @@ void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem * ai->appendChild(ac); } } - l = g_slist_remove (l, o); } } @@ -828,10 +813,10 @@ void SPGroup::update_patheffect(bool write) { g_message("sp_group_update_patheffect: %p\n", lpeitem); #endif - GSList const *item_list = sp_item_group_item_list(this); + SelContainer const item_list = sp_item_group_item_list(this); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast<SPObject *>(iter->data); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast<SPObject *>(*iter); SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem); if (lpeItem) { @@ -856,10 +841,10 @@ void SPGroup::update_patheffect(bool write) { static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - GSList const *item_list = sp_item_group_item_list(group); + SelContainer const item_list = sp_item_group_item_list(group); - for ( GSList const *iter = item_list; iter; iter = iter->next ) { - SPObject *subitem = static_cast<SPObject *>(iter->data); + for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + SPObject *subitem = static_cast<SPObject *>(*iter); SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem); if (subGroup) { |
