summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/coreplugin')
-rw-r--r--src/plugins/coreplugin/actionmanager/commandmappings.cpp2
-rw-r--r--src/plugins/coreplugin/coreplugin.pro18
-rw-r--r--src/plugins/coreplugin/designmode.cpp4
-rw-r--r--src/plugins/coreplugin/dialogs/saveitemsdialog.cpp18
-rw-r--r--src/plugins/coreplugin/dialogs/saveitemsdialog.h8
-rw-r--r--src/plugins/coreplugin/dialogs/shortcutsettings.cpp4
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp (renamed from src/plugins/coreplugin/filemanager.cpp)512
-rw-r--r--src/plugins/coreplugin/documentmanager.h (renamed from src/plugins/coreplugin/filemanager.h)40
-rw-r--r--src/plugins/coreplugin/editmode.cpp2
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp206
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h24
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp46
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.h4
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.h4
-rw-r--r--src/plugins/coreplugin/editormanager/ieditorfactory.h6
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsmodel.cpp22
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsmodel.h4
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsview.cpp2
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp38
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp12
-rw-r--r--src/plugins/coreplugin/externaltool.cpp12
-rw-r--r--src/plugins/coreplugin/generalsettings.cpp2
-rw-r--r--src/plugins/coreplugin/icore.cpp9
-rw-r--r--src/plugins/coreplugin/icore.h4
-rw-r--r--src/plugins/coreplugin/idocument.cpp (renamed from src/plugins/coreplugin/ifile.cpp)22
-rw-r--r--src/plugins/coreplugin/idocument.h (renamed from src/plugins/coreplugin/ifile.h)14
-rw-r--r--src/plugins/coreplugin/idocumentfactory.h (renamed from src/plugins/coreplugin/ifilefactory.h)14
-rw-r--r--src/plugins/coreplugin/mainwindow.cpp55
-rw-r--r--src/plugins/coreplugin/mainwindow.h3
-rw-r--r--src/plugins/coreplugin/scriptmanager/metatypedeclarations.h10
-rw-r--r--src/plugins/coreplugin/textdocument.cpp (renamed from src/plugins/coreplugin/textfile.cpp)30
-rw-r--r--src/plugins/coreplugin/textdocument.h (renamed from src/plugins/coreplugin/textfile.h)18
-rw-r--r--src/plugins/coreplugin/variablemanager.cpp2
-rw-r--r--src/plugins/coreplugin/vcsmanager.cpp4
34 files changed, 585 insertions, 590 deletions
diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
index 7709fff66c..01f9315af3 100644
--- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
@@ -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"
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro
index fe78c4b558..d7eb7b20b0 100644
--- a/src/plugins/coreplugin/coreplugin.pro
+++ b/src/plugins/coreplugin/coreplugin.pro
@@ -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 \
diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp
index bf9a33a2b0..47f19d36d5 100644
--- a/src/plugins/coreplugin/designmode.cpp
+++ b/src/plugins/coreplugin/designmode.cpp
@@ -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) {
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
index 2eb3dda40d..ecec8c00bb 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
@@ -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;
}
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.h b/src/plugins/coreplugin/dialogs/saveitemsdialog.h
index 384306f034..e4702f0dbc 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.h
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.h
@@ -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
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
index dd3f45c6fb..c55e5d862f 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
@@ -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)"));
diff --git a/src/plugins/coreplugin/filemanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 8736ea1aa8..9ab5362645 100644
--- a/src/plugins/coreplugin/filemanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -30,14 +30,14 @@
**
**************************************************************************/
-#include "filemanager.h"
+#include "documentmanager.h"
#include "editormanager.h"
#include "icore.h"
#include "ieditor.h"
#include "ieditorfactory.h"
#include "iexternaleditor.h"
-#include "ifile.h"
+#include "idocument.h"
#include "iversioncontrol.h"
#include "mimedatabase.h"
#include "saveitemsdialog.h"
@@ -64,26 +64,26 @@
#include <QPushButton>
/*!
- \class Core::FileManager
+ \class Core::DocumentManager
\mainclass
- \inheaderfile filemanager.h
- \brief Manages a set of IFile objects.
+ \inheaderfile documentmanager.h
+ \brief Manages a set of IDocument objects.
- The FileManager service monitors a set of IFile's. Plugins should register
- files they work with at the service. The files the IFile's point to will be
- monitored at filesystem level. If a file changes, the status of the IFile's
+ The DocumentManager service monitors a set of IDocument's. Plugins should register
+ files they work with at the service. The files the IDocument's point to will be
+ monitored at filesystem level. If a file changes, the status of the IDocument's
will be adjusted accordingly. Furthermore, on application exit the user will
be asked to save all modified files.
- Different IFile objects in the set can point to the same file in the
- filesystem. The monitoring for a IFile can be blocked by blockFileChange(), and
+ Different IDocument objects in the set can point to the same file in the
+ filesystem. The monitoring for a IDocument can be blocked by blockFileChange(), and
enabled again by unblockFileChange().
The functions expectFileChange() and unexpectFileChange() mark a file change
- as expected. On expected file changes all IFile objects are notified to reload
+ as expected. On expected file changes all IDocument objects are notified to reload
themselves.
- The FileManager service also provides two convenience methods for saving
+ The DocumentManager service also provides two convenience methods for saving
files: saveModifiedFiles() and saveModifiedFilesSilently(). Both take a list
of FileInterfaces as an argument, and return the list of files which were
_not_ saved.
@@ -105,7 +105,7 @@ namespace Core {
static void readSettings();
-static QList<IFile *> saveModifiedFilesHelper(const QList<IFile *> &files,
+static QList<IDocument *> saveModifiedFilesHelper(const QList<IDocument *> &documents,
bool *cancelled, bool silently,
const QString &message,
const QString &alwaysSaveMessage = QString(),
@@ -129,24 +129,24 @@ struct FileStateItem
struct FileState
{
- QMap<IFile *, FileStateItem> lastUpdatedState;
+ QMap<IDocument *, FileStateItem> lastUpdatedState;
FileStateItem expected;
};
-struct FileManagerPrivate
+struct DocumentManagerPrivate
{
- explicit FileManagerPrivate(QMainWindow *mw);
+ explicit DocumentManagerPrivate(QMainWindow *mw);
QFileSystemWatcher *fileWatcher();
QFileSystemWatcher *linkWatcher();
QMap<QString, FileState> m_states;
QSet<QString> m_changedFiles;
- QList<IFile *> m_filesWithoutWatch;
- QMap<IFile *, QStringList> m_filesWithWatch;
+ QList<IDocument *> m_documentsWithoutWatch;
+ QMap<IDocument *, QStringList> m_documentsWithWatch;
QSet<QString> m_expectedFileNames;
- QList<FileManager::RecentFile> m_recentFiles;
+ QList<DocumentManager::RecentFile> m_recentFiles;
static const int m_maxRecentFiles = 7;
QString m_currentFile;
@@ -158,17 +158,17 @@ struct FileManagerPrivate
QString m_lastVisitedDirectory;
QString m_projectsDirectory;
bool m_useProjectsDirectory;
- // When we are callling into a IFile
+ // When we are callling into a IDocument
// we don't want to receive a changed()
// signal
// That makes the code easier
- IFile *m_blockedIFile;
+ IDocument *m_blockedIDocument;
};
-static FileManager *m_instance;
-static Internal::FileManagerPrivate *d;
+static DocumentManager *m_instance;
+static Internal::DocumentManagerPrivate *d;
-QFileSystemWatcher *FileManagerPrivate::fileWatcher()
+QFileSystemWatcher *DocumentManagerPrivate::fileWatcher()
{
if (!m_fileWatcher) {
m_fileWatcher= new QFileSystemWatcher(m_instance);
@@ -178,7 +178,7 @@ QFileSystemWatcher *FileManagerPrivate::fileWatcher()
return m_fileWatcher;
}
-QFileSystemWatcher *FileManagerPrivate::linkWatcher()
+QFileSystemWatcher *DocumentManagerPrivate::linkWatcher()
{
#ifdef Q_OS_UNIX
if (!m_linkWatcher) {
@@ -193,7 +193,7 @@ QFileSystemWatcher *FileManagerPrivate::linkWatcher()
#endif
}
-FileManagerPrivate::FileManagerPrivate(QMainWindow *mw) :
+DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
m_mainWindow(mw),
m_fileWatcher(0),
m_linkWatcher(0),
@@ -204,7 +204,7 @@ FileManagerPrivate::FileManagerPrivate(QMainWindow *mw) :
#else
m_useProjectsDirectory(false),
#endif
- m_blockedIFile(0)
+ m_blockedIDocument(0)
{
}
@@ -217,10 +217,10 @@ namespace Core {
using namespace Internal;
-FileManager::FileManager(QMainWindow *mw)
+DocumentManager::DocumentManager(QMainWindow *mw)
: QObject(mw)
{
- d = new FileManagerPrivate(mw);
+ d = new DocumentManagerPrivate(mw);
m_instance = this;
connect(d->m_mainWindow, SIGNAL(windowActivated()),
this, SLOT(mainWindowActivated()));
@@ -230,18 +230,18 @@ FileManager::FileManager(QMainWindow *mw)
readSettings();
}
-FileManager::~FileManager()
+DocumentManager::~DocumentManager()
{
delete d;
}
-FileManager *FileManager::instance()
+DocumentManager *DocumentManager::instance()
{
return m_instance;
}
-/* only called from addFileInfo(IFile *) */
-static void addFileInfo(const QString &fileName, IFile *file, bool isLink)
+/* only called from addFileInfo(IDocument *) */
+static void addFileInfo(const QString &fileName, IDocument *document, bool isLink)
{
FileStateItem state;
if (!fileName.isEmpty()) {
@@ -261,67 +261,67 @@ static void addFileInfo(const QString &fileName, IFile *file, bool isLink)
if (!watcher->files().contains(fileName))
watcher->addPath(fileName);
- d->m_states[fileName].lastUpdatedState.insert(file, state);
+ d->m_states[fileName].lastUpdatedState.insert(document, state);
}
- d->m_filesWithWatch[file].append(fileName); // inserts a new QStringList if not already there
+ d->m_documentsWithWatch[document].append(fileName); // inserts a new QStringList if not already there
}
-/* Adds the IFile's file and possibly it's final link target to both m_states
+/* Adds the IDocument's file and possibly it's final link target to both m_states
(if it's file name is not empty), and the m_filesWithWatch list,
and adds a file watcher for each if not already done.
(The added file names are guaranteed to be absolute and cleaned.) */
-static void addFileInfo(IFile *file)
+static void addFileInfo(IDocument *document)
{
- const QString fixedName = FileManager::fixFileName(file->fileName(), FileManager::KeepLinks);
- const QString fixedResolvedName = FileManager::fixFileName(file->fileName(), FileManager::ResolveLinks);
- addFileInfo(fixedResolvedName, file, false);
+ const QString fixedName = DocumentManager::fixFileName(document->fileName(), DocumentManager::KeepLinks);
+ const QString fixedResolvedName = DocumentManager::fixFileName(document->fileName(), DocumentManager::ResolveLinks);
+ addFileInfo(fixedResolvedName, document, false);
if (fixedName != fixedResolvedName)
- addFileInfo(fixedName, file, true);
+ addFileInfo(fixedName, document, true);
}
/*!
- \fn bool FileManager::addFiles(const QList<IFile *> &files, bool addWatcher)
+ \fn bool DocumentManager::addFiles(const QList<IDocument *> &documents, bool addWatcher)
- Adds a list of IFile's to the collection. If \a addWatcher is true (the default),
+ Adds a list of IDocument's to the collection. If \a addWatcher is true (the default),
the files are added to a file system watcher that notifies the file manager
about file changes.
*/
-void FileManager::addFiles(const QList<IFile *> &files, bool addWatcher)
+void DocumentManager::addDocuments(const QList<IDocument *> &documents, bool addWatcher)
{
if (!addWatcher) {
// We keep those in a separate list
- foreach (IFile *file, files) {
- if (file && !d->m_filesWithoutWatch.contains(file)) {
- connect(file, SIGNAL(destroyed(QObject *)), m_instance, SLOT(fileDestroyed(QObject *)));
- d->m_filesWithoutWatch.append(file);
+ foreach (IDocument *document, documents) {
+ if (document && !d->m_documentsWithoutWatch.contains(document)) {
+ connect(document, SIGNAL(destroyed(QObject *)), m_instance, SLOT(documentDestroyed(QObject *)));
+ d->m_documentsWithoutWatch.append(document);
}
}
return;
}
- foreach (IFile *file, files) {
- if (file && !d->m_filesWithWatch.contains(file)) {
- connect(file, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName()));
- connect(file, SIGNAL(destroyed(QObject *)), m_instance, SLOT(fileDestroyed(QObject *)));
- addFileInfo(file);
+ foreach (IDocument *document, documents) {
+ if (document && !d->m_documentsWithWatch.contains(document)) {
+ connect(document, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName()));
+ connect(document, SIGNAL(destroyed(QObject *)), m_instance, SLOT(documentDestroyed(QObject *)));
+ addFileInfo(document);
}
}
}
-/* Removes all occurrences of the IFile from m_filesWithWatch and m_states.
- If that results in a file no longer being referenced by any IFile, this
+/* Removes all occurrences of the IDocument from m_filesWithWatch and m_states.
+ If that results in a file no longer being referenced by any IDocument, this
also removes the file watcher.
*/
-static void removeFileInfo(IFile *file)
+static void removeFileInfo(IDocument *document)
{
- if (!d->m_filesWithWatch.contains(file))
+ if (!d->m_documentsWithWatch.contains(document))
return;
- foreach (const QString &fileName, d->m_filesWithWatch.value(file)) {
+ foreach (const QString &fileName, d->m_documentsWithWatch.value(document)) {
if (!d->m_states.contains(fileName))
continue;
- d->m_states[fileName].lastUpdatedState.remove(file);
+ d->m_states[fileName].lastUpdatedState.remove(document);
if (d->m_states.value(fileName).lastUpdatedState.isEmpty()) {
if (d->m_fileWatcher && d->m_fileWatcher->files().contains(fileName))
d->m_fileWatcher->removePath(fileName);
@@ -330,7 +330,7 @@ static void removeFileInfo(IFile *file)
d->m_states.remove(fileName);
}
}
- d->m_filesWithWatch.remove(file);
+ d->m_documentsWithWatch.remove(document);
}
/// Dumps the state of the file manager's map
@@ -346,7 +346,7 @@ static void dump()
qDebug() << it.key();
qDebug() << " expected:" << it.value().expected.modified;
- QMap<IFile *, FileStateItem>::const_iterator jt, jend;
+ QMap<IDocument *, FileStateItem>::const_iterator jt, jend;
jt = it.value().lastUpdatedState.constBegin();
jend = it.value().lastUpdatedState.constEnd();
for (; jt != jend; ++jt) {
@@ -354,7 +354,7 @@ static void dump()
}
}
qDebug() << "------- dumping files with watch list";
- foreach (IFile *key, d->m_filesWithWatch.keys()) {
+ foreach (IDocument *key, d->m_filesWithWatch.keys()) {
qDebug() << key->fileName() << d->m_filesWithWatch.value(key);
}
qDebug() << "------- dumping watch list";
@@ -367,105 +367,105 @@ static void dump()
*/
/*!
- \fn void FileManager::renamedFile(const QString &from, const QString &to)
+ \fn void DocumentManager::renamedFile(const QString &from, const QString &to)
\brief Tells the file manager that a file has been renamed on disk from within Qt Creator.
Needs to be called right after the actual renaming on disk (i.e. before the file system
watcher can report the event during the next event loop run). \a from needs to be an absolute file path.
- This will notify all IFile objects pointing to that file of the rename
- by calling IFile::rename, and update the cached time and permission
+ This will notify all IDocument objects pointing to that file of the rename
+ by calling IDocument::rename, and update the cached time and permission
information to avoid annoying the user with "file has been removed"
popups.
*/
-void FileManager::renamedFile(const QString &from, const QString &to)
+void DocumentManager::renamedFile(const QString &from, const QString &to)
{
const QString &fixedFrom = fixFileName(from, KeepLinks);
- // gather the list of IFiles
- QList<IFile *> filesToRename;
- QMapIterator<IFile *, QStringList> it(d->m_filesWithWatch);
+ // gather the list of IDocuments
+ QList<IDocument *> documentsToRename;
+ QMapIterator<IDocument *, QStringList> it(d->m_documentsWithWatch);
while (it.hasNext()) {
it.next();
if (it.value().contains(fixedFrom))
- filesToRename.append(it.key());
+ documentsToRename.append(it.key());
}
- // rename the IFiles
- foreach (IFile *file, filesToRename) {
- d->m_blockedIFile = file;
- removeFileInfo(file);
- file->rename(to);
- addFileInfo(file);
- d->m_blockedIFile = 0;
+ // rename the IDocuments
+ foreach (IDocument *document, documentsToRename) {
+ d->m_blockedIDocument = document;
+ removeFileInfo(document);
+ document->rename(to);
+ addFileInfo(document);
+ d->m_blockedIDocument = 0;
}
}
/*!
- \fn bool FileManager::addFile(IFile *files, bool addWatcher)
+ \fn bool DocumentManager::addFile(IDocument *document, bool addWatcher)
- Adds a IFile object to the collection. If \a addWatcher is true (the default),
+ Adds a IDocument object to the collection. If \a addWatcher is true (the default),
the file is added to a file system watcher that notifies the file manager
about file changes.
*/
-void FileManager::addFile(IFile *file, bool addWatcher)
+void DocumentManager::addDocument(IDocument *document, bool addWatcher)
{
- addFiles(QList<IFile *>() << file, addWatcher);
+ addDocuments(QList<IDocument *>() << document, addWatcher);
}
-void FileManager::fileDestroyed(QObject *obj)
+void DocumentManager::documentDestroyed(QObject *obj)
{
- IFile *file = static_cast<IFile*>(obj);
+ IDocument *document = static_cast<IDocument*>(obj);
// Check the special unwatched first:
- if (!d->m_filesWithoutWatch.removeOne(file))
- removeFileInfo(file);
+ if (!d->m_documentsWithoutWatch.removeOne(document))
+ removeFileInfo(document);
}
/*!
- \fn bool FileManager::removeFile(IFile *file)
+ \fn bool DocumentManager::removeFile(IDocument *document)
- Removes a IFile object from the collection.
+ Removes a IDocument object from the collection.
- Returns true if the file specified by \a file had the addWatcher argument to addFile() set.
+ Returns true if the file specified by \a document had the addWatcher argument to addDocument() set.
*/
-bool FileManager::removeFile(IFile *file)
+bool DocumentManager::removeDocument(IDocument *document)
{
- QTC_ASSERT(file, return false);
+ QTC_ASSERT(document, return false);
bool addWatcher = false;
// Special casing unwatched files
- if (!d->m_filesWithoutWatch.removeOne(file)) {
+ if (!d->m_documentsWithoutWatch.removeOne(document)) {
addWatcher = true;
- removeFileInfo(file);
- disconnect(file, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName()));
+ removeFileInfo(document);
+ disconnect(document, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName()));
}
- disconnect(file, SIGNAL(destroyed(QObject *)), m_instance, SLOT(fileDestroyed(QObject *)));
+ disconnect(document, SIGNAL(destroyed(QObject *)), m_instance, SLOT(documentDestroyed(QObject *)));
return addWatcher;
}
-/* Slot reacting on IFile::changed. We need to check if the signal was sent
+/* Slot reacting on IDocument::changed. We need to check if the signal was sent
because the file was saved under different name. */
-void FileManager::checkForNewFileName()
+void DocumentManager::checkForNewFileName()
{
- IFile *file = qobject_cast<IFile *>(sender());
- // We modified the IFile
+ IDocument *document = qobject_cast<IDocument *>(sender());
+ // We modified the IDocument
// Trust the other code to also update the m_states map
- if (file == d->m_blockedIFile)
+ if (document == d->m_blockedIDocument)
return;
- QTC_ASSERT(file, return);
- QTC_ASSERT(d->m_filesWithWatch.contains(file), return);
+ QTC_ASSERT(document, return);
+ QTC_ASSERT(d->m_documentsWithWatch.contains(document), return);
// Maybe the name has changed or file has been deleted and created again ...
// This also updates the state to the on disk state
- removeFileInfo(file);
- addFileInfo(file);
+ removeFileInfo(document);
+ addFileInfo(document);
}
/*!
- \fn QString FileManager::fixFileName(const QString &fileName, FixMode fixmode)
+ \fn QString DocumentManager::fixFileName(const QString &fileName, FixMode fixmode)
Returns a guaranteed cleaned path in native form. If the file exists,
it will either be a cleaned absolute file path (fixmode == KeepLinks), or
a cleaned canonical file path (fixmode == ResolveLinks).
*/
-QString FileManager::fixFileName(const QString &fileName, FixMode fixmode)
+QString DocumentManager::fixFileName(const QString &fileName, FixMode fixmode)
{
QString s = fileName;
QFileInfo fi(s);
@@ -485,35 +485,35 @@ QString FileManager::fixFileName(const QString &fileName, FixMode fixmode)
}
/*!
- \fn QList<IFile*> FileManager::modifiedFiles() const
+ \fn QList<IDocument*> DocumentManager::modifiedFiles() const
- Returns the list of IFile's that have been modified.
+ Returns the list of IDocument's that have been modified.
*/
-QList<IFile *> FileManager::modifiedFiles()
+QList<IDocument *> DocumentManager::modifiedDocuments()
{
- QList<IFile *> modifiedFiles;
+ QList<IDocument *> modified;
- foreach (IFile *file, d->m_filesWithWatch.keys()) {
- if (file->isModified())
- modifiedFiles << file;
+ foreach (IDocument *document, d->m_documentsWithWatch.keys()) {
+ if (document->isModified())
+ modified << document;
}
- foreach(IFile *file, d->m_filesWithoutWatch) {
- if (file->isModified())
- modifiedFiles << file;
+ foreach (IDocument *document, d->m_documentsWithoutWatch) {
+ if (document->isModified())
+ modified << document;
}
- return modifiedFiles;
+ return modified;
}
/*!
- \fn void FileManager::expectFileChange(const QString &fileName)
+ \fn void DocumentManager::expectFileChange(const QString &fileName)
Any subsequent change to \a fileName is treated as a expected file change.
- \see FileManager::unexpectFileChange(const QString &fileName)
+ \see DocumentManager::unexpectFileChange(const QString &fileName)
*/
-void FileManager::expectFileChange(const QString &fileName)
+void DocumentManager::expectFileChange(const QString &fileName)
{
if (fileName.isEmpty())
return;
@@ -533,13 +533,13 @@ static void updateExpectedState(const QString &fileName)
}
/*!
- \fn void FileManager::unexpectFileChange(const QString &fileName)
+ \fn void DocumentManager::unexpectFileChange(const QString &fileName)
Any change to \a fileName are unexpected again.
- \see FileManager::expectFileChange(const QString &fileName)
+ \see DocumentManager::expectFileChange(const QString &fileName)
*/
-void FileManager::unexpectFileChange(const QString &fileName)
+void DocumentManager::unexpectFileChange(const QString &fileName)
{
// We are updating the expected time of the file
// And in changedFile we'll check if the modification time
@@ -557,20 +557,20 @@ void FileManager::unexpectFileChange(const QString &fileName)
}
/*!
- \fn QList<IFile*> FileManager::saveModifiedFilesSilently(const QList<IFile*> &files)
+ \fn QList<IDocument*> DocumentManager::saveModifiedFilesSilently(const QList<IDocument*> &documents)
- Tries to save the files listed in \a files. The \a cancelled argument is set to true
+ Tries to save the files listed in \a documents. The \a cancelled argument is set to true
if the user cancelled the dialog. Returns the files that could not be saved.
*/
-QList<IFile *> FileManager::saveModifiedFilesSilently(const QList<IFile *> &files, bool *cancelled)
+QList<IDocument *> DocumentManager::saveModifiedDocumentsSilently(const QList<IDocument *> &documents, bool *cancelled)
{
- return saveModifiedFilesHelper(files, cancelled, true, QString());
+ return saveModifiedFilesHelper(documents, cancelled, true, QString());
}
/*!
- \fn QList<IFile*> FileManager::saveModifiedFiles(const QList<IFile *> &files, bool *cancelled, const QString &message, const QString &alwaysSaveMessage, bool *alwaysSave)
+ \fn QList<IDocument*> DocumentManager::saveModifiedFiles(const QList<IDocument *> &documents, bool *cancelled, const QString &message, const QString &alwaysSaveMessage, bool *alwaysSave)
- Asks the user whether to save the files listed in \a files .
+ Asks the user whether to save the files listed in \a documents .
Opens a dialog with the given \a message, and a additional
text that should be used to ask if the user wants to enabled automatic save
of modified files (in this context).
@@ -579,15 +579,15 @@ QList<IFile *> FileManager::saveModifiedFilesSilently(const QList<IFile *> &file
always automatically be saved.
Returns the files that have not been saved.
*/
-QList<IFile *> FileManager::saveModifiedFiles(const QList<IFile *> &files,
+QList<IDocument *> DocumentManager::saveModifiedDocuments(const QList<IDocument *> &documents,
bool *cancelled, const QString &message,
const QString &alwaysSaveMessage,
bool *alwaysSave)
{
- return saveModifiedFilesHelper(files, cancelled, false, message, alwaysSaveMessage, alwaysSave);
+ return saveModifiedFilesHelper(documents, cancelled, false, message, alwaysSaveMessage, alwaysSave);
}
-static QList<IFile *> saveModifiedFilesHelper(const QList<IFile *> &files,
+static QList<IDocument *> saveModifiedFilesHelper(const QList<IDocument *> &documents,
bool *cancelled,
bool silently,
const QString &message,
@@ -597,30 +597,30 @@ static QList<IFile *> saveModifiedFilesHelper(const QList<IFile *> &files,
if (cancelled)
(*cancelled) = false;
- QList<IFile *> notSaved;
- QMap<IFile *, QString> modifiedFilesMap;
- QList<IFile *> modifiedFiles;
+ QList<IDocument *> notSaved;
+ QMap<IDocument *, QString> modifiedDocumentsMap;
+ QList<IDocument *> modifiedDocuments;
- foreach (IFile *file, files) {
- if (file->isModified()) {
- QString name = file->fileName();
+ foreach (IDocument *document, documents) {
+ if (document->isModified()) {
+ QString name = document->fileName();
if (name.isEmpty())
- name = file->suggestedFileName();
+ name = document->suggestedFileName();
- // There can be several IFiles pointing to the same file
+ // There can be several IDocuments pointing to the same file
// Prefer one that is not readonly
- // (even though it *should* not happen that the IFiles are inconsistent with readonly)
- if (!modifiedFilesMap.key(name, 0) || !file->isReadOnly())
- modifiedFilesMap.insert(file, name);
+ // (even though it *should* not happen that the IDocuments are inconsistent with readonly)
+ if (!modifiedDocumentsMap.key(name, 0) || !document->isFileReadOnly())
+ modifiedDocumentsMap.insert(document, name);
}
}
- modifiedFiles = modifiedFilesMap.keys();
- if (!modifiedFiles.isEmpty()) {
- QList<IFile *> filesToSave;
+ modifiedDocuments = modifiedDocumentsMap.keys();
+ if (!modifiedDocuments.isEmpty()) {
+ QList<IDocument *> documentsToSave;
if (silently) {
- filesToSave = modifiedFiles;
+ documentsToSave = modifiedDocuments;
} else {
- SaveItemsDialog dia(d->m_mainWindow, modifiedFiles);
+ SaveItemsDialog dia(d->m_mainWindow, modifiedDocuments);
if (!message.isEmpty())
dia.setMessage(message);
if (!alwaysSaveMessage.isNull())
@@ -630,34 +630,34 @@ static QList<IFile *> saveModifiedFilesHelper(const QList<IFile *> &files,
(*cancelled) = true;
if (alwaysSave)
*alwaysSave = dia.alwaysSaveChecked();
- notSaved = modifiedFiles;
+ notSaved = modifiedDocuments;
return notSaved;
}
if (alwaysSave)
*alwaysSave = dia.alwaysSaveChecked();
- filesToSave = dia.itemsToSave();
+ documentsToSave = dia.itemsToSave();
}
- foreach (IFile *file, filesToSave) {
- if (!EditorManager::instance()->saveFile(file)) {
+ foreach (IDocument *document, documentsToSave) {
+ if (!EditorManager::instance()->saveDocument(document)) {
if (cancelled)
*cancelled = true;
- notSaved.append(file);
+ notSaved.append(document);
}
}
}
return notSaved;
}
-bool FileManager::saveFile(IFile *file, const QString &fileName, bool *isReadOnly)
+bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, bool *isReadOnly)
{
bool ret = true;
- QString effName = fileName.isEmpty() ? file->fileName() : fileName;
- expectFileChange(effName); // This only matters to other IFiles which refer to this file
- bool addWatcher = removeFile(file); // So that our own IFile gets no notification at all
+ QString effName = fileName.isEmpty() ? document->fileName() : fileName;
+ expectFileChange(effName); // This only matters to other IDocuments which refer to this file
+ bool addWatcher = removeDocument(document); // So that our own IDocument gets no notification at all
QString errorString;
- if (!file->save(&errorString, fileName, false)) {
+ if (!document->save(&errorString, fileName, false)) {
if (isReadOnly) {
QFile ofi(effName);
// Check whether the existing file is writable
@@ -672,12 +672,12 @@ bool FileManager::saveFile(IFile *file, const QString &fileName, bool *isReadOnl
ret = false;
}
- addFile(file, addWatcher);
+ addDocument(document, addWatcher);
unexpectFileChange(effName);
return ret;
}
-QString FileManager::getSaveFileName(const QString &title, const QString &pathIn,
+QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn,
const QString &filter, QString *selectedFilter)
{
const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn;
@@ -724,7 +724,7 @@ QString FileManager::getSaveFileName(const QString &title, const QString &pathIn
return fileName;
}
-QString FileManager::getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
+QString DocumentManager::getSaveFileNameWithExtension(const QString &title, const QString &pathIn,
const QString &filter)
{
QString selected = filter;
@@ -732,21 +732,21 @@ QString FileManager::getSaveFileNameWithExtension(const QString &title, const QS
}
/*!
- \fn QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QString *selectedFilter)
+ \fn QString DocumentManager::getSaveAsFileName(IDocument *document, const QString &filter, QString *selectedFilter)
- Asks the user for a new file name (Save File As) for /arg file.
+ Asks the user for a new file name (Save File As) for /arg document.
*/
-QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QString *selectedFilter)
+QString DocumentManager::getSaveAsFileName(IDocument *document, const QString &filter, QString *selectedFilter)
{
- if (!file)
+ if (!document)
return QLatin1String("");
- QString absoluteFilePath = file->fileName();
+ QString absoluteFilePath = document->fileName();
const QFileInfo fi(absoluteFilePath);
QString fileName = fi.fileName();
QString path = fi.absolutePath();
if (absoluteFilePath.isEmpty()) {
- fileName = file->suggestedFileName();
- const QString defaultPath = file->defaultPath();
+ fileName = document->suggestedFileName();
+ const QString defaultPath = document->defaultPath();
if (!defaultPath.isEmpty())
path = defaultPath;
}
@@ -768,7 +768,7 @@ QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QStri
}
/*!
- \fn QStringList FileManager::getOpenFileNames(const QString &filters,
+ \fn QStringList DocumentManager::getOpenFileNames(const QString &filters,
const QString pathIn,
QString *selectedFilter)
@@ -778,7 +778,7 @@ QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QStri
in, if that is not overridden by the users policy.
*/
-QStringList FileManager::getOpenFileNames(const QString &filters,
+QStringList DocumentManager::getOpenFileNames(const QString &filters,
const QString pathIn,
QString *selectedFilter)
{
@@ -798,8 +798,8 @@ QStringList FileManager::getOpenFileNames(const QString &filters,
return files;
}
-FileManager::ReadOnlyAction
- FileManager::promptReadOnlyFile(const QString &fileName,
+DocumentManager::ReadOnlyAction
+ DocumentManager::promptReadOnlyFile(const QString &fileName,
const IVersionControl *versionControl,
QWidget *parent,
bool displaySaveAsButton)
@@ -840,7 +840,7 @@ FileManager::ReadOnlyAction
return RO_Cancel;
}
-void FileManager::changedFile(const QString &fileName)
+void DocumentManager::changedFile(const QString &fileName)
{
const bool wasempty = d->m_changedFiles.isEmpty();
@@ -852,7 +852,7 @@ void FileManager::changedFile(const QString &fileName)
}
}
-void FileManager::mainWindowActivated()
+void DocumentManager::mainWindowActivated()
{
//we need to do this asynchronously because
//opening a dialog ("Reload?") in a windowactivated event
@@ -860,7 +860,7 @@ void FileManager::mainWindowActivated()
QTimer::singleShot(0, this, SLOT(checkForReload()));
}
-void FileManager::checkForReload()
+void DocumentManager::checkForReload()
{
if (d->m_changedFiles.isEmpty())
return;
@@ -872,30 +872,30 @@ void FileManager::checkForReload()
d->m_blockActivated = true;
- IFile::ReloadSetting defaultBehavior = EditorManager::instance()->reloadSetting();
+ IDocument::ReloadSetting defaultBehavior = EditorManager::instance()->reloadSetting();
Utils::ReloadPromptAnswer previousAnswer = Utils::ReloadCurrent;
QList<IEditor*> editorsToClose;
- QMap<IFile*, QString> filesToSave;
+ QMap<IDocument*, QString> documentsToSave;
// collect file information
QMap<QString, FileStateItem> currentStates;
- QMap<QString, IFile::ChangeType> changeTypes;
- QSet<IFile *> changedIFiles;
+ QMap<QString, IDocument::ChangeType> changeTypes;
+ QSet<IDocument *> changedIDocuments;
foreach (const QString &fileName, d->m_changedFiles) {
- IFile::ChangeType type = IFile::TypeContents;
+ IDocument::ChangeType type = IDocument::TypeContents;
FileStateItem state;
QFileInfo fi(fileName);
if (!fi.exists()) {
- type = IFile::TypeRemoved;
+ type = IDocument::TypeRemoved;
} else {
state.modified = fi.lastModified();
state.permissions = fi.permissions();
}
currentStates.insert(fileName, state);
changeTypes.insert(fileName, type);
- foreach (IFile *file, d->m_states.value(fileName).lastUpdatedState.keys())
- changedIFiles.insert(file);
+ foreach (IDocument *document, d->m_states.value(fileName).lastUpdatedState.keys())
+ changedIDocuments.insert(document);
}
// clean up. do this before we may enter the main loop, otherwise we would
@@ -915,23 +915,23 @@ void FileManager::checkForReload()
expectedFileNames.insert(fixedResolvedName);
}
- // handle the IFiles
+ // handle the IDocuments
QStringList errorStrings;
- foreach (IFile *file, changedIFiles) {
- IFile::ChangeTrigger trigger = IFile::TriggerInternal;
- IFile::ChangeType type = IFile::TypePermissions;
+ foreach (IDocument *document, changedIDocuments) {
+ IDocument::ChangeTrigger trigger = IDocument::TriggerInternal;
+ IDocument::ChangeType type = IDocument::TypePermissions;
bool changed = false;
// find out the type & behavior from the two possible files
// behavior is internal if all changes are expected (and none removed)
// type is "max" of both types (remove > contents > permissions)
- foreach (const QString & fileName, d->m_filesWithWatch.value(file)) {
+ foreach (const QString & fileName, d->m_documentsWithWatch.value(document)) {
// was the file reported?
if (!currentStates.contains(fileName))
continue;
FileStateItem currentState = currentStates.value(fileName);
FileStateItem expectedState = d->m_states.value(fileName).expected;
- FileStateItem lastState = d->m_states.value(fileName).lastUpdatedState.value(file);
+ FileStateItem lastState = d->m_states.value(fileName).lastUpdatedState.value(document);
// did the file actually change?
if (lastState.modified == currentState.modified && lastState.permissions == currentState.permissions)
@@ -945,15 +945,15 @@ void FileManager::checkForReload()
// was the change unexpected?
if ((currentState.modified != expectedState.modified || currentState.permissions != expectedState.permissions)
&& !expectedFileNames.contains(fileName)) {
- trigger = IFile::TriggerExternal;
+ trigger = IDocument::TriggerExternal;
}
// find out the type
- IFile::ChangeType fileChange = changeTypes.value(fileName);
- if (fileChange == IFile::TypeRemoved) {
- type = IFile::TypeRemoved;
- } else if (fileChange == IFile::TypeContents && type == IFile::TypePermissions) {
- type = IFile::TypeContents;
+ IDocument::ChangeType fileChange = changeTypes.value(fileName);
+ if (fileChange == IDocument::TypeRemoved) {
+ type = IDocument::TypeRemoved;
+ } else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions) {
+ type = IDocument::TypeContents;
}
}
@@ -961,82 +961,82 @@ void FileManager::checkForReload()
continue;
// handle it!
- d->m_blockedIFile = file;
+ d->m_blockedIDocument = document;
bool success = true;
QString errorString;
// we've got some modification
// check if it's contents or permissions:
- if (type == IFile::TypePermissions) {
+ if (type == IDocument::TypePermissions) {
// Only permission change
- success = file->reload(&errorString, IFile::FlagReload, IFile::TypePermissions);
+ success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypePermissions);
// now we know it's a content change or file was removed
- } else if (defaultBehavior == IFile::ReloadUnmodified
- && type == IFile::TypeContents && !file->isModified()) {
+ } else if (defaultBehavior == IDocument::ReloadUnmodified
+ && type == IDocument::TypeContents && !document->isModified()) {
// content change, but unmodified (and settings say to reload in this case)
- success = file->reload(&errorString, IFile::FlagReload, type);
+ success = document->reload(&errorString, IDocument::FlagReload, type);
// file was removed or it's a content change and the default behavior for
// unmodified files didn't kick in
- } else if (defaultBehavior == IFile::ReloadUnmodified
- && type == IFile::TypeRemoved && !file->isModified()) {
+ } else if (defaultBehavior == IDocument::ReloadUnmodified
+ && type == IDocument::TypeRemoved && !document->isModified()) {
// file removed, but unmodified files should be reloaded
// so we close the file
- editorsToClose << EditorManager::instance()->editorsForFile(file);
- } else if (defaultBehavior == IFile::IgnoreAll) {
+ editorsToClose << EditorManager::instance()->editorsForDocument(document);
+ } else if (defaultBehavior == IDocument::IgnoreAll) {
// content change or removed, but settings say ignore
- success = file->reload(&errorString, IFile::FlagIgnore, type);
+ success = document->reload(&errorString, IDocument::FlagIgnore, type);
// either the default behavior is to always ask,
// or the ReloadUnmodified default behavior didn't kick in,
- // so do whatever the IFile wants us to do
+ // so do whatever the IDocument wants us to do
} else {
- // check if IFile wants us to ask
- if (file->reloadBehavior(trigger, type) == IFile::BehaviorSilent) {
- // content change or removed, IFile wants silent handling
- success = file->reload(&errorString, IFile::FlagReload, type);
- // IFile wants us to ask
- } else if (type == IFile::TypeContents) {
- // content change, IFile wants to ask user
+ // check if IDocument wants us to ask
+ if (document->reloadBehavior(trigger, type) == IDocument::BehaviorSilent) {
+ // content change or removed, IDocument wants silent handling
+ success = document->reload(&errorString, IDocument::FlagReload, type);
+ // IDocument wants us to ask
+ } else if (type == IDocument::TypeContents) {
+ // content change, IDocument wants to ask user
if (previousAnswer == Utils::ReloadNone) {
// answer already given, ignore
- success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents);
+ success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
} else if (previousAnswer == Utils::ReloadAll) {
// answer already given, reload
- success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents);
+ success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
} else {
// Ask about content change
- previousAnswer = Utils::reloadPrompt(file->fileName(), file->isModified(), QApplication::activeWindow());
+ previousAnswer = Utils::reloadPrompt(document->fileName(), document->isModified(), QApplication::activeWindow());
switch (previousAnswer) {
case Utils::ReloadAll:
case Utils::ReloadCurrent:
- success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents);
+ success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents);
break;
case Utils::ReloadSkipCurrent:
case Utils::ReloadNone:
- success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents);
+ success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents);
break;
}
}
- // IFile wants us to ask, and it's the TypeRemoved case
+ // IDocument wants us to ask, and it's the TypeRemoved case
} else {
// Ask about removed file
bool unhandled = true;
while (unhandled) {
- switch (Utils::fileDeletedPrompt(file->fileName(), trigger == IFile::TriggerExternal, QApplication::activeWindow())) {
+ switch (Utils::fileDeletedPrompt(document->fileName(), trigger == IDocument::TriggerExternal, QApplication::activeWindow())) {
case Utils::FileDeletedSave:
- filesToSave.insert(file, file->fileName());
+ documentsToSave.insert(document, document->fileName());
unhandled = false;
break;
case Utils::FileDeletedSaveAs:
{
- const QString &saveFileName = getSaveAsFileName(file);
+ const QString &saveFileName = getSaveAsFileName(document);
if (!saveFileName.isEmpty()) {
- filesToSave.insert(file, saveFileName);
+ documentsToSave.insert(document, saveFileName);
unhandled = false;
}
break;
}
case Utils::FileDeletedClose:
- editorsToClose << EditorManager::instance()->editorsForFile(file);
+ editorsToClose << EditorManager::instance()->editorsForDocument(document);
unhandled = false;
break;
}
@@ -1045,15 +1045,15 @@ void FileManager::checkForReload()
}
if (!success) {
if (errorString.isEmpty())
- errorStrings << tr("Cannot reload %1").arg(QDir::toNativeSeparators(file->fileName()));
+ errorStrings << tr("Cannot reload %1").arg(QDir::toNativeSeparators(document->fileName()));
else
errorStrings << errorString;
}
// update file info, also handling if e.g. link target has changed
- removeFileInfo(file);
- addFileInfo(file);
- d->m_blockedIFile = 0;
+ removeFileInfo(document);
+ addFileInfo(document);
+ d->m_blockedIDocument = 0;
}
if (!errorStrings.isEmpty())
QMessageBox::critical(d->m_mainWindow, tr("File Error"),
@@ -1061,10 +1061,10 @@ void FileManager::checkForReload()
// handle deleted files
EditorManager::instance()->closeEditors(editorsToClose, false);
- QMapIterator<IFile *, QString> it(filesToSave);
+ QMapIterator<IDocument *, QString> it(documentsToSave);
while (it.hasNext()) {
it.next();
- saveFile(it.key(), it.value());
+ saveDocument(it.key(), it.value());
it.key()->checkPermissions();
}
@@ -1073,7 +1073,7 @@ void FileManager::checkForReload()
// dump();
}
-void FileManager::syncWithEditor(Core::IContext *context)
+void DocumentManager::syncWithEditor(Core::IContext *context)
{
if (!context)
return;
@@ -1081,18 +1081,18 @@ void FileManager::syncWithEditor(Core::IContext *context)
Core::IEditor *editor = Core::EditorManager::instance()->currentEditor();
if (editor && (editor->widget() == context->widget()) &&
!editor->isTemporary())
- setCurrentFile(editor->file()->fileName());
+ setCurrentFile(editor->document()->fileName());
}
/*!
- \fn void FileManager::addToRecentFiles(const QString &fileName, const QString &editorId)
+ \fn void DocumentManager::addToRecentFiles(const QString &fileName, const QString &editorId)
Adds the \a fileName to the list of recent files. Associates the file to
be reopened with an editor of the given \a editorId, if possible.
\a editorId defaults to the empty id, which means to let the system figure out
the best editor itself.
*/
-void FileManager::addToRecentFiles(const QString &fileName, const Id &editorId)
+void DocumentManager::addToRecentFiles(const QString &fileName, const Id &editorId)
{
if (fileName.isEmpty())
return;
@@ -1100,7 +1100,7 @@ void FileManager::addToRecentFiles(const QString &fileName, const Id &editorId)
QMutableListIterator<RecentFile > it(d->m_recentFiles);
while (it.hasNext()) {
RecentFile file = it.next();
- QString recentUnifiedForm(fixFileName(file.first, FileManager::KeepLinks));
+ QString recentUnifiedForm(fixFileName(file.first, DocumentManager::KeepLinks));
if (unifiedForm == recentUnifiedForm)
it.remove();
}
@@ -1110,27 +1110,27 @@ void FileManager::addToRecentFiles(const QString &fileName, const Id &editorId)
}
/*!
- \fn void FileManager::clearRecentFiles()
+ \fn void DocumentManager::clearRecentFiles()
Clears the list of recent files. Should only be called by
the core plugin when the user chooses to clear it.
*/
-void FileManager::clearRecentFiles()
+void DocumentManager::clearRecentFiles()
{
d->m_recentFiles.clear();
}
/*!
- \fn QStringList FileManager::recentFiles() const
+ \fn QStringList DocumentManager::recentFiles() const
Returns the list of recent files.
*/
-QList<FileManager::RecentFile> FileManager::recentFiles()
+QList<DocumentManager::RecentFile> DocumentManager::recentFiles()
{
return d->m_recentFiles;
}
-void FileManager::saveSettings()
+void DocumentManager::saveSettings()
{
QStringList recentFiles;
QStringList recentEditorIds;
@@ -1165,7 +1165,7 @@ void readSettings()
if (ids.hasNext()) // guard against old or weird settings
editorId = ids.next();
if (QFileInfo(fileName).isFile())
- d->m_recentFiles.append(FileManager::RecentFile(QDir::fromNativeSeparators(fileName), // from native to guard against old settings
+ d->m_recentFiles.append(DocumentManager::RecentFile(QDir::fromNativeSeparators(fileName), // from native to guard against old settings
Id(editorId)));
}
@@ -1189,7 +1189,7 @@ void readSettings()
\sa currentFile
*/
-void FileManager::setCurrentFile(const QString &filePath)
+void DocumentManager::setCurrentFile(const QString &filePath)
{
if (d->m_currentFile == filePath)
return;
@@ -1205,7 +1205,7 @@ void FileManager::setCurrentFile(const QString &filePath)
\sa setCurrentFile
*/
-QString FileManager::currentFile()
+QString DocumentManager::currentFile()
{
return d->m_currentFile;
}
@@ -1218,7 +1218,7 @@ QString FileManager::currentFile()
\sa setFileDialogLastVisitedDirectory
*/
-QString FileManager::fileDialogInitialDirectory()
+QString DocumentManager::fileDialogInitialDirectory()
{
if (!d->m_currentFile.isEmpty())
return QFileInfo(d->m_currentFile).absolutePath();
@@ -1232,7 +1232,7 @@ QString FileManager::fileDialogInitialDirectory()
\sa setProjectsDirectory, setUseProjectsDirectory
*/
-QString FileManager::projectsDirectory()
+QString DocumentManager::projectsDirectory()
{
return d->m_projectsDirectory;
}
@@ -1244,7 +1244,7 @@ QString FileManager::projectsDirectory()
\sa projectsDirectory, useProjectsDirectory
*/
-void FileManager::setProjectsDirectory(const QString &dir)
+void DocumentManager::setProjectsDirectory(const QString &dir)
{
d->m_projectsDirectory = dir;
}
@@ -1257,7 +1257,7 @@ void FileManager::setProjectsDirectory(const QString &dir)
\sa setProjectsDirectory, setUseProjectsDirectory
*/
-bool FileManager::useProjectsDirectory()
+bool DocumentManager::useProjectsDirectory()
{
return d->m_useProjectsDirectory;
}
@@ -1269,7 +1269,7 @@ bool FileManager::useProjectsDirectory()
\sa projectsDirectory, useProjectsDirectory
*/
-void FileManager::setUseProjectsDirectory(bool useProjectsDirectory)
+void DocumentManager::setUseProjectsDirectory(bool useProjectsDirectory)
{
d->m_useProjectsDirectory = useProjectsDirectory;
}
@@ -1282,7 +1282,7 @@ void FileManager::setUseProjectsDirectory(bool useProjectsDirectory)
*/
-QString FileManager::fileDialogLastVisitedDirectory()
+QString DocumentManager::fileDialogLastVisitedDirectory()
{
return d->m_lastVisitedDirectory;
}
@@ -1296,17 +1296,17 @@ QString FileManager::fileDialogLastVisitedDirectory()
*/
-void FileManager::setFileDialogLastVisitedDirectory(const QString &directory)
+void DocumentManager::setFileDialogLastVisitedDirectory(const QString &directory)
{
d->m_lastVisitedDirectory = directory;
}
-void FileManager::notifyFilesChangedInternally(const QStringList &files)
+void DocumentManager::notifyFilesChangedInternally(const QStringList &files)
{
emit m_instance->filesChangedInternally(files);
}
-void FileManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
+void DocumentManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
{
typedef QList<IEditorFactory*> EditorFactoryList;
typedef QList<IExternalEditor*> ExternalEditorList;
@@ -1343,7 +1343,7 @@ void FileManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
menu->setEnabled(anyMatches);
}
-void FileManager::executeOpenWithMenuAction(QAction *action)
+void DocumentManager::executeOpenWithMenuAction(QAction *action)
{
QTC_ASSERT(action, return);
EditorManager *em = EditorManager::instance();
@@ -1368,7 +1368,7 @@ void FileManager::executeOpenWithMenuAction(QAction *action)
em->openExternalEditor(entry.fileName, entry.externalEditor->id());
}
-void FileManager::slotExecuteOpenWithMenuAction(QAction *action)
+void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action)
{
executeOpenWithMenuAction(action);
}
@@ -1378,12 +1378,12 @@ void FileManager::slotExecuteOpenWithMenuAction(QAction *action)
FileChangeBlocker::FileChangeBlocker(const QString &fileName)
: m_fileName(fileName)
{
- FileManager::expectFileChange(fileName);
+ DocumentManager::expectFileChange(fileName);
}
FileChangeBlocker::~FileChangeBlocker()
{
- FileManager::unexpectFileChange(m_fileName);
+ DocumentManager::unexpectFileChange(m_fileName);
}
} // namespace Core
diff --git a/src/plugins/coreplugin/filemanager.h b/src/plugins/coreplugin/documentmanager.h
index e569bc6088..7f59e50ecd 100644
--- a/src/plugins/coreplugin/filemanager.h
+++ b/src/plugins/coreplugin/documentmanager.h
@@ -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
diff --git a/src/plugins/coreplugin/editmode.cpp b/src/plugins/coreplugin/editmode.cpp
index 24a1aefd1e..e141b0160b 100644
--- a/src/plugins/coreplugin/editmode.cpp
+++ b/src/plugins/coreplugin/editmode.cpp
@@ -40,7 +40,7 @@
#include "navigationwidget.h"
#include "rightpane.h"
#include "ieditor.h"
-#include "ifile.h"
+#include "idocument.h"
#include <QLatin1String>
#include <QHBoxLayout>
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 26c9a7ef4f..b875f9ed9e 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -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();
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index 3df12fc46b..295e9926e2 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -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);
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 99090b4a14..1e628d09da 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -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;
diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h
index 40275797eb..e30d74a272 100644
--- a/src/plugins/coreplugin/editormanager/editorview.h
+++ b/src/plugins/coreplugin/editormanager/editorview.h
@@ -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;
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index f06b2e2cee..131b6b379c 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -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;
diff --git a/src/plugins/coreplugin/editormanager/ieditorfactory.h b/src/plugins/coreplugin/editormanager/ieditorfactory.h
index 9b45dc4d30..97e4860fc5 100644
--- a/src/plugins/coreplugin/editormanager/ieditorfactory.h
+++ b/src/plugins/coreplugin/editormanager/ieditorfactory.h
@@ -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;
};
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
index 2b9873cbe6..07241214b0 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
@@ -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();
}
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.h b/src/plugins/coreplugin/editormanager/openeditorsmodel.h
index 6c168ac331..98ac72a798 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.h
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.h
@@ -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();
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
index c7a232876f..b30112bc3d 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
@@ -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>
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 6264427095..112f074feb 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -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>(),
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index 17e3e62f74..1148a0c2ec 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -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())
);
}
diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp
index 8a9edc5584..51bba893fb 100644
--- a/src/plugins/coreplugin/externaltool.cpp
+++ b/src/plugins/coreplugin/externaltool.cpp
@@ -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();
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index 36e93d0a3c..87d2db42cf 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -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());
diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp
index 471cca42e0..ff9f8619fe 100644
--- a/src/plugins/coreplugin/icore.cpp
+++ b/src/plugins/coreplugin/icore.cpp
@@ -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()
diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h
index 14cd5f38d3..5b06c7fbf6 100644
--- a/src/plugins/coreplugin/icore.h
+++ b/src/plugins/coreplugin/icore.h
@@ -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();
diff --git a/src/plugins/coreplugin/ifile.cpp b/src/plugins/coreplugin/idocument.cpp
index a6c72d51d1..3799100751 100644
--- a/src/plugins/coreplugin/ifile.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -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;
diff --git a/src/plugins/coreplugin/ifile.h b/src/plugins/coreplugin/idocument.h
index 8e097cb002..8a2716d398 100644
--- a/src/plugins/coreplugin/ifile.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -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
diff --git a/src/plugins/coreplugin/ifilefactory.h b/src/plugins/coreplugin/idocumentfactory.h
index 5a4e5f0b43..95a80fd5f2 100644
--- a/src/plugins/coreplugin/ifilefactory.h
+++ b/src/plugins/coreplugin/idocumentfactory.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
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp
index b95c516191..baa881d204 100644
--- a/src/plugins/coreplugin/mainwindow.cpp
+++ b/src/plugins/coreplugin/mainwindow.cpp
@@ -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);
}
}
diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h
index 5c1d3af945..ed60198476 100644
--- a/src/plugins/coreplugin/mainwindow.h
+++ b/src/plugins/coreplugin/mainwindow.h
@@ -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;
diff --git a/src/plugins/coreplugin/scriptmanager/metatypedeclarations.h b/src/plugins/coreplugin/scriptmanager/metatypedeclarations.h
index 6126337f99..9b8aae94b8 100644
--- a/src/plugins/coreplugin/scriptmanager/metatypedeclarations.h
+++ b/src/plugins/coreplugin/scriptmanager/metatypedeclarations.h
@@ -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*)
diff --git a/src/plugins/coreplugin/textfile.cpp b/src/plugins/coreplugin/textdocument.cpp
index 54c64a8483..78a3447d7d 100644
--- a/src/plugins/coreplugin/textfile.cpp
+++ b/src/plugins/coreplugin/textdocument.cpp
@@ -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;
}
diff --git a/src/plugins/coreplugin/textfile.h b/src/plugins/coreplugin/textdocument.h
index 61a74d06c1..9fc5a89056 100644
--- a/src/plugins/coreplugin/textfile.h
+++ b/src/plugins/coreplugin/textdocument.h
@@ -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
diff --git a/src/plugins/coreplugin/variablemanager.cpp b/src/plugins/coreplugin/variablemanager.cpp
index 20c40bfa5e..7f66e6caf9 100644
--- a/src/plugins/coreplugin/variablemanager.cpp
+++ b/src/plugins/coreplugin/variablemanager.cpp
@@ -31,7 +31,7 @@
**************************************************************************/
#include "variablemanager.h"
-#include "ifile.h"
+#include "idocument.h"
#include "editormanager/ieditor.h"
#include "editormanager/editormanager.h"
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp
index cd9a33f47e..a36556e41a 100644
--- a/src/plugins/coreplugin/vcsmanager.cpp
+++ b/src/plugins/coreplugin/vcsmanager.cpp
@@ -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)));
}