summaryrefslogtreecommitdiff
path: root/src/project.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/project.cc')
-rw-r--r--src/project.cc70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/project.cc b/src/project.cc
index 33c3054..ba7f279 100644
--- a/src/project.cc
+++ b/src/project.cc
@@ -28,6 +28,35 @@
#include <QtGlobal>
+Instrument::Instrument(Project& project, int id)
+ : id(id)
+ , project(project)
+{
+}
+
+int Instrument::getId() const
+{
+ return id;
+}
+
+QString Instrument::getInstrumentName() const
+{
+ return instrument_name;
+}
+
+void Instrument::setInstrumentName(const QString& instrument_name)
+{
+ if(this->instrument_name == instrument_name)
+ {
+ return;
+ }
+
+ {
+ Project::RAIIBulkUpdate bulkUpdate(project);
+ this->instrument_name = instrument_name;
+ }
+}
+
void Project::bulkUpdateBegin()
{
++update_count;
@@ -90,9 +119,50 @@ void Project::setRawFileRoot(const QString& raw_file_root)
}
}
+Instrument& Project::getInstrument(int id)
+{
+ for(auto& instrument : instruments)
+ {
+ if(instrument.getId() == id)
+ {
+ return instrument;
+ }
+ }
+
+ Q_ASSERT(false); // No such instrument id.
+}
+
+int Project::createInstrument()
+{
+ RAIIBulkUpdate bulkUpdate(*this);
+
+ instruments.emplace_back(Instrument(*this, next_id));
+ ++next_id;
+
+ return instruments.back().getId();
+}
+
+void Project::deleteInstrument(int id)
+{
+ RAIIBulkUpdate bulkUpdate(*this);
+
+ for(auto it = instruments.begin(); it != instruments.end(); ++it)
+ {
+ if((*it).getId() == id)
+ {
+ instruments.erase(it);
+ return;
+ }
+ }
+
+ Q_ASSERT(false); // No such instrument id.
+}
+
void Project::reset()
{
RAIIBulkUpdate bulkUpdate(*this);
setRawFileRoot("");
setProjectName("");
+ instruments.clear();
+ next_id = 0;
}