Skip to content
Snippets Groups Projects
Commit fad20152 authored by Mikhail Svechnikov's avatar Mikhail Svechnikov Committed by Mikhail Svechnikov
Browse files

MaskContainerItem: use SelectionVector

parent 76750f7a
No related branches found
No related tags found
1 merge request!1336GUI: masks are not inherited from SessionItem anymore
...@@ -47,9 +47,9 @@ void ProjectionContainerItem::verifyMask(MaskItem* maskItem) const ...@@ -47,9 +47,9 @@ void ProjectionContainerItem::verifyMask(MaskItem* maskItem) const
QVector<SessionItem*> ProjectionContainerItem::projectionsOfType(const QString& projectionType) QVector<SessionItem*> ProjectionContainerItem::projectionsOfType(const QString& projectionType)
{ {
QVector<SessionItem*> projections; QVector<SessionItem*> projections;
for (MaskItem* projection : m_maskItems) { for (const auto& proj : m_maskItems) {
if (projection->modelType() == projectionType) if (proj.currentItem()->modelType() == projectionType)
projections.push_back(projection); projections.push_back(proj.currentItem());
} }
return projections; return projections;
......
...@@ -58,24 +58,13 @@ MaskContainerItem::MaskContainerItem(const QString& modelType) ...@@ -58,24 +58,13 @@ MaskContainerItem::MaskContainerItem(const QString& modelType)
QVector<MaskItem*> MaskContainerItem::maskItems() const QVector<MaskItem*> MaskContainerItem::maskItems() const
{ {
return m_maskItems; return m_maskItems.toQVector();
}
std::vector<SelectionProperty<MaskItemCatalog>> MaskContainerItem::maskItemSelections() const
{
std::vector<SelectionProperty<MaskItemCatalog>> maskSelections;
for (MaskItem* maskItem : m_maskItems) {
SelectionProperty<MaskItemCatalog> newMaskSelection;
newMaskSelection.setCurrentItem(maskItem);
maskSelections.push_back(std::move(newMaskSelection));
}
return maskSelections;
} }
void MaskContainerItem::insertMask(int row, MaskItem* maskItem) void MaskContainerItem::insertMask(int row, MaskItem* maskItem)
{ {
maskItem->setParentAndModel(this, SessionItem::model()); maskItem->setParentAndModel(this, SessionItem::model());
m_maskItems.insert(row, maskItem); m_maskItems.insert_at(row, maskItem);
} }
void MaskContainerItem::addMask(MaskItem* maskItem) void MaskContainerItem::addMask(MaskItem* maskItem)
...@@ -91,19 +80,19 @@ void MaskContainerItem::moveMask(int from_row, int to_row) ...@@ -91,19 +80,19 @@ void MaskContainerItem::moveMask(int from_row, int to_row)
void MaskContainerItem::removeMaskAt(int row) void MaskContainerItem::removeMaskAt(int row)
{ {
m_maskItems.removeAt(row); m_maskItems.delete_at(row);
} }
void MaskContainerItem::removeMask(MaskItem* maskItem) void MaskContainerItem::removeMask(MaskItem* maskItem)
{ {
m_maskItems.removeOne(maskItem); m_maskItems.delete_element(maskItem);
} }
RegionOfInterestItem* MaskContainerItem::regionOfInterestItem() const RegionOfInterestItem* MaskContainerItem::regionOfInterestItem() const
{ {
for (MaskItem* maskItem : m_maskItems) for (const auto& maskSel: m_maskItems)
if (maskItem->modelType() == RegionOfInterestItem::M_TYPE) if (maskSel.currentItem()->modelType() == RegionOfInterestItem::M_TYPE)
return dynamic_cast<RegionOfInterestItem*>(maskItem); return dynamic_cast<RegionOfInterestItem*>(maskSel.currentItem());
return nullptr; return nullptr;
} }
...@@ -125,12 +114,12 @@ int MaskContainerItem::size() const ...@@ -125,12 +114,12 @@ int MaskContainerItem::size() const
MaskItem* MaskContainerItem::at(const int idx) MaskItem* MaskContainerItem::at(const int idx)
{ {
return m_maskItems.at(idx); return m_maskItems.at(idx).currentItem();
} }
int MaskContainerItem::indexOfItem(MaskItem* maskItem) const int MaskContainerItem::indexOfItem(MaskItem* maskItem) const
{ {
return m_maskItems.indexOf(maskItem); return m_maskItems.index_of(maskItem);
} }
void MaskContainerItem::copy(const MaskContainerItem* maskContainer) void MaskContainerItem::copy(const MaskContainerItem* maskContainer)
...@@ -156,7 +145,7 @@ void MaskContainerItem::writeTo(QXmlStreamWriter* w) const ...@@ -156,7 +145,7 @@ void MaskContainerItem::writeTo(QXmlStreamWriter* w) const
{ {
XML::writeAttribute(w, XML::Attrib::version, uint(1)); XML::writeAttribute(w, XML::Attrib::version, uint(1));
for (const SelectionProperty<MaskItemCatalog>& sel : maskItemSelections()) { for (const auto& sel : m_maskItems) {
w->writeStartElement(Tag::Mask); w->writeStartElement(Tag::Mask);
sel.writeTo(w); sel.writeTo(w);
w->writeEndElement(); w->writeEndElement();
...@@ -948,6 +937,7 @@ void MaskContainerModel::setParent(QObject* parent) ...@@ -948,6 +937,7 @@ void MaskContainerModel::setParent(QObject* parent)
void MaskContainerModel::insertMask(int row, MaskItem* maskItem) void MaskContainerModel::insertMask(int row, MaskItem* maskItem)
{ {
// TODO: unused method. Remove it?
QAbstractListModel::beginInsertRows(maskContainer->rootIndex, row, row); QAbstractListModel::beginInsertRows(maskContainer->rootIndex, row, row);
maskContainer->insertMask(row, maskItem); maskContainer->insertMask(row, maskItem);
// QModelIndex idx = index(row, 0, {}); // QModelIndex idx = index(row, 0, {});
......
...@@ -230,7 +230,6 @@ public: ...@@ -230,7 +230,6 @@ public:
MaskContainerItem(const QString& modelType); MaskContainerItem(const QString& modelType);
QVector<MaskItem*> maskItems() const; QVector<MaskItem*> maskItems() const;
std::vector<SelectionProperty<MaskItemCatalog>> maskItemSelections() const;
//! Insert mask at given row. //! Insert mask at given row.
virtual void insertMask(int row, MaskItem* maskItem); virtual void insertMask(int row, MaskItem* maskItem);
...@@ -280,7 +279,7 @@ public: ...@@ -280,7 +279,7 @@ public:
const QModelIndex rootIndex; const QModelIndex rootIndex;
protected: protected:
QVector<MaskItem*> m_maskItems; SelectionVector<MaskItemCatalog> m_maskItems;
MaskContainerModel* m_model = nullptr; MaskContainerModel* m_model = nullptr;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment