Improve LinkableValueNode::get_description().
[synfig.git] / synfig-core / trunk / src / synfig / valuenode.cpp
index 03a8757..44a1b43 100644 (file)
@@ -314,10 +314,18 @@ ValueNode::set_id(const String &x)
 String
 ValueNode::get_description(bool show_exported_name)const
 {
+       String ret(_("ValueNode"));
+
        if (dynamic_cast<const LinkableValueNode*>(this))
                return (dynamic_cast<const LinkableValueNode*>(this))->get_description(-1, show_exported_name);
 
-       return "ValueNode";
+       if (show_exported_name && !is_exported())
+               show_exported_name = false;
+
+       if (show_exported_name)
+               ret += strprintf(" (%s)", get_id().c_str());
+
+       return ret;
 }
 
 ValueNodeList::ValueNodeList():
@@ -333,7 +341,8 @@ ValueNodeList::count(const String &id)const
        if(id.empty())
                return false;
 
-       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter);
+       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
+               ;
 
        if(iter==end())
                return false;
@@ -349,7 +358,8 @@ ValueNodeList::find(const String &id)
        if(id.empty())
                throw Exception::IDNotFound("Empty ID");
 
-       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter);
+       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
+               ;
 
        if(iter==end())
                throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id);
@@ -365,7 +375,8 @@ ValueNodeList::find(const String &id)const
        if(id.empty())
                throw Exception::IDNotFound("Empty ID");
 
-       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter);
+       for(iter=begin();iter!=end() && id!=(*iter)->get_id();++iter)
+               ;
 
        if(iter==end())
                throw Exception::IDNotFound("ValueNode in ValueNodeList: "+id);
@@ -571,12 +582,23 @@ LinkableValueNode::get_description(int index, bool show_exported_name)const
 {
        String description;
 
-       if (show_exported_name && !is_exported())
-               show_exported_name = false;
-
-       if (index != -1)
+       if (index == -1)
+       {
+               if (show_exported_name && is_exported())
+                       description += strprintf(" (%s)", get_id().c_str());
+       }
+       else
+       {
                description = String(":") + link_local_name(index);
 
+               if (show_exported_name)
+               {
+                       ValueNode::LooseHandle link(get_link(index));
+                       if (link->is_exported())
+                               description += strprintf(" (%s)", link->get_id().c_str());
+               }
+       }
+
        const synfig::Node* node = this;
        LinkableValueNode::ConstHandle parent_linkable_vn = 0;
 
@@ -616,8 +638,5 @@ LinkableValueNode::get_description(int index, bool show_exported_name)const
                                                                description.c_str());
        }
 
-       if (show_exported_name)
-               description += strprintf(" (%s)", get_id().c_str());
-
        return description;
 }