Skip to content
Snippets Groups Projects

GUI: serialization refactoring part 7

Merged Mikhail Svechnikov requested to merge serialization_7 into main
2 files
+ 6
19
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -26,15 +26,10 @@ const QString Instrument("Instrument");
@@ -26,15 +26,10 @@ const QString Instrument("Instrument");
} // namespace Tag
} // namespace Tag
} // namespace
} // namespace
InstrumentCollection::~InstrumentCollection()
InstrumentCollection::~InstrumentCollection() {}
{
// qDeleteAll(m_instruments);
}
void InstrumentCollection::clear()
void InstrumentCollection::clear()
{
{
// qDeleteAll(m_instruments);
// m_instruments.clear();
m_instrumentSelections.clear();
m_instrumentSelections.clear();
}
}
@@ -70,9 +65,9 @@ void InstrumentCollection::readFrom(QXmlStreamReader *r)
@@ -70,9 +65,9 @@ void InstrumentCollection::readFrom(QXmlStreamReader *r)
while (r->readNextStartElement()) {
while (r->readNextStartElement()) {
QString tag = r->name().toString();
QString tag = r->name().toString();
// particle
// instrument
if (tag == Tag::Instrument) {
if (tag == Tag::Instrument) {
createEmptyInstrumentSelection().readFrom(r);
addEmptyInstrumentSelection().readFrom(r);
XML::gotoEndElementOfTag(r, tag);
XML::gotoEndElementOfTag(r, tag);
} else
} else
@@ -82,22 +77,19 @@ void InstrumentCollection::readFrom(QXmlStreamReader *r)
@@ -82,22 +77,19 @@ void InstrumentCollection::readFrom(QXmlStreamReader *r)
void InstrumentCollection::emplace_back(InstrumentItem *item)
void InstrumentCollection::emplace_back(InstrumentItem *item)
{
{
// m_instruments.push_back(item);
addEmptyInstrumentSelection().setCurrentItem(item);
createEmptyInstrumentSelection().setCurrentItem(item);
}
}
InstrumentItem* InstrumentCollection::insertCopy(const InstrumentItem& source)
InstrumentItem* InstrumentCollection::insertCopy(const InstrumentItem& source)
{
{
auto* copy = source.createCopy();
auto* copy = source.createCopy();
copy->setId(QUuid::createUuid().toString());
copy->setId(QUuid::createUuid().toString());
// m_instruments << copy;
emplace_back(copy);
emplace_back(copy);
return copy;
return copy;
}
}
QVector<InstrumentItem*> InstrumentCollection::collectedItems() const
QVector<InstrumentItem*> InstrumentCollection::collectedItems() const
{
{
// return m_instruments;
QVector<InstrumentItem*> output;
QVector<InstrumentItem*> output;
for (const auto& sel : m_instrumentSelections)
for (const auto& sel : m_instrumentSelections)
output.append(sel.currentItem());
output.append(sel.currentItem());
@@ -112,7 +104,7 @@ QStringList InstrumentCollection::instrumentNames() const
@@ -112,7 +104,7 @@ QStringList InstrumentCollection::instrumentNames() const
return existingNames;
return existingNames;
}
}
SelectionProperty<InstrumentItemCatalog> &InstrumentCollection::createEmptyInstrumentSelection()
SelectionProperty<InstrumentItemCatalog> &InstrumentCollection::addEmptyInstrumentSelection()
{
{
SelectionProperty<InstrumentItemCatalog> newInstrumentSelection;
SelectionProperty<InstrumentItemCatalog> newInstrumentSelection;
m_instrumentSelections.push_back(std::move(newInstrumentSelection));
m_instrumentSelections.push_back(std::move(newInstrumentSelection));
@@ -161,10 +153,7 @@ bool InstrumentCollection::instrumentExists(const QString& instrumentId) const
@@ -161,10 +153,7 @@ bool InstrumentCollection::instrumentExists(const QString& instrumentId) const
void InstrumentCollection::removeInstrument(InstrumentItem* instrument)
void InstrumentCollection::removeInstrument(InstrumentItem* instrument)
{
{
// m_instruments.removeAll(instrument);
// delete instrument;
for (size_t i = 0; i < m_instrumentSelections.size(); i++)
for (size_t i = 0; i < m_instrumentSelections.size(); i++)
if (m_instrumentSelections[i].currentItem() == instrument)
if (m_instrumentSelections[i].currentItem() == instrument)
m_instrumentSelections.erase(m_instrumentSelections.begin() + i);
m_instrumentSelections.erase(m_instrumentSelections.begin() + i);
}
}
Loading