QmlDesigner: reactivating subcomponent editing

This includes refactoring the DesignDocumentController.
In the ComponentTextMoifier I use replaced because it is not blocked by
beginEditBlock() of the text cursor.

I use the same pattern now for ComponentView like for all the other
views.
The view is created and controlled by DesignModeWidget because we
have only a single instance.

Change-Id: I7809b96f52f4d275f0231f3961c3c4bc2618ce89
Reviewed-on: http://codereview.qt.nokia.com/96
Reviewed-by: Marco Bubke <marco.bubke@nokia.com>
This commit is contained in:
Thomas Hartmann
2011-05-24 18:47:33 +02:00
committed by Marco Bubke
parent e3842f9973
commit f950b8d7c7
9 changed files with 109 additions and 64 deletions

View File

@@ -39,30 +39,17 @@
namespace QmlDesigner {
ComponentAction::ComponentAction(QObject *parent)
: QWidgetAction(parent),
m_componentView(new ComponentView(this))
ComponentAction::ComponentAction(ComponentView *componentView)
: QWidgetAction(componentView),
m_componentView(componentView)
{
}
void ComponentAction::setModel(Model* model)
{
if (model == m_componentView->model())
return;
blockSignals(true);
if (model)
model->attachView(m_componentView.data());
else if (m_componentView->model())
m_componentView->model()->detachView(m_componentView.data());
blockSignals(false);
}
QWidget *ComponentAction::createWidget(QWidget *parent)
{
QComboBox *comboBox = new QComboBox(parent);
comboBox->setMinimumWidth(120);
comboBox->setToolTip(tr("Edit sub components defined in this file"));
comboBox->setModel(m_componentView->standardItemModel());
connect(comboBox, SIGNAL(currentIndexChanged(int)), SLOT(emitCurrentComponentChanged(int)));