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/PatchModel.cpp | |
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/PatchModel.cpp')
-rw-r--r-- | src/libs/client/PatchModel.cpp | 23 |
1 files changed, 23 insertions, 0 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 |