Skip to content
Snippets Groups Projects
Commit f11d8338 authored by Matthias Puchner's avatar Matthias Puchner
Browse files

add top/bottom info to layer

parent 4a613b32
No related branches found
No related tags found
1 merge request!570remove SessionModel/Item from SampleModel and all related items
......@@ -165,3 +165,23 @@ void LayerItem::setColor(const QColor& color)
{
setItemValue(P_COLOR, color);
}
void LayerItem::setIsTopLayer(bool b)
{
m_isTopLayer = b;
}
bool LayerItem::isTopLayer() const
{
return m_isTopLayer;
}
void LayerItem::setIsBottomLayer(bool b)
{
m_isBottomLayer = b;
}
bool LayerItem::isBottomLayer() const
{
return m_isBottomLayer;
}
......@@ -61,6 +61,16 @@ public:
QColor color() const;
void setColor(const QColor& color);
void setIsTopLayer(bool b);
bool isTopLayer() const;
void setIsBottomLayer(bool b);
bool isBottomLayer() const;
private:
bool m_isTopLayer = false;
bool m_isBottomLayer = false;
private:
// -- Only for testing
friend class TestMapperForItem_onPropertyChange_Test;
......
......@@ -106,23 +106,35 @@ LayerItem* MultiLayerItem::addLayer(int index)
if (index < 0)
index = m_layers.size();
auto* l = new LayerItem();
m_layers.insert(index, l);
return l;
auto* layer = new LayerItem();
m_layers.insert(index, layer);
layer->setIsTopLayer(m_layers.first() == layer);
layer->setIsBottomLayer(m_layers.last() == layer);
return layer;
}
void MultiLayerItem::removeLayer(LayerItem* item)
void MultiLayerItem::removeLayer(LayerItem* layer)
{
m_layers.removeAll(item);
m_layers.removeAll(layer);
delete layer;
if (!m_layers.isEmpty()) {
m_layers.first()->setIsTopLayer(true);
m_layers.last()->setIsBottomLayer(true);
}
}
void MultiLayerItem::moveLayer(LayerItem* item, LayerItem* beforeThisLayer)
void MultiLayerItem::moveLayer(LayerItem* layer, LayerItem* beforeThisLayer)
{
m_layers.removeAll(item);
int index = -1; // move to end
m_layers.removeAll(layer);
int index = m_layers.size(); // move to end
if (beforeThisLayer != nullptr)
index = m_layers.indexOf(beforeThisLayer);
m_layers.insert(index, item);
m_layers.insert(index, layer);
for (auto l : m_layers) {
l->setIsTopLayer(m_layers.first() == l);
l->setIsBottomLayer(m_layers.last() == l);
}
}
void MultiLayerItem::writeContentTo(QXmlStreamWriter* writer) const
......@@ -144,6 +156,12 @@ void MultiLayerItem::writeContentTo(QXmlStreamWriter* writer) const
void MultiLayerItem::readContentFrom(QXmlStreamReader* reader)
{
// #baMigration ++ implement
// set non-stored infos
for (auto l : m_layers) {
l->setIsTopLayer(m_layers.first() == l);
l->setIsBottomLayer(m_layers.last() == l);
}
}
QString MultiLayerItem::uidForDescriptor(const QString& lastPart) const
......
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