Make IDocument::fileName a member with setter.

Instead of requiring subclasses to implement a method.
Also renames IDocument::rename to IDocument::setFileName,
since it doesn't really rename any files or such.

Change-Id: I1344025c24d2f74a6a983e04fb0a5245f1f37aad
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Eike Ziller
2013-07-04 11:35:56 +02:00
parent 7dd81eca30
commit 99c383f3d0
34 changed files with 123 additions and 326 deletions

View File

@@ -94,31 +94,21 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa
return false;
}
const QString oldFileName = m_fileName;
m_fileName = fi.absoluteFilePath();
emit setDisplayName(fi.fileName());
m_formWindow->setDirty(false);
emit fileNameChanged(oldFileName, m_fileName);
setFileName(fi.absoluteFilePath());
emit changed();
emit saved();
return true;
}
void FormWindowFile::rename(const QString &newName)
void FormWindowFile::setFileName(const QString &newName)
{
m_formWindow->setFileName(newName);
QFileInfo fi(newName);
const QString oldFileName = m_fileName;
m_fileName = fi.absoluteFilePath();
emit setDisplayName(fi.fileName());
emit fileNameChanged(oldFileName, m_fileName);
emit changed();
}
QString FormWindowFile::fileName() const
{
return m_fileName;
IDocument::setFileName(fi.absoluteFilePath());
}
bool FormWindowFile::shouldAutoSave() const
@@ -144,7 +134,7 @@ bool FormWindowFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
emit changed();
} else {
emit aboutToReload();
emit reload(errorString, m_fileName);
emit reload(errorString, fileName());
const bool success = errorString->isEmpty();
emit reloadFinished(success);
return success;
@@ -157,12 +147,12 @@ QString FormWindowFile::defaultPath() const
return QString();
}
void FormWindowFile::setSuggestedFileName(const QString &fileName)
void FormWindowFile::setSuggestedFileName(const QString &fn)
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << m_fileName << fileName;
qDebug() << Q_FUNC_INFO << fileName() << fn;
m_suggestedName = fileName;
m_suggestedName = fn;
}
QString FormWindowFile::suggestedFileName() const
@@ -175,16 +165,11 @@ QString FormWindowFile::mimeType() const
return m_mimeType;
}
bool FormWindowFile::writeFile(const QString &fileName, QString *errorString) const
bool FormWindowFile::writeFile(const QString &fn, QString *errorString) const
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << m_fileName << fileName;
return write(fileName, format(), m_formWindow->contents(), errorString);
}
void FormWindowFile::setFileName(const QString &fname)
{
m_fileName = fname;
qDebug() << Q_FUNC_INFO << fileName() << fn;
return write(fn, format(), m_formWindow->contents(), errorString);
}
QDesignerFormWindowInterface *FormWindowFile::formWindow() const