forked from qt-creator/qt-creator
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:
@@ -34,6 +34,13 @@
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
||||
/*!
|
||||
\fn QString Core::IDocument::fileName() const
|
||||
Returns the absolute path of the file that this document refers to. May be empty for
|
||||
non-file documents.
|
||||
\sa setFileName()
|
||||
*/
|
||||
|
||||
namespace Core {
|
||||
|
||||
IDocument::IDocument(QObject *parent) : QObject(parent), m_infoBar(0), m_hasWriteWarning(false), m_restored(false)
|
||||
@@ -110,4 +117,20 @@ InfoBar *IDocument::infoBar()
|
||||
return m_infoBar;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set absolute file path for this file to \a fileName. Can be empty.
|
||||
The default implementation sets the file name and sends fileNameChanged() and changed()
|
||||
signals. Can be reimplemented by subclasses to do more.
|
||||
\sa fileName()
|
||||
*/
|
||||
void IDocument::setFileName(const QString &fileName)
|
||||
{
|
||||
if (m_fileName == fileName)
|
||||
return;
|
||||
QString oldName = m_fileName;
|
||||
m_fileName = fileName;
|
||||
emit fileNameChanged(oldName, m_fileName);
|
||||
emit changed();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
Reference in New Issue
Block a user