Пример #1
0
RackInspectorSection::RackInspectorSection(
    const QString& name,
    const RackModel& rack,
    const ConstraintInspectorWidget& parentConstraint,
    QWidget* parent) :
    InspectorSectionWidget {name, false, parent},
    m_parent{parentConstraint},
    m_model {rack}
{
    auto framewidg = new QFrame;
    auto lay = new iscore::MarginLess<QVBoxLayout> {framewidg};
    framewidg->setFrameShape(QFrame::StyledPanel);
    addContent(framewidg);

    this->showMenu(true);
    auto del = this->menu()->addAction(tr("Remove Rack"));
    del->setIcon(genIconFromPixmaps(QString(":/icons/delete_on.png"), QString(":/icons/delete_off.png")));
    connect(del, &QAction::triggered, this, [=] ()
    {
        auto cmd = new Command::RemoveRackFromConstraint{
            m_parent.model(),
            m_model.id()};
        emit m_parent.commandDispatcher()->submitCommand(cmd);
    });

    // Slots
    m_slotSection = new InspectorSectionWidget{"Slots", false, this};  // TODO Make a custom widget.
    m_slotSection->setObjectName("Slots");

    m_model.slotmodels.added.connect<RackInspectorSection, &RackInspectorSection::on_slotCreated>(this);
    m_model.slotmodels.removed.connect<RackInspectorSection, &RackInspectorSection::on_slotRemoved>(this);

    for(const auto& slot : m_model.slotmodels)
    {
        addSlotInspectorSection(slot);
    }

    // add indention in section
    auto indentWidg = new QWidget{this};
    auto indentLay = new iscore::MarginLess<QHBoxLayout> {indentWidg};

    indentLay->addWidget(new Inspector::VSeparator{this});
    indentLay->addWidget(m_slotSection);
    indentLay->setStretchFactor(m_slotSection, 10);

    m_slotWidget = new AddSlotWidget{this};
    lay->addWidget(indentWidg);
    lay->addWidget(m_slotWidget);

    connect(this, &InspectorSectionWidget::nameChanged,
            this, &RackInspectorSection::ask_changeName);
}
Пример #2
0
void RackInspectorSection::on_slotCreated(const SlotModel& slot)
{
    // TODO display them in the order of their position.
    // TODO issue : the rack should grow of 10 more pixels for each slot.
    addSlotInspectorSection(slot);
}