Skip to content
Snippets Groups Projects

GUI: serialization refactoring part 7

Merged Mikhail Svechnikov requested to merge serialization_7 into main
2 files
+ 11
12
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -13,10 +13,9 @@
// ************************************************************************************************
#include "GUI/Model/Device/InstrumentCollection.h"
#include "GUI/Model/Data/RealItem.h"
#include "GUI/Model/Device/InstrumentItems.h"
#include "GUI/Support/XML/Serialize.h"
#include "GUI/Util/String.h"
#include <QUuid>
namespace {
namespace Tag {
@@ -30,7 +29,7 @@ InstrumentCollection::~InstrumentCollection() {}
void InstrumentCollection::clear()
{
m_instrumentSelections.clear();
m_instruments.clear();
}
void InstrumentCollection::serialize(Streamer& s)
@@ -48,7 +47,7 @@ void InstrumentCollection::writeTo(QXmlStreamWriter *w) const
XML::writeAttribute(w, XML::Attrib::version, uint(1));
// instruments
for (const auto& sel : m_instrumentSelections) {
for (const auto& sel : m_instruments) {
w->writeStartElement(Tag::Instrument);
sel.writeTo(w);
w->writeEndElement();
@@ -57,7 +56,7 @@ void InstrumentCollection::writeTo(QXmlStreamWriter *w) const
void InstrumentCollection::readFrom(QXmlStreamReader *r)
{
m_instrumentSelections.clear();
m_instruments.clear();
const uint version = XML::readUIntAttribute(r, XML::Attrib::version);
Q_UNUSED(version)
@@ -91,7 +90,7 @@ InstrumentItem* InstrumentCollection::insertCopy(const InstrumentItem& source)
QVector<InstrumentItem*> InstrumentCollection::collectedItems() const
{
QVector<InstrumentItem*> output;
for (const auto& sel : m_instrumentSelections)
for (const auto& sel : m_instruments)
output.append(sel.currentItem());
return output;
}
@@ -107,8 +106,8 @@ QStringList InstrumentCollection::instrumentNames() const
SelectionProperty<InstrumentItemCatalog> &InstrumentCollection::addEmptyInstrumentSelection()
{
SelectionProperty<InstrumentItemCatalog> newInstrumentSelection;
m_instrumentSelections.push_back(std::move(newInstrumentSelection));
return m_instrumentSelections.back();
m_instruments.push_back(std::move(newInstrumentSelection));
return m_instruments.back();
}
QString InstrumentCollection::suggestInstrumentName(const QString& baseName) const
@@ -153,7 +152,7 @@ bool InstrumentCollection::instrumentExists(const QString& instrumentId) const
void InstrumentCollection::removeInstrument(InstrumentItem* instrument)
{
for (size_t i = 0; i < m_instrumentSelections.size(); i++)
if (m_instrumentSelections[i].currentItem() == instrument)
m_instrumentSelections.erase(m_instrumentSelections.begin() + i);
for (size_t i = 0; i < m_instruments.size(); i++)
if (m_instruments[i].currentItem() == instrument)
m_instruments.erase(m_instruments.begin() + i);
}
Loading