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