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;
......
Supports Markdown
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