From d66acb51d0c8b511df9f679806cbd3d84cce41ef Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 14 Feb 2012 16:43:51 +0100 Subject: Rename IFile->IDocument and FileManager->DocumentManager And adapt the other API respectively. Change-Id: I1e04e555409be09242db6890f9e013396f83aeed Reviewed-by: Bill King Reviewed-by: Eike Ziller --- doc/api/coding-style.qdoc | 2 +- doc/api/qtcreator-api.qdoc | 2 +- src/plugins/analyzerbase/analyzerutils.cpp | 2 +- .../autotoolsprojectmanager/autotoolsmanager.cpp | 4 +- .../autotoolsprojectmanager/autotoolsproject.cpp | 2 +- .../autotoolsprojectmanager/autotoolsproject.h | 2 +- .../autotoolsprojectfile.cpp | 2 +- .../autotoolsprojectmanager/autotoolsprojectfile.h | 6 +- .../autotoolsprojectnode.cpp | 2 +- .../autotoolsprojectmanager/autotoolsprojectnode.h | 6 +- src/plugins/bazaar/bazaarplugin.cpp | 10 +- src/plugins/bineditor/bineditorplugin.cpp | 22 +- src/plugins/bineditor/bineditorplugin.h | 2 +- src/plugins/bookmarks/bookmarkmanager.cpp | 10 +- src/plugins/bookmarks/bookmarksplugin.cpp | 2 +- src/plugins/classview/classviewmanager.cpp | 6 +- src/plugins/classview/classviewparser.cpp | 6 +- src/plugins/cmakeprojectmanager/cmakeeditor.cpp | 6 +- .../cmakeprojectmanager/cmakeeditorfactory.cpp | 4 +- .../cmakeprojectmanager/cmakeeditorfactory.h | 2 +- .../cmakeprojectmanager/cmakelocatorfilter.cpp | 6 +- src/plugins/cmakeprojectmanager/cmakeproject.cpp | 14 +- src/plugins/cmakeprojectmanager/cmakeproject.h | 6 +- .../coreplugin/actionmanager/commandmappings.cpp | 2 +- src/plugins/coreplugin/coreplugin.pro | 18 +- src/plugins/coreplugin/designmode.cpp | 4 +- src/plugins/coreplugin/dialogs/saveitemsdialog.cpp | 18 +- src/plugins/coreplugin/dialogs/saveitemsdialog.h | 8 +- .../coreplugin/dialogs/shortcutsettings.cpp | 4 +- src/plugins/coreplugin/documentmanager.cpp | 1389 ++++++++++++++++++++ src/plugins/coreplugin/documentmanager.h | 181 +++ src/plugins/coreplugin/editmode.cpp | 2 +- .../coreplugin/editormanager/editormanager.cpp | 206 +-- .../coreplugin/editormanager/editormanager.h | 24 +- .../coreplugin/editormanager/editorview.cpp | 46 +- src/plugins/coreplugin/editormanager/editorview.h | 4 +- src/plugins/coreplugin/editormanager/ieditor.h | 4 +- .../coreplugin/editormanager/ieditorfactory.h | 6 +- .../coreplugin/editormanager/openeditorsmodel.cpp | 22 +- .../coreplugin/editormanager/openeditorsmodel.h | 4 +- .../coreplugin/editormanager/openeditorsview.cpp | 2 +- .../coreplugin/editormanager/openeditorswindow.cpp | 38 +- src/plugins/coreplugin/editortoolbar.cpp | 12 +- src/plugins/coreplugin/externaltool.cpp | 12 +- src/plugins/coreplugin/filemanager.cpp | 1389 -------------------- src/plugins/coreplugin/filemanager.h | 181 --- src/plugins/coreplugin/generalsettings.cpp | 2 +- src/plugins/coreplugin/icore.cpp | 9 +- src/plugins/coreplugin/icore.h | 4 +- src/plugins/coreplugin/idocument.cpp | 116 ++ src/plugins/coreplugin/idocument.h | 129 ++ src/plugins/coreplugin/idocumentfactory.h | 64 + src/plugins/coreplugin/ifile.cpp | 116 -- src/plugins/coreplugin/ifile.h | 129 -- src/plugins/coreplugin/ifilefactory.h | 64 - src/plugins/coreplugin/mainwindow.cpp | 55 +- src/plugins/coreplugin/mainwindow.h | 3 +- .../scriptmanager/metatypedeclarations.h | 10 +- src/plugins/coreplugin/textdocument.cpp | 152 +++ src/plugins/coreplugin/textdocument.h | 74 ++ src/plugins/coreplugin/textfile.cpp | 152 --- src/plugins/coreplugin/textfile.h | 74 -- src/plugins/coreplugin/variablemanager.cpp | 2 +- src/plugins/coreplugin/vcsmanager.cpp | 4 +- src/plugins/cpaster/cpasterplugin.cpp | 2 +- src/plugins/cppeditor/cppeditor.cpp | 18 +- src/plugins/cppeditor/cppelementevaluator.cpp | 4 +- .../cppeditor/cppinsertqtpropertymembers.cpp | 2 +- src/plugins/cppeditor/cppoutline.cpp | 2 +- src/plugins/cppeditor/cppplugin.cpp | 4 +- src/plugins/cppeditor/cppplugin.h | 2 +- src/plugins/cppeditor/cppquickfix.cpp | 2 +- src/plugins/cppeditor/cppquickfixassistant.cpp | 2 +- src/plugins/cpptools/cppcompletionassist.cpp | 36 +- src/plugins/cpptools/cppcompletionassist.h | 6 +- src/plugins/cpptools/cppcompletionsupport.cpp | 4 +- src/plugins/cpptools/cppcompletionsupport.h | 2 +- src/plugins/cpptools/cppcurrentdocumentfilter.cpp | 4 +- src/plugins/cpptools/cppmodelmanager.cpp | 4 +- src/plugins/cpptools/cpptoolseditorsupport.cpp | 4 +- src/plugins/cpptools/cpptoolsplugin.cpp | 6 +- src/plugins/cvs/cvsplugin.cpp | 10 +- src/plugins/debugger/debuggerengine.cpp | 2 +- src/plugins/debugger/debuggerplugin.cpp | 20 +- src/plugins/debugger/debuggertooltipmanager.cpp | 16 +- src/plugins/debugger/disassembleragent.cpp | 2 +- src/plugins/debugger/gdb/gdbengine.cpp | 2 +- src/plugins/debugger/pdb/pdbengine.cpp | 4 +- src/plugins/debugger/qml/qmlv8debuggerclient.cpp | 2 +- src/plugins/debugger/script/scriptengine.cpp | 4 +- src/plugins/debugger/watchutils.cpp | 20 +- src/plugins/designer/formeditorfactory.cpp | 6 +- src/plugins/designer/formeditorfactory.h | 2 +- src/plugins/designer/formeditorw.cpp | 6 +- src/plugins/designer/formwindoweditor.cpp | 6 +- src/plugins/designer/formwindoweditor.h | 4 +- src/plugins/designer/formwindowfile.cpp | 2 +- src/plugins/designer/formwindowfile.h | 6 +- src/plugins/designer/qtcreatorintegration.cpp | 2 +- src/plugins/fakevim/fakevimplugin.cpp | 16 +- .../genericprojectmanager/genericproject.cpp | 28 +- src/plugins/genericprojectmanager/genericproject.h | 14 +- .../genericprojectfileseditor.cpp | 4 +- .../genericprojectfileseditor.h | 2 +- .../genericprojectmanager.cpp | 2 +- .../genericprojectmanager/genericprojectnodes.cpp | 6 +- .../genericprojectmanager/genericprojectnodes.h | 8 +- .../genericprojectmanager/genericprojectplugin.cpp | 2 +- src/plugins/git/gitclient.cpp | 6 +- src/plugins/git/gitplugin.cpp | 22 +- src/plugins/glsleditor/glslcompletionassist.cpp | 12 +- src/plugins/glsleditor/glslcompletionassist.h | 5 +- src/plugins/glsleditor/glsleditor.cpp | 2 +- src/plugins/glsleditor/glsleditorfactory.cpp | 4 +- src/plugins/glsleditor/glsleditorfactory.h | 2 +- src/plugins/imageviewer/imageviewer.cpp | 2 +- src/plugins/imageviewer/imageviewer.h | 4 +- src/plugins/imageviewer/imageviewerfactory.cpp | 2 +- src/plugins/imageviewer/imageviewerfactory.h | 4 +- src/plugins/imageviewer/imageviewerfile.cpp | 6 +- src/plugins/imageviewer/imageviewerfile.h | 4 +- src/plugins/locator/filesystemfilter.cpp | 4 +- src/plugins/locator/opendocumentsfilter.cpp | 2 +- src/plugins/madde/maemoglobal.h | 6 +- src/plugins/madde/maemopublisherfremantlefree.cpp | 4 +- src/plugins/madde/qt4maemotarget.cpp | 6 +- src/plugins/mercurial/mercurialplugin.cpp | 6 +- src/plugins/perforce/perforceplugin.cpp | 8 +- .../projectexplorer/baseprojectwizarddialog.cpp | 6 +- src/plugins/projectexplorer/currentprojectfind.cpp | 8 +- src/plugins/projectexplorer/dependenciespanel.cpp | 4 +- .../projectexplorer/editorconfiguration.cpp | 2 +- .../projectexplorer/foldernavigationwidget.cpp | 12 +- .../projectexplorer/miniprojecttargetselector.cpp | 4 +- src/plugins/projectexplorer/pluginfilefactory.cpp | 2 +- src/plugins/projectexplorer/pluginfilefactory.h | 6 +- src/plugins/projectexplorer/processstep.cpp | 2 +- src/plugins/projectexplorer/project.cpp | 4 +- src/plugins/projectexplorer/project.h | 4 +- src/plugins/projectexplorer/projectexplorer.cpp | 62 +- .../projectexplorersettingspage.cpp | 10 +- .../projectexplorer/projectfilewizardextension.cpp | 2 +- src/plugins/projectexplorer/projectwindow.cpp | 4 +- src/plugins/projectexplorer/session.cpp | 36 +- src/plugins/projectexplorer/session.h | 2 +- src/plugins/projectexplorer/settingsaccessor.cpp | 4 +- src/plugins/qmldesigner/designmodewidget.cpp | 8 +- src/plugins/qmldesigner/qmldesignerplugin.cpp | 16 +- src/plugins/qmljseditor/qmljscompletionassist.cpp | 28 +- src/plugins/qmljseditor/qmljscompletionassist.h | 4 +- .../qmljseditor/qmljscomponentfromobjectdef.cpp | 2 +- src/plugins/qmljseditor/qmljseditor.cpp | 14 +- src/plugins/qmljseditor/qmljseditorfactory.cpp | 4 +- src/plugins/qmljseditor/qmljseditorfactory.h | 2 +- src/plugins/qmljseditor/qmljsoutline.cpp | 2 +- src/plugins/qmljseditor/qmljsquickfixassist.cpp | 2 +- src/plugins/qmljseditor/qmljswrapinloader.cpp | 2 +- src/plugins/qmljseditor/qmltaskmanager.cpp | 2 +- src/plugins/qmljsinspector/qmljsinspector.cpp | 6 +- .../qmljsinspector/qmljslivetextpreview.cpp | 8 +- src/plugins/qmljstools/qmljsmodelmanager.cpp | 2 +- src/plugins/qmljstools/qmljstoolsplugin.cpp | 2 +- src/plugins/qmlprojectmanager/qmlproject.cpp | 10 +- src/plugins/qmlprojectmanager/qmlproject.h | 2 +- src/plugins/qmlprojectmanager/qmlprojectfile.cpp | 4 +- src/plugins/qmlprojectmanager/qmlprojectfile.h | 4 +- .../qmlprojectmanager/qmlprojectmanager.cpp | 4 +- src/plugins/qmlprojectmanager/qmlprojectnodes.cpp | 6 +- src/plugins/qmlprojectmanager/qmlprojectnodes.h | 8 +- .../qmlprojectrunconfiguration.cpp | 6 +- .../qt4projectmanager/profilecompletionassist.cpp | 2 +- src/plugins/qt4projectmanager/profileeditor.cpp | 2 +- .../qt4projectmanager/profileeditorfactory.cpp | 4 +- .../qt4projectmanager/profileeditorfactory.h | 2 +- src/plugins/qt4projectmanager/qmakestep.cpp | 4 +- .../qt-desktop/qt4runconfiguration.cpp | 2 +- .../qt4projectmanager/qt4buildconfiguration.cpp | 2 +- src/plugins/qt4projectmanager/qt4nodes.cpp | 38 +- src/plugins/qt4projectmanager/qt4nodes.h | 4 +- src/plugins/qt4projectmanager/qt4project.cpp | 12 +- src/plugins/qt4projectmanager/qt4project.h | 4 +- .../qt4projectmanager/qt4projectconfigwidget.cpp | 8 +- .../qt4projectmanager/qt4projectmanager.cpp | 8 +- .../qt4projectmanager/unconfiguredprojectpanel.cpp | 4 +- .../remotelinux/deploymentsettingsassistant.cpp | 2 +- .../resourceeditor/resourceeditorfactory.cpp | 4 +- src/plugins/resourceeditor/resourceeditorfactory.h | 2 +- src/plugins/resourceeditor/resourceeditorw.cpp | 34 +- src/plugins/resourceeditor/resourceeditorw.h | 16 +- src/plugins/subversion/subversionplugin.cpp | 10 +- src/plugins/tasklist/taskfile.cpp | 4 +- src/plugins/tasklist/taskfile.h | 4 +- src/plugins/tasklist/taskfilefactory.cpp | 14 +- src/plugins/tasklist/taskfilefactory.h | 12 +- src/plugins/texteditor/basefilefind.cpp | 4 +- src/plugins/texteditor/basetextdocument.cpp | 4 +- src/plugins/texteditor/basetextdocument.h | 8 +- src/plugins/texteditor/basetexteditor.cpp | 2 +- src/plugins/texteditor/basetexteditor.h | 4 +- src/plugins/texteditor/basetextmark.cpp | 8 +- .../codeassist/defaultassistinterface.cpp | 18 +- .../texteditor/codeassist/defaultassistinterface.h | 12 +- .../texteditor/codeassist/iassistinterface.cpp | 2 +- .../texteditor/codeassist/iassistinterface.h | 6 +- src/plugins/texteditor/findincurrentfile.cpp | 20 +- src/plugins/texteditor/findincurrentfile.h | 4 +- src/plugins/texteditor/itexteditor.cpp | 4 +- src/plugins/texteditor/plaintexteditor.cpp | 10 +- src/plugins/texteditor/plaintexteditorfactory.cpp | 6 +- src/plugins/texteditor/plaintexteditorfactory.h | 2 +- src/plugins/texteditor/refactoringchanges.cpp | 2 +- src/plugins/valgrind/callgrindtool.cpp | 2 +- src/plugins/vcsbase/basevcseditorfactory.cpp | 4 +- src/plugins/vcsbase/basevcseditorfactory.h | 2 +- src/plugins/vcsbase/basevcssubmiteditorfactory.cpp | 4 +- src/plugins/vcsbase/basevcssubmiteditorfactory.h | 2 +- src/plugins/vcsbase/submiteditorfile.cpp | 6 +- src/plugins/vcsbase/submiteditorfile.h | 4 +- src/plugins/vcsbase/vcsbaseclient.cpp | 4 +- src/plugins/vcsbase/vcsbaseeditor.cpp | 10 +- src/plugins/vcsbase/vcsbaseplugin.cpp | 10 +- src/plugins/vcsbase/vcsbasesubmiteditor.cpp | 8 +- src/plugins/vcsbase/vcsbasesubmiteditor.h | 2 +- 223 files changed, 2981 insertions(+), 2987 deletions(-) create mode 100644 src/plugins/coreplugin/documentmanager.cpp create mode 100644 src/plugins/coreplugin/documentmanager.h delete mode 100644 src/plugins/coreplugin/filemanager.cpp delete mode 100644 src/plugins/coreplugin/filemanager.h create mode 100644 src/plugins/coreplugin/idocument.cpp create mode 100644 src/plugins/coreplugin/idocument.h create mode 100644 src/plugins/coreplugin/idocumentfactory.h delete mode 100644 src/plugins/coreplugin/ifile.cpp delete mode 100644 src/plugins/coreplugin/ifile.h delete mode 100644 src/plugins/coreplugin/ifilefactory.h create mode 100644 src/plugins/coreplugin/textdocument.cpp create mode 100644 src/plugins/coreplugin/textdocument.h delete mode 100644 src/plugins/coreplugin/textfile.cpp delete mode 100644 src/plugins/coreplugin/textfile.h diff --git a/doc/api/coding-style.qdoc b/doc/api/coding-style.qdoc index c3c2455db2..5d308131d0 100644 --- a/doc/api/coding-style.qdoc +++ b/doc/api/coding-style.qdoc @@ -540,7 +540,7 @@ name to the user, convert it back to native format with QDir::toNativeSeparators. - When comparing file names, consider using FileManager::fixFileName which + When comparing file names, consider using DocumentManager::fixFileName which makes sure that paths are clean and absolute and also takes Windows case-insensitivity into account (even if it is an expensive operation). diff --git a/doc/api/qtcreator-api.qdoc b/doc/api/qtcreator-api.qdoc index a5538541c0..94ddff2a4f 100644 --- a/doc/api/qtcreator-api.qdoc +++ b/doc/api/qtcreator-api.qdoc @@ -186,7 +186,7 @@ \row \o Add a new editor type. \o Such as an editor for XML files. - \o \l{Core::IEditorFactory}, \l{Core::IEditor}, \l{Core::IFile} + \o \l{Core::IEditorFactory}, \l{Core::IEditor}, \l{Core::IDocument} \row \o Add a new wizard. diff --git a/src/plugins/analyzerbase/analyzerutils.cpp b/src/plugins/analyzerbase/analyzerutils.cpp index 2465742863..902bac3404 100644 --- a/src/plugins/analyzerbase/analyzerutils.cpp +++ b/src/plugins/analyzerbase/analyzerutils.cpp @@ -98,7 +98,7 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor() editorWidget->convertPosition(pos, &line, &column); const CPlusPlus::Snapshot &snapshot = CPlusPlus::CppModelManagerInterface::instance()->snapshot(); - CPlusPlus::Document::Ptr doc = snapshot.document(editor->file()->fileName()); + CPlusPlus::Document::Ptr doc = snapshot.document(editor->document()->fileName()); QTC_ASSERT(doc, return 0) // fetch the expression's code diff --git a/src/plugins/autotoolsprojectmanager/autotoolsmanager.cpp b/src/plugins/autotoolsprojectmanager/autotoolsmanager.cpp index 29149be2e9..e185fc3a60 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsmanager.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsmanager.cpp @@ -37,7 +37,7 @@ #include "autotoolsprojectconstants.h" #include -#include +#include #include #include #include @@ -62,7 +62,7 @@ Project *AutotoolsManager::openProject(const QString &fileName, QString *errorSt // Check whether the project is already open or not. ProjectExplorerPlugin *projectExplorer = ProjectExplorerPlugin::instance(); foreach (Project *pi, projectExplorer->session()->projects()) { - if (canonicalFilePath == pi->file()->fileName()) { + if (canonicalFilePath == pi->document()->fileName()) { *errorString = tr("Failed opening project '%1': Project already open") .arg(QDir::toNativeSeparators(canonicalFilePath)); return 0; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp index e6fd4e7d3d..aede667f7a 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp @@ -133,7 +133,7 @@ QString AutotoolsProject::id() const return QLatin1String(Constants::AUTOTOOLS_PROJECT_ID); } -Core::IFile *AutotoolsProject::file() const +Core::IDocument *AutotoolsProject::document() const { return m_file; } diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.h b/src/plugins/autotoolsprojectmanager/autotoolsproject.h index 0ec30b4d91..418f00a255 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.h @@ -78,7 +78,7 @@ public: QString displayName() const; QString id() const; - Core::IFile *file() const; + Core::IDocument *document() const; ProjectExplorer::IProjectManager *projectManager() const; AutotoolsTarget *activeTarget() const; QList subConfigWidgets(); diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp index f528f7438f..80cf6767be 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp @@ -40,7 +40,7 @@ using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QString &fileName) : - Core::IFile(project), + Core::IDocument(project), m_project(project), m_fileName(fileName) { diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h index 9f7750a11c..5ed740d5eb 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h @@ -35,7 +35,7 @@ #ifndef AUTOTOOLSPROJECTFILE_H #define AUTOTOOLSPROJECTFILE_H -#include +#include namespace AutotoolsProjectManager { namespace Internal { @@ -43,7 +43,7 @@ namespace Internal { class AutotoolsProject; /** - * @brief Implementation of the Core::IFile interface. + * @brief Implementation of the Core::IDocument interface. * * Is used in AutotoolsProject and describes the root * of a project. In the context of autotools the implementation @@ -52,7 +52,7 @@ class AutotoolsProject; * * @see AutotoolsProject */ -class AutotoolsProjectFile : public Core::IFile +class AutotoolsProjectFile : public Core::IDocument { Q_OBJECT diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.cpp index e926c991f0..3234afbad4 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.cpp @@ -39,7 +39,7 @@ using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; -AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IFile *projectFile) : +AutotoolsProjectNode::AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile) : ProjectNode(projectFile->fileName()), m_project(project), m_projectFile(projectFile) diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.h index e0963f77a8..433e662eac 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectnode.h @@ -36,7 +36,7 @@ #define AUTOTOOLSPROJECTNODE_H #include -#include +#include namespace AutotoolsProjectManager { namespace Internal { @@ -57,7 +57,7 @@ class AutotoolsProjectNode : public ProjectExplorer::ProjectNode Q_OBJECT public: - AutotoolsProjectNode(AutotoolsProject *project, Core::IFile *projectFile); + AutotoolsProjectNode(AutotoolsProject *project, Core::IDocument *projectFile); bool hasBuildTargets() const; QList supportedActions(Node *node) const; @@ -79,7 +79,7 @@ public: private: AutotoolsProject *m_project; - Core::IFile *m_projectFile; + Core::IDocument *m_projectFile; // TODO: AutotoolsProject calls the protected method addFileNodes() from AutotoolsProjectNode. // Instead of this friend declaration, a public interface might be preferable. diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 248ef882bc..a110b3063c 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include @@ -617,9 +617,9 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit { if (!m_changeLog) return true; - Core::IFile *editorFile = submitEditor->file(); + Core::IDocument *editorDocument = submitEditor->document(); const CommitEditor *commitEditor = qobject_cast(submitEditor); - if (!editorFile || !commitEditor) + if (!editorDocument || !commitEditor) return true; bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey); @@ -641,7 +641,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit QStringList files = commitEditor->checkedFiles(); if (!files.empty()) { //save the commit message - if (!Core::FileManager::saveFile(editorFile)) + if (!Core::DocumentManager::saveDocument(editorDocument)) return false; //rewrite entries of the form 'file => newfile' to 'newfile' because @@ -665,7 +665,7 @@ bool BazaarPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submit // Whether local commit or not if (commitWidget->isLocalOptionEnabled()) extraOptions += QLatin1String("--local"); - m_client->commit(m_submitRepository, files, editorFile->fileName(), extraOptions); + m_client->commit(m_submitRepository, files, editorDocument->fileName(), extraOptions); } return true; } diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 89e0da4975..eb42b918fa 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include @@ -185,12 +185,12 @@ private: }; -class BinEditorFile : public Core::IFile +class BinEditorDocument : public Core::IDocument { Q_OBJECT public: - BinEditorFile(BinEditor *parent) : - Core::IFile(parent) + BinEditorDocument(BinEditor *parent) : + Core::IDocument(parent) { m_editor = parent; connect(m_editor, SIGNAL(dataRequested(Core::IEditor*,quint64)), @@ -202,7 +202,7 @@ public: connect(m_editor, SIGNAL(endOfFileRequested(Core::IEditor*)), this, SLOT(handleEndOfFileRequested(Core::IEditor*))); } - ~BinEditorFile() {} + ~BinEditorDocument() {} QString mimeType() const { return QLatin1String(Constants::C_BINEDITOR_MIMETYPE); @@ -296,7 +296,7 @@ public: bool isModified() const { return m_editor->isMemoryView() ? false : m_editor->isModified(); } - bool isReadOnly() const { + bool isFileReadOnly() const { if (m_editor->isMemoryView() || m_fileName.isEmpty()) return false; const QFileInfo fi(m_fileName); @@ -332,7 +332,7 @@ public: { setWidget(editor); m_editor = editor; - m_file = new BinEditorFile(m_editor); + m_file = new BinEditorDocument(m_editor); m_context.add(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); m_context.add(Constants::C_BINEDITOR); m_addressEdit = new QLineEdit; @@ -373,7 +373,7 @@ public: QTC_ASSERT(fileName == realFileName, return false); // The bineditor can do no autosaving return m_file->open(errorString, fileName); } - Core::IFile *file() { return m_file; } + Core::IDocument *document() { return m_file; } Core::Id id() const { return Core::Constants::K_DEFAULT_BINARY_EDITOR_ID; } QString displayName() const { return m_displayName; } void setDisplayName(const QString &title) { m_displayName = title; emit changed(); } @@ -401,7 +401,7 @@ private slots: private: BinEditor *m_editor; QString m_displayName; - BinEditorFile *m_file; + BinEditorDocument *m_file; QToolBar *m_toolBar; QLineEdit *m_addressEdit; }; @@ -426,11 +426,11 @@ QString BinEditorFactory::displayName() const return tr(Constants::C_BINEDITOR_DISPLAY_NAME); } -Core::IFile *BinEditorFactory::open(const QString &fileName) +Core::IDocument *BinEditorFactory::open(const QString &fileName) { Core::EditorManager *em = Core::EditorManager::instance(); Core::IEditor *iface = em->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *BinEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index 02fdff35c4..2db7c38001 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -108,7 +108,7 @@ public: Core::IEditor *createEditor(QWidget *parent); Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); private: const QStringList m_mimeTypes; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index f4961c6f1b..21b62dee5a 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -393,7 +393,7 @@ void BookmarkManager::toggleBookmark() if (!editor) return; - toggleBookmark(editor->file()->fileName(), editor->currentLine()); + toggleBookmark(editor->document()->fileName(), editor->currentLine()); } void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber) @@ -508,7 +508,7 @@ void BookmarkManager::documentPrevNext(bool next) { TextEditor::ITextEditor *editor = currentTextEditor(); int editorLine = editor->currentLine(); - QFileInfo fi(editor->file()->fileName()); + QFileInfo fi(editor->document()->fileName()); if (!m_bookmarksMap.contains(fi.path())) return; @@ -615,7 +615,7 @@ BookmarkManager::State BookmarkManager::state() const if (!editor) return HasBookMarks; - const QFileInfo fi(editor->file()->fileName()); + const QFileInfo fi(editor->document()->fileName()); const DirectoryFileBookmarksMap::const_iterator dit = m_bookmarksMap.constFind(fi.path()); if (dit == m_bookmarksMap.constEnd()) @@ -757,8 +757,8 @@ void BookmarkManager::handleBookmarkRequest(TextEditor::ITextEditor *textEditor, int line, TextEditor::ITextEditor::MarkRequestKind kind) { - if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->file()) - toggleBookmark(textEditor->file()->fileName(), line); + if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->document()) + toggleBookmark(textEditor->document()->fileName(), line); } // BookmarkViewFactory diff --git a/src/plugins/bookmarks/bookmarksplugin.cpp b/src/plugins/bookmarks/bookmarksplugin.cpp index 1fccae71aa..e477eb260b 100644 --- a/src/plugins/bookmarks/bookmarksplugin.cpp +++ b/src/plugins/bookmarks/bookmarksplugin.cpp @@ -200,7 +200,7 @@ void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor, int lineNumber, QMenu *menu) { m_bookmarkMarginActionLineNumber = lineNumber; - m_bookmarkMarginActionFileName = editor->file()->fileName(); + m_bookmarkMarginActionFileName = editor->document()->fileName(); menu->addAction(m_bookmarkMarginAction); } diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index 51ef04c418..e3e78ccbff 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -312,9 +312,9 @@ void Manager::gotoLocations(const QList &list) Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); if (editor) { // get current file name - Core::IFile *file = editor->file(); - if (file) - fileName = file->fileName(); + Core::IDocument *document = editor->document(); + if (document) + fileName = document->fileName(); // if text file - what is current position? TextEditor::ITextEditor *textEditor = qobject_cast(editor); diff --git a/src/plugins/classview/classviewparser.cpp b/src/plugins/classview/classviewparser.cpp index 035b985ade..0056918976 100644 --- a/src/plugins/classview/classviewparser.cpp +++ b/src/plugins/classview/classviewparser.cpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include @@ -236,8 +236,8 @@ ParserTreeItem::ConstPtr Parser::parse() QString prjName(prj->displayName()); QString prjType(prjName); - if (prj->file()) - prjType = prj->file()->fileName(); + if (prj->document()) + prjType = prj->document()->fileName(); SymbolInformation inf(prjName, prjType); QStringList projectList = addProjectNode(item, prj->rootProjectNode()); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 27057cce2e..a0586f9168 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -79,7 +79,7 @@ Core::Id CMakeEditor::id() const void CMakeEditor::markAsChanged() { - if (!file()->isModified()) + if (!document()->isModified()) return; if (m_infoBarShown) return; @@ -87,7 +87,7 @@ void CMakeEditor::markAsChanged() Core::InfoBarEntry info(QLatin1String("CMakeEditor.RunCMake"), tr("Changes to cmake files are shown in the project tree after building.")); info.setCustomButtonInfo(tr("Build now"), this, SLOT(build())); - file()->infoBar()->addInfo(info); + document()->infoBar()->addInfo(info); } void CMakeEditor::build() @@ -97,7 +97,7 @@ void CMakeEditor::build() foreach (ProjectExplorer::Project *p, projects) { CMakeProject *cmakeProject = qobject_cast(p); if (cmakeProject) { - if (cmakeProject->isProjectFile(file()->fileName())) { + if (cmakeProject->isProjectFile(document()->fileName())) { ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject); break; } diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp index 5f12897c5f..c5b8ee9053 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.cpp @@ -58,10 +58,10 @@ QString CMakeEditorFactory::displayName() const return tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME); } -Core::IFile *CMakeEditorFactory::open(const QString &fileName) +Core::IDocument *CMakeEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h index 7a61cf10ff..e23a654808 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditorfactory.h @@ -57,7 +57,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp index f2a71d3ad7..50cdf33bf3 100644 --- a/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp +++ b/src/plugins/cmakeprojectmanager/cmakelocatorfilter.cpp @@ -75,8 +75,8 @@ QList CMakeLocatorFilter::matchesFor(QFutureInterfacebuildTargets()) { if (ct.title.contains(entry)) { - Locator::FilterEntry entry(this, ct.title, cmakeProject->file()->fileName()); - entry.extraInfo = cmakeProject->file()->fileName(); + Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->fileName()); + entry.extraInfo = cmakeProject->document()->fileName(); result.append(entry); } } @@ -95,7 +95,7 @@ void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects(); foreach (ProjectExplorer::Project *p, projects) { cmakeProject = qobject_cast(p); - if (cmakeProject && cmakeProject->file()->fileName() == selection.internalData.toString()) + if (cmakeProject && cmakeProject->document()->fileName() == selection.internalData.toString()) break; cmakeProject = 0; } diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index d6eb593612..d5aabb4531 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -197,8 +197,8 @@ bool CMakeProject::parseCMakeLists() return false; foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors()) - if (isProjectFile(editor->file()->fileName())) - editor->file()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake")); + if (isProjectFile(editor->document()->fileName())) + editor->document()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake")); // Find cbp file CMakeBuildConfiguration *activeBC = activeTarget()->activeBuildConfiguration(); @@ -481,7 +481,7 @@ QString CMakeProject::id() const return QLatin1String(Constants::CMAKEPROJECT_ID); } -Core::IFile *CMakeProject::file() const +Core::IDocument *CMakeProject::document() const { return m_file; } @@ -692,7 +692,7 @@ void CMakeProject::editorChanged(Core::IEditor *editor) disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged())); if (m_dirtyUic) { const QString contents = formWindowEditorContents(m_lastEditor); - updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents); + updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); m_dirtyUic = false; } } @@ -713,7 +713,7 @@ void CMakeProject::editorAboutToClose(Core::IEditor *editor) disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged())); if (m_dirtyUic) { const QString contents = formWindowEditorContents(m_lastEditor); - updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents); + updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); m_dirtyUic = false; } } @@ -744,7 +744,7 @@ void CMakeProject::buildStateChanged(ProjectExplorer::Project *project) // CMakeFile CMakeFile::CMakeFile(CMakeProject *parent, QString fileName) - : Core::IFile(parent), m_project(parent), m_fileName(fileName) + : Core::IDocument(parent), m_project(parent), m_fileName(fileName) { } @@ -797,7 +797,7 @@ void CMakeFile::rename(const QString &newName) // Can't happen.... } -Core::IFile::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index 24bee0b1b1..f5bb915b80 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include @@ -81,7 +81,7 @@ public: QString displayName() const; QString id() const; - Core::IFile *file() const; + Core::IDocument *document() const; CMakeManager *projectManager() const; CMakeTarget *activeTarget() const; @@ -193,7 +193,7 @@ private: QString m_compiler; }; -class CMakeFile : public Core::IFile +class CMakeFile : public Core::IDocument { Q_OBJECT public: 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 +#include #include #include @@ -43,13 +43,13 @@ #include #include -Q_DECLARE_METATYPE(Core::IFile*) +Q_DECLARE_METATYPE(Core::IDocument*) using namespace Core; using namespace Core::Internal; SaveItemsDialog::SaveItemsDialog(QWidget *parent, - QList items) + QList 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()); + m_itemsToSave.append(item->data(0, Qt::UserRole).value()); } accept(); } @@ -123,7 +123,7 @@ void SaveItemsDialog::discardAll() collectItemsToSave(); } -QList SaveItemsDialog::itemsToSave() const +QList 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 items); + QList items); void setMessage(const QString &msg); void setAlwaysSaveMessage(const QString &msg); bool alwaysSaveChecked(); - QList itemsToSave() const; + QList itemsToSave() const; private slots: void collectItemsToSave(); @@ -71,7 +71,7 @@ private slots: private: Ui::SaveItemsDialog m_ui; - QList m_itemsToSave; + QList 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/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp new file mode 100644 index 0000000000..9ab5362645 --- /dev/null +++ b/src/plugins/coreplugin/documentmanager.cpp @@ -0,0 +1,1389 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "documentmanager.h" + +#include "editormanager.h" +#include "icore.h" +#include "ieditor.h" +#include "ieditorfactory.h" +#include "iexternaleditor.h" +#include "idocument.h" +#include "iversioncontrol.h" +#include "mimedatabase.h" +#include "saveitemsdialog.h" +#include "vcsmanager.h" +#include "coreconstants.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + \class Core::DocumentManager + \mainclass + \inheaderfile documentmanager.h + \brief Manages a set of IDocument objects. + + 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 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 IDocument objects are notified to reload + themselves. + + 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. + + The service also manages the list of recent files to be shown to the user + (see addToRecentFiles() and recentFiles()). + */ + +static const char settingsGroupC[] = "RecentFiles"; +static const char filesKeyC[] = "Files"; +static const char editorsKeyC[] = "EditorIds"; + +static const char directoryGroupC[] = "Directories"; +static const char projectDirectoryKeyC[] = "Projects"; +static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory"; + + +namespace Core { + +static void readSettings(); + +static QList saveModifiedFilesHelper(const QList &documents, + bool *cancelled, bool silently, + const QString &message, + const QString &alwaysSaveMessage = QString(), + bool *alwaysSave = 0); + +namespace Internal { + +struct OpenWithEntry +{ + OpenWithEntry() : editorFactory(0), externalEditor(0) {} + IEditorFactory *editorFactory; + IExternalEditor *externalEditor; + QString fileName; +}; + +struct FileStateItem +{ + QDateTime modified; + QFile::Permissions permissions; +}; + +struct FileState +{ + QMap lastUpdatedState; + FileStateItem expected; +}; + + +struct DocumentManagerPrivate +{ + explicit DocumentManagerPrivate(QMainWindow *mw); + QFileSystemWatcher *fileWatcher(); + QFileSystemWatcher *linkWatcher(); + + QMap m_states; + QSet m_changedFiles; + QList m_documentsWithoutWatch; + QMap m_documentsWithWatch; + QSet m_expectedFileNames; + + QList m_recentFiles; + static const int m_maxRecentFiles = 7; + + QString m_currentFile; + + QMainWindow *m_mainWindow; + QFileSystemWatcher *m_fileWatcher; // Delayed creation. + QFileSystemWatcher *m_linkWatcher; // Delayed creation (only UNIX/if a link is seen). + bool m_blockActivated; + QString m_lastVisitedDirectory; + QString m_projectsDirectory; + bool m_useProjectsDirectory; + // When we are callling into a IDocument + // we don't want to receive a changed() + // signal + // That makes the code easier + IDocument *m_blockedIDocument; +}; + +static DocumentManager *m_instance; +static Internal::DocumentManagerPrivate *d; + +QFileSystemWatcher *DocumentManagerPrivate::fileWatcher() +{ + if (!m_fileWatcher) { + m_fileWatcher= new QFileSystemWatcher(m_instance); + QObject::connect(m_fileWatcher, SIGNAL(fileChanged(QString)), + m_instance, SLOT(changedFile(QString))); + } + return m_fileWatcher; +} + +QFileSystemWatcher *DocumentManagerPrivate::linkWatcher() +{ +#ifdef Q_OS_UNIX + if (!m_linkWatcher) { + m_linkWatcher = new QFileSystemWatcher(m_instance); + m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller")); + QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)), + m_instance, SLOT(changedFile(QString))); + } + return m_linkWatcher; +#else + return fileWatcher(); +#endif +} + +DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) : + m_mainWindow(mw), + m_fileWatcher(0), + m_linkWatcher(0), + m_blockActivated(false), + m_lastVisitedDirectory(QDir::currentPath()), +#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder. + m_useProjectsDirectory(true), +#else + m_useProjectsDirectory(false), +#endif + m_blockedIDocument(0) +{ +} + +} // namespace Internal +} // namespace Core + +Q_DECLARE_METATYPE(Core::Internal::OpenWithEntry) + +namespace Core { + +using namespace Internal; + +DocumentManager::DocumentManager(QMainWindow *mw) + : QObject(mw) +{ + d = new DocumentManagerPrivate(mw); + m_instance = this; + connect(d->m_mainWindow, SIGNAL(windowActivated()), + this, SLOT(mainWindowActivated())); + connect(ICore::instance(), SIGNAL(contextChanged(Core::IContext*,Core::Context)), + this, SLOT(syncWithEditor(Core::IContext*))); + + readSettings(); +} + +DocumentManager::~DocumentManager() +{ + delete d; +} + +DocumentManager *DocumentManager::instance() +{ + return m_instance; +} + +/* only called from addFileInfo(IDocument *) */ +static void addFileInfo(const QString &fileName, IDocument *document, bool isLink) +{ + FileStateItem state; + if (!fileName.isEmpty()) { + const QFileInfo fi(fileName); + state.modified = fi.lastModified(); + state.permissions = fi.permissions(); + // Add watcher if we don't have that already + if (!d->m_states.contains(fileName)) { + d->m_states.insert(fileName, FileState()); + + } + QFileSystemWatcher *watcher = 0; + if (isLink) + watcher = d->linkWatcher(); + else + watcher = d->fileWatcher(); + if (!watcher->files().contains(fileName)) + watcher->addPath(fileName); + + d->m_states[fileName].lastUpdatedState.insert(document, state); + } + d->m_documentsWithWatch[document].append(fileName); // inserts a new QStringList if not already there +} + +/* 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(IDocument *document) +{ + 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, document, true); +} + +/*! + \fn bool DocumentManager::addFiles(const QList &documents, bool addWatcher) + + 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 DocumentManager::addDocuments(const QList &documents, bool addWatcher) +{ + if (!addWatcher) { + // We keep those in a separate list + + 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 (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 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(IDocument *document) +{ + if (!d->m_documentsWithWatch.contains(document)) + return; + foreach (const QString &fileName, d->m_documentsWithWatch.value(document)) { + if (!d->m_states.contains(fileName)) + continue; + 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); + if (d->m_linkWatcher && d->m_linkWatcher->files().contains(fileName)) + d->m_linkWatcher->removePath(fileName); + d->m_states.remove(fileName); + } + } + d->m_documentsWithWatch.remove(document); +} + +/// Dumps the state of the file manager's map +/// For debugging purposes +/* +static void dump() +{ + qDebug() << "======== dumping state map"; + QMap::const_iterator it, end; + it = d->m_states.constBegin(); + end = d->m_states.constEnd(); + for (; it != end; ++it) { + qDebug() << it.key(); + qDebug() << " expected:" << it.value().expected.modified; + + QMap::const_iterator jt, jend; + jt = it.value().lastUpdatedState.constBegin(); + jend = it.value().lastUpdatedState.constEnd(); + for (; jt != jend; ++jt) { + qDebug() << " " << jt.key()->fileName() << jt.value().modified; + } + } + qDebug() << "------- dumping files with watch list"; + foreach (IDocument *key, d->m_filesWithWatch.keys()) { + qDebug() << key->fileName() << d->m_filesWithWatch.value(key); + } + qDebug() << "------- dumping watch list"; + if (d->m_fileWatcher) + qDebug() << d->m_fileWatcher->files(); + qDebug() << "------- dumping link watch list"; + if (d->m_linkWatcher) + qDebug() << d->m_linkWatcher->files(); +} +*/ + +/*! + \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 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 DocumentManager::renamedFile(const QString &from, const QString &to) +{ + const QString &fixedFrom = fixFileName(from, KeepLinks); + + // gather the list of IDocuments + QList documentsToRename; + QMapIterator it(d->m_documentsWithWatch); + while (it.hasNext()) { + it.next(); + if (it.value().contains(fixedFrom)) + documentsToRename.append(it.key()); + } + + // rename the IDocuments + foreach (IDocument *document, documentsToRename) { + d->m_blockedIDocument = document; + removeFileInfo(document); + document->rename(to); + addFileInfo(document); + d->m_blockedIDocument = 0; + } +} +/*! + \fn bool DocumentManager::addFile(IDocument *document, bool addWatcher) + + 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 DocumentManager::addDocument(IDocument *document, bool addWatcher) +{ + addDocuments(QList() << document, addWatcher); +} + +void DocumentManager::documentDestroyed(QObject *obj) +{ + IDocument *document = static_cast(obj); + // Check the special unwatched first: + if (!d->m_documentsWithoutWatch.removeOne(document)) + removeFileInfo(document); +} + +/*! + \fn bool DocumentManager::removeFile(IDocument *document) + + Removes a IDocument object from the collection. + + Returns true if the file specified by \a document had the addWatcher argument to addDocument() set. +*/ +bool DocumentManager::removeDocument(IDocument *document) +{ + QTC_ASSERT(document, return false); + + bool addWatcher = false; + // Special casing unwatched files + if (!d->m_documentsWithoutWatch.removeOne(document)) { + addWatcher = true; + removeFileInfo(document); + disconnect(document, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName())); + } + disconnect(document, SIGNAL(destroyed(QObject *)), m_instance, SLOT(documentDestroyed(QObject *))); + return addWatcher; +} + +/* Slot reacting on IDocument::changed. We need to check if the signal was sent + because the file was saved under different name. */ +void DocumentManager::checkForNewFileName() +{ + IDocument *document = qobject_cast(sender()); + // We modified the IDocument + // Trust the other code to also update the m_states map + if (document == d->m_blockedIDocument) + 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(document); + addFileInfo(document); +} + +/*! + \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 DocumentManager::fixFileName(const QString &fileName, FixMode fixmode) +{ + QString s = fileName; + QFileInfo fi(s); + if (fi.exists()) { + if (fixmode == ResolveLinks) + s = fi.canonicalFilePath(); + else + s = QDir::cleanPath(fi.absoluteFilePath()); + } else { + s = QDir::cleanPath(s); + } + s = QDir::toNativeSeparators(s); +#ifdef Q_OS_WIN + s = s.toLower(); +#endif + return s; +} + +/*! + \fn QList DocumentManager::modifiedFiles() const + + Returns the list of IDocument's that have been modified. +*/ +QList DocumentManager::modifiedDocuments() +{ + QList modified; + + foreach (IDocument *document, d->m_documentsWithWatch.keys()) { + if (document->isModified()) + modified << document; + } + + foreach (IDocument *document, d->m_documentsWithoutWatch) { + if (document->isModified()) + modified << document; + } + + return modified; +} + +/*! + \fn void DocumentManager::expectFileChange(const QString &fileName) + + Any subsequent change to \a fileName is treated as a expected file change. + + \see DocumentManager::unexpectFileChange(const QString &fileName) +*/ +void DocumentManager::expectFileChange(const QString &fileName) +{ + if (fileName.isEmpty()) + return; + d->m_expectedFileNames.insert(fileName); +} + +/* only called from unblock and unexpect file change methods */ +static void updateExpectedState(const QString &fileName) +{ + if (fileName.isEmpty()) + return; + if (d->m_states.contains(fileName)) { + QFileInfo fi(fileName); + d->m_states[fileName].expected.modified = fi.lastModified(); + d->m_states[fileName].expected.permissions = fi.permissions(); + } +} + +/*! + \fn void DocumentManager::unexpectFileChange(const QString &fileName) + + Any change to \a fileName are unexpected again. + + \see DocumentManager::expectFileChange(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 + // is the same as the saved one here + // If so then it's a expected change + + if (fileName.isEmpty()) + return; + d->m_expectedFileNames.remove(fileName); + const QString fixedName = fixFileName(fileName, KeepLinks); + updateExpectedState(fixedName); + const QString fixedResolvedName = fixFileName(fileName, ResolveLinks); + if (fixedName != fixedResolvedName) + updateExpectedState(fixedResolvedName); +} + +/*! + \fn QList DocumentManager::saveModifiedFilesSilently(const QList &documents) + + 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 DocumentManager::saveModifiedDocumentsSilently(const QList &documents, bool *cancelled) +{ + return saveModifiedFilesHelper(documents, cancelled, true, QString()); +} + +/*! + \fn QList DocumentManager::saveModifiedFiles(const QList &documents, bool *cancelled, const QString &message, const QString &alwaysSaveMessage, bool *alwaysSave) + + 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). + The \a cancelled argument is set to true if the user cancelled the dialog, + \a alwaysSave is set to match the selection of the user, if files should + always automatically be saved. + Returns the files that have not been saved. +*/ +QList DocumentManager::saveModifiedDocuments(const QList &documents, + bool *cancelled, const QString &message, + const QString &alwaysSaveMessage, + bool *alwaysSave) +{ + return saveModifiedFilesHelper(documents, cancelled, false, message, alwaysSaveMessage, alwaysSave); +} + +static QList saveModifiedFilesHelper(const QList &documents, + bool *cancelled, + bool silently, + const QString &message, + const QString &alwaysSaveMessage, + bool *alwaysSave) +{ + if (cancelled) + (*cancelled) = false; + + QList notSaved; + QMap modifiedDocumentsMap; + QList modifiedDocuments; + + foreach (IDocument *document, documents) { + if (document->isModified()) { + QString name = document->fileName(); + if (name.isEmpty()) + name = document->suggestedFileName(); + + // There can be several IDocuments pointing to the same file + // Prefer one that is not readonly + // (even though it *should* not happen that the IDocuments are inconsistent with readonly) + if (!modifiedDocumentsMap.key(name, 0) || !document->isFileReadOnly()) + modifiedDocumentsMap.insert(document, name); + } + } + modifiedDocuments = modifiedDocumentsMap.keys(); + if (!modifiedDocuments.isEmpty()) { + QList documentsToSave; + if (silently) { + documentsToSave = modifiedDocuments; + } else { + SaveItemsDialog dia(d->m_mainWindow, modifiedDocuments); + if (!message.isEmpty()) + dia.setMessage(message); + if (!alwaysSaveMessage.isNull()) + dia.setAlwaysSaveMessage(alwaysSaveMessage); + if (dia.exec() != QDialog::Accepted) { + if (cancelled) + (*cancelled) = true; + if (alwaysSave) + *alwaysSave = dia.alwaysSaveChecked(); + notSaved = modifiedDocuments; + return notSaved; + } + if (alwaysSave) + *alwaysSave = dia.alwaysSaveChecked(); + documentsToSave = dia.itemsToSave(); + } + + foreach (IDocument *document, documentsToSave) { + if (!EditorManager::instance()->saveDocument(document)) { + if (cancelled) + *cancelled = true; + notSaved.append(document); + } + } + } + return notSaved; +} + +bool DocumentManager::saveDocument(IDocument *document, const QString &fileName, bool *isReadOnly) +{ + bool ret = true; + 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 (!document->save(&errorString, fileName, false)) { + if (isReadOnly) { + QFile ofi(effName); + // Check whether the existing file is writable + if (!ofi.open(QIODevice::ReadWrite) && ofi.open(QIODevice::ReadOnly)) { + *isReadOnly = true; + goto out; + } + *isReadOnly = false; + } + QMessageBox::critical(d->m_mainWindow, tr("File Error"), errorString); + out: + ret = false; + } + + addDocument(document, addWatcher); + unexpectFileChange(effName); + return ret; +} + +QString DocumentManager::getSaveFileName(const QString &title, const QString &pathIn, + const QString &filter, QString *selectedFilter) +{ + const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn; + QString fileName; + bool repeat; + do { + repeat = false; + fileName = QFileDialog::getSaveFileName( + d->m_mainWindow, title, path, filter, selectedFilter, QFileDialog::DontConfirmOverwrite); + if (!fileName.isEmpty()) { + // If the selected filter is All Files (*) we leave the name exactly as the user + // specified. Otherwise the suffix must be one available in the selected filter. If + // the name already ends with such suffix nothing needs to be done. But if not, the + // first one from the filter is appended. + if (selectedFilter && *selectedFilter != QCoreApplication::translate( + "Core", Constants::ALL_FILES_FILTER)) { + // Mime database creates filter strings like this: Anything here (*.foo *.bar) + QRegExp regExp(QLatin1String(".*\\s+\\((.*)\\)$")); + const int index = regExp.lastIndexIn(*selectedFilter); + bool suffixOk = false; + if (index != -1) { + const QStringList &suffixes = regExp.cap(1).remove(QLatin1Char('*')).split(QLatin1Char(' ')); + foreach (const QString &suffix, suffixes) + if (fileName.endsWith(suffix)) { + suffixOk = true; + break; + } + if (!suffixOk && !suffixes.isEmpty()) + fileName.append(suffixes.at(0)); + } + } + if (QFile::exists(fileName)) { + if (QMessageBox::warning(d->m_mainWindow, tr("Overwrite?"), + tr("An item named '%1' already exists at this location. " + "Do you want to overwrite it?").arg(fileName), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { + repeat = true; + } + } + } + } while (repeat); + if (!fileName.isEmpty()) + setFileDialogLastVisitedDirectory(QFileInfo(fileName).absolutePath()); + return fileName; +} + +QString DocumentManager::getSaveFileNameWithExtension(const QString &title, const QString &pathIn, + const QString &filter) +{ + QString selected = filter; + return getSaveFileName(title, pathIn, filter, &selected); +} + +/*! + \fn QString DocumentManager::getSaveAsFileName(IDocument *document, const QString &filter, QString *selectedFilter) + + Asks the user for a new file name (Save File As) for /arg document. +*/ +QString DocumentManager::getSaveAsFileName(IDocument *document, const QString &filter, QString *selectedFilter) +{ + if (!document) + return QLatin1String(""); + QString absoluteFilePath = document->fileName(); + const QFileInfo fi(absoluteFilePath); + QString fileName = fi.fileName(); + QString path = fi.absolutePath(); + if (absoluteFilePath.isEmpty()) { + fileName = document->suggestedFileName(); + const QString defaultPath = document->defaultPath(); + if (!defaultPath.isEmpty()) + path = defaultPath; + } + + QString filterString; + if (filter.isEmpty()) { + if (const MimeType &mt = Core::ICore::mimeDatabase()->findByFile(fi)) + filterString = mt.filterString(); + selectedFilter = &filterString; + } else { + filterString = filter; + } + + absoluteFilePath = getSaveFileName(tr("Save File As"), + path + QDir::separator() + fileName, + filterString, + selectedFilter); + return absoluteFilePath; +} + +/*! + \fn QStringList DocumentManager::getOpenFileNames(const QString &filters, + const QString pathIn, + QString *selectedFilter) + + Asks the user for a set of file names to be opened. The \a filters + and \a selectedFilter parameters is interpreted like in + QFileDialog::getOpenFileNames(), \a pathIn specifies a path to open the dialog + in, if that is not overridden by the users policy. +*/ + +QStringList DocumentManager::getOpenFileNames(const QString &filters, + const QString pathIn, + QString *selectedFilter) +{ + QString path = pathIn; + if (path.isEmpty()) { + if (!d->m_currentFile.isEmpty()) + path = QFileInfo(d->m_currentFile).absoluteFilePath(); + if (path.isEmpty() && useProjectsDirectory()) + path = projectsDirectory(); + } + const QStringList files = QFileDialog::getOpenFileNames(d->m_mainWindow, + tr("Open File"), + path, filters, + selectedFilter); + if (!files.isEmpty()) + setFileDialogLastVisitedDirectory(QFileInfo(files.front()).absolutePath()); + return files; +} + +DocumentManager::ReadOnlyAction + DocumentManager::promptReadOnlyFile(const QString &fileName, + const IVersionControl *versionControl, + QWidget *parent, + bool displaySaveAsButton) +{ + // Version Control: If automatic open is desired, open right away. + bool promptVCS = false; + if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) { + if (versionControl->settingsFlags() & IVersionControl::AutoOpen) + return RO_OpenVCS; + promptVCS = true; + } + + // Create message box. + QMessageBox msgBox(QMessageBox::Question, tr("File Is Read Only"), + tr("The file %1 is read only.").arg(QDir::toNativeSeparators(fileName)), + QMessageBox::Cancel, parent); + + QPushButton *vcsButton = 0; + if (promptVCS) + vcsButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->displayName()), QMessageBox::AcceptRole); + + QPushButton *makeWritableButton = msgBox.addButton(tr("Make Writable"), QMessageBox::AcceptRole); + + QPushButton *saveAsButton = 0; + if (displaySaveAsButton) + saveAsButton = msgBox.addButton(tr("Save As..."), QMessageBox::ActionRole); + + msgBox.setDefaultButton(vcsButton ? vcsButton : makeWritableButton); + msgBox.exec(); + + QAbstractButton *clickedButton = msgBox.clickedButton(); + if (clickedButton == vcsButton) + return RO_OpenVCS; + if (clickedButton == makeWritableButton) + return RO_MakeWriteable; + if (displaySaveAsButton && clickedButton == saveAsButton) + return RO_SaveAs; + return RO_Cancel; +} + +void DocumentManager::changedFile(const QString &fileName) +{ + const bool wasempty = d->m_changedFiles.isEmpty(); + + if (d->m_states.contains(fileName)) + d->m_changedFiles.insert(fileName); + + if (wasempty && !d->m_changedFiles.isEmpty()) { + QTimer::singleShot(200, this, SLOT(checkForReload())); + } +} + +void DocumentManager::mainWindowActivated() +{ + //we need to do this asynchronously because + //opening a dialog ("Reload?") in a windowactivated event + //freezes on Mac + QTimer::singleShot(0, this, SLOT(checkForReload())); +} + +void DocumentManager::checkForReload() +{ + if (d->m_changedFiles.isEmpty()) + return; + if (QApplication::activeWindow() != d->m_mainWindow) + return; + + if (d->m_blockActivated) + return; + + d->m_blockActivated = true; + + IDocument::ReloadSetting defaultBehavior = EditorManager::instance()->reloadSetting(); + Utils::ReloadPromptAnswer previousAnswer = Utils::ReloadCurrent; + + QList editorsToClose; + QMap documentsToSave; + + // collect file information + QMap currentStates; + QMap changeTypes; + QSet changedIDocuments; + foreach (const QString &fileName, d->m_changedFiles) { + IDocument::ChangeType type = IDocument::TypeContents; + FileStateItem state; + QFileInfo fi(fileName); + if (!fi.exists()) { + type = IDocument::TypeRemoved; + } else { + state.modified = fi.lastModified(); + state.permissions = fi.permissions(); + } + currentStates.insert(fileName, state); + changeTypes.insert(fileName, type); + 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 + // lose consecutive notifications. + d->m_changedFiles.clear(); + + // collect information about "expected" file names + // we can't do the "resolving" already in expectFileChange, because + // if the resolved names are different when unexpectFileChange is called + // we would end up with never-unexpected file names + QSet expectedFileNames; + foreach (const QString &fileName, d->m_expectedFileNames) { + const QString fixedName = fixFileName(fileName, KeepLinks); + expectedFileNames.insert(fixedName); + const QString fixedResolvedName = fixFileName(fileName, ResolveLinks); + if (fixedName != fixedResolvedName) + expectedFileNames.insert(fixedResolvedName); + } + + // handle the IDocuments + QStringList errorStrings; + 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_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(document); + + // did the file actually change? + if (lastState.modified == currentState.modified && lastState.permissions == currentState.permissions) + continue; + changed = true; + + // was it only a permission change? + if (lastState.modified == currentState.modified) + continue; + + // was the change unexpected? + if ((currentState.modified != expectedState.modified || currentState.permissions != expectedState.permissions) + && !expectedFileNames.contains(fileName)) { + trigger = IDocument::TriggerExternal; + } + + // find out the type + IDocument::ChangeType fileChange = changeTypes.value(fileName); + if (fileChange == IDocument::TypeRemoved) { + type = IDocument::TypeRemoved; + } else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions) { + type = IDocument::TypeContents; + } + } + + if (!changed) // probably because the change was blocked with (un)blockFileChange + continue; + + // handle it! + d->m_blockedIDocument = document; + + bool success = true; + QString errorString; + // we've got some modification + // check if it's contents or permissions: + if (type == IDocument::TypePermissions) { + // Only permission change + success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypePermissions); + // now we know it's a content change or file was removed + } else if (defaultBehavior == IDocument::ReloadUnmodified + && type == IDocument::TypeContents && !document->isModified()) { + // content change, but unmodified (and settings say to reload in this case) + 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 == IDocument::ReloadUnmodified + && type == IDocument::TypeRemoved && !document->isModified()) { + // file removed, but unmodified files should be reloaded + // so we close the file + editorsToClose << EditorManager::instance()->editorsForDocument(document); + } else if (defaultBehavior == IDocument::IgnoreAll) { + // content change or removed, but settings say ignore + 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 IDocument wants us to do + } else { + // 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 = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents); + } else if (previousAnswer == Utils::ReloadAll) { + // answer already given, reload + success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents); + } else { + // Ask about content change + previousAnswer = Utils::reloadPrompt(document->fileName(), document->isModified(), QApplication::activeWindow()); + switch (previousAnswer) { + case Utils::ReloadAll: + case Utils::ReloadCurrent: + success = document->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents); + break; + case Utils::ReloadSkipCurrent: + case Utils::ReloadNone: + success = document->reload(&errorString, IDocument::FlagIgnore, IDocument::TypeContents); + break; + } + } + // IDocument wants us to ask, and it's the TypeRemoved case + } else { + // Ask about removed file + bool unhandled = true; + while (unhandled) { + switch (Utils::fileDeletedPrompt(document->fileName(), trigger == IDocument::TriggerExternal, QApplication::activeWindow())) { + case Utils::FileDeletedSave: + documentsToSave.insert(document, document->fileName()); + unhandled = false; + break; + case Utils::FileDeletedSaveAs: + { + const QString &saveFileName = getSaveAsFileName(document); + if (!saveFileName.isEmpty()) { + documentsToSave.insert(document, saveFileName); + unhandled = false; + } + break; + } + case Utils::FileDeletedClose: + editorsToClose << EditorManager::instance()->editorsForDocument(document); + unhandled = false; + break; + } + } + } + } + if (!success) { + if (errorString.isEmpty()) + 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(document); + addFileInfo(document); + d->m_blockedIDocument = 0; + } + if (!errorStrings.isEmpty()) + QMessageBox::critical(d->m_mainWindow, tr("File Error"), + errorStrings.join(QLatin1String("\n"))); + + // handle deleted files + EditorManager::instance()->closeEditors(editorsToClose, false); + QMapIterator it(documentsToSave); + while (it.hasNext()) { + it.next(); + saveDocument(it.key(), it.value()); + it.key()->checkPermissions(); + } + + d->m_blockActivated = false; + +// dump(); +} + +void DocumentManager::syncWithEditor(Core::IContext *context) +{ + if (!context) + return; + + Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); + if (editor && (editor->widget() == context->widget()) && + !editor->isTemporary()) + setCurrentFile(editor->document()->fileName()); +} + +/*! + \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 DocumentManager::addToRecentFiles(const QString &fileName, const Id &editorId) +{ + if (fileName.isEmpty()) + return; + QString unifiedForm(fixFileName(fileName, KeepLinks)); + QMutableListIterator it(d->m_recentFiles); + while (it.hasNext()) { + RecentFile file = it.next(); + QString recentUnifiedForm(fixFileName(file.first, DocumentManager::KeepLinks)); + if (unifiedForm == recentUnifiedForm) + it.remove(); + } + if (d->m_recentFiles.count() > d->m_maxRecentFiles) + d->m_recentFiles.removeLast(); + d->m_recentFiles.prepend(RecentFile(fileName, editorId)); +} + +/*! + \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 DocumentManager::clearRecentFiles() +{ + d->m_recentFiles.clear(); +} + +/*! + \fn QStringList DocumentManager::recentFiles() const + + Returns the list of recent files. +*/ +QList DocumentManager::recentFiles() +{ + return d->m_recentFiles; +} + +void DocumentManager::saveSettings() +{ + QStringList recentFiles; + QStringList recentEditorIds; + foreach (const RecentFile &file, d->m_recentFiles) { + recentFiles.append(file.first); + recentEditorIds.append(file.second.toString()); + } + + QSettings *s = Core::ICore::settings(); + s->beginGroup(QLatin1String(settingsGroupC)); + s->setValue(QLatin1String(filesKeyC), recentFiles); + s->setValue(QLatin1String(editorsKeyC), recentEditorIds); + s->endGroup(); + s->beginGroup(QLatin1String(directoryGroupC)); + s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory); + s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory); + s->endGroup(); +} + +void readSettings() +{ + QSettings *s = Core::ICore::settings(); + d->m_recentFiles.clear(); + s->beginGroup(QLatin1String(settingsGroupC)); + QStringList recentFiles = s->value(QLatin1String(filesKeyC)).toStringList(); + QStringList recentEditorIds = s->value(QLatin1String(editorsKeyC)).toStringList(); + s->endGroup(); + // clean non-existing files + QStringListIterator ids(recentEditorIds); + foreach (const QString &fileName, recentFiles) { + QString editorId; + if (ids.hasNext()) // guard against old or weird settings + editorId = ids.next(); + if (QFileInfo(fileName).isFile()) + d->m_recentFiles.append(DocumentManager::RecentFile(QDir::fromNativeSeparators(fileName), // from native to guard against old settings + Id(editorId))); + } + + s->beginGroup(QLatin1String(directoryGroupC)); + const QString settingsProjectDir = s->value(QLatin1String(projectDirectoryKeyC), + QString()).toString(); + if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir()) { + d->m_projectsDirectory = settingsProjectDir; + } else { + d->m_projectsDirectory = Utils::PathChooser::homePath(); + } + d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC), + d->m_useProjectsDirectory).toBool(); + s->endGroup(); +} + +/*! + + The current file is e.g. the file currently opened when an editor is active, + or the selected file in case a Project Explorer is active ... + + \sa currentFile + */ +void DocumentManager::setCurrentFile(const QString &filePath) +{ + if (d->m_currentFile == filePath) + return; + d->m_currentFile = filePath; + emit m_instance->currentFileChanged(d->m_currentFile); +} + +/*! + Returns the absolute path of the current file + + The current file is e.g. the file currently opened when an editor is active, + or the selected file in case a Project Explorer is active ... + + \sa setCurrentFile + */ +QString DocumentManager::currentFile() +{ + return d->m_currentFile; +} + +/*! + + Returns the initial directory for a new file dialog. If there is + a current file, use that, else use last visited directory. + + \sa setFileDialogLastVisitedDirectory +*/ + +QString DocumentManager::fileDialogInitialDirectory() +{ + if (!d->m_currentFile.isEmpty()) + return QFileInfo(d->m_currentFile).absolutePath(); + return d->m_lastVisitedDirectory; +} + +/*! + + Returns the directory for projects. Defaults to HOME. + + \sa setProjectsDirectory, setUseProjectsDirectory +*/ + +QString DocumentManager::projectsDirectory() +{ + return d->m_projectsDirectory; +} + +/*! + + Set the directory for projects. + + \sa projectsDirectory, useProjectsDirectory +*/ + +void DocumentManager::setProjectsDirectory(const QString &dir) +{ + d->m_projectsDirectory = dir; +} + +/*! + + Returns whether the directory for projects is to be + used or the user wants the current directory. + + \sa setProjectsDirectory, setUseProjectsDirectory +*/ + +bool DocumentManager::useProjectsDirectory() +{ + return d->m_useProjectsDirectory; +} + +/*! + + Sets whether the directory for projects is to be used. + + \sa projectsDirectory, useProjectsDirectory +*/ + +void DocumentManager::setUseProjectsDirectory(bool useProjectsDirectory) +{ + d->m_useProjectsDirectory = useProjectsDirectory; +} + +/*! + + Returns last visited directory of a file dialog. + + \sa setFileDialogLastVisitedDirectory, fileDialogInitialDirectory + +*/ + +QString DocumentManager::fileDialogLastVisitedDirectory() +{ + return d->m_lastVisitedDirectory; +} + +/*! + + Set the last visited directory of a file dialog that will be remembered + for the next one. + + \sa fileDialogLastVisitedDirectory, fileDialogInitialDirectory + + */ + +void DocumentManager::setFileDialogLastVisitedDirectory(const QString &directory) +{ + d->m_lastVisitedDirectory = directory; +} + +void DocumentManager::notifyFilesChangedInternally(const QStringList &files) +{ + emit m_instance->filesChangedInternally(files); +} + +void DocumentManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) +{ + typedef QList EditorFactoryList; + typedef QList ExternalEditorList; + + menu->clear(); + + bool anyMatches = false; + + if (const MimeType mt = ICore::mimeDatabase()->findByFile(QFileInfo(fileName))) { + const EditorFactoryList factories = ICore::editorManager()->editorFactories(mt, false); + const ExternalEditorList externalEditors = ICore::editorManager()->externalEditors(mt, false); + anyMatches = !factories.empty() || !externalEditors.empty(); + if (anyMatches) { + // Add all suitable editors + foreach (IEditorFactory *editorFactory, factories) { + // Add action to open with this very editor factory + QString const actionTitle = editorFactory->displayName(); + QAction * const action = menu->addAction(actionTitle); + OpenWithEntry entry; + entry.editorFactory = editorFactory; + entry.fileName = fileName; + action->setData(qVariantFromValue(entry)); + } + // Add all suitable external editors + foreach (IExternalEditor *externalEditor, externalEditors) { + QAction * const action = menu->addAction(externalEditor->displayName()); + OpenWithEntry entry; + entry.externalEditor = externalEditor; + entry.fileName = fileName; + action->setData(qVariantFromValue(entry)); + } + } + } + menu->setEnabled(anyMatches); +} + +void DocumentManager::executeOpenWithMenuAction(QAction *action) +{ + QTC_ASSERT(action, return); + EditorManager *em = EditorManager::instance(); + const QVariant data = action->data(); + OpenWithEntry entry = qVariantValue(data); + if (entry.editorFactory) { + // close any open editors that have this file open, but have a different type. + QList editorsOpenForFile = em->editorsForFileName(entry.fileName); + if (!editorsOpenForFile.isEmpty()) { + foreach (IEditor *openEditor, editorsOpenForFile) { + if (entry.editorFactory->id() == openEditor->id()) + editorsOpenForFile.removeAll(openEditor); + } + if (!em->closeEditors(editorsOpenForFile)) // don't open if cancel was pressed + return; + } + + em->openEditor(entry.fileName, entry.editorFactory->id(), EditorManager::ModeSwitch); + return; + } + if (entry.externalEditor) + em->openExternalEditor(entry.fileName, entry.externalEditor->id()); +} + +void DocumentManager::slotExecuteOpenWithMenuAction(QAction *action) +{ + executeOpenWithMenuAction(action); +} + +// -------------- FileChangeBlocker + +FileChangeBlocker::FileChangeBlocker(const QString &fileName) + : m_fileName(fileName) +{ + DocumentManager::expectFileChange(fileName); +} + +FileChangeBlocker::~FileChangeBlocker() +{ + DocumentManager::unexpectFileChange(m_fileName); +} + +} // namespace Core diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h new file mode 100644 index 0000000000..7f59e50ecd --- /dev/null +++ b/src/plugins/coreplugin/documentmanager.h @@ -0,0 +1,181 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef DOCUMENTMANAGER_H +#define DOCUMENTMANAGER_H + +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QAction; +class QMainWindow; +class QMenu; +QT_END_NAMESPACE + +namespace Core { + +class IContext; +class IDocument; +class IVersionControl; + +class CORE_EXPORT DocumentManager : public QObject +{ + Q_OBJECT +public: + enum FixMode { + ResolveLinks, + KeepLinks + }; + + typedef QPair RecentFile; + + explicit DocumentManager(QMainWindow *ew); + virtual ~DocumentManager(); + + static DocumentManager *instance(); + + // file pool to monitor + static void addDocuments(const QList &documents, bool addWatcher = true); + static void addDocument(IDocument *document, bool addWatcher = true); + static bool removeDocument(IDocument *document); + static QList modifiedDocuments(); + + static void renamedFile(const QString &from, const QString &to); + + static void expectFileChange(const QString &fileName); + static void unexpectFileChange(const QString &fileName); + + // recent files + static void addToRecentFiles(const QString &fileName, const Id &editorId = Id()); + Q_SLOT void clearRecentFiles(); + static QList recentFiles(); + + static void saveSettings(); + + // current file + static void setCurrentFile(const QString &filePath); + static QString currentFile(); + + // helper methods + static QString fixFileName(const QString &fileName, FixMode fixmode); + + static bool saveDocument(IDocument *document, const QString &fileName = QString(), bool *isReadOnly = 0); + + static QStringList getOpenFileNames(const QString &filters, + const QString path = QString(), + QString *selectedFilter = 0); + static QString getSaveFileName(const QString &title, const QString &pathIn, + const QString &filter = QString(), QString *selectedFilter = 0); + static QString getSaveFileNameWithExtension(const QString &title, const QString &pathIn, + const QString &filter); + static QString getSaveAsFileName(IDocument *document, const QString &filter = QString(), + QString *selectedFilter = 0); + + static QList saveModifiedDocumentsSilently(const QList &documents, bool *cancelled = 0); + static QList saveModifiedDocuments(const QList &documents, + bool *cancelled = 0, + const QString &message = QString(), + const QString &alwaysSaveMessage = QString(), + bool *alwaysSave = 0); + + + // Helper to display a message dialog when encountering a read-only + // file, prompting the user about how to make it writeable. + enum ReadOnlyAction { RO_Cancel, RO_OpenVCS, RO_MakeWriteable, RO_SaveAs }; + static ReadOnlyAction promptReadOnlyFile(const QString &fileName, + const IVersionControl *versionControl, + QWidget *parent, + bool displaySaveAsButton = false); + + static QString fileDialogLastVisitedDirectory(); + static void setFileDialogLastVisitedDirectory(const QString &); + + static QString fileDialogInitialDirectory(); + + static bool useProjectsDirectory(); + static void setUseProjectsDirectory(bool); + + static QString projectsDirectory(); + static void setProjectsDirectory(const QString &); + + static void populateOpenWithMenu(QMenu *menu, const QString &fileName); + + /* Used to notify e.g. the code model to update the given files. Does *not* + lead to any editors to reload or any other editor manager actions. */ + static void notifyFilesChangedInternally(const QStringList &files); + + static void executeOpenWithMenuAction(QAction *action); + +public slots: + void slotExecuteOpenWithMenuAction(QAction *action); + +signals: + void currentFileChanged(const QString &filePath); + /* Used to notify e.g. the code model to update the given files. Does *not* + lead to any editors to reload or any other editor manager actions. */ + void filesChangedInternally(const QStringList &files); + +private slots: + void documentDestroyed(QObject *obj); + void checkForNewFileName(); + void checkForReload(); + void changedFile(const QString &file); + void mainWindowActivated(); + void syncWithEditor(Core::IContext *context); +}; + +/*! The FileChangeBlocker blocks all change notifications to all IDocument * that + match the given filename. And unblocks in the destructor. + + To also reload the IDocument in the destructor class set modifiedReload to true + + */ +class CORE_EXPORT FileChangeBlocker +{ +public: + explicit FileChangeBlocker(const QString &fileName); + ~FileChangeBlocker(); +private: + const QString m_fileName; + Q_DISABLE_COPY(FileChangeBlocker) +}; + +} // namespace Core + +Q_DECLARE_METATYPE(Core::DocumentManager::RecentFile) + +#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 #include 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 EditorManager::editorsForFileName(const QString &filename) const { QList 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 EditorManager::editorsForFile(IFile *file) const +QList EditorManager::editorsForDocument(IDocument *document) const { QList 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 - EditorManager::editorsForFiles(QList files) const + EditorManager::editorsForDocuments(QList documents) const { const QList editors = openedEditors(); QSet 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 return found.toList(); } -QList EditorManager::filesForEditors(QList editors) const +QList EditorManager::documentsForEditors(QList editors) const { QSet handledEditors; - QList files; + QList 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 &editorsToClose, bool ask //ask whether to save modified files if (askAboutModifiedEditors) { bool cancelled = false; - QList list = FileManager::saveModifiedFiles(filesForEditors(acceptedEditors), &cancelled); + QList list = DocumentManager::saveModifiedDocuments(documentsForEditors(acceptedEditors), &cancelled); if (cancelled) return false; if (!list.isEmpty()) { closingFailed = true; - QSet skipSet = editorsForFiles(list).toSet(); + QSet skipSet = editorsForDocuments(list).toSet(); acceptedEditors = acceptedEditors.toSet().subtract(skipSet).toList(); } } @@ -891,11 +891,11 @@ bool EditorManager::closeEditors(const QList &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 editors = editorsForFile(file); + const QList 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 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 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 editors = editorsForFile(file); + QList 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(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("Warning: 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("Warning: 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 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 >(); 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 -#include // enumerations +#include // enumerations #include #include @@ -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 editorsForFileName(const QString &filename) const; - QList editorsForFile(IFile *file) const; + QList editorsForDocument(IDocument *document) const; IEditor *currentEditor() const; QList 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 editorsForFiles(QList files) const; + QList editorsForDocuments(QList documents) const; void addCurrentPositionToNavigationHistory(IEditor *editor = 0, const QByteArray &saveState = QByteArray()); void cutForwardNavigationHistory(); @@ -151,7 +151,7 @@ public: bool closeEditors(const QList &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 filesForEditors(QList editors) const; + QList documentsForEditors(QList 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 file; + QPointer 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 +#include 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 #include @@ -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 OpenEditorsModel::duplicatesFor(IEditor *editor) const { QList 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 #include -#include +#include #include #include #include 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 @@ -44,7 +44,7 @@ #include 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 filesDone; + QSet 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()) { + if (IDocument *document = item->data(0, Qt::UserRole).value()) { EditorView *view = item->data(0, Qt::UserRole+1).value(); - 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(), 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 #include #include -#include +#include #include #include #include @@ -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() << editor->file(), &cancelled); + DocumentManager::saveModifiedDocuments(QList() << 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/filemanager.cpp b/src/plugins/coreplugin/filemanager.cpp deleted file mode 100644 index 8736ea1aa8..0000000000 --- a/src/plugins/coreplugin/filemanager.cpp +++ /dev/null @@ -1,1389 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "filemanager.h" - -#include "editormanager.h" -#include "icore.h" -#include "ieditor.h" -#include "ieditorfactory.h" -#include "iexternaleditor.h" -#include "ifile.h" -#include "iversioncontrol.h" -#include "mimedatabase.h" -#include "saveitemsdialog.h" -#include "vcsmanager.h" -#include "coreconstants.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/*! - \class Core::FileManager - \mainclass - \inheaderfile filemanager.h - \brief Manages a set of IFile 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 - 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 - 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 - themselves. - - The FileManager 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. - - The service also manages the list of recent files to be shown to the user - (see addToRecentFiles() and recentFiles()). - */ - -static const char settingsGroupC[] = "RecentFiles"; -static const char filesKeyC[] = "Files"; -static const char editorsKeyC[] = "EditorIds"; - -static const char directoryGroupC[] = "Directories"; -static const char projectDirectoryKeyC[] = "Projects"; -static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory"; - - -namespace Core { - -static void readSettings(); - -static QList saveModifiedFilesHelper(const QList &files, - bool *cancelled, bool silently, - const QString &message, - const QString &alwaysSaveMessage = QString(), - bool *alwaysSave = 0); - -namespace Internal { - -struct OpenWithEntry -{ - OpenWithEntry() : editorFactory(0), externalEditor(0) {} - IEditorFactory *editorFactory; - IExternalEditor *externalEditor; - QString fileName; -}; - -struct FileStateItem -{ - QDateTime modified; - QFile::Permissions permissions; -}; - -struct FileState -{ - QMap lastUpdatedState; - FileStateItem expected; -}; - - -struct FileManagerPrivate -{ - explicit FileManagerPrivate(QMainWindow *mw); - QFileSystemWatcher *fileWatcher(); - QFileSystemWatcher *linkWatcher(); - - QMap m_states; - QSet m_changedFiles; - QList m_filesWithoutWatch; - QMap m_filesWithWatch; - QSet m_expectedFileNames; - - QList m_recentFiles; - static const int m_maxRecentFiles = 7; - - QString m_currentFile; - - QMainWindow *m_mainWindow; - QFileSystemWatcher *m_fileWatcher; // Delayed creation. - QFileSystemWatcher *m_linkWatcher; // Delayed creation (only UNIX/if a link is seen). - bool m_blockActivated; - QString m_lastVisitedDirectory; - QString m_projectsDirectory; - bool m_useProjectsDirectory; - // When we are callling into a IFile - // we don't want to receive a changed() - // signal - // That makes the code easier - IFile *m_blockedIFile; -}; - -static FileManager *m_instance; -static Internal::FileManagerPrivate *d; - -QFileSystemWatcher *FileManagerPrivate::fileWatcher() -{ - if (!m_fileWatcher) { - m_fileWatcher= new QFileSystemWatcher(m_instance); - QObject::connect(m_fileWatcher, SIGNAL(fileChanged(QString)), - m_instance, SLOT(changedFile(QString))); - } - return m_fileWatcher; -} - -QFileSystemWatcher *FileManagerPrivate::linkWatcher() -{ -#ifdef Q_OS_UNIX - if (!m_linkWatcher) { - m_linkWatcher = new QFileSystemWatcher(m_instance); - m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller")); - QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)), - m_instance, SLOT(changedFile(QString))); - } - return m_linkWatcher; -#else - return fileWatcher(); -#endif -} - -FileManagerPrivate::FileManagerPrivate(QMainWindow *mw) : - m_mainWindow(mw), - m_fileWatcher(0), - m_linkWatcher(0), - m_blockActivated(false), - m_lastVisitedDirectory(QDir::currentPath()), -#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder. - m_useProjectsDirectory(true), -#else - m_useProjectsDirectory(false), -#endif - m_blockedIFile(0) -{ -} - -} // namespace Internal -} // namespace Core - -Q_DECLARE_METATYPE(Core::Internal::OpenWithEntry) - -namespace Core { - -using namespace Internal; - -FileManager::FileManager(QMainWindow *mw) - : QObject(mw) -{ - d = new FileManagerPrivate(mw); - m_instance = this; - connect(d->m_mainWindow, SIGNAL(windowActivated()), - this, SLOT(mainWindowActivated())); - connect(ICore::instance(), SIGNAL(contextChanged(Core::IContext*,Core::Context)), - this, SLOT(syncWithEditor(Core::IContext*))); - - readSettings(); -} - -FileManager::~FileManager() -{ - delete d; -} - -FileManager *FileManager::instance() -{ - return m_instance; -} - -/* only called from addFileInfo(IFile *) */ -static void addFileInfo(const QString &fileName, IFile *file, bool isLink) -{ - FileStateItem state; - if (!fileName.isEmpty()) { - const QFileInfo fi(fileName); - state.modified = fi.lastModified(); - state.permissions = fi.permissions(); - // Add watcher if we don't have that already - if (!d->m_states.contains(fileName)) { - d->m_states.insert(fileName, FileState()); - - } - QFileSystemWatcher *watcher = 0; - if (isLink) - watcher = d->linkWatcher(); - else - watcher = d->fileWatcher(); - if (!watcher->files().contains(fileName)) - watcher->addPath(fileName); - - d->m_states[fileName].lastUpdatedState.insert(file, state); - } - d->m_filesWithWatch[file].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 - (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) -{ - const QString fixedName = FileManager::fixFileName(file->fileName(), FileManager::KeepLinks); - const QString fixedResolvedName = FileManager::fixFileName(file->fileName(), FileManager::ResolveLinks); - addFileInfo(fixedResolvedName, file, false); - if (fixedName != fixedResolvedName) - addFileInfo(fixedName, file, true); -} - -/*! - \fn bool FileManager::addFiles(const QList &files, bool addWatcher) - - Adds a list of IFile'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 &files, 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); - } - } - 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); - } - } -} - - -/* 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 - also removes the file watcher. -*/ -static void removeFileInfo(IFile *file) -{ - if (!d->m_filesWithWatch.contains(file)) - return; - foreach (const QString &fileName, d->m_filesWithWatch.value(file)) { - if (!d->m_states.contains(fileName)) - continue; - d->m_states[fileName].lastUpdatedState.remove(file); - if (d->m_states.value(fileName).lastUpdatedState.isEmpty()) { - if (d->m_fileWatcher && d->m_fileWatcher->files().contains(fileName)) - d->m_fileWatcher->removePath(fileName); - if (d->m_linkWatcher && d->m_linkWatcher->files().contains(fileName)) - d->m_linkWatcher->removePath(fileName); - d->m_states.remove(fileName); - } - } - d->m_filesWithWatch.remove(file); -} - -/// Dumps the state of the file manager's map -/// For debugging purposes -/* -static void dump() -{ - qDebug() << "======== dumping state map"; - QMap::const_iterator it, end; - it = d->m_states.constBegin(); - end = d->m_states.constEnd(); - for (; it != end; ++it) { - qDebug() << it.key(); - qDebug() << " expected:" << it.value().expected.modified; - - QMap::const_iterator jt, jend; - jt = it.value().lastUpdatedState.constBegin(); - jend = it.value().lastUpdatedState.constEnd(); - for (; jt != jend; ++jt) { - qDebug() << " " << jt.key()->fileName() << jt.value().modified; - } - } - qDebug() << "------- dumping files with watch list"; - foreach (IFile *key, d->m_filesWithWatch.keys()) { - qDebug() << key->fileName() << d->m_filesWithWatch.value(key); - } - qDebug() << "------- dumping watch list"; - if (d->m_fileWatcher) - qDebug() << d->m_fileWatcher->files(); - qDebug() << "------- dumping link watch list"; - if (d->m_linkWatcher) - qDebug() << d->m_linkWatcher->files(); -} -*/ - -/*! - \fn void FileManager::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 - information to avoid annoying the user with "file has been removed" - popups. -*/ -void FileManager::renamedFile(const QString &from, const QString &to) -{ - const QString &fixedFrom = fixFileName(from, KeepLinks); - - // gather the list of IFiles - QList filesToRename; - QMapIterator it(d->m_filesWithWatch); - while (it.hasNext()) { - it.next(); - if (it.value().contains(fixedFrom)) - filesToRename.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; - } -} -/*! - \fn bool FileManager::addFile(IFile *files, bool addWatcher) - - Adds a IFile 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) -{ - addFiles(QList() << file, addWatcher); -} - -void FileManager::fileDestroyed(QObject *obj) -{ - IFile *file = static_cast(obj); - // Check the special unwatched first: - if (!d->m_filesWithoutWatch.removeOne(file)) - removeFileInfo(file); -} - -/*! - \fn bool FileManager::removeFile(IFile *file) - - Removes a IFile object from the collection. - - Returns true if the file specified by \a file had the addWatcher argument to addFile() set. -*/ -bool FileManager::removeFile(IFile *file) -{ - QTC_ASSERT(file, return false); - - bool addWatcher = false; - // Special casing unwatched files - if (!d->m_filesWithoutWatch.removeOne(file)) { - addWatcher = true; - removeFileInfo(file); - disconnect(file, SIGNAL(changed()), m_instance, SLOT(checkForNewFileName())); - } - disconnect(file, SIGNAL(destroyed(QObject *)), m_instance, SLOT(fileDestroyed(QObject *))); - return addWatcher; -} - -/* Slot reacting on IFile::changed. We need to check if the signal was sent - because the file was saved under different name. */ -void FileManager::checkForNewFileName() -{ - IFile *file = qobject_cast(sender()); - // We modified the IFile - // Trust the other code to also update the m_states map - if (file == d->m_blockedIFile) - return; - QTC_ASSERT(file, return); - QTC_ASSERT(d->m_filesWithWatch.contains(file), 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); -} - -/*! - \fn QString FileManager::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 s = fileName; - QFileInfo fi(s); - if (fi.exists()) { - if (fixmode == ResolveLinks) - s = fi.canonicalFilePath(); - else - s = QDir::cleanPath(fi.absoluteFilePath()); - } else { - s = QDir::cleanPath(s); - } - s = QDir::toNativeSeparators(s); -#ifdef Q_OS_WIN - s = s.toLower(); -#endif - return s; -} - -/*! - \fn QList FileManager::modifiedFiles() const - - Returns the list of IFile's that have been modified. -*/ -QList FileManager::modifiedFiles() -{ - QList modifiedFiles; - - foreach (IFile *file, d->m_filesWithWatch.keys()) { - if (file->isModified()) - modifiedFiles << file; - } - - foreach(IFile *file, d->m_filesWithoutWatch) { - if (file->isModified()) - modifiedFiles << file; - } - - return modifiedFiles; -} - -/*! - \fn void FileManager::expectFileChange(const QString &fileName) - - Any subsequent change to \a fileName is treated as a expected file change. - - \see FileManager::unexpectFileChange(const QString &fileName) -*/ -void FileManager::expectFileChange(const QString &fileName) -{ - if (fileName.isEmpty()) - return; - d->m_expectedFileNames.insert(fileName); -} - -/* only called from unblock and unexpect file change methods */ -static void updateExpectedState(const QString &fileName) -{ - if (fileName.isEmpty()) - return; - if (d->m_states.contains(fileName)) { - QFileInfo fi(fileName); - d->m_states[fileName].expected.modified = fi.lastModified(); - d->m_states[fileName].expected.permissions = fi.permissions(); - } -} - -/*! - \fn void FileManager::unexpectFileChange(const QString &fileName) - - Any change to \a fileName are unexpected again. - - \see FileManager::expectFileChange(const QString &fileName) -*/ -void FileManager::unexpectFileChange(const QString &fileName) -{ - // We are updating the expected time of the file - // And in changedFile we'll check if the modification time - // is the same as the saved one here - // If so then it's a expected change - - if (fileName.isEmpty()) - return; - d->m_expectedFileNames.remove(fileName); - const QString fixedName = fixFileName(fileName, KeepLinks); - updateExpectedState(fixedName); - const QString fixedResolvedName = fixFileName(fileName, ResolveLinks); - if (fixedName != fixedResolvedName) - updateExpectedState(fixedResolvedName); -} - -/*! - \fn QList FileManager::saveModifiedFilesSilently(const QList &files) - - Tries to save the files listed in \a files. The \a cancelled argument is set to true - if the user cancelled the dialog. Returns the files that could not be saved. -*/ -QList FileManager::saveModifiedFilesSilently(const QList &files, bool *cancelled) -{ - return saveModifiedFilesHelper(files, cancelled, true, QString()); -} - -/*! - \fn QList FileManager::saveModifiedFiles(const QList &files, bool *cancelled, const QString &message, const QString &alwaysSaveMessage, bool *alwaysSave) - - Asks the user whether to save the files listed in \a files . - 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). - The \a cancelled argument is set to true if the user cancelled the dialog, - \a alwaysSave is set to match the selection of the user, if files should - always automatically be saved. - Returns the files that have not been saved. -*/ -QList FileManager::saveModifiedFiles(const QList &files, - bool *cancelled, const QString &message, - const QString &alwaysSaveMessage, - bool *alwaysSave) -{ - return saveModifiedFilesHelper(files, cancelled, false, message, alwaysSaveMessage, alwaysSave); -} - -static QList saveModifiedFilesHelper(const QList &files, - bool *cancelled, - bool silently, - const QString &message, - const QString &alwaysSaveMessage, - bool *alwaysSave) -{ - if (cancelled) - (*cancelled) = false; - - QList notSaved; - QMap modifiedFilesMap; - QList modifiedFiles; - - foreach (IFile *file, files) { - if (file->isModified()) { - QString name = file->fileName(); - if (name.isEmpty()) - name = file->suggestedFileName(); - - // There can be several IFiles 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); - } - } - modifiedFiles = modifiedFilesMap.keys(); - if (!modifiedFiles.isEmpty()) { - QList filesToSave; - if (silently) { - filesToSave = modifiedFiles; - } else { - SaveItemsDialog dia(d->m_mainWindow, modifiedFiles); - if (!message.isEmpty()) - dia.setMessage(message); - if (!alwaysSaveMessage.isNull()) - dia.setAlwaysSaveMessage(alwaysSaveMessage); - if (dia.exec() != QDialog::Accepted) { - if (cancelled) - (*cancelled) = true; - if (alwaysSave) - *alwaysSave = dia.alwaysSaveChecked(); - notSaved = modifiedFiles; - return notSaved; - } - if (alwaysSave) - *alwaysSave = dia.alwaysSaveChecked(); - filesToSave = dia.itemsToSave(); - } - - foreach (IFile *file, filesToSave) { - if (!EditorManager::instance()->saveFile(file)) { - if (cancelled) - *cancelled = true; - notSaved.append(file); - } - } - } - return notSaved; -} - -bool FileManager::saveFile(IFile *file, 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 errorString; - if (!file->save(&errorString, fileName, false)) { - if (isReadOnly) { - QFile ofi(effName); - // Check whether the existing file is writable - if (!ofi.open(QIODevice::ReadWrite) && ofi.open(QIODevice::ReadOnly)) { - *isReadOnly = true; - goto out; - } - *isReadOnly = false; - } - QMessageBox::critical(d->m_mainWindow, tr("File Error"), errorString); - out: - ret = false; - } - - addFile(file, addWatcher); - unexpectFileChange(effName); - return ret; -} - -QString FileManager::getSaveFileName(const QString &title, const QString &pathIn, - const QString &filter, QString *selectedFilter) -{ - const QString &path = pathIn.isEmpty() ? fileDialogInitialDirectory() : pathIn; - QString fileName; - bool repeat; - do { - repeat = false; - fileName = QFileDialog::getSaveFileName( - d->m_mainWindow, title, path, filter, selectedFilter, QFileDialog::DontConfirmOverwrite); - if (!fileName.isEmpty()) { - // If the selected filter is All Files (*) we leave the name exactly as the user - // specified. Otherwise the suffix must be one available in the selected filter. If - // the name already ends with such suffix nothing needs to be done. But if not, the - // first one from the filter is appended. - if (selectedFilter && *selectedFilter != QCoreApplication::translate( - "Core", Constants::ALL_FILES_FILTER)) { - // Mime database creates filter strings like this: Anything here (*.foo *.bar) - QRegExp regExp(QLatin1String(".*\\s+\\((.*)\\)$")); - const int index = regExp.lastIndexIn(*selectedFilter); - bool suffixOk = false; - if (index != -1) { - const QStringList &suffixes = regExp.cap(1).remove(QLatin1Char('*')).split(QLatin1Char(' ')); - foreach (const QString &suffix, suffixes) - if (fileName.endsWith(suffix)) { - suffixOk = true; - break; - } - if (!suffixOk && !suffixes.isEmpty()) - fileName.append(suffixes.at(0)); - } - } - if (QFile::exists(fileName)) { - if (QMessageBox::warning(d->m_mainWindow, tr("Overwrite?"), - tr("An item named '%1' already exists at this location. " - "Do you want to overwrite it?").arg(fileName), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) { - repeat = true; - } - } - } - } while (repeat); - if (!fileName.isEmpty()) - setFileDialogLastVisitedDirectory(QFileInfo(fileName).absolutePath()); - return fileName; -} - -QString FileManager::getSaveFileNameWithExtension(const QString &title, const QString &pathIn, - const QString &filter) -{ - QString selected = filter; - return getSaveFileName(title, pathIn, filter, &selected); -} - -/*! - \fn QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QString *selectedFilter) - - Asks the user for a new file name (Save File As) for /arg file. -*/ -QString FileManager::getSaveAsFileName(IFile *file, const QString &filter, QString *selectedFilter) -{ - if (!file) - return QLatin1String(""); - QString absoluteFilePath = file->fileName(); - const QFileInfo fi(absoluteFilePath); - QString fileName = fi.fileName(); - QString path = fi.absolutePath(); - if (absoluteFilePath.isEmpty()) { - fileName = file->suggestedFileName(); - const QString defaultPath = file->defaultPath(); - if (!defaultPath.isEmpty()) - path = defaultPath; - } - - QString filterString; - if (filter.isEmpty()) { - if (const MimeType &mt = Core::ICore::mimeDatabase()->findByFile(fi)) - filterString = mt.filterString(); - selectedFilter = &filterString; - } else { - filterString = filter; - } - - absoluteFilePath = getSaveFileName(tr("Save File As"), - path + QDir::separator() + fileName, - filterString, - selectedFilter); - return absoluteFilePath; -} - -/*! - \fn QStringList FileManager::getOpenFileNames(const QString &filters, - const QString pathIn, - QString *selectedFilter) - - Asks the user for a set of file names to be opened. The \a filters - and \a selectedFilter parameters is interpreted like in - QFileDialog::getOpenFileNames(), \a pathIn specifies a path to open the dialog - in, if that is not overridden by the users policy. -*/ - -QStringList FileManager::getOpenFileNames(const QString &filters, - const QString pathIn, - QString *selectedFilter) -{ - QString path = pathIn; - if (path.isEmpty()) { - if (!d->m_currentFile.isEmpty()) - path = QFileInfo(d->m_currentFile).absoluteFilePath(); - if (path.isEmpty() && useProjectsDirectory()) - path = projectsDirectory(); - } - const QStringList files = QFileDialog::getOpenFileNames(d->m_mainWindow, - tr("Open File"), - path, filters, - selectedFilter); - if (!files.isEmpty()) - setFileDialogLastVisitedDirectory(QFileInfo(files.front()).absolutePath()); - return files; -} - -FileManager::ReadOnlyAction - FileManager::promptReadOnlyFile(const QString &fileName, - const IVersionControl *versionControl, - QWidget *parent, - bool displaySaveAsButton) -{ - // Version Control: If automatic open is desired, open right away. - bool promptVCS = false; - if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) { - if (versionControl->settingsFlags() & IVersionControl::AutoOpen) - return RO_OpenVCS; - promptVCS = true; - } - - // Create message box. - QMessageBox msgBox(QMessageBox::Question, tr("File Is Read Only"), - tr("The file %1 is read only.").arg(QDir::toNativeSeparators(fileName)), - QMessageBox::Cancel, parent); - - QPushButton *vcsButton = 0; - if (promptVCS) - vcsButton = msgBox.addButton(tr("Open with VCS (%1)").arg(versionControl->displayName()), QMessageBox::AcceptRole); - - QPushButton *makeWritableButton = msgBox.addButton(tr("Make Writable"), QMessageBox::AcceptRole); - - QPushButton *saveAsButton = 0; - if (displaySaveAsButton) - saveAsButton = msgBox.addButton(tr("Save As..."), QMessageBox::ActionRole); - - msgBox.setDefaultButton(vcsButton ? vcsButton : makeWritableButton); - msgBox.exec(); - - QAbstractButton *clickedButton = msgBox.clickedButton(); - if (clickedButton == vcsButton) - return RO_OpenVCS; - if (clickedButton == makeWritableButton) - return RO_MakeWriteable; - if (displaySaveAsButton && clickedButton == saveAsButton) - return RO_SaveAs; - return RO_Cancel; -} - -void FileManager::changedFile(const QString &fileName) -{ - const bool wasempty = d->m_changedFiles.isEmpty(); - - if (d->m_states.contains(fileName)) - d->m_changedFiles.insert(fileName); - - if (wasempty && !d->m_changedFiles.isEmpty()) { - QTimer::singleShot(200, this, SLOT(checkForReload())); - } -} - -void FileManager::mainWindowActivated() -{ - //we need to do this asynchronously because - //opening a dialog ("Reload?") in a windowactivated event - //freezes on Mac - QTimer::singleShot(0, this, SLOT(checkForReload())); -} - -void FileManager::checkForReload() -{ - if (d->m_changedFiles.isEmpty()) - return; - if (QApplication::activeWindow() != d->m_mainWindow) - return; - - if (d->m_blockActivated) - return; - - d->m_blockActivated = true; - - IFile::ReloadSetting defaultBehavior = EditorManager::instance()->reloadSetting(); - Utils::ReloadPromptAnswer previousAnswer = Utils::ReloadCurrent; - - QList editorsToClose; - QMap filesToSave; - - // collect file information - QMap currentStates; - QMap changeTypes; - QSet changedIFiles; - foreach (const QString &fileName, d->m_changedFiles) { - IFile::ChangeType type = IFile::TypeContents; - FileStateItem state; - QFileInfo fi(fileName); - if (!fi.exists()) { - type = IFile::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); - } - - // clean up. do this before we may enter the main loop, otherwise we would - // lose consecutive notifications. - d->m_changedFiles.clear(); - - // collect information about "expected" file names - // we can't do the "resolving" already in expectFileChange, because - // if the resolved names are different when unexpectFileChange is called - // we would end up with never-unexpected file names - QSet expectedFileNames; - foreach (const QString &fileName, d->m_expectedFileNames) { - const QString fixedName = fixFileName(fileName, KeepLinks); - expectedFileNames.insert(fixedName); - const QString fixedResolvedName = fixFileName(fileName, ResolveLinks); - if (fixedName != fixedResolvedName) - expectedFileNames.insert(fixedResolvedName); - } - - // handle the IFiles - QStringList errorStrings; - foreach (IFile *file, changedIFiles) { - IFile::ChangeTrigger trigger = IFile::TriggerInternal; - IFile::ChangeType type = IFile::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)) { - // 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); - - // did the file actually change? - if (lastState.modified == currentState.modified && lastState.permissions == currentState.permissions) - continue; - changed = true; - - // was it only a permission change? - if (lastState.modified == currentState.modified) - continue; - - // was the change unexpected? - if ((currentState.modified != expectedState.modified || currentState.permissions != expectedState.permissions) - && !expectedFileNames.contains(fileName)) { - trigger = IFile::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; - } - } - - if (!changed) // probably because the change was blocked with (un)blockFileChange - continue; - - // handle it! - d->m_blockedIFile = file; - - bool success = true; - QString errorString; - // we've got some modification - // check if it's contents or permissions: - if (type == IFile::TypePermissions) { - // Only permission change - success = file->reload(&errorString, IFile::FlagReload, IFile::TypePermissions); - // now we know it's a content change or file was removed - } else if (defaultBehavior == IFile::ReloadUnmodified - && type == IFile::TypeContents && !file->isModified()) { - // content change, but unmodified (and settings say to reload in this case) - success = file->reload(&errorString, IFile::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()) { - // file removed, but unmodified files should be reloaded - // so we close the file - editorsToClose << EditorManager::instance()->editorsForFile(file); - } else if (defaultBehavior == IFile::IgnoreAll) { - // content change or removed, but settings say ignore - success = file->reload(&errorString, IFile::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 - } 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 - if (previousAnswer == Utils::ReloadNone) { - // answer already given, ignore - success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents); - } else if (previousAnswer == Utils::ReloadAll) { - // answer already given, reload - success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents); - } else { - // Ask about content change - previousAnswer = Utils::reloadPrompt(file->fileName(), file->isModified(), QApplication::activeWindow()); - switch (previousAnswer) { - case Utils::ReloadAll: - case Utils::ReloadCurrent: - success = file->reload(&errorString, IFile::FlagReload, IFile::TypeContents); - break; - case Utils::ReloadSkipCurrent: - case Utils::ReloadNone: - success = file->reload(&errorString, IFile::FlagIgnore, IFile::TypeContents); - break; - } - } - // IFile 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())) { - case Utils::FileDeletedSave: - filesToSave.insert(file, file->fileName()); - unhandled = false; - break; - case Utils::FileDeletedSaveAs: - { - const QString &saveFileName = getSaveAsFileName(file); - if (!saveFileName.isEmpty()) { - filesToSave.insert(file, saveFileName); - unhandled = false; - } - break; - } - case Utils::FileDeletedClose: - editorsToClose << EditorManager::instance()->editorsForFile(file); - unhandled = false; - break; - } - } - } - } - if (!success) { - if (errorString.isEmpty()) - errorStrings << tr("Cannot reload %1").arg(QDir::toNativeSeparators(file->fileName())); - else - errorStrings << errorString; - } - - // update file info, also handling if e.g. link target has changed - removeFileInfo(file); - addFileInfo(file); - d->m_blockedIFile = 0; - } - if (!errorStrings.isEmpty()) - QMessageBox::critical(d->m_mainWindow, tr("File Error"), - errorStrings.join(QLatin1String("\n"))); - - // handle deleted files - EditorManager::instance()->closeEditors(editorsToClose, false); - QMapIterator it(filesToSave); - while (it.hasNext()) { - it.next(); - saveFile(it.key(), it.value()); - it.key()->checkPermissions(); - } - - d->m_blockActivated = false; - -// dump(); -} - -void FileManager::syncWithEditor(Core::IContext *context) -{ - if (!context) - return; - - Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); - if (editor && (editor->widget() == context->widget()) && - !editor->isTemporary()) - setCurrentFile(editor->file()->fileName()); -} - -/*! - \fn void FileManager::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) -{ - if (fileName.isEmpty()) - return; - QString unifiedForm(fixFileName(fileName, KeepLinks)); - QMutableListIterator it(d->m_recentFiles); - while (it.hasNext()) { - RecentFile file = it.next(); - QString recentUnifiedForm(fixFileName(file.first, FileManager::KeepLinks)); - if (unifiedForm == recentUnifiedForm) - it.remove(); - } - if (d->m_recentFiles.count() > d->m_maxRecentFiles) - d->m_recentFiles.removeLast(); - d->m_recentFiles.prepend(RecentFile(fileName, editorId)); -} - -/*! - \fn void FileManager::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() -{ - d->m_recentFiles.clear(); -} - -/*! - \fn QStringList FileManager::recentFiles() const - - Returns the list of recent files. -*/ -QList FileManager::recentFiles() -{ - return d->m_recentFiles; -} - -void FileManager::saveSettings() -{ - QStringList recentFiles; - QStringList recentEditorIds; - foreach (const RecentFile &file, d->m_recentFiles) { - recentFiles.append(file.first); - recentEditorIds.append(file.second.toString()); - } - - QSettings *s = Core::ICore::settings(); - s->beginGroup(QLatin1String(settingsGroupC)); - s->setValue(QLatin1String(filesKeyC), recentFiles); - s->setValue(QLatin1String(editorsKeyC), recentEditorIds); - s->endGroup(); - s->beginGroup(QLatin1String(directoryGroupC)); - s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory); - s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory); - s->endGroup(); -} - -void readSettings() -{ - QSettings *s = Core::ICore::settings(); - d->m_recentFiles.clear(); - s->beginGroup(QLatin1String(settingsGroupC)); - QStringList recentFiles = s->value(QLatin1String(filesKeyC)).toStringList(); - QStringList recentEditorIds = s->value(QLatin1String(editorsKeyC)).toStringList(); - s->endGroup(); - // clean non-existing files - QStringListIterator ids(recentEditorIds); - foreach (const QString &fileName, recentFiles) { - QString editorId; - 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 - Id(editorId))); - } - - s->beginGroup(QLatin1String(directoryGroupC)); - const QString settingsProjectDir = s->value(QLatin1String(projectDirectoryKeyC), - QString()).toString(); - if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir()) { - d->m_projectsDirectory = settingsProjectDir; - } else { - d->m_projectsDirectory = Utils::PathChooser::homePath(); - } - d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC), - d->m_useProjectsDirectory).toBool(); - s->endGroup(); -} - -/*! - - The current file is e.g. the file currently opened when an editor is active, - or the selected file in case a Project Explorer is active ... - - \sa currentFile - */ -void FileManager::setCurrentFile(const QString &filePath) -{ - if (d->m_currentFile == filePath) - return; - d->m_currentFile = filePath; - emit m_instance->currentFileChanged(d->m_currentFile); -} - -/*! - Returns the absolute path of the current file - - The current file is e.g. the file currently opened when an editor is active, - or the selected file in case a Project Explorer is active ... - - \sa setCurrentFile - */ -QString FileManager::currentFile() -{ - return d->m_currentFile; -} - -/*! - - Returns the initial directory for a new file dialog. If there is - a current file, use that, else use last visited directory. - - \sa setFileDialogLastVisitedDirectory -*/ - -QString FileManager::fileDialogInitialDirectory() -{ - if (!d->m_currentFile.isEmpty()) - return QFileInfo(d->m_currentFile).absolutePath(); - return d->m_lastVisitedDirectory; -} - -/*! - - Returns the directory for projects. Defaults to HOME. - - \sa setProjectsDirectory, setUseProjectsDirectory -*/ - -QString FileManager::projectsDirectory() -{ - return d->m_projectsDirectory; -} - -/*! - - Set the directory for projects. - - \sa projectsDirectory, useProjectsDirectory -*/ - -void FileManager::setProjectsDirectory(const QString &dir) -{ - d->m_projectsDirectory = dir; -} - -/*! - - Returns whether the directory for projects is to be - used or the user wants the current directory. - - \sa setProjectsDirectory, setUseProjectsDirectory -*/ - -bool FileManager::useProjectsDirectory() -{ - return d->m_useProjectsDirectory; -} - -/*! - - Sets whether the directory for projects is to be used. - - \sa projectsDirectory, useProjectsDirectory -*/ - -void FileManager::setUseProjectsDirectory(bool useProjectsDirectory) -{ - d->m_useProjectsDirectory = useProjectsDirectory; -} - -/*! - - Returns last visited directory of a file dialog. - - \sa setFileDialogLastVisitedDirectory, fileDialogInitialDirectory - -*/ - -QString FileManager::fileDialogLastVisitedDirectory() -{ - return d->m_lastVisitedDirectory; -} - -/*! - - Set the last visited directory of a file dialog that will be remembered - for the next one. - - \sa fileDialogLastVisitedDirectory, fileDialogInitialDirectory - - */ - -void FileManager::setFileDialogLastVisitedDirectory(const QString &directory) -{ - d->m_lastVisitedDirectory = directory; -} - -void FileManager::notifyFilesChangedInternally(const QStringList &files) -{ - emit m_instance->filesChangedInternally(files); -} - -void FileManager::populateOpenWithMenu(QMenu *menu, const QString &fileName) -{ - typedef QList EditorFactoryList; - typedef QList ExternalEditorList; - - menu->clear(); - - bool anyMatches = false; - - if (const MimeType mt = ICore::mimeDatabase()->findByFile(QFileInfo(fileName))) { - const EditorFactoryList factories = ICore::editorManager()->editorFactories(mt, false); - const ExternalEditorList externalEditors = ICore::editorManager()->externalEditors(mt, false); - anyMatches = !factories.empty() || !externalEditors.empty(); - if (anyMatches) { - // Add all suitable editors - foreach (IEditorFactory *editorFactory, factories) { - // Add action to open with this very editor factory - QString const actionTitle = editorFactory->displayName(); - QAction * const action = menu->addAction(actionTitle); - OpenWithEntry entry; - entry.editorFactory = editorFactory; - entry.fileName = fileName; - action->setData(qVariantFromValue(entry)); - } - // Add all suitable external editors - foreach (IExternalEditor *externalEditor, externalEditors) { - QAction * const action = menu->addAction(externalEditor->displayName()); - OpenWithEntry entry; - entry.externalEditor = externalEditor; - entry.fileName = fileName; - action->setData(qVariantFromValue(entry)); - } - } - } - menu->setEnabled(anyMatches); -} - -void FileManager::executeOpenWithMenuAction(QAction *action) -{ - QTC_ASSERT(action, return); - EditorManager *em = EditorManager::instance(); - const QVariant data = action->data(); - OpenWithEntry entry = qVariantValue(data); - if (entry.editorFactory) { - // close any open editors that have this file open, but have a different type. - QList editorsOpenForFile = em->editorsForFileName(entry.fileName); - if (!editorsOpenForFile.isEmpty()) { - foreach (IEditor *openEditor, editorsOpenForFile) { - if (entry.editorFactory->id() == openEditor->id()) - editorsOpenForFile.removeAll(openEditor); - } - if (!em->closeEditors(editorsOpenForFile)) // don't open if cancel was pressed - return; - } - - em->openEditor(entry.fileName, entry.editorFactory->id(), EditorManager::ModeSwitch); - return; - } - if (entry.externalEditor) - em->openExternalEditor(entry.fileName, entry.externalEditor->id()); -} - -void FileManager::slotExecuteOpenWithMenuAction(QAction *action) -{ - executeOpenWithMenuAction(action); -} - -// -------------- FileChangeBlocker - -FileChangeBlocker::FileChangeBlocker(const QString &fileName) - : m_fileName(fileName) -{ - FileManager::expectFileChange(fileName); -} - -FileChangeBlocker::~FileChangeBlocker() -{ - FileManager::unexpectFileChange(m_fileName); -} - -} // namespace Core diff --git a/src/plugins/coreplugin/filemanager.h b/src/plugins/coreplugin/filemanager.h deleted file mode 100644 index e569bc6088..0000000000 --- a/src/plugins/coreplugin/filemanager.h +++ /dev/null @@ -1,181 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef FILEMANAGER_H -#define FILEMANAGER_H - -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE -class QAction; -class QMainWindow; -class QMenu; -QT_END_NAMESPACE - -namespace Core { - -class IContext; -class IFile; -class IVersionControl; - -class CORE_EXPORT FileManager : public QObject -{ - Q_OBJECT -public: - enum FixMode { - ResolveLinks, - KeepLinks - }; - - typedef QPair RecentFile; - - explicit FileManager(QMainWindow *ew); - virtual ~FileManager(); - - static FileManager *instance(); - - // file pool to monitor - static void addFiles(const QList &files, bool addWatcher = true); - static void addFile(IFile *file, bool addWatcher = true); - static bool removeFile(IFile *file); - static QList modifiedFiles(); - - static void renamedFile(const QString &from, const QString &to); - - static void expectFileChange(const QString &fileName); - static void unexpectFileChange(const QString &fileName); - - // recent files - static void addToRecentFiles(const QString &fileName, const Id &editorId = Id()); - Q_SLOT void clearRecentFiles(); - static QList recentFiles(); - - static void saveSettings(); - - // current file - static void setCurrentFile(const QString &filePath); - static QString currentFile(); - - // helper methods - static QString fixFileName(const QString &fileName, FixMode fixmode); - - static bool saveFile(IFile *file, const QString &fileName = QString(), bool *isReadOnly = 0); - - static QStringList getOpenFileNames(const QString &filters, - const QString path = QString(), - QString *selectedFilter = 0); - static QString getSaveFileName(const QString &title, const QString &pathIn, - 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(), - QString *selectedFilter = 0); - - static QList saveModifiedFilesSilently(const QList &files, bool *cancelled = 0); - static QList saveModifiedFiles(const QList &files, - bool *cancelled = 0, - const QString &message = QString(), - const QString &alwaysSaveMessage = QString(), - bool *alwaysSave = 0); - - - // Helper to display a message dialog when encountering a read-only - // file, prompting the user about how to make it writeable. - enum ReadOnlyAction { RO_Cancel, RO_OpenVCS, RO_MakeWriteable, RO_SaveAs }; - static ReadOnlyAction promptReadOnlyFile(const QString &fileName, - const IVersionControl *versionControl, - QWidget *parent, - bool displaySaveAsButton = false); - - static QString fileDialogLastVisitedDirectory(); - static void setFileDialogLastVisitedDirectory(const QString &); - - static QString fileDialogInitialDirectory(); - - static bool useProjectsDirectory(); - static void setUseProjectsDirectory(bool); - - static QString projectsDirectory(); - static void setProjectsDirectory(const QString &); - - static void populateOpenWithMenu(QMenu *menu, const QString &fileName); - - /* Used to notify e.g. the code model to update the given files. Does *not* - lead to any editors to reload or any other editor manager actions. */ - static void notifyFilesChangedInternally(const QStringList &files); - - static void executeOpenWithMenuAction(QAction *action); - -public slots: - void slotExecuteOpenWithMenuAction(QAction *action); - -signals: - void currentFileChanged(const QString &filePath); - /* Used to notify e.g. the code model to update the given files. Does *not* - lead to any editors to reload or any other editor manager actions. */ - void filesChangedInternally(const QStringList &files); - -private slots: - void fileDestroyed(QObject *obj); - void checkForNewFileName(); - void checkForReload(); - void changedFile(const QString &file); - void mainWindowActivated(); - void syncWithEditor(Core::IContext *context); -}; - -/*! The FileChangeBlocker blocks all change notifications to all IFile * that - match the given filename. And unblocks in the destructor. - - To also reload the IFile in the destructor class set modifiedReload to true - - */ -class CORE_EXPORT FileChangeBlocker -{ -public: - explicit FileChangeBlocker(const QString &fileName); - ~FileChangeBlocker(); -private: - const QString m_fileName; - Q_DISABLE_COPY(FileChangeBlocker) -}; - -} // namespace Core - -Q_DECLARE_METATYPE(Core::FileManager::RecentFile) - -#endif // FILEMANAGER_H 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 #include @@ -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/idocument.cpp b/src/plugins/coreplugin/idocument.cpp new file mode 100644 index 0000000000..3799100751 --- /dev/null +++ b/src/plugins/coreplugin/idocument.cpp @@ -0,0 +1,116 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "idocument.h" + +#include "infobar.h" + +#include +#include + +namespace Core { + +IDocument::IDocument(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false) +{ +} + +IDocument::~IDocument() +{ + removeAutoSaveFile(); + delete m_infoBar; +} + +IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeType type) const +{ + if (type == TypePermissions) + return BehaviorSilent; + if (type == TypeContents && state == TriggerInternal && !isModified()) + return BehaviorSilent; + return BehaviorAsk; +} + +void IDocument::checkPermissions() +{ +} + +bool IDocument::shouldAutoSave() const +{ + return false; +} + +bool IDocument::isFileReadOnly() const +{ + if (fileName().isEmpty()) + return false; + return !QFileInfo(fileName()).isWritable(); +} + +bool IDocument::autoSave(QString *errorString, const QString &fileName) +{ + if (!save(errorString, fileName, true)) + return false; + m_autoSaveName = fileName; + return true; +} + +static const char kRestoredAutoSave[] = "RestoredAutoSave"; + +void IDocument::setRestoredFrom(const QString &name) +{ + m_autoSaveName = name; + m_restored = true; + InfoBarEntry info(QLatin1String(kRestoredAutoSave), + tr("File was restored from auto-saved copy. " + "Use Save to confirm, or Revert to Saved to discard changes.")); + infoBar()->addInfo(info); +} + +void IDocument::removeAutoSaveFile() +{ + if (!m_autoSaveName.isEmpty()) { + QFile::remove(m_autoSaveName); + m_autoSaveName.clear(); + if (m_restored) { + m_restored = false; + infoBar()->removeInfo(QLatin1String(kRestoredAutoSave)); + } + } +} + +InfoBar *IDocument::infoBar() +{ + if (!m_infoBar) + m_infoBar = new InfoBar; + return m_infoBar; +} + +} // namespace Core diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h new file mode 100644 index 0000000000..8a2716d398 --- /dev/null +++ b/src/plugins/coreplugin/idocument.h @@ -0,0 +1,129 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef IDOCUMENT_H +#define IDOCUMENT_H + +#include "core_global.h" +#include + +namespace Core { + +class MimeType; +class InfoBar; + +class CORE_EXPORT IDocument : public QObject +{ + Q_OBJECT + +public: + // This enum must match the indexes of the reloadBehavior widget + // in generalsettings.ui + enum ReloadSetting { + AlwaysAsk = 0, + ReloadUnmodified = 1, + IgnoreAll = 2 + }; + + enum Utf8BomSetting { + AlwaysAdd = 0, + OnlyKeep = 1, + AlwaysDelete = 2 + }; + + enum ChangeTrigger { + TriggerInternal, + TriggerExternal + }; + + enum ChangeType { + TypeContents, + TypePermissions, + TypeRemoved + }; + + enum ReloadBehavior { + BehaviorAsk, + BehaviorSilent + }; + + enum ReloadFlag { + FlagReload, + FlagIgnore + }; + + 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; + virtual QString mimeType() const = 0; + + virtual bool shouldAutoSave() const; + virtual bool isModified() const = 0; + virtual bool isSaveAsAllowed() const = 0; + + virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; + virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0; + virtual void rename(const QString &newName) = 0; + + virtual void checkPermissions(); + + bool autoSave(QString *errorString, const QString &fileName); + void setRestoredFrom(const QString &name); + void removeAutoSaveFile(); + + bool hasWriteWarning() const { return m_hasWriteWarning; } + void setWriteWarning(bool has) { m_hasWriteWarning = has; } + + InfoBar *infoBar(); + +signals: + void changed(); + + void aboutToReload(); + void reloaded(); + +private: + QString m_autoSaveName; + InfoBar *m_infoBar; + bool m_hasWriteWarning; + bool m_restored; +}; + +} // namespace Core + +#endif // IDOCUMENT_H diff --git a/src/plugins/coreplugin/idocumentfactory.h b/src/plugins/coreplugin/idocumentfactory.h new file mode 100644 index 0000000000..95a80fd5f2 --- /dev/null +++ b/src/plugins/coreplugin/idocumentfactory.h @@ -0,0 +1,64 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef IDOCUMENTFACTORY_H +#define IDOCUMENTFACTORY_H + +#include "core_global.h" + +#include + +QT_BEGIN_NAMESPACE +class QStringList; +QT_END_NAMESPACE + +namespace Core { + +class IDocument; +class Id; + +class CORE_EXPORT IDocumentFactory : public QObject +{ + Q_OBJECT + +public: + IDocumentFactory(QObject *parent = 0) : QObject(parent) {} + + virtual QStringList mimeTypes() const = 0; + virtual Id id() const = 0; + virtual QString displayName() const = 0; + virtual IDocument *open(const QString &fileName) = 0; +}; + +} // namespace Core + +#endif // IDOCUMENTFACTORY_H diff --git a/src/plugins/coreplugin/ifile.cpp b/src/plugins/coreplugin/ifile.cpp deleted file mode 100644 index a6c72d51d1..0000000000 --- a/src/plugins/coreplugin/ifile.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "ifile.h" - -#include "infobar.h" - -#include -#include - -namespace Core { - -IFile::IFile(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false) -{ -} - -IFile::~IFile() -{ - removeAutoSaveFile(); - delete m_infoBar; -} - -IFile::ReloadBehavior IFile::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - if (type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents && state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; -} - -void IFile::checkPermissions() -{ -} - -bool IFile::shouldAutoSave() const -{ - return false; -} - -bool IFile::isReadOnly() const -{ - if (fileName().isEmpty()) - return false; - return !QFileInfo(fileName()).isWritable(); -} - -bool IFile::autoSave(QString *errorString, const QString &fileName) -{ - if (!save(errorString, fileName, true)) - return false; - m_autoSaveName = fileName; - return true; -} - -static const char kRestoredAutoSave[] = "RestoredAutoSave"; - -void IFile::setRestoredFrom(const QString &name) -{ - m_autoSaveName = name; - m_restored = true; - InfoBarEntry info(QLatin1String(kRestoredAutoSave), - tr("File was restored from auto-saved copy. " - "Use Save to confirm, or Revert to Saved to discard changes.")); - infoBar()->addInfo(info); -} - -void IFile::removeAutoSaveFile() -{ - if (!m_autoSaveName.isEmpty()) { - QFile::remove(m_autoSaveName); - m_autoSaveName.clear(); - if (m_restored) { - m_restored = false; - infoBar()->removeInfo(QLatin1String(kRestoredAutoSave)); - } - } -} - -InfoBar *IFile::infoBar() -{ - if (!m_infoBar) - m_infoBar = new InfoBar; - return m_infoBar; -} - -} // namespace Core diff --git a/src/plugins/coreplugin/ifile.h b/src/plugins/coreplugin/ifile.h deleted file mode 100644 index 8e097cb002..0000000000 --- a/src/plugins/coreplugin/ifile.h +++ /dev/null @@ -1,129 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef IFILE_H -#define IFILE_H - -#include "core_global.h" -#include - -namespace Core { - -class MimeType; -class InfoBar; - -class CORE_EXPORT IFile : public QObject -{ - Q_OBJECT - -public: - // This enum must match the indexes of the reloadBehavior widget - // in generalsettings.ui - enum ReloadSetting { - AlwaysAsk = 0, - ReloadUnmodified = 1, - IgnoreAll = 2 - }; - - enum Utf8BomSetting { - AlwaysAdd = 0, - OnlyKeep = 1, - AlwaysDelete = 2 - }; - - enum ChangeTrigger { - TriggerInternal, - TriggerExternal - }; - - enum ChangeType { - TypeContents, - TypePermissions, - TypeRemoved - }; - - enum ReloadBehavior { - BehaviorAsk, - BehaviorSilent - }; - - enum ReloadFlag { - FlagReload, - FlagIgnore - }; - - IFile(QObject *parent = 0); - virtual ~IFile(); - - virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0; - virtual QString fileName() const = 0; - - virtual QString defaultPath() const = 0; - virtual QString suggestedFileName() const = 0; - virtual QString mimeType() const = 0; - - 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; - virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0; - virtual void rename(const QString &newName) = 0; - - virtual void checkPermissions(); - - bool autoSave(QString *errorString, const QString &fileName); - void setRestoredFrom(const QString &name); - void removeAutoSaveFile(); - - bool hasWriteWarning() const { return m_hasWriteWarning; } - void setWriteWarning(bool has) { m_hasWriteWarning = has; } - - InfoBar *infoBar(); - -signals: - void changed(); - - void aboutToReload(); - void reloaded(); - -private: - QString m_autoSaveName; - InfoBar *m_infoBar; - bool m_hasWriteWarning; - bool m_restored; -}; - -} // namespace Core - -#endif // IFILE_H diff --git a/src/plugins/coreplugin/ifilefactory.h b/src/plugins/coreplugin/ifilefactory.h deleted file mode 100644 index 5a4e5f0b43..0000000000 --- a/src/plugins/coreplugin/ifilefactory.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef IFILEFACTORY_H -#define IFILEFACTORY_H - -#include "core_global.h" - -#include - -QT_BEGIN_NAMESPACE -class QStringList; -QT_END_NAMESPACE - -namespace Core { - -class IFile; -class Id; - -class CORE_EXPORT IFileFactory : public QObject -{ - Q_OBJECT - -public: - IFileFactory(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; -}; - -} // namespace Core - -#endif // IFILEFACTORY_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 notSaved = FileManager::saveModifiedFiles(FileManager::modifiedFiles(), &cancelled); + QList 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 getNonEditorFileFactories() +static QList getNonEditorDocumentFactories() { - const QList allFileFactories = - ExtensionSystem::PluginManager::instance()->getObjects(); - QList nonEditorFileFactories; - foreach (IFileFactory *factory, allFileFactories) { + const QList allFileFactories = + ExtensionSystem::PluginManager::instance()->getObjects(); + QList nonEditorFileFactories; + foreach (IDocumentFactory *factory, allFileFactories) { if (!qobject_cast(factory)) nonEditorFileFactories.append(factory); } return nonEditorFileFactories; } -static IFileFactory *findFileFactory(const QList &fileFactories, +static IDocumentFactory *findDocumentFactory(const QList &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 &fileFactories, // opens either an editor or loads a project void MainWindow::openFiles(const QStringList &fileNames, ICore::OpenFilesFlags flags) { - QList nonEditorFileFactories = getNonEditorFileFactories(); + QList 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 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(sender())) { - const FileManager::RecentFile file = action->data().value(); + const DocumentManager::RecentFile file = action->data().value(); 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 -#include -#include +#include +#include #include #include #include @@ -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) +Q_DECLARE_METATYPE(Core::DocumentManager*) +Q_DECLARE_METATYPE(Core::IDocument*) +Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(QList) Q_DECLARE_METATYPE(Core::EditorManager*) Q_DECLARE_METATYPE(Core::ICore*) diff --git a/src/plugins/coreplugin/textdocument.cpp b/src/plugins/coreplugin/textdocument.cpp new file mode 100644 index 0000000000..78a3447d7d --- /dev/null +++ b/src/plugins/coreplugin/textdocument.cpp @@ -0,0 +1,152 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#include "textdocument.h" +#include "editormanager.h" + +#include +#include + +/*! + \class Core::TextFile + \brief Base class for text files with encoding helpers. + + Stores the format obtained from read operations and uses that when writing + out files, thus ensuring that CRLF/encodings are preserved. + + \sa Utils::TextFileUtils +*/ + +enum { debug = 0 }; + +namespace Core { + +namespace Internal { +class TextDocumentPrivate +{ +public: + TextDocumentPrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {} + + Utils::TextFileFormat m_format; + Utils::TextFileFormat::ReadResult m_readResult; + QByteArray m_decodingErrorSample; +}; + +} // namespace Internal + +TextDocument::TextDocument(QObject *parent) : + IDocument(parent), d(new Internal::TextDocumentPrivate) +{ + setCodec(Core::EditorManager::instance()->defaultTextCodec()); +} + +TextDocument::~TextDocument() +{ + delete d; +} + +bool TextDocument::hasDecodingError() const +{ + return d->m_readResult == Utils::TextFileFormat::ReadEncodingError; +} + +QByteArray TextDocument::decodingErrorSample() const +{ + return d->m_decodingErrorSample; +} + +/*! + \brief Writes out text using the format obtained from the last read. +*/ + +bool TextDocument::write(const QString &fileName, const QString &data, QString *errorMessage) const +{ + return write(fileName, format(), data, errorMessage); +} + +/*! + \brief Writes out text using a custom format obtained. +*/ + +bool TextDocument::write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const +{ + if (debug) + qDebug() << Q_FUNC_INFO << this << fileName; + return format.writeFile(fileName, data, errorMessage); +} + +/*! + \brief Autodetect format and read in a text file. +*/ + +TextDocument::ReadResult TextDocument::read(const QString &fileName, QStringList *plainTextList, QString *errorString) +{ + d->m_readResult = + Utils::TextFileFormat::readFile(fileName, codec(), + plainTextList, &d->m_format, errorString, &d->m_decodingErrorSample); + return d->m_readResult; +} + +/*! + \brief Autodetect format and read in a text file. +*/ + +TextDocument::ReadResult TextDocument::read(const QString &fileName, QString *plainText, QString *errorString) +{ + d->m_readResult = + Utils::TextFileFormat::readFile(fileName, codec(), + plainText, &d->m_format, errorString, &d->m_decodingErrorSample); + return d->m_readResult; +} + +const QTextCodec *TextDocument::codec() const +{ + return d->m_format.codec; +} + +void TextDocument::setCodec(const QTextCodec *codec) +{ + if (debug) + qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray()); + d->m_format.codec = codec; +} + +/*! + \brief Returns the format obtained from the last call to read(). +*/ + +Utils::TextFileFormat TextDocument::format() const +{ + return d->m_format; +} + +} // namespace Core diff --git a/src/plugins/coreplugin/textdocument.h b/src/plugins/coreplugin/textdocument.h new file mode 100644 index 0000000000..9fc5a89056 --- /dev/null +++ b/src/plugins/coreplugin/textdocument.h @@ -0,0 +1,74 @@ +/************************************************************************** +** +** This file is part of Qt Creator +** +** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** Other Usage +** +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +**************************************************************************/ + +#ifndef CORE_TEXTDOCUMENT_H +#define CORE_TEXTDOCUMENT_H + +#include "idocument.h" + +#include + +namespace Core { + +namespace Internal { +class TextDocumentPrivate; +} + +class CORE_EXPORT TextDocument : public IDocument +{ + Q_OBJECT +public: + typedef Utils::TextFileFormat::ReadResult ReadResult; + + explicit TextDocument(QObject *parent = 0); + virtual ~TextDocument(); + + Utils::TextFileFormat format() const; + const QTextCodec *codec() const; + void setCodec(const QTextCodec *); + + ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString); + ReadResult read(const QString &fileName, QString *plainText, QString *errorString); + + bool hasDecodingError() const; + QByteArray decodingErrorSample() const; + + bool write(const QString &fileName, const QString &data, QString *errorMessage) const; + bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const; + +private: + Internal::TextDocumentPrivate *d; +}; + +} // namespace Core + +#endif // CORE_TEXTDOCUMENT_H diff --git a/src/plugins/coreplugin/textfile.cpp b/src/plugins/coreplugin/textfile.cpp deleted file mode 100644 index 54c64a8483..0000000000 --- a/src/plugins/coreplugin/textfile.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#include "textfile.h" -#include "editormanager.h" - -#include -#include - -/*! - \class Core::TextFile - \brief Base class for text files with encoding helpers. - - Stores the format obtained from read operations and uses that when writing - out files, thus ensuring that CRLF/encodings are preserved. - - \sa Utils::TextFileUtils -*/ - -enum { debug = 0 }; - -namespace Core { - -namespace Internal { -class TextFilePrivate -{ -public: - TextFilePrivate() : m_readResult(Utils::TextFileFormat::ReadSuccess) {} - - Utils::TextFileFormat m_format; - Utils::TextFileFormat::ReadResult m_readResult; - QByteArray m_decodingErrorSample; -}; - -} // namespace Internal - -TextFile::TextFile(QObject *parent) : - IFile(parent), d(new Internal::TextFilePrivate) -{ - setCodec(Core::EditorManager::instance()->defaultTextCodec()); -} - -TextFile::~TextFile() -{ - delete d; -} - -bool TextFile::hasDecodingError() const -{ - return d->m_readResult == Utils::TextFileFormat::ReadEncodingError; -} - -QByteArray TextFile::decodingErrorSample() const -{ - return d->m_decodingErrorSample; -} - -/*! - \brief Writes out text using the format obtained from the last read. -*/ - -bool TextFile::write(const QString &fileName, const QString &data, QString *errorMessage) const -{ - return write(fileName, format(), data, errorMessage); -} - -/*! - \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 -{ - if (debug) - qDebug() << Q_FUNC_INFO << this << fileName; - return format.writeFile(fileName, data, errorMessage); -} - -/*! - \brief Autodetect format and read in a text file. -*/ - -TextFile::ReadResult TextFile::read(const QString &fileName, QStringList *plainTextList, QString *errorString) -{ - d->m_readResult = - Utils::TextFileFormat::readFile(fileName, codec(), - plainTextList, &d->m_format, errorString, &d->m_decodingErrorSample); - return d->m_readResult; -} - -/*! - \brief Autodetect format and read in a text file. -*/ - -TextFile::ReadResult TextFile::read(const QString &fileName, QString *plainText, QString *errorString) -{ - d->m_readResult = - Utils::TextFileFormat::readFile(fileName, codec(), - plainText, &d->m_format, errorString, &d->m_decodingErrorSample); - return d->m_readResult; -} - -const QTextCodec *TextFile::codec() const -{ - return d->m_format.codec; -} - -void TextFile::setCodec(const QTextCodec *codec) -{ - if (debug) - qDebug() << Q_FUNC_INFO << this << (codec ? codec->name() : QByteArray()); - d->m_format.codec = codec; -} - -/*! - \brief Returns the format obtained from the last call to read(). -*/ - -Utils::TextFileFormat TextFile::format() const -{ - return d->m_format; -} - -} // namespace Core diff --git a/src/plugins/coreplugin/textfile.h b/src/plugins/coreplugin/textfile.h deleted file mode 100644 index 61a74d06c1..0000000000 --- a/src/plugins/coreplugin/textfile.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** This file is part of Qt Creator -** -** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies). -** -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** -** GNU Lesser General Public License Usage -** -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this file. -** Please review the following information to ensure the GNU Lesser General -** Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** Other Usage -** -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -**************************************************************************/ - -#ifndef CORE_TEXTFILE_H -#define CORE_TEXTFILE_H - -#include "ifile.h" - -#include - -namespace Core { - -namespace Internal { -class TextFilePrivate; -} - -class CORE_EXPORT TextFile : public IFile -{ - Q_OBJECT -public: - typedef Utils::TextFileFormat::ReadResult ReadResult; - - explicit TextFile(QObject *parent = 0); - virtual ~TextFile(); - - Utils::TextFileFormat format() const; - const QTextCodec *codec() const; - void setCodec(const QTextCodec *); - - ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString); - ReadResult read(const QString &fileName, QString *plainText, QString *errorString); - - bool hasDecodingError() const; - QByteArray decodingErrorSample() const; - - bool write(const QString &fileName, const QString &data, QString *errorMessage) const; - bool write(const QString &fileName, const Utils::TextFileFormat &format, const QString &data, QString *errorMessage) const; - -private: - Internal::TextFilePrivate *d; -}; - -} // namespace Core - -#endif // CORE_TEXTFILE_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 #include @@ -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))); } diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp index 360b3574e8..fc6fe11e91 100644 --- a/src/plugins/cpaster/cpasterplugin.cpp +++ b/src/plugins/cpaster/cpasterplugin.cpp @@ -346,7 +346,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription, // If the mime type has a preferred suffix (cpp/h/patch...), use that for // the temporary file. This is to make it more convenient to "Save as" // for the user and also to be able to tell a patch or diff in the VCS plugins - // by looking at the file name of FileManager::currentFile() without expensive checking. + // by looking at the file name of DocumentManager::currentFile() without expensive checking. // Default to "txt". QByteArray byteContent = content.toUtf8(); QString suffix; diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index e4e0b712d5..a7f60d35be 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -544,7 +544,7 @@ void CPPEditorWidget::createToolBar(CPPEditor *editor) connect(m_outlineCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(updateOutlineToolTip())); connect(document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(onContentsChanged(int,int,int))); - connect(file(), SIGNAL(changed()), this, SLOT(updateFileName())); + connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName())); // set up function declaration - definition link connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateFunctionDeclDefLink())); @@ -675,7 +675,7 @@ void CPPEditorWidget::abortRename() void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc) { - if (doc->fileName() != file()->fileName()) + if (doc->fileName() != editorDocument()->fileName()) return; if (doc->editorRevision() != editorRevision()) @@ -685,7 +685,7 @@ void CPPEditorWidget::onDocumentUpdated(Document::Ptr doc) (Core::EditorManager::instance()->currentEditor() == editor() && (!m_lastSemanticInfo.doc || !m_lastSemanticInfo.doc->translationUnit()->ast() - || m_lastSemanticInfo.doc->fileName() != file()->fileName()))) { + || m_lastSemanticInfo.doc->fileName() != editorDocument()->fileName()))) { m_initialized = true; semanticRehighlight(/* force = */ true); } @@ -901,7 +901,7 @@ bool CPPEditorWidget::sortedOutline() const void CPPEditorWidget::updateOutlineNow() { const Snapshot snapshot = m_modelManager->snapshot(); - Document::Ptr document = snapshot.document(file()->fileName()); + Document::Ptr document = snapshot.document(editorDocument()->fileName()); if (!document) return; @@ -1047,7 +1047,7 @@ void CPPEditorWidget::switchDeclarationDefinition() const Snapshot snapshot = m_modelManager->snapshot(); - if (Document::Ptr thisDocument = snapshot.document(file()->fileName())) { + if (Document::Ptr thisDocument = snapshot.document(editorDocument()->fileName())) { int line = 0, positionInBlock = 0; convertPosition(position(), &line, &positionInBlock); @@ -1281,7 +1281,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor, } // Now we prefer the doc from the snapshot with macros expanded. - Document::Ptr doc = snapshot.document(file()->fileName()); + Document::Ptr doc = snapshot.document(editorDocument()->fileName()); if (!doc) { doc = m_lastSemanticInfo.doc; if (!doc) @@ -1411,7 +1411,7 @@ CPPEditorWidget::Link CPPEditorWidget::findLinkAt(const QTextCursor &cursor, foreach (const LookupItem &r, resolvedSymbols) { if (Symbol *d = r.declaration()) { if (d->isDeclaration() || d->isFunction()) { - if (file()->fileName() == QString::fromUtf8(d->fileName(), d->fileNameLength())) { + if (editorDocument()->fileName() == QString::fromUtf8(d->fileName(), d->fileNameLength())) { if (unsigned(lineNumber) == d->line() && unsigned(positionInBlock) >= d->column()) { // ### TODO: check the end result = r; // take the symbol under cursor. break; @@ -1820,7 +1820,7 @@ void CPPEditorWidget::updateSemanticInfo(const SemanticInfo &semanticInfo) // We can use the semanticInfo's snapshot (and avoid locking), but not its // document, since it doesn't contain expanded macros. - LookupContext context(semanticInfo.snapshot.document(file()->fileName()), + LookupContext context(semanticInfo.snapshot.document(editorDocument()->fileName()), semanticInfo.snapshot); SemanticInfo::LocalUseIterator it(semanticInfo.localUses); @@ -1984,7 +1984,7 @@ SemanticHighlighter::Source CPPEditorWidget::currentSource(bool force) convertPosition(position(), &line, &column); const Snapshot snapshot = m_modelManager->snapshot(); - const QString fileName = file()->fileName(); + const QString fileName = editorDocument()->fileName(); QString code; if (force || m_lastSemanticInfo.revision != editorRevision()) diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index 980768e593..faa723a215 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -32,7 +32,7 @@ #include "cppelementevaluator.h" -#include +#include #include #include @@ -100,7 +100,7 @@ void CppElementEvaluator::execute() return; const Snapshot &snapshot = m_modelManager->snapshot(); - Document::Ptr doc = snapshot.document(m_editor->file()->fileName()); + Document::Ptr doc = snapshot.document(m_editor->editorDocument()->fileName()); if (!doc) return; diff --git a/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp b/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp index 7a5e34ec54..6651e4a46b 100644 --- a/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp +++ b/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp @@ -40,7 +40,7 @@ #include #include #include -#include +#include #include diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp index 727f0c5fa5..217bd580cf 100644 --- a/src/plugins/cppeditor/cppoutline.cpp +++ b/src/plugins/cppeditor/cppoutline.cpp @@ -35,7 +35,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/plugins/cppeditor/cppplugin.cpp b/src/plugins/cppeditor/cppplugin.cpp index 072cce9806..ca3476bd40 100644 --- a/src/plugins/cppeditor/cppplugin.cpp +++ b/src/plugins/cppeditor/cppplugin.cpp @@ -108,10 +108,10 @@ QString CppEditorFactory::displayName() const return tr(CppEditor::Constants::CPPEDITOR_DISPLAY_NAME); } -Core::IFile *CppEditorFactory::open(const QString &fileName) +Core::IDocument *CppEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *CppEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/cppeditor/cppplugin.h b/src/plugins/cppeditor/cppplugin.h index f082fdcdc2..acc251e5cb 100644 --- a/src/plugins/cppeditor/cppplugin.h +++ b/src/plugins/cppeditor/cppplugin.h @@ -121,7 +121,7 @@ public: Core::IEditor *createEditor(QWidget *parent); Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); private: CppPlugin *m_owner; diff --git a/src/plugins/cppeditor/cppquickfix.cpp b/src/plugins/cppeditor/cppquickfix.cpp index 247d4ab3c9..96eb58048a 100644 --- a/src/plugins/cppeditor/cppquickfix.cpp +++ b/src/plugins/cppeditor/cppquickfix.cpp @@ -82,7 +82,7 @@ const CppQuickFixAssistInterface *CppQuickFixOperation::assistInterface() const QString CppQuickFixOperation::fileName() const { - return m_interface->file()->fileName(); + return m_interface->document()->fileName(); } CppQuickFixFactory::CppQuickFixFactory() diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp index 23ed9bfa0c..41e52db9f6 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.cpp +++ b/src/plugins/cppeditor/cppquickfixassistant.cpp @@ -101,7 +101,7 @@ const IAssistProvider *CppQuickFixAssistProcessor::provider() const // -------------------------- CppQuickFixAssistInterface::CppQuickFixAssistInterface(CPPEditorWidget *editor, TextEditor::AssistReason reason) - : DefaultAssistInterface(editor->document(), editor->position(), editor->file(), reason) + : DefaultAssistInterface(editor->document(), editor->position(), editor->editorDocument(), reason) , m_editor(editor) , m_semanticInfo(editor->semanticInfo()) , m_snapshot(CPlusPlus::CppModelManagerInterface::instance()->snapshot()) diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index 868d454084..f9853f5a88 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -56,7 +56,7 @@ #include #include -#include +#include #include #include #include @@ -719,7 +719,7 @@ bool CppCompletionAssistProcessor::accepts() const const int start = startOfOperator(pos, &token, /*want function call=*/ true); if (start != pos) { if (token == T_POUND) { - const int column = pos - m_interface->document()->findBlock(start).position(); + const int column = pos - m_interface->textDocument()->findBlock(start).position(); if (column != 1) return false; } @@ -734,7 +734,7 @@ bool CppCompletionAssistProcessor::accepts() const const QChar firstCharacter = m_interface->characterAt(startOfName); if (firstCharacter.isLetter() || firstCharacter == QLatin1Char('_')) { // Finally check that we're not inside a comment or string (code copied from startOfOperator) - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); SimpleLexer tokenize; @@ -818,7 +818,7 @@ int CppCompletionAssistProcessor::startOfOperator(int pos, int start = pos - activationSequenceChar(ch, ch2, ch3, kind, wantFunctionCall); if (start != pos) { - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); // Include completion: make sure the quote character is the first one on the line @@ -944,8 +944,8 @@ int CppCompletionAssistProcessor::startCompletionHelper() &m_model->m_completionOperator, /*want function call =*/ true); - const Core::IFile *file = m_interface->file(); - QString fileName = file->fileName(); + const Core::IDocument *document = m_interface->document(); + QString fileName = document->fileName(); if (m_model->m_completionOperator == T_DOXY_COMMENT) { for (int i = 1; i < T_DOXY_LAST_TAG; ++i) @@ -965,7 +965,7 @@ int CppCompletionAssistProcessor::startCompletionHelper() || m_model->m_completionOperator == T_ANGLE_STRING_LITERAL || m_model->m_completionOperator == T_SLASH) { - QTextCursor c(m_interface->document()); + QTextCursor c(m_interface->textDocument()); c.setPosition(endOfExpression); if (completeInclude(c)) m_startPosition = startOfName; @@ -973,7 +973,7 @@ int CppCompletionAssistProcessor::startCompletionHelper() } ExpressionUnderCursor expressionUnderCursor; - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); if (m_model->m_completionOperator == T_COMMA) { tc.setPosition(endOfExpression); @@ -1017,7 +1017,7 @@ int CppCompletionAssistProcessor::startCompletionHelper() } int line = 0, column = 0; - Convenience::convertPosition(m_interface->document(), startOfExpression, &line, &column); + Convenience::convertPosition(m_interface->textDocument(), startOfExpression, &line, &column); return startCompletionInternal(fileName, line, column, expression, endOfExpression); } @@ -1029,7 +1029,7 @@ bool CppCompletionAssistProcessor::tryObjCCompletion() if (m_interface->characterAt(end) != QLatin1Char(']')) return false; - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(end); BackwardsScanner tokens(tc); if (tokens[tokens.startToken() - 1].isNot(T_RBRACKET)) @@ -1042,14 +1042,14 @@ bool CppCompletionAssistProcessor::tryObjCCompletion() const int startPos = tokens[start].begin() + tokens.startPosition(); const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos); - Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->file()->fileName()); + Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->document()->fileName()); if (! thisDocument) return false; m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot()); int line = 0, column = 0; - Convenience::convertPosition(m_interface->document(), m_interface->position(), &line, &column); + Convenience::convertPosition(m_interface->textDocument(), m_interface->position(), &line, &column); Scope *scope = thisDocument->scopeAt(line, column); if (!scope) return false; @@ -1171,7 +1171,7 @@ bool CppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor) // Make completion for all relevant includes QStringList includePaths = m_interface->includePaths(); - const QString ¤tFilePath = QFileInfo(m_interface->file()->fileName()).path(); + const QString ¤tFilePath = QFileInfo(m_interface->document()->fileName()).path(); if (!includePaths.contains(currentFilePath)) includePaths.append(currentFilePath); @@ -1232,8 +1232,8 @@ bool CppCompletionAssistProcessor::objcKeywordsWanted() const if (!m_objcEnabled) return false; - const Core::IFile *file = m_interface->file(); - QString fileName = file->fileName(); + const Core::IDocument *document = m_interface->document(); + QString fileName = document->fileName(); const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase(); return mdb->findByFile(fileName).type() == CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE; @@ -1291,7 +1291,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName --index; index = findStartOfName(index); - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(index); ExpressionUnderCursor expressionUnderCursor; @@ -1824,7 +1824,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QListdocument(), m_interface->position(), &lineSigned, &columnSigned); + Convenience::convertPosition(m_interface->textDocument(), m_interface->position(), &lineSigned, &columnSigned); unsigned line = lineSigned, column = columnSigned; // find a scope that encloses the current location, starting from the lastVisibileSymbol @@ -1837,7 +1837,7 @@ bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QListdocument()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(endOfExpression); BackwardsScanner bs(tc); const int startToken = bs.startToken(); diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 7991acfc62..48dbd8fa2d 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -145,14 +145,14 @@ private: class CppCompletionAssistInterface : public TextEditor::DefaultAssistInterface { public: - CppCompletionAssistInterface(QTextDocument *document, + CppCompletionAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, TextEditor::AssistReason reason, const CPlusPlus::Snapshot &snapshot, const QStringList &includePaths, const QStringList &frameworkPaths) - : TextEditor::DefaultAssistInterface(document, position, file, reason) + : TextEditor::DefaultAssistInterface(textDocument, position, document, reason) , m_snapshot(snapshot) , m_includePaths(includePaths) , m_frameworkPaths(frameworkPaths) diff --git a/src/plugins/cpptools/cppcompletionsupport.cpp b/src/plugins/cpptools/cppcompletionsupport.cpp index e68073fcee..30c2d8c363 100644 --- a/src/plugins/cpptools/cppcompletionsupport.cpp +++ b/src/plugins/cpptools/cppcompletionsupport.cpp @@ -35,7 +35,7 @@ #include "cppmodelmanager.h" #include "cpptoolseditorsupport.h" -#include +#include #include #include @@ -64,7 +64,7 @@ TextEditor::IAssistInterface *CppCompletionSupport::createAssistInterface(Projec return new CppTools::Internal::CppCompletionAssistInterface( document, position, - m_editorSupport->textEditor()->file(), + m_editorSupport->textEditor()->document(), reason, modelManager->snapshot(), includePaths, diff --git a/src/plugins/cpptools/cppcompletionsupport.h b/src/plugins/cpptools/cppcompletionsupport.h index 0435c8a700..5764e18fca 100644 --- a/src/plugins/cpptools/cppcompletionsupport.h +++ b/src/plugins/cpptools/cppcompletionsupport.h @@ -42,7 +42,7 @@ class QTextDocument; QT_END_NAMESPACE namespace Core { -class IFile; +class IDocument; } namespace ProjectExplorer { diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp index bad78b3211..ced6396422 100644 --- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp +++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp @@ -131,7 +131,7 @@ void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc) void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor * currentEditor) { if (currentEditor) { - m_currentFileName = currentEditor->file()->fileName(); + m_currentFileName = currentEditor->document()->fileName(); } else { m_currentFileName.clear(); } @@ -141,7 +141,7 @@ void CppCurrentDocumentFilter::onCurrentEditorChanged(Core::IEditor * currentEdi void CppCurrentDocumentFilter::onEditorAboutToClose(Core::IEditor * editorAboutToClose) { if (!editorAboutToClose) return; - if (m_currentFileName == editorAboutToClose->file()->fileName()) { + if (m_currentFileName == editorAboutToClose->document()->fileName()) { m_currentFileName.clear(); m_itemsOfCurrentDoc.clear(); } diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp index 2429265fb6..81e4ca6e0c 100644 --- a/src/plugins/cpptools/cppmodelmanager.cpp +++ b/src/plugins/cpptools/cppmodelmanager.cpp @@ -850,7 +850,7 @@ CppModelManager::WorkingCopy CppModelManager::buildWorkingCopyList() it.next(); TextEditor::ITextEditor *textEditor = it.key(); CppEditorSupport *editorSupport = it.value(); - QString fileName = textEditor->file()->fileName(); + QString fileName = textEditor->document()->fileName(); workingCopy.insert(fileName, editorSupport->contents(), editorSupport->editorRevision()); } @@ -1072,7 +1072,7 @@ void CppModelManager::updateEditor(Document::Ptr doc) QList openedEditors = Core::ICore::editorManager()->openedEditors(); foreach (Core::IEditor *editor, openedEditors) { - if (editor->file()->fileName() == fileName) { + if (editor->document()->fileName() == fileName) { TextEditor::ITextEditor *textEditor = qobject_cast(editor); if (! textEditor) continue; diff --git a/src/plugins/cpptools/cpptoolseditorsupport.cpp b/src/plugins/cpptools/cpptoolseditorsupport.cpp index 92a448d55c..d1c75e6063 100644 --- a/src/plugins/cpptools/cpptoolseditorsupport.cpp +++ b/src/plugins/cpptools/cpptoolseditorsupport.cpp @@ -35,7 +35,7 @@ #include "cpptoolseditorsupport.h" #include "cppmodelmanager.h" -#include +#include #include #include @@ -137,7 +137,7 @@ void CppEditorSupport::updateDocumentNow() } else { _updateDocumentTimer->stop(); - QStringList sourceFiles(_textEditor->file()->fileName()); + QStringList sourceFiles(_textEditor->document()->fileName()); _cachedContents = _textEditor->contents().toUtf8(); _documentParser = _modelManager->refreshSourceFiles(sourceFiles); } diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp index c72e65e46c..fd52c2f87c 100644 --- a/src/plugins/cpptools/cpptoolsplugin.cpp +++ b/src/plugins/cpptools/cpptoolsplugin.cpp @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include @@ -112,7 +112,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error) Core::VcsManager *vcsManager = Core::ICore::vcsManager(); connect(vcsManager, SIGNAL(repositoryChanged(QString)), m_modelManager, SLOT(updateModifiedSourceFiles())); - connect(Core::FileManager::instance(), SIGNAL(filesChangedInternally(QStringList)), + connect(Core::DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)), m_modelManager, SLOT(updateSourceFiles(QStringList))); addAutoReleasedObject(m_modelManager); @@ -163,7 +163,7 @@ void CppToolsPlugin::switchHeaderSource() { Core::EditorManager *editorManager = Core::EditorManager::instance(); Core::IEditor *editor = editorManager->currentEditor(); - QString otherFile = correspondingHeaderOrSource(editor->file()->fileName()); + QString otherFile = correspondingHeaderOrSource(editor->document()->fileName()); if (!otherFile.isEmpty()) editorManager->openEditor(otherFile); } diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 9ad8bccfa9..46f3209f77 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include #include @@ -469,14 +469,14 @@ bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor) if (!isCommitEditorOpen()) return true; - IFile *fileIFace = submitEditor->file(); + IDocument *editorDocument = submitEditor->document(); const CvsSubmitEditor *editor = qobject_cast(submitEditor); - if (!fileIFace || !editor) + if (!editorDocument || !editor) return true; // Submit editor closing. Make it write out the commit message // and retrieve files - const QFileInfo editorFile(fileIFace->fileName()); + const QFileInfo editorFile(editorDocument->fileName()); const QFileInfo changeFile(m_commitMessageFileName); if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) return true; // Oops?! @@ -504,7 +504,7 @@ bool CvsPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor) bool closeEditor = true; if (!fileList.empty()) { // get message & commit - closeEditor = FileManager::saveFile(fileIFace); + closeEditor = DocumentManager::saveDocument(editorDocument); if (closeEditor) closeEditor = commit(m_commitMessageFileName, fileList); } diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 888b8a1d52..743e0c1350 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -52,7 +52,7 @@ #include "watchhandler.h" #include -#include +#include #include #include #include diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 5794376538..60e9cbb8ba 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -585,9 +585,9 @@ static bool currentTextEditorPosition(ContextData *data) TextEditor::ITextEditor *textEditor = currentTextEditor(); if (!textEditor) return false; - const Core::IFile *file = textEditor->file(); - QTC_ASSERT(file, return false); - data->fileName = file->fileName(); + const Core::IDocument *document = textEditor->document(); + QTC_ASSERT(document, return false); + data->fileName = document->fileName(); if (textEditor->property("DisassemblerView").toBool()) { int lineNumber = textEditor->currentLine(); QString line = textEditor->contents() @@ -1868,7 +1868,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor, bool contextUsable = true; BreakpointModelId id = BreakpointModelId(); - const QString fileName = editor->file()->fileName(); + const QString fileName = editor->document()->fileName(); if (editor->property("DisassemblerView").toBool()) { args.fileName = fileName; QString line = editor->contents() @@ -1881,7 +1881,7 @@ void DebuggerPluginPrivate::requestContextMenu(ITextEditor *editor, id = breakHandler()->findSimilarBreakpoint(needle); contextUsable = args.address != 0; } else { - args.fileName = editor->file()->fileName(); + args.fileName = editor->document()->fileName(); id = breakHandler() ->findBreakpointByFileAndLine(args.fileName, lineNumber); if (!id) @@ -1989,7 +1989,7 @@ void DebuggerPluginPrivate::toggleBreakpoint() quint64 address = DisassemblerLine::addressFromDisassemblyLine(line); toggleBreakpointByAddress(address); } else if (lineNumber >= 0) { - toggleBreakpointByFileAndLine(textEditor->file()->fileName(), lineNumber); + toggleBreakpointByFileAndLine(textEditor->document()->fileName(), lineNumber); } } @@ -2043,8 +2043,8 @@ void DebuggerPluginPrivate::requestMark(ITextEditor *editor, .section(QLatin1Char('\n'), lineNumber - 1, lineNumber - 1); quint64 address = DisassemblerLine::addressFromDisassemblyLine(line); toggleBreakpointByAddress(address); - } else if (editor->file()) { - toggleBreakpointByFileAndLine(editor->file()->fileName(), lineNumber); + } else if (editor->document()) { + toggleBreakpointByFileAndLine(editor->document()->fileName(), lineNumber); } } @@ -2146,7 +2146,7 @@ void DebuggerPluginPrivate::cleanupViews() // Close disassembly views. Close other opened files // if they are not modified and not current editor. if (editor->property(Constants::OPENED_WITH_DISASSEMBLY).toBool() - || (!editor->file()->isModified() + || (!editor->document()->isModified() && editor != editorManager->currentEditor())) { toClose.append(editor); } else { @@ -3659,7 +3659,7 @@ void DebuggerPluginPrivate::testProjectLoaded(Project *project) disconnect(pe, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), this, SLOT(testProjectLoaded(ProjectExplorer::Project*))); - QString fileName = project->file()->fileName(); + QString fileName = project->document()->fileName(); QVERIFY(!fileName.isEmpty()); qWarning("Project %s loaded", qPrintable(fileName)); diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 1a8de6ee43..3271760716 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -210,26 +210,26 @@ class DebuggerToolTipEditor { public: explicit DebuggerToolTipEditor(IEditor *ie = 0); - bool isValid() const { return textEditor && baseTextEditor && file; } + bool isValid() const { return textEditor && baseTextEditor && document; } operator bool() const { return isValid(); } - QString fileName() const { return file ? file->fileName() : QString(); } + QString fileName() const { return document ? document->fileName() : QString(); } static DebuggerToolTipEditor currentToolTipEditor(); ITextEditor *textEditor; BaseTextEditorWidget *baseTextEditor; - IFile *file; + IDocument *document; }; DebuggerToolTipEditor::DebuggerToolTipEditor(IEditor *ie) : - textEditor(0), baseTextEditor(0), file(0) + textEditor(0), baseTextEditor(0), document(0) { - if (ie && ie->file() && isEditorDebuggable(ie)) { + if (ie && ie->document() && isEditorDebuggable(ie)) { if (ITextEditor *te = qobject_cast(ie)) { if (BaseTextEditorWidget *pe = qobject_cast(ie->widget())) { textEditor = te; baseTextEditor = pe; - file = ie->file(); + document = ie->document(); } } } @@ -552,9 +552,9 @@ DebuggerToolTipContext::DebuggerToolTipContext() : position(0), line(0), column( DebuggerToolTipContext DebuggerToolTipContext::fromEditor(IEditor *ie, int pos) { DebuggerToolTipContext rc; - if (const IFile *file = ie->file()) { + if (const IDocument *document = ie->document()) { if (const ITextEditor *te = qobject_cast(ie)) { - rc.fileName = file->fileName(); + rc.fileName = document->fileName(); rc.position = pos; te->convertPosition(pos, &rc.line, &rc.column); } diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index e8dabf52b5..e058f2ab9c 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -251,7 +251,7 @@ void DisassemblerAgentPrivate::configureMimeType() QTC_ASSERT(editor, return); TextEditor::BaseTextDocument *doc = - qobject_cast(editor->file()); + qobject_cast(editor->document()); QTC_ASSERT(doc, return); doc->setMimeType(mimeType); diff --git a/src/plugins/debugger/gdb/gdbengine.cpp b/src/plugins/debugger/gdb/gdbengine.cpp index 5c18eff124..a3031d5abf 100644 --- a/src/plugins/debugger/gdb/gdbengine.cpp +++ b/src/plugins/debugger/gdb/gdbengine.cpp @@ -71,7 +71,7 @@ #include "logwindow.h" #include -#include +#include #include #include #include diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 72631e4b5b..8dca7e0fed 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -54,7 +54,7 @@ #include #include -#include +#include #include #include @@ -466,7 +466,7 @@ bool PdbEngine::setToolTipExpression(const QPoint &mousePos, // Check mime type and get expression (borrowing some C++ - functions) const QString javaPythonMimeType = QLatin1String("application/javascript"); - if (!editor->file() || editor->file()->mimeType() != javaPythonMimeType) + if (!editor->document() || editor->document()->mimeType() != javaPythonMimeType) return false; int line; diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index 471eb42b76..3cd5e08f40 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -1988,7 +1988,7 @@ void QmlV8DebuggerClient::highlightExceptionCode(int lineNumber, errorFormat.setUnderlineColor(Qt::red); foreach (IEditor *editor, openedEditors) { - if (editor->file()->fileName() == filePath) { + if (editor->document()->fileName() == filePath) { TextEditor::BaseTextEditorWidget *ed = qobject_cast(editor->widget()); if (!ed) continue; diff --git a/src/plugins/debugger/script/scriptengine.cpp b/src/plugins/debugger/script/scriptengine.cpp index b95b4ec697..fb8731e3bb 100644 --- a/src/plugins/debugger/script/scriptengine.cpp +++ b/src/plugins/debugger/script/scriptengine.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -522,7 +522,7 @@ bool ScriptEngine::setToolTipExpression(const QPoint &mousePos, // Check mime type and get expression (borrowing some C++ - functions) const QString javaScriptMimeType = QLatin1String("application/javascript"); - if (!editor->file() || editor->file()->mimeType() != javaScriptMimeType) + if (!editor->document() || editor->document()->mimeType() != javaScriptMimeType) return false; int line; diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index 7007a1133c..d95834e481 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -36,7 +36,7 @@ #include -#include +#include #include #include @@ -151,7 +151,7 @@ bool isEditorDebuggable(Core::IEditor *editor) { // Only blacklist Qml. Whitelisting would fail on C++ code in files // with strange names, more harm would be done this way. - // IFile *file = editor->file(); + // IDocument *file = editor->document(); // return !(file && file->mimeType() == "application/x-qml"); // Nowadays, even Qml is debuggable. return editor; @@ -442,9 +442,9 @@ bool getUninitializedVariables(const CPlusPlus::Snapshot &snapshot, QByteArray gdbQuoteTypes(const QByteArray &type) { - // gdb does not understand sizeof(Core::IFile*). - // "sizeof('Core::IFile*')" is also not acceptable, - // it needs to be "sizeof('Core::IFile'*)" + // gdb does not understand sizeof(Core::IDocument*). + // "sizeof('Core::IDocument*')" is also not acceptable, + // it needs to be "sizeof('Core::IDocument'*)" // // We never will have a perfect solution here (even if we had a full blown // C++ parser as we do not have information on what is a type and what is @@ -647,10 +647,10 @@ QString decodeData(const QByteArray &ba, int encoding) bool isCppEditor(Core::IEditor *editor) { using namespace CppTools::Constants; - const Core::IFile *file = editor->file(); - if (!file) + const Core::IDocument *document= editor->document(); + if (!document) return false; - const QByteArray mimeType = file->mimeType().toLatin1(); + const QByteArray mimeType = document->mimeType().toLatin1(); return mimeType == C_SOURCE_MIMETYPE || mimeType == CPP_SOURCE_MIMETYPE || mimeType == CPP_HEADER_MIMETYPE @@ -693,10 +693,10 @@ QString cppExpressionAt(TextEditor::ITextEditor *editor, int pos, } if (function && !expr.isEmpty()) - if (const Core::IFile *file = editor->file()) + if (const Core::IDocument *document= editor->document()) if (modelManager) *function = AbstractEditorSupport::functionAt(modelManager, - file->fileName(), *line, *column); + document->fileName(), *line, *column); return expr; } diff --git a/src/plugins/designer/formeditorfactory.cpp b/src/plugins/designer/formeditorfactory.cpp index a1a32a05be..87bbb5fbcc 100644 --- a/src/plugins/designer/formeditorfactory.cpp +++ b/src/plugins/designer/formeditorfactory.cpp @@ -71,7 +71,7 @@ QString FormEditorFactory::displayName() const return tr(C_DESIGNER_XML_DISPLAY_NAME); } -Core::IFile *FormEditorFactory::open(const QString &fileName) +Core::IDocument *FormEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); if (!iface) @@ -80,9 +80,9 @@ Core::IFile *FormEditorFactory::open(const QString &fileName) Core::InfoBarEntry info(QLatin1String(Constants::INFO_READ_ONLY), tr("This file can only be edited in Design mode.")); info.setCustomButtonInfo(tr("Switch mode"), this, SLOT(designerModeClicked())); - iface->file()->infoBar()->addInfo(info); + iface->document()->infoBar()->addInfo(info); } - return iface->file(); + return iface->document(); } Core::IEditor *FormEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/designer/formeditorfactory.h b/src/plugins/designer/formeditorfactory.h index c0bf0c7b54..b39d835265 100644 --- a/src/plugins/designer/formeditorfactory.h +++ b/src/plugins/designer/formeditorfactory.h @@ -51,7 +51,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private slots: diff --git a/src/plugins/designer/formeditorw.cpp b/src/plugins/designer/formeditorw.cpp index f5be9b430c..f07be2ace9 100644 --- a/src/plugins/designer/formeditorw.cpp +++ b/src/plugins/designer/formeditorw.cpp @@ -757,7 +757,7 @@ EditorData FormEditorW::createEditor(QWidget *parent) data.formWindowEditor = xmlEditor->designerEditor(); connect(data.widgetHost, SIGNAL(formWindowSizeChanged(int,int)), xmlEditor, SIGNAL(changed())); - connect(data.formWindowEditor->file(), SIGNAL(changed()), + connect(data.formWindowEditor->document(), SIGNAL(changed()), resourceHandler, SLOT(updateResources())); m_editorWidget->add(data); @@ -907,8 +907,8 @@ void FormEditorW::print() static QString currentFile() { if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor()) - if (const Core::IFile *file = editor->file()) { - const QString fileName = file->fileName(); + if (const Core::IDocument *document= editor->document()) { + const QString fileName = document->fileName(); if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) return fileName; } diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp index 822b1b26a3..a8358db380 100644 --- a/src/plugins/designer/formwindoweditor.cpp +++ b/src/plugins/designer/formwindoweditor.cpp @@ -201,10 +201,10 @@ void FormWindowEditor::syncXmlEditor(const QString &contents) d->m_textEditor.editorWidget()->setPlainText(contents); d->m_textEditor.editorWidget()->setReadOnly(true); static_cast - (d->m_textEditor.editorWidget())->configure(file()->mimeType()); + (d->m_textEditor.editorWidget())->configure(document()->mimeType()); } -Core::IFile *FormWindowEditor::file() +Core::IDocument *FormWindowEditor::document() { return &d->m_file; } @@ -271,7 +271,7 @@ QString FormWindowEditor::contents() const TextEditor::BaseTextDocument *FormWindowEditor::textDocument() { - return qobject_cast(d->m_textEditor.file()); + return qobject_cast(d->m_textEditor.document()); } TextEditor::PlainTextEditor *FormWindowEditor::textEditor() diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h index 831f72b12c..bea7b25cd0 100644 --- a/src/plugins/designer/formwindoweditor.h +++ b/src/plugins/designer/formwindoweditor.h @@ -53,7 +53,7 @@ namespace Internal { struct FormWindowEditorPrivate; // The actual Core::IEditor belonging to Qt Designer. Uses FormWindowFile -// as the Core::IFile to do the isModified() handling, +// as the Core::IDocument to do the isModified() handling, // which needs to be done by Qt Designer. // However, to make the read-only XML text editor work, // a TextEditor::PlainTextEditorEditable (IEditor) is also required. @@ -72,7 +72,7 @@ public: // IEditor virtual bool createNew(const QString &contents = QString()); virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName); - virtual Core::IFile *file(); + virtual Core::IDocument *document(); virtual Core::Id id() const; virtual QString displayName() const; virtual void setDisplayName(const QString &title); diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp index 985f5c6328..0b05e675ed 100644 --- a/src/plugins/designer/formwindowfile.cpp +++ b/src/plugins/designer/formwindowfile.cpp @@ -59,7 +59,7 @@ namespace Designer { namespace Internal { FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent) - : Core::TextFile(parent), + : Core::TextDocument(parent), m_mimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE)), m_shouldAutoSave(false), m_formWindow(form) diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h index bf9eee1989..59e4ec1fe5 100644 --- a/src/plugins/designer/formwindowfile.h +++ b/src/plugins/designer/formwindowfile.h @@ -33,7 +33,7 @@ #ifndef FORMWINDOWFILE_H #define FORMWINDOWFILE_H -#include +#include #include @@ -45,14 +45,14 @@ QT_END_NAMESPACE namespace Designer { namespace Internal { -class FormWindowFile : public Core::TextFile +class FormWindowFile : public Core::TextDocument { Q_OBJECT public: explicit FormWindowFile(QDesignerFormWindowInterface *form, QObject *parent = 0); - // IFile + // IDocument virtual bool save(QString *errorString, const QString &fileName, bool autoSave); virtual QString fileName() const; virtual bool shouldAutoSave() const; diff --git a/src/plugins/designer/qtcreatorintegration.cpp b/src/plugins/designer/qtcreatorintegration.cpp index 12788ea66a..aa551b6cea 100644 --- a/src/plugins/designer/qtcreatorintegration.cpp +++ b/src/plugins/designer/qtcreatorintegration.cpp @@ -534,7 +534,7 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName, const EditorData ed = m_few->activeEditor(); QTC_ASSERT(ed, return false) - const QString currentUiFile = ed.formWindowEditor->file()->fileName(); + const QString currentUiFile = ed.formWindowEditor->document()->fileName(); #if 0 return Designer::Internal::navigateToSlot(currentUiFile, objectName, signalSignature, parameterNames, errorMessage); #endif diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 015d6ff47d..350d9b58a5 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -44,9 +44,9 @@ #include #include #include -#include +#include #include -#include +#include #include #include #include @@ -726,7 +726,7 @@ public: const int basePosition = interface->position() - needle.size(); - QTextCursor tc(interface->document()); + QTextCursor tc(interface->textDocument()); tc.setPosition(interface->position()); tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); @@ -1388,7 +1388,7 @@ void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor) connect(ICore::instance(), SIGNAL(saveSettingsRequested()), SLOT(writeSettings())); - handler->setCurrentFileName(editor->file()->fileName()); + handler->setCurrentFileName(editor->document()->fileName()); handler->installEventFilter(); // pop up the bar @@ -1495,9 +1495,9 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) // :w[rite] Core::IEditor *editor = m_editorToHandler.key(handler); const QString fileName = handler->currentFileName(); - if (editor && editor->file()->fileName() == fileName) { + if (editor && editor->document()->fileName() == fileName) { // Handle that as a special case for nicer interaction with core - FileManager::saveFile(editor->file()); + DocumentManager::saveDocument(editor->document()); // Check result by reading back. QFile file3(fileName); file3.open(QIODevice::ReadOnly); @@ -1512,8 +1512,8 @@ void FakeVimPluginPrivate::handleExCommand(bool *handled, const ExCommand &cmd) } } else if (cmd.matches("wa", "wall")) { // :w[all] - QList toSave = FileManager::modifiedFiles(); - QList failed = FileManager::saveModifiedFilesSilently(toSave); + QList toSave = DocumentManager::modifiedDocuments(); + QList failed = DocumentManager::saveModifiedDocumentsSilently(toSave); if (failed.isEmpty()) handler->showBlackMessage(tr("Saving succeeded")); else diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index c1b2adb185..db917e4249 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include @@ -86,17 +86,17 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) m_includesFileName = QFileInfo(dir, m_projectName + QLatin1String(".includes")).absoluteFilePath(); m_configFileName = QFileInfo(dir, m_projectName + QLatin1String(".config")).absoluteFilePath(); - m_creatorIFile = new GenericProjectFile(this, m_fileName, GenericProject::Everything); - m_filesIFile = new GenericProjectFile(this, m_filesFileName, GenericProject::Files); - m_includesIFile = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration); - m_configIFile = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration); + m_creatorIDocument = new GenericProjectFile(this, m_fileName, GenericProject::Everything); + m_filesIDocument = new GenericProjectFile(this, m_filesFileName, GenericProject::Files); + m_includesIDocument = new GenericProjectFile(this, m_includesFileName, GenericProject::Configuration); + m_configIDocument = new GenericProjectFile(this, m_configFileName, GenericProject::Configuration); - Core::FileManager::addFile(m_creatorIFile); - Core::FileManager::addFile(m_filesIFile); - Core::FileManager::addFile(m_includesIFile); - Core::FileManager::addFile(m_configIFile); + Core::DocumentManager::addDocument(m_creatorIDocument); + Core::DocumentManager::addDocument(m_filesIDocument); + Core::DocumentManager::addDocument(m_includesIDocument); + Core::DocumentManager::addDocument(m_configIDocument); - m_rootNode = new GenericProjectNode(this, m_creatorIFile); + m_rootNode = new GenericProjectNode(this, m_creatorIDocument); m_manager->registerProject(this); } @@ -420,9 +420,9 @@ QString GenericProject::id() const return QLatin1String(Constants::GENERICPROJECT_ID); } -Core::IFile *GenericProject::file() const +Core::IDocument *GenericProject::document() const { - return m_creatorIFile; + return m_creatorIDocument; } IProjectManager *GenericProject::projectManager() const @@ -605,7 +605,7 @@ void GenericBuildSettingsWidget::updateToolChainList() //////////////////////////////////////////////////////////////////////////////////// GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options) - : Core::IFile(parent), + : Core::IDocument(parent), m_project(parent), m_fileName(fileName), m_options(options) @@ -656,7 +656,7 @@ void GenericProjectFile::rename(const QString &newName) QTC_CHECK(false); } -Core::IFile::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h index 6a81adebab..80517fc151 100644 --- a/src/plugins/genericprojectmanager/genericproject.h +++ b/src/plugins/genericprojectmanager/genericproject.h @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include @@ -82,7 +82,7 @@ public: QString displayName() const; QString id() const; - Core::IFile *file() const; + Core::IDocument *document() const; ProjectExplorer::IProjectManager *projectManager() const; GenericTarget *activeTarget() const; @@ -139,10 +139,10 @@ private: QString m_includesFileName; QString m_configFileName; QString m_projectName; - GenericProjectFile *m_creatorIFile; - GenericProjectFile *m_filesIFile; - GenericProjectFile *m_includesIFile; - GenericProjectFile *m_configIFile; + GenericProjectFile *m_creatorIDocument; + GenericProjectFile *m_filesIDocument; + GenericProjectFile *m_includesIDocument; + GenericProjectFile *m_configIDocument; QStringList m_rawFileList; QStringList m_files; QHash m_rawListEntries; @@ -156,7 +156,7 @@ private: QFuture m_codeModelFuture; }; -class GenericProjectFile : public Core::IFile +class GenericProjectFile : public Core::IDocument { Q_OBJECT diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp index 6337bec460..6869454520 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.cpp @@ -79,12 +79,12 @@ QString ProjectFilesFactory::displayName() const return tr(Constants::FILES_EDITOR_DISPLAY_NAME); } -Core::IFile *ProjectFilesFactory::open(const QString &fileName) +Core::IDocument *ProjectFilesFactory::open(const QString &fileName) { Core::EditorManager *editorManager = Core::EditorManager::instance(); if (Core::IEditor *editor = editorManager->openEditor(fileName, id())) - return editor->file(); + return editor->document(); return 0; } diff --git a/src/plugins/genericprojectmanager/genericprojectfileseditor.h b/src/plugins/genericprojectmanager/genericprojectfileseditor.h index 3d0556cfde..a00005e31f 100644 --- a/src/plugins/genericprojectmanager/genericprojectfileseditor.h +++ b/src/plugins/genericprojectmanager/genericprojectfileseditor.h @@ -62,7 +62,7 @@ public: virtual QStringList mimeTypes() const; virtual Core::Id id() const; virtual QString displayName() const; - virtual Core::IFile *open(const QString &fileName); + virtual Core::IDocument *open(const QString &fileName); private: TextEditor::TextEditorActionHandler *m_actionHandler; diff --git a/src/plugins/genericprojectmanager/genericprojectmanager.cpp b/src/plugins/genericprojectmanager/genericprojectmanager.cpp index aab11f8f76..ca4c401243 100644 --- a/src/plugins/genericprojectmanager/genericprojectmanager.cpp +++ b/src/plugins/genericprojectmanager/genericprojectmanager.cpp @@ -58,7 +58,7 @@ ProjectExplorer::Project *Manager::openProject(const QString &fileName, QString ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) { - if (fileName == pi->file()->fileName()) { + if (fileName == pi->document()->fileName()) { if (errorString) *errorString = tr("Failed opening project '%1': Project already open") .arg(QDir::toNativeSeparators(fileName)); diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp index 1e99b409e6..5327fcf71b 100644 --- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp +++ b/src/plugins/genericprojectmanager/genericprojectnodes.cpp @@ -33,7 +33,7 @@ #include "genericprojectnodes.h" #include "genericproject.h" -#include +#include #include #include @@ -41,7 +41,7 @@ using namespace GenericProjectManager; using namespace GenericProjectManager::Internal; -GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *projectFile) +GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IDocument *projectFile) : ProjectExplorer::ProjectNode(projectFile->fileName()), m_project(project), m_projectFile(projectFile) @@ -49,7 +49,7 @@ GenericProjectNode::GenericProjectNode(GenericProject *project, Core::IFile *pro setDisplayName(QFileInfo(projectFile->fileName()).completeBaseName()); } -Core::IFile *GenericProjectNode::projectFile() const +Core::IDocument *GenericProjectNode::projectFile() const { return m_projectFile; } diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.h b/src/plugins/genericprojectmanager/genericprojectnodes.h index d7e6dc0ee9..1aeac40043 100644 --- a/src/plugins/genericprojectmanager/genericprojectnodes.h +++ b/src/plugins/genericprojectmanager/genericprojectnodes.h @@ -39,7 +39,7 @@ #include namespace Core { -class IFile; +class IDocument; } namespace GenericProjectManager { @@ -50,9 +50,9 @@ class GenericProject; class GenericProjectNode : public ProjectExplorer::ProjectNode { public: - GenericProjectNode(GenericProject *project, Core::IFile *projectFile); + GenericProjectNode(GenericProject *project, Core::IDocument *projectFile); - Core::IFile *projectFile() const; + Core::IDocument *projectFile() const; QString projectFilePath() const; virtual bool hasBuildTargets() const; @@ -89,7 +89,7 @@ private: private: GenericProject *m_project; - Core::IFile *m_projectFile; + Core::IDocument *m_projectFile; }; } // namespace Internal diff --git a/src/plugins/genericprojectmanager/genericprojectplugin.cpp b/src/plugins/genericprojectmanager/genericprojectplugin.cpp index fd9b48f204..d7da6323b1 100644 --- a/src/plugins/genericprojectmanager/genericprojectplugin.cpp +++ b/src/plugins/genericprojectmanager/genericprojectplugin.cpp @@ -124,7 +124,7 @@ void GenericProjectPlugin::editFiles() GenericProject *genericProject = static_cast(m_contextMenuProject); Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase(); - SelectableFilesDialog sfd(QFileInfo(genericProject->file()->fileName()).path(), genericProject->files(), + SelectableFilesDialog sfd(QFileInfo(genericProject->document()->fileName()).path(), genericProject->files(), mimeDatabase->suffixes().toSet(), Core::ICore::mainWindow()); if (sfd.exec() == QDialog::Accepted) { genericProject->setFiles(sfd.selectedFiles()); diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 9bf8a43440..79d649f8f1 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include @@ -298,7 +298,7 @@ private: Core::IEditor *locateEditor(const char *property, const QString &entry) { foreach (Core::IEditor *ed, Core::ICore::editorManager()->openedEditors()) - if (ed->file()->property(property).toString() == entry) + if (ed->document()->property(property).toString() == entry) return ed; return 0; } @@ -428,7 +428,7 @@ VcsBase::VcsBaseEditorWidget *GitClient::createVcsEditor(const Core::Id &id, // Create new, set wait message, set up with source and codec Core::IEditor *outputEditor = Core::ICore::editorManager()->openEditorWithContents(id, &title, m_msgWait); - outputEditor->file()->setProperty(registerDynamicProperty, dynamicPropertyValue); + outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); rc = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); connect(rc, SIGNAL(annotateRevisionRequested(QString,QString,int)), this, SLOT(slotBlameRevisionRequested(QString,QString,int))); diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 5da760b77c..bd11886cab 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -48,7 +48,7 @@ #include #include -#include +#include #include #include #include @@ -56,7 +56,7 @@ #include #include #include -#include +#include #include #include @@ -738,13 +738,13 @@ bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEdi { if (!isCommitEditorOpen()) return false; - Core::IFile *fileIFace = submitEditor->file(); + Core::IDocument *editorDocument = submitEditor->document(); const GitSubmitEditor *editor = qobject_cast(submitEditor); - if (!fileIFace || !editor) + if (!editorDocument || !editor) return true; // Submit editor closing. Make it write out the commit message // and retrieve files - const QFileInfo editorFile(fileIFace->fileName()); + const QFileInfo editorFile(editorDocument->fileName()); const QFileInfo changeFile(m_commitMessageFileName); // Paranoia! if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) @@ -774,7 +774,7 @@ bool GitPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *submitEdi bool closeEditor = true; if (model->hasCheckedFiles() || !m_commitAmendSHA1.isEmpty()) { // get message & commit - if (!Core::FileManager::saveFile(fileIFace)) + if (!Core::DocumentManager::saveDocument(editorDocument)) return false; closeEditor = m_gitClient->addAndCommit(m_submitRepository, editor->panelData(), @@ -888,13 +888,13 @@ static bool ensureFileSaved(const QString &fileName) const QList editors = Core::EditorManager::instance()->editorsForFileName(fileName); if (editors.isEmpty()) return true; - Core::IFile *file = editors.front()->file(); - if (!file || !file->isModified()) + Core::IDocument *document = editors.front()->document(); + if (!document || !document->isModified()) return true; bool canceled; - QList files; - files << file; - Core::FileManager::saveModifiedFiles(files, &canceled); + QList documents; + documents << document; + Core::DocumentManager::saveModifiedDocuments(documents, &canceled); return !canceled; } diff --git a/src/plugins/glsleditor/glslcompletionassist.cpp b/src/plugins/glsleditor/glslcompletionassist.cpp index 01c35d0e5f..6bd3469759 100644 --- a/src/plugins/glsleditor/glslcompletionassist.cpp +++ b/src/plugins/glsleditor/glslcompletionassist.cpp @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include #include @@ -239,7 +239,7 @@ IAssistProposal *GLSLCompletionAssistProcessor::perform(const IAssistInterface * bool functionCall = (ch == QLatin1Char('(') && pos == m_interface->position() - 1); if (ch == QLatin1Char(',')) { - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); const int start = expressionUnderCursor.startOfFunctionCall(tc); if (start == -1) @@ -254,7 +254,7 @@ IAssistProposal *GLSLCompletionAssistProcessor::perform(const IAssistInterface * if (ch == QLatin1Char('.') || functionCall) { const bool memberCompletion = ! functionCall; - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(pos); // get the expression under cursor @@ -465,13 +465,13 @@ void GLSLCompletionAssistProcessor::addCompletion(const QString &text, // ----------------------------- // GLSLCompletionAssistInterface // ----------------------------- -GLSLCompletionAssistInterface::GLSLCompletionAssistInterface(QTextDocument *document, +GLSLCompletionAssistInterface::GLSLCompletionAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, TextEditor::AssistReason reason, const QString &mimeType, const Document::Ptr &glslDoc) - : DefaultAssistInterface(document, position, file, reason) + : DefaultAssistInterface(textDocument, position, document, reason) , m_mimeType(mimeType) , m_glslDoc(glslDoc) { diff --git a/src/plugins/glsleditor/glslcompletionassist.h b/src/plugins/glsleditor/glslcompletionassist.h index d0c134360f..e644d2b1d1 100644 --- a/src/plugins/glsleditor/glslcompletionassist.h +++ b/src/plugins/glsleditor/glslcompletionassist.h @@ -98,9 +98,8 @@ private: class GLSLCompletionAssistInterface : public TextEditor::DefaultAssistInterface { public: - GLSLCompletionAssistInterface(QTextDocument *document, - int position, - Core::IFile *file, + GLSLCompletionAssistInterface(QTextDocument *textDocument, + int position, Core::IDocument *document, TextEditor::AssistReason reason, const QString &mimeType, const Document::Ptr &glslDoc); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index 6a6f9a1f69..e9a7a1738c 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -420,7 +420,7 @@ TextEditor::IAssistInterface *GLSLTextEditorWidget::createAssistInterface( if (kind == TextEditor::Completion) return new GLSLCompletionAssistInterface(document(), position(), - editor()->file(), + editor()->document(), reason, mimeType(), glslDocument()); diff --git a/src/plugins/glsleditor/glsleditorfactory.cpp b/src/plugins/glsleditor/glsleditorfactory.cpp index deadc5ea34..397e392241 100644 --- a/src/plugins/glsleditor/glsleditorfactory.cpp +++ b/src/plugins/glsleditor/glsleditorfactory.cpp @@ -75,14 +75,14 @@ QString GLSLEditorFactory::displayName() const return tr(C_GLSLEDITOR_DISPLAY_NAME); } -Core::IFile *GLSLEditorFactory::open(const QString &fileName) +Core::IDocument *GLSLEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); if (!iface) { qWarning() << "QmlEditorFactory::open: openEditor failed for " << fileName; return 0; } - return iface->file(); + return iface->document(); } Core::IEditor *GLSLEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/glsleditor/glsleditorfactory.h b/src/plugins/glsleditor/glsleditorfactory.h index e54128266b..3cfad99e31 100644 --- a/src/plugins/glsleditor/glsleditorfactory.h +++ b/src/plugins/glsleditor/glsleditorfactory.h @@ -51,7 +51,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private slots: diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp index 56ef88d9b7..da93135a36 100644 --- a/src/plugins/imageviewer/imageviewer.cpp +++ b/src/plugins/imageviewer/imageviewer.cpp @@ -131,7 +131,7 @@ bool ImageViewer::open(QString *errorString, const QString &fileName, const QStr return true; } -Core::IFile *ImageViewer::file() +Core::IDocument *ImageViewer::document() { return d->file; } diff --git a/src/plugins/imageviewer/imageviewer.h b/src/plugins/imageviewer/imageviewer.h index a79d4a967b..ef9a23eda1 100644 --- a/src/plugins/imageviewer/imageviewer.h +++ b/src/plugins/imageviewer/imageviewer.h @@ -35,7 +35,7 @@ #define IMAGEVIEWER_H #include -#include +#include #include #include @@ -59,7 +59,7 @@ public: bool createNew(const QString &contents = QString()); bool open(QString *errorString, const QString &fileName, const QString &realFileName); - Core::IFile *file(); + Core::IDocument *document(); Core::Id id() const; QString displayName() const; void setDisplayName(const QString &title); diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp index 5b423c33f9..74baf6b601 100644 --- a/src/plugins/imageviewer/imageviewerfactory.cpp +++ b/src/plugins/imageviewer/imageviewerfactory.cpp @@ -105,7 +105,7 @@ QString ImageViewerFactory::displayName() const return tr(Constants::IMAGEVIEWER_DISPLAY_NAME); } -Core::IFile *ImageViewerFactory::open(const QString & /*fileName*/) +Core::IDocument *ImageViewerFactory::open(const QString & /*fileName*/) { return 0; } diff --git a/src/plugins/imageviewer/imageviewerfactory.h b/src/plugins/imageviewer/imageviewerfactory.h index 41c70a3af4..7938afb784 100644 --- a/src/plugins/imageviewer/imageviewerfactory.h +++ b/src/plugins/imageviewer/imageviewerfactory.h @@ -36,7 +36,7 @@ #include #include -#include +#include namespace ImageViewer { namespace Internal { @@ -53,7 +53,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); void extensionsInitialized(); diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp index 88e7c58ccc..2db2908262 100644 --- a/src/plugins/imageviewer/imageviewerfile.cpp +++ b/src/plugins/imageviewer/imageviewerfile.cpp @@ -54,7 +54,7 @@ struct ImageViewerFilePrivate }; ImageViewerFile::ImageViewerFile(ImageViewer *parent) - : Core::IFile(parent), + : Core::IDocument(parent), d(new ImageViewerFilePrivate) { d->editor = parent; @@ -66,8 +66,8 @@ ImageViewerFile::~ImageViewerFile() } bool ImageViewerFile::reload(QString *errorString, - Core::IFile::ReloadFlag flag, - Core::IFile::ChangeType type) + Core::IDocument::ReloadFlag flag, + Core::IDocument::ChangeType type) { if (flag == FlagIgnore) return true; diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h index fb7eaa124e..2aa820b6fe 100644 --- a/src/plugins/imageviewer/imageviewerfile.h +++ b/src/plugins/imageviewer/imageviewerfile.h @@ -34,7 +34,7 @@ #ifndef IMAGEVIEWERFILE_H #define IMAGEVIEWERFILE_H -#include +#include #include @@ -43,7 +43,7 @@ namespace Internal { class ImageViewer; -class ImageViewerFile : public Core::IFile +class ImageViewerFile : public Core::IDocument { Q_OBJECT public: diff --git a/src/plugins/locator/filesystemfilter.cpp b/src/plugins/locator/filesystemfilter.cpp index dbc8962052..c148e95373 100644 --- a/src/plugins/locator/filesystemfilter.cpp +++ b/src/plugins/locator/filesystemfilter.cpp @@ -60,8 +60,8 @@ QList FileSystemFilter::matchesFor(QFutureInterfacecurrentEditor(); - if (editor && !editor->file()->fileName().isEmpty()) { - QFileInfo info(editor->file()->fileName()); + if (editor && !editor->document()->fileName().isEmpty()) { + QFileInfo info(editor->document()->fileName()); directory.prepend(info.absolutePath() + QLatin1Char('/')); } } diff --git a/src/plugins/locator/opendocumentsfilter.cpp b/src/plugins/locator/opendocumentsfilter.cpp index c9ca9e084f..604a6b4759 100644 --- a/src/plugins/locator/opendocumentsfilter.cpp +++ b/src/plugins/locator/opendocumentsfilter.cpp @@ -88,7 +88,7 @@ void OpenDocumentsFilter::refreshInternally() OpenEditorsModel::Entry entry; // don't work on IEditor directly, since that will be useless with split windows entry.m_displayName = editor->displayName(); - entry.m_fileName = editor->file()->fileName(); + entry.m_fileName = editor->document()->fileName(); m_editors.append(entry); } m_editors += m_editorManager->openedEditorsModel()->restoredEditors(); diff --git a/src/plugins/madde/maemoglobal.h b/src/plugins/madde/maemoglobal.h index f32e2a3054..3fb9b54aac 100644 --- a/src/plugins/madde/maemoglobal.h +++ b/src/plugins/madde/maemoglobal.h @@ -33,7 +33,7 @@ #ifndef MAEMOGLOBAL_H #define MAEMOGLOBAL_H -#include +#include #include #include @@ -56,12 +56,12 @@ class LinuxDeviceConfiguration; namespace Madde { namespace Internal { -class WatchableFile : public Core::IFile +class WatchableFile : public Core::IDocument { Q_OBJECT public: WatchableFile(const QString &fileName, QObject *parent = 0) - : Core::IFile(parent), m_fileName(fileName) {} + : Core::IDocument(parent), m_fileName(fileName) {} bool save(QString *, const QString &, bool) { return false; } QString fileName() const { return m_fileName; } diff --git a/src/plugins/madde/maemopublisherfremantlefree.cpp b/src/plugins/madde/maemopublisherfremantlefree.cpp index f73366c66f..4b3614e5d9 100644 --- a/src/plugins/madde/maemopublisherfremantlefree.cpp +++ b/src/plugins/madde/maemopublisherfremantlefree.cpp @@ -37,7 +37,7 @@ #include "qt4maemodeployconfiguration.h" #include "qt4maemotarget.h" -#include +#include #include #include #include @@ -218,7 +218,7 @@ bool MaemoPublisherFremantleFree::copyRecursively(const QString &srcFilePath, QByteArray rulesContents = reader.data(); rulesContents.replace("$(MAKE) clean", "# $(MAKE) clean"); rulesContents.replace("# Add here commands to configure the package.", - "qmake " + QFileInfo(m_project->file()->fileName()).fileName().toLocal8Bit()); + "qmake " + QFileInfo(m_project->document()->fileName()).fileName().toLocal8Bit()); MaemoDebianPackageCreationStep::ensureShlibdeps(rulesContents); Utils::FileSaver saver(tgtFilePath); saver.write(rulesContents); diff --git a/src/plugins/madde/qt4maemotarget.cpp b/src/plugins/madde/qt4maemotarget.cpp index 5b87fb329e..b273b2d80c 100644 --- a/src/plugins/madde/qt4maemotarget.cpp +++ b/src/plugins/madde/qt4maemotarget.cpp @@ -39,7 +39,7 @@ #include "maemotoolchain.h" #include "qt4maemodeployconfiguration.h" -#include +#include #include #include #include @@ -720,7 +720,7 @@ void AbstractDebBasedQt4MaemoTarget::handleTargetAddedSpecial() connect(m_controlFile, SIGNAL(modified()), SIGNAL(controlChanged())); m_changeLogFile = new WatchableFile(changeLogFilePath(), this); connect(m_changeLogFile, SIGNAL(modified()), SIGNAL(changeLogChanged())); - Core::FileManager::addFiles(QList() + Core::DocumentManager::addDocuments(QList() << m_controlFile << m_changeLogFile); connect(m_filesWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(handleDebianDirContentsChanged())); @@ -1070,7 +1070,7 @@ void AbstractRpmBasedQt4MaemoTarget::handleTargetAddedSpecial() { m_specFile = new WatchableFile(specFilePath(), this); connect(m_specFile, SIGNAL(modified()), SIGNAL(specFileChanged())); - Core::FileManager::addFile(m_specFile); + Core::DocumentManager::addDocument(m_specFile); emit specFileChanged(); } diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 9633f22830..e91fad15ed 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include @@ -627,7 +627,7 @@ bool MercurialPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor { if (!changeLog) return true; - Core::IFile *editorFile = submitEditor->file(); + Core::IDocument *editorFile = submitEditor->document(); CommitEditor *commitEditor = qobject_cast(submitEditor); if (!editorFile || !commitEditor) return true; @@ -651,7 +651,7 @@ bool MercurialPlugin::submitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor const QStringList files = commitEditor->checkedFiles(); if (!files.empty()) { //save the commit message - if (!Core::FileManager::saveFile(editorFile)) + if (!Core::DocumentManager::saveDocument(editorFile)) return false; QStringList extraOptions; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 786579848e..2a2183d346 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -1350,9 +1350,9 @@ bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *subm { if (!isCommitEditorOpen()) return true; - Core::IFile *fileIFace = submitEditor->file(); + Core::IDocument *editorDocument = submitEditor->document(); const PerforceSubmitEditor *perforceEditor = qobject_cast(submitEditor); - if (!fileIFace || !perforceEditor) + if (!editorDocument || !perforceEditor) return true; // Prompt the user. Force a prompt unless submit was actually invoked (that // is, the editor was closed or shutdown). @@ -1372,7 +1372,7 @@ bool PerforcePlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *subm m_settings.setPromptToSubmit(wantsPrompt); m_settings.toSettings(Core::ICore::settings()); } - if (!Core::FileManager::saveFile(fileIFace)) + if (!Core::DocumentManager::saveDocument(editorDocument)) return false; if (answer == VcsBase::VcsBaseSubmitEditor::SubmitDiscarded) { cleanCommitMessageFile(); diff --git a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp index ebe331af1b..f733af247d 100644 --- a/src/plugins/projectexplorer/baseprojectwizarddialog.cpp +++ b/src/plugins/projectexplorer/baseprojectwizarddialog.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include @@ -139,8 +139,8 @@ void BaseProjectWizardDialog::slotAccepted() { if (d->introPage->useAsDefaultPath()) { // Store the path as default path for new projects if desired. - Core::FileManager::setProjectsDirectory(path()); - Core::FileManager::setUseProjectsDirectory(true); + Core::DocumentManager::setProjectsDirectory(path()); + Core::DocumentManager::setUseProjectsDirectory(true); } } diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 6edab82dc2..205aa2466d 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -36,7 +36,7 @@ #include "project.h" #include "session.h" -#include +#include #include #include @@ -75,8 +75,8 @@ bool CurrentProjectFind::isEnabled() const QVariant CurrentProjectFind::additionalParameters() const { Project *project = ProjectExplorerPlugin::currentProject(); - if (project && project->file()) - return qVariantFromValue(project->file()->fileName()); + if (project && project->document()) + return qVariantFromValue(project->document()->fileName()); return QVariant(); } @@ -87,7 +87,7 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters, QList allProjects = m_plugin->session()->projects(); QString projectFile = additionalParameters.toString(); foreach (Project *project, allProjects) { - if (project->file() && projectFile == project->file()->fileName()) + if (project->document() && projectFile == project->document()->fileName()) return filesForProjects(nameFilters, QList() << project); } return new Utils::FileIterator(); diff --git a/src/plugins/projectexplorer/dependenciespanel.cpp b/src/plugins/projectexplorer/dependenciespanel.cpp index bdf8815a0e..64ce1ada92 100644 --- a/src/plugins/projectexplorer/dependenciespanel.cpp +++ b/src/plugins/projectexplorer/dependenciespanel.cpp @@ -35,7 +35,7 @@ #include "session.h" #include -#include +#include #include #include @@ -114,7 +114,7 @@ QVariant DependenciesModel::data(const QModelIndex &index, int role) const case Qt::CheckStateRole: return m_session->hasDependency(m_project, p) ? Qt::Checked : Qt::Unchecked; case Qt::DecorationRole: - return Core::FileIconProvider::instance()->icon(QFileInfo(p->file()->fileName())); + return Core::FileIconProvider::instance()->icon(QFileInfo(p->document()->fileName())); default: return QVariant(); } diff --git a/src/plugins/projectexplorer/editorconfiguration.cpp b/src/plugins/projectexplorer/editorconfiguration.cpp index 787a73f718..ee2459a23f 100644 --- a/src/plugins/projectexplorer/editorconfiguration.cpp +++ b/src/plugins/projectexplorer/editorconfiguration.cpp @@ -257,7 +257,7 @@ void EditorConfiguration::setUseGlobalSettings(bool use) QList opened = Core::EditorManager::instance()->openedEditors(); foreach (Core::IEditor *editor, opened) { if (BaseTextEditorWidget *baseTextEditor = qobject_cast(editor->widget())) { - Project *project = session->projectForFile(editor->file()->fileName()); + Project *project = session->projectForFile(editor->document()->fileName()); if (project && project->editorConfiguration() == this) switchSettings(baseTextEditor); } diff --git a/src/plugins/projectexplorer/foldernavigationwidget.cpp b/src/plugins/projectexplorer/foldernavigationwidget.cpp index 43fb44222d..b89e3a4274 100644 --- a/src/plugins/projectexplorer/foldernavigationwidget.cpp +++ b/src/plugins/projectexplorer/foldernavigationwidget.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include #include @@ -188,11 +188,11 @@ void FolderNavigationWidget::setAutoSynchronization(bool sync) m_autoSync = sync; if (m_autoSync) { - connect(Core::FileManager::instance(), SIGNAL(currentFileChanged(QString)), + connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)), this, SLOT(setCurrentFile(QString))); - setCurrentFile(Core::FileManager::currentFile()); + setCurrentFile(Core::DocumentManager::currentFile()); } else { - disconnect(Core::FileManager::instance(), SIGNAL(currentFileChanged(QString)), + disconnect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)), this, SLOT(setCurrentFile(QString))); } } @@ -322,7 +322,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) // open with... if (!m_fileSystemModel->isDir(current)) { QMenu *openWith = menu.addMenu(tr("Open with")); - Core::FileManager::populateOpenWithMenu(openWith, + Core::DocumentManager::populateOpenWithMenu(openWith, m_fileSystemModel->filePath(current)); } @@ -360,7 +360,7 @@ void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) findOnFileSystem(info.absolutePath()); return; } - Core::FileManager::executeOpenWithMenuAction(action); + Core::DocumentManager::executeOpenWithMenuAction(action); } QString FolderNavigationWidget::msgFindOnFileSystem() diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index 4115bdefda..70ea3ab7ea 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include #include @@ -229,7 +229,7 @@ QListWidgetItem *ProjectListWidget::itemForProject(Project *project) QString ProjectListWidget::fullName(ProjectExplorer::Project *project) { - return tr("%1 (%2)").arg(project->displayName(), project->file()->fileName()); + return tr("%1 (%2)").arg(project->displayName(), project->document()->fileName()); } void ProjectListWidget::addProject(Project *project) diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp index 4f18e32109..74ab068811 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.cpp +++ b/src/plugins/projectexplorer/pluginfilefactory.cpp @@ -75,7 +75,7 @@ QString ProjectFileFactory::displayName() const return tr("Project File Factory", "ProjectExplorer::ProjectFileFactory display name."); } -Core::IFile *ProjectFileFactory::open(const QString &fileName) +Core::IDocument *ProjectFileFactory::open(const QString &fileName) { ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); pe->openProject(fileName, 0); diff --git a/src/plugins/projectexplorer/pluginfilefactory.h b/src/plugins/projectexplorer/pluginfilefactory.h index 85b27e4615..b7b3d9bd1f 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.h +++ b/src/plugins/projectexplorer/pluginfilefactory.h @@ -33,7 +33,7 @@ #ifndef PLUGINFILEFACTORY_H #define PLUGINFILEFACTORY_H -#include +#include #include @@ -44,7 +44,7 @@ class ProjectExplorerPlugin; namespace Internal { -class ProjectFileFactory : public Core::IFileFactory +class ProjectFileFactory : public Core::IDocumentFactory { Q_OBJECT @@ -56,7 +56,7 @@ public: Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); static QList createFactories(QString *filterString); diff --git a/src/plugins/projectexplorer/processstep.cpp b/src/plugins/projectexplorer/processstep.cpp index 8b9e6eaf24..ff6623b31e 100644 --- a/src/plugins/projectexplorer/processstep.cpp +++ b/src/plugins/projectexplorer/processstep.cpp @@ -37,7 +37,7 @@ #include "projectexplorerconstants.h" #include "target.h" -#include +#include #include #include diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index ce9dfbef9f..cb60322621 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -40,7 +40,7 @@ #include "target.h" #include "settingsaccessor.h" -#include +#include #include #include #include @@ -274,7 +274,7 @@ QVariantMap Project::toMap() const QString Project::projectDirectory() const { - return projectDirectory(file()->fileName()); + return projectDirectory(document()->fileName()); } QString Project::projectDirectory(const QString &proFile) diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index d050b90939..b4f217c900 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -40,7 +40,7 @@ #include namespace Core { -class IFile; +class IDocument; class Context; } @@ -71,7 +71,7 @@ public: virtual QString displayName() const = 0; virtual QString id() const = 0; - virtual Core::IFile *file() const = 0; + virtual Core::IDocument *document() const = 0; virtual IProjectManager *projectManager() const = 0; virtual QList dependsOn() = 0; //NBS TODO implement dependsOn diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index a7664a63b6..267f469e5b 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -90,7 +90,7 @@ #include #include -#include +#include #include #include #include @@ -339,7 +339,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); addObject(d->m_welcomePage); - connect(Core::FileManager::instance(), SIGNAL(currentFileChanged(QString)), + connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)), this, SLOT(setCurrentFile(QString))); d->m_session = new SessionManager(this); @@ -519,7 +519,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_openWithMenu->setTitle(tr("Open With")); connect(d->m_openWithMenu, SIGNAL(triggered(QAction *)), - Core::FileManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*))); + Core::DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*))); // // Separators @@ -1032,9 +1032,9 @@ void ProjectExplorerPlugin::loadAction() // for your special convenience, we preselect a pro file if it is // the current file if (Core::IEditor *editor = Core::EditorManager::instance()->currentEditor()) { - if (const Core::IFile *file = editor->file()) { - const QString fn = file->fileName(); - const bool isProject = d->m_profileMimeTypes.contains(file->mimeType()); + if (const Core::IDocument *document= editor->document()) { + const QString fn = document->fileName(); + const bool isProject = d->m_profileMimeTypes.contains(document->mimeType()); dir = isProject ? fn : QFileInfo(fn).absolutePath(); } } @@ -1071,23 +1071,23 @@ void ProjectExplorerPlugin::unloadProject() buildManager()->cancel(); } - Core::IFile *fi = d->m_currentProject->file(); + Core::IDocument *document = d->m_currentProject->document(); - if (!fi || fi->fileName().isEmpty()) //nothing to save? + if (!document || document->fileName().isEmpty()) //nothing to save? return; - QList filesToSave; - filesToSave << fi; + QList documentsToSave; + documentsToSave << document; bool success = false; - if (fi->isReadOnly()) - success = Core::FileManager::saveModifiedFiles(filesToSave).isEmpty(); + if (document->isFileReadOnly()) + success = Core::DocumentManager::saveModifiedDocuments(documentsToSave).isEmpty(); else - success = Core::FileManager::saveModifiedFilesSilently(filesToSave).isEmpty(); + success = Core::DocumentManager::saveModifiedDocumentsSilently(documentsToSave).isEmpty(); if (!success) return; - addToRecentProjects(fi->fileName(), d->m_currentProject->displayName()); + addToRecentProjects(document->fileName(), d->m_currentProject->displayName()); d->m_session->removeProject(d->m_currentProject); updateActions(); } @@ -1130,16 +1130,16 @@ void ProjectExplorerPlugin::loadCustomWizards() void ProjectExplorerPlugin::updateVariable(const QByteArray &variable) { if (variable == kCurrentProjectFilePath) { - if (currentProject() && currentProject()->file()) { + if (currentProject() && currentProject()->document()) { Core::VariableManager::instance()->insert(variable, - currentProject()->file()->fileName()); + currentProject()->document()->fileName()); } else { Core::VariableManager::instance()->remove(variable); } } else if (variable == kCurrentProjectPath) { - if (currentProject() && currentProject()->file()) { + if (currentProject() && currentProject()->document()) { Core::VariableManager::instance()->insert(variable, - QFileInfo(currentProject()->file()->fileName()).path()); + QFileInfo(currentProject()->document()->fileName()).path()); } else { Core::VariableManager::instance()->remove(variable); } @@ -1556,7 +1556,7 @@ void ProjectExplorerPlugin::buildStateChanged(Project * pro) { if (debug) { qDebug() << "buildStateChanged"; - qDebug() << pro->file()->fileName() << "isBuilding()" << d->m_buildManager->isBuilding(pro); + qDebug() << pro->document()->fileName() << "isBuilding()" << d->m_buildManager->isBuilding(pro); } Q_UNUSED(pro) updateActions(); @@ -1666,7 +1666,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node updateActions(); } - Core::FileManager::setCurrentFile(filePath); + Core::DocumentManager::setCurrentFile(filePath); } void ProjectExplorerPlugin::updateActions() @@ -1747,7 +1747,7 @@ void ProjectExplorerPlugin::updateActions() QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro) { if (debug) - qDebug() << "ProjectExplorerPlugin::allFilesWithDependencies(" << pro->file()->fileName() << ")"; + qDebug() << "ProjectExplorerPlugin::allFilesWithDependencies(" << pro->document()->fileName() << ")"; QStringList filesToSave; foreach (Project *p, d->m_session->projectOrder(pro)) { @@ -1764,17 +1764,17 @@ bool ProjectExplorerPlugin::saveModifiedFiles() if (debug) qDebug() << "ProjectExplorerPlugin::saveModifiedFiles"; - QList filesToSave = Core::FileManager::modifiedFiles(); - if (!filesToSave.isEmpty()) { + QList documentsToSave = Core::DocumentManager::modifiedDocuments(); + if (!documentsToSave.isEmpty()) { if (d->m_projectExplorerSettings.saveBeforeBuild) { bool cancelled = false; - Core::FileManager::saveModifiedFilesSilently(filesToSave, &cancelled); + Core::DocumentManager::saveModifiedDocumentsSilently(documentsToSave, &cancelled); if (cancelled) return false; } else { bool cancelled = false; bool alwaysSave = false; - Core::FileManager::saveModifiedFiles(filesToSave, &cancelled, QString(), + Core::DocumentManager::saveModifiedDocuments(documentsToSave, &cancelled, QString(), tr("Always save files before build"), &alwaysSave); if (cancelled) @@ -2750,7 +2750,7 @@ void ProjectExplorerPlugin::deleteFile() projectNode->deleteFiles(fileNode->fileType(), QStringList(filePath)); - Core::FileManager::expectFileChange(filePath); + Core::DocumentManager::expectFileChange(filePath); if (Core::IVersionControl *vc = Core::ICore::vcsManager()->findVersionControlForDirectory(QFileInfo(filePath).absolutePath())) { vc->vcsDelete(filePath); @@ -2761,7 +2761,7 @@ void ProjectExplorerPlugin::deleteFile() QMessageBox::warning(Core::ICore::mainWindow(), tr("Deleting File Failed"), tr("Could not delete file %1.").arg(filePath)); } - Core::FileManager::unexpectFileChange(filePath); + Core::DocumentManager::unexpectFileChange(filePath); } void ProjectExplorerPlugin::renameFile() @@ -2810,7 +2810,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to) result = fileSystemRenameFile(orgFilePath, newFilePath); if (result) { // yeah we moved, tell the filemanager about it - Core::FileManager::renamedFile(orgFilePath, newFilePath); + Core::DocumentManager::renamedFile(orgFilePath, newFilePath); // Tell the project plugin about it ProjectNode *projectNode = fileNode->projectNode(); projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath); @@ -2825,7 +2825,7 @@ void ProjectExplorerPlugin::setStartupProject() void ProjectExplorerPlugin::populateOpenWithMenu() { - Core::FileManager::populateOpenWithMenu(d->m_openWithMenu, currentNode()->path()); + Core::DocumentManager::populateOpenWithMenu(d->m_openWithMenu, currentNode()->path()); } void ProjectExplorerPlugin::updateSessionMenu() @@ -2877,8 +2877,8 @@ QStringList ProjectExplorerPlugin::projectFilePatterns() void ProjectExplorerPlugin::openOpenProjectDialog() { - const QString path = Core::FileManager::useProjectsDirectory() ? Core::FileManager::projectsDirectory() : QString(); - const QStringList files = Core::FileManager::getOpenFileNames(d->m_projectFilterString, path); + const QString path = Core::DocumentManager::useProjectsDirectory() ? Core::DocumentManager::projectsDirectory() : QString(); + const QStringList files = Core::DocumentManager::getOpenFileNames(d->m_projectFilterString, path); if (!files.isEmpty()) Core::ICore::openFiles(files, Core::ICore::SwitchMode); } diff --git a/src/plugins/projectexplorer/projectexplorersettingspage.cpp b/src/plugins/projectexplorer/projectexplorersettingspage.cpp index 44398ff877..48489c428b 100644 --- a/src/plugins/projectexplorer/projectexplorersettingspage.cpp +++ b/src/plugins/projectexplorer/projectexplorersettingspage.cpp @@ -36,7 +36,7 @@ #include "projectexplorer.h" #include -#include +#include #include #include @@ -185,8 +185,8 @@ QWidget *ProjectExplorerSettingsPage::createPage(QWidget *parent) { m_widget = new ProjectExplorerSettingsWidget(parent); m_widget->setSettings(ProjectExplorerPlugin::instance()->projectExplorerSettings()); - m_widget->setProjectsDirectory(Core::FileManager::projectsDirectory()); - m_widget->setUseProjectsDirectory(Core::FileManager::useProjectsDirectory()); + m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory()); + m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory()); if (m_searchKeywords.isEmpty()) m_searchKeywords = m_widget->searchKeywords(); return m_widget; @@ -196,8 +196,8 @@ void ProjectExplorerSettingsPage::apply() { if (m_widget) { ProjectExplorerPlugin::instance()->setProjectExplorerSettings(m_widget->settings()); - Core::FileManager::setProjectsDirectory(m_widget->projectsDirectory()); - Core::FileManager::setUseProjectsDirectory(m_widget->useProjectsDirectory()); + Core::DocumentManager::setProjectsDirectory(m_widget->projectsDirectory()); + Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory()); } } diff --git a/src/plugins/projectexplorer/projectfilewizardextension.cpp b/src/plugins/projectexplorer/projectfilewizardextension.cpp index 2ace305d96..828948d44b 100644 --- a/src/plugins/projectexplorer/projectfilewizardextension.cpp +++ b/src/plugins/projectexplorer/projectfilewizardextension.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 2861451284..4c2a93cfe4 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -44,7 +44,7 @@ #include "target.h" #include -#include +#include #include #include #include @@ -367,7 +367,7 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project) } m_tabIndexToProject.insert(index, project); - m_tabWidget->insertTab(index, project->displayName(), project->file()->fileName(), subtabs); + m_tabWidget->insertTab(index, project->displayName(), project->document()->fileName(), subtabs); } void ProjectWindow::deregisterProject(ProjectExplorer::Project *project) diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index baa1613fd7..d36933fa7e 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -41,7 +41,7 @@ #include #include -#include +#include #include #include #include @@ -172,7 +172,7 @@ bool SessionManager::recursiveDependencyCheck(const QString &newDep, const QStri QList SessionManager::dependencies(const Project *project) const { - const QString &proName = project->file()->fileName(); + const QString &proName = project->document()->fileName(); const QStringList &proDeps = m_depMap.value(proName); QList projects; @@ -186,8 +186,8 @@ QList SessionManager::dependencies(const Project *project) const bool SessionManager::hasDependency(const Project *project, const Project *depProject) const { - const QString &proName = project->file()->fileName(); - const QString &depName = depProject->file()->fileName(); + const QString &proName = project->document()->fileName(); + const QString &depName = depProject->document()->fileName(); const QStringList &proDeps = m_depMap.value(proName); return proDeps.contains(depName); @@ -195,16 +195,16 @@ bool SessionManager::hasDependency(const Project *project, const Project *depPro bool SessionManager::canAddDependency(const Project *project, const Project *depProject) const { - const QString &newDep = project->file()->fileName(); - const QString &checkDep = depProject->file()->fileName(); + const QString &newDep = project->document()->fileName(); + const QString &checkDep = depProject->document()->fileName(); return recursiveDependencyCheck(newDep, checkDep); } bool SessionManager::addDependency(Project *project, Project *depProject) { - const QString &proName = project->file()->fileName(); - const QString &depName = depProject->file()->fileName(); + const QString &proName = project->document()->fileName(); + const QString &depName = depProject->document()->fileName(); // check if this dependency is valid if (!recursiveDependencyCheck(proName, depName)) @@ -222,8 +222,8 @@ bool SessionManager::addDependency(Project *project, Project *depProject) void SessionManager::removeDependency(Project *project, Project *depProject) { - const QString &proName = project->file()->fileName(); - const QString &depName = depProject->file()->fileName(); + const QString &proName = project->document()->fileName(); + const QString &depName = depProject->document()->fileName(); QStringList proDeps = m_depMap.value(proName); proDeps.removeAll(depName); @@ -313,12 +313,12 @@ bool SessionManager::save() // save the startup project if (m_startupProject) { - writer.saveValue(QLatin1String("StartupProject"), m_startupProject->file()->fileName()); + writer.saveValue(QLatin1String("StartupProject"), m_startupProject->document()->fileName()); } QStringList projectFiles; foreach (Project *pro, m_projects) - projectFiles << pro->file()->fileName(); + projectFiles << pro->document()->fileName(); // Restore infromation on projects that failed to load: projectFiles.append(m_failedProjects); @@ -405,7 +405,7 @@ QStringList SessionManager::dependenciesOrder() const // copy the map to a temporary list foreach (Project *pro, projects()) { - const QString &proName = pro->file()->fileName(); + const QString &proName = pro->document()->fileName(); unordered << QPair (proName, m_depMap.value(proName)); } @@ -438,14 +438,14 @@ QList SessionManager::projectOrder(Project *project) const QStringList pros; if (project) { - pros = dependencies(project->file()->fileName()); + pros = dependencies(project->document()->fileName()); } else { pros = dependenciesOrder(); } foreach (const QString &proFile, pros) { foreach (Project *pro, projects()) { - if (pro->file()->fileName() == proFile) { + if (pro->document()->fileName() == proFile) { result << pro; break; } @@ -566,7 +566,7 @@ void SessionManager::removeProjects(QList remove) QSet projectFiles; foreach (Project *pro, projects()) { if (!remove.contains(pro)) - projectFiles.insert(pro->file()->fileName()); + projectFiles.insert(pro->document()->fileName()); } QSet::const_iterator i = projectFiles.begin(); @@ -758,7 +758,7 @@ void SessionManager::restoreStartupProject(const Utils::PersistentSettingsReader if (!startupProject.isEmpty()) { const QString startupProjectPath = startupProject; foreach (Project *pro, m_projects) { - if (QDir::cleanPath(pro->file()->fileName()) == startupProjectPath) { + if (QDir::cleanPath(pro->document()->fileName()) == startupProjectPath) { setStartupProject(m_startupProject); break; } @@ -795,7 +795,7 @@ void SessionManager::restoreProjects(const QStringList &fileList) if (!errors.isEmpty()) QMessageBox::critical(Core::ICore::mainWindow(), tr("Failed to open project"), errors); foreach (Project *p, projects) - m_failedProjects.removeAll(p->file()->fileName()); + m_failedProjects.removeAll(p->document()->fileName()); } } diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 6f555f5ed6..0d9f370685 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -51,7 +51,7 @@ QT_END_NAMESPACE namespace Core { class IMode; class IEditor; -class IFile; +class IDocument; } namespace ProjectExplorer { diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp index 2b099643b1..dd17b9fdef 100644 --- a/src/plugins/projectexplorer/settingsaccessor.cpp +++ b/src/plugins/projectexplorer/settingsaccessor.cpp @@ -40,7 +40,7 @@ #include "target.h" #include -#include +#include #include #include #include @@ -774,7 +774,7 @@ void SettingsAccessor::FileAccessor::assignSuffix(const QString &defaultSuffix, QString SettingsAccessor::FileAccessor::assembleFileName(const Project *project) const { - return project->file()->fileName() + m_suffix; + return project->document()->fileName() + m_suffix; } bool SettingsAccessor::FileAccessor::findNewestCompatibleSetting(SettingsData *settings) const diff --git a/src/plugins/qmldesigner/designmodewidget.cpp b/src/plugins/qmldesigner/designmodewidget.cpp index 5a10db3a61..f066e13df7 100644 --- a/src/plugins/qmldesigner/designmodewidget.cpp +++ b/src/plugins/qmldesigner/designmodewidget.cpp @@ -276,9 +276,9 @@ void DesignModeWidget::toggleSidebars() void DesignModeWidget::showEditor(Core::IEditor *editor) { if (m_textEditor && editor) - if (m_textEditor->file()->fileName() != editor->file()->fileName()) { + if (m_textEditor->document()->fileName() != editor->document()->fileName()) { if (!m_keepNavigatorHistory) - addNavigatorHistoryEntry(editor->file()->fileName()); + addNavigatorHistoryEntry(editor->document()->fileName()); setupNavigatorHistory(); } @@ -299,7 +299,7 @@ void DesignModeWidget::showEditor(Core::IEditor *editor) TextEditor::ITextEditor *textEditor = 0; if (editor) { - fileName = editor->file()->fileName(); + fileName = editor->document()->fileName(); textEdit = qobject_cast(editor->widget()); textEditor = qobject_cast(editor); if (textEditor) @@ -352,7 +352,7 @@ void DesignModeWidget::closeEditors(QList editors) } if (m_documentHash.contains(textEdit)) { if (debug) - qDebug() << Q_FUNC_INFO << editor->file()->fileName(); + qDebug() << Q_FUNC_INFO << editor->document()->fileName(); DesignDocumentController *document = m_documentHash.take(textEdit).data(); delete document; } diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index 908c89b3d5..d71f9f7088 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -174,11 +174,11 @@ void BauhausPlugin::createDesignModeWidget() //Save actionManager->registerAction(m_saveAction, Core::Constants::SAVE, qmlDesignerMainContext); - connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFile())); + connect(m_saveAction, SIGNAL(triggered()), m_editorManager, SLOT(saveDocument())); //Save As actionManager->registerAction(m_saveAsAction, Core::Constants::SAVEAS, qmlDesignerMainContext); - connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveFileAs())); + connect(m_saveAsAction, SIGNAL(triggered()), m_editorManager, SLOT(saveDocumentAs())); //Close Editor actionManager->registerAction(m_closeCurrentEditorAction, Core::Constants::CLOSE, qmlDesignerMainContext); @@ -326,19 +326,19 @@ void BauhausPlugin::updateActions(Core::IEditor* editor) QString fName; 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(); } } - m_saveAction->setEnabled(curEditor != 0 && curEditor->file()->isModified()); - m_saveAsAction->setEnabled(curEditor != 0 && curEditor->file()->isSaveAsAllowed()); + m_saveAction->setEnabled(curEditor != 0 && curEditor->document()->isModified()); + m_saveAsAction->setEnabled(curEditor != 0 && curEditor->document()->isSaveAsAllowed()); m_revertToSavedAction->setEnabled(curEditor != 0 - && !curEditor->file()->fileName().isEmpty() - && curEditor->file()->isModified()); + && !curEditor->document()->fileName().isEmpty() + && curEditor->document()->isModified()); QString quotedName; if (!fName.isEmpty()) diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp index f90da289a4..61f9459f15 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.cpp +++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp @@ -35,7 +35,7 @@ #include "qmljsreuse.h" #include "qmlexpressionundercursor.h" -#include +#include #include #include @@ -530,10 +530,10 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor()) return 0; - const QString &fileName = m_interface->file()->fileName(); + const QString &fileName = m_interface->document()->fileName(); m_startPosition = assistInterface->position(); - while (isIdentifierChar(m_interface->document()->characterAt(m_startPosition - 1), false, false)) + while (isIdentifierChar(m_interface->textDocument()->characterAt(m_startPosition - 1), false, false)) --m_startPosition; const bool onIdentifier = m_startPosition != assistInterface->position(); @@ -563,9 +563,9 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface // a +b -> '+' QChar completionOperator; if (m_startPosition > 0) - completionOperator = m_interface->document()->characterAt(m_startPosition - 1); + completionOperator = m_interface->textDocument()->characterAt(m_startPosition - 1); - QTextCursor startPositionCursor(qmlInterface->document()); + QTextCursor startPositionCursor(qmlInterface->textDocument()); startPositionCursor.setPosition(m_startPosition); CompletionContextFinder contextFinder(startPositionCursor); @@ -609,7 +609,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface if (contextFinder.isInStringLiteral()) { // get the text of the literal up to the cursor position //QTextCursor tc = textWidget->textCursor(); - QTextCursor tc(qmlInterface->document()); + QTextCursor tc(qmlInterface->textDocument()); tc.setPosition(qmlInterface->position()); QmlExpressionUnderCursor expressionUnderCursor; expressionUnderCursor(tc); @@ -656,7 +656,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface || (completionOperator == QLatin1Char('(') && !onIdentifier)) { // Look at the expression under cursor. //QTextCursor tc = textWidget->textCursor(); - QTextCursor tc(qmlInterface->document()); + QTextCursor tc(qmlInterface->textDocument()); tc.setPosition(m_startPosition - 1); QmlExpressionUnderCursor expressionUnderCursor; @@ -822,11 +822,11 @@ bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const const int cursorPos = m_interface->position(); bool maybeAccept = false; - const QChar &charBeforeCursor = m_interface->document()->characterAt(cursorPos - 1); + const QChar &charBeforeCursor = m_interface->textDocument()->characterAt(cursorPos - 1); if (isActivationChar(charBeforeCursor)) { maybeAccept = true; } else { - const QChar &charUnderCursor = m_interface->document()->characterAt(cursorPos); + const QChar &charUnderCursor = m_interface->textDocument()->characterAt(cursorPos); if (isIdentifierChar(charBeforeCursor) && ((charUnderCursor.isSpace() || charUnderCursor.isNull() @@ -835,7 +835,7 @@ bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const int startPos = cursorPos - 1; for (; startPos != -1; --startPos) { - if (!isIdentifierChar(m_interface->document()->characterAt(startPos))) + if (!isIdentifierChar(m_interface->textDocument()->characterAt(startPos))) break; } ++startPos; @@ -852,7 +852,7 @@ bool QmlJSCompletionAssistProcessor::acceptsIdleEditor() const } if (maybeAccept) { - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(m_interface->position()); const QTextBlock &block = tc.block(); const QString &blockText = block.text(); @@ -933,12 +933,12 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath // ------------------------------ // QmlJSCompletionAssistInterface // ------------------------------ -QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *document, +QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, TextEditor::AssistReason reason, const SemanticInfo &info) - : DefaultAssistInterface(document, position, file, reason) + : DefaultAssistInterface(textDocument, position, document, reason) , m_semanticInfo(info) , m_darkBlueIcon(iconForColor(Qt::darkBlue)) , m_darkYellowIcon(iconForColor(Qt::darkYellow)) diff --git a/src/plugins/qmljseditor/qmljscompletionassist.h b/src/plugins/qmljseditor/qmljscompletionassist.h index 684918add5..37d3e23f10 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.h +++ b/src/plugins/qmljseditor/qmljscompletionassist.h @@ -121,9 +121,9 @@ private: class QmlJSCompletionAssistInterface : public TextEditor::DefaultAssistInterface { public: - QmlJSCompletionAssistInterface(QTextDocument *document, + QmlJSCompletionAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, TextEditor::AssistReason reason, const SemanticInfo &info); const SemanticInfo &semanticInfo() const; diff --git a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp index 83bc4cf1c3..ccc240bbd9 100644 --- a/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp +++ b/src/plugins/qmljseditor/qmljscomponentfromobjectdef.cpp @@ -34,7 +34,7 @@ #include "qmljscomponentnamedialog.h" #include "qmljsquickfixassist.h" -#include +#include #include #include diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 5be159ff91..78ea9cff7b 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -808,7 +808,7 @@ void QmlJSTextEditorWidget::reparseDocumentNow() { m_updateDocumentTimer->stop(); - const QString fileName = file()->fileName(); + const QString fileName = editorDocument()->fileName(); m_modelManager->updateSourceFiles(QStringList() << fileName, false); } @@ -889,7 +889,7 @@ static void appendExtraSelectionsForMessages( void QmlJSTextEditorWidget::onDocumentUpdated(QmlJS::Document::Ptr doc) { - if (file()->fileName() != doc->fileName()) + if (editorDocument()->fileName() != doc->fileName()) return; if (doc->editorRevision() != editorRevision()) { @@ -918,7 +918,7 @@ void QmlJSTextEditorWidget::onDocumentUpdated(QmlJS::Document::Ptr doc) void QmlJSTextEditorWidget::modificationChanged(bool changed) { if (!changed && m_modelManager) - m_modelManager->fileChangedOnDisk(file()->fileName()); + m_modelManager->fileChangedOnDisk(editorDocument()->fileName()); } void QmlJSTextEditorWidget::jumpToOutlineElement(int /*index*/) @@ -1301,7 +1301,7 @@ void QmlJSTextEditorWidget::createToolBar(QmlJSEditorEditable *editor) connect(m_outlineCombo, SIGNAL(activated(int)), this, SLOT(jumpToOutlineElement(int))); connect(this, SIGNAL(cursorPositionChanged()), m_updateOutlineIndexTimer, SLOT(start())); - connect(file(), SIGNAL(changed()), this, SLOT(updateFileName())); + connect(editorDocument(), SIGNAL(changed()), this, SLOT(updateFileName())); editor->insertExtraToolBarWidget(TextEditor::BaseTextEditor::Left, m_outlineCombo); } @@ -1394,12 +1394,12 @@ void QmlJSTextEditorWidget::followSymbolUnderCursor() void QmlJSTextEditorWidget::findUsages() { - m_findReferences->findUsages(file()->fileName(), textCursor().position()); + m_findReferences->findUsages(editorDocument()->fileName(), textCursor().position()); } void QmlJSTextEditorWidget::renameUsages() { - m_findReferences->renameUsages(file()->fileName(), textCursor().position()); + m_findReferences->renameUsages(editorDocument()->fileName(), textCursor().position()); } void QmlJSTextEditorWidget::showContextPane() @@ -1680,7 +1680,7 @@ TextEditor::IAssistInterface *QmlJSTextEditorWidget::createAssistInterface( if (assistKind == TextEditor::Completion) { return new QmlJSCompletionAssistInterface(document(), position(), - editor()->file(), + editor()->document(), reason, m_semanticInfo); } else if (assistKind == TextEditor::QuickFix) { diff --git a/src/plugins/qmljseditor/qmljseditorfactory.cpp b/src/plugins/qmljseditor/qmljseditorfactory.cpp index e5b6d470ab..42dfcabab6 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.cpp +++ b/src/plugins/qmljseditor/qmljseditorfactory.cpp @@ -78,14 +78,14 @@ QString QmlJSEditorFactory::displayName() const } -Core::IFile *QmlJSEditorFactory::open(const QString &fileName) +Core::IDocument *QmlJSEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); if (!iface) { qWarning() << "QmlEditorFactory::open: openEditor failed for " << fileName; return 0; } - return iface->file(); + return iface->document(); } Core::IEditor *QmlJSEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/qmljseditor/qmljseditorfactory.h b/src/plugins/qmljseditor/qmljseditorfactory.h index f5fa8e6c5f..92a5b60cee 100644 --- a/src/plugins/qmljseditor/qmljseditorfactory.h +++ b/src/plugins/qmljseditor/qmljseditorfactory.h @@ -51,7 +51,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/qmljseditor/qmljsoutline.cpp b/src/plugins/qmljseditor/qmljsoutline.cpp index 8bd602dc2a..56208371b1 100644 --- a/src/plugins/qmljseditor/qmljsoutline.cpp +++ b/src/plugins/qmljseditor/qmljsoutline.cpp @@ -36,7 +36,7 @@ #include "qmljsoutlinetreeview.h" #include -#include +#include #include #include diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index 1627c01726..ae8ac21cc9 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -48,7 +48,7 @@ using namespace TextEditor; // ----------------------- QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSTextEditorWidget *editor, TextEditor::AssistReason reason) - : DefaultAssistInterface(editor->document(), editor->position(), editor->file(), reason) + : DefaultAssistInterface(editor->document(), editor->position(), editor->editorDocument(), reason) , m_editor(editor) , m_semanticInfo(editor->semanticInfo()) , m_currentFile(QmlJSRefactoringChanges::file(m_editor, m_semanticInfo.document)) diff --git a/src/plugins/qmljseditor/qmljswrapinloader.cpp b/src/plugins/qmljseditor/qmljswrapinloader.cpp index e1887bf2cd..2673429a20 100644 --- a/src/plugins/qmljseditor/qmljswrapinloader.cpp +++ b/src/plugins/qmljseditor/qmljswrapinloader.cpp @@ -33,7 +33,7 @@ #include "qmljswrapinloader.h" #include "qmljsquickfixassist.h" -#include +#include #include #include diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index ee168a0878..4a238d5b8d 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -33,7 +33,7 @@ #include "qmltaskmanager.h" #include "qmljseditorconstants.h" -#include +#include #include #include #include diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 8a9912c494..f499111533 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -438,7 +438,7 @@ void InspectorUi::serverReloaded() void InspectorUi::removePreviewForEditor(Core::IEditor *oldEditor) { - if (QmlJSLiveTextPreview *preview = m_textPreviews.value(oldEditor->file()->fileName())) { + if (QmlJSLiveTextPreview *preview = m_textPreviews.value(oldEditor->document()->fileName())) { preview->unassociateEditor(oldEditor); } } @@ -453,7 +453,7 @@ QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEdit && newEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID ) { - QString filename = newEditor->file()->fileName(); + QString filename = newEditor->document()->fileName(); QmlJS::Document::Ptr doc = modelManager()->snapshot().document(filename); if (!doc) { if (filename.endsWith(".qml")) { @@ -482,7 +482,7 @@ QmlJSLiveTextPreview *InspectorUi::createPreviewForEditor(Core::IEditor *newEdit m_clientProxy, SLOT(reloadQmlViewer())); connect(preview, SIGNAL(disableLivePreviewRequested()), SLOT(disableLivePreview())); - m_textPreviews.insert(newEditor->file()->fileName(), preview); + m_textPreviews.insert(newEditor->document()->fileName(), preview); preview->associateEditor(newEditor); preview->updateDebugIds(); } diff --git a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp index dee2e8a435..17eed26cde 100644 --- a/src/plugins/qmljsinspector/qmljslivetextpreview.cpp +++ b/src/plugins/qmljsinspector/qmljslivetextpreview.cpp @@ -576,7 +576,7 @@ void QmlJSLiveTextPreview::showExperimentalWarning() tr("You changed a QML file in Live Preview mode, which modifies the running QML application. " "In case of unexpected behavior, please reload the QML application.")); info.setCustomButtonInfo(tr("Disable Live Preview"), this, SLOT(disableLivePreview())); - editor.data()->file()->infoBar()->addInfo(info); + editor.data()->editorDocument()->infoBar()->addInfo(info); } } @@ -602,7 +602,7 @@ void QmlJSLiveTextPreview::showSyncWarning(UnsyncronizableChangeType unsyncroniz foreach (QWeakPointer editor, m_editors) if (editor) - editor.data()->file()->infoBar()->addInfo(Core::InfoBarEntry( + editor.data()->editorDocument()->infoBar()->addInfo(Core::InfoBarEntry( QLatin1String(Constants::INFO_OUT_OF_SYNC), errorMessage)); } @@ -610,7 +610,7 @@ void QmlJSLiveTextPreview::reloadQmlViewer() { foreach (QWeakPointer editor, m_editors) if (editor) - editor.data()->file()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC); + editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC); emit reloadQmlViewerRequested(); } @@ -618,7 +618,7 @@ void QmlJSLiveTextPreview::disableLivePreview() { foreach (QWeakPointer editor, m_editors) if (editor) - editor.data()->file()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC); + editor.data()->editorDocument()->infoBar()->removeInfo(Constants::INFO_OUT_OF_SYNC); emit disableLivePreviewRequested(); } diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index e7e5346dee..35f141539a 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -209,7 +209,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopy() const return workingCopy; foreach (Core::IEditor *editor, Core::ICore::editorManager()->openedEditors()) { - const QString key = editor->file()->fileName(); + const QString key = editor->document()->fileName(); if (TextEditor::ITextEditor *textEditor = qobject_cast(editor)) { if (textEditor->context().contains(ProjectExplorer::Constants::LANG_QMLJS)) { diff --git a/src/plugins/qmljstools/qmljstoolsplugin.cpp b/src/plugins/qmljstools/qmljstoolsplugin.cpp index f395e23630..0b139f031a 100644 --- a/src/plugins/qmljstools/qmljstoolsplugin.cpp +++ b/src/plugins/qmljstools/qmljstoolsplugin.cpp @@ -84,7 +84,7 @@ bool QmlJSToolsPlugin::initialize(const QStringList &arguments, QString *error) // Objects m_modelManager = new ModelManager(this); // Core::VCSManager *vcsManager = core->vcsManager(); -// Core::FileManager *fileManager = core->fileManager(); +// Core::DocumentManager *fileManager = core->fileManager(); // connect(vcsManager, SIGNAL(repositoryChanged(QString)), // m_modelManager, SLOT(updateModifiedSourceFiles())); // connect(fileManager, SIGNAL(filesChangedInternally(QStringList)), diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index 64b84d90dc..89efc17182 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -42,7 +42,7 @@ #include #include -#include +#include #include #include #include @@ -72,7 +72,7 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName) m_file = new Internal::QmlProjectFile(this, fileName); m_rootNode = new Internal::QmlProjectNode(this, m_file); - Core::FileManager::addFile(m_file, true); + Core::DocumentManager::addDocument(m_file, true); m_manager->registerProject(this); } @@ -81,7 +81,7 @@ QmlProject::~QmlProject() { m_manager->unregisterProject(this); - Core::FileManager::removeFile(m_file); + Core::DocumentManager::removeDocument(m_file); delete m_projectItem.data(); delete m_rootNode; @@ -89,7 +89,7 @@ QmlProject::~QmlProject() QDir QmlProject::projectDir() const { - return QFileInfo(file()->fileName()).dir(); + return QFileInfo(document()->fileName()).dir(); } QString QmlProject::filesFileName() const @@ -262,7 +262,7 @@ QString QmlProject::id() const return QLatin1String("QmlProjectManager.QmlProject"); } -Core::IFile *QmlProject::file() const +Core::IDocument *QmlProject::document() const { return m_file; } diff --git a/src/plugins/qmlprojectmanager/qmlproject.h b/src/plugins/qmlprojectmanager/qmlproject.h index 0787ec97f7..1d70f3025f 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.h +++ b/src/plugins/qmlprojectmanager/qmlproject.h @@ -70,7 +70,7 @@ public: QString displayName() const; QString id() const; - Core::IFile *file() const; + Core::IDocument *document() const; ProjectExplorer::IProjectManager *projectManager() const; Internal::QmlProjectTarget *activeTarget() const; diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp index af3ca30f86..706e39c4cb 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp @@ -39,7 +39,7 @@ namespace QmlProjectManager { namespace Internal { QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName) - : Core::IFile(parent), + : Core::IDocument(parent), m_project(parent), m_fileName(fileName) { @@ -93,7 +93,7 @@ bool QmlProjectFile::isSaveAsAllowed() const return false; } -Core::IFile::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.h b/src/plugins/qmlprojectmanager/qmlprojectfile.h index deb117d9f0..13fdb0acde 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectfile.h +++ b/src/plugins/qmlprojectmanager/qmlprojectfile.h @@ -33,7 +33,7 @@ #ifndef QMLPROJECTFILE_H #define QMLPROJECTFILE_H -#include +#include namespace QmlProjectManager { @@ -41,7 +41,7 @@ class QmlProject; namespace Internal { -class QmlProjectFile : public Core::IFile +class QmlProjectFile : public Core::IDocument { Q_OBJECT diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.cpp b/src/plugins/qmlprojectmanager/qmlprojectmanager.cpp index 910e99049e..ba40e9c4ba 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.cpp @@ -35,7 +35,7 @@ #include "qmlproject.h" #include -#include +#include #include #include #include @@ -58,7 +58,7 @@ ProjectExplorer::Project *Manager::openProject(const QString &fileName, QString ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) { - if (fileName == pi->file()->fileName()) { + if (fileName == pi->document()->fileName()) { if (errorString) *errorString = tr("Failed opening project '%1': Project already open") .arg(QDir::toNativeSeparators(fileName)); return 0; diff --git a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp index f40a20f069..33ef5b669a 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectnodes.cpp @@ -34,7 +34,7 @@ #include "qmlprojectmanager.h" #include "qmlproject.h" -#include +#include #include #include @@ -46,7 +46,7 @@ namespace QmlProjectManager { namespace Internal { -QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IFile *projectFile) +QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IDocument *projectFile) : ProjectExplorer::ProjectNode(QFileInfo(projectFile->fileName()).absoluteFilePath()), m_project(project), m_projectFile(projectFile) @@ -64,7 +64,7 @@ QmlProjectNode::QmlProjectNode(QmlProject *project, Core::IFile *projectFile) QmlProjectNode::~QmlProjectNode() { } -Core::IFile *QmlProjectNode::projectFile() const +Core::IDocument *QmlProjectNode::projectFile() const { return m_projectFile; } QString QmlProjectNode::projectFilePath() const diff --git a/src/plugins/qmlprojectmanager/qmlprojectnodes.h b/src/plugins/qmlprojectmanager/qmlprojectnodes.h index fdcb6e127c..d9b7502f7f 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectnodes.h +++ b/src/plugins/qmlprojectmanager/qmlprojectnodes.h @@ -39,7 +39,7 @@ #include namespace Core { -class IFile; +class IDocument; } namespace QmlProjectManager { @@ -51,10 +51,10 @@ namespace Internal { class QmlProjectNode : public ProjectExplorer::ProjectNode { public: - QmlProjectNode(QmlProject *project, Core::IFile *projectFile); + QmlProjectNode(QmlProject *project, Core::IDocument *projectFile); virtual ~QmlProjectNode(); - Core::IFile *projectFile() const; + Core::IDocument *projectFile() const; QString projectFilePath() const; virtual bool hasBuildTargets() const; @@ -91,7 +91,7 @@ private: private: QmlProject *m_project; - Core::IFile *m_projectFile; + Core::IDocument *m_projectFile; QHash m_folderByName; }; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 0d1b1f33d9..d2f2384ff4 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -165,7 +165,7 @@ QString QmlProjectRunConfiguration::viewerArguments() const QString QmlProjectRunConfiguration::workingDirectory() const { - QFileInfo projectFile(qmlTarget()->qmlProject()->file()->fileName()); + QFileInfo projectFile(qmlTarget()->qmlProject()->document()->fileName()); return canonicalCapsPath(projectFile.absolutePath()); } @@ -321,7 +321,7 @@ bool QmlProjectRunConfiguration::fromMap(const QVariantMap &map) void QmlProjectRunConfiguration::changeCurrentFile(Core::IEditor *editor) { if (editor) { - m_currentFileFilename = editor->file()->fileName(); + m_currentFileFilename = editor->document()->fileName(); } updateEnabled(); } @@ -333,7 +333,7 @@ void QmlProjectRunConfiguration::updateEnabled() Core::IEditor *editor = Core::EditorManager::instance()->currentEditor(); Core::MimeDatabase *db = ICore::mimeDatabase(); if (editor) { - m_currentFileFilename = editor->file()->fileName(); + m_currentFileFilename = editor->document()->fileName(); if (db->findByFile(mainScript()).type() == QLatin1String("application/x-qml")) qmlFileFound = true; } diff --git a/src/plugins/qt4projectmanager/profilecompletionassist.cpp b/src/plugins/qt4projectmanager/profilecompletionassist.cpp index a6a1d8c99f..c1a6c3add6 100644 --- a/src/plugins/qt4projectmanager/profilecompletionassist.cpp +++ b/src/plugins/qt4projectmanager/profilecompletionassist.cpp @@ -205,7 +205,7 @@ int ProFileCompletionAssistProcessor::findStartOfName(int pos) const bool ProFileCompletionAssistProcessor::isInComment() const { - QTextCursor tc(m_interface->document()); + QTextCursor tc(m_interface->textDocument()); tc.setPosition(m_interface->position()); tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); const QString &lineBeginning = tc.selectedText(); diff --git a/src/plugins/qt4projectmanager/profileeditor.cpp b/src/plugins/qt4projectmanager/profileeditor.cpp index 239b20dd24..25dfee554b 100644 --- a/src/plugins/qt4projectmanager/profileeditor.cpp +++ b/src/plugins/qt4projectmanager/profileeditor.cpp @@ -172,7 +172,7 @@ ProFileEditorWidget::Link ProFileEditorWidget::findLinkAt(const QTextCursor &cur } } - QDir dir(QFileInfo(file()->fileName()).absolutePath()); + QDir dir(QFileInfo(editorDocument()->fileName()).absolutePath()); QString fileName = dir.filePath(buffer); QFileInfo fi(fileName); if (fi.exists()) { diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.cpp b/src/plugins/qt4projectmanager/profileeditorfactory.cpp index 0366de390f..20dea31896 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.cpp +++ b/src/plugins/qt4projectmanager/profileeditorfactory.cpp @@ -78,10 +78,10 @@ QString ProFileEditorFactory::displayName() const return tr(Qt4ProjectManager::Constants::PROFILE_EDITOR_DISPLAY_NAME); } -Core::IFile *ProFileEditorFactory::open(const QString &fileName) +Core::IDocument *ProFileEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *ProFileEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/qt4projectmanager/profileeditorfactory.h b/src/plugins/qt4projectmanager/profileeditorfactory.h index e89d759dd2..5c9d3ff604 100644 --- a/src/plugins/qt4projectmanager/profileeditorfactory.h +++ b/src/plugins/qt4projectmanager/profileeditorfactory.h @@ -59,7 +59,7 @@ public: QStringList mimeTypes() const; Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); Qt4Manager *qt4ProjectManager() const { return m_manager; } diff --git a/src/plugins/qt4projectmanager/qmakestep.cpp b/src/plugins/qt4projectmanager/qmakestep.cpp index 0a99e24105..30bf73e05d 100644 --- a/src/plugins/qt4projectmanager/qmakestep.cpp +++ b/src/plugins/qt4projectmanager/qmakestep.cpp @@ -131,9 +131,9 @@ QString QMakeStep::allArguments(bool shorted) if (bc->subNodeBuild()) arguments << QDir::toNativeSeparators(bc->subNodeBuild()->path()); else if (shorted) - arguments << QDir::toNativeSeparators(QFileInfo(project()->file()->fileName()).fileName()); + arguments << QDir::toNativeSeparators(QFileInfo(project()->document()->fileName()).fileName()); else - arguments << QDir::toNativeSeparators(project()->file()->fileName()); + arguments << QDir::toNativeSeparators(project()->document()->fileName()); arguments << QLatin1String("-r"); bool userProvidedMkspec = false; diff --git a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp index ac1cf7f906..ffe6f0e37d 100644 --- a/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt-desktop/qt4runconfiguration.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp index 92a72eb474..b522ec2050 100644 --- a/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp +++ b/src/plugins/qt4projectmanager/qt4buildconfiguration.cpp @@ -235,7 +235,7 @@ QString Qt4BuildConfiguration::defaultShadowBuildDirectory() const { Qt4BaseTargetFactory *factory = Qt4BaseTargetFactory::qt4BaseTargetFactoryForId(qt4Target()->id()); // todo displayName isn't ideal - return factory->shadowBuildDirectory(qt4Target()->qt4Project()->file()->fileName(), qt4Target()->id(), displayName()); + return factory->shadowBuildDirectory(qt4Target()->qt4Project()->document()->fileName(), qt4Target()->id(), displayName()); } /// returns the unexpanded build directory diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp index 93b1a5596e..766519ee10 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.cpp +++ b/src/plugins/qt4projectmanager/qt4nodes.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -166,7 +166,7 @@ using namespace Qt4ProjectManager; using namespace Qt4ProjectManager::Internal; Qt4PriFile::Qt4PriFile(Qt4ProjectManager::Qt4PriFileNode *qt4PriFile) - : IFile(qt4PriFile), m_priFile(qt4PriFile) + : IDocument(qt4PriFile), m_priFile(qt4PriFile) { } @@ -216,7 +216,7 @@ bool Qt4PriFile::isSaveAsAllowed() const return false; } -Core::IFile::ReloadBehavior Qt4PriFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior Qt4PriFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) @@ -250,7 +250,7 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo { Q_ASSERT(project); m_qt4PriFile = new Qt4PriFile(this); - Core::FileManager::addFile(m_qt4PriFile); + Core::DocumentManager::addDocument(m_qt4PriFile); setDisplayName(QFileInfo(filePath).completeBaseName()); @@ -1004,14 +1004,14 @@ bool Qt4PriFileNode::priFileWritable(const QString &path) { const QString dir = QFileInfo(path).dir().path(); Core::IVersionControl *versionControl = Core::ICore::vcsManager()->findVersionControlForDirectory(dir); - switch (Core::FileManager::promptReadOnlyFile(path, versionControl, Core::ICore::mainWindow(), false)) { - case Core::FileManager::RO_OpenVCS: + switch (Core::DocumentManager::promptReadOnlyFile(path, versionControl, Core::ICore::mainWindow(), false)) { + case Core::DocumentManager::RO_OpenVCS: if (!versionControl->vcsOpen(path)) { QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Open File"), tr("Cannot open the file for editing with VCS.")); return false; } break; - case Core::FileManager::RO_MakeWriteable: { + case Core::DocumentManager::RO_MakeWriteable: { const bool permsOk = QFile::setPermissions(path, QFile::permissions(path) | QFile::WriteUser); if (!permsOk) { QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set Permissions"), tr("Cannot set permissions to writable.")); @@ -1019,8 +1019,8 @@ bool Qt4PriFileNode::priFileWritable(const QString &path) } break; } - case Core::FileManager::RO_SaveAs: - case Core::FileManager::RO_Cancel: + case Core::DocumentManager::RO_SaveAs: + case Core::DocumentManager::RO_Cancel: return false; } return true; @@ -1028,18 +1028,18 @@ bool Qt4PriFileNode::priFileWritable(const QString &path) bool Qt4PriFileNode::saveModifiedEditors() { - QList modifiedFileHandles; + QList modifiedDocuments; foreach (Core::IEditor *editor, Core::ICore::editorManager()->editorsForFileName(m_projectFilePath)) { - if (Core::IFile *editorFile = editor->file()) { - if (editorFile->isModified()) - modifiedFileHandles << editorFile; + if (Core::IDocument *editorDocument = editor->document()) { + if (editorDocument->isModified()) + modifiedDocuments << editorDocument; } } - if (!modifiedFileHandles.isEmpty()) { + if (!modifiedDocuments.isEmpty()) { bool cancelled; - Core::FileManager::saveModifiedFiles(modifiedFileHandles, &cancelled, + Core::DocumentManager::saveModifiedDocuments(modifiedDocuments, &cancelled, tr("There are unsaved changes for project file %1.").arg(m_projectFilePath)); if (cancelled) return false; @@ -1146,9 +1146,9 @@ void Qt4PriFileNode::changeFiles(const FileType fileType, } // save file - Core::FileManager::expectFileChange(m_projectFilePath); + Core::DocumentManager::expectFileChange(m_projectFilePath); save(lines); - Core::FileManager::unexpectFileChange(m_projectFilePath); + Core::DocumentManager::unexpectFileChange(m_projectFilePath); // This is a hack. // We are saving twice in a very short timeframe, once the editor and once the ProFile. @@ -1157,9 +1157,9 @@ void Qt4PriFileNode::changeFiles(const FileType fileType, // (The .pro files are notified by the file system watcher.) QStringList errorStrings; foreach (Core::IEditor *editor, Core::ICore::editorManager()->editorsForFileName(m_projectFilePath)) { - if (Core::IFile *editorFile = editor->file()) { + if (Core::IDocument *editorDocument= editor->document()) { QString errorString; - if (!editorFile->reload(&errorString, Core::IFile::FlagReload, Core::IFile::TypeContents)) + if (!editorDocument->reload(&errorString, Core::IDocument::FlagReload, Core::IDocument::TypeContents)) errorStrings << errorString; } } diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h index d2474f035a..dfaec5e67b 100644 --- a/src/plugins/qt4projectmanager/qt4nodes.h +++ b/src/plugins/qt4projectmanager/qt4nodes.h @@ -36,7 +36,7 @@ #include "qt4projectmanager_global.h" #include -#include +#include #include #include @@ -219,7 +219,7 @@ private: }; namespace Internal { -class Qt4PriFile : public Core::IFile +class Qt4PriFile : public Core::IDocument { Q_OBJECT public: diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 0f57d95097..fffc3171ea 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -43,7 +43,7 @@ #include "findqt4profiles.h" #include -#include +#include #include #include #include @@ -81,7 +81,7 @@ enum { debug = 0 }; namespace Qt4ProjectManager { namespace Internal { -class Qt4ProjectFile : public Core::IFile +class Qt4ProjectFile : public Core::IDocument { Q_OBJECT @@ -237,7 +237,7 @@ void ProjectFilesVisitor::visitFolderNode(FolderNode *folderNode) // ----------- Qt4ProjectFile namespace Internal { Qt4ProjectFile::Qt4ProjectFile(Qt4Project *project, const QString &filePath, QObject *parent) - : Core::IFile(parent), + : Core::IDocument(parent), m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)), m_project(project), m_filePath(filePath) @@ -287,7 +287,7 @@ bool Qt4ProjectFile::isSaveAsAllowed() const return false; } -Core::IFile::ReloadBehavior Qt4ProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior Qt4ProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) @@ -853,7 +853,7 @@ Qt4Manager *Qt4Project::qt4ProjectManager() const QString Qt4Project::displayName() const { - return QFileInfo(file()->fileName()).completeBaseName(); + return QFileInfo(document()->fileName()).completeBaseName(); } QString Qt4Project::id() const @@ -861,7 +861,7 @@ QString Qt4Project::id() const return QLatin1String(Constants::QT4PROJECT_ID); } -Core::IFile *Qt4Project::file() const +Core::IDocument *Qt4Project::document() const { return m_fileInfo; } diff --git a/src/plugins/qt4projectmanager/qt4project.h b/src/plugins/qt4projectmanager/qt4project.h index 3b90ec039e..4b57c4f1e5 100644 --- a/src/plugins/qt4projectmanager/qt4project.h +++ b/src/plugins/qt4projectmanager/qt4project.h @@ -89,13 +89,13 @@ public: QString displayName() const; QString id() const; - Core::IFile *file() const; + Core::IDocument *document() const; ProjectExplorer::IProjectManager *projectManager() const; Qt4Manager *qt4ProjectManager() const; Qt4BaseTarget *activeTarget() const; - QList dependencies(); //NBS remove + QList dependencies(); //NBS remove QListdependsOn(); ProjectExplorer::ProjectNode *rootProjectNode() const; diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 614f109150..990d134d33 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -43,7 +43,7 @@ #include "ui_qt4projectconfigwidget.h" #include -#include +#include #include #include @@ -362,7 +362,7 @@ void Qt4ProjectConfigWidget::updateImportLabel() if (!qmakePath.isEmpty()) { // Is it from the same build? QtSupport::QtVersionManager::MakefileCompatible mc = - QtSupport::QtVersionManager::makefileIsFor(makefile, m_buildConfiguration->target()->project()->file()->fileName()); + QtSupport::QtVersionManager::makefileIsFor(makefile, m_buildConfiguration->target()->project()->document()->fileName()); if (mc == QtSupport::QtVersionManager::DifferentProject) { incompatibleBuild = true; } else if (mc == QtSupport::QtVersionManager::SameProject) { @@ -395,11 +395,11 @@ void Qt4ProjectConfigWidget::updateImportLabel() buildDirectory = m_buildConfiguration->buildDirectory(); QList issues; if (QtSupport::BaseQtVersion *version = m_buildConfiguration->qtVersion()) { - issues = version->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(), + issues = version->reportIssues(m_buildConfiguration->target()->project()->document()->fileName(), buildDirectory); foreach (Qt4BaseTargetFactory *factory, Qt4BaseTargetFactory::qt4BaseTargetFactoriesForIds(version->supportedTargetIds().toList())) - issues.append(factory->reportIssues(m_buildConfiguration->target()->project()->file()->fileName())); + issues.append(factory->reportIssues(m_buildConfiguration->target()->project()->document()->fileName())); qSort(issues); } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 7671a3baf1..033c9188e9 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -162,7 +162,7 @@ void Qt4Manager::editorChanged(Core::IEditor *editor) if (m_dirty) { const QString contents = formWindowEditorContents(m_lastEditor); foreach(Qt4Project *project, m_projects) - project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents); + project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); m_dirty = false; } } @@ -184,7 +184,7 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor) if (m_dirty) { const QString contents = formWindowEditorContents(m_lastEditor); foreach(Qt4Project *project, m_projects) - project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->file()->fileName(), contents); + project->rootQt4ProjectNode()->updateCodeModelSupportFromEditor(m_lastEditor->document()->fileName(), contents); m_dirty = false; } } @@ -263,7 +263,7 @@ ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName, QStri } foreach (ProjectExplorer::Project *pi, projectExplorer()->session()->projects()) { - if (canonicalFilePath == pi->file()->fileName()) { + if (canonicalFilePath == pi->document()->fileName()) { if (errorString) *errorString = tr("Failed opening project '%1': Project already open").arg(QDir::toNativeSeparators(canonicalFilePath)); return 0; @@ -309,7 +309,7 @@ void Qt4Manager::addLibrary() Core::EditorManager *em = Core::EditorManager::instance(); ProFileEditorWidget *editor = qobject_cast(em->currentEditor()->widget()); if (editor) - addLibrary(editor->file()->fileName(), editor); + addLibrary(editor->editorDocument()->fileName(), editor); } void Qt4Manager::addLibraryContextMenu() diff --git a/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp b/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp index 9cb6f5f541..67ce94b194 100644 --- a/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp +++ b/src/plugins/qt4projectmanager/unconfiguredprojectpanel.cpp @@ -37,7 +37,7 @@ #include "qt4project.h" #include "qt4projectmanager.h" -#include +#include #include #include #include @@ -107,7 +107,7 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(ProjectExplorer::Project *project m_targetSetupPage = new TargetSetupPage(this); m_targetSetupPage->setUseScrollArea(false); m_targetSetupPage->setImportSearch(true); - m_targetSetupPage->setProFilePath(project->file()->fileName()); + m_targetSetupPage->setProFilePath(project->document()->fileName()); m_targetSetupPage->initializePage(); m_targetSetupPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); updateNoteText(); diff --git a/src/plugins/remotelinux/deploymentsettingsassistant.cpp b/src/plugins/remotelinux/deploymentsettingsassistant.cpp index 330e9e3e70..23270136a0 100644 --- a/src/plugins/remotelinux/deploymentsettingsassistant.cpp +++ b/src/plugins/remotelinux/deploymentsettingsassistant.cpp @@ -35,7 +35,7 @@ #include "deployablefilesperprofile.h" #include "profilesupdatedialog.h" -#include +#include #include #include #include diff --git a/src/plugins/resourceeditor/resourceeditorfactory.cpp b/src/plugins/resourceeditor/resourceeditorfactory.cpp index 85c64688d4..30f25de2e4 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.cpp +++ b/src/plugins/resourceeditor/resourceeditorfactory.cpp @@ -64,14 +64,14 @@ QString ResourceEditorFactory::displayName() const return tr(C_RESOURCEEDITOR_DISPLAY_NAME); } -Core::IFile *ResourceEditorFactory::open(const QString &fileName) +Core::IDocument *ResourceEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); if (!iface) { qWarning() << "ResourceEditorFactory::open: openEditor failed for " << fileName; return 0; } - return iface->file(); + return iface->document(); } Core::IEditor *ResourceEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/resourceeditor/resourceeditorfactory.h b/src/plugins/resourceeditor/resourceeditorfactory.h index 376232c1bd..54dc1b5cfd 100644 --- a/src/plugins/resourceeditor/resourceeditorfactory.h +++ b/src/plugins/resourceeditor/resourceeditorfactory.h @@ -55,7 +55,7 @@ public: // IEditorFactory Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp index 85d415cd7f..cdd3af193d 100644 --- a/src/plugins/resourceeditor/resourceeditorw.cpp +++ b/src/plugins/resourceeditor/resourceeditorw.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include @@ -57,8 +57,8 @@ enum { debugResourceEditorW = 0 }; -ResourceEditorFile::ResourceEditorFile(ResourceEditorW *parent) : - IFile(parent), +ResourceEditorDocument::ResourceEditorDocument(ResourceEditorW *parent) : + IDocument(parent), m_mimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE)), m_parent(parent) { @@ -66,7 +66,7 @@ ResourceEditorFile::ResourceEditorFile(ResourceEditorW *parent) : qDebug() << "ResourceEditorFile::ResourceEditorFile()"; } -QString ResourceEditorFile::mimeType() const +QString ResourceEditorDocument::mimeType() const { return m_mimeType; } @@ -76,7 +76,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, ResourceEditorPlugin *plugin, QWidget *parent) : m_resourceEditor(new SharedTools::QrcEditor(parent)), - m_resourceFile(new ResourceEditorFile(this)), + m_resourceDocument(new ResourceEditorDocument(this)), m_plugin(plugin), m_shouldAutoSave(false), m_diskIo(false), @@ -92,7 +92,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, // (That is because this editor instance is deleted in executeOpenWithMenuAction // in that case.) connect(m_openWithMenu, SIGNAL(triggered(QAction*)), - Core::FileManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)), + Core::DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)), Qt::QueuedConnection); connect(m_resourceEditor, SIGNAL(dirtyChanged(bool)), this, SLOT(dirtyChanged(bool))); @@ -102,7 +102,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context, this, SLOT(showContextMenu(QPoint,QString))); connect(m_resourceEditor->commandHistory(), SIGNAL(indexChanged(int)), this, SLOT(setShouldAutoSave())); - connect(m_resourceFile, SIGNAL(changed()), this, SIGNAL(changed())); + connect(m_resourceDocument, SIGNAL(changed()), this, SIGNAL(changed())); if (debugResourceEditorW) qDebug() << "ResourceEditorW::ResourceEditorW()"; } @@ -158,7 +158,7 @@ bool ResourceEditorW::open(QString *errorString, const QString &fileName, const return true; } -bool ResourceEditorFile::save(QString *errorString, const QString &name, bool autoSave) +bool ResourceEditorDocument::save(QString *errorString, const QString &name, bool autoSave) { if (debugResourceEditorW) qDebug(">ResourceEditorW::save: %s", qPrintable(name)); @@ -192,7 +192,7 @@ bool ResourceEditorFile::save(QString *errorString, const QString &name, bool au return true; } -void ResourceEditorFile::rename(const QString &newName) +void ResourceEditorDocument::rename(const QString &newName) { m_parent->m_resourceEditor->setFileName(newName); emit changed(); @@ -203,27 +203,27 @@ Core::Id ResourceEditorW::id() const return Core::Id(ResourceEditor::Constants::RESOURCEEDITOR_ID); } -QString ResourceEditorFile::fileName() const +QString ResourceEditorDocument::fileName() const { return m_parent->m_resourceEditor->fileName(); } -bool ResourceEditorFile::shouldAutoSave() const +bool ResourceEditorDocument::shouldAutoSave() const { return m_parent->m_shouldAutoSave; } -bool ResourceEditorFile::isModified() const +bool ResourceEditorDocument::isModified() const { return m_parent->m_resourceEditor->isDirty(); } -bool ResourceEditorFile::isSaveAsAllowed() const +bool ResourceEditorDocument::isSaveAsAllowed() const { return true; } -bool ResourceEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) +bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type) { if (flag == FlagIgnore) return true; @@ -239,7 +239,7 @@ bool ResourceEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeTyp return true; } -QString ResourceEditorFile::defaultPath() const +QString ResourceEditorDocument::defaultPath() const { return QString(); } @@ -249,7 +249,7 @@ void ResourceEditorW::setSuggestedFileName(const QString &fileName) m_suggestedName = fileName; } -QString ResourceEditorFile::suggestedFileName() const +QString ResourceEditorDocument::suggestedFileName() const { return m_parent->m_suggestedName; } @@ -271,7 +271,7 @@ void ResourceEditorW::onUndoStackChanged(bool canUndo, bool canRedo) void ResourceEditorW::showContextMenu(const QPoint &globalPoint, const QString &fileName) { - Core::FileManager::populateOpenWithMenu(m_openWithMenu, fileName); + Core::DocumentManager::populateOpenWithMenu(m_openWithMenu, fileName); if (!m_openWithMenu->actions().isEmpty()) m_contextMenu->popup(globalPoint); } diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h index 55ce8a3e6c..d74a97711d 100644 --- a/src/plugins/resourceeditor/resourceeditorw.h +++ b/src/plugins/resourceeditor/resourceeditorw.h @@ -33,7 +33,7 @@ #ifndef RESOURCEDITORW_H #define RESOURCEDITORW_H -#include +#include #include #include @@ -52,15 +52,15 @@ namespace Internal { class ResourceEditorPlugin; class ResourceEditorW; -class ResourceEditorFile - : public virtual Core::IFile +class ResourceEditorDocument + : public virtual Core::IDocument { Q_OBJECT public: - ResourceEditorFile(ResourceEditorW *parent = 0); + ResourceEditorDocument(ResourceEditorW *parent = 0); - //IFile + //IDocument bool save(QString *errorString, const QString &fileName, bool autoSave); QString fileName() const; bool shouldAutoSave() const; @@ -92,7 +92,7 @@ public: bool open(QString *errorString, const QString &fileName, const QString &realFileName); bool duplicateSupported() const { return false; } Core::IEditor *duplicate(QWidget *) { return 0; } - Core::IFile *file() { return m_resourceFile; } + Core::IDocument *document() { return m_resourceDocument; } Core::Id id() const; QString displayName() const { return m_displayName; } void setDisplayName(const QString &title) { m_displayName = title; emit changed(); } @@ -115,7 +115,7 @@ private: QString m_displayName; QString m_suggestedName; QPointer m_resourceEditor; - ResourceEditorFile *m_resourceFile; + ResourceEditorDocument *m_resourceDocument; ResourceEditorPlugin *m_plugin; bool m_shouldAutoSave; bool m_diskIo; @@ -126,7 +126,7 @@ public: void onUndo(); void onRedo(); - friend class ResourceEditorFile; + friend class ResourceEditorDocument; }; } // namespace Internal diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 326b145f6c..2e63152bca 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -51,7 +51,7 @@ #include #include -#include +#include #include #include #include @@ -477,14 +477,14 @@ bool SubversionPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *su if (!isCommitEditorOpen()) return true; - Core::IFile *fileIFace = submitEditor->file(); + Core::IDocument *editorDocument = submitEditor->document(); const SubversionSubmitEditor *editor = qobject_cast(submitEditor); - if (!fileIFace || !editor) + if (!editorDocument || !editor) return true; // Submit editor closing. Make it write out the commit message // and retrieve files - const QFileInfo editorFile(fileIFace->fileName()); + const QFileInfo editorFile(editorDocument->fileName()); const QFileInfo changeFile(m_commitMessageFileName); if (editorFile.absoluteFilePath() != changeFile.absoluteFilePath()) return true; // Oops?! @@ -512,7 +512,7 @@ bool SubversionPlugin::submitEditorAboutToClose(VcsBase::VcsBaseSubmitEditor *su bool closeEditor = true; if (!fileList.empty()) { // get message & commit - closeEditor = Core::FileManager::saveFile(fileIFace); + closeEditor = Core::DocumentManager::saveDocument(editorDocument); if (closeEditor) closeEditor = commit(m_commitMessageFileName, fileList); } diff --git a/src/plugins/tasklist/taskfile.cpp b/src/plugins/tasklist/taskfile.cpp index 186dd5f9bd..0cb197e92b 100644 --- a/src/plugins/tasklist/taskfile.cpp +++ b/src/plugins/tasklist/taskfile.cpp @@ -41,7 +41,7 @@ using namespace TaskList::Internal; // TaskFile // -------------------------------------------------------------------------- -TaskFile::TaskFile(QObject *parent) : Core::IFile(parent), +TaskFile::TaskFile(QObject *parent) : Core::IDocument(parent), m_context(0) { } @@ -86,7 +86,7 @@ bool TaskFile::isSaveAsAllowed() const return false; } -Core::IFile::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state); Q_UNUSED(type); diff --git a/src/plugins/tasklist/taskfile.h b/src/plugins/tasklist/taskfile.h index 135e9e4bb1..59b5b2e109 100644 --- a/src/plugins/tasklist/taskfile.h +++ b/src/plugins/tasklist/taskfile.h @@ -33,7 +33,7 @@ #ifndef TASKFILE_H #define TASKFILE_H -#include +#include namespace ProjectExplorer { class Project; @@ -42,7 +42,7 @@ class Project; namespace TaskList { namespace Internal { -class TaskFile : public Core::IFile +class TaskFile : public Core::IDocument { public: TaskFile(QObject *parent); diff --git a/src/plugins/tasklist/taskfilefactory.cpp b/src/plugins/tasklist/taskfilefactory.cpp index 3bdcb8be11..1d33158b5c 100644 --- a/src/plugins/tasklist/taskfilefactory.cpp +++ b/src/plugins/tasklist/taskfilefactory.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -49,7 +49,7 @@ using namespace TaskList::Internal; // -------------------------------------------------------------------------- TaskFileFactory::TaskFileFactory(QObject * parent) : - Core::IFileFactory(parent), + Core::IDocumentFactory(parent), m_mimeTypes(QStringList() << QLatin1String("text/x-tasklist")) { } @@ -71,13 +71,13 @@ QString TaskFileFactory::displayName() const return tr("Task file reader"); } -Core::IFile *TaskFileFactory::open(const QString &fileName) +Core::IDocument *TaskFileFactory::open(const QString &fileName) { ProjectExplorer::Project *context = ProjectExplorer::ProjectExplorerPlugin::currentProject(); return open(context, fileName); } -Core::IFile *TaskFileFactory::open(ProjectExplorer::Project *context, const QString &fileName) +Core::IDocument *TaskFileFactory::open(ProjectExplorer::Project *context, const QString &fileName) { TaskFile *file = new TaskFile(this); file->setContext(context); @@ -92,14 +92,14 @@ Core::IFile *TaskFileFactory::open(ProjectExplorer::Project *context, const QStr m_openFiles.append(file); // Register with filemanager: - Core::FileManager::addFile(file); + Core::DocumentManager::addDocument(file); return file; } void TaskFileFactory::closeAllFiles() { - foreach(Core::IFile *file, m_openFiles) - file->deleteLater(); + foreach (Core::IDocument *document, m_openFiles) + document->deleteLater(); m_openFiles.clear(); } diff --git a/src/plugins/tasklist/taskfilefactory.h b/src/plugins/tasklist/taskfilefactory.h index 857ec455fd..3c60b2682c 100644 --- a/src/plugins/tasklist/taskfilefactory.h +++ b/src/plugins/tasklist/taskfilefactory.h @@ -33,8 +33,8 @@ #ifndef TASKFILEFACTORY_H #define TASKFILEFACTORY_H -#include -#include +#include +#include #include @@ -45,7 +45,7 @@ class Project; namespace TaskList { namespace Internal { -class TaskFileFactory : public Core::IFileFactory +class TaskFileFactory : public Core::IDocumentFactory { Q_OBJECT public: @@ -57,14 +57,14 @@ public: Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); - Core::IFile *open(ProjectExplorer::Project *context, const QString &fileName); + Core::IDocument *open(const QString &fileName); + Core::IDocument *open(ProjectExplorer::Project *context, const QString &fileName); void closeAllFiles(); private: QStringList m_mimeTypes; - QList m_openFiles; + QList m_openFiles; }; } // namespace Internal diff --git a/src/plugins/texteditor/basefilefind.cpp b/src/plugins/texteditor/basefilefind.cpp index 3a328c6183..18422609ae 100644 --- a/src/plugins/texteditor/basefilefind.cpp +++ b/src/plugins/texteditor/basefilefind.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -180,7 +180,7 @@ void BaseFileFind::doReplace(const QString &text, { QStringList files = replaceAll(text, items); if (!files.isEmpty()) { - Core::FileManager::notifyFilesChangedInternally(files); + Core::DocumentManager::notifyFilesChangedInternally(files); Find::SearchResultWindow::instance()->hide(); } } diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp index 9234b2821f..99b81191cc 100644 --- a/src/plugins/texteditor/basetextdocument.cpp +++ b/src/plugins/texteditor/basetextdocument.cpp @@ -213,7 +213,7 @@ bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool // When saving the current editor, make sure to maintain the cursor position for undo Core::IEditor *currentEditor = Core::EditorManager::instance()->currentEditor(); if (BaseTextEditor *editable = qobject_cast(currentEditor)) { - if (editable->file() == this) { + if (editable->document() == this) { editorWidget = editable->editorWidget(); QTextCursor cur = editorWidget->textCursor(); savedPosition = cur.position(); @@ -289,7 +289,7 @@ void BaseTextDocument::rename(const QString &newName) emit changed(); } -bool BaseTextDocument::isReadOnly() const +bool BaseTextDocument::isFileReadOnly() const { if (d->m_fileName.isEmpty()) //have no corresponding file, so editing is ok return false; diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h index 39f9b67c2b..7cd69b3e9a 100644 --- a/src/plugins/texteditor/basetextdocument.h +++ b/src/plugins/texteditor/basetextdocument.h @@ -35,7 +35,7 @@ #include "texteditor_global.h" -#include +#include QT_BEGIN_NAMESPACE class QTextCursor; @@ -52,7 +52,7 @@ class ExtraEncodingSettings; class SyntaxHighlighter; class BaseTextDocumentPrivate; -class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextFile +class TEXTEDITOR_EXPORT BaseTextDocument : public Core::TextDocument { Q_OBJECT @@ -72,11 +72,11 @@ public: ITextMarkable *documentMarker() const; - // IFile implementation. + // IDocument implementation. virtual bool save(QString *errorString, const QString &fileName, bool autoSave); virtual QString fileName() const; virtual bool shouldAutoSave() const; - virtual bool isReadOnly() const; + virtual bool isFileReadOnly() const; virtual bool isModified() const; virtual bool isSaveAsAllowed() const; virtual void checkPermissions(); diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 9f8442c39d..557bb25cd7 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -663,7 +663,7 @@ void BaseTextEditorWidget::setChangeSet(const Utils::ChangeSet &changeSet) } } -Core::IFile *BaseTextEditorWidget::file() const +Core::IDocument *BaseTextEditorWidget::editorDocument() const { return d->m_document; } diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h index f4ca0a3f06..dddb6bf008 100644 --- a/src/plugins/texteditor/basetexteditor.h +++ b/src/plugins/texteditor/basetexteditor.h @@ -141,7 +141,7 @@ public: void setChangeSet(const Utils::ChangeSet &changeSet); // EditorInterface - Core::IFile * file() const; + Core::IDocument *editorDocument() const; bool createNew(const QString &contents); virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName); QByteArray saveState() const; @@ -599,7 +599,7 @@ public: // EditorInterface //QWidget *widget() { return e; } - Core::IFile * file() { return e->file(); } + Core::IDocument * document() { return e->editorDocument(); } bool createNew(const QString &contents) { return e->createNew(contents); } bool open(QString *errorString, const QString &fileName, const QString &realFileName) { return e->open(errorString, fileName, realFileName); } QString displayName() const { return e->displayName(); } diff --git a/src/plugins/texteditor/basetextmark.cpp b/src/plugins/texteditor/basetextmark.cpp index 422649c049..0e3b55d357 100644 --- a/src/plugins/texteditor/basetextmark.cpp +++ b/src/plugins/texteditor/basetextmark.cpp @@ -60,7 +60,7 @@ void BaseTextMarkRegistry::add(BaseTextMark *mark) if (markableInterface->addMark(mark, mark->m_line)) { mark->m_markableInterface = markableInterface; // Handle reload of text documents, readding the mark as necessary - connect(textEditor->file(), SIGNAL(reloaded()), + connect(textEditor->document(), SIGNAL(reloaded()), this, SLOT(documentReloaded()), Qt::UniqueConnection); break; } @@ -79,14 +79,14 @@ void BaseTextMarkRegistry::editorOpened(Core::IEditor *editor) ITextEditor *textEditor = qobject_cast(editor); if (!textEditor) return; - if (!m_marks.contains(Utils::FileName::fromString(editor->file()->fileName()))) + if (!m_marks.contains(Utils::FileName::fromString(editor->document()->fileName()))) return; // Handle reload of text documents, readding the mark as necessary - connect(textEditor->file(), SIGNAL(reloaded()), + connect(textEditor->document(), SIGNAL(reloaded()), this, SLOT(documentReloaded()), Qt::UniqueConnection); - foreach (BaseTextMark *mark, m_marks.value(Utils::FileName::fromString(editor->file()->fileName()))) { + foreach (BaseTextMark *mark, m_marks.value(Utils::FileName::fromString(editor->document()->fileName()))) { if (mark->m_markableInterface == 0) { // We aren't added to something ITextMarkable *markableInterface = textEditor->markableInterface(); if (markableInterface->addMark(mark, mark->m_line)) diff --git a/src/plugins/texteditor/codeassist/defaultassistinterface.cpp b/src/plugins/texteditor/codeassist/defaultassistinterface.cpp index 2dc94176be..b02c5e166e 100644 --- a/src/plugins/texteditor/codeassist/defaultassistinterface.cpp +++ b/src/plugins/texteditor/codeassist/defaultassistinterface.cpp @@ -40,37 +40,37 @@ using namespace TextEditor; -DefaultAssistInterface::DefaultAssistInterface(QTextDocument *document, +DefaultAssistInterface::DefaultAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, AssistReason reason) - : m_document(document) + : m_textDocument(textDocument) , m_detached(false) , m_position(position) - , m_file(file) + , m_document(document) , m_reason(reason) {} DefaultAssistInterface::~DefaultAssistInterface() { if (m_detached) - delete m_document; + delete m_textDocument; } QChar DefaultAssistInterface::characterAt(int position) const { - return m_document->characterAt(position); + return m_textDocument->characterAt(position); } QString DefaultAssistInterface::textAt(int pos, int length) const { - return Convenience::textAt(QTextCursor(m_document), pos, length); + return Convenience::textAt(QTextCursor(m_textDocument), pos, length); } void DefaultAssistInterface::detach(QThread *destination) { - m_document = m_document->clone(); - m_document->moveToThread(destination); + m_textDocument = m_textDocument->clone(); + m_textDocument->moveToThread(destination); m_detached = true; } diff --git a/src/plugins/texteditor/codeassist/defaultassistinterface.h b/src/plugins/texteditor/codeassist/defaultassistinterface.h index ea4b66c060..7d701c21f7 100644 --- a/src/plugins/texteditor/codeassist/defaultassistinterface.h +++ b/src/plugins/texteditor/codeassist/defaultassistinterface.h @@ -40,25 +40,25 @@ namespace TextEditor { class TEXTEDITOR_EXPORT DefaultAssistInterface : public IAssistInterface { public: - DefaultAssistInterface(QTextDocument *document, + DefaultAssistInterface(QTextDocument *textDocument, int position, - Core::IFile *file, + Core::IDocument *document, AssistReason reason); virtual ~DefaultAssistInterface(); virtual int position() const { return m_position; } virtual QChar characterAt(int position) const; virtual QString textAt(int position, int length) const; - virtual const Core::IFile *file() const { return m_file; } - virtual QTextDocument *document() const { return m_document; } + virtual const Core::IDocument *document() const { return m_document; } + virtual QTextDocument *textDocument() const { return m_textDocument; } virtual void detach(QThread *destination); virtual AssistReason reason() const; private: - QTextDocument *m_document; + QTextDocument *m_textDocument; bool m_detached; int m_position; - Core::IFile *m_file; + Core::IDocument *m_document; AssistReason m_reason; }; diff --git a/src/plugins/texteditor/codeassist/iassistinterface.cpp b/src/plugins/texteditor/codeassist/iassistinterface.cpp index 5302c16505..581bb08f0c 100644 --- a/src/plugins/texteditor/codeassist/iassistinterface.cpp +++ b/src/plugins/texteditor/codeassist/iassistinterface.cpp @@ -78,7 +78,7 @@ IAssistInterface::~IAssistInterface() */ /*! - \fn const Core::IFile *TextEditor::IAssistInterface::file() const + \fn const Core::IDocument *TextEditor::IAssistInterface::file() const Returns the file associated. */ diff --git a/src/plugins/texteditor/codeassist/iassistinterface.h b/src/plugins/texteditor/codeassist/iassistinterface.h index 7c6b2d6d9e..9ca494dfaa 100644 --- a/src/plugins/texteditor/codeassist/iassistinterface.h +++ b/src/plugins/texteditor/codeassist/iassistinterface.h @@ -45,7 +45,7 @@ class QThread; QT_END_NAMESPACE namespace Core { -class IFile; +class IDocument; } namespace TextEditor { @@ -59,8 +59,8 @@ public: virtual int position() const = 0; virtual QChar characterAt(int position) const = 0; virtual QString textAt(int position, int length) const = 0; - virtual const Core::IFile *file() const = 0; - virtual QTextDocument *document() const = 0; + virtual const Core::IDocument *document() const = 0; + virtual QTextDocument *textDocument() const = 0; virtual void detach(QThread *destination) = 0; virtual AssistReason reason() const = 0; }; diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index 2350a1e988..df35d9db76 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -43,7 +43,7 @@ using namespace TextEditor; using namespace TextEditor::Internal; FindInCurrentFile::FindInCurrentFile() - : m_currentFile(0) + : m_currentDocument(0) { connect(Core::ICore::editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(handleFileChange(Core::IEditor*))); @@ -74,36 +74,36 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters, QVariant FindInCurrentFile::additionalParameters() const { - return qVariantFromValue(m_currentFile->fileName()); + return qVariantFromValue(m_currentDocument->fileName()); } QString FindInCurrentFile::label() const { - return tr("File '%1':").arg(QFileInfo(m_currentFile->fileName()).fileName()); + return tr("File '%1':").arg(QFileInfo(m_currentDocument->fileName()).fileName()); } QString FindInCurrentFile::toolTip() const { // %2 is filled by BaseFileFind::runNewSearch - return tr("File path: %1\n%2").arg(QDir::toNativeSeparators(m_currentFile->fileName())); + return tr("File path: %1\n%2").arg(QDir::toNativeSeparators(m_currentDocument->fileName())); } bool FindInCurrentFile::isEnabled() const { - return m_currentFile && !m_currentFile->fileName().isEmpty(); + return m_currentDocument && !m_currentDocument->fileName().isEmpty(); } void FindInCurrentFile::handleFileChange(Core::IEditor *editor) { if (!editor) { - if (m_currentFile) { - m_currentFile = 0; + if (m_currentDocument) { + m_currentDocument = 0; emit enabledChanged(isEnabled()); } } else { - Core::IFile *file = editor->file(); - if (file != m_currentFile) { - m_currentFile = file; + Core::IDocument *document = editor->document(); + if (document != m_currentDocument) { + m_currentDocument = document; emit enabledChanged(isEnabled()); } } diff --git a/src/plugins/texteditor/findincurrentfile.h b/src/plugins/texteditor/findincurrentfile.h index a4690073a6..132a762290 100644 --- a/src/plugins/texteditor/findincurrentfile.h +++ b/src/plugins/texteditor/findincurrentfile.h @@ -35,7 +35,7 @@ #include "basefilefind.h" -#include +#include #include #include @@ -67,7 +67,7 @@ private slots: void handleFileChange(Core::IEditor *editor); private: - QPointer m_currentFile; + QPointer m_currentDocument; }; } // namespace Internal diff --git a/src/plugins/texteditor/itexteditor.cpp b/src/plugins/texteditor/itexteditor.cpp index fe2e0f4de2..3631d59c55 100644 --- a/src/plugins/texteditor/itexteditor.cpp +++ b/src/plugins/texteditor/itexteditor.cpp @@ -93,7 +93,7 @@ QMap ITextEditor::openedTextEditorsContents() ITextEditor *textEditor = qobject_cast(editor); if (!textEditor) continue; - QString fileName = textEditor->file()->fileName(); + QString fileName = textEditor->document()->fileName(); workingCopy[fileName] = textEditor->contents(); } return workingCopy; @@ -106,7 +106,7 @@ QMap TextEditor::ITextEditor::openedTextEditorsEncodings( ITextEditor *textEditor = qobject_cast(editor); if (!textEditor) continue; - QString fileName = textEditor->file()->fileName(); + QString fileName = textEditor->document()->fileName(); workingCopy[fileName] = textEditor->textCodec(); } return workingCopy; diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp index 4f06f71561..d1abadb607 100644 --- a/src/plugins/texteditor/plaintexteditor.cpp +++ b/src/plugins/texteditor/plaintexteditor.cpp @@ -80,7 +80,7 @@ PlainTextEditorWidget::PlainTextEditorWidget(QWidget *parent) m_commentDefinition.clearCommentStyles(); - connect(file(), SIGNAL(changed()), this, SLOT(configure())); + connect(editorDocument(), SIGNAL(changed()), this, SLOT(configure())); connect(Manager::instance(), SIGNAL(mimeTypesRegistered()), this, SLOT(configure())); } @@ -149,8 +149,8 @@ void PlainTextEditorWidget::setTabSettings(const TextEditor::TabSettings &ts) void PlainTextEditorWidget::configure() { Core::MimeType mimeType; - if (file()) - mimeType = Core::ICore::mimeDatabase()->findByFile(file()->fileName()); + if (editorDocument()) + mimeType = Core::ICore::mimeDatabase()->findByFile(editorDocument()->fileName()); configure(mimeType); } @@ -190,8 +190,8 @@ void PlainTextEditorWidget::configure(const Core::MimeType &mimeType) setCodeFoldingSupported(true); } - } else if (file()) { - const QString &fileName = file()->fileName(); + } else if (editorDocument()) { + const QString &fileName = editorDocument()->fileName(); if (TextEditorSettings::instance()->highlighterSettings().isIgnoredFilePattern(fileName)) m_isMissingSyntaxDefinition = false; } diff --git a/src/plugins/texteditor/plaintexteditorfactory.cpp b/src/plugins/texteditor/plaintexteditorfactory.cpp index 7d35c352d7..308819e11b 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.cpp +++ b/src/plugins/texteditor/plaintexteditorfactory.cpp @@ -75,10 +75,10 @@ QString PlainTextEditorFactory::displayName() const return tr(Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME); } -Core::IFile *PlainTextEditorFactory::open(const QString &fileName) +Core::IDocument *PlainTextEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *PlainTextEditorFactory::createEditor(QWidget *parent) @@ -95,7 +95,7 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor) { PlainTextEditor *editorEditable = qobject_cast(editor); if (editorEditable) { - BaseTextDocument *file = qobject_cast(editor->file()); + BaseTextDocument *file = qobject_cast(editor->document()); if (!file) return; PlainTextEditorWidget *textEditor = static_cast(editorEditable->editorWidget()); diff --git a/src/plugins/texteditor/plaintexteditorfactory.h b/src/plugins/texteditor/plaintexteditorfactory.h index 14ca8632ec..f70111b8f0 100644 --- a/src/plugins/texteditor/plaintexteditorfactory.h +++ b/src/plugins/texteditor/plaintexteditorfactory.h @@ -55,7 +55,7 @@ public: Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); TextEditor::TextEditorActionHandler *actionHandler() const { return m_actionHandler; } diff --git a/src/plugins/texteditor/refactoringchanges.cpp b/src/plugins/texteditor/refactoringchanges.cpp index 5d665fb4dc..0db20597ad 100644 --- a/src/plugins/texteditor/refactoringchanges.cpp +++ b/src/plugins/texteditor/refactoringchanges.cpp @@ -175,7 +175,7 @@ RefactoringFile::RefactoringFile(QTextDocument *document, const QString &fileNam { } RefactoringFile::RefactoringFile(BaseTextEditorWidget *editor) - : m_fileName(editor->file()->fileName()) + : m_fileName(editor->editorDocument()->fileName()) , m_document(0) , m_editor(editor) , m_openEditor(false) diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index dd3287f251..db4a86b6c6 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -902,7 +902,7 @@ void CallgrindToolPrivate::requestContextMenu(TextEditor::ITextEditor *editor, i // find callgrind text mark that corresponds to this editor's file and line number const Function *func = 0; foreach (CallgrindTextMark *textMark, m_textMarks) { - if (textMark->fileName() == editor->file()->fileName() && textMark->lineNumber() == line) { + if (textMark->fileName() == editor->document()->fileName() && textMark->lineNumber() == line) { func = textMark->function(); break; } diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index bd32b2982b..a74d1390f7 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -99,10 +99,10 @@ QString BaseVcsEditorFactory::displayName() const return d->m_displayName; } -Core::IFile *BaseVcsEditorFactory::open(const QString &fileName) +Core::IDocument *BaseVcsEditorFactory::open(const QString &fileName) { Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id()); - return iface ? iface->file() : 0; + return iface ? iface->document() : 0; } Core::IEditor *BaseVcsEditorFactory::createEditor(QWidget *parent) diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index 72c5df4acc..10739978e5 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -58,7 +58,7 @@ public: Core::Id id() const; QString displayName() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); Core::IEditor *createEditor(QWidget *parent); private: diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp index d3548327a2..57d566f04c 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp @@ -91,10 +91,10 @@ QStringList BaseVcsSubmitEditorFactory::mimeTypes() const return d->m_mimeTypes; } -Core::IFile *BaseVcsSubmitEditorFactory::open(const QString &fileName) +Core::IDocument *BaseVcsSubmitEditorFactory::open(const QString &fileName) { if (Core::IEditor *iface = Core::EditorManager::instance()->openEditor(fileName, id())) - return iface->file(); + return iface->document(); return 0; } diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h index 827fa98883..3e3c3fe7eb 100644 --- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h +++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h @@ -62,7 +62,7 @@ public: Core::Id id() const; QString displayName() const; QStringList mimeTypes() const; - Core::IFile *open(const QString &fileName); + Core::IDocument *open(const QString &fileName); private: virtual VcsBaseSubmitEditor diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp index fe63906ad8..462c1a17a7 100644 --- a/src/plugins/vcsbase/submiteditorfile.cpp +++ b/src/plugins/vcsbase/submiteditorfile.cpp @@ -38,11 +38,11 @@ using namespace VcsBase::Internal; /*! \class VcsBase::Internal::SubmitEditorFile - \brief A non-saveable IFile for submit editor files. + \brief A non-saveable IDocument for submit editor files. */ SubmitEditorFile::SubmitEditorFile(const QString &mimeType, QObject *parent) : - Core::IFile(parent), + Core::IDocument(parent), m_mimeType(mimeType), m_modified(false) { @@ -83,7 +83,7 @@ QString SubmitEditorFile::mimeType() const return m_mimeType; } -Core::IFile::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +Core::IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h index 6dd5ae35b4..6b4b4a7642 100644 --- a/src/plugins/vcsbase/submiteditorfile.h +++ b/src/plugins/vcsbase/submiteditorfile.h @@ -33,12 +33,12 @@ #ifndef SUBMITEDITORFILE_H #define SUBMITEDITORFILE_H -#include +#include namespace VcsBase { namespace Internal { -class SubmitEditorFile : public Core::IFile +class SubmitEditorFile : public Core::IDocument { Q_OBJECT public: diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 0ee01f087d..06313e932c 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -72,7 +72,7 @@ Q_DECLARE_METATYPE(QVariant) inline Core::IEditor *locateEditor(const char *property, const QString &entry) { foreach (Core::IEditor *ed, Core::ICore::editorManager()->openedEditors()) - if (ed->file()->property(property).toString() == entry) + if (ed->document()->property(property).toString() == entry) return ed; return 0; } @@ -569,7 +569,7 @@ VcsBase::VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(const QString &kind QTC_ASSERT(baseEditor, return 0); } else { outputEditor = Core::ICore::editorManager()->openEditorWithContents(Core::Id(kind), &title, progressMsg); - outputEditor->file()->setProperty(registerDynamicProperty, dynamicPropertyValue); + outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); baseEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(outputEditor); connect(baseEditor, SIGNAL(annotateRevisionRequested(QString,QString,int)), this, SLOT(annotateRevision(QString,QString,int))); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index cf24e5f99f..e5dfe8f4fe 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include #include @@ -1202,8 +1202,8 @@ static QTextCodec *findProjectCodec(const QString &dir) if (!projects.empty()) { const ProjectList::const_iterator pcend = projects.constEnd(); for (ProjectList::const_iterator it = projects.constBegin(); it != pcend; ++it) - if (const Core::IFile *file = (*it)->file()) - if (file->fileName().startsWith(dir)) { + if (const Core::IDocument *document = (*it)->document()) + if (document->fileName().startsWith(dir)) { QTextCodec *codec = (*it)->editorConfiguration()->textCodec(); return codec; } @@ -1248,8 +1248,8 @@ int VcsBaseEditorWidget::lineNumberOfCurrentEditor(const QString ¤tFile) if (!ed) return -1; if (!currentFile.isEmpty()) { - const Core::IFile *ifile = ed->file(); - if (!ifile || ifile->fileName() != currentFile) + const Core::IDocument *idocument = ed->document(); + if (!idocument || idocument->fileName() != currentFile) return -1; } const TextEditor::BaseTextEditor *eda = qobject_cast(ed); diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 7d259a8d74..8ba89add11 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -38,9 +38,9 @@ #include "corelistener.h" #include -#include +#include #include -#include +#include #include #include #include @@ -238,10 +238,10 @@ void StateListener::slotStateChanged() // folder? State state; Core::EditorManager *em = Core::ICore::editorManager(); - if (!em || !em->currentEditor() || !em->currentEditor()->file()) + if (!em || !em->currentEditor() || !em->currentEditor()->document()) state.currentFile.clear(); else - state.currentFile = em->currentEditor()->file()->fileName(); + state.currentFile = em->currentEditor()->document()->fileName(); QScopedPointer currentFileInfo; // Instantiate QFileInfo only once if required. if (!state.currentFile.isEmpty()) { const bool isTempFile = state.currentFile.startsWith(QDir::tempPath()); @@ -643,7 +643,7 @@ void VcsBasePlugin::createRepository() // Find current starting directory QString directory; if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) - directory = QFileInfo(currentProject->file()->fileName()).absolutePath(); + directory = QFileInfo(currentProject->document()->fileName()).absolutePath(); // Prompt for a directory that is not under version control yet QMainWindow *mw = Core::ICore::mainWindow(); do { diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 778e79a6dc..38edfae954 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include @@ -141,8 +141,8 @@ static const char *belongingClassName(const CPlusPlus::Function *function) it. The submit process is started by listening on the editor close - signal and then asking the IFile interface of the editor to save the file - within a IFileManager::blockFileChange() section + signal and then asking the IDocument interface of the editor to save the file + within a DocumentManager::blockFileChange() section and to launch the submit process. In addition, the action registered for submit should be connected to a slot triggering the close of the current editor in the editor manager. @@ -391,7 +391,7 @@ bool VcsBaseSubmitEditor::open(QString *errorString, const QString &fileName, co return true; } -Core::IFile *VcsBaseSubmitEditor::file() +Core::IDocument *VcsBaseSubmitEditor::document() { return d->m_file; } diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h index 712d709813..e9536ed190 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.h +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h @@ -120,7 +120,7 @@ public: // Core::IEditor bool createNew(const QString &contents); bool open(QString *errorString, const QString &fileName, const QString &realFileName); - Core::IFile *file(); + Core::IDocument *document(); QString displayName() const; void setDisplayName(const QString &title); bool duplicateSupported() const; -- cgit v1.2.1