forked from qt-creator/qt-creator
Hooked up the QML task manager again.
The QML task manager behaviour is to show warnings/errors for _saved_ files only.
This commit is contained in:
@@ -651,6 +651,7 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
|
||||
m_semanticHighlighter->setModelManager(m_modelManager);
|
||||
connect(m_modelManager, SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
||||
this, SLOT(onDocumentUpdated(QmlJS::Document::Ptr)));
|
||||
connect(this->document(), SIGNAL(modificationChanged(bool)), this, SLOT(modificationChanged(bool)));
|
||||
}
|
||||
|
||||
connect(m_semanticHighlighter, SIGNAL(changed(QmlJSEditor::Internal::SemanticInfo)),
|
||||
@@ -775,6 +776,12 @@ void QmlJSTextEditor::onDocumentUpdated(QmlJS::Document::Ptr doc)
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSTextEditor::modificationChanged(bool changed)
|
||||
{
|
||||
if (!changed && m_modelManager)
|
||||
m_modelManager->fileChangedOnDisk(file()->fileName());
|
||||
}
|
||||
|
||||
void QmlJSTextEditor::jumpToMethod(int index)
|
||||
{
|
||||
if (index > 0 && index <= m_semanticInfo.declarations.size()) { // indexes are 1-based
|
||||
|
||||
@@ -218,6 +218,7 @@ public slots:
|
||||
|
||||
private slots:
|
||||
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||
void modificationChanged(bool);
|
||||
|
||||
void updateDocument();
|
||||
void updateDocumentNow();
|
||||
|
||||
@@ -112,7 +112,7 @@ QFuture<void> ModelManager::refreshSourceFiles(const QStringList &sourceFiles)
|
||||
|
||||
QFuture<void> result = QtConcurrent::run(&ModelManager::parse,
|
||||
workingCopy, sourceFiles,
|
||||
this);
|
||||
this, false);
|
||||
|
||||
if (m_synchronizer.futures().size() > 10) {
|
||||
QList<QFuture<void> > futures = m_synchronizer.futures();
|
||||
@@ -154,6 +154,16 @@ QMap<QString, ModelManager::WorkingCopy> ModelManager::buildWorkingCopyList()
|
||||
return workingCopy;
|
||||
}
|
||||
|
||||
void ModelManager::fileChangedOnDisk(const QString &path)
|
||||
{
|
||||
QtConcurrent::run(&ModelManager::parse,
|
||||
buildWorkingCopyList(), QStringList() << path,
|
||||
this, true);
|
||||
}
|
||||
|
||||
void ModelManager::emitDocumentChangedOnDisk(Document::Ptr doc)
|
||||
{ emit documentChangedOnDisk(doc); }
|
||||
|
||||
void ModelManager::emitDocumentUpdated(Document::Ptr doc)
|
||||
{ emit documentUpdated(doc); }
|
||||
|
||||
@@ -279,7 +289,8 @@ static void findNewLibraryImports(const Document::Ptr &doc, const Snapshot &snap
|
||||
void ModelManager::parse(QFutureInterface<void> &future,
|
||||
QMap<QString, WorkingCopy> workingCopy,
|
||||
QStringList files,
|
||||
ModelManager *modelManager)
|
||||
ModelManager *modelManager,
|
||||
bool emitDocChangedOnDisk)
|
||||
{
|
||||
Core::MimeDatabase *db = Core::ICore::instance()->mimeDatabase();
|
||||
Core::MimeType jsSourceTy = db->findByType(QLatin1String("application/javascript"));
|
||||
@@ -344,6 +355,8 @@ void ModelManager::parse(QFutureInterface<void> &future,
|
||||
}
|
||||
|
||||
modelManager->emitDocumentUpdated(doc);
|
||||
if (emitDocChangedOnDisk)
|
||||
modelManager->emitDocumentChangedOnDisk(doc);
|
||||
}
|
||||
|
||||
future.setProgressValue(progressRange);
|
||||
|
||||
@@ -55,18 +55,20 @@ public:
|
||||
|
||||
virtual QmlJS::Snapshot snapshot() const;
|
||||
virtual void updateSourceFiles(const QStringList &files);
|
||||
virtual void fileChangedOnDisk(const QString &path);
|
||||
|
||||
void emitDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||
void emitLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
||||
void emitDocumentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||
|
||||
virtual void setProjectImportPaths(const QStringList &importPaths);
|
||||
virtual QStringList importPaths() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void projectPathChanged(const QString &projectPath);
|
||||
void aboutToRemoveFiles(const QStringList &files);
|
||||
void libraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
// this should be executed in the GUI thread.
|
||||
void onDocumentUpdated(QmlJS::Document::Ptr doc);
|
||||
@@ -86,7 +88,8 @@ protected:
|
||||
static void parse(QFutureInterface<void> &future,
|
||||
QMap<QString, WorkingCopy> workingCopy,
|
||||
QStringList files,
|
||||
ModelManager *modelManager);
|
||||
ModelManager *modelManager,
|
||||
bool emitDocChangedOnDisk);
|
||||
|
||||
void loadQmlTypeDescriptions();
|
||||
|
||||
|
||||
@@ -54,12 +54,15 @@ public:
|
||||
|
||||
virtual QmlJS::Snapshot snapshot() const = 0;
|
||||
virtual void updateSourceFiles(const QStringList &files) = 0;
|
||||
virtual void fileChangedOnDisk(const QString &path) = 0;
|
||||
|
||||
virtual void setProjectImportPaths(const QStringList &importPaths) = 0;
|
||||
virtual QStringList importPaths() const = 0;
|
||||
|
||||
signals:
|
||||
void documentUpdated(QmlJS::Document::Ptr doc);
|
||||
void documentChangedOnDisk(QmlJS::Document::Ptr doc);
|
||||
void aboutToRemoveFiles(const QStringList &files);
|
||||
};
|
||||
|
||||
} // namespace QmlJSEditor
|
||||
|
||||
Reference in New Issue
Block a user