/** * Sets given model to edit widget. */ void TopologyWidget::setModel(TopologyEditModel* model){ this->model = model; npw->setModel(model); //clears widget when NULL pointer given if(model == NULL){ ui->itemName->setText(QString()); clearView(); } //fills view with model data else{ bool saved = model->isSaved(); ui->itemName->setText(model->name()); clearView(); makeView(); connect( model, SIGNAL(changed(ChangeType)), this, SLOT(modelChanged(ChangeType)), Qt::UniqueConnection ); if(model->selectedLayer() >= 0 && model->selectedLayer() < layerEditList.length()){ layerEditList[model->selectedLayer()]->setSelected(true); widgetPressed(layerEditList[model->selectedLayer()]); } else if(layerEditList.length() > 0){ model->setSelectedLayer(layerEditList.length()-1); layerEditList[model->selectedLayer()]->setSelected(true); widgetPressed(layerEditList[model->selectedLayer()]); } model->setSaved(saved); } }
ToolBarSpacer * ToolBar::createSpacer(QAction *before, ToolBarAction &action) { ToolBarSpacer *spacer = new ToolBarSpacer(this); action.action = insertWidget(before, spacer); action.widget = spacer; connect(spacer, SIGNAL(pressed()), this, SLOT(widgetPressed())); return spacer; }
ToolBarSeparator * ToolBar::createSeparator(QAction *before, ToolBarAction &action) { ToolBarSeparator *separator = new ToolBarSeparator(this); action.action = insertWidget(before, separator); action.widget = separator; connect(separator, SIGNAL(pressed()), this, SLOT(widgetPressed())); return separator; }
QToolButton * ToolBar::createPushButton(QAction *before, ToolBarAction &action) { if (!Actions::instance()->contains(action.actionName)) return nullptr; MainWindow *kaduMainWindow = qobject_cast<MainWindow *>(parentWidget()); if (!kaduMainWindow) return nullptr; auto actionByName = Actions::instance()->value(action.actionName); if (!actionByName) return nullptr; if (!kaduMainWindow->supportsActionType(actionByName->type())) return nullptr; action.action = Actions::instance()->createAction(action.actionName, kaduMainWindow->actionContext(), kaduMainWindow); insertAction(before, action.action); QToolButton *button = qobject_cast<QToolButton *>(widgetForAction(action.action)); action.widget = button; if (button) { connect(button, SIGNAL(pressed()), this, SLOT(widgetPressed())); button->installEventFilter(watcher); button->setToolButtonStyle(action.style); if (action.action->menu() && Actions::instance()->contains(action.actionName)) { ActionDescription *actionDescription = Actions::instance()->value(action.actionName); if (actionDescription) button->setPopupMode(actionDescription->buttonPopupMode()); } } return button; }
/** * Mouse press event implementation. */ void LayerEditWidget::mousePressEvent(QMouseEvent* e) { if(!selected) setSelected(true); emit widgetPressed(this); }