Ensure all ObjectIDs are unique project-wide

This commit is contained in:
Jack Andersen 2019-02-28 10:34:26 -10:00
parent 9f2bb1b371
commit a4b8946ee2
5 changed files with 98 additions and 124 deletions

View File

@ -580,10 +580,8 @@ bool ProjectModel::reloadSampleData(const QString& groupName, UIMessenger&) {
m_projectDatabase.setIdDatabases(); m_projectDatabase.setIdDatabases();
QString path = QFileInfo(m_dir, groupName).filePath(); QString path = QFileInfo(m_dir, groupName).filePath();
auto search = m_groups.find(groupName); auto search = m_groups.find(groupName);
if (search != m_groups.end()) { if (search != m_groups.end())
search->second->setIdDatabases();
search->second->getSdir().reloadSampleData(QStringToSysString(path)); search->second->getSdir().reloadSampleData(QStringToSysString(path));
}
m_needsReset = true; m_needsReset = true;
return true; return true;
@ -663,9 +661,6 @@ bool ProjectModel::saveToFile(UIMessenger& messenger) {
QDir dir(QFileInfo(m_dir, g.first).filePath()); QDir dir(QFileInfo(m_dir, g.first).filePath());
if (!MkPath(dir.path(), messenger)) if (!MkPath(dir.path(), messenger))
return false; return false;
g.second->setIdDatabases();
{ {
auto proj = g.second->getProj().toYAML(); auto proj = g.second->getProj().toYAML();
athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!project.yaml")).filePath())); athena::io::FileWriter fo(QStringToSysString(QFileInfo(dir, QStringLiteral("!project.yaml")).filePath()));
@ -708,7 +703,6 @@ bool ProjectModel::exportGroup(const QString& path, const QString& groupName, UI
const amuse::AudioGroupDatabase& group = *search->second; const amuse::AudioGroupDatabase& group = *search->second;
m_projectDatabase.setIdDatabases(); m_projectDatabase.setIdDatabases();
QString basePath = QFileInfo(QDir(path), groupName).filePath(); QString basePath = QFileInfo(QDir(path), groupName).filePath();
group.setIdDatabases();
{ {
auto proj = group.getProj().toGCNData(group.getPool(), group.getSdir()); auto proj = group.getProj().toGCNData(group.getPool(), group.getSdir());
athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".proj"))); athena::io::FileWriter fo(QStringToSysString(basePath + QStringLiteral(".proj")));
@ -917,7 +911,6 @@ void ProjectModel::_resetModelData() {
m_root = amuse::MakeObj<RootNode>(); m_root = amuse::MakeObj<RootNode>();
m_root->reserve(m_groups.size()); m_root->reserve(m_groups.size());
for (auto it = m_groups.begin(); it != m_groups.end(); ++it) { for (auto it = m_groups.begin(); it != m_groups.end(); ++it) {
it->second->setIdDatabases();
GroupNode& gn = m_root->makeChild<GroupNode>(it); GroupNode& gn = m_root->makeChild<GroupNode>(it);
_buildGroupNode(gn, *gn.m_it->second); _buildGroupNode(gn, *gn.m_it->second);
} }
@ -2088,6 +2081,4 @@ amuse::SongId ProjectModel::exchangeSongId(amuse::SongId oldId, std::string_view
void ProjectModel::setIdDatabases(INode* context) const { void ProjectModel::setIdDatabases(INode* context) const {
m_projectDatabase.setIdDatabases(); m_projectDatabase.setIdDatabases();
if (ProjectModel::GroupNode* group = getGroupNode(context))
group->getAudioGroup()->setIdDatabases();
} }

View File

@ -1231,341 +1231,341 @@
<context> <context>
<name>ProjectModel</name> <name>ProjectModel</name>
<message> <message>
<location filename="../ProjectModel.cpp" line="705"/> <location filename="../ProjectModel.cpp" line="700"/>
<location filename="../ProjectModel.cpp" line="716"/> <location filename="../ProjectModel.cpp" line="710"/>
<location filename="../ProjectModel.cpp" line="725"/> <location filename="../ProjectModel.cpp" line="719"/>
<location filename="../ProjectModel.cpp" line="735"/> <location filename="../ProjectModel.cpp" line="729"/>
<location filename="../ProjectModel.cpp" line="743"/> <location filename="../ProjectModel.cpp" line="737"/>
<location filename="../ProjectModel.cpp" line="781"/> <location filename="../ProjectModel.cpp" line="775"/>
<source>Export Error</source> <source>Export Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="705"/> <location filename="../ProjectModel.cpp" line="700"/>
<location filename="../ProjectModel.cpp" line="756"/> <location filename="../ProjectModel.cpp" line="750"/>
<location filename="../ProjectModel.cpp" line="781"/> <location filename="../ProjectModel.cpp" line="775"/>
<source>Unable to find group %1</source> <source>Unable to find group %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="716"/> <location filename="../ProjectModel.cpp" line="710"/>
<source>Unable to export %1.proj</source> <source>Unable to export %1.proj</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="725"/> <location filename="../ProjectModel.cpp" line="719"/>
<source>Unable to export %1.pool</source> <source>Unable to export %1.pool</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="735"/> <location filename="../ProjectModel.cpp" line="729"/>
<source>Unable to export %1.sdir</source> <source>Unable to export %1.sdir</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="743"/> <location filename="../ProjectModel.cpp" line="737"/>
<source>Unable to export %1.samp</source> <source>Unable to export %1.samp</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="756"/> <location filename="../ProjectModel.cpp" line="750"/>
<source>Import Error</source> <source>Import Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="766"/> <location filename="../ProjectModel.cpp" line="760"/>
<source>Export Header Error</source> <source>Export Header Error</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="766"/> <location filename="../ProjectModel.cpp" line="760"/>
<source>Unable to open %1 for reading</source> <source>Unable to open %1 for reading</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="787"/> <location filename="../ProjectModel.cpp" line="781"/>
<source>File Exists</source> <source>File Exists</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="787"/> <location filename="../ProjectModel.cpp" line="781"/>
<source>%1 already exists. Overwrite?</source> <source>%1 already exists. Overwrite?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="836"/> <location filename="../ProjectModel.cpp" line="830"/>
<source>Sound Macros</source> <source>Sound Macros</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="837"/> <location filename="../ProjectModel.cpp" line="831"/>
<source>ADSRs</source> <source>ADSRs</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="838"/> <location filename="../ProjectModel.cpp" line="832"/>
<source>Curves</source> <source>Curves</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="839"/> <location filename="../ProjectModel.cpp" line="833"/>
<source>Keymaps</source> <source>Keymaps</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="840"/> <location filename="../ProjectModel.cpp" line="834"/>
<source>Layers</source> <source>Layers</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="841"/> <location filename="../ProjectModel.cpp" line="835"/>
<source>Samples</source> <source>Samples</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1089"/> <location filename="../ProjectModel.cpp" line="1082"/>
<source>Naming Conflict</source> <source>Naming Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1090"/> <location filename="../ProjectModel.cpp" line="1083"/>
<source>%1 already exists in this context</source> <source>%1 already exists in this context</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1094"/> <location filename="../ProjectModel.cpp" line="1087"/>
<source>Rename %1</source> <source>Rename %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1213"/> <location filename="../ProjectModel.cpp" line="1206"/>
<source>Subproject Conflict</source> <source>Subproject Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1214"/> <location filename="../ProjectModel.cpp" line="1207"/>
<source>The subproject %1 is already defined</source> <source>The subproject %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1221"/> <location filename="../ProjectModel.cpp" line="1214"/>
<location filename="../ProjectModel.cpp" line="1758"/> <location filename="../ProjectModel.cpp" line="1751"/>
<location filename="../ProjectModel.cpp" line="1881"/> <location filename="../ProjectModel.cpp" line="1874"/>
<source>Add Subproject %1</source> <source>Add Subproject %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1302"/> <location filename="../ProjectModel.cpp" line="1295"/>
<source>Sound Group Conflict</source> <source>Sound Group Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1302"/> <location filename="../ProjectModel.cpp" line="1295"/>
<location filename="../ProjectModel.cpp" line="1322"/> <location filename="../ProjectModel.cpp" line="1315"/>
<source>The group %1 is already defined</source> <source>The group %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1306"/> <location filename="../ProjectModel.cpp" line="1299"/>
<location filename="../ProjectModel.cpp" line="1615"/> <location filename="../ProjectModel.cpp" line="1608"/>
<location filename="../ProjectModel.cpp" line="1888"/> <location filename="../ProjectModel.cpp" line="1881"/>
<source>Add Sound Group %1</source> <source>Add Sound Group %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1322"/> <location filename="../ProjectModel.cpp" line="1315"/>
<source>Song Group Conflict</source> <source>Song Group Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1326"/> <location filename="../ProjectModel.cpp" line="1319"/>
<location filename="../ProjectModel.cpp" line="1607"/> <location filename="../ProjectModel.cpp" line="1600"/>
<location filename="../ProjectModel.cpp" line="1895"/> <location filename="../ProjectModel.cpp" line="1888"/>
<source>Add Song Group %1</source> <source>Add Song Group %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1429"/> <location filename="../ProjectModel.cpp" line="1422"/>
<source>Sound Macro Conflict</source> <source>Sound Macro Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1429"/> <location filename="../ProjectModel.cpp" line="1422"/>
<source>The macro %1 is already defined</source> <source>The macro %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1438"/> <location filename="../ProjectModel.cpp" line="1431"/>
<location filename="../ProjectModel.cpp" line="1904"/> <location filename="../ProjectModel.cpp" line="1897"/>
<source>Add Sound Macro %1</source> <source>Add Sound Macro %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1454"/> <location filename="../ProjectModel.cpp" line="1447"/>
<source>ADSR Conflict</source> <source>ADSR Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1454"/> <location filename="../ProjectModel.cpp" line="1447"/>
<source>The ADSR %1 is already defined</source> <source>The ADSR %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1460"/> <location filename="../ProjectModel.cpp" line="1453"/>
<location filename="../ProjectModel.cpp" line="1640"/> <location filename="../ProjectModel.cpp" line="1633"/>
<location filename="../ProjectModel.cpp" line="1911"/> <location filename="../ProjectModel.cpp" line="1904"/>
<source>Add ADSR %1</source> <source>Add ADSR %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1476"/> <location filename="../ProjectModel.cpp" line="1469"/>
<source>Curve Conflict</source> <source>Curve Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1476"/> <location filename="../ProjectModel.cpp" line="1469"/>
<source>The Curve %1 is already defined</source> <source>The Curve %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1482"/> <location filename="../ProjectModel.cpp" line="1475"/>
<location filename="../ProjectModel.cpp" line="1648"/> <location filename="../ProjectModel.cpp" line="1641"/>
<location filename="../ProjectModel.cpp" line="1918"/> <location filename="../ProjectModel.cpp" line="1911"/>
<source>Add Curve %1</source> <source>Add Curve %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1498"/> <location filename="../ProjectModel.cpp" line="1491"/>
<source>Keymap Conflict</source> <source>Keymap Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1498"/> <location filename="../ProjectModel.cpp" line="1491"/>
<source>The Keymap %1 is already defined</source> <source>The Keymap %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1503"/> <location filename="../ProjectModel.cpp" line="1496"/>
<location filename="../ProjectModel.cpp" line="1663"/> <location filename="../ProjectModel.cpp" line="1656"/>
<location filename="../ProjectModel.cpp" line="1925"/> <location filename="../ProjectModel.cpp" line="1918"/>
<source>Add Keymap %1</source> <source>Add Keymap %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1519"/> <location filename="../ProjectModel.cpp" line="1512"/>
<source>Layers Conflict</source> <source>Layers Conflict</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1519"/> <location filename="../ProjectModel.cpp" line="1512"/>
<source>Layers %1 is already defined</source> <source>Layers %1 is already defined</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1524"/> <location filename="../ProjectModel.cpp" line="1517"/>
<location filename="../ProjectModel.cpp" line="1679"/> <location filename="../ProjectModel.cpp" line="1672"/>
<location filename="../ProjectModel.cpp" line="1932"/> <location filename="../ProjectModel.cpp" line="1925"/>
<source>Add Layers %1</source> <source>Add Layers %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1529"/> <location filename="../ProjectModel.cpp" line="1522"/>
<location filename="../ProjectModel.cpp" line="1538"/> <location filename="../ProjectModel.cpp" line="1531"/>
<source>-copy</source> <source>-copy</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1625"/> <location filename="../ProjectModel.cpp" line="1618"/>
<source>Add SoundMacro %1</source> <source>Add SoundMacro %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1811"/> <location filename="../ProjectModel.cpp" line="1804"/>
<source>Cut SongGroup %1</source> <source>Cut SongGroup %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1814"/> <location filename="../ProjectModel.cpp" line="1807"/>
<source>Cut SFXGroup %1</source> <source>Cut SFXGroup %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1817"/> <location filename="../ProjectModel.cpp" line="1810"/>
<source>Cut SoundMacro %1</source> <source>Cut SoundMacro %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1820"/> <location filename="../ProjectModel.cpp" line="1813"/>
<source>Cut ADSR %1</source> <source>Cut ADSR %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1823"/> <location filename="../ProjectModel.cpp" line="1816"/>
<source>Cut Curve %1</source> <source>Cut Curve %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1826"/> <location filename="../ProjectModel.cpp" line="1819"/>
<source>Cut Keymap %1</source> <source>Cut Keymap %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1829"/> <location filename="../ProjectModel.cpp" line="1822"/>
<source>Cut Layers %1</source> <source>Cut Layers %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1953"/> <location filename="../ProjectModel.cpp" line="1946"/>
<source>Delete Subproject</source> <source>Delete Subproject</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1954"/> <location filename="../ProjectModel.cpp" line="1947"/>
<source>&lt;p&gt;The subproject %1 will be permanently deleted from the project. Sample files will be permanently removed from the file system.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source> <source>&lt;p&gt;The subproject %1 will be permanently deleted from the project. Sample files will be permanently removed from the file system.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1968"/> <location filename="../ProjectModel.cpp" line="1961"/>
<source>Delete SongGroup %1</source> <source>Delete SongGroup %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1971"/> <location filename="../ProjectModel.cpp" line="1964"/>
<source>Delete SFXGroup %1</source> <source>Delete SFXGroup %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1974"/> <location filename="../ProjectModel.cpp" line="1967"/>
<source>Delete SoundMacro %1</source> <source>Delete SoundMacro %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1977"/> <location filename="../ProjectModel.cpp" line="1970"/>
<source>Delete ADSR %1</source> <source>Delete ADSR %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1980"/> <location filename="../ProjectModel.cpp" line="1973"/>
<source>Delete Curve %1</source> <source>Delete Curve %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1983"/> <location filename="../ProjectModel.cpp" line="1976"/>
<source>Delete Keymap %1</source> <source>Delete Keymap %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1986"/> <location filename="../ProjectModel.cpp" line="1979"/>
<source>Delete Layers %1</source> <source>Delete Layers %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1990"/> <location filename="../ProjectModel.cpp" line="1983"/>
<source>Delete Sample</source> <source>Delete Sample</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ProjectModel.cpp" line="1991"/> <location filename="../ProjectModel.cpp" line="1984"/>
<source>&lt;p&gt;The sample %1 will be permanently deleted from the file system. &lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source> <source>&lt;p&gt;The sample %1 will be permanently deleted from the file system. &lt;p&gt;&lt;strong&gt;This action cannot be undone!&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Continue?&lt;/p&gt;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>

View File

@ -47,43 +47,24 @@ public:
AudioGroupProject& getProj() { return m_proj; } AudioGroupProject& getProj() { return m_proj; }
AudioGroupPool& getPool() { return m_pool; } AudioGroupPool& getPool() { return m_pool; }
AudioGroupSampleDirectory& getSdir() { return m_sdir; } AudioGroupSampleDirectory& getSdir() { return m_sdir; }
virtual void setIdDatabases() const {}
}; };
class AudioGroupDatabase final : public AudioGroup { class AudioGroupDatabase final : public AudioGroup {
NameDB m_soundMacroDb;
NameDB m_sampleDb;
NameDB m_tableDb;
NameDB m_keymapDb;
NameDB m_layersDb;
void _recursiveRenameMacro(SoundMacroId id, std::string_view str, int& macroIdx, void _recursiveRenameMacro(SoundMacroId id, std::string_view str, int& macroIdx,
std::unordered_set<SoundMacroId>& renamedIds); std::unordered_set<SoundMacroId>& renamedIds);
public: public:
AudioGroupDatabase() = default; AudioGroupDatabase() = default;
explicit AudioGroupDatabase(const AudioGroupData& data) { explicit AudioGroupDatabase(const AudioGroupData& data) {
setIdDatabases();
assign(data); assign(data);
} }
explicit AudioGroupDatabase(SystemStringView groupPath) { explicit AudioGroupDatabase(SystemStringView groupPath) {
setIdDatabases();
assign(groupPath); assign(groupPath);
} }
explicit AudioGroupDatabase(const AudioGroupDatabase& data, SystemStringView groupPath) { explicit AudioGroupDatabase(const AudioGroupDatabase& data, SystemStringView groupPath) {
setIdDatabases();
assign(data, groupPath); assign(data, groupPath);
} }
void setIdDatabases() const {
SoundMacroId::CurNameDB = const_cast<NameDB*>(&m_soundMacroDb);
SampleId::CurNameDB = const_cast<NameDB*>(&m_sampleDb);
TableId::CurNameDB = const_cast<NameDB*>(&m_tableDb);
KeymapId::CurNameDB = const_cast<NameDB*>(&m_keymapDb);
LayersId::CurNameDB = const_cast<NameDB*>(&m_layersDb);
}
void renameSample(SampleId id, std::string_view str); void renameSample(SampleId id, std::string_view str);
void deleteSample(SampleId id); void deleteSample(SampleId id);
void copySampleInto(const SystemString& basePath, const SystemString& newBasePath); void copySampleInto(const SystemString& basePath, const SystemString& newBasePath);
@ -96,12 +77,22 @@ class ProjectDatabase {
NameDB m_songDb; NameDB m_songDb;
NameDB m_sfxDb; NameDB m_sfxDb;
NameDB m_groupDb; NameDB m_groupDb;
NameDB m_soundMacroDb;
NameDB m_sampleDb;
NameDB m_tableDb;
NameDB m_keymapDb;
NameDB m_layersDb;
public: public:
void setIdDatabases() const { void setIdDatabases() const {
SongId::CurNameDB = const_cast<NameDB*>(&m_songDb); SongId::CurNameDB = const_cast<NameDB*>(&m_songDb);
SFXId::CurNameDB = const_cast<NameDB*>(&m_sfxDb); SFXId::CurNameDB = const_cast<NameDB*>(&m_sfxDb);
GroupId::CurNameDB = const_cast<NameDB*>(&m_groupDb); GroupId::CurNameDB = const_cast<NameDB*>(&m_groupDb);
SoundMacroId::CurNameDB = const_cast<NameDB*>(&m_soundMacroDb);
SampleId::CurNameDB = const_cast<NameDB*>(&m_sampleDb);
TableId::CurNameDB = const_cast<NameDB*>(&m_tableDb);
KeymapId::CurNameDB = const_cast<NameDB*>(&m_keymapDb);
LayersId::CurNameDB = const_cast<NameDB*>(&m_layersDb);
} }
}; };
} // namespace amuse } // namespace amuse

View File

@ -48,7 +48,6 @@ SystemString AudioGroup::getSampleBasePath(SampleId sfxId) const {
std::pair<ObjToken<SampleEntryData>, const unsigned char*> AudioGroup::getSampleData(SampleId sfxId, std::pair<ObjToken<SampleEntryData>, const unsigned char*> AudioGroup::getSampleData(SampleId sfxId,
const SampleEntry* sample) const { const SampleEntry* sample) const {
if (sample->m_data->m_looseData) { if (sample->m_data->m_looseData) {
setIdDatabases();
SystemString basePath = getSampleBasePath(sfxId); SystemString basePath = getSampleBasePath(sfxId);
const_cast<SampleEntry*>(sample)->loadLooseData(basePath); const_cast<SampleEntry*>(sample)->loadLooseData(basePath);
return {sample->m_data, sample->m_data->m_looseData.get()}; return {sample->m_data, sample->m_data->m_looseData.get()};
@ -58,7 +57,6 @@ std::pair<ObjToken<SampleEntryData>, const unsigned char*> AudioGroup::getSample
SampleFileState AudioGroup::getSampleFileState(SampleId sfxId, const SampleEntry* sample, SystemString* pathOut) const { SampleFileState AudioGroup::getSampleFileState(SampleId sfxId, const SampleEntry* sample, SystemString* pathOut) const {
if (sample->m_data->m_looseData) { if (sample->m_data->m_looseData) {
setIdDatabases();
SystemString basePath = getSampleBasePath(sfxId); SystemString basePath = getSampleBasePath(sfxId);
return sample->getFileState(basePath, pathOut); return sample->getFileState(basePath, pathOut);
} }
@ -69,7 +67,6 @@ SampleFileState AudioGroup::getSampleFileState(SampleId sfxId, const SampleEntry
void AudioGroup::patchSampleMetadata(SampleId sfxId, const SampleEntry* sample) const { void AudioGroup::patchSampleMetadata(SampleId sfxId, const SampleEntry* sample) const {
if (sample->m_data->m_looseData) { if (sample->m_data->m_looseData) {
setIdDatabases();
SystemString basePath = getSampleBasePath(sfxId); SystemString basePath = getSampleBasePath(sfxId);
sample->patchSampleMetadata(basePath); sample->patchSampleMetadata(basePath);
} }
@ -77,14 +74,12 @@ void AudioGroup::patchSampleMetadata(SampleId sfxId, const SampleEntry* sample)
void AudioGroup::makeWAVVersion(SampleId sfxId, const SampleEntry* sample) const { void AudioGroup::makeWAVVersion(SampleId sfxId, const SampleEntry* sample) const {
if (sample->m_data->m_looseData) { if (sample->m_data->m_looseData) {
setIdDatabases();
m_sdir._extractWAV(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get()); m_sdir._extractWAV(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get());
} }
} }
void AudioGroup::makeCompressedVersion(SampleId sfxId, const SampleEntry* sample) const { void AudioGroup::makeCompressedVersion(SampleId sfxId, const SampleEntry* sample) const {
if (sample->m_data->m_looseData) { if (sample->m_data->m_looseData) {
setIdDatabases();
m_sdir._extractCompressed(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get(), true); m_sdir._extractCompressed(sfxId, *sample->m_data, m_groupPath, sample->m_data->m_looseData.get(), true);
} }
} }
@ -187,7 +182,6 @@ static const std::regex DefineSNGEntry(R"(#define\s+SNG(\S+)\s+(\S+))", std::reg
static const std::regex DefineSFXEntry(R"(#define\s+SFX(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize); static const std::regex DefineSFXEntry(R"(#define\s+SFX(\S+)\s+(\S+))", std::regex::ECMAScript | std::regex::optimize);
void AudioGroupDatabase::importCHeader(std::string_view header) { void AudioGroupDatabase::importCHeader(std::string_view header) {
setIdDatabases();
std::match_results<std::string_view::const_iterator> dirMatch; std::match_results<std::string_view::const_iterator> dirMatch;
auto begin = header.cbegin(); auto begin = header.cbegin();
auto end = header.cend(); auto end = header.cend();
@ -254,7 +248,6 @@ static void WriteDefineLine(std::string& ret, std::string_view typeStr, std::str
} }
std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std::string_view groupName) const { std::string AudioGroupDatabase::exportCHeader(std::string_view projectName, std::string_view groupName) const {
setIdDatabases();
std::string ret; std::string ret;
ret += ret +=
"/* Auto-generated Amuse Defines\n" "/* Auto-generated Amuse Defines\n"

View File

@ -874,7 +874,6 @@ void AudioGroupSampleDirectory::reloadSampleData(SystemStringView groupPath) {
std::pair<std::vector<uint8_t>, std::vector<uint8_t>> std::pair<std::vector<uint8_t>, std::vector<uint8_t>>
AudioGroupSampleDirectory::toGCNData(const AudioGroupDatabase& group) const { AudioGroupSampleDirectory::toGCNData(const AudioGroupDatabase& group) const {
constexpr athena::Endian DNAE = athena::Big; constexpr athena::Endian DNAE = athena::Big;
group.setIdDatabases();
athena::io::VectorWriter fo; athena::io::VectorWriter fo;
athena::io::VectorWriter sfo; athena::io::VectorWriter sfo;