SessionManager; configureEditors on project opening/parsing

So far editors were only configured on opening, which meant that if a
project was opened after the file was already open, the editor settings
were wrong. This commit fixes that by connecting to project opening.

Also due to changes in how qmake projects are parsed on initial opening
the project has a empty filelist. Connecting to fileListChanged() fixes
that too.

Task-number: QTCREATORBUG-13299
Change-Id: Ia648818c8c0adb9c6e5047b8c855b1f6790a7ae2
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
Daniel Teske
2014-11-04 17:40:29 +01:00
parent 403f55a517
commit df6ace109e
2 changed files with 22 additions and 1 deletions

View File

@@ -320,8 +320,14 @@ void SessionManager::addProjects(const QList<Project*> &projects)
} }
} }
foreach (Project *pro, clearedList) foreach (Project *pro, clearedList) {
emit m_instance->projectAdded(pro); emit m_instance->projectAdded(pro);
configureEditors(pro);
connect(pro, &Project::fileListChanged,
[pro](){
configureEditors(pro);
});
}
if (clearedList.count() == 1) if (clearedList.count() == 1)
emit m_instance->singleProjectAdded(clearedList.first()); emit m_instance->singleProjectAdded(clearedList.first());
@@ -611,6 +617,19 @@ void SessionManager::configureEditor(Core::IEditor *editor, const QString &fileN
} }
} }
void SessionManager::configureEditors(Project *project)
{
foreach (IDocument *document, DocumentModel::openedDocuments()) {
if (d->projectContainsFile(project, document->filePath())) {
foreach (IEditor *editor, DocumentModel::editorsForDocument(document)) {
if (TextEditor::BaseTextEditor *textEditor = qobject_cast<TextEditor::BaseTextEditor*>(editor)) {
project->editorConfiguration()->configureEditor(textEditor);
}
}
}
}
}
void SessionManager::removeProjects(QList<Project *> remove) void SessionManager::removeProjects(QList<Project *> remove)
{ {
QMap<QString, QStringList> resMap; QMap<QString, QStringList> resMap;

View File

@@ -147,6 +147,8 @@ private slots:
static void configureEditor(Core::IEditor *editor, const QString &fileName); static void configureEditor(Core::IEditor *editor, const QString &fileName);
static void markSessionFileDirty(bool makeDefaultVirginDirty = true); static void markSessionFileDirty(bool makeDefaultVirginDirty = true);
static void projectDisplayNameChanged(); static void projectDisplayNameChanged();
private:
static void configureEditors(Project *project);
}; };
} // namespace ProjectExplorer } // namespace ProjectExplorer