Fix code style
[ardour.git] / libs / ardour / presentation_info.cc
index 25048eaf98231eb9e5a9a9ab668c5657ad8fe9b6..23d82f6409ed6c5731284baf3be8ef76bbd055ca 100644 (file)
@@ -21,8 +21,8 @@
 
 #include <cassert>
 
-#include "pbd/convert.h"
 #include "pbd/debug.h"
+#include "pbd/enum_convert.h"
 #include "pbd/enumwriter.h"
 #include "pbd/error.h"
 #include "pbd/failed_constructor.h"
 #include "pbd/xml++.h"
 
 #include "ardour/presentation_info.h"
+#include "ardour/selection.h"
 
 #include "pbd/i18n.h"
 
+namespace PBD {
+       DEFINE_ENUM_CONVERT(ARDOUR::PresentationInfo::Flag);
+}
+
 using namespace ARDOUR;
 using namespace PBD;
 using std::string;
@@ -43,6 +48,7 @@ PBD::Signal1<void,PropertyChange const &> PresentationInfo::Change;
 Glib::Threads::Mutex PresentationInfo::static_signal_lock;
 int PresentationInfo::_change_signal_suspended = 0;
 PBD::PropertyChange PresentationInfo::_pending_static_changes;
+int PresentationInfo::selection_counter= 0;
 
 namespace ARDOUR {
        namespace Properties {
@@ -139,7 +145,8 @@ PresentationInfo::PresentationInfo (order_t o, Flag f)
        /* OrderSet is set */
 }
 PresentationInfo::PresentationInfo (PresentationInfo const& other)
-       : _order (other.order())
+       : PBD::Stateful ()
+       , _order (other.order())
        , _flags (other.flags())
        , _color (other.color())
 {
@@ -149,9 +156,9 @@ XMLNode&
 PresentationInfo::get_state ()
 {
        XMLNode* node = new XMLNode (state_node_name);
-       node->add_property ("order", PBD::to_string (_order, std::dec));
-       node->add_property ("flags", enum_2_string (_flags));
-       node->add_property ("color", PBD::to_string (_color, std::dec));
+       node->set_property ("order", _order);
+       node->set_property ("flags", _flags);
+       node->set_property ("color", _color);
 
        return *node;
 }
@@ -163,28 +170,27 @@ PresentationInfo::set_state (XMLNode const& node, int /* version */)
                return -1;
        }
 
-       XMLProperty const* prop;
        PropertyChange pc;
 
-       if ((prop = node.property (X_("order"))) != 0) {
-               order_t o = atoi (prop->value());
+       order_t o;
+       if (node.get_property (X_("order"), o)) {
                if (o != _order) {
                        pc.add (Properties::order);
                        _order = o;
                }
-               _order = atoi (prop->value());
+               _order = o; // huh?
        }
 
-       if ((prop = node.property (X_("flags"))) != 0) {
-               Flag f = Flag (string_2_enum (prop->value(), f));
+       Flag f;
+       if (node.get_property (X_("flags"), f)) {
                if ((f&Hidden) != (_flags&Hidden)) {
                        pc.add (Properties::hidden);
                }
                _flags = f;
        }
 
-       if ((prop = node.property (X_("color"))) != 0) {
-               color_t c = atoi (prop->value());
+       color_t c;
+       if (node.get_property (X_("color"), c)) {
                if (c != _color) {
                        pc.add (Properties::color);
                        _color = c;
@@ -206,9 +212,8 @@ PresentationInfo::get_flags (XMLNode const& node)
                XMLNode* child = *niter;
 
                if (child->name() == PresentationInfo::state_node_name) {
-                       XMLProperty const* prop = child->property (X_("flags"));
-                       if (prop) {
-                               Flag f = (Flag) string_2_enum (prop->value(), f);
+                       Flag f;
+                       if (child->get_property (X_("flags"), f)) {
                                return f;
                        }
                }
@@ -237,20 +242,6 @@ PresentationInfo::color_set () const
        return _color != 0;
 }
 
-void
-PresentationInfo::set_selected (bool yn)
-{
-       if (yn != selected()) {
-               if (yn) {
-                       _flags = Flag (_flags | Selected);
-               } else {
-                       _flags = Flag (_flags & ~Selected);
-               }
-               send_change (PropertyChange (Properties::selected));
-               send_static_change (PropertyChange (Properties::selected));
-       }
-}
-
 void
 PresentationInfo::set_hidden (bool yn)
 {