void SlotInspectorSection::on_layerModelRemoved(const Process::LayerModel& removed)
{
    // OPTIMIZEME
    m_lmSection->removeAll();

    auto frame = new QFrame{this};
    m_lmGridLayout = new iscore::MarginLess<QGridLayout>{frame};
    frame->setFrameShape(QFrame::StyledPanel);

    for (const auto& lm : m_model.layers)
    {
        if (lm.id() != removed.id())
        {
            displayLayerModel(lm);
        }
    }
}
void SlotInspectorSection::displayLayerModel(const Process::LayerModel& lm)
{
    auto lm_id = lm.id();

    // LM label
    QString name = lm.objectName();
    name.resize(name.indexOf("Layer"));
    auto id = lm.processModel().id();

    auto row = m_lmGridLayout->rowCount();

    auto label = new QLabel {QString{name + ".%1"} .arg(*id.val()), this};
    m_lmGridLayout->addWidget(label, row ,0);

    // To front button
    auto pb = new QPushButton {tr("Front")};

    connect(pb, &QPushButton::clicked,
            [=]() {
        PutLayerModelToFront cmd{m_model, lm_id};
        cmd.redo();
    });
    m_lmGridLayout->addWidget(new QWidget{this}, row, 1);
    m_lmGridLayout->addWidget(pb, row, 2);
    m_lmGridLayout->addWidget(new QWidget{this}, row, 3);

    // Delete button
    auto deleteButton = new QPushButton{{tr("Delete")}};
    connect(deleteButton, &QPushButton::pressed, this, [=] ()
    {
        auto cmd = new Command::RemoveLayerModelFromSlot{m_model, lm_id};
        emit m_parent.commandDispatcher()->submitCommand(cmd);
    });
    m_lmGridLayout->addWidget(deleteButton, row, 4);
    m_lmGridLayout->addWidget(new QWidget{this}, row, 5);
}
Exemple #3
0
void SlotModel::on_addLayer(const Process::LayerModel& viewmodel)
{
    putToFront(viewmodel.id());
}