TemporalConstraintPresenter::TemporalConstraintPresenter( const TemporalConstraintViewModel& cstr_model, QGraphicsObject *parentobject, QObject* parent) : AbstractConstraintPresenter {"TemporalConstraintPresenter", cstr_model, new TemporalConstraintView{*this, parentobject}, parent} { connect(::view(this), &TemporalConstraintView::constraintHoverEnter, this, &TemporalConstraintPresenter::constraintHoverEnter); connect(::view(this), &TemporalConstraintView::constraintHoverLeave, this, &TemporalConstraintPresenter::constraintHoverLeave); if(viewModel(this)->isRackShown()) { on_rackShown(viewModel(this)->shownRack()); } ::view(this)->setLabel(cstr_model.model().metadata.label()); connect(&cstr_model.model().metadata, &ModelMetadata::labelChanged, ::view(this), &TemporalConstraintView::setLabel); connect(&cstr_model.model().metadata, &ModelMetadata::colorChanged, ::view(this), &TemporalConstraintView::setLabelColor); updateHeight(); }
void MSOptionMenu::setSelectedItem(int item_) { _selectedItem=item_; if(hasModel()==MSTrue) { if(optionMenu()!=0) { _internalEvent=MSTrue; if(_selectedItem<optionsModel().length()) { viewModel()=optionsModel()(_selectedItem); } else viewModel().removeAll(); _internalEvent=MSFalse; } } }
void ProcessPanelPresenter::on_focusedViewModelChanged(const LayerModel* theLM) { if(theLM != m_layerModel) { m_layerModel = theLM; delete m_processPresenter; m_processPresenter = nullptr; if(!m_layerModel) return; auto& sharedmodel = m_layerModel->sharedProcessModel(); auto fact = ProcessList::getFactory(sharedmodel.processName()); auto proxy = m_layerModel->make_panelProxy(this); delete m_obj; m_obj = new ProcessPanelGraphicsProxy{*theLM, *this}; // Add the items to the scene early because // the presenters might call scene() in their ctor. auto panelview = static_cast<ProcessPanelView*>(view()); panelview->scene()->addItem(m_obj); m_layer = fact->makeView(proxy->viewModel(), m_obj); m_processPresenter = fact->makePresenter(proxy->viewModel(), m_layer, this); connect(m_layerModel, &QObject::destroyed, this, &ProcessPanelPresenter::cleanup); // Have a zoom here too. For now the process should be the size of the window. on_sizeChanged(panelview->view()->size()); on_zoomChanged(0.03); } }
void MSOptionMenu::updateData(void) { if(hasModel() == MSTrue && _internalEvent == MSFalse) { _internalEvent=MSTrue; unsigned index; if(optionMenu()==0) { if(viewModel().length()!=0) { MSStringVector sv(viewModel()); options(sv); _selectedItem=0; } } else { if(viewModel().length()!=0) { index = optionsModel().indexOf(viewModel()); if(index == optionsModel().length()) { //append the new value to the list. optionsModel().appendSingle(viewModel()); } _selectedItem=index; drawFieldValue(); } else { if(_selectedItem<optionsModel().length()) { viewModel()=optionsModel()(_selectedItem); } else viewModel().removeAll(); } } _internalEvent=MSFalse; } }