summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp14
-rw-r--r--src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h3
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp45
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp18
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.h4
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp2
-rw-r--r--src/plugins/coreplugin/idocument.cpp23
-rw-r--r--src/plugins/coreplugin/idocument.h5
-rw-r--r--src/plugins/designer/formwindowfile.cpp35
-rw-r--r--src/plugins/designer/formwindowfile.h3
-rw-r--r--src/plugins/diffeditor/diffeditorfile.cpp14
-rw-r--r--src/plugins/diffeditor/diffeditorfile.h4
-rw-r--r--src/plugins/genericprojectmanager/genericproject.cpp17
-rw-r--r--src/plugins/genericprojectmanager/genericproject.h3
-rw-r--r--src/plugins/imageviewer/imageviewerfile.cpp22
-rw-r--r--src/plugins/imageviewer/imageviewerfile.h5
-rw-r--r--src/plugins/madde/maemoglobal.h10
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectfile.cpp19
-rw-r--r--src/plugins/qbsprojectmanager/qbsprojectfile.h3
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.cpp16
-rw-r--r--src/plugins/qmlprojectmanager/qmlprojectfile.h3
-rw-r--r--src/plugins/qnx/bardescriptordocument.cpp25
-rw-r--r--src/plugins/qnx/bardescriptordocument.h5
-rw-r--r--src/plugins/qt4projectmanager/qt4nodes.cpp14
-rw-r--r--src/plugins/qt4projectmanager/qt4nodes.h2
-rw-r--r--src/plugins/qt4projectmanager/qt4project.cpp19
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.cpp28
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.h5
-rw-r--r--src/plugins/tasklist/taskfile.cpp16
-rw-r--r--src/plugins/tasklist/taskfile.h3
-rw-r--r--src/plugins/texteditor/basetextdocument.cpp42
-rw-r--r--src/plugins/texteditor/basetextdocument.h3
-rw-r--r--src/plugins/vcsbase/submiteditorfile.cpp15
-rw-r--r--src/plugins/vcsbase/submiteditorfile.h4
34 files changed, 123 insertions, 326 deletions
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp
index f1d51367b3..052bab1d02 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp
+++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.cpp
@@ -38,9 +38,9 @@ using namespace AutotoolsProjectManager::Internal;
AutotoolsProjectFile::AutotoolsProjectFile(AutotoolsProject *project, const QString &fileName) :
Core::IDocument(project),
- m_project(project),
- m_fileName(fileName)
+ m_project(project)
{
+ setFileName(fileName);
}
bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, bool autoSave)
@@ -52,11 +52,6 @@ bool AutotoolsProjectFile::save(QString *errorString, const QString &fileName, b
return false;
}
-QString AutotoolsProjectFile::fileName() const
-{
- return m_fileName;
-}
-
QString AutotoolsProjectFile::defaultPath() const
{
return QString();
@@ -90,8 +85,3 @@ bool AutotoolsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeT
return false;
}
-
-void AutotoolsProjectFile::rename(const QString &newName)
-{
- Q_UNUSED(newName);
-}
diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h
index 4c69c7472c..74babf0962 100644
--- a/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h
+++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectfile.h
@@ -57,18 +57,15 @@ public:
AutotoolsProjectFile(AutotoolsProject *project, const QString &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
QString defaultPath() const;
QString suggestedFileName() const;
QString mimeType() const;
bool isModified() const;
bool isSaveAsAllowed() const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
private:
AutotoolsProject *m_project;
- QString m_fileName;
};
} // namespace Internal
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index 3998c3d2e3..1d1d411320 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -195,25 +195,22 @@ public:
return QLatin1String(Constants::C_BINEDITOR_MIMETYPE);
}
- bool save(QString *errorString, const QString &fileName, bool autoSave)
+ bool save(QString *errorString, const QString &fn, bool autoSave)
{
QTC_ASSERT(!autoSave, return true); // bineditor does not support autosave - it would be a bit expensive
const QString fileNameToUse
- = fileName.isEmpty() ? m_fileName : fileName;
- if (m_widget->save(errorString, m_fileName, fileNameToUse)) {
- m_fileName = fileNameToUse;
- m_widget->editor()->setDisplayName(QFileInfo(fileNameToUse).fileName());
- emit changed();
+ = fn.isEmpty() ? fileName() : fn;
+ if (m_widget->save(errorString, fileName(), fileNameToUse)) {
+ setFileName(fileNameToUse);
return true;
} else {
return false;
}
}
- void rename(const QString &newName) {
- m_fileName = newName;
- m_widget->editor()->setDisplayName(QFileInfo(fileName()).fileName());
- emit changed();
+ void setFileName(const QString &newName) {
+ m_widget->editor()->setDisplayName(QFileInfo(newName).fileName());
+ IDocument::setFileName(newName);
}
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
@@ -231,9 +228,8 @@ public:
return false;
if (file.open(QIODevice::ReadOnly)) {
file.close();
- m_fileName = fileName;
+ setFileName(fileName);
m_widget->setSizes(offset, file.size());
- m_widget->editor()->setDisplayName(QFileInfo(fileName).fileName());
return true;
}
QString errStr = tr("Cannot open %1: %2").arg(
@@ -248,9 +244,10 @@ public:
private slots:
void provideData(quint64 block)
{
- if (m_fileName.isEmpty())
+ const QString fn = fileName();
+ if (fn.isEmpty())
return;
- QFile file(m_fileName);
+ QFile file(fn);
if (file.open(QIODevice::ReadOnly)) {
int blockSize = m_widget->dataBlockSize();
file.seek(block * blockSize);
@@ -263,23 +260,17 @@ private slots:
} else {
QMessageBox::critical(Core::ICore::mainWindow(), tr("File Error"),
tr("Cannot open %1: %2").arg(
- QDir::toNativeSeparators(m_fileName), file.errorString()));
+ QDir::toNativeSeparators(fn), file.errorString()));
}
}
void provideNewRange(quint64 offset)
{
- open(0, m_fileName, offset);
+ open(0, fileName(), offset);
}
public:
- void setFilename(const QString &filename) {
- m_fileName = filename;
- }
-
- QString fileName() const { return m_fileName; }
-
QString defaultPath() const { return QString(); }
QString suggestedFileName() const { return QString(); }
@@ -287,9 +278,10 @@ public:
bool isModified() const { return m_widget->isMemoryView() ? false : m_widget->isModified(); }
bool isFileReadOnly() const {
- if (m_widget->isMemoryView() || m_fileName.isEmpty())
+ const QString fn = fileName();
+ if (m_widget->isMemoryView() || fn.isEmpty())
return false;
- const QFileInfo fi(m_fileName);
+ const QFileInfo fi(fn);
return !fi.isWritable();
}
@@ -302,7 +294,7 @@ public:
emit changed();
} else {
emit aboutToReload();
- const bool success = open(errorString, m_fileName);
+ const bool success = open(errorString, fileName());
emit reloadFinished(success);
return success;
}
@@ -311,7 +303,6 @@ public:
private:
BinEditorWidget *m_widget;
- QString m_fileName;
};
class BinEditor : public Core::IEditor
@@ -358,7 +349,7 @@ public:
bool createNew(const QString & /* contents */ = QString()) {
m_widget->clear();
- m_file->setFilename(QString());
+ m_file->setFileName(QString());
return true;
}
bool open(QString *errorString, const QString &fileName, const QString &realFileName) {
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 810371761b..daa70d3708 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -105,7 +105,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
: m_manager(manager),
m_activeTarget(0),
m_fileName(fileName),
- m_rootNode(new CMakeProjectNode(m_fileName)),
+ m_rootNode(new CMakeProjectNode(fileName)),
m_lastEditor(0)
{
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
@@ -897,9 +897,9 @@ void CMakeProject::buildStateChanged(ProjectExplorer::Project *project)
// CMakeFile
CMakeFile::CMakeFile(CMakeProject *parent, QString fileName)
- : Core::IDocument(parent), m_project(parent), m_fileName(fileName)
+ : Core::IDocument(parent), m_project(parent)
{
-
+ setFileName(fileName);
}
bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave)
@@ -912,11 +912,6 @@ bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSav
return false;
}
-QString CMakeFile::fileName() const
-{
- return m_fileName;
-}
-
QString CMakeFile::defaultPath() const
{
return QString();
@@ -943,13 +938,6 @@ bool CMakeFile::isSaveAsAllowed() const
return false;
}
-void CMakeFile::rename(const QString &newName)
-{
- Q_ASSERT(false);
- Q_UNUSED(newName);
- // Can't happen....
-}
-
Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state)
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index f19422dcfc..543f3bdc8f 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -204,7 +204,6 @@ public:
CMakeFile(CMakeProject *parent, QString fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
QString defaultPath() const;
QString suggestedFileName() const;
@@ -216,11 +215,8 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
-
private:
CMakeProject *m_project;
- QString m_fileName;
};
class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index 4f10f51430..b53b1a6882 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -385,7 +385,7 @@ void DocumentManager::renamedFile(const QString &from, const QString &to)
foreach (IDocument *document, documentsToRename) {
d->m_blockedIDocument = document;
removeFileInfo(document);
- document->rename(to);
+ document->setFileName(to);
addFileInfo(document);
d->m_blockedIDocument = 0;
}
diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp
index 01ec58af3e..f737e22681 100644
--- a/src/plugins/coreplugin/idocument.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -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
diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h
index c543366316..36889a8ec9 100644
--- a/src/plugins/coreplugin/idocument.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -82,7 +82,8 @@ public:
virtual ~IDocument();
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
- virtual QString fileName() const = 0;
+ QString fileName() const { return m_fileName; }
+ virtual void setFileName(const QString &fileName);
virtual bool isFileReadOnly() const;
virtual QString defaultPath() const = 0;
@@ -95,7 +96,6 @@ public:
virtual ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
virtual bool reload(QString *errorString, ReloadFlag flag, ChangeType type) = 0;
- virtual void rename(const QString &newName) = 0;
virtual void checkPermissions();
@@ -117,6 +117,7 @@ signals:
void fileNameChanged(const QString &oldName, const QString &newName);
private:
+ QString m_fileName;
QString m_autoSaveName;
InfoBar *m_infoBar;
bool m_hasWriteWarning;
diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp
index 1aa35fc472..dd4e7caf02 100644
--- a/src/plugins/designer/formwindowfile.cpp
+++ b/src/plugins/designer/formwindowfile.cpp
@@ -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
diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h
index 9df02334b7..3228a381bc 100644
--- a/src/plugins/designer/formwindowfile.h
+++ b/src/plugins/designer/formwindowfile.h
@@ -51,7 +51,6 @@ public:
// IDocument
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
- virtual QString fileName() const;
virtual bool shouldAutoSave() const;
virtual bool isModified() const;
virtual bool isSaveAsAllowed() const;
@@ -59,7 +58,6 @@ public:
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
virtual QString mimeType() const;
- virtual void rename(const QString &newName);
// Internal
void setSuggestedFileName(const QString &fileName);
@@ -84,7 +82,6 @@ private slots:
private:
const QString m_mimeType;
- QString m_fileName;
QString m_suggestedName;
bool m_shouldAutoSave;
// Might actually go out of scope before the IEditor due
diff --git a/src/plugins/diffeditor/diffeditorfile.cpp b/src/plugins/diffeditor/diffeditorfile.cpp
index ede0392bd2..1825eea775 100644
--- a/src/plugins/diffeditor/diffeditorfile.cpp
+++ b/src/plugins/diffeditor/diffeditorfile.cpp
@@ -41,20 +41,6 @@ DiffEditorFile::DiffEditorFile(const QString &mimeType, QObject *parent) :
{
}
-void DiffEditorFile::rename(const QString &newName)
-{
- Q_UNUSED(newName);
- return;
-}
-
-void DiffEditorFile::setFileName(const QString &name)
-{
- if (m_fileName == name)
- return;
- m_fileName = name;
- emit changed();
-}
-
void DiffEditorFile::setModified(bool modified)
{
if (m_modified == modified)
diff --git a/src/plugins/diffeditor/diffeditorfile.h b/src/plugins/diffeditor/diffeditorfile.h
index 4a45fb4aa5..081253e6f9 100644
--- a/src/plugins/diffeditor/diffeditorfile.h
+++ b/src/plugins/diffeditor/diffeditorfile.h
@@ -48,7 +48,6 @@ public:
explicit DiffEditorFile(const QString &mimeType,
QObject *parent = 0);
- QString fileName() const { return m_fileName; }
QString defaultPath() const { return QString(); }
QString suggestedFileName() const { return QString(); }
@@ -58,9 +57,7 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
- void setFileName(const QString &name);
void setModified(bool modified = true);
signals:
@@ -69,7 +66,6 @@ signals:
private:
const QString m_mimeType;
bool m_modified;
- QString m_fileName;
};
} // namespace Internal
diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp
index afa10b6b59..2f36899ba7 100644
--- a/src/plugins/genericprojectmanager/genericproject.cpp
+++ b/src/plugins/genericprojectmanager/genericproject.cpp
@@ -455,18 +455,14 @@ bool GenericProject::fromMap(const QVariantMap &map)
GenericProjectFile::GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options)
: IDocument(parent),
m_project(parent),
- m_fileName(fileName),
m_options(options)
-{ }
-
-bool GenericProjectFile::save(QString *, const QString &, bool)
{
- return false;
+ setFileName(fileName);
}
-QString GenericProjectFile::fileName() const
+bool GenericProjectFile::save(QString *, const QString &, bool)
{
- return m_fileName;
+ return false;
}
QString GenericProjectFile::defaultPath() const
@@ -494,13 +490,6 @@ bool GenericProjectFile::isSaveAsAllowed() const
return false;
}
-void GenericProjectFile::rename(const QString &newName)
-{
- // Can't happen
- Q_UNUSED(newName);
- QTC_CHECK(false);
-}
-
IDocument::ReloadBehavior GenericProjectFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state)
diff --git a/src/plugins/genericprojectmanager/genericproject.h b/src/plugins/genericprojectmanager/genericproject.h
index 917a69482f..f4f2fb5457 100644
--- a/src/plugins/genericprojectmanager/genericproject.h
+++ b/src/plugins/genericprojectmanager/genericproject.h
@@ -128,7 +128,6 @@ public:
GenericProjectFile(GenericProject *parent, QString fileName, GenericProject::RefreshOptions options);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
QString defaultPath() const;
QString suggestedFileName() const;
@@ -136,14 +135,12 @@ public:
bool isModified() const;
bool isSaveAsAllowed() const;
- void rename(const QString &newName);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
GenericProject *m_project;
- QString m_fileName;
GenericProject::RefreshOptions m_options;
};
diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp
index 0f3850f896..36da85b7f7 100644
--- a/src/plugins/imageviewer/imageviewerfile.cpp
+++ b/src/plugins/imageviewer/imageviewerfile.cpp
@@ -61,7 +61,7 @@ bool ImageViewerFile::reload(QString *errorString,
emit changed();
return true;
}
- return m_editor->open(errorString, m_fileName, m_fileName);
+ return m_editor->open(errorString, fileName(), fileName());
}
bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool autoSave)
@@ -72,18 +72,10 @@ bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool a
return false;
}
-void ImageViewerFile::rename(const QString &newName)
+void ImageViewerFile::setFileName(const QString &newName)
{
- const QString oldFilename = m_fileName;
- m_fileName = newName;
- m_editor->setDisplayName(QFileInfo(m_fileName).fileName());
- emit fileNameChanged(oldFilename, newName);
- emit changed();
-}
-
-QString ImageViewerFile::fileName() const
-{
- return m_fileName;
+ m_editor->setDisplayName(QFileInfo(newName).fileName());
+ IDocument::setFileName(newName);
}
QString ImageViewerFile::defaultPath() const
@@ -117,11 +109,5 @@ void ImageViewerFile::setMimetype(const QString &mimetype)
emit changed();
}
-void ImageViewerFile::setFileName(const QString &filename)
-{
- m_fileName = filename;
- emit changed();
-}
-
} // namespace Internal
} // namespace ImageViewer
diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h
index ab913de68a..bc2c254d29 100644
--- a/src/plugins/imageviewer/imageviewerfile.h
+++ b/src/plugins/imageviewer/imageviewerfile.h
@@ -46,8 +46,7 @@ public:
explicit ImageViewerFile(ImageViewer *parent = 0);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- void rename(const QString &newName);
- QString fileName() const;
+ void setFileName(const QString &newName);
QString defaultPath() const;
QString suggestedFileName() const;
@@ -60,10 +59,8 @@ public:
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
void setMimetype(const QString &mimetype);
- void setFileName(const QString &filename);
private:
- QString m_fileName;
QString m_mimeType;
ImageViewer *m_editor;
};
diff --git a/src/plugins/madde/maemoglobal.h b/src/plugins/madde/maemoglobal.h
index 61a2fed058..33cdf9ad6a 100644
--- a/src/plugins/madde/maemoglobal.h
+++ b/src/plugins/madde/maemoglobal.h
@@ -56,10 +56,12 @@ class WatchableFile : public Core::IDocument
Q_OBJECT
public:
WatchableFile(const QString &fileName, QObject *parent = 0)
- : Core::IDocument(parent), m_fileName(fileName) {}
+ : Core::IDocument(parent)
+ {
+ setFileName(fileName);
+ }
bool save(QString *, const QString &, bool) { return false; }
- QString fileName() const { return m_fileName; }
QString defaultPath() const { return QString(); }
QString suggestedFileName() const { return QString(); }
QString mimeType() const { return QLatin1String("text/plain"); }
@@ -67,13 +69,9 @@ public:
bool isSaveAsAllowed() const { return false; }
ReloadBehavior reloadBehavior(ChangeTrigger, ChangeType) const { return BehaviorSilent; }
bool reload(QString *, ReloadFlag, ChangeType) { emit modified(); return true; }
- void rename(const QString &) {}
signals:
void modified();
-
-private:
- QString m_fileName;
};
class MaemoGlobal
diff --git a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp b/src/plugins/qbsprojectmanager/qbsprojectfile.cpp
index 14ea3b3e96..aa9aad6c64 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectfile.cpp
+++ b/src/plugins/qbsprojectmanager/qbsprojectfile.cpp
@@ -36,9 +36,10 @@ namespace QbsProjectManager {
namespace Internal {
QbsProjectFile::QbsProjectFile(QbsProject *parent, QString fileName) : Core::IDocument(parent),
- m_project(parent),
- m_fileName(fileName)
-{ }
+ m_project(parent)
+{
+ setFileName(fileName);
+}
QbsProjectFile::~QbsProjectFile()
{ }
@@ -48,11 +49,6 @@ bool QbsProjectFile::save(QString *, const QString &, bool)
return false;
}
-QString QbsProjectFile::fileName() const
-{
- return m_fileName;
-}
-
bool QbsProjectFile::isReadOnly() const
{
return true;
@@ -100,13 +96,6 @@ bool QbsProjectFile::reload(QString *errorString, ReloadFlag flag, ChangeType ty
return true;
}
-void QbsProjectFile::rename(const QString &newName)
-{
- // Can't happen
- Q_UNUSED(newName);
- Q_ASSERT(false);
-}
-
} // namespace Internal
} // namespace QbsProjectManager
diff --git a/src/plugins/qbsprojectmanager/qbsprojectfile.h b/src/plugins/qbsprojectmanager/qbsprojectfile.h
index bc45062b3c..6eea015168 100644
--- a/src/plugins/qbsprojectmanager/qbsprojectfile.h
+++ b/src/plugins/qbsprojectmanager/qbsprojectfile.h
@@ -46,7 +46,6 @@ public:
~QbsProjectFile();
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
bool isReadOnly() const;
QString defaultPath() const;
@@ -58,11 +57,9 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
private:
QbsProject *m_project;
- QString m_fileName;
};
} // namespace Internal
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
index 93ca0ccac8..c85ddddbb4 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
+++ b/src/plugins/qmlprojectmanager/qmlprojectfile.cpp
@@ -37,11 +37,11 @@ namespace Internal {
QmlProjectFile::QmlProjectFile(QmlProject *parent, QString fileName)
: Core::IDocument(parent),
- m_project(parent),
- m_fileName(fileName)
+ m_project(parent)
{
QTC_CHECK(m_project);
QTC_CHECK(!fileName.isEmpty());
+ setFileName(fileName);
}
QmlProjectFile::~QmlProjectFile()
@@ -53,18 +53,6 @@ bool QmlProjectFile::save(QString *, const QString &, bool)
return false;
}
-void QmlProjectFile::rename(const QString &newName)
-{
- // Can't happen...
- Q_UNUSED(newName);
- Q_ASSERT(false);
-}
-
-QString QmlProjectFile::fileName() const
-{
- return m_fileName;
-}
-
QString QmlProjectFile::defaultPath() const
{
return QString();
diff --git a/src/plugins/qmlprojectmanager/qmlprojectfile.h b/src/plugins/qmlprojectmanager/qmlprojectfile.h
index 36c5a3c7e4..842d9f5297 100644
--- a/src/plugins/qmlprojectmanager/qmlprojectfile.h
+++ b/src/plugins/qmlprojectmanager/qmlprojectfile.h
@@ -47,8 +47,6 @@ public:
virtual ~QmlProjectFile();
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
- virtual QString fileName() const;
- virtual void rename(const QString &newName);
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
@@ -62,7 +60,6 @@ public:
private:
QmlProject *m_project;
- QString m_fileName;
};
} // namespace Internal
diff --git a/src/plugins/qnx/bardescriptordocument.cpp b/src/plugins/qnx/bardescriptordocument.cpp
index 7b78bf7748..6ba4da0566 100644
--- a/src/plugins/qnx/bardescriptordocument.cpp
+++ b/src/plugins/qnx/bardescriptordocument.cpp
@@ -94,8 +94,7 @@ bool BarDescriptorDocument::open(QString *errorString, const QString &fileName)
if (read(fileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess)
return false;
- m_fileName = fileName;
- m_editorWidget->editor()->setDisplayName(QFileInfo(fileName).fileName());
+ setFileName(fileName);
bool result = loadContent(contents);
@@ -105,12 +104,12 @@ bool BarDescriptorDocument::open(QString *errorString, const QString &fileName)
return result;
}
-bool BarDescriptorDocument::save(QString *errorString, const QString &fileName, bool autoSave)
+bool BarDescriptorDocument::save(QString *errorString, const QString &fn, bool autoSave)
{
QTC_ASSERT(!autoSave, return false);
- QTC_ASSERT(fileName.isEmpty(), return false);
+ QTC_ASSERT(fn.isEmpty(), return false);
- bool result = write(m_fileName, xmlSource(), errorString);
+ bool result = write(fileName(), xmlSource(), errorString);
if (!result)
return false;
@@ -119,11 +118,6 @@ bool BarDescriptorDocument::save(QString *errorString, const QString &fileName,
return true;
}
-QString BarDescriptorDocument::fileName() const
-{
- return m_fileName;
-}
-
QString BarDescriptorDocument::defaultPath() const
{
QFileInfo fi(fileName());
@@ -172,16 +166,13 @@ bool BarDescriptorDocument::reload(QString *errorString, Core::IDocument::Reload
if (flag == Core::IDocument::FlagIgnore)
return true;
- return open(errorString, m_fileName);
+ return open(errorString, fileName());
}
-void BarDescriptorDocument::rename(const QString &newName)
+void BarDescriptorDocument::setFileName(const QString &newName)
{
- const QString oldFilename = m_fileName;
- m_fileName = newName;
- m_editorWidget->editor()->setDisplayName(QFileInfo(m_fileName).fileName());
- emit fileNameChanged(oldFilename, newName);
- emit changed();
+ m_editorWidget->editor()->setDisplayName(QFileInfo(newName).fileName());
+ IDocument::setFileName(newName);
}
QString BarDescriptorDocument::xmlSource() const
diff --git a/src/plugins/qnx/bardescriptordocument.h b/src/plugins/qnx/bardescriptordocument.h
index 1f271801b7..b8fb3a0d08 100644
--- a/src/plugins/qnx/bardescriptordocument.h
+++ b/src/plugins/qnx/bardescriptordocument.h
@@ -58,7 +58,6 @@ public:
bool open(QString *errorString, const QString &fileName);
bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false);
- QString fileName() const;
QString defaultPath() const;
QString suggestedFileName() const;
@@ -70,7 +69,7 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
+ void setFileName(const QString &newName);
QString xmlSource() const;
bool loadContent(const QString &xmlSource, QString *errorMessage = 0, int *errorLine = 0);
@@ -82,8 +81,6 @@ private:
QList<BarDescriptorDocumentAbstractNodeHandler *> m_nodeHandlers;
- QString m_fileName;
-
BarDescriptorEditorWidget *m_editorWidget;
};
diff --git a/src/plugins/qt4projectmanager/qt4nodes.cpp b/src/plugins/qt4projectmanager/qt4nodes.cpp
index b66cb033e3..e8beaceb8d 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.cpp
+++ b/src/plugins/qt4projectmanager/qt4nodes.cpp
@@ -173,7 +173,7 @@ using namespace Qt4ProjectManager::Internal;
Qt4PriFile::Qt4PriFile(Qt4ProjectManager::Qt4PriFileNode *qt4PriFile)
: IDocument(qt4PriFile), m_priFile(qt4PriFile)
{
-
+ setFileName(m_priFile->path());
}
bool Qt4PriFile::save(QString *errorString, const QString &fileName, bool autoSave)
@@ -184,18 +184,6 @@ bool Qt4PriFile::save(QString *errorString, const QString &fileName, bool autoSa
return false;
}
-void Qt4PriFile::rename(const QString &newName)
-{
- // Can't happen
- Q_ASSERT(false);
- Q_UNUSED(newName);
-}
-
-QString Qt4PriFile::fileName() const
-{
- return m_priFile->path();
-}
-
QString Qt4PriFile::defaultPath() const
{
return QString();
diff --git a/src/plugins/qt4projectmanager/qt4nodes.h b/src/plugins/qt4projectmanager/qt4nodes.h
index b2e4967861..e8828c5edc 100644
--- a/src/plugins/qt4projectmanager/qt4nodes.h
+++ b/src/plugins/qt4projectmanager/qt4nodes.h
@@ -227,8 +227,6 @@ class Qt4PriFile : public Core::IDocument
public:
Qt4PriFile(Qt4PriFileNode *qt4PriFile);
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
- virtual QString fileName() const;
- virtual void rename(const QString &newName);
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index 8922ad874a..bb5c147d04 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -120,8 +120,6 @@ public:
Qt4ProjectFile(const QString &filePath, QObject *parent = 0);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
- virtual void rename(const QString &newName);
QString defaultPath() const;
QString suggestedFileName() const;
@@ -135,7 +133,6 @@ public:
private:
const QString m_mimeType;
- QString m_filePath;
};
/// Watches folders for Qt4PriFile nodes
@@ -270,9 +267,9 @@ void ProjectFilesVisitor::visitFolderNode(FolderNode *folderNode)
namespace Internal {
Qt4ProjectFile::Qt4ProjectFile(const QString &filePath, QObject *parent)
: Core::IDocument(parent),
- m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)),
- m_filePath(filePath)
+ m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE))
{
+ setFileName(filePath);
}
bool Qt4ProjectFile::save(QString *, const QString &, bool)
@@ -281,18 +278,6 @@ bool Qt4ProjectFile::save(QString *, const QString &, bool)
return false;
}
-void Qt4ProjectFile::rename(const QString &newName)
-{
- // Can't happen
- Q_UNUSED(newName);
- Q_ASSERT(false);
-}
-
-QString Qt4ProjectFile::fileName() const
-{
- return m_filePath;
-}
-
QString Qt4ProjectFile::defaultPath() const
{
return QString();
diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp
index 1b49ad1e3c..f7442cb7b9 100644
--- a/src/plugins/resourceeditor/resourceeditorw.cpp
+++ b/src/plugins/resourceeditor/resourceeditorw.cpp
@@ -65,6 +65,7 @@ ResourceEditorDocument::ResourceEditorDocument(ResourceEditorW *parent) :
m_mimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE)),
m_parent(parent)
{
+ setFileName(parent->m_resourceEditor->fileName());
if (debugResourceEditorW)
qDebug() << "ResourceEditorFile::ResourceEditorFile()";
}
@@ -142,7 +143,7 @@ bool ResourceEditorW::createNew(const QString &contents)
return false;
const bool rc = m_resourceEditor->load(saver.fileName());
- m_resourceEditor->setFileName(QString());
+ m_resourceDocument->setFileName(QString());
m_shouldAutoSave = false;
if (debugResourceEditorW)
qDebug() << "ResourceEditorW::createNew: " << contents << " (" << saver.fileName() << ") returns " << rc;
@@ -168,9 +169,8 @@ bool ResourceEditorW::open(QString *errorString, const QString &fileName, const
return false;
}
- m_resourceEditor->setFileName(fileName);
+ m_resourceDocument->setFileName(fileName);
m_resourceEditor->setDirty(fileName != realFileName);
- setDisplayName(fi.fileName());
m_shouldAutoSave = false;
m_diskIo = false;
@@ -205,19 +205,22 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo
return true;
}
- m_parent->setDisplayName(QFileInfo(actualName).fileName());
+ setFileName(actualName);
m_parent->m_diskIo = false;
emit changed();
return true;
}
-void ResourceEditorDocument::rename(const QString &newName)
+void ResourceEditorDocument::setFileName(const QString &newName)
{
- const QString oldName = m_parent->m_resourceEditor->fileName();
- m_parent->m_resourceEditor->setFileName(newName);
- emit fileNameChanged(oldName, newName); // TODO Are there other cases where the ressource file name changes?
- emit changed();
+ if (newName != m_parent->m_resourceEditor->fileName())
+ m_parent->m_resourceEditor->setFileName(newName);
+ if (newName.isEmpty())
+ m_parent->setDisplayName(m_parent->tr("untitled"));
+ else
+ m_parent->setDisplayName(QFileInfo(newName).fileName());
+ IDocument::setFileName(newName);
}
Core::Id ResourceEditorW::id() const
@@ -230,11 +233,6 @@ QWidget *ResourceEditorW::toolBar()
return m_toolBar;
}
-QString ResourceEditorDocument::fileName() const
-{
- return m_parent->m_resourceEditor->fileName();
-}
-
bool ResourceEditorDocument::shouldAutoSave() const
{
return m_parent->m_shouldAutoSave;
@@ -258,7 +256,7 @@ bool ResourceEditorDocument::reload(QString *errorString, ReloadFlag flag, Chang
emit changed();
} else {
emit aboutToReload();
- QString fn = m_parent->m_resourceEditor->fileName();
+ QString fn = fileName();
const bool success = m_parent->open(errorString, fn, fn);
emit reloadFinished(success);
return success;
diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h
index 22d71f69c8..ef174ed5c7 100644
--- a/src/plugins/resourceeditor/resourceeditorw.h
+++ b/src/plugins/resourceeditor/resourceeditorw.h
@@ -55,15 +55,14 @@ public:
//IDocument
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
bool shouldAutoSave() const;
bool isModified() const;
bool isSaveAsAllowed() const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
QString defaultPath() const;
QString suggestedFileName() const;
- virtual QString mimeType() const;
- virtual void rename(const QString &newName);
+ QString mimeType() const;
+ void setFileName(const QString &newName);
private:
const QString m_mimeType;
diff --git a/src/plugins/tasklist/taskfile.cpp b/src/plugins/tasklist/taskfile.cpp
index cd0aaeaf14..f329d3b980 100644
--- a/src/plugins/tasklist/taskfile.cpp
+++ b/src/plugins/tasklist/taskfile.cpp
@@ -53,11 +53,6 @@ bool TaskFile::save(QString *errorString, const QString &fileName, bool autoSave
return false;
}
-QString TaskFile::fileName() const
-{
- return m_fileName;
-}
-
QString TaskFile::defaultPath() const
{
return QString();
@@ -100,18 +95,13 @@ bool TaskFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
deleteLater();
return true;
}
- return open(errorString, m_fileName);
-}
-
-void TaskFile::rename(const QString &newName)
-{
- Q_UNUSED(newName);
+ return open(errorString, fileName());
}
bool TaskFile::open(QString *errorString, const QString &fileName)
{
- m_fileName = fileName;
- return TaskList::TaskListPlugin::instance()->loadFile(errorString, m_context, m_fileName);
+ setFileName(fileName);
+ return TaskList::TaskListPlugin::instance()->loadFile(errorString, m_context, fileName);
}
ProjectExplorer::Project *TaskFile::context() const
diff --git a/src/plugins/tasklist/taskfile.h b/src/plugins/tasklist/taskfile.h
index a0f917531d..268d607fee 100644
--- a/src/plugins/tasklist/taskfile.h
+++ b/src/plugins/tasklist/taskfile.h
@@ -46,7 +46,6 @@ public:
~TaskFile();
bool save(QString *errorString, const QString &fileName, bool autoSave);
- QString fileName() const;
QString defaultPath() const;
QString suggestedFileName() const;
@@ -57,7 +56,6 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
bool open(QString *errorString, const QString &fileName);
@@ -65,7 +63,6 @@ public:
void setContext(ProjectExplorer::Project *context);
private:
- QString m_fileName;
ProjectExplorer::Project *m_context;
};
diff --git a/src/plugins/texteditor/basetextdocument.cpp b/src/plugins/texteditor/basetextdocument.cpp
index 64fb435930..ee85d15753 100644
--- a/src/plugins/texteditor/basetextdocument.cpp
+++ b/src/plugins/texteditor/basetextdocument.cpp
@@ -57,7 +57,6 @@ class BaseTextDocumentPrivate
public:
explicit BaseTextDocumentPrivate(BaseTextDocument *q);
- QString m_fileName;
QString m_defaultPath;
QString m_suggestedFileName;
QString m_mimeType;
@@ -159,11 +158,6 @@ const ExtraEncodingSettings &BaseTextDocument::extraEncodingSettings() const
return d->m_extraEncodingSettings;
}
-QString BaseTextDocument::fileName() const
-{
- return d->m_fileName;
-}
-
bool BaseTextDocument::isSaveAsAllowed() const
{
return true;
@@ -214,7 +208,7 @@ ITextMarkable *BaseTextDocument::documentMarker() const
* If autosave is true, the cursor will be restored and some signals suppressed
* and we do not clean up the text file (cleanWhitespace(), ensureFinalNewLine()).
*/
-bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool autoSave)
+bool BaseTextDocument::save(QString *errorString, const QString &saveFileName, bool autoSave)
{
QTextCursor cursor(d->m_document);
@@ -252,9 +246,9 @@ bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool
cursor.endEditBlock();
}
- QString fName = d->m_fileName;
- if (!fileName.isEmpty())
- fName = fileName;
+ QString fName = fileName();
+ if (!saveFileName.isEmpty())
+ fName = saveFileName;
// check if UTF8-BOM has to be added or removed
Utils::TextFileFormat saveFormat = format();
@@ -294,11 +288,8 @@ bool BaseTextDocument::save(QString *errorString, const QString &fileName, bool
// inform about the new filename
const QFileInfo fi(fName);
- const QString oldFileName = d->m_fileName;
- d->m_fileName = QDir::cleanPath(fi.absoluteFilePath());
d->m_document->setModified(false);
- emit fileNameChanged(oldFileName, d->m_fileName);
- emit titleChanged(fi.fileName());
+ setFileName(QDir::cleanPath(fi.absoluteFilePath()));
emit changed();
return true;
}
@@ -308,19 +299,18 @@ bool BaseTextDocument::shouldAutoSave() const
return d->m_autoSaveRevision != d->m_document->revision();
}
-void BaseTextDocument::rename(const QString &newName)
+void BaseTextDocument::setFileName(const QString &newName)
{
+ if (newName == fileName())
+ return;
const QFileInfo fi(newName);
- const QString oldFileName = d->m_fileName;
- d->m_fileName = QDir::cleanPath(fi.absoluteFilePath());
- emit fileNameChanged(oldFileName, d->m_fileName);
+ IDocument::setFileName(QDir::cleanPath(fi.absoluteFilePath()));
emit titleChanged(fi.fileName());
- emit changed();
}
bool BaseTextDocument::isFileReadOnly() const
{
- if (d->m_fileName.isEmpty()) //have no corresponding file, so editing is ok
+ if (fileName().isEmpty()) //have no corresponding file, so editing is ok
return false;
return d->m_fileIsReadOnly;
}
@@ -333,8 +323,8 @@ bool BaseTextDocument::isModified() const
void BaseTextDocument::checkPermissions()
{
bool previousReadOnly = d->m_fileIsReadOnly;
- if (!d->m_fileName.isEmpty()) {
- const QFileInfo fi(d->m_fileName);
+ if (!fileName().isEmpty()) {
+ const QFileInfo fi(fileName());
d->m_fileIsReadOnly = !fi.isWritable();
} else {
d->m_fileIsReadOnly = false;
@@ -353,9 +343,6 @@ bool BaseTextDocument::open(QString *errorString, const QString &fileName, const
if (!fileName.isEmpty()) {
const QFileInfo fi(fileName);
d->m_fileIsReadOnly = !fi.isWritable();
- d->m_fileName = QDir::cleanPath(fi.absoluteFilePath());
-
- title = fi.fileName();
readResult = read(realFileName, &content, errorString);
d->m_document->setModified(false);
@@ -388,8 +375,7 @@ bool BaseTextDocument::open(QString *errorString, const QString &fileName, const
QTC_ASSERT(documentLayout, return true);
documentLayout->lastSaveRevision = d->m_autoSaveRevision = d->m_document->revision();
d->m_document->setModified(fileName != realFileName);
- emit titleChanged(title);
- emit changed();
+ setFileName(QDir::cleanPath(fi.absoluteFilePath()));
}
return readResult == Utils::TextFileFormat::ReadSuccess
|| readResult == Utils::TextFileFormat::ReadEncodingError;
@@ -411,7 +397,7 @@ bool BaseTextDocument::reload(QString *errorString)
if (documentLayout)
marks = documentLayout->documentClosing(); // removes text marks non-permanently
- bool success = open(errorString, d->m_fileName, d->m_fileName);
+ bool success = open(errorString, fileName(), fileName());
if (documentLayout)
documentLayout->documentReloaded(marks); // readds text marks
diff --git a/src/plugins/texteditor/basetextdocument.h b/src/plugins/texteditor/basetextdocument.h
index 3e9e90688b..5f374dc2f0 100644
--- a/src/plugins/texteditor/basetextdocument.h
+++ b/src/plugins/texteditor/basetextdocument.h
@@ -76,7 +76,6 @@ public:
// IDocument implementation.
virtual bool save(QString *errorString, const QString &fileName, bool autoSave);
- virtual QString fileName() const;
virtual bool shouldAutoSave() const;
virtual bool isFileReadOnly() const;
virtual bool isModified() const;
@@ -85,7 +84,7 @@ public:
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
virtual QString mimeType() const;
void setMimeType(const QString &mt);
- virtual void rename(const QString &newName);
+ void setFileName(const QString &newName);
virtual QString defaultPath() const;
virtual QString suggestedFileName() const;
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
index c07e604c1b..f4f43966d0 100644
--- a/src/plugins/vcsbase/submiteditorfile.cpp
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -46,21 +46,6 @@ SubmitEditorFile::SubmitEditorFile(const QString &mimeType, QObject *parent) :
{
}
-void SubmitEditorFile::rename(const QString &newName)
-{
- Q_UNUSED(newName);
- // We can't be renamed
- return;
-}
-
-void SubmitEditorFile::setFileName(const QString &name)
-{
- if (m_fileName == name)
- return;
- m_fileName = name;
- emit changed();
-}
-
void SubmitEditorFile::setModified(bool modified)
{
if (m_modified == modified)
diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h
index 51887946a1..ae0b0ab80d 100644
--- a/src/plugins/vcsbase/submiteditorfile.h
+++ b/src/plugins/vcsbase/submiteditorfile.h
@@ -42,7 +42,6 @@ public:
explicit SubmitEditorFile(const QString &mimeType,
QObject *parent = 0);
- QString fileName() const { return m_fileName; }
QString defaultPath() const { return QString(); }
QString suggestedFileName() const { return QString(); }
@@ -52,9 +51,7 @@ public:
bool save(QString *errorString, const QString &fileName, bool autoSave);
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void rename(const QString &newName);
- void setFileName(const QString &name);
void setModified(bool modified = true);
signals:
@@ -63,7 +60,6 @@ signals:
private:
const QString m_mimeType;
bool m_modified;
- QString m_fileName;
};