Ejemplo n.º 1
0
/**
 * 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);
	}
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
/**
 * Mouse press event implementation.
 */
void LayerEditWidget::mousePressEvent(QMouseEvent* e) {
    if(!selected) setSelected(true);
    emit widgetPressed(this);
}