Commit 354cd410 authored by Eike Ziller's avatar Eike Ziller

Make document model static and add some document related methods

Change-Id: Ibcb863e67a2433529c9d2b6dec237f9d8b1d8d50
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 7b1941c7
......@@ -278,6 +278,11 @@ int DocumentModel::indexOfDocument(IDocument *document) const
return -1;
}
QList<IDocument *> DocumentModel::openedDocuments() const
{
return d->m_editors.keys();
}
QModelIndex DocumentModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent)
......
......@@ -77,6 +77,7 @@ public:
int documentCount() const;
QList<Entry *> documents() const;
int indexOfDocument(IDocument *document) const;
QList<IDocument *> openedDocuments() const;
QList<IEditor *> editorsForDocument(IDocument *document) const;
QList<IEditor *> editorsForDocuments(const QList<IDocument *> &documents) const;
......
......@@ -648,6 +648,11 @@ QList<IEditor *> EditorManager::editorsForDocument(IDocument *document) const
return found;
}
IDocument *EditorManager::currentDocument()
{
return d->m_currentEditor ? d->m_currentEditor->document() : 0;
}
IEditor *EditorManager::currentEditor()
{
return d->m_currentEditor;
......@@ -761,9 +766,9 @@ void EditorManager::closeOtherEditors(IDocument *document)
void EditorManager::closeOtherEditors()
{
IEditor *current = currentEditor();
IDocument *current = currentDocument();
QTC_ASSERT(current, return);
closeOtherEditors(current->document());
closeOtherEditors(current);
}
// SLOT connected to action
......@@ -1286,6 +1291,11 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
return editor;
}
IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEditorFlags flags)
{
return activateEditorForDocument(currentEditorView(), document, flags);
}
Core::IEditor *EditorManager::activateEditorForDocument(Core::Internal::EditorView *view, Core::IDocument *document, OpenEditorFlags flags)
{
Q_ASSERT(view);
......@@ -1705,8 +1715,8 @@ bool EditorManager::saveEditor(IEditor *editor)
bool EditorManager::saveDocument(IDocument *documentParam)
{
IDocument *document = documentParam;
if (!document && currentEditor())
document = currentEditor()->document();
if (!document && currentDocument())
document = currentDocument();
if (!document)
return false;
......@@ -1784,8 +1794,8 @@ MakeWritableResult EditorManager::makeFileWritable(IDocument *document)
bool EditorManager::saveDocumentAs(IDocument *documentParam)
{
IDocument *document = documentParam;
if (!document && currentEditor())
document = currentEditor()->document();
if (!document && currentDocument())
document = currentDocument();
if (!document)
return false;
......@@ -1866,22 +1876,22 @@ void EditorManager::gotoPreviousDocHistory()
void EditorManager::makeCurrentEditorWritable()
{
if (IEditor* curEditor = currentEditor())
makeFileWritable(curEditor->document());
if (IDocument* doc = currentDocument())
makeFileWritable(doc);
}
void EditorManager::vcsOpenCurrentEditor()
{
IEditor *curEditor = currentEditor();
if (!curEditor)
IDocument *document = currentDocument();
if (!document)
return;
const QString directory = QFileInfo(curEditor->document()->filePath()).absolutePath();
const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
if (!versionControl || versionControl->openSupportMode() == IVersionControl::NoOpen)
return;
if (!versionControl->vcsOpen(curEditor->document()->filePath())) {
if (!versionControl->vcsOpen(document->filePath())) {
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"),
tr("Cannot open the file for editing with VCS."));
}
......@@ -1895,12 +1905,12 @@ void EditorManager::updateWindowTitle()
windowTitle.prepend(d->m_titleVcsTopic + dashSep);
if (!d->m_titleAddition.isEmpty())
windowTitle.prepend(d->m_titleAddition + dashSep);
IEditor *curEditor = currentEditor();
if (curEditor) {
QString editorName = curEditor->document()->displayName();
IDocument *document = currentDocument();
if (document) {
QString editorName = document->displayName();
if (!editorName.isEmpty())
windowTitle.prepend(editorName + dashSep);
QString filePath = QFileInfo(curEditor->document()->filePath()).absoluteFilePath();
QString filePath = QFileInfo(document->filePath()).absoluteFilePath();
if (!filePath.isEmpty())
ICore::mainWindow()->setWindowFilePath(filePath);
} else {
......@@ -1912,11 +1922,10 @@ void EditorManager::updateWindowTitle()
void EditorManager::handleDocumentStateChange()
{
updateActions();
IDocument *document= qobject_cast<IDocument *>(sender());
IDocument *document = qobject_cast<IDocument *>(sender());
if (!document->isModified())
document->removeAutoSaveFile();
IEditor *currEditor = currentEditor();
if (currEditor && currEditor->document() == document) {
if (currentDocument() == document) {
updateWindowTitle();
emit currentDocumentStateChanged();
}
......@@ -1924,15 +1933,16 @@ void EditorManager::handleDocumentStateChange()
void EditorManager::updateMakeWritableWarning()
{
IEditor *curEditor = currentEditor();
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
if (ww != curEditor->document()->hasWriteWarning()) {
curEditor->document()->setWriteWarning(ww);
IDocument *document = currentDocument();
QTC_ASSERT(document, return);
bool ww = document->isModified() && document->isFileReadOnly();
if (ww != document->hasWriteWarning()) {
document->setWriteWarning(ww);
// Do this after setWriteWarning so we don't re-evaluate this part even
// if we do not really show a warning.
bool promptVCS = false;
const QString directory = QFileInfo(curEditor->document()->filePath()).absolutePath();
const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
if (versionControl && versionControl->openSupportMode() != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
......@@ -1950,15 +1960,15 @@ void EditorManager::updateMakeWritableWarning()
tr("<b>Warning:</b> This file was not opened in %1 yet.")
.arg(versionControl->displayName()));
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
curEditor->document()->infoBar()->addInfo(info);
document->infoBar()->addInfo(info);
} else {
InfoBarEntry info(Id(kMakeWritableWarning),
tr("<b>Warning:</b> You are changing a read-only file."));
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
curEditor->document()->infoBar()->addInfo(info);
document->infoBar()->addInfo(info);
}
} else {
curEditor->document()->infoBar()->removeInfo(Id(kMakeWritableWarning));
document->infoBar()->removeInfo(Id(kMakeWritableWarning));
}
}
}
......@@ -1983,8 +1993,7 @@ void EditorManager::setupSaveActions(IDocument *document, QAction *saveAction, Q
void EditorManager::updateActions()
{
IEditor *curEditor = currentEditor();
IDocument *curDocument = curEditor ? curEditor->document() : 0;
IDocument *curDocument = currentDocument();
int openedCount = d->m_documentModel->documentCount();
if (curDocument) {
......@@ -2074,11 +2083,16 @@ QList<IEditor*> EditorManager::openedEditors() const
return d->m_documentModel->oneEditorForEachOpenedDocument();
}
DocumentModel *EditorManager::documentModel() const
DocumentModel *EditorManager::documentModel()
{
return d->m_documentModel;
}
void EditorManager::closeDocuments(const QList<IDocument *> &document, bool askAboutModifiedEditors)
{
m_instance->closeEditors(d->m_documentModel->editorsForDocuments(document), askAboutModifiedEditors);
}
void EditorManager::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
{
currentEditorView()->addCurrentPositionToNavigationHistory(editor, saveState);
......@@ -2289,8 +2303,7 @@ void EditorManager::readSettings()
void EditorManager::revertToSaved()
{
IEditor *editor = currentEditor();
revertToSaved(editor ? editor->document() : 0);
revertToSaved(currentDocument());
}
void EditorManager::revertToSaved(Core::IDocument *document)
......@@ -2535,9 +2548,9 @@ void EditorManager::updateVariable(const QByteArray &variable)
{
if (VariableManager::instance()->isFileVariable(variable, kCurrentDocumentPrefix)) {
QString value;
IEditor *curEditor = currentEditor();
if (curEditor) {
QString fileName = curEditor->document()->filePath();
IDocument *document = currentDocument();
if (document) {
QString fileName = document->filePath();
if (!fileName.isEmpty())
value = VariableManager::fileVariableValue(variable, kCurrentDocumentPrefix,
fileName);
......
......@@ -126,15 +126,18 @@ public:
QList<IEditor *> editorsForFileName(const QString &filename) const;
QList<IEditor *> editorsForDocument(IDocument *document) const;
static IDocument *currentDocument();
static IEditor *currentEditor();
QList<IEditor *> visibleEditors() const;
QList<IEditor*> openedEditors() const;
static void activateEditor(IEditor *editor, OpenEditorFlags flags = 0);
void activateEditorForEntry(DocumentModel::Entry *entry, OpenEditorFlags flags = 0);
IEditor *activateEditorForDocument(IDocument *document, OpenEditorFlags flags = 0);
IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0);
DocumentModel *documentModel() const;
static DocumentModel *documentModel();
static void closeDocuments(const QList<IDocument *> &documents, bool askAboutModifiedEditors = true);
void closeEditor(DocumentModel::Entry *entry);
void closeOtherEditors(IDocument *document);
......
......@@ -303,8 +303,8 @@ IEditor *EditorView::currentEditor() const
void EditorView::listSelectionActivated(int index)
{
DocumentModel *model = EditorManager::instance()->documentModel();
EditorManager::instance()->activateEditorForEntry(this, model->documentAtRow(index));
EditorManager::instance()->activateEditorForEntry(
this, EditorManager::documentModel()->documentAtRow(index));
}
void EditorView::splitHorizontally()
......@@ -786,7 +786,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
| Core::EditorManager::DoNotChangeCurrentEditor);
if (!e) {
DocumentModel::Entry *entry = em->documentModel()->firstRestoredDocument();
DocumentModel::Entry *entry = EditorManager::documentModel()->firstRestoredDocument();
if (entry)
em->activateEditorForEntry(view(), entry, Core::EditorManager::IgnoreNavigationHistory
| Core::EditorManager::DoNotChangeCurrentEditor);
......
......@@ -96,9 +96,8 @@ OpenEditorsWidget::OpenEditorsWidget()
setTextElideMode(Qt::ElideMiddle);
setFrameStyle(QFrame::NoFrame);
setAttribute(Qt::WA_MacShowFocusRect, false);
EditorManager *em = EditorManager::instance();
m_model = new ProxyModel(this);
m_model->setSourceModel(em->documentModel());
m_model->setSourceModel(EditorManager::documentModel());
setModel(m_model);
setSelectionMode(QAbstractItemView::SingleSelection);
setSelectionBehavior(QAbstractItemView::SelectRows);
......@@ -110,7 +109,7 @@ OpenEditorsWidget::OpenEditorsWidget()
installEventFilter(this);
viewport()->installEventFilter(this);
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
connect(EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateCurrentItem(Core::IEditor*)));
connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(handleClicked(QModelIndex)));
......@@ -128,8 +127,7 @@ OpenEditorsWidget::~OpenEditorsWidget()
void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
{
IDocument *document = editor ? editor->document() : 0;
EditorManager *em = EditorManager::instance();
QModelIndex index = m_model->index(em->documentModel()->indexOfDocument(document), 0);
QModelIndex index = m_model->index(EditorManager::documentModel()->indexOfDocument(document), 0);
if (!index.isValid()) {
clearSelection();
return;
......@@ -194,14 +192,14 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
void OpenEditorsWidget::activateEditor(const QModelIndex &index)
{
selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
EditorManager *em = EditorManager::instance();
em->activateEditorForEntry(em->documentModel()->documentAtRow(m_model->mapToSource(index).row()));
EditorManager::instance()->activateEditorForEntry(
EditorManager::documentModel()->documentAtRow(m_model->mapToSource(index).row()));
}
void OpenEditorsWidget::closeEditor(const QModelIndex &index)
{
EditorManager *em = EditorManager::instance();
em->closeEditor(em->documentModel()->documentAtRow(m_model->mapToSource(index).row()));
EditorManager::instance()->closeEditor(
EditorManager::documentModel()->documentAtRow(m_model->mapToSource(index).row()));
// work around selection changes
updateCurrentItem(EditorManager::currentEditor());
}
......@@ -210,7 +208,7 @@ void OpenEditorsWidget::contextMenuRequested(QPoint pos)
{
QMenu contextMenu;
QModelIndex editorIndex = indexAt(pos);
DocumentModel::Entry *entry = EditorManager::instance()->documentModel()->documentAtRow(
DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
m_model->mapToSource(editorIndex).row());
EditorManager::instance()->addSaveAndCloseEditorActions(&contextMenu, entry);
contextMenu.addSeparator();
......
......@@ -229,7 +229,7 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
} else {
if (!EditorManager::openEditor(
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>())) {
EditorManager::instance()->documentModel()->removeDocument(item->toolTip(0));
EditorManager::documentModel()->removeDocument(item->toolTip(0));
delete item;
}
}
......
......@@ -115,7 +115,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_lockButton->setAutoRaise(true);
d->m_lockButton->setEnabled(false);
d->m_editorsListModel = EditorManager::instance()->documentModel();
d->m_editorsListModel = EditorManager::documentModel();
connect(d->m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked()));
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
......@@ -315,8 +315,8 @@ void EditorToolBar::changeActiveEditor(int row)
void EditorToolBar::listContextMenu(QPoint pos)
{
DocumentModel::Entry *entry = EditorManager::instance()
->documentModel()->documentAtRow(d->m_editorList->currentIndex());
DocumentModel::Entry *entry = EditorManager::documentModel()->documentAtRow(
d->m_editorList->currentIndex());
QString fileName = entry ? entry->fileName() : QString();
if (fileName.isEmpty())
return;
......@@ -333,8 +333,8 @@ void EditorToolBar::listContextMenu(QPoint pos)
void EditorToolBar::makeEditorWritable()
{
if (IEditor *current = EditorManager::currentEditor())
EditorManager::instance()->makeFileWritable(current->document());
if (IDocument *current = EditorManager::currentDocument())
EditorManager::instance()->makeFileWritable(current);
}
void EditorToolBar::setCanGoBack(bool canGoBack)
......
......@@ -590,10 +590,10 @@ void ExternalToolRunner::run()
return;
}
if (m_tool->modifiesCurrentDocument()) {
if (IEditor *editor = EditorManager::currentEditor()) {
m_expectedFileName = editor->document()->filePath();
if (IDocument *document = EditorManager::currentDocument()) {
m_expectedFileName = document->filePath();
bool cancelled = false;
DocumentManager::saveModifiedDocuments(QList<IDocument *>() << editor->document(), &cancelled);
DocumentManager::saveModifiedDocuments(QList<IDocument *>() << document, &cancelled);
if (cancelled) {
deleteLater();
return;
......
......@@ -279,9 +279,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
const bool isVcsConfigured = versionControl->isConfigured();
if (!isVcsConfigured || d->m_unconfiguredVcs) {
Id vcsWarning("VcsNotConfiguredWarning");
IDocument *curDocument = 0;
if (IEditor *curEditor = EditorManager::currentEditor())
curDocument = curEditor->document();
IDocument *curDocument = EditorManager::currentDocument();
if (isVcsConfigured) {
if (curDocument && d->m_unconfiguredVcs == versionControl) {
curDocument->infoBar()->removeInfo(vcsWarning);
......
......@@ -154,7 +154,7 @@ ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown()
void CppToolsPlugin::switchHeaderSource()
{
QString otherFile = correspondingHeaderOrSource(
Core::EditorManager::currentEditor()->document()->filePath());
Core::EditorManager::currentDocument()->filePath());
if (!otherFile.isEmpty())
Core::EditorManager::openEditor(otherFile);
}
......@@ -162,7 +162,7 @@ void CppToolsPlugin::switchHeaderSource()
void CppToolsPlugin::switchHeaderSourceInNextSplit()
{
QString otherFile = correspondingHeaderOrSource(
Core::EditorManager::currentEditor()->document()->filePath());
Core::EditorManager::currentDocument()->filePath());
if (!otherFile.isEmpty())
Core::EditorManager::openEditor(otherFile, Core::Id(), Core::EditorManager::OpenInOtherSplit);
}
......
......@@ -864,12 +864,11 @@ void FormEditorW::print()
// Find out current existing editor file
static QString currentFile()
{
if (Core::IEditor *editor = Core::EditorManager::currentEditor())
if (const Core::IDocument *document = editor->document()) {
const QString fileName = document->filePath();
if (!fileName.isEmpty() && QFileInfo(fileName).isFile())
return fileName;
}
if (const Core::IDocument *document = Core::EditorManager::currentDocument()) {
const QString fileName = document->filePath();
if (!fileName.isEmpty() && QFileInfo(fileName).isFile())
return fileName;
}
return QString();
}
......
......@@ -1997,23 +1997,20 @@ void FakeVimPluginPrivate::highlightMatches(const QString &needle)
int FakeVimPluginPrivate::currentFile() const
{
DocumentModel *model = EditorManager::instance()->documentModel();
IEditor *editor = EditorManager::currentEditor();
if (!editor)
return -1;
return model->indexOfDocument(editor->document());
return EditorManager::documentModel()->indexOfDocument(editor->document());
}
void FakeVimPluginPrivate::switchToFile(int n)
{
EditorManager *editorManager = ICore::editorManager();
DocumentModel *model = editorManager->documentModel();
int size = model->documentCount();
int size = EditorManager::documentModel()->documentCount();
QTC_ASSERT(size, return);
n = n % size;
if (n < 0)
n += size;
editorManager->activateEditorForEntry(model->documents().at(n));
EditorManager::instance()->activateEditorForEntry(EditorManager::documentModel()->documents().at(n));
}
ExCommandMap &FakeVimExCommandsPage::exCommandMap()
......
......@@ -782,8 +782,8 @@ static inline QString msgParseFilesFailed()
static inline QString currentDocumentPath()
{
if (Core::IEditor *editor = Core::EditorManager::currentEditor())
return QFileInfo(editor->document()->filePath()).path();
if (Core::IDocument *document= Core::EditorManager::currentDocument())
return QFileInfo(document->filePath()).path();
return QString();
}
......
......@@ -993,10 +993,7 @@ void GitPlugin::updateVersionWarning()
unsigned version = m_gitClient->gitVersion();
if (!version || version >= minimumRequiredVersion)
return;
Core::IEditor *curEditor = Core::EditorManager::currentEditor();
if (!curEditor)
return;
Core::IDocument *curDocument = curEditor->document();
Core::IDocument *curDocument = Core::EditorManager::currentDocument();
if (!curDocument)
return;
Core::InfoBar *infoBar = curDocument->infoBar();
......
......@@ -58,9 +58,9 @@ QList<FilterEntry> FileSystemFilter::matchesFor(QFutureInterface<Locator::Filter
if (filePath.startsWith(QLatin1String("~/"))) {
directory.replace(0, 1, QDir::homePath());
} else {
IEditor *editor = EditorManager::currentEditor();
if (editor && !editor->document()->filePath().isEmpty()) {
QFileInfo info(editor->document()->filePath());
IDocument *document= EditorManager::currentDocument();
if (document && !document->filePath().isEmpty()) {
QFileInfo info(document->filePath());
directory.prepend(info.absolutePath() + QLatin1Char('/'));
}
}
......
......@@ -87,7 +87,7 @@ QList<FilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locator::Fil
void OpenDocumentsFilter::refreshInternally()
{
m_editors.clear();
foreach (DocumentModel::Entry *e, EditorManager::instance()->documentModel()->documents()) {
foreach (DocumentModel::Entry *e, EditorManager::documentModel()->documents()) {
DocumentModel::Entry entry;
// create copy with only the information relevant to use
// to avoid model deleting entries behind our back
......
......@@ -1020,12 +1020,10 @@ void ProjectExplorerPlugin::loadAction()
// for your special convenience, we preselect a pro file if it is
// the current file
if (Core::IEditor *editor = Core::EditorManager::currentEditor()) {
if (const Core::IDocument *document= editor->document()) {
const QString fn = document->filePath();
const bool isProject = d->m_profileMimeTypes.contains(document->mimeType());
dir = isProject ? fn : QFileInfo(fn).absolutePath();
}
if (const Core::IDocument *document = Core::EditorManager::currentDocument()) {
const QString fn = document->filePath();
const bool isProject = d->m_profileMimeTypes.contains(document->mimeType());
dir = isProject ? fn : QFileInfo(fn).absolutePath();
}
QString filename = QFileDialog::getOpenFileName(0, tr("Load Project"),
......@@ -1827,8 +1825,8 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
}
d->m_currentProject = project;
if (!node && Core::EditorManager::currentEditor()) {
connect(Core::EditorManager::currentEditor()->document(), SIGNAL(changed()),
if (!node && Core::EditorManager::currentDocument()) {
connect(Core::EditorManager::currentDocument(), SIGNAL(changed()),
this, SLOT(updateExternalFileWarning()), Qt::UniqueConnection);
}
if (projectChanged || d->m_currentNode != node) {
......
......@@ -225,8 +225,8 @@ void QbsProjectManagerPlugin::updateBuildActions()
QString file;
if (Core::IEditor *currentEditor = Core::EditorManager::currentEditor()) {
file = currentEditor->document()->filePath();
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
file = currentDocument->filePath();
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
ProjectExplorer::Node *node = session->nodeForFile(file);
ProjectExplorer::Project *project
......@@ -296,8 +296,8 @@ void QbsProjectManagerPlugin::buildFile()
{
QString file;
QbsProject *project = 0;
if (Core::IEditor *currentEditor = Core::EditorManager::currentEditor()) {
file = currentEditor->document()->filePath();
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
file = currentDocument->filePath();
project = qobject_cast<QbsProject *>(m_projectExplorer->session()->projectForFile(file));
}
......@@ -319,8 +319,8 @@ void QbsProjectManagerPlugin::buildProduct()
{
QbsProject *project = 0;
QbsProductNode *product = 0;
if (Core::IEditor *currentEditor = Core::EditorManager::currentEditor()) {
const QString file = currentEditor->document()->filePath();
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
const QString file = currentDocument->filePath();
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
project = qobject_cast<QbsProject *>(session->projectForFile(file));
......
......@@ -172,7 +172,7 @@ void ShortCutManager::registerActions(const Core::Context &qmlDesignerMainContex
void ShortCutManager::updateActions(Core::IEditor* currentEditor)
{
int openedCount = Core::ICore::editorManager()->documentModel()->documentCount();
int openedCount = Core::EditorManager::documentModel()->documentCount();
m_saveAction.setEnabled(currentEditor != 0 && currentEditor->document()->isModified());
m_saveAsAction.setEnabled(currentEditor != 0 && currentEditor->document()->isSaveAsAllowed());
......
......@@ -281,14 +281,14 @@ void QmlProjectRunConfiguration::updateEnabled()
{
bool qmlFileFound = false;
if (mainScriptSource() == FileInEditor) {
Core::IEditor *editor = Core::EditorManager::currentEditor();
Core::IDocument *document= Core::EditorManager::currentDocument();
Core::MimeDatabase *db = ICore::mimeDatabase();
if (editor) {
m_currentFileFilename = editor->document()->filePath();
if (document) {
m_currentFileFilename = document->filePath();
if (db->findByFile(mainScript()).type() == QLatin1String("application/x-qml"))
qmlFileFound = true;
}
if (!editor
if (!document
|| db->findByFile(mainScript()).type() == QLatin1String("application/x-qmlproject")) {
// find a qml file with lowercase filename. This is slow, but only done
// in initialization/other border cases.
......
......@@ -326,8 +326,8 @@ void Qt4Manager::buildFileContextMenu()
void Qt4Manager::buildFile()
{
if (Core::IEditor *currentEditor = Core::EditorManager::currentEditor()) {
QString file = currentEditor->document()->filePath();
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
QString file = currentDocument->filePath();
ProjectExplorer::SessionManager *session = projectExplorer()->session();
ProjectExplorer::FileNode *node = qobject_cast<FileNode *>(session->nodeForFile(file));
ProjectExplorer::Project *project = session->projectForFile(file);
......
......@@ -416,8 +416,8 @@ void Qt4ProjectManagerPlugin::updateBuildFileAction()
bool enabled = false;
QString file;
if (Core::IEditor *currentEditor = Core::EditorManager::currentEditor()) {
file = currentEditor->document()->filePath();
if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) {
file = currentDocument->filePath();
ProjectExplorer::SessionManager *session = m_projectExplorer->session();
ProjectExplorer::Node *node = session->nodeForFile(file);
ProjectExplorer::Project *project = session->projectForFile(file);
......
......@@ -68,7 +68,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters,
QStringList fileNames;
QList<QTextCodec *> codecs;
foreach (Core::DocumentModel::Entry *entry,
Core::EditorManager::instance()->documentM