diff options
Diffstat (limited to 'src/libs/client')
-rw-r--r-- | src/libs/client/PatchModel.cpp | 23 | ||||
-rw-r--r-- | src/libs/client/PatchModel.hpp | 2 | ||||
-rw-r--r-- | src/libs/client/PluginModel.cpp | 17 | ||||
-rw-r--r-- | src/libs/client/PluginModel.hpp | 2 |
4 files changed, 27 insertions, 17 deletions
diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index a0f0aa4b..b47bd4f4 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -188,5 +188,28 @@ PatchModel::polyphonic() const } +unsigned +PatchModel::child_name_offset(const string& base_name) const +{ + assert(Path::is_valid_name(base_name)); + unsigned offset = 0; + + while (true) { + std::stringstream ss; + ss << base_name; + if (offset > 0) + ss << "_" << offset; + if (!find_child(ss.str())) + break; + else if (offset == 0) + offset = 2; + else + ++offset; + } + + return offset; +} + + } // namespace Client } // namespace Ingen diff --git a/src/libs/client/PatchModel.hpp b/src/libs/client/PatchModel.hpp index 909b9e9e..c73c60a3 100644 --- a/src/libs/client/PatchModel.hpp +++ b/src/libs/client/PatchModel.hpp @@ -61,6 +61,8 @@ public: _editable = e; signal_editable.emit(e); } } + + unsigned child_name_offset(const string& base_name) const; // Signals sigc::signal<void, SharedPtr<NodeModel> > signal_new_node; diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp index 99387dcd..8c2705da 100644 --- a/src/libs/client/PluginModel.cpp +++ b/src/libs/client/PluginModel.cpp @@ -37,24 +37,9 @@ Redland::World* PluginModel::_rdf_world = NULL; string -PluginModel::default_node_name(SharedPtr<PatchModel> parent) +PluginModel::default_node_name() { return Raul::Path::nameify(_symbol); - /*string default_name = Raul::Path::nameify(_symbol); - string name; - - char num_buf[3]; - for (uint i=0; i < 99; ++i) { - name = default_name; - if (i != 0) { - snprintf(num_buf, 4, "_%d", i+1); - name += num_buf; - } - if (!parent->find_child(name)) - break; - } - - return name;*/ } diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index e19d1691..4e2bfab1 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -82,7 +82,7 @@ public: } } - string default_node_name(SharedPtr<PatchModel> parent); + string default_node_name(); #ifdef HAVE_SLV2 static SLV2World slv2_world() { return _slv2_world; } |