QmlDesigner: Update item library if error is fixed

If the document has an error (e.g. incomplete type information),
then it is required to update the item library if this error is fixed.

Change-Id: Iee9629879a0d3ee4bbc76dc0701f023e3c12f394
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-04-25 11:58:57 +02:00
parent fa6caa3b02
commit b952d0420e
2 changed files with 13 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include "itemlibrarywidget.h"
#include <import.h>
#include <importmanagerview.h>
#include <rewriterview.h>
namespace QmlDesigner {
@@ -69,6 +70,7 @@ void ItemLibraryView::modelAttached(Model *model)
m_widget->setModel(model);
updateImports();
model->attachView(m_importManagerView);
m_hasErrors = !rewriterView()->errors().isEmpty();
}
void ItemLibraryView::modelAboutToBeDetached(Model *model)
@@ -93,6 +95,15 @@ void ItemLibraryView::setResourcePath(const QString &resourcePath)
m_widget->setResourcePath(resourcePath);
}
void ItemLibraryView::documentMessagesChanged(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &)
{
if (m_hasErrors && errors.isEmpty())
/* For some reason we have to call update from the event loop */
QTimer::singleShot(0, m_widget, &ItemLibraryWidget::updateModel);
m_hasErrors = !errors.isEmpty();
}
void ItemLibraryView::updateImports()
{
m_widget->updateModel();

View File

@@ -50,6 +50,7 @@ public:
void modelAttached(Model *model) override;
void modelAboutToBeDetached(Model *model) override;
void importsChanged(const QList<Import> &addedImports, const QList<Import> &removedImports) override;
void documentMessagesChanged(const QList<DocumentMessage> &errors, const QList<DocumentMessage> &warnings) override;
void setResourcePath(const QString &resourcePath);
@@ -59,6 +60,7 @@ protected:
private:
QPointer<ItemLibraryWidget> m_widget;
ImportManagerView *m_importManagerView;
bool m_hasErrors = false;
};
}