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 @@
#include "autotoolsproject.h"
#include "autotoolsprojectconstants.h"
using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Internal;
namespace AutotoolsProjectManager {
namespace Internal {
AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName)
{
......@@ -39,30 +39,5 @@ AutotoolsProjectFile::AutotoolsProjectFile(const QString &fileName)
setFilePath(Utils::FileName::fromString(fileName));
}
bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
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;
}
} // namespace Internal
} // namespace AutotoolsProjectManager
......@@ -32,8 +32,6 @@
namespace AutotoolsProjectManager {
namespace Internal {
class AutotoolsProject;
/**
* @brief Implementation of the Core::IDocument interface.
*
......@@ -47,14 +45,8 @@ class AutotoolsProject;
class AutotoolsProjectFile : public Core::IDocument
{
Q_OBJECT
public:
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
......
......@@ -41,26 +41,6 @@ CMakeFile::CMakeFile(const FileName &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
{
Q_UNUSED(state)
......@@ -68,12 +48,5 @@ Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, C
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 CMakeProjectManager
......@@ -38,13 +38,7 @@ class CMakeFile : public Core::IDocument
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
};
} // namespace Internal
......
......@@ -109,15 +109,6 @@ private:
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() :
m_lockedIcon(Icons::LOCKED.icon()),
m_unlockedIcon(Icons::UNLOCKED.icon())
......@@ -226,7 +217,7 @@ void DocumentModel::addEditor(IEditor *editor, bool *isNewDocument)
void DocumentModel::addSuspendedDocument(const QString &fileName, const QString &displayName, Id id)
{
Entry *entry = new Entry;
entry->document = new SuspendedDocument;
entry->document = new IDocument;
entry->document->setFilePath(Utils::FileName::fromString(fileName));
entry->document->setPreferredDisplayName(displayName);
entry->document->setId(id);
......
......@@ -145,6 +145,14 @@ IDocument::OpenResult IDocument::open(QString *errorString, const QString &fileN
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
* QByteArray.
......@@ -180,6 +188,14 @@ IDocument::ReloadBehavior IDocument::reloadBehavior(ChangeTrigger state, ChangeT
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()
{
}
......@@ -189,6 +205,16 @@ bool IDocument::shouldAutoSave() const
return false;
}
bool IDocument::isModified() const
{
return false;
}
bool IDocument::isSaveAsAllowed() const
{
return false;
}
bool IDocument::isFileReadOnly() const
{
if (filePath().isEmpty())
......
......@@ -89,7 +89,7 @@ public:
// required to be re-implemented for documents of IEditors
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 bool setContents(const QByteArray &contents);
......@@ -112,11 +112,11 @@ public:
void setMimeType(const QString &mimeType);
virtual bool shouldAutoSave() const;
virtual bool isModified() const = 0;
virtual bool isSaveAsAllowed() const = 0;
virtual bool isModified() const;
virtual bool isSaveAsAllowed() 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();
......
......@@ -442,21 +442,6 @@ GenericProjectFile::GenericProjectFile(GenericProject *parent, QString 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
{
Q_UNUSED(state);
......
......@@ -108,15 +108,9 @@ private:
class GenericProjectFile : public Core::IDocument
{
Q_OBJECT
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -249,23 +249,5 @@ void ImageViewerFile::cleanUp()
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 ImageViewer
......@@ -62,10 +62,6 @@ public:
OpenResult open(QString *errorString, const QString &fileName,
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -281,17 +281,6 @@ public:
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
{
Q_UNUSED(state)
......
......@@ -39,21 +39,6 @@ QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDo
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
{
Q_UNUSED(state);
......
......@@ -36,15 +36,9 @@ class QbsProject;
class QbsProjectFile : public Core::IDocument
{
Q_OBJECT
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -268,24 +268,6 @@ QmakePriFile::QmakePriFile(QmakeProjectManager::QmakePriFileNode *qmakePriFile)
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
{
Q_UNUSED(state)
......
......@@ -241,10 +241,6 @@ class QmakePriFile : public Core::IDocument
Q_OBJECT
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -95,15 +95,9 @@ namespace Internal {
class QmakeProjectFile : public Core::IDocument
{
Q_OBJECT
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
};
......@@ -254,22 +248,6 @@ QmakeProjectFile::QmakeProjectFile(const QString &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
{
Q_UNUSED(state)
......
......@@ -41,21 +41,6 @@ QmlProjectFile::QmlProjectFile(QmlProject *parent, const Utils::FileName &fileNa
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
{
Q_UNUSED(state)
......
......@@ -37,15 +37,9 @@ namespace Internal {
class QmlProjectFile : public Core::IDocument
{
Q_OBJECT
public:
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -552,24 +552,6 @@ ResourceFileWatcher::ResourceFileWatcher(ResourceTopLevelNode *node)
setFilePath(node->filePath());
}
bool ResourceFileWatcher::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString);
Q_UNUSED(fileName);
Q_UNUSED(autoSave);
return false;
}
bool ResourceFileWatcher::isModified() const
{
return false;
}
bool ResourceFileWatcher::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior ResourceFileWatcher::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state)
......
......@@ -168,10 +168,6 @@ class ResourceFileWatcher : public Core::IDocument
Q_OBJECT
public:
ResourceFileWatcher(ResourceTopLevelNode *node);
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -41,24 +41,6 @@ TaskFile::TaskFile(QObject *parent) : Core::IDocument(parent)
setId("TaskList.TaskFile");
}
bool TaskFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
Q_UNUSED(errorString)
Q_UNUSED(fileName);
Q_UNUSED(autoSave)
return false;
}
bool TaskFile::isModified() const
{
return false;
}
bool TaskFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior TaskFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state);
......
......@@ -38,11 +38,6 @@ class TaskFile : public Core::IDocument
public:
TaskFile(QObject *parent);
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;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -115,11 +115,3 @@ Core::IDocument::ReloadBehavior SubmitEditorFile::reloadBehavior(ChangeTrigger s
Q_UNUSED(type)
return BehaviorSilent;
}
bool SubmitEditorFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
return true;
}
......@@ -47,10 +47,8 @@ public:
bool setContents(const QByteArray &contents) override;
bool isModified() const override { return m_modified; }
bool isSaveAsAllowed() const override { return false; }
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
void setModified(bool modified = true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment