Let the DesignMode recover when the qml contains an error on first load

If the qml contains an error on frist call of
DesignDocumentController::loadMaster, we did not wire up the components
to the model. If the user then fixed the qml, the Design mode widgets
were 'enabled', but didn't contain any meaningful input.

Fixed by always wiring up the components. Unfortunately this shows the
'default' model with just a Rectangle.
This commit is contained in:
Kai Koehne
2010-01-13 11:44:13 +01:00
parent e929a40108
commit 84c30ea99e
2 changed files with 11 additions and 9 deletions

View File

@@ -332,10 +332,10 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
//m_d->masterModel = Model::create(m_d->textModifier, m_d->searchPath, errors); //m_d->masterModel = Model::create(m_d->textModifier, m_d->searchPath, errors);
m_d->masterModel = Model::create("Item", 4, 6); m_d->masterModel = Model::create("Qt/Rectangle", 4, 6);
m_d->masterModel->setFileUrl(m_d->searchPath); m_d->masterModel->setFileUrl(m_d->searchPath);
m_d->subComponentModel = Model::create("Item", 4, 6); m_d->subComponentModel = Model::create("Qt/Rectangle", 4, 6);
m_d->subComponentModel->setFileUrl(m_d->searchPath); m_d->subComponentModel->setFileUrl(m_d->searchPath);
m_d->subComponentManager = new SubComponentManager(m_d->masterModel->metaInfo(), this); m_d->subComponentManager = new SubComponentManager(m_d->masterModel->metaInfo(), this);
@@ -354,13 +354,9 @@ QList<RewriterView::Error> DesignDocumentController::loadMaster(QPlainTextEdit *
m_d->masterModel->attachView(m_d->viewLogger.data()); m_d->masterModel->attachView(m_d->viewLogger.data());
#endif #endif
// m_d->masterModel->detachView(m_d->rewriterView.data()); loadCurrentModel();
QList<RewriterView::Error> errors = m_d->rewriterView->errors(); return m_d->rewriterView->errors();
if (errors.isEmpty())
loadCurrentModel();
return errors;
} }
void DesignDocumentController::changeCurrentModelTo(const ModelNode &componentNode) void DesignDocumentController::changeCurrentModelTo(const ModelNode &componentNode)

View File

@@ -356,6 +356,9 @@ void DocumentWidget::disable(const QList<RewriterView::Error> &errors)
void DocumentWidget::updateErrorStatus(const QList<RewriterView::Error> &errors) void DocumentWidget::updateErrorStatus(const QList<RewriterView::Error> &errors)
{ {
if (debug)
qDebug() << Q_FUNC_INFO << errors.count();
if (m_isDisabled && errors.isEmpty()) { if (m_isDisabled && errors.isEmpty()) {
enable(); enable();
} else if (!errors.isEmpty()) { } else if (!errors.isEmpty()) {
@@ -526,7 +529,6 @@ void DesignModeWidget::showEditor(Core::IEditor *editor)
if (textEdit && textEditor && fileName.endsWith(".qml")) { if (textEdit && textEditor && fileName.endsWith(".qml")) {
if (m_documentHash.contains(textEdit)) { if (m_documentHash.contains(textEdit)) {
documentWidget = m_documentHash.value(textEdit); documentWidget = m_documentHash.value(textEdit);
documentWidget->setAutoSynchronization(true);
} else { } else {
DesignDocumentController *newDocument = new DesignDocumentController(0); DesignDocumentController *newDocument = new DesignDocumentController(0);
newDocument->setFileName(fileName); newDocument->setFileName(fileName);
@@ -659,6 +661,10 @@ void DesignModeWidget::setCurrentDocumentWidget(DocumentWidget *newDocumentWidge
{ {
if (debug) if (debug)
qDebug() << Q_FUNC_INFO << newDocumentWidget; qDebug() << Q_FUNC_INFO << newDocumentWidget;
if (m_currentDocumentWidget == newDocumentWidget)
return;
if (m_currentDocumentWidget) { if (m_currentDocumentWidget) {
m_currentDocumentWidget->setAutoSynchronization(false); m_currentDocumentWidget->setAutoSynchronization(false);
m_currentDocumentWidget->saveSettings(); m_currentDocumentWidget->saveSettings();