Commit fc485e6b authored by Eike Ziller's avatar Eike Ziller
Browse files

Add default implementation for IDocument::fallbackSaveAs(Path|FileName)



The methods are only relevant for documents without a filePath, and
there was a mix of different irrelevant implementations present in
subclasses.

Change-Id: I4f57d306e5ddd913974cfe6ed0b4db062eb907a1
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 24f5bc7d
......@@ -59,16 +59,6 @@ bool AndroidManifestDocument::save(QString *errorString, const QString &fileName
return result;
}
QString AndroidManifestDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString AndroidManifestDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
bool AndroidManifestDocument::isModified() const
{
return TextDocument::isModified() || m_editorWidget->isModified();
......
......@@ -45,9 +45,6 @@ public:
bool save(QString *errorString, const QString &fileName = QString(),
bool autoSave = false) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -58,8 +58,6 @@ class JavaDocument : public TextEditor::TextDocument
{
public:
JavaDocument();
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
};
......@@ -70,17 +68,6 @@ JavaDocument::JavaDocument()
setIndenter(new JavaIndenter);
}
QString JavaDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString JavaDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
//
// JavaEditorFactory
//
......
......@@ -53,16 +53,6 @@ bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, b
return false;
}
QString AutotoolsProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString AutotoolsProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
bool AutotoolsProjectFile::isModified() const
{
return false;
......
......@@ -58,8 +58,6 @@ public:
AutotoolsProjectFile(const QString &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -339,10 +339,6 @@ private slots:
public:
QString fallbackSaveAsPath() const override { return QString(); }
QString fallbackSaveAsFileName() const override { return QString(); }
bool isModified() const override
{
return isTemporary()/*e.g. memory view*/ ? false
......
......@@ -241,9 +241,6 @@ class CMakeDocument : public TextDocument
{
public:
CMakeDocument();
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
};
CMakeDocument::CMakeDocument()
......@@ -252,16 +249,6 @@ CMakeDocument::CMakeDocument()
setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
}
QString CMakeDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString CMakeDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
//
// CMakeEditorFactory
//
......
......@@ -56,16 +56,6 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav
return false;
}
QString CMakeFile::fallbackSaveAsPath() const
{
return QString();
}
QString CMakeFile::fallbackSaveAsFileName() const
{
return QString();
}
bool CMakeFile::isModified() const
{
return false;
......
......@@ -46,9 +46,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -118,8 +118,6 @@ class RestoredDocument : public IDocument
{
public:
bool save(QString *, const QString &, bool) override { return false; }
QString fallbackSaveAsPath() const override { return filePath().toFileInfo().absolutePath(); }
QString fallbackSaveAsFileName() const override { return filePath().fileName(); }
bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return false; }
bool reload(QString *, ReloadFlag, ChangeType) override { return true; }
......
......@@ -211,6 +211,16 @@ void IDocument::setTemporary(bool temporary)
d->temporary = temporary;
}
QString IDocument::fallbackSaveAsPath() const
{
return QString();
}
QString IDocument::fallbackSaveAsFileName() const
{
return QString();
}
QString IDocument::mimeType() const
{
return d->mimeType;
......
......@@ -108,8 +108,8 @@ public:
bool isTemporary() const;
void setTemporary(bool temporary);
virtual QString fallbackSaveAsPath() const = 0;
virtual QString fallbackSaveAsFileName() const = 0;
virtual QString fallbackSaveAsPath() const;
virtual QString fallbackSaveAsFileName() const;
QString mimeType() const;
void setMimeType(const QString &mimeType);
......
......@@ -221,11 +221,6 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
return true;
}
QString FormWindowFile::fallbackSaveAsPath() const
{
return QString();
}
void FormWindowFile::setFallbackSaveAsFileName(const QString &fn)
{
if (Designer::Constants::Internal::debug)
......
......@@ -61,7 +61,6 @@ public:
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
// Internal
......
......@@ -452,16 +452,6 @@ bool GenericProjectFile::save(QString *, const QString &, bool)
return false;
}
QString GenericProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString GenericProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
bool GenericProjectFile::isModified() const
{
return false;
......
......@@ -120,9 +120,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -262,16 +262,6 @@ bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool a
return false;
}
QString ImageViewerFile::fallbackSaveAsPath() const
{
return QString();
}
QString ImageViewerFile::fallbackSaveAsFileName() const
{
return QString();
}
bool ImageViewerFile::isModified() const
{
return false;
......
......@@ -69,9 +69,6 @@ public:
const QString &realFileName) override;
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -106,16 +106,6 @@ bool ModelDocument::save(QString *errorString, const QString &name, bool autoSav
return true;
}
QString ModelDocument::fallbackSaveAsPath() const
{
return QLatin1String(".");
}
QString ModelDocument::fallbackSaveAsFileName() const
{
return tr("model.qmodel");
}
bool ModelDocument::isModified() const
{
return d->documentController ? d->documentController->projectController()->isModified() : false;
......
......@@ -57,8 +57,6 @@ public:
OpenResult open(QString *errorString, const QString &fileName,
const QString &realFileName) override;
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
......@@ -293,9 +293,6 @@ public:
return false;
}
QString fallbackSaveAsPath() const override { return QString(); }
QString fallbackSaveAsFileName() const override { return QString(); }
bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return false; }
......
......@@ -49,16 +49,6 @@ bool QbsProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QbsProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QbsProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
bool QbsProjectFile::isModified() const
{
return false;
......
......@@ -47,9 +47,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -165,8 +165,6 @@ class ProFileDocument : public TextDocument
{
public:
ProFileDocument();
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
// qmake project files doesn't support UTF8-BOM
// If the BOM would be added qmake would fail and QtCreator couldn't parse the project file
......@@ -179,16 +177,6 @@ ProFileDocument::ProFileDocument()
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
}
QString ProFileDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString ProFileDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
//
// ProFileEditorFactory
//
......
......@@ -280,16 +280,6 @@ bool QmakePriFile::save(QString *errorString, const QString &fileName, bool auto
return false;
}
QString QmakePriFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmakePriFile::fallbackSaveAsFileName() const
{
return QString();
}
bool QmakePriFile::isModified() const
{
return false;
......
......@@ -247,9 +247,6 @@ public:
QmakePriFile(QmakePriFileNode *qmakePriFile);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -104,9 +104,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......@@ -266,16 +263,6 @@ bool QmakeProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QmakeProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmakeProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
bool QmakeProjectFile::isModified() const
{
return false; // we save after changing anyway
......
......@@ -51,16 +51,6 @@ bool QmlProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QmlProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmlProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
bool QmlProjectFile::isModified() const
{
return false;
......
......@@ -48,9 +48,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -262,16 +262,6 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang
return true;
}
QString ResourceEditorDocument::fallbackSaveAsPath() const
{
return QString();
}
QString ResourceEditorDocument::fallbackSaveAsFileName() const
{
return QString();
}
void ResourceEditorDocument::dirtyChanged(bool dirty)
{
if (m_blockDirtyChanged)
......
......@@ -66,8 +66,6 @@ public:
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
void setFilePath(const Utils::FileName &newName) override;
void setBlockDirtyChanged(bool value);
......
......@@ -565,16 +565,6 @@ bool ResourceFileWatcher::save(QString *errorString, const QString &fileName, bo
return false;
}
QString ResourceFileWatcher::fallbackSaveAsPath() const
{
return QString();
}
QString ResourceFileWatcher::fallbackSaveAsFileName() const
{
return QString();
}
bool ResourceFileWatcher::isModified() const
{
return false;
......
......@@ -175,9 +175,6 @@ public:
ResourceFileWatcher(ResourceTopLevelNode *node);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -54,16 +54,6 @@ bool TaskFile::save(QString *errorString, const QString &fileName, bool autoSave
return false;
}
QString TaskFile::fallbackSaveAsPath() const
{
return QString();
}
QString TaskFile::fallbackSaveAsFileName() const
{
return QString();
}
bool TaskFile::isModified() const
{
return false;
......
......@@ -45,9 +45,6 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -50,8 +50,6 @@ public:
OpenResult open(QString *errorString, const QString &fileName,
const QString &realFileName) override;
bool setContents(const QByteArray &contents) override;
QString fallbackSaveAsPath() const override { return QString(); }
QString fallbackSaveAsFileName() const override { return QString(); }
bool isModified() const override { return m_modified; }
bool isSaveAsAllowed() const override { return false; }
......
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