Skip to content

Commit

Permalink
Name instruments the same way as players.
Browse files Browse the repository at this point in the history
Bug #142
  • Loading branch information
cameronwhite committed Sep 22, 2014
1 parent 8b62e0e commit 562abb2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion source/app/documentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Document &DocumentManager::addDefaultDocument()
Instrument instrument;
instrument.setDescription(settings.value(
Settings::DEFAULT_INSTRUMENT_NAME,
Settings::DEFAULT_INSTRUMENT_NAME_DEFAULT).toString().toStdString());
Settings::DEFAULT_INSTRUMENT_NAME_DEFAULT).toString().toStdString() + " 1");
instrument.setMidiPreset(settings.value(Settings::DEFAULT_INSTRUMENT_PRESET,
Settings::DEFAULT_INSTRUMENT_PRESET_DEFAULT).toInt());
score.insertInstrument(instrument);
Expand Down
24 changes: 9 additions & 15 deletions source/app/powertabeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,24 +1406,18 @@ void PowerTabEditor::addInstrument()
Settings::DEFAULT_INSTRUMENT_NAME,
Settings::DEFAULT_INSTRUMENT_NAME_DEFAULT).toString().toStdString();

// Try to directly use the default name if possible.
if (std::find(names.begin(), names.end(), defaultName) == names.end())
instrument.setDescription(defaultName);
else
size_t i = score.getInstruments().size() + 1;
while (true)
{
size_t i = score.getInstruments().size() + 1;
while (true)
{
const std::string name = defaultName + " " + std::to_string(i);
const std::string name = defaultName + " " + std::to_string(i);

if (std::find(names.begin(), names.end(), name) == names.end())
{
instrument.setDescription(name);
break;
}
else
++i;
if (std::find(names.begin(), names.end(), name) == names.end())
{
instrument.setDescription(name);
break;
}
else
++i;
}
}

Expand Down

0 comments on commit 562abb2

Please sign in to comment.