Commit cfc89a68 authored by Eike Ziller's avatar Eike Ziller

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
return result;
}
QString AndroidManifestDocument::defaultPath() const
QString AndroidManifestDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString AndroidManifestDocument::suggestedFileName() const
QString AndroidManifestDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
......
......@@ -45,8 +45,8 @@ public:
bool save(QString *errorString, const QString &fileName = QString(),
bool autoSave = false) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -58,8 +58,8 @@ class JavaDocument : public TextEditor::TextDocument
{
public:
JavaDocument();
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
};
......@@ -70,12 +70,12 @@ JavaDocument::JavaDocument()
setIndenter(new JavaIndenter);
}
QString JavaDocument::defaultPath() const
QString JavaDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString JavaDocument::suggestedFileName() const
QString JavaDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
......
......@@ -53,12 +53,12 @@ bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, b
return false;
}
QString AutotoolsProjectFile::defaultPath() const
QString AutotoolsProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString AutotoolsProjectFile::suggestedFileName() const
QString AutotoolsProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -58,8 +58,8 @@ public:
AutotoolsProjectFile(const QString &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const 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,9 +339,9 @@ private slots:
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
{
......
......@@ -1541,7 +1541,7 @@ IEditor *ClearCasePlugin::showOutputInEditor(const QString& title, const QString
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s);
e->textDocument()->setFallbackSaveAsFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
......
......@@ -242,8 +242,8 @@ class CMakeDocument : public TextDocument
public:
CMakeDocument();
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
};
CMakeDocument::CMakeDocument()
......@@ -252,12 +252,12 @@ CMakeDocument::CMakeDocument()
setMimeType(QLatin1String(Constants::CMAKEMIMETYPE));
}
QString CMakeDocument::defaultPath() const
QString CMakeDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString CMakeDocument::suggestedFileName() const
QString CMakeDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
......
......@@ -56,12 +56,12 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav
return false;
}
QString CMakeFile::defaultPath() const
QString CMakeFile::fallbackSaveAsPath() const
{
return QString();
}
QString CMakeFile::suggestedFileName() const
QString CMakeFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -46,8 +46,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -67,7 +67,7 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
QString directory;
QString fileName = document->filePath().toString();
if (fileName.isEmpty()) {
visibleName = document->suggestedFileName();
visibleName = document->fallbackSaveAsFileName();
} else {
QFileInfo info = QFileInfo(fileName);
directory = info.absolutePath();
......
......@@ -559,7 +559,7 @@ static bool saveModifiedFilesHelper(const QList<IDocument *> &documents,
if (document && document->isModified()) {
QString name = document->filePath().toString();
if (name.isEmpty())
name = document->suggestedFileName();
name = document->fallbackSaveAsFileName();
// There can be several IDocuments pointing to the same file
// Prefer one that is not readonly
......@@ -719,8 +719,8 @@ QString DocumentManager::getSaveAsFileName(const IDocument *document, const QStr
QString path;
QString fileName;
if (absoluteFilePath.isEmpty()) {
fileName = document->suggestedFileName();
const QString defaultPath = document->defaultPath();
fileName = document->fallbackSaveAsFileName();
const QString defaultPath = document->fallbackSaveAsPath();
if (!defaultPath.isEmpty())
path = defaultPath;
} else {
......
......@@ -118,8 +118,8 @@ class RestoredDocument : public IDocument
{
public:
bool save(QString *, const QString &, bool) override { return false; }
QString defaultPath() const override { return filePath().toFileInfo().absolutePath(); }
QString suggestedFileName() const override { return filePath().fileName(); }
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; }
......
......@@ -1930,7 +1930,7 @@ bool EditorManagerPrivate::saveDocumentAs(IDocument *document)
if (!filePath.isEmpty()) {
selectedFilter = mdb.mimeTypeForFile(filePath).filterString();
} else {
const QString suggestedName = document->suggestedFileName();
const QString suggestedName = document->fallbackSaveAsFileName();
if (!suggestedName.isEmpty()) {
const QList<MimeType> types = mdb.mimeTypesForFileName(suggestedName);
if (!types.isEmpty())
......
......@@ -108,8 +108,8 @@ public:
bool isTemporary() const;
void setTemporary(bool temporary);
virtual QString defaultPath() const = 0;
virtual QString suggestedFileName() const = 0;
virtual QString fallbackSaveAsPath() const = 0;
virtual QString fallbackSaveAsFileName() const = 0;
QString mimeType() const;
void setMimeType(const QString &mimeType);
......
......@@ -1195,7 +1195,7 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp
if (!e)
return 0;
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s);
e->textDocument()->setFallbackSaveAsFileName(s);
e->setForceReadOnly(true);
if (!source.isEmpty())
e->setSource(source);
......
......@@ -3083,7 +3083,7 @@ void openTextEditor(const QString &titlePattern0, const QString &contents)
QString suggestion = titlePattern;
if (!suggestion.contains(QLatin1Char('.')))
suggestion.append(QLatin1String(".txt"));
textEditor->textDocument()->setSuggestedFileName(suggestion);
textEditor->textDocument()->setFallbackSaveAsFileName(suggestion);
}
QTC_ASSERT(editor, return);
}
......
......@@ -221,12 +221,12 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
return true;
}
QString FormWindowFile::defaultPath() const
QString FormWindowFile::fallbackSaveAsPath() const
{
return QString();
}
void FormWindowFile::setSuggestedFileName(const QString &fn)
void FormWindowFile::setFallbackSaveAsFileName(const QString &fn)
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << filePath() << fn;
......@@ -234,7 +234,7 @@ void FormWindowFile::setSuggestedFileName(const QString &fn)
m_suggestedName = fn;
}
QString FormWindowFile::suggestedFileName() const
QString FormWindowFile::fallbackSaveAsFileName() const
{
return m_suggestedName;
}
......
......@@ -61,11 +61,11 @@ public:
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
// Internal
void setSuggestedFileName(const QString &fileName);
void setFallbackSaveAsFileName(const QString &fileName);
bool writeFile(const QString &fileName, QString *errorString) const;
......
......@@ -198,7 +198,7 @@ bool DiffEditorDocument::setContents(const QByteArray &contents)
return true;
}
QString DiffEditorDocument::defaultPath() const
QString DiffEditorDocument::fallbackSaveAsPath() const
{
if (!m_baseDirectory.isEmpty())
return m_baseDirectory;
......@@ -274,7 +274,7 @@ Core::IDocument::OpenResult DiffEditorDocument::open(QString *errorString, const
return ok ? OpenResult::Success : OpenResult::CannotHandle;
}
QString DiffEditorDocument::suggestedFileName() const
QString DiffEditorDocument::fallbackSaveAsFileName() const
{
const int maxSubjectLength = 50;
......
......@@ -71,8 +71,8 @@ public:
bool ignoreWhitespace() const;
bool setContents(const QByteArray &contents) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override { return false; }
bool isSaveAsAllowed() const override { return true; }
......
......@@ -452,12 +452,12 @@ bool GenericProjectFile::save(QString *, const QString &, bool)
return false;
}
QString GenericProjectFile::defaultPath() const
QString GenericProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString GenericProjectFile::suggestedFileName() const
QString GenericProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -120,8 +120,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -268,12 +268,12 @@ bool ImageViewerFile::setContents(const QByteArray &contents)
return false;
}
QString ImageViewerFile::defaultPath() const
QString ImageViewerFile::fallbackSaveAsPath() const
{
return QString();
}
QString ImageViewerFile::suggestedFileName() const
QString ImageViewerFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -70,8 +70,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
bool setContents(const QByteArray &contents) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -106,12 +106,12 @@ bool ModelDocument::save(QString *errorString, const QString &name, bool autoSav
return true;
}
QString ModelDocument::defaultPath() const
QString ModelDocument::fallbackSaveAsPath() const
{
return QLatin1String(".");
}
QString ModelDocument::suggestedFileName() const
QString ModelDocument::fallbackSaveAsFileName() const
{
return tr("model.qmodel");
}
......
......@@ -57,8 +57,8 @@ public:
OpenResult open(QString *errorString, const QString &fileName,
const QString &realFileName) override;
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const 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;
......
......@@ -1241,7 +1241,7 @@ IEditor *PerforcePlugin::showOutputInEditor(const QString &title,
e->setForceReadOnly(true);
e->setSource(source);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s);
e->textDocument()->setFallbackSaveAsFileName(s);
if (codec)
e->setCodec(codec);
return editor;
......
......@@ -293,8 +293,8 @@ public:
return false;
}
QString defaultPath() const override { return QString(); }
QString suggestedFileName() const override { return QString(); }
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,12 +49,12 @@ bool QbsProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QbsProjectFile::defaultPath() const
QString QbsProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QbsProjectFile::suggestedFileName() const
QString QbsProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -47,8 +47,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -165,8 +165,8 @@ class ProFileDocument : public TextDocument
{
public:
ProFileDocument();
QString defaultPath() const override;
QString suggestedFileName() const override;
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,12 +179,12 @@ ProFileDocument::ProFileDocument()
setMimeType(QLatin1String(Constants::PROFILE_MIMETYPE));
}
QString ProFileDocument::defaultPath() const
QString ProFileDocument::fallbackSaveAsPath() const
{
return filePath().toFileInfo().absolutePath();
}
QString ProFileDocument::suggestedFileName() const
QString ProFileDocument::fallbackSaveAsFileName() const
{
return filePath().fileName();
}
......
......@@ -280,12 +280,12 @@ bool QmakePriFile::save(QString *errorString, const QString &fileName, bool auto
return false;
}
QString QmakePriFile::defaultPath() const
QString QmakePriFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmakePriFile::suggestedFileName() const
QString QmakePriFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -247,8 +247,8 @@ public:
QmakePriFile(QmakePriFileNode *qmakePriFile);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -104,8 +104,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......@@ -266,12 +266,12 @@ bool QmakeProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QmakeProjectFile::defaultPath() const
QString QmakeProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmakeProjectFile::suggestedFileName() const
QString QmakeProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -51,12 +51,12 @@ bool QmlProjectFile::save(QString *, const QString &, bool)
return false;
}
QString QmlProjectFile::defaultPath() const
QString QmlProjectFile::fallbackSaveAsPath() const
{
return QString();
}
QString QmlProjectFile::suggestedFileName() const
QString QmlProjectFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -48,8 +48,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -262,12 +262,12 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang
return true;
}
QString ResourceEditorDocument::defaultPath() const
QString ResourceEditorDocument::fallbackSaveAsPath() const
{
return QString();
}
QString ResourceEditorDocument::suggestedFileName() const
QString ResourceEditorDocument::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -66,8 +66,8 @@ public:
bool isModified() const override;
bool isSaveAsAllowed() const override;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
void setFilePath(const Utils::FileName &newName) override;
void setBlockDirtyChanged(bool value);
......
......@@ -565,12 +565,12 @@ bool ResourceFileWatcher::save(QString *errorString, const QString &fileName, bo
return false;
}
QString ResourceFileWatcher::defaultPath() const
QString ResourceFileWatcher::fallbackSaveAsPath() const
{
return QString();
}
QString ResourceFileWatcher::suggestedFileName() const
QString ResourceFileWatcher::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -175,8 +175,8 @@ public:
ResourceFileWatcher(ResourceTopLevelNode *node);
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -919,7 +919,7 @@ IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const QStrin
return 0;
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setSuggestedFileName(s);
e->textDocument()->setFallbackSaveAsFileName(s);
if (!source.isEmpty())
e->setSource(source);
if (codec)
......
......@@ -54,12 +54,12 @@ bool TaskFile::save(QString *errorString, const QString &fileName, bool autoSave
return false;
}
QString TaskFile::defaultPath() const
QString TaskFile::fallbackSaveAsPath() const
{
return QString();
}
QString TaskFile::suggestedFileName() const
QString TaskFile::fallbackSaveAsFileName() const
{
return QString();
}
......
......@@ -45,8 +45,8 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;
QString fallbackSaveAsFileName() const override;
bool isModified() const override;
bool isSaveAsAllowed() const override;
......
......@@ -429,22 +429,22 @@ bool TextDocument::isSaveAsAllowed() const
return true;
}
QString TextDocument::defaultPath() const
QString TextDocument::fallbackSaveAsPath() const
{
return d->m_defaultPath;
}
QString TextDocument::suggestedFileName() const
QString TextDocument::fallbackSaveAsFileName() const
{
return d->m_suggestedFileName;
}
void TextDocument::setDefaultPath(const QString &defaultPath)
void TextDocument::setFallbackSaveAsPath(const QString &defaultPath)
{
d->m_defaultPath = defaultPath;
}
void TextDocument::setSuggestedFileName(const QString &suggestedFileName)
void TextDocument::setFallbackSaveAsFileName(const QString &suggestedFileName)
{
d->m_suggestedFileName = suggestedFileName;
}
......
......@@ -113,11 +113,11 @@ public:
bool reload(QString *errorString, ReloadFlag flag, ChangeType type) override;
void setFilePath(const Utils::FileName &newName) override;
QString defaultPath() const override;
QString suggestedFileName() const override;
QString fallbackSaveAsPath() const override;