diff options
author | David Robillard <d@drobilla.net> | 2008-08-13 21:38:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-13 21:38:13 +0000 |
commit | cc67a8d797a1b9ba05440f8abb60815aabe838dd (patch) | |
tree | 03c757b346ec5f5c00de004b497696b2e6715524 /src/libs/client | |
parent | 3bc15f3e1fef153dd6f1898b981a409876c171ac (diff) | |
download | ingen-cc67a8d797a1b9ba05440f8abb60815aabe838dd.tar.gz ingen-cc67a8d797a1b9ba05440f8abb60815aabe838dd.tar.bz2 ingen-cc67a8d797a1b9ba05440f8abb60815aabe838dd.zip |
Fix new node default naming from both plugin window and patch context menu.
git-svn-id: http://svn.drobilla.net/lad/ingen@1355 a436a847-0d15-0410-975c-d299462d15a1
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; } |