forked from qt-creator/qt-creator
Rename IFile->IDocument and FileManager->DocumentManager
And adapt the other API respectively. Change-Id: I1e04e555409be09242db6890f9e013396f83aeed Reviewed-by: Bill King <bill.king@nokia.com> Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
@@ -540,7 +540,7 @@
|
||||
name to the user, convert it back to native format with
|
||||
QDir::toNativeSeparators.
|
||||
|
||||
When comparing file names, consider using FileManager::fixFileName which
|
||||
When comparing file names, consider using DocumentManager::fixFileName which
|
||||
makes sure that paths are clean and absolute and also takes Windows
|
||||
case-insensitivity into account (even if it is an expensive operation).
|
||||
|
||||
|
@@ -186,7 +186,7 @@
|
||||
\row
|
||||
\o Add a new editor type.
|
||||
\o Such as an editor for XML files.
|
||||
\o \l{Core::IEditorFactory}, \l{Core::IEditor}, \l{Core::IFile}
|
||||
\o \l{Core::IEditorFactory}, \l{Core::IEditor}, \l{Core::IDocument}
|
||||
|
||||
\row
|
||||
\o Add a new wizard.
|
||||
|
@@ -98,7 +98,7 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor()
|
||||
editorWidget->convertPosition(pos, &line, &column);
|
||||
|
||||
const CPlusPlus::Snapshot &snapshot = CPlusPlus::CppModelManagerInterface::instance()->snapshot();
|
||||
CPlusPlus::Document::Ptr doc = snapshot.document(editor->file()->fileName());
|
||||
CPlusPlus::Document::Ptr doc = snapshot.document(editor->document()->fileName());
|
||||
QTC_ASSERT(doc, return 0)
|
||||
|
||||
// fetch the expression's code
|
||||
|
@@ -37,7 +37,7 @@
|
||||
#include "autotoolsprojectconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
@@ -62,7 +62,7 @@ Project *AutotoolsManager::openProject(const QString &fileName, QString *errorSt
|
||||
// Check whether the project is already open or not.
|
||||
ProjectExplorerPlugin *projectExplorer = ProjectExplorerPlugin::instance();
|
||||
foreach (Project *pi, projectExplorer->session()->projects()) {
|
||||
if (canonicalFilePath == pi->file()->fileName()) {
|
||||
if (canonicalFilePath == pi->document()->fileName()) {
|
||||
*errorString = tr("Failed opening project '%1': Project already open")
|
||||
.arg(QDir::toNativeSeparators(canonicalFilePath));
|
||||
return 0;
|
||||
|
@@ -133,7 +133,7 @@ QString AutotoolsProject::id() const
|
||||
return QLatin1String(Constants::AUTOTOOLS_PROJECT_ID);
|
||||
}
|
||||
|
||||
Core::IFile *AutotoolsProject::file() const
|
||||
Core::IDocument *AutotoolsProject::document() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ public:
|
||||
|
||||
QString displayName() const;
|
||||
QString id() const;
|
||||
Core::IFile *file() const;
|
||||
Core::IDocument *document() const;
|
||||
ProjectExplorer::IProjectManager *projectManager() const;
|
||||
AutotoolsTarget *activeTarget() const;
|
||||
QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
|
||||
|
@@ -40,7 +40,7 @@ using namespace AutotoolsProjectManager;
|
||||
using namespace AutotoolsProjectManager::Internal;
|
||||
|
||||
AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QString &fileName) :
|
||||
Core::IFile(project),
|
||||
Core::IDocument(project),
|
||||
m_project(project),
|
||||
m_fileName(fileName)
|
||||
{
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#ifndef AUTOTOOLSPROJECTFILE_H
|
||||
#define AUTOTOOLSPROJECTFILE_H
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
namespace AutotoolsProjectManager {
|
||||
namespace Internal {
|
||||
@@ -43,7 +43,7 @@ namespace Internal {
|
||||
class AutotoolsProject;
|
||||
|
||||
/**
|
||||
* @brief Implementation of the Core::IFile interface.
|
||||
* @brief Implementation of the Core::IDocument interface.
|
||||
*
|
||||
* Is used in AutotoolsProject and describes the root
|
||||
* of a project. In the context of autotools the implementation
|
||||
@@ -52,7 +52,7 @@ class AutotoolsProject;
|
||||
*
|
||||
* @see AutotoolsProject
|
||||
*/
|
||||
class AutotoolsProjectFile : public Core::IFile
|
||||
class AutotoolsProjectFile : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -39,7 +39,7 @@ using namespace AutotoolsProjectManager;
|
||||
using namespace AutotoolsProjectManager::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IFile *projectFile) :
|
||||
AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile) :
|
||||
ProjectNode(projectFile->fileName()),
|
||||
m_project(project),
|
||||
m_projectFile(projectFile)
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#define AUTOTOOLSPROJECTNODE_H
|
||||
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
namespace AutotoolsProjectManager {
|
||||
namespace Internal {
|
||||
@@ -57,7 +57,7 @@ class AutotoolsProjectNode : public ProjectExplorer::ProjectNode
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AutotoolsProjectNode(AutotoolsProject *project, Core::IFile *projectFile);
|
||||
AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile);
|
||||
|
||||
bool hasBuildTargets() const;
|
||||
QList<ProjectExplorer::ProjectNode::ProjectAction> supportedActions(Node *node) const;
|
||||
@@ -79,7 +79,7 @@ public:
|
||||
|
||||
private:
|
||||
AutotoolsProject *m_project;
|
||||
Core::IFile *m_projectFile;
|
||||
Core::IDocument *m_projectFile;
|
||||
|
||||
// TODO: AutotoolsProject calls the protected method addFileNodes() from AutotoolsProjectNode.
|
||||
// Instead of this friend declaration, a public interface might be preferable.
|
||||
|
@@ -50,7 +50,7 @@
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <locator/commandlocator.h>
|
||||
@@ -617,9 +617,9 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit
|
||||
{
|
||||
if (!m_changeLog)
|
||||
return true;
|
||||
Core::IFile *editorFile = submitEditor->file();
|
||||
Core::IDocument *editorDocument = submitEditor->document();
|
||||
const CommitEditor *commitEditor = qobject_cast<const CommitEditor *>(submitEditor);
|
||||
if (!editorFile || !commitEditor)
|
||||
if (!editorDocument || !commitEditor)
|
||||
return true;
|
||||
|
||||
bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey);
|
||||
@@ -641,7 +641,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit
|
||||
QStringList files = commitEditor->checkedFiles();
|
||||
if (!files.empty()) {
|
||||
//save the commit message
|
||||
if (!Core::FileManager::saveFile(editorFile))
|
||||
if (!Core::DocumentManager::saveDocument(editorDocument))
|
||||
return false;
|
||||
|
||||
//rewrite entries of the form 'file => newfile' to 'newfile' because
|
||||
@@ -665,7 +665,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit
|
||||
// Whether local commit or not
|
||||
if (commitWidget->isLocalOptionEnabled())
|
||||
extraOptions += QLatin1String("--local");
|
||||
m_client->commit(m_submitRepository, files, editorFile->fileName(), extraOptions);
|
||||
m_client->commit(m_submitRepository, files, editorDocument->fileName(), extraOptions);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -58,7 +58,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <find/ifindsupport.h>
|
||||
@@ -185,12 +185,12 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class BinEditorFile : public Core::IFile
|
||||
class BinEditorDocument : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BinEditorFile(BinEditor *parent) :
|
||||
Core::IFile(parent)
|
||||
BinEditorDocument(BinEditor *parent) :
|
||||
Core::IDocument(parent)
|
||||
{
|
||||
m_editor = parent;
|
||||
connect(m_editor, SIGNAL(dataRequested(Core::IEditor*,quint64)),
|
||||
@@ -202,7 +202,7 @@ public:
|
||||
connect(m_editor, SIGNAL(endOfFileRequested(Core::IEditor*)), this,
|
||||
SLOT(handleEndOfFileRequested(Core::IEditor*)));
|
||||
}
|
||||
~BinEditorFile() {}
|
||||
~BinEditorDocument() {}
|
||||
|
||||
QString mimeType() const {
|
||||
return QLatin1String(Constants::C_BINEDITOR_MIMETYPE);
|
||||
@@ -296,7 +296,7 @@ public:
|
||||
|
||||
bool isModified() const { return m_editor->isMemoryView() ? false : m_editor->isModified(); }
|
||||
|
||||
bool isReadOnly() const {
|
||||
bool isFileReadOnly() const {
|
||||
if (m_editor->isMemoryView() || m_fileName.isEmpty())
|
||||
return false;
|
||||
const QFileInfo fi(m_fileName);
|
||||
@@ -332,7 +332,7 @@ public:
|
||||
{
|
||||
setWidget(editor);
|
||||
m_editor = editor;
|
||||
m_file = new BinEditorFile(m_editor);
|
||||
m_file = new BinEditorDocument(m_editor);
|
||||
m_context.add(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID);
|
||||
m_context.add(Constants::C_BINEDITOR);
|
||||
m_addressEdit = new QLineEdit;
|
||||
@@ -373,7 +373,7 @@ public:
|
||||
QTC_ASSERT(fileName == realFileName, return false); // The bineditor can do no autosaving
|
||||
return m_file->open(errorString, fileName);
|
||||
}
|
||||
Core::IFile *file() { return m_file; }
|
||||
Core::IDocument *document() { return m_file; }
|
||||
Core::Id id() const { return Core::Constants::K_DEFAULT_BINARY_EDITOR_ID; }
|
||||
QString displayName() const { return m_displayName; }
|
||||
void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
|
||||
@@ -401,7 +401,7 @@ private slots:
|
||||
private:
|
||||
BinEditor *m_editor;
|
||||
QString m_displayName;
|
||||
BinEditorFile *m_file;
|
||||
BinEditorDocument *m_file;
|
||||
QToolBar *m_toolBar;
|
||||
QLineEdit *m_addressEdit;
|
||||
};
|
||||
@@ -426,11 +426,11 @@ QString BinEditorFactory::displayName() const
|
||||
return tr(Constants::C_BINEDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IFile *BinEditorFactory::open(const QString &fileName)
|
||||
Core::IDocument *BinEditorFactory::open(const QString &fileName)
|
||||
{
|
||||
Core::EditorManager *em = Core::EditorManager::instance();
|
||||
Core::IEditor *iface = em->openEditor(fileName, id());
|
||||
return iface ? iface->file() : 0;
|
||||
return iface ? iface->document() : 0;
|
||||
}
|
||||
|
||||
Core::IEditor *BinEditorFactory::createEditor(QWidget *parent)
|
||||
|
@@ -108,7 +108,7 @@ public:
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
Core::IFile *open(const QString &fileName);
|
||||
Core::IDocument *open(const QString &fileName);
|
||||
|
||||
private:
|
||||
const QStringList m_mimeTypes;
|
||||
|
@@ -393,7 +393,7 @@ void BookmarkManager::toggleBookmark()
|
||||
if (!editor)
|
||||
return;
|
||||
|
||||
toggleBookmark(editor->file()->fileName(), editor->currentLine());
|
||||
toggleBookmark(editor->document()->fileName(), editor->currentLine());
|
||||
}
|
||||
|
||||
void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
|
||||
@@ -508,7 +508,7 @@ void BookmarkManager::documentPrevNext(bool next)
|
||||
{
|
||||
TextEditor::ITextEditor *editor = currentTextEditor();
|
||||
int editorLine = editor->currentLine();
|
||||
QFileInfo fi(editor->file()->fileName());
|
||||
QFileInfo fi(editor->document()->fileName());
|
||||
if (!m_bookmarksMap.contains(fi.path()))
|
||||
return;
|
||||
|
||||
@@ -615,7 +615,7 @@ BookmarkManager::State BookmarkManager::state() const
|
||||
if (!editor)
|
||||
return HasBookMarks;
|
||||
|
||||
const QFileInfo fi(editor->file()->fileName());
|
||||
const QFileInfo fi(editor->document()->fileName());
|
||||
|
||||
const DirectoryFileBookmarksMap::const_iterator dit = m_bookmarksMap.constFind(fi.path());
|
||||
if (dit == m_bookmarksMap.constEnd())
|
||||
@@ -757,8 +757,8 @@ void BookmarkManager::handleBookmarkRequest(TextEditor::ITextEditor *textEditor,
|
||||
int line,
|
||||
TextEditor::ITextEditor::MarkRequestKind kind)
|
||||
{
|
||||
if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->file())
|
||||
toggleBookmark(textEditor->file()->fileName(), line);
|
||||
if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->document())
|
||||
toggleBookmark(textEditor->document()->fileName(), line);
|
||||
}
|
||||
|
||||
// BookmarkViewFactory
|
||||
|
@@ -200,7 +200,7 @@ void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
|
||||
int lineNumber, QMenu *menu)
|
||||
{
|
||||
m_bookmarkMarginActionLineNumber = lineNumber;
|
||||
m_bookmarkMarginActionFileName = editor->file()->fileName();
|
||||
m_bookmarkMarginActionFileName = editor->document()->fileName();
|
||||
menu->addAction(m_bookmarkMarginAction);
|
||||
}
|
||||
|
||||
|
@@ -312,9 +312,9 @@ void Manager::gotoLocations(const QList<QVariant> &list)
|
||||
Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
|
||||
if (editor) {
|
||||
// get current file name
|
||||
Core::IFile *file = editor->file();
|
||||
if (file)
|
||||
fileName = file->fileName();
|
||||
Core::IDocument *document = editor->document();
|
||||
if (document)
|
||||
fileName = document->fileName();
|
||||
|
||||
// if text file - what is current position?
|
||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
|
||||
|
@@ -48,7 +48,7 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QStandardItem>
|
||||
@@ -236,8 +236,8 @@ ParserTreeItem::ConstPtr Parser::parse()
|
||||
|
||||
QString prjName(prj->displayName());
|
||||
QString prjType(prjName);
|
||||
if (prj->file())
|
||||
prjType = prj->file()->fileName();
|
||||
if (prj->document())
|
||||
prjType = prj->document()->fileName();
|
||||
SymbolInformation inf(prjName, prjType);
|
||||
|
||||
QStringList projectList = addProjectNode(item, prj->rootProjectNode());
|
||||
|
@@ -79,7 +79,7 @@ Core::Id CMakeEditor::id() const
|
||||
|
||||
void CMakeEditor::markAsChanged()
|
||||
{
|
||||
if (!file()->isModified())
|
||||
if (!document()->isModified())
|
||||
return;
|
||||
if (m_infoBarShown)
|
||||
return;
|
||||
@@ -87,7 +87,7 @@ void CMakeEditor::markAsChanged()
|
||||
Core::InfoBarEntry info(QLatin1String("CMakeEditor.RunCMake"),
|
||||
tr("Changes to cmake files are shown in the project tree after building."));
|
||||
info.setCustomButtonInfo(tr("Build now"), this, SLOT(build()));
|
||||
file()->infoBar()->addInfo(info);
|
||||
document()->infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void CMakeEditor::build()
|
||||
@@ -97,7 +97,7 @@ void CMakeEditor::build()
|
||||
foreach (ProjectExplorer::Project *p, projects) {
|
||||
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
|
||||
if (cmakeProject) {
|
||||
if (cmakeProject->isProjectFile(file()->fileName())) {
|
||||
if (cmakeProject->isProjectFile(document()->fileName())) {
|
||||
ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject);
|
||||
break;
|
||||
}
|
||||
|
@@ -58,10 +58,10 @@ QString CMakeEditorFactory::displayName() const
|
||||
return tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IFile *CMakeEditorFactory::open(const QString &fileName)
|
||||
Core::IDocument *CMakeEditorFactory::open(const QString &fileName)
|
||||
{
|
||||
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
|
||||
return iface ? iface->file() : 0;
|
||||
return iface ? iface->document() : 0;
|
||||
}
|
||||
|
||||
Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent)
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
QStringList mimeTypes() const;
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
Core::IFile *open(const QString &fileName);
|
||||
Core::IDocument *open(const QString &fileName);
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
|
||||
private:
|
||||
|
@@ -75,8 +75,8 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
|
||||
if (cmakeProject) {
|
||||
foreach (CMakeBuildTarget ct, cmakeProject->buildTargets()) {
|
||||
if (ct.title.contains(entry)) {
|
||||
Locator::FilterEntry entry(this, ct.title, cmakeProject->file()->fileName());
|
||||
entry.extraInfo = cmakeProject->file()->fileName();
|
||||
Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->fileName());
|
||||
entry.extraInfo = cmakeProject->document()->fileName();
|
||||
result.append(entry);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
|
||||
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
|
||||
foreach (ProjectExplorer::Project *p, projects) {
|
||||
cmakeProject = qobject_cast<CMakeProject *>(p);
|
||||
if (cmakeProject && cmakeProject->file()->fileName() == selection.internalData.toString())
|
||||
if (cmakeProject && cmakeProject->document()->fileName() == selection.internalData.toString())
|
||||
break;
|
||||
cmakeProject = 0;
|
||||
}
|
||||
|
@@ -197,8 +197,8 @@ bool CMakeProject::parseCMakeLists()
|
||||
return false;
|
||||
|
||||
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors())
|
||||
if (isProjectFile(editor->file()->fileName()))
|
||||
editor->file()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake"));
|
||||
if (isProjectFile(editor->document()->fileName()))
|
||||
editor->document()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake"));
|
||||
|
||||
// Find cbp file
|
||||
CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration();
|
||||
@@ -481,7 +481,7 @@ QString CMakeProject::id() const
|
||||
return QLatin1String(Constants::CMAKEPROJECT_ID);
|
||||
}
|
||||
|
||||
Core::IFile *CMakeProject::file() const
|
||||
Core::IDocument *CMakeProject::document() const
|
||||
{
|
||||
return m_file;
|
||||
}
|
||||
@@ -692,7 +692,7 @@ void CMakeProject::editorChanged(Core::IEditor *editor)
|
||||
disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
|
||||
if (m_dirtyUic) {
|
||||
const QString contents = formWindowEditorContents(m_lastEditor);
|
||||
updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents);
|
||||
updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents);
|
||||
m_dirtyUic = false;
|
||||
}
|
||||
}
|
||||
@@ -713,7 +713,7 @@ void CMakeProject::editorAboutToClose(Core::IEditor *editor)
|
||||
disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
|
||||
if (m_dirtyUic) {
|
||||
const QString contents = formWindowEditorContents(m_lastEditor);
|
||||
updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents);
|
||||
updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents);
|
||||
m_dirtyUic = false;
|
||||
}
|
||||
}
|
||||
@@ -744,7 +744,7 @@ void CMakeProject::buildStateChanged(ProjectExplorer::Project *project)
|
||||
// CMakeFile
|
||||
|
||||
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
|
||||
: Core::IFile(parent), m_project(parent), m_fileName(fileName)
|
||||
: Core::IDocument(parent), m_project(parent), m_fileName(fileName)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -797,7 +797,7 @@ void CMakeFile::rename(const QString &newName)
|
||||
// Can't happen....
|
||||
}
|
||||
|
||||
Core::IFile::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
Q_UNUSED(type)
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include <projectexplorer/projectnodes.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
|
||||
QString displayName() const;
|
||||
QString id() const;
|
||||
Core::IFile *file() const;
|
||||
Core::IDocument *document() const;
|
||||
CMakeManager *projectManager() const;
|
||||
|
||||
CMakeTarget *activeTarget() const;
|
||||
@@ -193,7 +193,7 @@ private:
|
||||
QString m_compiler;
|
||||
};
|
||||
|
||||
class CMakeFile : public Core::IFile
|
||||
class CMakeFile : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@@ -38,7 +38,7 @@
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
#include "coreconstants.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "id.h"
|
||||
|
||||
|
@@ -23,7 +23,6 @@ SOURCES += mainwindow.cpp \
|
||||
fancyactionbar.cpp \
|
||||
fancytabwidget.cpp \
|
||||
generalsettings.cpp \
|
||||
filemanager.cpp \
|
||||
id.cpp \
|
||||
messagemanager.cpp \
|
||||
messageoutputwindow.cpp \
|
||||
@@ -71,7 +70,6 @@ SOURCES += mainwindow.cpp \
|
||||
fileiconprovider.cpp \
|
||||
mimedatabase.cpp \
|
||||
icore.cpp \
|
||||
ifile.cpp \
|
||||
infobar.cpp \
|
||||
editormanager/ieditor.cpp \
|
||||
dialogs/ioptionspage.cpp \
|
||||
@@ -94,8 +92,10 @@ SOURCES += mainwindow.cpp \
|
||||
mimetypesettings.cpp \
|
||||
dialogs/promptoverwritedialog.cpp \
|
||||
fileutils.cpp \
|
||||
textfile.cpp \
|
||||
featureprovider.cpp
|
||||
featureprovider.cpp \
|
||||
idocument.cpp \
|
||||
textdocument.cpp \
|
||||
documentmanager.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
editmode.h \
|
||||
@@ -103,7 +103,6 @@ HEADERS += mainwindow.h \
|
||||
fancyactionbar.h \
|
||||
fancytabwidget.h \
|
||||
generalsettings.h \
|
||||
filemanager.h \
|
||||
id.h \
|
||||
messagemanager.h \
|
||||
messageoutputwindow.h \
|
||||
@@ -141,9 +140,7 @@ HEADERS += mainwindow.h \
|
||||
progressmanager/progressmanager.h \
|
||||
icontext.h \
|
||||
icore.h \
|
||||
ifile.h \
|
||||
infobar.h \
|
||||
ifilefactory.h \
|
||||
imode.h \
|
||||
ioutputpane.h \
|
||||
coreconstants.h \
|
||||
@@ -190,9 +187,12 @@ HEADERS += mainwindow.h \
|
||||
dialogs/promptoverwritedialog.h \
|
||||
fileutils.h \
|
||||
externaltoolmanager.h \
|
||||
textfile.h \
|
||||
generatedfile.h \
|
||||
featureprovider.h
|
||||
featureprovider.h \
|
||||
idocument.h \
|
||||
idocumentfactory.h \
|
||||
textdocument.h \
|
||||
documentmanager.h
|
||||
|
||||
FORMS += dialogs/newdialog.ui \
|
||||
actionmanager/commandmappings.ui \
|
||||
|
@@ -213,8 +213,8 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
|
||||
|
||||
bool mimeEditorAvailable = false;
|
||||
|
||||
if (editor && editor->file()) {
|
||||
const QString mimeType = editor->file()->mimeType();
|
||||
if (editor && editor->document()) {
|
||||
const QString mimeType = editor->document()->mimeType();
|
||||
if (!mimeType.isEmpty()) {
|
||||
foreach (DesignEditorInfo *editorInfo, d->m_editors) {
|
||||
foreach (const QString &mime, editorInfo->mimeTypes) {
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "vcsmanager.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -43,13 +43,13 @@
|
||||
#include <QHeaderView>
|
||||
#include <QCheckBox>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::IFile*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
QList<IFile *> items)
|
||||
QList<IDocument *> items)
|
||||
: QDialog(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
@@ -61,12 +61,12 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
|
||||
m_ui.saveBeforeBuildCheckBox->setVisible(false);
|
||||
|
||||
foreach (IFile *file, items) {
|
||||
foreach (IDocument *document, items) {
|
||||
QString visibleName;
|
||||
QString directory;
|
||||
QString fileName = file->fileName();
|
||||
QString fileName = document->fileName();
|
||||
if (fileName.isEmpty()) {
|
||||
visibleName = file->suggestedFileName();
|
||||
visibleName = document->suggestedFileName();
|
||||
} else {
|
||||
QFileInfo info = QFileInfo(fileName);
|
||||
directory = info.absolutePath();
|
||||
@@ -74,7 +74,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
}
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList()
|
||||
<< visibleName << QDir::toNativeSeparators(directory));
|
||||
item->setData(0, Qt::UserRole, qVariantFromValue(file));
|
||||
item->setData(0, Qt::UserRole, qVariantFromValue(document));
|
||||
}
|
||||
|
||||
m_ui.treeWidget->resizeColumnToContents(0);
|
||||
@@ -112,7 +112,7 @@ void SaveItemsDialog::collectItemsToSave()
|
||||
{
|
||||
m_itemsToSave.clear();
|
||||
foreach (QTreeWidgetItem *item, m_ui.treeWidget->selectedItems()) {
|
||||
m_itemsToSave.append(item->data(0, Qt::UserRole).value<IFile*>());
|
||||
m_itemsToSave.append(item->data(0, Qt::UserRole).value<IDocument*>());
|
||||
}
|
||||
accept();
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void SaveItemsDialog::discardAll()
|
||||
collectItemsToSave();
|
||||
}
|
||||
|
||||
QList<IFile*> SaveItemsDialog::itemsToSave() const
|
||||
QList<IDocument*> SaveItemsDialog::itemsToSave() const
|
||||
{
|
||||
return m_itemsToSave;
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class EditorManager;
|
||||
|
||||
namespace Internal {
|
||||
@@ -57,12 +57,12 @@ class SaveItemsDialog : public QDialog
|
||||
|
||||
public:
|
||||
SaveItemsDialog(QWidget *parent,
|
||||
QList<Core::IFile *> items);
|
||||
QList<Core::IDocument *> items);
|
||||
|
||||
void setMessage(const QString &msg);
|
||||
void setAlwaysSaveMessage(const QString &msg);
|
||||
bool alwaysSaveChecked();
|
||||
QList<Core::IFile *> itemsToSave() const;
|
||||
QList<Core::IDocument *> itemsToSave() const;
|
||||
|
||||
private slots:
|
||||
void collectItemsToSave();
|
||||
@@ -71,7 +71,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SaveItemsDialog m_ui;
|
||||
QList<Core::IFile*> m_itemsToSave;
|
||||
QList<Core::IDocument*> m_itemsToSave;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
#include "coreconstants.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "id.h"
|
||||
|
||||
@@ -266,7 +266,7 @@ void ShortcutSettings::defaultAction()
|
||||
|
||||
void ShortcutSettings::exportAction()
|
||||
{
|
||||
QString fileName = FileManager::getSaveFileNameWithExtension(
|
||||
QString fileName = DocumentManager::getSaveFileNameWithExtension(
|
||||
tr("Export Keyboard Mapping Scheme"),
|
||||
ICore::resourcePath() + QLatin1String("/schemes/"),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef FILEMANAGER_H
|
||||
#define FILEMANAGER_H
|
||||
#ifndef DOCUMENTMANAGER_H
|
||||
#define DOCUMENTMANAGER_H
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
@@ -49,10 +49,10 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
|
||||
class IContext;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IVersionControl;
|
||||
|
||||
class CORE_EXPORT FileManager : public QObject
|
||||
class CORE_EXPORT DocumentManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -63,16 +63,16 @@ public:
|
||||
|
||||
typedef QPair<QString, Id> RecentFile;
|
||||
|
||||
explicit FileManager(QMainWindow *ew);
|
||||
virtual ~FileManager();
|
||||
explicit DocumentManager(QMainWindow *ew);
|
||||
virtual ~DocumentManager();
|
||||
|
||||
static FileManager *instance();
|
||||
static DocumentManager *instance();
|
||||
|
||||
// file pool to monitor
|
||||
static void addFiles(const QList<IFile *> &files, bool addWatcher = true);
|
||||
static void addFile(IFile *file, bool addWatcher = true);
|
||||
static bool removeFile(IFile *file);
|
||||
static QList<IFile *> modifiedFiles();
|
||||
static void addDocuments(const QList<IDocument *> &documents, bool addWatcher = true);
|
||||
static void addDocument(IDocument *document, bool addWatcher = true);
|
||||
static bool removeDocument(IDocument *document);
|
||||
static QList<IDocument *> modifiedDocuments();
|
||||
|
||||
static void renamedFile(const QString &from, const QString &to);
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
// helper methods
|
||||
static QString fixFileName(const QString &fileName, FixMode fixmode);
|
||||
|
||||
static bool saveFile(IFile *file, const QString &fileName = QString(), bool *isReadOnly = 0);
|
||||
static bool saveDocument(IDocument *document, const QString &fileName = QString(), bool *isReadOnly = 0);
|
||||
|
||||
static QStringList getOpenFileNames(const QString &filters,
|
||||
const QString path = QString(),
|
||||
@@ -102,11 +102,11 @@ public:
|
||||
const QString &filter = QString(), QString *selectedFilter = 0);
|
||||
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||
const QString &filter);
|
||||
static QString getSaveAsFileName(IFile *file, const QString &filter = QString(),
|
||||
static QString getSaveAsFileName(IDocument *document, const QString &filter = QString(),
|
||||
QString *selectedFilter = 0);
|
||||
|
||||
static QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files, bool *cancelled = 0);
|
||||
static QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
|
||||
static QList<IDocument *> saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *cancelled = 0);
|
||||
static QList<IDocument *> saveModifiedDocuments(const QList<IDocument *> &documents,
|
||||
bool *cancelled = 0,
|
||||
const QString &message = QString(),
|
||||
const QString &alwaysSaveMessage = QString(),
|
||||
@@ -150,7 +150,7 @@ signals:
|
||||
void filesChangedInternally(const QStringList &files);
|
||||
|
||||
private slots:
|
||||
void fileDestroyed(QObject *obj);
|
||||
void documentDestroyed(QObject *obj);
|
||||
void checkForNewFileName();
|
||||
void checkForReload();
|
||||
void changedFile(const QString &file);
|
||||
@@ -158,10 +158,10 @@ private slots:
|
||||
void syncWithEditor(Core::IContext *context);
|
||||
};
|
||||
|
||||
/*! The FileChangeBlocker blocks all change notifications to all IFile * that
|
||||
/*! The FileChangeBlocker blocks all change notifications to all IDocument * that
|
||||
match the given filename. And unblocks in the destructor.
|
||||
|
||||
To also reload the IFile in the destructor class set modifiedReload to true
|
||||
To also reload the IDocument in the destructor class set modifiedReload to true
|
||||
|
||||
*/
|
||||
class CORE_EXPORT FileChangeBlocker
|
||||
@@ -176,6 +176,6 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_METATYPE(Core::FileManager::RecentFile)
|
||||
Q_DECLARE_METATYPE(Core::DocumentManager::RecentFile)
|
||||
|
||||
#endif // FILEMANAGER_H
|
||||
#endif // DOCUMENTMANAGER_H
|
@@ -40,7 +40,7 @@
|
||||
#include "navigationwidget.h"
|
||||
#include "rightpane.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <QLatin1String>
|
||||
#include <QHBoxLayout>
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "openeditorsview.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "openwithdialog.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "ieditor.h"
|
||||
#include "iversioncontrol.h"
|
||||
@@ -228,7 +228,7 @@ struct EditorManagerPrivate
|
||||
|
||||
OpenEditorsModel *m_editorModel;
|
||||
|
||||
IFile::ReloadSetting m_reloadSetting;
|
||||
IDocument::ReloadSetting m_reloadSetting;
|
||||
|
||||
QString m_titleAddition;
|
||||
|
||||
@@ -258,7 +258,7 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
|
||||
m_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), parent)),
|
||||
m_windowPopup(0),
|
||||
m_coreListener(0),
|
||||
m_reloadSetting(IFile::AlwaysAsk),
|
||||
m_reloadSetting(IDocument::AlwaysAsk),
|
||||
m_autoSaveEnabled(true),
|
||||
m_autoSaveInterval(5)
|
||||
{
|
||||
@@ -310,11 +310,11 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
|
||||
// Save Action
|
||||
am->registerAction(d->m_saveAction, Constants::SAVE, editManagerContext);
|
||||
connect(d->m_saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
|
||||
connect(d->m_saveAction, SIGNAL(triggered()), this, SLOT(saveDocument()));
|
||||
|
||||
// Save As Action
|
||||
am->registerAction(d->m_saveAsAction, Constants::SAVEAS, editManagerContext);
|
||||
connect(d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveFileAs()));
|
||||
connect(d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveDocumentAs()));
|
||||
|
||||
// Window Menu
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
@@ -536,7 +536,7 @@ void EditorManager::removeEditor(IEditor *editor)
|
||||
bool isDuplicate = d->m_editorModel->isDuplicate(editor);
|
||||
d->m_editorModel->removeEditor(editor);
|
||||
if (!isDuplicate)
|
||||
FileManager::removeFile(editor->file());
|
||||
DocumentManager::removeDocument(editor->document());
|
||||
ICore::removeContextObject(editor);
|
||||
}
|
||||
|
||||
@@ -616,19 +616,19 @@ Core::Internal::EditorView *EditorManager::currentEditorView() const
|
||||
QList<IEditor *> EditorManager::editorsForFileName(const QString &filename) const
|
||||
{
|
||||
QList<IEditor *> found;
|
||||
QString fixedname = FileManager::fixFileName(filename, FileManager::KeepLinks);
|
||||
QString fixedname = DocumentManager::fixFileName(filename, DocumentManager::KeepLinks);
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
if (fixedname == FileManager::fixFileName(editor->file()->fileName(), FileManager::KeepLinks))
|
||||
if (fixedname == DocumentManager::fixFileName(editor->document()->fileName(), DocumentManager::KeepLinks))
|
||||
found << editor;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
QList<IEditor *> EditorManager::editorsForFile(IFile *file) const
|
||||
QList<IEditor *> EditorManager::editorsForDocument(IDocument *document) const
|
||||
{
|
||||
QList<IEditor *> found;
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
if (editor->file() == file)
|
||||
if (editor->document() == document)
|
||||
found << editor;
|
||||
}
|
||||
return found;
|
||||
@@ -713,13 +713,13 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
||||
}
|
||||
|
||||
QList<IEditor*>
|
||||
EditorManager::editorsForFiles(QList<IFile*> files) const
|
||||
EditorManager::editorsForDocuments(QList<IDocument*> documents) const
|
||||
{
|
||||
const QList<IEditor *> editors = openedEditors();
|
||||
QSet<IEditor *> found;
|
||||
foreach (IFile *file, files) {
|
||||
foreach (IDocument *document, documents) {
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (editor->file() == file && !found.contains(editor)) {
|
||||
if (editor->document() == document && !found.contains(editor)) {
|
||||
found << editor;
|
||||
}
|
||||
}
|
||||
@@ -727,17 +727,17 @@ QList<IEditor*>
|
||||
return found.toList();
|
||||
}
|
||||
|
||||
QList<IFile *> EditorManager::filesForEditors(QList<IEditor *> editors) const
|
||||
QList<IDocument *> EditorManager::documentsForEditors(QList<IEditor *> editors) const
|
||||
{
|
||||
QSet<IEditor *> handledEditors;
|
||||
QList<IFile *> files;
|
||||
QList<IDocument *> documents;
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!handledEditors.contains(editor)) {
|
||||
files << editor->file();
|
||||
documents << editor->document();
|
||||
handledEditors.insert(editor);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
return documents;
|
||||
}
|
||||
|
||||
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||
@@ -870,12 +870,12 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
//ask whether to save modified files
|
||||
if (askAboutModifiedEditors) {
|
||||
bool cancelled = false;
|
||||
QList<IFile*> list = FileManager::saveModifiedFiles(filesForEditors(acceptedEditors), &cancelled);
|
||||
QList<IDocument*> list = DocumentManager::saveModifiedDocuments(documentsForEditors(acceptedEditors), &cancelled);
|
||||
if (cancelled)
|
||||
return false;
|
||||
if (!list.isEmpty()) {
|
||||
closingFailed = true;
|
||||
QSet<IEditor*> skipSet = editorsForFiles(list).toSet();
|
||||
QSet<IEditor*> skipSet = editorsForDocuments(list).toSet();
|
||||
acceptedEditors = acceptedEditors.toSet().subtract(skipSet).toList();
|
||||
}
|
||||
}
|
||||
@@ -891,11 +891,11 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
// remove the editors
|
||||
foreach (IEditor *editor, acceptedEditors) {
|
||||
emit editorAboutToClose(editor);
|
||||
if (!editor->file()->fileName().isEmpty()
|
||||
if (!editor->document()->fileName().isEmpty()
|
||||
&& !editor->isTemporary()) {
|
||||
QByteArray state = editor->saveState();
|
||||
if (!state.isEmpty())
|
||||
d->m_editorStates.insert(editor->file()->fileName(), QVariant(state));
|
||||
d->m_editorStates.insert(editor->document()->fileName(), QVariant(state));
|
||||
}
|
||||
|
||||
removeEditor(editor);
|
||||
@@ -1018,7 +1018,7 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
|
||||
{
|
||||
Q_ASSERT(view && editor);
|
||||
|
||||
if (view->currentEditor() && view->currentEditor()->file() == editor->file())
|
||||
if (view->currentEditor() && view->currentEditor()->document() == editor->document())
|
||||
editor = view->currentEditor();
|
||||
|
||||
if (!view->hasEditor(editor)) {
|
||||
@@ -1078,10 +1078,10 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
|
||||
return editor;
|
||||
}
|
||||
|
||||
Core::IEditor *EditorManager::activateEditorForFile(Core::Internal::EditorView *view, Core::IFile *file, OpenEditorFlags flags)
|
||||
Core::IEditor *EditorManager::activateEditorForDocument(Core::Internal::EditorView *view, Core::IDocument *document, OpenEditorFlags flags)
|
||||
{
|
||||
Q_ASSERT(view);
|
||||
const QList<IEditor*> editors = editorsForFile(file);
|
||||
const QList<IEditor*> editors = editorsForDocument(document);
|
||||
if (editors.isEmpty())
|
||||
return 0;
|
||||
|
||||
@@ -1205,9 +1205,9 @@ void EditorManager::addEditor(IEditor *editor, bool isDuplicate)
|
||||
if (!isDuplicate) {
|
||||
const bool isTemporary = editor->isTemporary();
|
||||
const bool addWatcher = !isTemporary;
|
||||
FileManager::addFile(editor->file(), addWatcher);
|
||||
DocumentManager::addDocument(editor->document(), addWatcher);
|
||||
if (!isTemporary)
|
||||
FileManager::addToRecentFiles(editor->file()->fileName(), editor->id());
|
||||
DocumentManager::addToRecentFiles(editor->document()->fileName(), editor->id());
|
||||
}
|
||||
emit editorOpened(editor);
|
||||
}
|
||||
@@ -1330,7 +1330,7 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
|
||||
return 0;
|
||||
}
|
||||
if (realFn != fn)
|
||||
editor->file()->setRestoredFrom(realFn);
|
||||
editor->document()->setRestoredFrom(realFn);
|
||||
addEditor(editor);
|
||||
|
||||
if (newEditor)
|
||||
@@ -1365,7 +1365,7 @@ QStringList EditorManager::getOpenFileNames() const
|
||||
{
|
||||
QString selectedFilter;
|
||||
const QString &fileFilters = ICore::mimeDatabase()->allFiltersString(&selectedFilter);
|
||||
return FileManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
|
||||
return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1405,7 +1405,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
||||
int i = 1;
|
||||
QSet<QString> docnames;
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
QString name = editor->file()->fileName();
|
||||
QString name = editor->document()->fileName();
|
||||
if (name.isEmpty()) {
|
||||
name = editor->displayName();
|
||||
} else {
|
||||
@@ -1454,51 +1454,51 @@ bool EditorManager::hasEditor(const QString &fileName) const
|
||||
void EditorManager::restoreEditorState(IEditor *editor)
|
||||
{
|
||||
QTC_ASSERT(editor, return);
|
||||
QString fileName = editor->file()->fileName();
|
||||
QString fileName = editor->document()->fileName();
|
||||
editor->restoreState(d->m_editorStates.value(fileName).toByteArray());
|
||||
}
|
||||
|
||||
bool EditorManager::saveEditor(IEditor *editor)
|
||||
{
|
||||
return saveFile(editor->file());
|
||||
return saveDocument(editor->document());
|
||||
}
|
||||
|
||||
bool EditorManager::saveFile(IFile *fileParam)
|
||||
bool EditorManager::saveDocument(IDocument *documentParam)
|
||||
{
|
||||
IFile *file = fileParam;
|
||||
if (!file && currentEditor())
|
||||
file = currentEditor()->file();
|
||||
if (!file)
|
||||
IDocument *document = documentParam;
|
||||
if (!document && currentEditor())
|
||||
document = currentEditor()->document();
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
|
||||
const QString &fileName = file->fileName();
|
||||
const QString &fileName = document->fileName();
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return saveFileAs(file);
|
||||
return saveDocumentAs(document);
|
||||
|
||||
bool success = false;
|
||||
bool isReadOnly;
|
||||
|
||||
// try saving, no matter what isReadOnly tells us
|
||||
success = FileManager::saveFile(file, QString(), &isReadOnly);
|
||||
success = DocumentManager::saveDocument(document, QString(), &isReadOnly);
|
||||
|
||||
if (!success && isReadOnly) {
|
||||
MakeWritableResult answer =
|
||||
makeFileWritable(file);
|
||||
makeFileWritable(document);
|
||||
if (answer == Failed)
|
||||
return false;
|
||||
if (answer == SavedAs)
|
||||
return true;
|
||||
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
|
||||
success = FileManager::saveFile(file);
|
||||
success = DocumentManager::saveDocument(document);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
addFileToRecentFiles(file);
|
||||
addDocumentToRecentFiles(document);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -1509,13 +1509,13 @@ void EditorManager::autoSave()
|
||||
QStringList errors;
|
||||
// FIXME: the saving should be staggered
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
IFile *file = editor->file();
|
||||
if (!file->isModified() || !file->shouldAutoSave())
|
||||
IDocument *document = editor->document();
|
||||
if (!document->isModified() || !document->shouldAutoSave())
|
||||
continue;
|
||||
if (file->fileName().isEmpty()) // FIXME: save them to a dedicated directory
|
||||
if (document->fileName().isEmpty()) // FIXME: save them to a dedicated directory
|
||||
continue;
|
||||
QString errorString;
|
||||
if (!file->autoSave(&errorString, autoSaveName(file->fileName())))
|
||||
if (!document->autoSave(&errorString, autoSaveName(document->fileName())))
|
||||
errors << errorString;
|
||||
}
|
||||
if (!errors.isEmpty())
|
||||
@@ -1523,57 +1523,57 @@ void EditorManager::autoSave()
|
||||
errors.join(QLatin1String("\n")));
|
||||
}
|
||||
|
||||
MakeWritableResult EditorManager::makeFileWritable(IFile *file)
|
||||
MakeWritableResult EditorManager::makeFileWritable(IDocument *document)
|
||||
{
|
||||
if (!file)
|
||||
if (!document)
|
||||
return Failed;
|
||||
QString directory = QFileInfo(file->fileName()).absolutePath();
|
||||
QString directory = QFileInfo(document->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
const QString &fileName = file->fileName();
|
||||
const QString &fileName = document->fileName();
|
||||
|
||||
switch (FileManager::promptReadOnlyFile(fileName, versionControl, ICore::mainWindow(), file->isSaveAsAllowed())) {
|
||||
case FileManager::RO_OpenVCS:
|
||||
switch (DocumentManager::promptReadOnlyFile(fileName, versionControl, ICore::mainWindow(), document->isSaveAsAllowed())) {
|
||||
case DocumentManager::RO_OpenVCS:
|
||||
if (!versionControl->vcsOpen(fileName)) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"), tr("Cannot open the file for editing with SCC."));
|
||||
return Failed;
|
||||
}
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
return OpenedWithVersionControl;
|
||||
case FileManager::RO_MakeWriteable: {
|
||||
case DocumentManager::RO_MakeWriteable: {
|
||||
const bool permsOk = QFile::setPermissions(fileName, QFile::permissions(fileName) | QFile::WriteUser);
|
||||
if (!permsOk) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Set Permissions"), tr("Cannot set permissions to writable."));
|
||||
return Failed;
|
||||
}
|
||||
}
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
return MadeWritable;
|
||||
case FileManager::RO_SaveAs :
|
||||
return saveFileAs(file) ? SavedAs : Failed;
|
||||
case FileManager::RO_Cancel:
|
||||
case DocumentManager::RO_SaveAs :
|
||||
return saveDocumentAs(document) ? SavedAs : Failed;
|
||||
case DocumentManager::RO_Cancel:
|
||||
break;
|
||||
}
|
||||
return Failed;
|
||||
}
|
||||
|
||||
bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
bool EditorManager::saveDocumentAs(IDocument *documentParam)
|
||||
{
|
||||
IFile *file = fileParam;
|
||||
if (!file && currentEditor())
|
||||
file = currentEditor()->file();
|
||||
if (!file)
|
||||
IDocument *document = documentParam;
|
||||
if (!document && currentEditor())
|
||||
document = currentEditor()->document();
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
const QString &filter = ICore::mimeDatabase()->allFiltersString();
|
||||
QString selectedFilter =
|
||||
ICore::mimeDatabase()->findByFile(QFileInfo(file->fileName())).filterString();
|
||||
ICore::mimeDatabase()->findByFile(QFileInfo(document->fileName())).filterString();
|
||||
const QString &absoluteFilePath =
|
||||
FileManager::getSaveAsFileName(file, filter, &selectedFilter);
|
||||
DocumentManager::getSaveAsFileName(document, filter, &selectedFilter);
|
||||
|
||||
if (absoluteFilePath.isEmpty())
|
||||
return false;
|
||||
|
||||
if (absoluteFilePath != file->fileName()) {
|
||||
if (absoluteFilePath != document->fileName()) {
|
||||
// close existing editors for the new file name
|
||||
const QList<IEditor *> existList = editorsForFileName(absoluteFilePath);
|
||||
if (!existList.isEmpty()) {
|
||||
@@ -1581,8 +1581,8 @@ bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
}
|
||||
}
|
||||
|
||||
const bool success = FileManager::saveFile(file, absoluteFilePath);
|
||||
file->checkPermissions();
|
||||
const bool success = DocumentManager::saveDocument(document, absoluteFilePath);
|
||||
document->checkPermissions();
|
||||
|
||||
// @todo: There is an issue to be treated here. The new file might be of a different mime
|
||||
// type than the original and thus require a different editor. An alternative strategy
|
||||
@@ -1591,18 +1591,18 @@ bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
// re-think part of the editors design.
|
||||
|
||||
if (success)
|
||||
addFileToRecentFiles(file);
|
||||
addDocumentToRecentFiles(document);
|
||||
|
||||
updateActions();
|
||||
return success;
|
||||
}
|
||||
|
||||
/* Adds the file name to the recent files if there is at least one non-temporary editor for it */
|
||||
void EditorManager::addFileToRecentFiles(IFile *file)
|
||||
void EditorManager::addDocumentToRecentFiles(IDocument *document)
|
||||
{
|
||||
bool isTemporary = true;
|
||||
Id editorId;
|
||||
QList<IEditor *> editors = editorsForFile(file);
|
||||
QList<IEditor *> editors = editorsForDocument(document);
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!editor->isTemporary()) {
|
||||
editorId = editor->id();
|
||||
@@ -1611,7 +1611,7 @@ void EditorManager::addFileToRecentFiles(IFile *file)
|
||||
}
|
||||
}
|
||||
if (!isTemporary)
|
||||
FileManager::addToRecentFiles(file->fileName(), editorId);
|
||||
DocumentManager::addToRecentFiles(document->fileName(), editorId);
|
||||
}
|
||||
|
||||
void EditorManager::gotoNextDocHistory()
|
||||
@@ -1643,7 +1643,7 @@ void EditorManager::gotoPreviousDocHistory()
|
||||
void EditorManager::makeCurrentEditorWritable()
|
||||
{
|
||||
if (IEditor* curEditor = currentEditor())
|
||||
makeFileWritable(curEditor->file());
|
||||
makeFileWritable(curEditor->document());
|
||||
}
|
||||
|
||||
void EditorManager::vcsOpenCurrentEditor()
|
||||
@@ -1652,12 +1652,12 @@ void EditorManager::vcsOpenCurrentEditor()
|
||||
if (!curEditor)
|
||||
return;
|
||||
|
||||
const QString directory = QFileInfo(curEditor->file()->fileName()).absolutePath();
|
||||
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
if (!versionControl || !versionControl->supportsOperation(IVersionControl::OpenOperation))
|
||||
return;
|
||||
|
||||
if (!versionControl->vcsOpen(curEditor->file()->fileName())) {
|
||||
if (!versionControl->vcsOpen(curEditor->document()->fileName())) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"),
|
||||
tr("Cannot open the file for editing with VCS."));
|
||||
}
|
||||
@@ -1675,7 +1675,7 @@ void EditorManager::updateWindowTitle()
|
||||
QString editorName = curEditor->displayName();
|
||||
if (!editorName.isEmpty())
|
||||
windowTitle.prepend(editorName + dashSep);
|
||||
QString filePath = QFileInfo(curEditor->file()->fileName()).absoluteFilePath();
|
||||
QString filePath = QFileInfo(curEditor->document()->fileName()).absoluteFilePath();
|
||||
if (!filePath.isEmpty())
|
||||
ICore::mainWindow()->setWindowFilePath(filePath);
|
||||
} else {
|
||||
@@ -1688,8 +1688,8 @@ void EditorManager::handleEditorStateChange()
|
||||
{
|
||||
updateActions();
|
||||
IEditor *theEditor = qobject_cast<IEditor *>(sender());
|
||||
if (!theEditor->file()->isModified())
|
||||
theEditor->file()->removeAutoSaveFile();
|
||||
if (!theEditor->document()->isModified())
|
||||
theEditor->document()->removeAutoSaveFile();
|
||||
IEditor *currEditor = currentEditor();
|
||||
if (theEditor == currEditor) {
|
||||
updateWindowTitle();
|
||||
@@ -1705,24 +1705,24 @@ void EditorManager::updateActions()
|
||||
|
||||
if (curEditor) {
|
||||
|
||||
if (!curEditor->file()->fileName().isEmpty()) {
|
||||
QFileInfo fi(curEditor->file()->fileName());
|
||||
if (!curEditor->document()->fileName().isEmpty()) {
|
||||
QFileInfo fi(curEditor->document()->fileName());
|
||||
fName = fi.fileName();
|
||||
} else {
|
||||
fName = curEditor->displayName();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
window()->setWindowModified(curEditor->file()->isModified());
|
||||
window()->setWindowModified(curEditor->document()->isModified());
|
||||
#endif
|
||||
bool ww = curEditor->file()->isModified() && curEditor->file()->isReadOnly();
|
||||
if (ww != curEditor->file()->hasWriteWarning()) {
|
||||
curEditor->file()->setWriteWarning(ww);
|
||||
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
|
||||
if (ww != curEditor->document()->hasWriteWarning()) {
|
||||
curEditor->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->file()->fileName()).absolutePath();
|
||||
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
|
||||
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
|
||||
@@ -1740,15 +1740,15 @@ void EditorManager::updateActions()
|
||||
tr("<b>Warning:</b> This file was not opened in %1 yet.")
|
||||
.arg(versionControl->displayName()));
|
||||
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
|
||||
curEditor->file()->infoBar()->addInfo(info);
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
} else {
|
||||
InfoBarEntry info(QLatin1String("Core.EditorManager.MakeWritable"),
|
||||
tr("<b>Warning:</b> You are changing a read-only file."));
|
||||
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
|
||||
curEditor->file()->infoBar()->addInfo(info);
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
} else {
|
||||
curEditor->file()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
|
||||
curEditor->document()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -1759,10 +1759,10 @@ void EditorManager::updateActions()
|
||||
|
||||
setCloseSplitEnabled(d->m_splitter, d->m_splitter->isSplitter());
|
||||
|
||||
d->m_saveAction->setEnabled(curEditor != 0 && curEditor->file()->isModified());
|
||||
d->m_saveAsAction->setEnabled(curEditor != 0 && curEditor->file()->isSaveAsAllowed());
|
||||
d->m_saveAction->setEnabled(curEditor != 0 && curEditor->document()->isModified());
|
||||
d->m_saveAsAction->setEnabled(curEditor != 0 && curEditor->document()->isSaveAsAllowed());
|
||||
d->m_revertToSavedAction->setEnabled(curEditor != 0
|
||||
&& !curEditor->file()->fileName().isEmpty() && curEditor->file()->isModified());
|
||||
&& !curEditor->document()->fileName().isEmpty() && curEditor->document()->isModified());
|
||||
|
||||
QString quotedName;
|
||||
if (!fName.isEmpty())
|
||||
@@ -1894,11 +1894,11 @@ QByteArray EditorManager::saveState() const
|
||||
|
||||
QList<IEditor *> editors = openedEditors();
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!editor->file()->fileName().isEmpty()
|
||||
if (!editor->document()->fileName().isEmpty()
|
||||
&& !editor->isTemporary()) {
|
||||
QByteArray state = editor->saveState();
|
||||
if (!state.isEmpty())
|
||||
d->m_editorStates.insert(editor->file()->fileName(), QVariant(state));
|
||||
d->m_editorStates.insert(editor->document()->fileName(), QVariant(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2012,7 +2012,7 @@ void EditorManager::readSettings()
|
||||
.value<QMap<QString, QVariant> >();
|
||||
|
||||
if (settings->contains(QLatin1String(reloadBehaviorKey)))
|
||||
d->m_reloadSetting = (IFile::ReloadSetting)settings->value(QLatin1String(reloadBehaviorKey)).toInt();
|
||||
d->m_reloadSetting = (IDocument::ReloadSetting)settings->value(QLatin1String(reloadBehaviorKey)).toInt();
|
||||
|
||||
if (settings->contains(QLatin1String(autoSaveEnabledKey))) {
|
||||
d->m_autoSaveEnabled = settings->value(QLatin1String(autoSaveEnabledKey)).toBool();
|
||||
@@ -2027,10 +2027,10 @@ void EditorManager::revertToSaved()
|
||||
IEditor *currEditor = currentEditor();
|
||||
if (!currEditor)
|
||||
return;
|
||||
const QString fileName = currEditor->file()->fileName();
|
||||
const QString fileName = currEditor->document()->fileName();
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
if (currEditor->file()->isModified()) {
|
||||
if (currEditor->document()->isModified()) {
|
||||
QMessageBox msgBox(QMessageBox::Question, tr("Revert to Saved"),
|
||||
tr("You will lose your current changes if you proceed reverting %1.").arg(QDir::toNativeSeparators(fileName)),
|
||||
QMessageBox::Yes|QMessageBox::No, ICore::mainWindow());
|
||||
@@ -2043,7 +2043,7 @@ void EditorManager::revertToSaved()
|
||||
|
||||
}
|
||||
QString errorString;
|
||||
if (!currEditor->file()->reload(&errorString, IFile::FlagReload, IFile::TypeContents))
|
||||
if (!currEditor->document()->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents))
|
||||
QMessageBox::critical(ICore::mainWindow(), tr("File Error"), errorString);
|
||||
}
|
||||
|
||||
@@ -2061,12 +2061,12 @@ void EditorManager::hideEditorStatusBar(const QString &id)
|
||||
currentEditorView()->hideEditorStatusBar(id);
|
||||
}
|
||||
|
||||
void EditorManager::setReloadSetting(IFile::ReloadSetting behavior)
|
||||
void EditorManager::setReloadSetting(IDocument::ReloadSetting behavior)
|
||||
{
|
||||
d->m_reloadSetting = behavior;
|
||||
}
|
||||
|
||||
IFile::ReloadSetting EditorManager::reloadSetting() const
|
||||
IDocument::ReloadSetting EditorManager::reloadSetting() const
|
||||
{
|
||||
return d->m_reloadSetting;
|
||||
}
|
||||
@@ -2110,7 +2110,7 @@ Core::IEditor *EditorManager::duplicateEditor(Core::IEditor *editor)
|
||||
IEditor *duplicate = editor->duplicate(0);
|
||||
duplicate->restoreState(editor->saveState());
|
||||
connect(duplicate, SIGNAL(changed()), this, SLOT(handleEditorStateChange()));
|
||||
emit editorCreated(duplicate, duplicate->file()->fileName());
|
||||
emit editorCreated(duplicate, duplicate->document()->fileName());
|
||||
addEditor(duplicate, true);
|
||||
return duplicate;
|
||||
}
|
||||
@@ -2211,7 +2211,7 @@ void EditorManager::updateVariable(const QByteArray &variable)
|
||||
QString value;
|
||||
IEditor *curEditor = currentEditor();
|
||||
if (curEditor) {
|
||||
QString fileName = curEditor->file()->fileName();
|
||||
QString fileName = curEditor->document()->fileName();
|
||||
if (!fileName.isEmpty()) {
|
||||
if (variable == kCurrentDocumentFilePath)
|
||||
value = QFileInfo(fileName).filePath();
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/ifile.h> // enumerations
|
||||
#include <coreplugin/idocument.h> // enumerations
|
||||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
@@ -53,7 +53,7 @@ class IEditor;
|
||||
class IEditorFactory;
|
||||
class IExternalEditor;
|
||||
class MimeType;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IMode;
|
||||
class IVersionControl;
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
|
||||
bool hasEditor(const QString &fileName) const;
|
||||
QList<IEditor *> editorsForFileName(const QString &filename) const;
|
||||
QList<IEditor *> editorsForFile(IFile *file) const;
|
||||
QList<IEditor *> editorsForDocument(IDocument *document) const;
|
||||
|
||||
IEditor *currentEditor() const;
|
||||
QList<IEditor *> visibleEditors() const;
|
||||
@@ -137,13 +137,13 @@ public:
|
||||
|
||||
void activateEditor(IEditor *editor, OpenEditorFlags flags = 0);
|
||||
void activateEditorForIndex(const QModelIndex &index, OpenEditorFlags = 0);
|
||||
IEditor *activateEditorForFile(Internal::EditorView *view, IFile *file, OpenEditorFlags flags = 0);
|
||||
IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0);
|
||||
|
||||
OpenEditorsModel *openedEditorsModel() const;
|
||||
void closeEditor(const QModelIndex &index);
|
||||
void closeOtherEditors(IEditor *editor);
|
||||
|
||||
QList<IEditor*> editorsForFiles(QList<IFile *> files) const;
|
||||
QList<IEditor*> editorsForDocuments(QList<IDocument *> documents) const;
|
||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
bool closeEditors(const QList<IEditor *> &editorsToClose, bool askAboutModifiedEditors = true);
|
||||
|
||||
MakeWritableResult makeFileWritable(IFile *file);
|
||||
MakeWritableResult makeFileWritable(IDocument *document);
|
||||
|
||||
QByteArray saveState() const;
|
||||
bool restoreState(const QByteArray &state);
|
||||
@@ -173,8 +173,8 @@ public:
|
||||
EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true) const;
|
||||
ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true) const;
|
||||
|
||||
void setReloadSetting(IFile::ReloadSetting behavior);
|
||||
IFile::ReloadSetting reloadSetting() const;
|
||||
void setReloadSetting(IDocument::ReloadSetting behavior);
|
||||
IDocument::ReloadSetting reloadSetting() const;
|
||||
|
||||
void setAutoSaveEnabled(bool enabled);
|
||||
bool autoSaveEnabled() const;
|
||||
@@ -202,8 +202,8 @@ signals:
|
||||
public slots:
|
||||
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
||||
|
||||
bool saveFile(Core::IFile *file = 0);
|
||||
bool saveFileAs(Core::IFile *file = 0);
|
||||
bool saveDocument(Core::IDocument *documentParam = 0);
|
||||
bool saveDocumentAs(Core::IDocument *documentParam = 0);
|
||||
void revertToSaved();
|
||||
void closeEditor();
|
||||
void closeOtherEditors();
|
||||
@@ -237,7 +237,7 @@ public slots:
|
||||
void gotoOtherSplit();
|
||||
|
||||
private:
|
||||
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
||||
QList<IDocument *> documentsForEditors(QList<IEditor *> editors) const;
|
||||
IEditor *createEditor(const Id &id = Id(), const QString &fileName = QString());
|
||||
void addEditor(IEditor *editor, bool isDuplicate = false);
|
||||
void removeEditor(IEditor *editor);
|
||||
@@ -261,7 +261,7 @@ private:
|
||||
void emptyView(Internal::EditorView *view);
|
||||
Internal::EditorView *currentEditorView() const;
|
||||
IEditor *pickUnusedEditor() const;
|
||||
void addFileToRecentFiles(IFile *file);
|
||||
void addDocumentToRecentFiles(IDocument *document);
|
||||
void switchToPreferedMode();
|
||||
void updateAutoSave();
|
||||
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
|
||||
|
@@ -278,7 +278,7 @@ void EditorView::setCurrentEditor(IEditor *editor)
|
||||
|
||||
updateEditorHistory(editor);
|
||||
|
||||
m_infoBarDisplay->setInfoBar(editor->file()->infoBar());
|
||||
m_infoBarDisplay->setInfoBar(editor->document()->infoBar());
|
||||
}
|
||||
|
||||
int EditorView::editorCount() const
|
||||
@@ -295,22 +295,22 @@ void EditorView::updateEditorHistory(IEditor *editor)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
|
||||
if (!file)
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
QByteArray state = editor->saveState();
|
||||
|
||||
EditLocation location;
|
||||
location.file = file;
|
||||
location.fileName = file->fileName();
|
||||
location.document = document;
|
||||
location.fileName = document->fileName();
|
||||
location.id = editor->id();
|
||||
location.state = QVariant(state);
|
||||
|
||||
for(int i = 0; i < m_editorHistory.size(); ++i) {
|
||||
if (m_editorHistory.at(i).file == 0
|
||||
|| m_editorHistory.at(i).file == file
|
||||
if (m_editorHistory.at(i).document == 0
|
||||
|| m_editorHistory.at(i).document == document
|
||||
){
|
||||
m_editorHistory.removeAt(i--);
|
||||
continue;
|
||||
@@ -335,9 +335,9 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
editor = currentEditor();
|
||||
if (!editor)
|
||||
return;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
|
||||
if (!file)
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
QByteArray state;
|
||||
@@ -348,8 +348,8 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
}
|
||||
|
||||
EditLocation location;
|
||||
location.file = file;
|
||||
location.fileName = file->fileName();
|
||||
location.document = document;
|
||||
location.fileName = document->fileName();
|
||||
location.id = editor->id();
|
||||
location.state = QVariant(state);
|
||||
m_currentNavigationHistoryPosition = qMin(m_currentNavigationHistoryPosition, m_navigationHistory.size()); // paranoia
|
||||
@@ -392,10 +392,10 @@ void EditorView::copyNavigationHistoryFrom(EditorView* other)
|
||||
void EditorView::updateCurrentPositionInNavigationHistory()
|
||||
{
|
||||
IEditor *editor = currentEditor();
|
||||
if (!editor || !editor->file())
|
||||
if (!editor || !editor->document())
|
||||
return;
|
||||
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
EditLocation *location;
|
||||
if (m_currentNavigationHistoryPosition < m_navigationHistory.size()) {
|
||||
location = &m_navigationHistory[m_currentNavigationHistoryPosition];
|
||||
@@ -403,8 +403,8 @@ void EditorView::updateCurrentPositionInNavigationHistory()
|
||||
m_navigationHistory.append(EditLocation());
|
||||
location = &m_navigationHistory[m_navigationHistory.size()-1];
|
||||
}
|
||||
location->file = file;
|
||||
location->fileName = file->fileName();
|
||||
location->document = document;
|
||||
location->fileName = document->fileName();
|
||||
location->id = editor->id();
|
||||
location->state = QVariant(editor->saveState());
|
||||
}
|
||||
@@ -417,8 +417,8 @@ void EditorView::goBackInNavigationHistory()
|
||||
--m_currentNavigationHistoryPosition;
|
||||
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
|
||||
IEditor *editor;
|
||||
if (location.file) {
|
||||
editor = em->activateEditorForFile(this, location.file,
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
} else {
|
||||
editor = em->openEditor(this, location.fileName, location.id,
|
||||
@@ -443,8 +443,8 @@ void EditorView::goForwardInNavigationHistory()
|
||||
++m_currentNavigationHistoryPosition;
|
||||
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
|
||||
IEditor *editor;
|
||||
if (location.file) {
|
||||
editor = em->activateEditorForFile(this, location.file,
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
} else {
|
||||
editor = em->openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory);
|
||||
@@ -801,11 +801,11 @@ QByteArray SplitterOrView::saveState() const
|
||||
EditorManager *em = ICore::editorManager();
|
||||
|
||||
// don't save state of temporary or ad-hoc editors
|
||||
if (e && (e->isTemporary() || e->file()->fileName().isEmpty())) {
|
||||
if (e && (e->isTemporary() || e->document()->fileName().isEmpty())) {
|
||||
// look for another editor that is more suited
|
||||
e = 0;
|
||||
foreach (IEditor *otherEditor, editors()) {
|
||||
if (!otherEditor->isTemporary() && !otherEditor->file()->fileName().isEmpty()) {
|
||||
if (!otherEditor->isTemporary() && !otherEditor->document()->fileName().isEmpty()) {
|
||||
e = otherEditor;
|
||||
break;
|
||||
}
|
||||
@@ -816,10 +816,10 @@ QByteArray SplitterOrView::saveState() const
|
||||
stream << QByteArray("empty");
|
||||
} else if (e == em->currentEditor()) {
|
||||
stream << QByteArray("currenteditor")
|
||||
<< e->file()->fileName() << e->id().toString() << e->saveState();
|
||||
<< e->document()->fileName() << e->id().toString() << e->saveState();
|
||||
} else {
|
||||
stream << QByteArray("editor")
|
||||
<< e->file()->fileName() << e->id().toString() << e->saveState();
|
||||
<< e->document()->fileName() << e->id().toString() << e->saveState();
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
|
@@ -57,7 +57,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class IContext;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IEditor;
|
||||
class InfoBarDisplay;
|
||||
class OpenEditorsModel;
|
||||
@@ -66,7 +66,7 @@ class EditorToolBar;
|
||||
namespace Internal {
|
||||
|
||||
struct EditLocation {
|
||||
QPointer<IFile> file;
|
||||
QPointer<IDocument> document;
|
||||
QString fileName;
|
||||
Id id;
|
||||
QVariant state;
|
||||
|
@@ -41,7 +41,7 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
|
||||
class CORE_EXPORT IEditor : public IContext
|
||||
{
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
virtual bool createNew(const QString &contents = QString()) = 0;
|
||||
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName) = 0;
|
||||
virtual IFile *file() = 0;
|
||||
virtual IDocument *document() = 0;
|
||||
virtual Core::Id id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
virtual void setDisplayName(const QString &title) = 0;
|
||||
|
@@ -33,18 +33,18 @@
|
||||
#ifndef IEDITORFACTORY_H
|
||||
#define IEDITORFACTORY_H
|
||||
|
||||
#include <coreplugin/ifilefactory.h>
|
||||
#include <coreplugin/idocumentfactory.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IEditor;
|
||||
|
||||
class CORE_EXPORT IEditorFactory : public Core::IFileFactory
|
||||
class CORE_EXPORT IEditorFactory : public Core::IDocumentFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IEditorFactory(QObject *parent = 0) : IFileFactory(parent) {}
|
||||
IEditorFactory(QObject *parent = 0) : IDocumentFactory(parent) {}
|
||||
|
||||
virtual IEditor *createEditor(QWidget *parent) = 0;
|
||||
};
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "openeditorsmodel.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QIcon>
|
||||
@@ -82,7 +82,7 @@ QIcon OpenEditorsModel::unlockedIcon() const
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::fileName() const {
|
||||
return editor ? editor->file()->fileName() : m_fileName;
|
||||
return editor ? editor->document()->fileName() : m_fileName;
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::displayName() const {
|
||||
@@ -252,9 +252,9 @@ bool OpenEditorsModel::isDuplicate(IEditor *editor) const
|
||||
|
||||
IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
|
||||
{
|
||||
IFile *file = duplicate->file();
|
||||
IDocument *document = duplicate->document();
|
||||
foreach(const Entry &e, d->m_editors)
|
||||
if (e.editor && e.editor->file() == file)
|
||||
if (e.editor && e.editor->document() == document)
|
||||
return e.editor;
|
||||
return 0;
|
||||
}
|
||||
@@ -262,9 +262,9 @@ IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
|
||||
QList<IEditor *> OpenEditorsModel::duplicatesFor(IEditor *editor) const
|
||||
{
|
||||
QList<IEditor *> result;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
foreach(IEditor *e, d->m_duplicateEditors)
|
||||
if (e->file() == file)
|
||||
if (e->document() == document)
|
||||
result += e;
|
||||
return result;
|
||||
}
|
||||
@@ -306,16 +306,16 @@ QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
|
||||
Entry e = d->m_editors.at(index.row());
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return (e.editor && e.editor->file()->isModified())
|
||||
return (e.editor && e.editor->document()->isModified())
|
||||
? e.displayName() + QLatin1Char('*')
|
||||
: e.displayName();
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
bool showLock = false;
|
||||
if (e.editor) {
|
||||
showLock = e.editor->file()->fileName().isEmpty()
|
||||
showLock = e.editor->document()->fileName().isEmpty()
|
||||
? false
|
||||
: e.editor->file()->isReadOnly();
|
||||
: e.editor->document()->isFileReadOnly();
|
||||
} else {
|
||||
showLock = !QFileInfo(e.m_fileName).isWritable();
|
||||
}
|
||||
@@ -343,10 +343,10 @@ QModelIndex OpenEditorsModel::indexOf(IEditor *editor) const
|
||||
return createIndex(idx, 0);
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::displayNameForFile(IFile *file) const
|
||||
QString OpenEditorsModel::displayNameForDocument(IDocument *document) const
|
||||
{
|
||||
for (int i = 0; i < d->m_editors.count(); ++i)
|
||||
if (d->m_editors.at(i).editor && d->m_editors.at(i).editor->file() == file)
|
||||
if (d->m_editors.at(i).editor && d->m_editors.at(i).editor->document() == document)
|
||||
return d->m_editors.at(i).editor->displayName();
|
||||
return QString();
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ namespace Core {
|
||||
|
||||
struct OpenEditorsModelPrivate;
|
||||
class IEditor;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
|
||||
class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void makeOriginal(IEditor *duplicate);
|
||||
QModelIndex indexOf(IEditor *editor) const;
|
||||
|
||||
QString displayNameForFile(IFile *file) const;
|
||||
QString displayNameForDocument(IDocument *document) const;
|
||||
|
||||
private slots:
|
||||
void itemChanged();
|
||||
|
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
@@ -34,7 +34,7 @@
|
||||
#include "openeditorsmodel.h"
|
||||
#include "editormanager.h"
|
||||
#include "editorview.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::EditorView*)
|
||||
Q_DECLARE_METATYPE(Core::IFile *)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
@@ -203,21 +203,21 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
|
||||
m_editorList->clear();
|
||||
bool first = true;
|
||||
|
||||
QSet<IFile*> filesDone;
|
||||
QSet<IDocument*> documentsDone;
|
||||
foreach (const EditLocation &hi, view->editorHistory()) {
|
||||
if (hi.file.isNull() || filesDone.contains(hi.file))
|
||||
if (hi.document.isNull() || documentsDone.contains(hi.document))
|
||||
continue;
|
||||
QString title = model->displayNameForFile(hi.file);
|
||||
QString title = model->displayNameForDocument(hi.document);
|
||||
QTC_ASSERT(!title.isEmpty(), continue;)
|
||||
filesDone.insert(hi.file.data());
|
||||
documentsDone.insert(hi.document.data());
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
if (hi.file->isModified())
|
||||
if (hi.document->isModified())
|
||||
title += tr("*");
|
||||
item->setIcon(0, !hi.file->fileName().isEmpty() && hi.file->isReadOnly()
|
||||
item->setIcon(0, !hi.document->fileName().isEmpty() && hi.document->isFileReadOnly()
|
||||
? model->lockedIcon() : m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, hi.file->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
|
||||
item->setToolTip(0, hi.document->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
|
||||
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
|
||||
@@ -232,20 +232,20 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
|
||||
// add missing editors from the main view
|
||||
if (mainView != view) {
|
||||
foreach (const EditLocation &hi, mainView->editorHistory()) {
|
||||
if (hi.file.isNull() || filesDone.contains(hi.file))
|
||||
if (hi.document.isNull() || documentsDone.contains(hi.document))
|
||||
continue;
|
||||
filesDone.insert(hi.file.data());
|
||||
documentsDone.insert(hi.document.data());
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
|
||||
QString title = model->displayNameForFile(hi.file);
|
||||
if (hi.file->isModified())
|
||||
QString title = model->displayNameForDocument(hi.document);
|
||||
if (hi.document->isModified())
|
||||
title += tr("*");
|
||||
item->setIcon(0, !hi.file->fileName().isEmpty() && hi.file->isReadOnly()
|
||||
item->setIcon(0, !hi.document->fileName().isEmpty() && hi.document->isFileReadOnly()
|
||||
? model->lockedIcon() : m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, hi.file->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
|
||||
item->setToolTip(0, hi.document->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
|
||||
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
|
||||
item->setData(0, Qt::UserRole+2, QVariant::fromValue(hi.id));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
@@ -280,9 +280,9 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
if (IFile *file = item->data(0, Qt::UserRole).value<IFile*>()) {
|
||||
if (IDocument *document = item->data(0, Qt::UserRole).value<IDocument*>()) {
|
||||
EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>();
|
||||
EditorManager::instance()->activateEditorForFile(view, file, EditorManager::ModeSwitch);
|
||||
EditorManager::instance()->activateEditorForDocument(view, document, EditorManager::ModeSwitch);
|
||||
} else {
|
||||
if (!EditorManager::instance()->openEditor(
|
||||
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>(),
|
||||
|
@@ -351,7 +351,7 @@ void EditorToolBar::listContextMenu(QPoint pos)
|
||||
void EditorToolBar::makeEditorWritable()
|
||||
{
|
||||
if (currentEditor())
|
||||
ICore::editorManager()->makeFileWritable(currentEditor()->file());
|
||||
ICore::editorManager()->makeFileWritable(currentEditor()->document());
|
||||
}
|
||||
|
||||
void EditorToolBar::setCanGoBack(bool canGoBack)
|
||||
@@ -390,7 +390,7 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
{
|
||||
d->m_closeEditorButton->setEnabled(editor != 0);
|
||||
|
||||
if (!editor || !editor->file()) {
|
||||
if (!editor || !editor->document()) {
|
||||
d->m_lockButton->setIcon(QIcon());
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(QString());
|
||||
@@ -400,11 +400,11 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
|
||||
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(editor).row());
|
||||
|
||||
if (editor->file()->fileName().isEmpty()) {
|
||||
if (editor->document()->fileName().isEmpty()) {
|
||||
d->m_lockButton->setIcon(QIcon());
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(QString());
|
||||
} else if (editor->file()->isReadOnly()) {
|
||||
} else if (editor->document()->isFileReadOnly()) {
|
||||
d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->lockedIcon()));
|
||||
d->m_lockButton->setEnabled(true);
|
||||
d->m_lockButton->setToolTip(tr("Make Writable"));
|
||||
@@ -415,9 +415,9 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
}
|
||||
if (editor == currentEditor())
|
||||
d->m_editorList->setToolTip(
|
||||
currentEditor()->file()->fileName().isEmpty()
|
||||
currentEditor()->document()->fileName().isEmpty()
|
||||
? currentEditor()->displayName()
|
||||
: QDir::toNativeSeparators(editor->file()->fileName())
|
||||
: QDir::toNativeSeparators(editor->document()->fileName())
|
||||
);
|
||||
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include <app/app_version.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -601,14 +601,14 @@ void ExternalToolRunner::run()
|
||||
}
|
||||
if (m_tool->modifiesCurrentDocument()) {
|
||||
if (IEditor *editor = EditorManager::instance()->currentEditor()) {
|
||||
m_expectedFileName = editor->file()->fileName();
|
||||
m_expectedFileName = editor->document()->fileName();
|
||||
bool cancelled = false;
|
||||
FileManager::saveModifiedFiles(QList<IFile *>() << editor->file(), &cancelled);
|
||||
DocumentManager::saveModifiedDocuments(QList<IDocument *>() << editor->document(), &cancelled);
|
||||
if (cancelled) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
FileManager::expectFileChange(m_expectedFileName);
|
||||
DocumentManager::expectFileChange(m_expectedFileName);
|
||||
}
|
||||
}
|
||||
m_process = new Utils::QtcProcess(this);
|
||||
@@ -641,7 +641,7 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
emit ExternalToolManager::instance()->replaceSelectionRequested(m_processOutput);
|
||||
}
|
||||
if (m_tool->modifiesCurrentDocument()) {
|
||||
FileManager::unexpectFileChange(m_expectedFileName);
|
||||
DocumentManager::unexpectFileChange(m_expectedFileName);
|
||||
}
|
||||
}
|
||||
ICore::messageManager()->printToOutputPane(
|
||||
@@ -652,7 +652,7 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
void ExternalToolRunner::error(QProcess::ProcessError error)
|
||||
{
|
||||
if (m_tool->modifiesCurrentDocument())
|
||||
FileManager::unexpectFileChange(m_expectedFileName);
|
||||
DocumentManager::unexpectFileChange(m_expectedFileName);
|
||||
// TODO inform about errors
|
||||
Q_UNUSED(error);
|
||||
deleteLater();
|
||||
|
@@ -195,7 +195,7 @@ void GeneralSettings::apply()
|
||||
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
||||
// Apply the new base color if accepted
|
||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||
EditorManager::instance()->setReloadSetting(IFile::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
||||
EditorManager::instance()->setReloadSetting(IDocument::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
||||
#ifdef Q_OS_UNIX
|
||||
ConsoleProcess::setTerminalEmulator(Core::ICore::settings(),
|
||||
m_page->terminalEdit->text());
|
||||
|
@@ -67,7 +67,7 @@
|
||||
in \a defaultLocation. It defaults to the path of the file manager's
|
||||
current file.
|
||||
|
||||
\sa Core::FileManager
|
||||
\sa Core::DocumentManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -103,7 +103,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn FileManager *ICore::fileManager() const
|
||||
\fn DocumentManager *ICore::fileManager() const
|
||||
\brief Returns the application's file manager.
|
||||
|
||||
The file manager keeps track of files for changes outside the application.
|
||||
@@ -346,6 +346,7 @@
|
||||
|
||||
#include "icore.h"
|
||||
#include "mainwindow.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
@@ -410,9 +411,9 @@ ActionManager *ICore::actionManager()
|
||||
return m_mainwindow->actionManager();
|
||||
}
|
||||
|
||||
FileManager *ICore::fileManager()
|
||||
DocumentManager *ICore::documentManager()
|
||||
{
|
||||
return m_mainwindow->fileManager();
|
||||
return DocumentManager::instance();
|
||||
}
|
||||
|
||||
MessageManager *ICore::messageManager()
|
||||
|
@@ -51,7 +51,7 @@ class IWizard;
|
||||
class ActionManager;
|
||||
class Context;
|
||||
class EditorManager;
|
||||
class FileManager;
|
||||
class DocumentManager;
|
||||
class HelpManager;
|
||||
class IContext;
|
||||
class MessageManager;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
QWidget *parent = 0);
|
||||
|
||||
static ActionManager *actionManager();
|
||||
static QT_DEPRECATED FileManager *fileManager(); // Use FileManager::... directly.
|
||||
static QT_DEPRECATED DocumentManager *documentManager(); // Use DocumentManager::... directly.
|
||||
static MessageManager *messageManager();
|
||||
static EditorManager *editorManager();
|
||||
static ProgressManager *progressManager();
|
||||
|
@@ -30,7 +30,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include "infobar.h"
|
||||
|
||||
@@ -39,17 +39,17 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
IFile::IFile(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
|
||||
IDocument::IDocument(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
|
||||
{
|
||||
}
|
||||
|
||||
IFile::~IFile()
|
||||
IDocument::~IDocument()
|
||||
{
|
||||
removeAutoSaveFile();
|
||||
delete m_infoBar;
|
||||
}
|
||||
|
||||
IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
{
|
||||
if (type == TypePermissions)
|
||||
return BehaviorSilent;
|
||||
@@ -58,23 +58,23 @@ IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type
|
||||
return BehaviorAsk;
|
||||
}
|
||||
|
||||
void IFile::checkPermissions()
|
||||
void IDocument::checkPermissions()
|
||||
{
|
||||
}
|
||||
|
||||
bool IFile::shouldAutoSave() const
|
||||
bool IDocument::shouldAutoSave() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IFile::isReadOnly() const
|
||||
bool IDocument::isFileReadOnly() const
|
||||
{
|
||||
if (fileName().isEmpty())
|
||||
return false;
|
||||
return !QFileInfo(fileName()).isWritable();
|
||||
}
|
||||
|
||||
bool IFile::autoSave(QString *errorString, const QString &fileName)
|
||||
bool IDocument::autoSave(QString *errorString, const QString &fileName)
|
||||
{
|
||||
if (!save(errorString, fileName, true))
|
||||
return false;
|
||||
@@ -84,7 +84,7 @@ bool IFile::autoSave(QString *errorString, const QString &fileName)
|
||||
|
||||
static const char kRestoredAutoSave[] = "RestoredAutoSave";
|
||||
|
||||
void IFile::setRestoredFrom(const QString &name)
|
||||
void IDocument::setRestoredFrom(const QString &name)
|
||||
{
|
||||
m_autoSaveName = name;
|
||||
m_restored = true;
|
||||
@@ -94,7 +94,7 @@ void IFile::setRestoredFrom(const QString &name)
|
||||
infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void IFile::removeAutoSaveFile()
|
||||
void IDocument::removeAutoSaveFile()
|
||||
{
|
||||
if (!m_autoSaveName.isEmpty()) {
|
||||
QFile::remove(m_autoSaveName);
|
||||
@@ -106,7 +106,7 @@ void IFile::removeAutoSaveFile()
|
||||
}
|
||||
}
|
||||
|
||||
InfoBar *IFile::infoBar()
|
||||
InfoBar *IDocument::infoBar()
|
||||
{
|
||||
if (!m_infoBar)
|
||||
m_infoBar = new InfoBar;
|
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef IFILE_H
|
||||
#define IFILE_H
|
||||
#ifndef IDOCUMENT_H
|
||||
#define IDOCUMENT_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include <QObject>
|
||||
@@ -41,7 +41,7 @@ namespace Core {
|
||||
class MimeType;
|
||||
class InfoBar;
|
||||
|
||||
class CORE_EXPORT IFile : public QObject
|
||||
class CORE_EXPORT IDocument : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -81,11 +81,12 @@ public:
|
||||
FlagIgnore
|
||||
};
|
||||
|
||||
IFile(QObject *parent = 0);
|
||||
virtual ~IFile();
|
||||
IDocument(QObject *parent = 0);
|
||||
virtual ~IDocument();
|
||||
|
||||
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
|
||||
virtual QString fileName() const = 0;
|
||||
virtual bool isFileReadOnly() const;
|
||||
|
||||
virtual QString defaultPath() const = 0;
|
||||
virtual QString suggestedFileName() const = 0;
|
||||
@@ -93,7 +94,6 @@ public:
|
||||
|
||||
virtual bool shouldAutoSave() const;
|
||||
virtual bool isModified() const = 0;
|
||||
virtual bool isReadOnly() const;
|
||||
virtual bool isSaveAsAllowed() const = 0;
|
||||
|
||||
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||
@@ -126,4 +126,4 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IFILE_H
|
||||
#endif // IDOCUMENT_H
|
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef IFILEFACTORY_H
|
||||
#define IFILEFACTORY_H
|
||||
#ifndef IDOCUMENTFACTORY_H
|
||||
#define IDOCUMENTFACTORY_H
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
@@ -43,22 +43,22 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class Id;
|
||||
|
||||
class CORE_EXPORT IFileFactory : public QObject
|
||||
class CORE_EXPORT IDocumentFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IFileFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
IDocumentFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
virtual QStringList mimeTypes() const = 0;
|
||||
virtual Id id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
virtual IFile *open(const QString &fileName) = 0;
|
||||
virtual IDocument *open(const QString &fileName) = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IFILEFACTORY_H
|
||||
#endif // IDOCUMENTFACTORY_H
|
@@ -41,11 +41,11 @@
|
||||
#include "toolsettings.h"
|
||||
#include "mimetypesettings.h"
|
||||
#include "fancytabwidget.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "generalsettings.h"
|
||||
#include "helpmanager.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifilefactory.h"
|
||||
#include "idocumentfactory.h"
|
||||
#include "messagemanager.h"
|
||||
#include "modemanager.h"
|
||||
#include "mimedatabase.h"
|
||||
@@ -170,7 +170,7 @@ MainWindow::MainWindow() :
|
||||
#endif
|
||||
m_toggleSideBarButton(new QToolButton)
|
||||
{
|
||||
(void) new FileManager(this);
|
||||
(void) new DocumentManager(this);
|
||||
OutputPaneManager::create();
|
||||
|
||||
setWindowTitle(tr("Qt Creator"));
|
||||
@@ -376,7 +376,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
// Save opened files
|
||||
bool cancelled;
|
||||
QList<IFile*> notSaved = FileManager::saveModifiedFiles(FileManager::modifiedFiles(), &cancelled);
|
||||
QList<IDocument*> notSaved = DocumentManager::saveModifiedDocuments(DocumentManager::modifiedDocuments(), &cancelled);
|
||||
if (cancelled || !notSaved.isEmpty()) {
|
||||
event->ignore();
|
||||
return;
|
||||
@@ -836,25 +836,25 @@ void MainWindow::openFile()
|
||||
openFiles(editorManager()->getOpenFileNames(), ICore::SwitchMode);
|
||||
}
|
||||
|
||||
static QList<IFileFactory*> getNonEditorFileFactories()
|
||||
static QList<IDocumentFactory*> getNonEditorDocumentFactories()
|
||||
{
|
||||
const QList<IFileFactory*> allFileFactories =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IFileFactory>();
|
||||
QList<IFileFactory*> nonEditorFileFactories;
|
||||
foreach (IFileFactory *factory, allFileFactories) {
|
||||
const QList<IDocumentFactory*> allFileFactories =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IDocumentFactory>();
|
||||
QList<IDocumentFactory*> nonEditorFileFactories;
|
||||
foreach (IDocumentFactory *factory, allFileFactories) {
|
||||
if (!qobject_cast<IEditorFactory *>(factory))
|
||||
nonEditorFileFactories.append(factory);
|
||||
}
|
||||
return nonEditorFileFactories;
|
||||
}
|
||||
|
||||
static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
|
||||
static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fileFactories,
|
||||
const MimeDatabase *db,
|
||||
const QFileInfo &fi)
|
||||
{
|
||||
if (const MimeType mt = db->findByFile(fi)) {
|
||||
const QString type = mt.type();
|
||||
foreach (IFileFactory *factory, fileFactories) {
|
||||
foreach (IDocumentFactory *factory, fileFactories) {
|
||||
if (factory->mimeTypes().contains(type))
|
||||
return factory;
|
||||
}
|
||||
@@ -865,16 +865,16 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
|
||||
// opens either an editor or loads a project
|
||||
void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags)
|
||||
{
|
||||
QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories();
|
||||
QList<IDocumentFactory*> nonEditorFileFactories = getNonEditorDocumentFactories();
|
||||
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
const QFileInfo fi(fileName);
|
||||
const QString absoluteFilePath = fi.absoluteFilePath();
|
||||
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||
Core::IFile *file = fileFactory->open(absoluteFilePath);
|
||||
if (!file && (flags & ICore::StopOnLoadFail))
|
||||
if (IDocumentFactory *documentFactory = findDocumentFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||
Core::IDocument *document = documentFactory->open(absoluteFilePath);
|
||||
if (!document && (flags & ICore::StopOnLoadFail))
|
||||
return;
|
||||
if (file && (flags & ICore::SwitchMode))
|
||||
if (document && (flags & ICore::SwitchMode))
|
||||
ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
} else {
|
||||
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
||||
@@ -969,12 +969,12 @@ void MainWindow::showNewItemDialog(const QString &title,
|
||||
// Project wizards: Check for projects directory or
|
||||
// use last visited directory of file dialog. Never start
|
||||
// at current.
|
||||
path = FileManager::useProjectsDirectory() ?
|
||||
FileManager::projectsDirectory() :
|
||||
FileManager::fileDialogLastVisitedDirectory();
|
||||
path = DocumentManager::useProjectsDirectory() ?
|
||||
DocumentManager::projectsDirectory() :
|
||||
DocumentManager::fileDialogLastVisitedDirectory();
|
||||
break;
|
||||
default:
|
||||
path = FileManager::fileDialogInitialDirectory();
|
||||
path = DocumentManager::fileDialogInitialDirectory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -994,7 +994,7 @@ bool MainWindow::showOptionsDialog(const QString &category,
|
||||
|
||||
void MainWindow::saveAll()
|
||||
{
|
||||
FileManager::saveModifiedFilesSilently(FileManager::modifiedFiles());
|
||||
DocumentManager::saveModifiedDocumentsSilently(DocumentManager::modifiedDocuments());
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
}
|
||||
|
||||
@@ -1029,11 +1029,6 @@ ActionManager *MainWindow::actionManager() const
|
||||
return m_actionManager;
|
||||
}
|
||||
|
||||
FileManager *MainWindow::fileManager() const
|
||||
{
|
||||
return FileManager::instance();
|
||||
}
|
||||
|
||||
MessageManager *MainWindow::messageManager() const
|
||||
{
|
||||
return m_messageManager;
|
||||
@@ -1237,7 +1232,7 @@ void MainWindow::writeSettings()
|
||||
|
||||
m_settings->endGroup();
|
||||
|
||||
FileManager::saveSettings();
|
||||
DocumentManager::saveSettings();
|
||||
m_actionManager->saveSettings(m_settings);
|
||||
m_editorManager->saveSettings();
|
||||
m_navigationWidget->saveSettings(m_settings);
|
||||
@@ -1297,7 +1292,7 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
aci->menu()->clear();
|
||||
|
||||
bool hasRecentFiles = false;
|
||||
foreach (const FileManager::RecentFile &file, FileManager::recentFiles()) {
|
||||
foreach (const DocumentManager::RecentFile &file, DocumentManager::recentFiles()) {
|
||||
hasRecentFiles = true;
|
||||
QAction *action = aci->menu()->addAction(
|
||||
QDir::toNativeSeparators(Utils::withTildeHomePath(file.first)));
|
||||
@@ -1311,14 +1306,14 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
aci->menu()->addSeparator();
|
||||
QAction *action = aci->menu()->addAction(QCoreApplication::translate(
|
||||
"Core", Core::Constants::TR_CLEAR_MENU));
|
||||
connect(action, SIGNAL(triggered()), FileManager::instance(), SLOT(clearRecentFiles()));
|
||||
connect(action, SIGNAL(triggered()), DocumentManager::instance(), SLOT(clearRecentFiles()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openRecentFile()
|
||||
{
|
||||
if (const QAction *action = qobject_cast<const QAction*>(sender())) {
|
||||
const FileManager::RecentFile file = action->data().value<FileManager::RecentFile>();
|
||||
const DocumentManager::RecentFile file = action->data().value<DocumentManager::RecentFile>();
|
||||
editorManager()->openEditor(file.first, file.second, Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ class ActionManager;
|
||||
class StatusBarWidget;
|
||||
class EditorManager;
|
||||
class ExternalToolManager;
|
||||
class FileManager;
|
||||
class DocumentManager;
|
||||
class HelpManager;
|
||||
class IWizard;
|
||||
class MessageManager;
|
||||
@@ -100,7 +100,6 @@ public:
|
||||
void openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
|
||||
|
||||
Core::ActionManager *actionManager() const;
|
||||
Core::FileManager *fileManager() const;
|
||||
Core::MessageManager *messageManager() const;
|
||||
Core::EditorManager *editorManager() const;
|
||||
Core::ProgressManager *progressManager() const;
|
||||
|
@@ -34,8 +34,8 @@
|
||||
#define METATYPEDECLARATIONS_H
|
||||
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -50,9 +50,9 @@ class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(Core::MessageManager*)
|
||||
Q_DECLARE_METATYPE(Core::FileManager*)
|
||||
Q_DECLARE_METATYPE(Core::IFile*)
|
||||
Q_DECLARE_METATYPE(QList<Core::IFile*>)
|
||||
Q_DECLARE_METATYPE(Core::DocumentManager*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
Q_DECLARE_METATYPE(QList<Core::IDocument*>)
|
||||
Q_DECLARE_METATYPE(QList<Core::IEditor*>)
|
||||
Q_DECLARE_METATYPE(Core::EditorManager*)
|
||||
Q_DECLARE_METATYPE(Core::ICore*)
|
||||
|
@@ -30,7 +30,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "textfile.h"
|
||||
#include "textdocument.h"
|
||||
#include "editormanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
@@ -51,10 +51,10 @@ enum { debug = 0 };
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
class TextFilePrivate
|
||||
class TextDocumentPrivate
|
||||
{
|
||||
public:
|
||||
TextFilePrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
||||
TextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
||||
|
||||
Utils::TextFileFormat m_format;
|
||||
Utils::TextFileFormat::ReadResult m_readResult;
|
||||
@@ -63,23 +63,23 @@ public:
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
TextFile::TextFile(QObject *parent) :
|
||||
IFile(parent), d(new Internal::TextFilePrivate)
|
||||
TextDocument::TextDocument(QObject *parent) :
|
||||
IDocument(parent), d(new Internal::TextDocumentPrivate)
|
||||
{
|
||||
setCodec(Core::EditorManager::instance()->defaultTextCodec());
|
||||
}
|
||||
|
||||
TextFile::~TextFile()
|
||||
TextDocument::~TextDocument()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool TextFile::hasDecodingError() const
|
||||
bool TextDocument::hasDecodingError() const
|
||||
{
|
||||
return d->m_readResult == Utils::TextFileFormat::ReadEncodingError;
|
||||
}
|
||||
|
||||
QByteArray TextFile::decodingErrorSample() const
|
||||
QByteArray TextDocument::decodingErrorSample() const
|
||||
{
|
||||
return d->m_decodingErrorSample;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ QByteArray TextFile::decodingErrorSample() const
|
||||
\brief Writes out text using the format obtained from the last read.
|
||||
*/
|
||||
|
||||
bool TextFile::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
||||
bool TextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
||||
{
|
||||
return write(fileName, format(), data, errorMessage);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ bool TextFile::write(const QString &fileName, const QString &data, QString *erro
|
||||
\brief Writes out text using a custom format obtained.
|
||||
*/
|
||||
|
||||
bool TextFile::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
||||
bool TextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << this << fileName;
|
||||
@@ -108,7 +108,7 @@ bool TextFile::write(const QString &fileName, const Utils::TextFileFormat &forma
|
||||
\brief Autodetect format and read in a text file.
|
||||
*/
|
||||
|
||||
TextFile::ReadResult TextFile::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
||||
{
|
||||
d->m_readResult =
|
||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||
@@ -120,7 +120,7 @@ TextFile::ReadResult TextFile::read(const QString &fileName, QStringList *plainT
|
||||
\brief Autodetect format and read in a text file.
|
||||
*/
|
||||
|
||||
TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText, QString *errorString)
|
||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QString *plainText, QString *errorString)
|
||||
{
|
||||
d->m_readResult =
|
||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||
@@ -128,12 +128,12 @@ TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText,
|
||||
return d->m_readResult;
|
||||
}
|
||||
|
||||
const QTextCodec *TextFile::codec() const
|
||||
const QTextCodec *TextDocument::codec() const
|
||||
{
|
||||
return d->m_format.codec;
|
||||
}
|
||||
|
||||
void TextFile::setCodec(const QTextCodec *codec)
|
||||
void TextDocument::setCodec(const QTextCodec *codec)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray());
|
||||
@@ -144,7 +144,7 @@ void TextFile::setCodec(const QTextCodec *codec)
|
||||
\brief Returns the format obtained from the last call to read().
|
||||
*/
|
||||
|
||||
Utils::TextFileFormat TextFile::format() const
|
||||
Utils::TextFileFormat TextDocument::format() const
|
||||
{
|
||||
return d->m_format;
|
||||
}
|
@@ -30,27 +30,27 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CORE_TEXTFILE_H
|
||||
#define CORE_TEXTFILE_H
|
||||
#ifndef CORE_TEXTDOCUMENT_H
|
||||
#define CORE_TEXTDOCUMENT_H
|
||||
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <utils/textfileformat.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
class TextFilePrivate;
|
||||
class TextDocumentPrivate;
|
||||
}
|
||||
|
||||
class CORE_EXPORT TextFile : public IFile
|
||||
class CORE_EXPORT TextDocument : public IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef Utils::TextFileFormat::ReadResult ReadResult;
|
||||
|
||||
explicit TextFile(QObject *parent = 0);
|
||||
virtual ~TextFile();
|
||||
explicit TextDocument(QObject *parent = 0);
|
||||
virtual ~TextDocument();
|
||||
|
||||
Utils::TextFileFormat format() const;
|
||||
const QTextCodec *codec() const;
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
||||
|
||||
private:
|
||||
Internal::TextFilePrivate *d;
|
||||
Internal::TextDocumentPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // CORE_TEXTFILE_H
|
||||
#endif // CORE_TEXTDOCUMENT_H
|
@@ -31,7 +31,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "variablemanager.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
#include "editormanager/ieditor.h"
|
||||
#include "editormanager/editormanager.h"
|
||||
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include "vcsmanager.h"
|
||||
#include "iversioncontrol.h"
|
||||
#include "icore.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -181,7 +181,7 @@ void VcsManager::extensionsInitialized()
|
||||
// Change signal connections
|
||||
foreach (IVersionControl *versionControl, allVersionControls()) {
|
||||
connect(versionControl, SIGNAL(filesChanged(QStringList)),
|
||||
FileManager::instance(), SIGNAL(filesChangedInternally(QStringList)));
|
||||
DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)));
|
||||
connect(versionControl, SIGNAL(repositoryChanged(QString)),
|
||||
this, SIGNAL(repositoryChanged(QString)));
|
||||
}
|
||||
|
@@ -346,7 +346,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
|
||||
// If the mime type has a preferred suffix (cpp/h/patch...), use that for
|
||||
// the temporary file. This is to make it more convenient to "Save as"
|
||||
// for the user and also to be able to tell a patch or diff in the VCS plugins
|
||||
// by looking at the file name of FileManager::currentFile() without expensive checking.
|
||||
// by looking at the file name of DocumentManager::currentFile() without expensive checking.
|
||||
// Default to "txt".
|
||||
QByteArray byteContent = content.toUtf8();
|
||||
QString suffix;
|
||||
|
@@ -544,7 +544,7 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor)
|
||||
connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip()));
|
||||
connect(document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onContentsChanged(int,int,int)));
|
||||
|
||||
connect(file(), SIGNAL(changed()), this, SLOT(updateFileName()));
|
||||
connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName()));
|
||||
|
||||
// set up function declaration - definition link
|
||||
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateFunctionDeclDefLink()));
|
||||
@@ -675,7 +675,7 @@ void CPPEditorWidget::abortRename()
|
||||
|
||||
void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc)
|
||||
{
|
||||
if (doc->fileName() != file()->fileName())
|
||||
if (doc->fileName() != editorDocument()->fileName())
|
||||
return;
|
||||
|
||||
if (doc->editorRevision() != editorRevision())
|
||||
@@ -685,7 +685,7 @@ void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc)
|
||||
(Core::EditorManager::instance()->currentEditor() == editor()
|
||||
&& (!m_lastSemanticInfo.doc
|
||||
|| !m_lastSemanticInfo.doc->translationUnit()->ast()
|
||||
|| m_lastSemanticInfo.doc->fileName() != file()->fileName()))) {
|
||||
|| m_lastSemanticInfo.doc->fileName() != editorDocument()->fileName()))) {
|
||||
m_initialized = true;
|
||||
semanticRehighlight(/* force = */ true);
|
||||
}
|
||||
@@ -901,7 +901,7 @@ bool CPPEditorWidget::sortedOutline() const
|
||||
void CPPEditorWidget::updateOutlineNow()
|
||||
{
|
||||
const Snapshot snapshot = m_modelManager->snapshot();
|
||||
Document::Ptr document = snapshot.document(file()->fileName());
|
||||
Document::Ptr document = snapshot.document(editorDocument()->fileName());
|
||||
|
||||
if (!document)
|
||||
return;
|
||||
@@ -1047,7 +1047,7 @@ void CPPEditorWidget::switchDeclarationDefinition()
|
||||
|
||||
const Snapshot snapshot = m_modelManager->snapshot();
|
||||
|
||||
if (Document::Ptr thisDocument = snapshot.document(file()->fileName())) {
|
||||
if (Document::Ptr thisDocument = snapshot.document(editorDocument()->fileName())) {
|
||||
int line = 0, positionInBlock = 0;
|
||||
convertPosition(position(), &line, &positionInBlock);
|
||||
|
||||
@@ -1281,7 +1281,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
}
|
||||
|
||||
// Now we prefer the doc from the snapshot with macros expanded.
|
||||
Document::Ptr doc = snapshot.document(file()->fileName());
|
||||
Document::Ptr doc = snapshot.document(editorDocument()->fileName());
|
||||
if (!doc) {
|
||||
doc = m_lastSemanticInfo.doc;
|
||||
if (!doc)
|
||||
@@ -1411,7 +1411,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor,
|
||||
foreach (const LookupItem &r, resolvedSymbols) {
|
||||
if (Symbol *d = r.declaration()) {
|
||||
if (d->isDeclaration() || d->isFunction()) {
|
||||
if (file()->fileName() == QString::fromUtf8(d->fileName(), d->fileNameLength())) {
|
||||
if (editorDocument()->fileName() == QString::fromUtf8(d->fileName(), d->fileNameLength())) {
|
||||
if (unsigned(lineNumber) == d->line() && unsigned(positionInBlock) >= d->column()) { // ### TODO: check the end
|
||||
result = r; // take the symbol under cursor.
|
||||
break;
|
||||
@@ -1820,7 +1820,7 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo)
|
||||
|
||||
// We can use the semanticInfo's snapshot (and avoid locking), but not its
|
||||
// document, since it doesn't contain expanded macros.
|
||||
LookupContext context(semanticInfo.snapshot.document(file()->fileName()),
|
||||
LookupContext context(semanticInfo.snapshot.document(editorDocument()->fileName()),
|
||||
semanticInfo.snapshot);
|
||||
|
||||
SemanticInfo::LocalUseIterator it(semanticInfo.localUses);
|
||||
@@ -1984,7 +1984,7 @@ SemanticHighlighter::Source CPPEditorWidget::currentSource(bool force)
|
||||
convertPosition(position(), &line, &column);
|
||||
|
||||
const Snapshot snapshot = m_modelManager->snapshot();
|
||||
const QString fileName = file()->fileName();
|
||||
const QString fileName = editorDocument()->fileName();
|
||||
|
||||
QString code;
|
||||
if (force || m_lastSemanticInfo.revision != editorRevision())
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "cppelementevaluator.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <cpptools/cpptoolsreuse.h>
|
||||
|
||||
#include <FullySpecifiedType.h>
|
||||
@@ -100,7 +100,7 @@ void CppElementEvaluator::execute()
|
||||
return;
|
||||
|
||||
const Snapshot &snapshot = m_modelManager->snapshot();
|
||||
Document::Ptr doc = snapshot.document(m_editor->file()->fileName());
|
||||
Document::Ptr doc = snapshot.document(m_editor->editorDocument()->fileName());
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
#include <cpptools/insertionpointlocator.h>
|
||||
#include <cpptools/cpprefactoringchanges.h>
|
||||
#include <cppeditor/cppquickfix.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <TranslationUnit.h>
|
||||
#include <Symbol.h>
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <cplusplus/OverviewModel.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
@@ -108,10 +108,10 @@ QString CppEditorFactory::displayName() const
|
||||
return tr(CppEditor::Constants::CPPEDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IFile *CppEditorFactory::open(const QString &fileName)
|
||||
Core::IDocument *CppEditorFactory::open(const QString &fileName)
|
||||
{
|
||||
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
|
||||
return iface ? iface->file() : 0;
|
||||
return iface ? iface->document() : 0;
|
||||
}
|
||||
|
||||
Core::IEditor *CppEditorFactory::createEditor(QWidget *parent)
|
||||
|
@@ -121,7 +121,7 @@ public:
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
Core::IFile *open(const QString &fileName);
|
||||
Core::IDocument *open(const QString &fileName);
|
||||
|
||||
private:
|
||||
CppPlugin *m_owner;
|
||||
|
@@ -82,7 +82,7 @@ const CppQuickFixAssistInterface *CppQuickFixOperation::assistInterface() const
|
||||
|
||||
QString CppQuickFixOperation::fileName() const
|
||||
{
|
||||
return m_interface->file()->fileName();
|
||||
return m_interface->document()->fileName();
|
||||
}
|
||||
|
||||
CppQuickFixFactory::CppQuickFixFactory()
|
||||
|
@@ -101,7 +101,7 @@ const IAssistProvider *CppQuickFixAssistProcessor::provider() const
|
||||
// --------------------------
|
||||
CppQuickFixAssistInterface::CppQuickFixAssistInterface(CPPEditorWidget *editor,
|
||||
TextEditor::AssistReason reason)
|
||||
: DefaultAssistInterface(editor->document(), editor->position(), editor->file(), reason)
|
||||
: DefaultAssistInterface(editor->document(), editor->position(), editor->editorDocument(), reason)
|
||||
, m_editor(editor)
|
||||
, m_semanticInfo(editor->semanticInfo())
|
||||
, m_snapshot(CPlusPlus::CppModelManagerInterface::instance()->snapshot())
|
||||
|
@@ -56,7 +56,7 @@
|
||||
#include <cplusplus/BackwardsScanner.h>
|
||||
#include <cplusplus/LookupContext.h>
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
@@ -719,7 +719,7 @@ bool CppCompletionAssistProcessor::accepts() const
|
||||
const int start = startOfOperator(pos, &token, /*want function call=*/ true);
|
||||
if (start != pos) {
|
||||
if (token == T_POUND) {
|
||||
const int column = pos - m_interface->document()->findBlock(start).position();
|
||||
const int column = pos - m_interface->textDocument()->findBlock(start).position();
|
||||
if (column != 1)
|
||||
return false;
|
||||
}
|
||||
@@ -734,7 +734,7 @@ bool CppCompletionAssistProcessor::accepts() const
|
||||
const QChar firstCharacter = m_interface->characterAt(startOfName);
|
||||
if (firstCharacter.isLetter() || firstCharacter == QLatin1Char('_')) {
|
||||
// Finally check that we're not inside a comment or string (code copied from startOfOperator)
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
tc.setPosition(pos);
|
||||
|
||||
SimpleLexer tokenize;
|
||||
@@ -818,7 +818,7 @@ int CppCompletionAssistProcessor::startOfOperator(int pos,
|
||||
|
||||
int start = pos - activationSequenceChar(ch, ch2, ch3, kind, wantFunctionCall);
|
||||
if (start != pos) {
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
tc.setPosition(pos);
|
||||
|
||||
// Include completion: make sure the quote character is the first one on the line
|
||||
@@ -944,8 +944,8 @@ int CppCompletionAssistProcessor::startCompletionHelper()
|
||||
&m_model->m_completionOperator,
|
||||
/*want function call =*/ true);
|
||||
|
||||
const Core::IFile *file = m_interface->file();
|
||||
QString fileName = file->fileName();
|
||||
const Core::IDocument *document = m_interface->document();
|
||||
QString fileName = document->fileName();
|
||||
|
||||
if (m_model->m_completionOperator == T_DOXY_COMMENT) {
|
||||
for (int i = 1; i < T_DOXY_LAST_TAG; ++i)
|
||||
@@ -965,7 +965,7 @@ int CppCompletionAssistProcessor::startCompletionHelper()
|
||||
|| m_model->m_completionOperator == T_ANGLE_STRING_LITERAL
|
||||
|| m_model->m_completionOperator == T_SLASH) {
|
||||
|
||||
QTextCursor c(m_interface->document());
|
||||
QTextCursor c(m_interface->textDocument());
|
||||
c.setPosition(endOfExpression);
|
||||
if (completeInclude(c))
|
||||
m_startPosition = startOfName;
|
||||
@@ -973,7 +973,7 @@ int CppCompletionAssistProcessor::startCompletionHelper()
|
||||
}
|
||||
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
|
||||
if (m_model->m_completionOperator == T_COMMA) {
|
||||
tc.setPosition(endOfExpression);
|
||||
@@ -1017,7 +1017,7 @@ int CppCompletionAssistProcessor::startCompletionHelper()
|
||||
}
|
||||
|
||||
int line = 0, column = 0;
|
||||
Convenience::convertPosition(m_interface->document(), startOfExpression, &line, &column);
|
||||
Convenience::convertPosition(m_interface->textDocument(), startOfExpression, &line, &column);
|
||||
return startCompletionInternal(fileName, line, column, expression, endOfExpression);
|
||||
}
|
||||
|
||||
@@ -1029,7 +1029,7 @@ bool CppCompletionAssistProcessor::tryObjCCompletion()
|
||||
if (m_interface->characterAt(end) != QLatin1Char(']'))
|
||||
return false;
|
||||
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
tc.setPosition(end);
|
||||
BackwardsScanner tokens(tc);
|
||||
if (tokens[tokens.startToken() - 1].isNot(T_RBRACKET))
|
||||
@@ -1042,14 +1042,14 @@ bool CppCompletionAssistProcessor::tryObjCCompletion()
|
||||
const int startPos = tokens[start].begin() + tokens.startPosition();
|
||||
const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos);
|
||||
|
||||
Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->file()->fileName());
|
||||
Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->document()->fileName());
|
||||
if (! thisDocument)
|
||||
return false;
|
||||
|
||||
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
|
||||
|
||||
int line = 0, column = 0;
|
||||
Convenience::convertPosition(m_interface->document(), m_interface->position(), &line, &column);
|
||||
Convenience::convertPosition(m_interface->textDocument(), m_interface->position(), &line, &column);
|
||||
Scope *scope = thisDocument->scopeAt(line, column);
|
||||
if (!scope)
|
||||
return false;
|
||||
@@ -1171,7 +1171,7 @@ bool CppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
|
||||
|
||||
// Make completion for all relevant includes
|
||||
QStringList includePaths = m_interface->includePaths();
|
||||
const QString ¤tFilePath = QFileInfo(m_interface->file()->fileName()).path();
|
||||
const QString ¤tFilePath = QFileInfo(m_interface->document()->fileName()).path();
|
||||
if (!includePaths.contains(currentFilePath))
|
||||
includePaths.append(currentFilePath);
|
||||
|
||||
@@ -1232,8 +1232,8 @@ bool CppCompletionAssistProcessor::objcKeywordsWanted() const
|
||||
if (!m_objcEnabled)
|
||||
return false;
|
||||
|
||||
const Core::IFile *file = m_interface->file();
|
||||
QString fileName = file->fileName();
|
||||
const Core::IDocument *document = m_interface->document();
|
||||
QString fileName = document->fileName();
|
||||
|
||||
const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
|
||||
return mdb->findByFile(fileName).type() == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE;
|
||||
@@ -1291,7 +1291,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName
|
||||
--index;
|
||||
index = findStartOfName(index);
|
||||
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
tc.setPosition(index);
|
||||
|
||||
ExpressionUnderCursor expressionUnderCursor;
|
||||
@@ -1824,7 +1824,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
|
||||
|
||||
// get current line and column
|
||||
int lineSigned = 0, columnSigned = 0;
|
||||
Convenience::convertPosition(m_interface->document(), m_interface->position(), &lineSigned, &columnSigned);
|
||||
Convenience::convertPosition(m_interface->textDocument(), m_interface->position(), &lineSigned, &columnSigned);
|
||||
unsigned line = lineSigned, column = columnSigned;
|
||||
|
||||
// find a scope that encloses the current location, starting from the lastVisibileSymbol
|
||||
@@ -1837,7 +1837,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPl
|
||||
// declaration, we should be certain that it isn't.
|
||||
bool autocompleteSignature = false;
|
||||
|
||||
QTextCursor tc(m_interface->document());
|
||||
QTextCursor tc(m_interface->textDocument());
|
||||
tc.setPosition(endOfExpression);
|
||||
BackwardsScanner bs(tc);
|
||||
const int startToken = bs.startToken();
|
||||
|
@@ -145,14 +145,14 @@ private:
|
||||
class CppCompletionAssistInterface : public TextEditor::DefaultAssistInterface
|
||||
{
|
||||
public:
|
||||
CppCompletionAssistInterface(QTextDocument *document,
|
||||
CppCompletionAssistInterface(QTextDocument *textDocument,
|
||||
int position,
|
||||
Core::IFile *file,
|
||||
Core::IDocument *document,
|
||||
TextEditor::AssistReason reason,
|
||||
const CPlusPlus::Snapshot &snapshot,
|
||||
const QStringList &includePaths,
|
||||
const QStringList &frameworkPaths)
|
||||
: TextEditor::DefaultAssistInterface(document, position, file, reason)
|
||||
: TextEditor::DefaultAssistInterface(textDocument, position, document, reason)
|
||||
, m_snapshot(snapshot)
|
||||
, m_includePaths(includePaths)
|
||||
, m_frameworkPaths(frameworkPaths)
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "cppmodelmanager.h"
|
||||
#include "cpptoolseditorsupport.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <texteditor/codeassist/iassistinterface.h>
|
||||
|
||||
@@ -64,7 +64,7 @@ TextEditor::IAssistInterface *CppCompletionSupport::createAssistInterface(Projec
|
||||
return new CppTools::Internal::CppCompletionAssistInterface(
|
||||
document,
|
||||
position,
|
||||
m_editorSupport->textEditor()->file(),
|
||||
m_editorSupport->textEditor()->document(),
|
||||
reason,
|
||||
modelManager->snapshot(),
|
||||
includePaths,
|
||||
|
@@ -42,7 +42,7 @@ class QTextDocument;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class IFile;
|
||||
class IDocument;
|
||||
}
|
||||
|
||||
namespace ProjectExplorer {
|
||||
|
@@ -131,7 +131,7 @@ void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc)
|
||||
void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor * currentEditor)
|
||||
{
|
||||
if (currentEditor) {
|
||||
m_currentFileName = currentEditor->file()->fileName();
|
||||
m_currentFileName = currentEditor->document()->fileName();
|
||||
} else {
|
||||
m_currentFileName.clear();
|
||||
}
|
||||
@@ -141,7 +141,7 @@ void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor * currentEdi
|
||||
void CppCurrentDocumentFilter::onEditorAboutToClose(Core::IEditor * editorAboutToClose)
|
||||
{
|
||||
if (!editorAboutToClose) return;
|
||||
if (m_currentFileName == editorAboutToClose->file()->fileName()) {
|
||||
if (m_currentFileName == editorAboutToClose->document()->fileName()) {
|
||||
m_currentFileName.clear();
|
||||
m_itemsOfCurrentDoc.clear();
|
||||
}
|
||||
|
@@ -850,7 +850,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList()
|
||||
it.next();
|
||||
TextEditor::ITextEditor *textEditor = it.key();
|
||||
CppEditorSupport *editorSupport = it.value();
|
||||
QString fileName = textEditor->file()->fileName();
|
||||
QString fileName = textEditor->document()->fileName();
|
||||
workingCopy.insert(fileName, editorSupport->contents(), editorSupport->editorRevision());
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ void CppModelManager::updateEditor(Document::Ptr doc)
|
||||
|
||||
QList<Core::IEditor *> openedEditors = Core::ICore::editorManager()->openedEditors();
|
||||
foreach (Core::IEditor *editor, openedEditors) {
|
||||
if (editor->file()->fileName() == fileName) {
|
||||
if (editor->document()->fileName() == fileName) {
|
||||
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor *>(editor);
|
||||
if (! textEditor)
|
||||
continue;
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include "cpptoolseditorsupport.h"
|
||||
#include "cppmodelmanager.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/basetexteditor.h>
|
||||
@@ -137,7 +137,7 @@ void CppEditorSupport::updateDocumentNow()
|
||||
} else {
|
||||
_updateDocumentTimer->stop();
|
||||
|
||||
QStringList sourceFiles(_textEditor->file()->fileName());
|
||||
QStringList sourceFiles(_textEditor->document()->fileName());
|
||||
_cachedContents = _textEditor->contents().toUtf8();
|
||||
_documentParser = _modelManager->refreshSourceFiles(sourceFiles);
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/vcsmanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
|
||||
#include <QtConcurrentRun>
|
||||
@@ -112,7 +112,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
||||
Core::VcsManager *vcsManager = Core::ICore::vcsManager();
|
||||
connect(vcsManager, SIGNAL(repositoryChanged(QString)),
|
||||
m_modelManager, SLOT(updateModifiedSourceFiles()));
|
||||
connect(Core::FileManager::instance(), SIGNAL(filesChangedInternally(QStringList)),
|
||||
connect(Core::DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)),
|
||||
m_modelManager, SLOT(updateSourceFiles(QStringList)));
|
||||
addAutoReleasedObject(m_modelManager);
|
||||
|
||||
@@ -163,7 +163,7 @@ void CppToolsPlugin::switchHeaderSource()
|
||||
{
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
Core::IEditor *editor = editorManager->currentEditor();
|
||||
QString otherFile = correspondingHeaderOrSource(editor->file()->fileName());
|
||||
QString otherFile = correspondingHeaderOrSource(editor->document()->fileName());
|
||||
if (!otherFile.isEmpty())
|
||||
editorManager->openEditor(otherFile);
|
||||
}
|
||||
|
@@ -50,7 +50,7 @@
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
@@ -469,14 +469,14 @@ bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
|
||||
if (!isCommitEditorOpen())
|
||||
return true;
|
||||
|
||||
IFile *fileIFace = submitEditor->file();
|
||||
IDocument *editorDocument = submitEditor->document();
|
||||
const CvsSubmitEditor *editor = qobject_cast<CvsSubmitEditor *>(submitEditor);
|
||||
if (!fileIFace || !editor)
|
||||
if (!editorDocument || !editor)
|
||||
return true;
|
||||
|
||||
// Submit editor closing. Make it write out the commit message
|
||||
// and retrieve files
|
||||
const QFileInfo editorFile(fileIFace->fileName());
|
||||
const QFileInfo editorFile(editorDocument->fileName());
|
||||
const QFileInfo changeFile(m_commitMessageFileName);
|
||||
if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath())
|
||||
return true; // Oops?!
|
||||
@@ -504,7 +504,7 @@ bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor)
|
||||
bool closeEditor = true;
|
||||
if (!fileList.empty()) {
|
||||
// get message & commit
|
||||
closeEditor = FileManager::saveFile(fileIFace);
|
||||
closeEditor = DocumentManager::saveDocument(editorDocument);
|
||||
if (closeEditor)
|
||||
closeEditor = commit(m_commitMessageFileName, fileList);
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@
|
||||
#include "watchhandler.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <coreplugin/progressmanager/futureprogress.h>
|
||||
|
@@ -585,9 +585,9 @@ static bool currentTextEditorPosition(ContextData *data)
|
||||
TextEditor::ITextEditor *textEditor = currentTextEditor();
|
||||
if (!textEditor)
|
||||
return false;
|
||||
const Core::IFile *file = textEditor->file();
|
||||
QTC_ASSERT(file, return false);
|
||||
data->fileName = file->fileName();
|
||||
const Core::IDocument *document = textEditor->document();
|
||||
QTC_ASSERT(document, return false);
|
||||
data->fileName = document->fileName();
|
||||
if (textEditor->property("DisassemblerView").toBool()) {
|
||||
int lineNumber = textEditor->currentLine();
|
||||
QString line = textEditor->contents()
|
||||
@@ -1868,7 +1868,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor,
|
||||
bool contextUsable = true;
|
||||
|
||||
BreakpointModelId id = BreakpointModelId();
|
||||
const QString fileName = editor->file()->fileName();
|
||||
const QString fileName = editor->document()->fileName();
|
||||
if (editor->property("DisassemblerView").toBool()) {
|
||||
args.fileName = fileName;
|
||||
QString line = editor->contents()
|
||||
@@ -1881,7 +1881,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor,
|
||||
id = breakHandler()->findSimilarBreakpoint(needle);
|
||||
contextUsable = args.address != 0;
|
||||
} else {
|
||||
args.fileName = editor->file()->fileName();
|
||||
args.fileName = editor->document()->fileName();
|
||||
id = breakHandler()
|
||||
->findBreakpointByFileAndLine(args.fileName, lineNumber);
|
||||
if (!id)
|
||||
@@ -1989,7 +1989,7 @@ void DebuggerPluginPrivate::toggleBreakpoint()
|
||||
quint64 address = DisassemblerLine::addressFromDisassemblyLine(line);
|
||||
toggleBreakpointByAddress(address);
|
||||
} else if (lineNumber >= 0) {
|
||||
toggleBreakpointByFileAndLine(textEditor->file()->fileName(), lineNumber);
|
||||
toggleBreakpointByFileAndLine(textEditor->document()->fileName(), lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2043,8 +2043,8 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor,
|
||||
.section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1);
|
||||
quint64 address = DisassemblerLine::addressFromDisassemblyLine(line);
|
||||
toggleBreakpointByAddress(address);
|
||||
} else if (editor->file()) {
|
||||
toggleBreakpointByFileAndLine(editor->file()->fileName(), lineNumber);
|
||||
} else if (editor->document()) {
|
||||
toggleBreakpointByFileAndLine(editor->document()->fileName(), lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2146,7 +2146,7 @@ void DebuggerPluginPrivate::cleanupViews()
|
||||
// Close disassembly views. Close other opened files
|
||||
// if they are not modified and not current editor.
|
||||
if (editor->property(Constants::OPENED_WITH_DISASSEMBLY).toBool()
|
||||
|| (!editor->file()->isModified()
|
||||
|| (!editor->document()->isModified()
|
||||
&& editor != editorManager->currentEditor())) {
|
||||
toClose.append(editor);
|
||||
} else {
|
||||
@@ -3659,7 +3659,7 @@ void DebuggerPluginPrivate::testProjectLoaded(Project *project)
|
||||
disconnect(pe, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)),
|
||||
this, SLOT(testProjectLoaded(ProjectExplorer::Project*)));
|
||||
|
||||
QString fileName = project->file()->fileName();
|
||||
QString fileName = project->document()->fileName();
|
||||
QVERIFY(!fileName.isEmpty());
|
||||
qWarning("Project %s loaded", qPrintable(fileName));
|
||||
|
||||
|
@@ -210,26 +210,26 @@ class DebuggerToolTipEditor
|
||||
{
|
||||
public:
|
||||
explicit DebuggerToolTipEditor(IEditor *ie = 0);
|
||||
bool isValid() const { return textEditor && baseTextEditor && file; }
|
||||
bool isValid() const { return textEditor && baseTextEditor && document; }
|
||||
operator bool() const { return isValid(); }
|
||||
QString fileName() const { return file ? file->fileName() : QString(); }
|
||||
QString fileName() const { return document ? document->fileName() : QString(); }
|
||||
|
||||
static DebuggerToolTipEditor currentToolTipEditor();
|
||||
|
||||
ITextEditor *textEditor;
|
||||
BaseTextEditorWidget *baseTextEditor;
|
||||
IFile *file;
|
||||
IDocument *document;
|
||||
};
|
||||
|
||||
DebuggerToolTipEditor::DebuggerToolTipEditor(IEditor *ie) :
|
||||
textEditor(0), baseTextEditor(0), file(0)
|
||||
textEditor(0), baseTextEditor(0), document(0)
|
||||
{
|
||||
if (ie && ie->file() && isEditorDebuggable(ie)) {
|
||||
if (ie && ie->document() && isEditorDebuggable(ie)) {
|
||||
if (ITextEditor *te = qobject_cast<ITextEditor *>(ie)) {
|
||||
if (BaseTextEditorWidget *pe = qobject_cast<BaseTextEditorWidget *>(ie->widget())) {
|
||||
textEditor = te;
|
||||
baseTextEditor = pe;
|
||||
file = ie->file();
|
||||
document = ie->document();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -552,9 +552,9 @@ DebuggerToolTipContext::DebuggerToolTipContext() : position(0), line(0), column(
|
||||
DebuggerToolTipContext DebuggerToolTipContext::fromEditor(IEditor *ie, int pos)
|
||||
{
|
||||
DebuggerToolTipContext rc;
|
||||
if (const IFile *file = ie->file()) {
|
||||
if (const IDocument *document = ie->document()) {
|
||||
if (const ITextEditor *te = qobject_cast<const ITextEditor *>(ie)) {
|
||||
rc.fileName = file->fileName();
|
||||
rc.fileName = document->fileName();
|
||||
rc.position = pos;
|
||||
te->convertPosition(pos, &rc.line, &rc.column);
|
||||
}
|
||||
|
@@ -251,7 +251,7 @@ void DisassemblerAgentPrivate::configureMimeType()
|
||||
QTC_ASSERT(editor, return);
|
||||
|
||||
TextEditor::BaseTextDocument *doc =
|
||||
qobject_cast<TextEditor::BaseTextDocument *>(editor->file());
|
||||
qobject_cast<TextEditor::BaseTextDocument *>(editor->document());
|
||||
QTC_ASSERT(doc, return);
|
||||
doc->setMimeType(mimeType);
|
||||
|
||||
|
@@ -71,7 +71,7 @@
|
||||
#include "logwindow.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <projectexplorer/abi.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
|
@@ -54,7 +54,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -466,7 +466,7 @@ bool PdbEngine::setToolTipExpression(const QPoint &mousePos,
|
||||
// Check mime type and get expression (borrowing some C++ - functions)
|
||||
const QString javaPythonMimeType =
|
||||
QLatin1String("application/javascript");
|
||||
if (!editor->file() || editor->file()->mimeType() != javaPythonMimeType)
|
||||
if (!editor->document() || editor->document()->mimeType() != javaPythonMimeType)
|
||||
return false;
|
||||
|
||||
int line;
|
||||
|
@@ -1988,7 +1988,7 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber,
|
||||
errorFormat.setUnderlineColor(Qt::red);
|
||||
|
||||
foreach (IEditor *editor, openedEditors) {
|
||||
if (editor->file()->fileName() == filePath) {
|
||||
if (editor->document()->fileName() == filePath) {
|
||||
TextEditor::BaseTextEditorWidget *ed = qobject_cast<TextEditor::BaseTextEditorWidget *>(editor->widget());
|
||||
if (!ed)
|
||||
continue;
|
||||
|
@@ -50,7 +50,7 @@
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/scriptmanager/scriptmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
@@ -522,7 +522,7 @@ bool ScriptEngine::setToolTipExpression(const QPoint &mousePos,
|
||||
// Check mime type and get expression (borrowing some C++ - functions)
|
||||
const QString javaScriptMimeType =
|
||||
QLatin1String("application/javascript");
|
||||
if (!editor->file() || editor->file()->mimeType() != javaScriptMimeType)
|
||||
if (!editor->document() || editor->document()->mimeType() != javaScriptMimeType)
|
||||
return false;
|
||||
|
||||
int line;
|
||||
|
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <texteditor/basetexteditor.h>
|
||||
#include <texteditor/basetextmark.h>
|
||||
@@ -151,7 +151,7 @@ bool isEditorDebuggable(Core::IEditor *editor)
|
||||
{
|
||||
// Only blacklist Qml. Whitelisting would fail on C++ code in files
|
||||
// with strange names, more harm would be done this way.
|
||||
// IFile *file = editor->file();
|
||||
// IDocument *file = editor->document();
|
||||
// return !(file && file->mimeType() == "application/x-qml");
|
||||
// Nowadays, even Qml is debuggable.
|
||||
return editor;
|
||||
@@ -442,9 +442,9 @@ bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot,
|
||||
|
||||
QByteArray gdbQuoteTypes(const QByteArray &type)
|
||||
{
|
||||
// gdb does not understand sizeof(Core::IFile*).
|
||||
// "sizeof('Core::IFile*')" is also not acceptable,
|
||||
// it needs to be "sizeof('Core::IFile'*)"
|
||||
// gdb does not understand sizeof(Core::IDocument*).
|
||||
// "sizeof('Core::IDocument*')" is also not acceptable,
|
||||
// it needs to be "sizeof('Core::IDocument'*)"
|
||||
//
|
||||
// We never will have a perfect solution here (even if we had a full blown
|
||||
// C++ parser as we do not have information on what is a type and what is
|
||||
@@ -647,10 +647,10 @@ QString decodeData(const QByteArray &ba, int encoding)
|
||||
bool isCppEditor(Core::IEditor *editor)
|
||||
{
|
||||
using namespace CppTools::Constants;
|
||||
const Core::IFile *file = editor->file();
|
||||
if (!file)
|
||||
const Core::IDocument *document= editor->document();
|
||||
if (!document)
|
||||
return false;
|
||||
const QByteArray mimeType = file->mimeType().toLatin1();
|
||||
const QByteArray mimeType = document->mimeType().toLatin1();
|
||||
return mimeType == C_SOURCE_MIMETYPE
|
||||
|| mimeType == CPP_SOURCE_MIMETYPE
|
||||
|| mimeType == CPP_HEADER_MIMETYPE
|
||||
@@ -693,10 +693,10 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos,
|
||||
}
|
||||
|
||||
if (function && !expr.isEmpty())
|
||||
if (const Core::IFile *file = editor->file())
|
||||
if (const Core::IDocument *document= editor->document())
|
||||
if (modelManager)
|
||||
*function = AbstractEditorSupport::functionAt(modelManager,
|
||||
file->fileName(), *line, *column);
|
||||
document->fileName(), *line, *column);
|
||||
|
||||
return expr;
|
||||
}
|
||||
|
@@ -71,7 +71,7 @@ QString FormEditorFactory::displayName() const
|
||||
return tr(C_DESIGNER_XML_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IFile *FormEditorFactory::open(const QString &fileName)
|
||||
Core::IDocument *FormEditorFactory::open(const QString &fileName)
|
||||
{
|
||||
Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id());
|
||||
if (!iface)
|
||||
@@ -80,9 +80,9 @@ Core::IFile *FormEditorFactory::open(const QString &fileName)
|
||||
Core::InfoBarEntry info(QLatin1String(Constants::INFO_READ_ONLY),
|
||||
tr("This file can only be edited in <b>Design</b> mode."));
|
||||
info.setCustomButtonInfo(tr("Switch mode"), this, SLOT(designerModeClicked()));
|
||||
iface->file()->infoBar()->addInfo(info);
|
||||
iface->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
return iface->file();
|
||||
return iface->document();
|
||||
}
|
||||
|
||||
Core::IEditor *FormEditorFactory::createEditor(QWidget *parent)
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
QStringList mimeTypes() const;
|
||||
Core::Id id() const;
|
||||
QString displayName() const;
|
||||
Core::IFile *open(const QString &fileName);
|
||||
Core::IDocument *open(const QString &fileName);
|
||||
Core::IEditor *createEditor(QWidget *parent);
|
||||
|
||||
private slots:
|
||||
|
@@ -757,7 +757,7 @@ EditorData FormEditorW::createEditor(QWidget *parent)
|
||||
data.formWindowEditor = xmlEditor->designerEditor();
|
||||
connect(data.widgetHost, SIGNAL(formWindowSizeChanged(int,int)),
|
||||
xmlEditor, SIGNAL(changed()));
|
||||
connect(data.formWindowEditor->file(), SIGNAL(changed()),
|
||||
connect(data.formWindowEditor->document(), SIGNAL(changed()),
|
||||
resourceHandler, SLOT(updateResources()));
|
||||
m_editorWidget->add(data);
|
||||
|
||||
@@ -907,8 +907,8 @@ void FormEditorW::print()
|
||||
static QString currentFile()
|
||||
{
|
||||
if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor())
|
||||
if (const Core::IFile *file = editor->file()) {
|
||||
const QString fileName = file->fileName();
|
||||
if (const Core::IDocument *document= editor->document()) {
|
||||
const QString fileName = document->fileName();
|
||||
if (!fileName.isEmpty() && QFileInfo(fileName).isFile())
|
||||
return fileName;
|
||||
}
|
||||
|
@@ -201,10 +201,10 @@ void FormWindowEditor::syncXmlEditor(const QString &contents)
|
||||
d->m_textEditor.editorWidget()->setPlainText(contents);
|
||||
d->m_textEditor.editorWidget()->setReadOnly(true);
|
||||
static_cast<TextEditor::PlainTextEditorWidget *>
|
||||
(d->m_textEditor.editorWidget())->configure(file()->mimeType());
|
||||
(d->m_textEditor.editorWidget())->configure(document()->mimeType());
|
||||
}
|
||||
|
||||
Core::IFile *FormWindowEditor::file()
|
||||
Core::IDocument *FormWindowEditor::document()
|
||||
{
|
||||
return &d->m_file;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ QString FormWindowEditor::contents() const
|
||||
|
||||
TextEditor::BaseTextDocument *FormWindowEditor::textDocument()
|
||||
{
|
||||
return qobject_cast<TextEditor::BaseTextDocument*>(d->m_textEditor.file());
|
||||
return qobject_cast<TextEditor::BaseTextDocument*>(d->m_textEditor.document());
|
||||
}
|
||||
|
||||
TextEditor::PlainTextEditor *FormWindowEditor::textEditor()
|
||||
|
@@ -53,7 +53,7 @@ namespace Internal {
|
||||
struct FormWindowEditorPrivate;
|
||||
|
||||
// The actual Core::IEditor belonging to Qt Designer. Uses FormWindowFile
|
||||
// as the Core::IFile to do the isModified() handling,
|
||||
// as the Core::IDocument to do the isModified() handling,
|
||||
// which needs to be done by Qt Designer.
|
||||
// However, to make the read-only XML text editor work,
|
||||
// a TextEditor::PlainTextEditorEditable (IEditor) is also required.
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
// IEditor
|
||||
virtual bool createNew(const QString &contents = QString());
|
||||
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
|
||||
virtual Core::IFile *file();
|
||||
virtual Core::IDocument *document();
|
||||
virtual Core::Id id() const;
|
||||
virtual QString displayName() const;
|
||||
virtual void setDisplayName(const QString &title);
|
||||
|
@@ -59,7 +59,7 @@ namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent)
|
||||
: Core::TextFile(parent),
|
||||
: Core::TextDocument(parent),
|
||||
m_mimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE)),
|
||||
m_shouldAutoSave(false),
|
||||
m_formWindow(form)
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#ifndef FORMWINDOWFILE_H
|
||||
#define FORMWINDOWFILE_H
|
||||
|
||||
#include <coreplugin/textfile.h>
|
||||
#include <coreplugin/textdocument.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
@@ -45,14 +45,14 @@ QT_END_NAMESPACE
|
||||
namespace Designer {
|
||||
namespace Internal {
|
||||
|
||||
class FormWindowFile : public Core::TextFile
|
||||
class FormWindowFile : public Core::TextDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent = 0);
|
||||
|
||||
// IFile
|
||||
// IDocument
|
||||
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
|
||||
virtual QString fileName() const;
|
||||
virtual bool shouldAutoSave() const;
|
||||
|
@@ -534,7 +534,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
|
||||
|
||||
const EditorData ed = m_few->activeEditor();
|
||||
QTC_ASSERT(ed, return false)
|
||||
const QString currentUiFile = ed.formWindowEditor->file()->fileName();
|
||||
const QString currentUiFile = ed.formWindowEditor->document()->fileName();
|
||||
#if 0
|
||||
return Designer::Internal::navigateToSlot(currentUiFile, objectName, signalSignature, parameterNames, errorMessage);
|
||||
#endif
|
||||
|
@@ -44,9 +44,9 @@
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/openeditorsmodel.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/statusbarwidget.h>
|
||||
@@ -726,7 +726,7 @@ public:
|
||||
|
||||
const int basePosition = interface->position() - needle.size();
|
||||
|
||||
QTextCursor tc(interface->document());
|
||||
QTextCursor tc(interface->textDocument());
|
||||
tc.setPosition(interface->position());
|
||||
tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor);
|
||||
|
||||
@@ -1388,7 +1388,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||
connect(ICore::instance(), SIGNAL(saveSettingsRequested()),
|
||||
SLOT(writeSettings()));
|
||||
|
||||
handler->setCurrentFileName(editor->file()->fileName());
|
||||
handler->setCurrentFileName(editor->document()->fileName());
|
||||
handler->installEventFilter();
|
||||
|
||||
// pop up the bar
|
||||
@@ -1495,9 +1495,9 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd)
|
||||
// :w[rite]
|
||||
Core::IEditor *editor = m_editorToHandler.key(handler);
|
||||
const QString fileName = handler->currentFileName();
|
||||
if (editor && editor->file()->fileName() == fileName) {
|
||||
if (editor && editor->document()->fileName() == fileName) {
|
||||
// Handle that as a special case for nicer interaction with core
|
||||
FileManager::saveFile(editor->file());
|
||||
DocumentManager::saveDocument(editor->document());
|
||||
// Check result by reading back.
|
||||
QFile file3(fileName);
|
||||
file3.open(QIODevice::ReadOnly);
|
||||
@@ -1512,8 +1512,8 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd)
|
||||
}
|
||||
} else if (cmd.matches("wa", "wall")) {
|
||||
// :w[all]
|
||||
QList<IFile *> toSave = FileManager::modifiedFiles();
|
||||
QList<IFile *> failed = FileManager::saveModifiedFilesSilently(toSave);
|
||||
QList<IDocument *> toSave = DocumentManager::modifiedDocuments();
|
||||
QList<IDocument *> failed = DocumentManager::saveModifiedDocumentsSilently(toSave);
|
||||
if (failed.isEmpty())
|
||||
handler->showBlackMessage(tr("Saving succeeded"));
|
||||
else
|
||||
|
@@ -49,7 +49,7 @@
|
||||
#include <utils/fileutils.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QProcessEnvironment>
|
||||
@@ -86,17 +86,17 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName)
|
||||
m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath();
|
||||
m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath();
|
||||
|
||||
m_creatorIFile = new GenericProjectFile(this, m_fileName, GenericProject::Everything);
|
||||
m_filesIFile = new GenericProjectFile(this, m_filesFileName, GenericProject::Files);
|
||||
m_includesIFile = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration);
|
||||
m_configIFile = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration);
|
||||
m_creatorIDocument = new GenericProjectFile(this, m_fileName, GenericProject::Everything);
|
||||
m_filesIDocument = new GenericProjectFile(this, m_filesFileName, GenericProject::Files);
|
||||
m_includesIDocument = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration);
|
||||
m_configIDocument = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration);
|
||||
|
||||
Core::FileManager::addFile(m_creatorIFile);
|
||||
Core::FileManager::addFile(m_filesIFile);
|
||||
Core::FileManager::addFile(m_includesIFile);
|
||||
Core::FileManager::addFile(m_configIFile);
|
||||
Core::DocumentManager::addDocument(m_creatorIDocument);
|
||||
Core::DocumentManager::addDocument(m_filesIDocument);
|
||||
Core::DocumentManager::addDocument(m_includesIDocument);
|
||||
Core::DocumentManager::addDocument(m_configIDocument);
|
||||
|
||||
m_rootNode = new GenericProjectNode(this, m_creatorIFile);
|
||||
m_rootNode = new GenericProjectNode(this, m_creatorIDocument);
|
||||
|
||||
m_manager->registerProject(this);
|
||||
}
|
||||
@@ -420,9 +420,9 @@ QString GenericProject::id() const
|
||||
return QLatin1String(Constants::GENERICPROJECT_ID);
|
||||
}
|
||||
|
||||
Core::IFile *GenericProject::file() const
|
||||
Core::IDocument *GenericProject::document() const
|
||||
{
|
||||
return m_creatorIFile;
|
||||
return m_creatorIDocument;
|
||||
}
|
||||
|
||||
IProjectManager *GenericProject::projectManager() const
|
||||
@@ -605,7 +605,7 @@ void GenericBuildSettingsWidget::updateToolChainList()
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options)
|
||||
: Core::IFile(parent),
|
||||
: Core::IDocument(parent),
|
||||
m_project(parent),
|
||||
m_fileName(fileName),
|
||||
m_options(options)
|
||||
@@ -656,7 +656,7 @@ void GenericProjectFile::rename(const QString &newName)
|
||||
QTC_CHECK(false);
|
||||
}
|
||||
|
||||
Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
Core::IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
{
|
||||
Q_UNUSED(state)
|
||||
Q_UNUSED(type)
|
||||
|
@@ -43,7 +43,7 @@
|
||||
#include <projectexplorer/toolchain.h>
|
||||
#include <projectexplorer/buildstep.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QFuture>
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
|
||||
QString displayName() const;
|
||||
QString id() const;
|
||||
Core::IFile *file() const;
|
||||
Core::IDocument *document() const;
|
||||
ProjectExplorer::IProjectManager *projectManager() const;
|
||||
GenericTarget *activeTarget() const;
|
||||
|
||||
@@ -139,10 +139,10 @@ private:
|
||||
QString m_includesFileName;
|
||||
QString m_configFileName;
|
||||
QString m_projectName;
|
||||
GenericProjectFile *m_creatorIFile;
|
||||
GenericProjectFile *m_filesIFile;
|
||||
GenericProjectFile *m_includesIFile;
|
||||
GenericProjectFile *m_configIFile;
|
||||
GenericProjectFile *m_creatorIDocument;
|
||||
GenericProjectFile *m_filesIDocument;
|
||||
GenericProjectFile *m_includesIDocument;
|
||||
GenericProjectFile *m_configIDocument;
|
||||
QStringList m_rawFileList;
|
||||
QStringList m_files;
|
||||
QHash<QString, QString> m_rawListEntries;
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
QFuture<void> m_codeModelFuture;
|
||||
};
|
||||
|
||||
class GenericProjectFile : public Core::IFile
|
||||
class GenericProjectFile : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@@ -79,12 +79,12 @@ QString ProjectFilesFactory::displayName() const
|
||||
return tr(Constants::FILES_EDITOR_DISPLAY_NAME);
|
||||
}
|
||||
|
||||
Core::IFile *ProjectFilesFactory::open(const QString &fileName)
|
||||
Core::IDocument *ProjectFilesFactory::open(const QString &fileName)
|
||||
{
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
|
||||
if (Core::IEditor *editor = editorManager->openEditor(fileName, id()))
|
||||
return editor->file();
|
||||
return editor->document();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ public:
|
||||
virtual QStringList mimeTypes() const;
|
||||
virtual Core::Id id() const;
|
||||
virtual QString displayName() const;
|
||||
virtual Core::IFile *open(const QString &fileName);
|
||||
virtual Core::IDocument *open(const QString &fileName);
|
||||
|
||||
private:
|
||||
TextEditor::TextEditorActionHandler *m_actionHandler;
|
||||
|
@@ -58,7 +58,7 @@ ProjectExplorer::Project *Manager::openProject(const QString &fileName, QString
|
||||
|
||||
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
|
||||
foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) {
|
||||
if (fileName == pi->file()->fileName()) {
|
||||
if (fileName == pi->document()->fileName()) {
|
||||
if (errorString)
|
||||
*errorString = tr("Failed opening project '%1': Project already open")
|
||||
.arg(QDir::toNativeSeparators(fileName));
|
||||
|
@@ -33,7 +33,7 @@
|
||||
#include "genericprojectnodes.h"
|
||||
#include "genericproject.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
@@ -41,7 +41,7 @@
|
||||
using namespace GenericProjectManager;
|
||||
using namespace GenericProjectManager::Internal;
|
||||
|
||||
GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *projectFile)
|
||||
GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IDocument *projectFile)
|
||||
: ProjectExplorer::ProjectNode(projectFile->fileName()),
|
||||
m_project(project),
|
||||
m_projectFile(projectFile)
|
||||
@@ -49,7 +49,7 @@ GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *pro
|
||||
setDisplayName(QFileInfo(projectFile->fileName()).completeBaseName());
|
||||
}
|
||||
|
||||
Core::IFile *GenericProjectNode::projectFile() const
|
||||
Core::IDocument *GenericProjectNode::projectFile() const
|
||||
{
|
||||
return m_projectFile;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@
|
||||
#include <QHash>
|
||||
|
||||
namespace Core {
|
||||
class IFile;
|
||||
class IDocument;
|
||||
}
|
||||
|
||||
namespace GenericProjectManager {
|
||||
@@ -50,9 +50,9 @@ class GenericProject;
|
||||
class GenericProjectNode : public ProjectExplorer::ProjectNode
|
||||
{
|
||||
public:
|
||||
GenericProjectNode(GenericProject *project, Core::IFile *projectFile);
|
||||
GenericProjectNode(GenericProject *project, Core::IDocument *projectFile);
|
||||
|
||||
Core::IFile *projectFile() const;
|
||||
Core::IDocument *projectFile() const;
|
||||
QString projectFilePath() const;
|
||||
|
||||
virtual bool hasBuildTargets() const;
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
|
||||
private:
|
||||
GenericProject *m_project;
|
||||
Core::IFile *m_projectFile;
|
||||
Core::IDocument *m_projectFile;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user