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
QVector<SessionItem*> ProjectionContainerItem::projectionsOfType(const QString& projectionType)
{
QVector<SessionItem*> projections;
for (MaskItem* projection : m_maskItems) {
if (projection->modelType() == projectionType)
projections.push_back(projection);
for (const auto& proj : m_maskItems) {
if (proj.currentItem()->modelType() == projectionType)
projections.push_back(proj.currentItem());
}
return projections;
......
......@@ -58,24 +58,13 @@ MaskContainerItem::MaskContainerItem(const QString& modelType)
QVector<MaskItem*> MaskContainerItem::maskItems() const
{
return m_maskItems;
}
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;
return m_maskItems.toQVector();
}
void MaskContainerItem::insertMask(int row, MaskItem* maskItem)
{
maskItem->setParentAndModel(this, SessionItem::model());
m_maskItems.insert(row, maskItem);
m_maskItems.insert_at(row, maskItem);
}
void MaskContainerItem::addMask(MaskItem* maskItem)
......@@ -91,19 +80,19 @@ void MaskContainerItem::moveMask(int from_row, int to_row)
void MaskContainerItem::removeMaskAt(int row)
{
m_maskItems.removeAt(row);
m_maskItems.delete_at(row);
}
void MaskContainerItem::removeMask(MaskItem* maskItem)
{
m_maskItems.removeOne(maskItem);
m_maskItems.delete_element(maskItem);
}
RegionOfInterestItem* MaskContainerItem::regionOfInterestItem() const
{
for (MaskItem* maskItem : m_maskItems)
if (maskItem->modelType() == RegionOfInterestItem::M_TYPE)
return dynamic_cast<RegionOfInterestItem*>(maskItem);
for (const auto& maskSel: m_maskItems)
if (maskSel.currentItem()->modelType() == RegionOfInterestItem::M_TYPE)
return dynamic_cast<RegionOfInterestItem*>(maskSel.currentItem());
return nullptr;
}
......@@ -125,12 +114,12 @@ int MaskContainerItem::size() const
MaskItem* MaskContainerItem::at(const int idx)
{
return m_maskItems.at(idx);
return m_maskItems.at(idx).currentItem();
}
int MaskContainerItem::indexOfItem(MaskItem* maskItem) const
{
return m_maskItems.indexOf(maskItem);
return m_maskItems.index_of(maskItem);
}
void MaskContainerItem::copy(const MaskContainerItem* maskContainer)
......@@ -156,7 +145,7 @@ void MaskContainerItem::writeTo(QXmlStreamWriter* w) const
{
XML::writeAttribute(w, XML::Attrib::version, uint(1));
for (const SelectionProperty<MaskItemCatalog>& sel : maskItemSelections()) {
for (const auto& sel : m_maskItems) {
w->writeStartElement(Tag::Mask);
sel.writeTo(w);
w->writeEndElement();
......@@ -948,6 +937,7 @@ void MaskContainerModel::setParent(QObject* parent)
void MaskContainerModel::insertMask(int row, MaskItem* maskItem)
{
// TODO: unused method. Remove it?
QAbstractListModel::beginInsertRows(maskContainer->rootIndex, row, row);
maskContainer->insertMask(row, maskItem);
// QModelIndex idx = index(row, 0, {});
......
......@@ -230,7 +230,6 @@ public:
MaskContainerItem(const QString& modelType);
QVector<MaskItem*> maskItems() const;
std::vector<SelectionProperty<MaskItemCatalog>> maskItemSelections() const;
//! Insert mask at given row.
virtual void insertMask(int row, MaskItem* maskItem);
......@@ -280,7 +279,7 @@ public:
const QModelIndex rootIndex;
protected:
QVector<MaskItem*> m_maskItems;
SelectionVector<MaskItemCatalog> m_maskItems;
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