From: dooglus Date: Tue, 15 Jan 2008 14:47:28 +0000 (+0000) Subject: Added a couple of implementations of Action::Base::get_layer_descriptions() to format... X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=8f5280e98450784d7eff88091fc7fabd7b4a93a0;p=synfig.git Added a couple of implementations of Action::Base::get_layer_descriptions() to format lists of layer descriptions for use in the History dialog. git-svn-id: http://svn.voria.com/code@1368 1f10aa63-cdf2-0310-b900-c93c546f37ac --- diff --git a/synfig-studio/trunk/src/synfigapp/action.cpp b/synfig-studio/trunk/src/synfigapp/action.cpp index aa026f4..a8de89e 100644 --- a/synfig-studio/trunk/src/synfigapp/action.cpp +++ b/synfig-studio/trunk/src/synfigapp/action.cpp @@ -284,6 +284,72 @@ Action::Base::set_param_list(const ParamList ¶m_list) set_param(iter->first,iter->second); } +synfig::String +Action::Base::get_layer_descriptions(const std::list layers, synfig::String singular_prefix, synfig::String plural_prefix) +{ + String ret; + bool first = true; + + if (plural_prefix.empty()) + plural_prefix = singular_prefix; + + if (layers.empty()) + return plural_prefix; + + if (layers.size() == 1) + ret = singular_prefix; + else + ret = plural_prefix; + + if (!ret.empty()) + ret.push_back(' '); + + for(std::list::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter) + { + if (first) + first = false; + else + ret += ", "; + + ret += strprintf("'%s'", (*iter)->get_non_empty_description().c_str()); + } + + return ret; +} + +synfig::String +Action::Base::get_layer_descriptions(const std::list > layers, synfig::String singular_prefix, synfig::String plural_prefix) +{ + String ret; + bool first = true; + + if (plural_prefix.empty()) + plural_prefix = singular_prefix; + + if (layers.empty()) + return plural_prefix; + + if (layers.size() == 1) + ret = singular_prefix; + else + ret = plural_prefix; + + if (!ret.empty()) + ret.push_back(' '); + + for(std::list >::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter) + { + if (first) + first = false; + else + ret += ", "; + + ret += strprintf("'%s'", iter->first->get_non_empty_description().c_str()); + } + + return ret; +} + void Super::perform() { diff --git a/synfig-studio/trunk/src/synfigapp/action.h b/synfig-studio/trunk/src/synfigapp/action.h index 4458062..d23039c 100644 --- a/synfig-studio/trunk/src/synfigapp/action.h +++ b/synfig-studio/trunk/src/synfigapp/action.h @@ -211,6 +211,8 @@ public: void set_param_list(const ParamList &); + static synfig::String get_layer_descriptions(const std::list layers, synfig::String singular_prefix = "", synfig::String plural_prefix = ""); + static synfig::String get_layer_descriptions(const std::list > layers, synfig::String singular_prefix = "", synfig::String plural_prefix = ""); }; // END of class Action::Base typedef Action::Base* (*Factory)();