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:
@@ -38,7 +38,7 @@
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
#include "coreconstants.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "id.h"
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ SOURCES += mainwindow.cpp \
|
||||
fancyactionbar.cpp \
|
||||
fancytabwidget.cpp \
|
||||
generalsettings.cpp \
|
||||
filemanager.cpp \
|
||||
id.cpp \
|
||||
messagemanager.cpp \
|
||||
messageoutputwindow.cpp \
|
||||
@@ -71,7 +70,6 @@ SOURCES += mainwindow.cpp \
|
||||
fileiconprovider.cpp \
|
||||
mimedatabase.cpp \
|
||||
icore.cpp \
|
||||
ifile.cpp \
|
||||
infobar.cpp \
|
||||
editormanager/ieditor.cpp \
|
||||
dialogs/ioptionspage.cpp \
|
||||
@@ -94,8 +92,10 @@ SOURCES += mainwindow.cpp \
|
||||
mimetypesettings.cpp \
|
||||
dialogs/promptoverwritedialog.cpp \
|
||||
fileutils.cpp \
|
||||
textfile.cpp \
|
||||
featureprovider.cpp
|
||||
featureprovider.cpp \
|
||||
idocument.cpp \
|
||||
textdocument.cpp \
|
||||
documentmanager.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
editmode.h \
|
||||
@@ -103,7 +103,6 @@ HEADERS += mainwindow.h \
|
||||
fancyactionbar.h \
|
||||
fancytabwidget.h \
|
||||
generalsettings.h \
|
||||
filemanager.h \
|
||||
id.h \
|
||||
messagemanager.h \
|
||||
messageoutputwindow.h \
|
||||
@@ -141,9 +140,7 @@ HEADERS += mainwindow.h \
|
||||
progressmanager/progressmanager.h \
|
||||
icontext.h \
|
||||
icore.h \
|
||||
ifile.h \
|
||||
infobar.h \
|
||||
ifilefactory.h \
|
||||
imode.h \
|
||||
ioutputpane.h \
|
||||
coreconstants.h \
|
||||
@@ -190,9 +187,12 @@ HEADERS += mainwindow.h \
|
||||
dialogs/promptoverwritedialog.h \
|
||||
fileutils.h \
|
||||
externaltoolmanager.h \
|
||||
textfile.h \
|
||||
generatedfile.h \
|
||||
featureprovider.h
|
||||
featureprovider.h \
|
||||
idocument.h \
|
||||
idocumentfactory.h \
|
||||
textdocument.h \
|
||||
documentmanager.h
|
||||
|
||||
FORMS += dialogs/newdialog.ui \
|
||||
actionmanager/commandmappings.ui \
|
||||
|
||||
@@ -213,8 +213,8 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
|
||||
|
||||
bool mimeEditorAvailable = false;
|
||||
|
||||
if (editor && editor->file()) {
|
||||
const QString mimeType = editor->file()->mimeType();
|
||||
if (editor && editor->document()) {
|
||||
const QString mimeType = editor->document()->mimeType();
|
||||
if (!mimeType.isEmpty()) {
|
||||
foreach (DesignEditorInfo *editorInfo, d->m_editors) {
|
||||
foreach (const QString &mime, editorInfo->mimeTypes) {
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "mainwindow.h"
|
||||
#include "vcsmanager.h"
|
||||
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
@@ -43,13 +43,13 @@
|
||||
#include <QHeaderView>
|
||||
#include <QCheckBox>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::IFile*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
||||
SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
QList<IFile *> items)
|
||||
QList<IDocument *> items)
|
||||
: QDialog(parent)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
@@ -61,12 +61,12 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
|
||||
m_ui.saveBeforeBuildCheckBox->setVisible(false);
|
||||
|
||||
foreach (IFile *file, items) {
|
||||
foreach (IDocument *document, items) {
|
||||
QString visibleName;
|
||||
QString directory;
|
||||
QString fileName = file->fileName();
|
||||
QString fileName = document->fileName();
|
||||
if (fileName.isEmpty()) {
|
||||
visibleName = file->suggestedFileName();
|
||||
visibleName = document->suggestedFileName();
|
||||
} else {
|
||||
QFileInfo info = QFileInfo(fileName);
|
||||
directory = info.absolutePath();
|
||||
@@ -74,7 +74,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
|
||||
}
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList()
|
||||
<< visibleName << QDir::toNativeSeparators(directory));
|
||||
item->setData(0, Qt::UserRole, qVariantFromValue(file));
|
||||
item->setData(0, Qt::UserRole, qVariantFromValue(document));
|
||||
}
|
||||
|
||||
m_ui.treeWidget->resizeColumnToContents(0);
|
||||
@@ -112,7 +112,7 @@ void SaveItemsDialog::collectItemsToSave()
|
||||
{
|
||||
m_itemsToSave.clear();
|
||||
foreach (QTreeWidgetItem *item, m_ui.treeWidget->selectedItems()) {
|
||||
m_itemsToSave.append(item->data(0, Qt::UserRole).value<IFile*>());
|
||||
m_itemsToSave.append(item->data(0, Qt::UserRole).value<IDocument*>());
|
||||
}
|
||||
accept();
|
||||
}
|
||||
@@ -123,7 +123,7 @@ void SaveItemsDialog::discardAll()
|
||||
collectItemsToSave();
|
||||
}
|
||||
|
||||
QList<IFile*> SaveItemsDialog::itemsToSave() const
|
||||
QList<IDocument*> SaveItemsDialog::itemsToSave() const
|
||||
{
|
||||
return m_itemsToSave;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class EditorManager;
|
||||
|
||||
namespace Internal {
|
||||
@@ -57,12 +57,12 @@ class SaveItemsDialog : public QDialog
|
||||
|
||||
public:
|
||||
SaveItemsDialog(QWidget *parent,
|
||||
QList<Core::IFile *> items);
|
||||
QList<Core::IDocument *> items);
|
||||
|
||||
void setMessage(const QString &msg);
|
||||
void setAlwaysSaveMessage(const QString &msg);
|
||||
bool alwaysSaveChecked();
|
||||
QList<Core::IFile *> itemsToSave() const;
|
||||
QList<Core::IDocument *> itemsToSave() const;
|
||||
|
||||
private slots:
|
||||
void collectItemsToSave();
|
||||
@@ -71,7 +71,7 @@ private slots:
|
||||
|
||||
private:
|
||||
Ui::SaveItemsDialog m_ui;
|
||||
QList<Core::IFile*> m_itemsToSave;
|
||||
QList<Core::IDocument*> m_itemsToSave;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "command_p.h"
|
||||
#include "commandsfile.h"
|
||||
#include "coreconstants.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "id.h"
|
||||
|
||||
@@ -266,7 +266,7 @@ void ShortcutSettings::defaultAction()
|
||||
|
||||
void ShortcutSettings::exportAction()
|
||||
{
|
||||
QString fileName = FileManager::getSaveFileNameWithExtension(
|
||||
QString fileName = DocumentManager::getSaveFileNameWithExtension(
|
||||
tr("Export Keyboard Mapping Scheme"),
|
||||
ICore::resourcePath() + QLatin1String("/schemes/"),
|
||||
tr("Keyboard Mapping Scheme (*.kms)"));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef FILEMANAGER_H
|
||||
#define FILEMANAGER_H
|
||||
#ifndef DOCUMENTMANAGER_H
|
||||
#define DOCUMENTMANAGER_H
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
@@ -49,10 +49,10 @@ QT_END_NAMESPACE
|
||||
namespace Core {
|
||||
|
||||
class IContext;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IVersionControl;
|
||||
|
||||
class CORE_EXPORT FileManager : public QObject
|
||||
class CORE_EXPORT DocumentManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@@ -63,16 +63,16 @@ public:
|
||||
|
||||
typedef QPair<QString, Id> RecentFile;
|
||||
|
||||
explicit FileManager(QMainWindow *ew);
|
||||
virtual ~FileManager();
|
||||
explicit DocumentManager(QMainWindow *ew);
|
||||
virtual ~DocumentManager();
|
||||
|
||||
static FileManager *instance();
|
||||
static DocumentManager *instance();
|
||||
|
||||
// file pool to monitor
|
||||
static void addFiles(const QList<IFile *> &files, bool addWatcher = true);
|
||||
static void addFile(IFile *file, bool addWatcher = true);
|
||||
static bool removeFile(IFile *file);
|
||||
static QList<IFile *> modifiedFiles();
|
||||
static void addDocuments(const QList<IDocument *> &documents, bool addWatcher = true);
|
||||
static void addDocument(IDocument *document, bool addWatcher = true);
|
||||
static bool removeDocument(IDocument *document);
|
||||
static QList<IDocument *> modifiedDocuments();
|
||||
|
||||
static void renamedFile(const QString &from, const QString &to);
|
||||
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
// helper methods
|
||||
static QString fixFileName(const QString &fileName, FixMode fixmode);
|
||||
|
||||
static bool saveFile(IFile *file, const QString &fileName = QString(), bool *isReadOnly = 0);
|
||||
static bool saveDocument(IDocument *document, const QString &fileName = QString(), bool *isReadOnly = 0);
|
||||
|
||||
static QStringList getOpenFileNames(const QString &filters,
|
||||
const QString path = QString(),
|
||||
@@ -102,11 +102,11 @@ public:
|
||||
const QString &filter = QString(), QString *selectedFilter = 0);
|
||||
static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
|
||||
const QString &filter);
|
||||
static QString getSaveAsFileName(IFile *file, const QString &filter = QString(),
|
||||
static QString getSaveAsFileName(IDocument *document, const QString &filter = QString(),
|
||||
QString *selectedFilter = 0);
|
||||
|
||||
static QList<IFile *> saveModifiedFilesSilently(const QList<IFile *> &files, bool *cancelled = 0);
|
||||
static QList<IFile *> saveModifiedFiles(const QList<IFile *> &files,
|
||||
static QList<IDocument *> saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *cancelled = 0);
|
||||
static QList<IDocument *> saveModifiedDocuments(const QList<IDocument *> &documents,
|
||||
bool *cancelled = 0,
|
||||
const QString &message = QString(),
|
||||
const QString &alwaysSaveMessage = QString(),
|
||||
@@ -150,7 +150,7 @@ signals:
|
||||
void filesChangedInternally(const QStringList &files);
|
||||
|
||||
private slots:
|
||||
void fileDestroyed(QObject *obj);
|
||||
void documentDestroyed(QObject *obj);
|
||||
void checkForNewFileName();
|
||||
void checkForReload();
|
||||
void changedFile(const QString &file);
|
||||
@@ -158,10 +158,10 @@ private slots:
|
||||
void syncWithEditor(Core::IContext *context);
|
||||
};
|
||||
|
||||
/*! The FileChangeBlocker blocks all change notifications to all IFile * that
|
||||
/*! The FileChangeBlocker blocks all change notifications to all IDocument * that
|
||||
match the given filename. And unblocks in the destructor.
|
||||
|
||||
To also reload the IFile in the destructor class set modifiedReload to true
|
||||
To also reload the IDocument in the destructor class set modifiedReload to true
|
||||
|
||||
*/
|
||||
class CORE_EXPORT FileChangeBlocker
|
||||
@@ -176,6 +176,6 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Q_DECLARE_METATYPE(Core::FileManager::RecentFile)
|
||||
Q_DECLARE_METATYPE(Core::DocumentManager::RecentFile)
|
||||
|
||||
#endif // FILEMANAGER_H
|
||||
#endif // DOCUMENTMANAGER_H
|
||||
@@ -40,7 +40,7 @@
|
||||
#include "navigationwidget.h"
|
||||
#include "rightpane.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <QLatin1String>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "openeditorsview.h"
|
||||
#include "openeditorsmodel.h"
|
||||
#include "openwithdialog.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "icore.h"
|
||||
#include "ieditor.h"
|
||||
#include "iversioncontrol.h"
|
||||
@@ -228,7 +228,7 @@ struct EditorManagerPrivate
|
||||
|
||||
OpenEditorsModel *m_editorModel;
|
||||
|
||||
IFile::ReloadSetting m_reloadSetting;
|
||||
IDocument::ReloadSetting m_reloadSetting;
|
||||
|
||||
QString m_titleAddition;
|
||||
|
||||
@@ -258,7 +258,7 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
|
||||
m_openTerminalAction(new QAction(FileUtils::msgTerminalAction(), parent)),
|
||||
m_windowPopup(0),
|
||||
m_coreListener(0),
|
||||
m_reloadSetting(IFile::AlwaysAsk),
|
||||
m_reloadSetting(IDocument::AlwaysAsk),
|
||||
m_autoSaveEnabled(true),
|
||||
m_autoSaveInterval(5)
|
||||
{
|
||||
@@ -310,11 +310,11 @@ EditorManager::EditorManager(QWidget *parent) :
|
||||
|
||||
// Save Action
|
||||
am->registerAction(d->m_saveAction, Constants::SAVE, editManagerContext);
|
||||
connect(d->m_saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
|
||||
connect(d->m_saveAction, SIGNAL(triggered()), this, SLOT(saveDocument()));
|
||||
|
||||
// Save As Action
|
||||
am->registerAction(d->m_saveAsAction, Constants::SAVEAS, editManagerContext);
|
||||
connect(d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveFileAs()));
|
||||
connect(d->m_saveAsAction, SIGNAL(triggered()), this, SLOT(saveDocumentAs()));
|
||||
|
||||
// Window Menu
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
@@ -536,7 +536,7 @@ void EditorManager::removeEditor(IEditor *editor)
|
||||
bool isDuplicate = d->m_editorModel->isDuplicate(editor);
|
||||
d->m_editorModel->removeEditor(editor);
|
||||
if (!isDuplicate)
|
||||
FileManager::removeFile(editor->file());
|
||||
DocumentManager::removeDocument(editor->document());
|
||||
ICore::removeContextObject(editor);
|
||||
}
|
||||
|
||||
@@ -616,19 +616,19 @@ Core::Internal::EditorView *EditorManager::currentEditorView() const
|
||||
QList<IEditor *> EditorManager::editorsForFileName(const QString &filename) const
|
||||
{
|
||||
QList<IEditor *> found;
|
||||
QString fixedname = FileManager::fixFileName(filename, FileManager::KeepLinks);
|
||||
QString fixedname = DocumentManager::fixFileName(filename, DocumentManager::KeepLinks);
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
if (fixedname == FileManager::fixFileName(editor->file()->fileName(), FileManager::KeepLinks))
|
||||
if (fixedname == DocumentManager::fixFileName(editor->document()->fileName(), DocumentManager::KeepLinks))
|
||||
found << editor;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
QList<IEditor *> EditorManager::editorsForFile(IFile *file) const
|
||||
QList<IEditor *> EditorManager::editorsForDocument(IDocument *document) const
|
||||
{
|
||||
QList<IEditor *> found;
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
if (editor->file() == file)
|
||||
if (editor->document() == document)
|
||||
found << editor;
|
||||
}
|
||||
return found;
|
||||
@@ -713,13 +713,13 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
|
||||
}
|
||||
|
||||
QList<IEditor*>
|
||||
EditorManager::editorsForFiles(QList<IFile*> files) const
|
||||
EditorManager::editorsForDocuments(QList<IDocument*> documents) const
|
||||
{
|
||||
const QList<IEditor *> editors = openedEditors();
|
||||
QSet<IEditor *> found;
|
||||
foreach (IFile *file, files) {
|
||||
foreach (IDocument *document, documents) {
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (editor->file() == file && !found.contains(editor)) {
|
||||
if (editor->document() == document && !found.contains(editor)) {
|
||||
found << editor;
|
||||
}
|
||||
}
|
||||
@@ -727,17 +727,17 @@ QList<IEditor*>
|
||||
return found.toList();
|
||||
}
|
||||
|
||||
QList<IFile *> EditorManager::filesForEditors(QList<IEditor *> editors) const
|
||||
QList<IDocument *> EditorManager::documentsForEditors(QList<IEditor *> editors) const
|
||||
{
|
||||
QSet<IEditor *> handledEditors;
|
||||
QList<IFile *> files;
|
||||
QList<IDocument *> documents;
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!handledEditors.contains(editor)) {
|
||||
files << editor->file();
|
||||
documents << editor->document();
|
||||
handledEditors.insert(editor);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
return documents;
|
||||
}
|
||||
|
||||
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||
@@ -870,12 +870,12 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
//ask whether to save modified files
|
||||
if (askAboutModifiedEditors) {
|
||||
bool cancelled = false;
|
||||
QList<IFile*> list = FileManager::saveModifiedFiles(filesForEditors(acceptedEditors), &cancelled);
|
||||
QList<IDocument*> list = DocumentManager::saveModifiedDocuments(documentsForEditors(acceptedEditors), &cancelled);
|
||||
if (cancelled)
|
||||
return false;
|
||||
if (!list.isEmpty()) {
|
||||
closingFailed = true;
|
||||
QSet<IEditor*> skipSet = editorsForFiles(list).toSet();
|
||||
QSet<IEditor*> skipSet = editorsForDocuments(list).toSet();
|
||||
acceptedEditors = acceptedEditors.toSet().subtract(skipSet).toList();
|
||||
}
|
||||
}
|
||||
@@ -891,11 +891,11 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
|
||||
// remove the editors
|
||||
foreach (IEditor *editor, acceptedEditors) {
|
||||
emit editorAboutToClose(editor);
|
||||
if (!editor->file()->fileName().isEmpty()
|
||||
if (!editor->document()->fileName().isEmpty()
|
||||
&& !editor->isTemporary()) {
|
||||
QByteArray state = editor->saveState();
|
||||
if (!state.isEmpty())
|
||||
d->m_editorStates.insert(editor->file()->fileName(), QVariant(state));
|
||||
d->m_editorStates.insert(editor->document()->fileName(), QVariant(state));
|
||||
}
|
||||
|
||||
removeEditor(editor);
|
||||
@@ -1018,7 +1018,7 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
|
||||
{
|
||||
Q_ASSERT(view && editor);
|
||||
|
||||
if (view->currentEditor() && view->currentEditor()->file() == editor->file())
|
||||
if (view->currentEditor() && view->currentEditor()->document() == editor->document())
|
||||
editor = view->currentEditor();
|
||||
|
||||
if (!view->hasEditor(editor)) {
|
||||
@@ -1078,10 +1078,10 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
|
||||
return editor;
|
||||
}
|
||||
|
||||
Core::IEditor *EditorManager::activateEditorForFile(Core::Internal::EditorView *view, Core::IFile *file, OpenEditorFlags flags)
|
||||
Core::IEditor *EditorManager::activateEditorForDocument(Core::Internal::EditorView *view, Core::IDocument *document, OpenEditorFlags flags)
|
||||
{
|
||||
Q_ASSERT(view);
|
||||
const QList<IEditor*> editors = editorsForFile(file);
|
||||
const QList<IEditor*> editors = editorsForDocument(document);
|
||||
if (editors.isEmpty())
|
||||
return 0;
|
||||
|
||||
@@ -1205,9 +1205,9 @@ void EditorManager::addEditor(IEditor *editor, bool isDuplicate)
|
||||
if (!isDuplicate) {
|
||||
const bool isTemporary = editor->isTemporary();
|
||||
const bool addWatcher = !isTemporary;
|
||||
FileManager::addFile(editor->file(), addWatcher);
|
||||
DocumentManager::addDocument(editor->document(), addWatcher);
|
||||
if (!isTemporary)
|
||||
FileManager::addToRecentFiles(editor->file()->fileName(), editor->id());
|
||||
DocumentManager::addToRecentFiles(editor->document()->fileName(), editor->id());
|
||||
}
|
||||
emit editorOpened(editor);
|
||||
}
|
||||
@@ -1330,7 +1330,7 @@ IEditor *EditorManager::openEditor(Core::Internal::EditorView *view, const QStri
|
||||
return 0;
|
||||
}
|
||||
if (realFn != fn)
|
||||
editor->file()->setRestoredFrom(realFn);
|
||||
editor->document()->setRestoredFrom(realFn);
|
||||
addEditor(editor);
|
||||
|
||||
if (newEditor)
|
||||
@@ -1365,7 +1365,7 @@ QStringList EditorManager::getOpenFileNames() const
|
||||
{
|
||||
QString selectedFilter;
|
||||
const QString &fileFilters = ICore::mimeDatabase()->allFiltersString(&selectedFilter);
|
||||
return FileManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
|
||||
return DocumentManager::getOpenFileNames(fileFilters, QString(), &selectedFilter);
|
||||
}
|
||||
|
||||
|
||||
@@ -1405,7 +1405,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
|
||||
int i = 1;
|
||||
QSet<QString> docnames;
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
QString name = editor->file()->fileName();
|
||||
QString name = editor->document()->fileName();
|
||||
if (name.isEmpty()) {
|
||||
name = editor->displayName();
|
||||
} else {
|
||||
@@ -1454,51 +1454,51 @@ bool EditorManager::hasEditor(const QString &fileName) const
|
||||
void EditorManager::restoreEditorState(IEditor *editor)
|
||||
{
|
||||
QTC_ASSERT(editor, return);
|
||||
QString fileName = editor->file()->fileName();
|
||||
QString fileName = editor->document()->fileName();
|
||||
editor->restoreState(d->m_editorStates.value(fileName).toByteArray());
|
||||
}
|
||||
|
||||
bool EditorManager::saveEditor(IEditor *editor)
|
||||
{
|
||||
return saveFile(editor->file());
|
||||
return saveDocument(editor->document());
|
||||
}
|
||||
|
||||
bool EditorManager::saveFile(IFile *fileParam)
|
||||
bool EditorManager::saveDocument(IDocument *documentParam)
|
||||
{
|
||||
IFile *file = fileParam;
|
||||
if (!file && currentEditor())
|
||||
file = currentEditor()->file();
|
||||
if (!file)
|
||||
IDocument *document = documentParam;
|
||||
if (!document && currentEditor())
|
||||
document = currentEditor()->document();
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
|
||||
const QString &fileName = file->fileName();
|
||||
const QString &fileName = document->fileName();
|
||||
|
||||
if (fileName.isEmpty())
|
||||
return saveFileAs(file);
|
||||
return saveDocumentAs(document);
|
||||
|
||||
bool success = false;
|
||||
bool isReadOnly;
|
||||
|
||||
// try saving, no matter what isReadOnly tells us
|
||||
success = FileManager::saveFile(file, QString(), &isReadOnly);
|
||||
success = DocumentManager::saveDocument(document, QString(), &isReadOnly);
|
||||
|
||||
if (!success && isReadOnly) {
|
||||
MakeWritableResult answer =
|
||||
makeFileWritable(file);
|
||||
makeFileWritable(document);
|
||||
if (answer == Failed)
|
||||
return false;
|
||||
if (answer == SavedAs)
|
||||
return true;
|
||||
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
|
||||
success = FileManager::saveFile(file);
|
||||
success = DocumentManager::saveDocument(document);
|
||||
}
|
||||
|
||||
if (success) {
|
||||
addFileToRecentFiles(file);
|
||||
addDocumentToRecentFiles(document);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -1509,13 +1509,13 @@ void EditorManager::autoSave()
|
||||
QStringList errors;
|
||||
// FIXME: the saving should be staggered
|
||||
foreach (IEditor *editor, openedEditors()) {
|
||||
IFile *file = editor->file();
|
||||
if (!file->isModified() || !file->shouldAutoSave())
|
||||
IDocument *document = editor->document();
|
||||
if (!document->isModified() || !document->shouldAutoSave())
|
||||
continue;
|
||||
if (file->fileName().isEmpty()) // FIXME: save them to a dedicated directory
|
||||
if (document->fileName().isEmpty()) // FIXME: save them to a dedicated directory
|
||||
continue;
|
||||
QString errorString;
|
||||
if (!file->autoSave(&errorString, autoSaveName(file->fileName())))
|
||||
if (!document->autoSave(&errorString, autoSaveName(document->fileName())))
|
||||
errors << errorString;
|
||||
}
|
||||
if (!errors.isEmpty())
|
||||
@@ -1523,57 +1523,57 @@ void EditorManager::autoSave()
|
||||
errors.join(QLatin1String("\n")));
|
||||
}
|
||||
|
||||
MakeWritableResult EditorManager::makeFileWritable(IFile *file)
|
||||
MakeWritableResult EditorManager::makeFileWritable(IDocument *document)
|
||||
{
|
||||
if (!file)
|
||||
if (!document)
|
||||
return Failed;
|
||||
QString directory = QFileInfo(file->fileName()).absolutePath();
|
||||
QString directory = QFileInfo(document->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
const QString &fileName = file->fileName();
|
||||
const QString &fileName = document->fileName();
|
||||
|
||||
switch (FileManager::promptReadOnlyFile(fileName, versionControl, ICore::mainWindow(), file->isSaveAsAllowed())) {
|
||||
case FileManager::RO_OpenVCS:
|
||||
switch (DocumentManager::promptReadOnlyFile(fileName, versionControl, ICore::mainWindow(), document->isSaveAsAllowed())) {
|
||||
case DocumentManager::RO_OpenVCS:
|
||||
if (!versionControl->vcsOpen(fileName)) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"), tr("Cannot open the file for editing with SCC."));
|
||||
return Failed;
|
||||
}
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
return OpenedWithVersionControl;
|
||||
case FileManager::RO_MakeWriteable: {
|
||||
case DocumentManager::RO_MakeWriteable: {
|
||||
const bool permsOk = QFile::setPermissions(fileName, QFile::permissions(fileName) | QFile::WriteUser);
|
||||
if (!permsOk) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Set Permissions"), tr("Cannot set permissions to writable."));
|
||||
return Failed;
|
||||
}
|
||||
}
|
||||
file->checkPermissions();
|
||||
document->checkPermissions();
|
||||
return MadeWritable;
|
||||
case FileManager::RO_SaveAs :
|
||||
return saveFileAs(file) ? SavedAs : Failed;
|
||||
case FileManager::RO_Cancel:
|
||||
case DocumentManager::RO_SaveAs :
|
||||
return saveDocumentAs(document) ? SavedAs : Failed;
|
||||
case DocumentManager::RO_Cancel:
|
||||
break;
|
||||
}
|
||||
return Failed;
|
||||
}
|
||||
|
||||
bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
bool EditorManager::saveDocumentAs(IDocument *documentParam)
|
||||
{
|
||||
IFile *file = fileParam;
|
||||
if (!file && currentEditor())
|
||||
file = currentEditor()->file();
|
||||
if (!file)
|
||||
IDocument *document = documentParam;
|
||||
if (!document && currentEditor())
|
||||
document = currentEditor()->document();
|
||||
if (!document)
|
||||
return false;
|
||||
|
||||
const QString &filter = ICore::mimeDatabase()->allFiltersString();
|
||||
QString selectedFilter =
|
||||
ICore::mimeDatabase()->findByFile(QFileInfo(file->fileName())).filterString();
|
||||
ICore::mimeDatabase()->findByFile(QFileInfo(document->fileName())).filterString();
|
||||
const QString &absoluteFilePath =
|
||||
FileManager::getSaveAsFileName(file, filter, &selectedFilter);
|
||||
DocumentManager::getSaveAsFileName(document, filter, &selectedFilter);
|
||||
|
||||
if (absoluteFilePath.isEmpty())
|
||||
return false;
|
||||
|
||||
if (absoluteFilePath != file->fileName()) {
|
||||
if (absoluteFilePath != document->fileName()) {
|
||||
// close existing editors for the new file name
|
||||
const QList<IEditor *> existList = editorsForFileName(absoluteFilePath);
|
||||
if (!existList.isEmpty()) {
|
||||
@@ -1581,8 +1581,8 @@ bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
}
|
||||
}
|
||||
|
||||
const bool success = FileManager::saveFile(file, absoluteFilePath);
|
||||
file->checkPermissions();
|
||||
const bool success = DocumentManager::saveDocument(document, absoluteFilePath);
|
||||
document->checkPermissions();
|
||||
|
||||
// @todo: There is an issue to be treated here. The new file might be of a different mime
|
||||
// type than the original and thus require a different editor. An alternative strategy
|
||||
@@ -1591,18 +1591,18 @@ bool EditorManager::saveFileAs(IFile *fileParam)
|
||||
// re-think part of the editors design.
|
||||
|
||||
if (success)
|
||||
addFileToRecentFiles(file);
|
||||
addDocumentToRecentFiles(document);
|
||||
|
||||
updateActions();
|
||||
return success;
|
||||
}
|
||||
|
||||
/* Adds the file name to the recent files if there is at least one non-temporary editor for it */
|
||||
void EditorManager::addFileToRecentFiles(IFile *file)
|
||||
void EditorManager::addDocumentToRecentFiles(IDocument *document)
|
||||
{
|
||||
bool isTemporary = true;
|
||||
Id editorId;
|
||||
QList<IEditor *> editors = editorsForFile(file);
|
||||
QList<IEditor *> editors = editorsForDocument(document);
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!editor->isTemporary()) {
|
||||
editorId = editor->id();
|
||||
@@ -1611,7 +1611,7 @@ void EditorManager::addFileToRecentFiles(IFile *file)
|
||||
}
|
||||
}
|
||||
if (!isTemporary)
|
||||
FileManager::addToRecentFiles(file->fileName(), editorId);
|
||||
DocumentManager::addToRecentFiles(document->fileName(), editorId);
|
||||
}
|
||||
|
||||
void EditorManager::gotoNextDocHistory()
|
||||
@@ -1643,7 +1643,7 @@ void EditorManager::gotoPreviousDocHistory()
|
||||
void EditorManager::makeCurrentEditorWritable()
|
||||
{
|
||||
if (IEditor* curEditor = currentEditor())
|
||||
makeFileWritable(curEditor->file());
|
||||
makeFileWritable(curEditor->document());
|
||||
}
|
||||
|
||||
void EditorManager::vcsOpenCurrentEditor()
|
||||
@@ -1652,12 +1652,12 @@ void EditorManager::vcsOpenCurrentEditor()
|
||||
if (!curEditor)
|
||||
return;
|
||||
|
||||
const QString directory = QFileInfo(curEditor->file()->fileName()).absolutePath();
|
||||
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
if (!versionControl || !versionControl->supportsOperation(IVersionControl::OpenOperation))
|
||||
return;
|
||||
|
||||
if (!versionControl->vcsOpen(curEditor->file()->fileName())) {
|
||||
if (!versionControl->vcsOpen(curEditor->document()->fileName())) {
|
||||
QMessageBox::warning(ICore::mainWindow(), tr("Cannot Open File"),
|
||||
tr("Cannot open the file for editing with VCS."));
|
||||
}
|
||||
@@ -1675,7 +1675,7 @@ void EditorManager::updateWindowTitle()
|
||||
QString editorName = curEditor->displayName();
|
||||
if (!editorName.isEmpty())
|
||||
windowTitle.prepend(editorName + dashSep);
|
||||
QString filePath = QFileInfo(curEditor->file()->fileName()).absoluteFilePath();
|
||||
QString filePath = QFileInfo(curEditor->document()->fileName()).absoluteFilePath();
|
||||
if (!filePath.isEmpty())
|
||||
ICore::mainWindow()->setWindowFilePath(filePath);
|
||||
} else {
|
||||
@@ -1688,8 +1688,8 @@ void EditorManager::handleEditorStateChange()
|
||||
{
|
||||
updateActions();
|
||||
IEditor *theEditor = qobject_cast<IEditor *>(sender());
|
||||
if (!theEditor->file()->isModified())
|
||||
theEditor->file()->removeAutoSaveFile();
|
||||
if (!theEditor->document()->isModified())
|
||||
theEditor->document()->removeAutoSaveFile();
|
||||
IEditor *currEditor = currentEditor();
|
||||
if (theEditor == currEditor) {
|
||||
updateWindowTitle();
|
||||
@@ -1705,24 +1705,24 @@ void EditorManager::updateActions()
|
||||
|
||||
if (curEditor) {
|
||||
|
||||
if (!curEditor->file()->fileName().isEmpty()) {
|
||||
QFileInfo fi(curEditor->file()->fileName());
|
||||
if (!curEditor->document()->fileName().isEmpty()) {
|
||||
QFileInfo fi(curEditor->document()->fileName());
|
||||
fName = fi.fileName();
|
||||
} else {
|
||||
fName = curEditor->displayName();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
window()->setWindowModified(curEditor->file()->isModified());
|
||||
window()->setWindowModified(curEditor->document()->isModified());
|
||||
#endif
|
||||
bool ww = curEditor->file()->isModified() && curEditor->file()->isReadOnly();
|
||||
if (ww != curEditor->file()->hasWriteWarning()) {
|
||||
curEditor->file()->setWriteWarning(ww);
|
||||
bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
|
||||
if (ww != curEditor->document()->hasWriteWarning()) {
|
||||
curEditor->document()->setWriteWarning(ww);
|
||||
|
||||
// Do this after setWriteWarning so we don't re-evaluate this part even
|
||||
// if we do not really show a warning.
|
||||
bool promptVCS = false;
|
||||
const QString directory = QFileInfo(curEditor->file()->fileName()).absolutePath();
|
||||
const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
|
||||
IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
|
||||
if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
|
||||
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
|
||||
@@ -1740,15 +1740,15 @@ void EditorManager::updateActions()
|
||||
tr("<b>Warning:</b> This file was not opened in %1 yet.")
|
||||
.arg(versionControl->displayName()));
|
||||
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
|
||||
curEditor->file()->infoBar()->addInfo(info);
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
} else {
|
||||
InfoBarEntry info(QLatin1String("Core.EditorManager.MakeWritable"),
|
||||
tr("<b>Warning:</b> You are changing a read-only file."));
|
||||
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
|
||||
curEditor->file()->infoBar()->addInfo(info);
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
} else {
|
||||
curEditor->file()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
|
||||
curEditor->document()->infoBar()->removeInfo(QLatin1String("Core.EditorManager.MakeWritable"));
|
||||
}
|
||||
}
|
||||
#ifdef Q_OS_MAC
|
||||
@@ -1759,10 +1759,10 @@ void EditorManager::updateActions()
|
||||
|
||||
setCloseSplitEnabled(d->m_splitter, d->m_splitter->isSplitter());
|
||||
|
||||
d->m_saveAction->setEnabled(curEditor != 0 && curEditor->file()->isModified());
|
||||
d->m_saveAsAction->setEnabled(curEditor != 0 && curEditor->file()->isSaveAsAllowed());
|
||||
d->m_saveAction->setEnabled(curEditor != 0 && curEditor->document()->isModified());
|
||||
d->m_saveAsAction->setEnabled(curEditor != 0 && curEditor->document()->isSaveAsAllowed());
|
||||
d->m_revertToSavedAction->setEnabled(curEditor != 0
|
||||
&& !curEditor->file()->fileName().isEmpty() && curEditor->file()->isModified());
|
||||
&& !curEditor->document()->fileName().isEmpty() && curEditor->document()->isModified());
|
||||
|
||||
QString quotedName;
|
||||
if (!fName.isEmpty())
|
||||
@@ -1894,11 +1894,11 @@ QByteArray EditorManager::saveState() const
|
||||
|
||||
QList<IEditor *> editors = openedEditors();
|
||||
foreach (IEditor *editor, editors) {
|
||||
if (!editor->file()->fileName().isEmpty()
|
||||
if (!editor->document()->fileName().isEmpty()
|
||||
&& !editor->isTemporary()) {
|
||||
QByteArray state = editor->saveState();
|
||||
if (!state.isEmpty())
|
||||
d->m_editorStates.insert(editor->file()->fileName(), QVariant(state));
|
||||
d->m_editorStates.insert(editor->document()->fileName(), QVariant(state));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2012,7 +2012,7 @@ void EditorManager::readSettings()
|
||||
.value<QMap<QString, QVariant> >();
|
||||
|
||||
if (settings->contains(QLatin1String(reloadBehaviorKey)))
|
||||
d->m_reloadSetting = (IFile::ReloadSetting)settings->value(QLatin1String(reloadBehaviorKey)).toInt();
|
||||
d->m_reloadSetting = (IDocument::ReloadSetting)settings->value(QLatin1String(reloadBehaviorKey)).toInt();
|
||||
|
||||
if (settings->contains(QLatin1String(autoSaveEnabledKey))) {
|
||||
d->m_autoSaveEnabled = settings->value(QLatin1String(autoSaveEnabledKey)).toBool();
|
||||
@@ -2027,10 +2027,10 @@ void EditorManager::revertToSaved()
|
||||
IEditor *currEditor = currentEditor();
|
||||
if (!currEditor)
|
||||
return;
|
||||
const QString fileName = currEditor->file()->fileName();
|
||||
const QString fileName = currEditor->document()->fileName();
|
||||
if (fileName.isEmpty())
|
||||
return;
|
||||
if (currEditor->file()->isModified()) {
|
||||
if (currEditor->document()->isModified()) {
|
||||
QMessageBox msgBox(QMessageBox::Question, tr("Revert to Saved"),
|
||||
tr("You will lose your current changes if you proceed reverting %1.").arg(QDir::toNativeSeparators(fileName)),
|
||||
QMessageBox::Yes|QMessageBox::No, ICore::mainWindow());
|
||||
@@ -2043,7 +2043,7 @@ void EditorManager::revertToSaved()
|
||||
|
||||
}
|
||||
QString errorString;
|
||||
if (!currEditor->file()->reload(&errorString, IFile::FlagReload, IFile::TypeContents))
|
||||
if (!currEditor->document()->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents))
|
||||
QMessageBox::critical(ICore::mainWindow(), tr("File Error"), errorString);
|
||||
}
|
||||
|
||||
@@ -2061,12 +2061,12 @@ void EditorManager::hideEditorStatusBar(const QString &id)
|
||||
currentEditorView()->hideEditorStatusBar(id);
|
||||
}
|
||||
|
||||
void EditorManager::setReloadSetting(IFile::ReloadSetting behavior)
|
||||
void EditorManager::setReloadSetting(IDocument::ReloadSetting behavior)
|
||||
{
|
||||
d->m_reloadSetting = behavior;
|
||||
}
|
||||
|
||||
IFile::ReloadSetting EditorManager::reloadSetting() const
|
||||
IDocument::ReloadSetting EditorManager::reloadSetting() const
|
||||
{
|
||||
return d->m_reloadSetting;
|
||||
}
|
||||
@@ -2110,7 +2110,7 @@ Core::IEditor *EditorManager::duplicateEditor(Core::IEditor *editor)
|
||||
IEditor *duplicate = editor->duplicate(0);
|
||||
duplicate->restoreState(editor->saveState());
|
||||
connect(duplicate, SIGNAL(changed()), this, SLOT(handleEditorStateChange()));
|
||||
emit editorCreated(duplicate, duplicate->file()->fileName());
|
||||
emit editorCreated(duplicate, duplicate->document()->fileName());
|
||||
addEditor(duplicate, true);
|
||||
return duplicate;
|
||||
}
|
||||
@@ -2211,7 +2211,7 @@ void EditorManager::updateVariable(const QByteArray &variable)
|
||||
QString value;
|
||||
IEditor *curEditor = currentEditor();
|
||||
if (curEditor) {
|
||||
QString fileName = curEditor->file()->fileName();
|
||||
QString fileName = curEditor->document()->fileName();
|
||||
if (!fileName.isEmpty()) {
|
||||
if (variable == kCurrentDocumentFilePath)
|
||||
value = QFileInfo(fileName).filePath();
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "../core_global.h"
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/ifile.h> // enumerations
|
||||
#include <coreplugin/idocument.h> // enumerations
|
||||
|
||||
#include <QList>
|
||||
#include <QWidget>
|
||||
@@ -53,7 +53,7 @@ class IEditor;
|
||||
class IEditorFactory;
|
||||
class IExternalEditor;
|
||||
class MimeType;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IMode;
|
||||
class IVersionControl;
|
||||
|
||||
@@ -129,7 +129,7 @@ public:
|
||||
|
||||
bool hasEditor(const QString &fileName) const;
|
||||
QList<IEditor *> editorsForFileName(const QString &filename) const;
|
||||
QList<IEditor *> editorsForFile(IFile *file) const;
|
||||
QList<IEditor *> editorsForDocument(IDocument *document) const;
|
||||
|
||||
IEditor *currentEditor() const;
|
||||
QList<IEditor *> visibleEditors() const;
|
||||
@@ -137,13 +137,13 @@ public:
|
||||
|
||||
void activateEditor(IEditor *editor, OpenEditorFlags flags = 0);
|
||||
void activateEditorForIndex(const QModelIndex &index, OpenEditorFlags = 0);
|
||||
IEditor *activateEditorForFile(Internal::EditorView *view, IFile *file, OpenEditorFlags flags = 0);
|
||||
IEditor *activateEditorForDocument(Internal::EditorView *view, IDocument *document, OpenEditorFlags flags = 0);
|
||||
|
||||
OpenEditorsModel *openedEditorsModel() const;
|
||||
void closeEditor(const QModelIndex &index);
|
||||
void closeOtherEditors(IEditor *editor);
|
||||
|
||||
QList<IEditor*> editorsForFiles(QList<IFile *> files) const;
|
||||
QList<IEditor*> editorsForDocuments(QList<IDocument *> documents) const;
|
||||
void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray());
|
||||
void cutForwardNavigationHistory();
|
||||
|
||||
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
bool closeEditors(const QList<IEditor *> &editorsToClose, bool askAboutModifiedEditors = true);
|
||||
|
||||
MakeWritableResult makeFileWritable(IFile *file);
|
||||
MakeWritableResult makeFileWritable(IDocument *document);
|
||||
|
||||
QByteArray saveState() const;
|
||||
bool restoreState(const QByteArray &state);
|
||||
@@ -173,8 +173,8 @@ public:
|
||||
EditorFactoryList editorFactories(const MimeType &mimeType, bool bestMatchOnly = true) const;
|
||||
ExternalEditorList externalEditors(const MimeType &mimeType, bool bestMatchOnly = true) const;
|
||||
|
||||
void setReloadSetting(IFile::ReloadSetting behavior);
|
||||
IFile::ReloadSetting reloadSetting() const;
|
||||
void setReloadSetting(IDocument::ReloadSetting behavior);
|
||||
IDocument::ReloadSetting reloadSetting() const;
|
||||
|
||||
void setAutoSaveEnabled(bool enabled);
|
||||
bool autoSaveEnabled() const;
|
||||
@@ -202,8 +202,8 @@ signals:
|
||||
public slots:
|
||||
bool closeAllEditors(bool askAboutModifiedEditors = true);
|
||||
|
||||
bool saveFile(Core::IFile *file = 0);
|
||||
bool saveFileAs(Core::IFile *file = 0);
|
||||
bool saveDocument(Core::IDocument *documentParam = 0);
|
||||
bool saveDocumentAs(Core::IDocument *documentParam = 0);
|
||||
void revertToSaved();
|
||||
void closeEditor();
|
||||
void closeOtherEditors();
|
||||
@@ -237,7 +237,7 @@ public slots:
|
||||
void gotoOtherSplit();
|
||||
|
||||
private:
|
||||
QList<IFile *> filesForEditors(QList<IEditor *> editors) const;
|
||||
QList<IDocument *> documentsForEditors(QList<IEditor *> editors) const;
|
||||
IEditor *createEditor(const Id &id = Id(), const QString &fileName = QString());
|
||||
void addEditor(IEditor *editor, bool isDuplicate = false);
|
||||
void removeEditor(IEditor *editor);
|
||||
@@ -261,7 +261,7 @@ private:
|
||||
void emptyView(Internal::EditorView *view);
|
||||
Internal::EditorView *currentEditorView() const;
|
||||
IEditor *pickUnusedEditor() const;
|
||||
void addFileToRecentFiles(IFile *file);
|
||||
void addDocumentToRecentFiles(IDocument *document);
|
||||
void switchToPreferedMode();
|
||||
void updateAutoSave();
|
||||
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
|
||||
|
||||
@@ -278,7 +278,7 @@ void EditorView::setCurrentEditor(IEditor *editor)
|
||||
|
||||
updateEditorHistory(editor);
|
||||
|
||||
m_infoBarDisplay->setInfoBar(editor->file()->infoBar());
|
||||
m_infoBarDisplay->setInfoBar(editor->document()->infoBar());
|
||||
}
|
||||
|
||||
int EditorView::editorCount() const
|
||||
@@ -295,22 +295,22 @@ void EditorView::updateEditorHistory(IEditor *editor)
|
||||
{
|
||||
if (!editor)
|
||||
return;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
|
||||
if (!file)
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
QByteArray state = editor->saveState();
|
||||
|
||||
EditLocation location;
|
||||
location.file = file;
|
||||
location.fileName = file->fileName();
|
||||
location.document = document;
|
||||
location.fileName = document->fileName();
|
||||
location.id = editor->id();
|
||||
location.state = QVariant(state);
|
||||
|
||||
for(int i = 0; i < m_editorHistory.size(); ++i) {
|
||||
if (m_editorHistory.at(i).file == 0
|
||||
|| m_editorHistory.at(i).file == file
|
||||
if (m_editorHistory.at(i).document == 0
|
||||
|| m_editorHistory.at(i).document == document
|
||||
){
|
||||
m_editorHistory.removeAt(i--);
|
||||
continue;
|
||||
@@ -335,9 +335,9 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
editor = currentEditor();
|
||||
if (!editor)
|
||||
return;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
|
||||
if (!file)
|
||||
if (!document)
|
||||
return;
|
||||
|
||||
QByteArray state;
|
||||
@@ -348,8 +348,8 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
|
||||
}
|
||||
|
||||
EditLocation location;
|
||||
location.file = file;
|
||||
location.fileName = file->fileName();
|
||||
location.document = document;
|
||||
location.fileName = document->fileName();
|
||||
location.id = editor->id();
|
||||
location.state = QVariant(state);
|
||||
m_currentNavigationHistoryPosition = qMin(m_currentNavigationHistoryPosition, m_navigationHistory.size()); // paranoia
|
||||
@@ -392,10 +392,10 @@ void EditorView::copyNavigationHistoryFrom(EditorView* other)
|
||||
void EditorView::updateCurrentPositionInNavigationHistory()
|
||||
{
|
||||
IEditor *editor = currentEditor();
|
||||
if (!editor || !editor->file())
|
||||
if (!editor || !editor->document())
|
||||
return;
|
||||
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
EditLocation *location;
|
||||
if (m_currentNavigationHistoryPosition < m_navigationHistory.size()) {
|
||||
location = &m_navigationHistory[m_currentNavigationHistoryPosition];
|
||||
@@ -403,8 +403,8 @@ void EditorView::updateCurrentPositionInNavigationHistory()
|
||||
m_navigationHistory.append(EditLocation());
|
||||
location = &m_navigationHistory[m_navigationHistory.size()-1];
|
||||
}
|
||||
location->file = file;
|
||||
location->fileName = file->fileName();
|
||||
location->document = document;
|
||||
location->fileName = document->fileName();
|
||||
location->id = editor->id();
|
||||
location->state = QVariant(editor->saveState());
|
||||
}
|
||||
@@ -417,8 +417,8 @@ void EditorView::goBackInNavigationHistory()
|
||||
--m_currentNavigationHistoryPosition;
|
||||
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
|
||||
IEditor *editor;
|
||||
if (location.file) {
|
||||
editor = em->activateEditorForFile(this, location.file,
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
} else {
|
||||
editor = em->openEditor(this, location.fileName, location.id,
|
||||
@@ -443,8 +443,8 @@ void EditorView::goForwardInNavigationHistory()
|
||||
++m_currentNavigationHistoryPosition;
|
||||
EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition);
|
||||
IEditor *editor;
|
||||
if (location.file) {
|
||||
editor = em->activateEditorForFile(this, location.file,
|
||||
if (location.document) {
|
||||
editor = em->activateEditorForDocument(this, location.document,
|
||||
EditorManager::IgnoreNavigationHistory | EditorManager::ModeSwitch);
|
||||
} else {
|
||||
editor = em->openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory);
|
||||
@@ -801,11 +801,11 @@ QByteArray SplitterOrView::saveState() const
|
||||
EditorManager *em = ICore::editorManager();
|
||||
|
||||
// don't save state of temporary or ad-hoc editors
|
||||
if (e && (e->isTemporary() || e->file()->fileName().isEmpty())) {
|
||||
if (e && (e->isTemporary() || e->document()->fileName().isEmpty())) {
|
||||
// look for another editor that is more suited
|
||||
e = 0;
|
||||
foreach (IEditor *otherEditor, editors()) {
|
||||
if (!otherEditor->isTemporary() && !otherEditor->file()->fileName().isEmpty()) {
|
||||
if (!otherEditor->isTemporary() && !otherEditor->document()->fileName().isEmpty()) {
|
||||
e = otherEditor;
|
||||
break;
|
||||
}
|
||||
@@ -816,10 +816,10 @@ QByteArray SplitterOrView::saveState() const
|
||||
stream << QByteArray("empty");
|
||||
} else if (e == em->currentEditor()) {
|
||||
stream << QByteArray("currenteditor")
|
||||
<< e->file()->fileName() << e->id().toString() << e->saveState();
|
||||
<< e->document()->fileName() << e->id().toString() << e->saveState();
|
||||
} else {
|
||||
stream << QByteArray("editor")
|
||||
<< e->file()->fileName() << e->id().toString() << e->saveState();
|
||||
<< e->document()->fileName() << e->id().toString() << e->saveState();
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
|
||||
@@ -57,7 +57,7 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class IContext;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class IEditor;
|
||||
class InfoBarDisplay;
|
||||
class OpenEditorsModel;
|
||||
@@ -66,7 +66,7 @@ class EditorToolBar;
|
||||
namespace Internal {
|
||||
|
||||
struct EditLocation {
|
||||
QPointer<IFile> file;
|
||||
QPointer<IDocument> document;
|
||||
QString fileName;
|
||||
Id id;
|
||||
QVariant state;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
|
||||
class CORE_EXPORT IEditor : public IContext
|
||||
{
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
|
||||
virtual bool createNew(const QString &contents = QString()) = 0;
|
||||
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName) = 0;
|
||||
virtual IFile *file() = 0;
|
||||
virtual IDocument *document() = 0;
|
||||
virtual Core::Id id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
virtual void setDisplayName(const QString &title) = 0;
|
||||
|
||||
@@ -33,18 +33,18 @@
|
||||
#ifndef IEDITORFACTORY_H
|
||||
#define IEDITORFACTORY_H
|
||||
|
||||
#include <coreplugin/ifilefactory.h>
|
||||
#include <coreplugin/idocumentfactory.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IEditor;
|
||||
|
||||
class CORE_EXPORT IEditorFactory : public Core::IFileFactory
|
||||
class CORE_EXPORT IEditorFactory : public Core::IDocumentFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IEditorFactory(QObject *parent = 0) : IFileFactory(parent) {}
|
||||
IEditorFactory(QObject *parent = 0) : IDocumentFactory(parent) {}
|
||||
|
||||
virtual IEditor *createEditor(QWidget *parent) = 0;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include "openeditorsmodel.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QIcon>
|
||||
@@ -82,7 +82,7 @@ QIcon OpenEditorsModel::unlockedIcon() const
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::fileName() const {
|
||||
return editor ? editor->file()->fileName() : m_fileName;
|
||||
return editor ? editor->document()->fileName() : m_fileName;
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::Entry::displayName() const {
|
||||
@@ -252,9 +252,9 @@ bool OpenEditorsModel::isDuplicate(IEditor *editor) const
|
||||
|
||||
IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
|
||||
{
|
||||
IFile *file = duplicate->file();
|
||||
IDocument *document = duplicate->document();
|
||||
foreach(const Entry &e, d->m_editors)
|
||||
if (e.editor && e.editor->file() == file)
|
||||
if (e.editor && e.editor->document() == document)
|
||||
return e.editor;
|
||||
return 0;
|
||||
}
|
||||
@@ -262,9 +262,9 @@ IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
|
||||
QList<IEditor *> OpenEditorsModel::duplicatesFor(IEditor *editor) const
|
||||
{
|
||||
QList<IEditor *> result;
|
||||
IFile *file = editor->file();
|
||||
IDocument *document = editor->document();
|
||||
foreach(IEditor *e, d->m_duplicateEditors)
|
||||
if (e->file() == file)
|
||||
if (e->document() == document)
|
||||
result += e;
|
||||
return result;
|
||||
}
|
||||
@@ -306,16 +306,16 @@ QVariant OpenEditorsModel::data(const QModelIndex &index, int role) const
|
||||
Entry e = d->m_editors.at(index.row());
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return (e.editor && e.editor->file()->isModified())
|
||||
return (e.editor && e.editor->document()->isModified())
|
||||
? e.displayName() + QLatin1Char('*')
|
||||
: e.displayName();
|
||||
case Qt::DecorationRole:
|
||||
{
|
||||
bool showLock = false;
|
||||
if (e.editor) {
|
||||
showLock = e.editor->file()->fileName().isEmpty()
|
||||
showLock = e.editor->document()->fileName().isEmpty()
|
||||
? false
|
||||
: e.editor->file()->isReadOnly();
|
||||
: e.editor->document()->isFileReadOnly();
|
||||
} else {
|
||||
showLock = !QFileInfo(e.m_fileName).isWritable();
|
||||
}
|
||||
@@ -343,10 +343,10 @@ QModelIndex OpenEditorsModel::indexOf(IEditor *editor) const
|
||||
return createIndex(idx, 0);
|
||||
}
|
||||
|
||||
QString OpenEditorsModel::displayNameForFile(IFile *file) const
|
||||
QString OpenEditorsModel::displayNameForDocument(IDocument *document) const
|
||||
{
|
||||
for (int i = 0; i < d->m_editors.count(); ++i)
|
||||
if (d->m_editors.at(i).editor && d->m_editors.at(i).editor->file() == file)
|
||||
if (d->m_editors.at(i).editor && d->m_editors.at(i).editor->document() == document)
|
||||
return d->m_editors.at(i).editor->displayName();
|
||||
return QString();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Core {
|
||||
|
||||
struct OpenEditorsModelPrivate;
|
||||
class IEditor;
|
||||
class IFile;
|
||||
class IDocument;
|
||||
|
||||
class CORE_EXPORT OpenEditorsModel : public QAbstractItemModel
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
void makeOriginal(IEditor *duplicate);
|
||||
QModelIndex indexOf(IEditor *editor) const;
|
||||
|
||||
QString displayNameForFile(IFile *file) const;
|
||||
QString displayNameForDocument(IDocument *document) const;
|
||||
|
||||
private slots:
|
||||
void itemChanged();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "openeditorsmodel.h"
|
||||
#include "editormanager.h"
|
||||
#include "editorview.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <QVBoxLayout>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::EditorView*)
|
||||
Q_DECLARE_METATYPE(Core::IFile *)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
@@ -203,21 +203,21 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
|
||||
m_editorList->clear();
|
||||
bool first = true;
|
||||
|
||||
QSet<IFile*> filesDone;
|
||||
QSet<IDocument*> documentsDone;
|
||||
foreach (const EditLocation &hi, view->editorHistory()) {
|
||||
if (hi.file.isNull() || filesDone.contains(hi.file))
|
||||
if (hi.document.isNull() || documentsDone.contains(hi.document))
|
||||
continue;
|
||||
QString title = model->displayNameForFile(hi.file);
|
||||
QString title = model->displayNameForDocument(hi.document);
|
||||
QTC_ASSERT(!title.isEmpty(), continue;)
|
||||
filesDone.insert(hi.file.data());
|
||||
documentsDone.insert(hi.document.data());
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
if (hi.file->isModified())
|
||||
if (hi.document->isModified())
|
||||
title += tr("*");
|
||||
item->setIcon(0, !hi.file->fileName().isEmpty() && hi.file->isReadOnly()
|
||||
item->setIcon(0, !hi.document->fileName().isEmpty() && hi.document->isFileReadOnly()
|
||||
? model->lockedIcon() : m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, hi.file->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
|
||||
item->setToolTip(0, hi.document->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
|
||||
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
|
||||
@@ -232,20 +232,20 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
|
||||
// add missing editors from the main view
|
||||
if (mainView != view) {
|
||||
foreach (const EditLocation &hi, mainView->editorHistory()) {
|
||||
if (hi.file.isNull() || filesDone.contains(hi.file))
|
||||
if (hi.document.isNull() || documentsDone.contains(hi.document))
|
||||
continue;
|
||||
filesDone.insert(hi.file.data());
|
||||
documentsDone.insert(hi.document.data());
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
|
||||
QString title = model->displayNameForFile(hi.file);
|
||||
if (hi.file->isModified())
|
||||
QString title = model->displayNameForDocument(hi.document);
|
||||
if (hi.document->isModified())
|
||||
title += tr("*");
|
||||
item->setIcon(0, !hi.file->fileName().isEmpty() && hi.file->isReadOnly()
|
||||
item->setIcon(0, !hi.document->fileName().isEmpty() && hi.document->isFileReadOnly()
|
||||
? model->lockedIcon() : m_emptyIcon);
|
||||
item->setText(0, title);
|
||||
item->setToolTip(0, hi.file->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.file.data()));
|
||||
item->setToolTip(0, hi.document->fileName());
|
||||
item->setData(0, Qt::UserRole, QVariant::fromValue(hi.document.data()));
|
||||
item->setData(0, Qt::UserRole+1, QVariant::fromValue(view));
|
||||
item->setData(0, Qt::UserRole+2, QVariant::fromValue(hi.id));
|
||||
item->setTextAlignment(0, Qt::AlignLeft);
|
||||
@@ -280,9 +280,9 @@ void OpenEditorsWindow::selectEditor(QTreeWidgetItem *item)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
if (IFile *file = item->data(0, Qt::UserRole).value<IFile*>()) {
|
||||
if (IDocument *document = item->data(0, Qt::UserRole).value<IDocument*>()) {
|
||||
EditorView *view = item->data(0, Qt::UserRole+1).value<EditorView*>();
|
||||
EditorManager::instance()->activateEditorForFile(view, file, EditorManager::ModeSwitch);
|
||||
EditorManager::instance()->activateEditorForDocument(view, document, EditorManager::ModeSwitch);
|
||||
} else {
|
||||
if (!EditorManager::instance()->openEditor(
|
||||
item->toolTip(0), item->data(0, Qt::UserRole+2).value<Core::Id>(),
|
||||
|
||||
@@ -351,7 +351,7 @@ void EditorToolBar::listContextMenu(QPoint pos)
|
||||
void EditorToolBar::makeEditorWritable()
|
||||
{
|
||||
if (currentEditor())
|
||||
ICore::editorManager()->makeFileWritable(currentEditor()->file());
|
||||
ICore::editorManager()->makeFileWritable(currentEditor()->document());
|
||||
}
|
||||
|
||||
void EditorToolBar::setCanGoBack(bool canGoBack)
|
||||
@@ -390,7 +390,7 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
{
|
||||
d->m_closeEditorButton->setEnabled(editor != 0);
|
||||
|
||||
if (!editor || !editor->file()) {
|
||||
if (!editor || !editor->document()) {
|
||||
d->m_lockButton->setIcon(QIcon());
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(QString());
|
||||
@@ -400,11 +400,11 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
|
||||
d->m_editorList->setCurrentIndex(d->m_editorsListModel->indexOf(editor).row());
|
||||
|
||||
if (editor->file()->fileName().isEmpty()) {
|
||||
if (editor->document()->fileName().isEmpty()) {
|
||||
d->m_lockButton->setIcon(QIcon());
|
||||
d->m_lockButton->setEnabled(false);
|
||||
d->m_lockButton->setToolTip(QString());
|
||||
} else if (editor->file()->isReadOnly()) {
|
||||
} else if (editor->document()->isFileReadOnly()) {
|
||||
d->m_lockButton->setIcon(QIcon(d->m_editorsListModel->lockedIcon()));
|
||||
d->m_lockButton->setEnabled(true);
|
||||
d->m_lockButton->setToolTip(tr("Make Writable"));
|
||||
@@ -415,9 +415,9 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
|
||||
}
|
||||
if (editor == currentEditor())
|
||||
d->m_editorList->setToolTip(
|
||||
currentEditor()->file()->fileName().isEmpty()
|
||||
currentEditor()->document()->fileName().isEmpty()
|
||||
? currentEditor()->displayName()
|
||||
: QDir::toNativeSeparators(editor->file()->fileName())
|
||||
: QDir::toNativeSeparators(editor->document()->fileName())
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <app/app_version.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -601,14 +601,14 @@ void ExternalToolRunner::run()
|
||||
}
|
||||
if (m_tool->modifiesCurrentDocument()) {
|
||||
if (IEditor *editor = EditorManager::instance()->currentEditor()) {
|
||||
m_expectedFileName = editor->file()->fileName();
|
||||
m_expectedFileName = editor->document()->fileName();
|
||||
bool cancelled = false;
|
||||
FileManager::saveModifiedFiles(QList<IFile *>() << editor->file(), &cancelled);
|
||||
DocumentManager::saveModifiedDocuments(QList<IDocument *>() << editor->document(), &cancelled);
|
||||
if (cancelled) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
FileManager::expectFileChange(m_expectedFileName);
|
||||
DocumentManager::expectFileChange(m_expectedFileName);
|
||||
}
|
||||
}
|
||||
m_process = new Utils::QtcProcess(this);
|
||||
@@ -641,7 +641,7 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
emit ExternalToolManager::instance()->replaceSelectionRequested(m_processOutput);
|
||||
}
|
||||
if (m_tool->modifiesCurrentDocument()) {
|
||||
FileManager::unexpectFileChange(m_expectedFileName);
|
||||
DocumentManager::unexpectFileChange(m_expectedFileName);
|
||||
}
|
||||
}
|
||||
ICore::messageManager()->printToOutputPane(
|
||||
@@ -652,7 +652,7 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|
||||
void ExternalToolRunner::error(QProcess::ProcessError error)
|
||||
{
|
||||
if (m_tool->modifiesCurrentDocument())
|
||||
FileManager::unexpectFileChange(m_expectedFileName);
|
||||
DocumentManager::unexpectFileChange(m_expectedFileName);
|
||||
// TODO inform about errors
|
||||
Q_UNUSED(error);
|
||||
deleteLater();
|
||||
|
||||
@@ -195,7 +195,7 @@ void GeneralSettings::apply()
|
||||
setLanguage(m_page->languageBox->itemData(currentIndex, Qt::UserRole).toString());
|
||||
// Apply the new base color if accepted
|
||||
StyleHelper::setBaseColor(m_page->colorButton->color());
|
||||
EditorManager::instance()->setReloadSetting(IFile::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
||||
EditorManager::instance()->setReloadSetting(IDocument::ReloadSetting(m_page->reloadBehavior->currentIndex()));
|
||||
#ifdef Q_OS_UNIX
|
||||
ConsoleProcess::setTerminalEmulator(Core::ICore::settings(),
|
||||
m_page->terminalEdit->text());
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
in \a defaultLocation. It defaults to the path of the file manager's
|
||||
current file.
|
||||
|
||||
\sa Core::FileManager
|
||||
\sa Core::DocumentManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
@@ -103,7 +103,7 @@
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn FileManager *ICore::fileManager() const
|
||||
\fn DocumentManager *ICore::fileManager() const
|
||||
\brief Returns the application's file manager.
|
||||
|
||||
The file manager keeps track of files for changes outside the application.
|
||||
@@ -346,6 +346,7 @@
|
||||
|
||||
#include "icore.h"
|
||||
#include "mainwindow.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
@@ -410,9 +411,9 @@ ActionManager *ICore::actionManager()
|
||||
return m_mainwindow->actionManager();
|
||||
}
|
||||
|
||||
FileManager *ICore::fileManager()
|
||||
DocumentManager *ICore::documentManager()
|
||||
{
|
||||
return m_mainwindow->fileManager();
|
||||
return DocumentManager::instance();
|
||||
}
|
||||
|
||||
MessageManager *ICore::messageManager()
|
||||
|
||||
@@ -51,7 +51,7 @@ class IWizard;
|
||||
class ActionManager;
|
||||
class Context;
|
||||
class EditorManager;
|
||||
class FileManager;
|
||||
class DocumentManager;
|
||||
class HelpManager;
|
||||
class IContext;
|
||||
class MessageManager;
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
QWidget *parent = 0);
|
||||
|
||||
static ActionManager *actionManager();
|
||||
static QT_DEPRECATED FileManager *fileManager(); // Use FileManager::... directly.
|
||||
static QT_DEPRECATED DocumentManager *documentManager(); // Use DocumentManager::... directly.
|
||||
static MessageManager *messageManager();
|
||||
static EditorManager *editorManager();
|
||||
static ProgressManager *progressManager();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include "infobar.h"
|
||||
|
||||
@@ -39,17 +39,17 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
IFile::IFile(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
|
||||
IDocument::IDocument(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
|
||||
{
|
||||
}
|
||||
|
||||
IFile::~IFile()
|
||||
IDocument::~IDocument()
|
||||
{
|
||||
removeAutoSaveFile();
|
||||
delete m_infoBar;
|
||||
}
|
||||
|
||||
IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const
|
||||
{
|
||||
if (type == TypePermissions)
|
||||
return BehaviorSilent;
|
||||
@@ -58,23 +58,23 @@ IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type
|
||||
return BehaviorAsk;
|
||||
}
|
||||
|
||||
void IFile::checkPermissions()
|
||||
void IDocument::checkPermissions()
|
||||
{
|
||||
}
|
||||
|
||||
bool IFile::shouldAutoSave() const
|
||||
bool IDocument::shouldAutoSave() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IFile::isReadOnly() const
|
||||
bool IDocument::isFileReadOnly() const
|
||||
{
|
||||
if (fileName().isEmpty())
|
||||
return false;
|
||||
return !QFileInfo(fileName()).isWritable();
|
||||
}
|
||||
|
||||
bool IFile::autoSave(QString *errorString, const QString &fileName)
|
||||
bool IDocument::autoSave(QString *errorString, const QString &fileName)
|
||||
{
|
||||
if (!save(errorString, fileName, true))
|
||||
return false;
|
||||
@@ -84,7 +84,7 @@ bool IFile::autoSave(QString *errorString, const QString &fileName)
|
||||
|
||||
static const char kRestoredAutoSave[] = "RestoredAutoSave";
|
||||
|
||||
void IFile::setRestoredFrom(const QString &name)
|
||||
void IDocument::setRestoredFrom(const QString &name)
|
||||
{
|
||||
m_autoSaveName = name;
|
||||
m_restored = true;
|
||||
@@ -94,7 +94,7 @@ void IFile::setRestoredFrom(const QString &name)
|
||||
infoBar()->addInfo(info);
|
||||
}
|
||||
|
||||
void IFile::removeAutoSaveFile()
|
||||
void IDocument::removeAutoSaveFile()
|
||||
{
|
||||
if (!m_autoSaveName.isEmpty()) {
|
||||
QFile::remove(m_autoSaveName);
|
||||
@@ -106,7 +106,7 @@ void IFile::removeAutoSaveFile()
|
||||
}
|
||||
}
|
||||
|
||||
InfoBar *IFile::infoBar()
|
||||
InfoBar *IDocument::infoBar()
|
||||
{
|
||||
if (!m_infoBar)
|
||||
m_infoBar = new InfoBar;
|
||||
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef IFILE_H
|
||||
#define IFILE_H
|
||||
#ifndef IDOCUMENT_H
|
||||
#define IDOCUMENT_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include <QObject>
|
||||
@@ -41,7 +41,7 @@ namespace Core {
|
||||
class MimeType;
|
||||
class InfoBar;
|
||||
|
||||
class CORE_EXPORT IFile : public QObject
|
||||
class CORE_EXPORT IDocument : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -81,11 +81,12 @@ public:
|
||||
FlagIgnore
|
||||
};
|
||||
|
||||
IFile(QObject *parent = 0);
|
||||
virtual ~IFile();
|
||||
IDocument(QObject *parent = 0);
|
||||
virtual ~IDocument();
|
||||
|
||||
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
|
||||
virtual QString fileName() const = 0;
|
||||
virtual bool isFileReadOnly() const;
|
||||
|
||||
virtual QString defaultPath() const = 0;
|
||||
virtual QString suggestedFileName() const = 0;
|
||||
@@ -93,7 +94,6 @@ public:
|
||||
|
||||
virtual bool shouldAutoSave() const;
|
||||
virtual bool isModified() const = 0;
|
||||
virtual bool isReadOnly() const;
|
||||
virtual bool isSaveAsAllowed() const = 0;
|
||||
|
||||
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
|
||||
@@ -126,4 +126,4 @@ private:
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IFILE_H
|
||||
#endif // IDOCUMENT_H
|
||||
@@ -30,8 +30,8 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef IFILEFACTORY_H
|
||||
#define IFILEFACTORY_H
|
||||
#ifndef IDOCUMENTFACTORY_H
|
||||
#define IDOCUMENTFACTORY_H
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
@@ -43,22 +43,22 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IFile;
|
||||
class IDocument;
|
||||
class Id;
|
||||
|
||||
class CORE_EXPORT IFileFactory : public QObject
|
||||
class CORE_EXPORT IDocumentFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
IFileFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
IDocumentFactory(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
virtual QStringList mimeTypes() const = 0;
|
||||
virtual Id id() const = 0;
|
||||
virtual QString displayName() const = 0;
|
||||
virtual IFile *open(const QString &fileName) = 0;
|
||||
virtual IDocument *open(const QString &fileName) = 0;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // IFILEFACTORY_H
|
||||
#endif // IDOCUMENTFACTORY_H
|
||||
@@ -41,11 +41,11 @@
|
||||
#include "toolsettings.h"
|
||||
#include "mimetypesettings.h"
|
||||
#include "fancytabwidget.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
#include "generalsettings.h"
|
||||
#include "helpmanager.h"
|
||||
#include "ieditor.h"
|
||||
#include "ifilefactory.h"
|
||||
#include "idocumentfactory.h"
|
||||
#include "messagemanager.h"
|
||||
#include "modemanager.h"
|
||||
#include "mimedatabase.h"
|
||||
@@ -170,7 +170,7 @@ MainWindow::MainWindow() :
|
||||
#endif
|
||||
m_toggleSideBarButton(new QToolButton)
|
||||
{
|
||||
(void) new FileManager(this);
|
||||
(void) new DocumentManager(this);
|
||||
OutputPaneManager::create();
|
||||
|
||||
setWindowTitle(tr("Qt Creator"));
|
||||
@@ -376,7 +376,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
|
||||
// Save opened files
|
||||
bool cancelled;
|
||||
QList<IFile*> notSaved = FileManager::saveModifiedFiles(FileManager::modifiedFiles(), &cancelled);
|
||||
QList<IDocument*> notSaved = DocumentManager::saveModifiedDocuments(DocumentManager::modifiedDocuments(), &cancelled);
|
||||
if (cancelled || !notSaved.isEmpty()) {
|
||||
event->ignore();
|
||||
return;
|
||||
@@ -836,25 +836,25 @@ void MainWindow::openFile()
|
||||
openFiles(editorManager()->getOpenFileNames(), ICore::SwitchMode);
|
||||
}
|
||||
|
||||
static QList<IFileFactory*> getNonEditorFileFactories()
|
||||
static QList<IDocumentFactory*> getNonEditorDocumentFactories()
|
||||
{
|
||||
const QList<IFileFactory*> allFileFactories =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IFileFactory>();
|
||||
QList<IFileFactory*> nonEditorFileFactories;
|
||||
foreach (IFileFactory *factory, allFileFactories) {
|
||||
const QList<IDocumentFactory*> allFileFactories =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IDocumentFactory>();
|
||||
QList<IDocumentFactory*> nonEditorFileFactories;
|
||||
foreach (IDocumentFactory *factory, allFileFactories) {
|
||||
if (!qobject_cast<IEditorFactory *>(factory))
|
||||
nonEditorFileFactories.append(factory);
|
||||
}
|
||||
return nonEditorFileFactories;
|
||||
}
|
||||
|
||||
static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
|
||||
static IDocumentFactory *findDocumentFactory(const QList<IDocumentFactory*> &fileFactories,
|
||||
const MimeDatabase *db,
|
||||
const QFileInfo &fi)
|
||||
{
|
||||
if (const MimeType mt = db->findByFile(fi)) {
|
||||
const QString type = mt.type();
|
||||
foreach (IFileFactory *factory, fileFactories) {
|
||||
foreach (IDocumentFactory *factory, fileFactories) {
|
||||
if (factory->mimeTypes().contains(type))
|
||||
return factory;
|
||||
}
|
||||
@@ -865,16 +865,16 @@ static IFileFactory *findFileFactory(const QList<IFileFactory*> &fileFactories,
|
||||
// opens either an editor or loads a project
|
||||
void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags)
|
||||
{
|
||||
QList<IFileFactory*> nonEditorFileFactories = getNonEditorFileFactories();
|
||||
QList<IDocumentFactory*> nonEditorFileFactories = getNonEditorDocumentFactories();
|
||||
|
||||
foreach (const QString &fileName, fileNames) {
|
||||
const QFileInfo fi(fileName);
|
||||
const QString absoluteFilePath = fi.absoluteFilePath();
|
||||
if (IFileFactory *fileFactory = findFileFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||
Core::IFile *file = fileFactory->open(absoluteFilePath);
|
||||
if (!file && (flags & ICore::StopOnLoadFail))
|
||||
if (IDocumentFactory *documentFactory = findDocumentFactory(nonEditorFileFactories, mimeDatabase(), fi)) {
|
||||
Core::IDocument *document = documentFactory->open(absoluteFilePath);
|
||||
if (!document && (flags & ICore::StopOnLoadFail))
|
||||
return;
|
||||
if (file && (flags & ICore::SwitchMode))
|
||||
if (document && (flags & ICore::SwitchMode))
|
||||
ModeManager::activateMode(QLatin1String(Core::Constants::MODE_EDIT));
|
||||
} else {
|
||||
QFlags<EditorManager::OpenEditorFlag> emFlags;
|
||||
@@ -969,12 +969,12 @@ void MainWindow::showNewItemDialog(const QString &title,
|
||||
// Project wizards: Check for projects directory or
|
||||
// use last visited directory of file dialog. Never start
|
||||
// at current.
|
||||
path = FileManager::useProjectsDirectory() ?
|
||||
FileManager::projectsDirectory() :
|
||||
FileManager::fileDialogLastVisitedDirectory();
|
||||
path = DocumentManager::useProjectsDirectory() ?
|
||||
DocumentManager::projectsDirectory() :
|
||||
DocumentManager::fileDialogLastVisitedDirectory();
|
||||
break;
|
||||
default:
|
||||
path = FileManager::fileDialogInitialDirectory();
|
||||
path = DocumentManager::fileDialogInitialDirectory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -994,7 +994,7 @@ bool MainWindow::showOptionsDialog(const QString &category,
|
||||
|
||||
void MainWindow::saveAll()
|
||||
{
|
||||
FileManager::saveModifiedFilesSilently(FileManager::modifiedFiles());
|
||||
DocumentManager::saveModifiedDocumentsSilently(DocumentManager::modifiedDocuments());
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
}
|
||||
|
||||
@@ -1029,11 +1029,6 @@ ActionManager *MainWindow::actionManager() const
|
||||
return m_actionManager;
|
||||
}
|
||||
|
||||
FileManager *MainWindow::fileManager() const
|
||||
{
|
||||
return FileManager::instance();
|
||||
}
|
||||
|
||||
MessageManager *MainWindow::messageManager() const
|
||||
{
|
||||
return m_messageManager;
|
||||
@@ -1237,7 +1232,7 @@ void MainWindow::writeSettings()
|
||||
|
||||
m_settings->endGroup();
|
||||
|
||||
FileManager::saveSettings();
|
||||
DocumentManager::saveSettings();
|
||||
m_actionManager->saveSettings(m_settings);
|
||||
m_editorManager->saveSettings();
|
||||
m_navigationWidget->saveSettings(m_settings);
|
||||
@@ -1297,7 +1292,7 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
aci->menu()->clear();
|
||||
|
||||
bool hasRecentFiles = false;
|
||||
foreach (const FileManager::RecentFile &file, FileManager::recentFiles()) {
|
||||
foreach (const DocumentManager::RecentFile &file, DocumentManager::recentFiles()) {
|
||||
hasRecentFiles = true;
|
||||
QAction *action = aci->menu()->addAction(
|
||||
QDir::toNativeSeparators(Utils::withTildeHomePath(file.first)));
|
||||
@@ -1311,14 +1306,14 @@ void MainWindow::aboutToShowRecentFiles()
|
||||
aci->menu()->addSeparator();
|
||||
QAction *action = aci->menu()->addAction(QCoreApplication::translate(
|
||||
"Core", Core::Constants::TR_CLEAR_MENU));
|
||||
connect(action, SIGNAL(triggered()), FileManager::instance(), SLOT(clearRecentFiles()));
|
||||
connect(action, SIGNAL(triggered()), DocumentManager::instance(), SLOT(clearRecentFiles()));
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::openRecentFile()
|
||||
{
|
||||
if (const QAction *action = qobject_cast<const QAction*>(sender())) {
|
||||
const FileManager::RecentFile file = action->data().value<FileManager::RecentFile>();
|
||||
const DocumentManager::RecentFile file = action->data().value<DocumentManager::RecentFile>();
|
||||
editorManager()->openEditor(file.first, file.second, Core::EditorManager::ModeSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class ActionManager;
|
||||
class StatusBarWidget;
|
||||
class EditorManager;
|
||||
class ExternalToolManager;
|
||||
class FileManager;
|
||||
class DocumentManager;
|
||||
class HelpManager;
|
||||
class IWizard;
|
||||
class MessageManager;
|
||||
@@ -100,7 +100,6 @@ public:
|
||||
void openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags);
|
||||
|
||||
Core::ActionManager *actionManager() const;
|
||||
Core::FileManager *fileManager() const;
|
||||
Core::MessageManager *messageManager() const;
|
||||
Core::EditorManager *editorManager() const;
|
||||
Core::ProgressManager *progressManager() const;
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#define METATYPEDECLARATIONS_H
|
||||
|
||||
#include <coreplugin/messagemanager.h>
|
||||
#include <coreplugin/filemanager.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -50,9 +50,9 @@ class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(Core::MessageManager*)
|
||||
Q_DECLARE_METATYPE(Core::FileManager*)
|
||||
Q_DECLARE_METATYPE(Core::IFile*)
|
||||
Q_DECLARE_METATYPE(QList<Core::IFile*>)
|
||||
Q_DECLARE_METATYPE(Core::DocumentManager*)
|
||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
||||
Q_DECLARE_METATYPE(QList<Core::IDocument*>)
|
||||
Q_DECLARE_METATYPE(QList<Core::IEditor*>)
|
||||
Q_DECLARE_METATYPE(Core::EditorManager*)
|
||||
Q_DECLARE_METATYPE(Core::ICore*)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#include "textfile.h"
|
||||
#include "textdocument.h"
|
||||
#include "editormanager.h"
|
||||
|
||||
#include <QDebug>
|
||||
@@ -51,10 +51,10 @@ enum { debug = 0 };
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
class TextFilePrivate
|
||||
class TextDocumentPrivate
|
||||
{
|
||||
public:
|
||||
TextFilePrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
||||
TextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {}
|
||||
|
||||
Utils::TextFileFormat m_format;
|
||||
Utils::TextFileFormat::ReadResult m_readResult;
|
||||
@@ -63,23 +63,23 @@ public:
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
TextFile::TextFile(QObject *parent) :
|
||||
IFile(parent), d(new Internal::TextFilePrivate)
|
||||
TextDocument::TextDocument(QObject *parent) :
|
||||
IDocument(parent), d(new Internal::TextDocumentPrivate)
|
||||
{
|
||||
setCodec(Core::EditorManager::instance()->defaultTextCodec());
|
||||
}
|
||||
|
||||
TextFile::~TextFile()
|
||||
TextDocument::~TextDocument()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool TextFile::hasDecodingError() const
|
||||
bool TextDocument::hasDecodingError() const
|
||||
{
|
||||
return d->m_readResult == Utils::TextFileFormat::ReadEncodingError;
|
||||
}
|
||||
|
||||
QByteArray TextFile::decodingErrorSample() const
|
||||
QByteArray TextDocument::decodingErrorSample() const
|
||||
{
|
||||
return d->m_decodingErrorSample;
|
||||
}
|
||||
@@ -88,7 +88,7 @@ QByteArray TextFile::decodingErrorSample() const
|
||||
\brief Writes out text using the format obtained from the last read.
|
||||
*/
|
||||
|
||||
bool TextFile::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
||||
bool TextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const
|
||||
{
|
||||
return write(fileName, format(), data, errorMessage);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ bool TextFile::write(const QString &fileName, const QString &data, QString *erro
|
||||
\brief Writes out text using a custom format obtained.
|
||||
*/
|
||||
|
||||
bool TextFile::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
||||
bool TextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << this << fileName;
|
||||
@@ -108,7 +108,7 @@ bool TextFile::write(const QString &fileName, const Utils::TextFileFormat &forma
|
||||
\brief Autodetect format and read in a text file.
|
||||
*/
|
||||
|
||||
TextFile::ReadResult TextFile::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString)
|
||||
{
|
||||
d->m_readResult =
|
||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||
@@ -120,7 +120,7 @@ TextFile::ReadResult TextFile::read(const QString &fileName, QStringList *plainT
|
||||
\brief Autodetect format and read in a text file.
|
||||
*/
|
||||
|
||||
TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText, QString *errorString)
|
||||
TextDocument::ReadResult TextDocument::read(const QString &fileName, QString *plainText, QString *errorString)
|
||||
{
|
||||
d->m_readResult =
|
||||
Utils::TextFileFormat::readFile(fileName, codec(),
|
||||
@@ -128,12 +128,12 @@ TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText,
|
||||
return d->m_readResult;
|
||||
}
|
||||
|
||||
const QTextCodec *TextFile::codec() const
|
||||
const QTextCodec *TextDocument::codec() const
|
||||
{
|
||||
return d->m_format.codec;
|
||||
}
|
||||
|
||||
void TextFile::setCodec(const QTextCodec *codec)
|
||||
void TextDocument::setCodec(const QTextCodec *codec)
|
||||
{
|
||||
if (debug)
|
||||
qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray());
|
||||
@@ -144,7 +144,7 @@ void TextFile::setCodec(const QTextCodec *codec)
|
||||
\brief Returns the format obtained from the last call to read().
|
||||
*/
|
||||
|
||||
Utils::TextFileFormat TextFile::format() const
|
||||
Utils::TextFileFormat TextDocument::format() const
|
||||
{
|
||||
return d->m_format;
|
||||
}
|
||||
@@ -30,27 +30,27 @@
|
||||
**
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CORE_TEXTFILE_H
|
||||
#define CORE_TEXTFILE_H
|
||||
#ifndef CORE_TEXTDOCUMENT_H
|
||||
#define CORE_TEXTDOCUMENT_H
|
||||
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
|
||||
#include <utils/textfileformat.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
class TextFilePrivate;
|
||||
class TextDocumentPrivate;
|
||||
}
|
||||
|
||||
class CORE_EXPORT TextFile : public IFile
|
||||
class CORE_EXPORT TextDocument : public IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
typedef Utils::TextFileFormat::ReadResult ReadResult;
|
||||
|
||||
explicit TextFile(QObject *parent = 0);
|
||||
virtual ~TextFile();
|
||||
explicit TextDocument(QObject *parent = 0);
|
||||
virtual ~TextDocument();
|
||||
|
||||
Utils::TextFileFormat format() const;
|
||||
const QTextCodec *codec() const;
|
||||
@@ -66,9 +66,9 @@ public:
|
||||
bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const;
|
||||
|
||||
private:
|
||||
Internal::TextFilePrivate *d;
|
||||
Internal::TextDocumentPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
#endif // CORE_TEXTFILE_H
|
||||
#endif // CORE_TEXTDOCUMENT_H
|
||||
@@ -31,7 +31,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "variablemanager.h"
|
||||
#include "ifile.h"
|
||||
#include "idocument.h"
|
||||
#include "editormanager/ieditor.h"
|
||||
#include "editormanager/editormanager.h"
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "vcsmanager.h"
|
||||
#include "iversioncontrol.h"
|
||||
#include "icore.h"
|
||||
#include "filemanager.h"
|
||||
#include "documentmanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
@@ -181,7 +181,7 @@ void VcsManager::extensionsInitialized()
|
||||
// Change signal connections
|
||||
foreach (IVersionControl *versionControl, allVersionControls()) {
|
||||
connect(versionControl, SIGNAL(filesChanged(QStringList)),
|
||||
FileManager::instance(), SIGNAL(filesChangedInternally(QStringList)));
|
||||
DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)));
|
||||
connect(versionControl, SIGNAL(repositoryChanged(QString)),
|
||||
this, SIGNAL(repositoryChanged(QString)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user