Commit a5a4f02c authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

Core: Make IDocument concrete

Change-Id: I8290943614ea4a2060cf09a71fb4f957852ab705
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 5e623ddf
...@@ -29,8 +29,8 @@ ...@@ -29,8 +29,8 @@
#include "autotoolsproject.h" #include "autotoolsproject.h"
#include "autotoolsprojectconstants.h" #include "autotoolsprojectconstants.h"
using namespace AutotoolsProjectManager; namespace AutotoolsProjectManager {
using namespace AutotoolsProjectManager::Internal; namespace Internal {
AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName) AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName)
{ {
...@@ -39,30 +39,5 @@ AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName) ...@@ -39,30 +39,5 @@ AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName)
setFilePath(Utils::FileName::fromString(fileName)); setFilePath(Utils::FileName::fromString(fileName));
} }
bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, bool autoSave) } // namespace Internal
{ } // namespace AutotoolsProjectManager
Q_UNUSED(errorString);
Q_UNUSED(fileName);
Q_UNUSED(autoSave);
return false;
}
bool AutotoolsProjectFile::isModified() const
{
return false;
}
bool AutotoolsProjectFile::isSaveAsAllowed() const
{
return false;
}
bool AutotoolsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(errorString);
Q_UNUSED(flag);
Q_UNUSED(type);
return false;
}
...@@ -32,8 +32,6 @@ ...@@ -32,8 +32,6 @@
namespace AutotoolsProjectManager { namespace AutotoolsProjectManager {
namespace Internal { namespace Internal {
class AutotoolsProject;
/** /**
* @brief Implementation of the Core::IDocument interface. * @brief Implementation of the Core::IDocument interface.
* *
...@@ -47,14 +45,8 @@ class AutotoolsProject; ...@@ -47,14 +45,8 @@ class AutotoolsProject;
class AutotoolsProjectFile : public Core::IDocument class AutotoolsProjectFile : public Core::IDocument
{ {
Q_OBJECT Q_OBJECT
public: public:
AutotoolsProjectFile(const QString &fileName); AutotoolsProjectFile(const QString &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -41,26 +41,6 @@ CMakeFile::CMakeFile(const FileName &fileName) ...@@ -41,26 +41,6 @@ CMakeFile::CMakeFile(const FileName &fileName)
setFilePath(fileName); setFilePath(fileName);
} }
bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
// Once we have an texteditor open for this file, we probably do
// need to implement this, don't we.
Q_UNUSED(errorString)
Q_UNUSED(fileName)
Q_UNUSED(autoSave)
return false;
}
bool CMakeFile::isModified() const
{
return false;
}
bool CMakeFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
...@@ -68,12 +48,5 @@ Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, C ...@@ -68,12 +48,5 @@ Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, C
return BehaviorSilent; return BehaviorSilent;
} }
bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
return true;
}
} // namespace Internal } // namespace Internal
} // namespace CMakeProjectManager } // namespace CMakeProjectManager
...@@ -38,13 +38,7 @@ class CMakeFile : public Core::IDocument ...@@ -38,13 +38,7 @@ class CMakeFile : public Core::IDocument
public: public:
CMakeFile(const Utils::FileName &fileName); CMakeFile(const Utils::FileName &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
}; };
} // namespace Internal } // namespace Internal
......
...@@ -109,15 +109,6 @@ private: ...@@ -109,15 +109,6 @@ private:
QHash<QString, DocumentModel::Entry *> m_entryByFixedPath; QHash<QString, DocumentModel::Entry *> m_entryByFixedPath;
}; };
class SuspendedDocument : public IDocument
{
public:
bool save(QString *, const QString &, bool) override { return false; }
bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return false; }
bool reload(QString *, ReloadFlag, ChangeType) override { return true; }
};
DocumentModelPrivate::DocumentModelPrivate() : DocumentModelPrivate::DocumentModelPrivate() :
m_lockedIcon(Icons::LOCKED.icon()), m_lockedIcon(Icons::LOCKED.icon()),
m_unlockedIcon(Icons::UNLOCKED.icon()) m_unlockedIcon(Icons::UNLOCKED.icon())
...@@ -226,7 +217,7 @@ void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument) ...@@ -226,7 +217,7 @@ void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument)
void DocumentModel::addSuspendedDocument(const QString &fileName, const QString &displayName, Id id) void DocumentModel::addSuspendedDocument(const QString &fileName, const QString &displayName, Id id)
{ {
Entry *entry = new Entry; Entry *entry = new Entry;
entry->document = new SuspendedDocument; entry->document = new IDocument;
entry->document->setFilePath(Utils::FileName::fromString(fileName)); entry->document->setFilePath(Utils::FileName::fromString(fileName));
entry->document->setPreferredDisplayName(displayName); entry->document->setPreferredDisplayName(displayName);
entry->document->setId(id); entry->document->setId(id);
......
...@@ -145,6 +145,14 @@ IDocument::OpenResult IDocument::open(QString *errorString, const QString &fileN ...@@ -145,6 +145,14 @@ IDocument::OpenResult IDocument::open(QString *errorString, const QString &fileN
return OpenResult::CannotHandle; return OpenResult::CannotHandle;
} }
bool IDocument::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString)
Q_UNUSED(fileName)
Q_UNUSED(autoSave)
return false;
}
/*! /*!
* Returns the current contents of the document. The base implementation returns an empty * Returns the current contents of the document. The base implementation returns an empty
* QByteArray. * QByteArray.
...@@ -180,6 +188,14 @@ IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeT ...@@ -180,6 +188,14 @@ IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeT
return BehaviorAsk; return BehaviorAsk;
} }
bool IDocument::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
return true;
}
void IDocument::checkPermissions() void IDocument::checkPermissions()
{ {
} }
...@@ -189,6 +205,16 @@ bool IDocument::shouldAutoSave() const ...@@ -189,6 +205,16 @@ bool IDocument::shouldAutoSave() const
return false; return false;
} }
bool IDocument::isModified() const
{
return false;
}
bool IDocument::isSaveAsAllowed() const
{
return false;
}
bool IDocument::isFileReadOnly() const bool IDocument::isFileReadOnly() const
{ {
if (filePath().isEmpty()) if (filePath().isEmpty())
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
// required to be re-implemented for documents of IEditors // required to be re-implemented for documents of IEditors
virtual OpenResult open(QString *errorString, const QString &fileName, const QString &realFileName); virtual OpenResult open(QString *errorString, const QString &fileName, const QString &realFileName);
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0; virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false);
virtual QByteArray contents() const; virtual QByteArray contents() const;
virtual bool setContents(const QByteArray &contents); virtual bool setContents(const QByteArray &contents);
...@@ -112,11 +112,11 @@ public: ...@@ -112,11 +112,11 @@ public:
void setMimeType(const QString &mimeType); void setMimeType(const QString &mimeType);
virtual bool shouldAutoSave() const; virtual bool shouldAutoSave() const;
virtual bool isModified() const = 0; virtual bool isModified() const;
virtual bool isSaveAsAllowed() const = 0; virtual bool isSaveAsAllowed() const;
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0; virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
virtual void checkPermissions(); virtual void checkPermissions();
......
...@@ -442,21 +442,6 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, ...@@ -442,21 +442,6 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName,
setFilePath(Utils::FileName::fromString(fileName)); setFilePath(Utils::FileName::fromString(fileName));
} }
bool GenericProjectFile::save(QString *, const QString &, bool)
{
return false;
}
bool GenericProjectFile::isModified() const
{
return false;
}
bool GenericProjectFile::isSaveAsAllowed() const
{
return false;
}
IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state); Q_UNUSED(state);
......
...@@ -108,15 +108,9 @@ private: ...@@ -108,15 +108,9 @@ private:
class GenericProjectFile : public Core::IDocument class GenericProjectFile : public Core::IDocument
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options); GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -249,23 +249,5 @@ void ImageViewerFile::cleanUp() ...@@ -249,23 +249,5 @@ void ImageViewerFile::cleanUp()
m_type = TypeInvalid; m_type = TypeInvalid;
} }
bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString)
Q_UNUSED(fileName);
Q_UNUSED(autoSave)
return false;
}
bool ImageViewerFile::isModified() const
{
return false;
}
bool ImageViewerFile::isSaveAsAllowed() const
{
return false;
}
} // namespace Internal } // namespace Internal
} // namespace ImageViewer } // namespace ImageViewer
...@@ -62,10 +62,6 @@ public: ...@@ -62,10 +62,6 @@ public:
OpenResult open(QString *errorString, const QString &fileName, OpenResult open(QString *errorString, const QString &fileName,
const QString &realFileName) override; const QString &realFileName) override;
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -281,17 +281,6 @@ public: ...@@ -281,17 +281,6 @@ public:
setFilePath(FileName::fromString(fileName)); setFilePath(FileName::fromString(fileName));
} }
bool save(QString *errorString, const QString &fileName, bool autoSave) override
{
Q_UNUSED(errorString)
Q_UNUSED(fileName)
Q_UNUSED(autoSave)
return false;
}
bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return false; }
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override
{ {
Q_UNUSED(state) Q_UNUSED(state)
......
...@@ -39,21 +39,6 @@ QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDo ...@@ -39,21 +39,6 @@ QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDo
setFilePath(Utils::FileName::fromString(fileName)); setFilePath(Utils::FileName::fromString(fileName));
} }
bool QbsProjectFile::save(QString *, const QString &, bool)
{
return false;
}
bool QbsProjectFile::isModified() const
{
return false;
}
bool QbsProjectFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior QbsProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior QbsProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state); Q_UNUSED(state);
......
...@@ -36,15 +36,9 @@ class QbsProject; ...@@ -36,15 +36,9 @@ class QbsProject;
class QbsProjectFile : public Core::IDocument class QbsProjectFile : public Core::IDocument
{ {
Q_OBJECT Q_OBJECT
public: public:
QbsProjectFile(QbsProject *parent, QString fileName); QbsProjectFile(QbsProject *parent, QString fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -268,24 +268,6 @@ QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile) ...@@ -268,24 +268,6 @@ QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile)
setFilePath(m_priFile->filePath()); setFilePath(m_priFile->filePath());
} }
bool QmakePriFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString);
Q_UNUSED(fileName);
Q_UNUSED(autoSave);
return false;
}
bool QmakePriFile::isModified() const
{
return false;
}
bool QmakePriFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior QmakePriFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior QmakePriFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
......
...@@ -241,10 +241,6 @@ class QmakePriFile : public Core::IDocument ...@@ -241,10 +241,6 @@ class QmakePriFile : public Core::IDocument
Q_OBJECT Q_OBJECT
public: public:
QmakePriFile(QmakePriFileNode *qmakePriFile); QmakePriFile(QmakePriFileNode *qmakePriFile);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -95,15 +95,9 @@ namespace Internal { ...@@ -95,15 +95,9 @@ namespace Internal {
class QmakeProjectFile : public Core::IDocument class QmakeProjectFile : public Core::IDocument
{ {
Q_OBJECT Q_OBJECT
public: public:
QmakeProjectFile(const QString &filePath); QmakeProjectFile(const QString &filePath);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
}; };
...@@ -254,22 +248,6 @@ QmakeProjectFile::QmakeProjectFile(const QString &filePath) ...@@ -254,22 +248,6 @@ QmakeProjectFile::QmakeProjectFile(const QString &filePath)
setFilePath(FileName::fromString(filePath)); setFilePath(FileName::fromString(filePath));
} }
bool QmakeProjectFile::save(QString *, const QString &, bool)
{
// This is never used
return false;
}
bool QmakeProjectFile::isModified() const
{
return false; // we save after changing anyway
}
bool QmakeProjectFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior QmakeProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior QmakeProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
......
...@@ -41,21 +41,6 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, const Utils::FileName &fileNa ...@@ -41,21 +41,6 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, const Utils::FileName &fileNa
setFilePath(fileName); setFilePath(fileName);
} }
bool QmlProjectFile::save(QString *, const QString &, bool)
{
return false;
}
bool QmlProjectFile::isModified() const
{
return false;
}
bool QmlProjectFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const Core::IDocument::ReloadBehavior QmlProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{ {
Q_UNUSED(state) Q_UNUSED(state)
......
...@@ -37,15 +37,9 @@ namespace Internal { ...@@ -37,15 +37,9 @@ namespace Internal {
class QmlProjectFile : public Core::IDocument class QmlProjectFile : public Core::IDocument
{ {
Q_OBJECT Q_OBJECT
public: public:
QmlProjectFile(QmlProject *parent, const Utils::FileName &fileName); QmlProjectFile(QmlProject *parent, const Utils::FileName &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -552,24 +552,6 @@ ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node) ...@@ -552,24 +552,6 @@ ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
setFilePath(node->filePath()); setFilePath(node->filePath());
} }
bool ResourceFileWatcher::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString);
Q_UNUSED(fileName);