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

IDocument: Rename defaultPath and suggestedFileName



To fallbackSaveAsPath and fallbackSaveAsFileName. That makes it clearer
what they are for, and that they actually belong to each other.

Change-Id: Ie5b83b9db77d39a7fe9e979cc8f22b7f5b9101a3
Reviewed-by: default avatarDavid Schulz <david.schulz@theqtcompany.com>
parent 66088a79
...@@ -59,12 +59,12 @@ bool AndroidManifestDocument::save(QString *errorString, const QString &fileName ...@@ -59,12 +59,12 @@ bool AndroidManifestDocument::save(QString *errorString, const QString &fileName
return result; return result;
} }
QString AndroidManifestDocument::defaultPath() const QString AndroidManifestDocument::fallbackSaveAsPath() const
{ {
return filePath().toFileInfo().absolutePath(); return filePath().toFileInfo().absolutePath();
} }
QString AndroidManifestDocument::suggestedFileName() const QString AndroidManifestDocument::fallbackSaveAsFileName() const
{ {
return filePath().fileName(); return filePath().fileName();
} }
......
...@@ -45,8 +45,8 @@ public: ...@@ -45,8 +45,8 @@ public:
bool save(QString *errorString, const QString &fileName = QString(), bool save(QString *errorString, const QString &fileName = QString(),
bool autoSave = false) override; bool autoSave = false) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
......
...@@ -58,8 +58,8 @@ class JavaDocument : public TextEditor::TextDocument ...@@ -58,8 +58,8 @@ class JavaDocument : public TextEditor::TextDocument
{ {
public: public:
JavaDocument(); JavaDocument();
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
}; };
...@@ -70,12 +70,12 @@ JavaDocument::JavaDocument() ...@@ -70,12 +70,12 @@ JavaDocument::JavaDocument()
setIndenter(new JavaIndenter); setIndenter(new JavaIndenter);
} }
QString JavaDocument::defaultPath() const QString JavaDocument::fallbackSaveAsPath() const
{ {
return filePath().toFileInfo().absolutePath(); return filePath().toFileInfo().absolutePath();
} }
QString JavaDocument::suggestedFileName() const QString JavaDocument::fallbackSaveAsFileName() const
{ {
return filePath().fileName(); return filePath().fileName();
} }
......
...@@ -53,12 +53,12 @@ bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, b ...@@ -53,12 +53,12 @@ bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, b
return false; return false;
} }
QString AutotoolsProjectFile::defaultPath() const QString AutotoolsProjectFile::fallbackSaveAsPath() const
{ {
return QString(); return QString();
} }
QString AutotoolsProjectFile::suggestedFileName() const QString AutotoolsProjectFile::fallbackSaveAsFileName() const
{ {
return QString(); return QString();
} }
......
...@@ -58,8 +58,8 @@ public: ...@@ -58,8 +58,8 @@ public:
AutotoolsProjectFile(const QString &fileName); AutotoolsProjectFile(const QString &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override; bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
......
...@@ -339,9 +339,9 @@ private slots: ...@@ -339,9 +339,9 @@ private slots:
public: public:
QString defaultPath() const override { return QString(); } QString fallbackSaveAsPath() const override { return QString(); }
QString suggestedFileName() const override { return QString(); } QString fallbackSaveAsFileName() const override { return QString(); }
bool isModified() const override bool isModified() const override
{ {
......
...@@ -1541,7 +1541,7 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString ...@@ -1541,7 +1541,7 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString
return 0; return 0;
e->setForceReadOnly(true); e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_')); s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s); e->textDocument()->setFallbackSaveAsFileName(s);
if (!source.isEmpty()) if (!source.isEmpty())
e->setSource(source); e->setSource(source);
if (codec) if (codec)
......
...@@ -242,8 +242,8 @@ class CMakeDocument : public TextDocument ...@@ -242,8 +242,8 @@ class CMakeDocument : public TextDocument
public: public:
CMakeDocument(); CMakeDocument();
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
}; };
CMakeDocument::CMakeDocument() CMakeDocument::CMakeDocument()
...@@ -252,12 +252,12 @@ CMakeDocument::CMakeDocument() ...@@ -252,12 +252,12 @@ CMakeDocument::CMakeDocument()
setMimeType(QLatin1String(Constants::CMAKEMIMETYPE)); setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
} }
QString CMakeDocument::defaultPath() const QString CMakeDocument::fallbackSaveAsPath() const
{ {
return filePath().toFileInfo().absolutePath(); return filePath().toFileInfo().absolutePath();
} }
QString CMakeDocument::suggestedFileName() const QString CMakeDocument::fallbackSaveAsFileName() const
{ {
return filePath().fileName(); return filePath().fileName();
} }
......
...@@ -56,12 +56,12 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav ...@@ -56,12 +56,12 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav
return false; return false;
} }
QString CMakeFile::defaultPath() const QString CMakeFile::fallbackSaveAsPath() const
{ {
return QString(); return QString();
} }
QString CMakeFile::suggestedFileName() const QString CMakeFile::fallbackSaveAsFileName() const
{ {
return QString(); return QString();
} }
......
...@@ -46,8 +46,8 @@ public: ...@@ -46,8 +46,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override; bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
......
...@@ -67,7 +67,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent, ...@@ -67,7 +67,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
QString directory; QString directory;
QString fileName = document->filePath().toString(); QString fileName = document->filePath().toString();
if (fileName.isEmpty()) { if (fileName.isEmpty()) {
visibleName = document->suggestedFileName(); visibleName = document->fallbackSaveAsFileName();
} else { } else {
QFileInfo info = QFileInfo(fileName); QFileInfo info = QFileInfo(fileName);
directory = info.absolutePath(); directory = info.absolutePath();
......
...@@ -559,7 +559,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents, ...@@ -559,7 +559,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents,
if (document && document->isModified()) { if (document && document->isModified()) {
QString name = document->filePath().toString(); QString name = document->filePath().toString();
if (name.isEmpty()) if (name.isEmpty())
name = document->suggestedFileName(); name = document->fallbackSaveAsFileName();
// There can be several IDocuments pointing to the same file // There can be several IDocuments pointing to the same file
// Prefer one that is not readonly // Prefer one that is not readonly
...@@ -719,8 +719,8 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document, const QStr ...@@ -719,8 +719,8 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document, const QStr
QString path; QString path;
QString fileName; QString fileName;
if (absoluteFilePath.isEmpty()) { if (absoluteFilePath.isEmpty()) {
fileName = document->suggestedFileName(); fileName = document->fallbackSaveAsFileName();
const QString defaultPath = document->defaultPath(); const QString defaultPath = document->fallbackSaveAsPath();
if (!defaultPath.isEmpty()) if (!defaultPath.isEmpty())
path = defaultPath; path = defaultPath;
} else { } else {
......
...@@ -118,8 +118,8 @@ class RestoredDocument : public IDocument ...@@ -118,8 +118,8 @@ class RestoredDocument : public IDocument
{ {
public: public:
bool save(QString *, const QString &, bool) override { return false; } bool save(QString *, const QString &, bool) override { return false; }
QString defaultPath() const override { return filePath().toFileInfo().absolutePath(); } QString fallbackSaveAsPath() const override { return filePath().toFileInfo().absolutePath(); }
QString suggestedFileName() const override { return filePath().fileName(); } QString fallbackSaveAsFileName() const override { return filePath().fileName(); }
bool isModified() const override { return false; } bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return false; } bool isSaveAsAllowed() const override { return false; }
bool reload(QString *, ReloadFlag, ChangeType) override { return true; } bool reload(QString *, ReloadFlag, ChangeType) override { return true; }
......
...@@ -1930,7 +1930,7 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document) ...@@ -1930,7 +1930,7 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
if (!filePath.isEmpty()) { if (!filePath.isEmpty()) {
selectedFilter = mdb.mimeTypeForFile(filePath).filterString(); selectedFilter = mdb.mimeTypeForFile(filePath).filterString();
} else { } else {
const QString suggestedName = document->suggestedFileName(); const QString suggestedName = document->fallbackSaveAsFileName();
if (!suggestedName.isEmpty()) { if (!suggestedName.isEmpty()) {
const QList<MimeType> types = mdb.mimeTypesForFileName(suggestedName); const QList<MimeType> types = mdb.mimeTypesForFileName(suggestedName);
if (!types.isEmpty()) if (!types.isEmpty())
......
...@@ -108,8 +108,8 @@ public: ...@@ -108,8 +108,8 @@ public:
bool isTemporary() const; bool isTemporary() const;
void setTemporary(bool temporary); void setTemporary(bool temporary);
virtual QString defaultPath() const = 0; virtual QString fallbackSaveAsPath() const = 0;
virtual QString suggestedFileName() const = 0; virtual QString fallbackSaveAsFileName() const = 0;
QString mimeType() const; QString mimeType() const;
void setMimeType(const QString &mimeType); void setMimeType(const QString &mimeType);
......
...@@ -1195,7 +1195,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp ...@@ -1195,7 +1195,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
if (!e) if (!e)
return 0; return 0;
s.replace(QLatin1Char(' '), QLatin1Char('_')); s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s); e->textDocument()->setFallbackSaveAsFileName(s);
e->setForceReadOnly(true); e->setForceReadOnly(true);
if (!source.isEmpty()) if (!source.isEmpty())
e->setSource(source); e->setSource(source);
......
...@@ -3083,7 +3083,7 @@ void openTextEditor(const QString &titlePattern0, const QString &contents) ...@@ -3083,7 +3083,7 @@ void openTextEditor(const QString &titlePattern0, const QString &contents)
QString suggestion = titlePattern; QString suggestion = titlePattern;
if (!suggestion.contains(QLatin1Char('.'))) if (!suggestion.contains(QLatin1Char('.')))
suggestion.append(QLatin1String(".txt")); suggestion.append(QLatin1String(".txt"));
textEditor->textDocument()->setSuggestedFileName(suggestion); textEditor->textDocument()->setFallbackSaveAsFileName(suggestion);
} }
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
} }
......
...@@ -221,12 +221,12 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty ...@@ -221,12 +221,12 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
return true; return true;
} }
QString FormWindowFile::defaultPath() const QString FormWindowFile::fallbackSaveAsPath() const
{ {
return QString(); return QString();
} }
void FormWindowFile::setSuggestedFileName(const QString &fn) void FormWindowFile::setFallbackSaveAsFileName(const QString &fn)
{ {
if (Designer::Constants::Internal::debug) if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << filePath() << fn; qDebug() << Q_FUNC_INFO << filePath() << fn;
...@@ -234,7 +234,7 @@ void FormWindowFile::setSuggestedFileName(const QString &fn) ...@@ -234,7 +234,7 @@ void FormWindowFile::setSuggestedFileName(const QString &fn)
m_suggestedName = fn; m_suggestedName = fn;
} }
QString FormWindowFile::suggestedFileName() const QString FormWindowFile::fallbackSaveAsFileName() const
{ {
return m_suggestedName; return m_suggestedName;
} }
......
...@@ -61,11 +61,11 @@ public: ...@@ -61,11 +61,11 @@ public:
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override; bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
// Internal // Internal
void setSuggestedFileName(const QString &fileName); void setFallbackSaveAsFileName(const QString &fileName);
bool writeFile(const QString &fileName, QString *errorString) const; bool writeFile(const QString &fileName, QString *errorString) const;
......
...@@ -198,7 +198,7 @@ bool DiffEditorDocument::setContents(const QByteArray &contents) ...@@ -198,7 +198,7 @@ bool DiffEditorDocument::setContents(const QByteArray &contents)
return true; return true;
} }
QString DiffEditorDocument::defaultPath() const QString DiffEditorDocument::fallbackSaveAsPath() const
{ {
if (!m_baseDirectory.isEmpty()) if (!m_baseDirectory.isEmpty())
return m_baseDirectory; return m_baseDirectory;
...@@ -274,7 +274,7 @@ Core::IDocument::OpenResult DiffEditorDocument::open(QString *errorString, const ...@@ -274,7 +274,7 @@ Core::IDocument::OpenResult DiffEditorDocument::open(QString *errorString, const
return ok ? OpenResult::Success : OpenResult::CannotHandle; return ok ? OpenResult::Success : OpenResult::CannotHandle;
} }
QString DiffEditorDocument::suggestedFileName() const QString DiffEditorDocument::fallbackSaveAsFileName() const
{ {
const int maxSubjectLength = 50; const int maxSubjectLength = 50;
......
...@@ -71,8 +71,8 @@ public: ...@@ -71,8 +71,8 @@ public:
bool ignoreWhitespace() const; bool ignoreWhitespace() const;
bool setContents(const QByteArray &contents) override; bool setContents(const QByteArray &contents) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override { return false; } bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return true; } bool isSaveAsAllowed() const override { return true; }
......
...@@ -452,12 +452,12 @@ bool GenericProjectFile::save(QString *, const QString &, bool) ...@@ -452,12 +452,12 @@ bool GenericProjectFile::save(QString *, const QString &, bool)
return false; return false;
} }
QString GenericProjectFile::defaultPath() const QString GenericProjectFile::fallbackSaveAsPath() const
{ {
return QString(); return QString();
} }
QString GenericProjectFile::suggestedFileName() const QString GenericProjectFile::fallbackSaveAsFileName() const
{ {
return QString(); return QString();
} }
......
...@@ -120,8 +120,8 @@ public: ...@@ -120,8 +120,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override; bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
......
...@@ -268,12 +268,12 @@ bool ImageViewerFile::setContents(const QByteArray &contents) ...@@ -268,12 +268,12 @@ bool ImageViewerFile::setContents(const QByteArray &contents)
return false; return false;
} }
QString ImageViewerFile::defaultPath() const QString ImageViewerFile::fallbackSaveAsPath() const
{ {
return QString(); return QString();
} }
QString ImageViewerFile::suggestedFileName() const QString ImageViewerFile::fallbackSaveAsFileName() const
{ {
return QString(); return QString();
} }
......
...@@ -70,8 +70,8 @@ public: ...@@ -70,8 +70,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override; bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool setContents(const QByteArray &contents) override; bool setContents(const QByteArray &contents) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;
......
...@@ -106,12 +106,12 @@ bool ModelDocument::save(QString *errorString, const QString &name, bool autoSav ...@@ -106,12 +106,12 @@ bool ModelDocument::save(QString *errorString, const QString &name, bool autoSav
return true; return true;
} }
QString ModelDocument::defaultPath() const QString ModelDocument::fallbackSaveAsPath() const
{ {
return QLatin1String("."); return QLatin1String(".");
} }
QString ModelDocument::suggestedFileName() const QString ModelDocument::fallbackSaveAsFileName() const
{ {
return tr("model.qmodel"); return tr("model.qmodel");
} }
......
...@@ -57,8 +57,8 @@ public: ...@@ -57,8 +57,8 @@ 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 save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override; QString fallbackSaveAsPath() const override;
QString suggestedFileName() const override; QString fallbackSaveAsFileName() const override;
bool isModified() const override; bool isModified() const override;
bool isSaveAsAllowed() const override; bool isSaveAsAllowed() const override;