CppEditor: Remember project in preprocessor dialog.

Change-Id: If226707541b1fd4d5c22de2795fb39bc333cfa49
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
David Schulz
2013-10-17 07:59:57 +02:00
parent ffc90ba09f
commit 10f42df8b3
3 changed files with 23 additions and 13 deletions

View File

@@ -702,17 +702,14 @@ void CPPEditorWidget::selectAll()
void CPPEditorWidget::setMimeType(const QString &mt)
{
const QString &filePath = editor()->document()->filePath();
// Check if this editor belongs to a project
QList<ProjectPart::Ptr> projectParts = m_modelManager->projectPart(filePath);
if (projectParts.isEmpty())
projectParts = m_modelManager->projectPartFromDependencies(filePath);
if (!projectParts.isEmpty()) {
QSharedPointer<SnapshotUpdater> updater
= m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
const QString &projectFile = projectParts.first()->projectFile;
updater->setEditorDefines(ProjectExplorer::SessionManager::value(
projectFile + QLatin1Char(',') + filePath).toByteArray());
}
const QString &projectFile = ProjectExplorer::SessionManager::value(
QLatin1String(Constants::CPP_PREPROCESSOR_PROJECT_PREFIX) + filePath).toString();
const QByteArray &additionalDirectives = ProjectExplorer::SessionManager::value(
projectFile + QLatin1Char(',') + filePath).toByteArray();
QSharedPointer<SnapshotUpdater> updater
= m_modelManager->cppEditorSupport(editor())->snapshotUpdater();
updater->setEditorDefines(additionalDirectives);
BaseTextEditorWidget::setMimeType(mt);
setObjCEnabled(mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)