Commit 1ed12d39 authored by Daniel Teske's avatar Daniel Teske

Remove DocumentManager::currentFile, use DocumentManager::currentEditor

Change-Id: Ided1a14481cfbbcc49e901f3837e056582ff60e3
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent a6ea3808
......@@ -152,8 +152,6 @@ struct DocumentManagerPrivate
QList<DocumentManager::RecentFile> m_recentFiles;
static const int m_maxRecentFiles = 7;
QString m_currentFile;
QFileSystemWatcher *m_fileWatcher; // Delayed creation.
QFileSystemWatcher *m_linkWatcher; // Delayed creation (only UNIX/if a link is seen).
bool m_blockActivated;
......@@ -878,8 +876,8 @@ QStringList DocumentManager::getOpenFileNames(const QString &filters,
{
QString path = pathIn;
if (path.isEmpty()) {
if (!d->m_currentFile.isEmpty())
path = QFileInfo(d->m_currentFile).absoluteFilePath();
if (EditorManager::currentDocument() && !EditorManager::currentDocument()->isTemporary())
path = EditorManager::currentDocument()->filePath().toString();
if (path.isEmpty() && useProjectsDirectory())
path = projectsDirectory();
}
......@@ -1242,34 +1240,6 @@ void readSettings()
s->endGroup();
}
/*!
The current file is the file currently opened when an editor is active,
or the selected file in case a Project Explorer is active.
\sa currentFile
*/
void DocumentManager::setCurrentFile(const QString &filePath)
{
if (d->m_currentFile == filePath)
return;
d->m_currentFile = filePath;
emit m_instance->currentFileChanged(d->m_currentFile);
}
/*!
Returns the absolute path of the current file.
The current file is the file currently opened when an editor is active,
or the selected file in case a Project Explorer is active.
\sa setCurrentFile
*/
QString DocumentManager::currentFile()
{
return d->m_currentFile;
}
/*!
Returns the initial directory for a new file dialog. If there is
......@@ -1280,8 +1250,8 @@ QString DocumentManager::currentFile()
QString DocumentManager::fileDialogInitialDirectory()
{
if (!d->m_currentFile.isEmpty())
return QFileInfo(d->m_currentFile).absolutePath();
if (EditorManager::currentDocument() && !EditorManager::currentDocument()->isTemporary())
return QFileInfo(EditorManager::currentDocument()->filePath().toString()).absolutePath();
return d->m_lastVisitedDirectory;
}
......
......@@ -83,10 +83,6 @@ public:
static void saveSettings();
// current file
static void setCurrentFile(const QString &filePath);
static QString currentFile();
// helper functions
static QString fixFileName(const QString &fileName, FixMode fixmode);
......@@ -148,7 +144,6 @@ public slots:
static void executeOpenWithMenuAction(QAction *action);
signals:
void currentFileChanged(const QString &filePath);
/* Used to notify e.g. the code model to update the given files. Does *not*
lead to any editors to reload or any other editor manager actions. */
void filesChangedInternally(const QStringList &files);
......
......@@ -1576,8 +1576,6 @@ void EditorManagerPrivate::handleContextChange(const QList<IContext *> &context)
d->m_scheduledCurrentEditor = editor;
QTimer::singleShot(0, d, SLOT(setCurrentEditorFromContextChange()));
} else {
if (editor && !editor->document()->isTemporary())
DocumentManager::setCurrentFile(editor->document()->filePath().toString());
updateActions();
}
}
......@@ -1823,9 +1821,6 @@ void EditorManagerPrivate::setCurrentEditorFromContextChange()
IEditor *newCurrent = d->m_scheduledCurrentEditor;
d->m_scheduledCurrentEditor = 0;
setCurrentEditor(newCurrent);
if (!newCurrent->document()->isTemporary())
DocumentManager::setCurrentFile(newCurrent->document()->filePath().toString());
}
EditorView *EditorManagerPrivate::currentEditorView()
......
......@@ -38,6 +38,7 @@
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/fileutils.h>
#include <coreplugin/find/findplugin.h>
......@@ -199,17 +200,18 @@ void FolderNavigationWidget::setAutoSynchronization(bool sync)
m_autoSync = sync;
if (m_autoSync) {
connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
this, SLOT(setCurrentFile(QString)));
setCurrentFile(Core::DocumentManager::currentFile());
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
this, &FolderNavigationWidget::setCurrentFile);
setCurrentFile(Core::EditorManager::currentEditor());
} else {
disconnect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
this, SLOT(setCurrentFile(QString)));
disconnect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
this, &FolderNavigationWidget::setCurrentFile);
}
}
void FolderNavigationWidget::setCurrentFile(const QString &filePath)
void FolderNavigationWidget::setCurrentFile(Core::IEditor *editor)
{
const QString filePath = editor->document()->filePath().toString();
// Try to find directory of current file
bool pathOpened = false;
if (!filePath.isEmpty()) {
......
......@@ -36,6 +36,7 @@
#include <QWidget>
namespace Utils { class ListView; }
namespace Core { class IEditor; }
QT_BEGIN_NAMESPACE
class QLabel;
......@@ -63,7 +64,7 @@ public slots:
void toggleAutoSynchronization();
private slots:
void setCurrentFile(const QString &filePath);
void setCurrentFile(Core::IEditor *editor);
void slotOpenItem(const QModelIndex &viewIndex);
void setHiddenFilesFilter(bool filter);
void ensureCurrentIndex();
......
......@@ -36,7 +36,6 @@
#include "projectexplorerconstants.h"
#include <utils/algorithm.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
......@@ -68,7 +67,7 @@ ProjectTree::ProjectTree(QObject *parent)
{
s_instance = this;
connect(Core::DocumentManager::instance(), &Core::DocumentManager::currentFileChanged,
connect(Core::EditorManager::instance(), &Core::EditorManager::currentEditorChanged,
this, &ProjectTree::documentManagerCurrentFileChanged);
connect(qApp, &QApplication::focusChanged,
......@@ -167,7 +166,8 @@ Project *ProjectTree::projectForNode(Node *node)
void ProjectTree::updateFromDocumentManager(bool invalidCurrentNode)
{
const QString &fileName = Core::DocumentManager::currentFile();
Core::IDocument *document = Core::EditorManager::currentDocument();
const QString &fileName = document ? document->filePath().toString() : QString();
Node *currentNode = 0;
if (!invalidCurrentNode && m_currentNode && m_currentNode->path() == fileName)
......
......@@ -335,7 +335,9 @@ void ProjectTreeWidget::setAutoSynchronization(bool sync)
if (m_autoSync) {
// sync from document manager
const QString &fileName = Core::DocumentManager::currentFile();
QString fileName;
if (IDocument *doc = EditorManager::currentDocument())
fileName = doc->filePath().toString();
if (!currentNode() || currentNode()->path() != fileName)
setCurrentItem(ProjectTreeWidget::nodeForFile(fileName));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment