aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@digia.com>2013-07-04 22:25:15 +0200
committerEike Ziller <eike.ziller@digia.com>2013-07-10 17:26:15 +0200
commit113c5600c909791ddfea3d424a41d982dcdda6b7 (patch)
tree33638a66c8cd6f6f9c376d1aba52e8fca862a887
parent81eba6f9843179804ed2e53d490e718b12c04044 (diff)
Move displayName from IEditor to IDocument
The display name is not editor instance specific, but belongs to the document. Change-Id: I3c936f04a86e10e6ca30063d85036d85b4b5880e Reviewed-by: Daniel Teske <daniel.teske@digia.com>
-rw-r--r--src/plugins/bazaar/bazaarplugin.cpp2
-rw-r--r--src/plugins/bazaar/commiteditor.cpp3
-rw-r--r--src/plugins/bineditor/bineditorplugin.cpp11
-rw-r--r--src/plugins/clearcase/clearcasesubmiteditor.cpp3
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeeditor.cpp2
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.cpp20
-rw-r--r--src/plugins/cmakeprojectmanager/cmakeproject.h2
-rw-r--r--src/plugins/coreplugin/designmode.cpp6
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp52
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h5
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.cpp2
-rw-r--r--src/plugins/coreplugin/editormanager/ieditor.h5
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsmodel.cpp44
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsmodel.h4
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp2
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp6
-rw-r--r--src/plugins/coreplugin/idocument.cpp27
-rw-r--r--src/plugins/coreplugin/idocument.h4
-rw-r--r--src/plugins/cpaster/cpasterplugin.cpp2
-rw-r--r--src/plugins/debugger/disassembleragent.cpp2
-rw-r--r--src/plugins/debugger/qml/qmlengine.cpp4
-rw-r--r--src/plugins/designer/formwindoweditor.cpp23
-rw-r--r--src/plugins/designer/formwindoweditor.h2
-rw-r--r--src/plugins/designer/formwindowfile.cpp19
-rw-r--r--src/plugins/designer/formwindowfile.h3
-rw-r--r--src/plugins/diffeditor/diffeditor.cpp14
-rw-r--r--src/plugins/diffeditor/diffeditor.h3
-rw-r--r--src/plugins/diffeditor/diffeditorfile.cpp4
-rw-r--r--src/plugins/diffeditor/diffshoweditor.cpp15
-rw-r--r--src/plugins/diffeditor/diffshoweditor.h3
-rw-r--r--src/plugins/git/gitplugin.cpp2
-rw-r--r--src/plugins/imageviewer/imageviewer.cpp15
-rw-r--r--src/plugins/imageviewer/imageviewer.h2
-rw-r--r--src/plugins/imageviewer/imageviewerfile.cpp6
-rw-r--r--src/plugins/imageviewer/imageviewerfile.h1
-rw-r--r--src/plugins/mercurial/commiteditor.cpp3
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp2
-rw-r--r--src/plugins/perforce/perforcesubmiteditor.cpp3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp13
-rw-r--r--src/plugins/qmldesigner/shortcutmanager.cpp14
-rw-r--r--src/plugins/qnx/bardescriptordocument.cpp6
-rw-r--r--src/plugins/qnx/bardescriptordocument.h1
-rw-r--r--src/plugins/qnx/bardescriptoreditor.cpp14
-rw-r--r--src/plugins/qnx/bardescriptoreditor.h4
-rw-r--r--src/plugins/qnx/bardescriptoreditorwidget.cpp2
-rw-r--r--src/plugins/qt4projectmanager/qt4projectmanager.cpp20
-rw-r--r--src/plugins/qt4projectmanager/qt4projectmanager.h2
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.cpp39
-rw-r--r--src/plugins/resourceeditor/resourceeditorw.h9
-rw-r--r--src/plugins/subversion/subversionsubmiteditor.cpp3
-rw-r--r--src/plugins/texteditor/basetexteditor.cpp20
-rw-r--r--src/plugins/texteditor/basetexteditor.h5
-rw-r--r--src/plugins/texteditor/basetexteditor_p.h1
-rw-r--r--src/plugins/texteditor/plaintexteditor.cpp1
-rw-r--r--src/plugins/vcsbase/vcsbaseplugin.cpp4
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.cpp14
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.h2
57 files changed, 177 insertions, 325 deletions
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp
index e1797c3229..b5c0dda3ad 100644
--- a/src/plugins/bazaar/bazaarplugin.cpp
+++ b/src/plugins/bazaar/bazaarplugin.cpp
@@ -561,7 +561,7 @@ void BazaarPlugin::showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusIt
const QString msg = tr("Commit changes for \"%1\".").
arg(QDir::toNativeSeparators(m_submitRepository));
- commitEditor->setDisplayName(msg);
+ commitEditor->document()->setDisplayName(msg);
const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository);
commitEditor->setFields(m_submitRepository, branch,
diff --git a/src/plugins/bazaar/commiteditor.cpp b/src/plugins/bazaar/commiteditor.cpp
index b41a04012f..ea7fef2372 100644
--- a/src/plugins/bazaar/commiteditor.cpp
+++ b/src/plugins/bazaar/commiteditor.cpp
@@ -30,6 +30,7 @@
#include "branchinfo.h"
#include "bazaarcommitwidget.h"
+#include <coreplugin/idocument.h>
#include <vcsbase/submitfilemodel.h>
#include <QDebug>
@@ -40,7 +41,7 @@ CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *paramet
: VcsBase::VcsBaseSubmitEditor(parameters, new BazaarCommitWidget(parent)),
m_fileModel(0)
{
- setDisplayName(tr("Commit Editor"));
+ document()->setDisplayName(tr("Commit Editor"));
}
BazaarCommitWidget *CommitEditor::commitWidget()
diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp
index c447e3e65b..7308c99c70 100644
--- a/src/plugins/bineditor/bineditorplugin.cpp
+++ b/src/plugins/bineditor/bineditorplugin.cpp
@@ -208,11 +208,6 @@ public:
}
}
- void setFilePath(const QString &newName) {
- m_widget->editor()->setDisplayName(QFileInfo(newName).fileName());
- IDocument::setFilePath(newName);
- }
-
bool open(QString *errorString, const QString &fileName, quint64 offset = 0) {
QFile file(fileName);
quint64 size = static_cast<quint64>(file.size());
@@ -337,9 +332,8 @@ public:
widget->setEditor(this);
connect(m_widget, SIGNAL(cursorPositionChanged(int)), SLOT(updateCursorPosition(int)));
- connect(m_file, SIGNAL(changed()), SIGNAL(changed()));
connect(m_addressEdit, SIGNAL(editingFinished()), SLOT(jumpToAddress()));
- connect(m_widget, SIGNAL(modificationChanged(bool)), SIGNAL(changed()));
+ connect(m_widget, SIGNAL(modificationChanged(bool)), m_file, SIGNAL(changed()));
updateCursorPosition(m_widget->cursorPosition());
}
@@ -358,8 +352,6 @@ public:
}
Core::IDocument *document() { return m_file; }
Core::Id id() const { return Core::Id(Core::Constants::K_DEFAULT_BINARY_EDITOR_ID); }
- QString displayName() const { return m_displayName; }
- void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
QWidget *toolBar() { return m_toolBar; }
@@ -377,7 +369,6 @@ private slots:
private:
BinEditorWidget *m_widget;
- QString m_displayName;
BinEditorDocument *m_file;
QToolBar *m_toolBar;
QLineEdit *m_addressEdit;
diff --git a/src/plugins/clearcase/clearcasesubmiteditor.cpp b/src/plugins/clearcase/clearcasesubmiteditor.cpp
index ac24ec80b0..3d886a1b48 100644
--- a/src/plugins/clearcase/clearcasesubmiteditor.cpp
+++ b/src/plugins/clearcase/clearcasesubmiteditor.cpp
@@ -31,6 +31,7 @@
#include "clearcasesubmiteditor.h"
#include "clearcasesubmiteditorwidget.h"
+#include <coreplugin/idocument.h>
#include <vcsbase/submiteditorwidget.h>
#include <vcsbase/submitfilemodel.h>
@@ -40,7 +41,7 @@ ClearCaseSubmitEditor::ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorP
QWidget *parentWidget) :
VcsBase::VcsBaseSubmitEditor(parameters, new ClearCaseSubmitEditorWidget(parentWidget))
{
- setDisplayName(tr("ClearCase Check In"));
+ document()->setDisplayName(tr("ClearCase Check In"));
}
ClearCaseSubmitEditorWidget *ClearCaseSubmitEditor::submitEditorWidget()
diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
index 881e662fa8..88045e13af 100644
--- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp
@@ -60,7 +60,7 @@ CMakeEditor::CMakeEditor(CMakeEditorWidget *editor)
{
setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR,
TextEditor::Constants::C_TEXTEDITOR));
- connect(this, SIGNAL(changed()), this, SLOT(markAsChanged()));
+ connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged()));
}
Core::IEditor *CMakeEditor::duplicate(QWidget *parent)
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 16503b09fe..3b4f37e64a 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -85,9 +85,9 @@ using namespace ProjectExplorer;
// Who sets up the environment for cl.exe ? INCLUDEPATH and so on
// Test for form editor (loosely coupled)
-static inline bool isFormWindowEditor(const QObject *o)
+static inline bool isFormWindowDocument(const QObject *o)
{
- return o && !qstrcmp(o->metaObject()->className(), "Designer::FormWindowEditor");
+ return o && !qstrcmp(o->metaObject()->className(), "Designer::Internal::FormWindowFile");
}
// Return contents of form editor (loosely coupled)
@@ -822,8 +822,8 @@ void CMakeProject::updateCodeModelSupportFromEditor(const QString &uiFileName,
void CMakeProject::editorChanged(Core::IEditor *editor)
{
// Handle old editor
- if (isFormWindowEditor(m_lastEditor)) {
- disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (m_lastEditor && isFormWindowDocument(m_lastEditor->document())) {
+ disconnect(m_lastEditor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
if (m_dirtyUic) {
const QString contents = formWindowEditorContents(m_lastEditor);
updateCodeModelSupportFromEditor(m_lastEditor->document()->filePath(), contents);
@@ -834,8 +834,8 @@ void CMakeProject::editorChanged(Core::IEditor *editor)
m_lastEditor = editor;
// Handle new editor
- if (isFormWindowEditor(editor))
- connect(editor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (editor && isFormWindowDocument(editor->document()))
+ connect(editor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
}
void CMakeProject::editorAboutToClose(Core::IEditor *editor)
@@ -843,8 +843,8 @@ void CMakeProject::editorAboutToClose(Core::IEditor *editor)
if (m_lastEditor == editor) {
// Oh no our editor is going to be closed
// get the content first
- if (isFormWindowEditor(m_lastEditor)) {
- disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (isFormWindowDocument(m_lastEditor->document())) {
+ disconnect(m_lastEditor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
if (m_dirtyUic) {
const QString contents = formWindowEditorContents(m_lastEditor);
updateCodeModelSupportFromEditor(m_lastEditor->document()->filePath(), contents);
@@ -855,10 +855,10 @@ void CMakeProject::editorAboutToClose(Core::IEditor *editor)
}
}
-void CMakeProject::uiEditorContentsChanged()
+void CMakeProject::uiDocumentContentsChanged()
{
// cast sender, get filename
- if (!m_dirtyUic && isFormWindowEditor(sender()))
+ if (!m_dirtyUic && isFormWindowDocument(sender()))
m_dirtyUic = true;
}
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h
index 936139ea75..38c8ebddb1 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.h
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.h
@@ -119,7 +119,7 @@ private slots:
void editorChanged(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
- void uiEditorContentsChanged();
+ void uiDocumentContentsChanged();
void buildStateChanged(ProjectExplorer::Project *project);
void updateRunConfigurations();
diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp
index a591d995fc..4173f73b00 100644
--- a/src/plugins/coreplugin/designmode.cpp
+++ b/src/plugins/coreplugin/designmode.cpp
@@ -201,7 +201,7 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
bool mimeEditorAvailable = false;
- if (editor && editor->document()) {
+ if (editor) {
const QString mimeType = editor->document()->mimeType();
if (!mimeType.isEmpty()) {
foreach (DesignEditorInfo *editorInfo, d->m_editors) {
@@ -220,7 +220,7 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
}
}
if (d->m_currentEditor)
- disconnect(d->m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
+ disconnect(d->m_currentEditor.data()->document(), SIGNAL(changed()), this, SLOT(updateActions()));
if (!mimeEditorAvailable) {
setActiveContext(Context());
@@ -233,7 +233,7 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
d->m_currentEditor = editor;
if (d->m_currentEditor)
- connect(d->m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
+ connect(d->m_currentEditor.data()->document(), SIGNAL(changed()), this, SLOT(updateActions()));
emit actionsUpdated(d->m_currentEditor.data());
}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index bb403e12be..6666efe3b1 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1468,7 +1468,7 @@ IEditor *EditorManager::createEditor(const Id &editorId, const QString &fileName
IEditor *editor = factories.front()->createEditor(m_instance);
if (editor)
- connect(editor, SIGNAL(changed()), m_instance, SLOT(handleEditorStateChange()));
+ connect(editor->document(), SIGNAL(changed()), m_instance, SLOT(handleDocumentStateChange()));
if (editor)
emit m_instance->editorCreated(editor, fileName);
return editor;
@@ -1718,7 +1718,7 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
foreach (IEditor *editor, m_instance->openedEditors()) {
QString name = editor->document()->filePath();
if (name.isEmpty())
- name = editor->displayName();
+ name = editor->document()->displayName();
else
name = QFileInfo(name).completeBaseName();
docnames << name;
@@ -1747,10 +1747,10 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
return 0;
}
- if (title.isEmpty())
- title = edt->displayName();
+ if (!title.isEmpty())
+ edt->document()->setDisplayName(title);
+
- edt->setDisplayName(title);
m_instance->addEditor(edt);
QApplication::restoreOverrideCursor();
return edt;
@@ -1966,7 +1966,7 @@ void EditorManager::updateWindowTitle()
windowTitle.prepend(d->m_titleAddition + dashSep);
IEditor *curEditor = currentEditor();
if (curEditor) {
- QString editorName = curEditor->displayName();
+ QString editorName = curEditor->document()->displayName();
if (!editorName.isEmpty())
windowTitle.prepend(editorName + dashSep);
QString filePath = QFileInfo(curEditor->document()->filePath()).absoluteFilePath();
@@ -1978,16 +1978,16 @@ void EditorManager::updateWindowTitle()
ICore::mainWindow()->setWindowTitle(windowTitle);
}
-void EditorManager::handleEditorStateChange()
+void EditorManager::handleDocumentStateChange()
{
updateActions();
- IEditor *theEditor = qobject_cast<IEditor *>(sender());
- if (!theEditor->document()->isModified())
- theEditor->document()->removeAutoSaveFile();
+ IDocument *document= qobject_cast<IDocument *>(sender());
+ if (!document->isModified())
+ document->removeAutoSaveFile();
IEditor *currEditor = currentEditor();
- if (theEditor == currEditor) {
+ if (currEditor && currEditor->document() == document) {
updateWindowTitle();
- emit currentEditorStateChanged(currEditor);
+ emit currentDocumentStateChanged();
}
}
@@ -2032,21 +2032,6 @@ void EditorManager::updateMakeWritableWarning()
}
}
-QString EditorManager::fileNameForEditor(IEditor *editor)
-{
- QString fileName;
-
- if (editor) {
- if (!editor->document()->filePath().isEmpty()) {
- QFileInfo fileInfo(editor->document()->filePath());
- fileName = fileInfo.fileName();
- } else {
- fileName = editor->displayName();
- }
- }
- return fileName;
-}
-
void EditorManager::setupSaveActions(IEditor *editor, QAction *saveAction, QAction *saveAsAction, QAction *revertToSavedAction)
{
saveAction->setEnabled(editor != 0 && editor->document()->isModified());
@@ -2054,12 +2039,11 @@ void EditorManager::setupSaveActions(IEditor *editor, QAction *saveAction, QActi
revertToSavedAction->setEnabled(editor != 0
&& !editor->document()->filePath().isEmpty() && editor->document()->isModified());
- const QString fileName = fileNameForEditor(editor);
+ const QString documentName = editor ? editor->document()->displayName() : QString();
QString quotedName;
- if (!fileName.isEmpty())
- quotedName = QLatin1Char('"') + fileName + QLatin1Char('"');
- if (!quotedName.isEmpty()) {
+ if (!documentName.isEmpty()) {
+ quotedName = QLatin1Char('"') + documentName + QLatin1Char('"');
saveAction->setText(tr("&Save %1").arg(quotedName));
saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
@@ -2069,7 +2053,6 @@ void EditorManager::setupSaveActions(IEditor *editor, QAction *saveAction, QActi
void EditorManager::updateActions()
{
IEditor *curEditor = currentEditor();
- const QString fileName = fileNameForEditor(curEditor);
int openedCount = d->m_editorModel->openDocumentCount();
if (curEditor) {
@@ -2084,8 +2067,8 @@ void EditorManager::updateActions()
setCloseSplitEnabled(root, root->isSplitter());
QString quotedName;
- if (!fileName.isEmpty())
- quotedName = QLatin1Char('"') + fileName + QLatin1Char('"');
+ if (curEditor)
+ quotedName = QLatin1Char('"') + curEditor->document()->displayName() + QLatin1Char('"');
setupSaveActions(curEditor, d->m_saveAction, d->m_saveAsAction, d->m_revertToSavedAction);
d->m_closeCurrentEditorAction->setEnabled(curEditor != 0);
@@ -2457,7 +2440,6 @@ Core::IEditor *EditorManager::duplicateEditor(Core::IEditor *editor)
IEditor *duplicate = editor->duplicate(0);
duplicate->restoreState(editor->saveState());
- connect(duplicate, SIGNAL(changed()), this, SLOT(handleEditorStateChange()));
emit editorCreated(duplicate, duplicate->document()->filePath());
addEditor(duplicate, true);
return duplicate;
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index b9daf5ac51..39946fcadf 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -188,7 +188,7 @@ public:
signals:
void currentEditorChanged(Core::IEditor *editor);
- void currentEditorStateChanged(Core::IEditor *editor);
+ void currentDocumentStateChanged();
void editorCreated(Core::IEditor *editor, const QString &fileName);
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
@@ -213,7 +213,7 @@ private slots:
void makeCurrentEditorWritable();
void vcsOpenCurrentEditor();
void updateWindowTitle();
- void handleEditorStateChange();
+ void handleDocumentStateChange();
void updateVariable(const QByteArray &variable);
void autoSave();
@@ -279,7 +279,6 @@ private:
void updateAutoSave();
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
void updateMakeWritableWarning();
- QString fileNameForEditor(IEditor *editor);
void setupSaveActions(IEditor *editor, QAction *saveAction, QAction *saveAsAction, QAction *revertToSavedAction);
friend class Core::Internal::MainWindow;
diff --git a/src/plugins/coreplugin/editormanager/ieditor.cpp b/src/plugins/coreplugin/editormanager/ieditor.cpp
index 45ed5897df..e850e5eb08 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.cpp
+++ b/src/plugins/coreplugin/editormanager/ieditor.cpp
@@ -45,8 +45,6 @@
\list
\li displayName() is used as a user visible description of the document (usually filename w/o path).
\li kind() must be the same value as the kind() of the corresponding EditorFactory.
- \li The changed() signal should be emitted when the modified state of the document changes
- (so /bold{not} every time the document changes, but /bold{only once}).
\li If duplication is supported, you need to ensure that all duplicates
return the same file().
\li QString preferredMode() const is the mode the editor manager should activate.
diff --git a/src/plugins/coreplugin/editormanager/ieditor.h b/src/plugins/coreplugin/editormanager/ieditor.h
index f2c64f7a9b..529a141f27 100644
--- a/src/plugins/coreplugin/editormanager/ieditor.h
+++ b/src/plugins/coreplugin/editormanager/ieditor.h
@@ -51,8 +51,6 @@ public:
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName) = 0;
virtual IDocument *document() = 0;
virtual Core::Id id() const = 0;
- virtual QString displayName() const = 0;
- virtual void setDisplayName(const QString &title) = 0;
virtual bool duplicateSupported() const { return false; }
virtual IEditor *duplicate(QWidget * /*parent*/) { return 0; }
@@ -69,9 +67,6 @@ public:
virtual QWidget *toolBar() = 0;
virtual bool isDesignModePreferred() const { return false; }
-
-signals:
- void changed();
};
} // namespace Core
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
index d58b497938..33efe4032c 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
@@ -85,7 +85,7 @@ QString OpenEditorsModel::Entry::fileName() const {
}
QString OpenEditorsModel::Entry::displayName() const {
- return editor ? editor->displayName() : m_displayName;
+ return editor ? editor->document()->displayName() : m_displayName;
}
Id OpenEditorsModel::Entry::id() const
@@ -156,7 +156,7 @@ void OpenEditorsModel::addEntry(Entry *entry)
if (previousIndex >= 0) {
if (entry->editor && d->m_editors.at(previousIndex)->editor == 0) {
d->m_editors[previousIndex] = entry;
- connect(entry->editor, SIGNAL(changed()), this, SLOT(itemChanged()));
+ connect(entry->editor->document(), SIGNAL(changed()), this, SLOT(itemChanged()));
}
return;
}
@@ -171,10 +171,19 @@ void OpenEditorsModel::addEntry(Entry *entry)
beginInsertRows(QModelIndex(), row, row);
d->m_editors.insert(index, entry);
if (entry->editor)
- connect(entry->editor, SIGNAL(changed()), this, SLOT(itemChanged()));
+ connect(entry->editor->document(), SIGNAL(changed()), this, SLOT(itemChanged()));
endInsertRows();
}
+int OpenEditorsModel::findDocument(IDocument *document) const
+{
+ for (int i = 0; i < d->m_editors.count(); ++i) {
+ IEditor *editor = d->m_editors.at(i)->editor;
+ if (editor && editor->document() == document)
+ return i;
+ }
+ return -1;
+}
int OpenEditorsModel::findEditor(IEditor *editor) const
{
@@ -223,7 +232,7 @@ void OpenEditorsModel::removeEditor(int idx)
d->m_editors.removeAt(idx);
endRemoveRows();
if (editor)
- disconnect(editor, SIGNAL(changed()), this, SLOT(itemChanged()));
+ disconnect(editor->document(), SIGNAL(changed()), this, SLOT(itemChanged()));
}
void OpenEditorsModel::removeAllRestoredEditors()
@@ -271,8 +280,6 @@ void OpenEditorsModel::makeOriginal(IEditor *duplicate)
d->m_editors[i]->editor = duplicate;
d->m_duplicateEditors.removeOne(duplicate);
d->m_duplicateEditors.append(original);
- disconnect(original, SIGNAL(changed()), this, SLOT(itemChanged()));
- connect(duplicate, SIGNAL(changed()), this, SLOT(itemChanged()));
}
int OpenEditorsModel::indexOfEditor(IEditor *editor) const
@@ -282,15 +289,6 @@ int OpenEditorsModel::indexOfEditor(IEditor *editor) const
return findEditor(editor);
}
-void OpenEditorsModel::emitDataChanged(IEditor *editor)
-{
- int idx = findEditor(editor);
- if (idx < 0)
- return;
- QModelIndex mindex = index(idx + 1/*<no document>*/, 0);
- emit dataChanged(mindex, mindex);
-}
-
QModelIndex OpenEditorsModel::index(int row, int column, const QModelIndex &parent) const
{
Q_UNUSED(parent)
@@ -369,17 +367,15 @@ int OpenEditorsModel::rowOfEditor(IEditor *editor) const
return findEditor(originalForDuplicate(editor)) + 1/*<no document>*/;
}
-QString OpenEditorsModel::displayNameForDocument(IDocument *document) const
-{
- for (int i = 0; i < d->m_editors.count(); ++i)
- if (d->m_editors.at(i)->editor && d->m_editors.at(i)->editor->document() == document)
- return d->m_editors.at(i)->editor->displayName();
- return QString();
-}
-
void OpenEditorsModel::itemChanged()
{
- emitDataChanged(qobject_cast<IEditor*>(sender()));
+ IDocument *document = qobject_cast<IDocument *>(sender());
+
+ int idx = findDocument(document);
+ if (idx < 0)
+ return;
+ QModelIndex mindex = index(idx + 1/*<no document>*/, 0);
+ emit dataChanged(mindex, mindex);
}
QList<OpenEditorsModel::Entry *> OpenEditorsModel::entries() const
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.h b/src/plugins/coreplugin/editormanager/openeditorsmodel.h
index 2edb31d4bb..0df21296c6 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.h
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.h
@@ -95,17 +95,15 @@ public:
void makeOriginal(IEditor *duplicate);
int indexOfEditor(IEditor *editor) const;
- QString displayNameForDocument(IDocument *document) const;
-
private slots:
void itemChanged();
private:
void addEntry(Entry *entry);
+ int findDocument(IDocument *document) const;
int findEditor(IEditor *editor) const;
int findFileName(const QString &filename) const;
void removeEditor(int idx);
- void emitDataChanged(IEditor *editor);
OpenEditorsModelPrivate *d;
};
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 19c1a7b3ab..0b1629dade 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -255,7 +255,7 @@ void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, Edit
if (hi.document.isNull() || documentsDone.contains(hi.document))
continue;
documentsDone.insert(hi.document.data());
- QString title = model->displayNameForDocument(hi.document);
+ QString title = hi.document->displayName();
QTC_ASSERT(!title.isEmpty(), continue);
QTreeWidgetItem *item = new QTreeWidgetItem();
if (hi.document->isModified())
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index aa0c3b7829..905d3e68ec 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -207,7 +207,7 @@ EditorToolBar::~EditorToolBar()
void EditorToolBar::removeToolbarForEditor(IEditor *editor)
{
QTC_ASSERT(editor, return);
- disconnect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
+ disconnect(editor->document(), SIGNAL(changed()), this, SLOT(checkEditorStatus()));
QWidget *toolBar = editor->toolBar();
if (toolBar != 0) {
@@ -245,7 +245,7 @@ void EditorToolBar::closeEditor()
void EditorToolBar::addEditor(IEditor *editor)
{
QTC_ASSERT(editor, return);
- connect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
+ connect(editor->document(), SIGNAL(changed()), this, SLOT(checkEditorStatus()));
QWidget *toolBar = editor->toolBar();
if (toolBar && !d->m_isStandalone)
@@ -394,7 +394,7 @@ void EditorToolBar::updateEditorStatus(IEditor *editor)
if (editor == current)
d->m_editorList->setToolTip(
current->document()->filePath().isEmpty()
- ? current->displayName()
+ ? current->document()->displayName()
: QDir::toNativeSeparators(editor->document()->filePath())
);
}
diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp
index df9429cf48..8bb8f26c08 100644
--- a/src/plugins/coreplugin/idocument.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -133,4 +133,31 @@ void IDocument::setFilePath(const QString &filePath)
emit changed();
}
+/*!
+ Returns the string to display for this document, e.g. in the open document combo box
+ and pane.
+ \sa setDisplayName()
+*/
+QString IDocument::displayName() const
+{
+ if (!m_displayName.isEmpty())
+ return m_displayName;
+ return QFileInfo(m_filePath).fileName();
+}
+
+/*!
+ Sets the string that is displayed for this document, e.g. in the open document combo box
+ and pane, to \a name. Defaults to the file name of the file path for this document.
+ You can reset the display name to the default by passing an empty string.
+ \sa displayName()
+ \sa filePath()
+ */
+void IDocument::setDisplayName(const QString &name)
+{
+ if (name == m_displayName)
+ return;
+ m_displayName = name;
+ emit changed();
+}
+
} // namespace Core
diff --git a/src/plugins/coreplugin/idocument.h b/src/plugins/coreplugin/idocument.h
index 5eb8024f9f..76f095a60d 100644
--- a/src/plugins/coreplugin/idocument.h
+++ b/src/plugins/coreplugin/idocument.h
@@ -84,6 +84,9 @@ public:
virtual bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false) = 0;
QString filePath() const { return m_filePath; }
virtual void setFilePath(const QString &filePath);
+ QString displayName() const;
+ void setDisplayName(const QString &name);
+
virtual bool isFileReadOnly() const;
virtual QString defaultPath() const = 0;
@@ -118,6 +121,7 @@ signals:
private:
QString m_filePath;
+ QString m_displayName;
QString m_autoSaveName;
InfoBar *m_infoBar;
bool m_hasWriteWarning;
diff --git a/src/plugins/cpaster/cpasterplugin.cpp b/src/plugins/cpaster/cpasterplugin.cpp
index 5c39007014..1c2e4e4a12 100644
--- a/src/plugins/cpaster/cpasterplugin.cpp
+++ b/src/plugins/cpaster/cpasterplugin.cpp
@@ -382,7 +382,7 @@ void CodepasterPlugin::finishFetch(const QString &titleDescription,
// Open editor with title.
Core::IEditor *editor = EditorManager::openEditor(fileName);
QTC_ASSERT(editor, return);
- editor->setDisplayName(titleDescription);
+ editor->document()->setDisplayName(titleDescription);
}
CodepasterPlugin *CodepasterPlugin::instance()
diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp
index a45dbf3fa8..16cc796703 100644
--- a/src/plugins/debugger/disassembleragent.cpp
+++ b/src/plugins/debugger/disassembleragent.cpp
@@ -334,7 +334,7 @@ void DisassemblerAgent::setContentsToEditor(const DisassemblerLines &contents)
plainTextEdit->setPlainText(str);
plainTextEdit->setReadOnly(true);
- d->editor->setDisplayName(_("Disassembler (%1)")
+ d->editor->document()->setDisplayName(_("Disassembler (%1)")
.arg(d->location.functionName()));
updateBreakpointMarkers();
diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp
index 323f196ad9..54d2342ee8 100644
--- a/src/plugins/debugger/qml/qmlengine.cpp
+++ b/src/plugins/debugger/qml/qmlengine.cpp
@@ -535,7 +535,7 @@ void QmlEngine::gotoLocation(const Location &location)
//Check if there are open editors with the same title
QList<Core::IEditor *> editors = editorManager->openedEditors();
foreach (Core::IEditor *ed, editors) {
- if (ed->displayName() == titlePattern) {
+ if (ed->document()->displayName() == titlePattern) {
editor = ed;
break;
}
@@ -1301,7 +1301,7 @@ void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int
//Check if there are open editors with the same title
QList<Core::IEditor *> editors = Core::EditorManager::instance()->openedEditors();
foreach (Core::IEditor *editor, editors) {
- if (editor->displayName() == titlePattern) {
+ if (editor->document()->displayName() == titlePattern) {
updateEditor(editor, document);
break;
}
diff --git a/src/plugins/designer/formwindoweditor.cpp b/src/plugins/designer/formwindoweditor.cpp
index 1c865fa4c4..b7de0a3c06 100644
--- a/src/plugins/designer/formwindoweditor.cpp
+++ b/src/plugins/designer/formwindoweditor.cpp
@@ -72,12 +72,8 @@ FormWindowEditor::FormWindowEditor(Internal::DesignerXmlEditor *editor,
Designer::Constants::C_DESIGNER_XML_EDITOR));
setWidget(d->m_textEditor.widget());
- connect(form, SIGNAL(changed()), this, SIGNAL(changed()));
// Revert to saved/load externally modified files.
connect(&d->m_file, SIGNAL(reload(QString*,QString)), this, SLOT(slotOpen(QString*,QString)));
- // Force update of open editors model.
- connect(&d->m_file, SIGNAL(saved()), this, SIGNAL(changed()));
- connect(&d->m_file, SIGNAL(changed()), this, SIGNAL(changed()));
}
FormWindowEditor::~FormWindowEditor()
@@ -139,10 +135,8 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const
QDesignerFormWindowInterface *form = d->m_file.formWindow();
QTC_ASSERT(form, return false);
- if (fileName.isEmpty()) {
- setDisplayName(tr("untitled"));
+ if (fileName.isEmpty())
return true;
- }
const QFileInfo fi(fileName);
const QString absfileName = fi.absoluteFilePath();
@@ -167,15 +161,12 @@ bool FormWindowEditor::open(QString *errorString, const QString &fileName, const
form->setDirty(fileName != realFileName);
syncXmlEditor(contents);
- setDisplayName(fi.fileName());
d->m_file.setFilePath(absfileName);
d->m_file.setShouldAutoSave(false);
if (Internal::ResourceHandler *rh = form->findChild<Designer::Internal::ResourceHandler*>())
rh->updateResources();
- emit changed();
-
return true;
}
@@ -190,6 +181,7 @@ void FormWindowEditor::syncXmlEditor(const QString &contents)
{
d->m_textEditor.editorWidget()->setPlainText(contents);
d->m_textEditor.editorWidget()->setReadOnly(true);
+ d->m_textEditor.document()->setDisplayName(d->m_file.displayName());
static_cast<TextEditor::PlainTextEditorWidget *>
(d->m_textEditor.editorWidget())->configure(document()->mimeType());
}
@@ -204,17 +196,6 @@ Core::Id FormWindowEditor::id() const
return Core::Id(Designer::Constants::K_DESIGNER_XML_EDITOR_ID);
}
-QString FormWindowEditor::displayName() const
-{
- return d->m_textEditor.displayName();
-}
-
-void FormWindowEditor::setDisplayName(const QString &title)
-{
- d->m_textEditor.setDisplayName(title);
- emit changed();
-}
-
QByteArray FormWindowEditor::saveState() const
{
return d->m_textEditor.saveState();
diff --git a/src/plugins/designer/formwindoweditor.h b/src/plugins/designer/formwindoweditor.h
index a04f417d16..94eef91280 100644
--- a/src/plugins/designer/formwindoweditor.h
+++ b/src/plugins/designer/formwindoweditor.h
@@ -71,8 +71,6 @@ public:
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
virtual Core::IDocument *document();
virtual Core::Id id() const;
- virtual QString displayName() const;
- virtual void setDisplayName(const QString &title);
virtual QByteArray saveState() const;
virtual bool restoreState(const QByteArray &state);
diff --git a/src/plugins/designer/formwindowfile.cpp b/src/plugins/designer/formwindowfile.cpp
index dfd12e08d3..b12d3f4cd4 100644
--- a/src/plugins/designer/formwindowfile.cpp
+++ b/src/plugins/designer/formwindowfile.cpp
@@ -52,7 +52,8 @@ FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *pare
: Core::TextDocument(parent),
m_mimeType(QLatin1String(Designer::Constants::FORM_MIMETYPE)),
m_shouldAutoSave(false),
- m_formWindow(form)
+ m_formWindow(form),
+ m_isModified(false)
{
// Designer needs UTF-8 regardless of settings.
setCodec(QTextCodec::codecForName("UTF-8"));
@@ -60,6 +61,7 @@ FormWindowFile::FormWindowFile(QDesignerFormWindowInterface *form, QObject *pare
this, SLOT(slotFormWindowRemoved(QDesignerFormWindowInterface*)));
connect(m_formWindow->commandHistory(), SIGNAL(indexChanged(int)),
this, SLOT(setShouldAutoSave()));
+ connect(m_formWindow, SIGNAL(changed()), SLOT(updateIsModified()));
}
bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSave)
@@ -94,11 +96,9 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa
return false;
}
- emit setDisplayName(fi.fileName());
m_formWindow->setDirty(false);
setFilePath(fi.absoluteFilePath());
emit changed();
- emit saved();
return true;
}
@@ -106,9 +106,16 @@ bool FormWindowFile::save(QString *errorString, const QString &name, bool autoSa
void FormWindowFile::setFilePath(const QString &newName)
{
m_formWindow->setFileName(newName);
- QFileInfo fi(newName);
- emit setDisplayName(fi.fileName());
- IDocument::setFilePath(fi.absoluteFilePath());
+ IDocument::setFilePath(newName);
+}
+
+void FormWindowFile::updateIsModified()
+{
+ bool value = m_formWindow && m_formWindow->isDirty();
+ if (value == m_isModified)
+ return;
+ m_isModified = value;
+ emit changed();
}
bool FormWindowFile::shouldAutoSave() const
diff --git a/src/plugins/designer/formwindowfile.h b/src/plugins/designer/formwindowfile.h
index 2daf6cfdf3..6fdca217b1 100644
--- a/src/plugins/designer/formwindowfile.h
+++ b/src/plugins/designer/formwindowfile.h
@@ -68,13 +68,13 @@ public:
signals:
// Internal
- void saved();
void reload(QString *errorString, const QString &);
void setDisplayName(const QString &);
public slots:
void setFilePath(const QString &);
void setShouldAutoSave(bool sad = true) { m_shouldAutoSave = sad; }
+ void updateIsModified();
private slots:
void slotFormWindowRemoved(QDesignerFormWindowInterface *w);
@@ -87,6 +87,7 @@ private:
// Might actually go out of scope before the IEditor due
// to deleting the WidgetHost which owns it.
QPointer<QDesignerFormWindowInterface> m_formWindow;
+ bool m_isModified;
};
} // namespace Internal
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp
index 2c1245e439..d51c44997f 100644
--- a/src/plugins/diffeditor/diffeditor.cpp
+++ b/src/plugins/diffeditor/diffeditor.cpp
@@ -35,7 +35,6 @@
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
-#include <QCoreApplication>
#include <QToolButton>
#include <QSpinBox>
#include <QStyle>
@@ -87,19 +86,6 @@ Core::IDocument *DiffEditor::document()
return m_file;
}
-QString DiffEditor::displayName() const
-{
- if (m_displayName.isEmpty())
- m_displayName = QCoreApplication::translate("DiffEditor", Constants::DIFF_EDITOR_DISPLAY_NAME);
- return m_displayName;
-}
-
-void DiffEditor::setDisplayName(const QString &title)
-{
- m_displayName = title;
- emit changed();
-}
-
Core::Id DiffEditor::id() const
{
return Constants::DIFF_EDITOR_ID;
diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h
index 735b9a988d..5a33e151fe 100644
--- a/src/plugins/diffeditor/diffeditor.h
+++ b/src/plugins/diffeditor/diffeditor.h
@@ -63,8 +63,6 @@ public:
bool createNew(const QString &contents);
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
- QString displayName() const;
- void setDisplayName(const QString &title);
Core::Id id() const;
bool isTemporary() const { return true; }
DiffEditorWidget *editorWidget() const { return m_editorWidget; }
@@ -86,7 +84,6 @@ private:
Internal::DiffEditorFile *m_file;
DiffEditorWidget *m_editorWidget;
QComboBox *m_entriesComboBox;
- mutable QString m_displayName;
};
} // namespace DiffEditor
diff --git a/src/plugins/diffeditor/diffeditorfile.cpp b/src/plugins/diffeditor/diffeditorfile.cpp
index 1825eea775..deeb4cd81e 100644
--- a/src/plugins/diffeditor/diffeditorfile.cpp
+++ b/src/plugins/diffeditor/diffeditorfile.cpp
@@ -28,6 +28,9 @@
****************************************************************************/
#include "diffeditorfile.h"
+#include "diffeditorconstants.h"
+
+#include <QCoreApplication>
namespace DiffEditor {
namespace Internal {
@@ -39,6 +42,7 @@ DiffEditorFile::DiffEditorFile(const QString &mimeType, QObject *parent) :
m_mimeType(mimeType),
m_modified(false)
{
+ setDisplayName(QCoreApplication::translate("DiffEditor", Constants::DIFF_EDITOR_DISPLAY_NAME));
}
void DiffEditorFile::setModified(bool modified)
diff --git a/src/plugins/diffeditor/diffshoweditor.cpp b/src/plugins/diffeditor/diffshoweditor.cpp
index 9e586eebbb..310acf03b7 100644
--- a/src/plugins/diffeditor/diffshoweditor.cpp
+++ b/src/plugins/diffeditor/diffshoweditor.cpp
@@ -110,6 +110,8 @@ void DiffShowEditorWidget::setDisplaySettings(const DisplaySettings &ds)
DiffShowEditor::DiffShowEditor(DiffEditorWidget *editorWidget)
: DiffEditor(editorWidget)
{
+ document()->setDisplayName(QCoreApplication::translate("DiffShowEditor",
+ Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME));
QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical);
m_diffShowWidget = new Internal::DiffShowEditorWidget(splitter);
m_diffShowWidget->setReadOnly(true);
@@ -136,19 +138,6 @@ void DiffShowEditor::setDescription(const QString &description)
m_diffShowWidget->setPlainText(description);
}
-QString DiffShowEditor::displayName() const
-{
- if (m_displayName.isEmpty())
- m_displayName = QCoreApplication::translate("DiffShowEditor", Constants::DIFF_SHOW_EDITOR_DISPLAY_NAME);
- return m_displayName;
-}
-
-void DiffShowEditor::setDisplayName(const QString &title)
-{
- m_displayName = title;
- emit changed();
-}
-
Core::Id DiffShowEditor::id() const
{
return Constants::DIFF_SHOW_EDITOR_ID;
diff --git a/src/plugins/diffeditor/diffshoweditor.h b/src/plugins/diffeditor/diffshoweditor.h
index c53a4c820a..fedd94fc5e 100644
--- a/src/plugins/diffeditor/diffshoweditor.h
+++ b/src/plugins/diffeditor/diffshoweditor.h
@@ -56,8 +56,6 @@ public:
public:
void setDescription(const QString &description);
// Core::IEditor
- QString displayName() const;
- void setDisplayName(const QString &title);
Core::Id id() const;
QWidget *toolBar();
@@ -69,7 +67,6 @@ private:
void updateEntryToolTip();
TextEditor::BaseTextEditorWidget *m_diffShowWidget;
- mutable QString m_displayName;
QToolButton *m_toggleDescriptionButton;
};
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index af9f31a532..6ad53f5ad5 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -1031,7 +1031,7 @@ Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const Commit
default:
title = tr("Git Commit");
}
- submitEditor->setDisplayName(title);
+ submitEditor->document()->setDisplayName(title);
connect(submitEditor, SIGNAL(diff(QStringList,QStringList)), this, SLOT(submitEditorDiff(QStringList,QStringList)));
connect(submitEditor, SIGNAL(merge(QStringList)), this, SLOT(submitEditorMerge(QStringList)));
connect(submitEditor, SIGNAL(show(QString,QString)), m_gitClient, SLOT(show(QString,QString)));
diff --git a/src/plugins/imageviewer/imageviewer.cpp b/src/plugins/imageviewer/imageviewer.cpp
index d2bdb13ae2..0bc59e5b1e 100644
--- a/src/plugins/imageviewer/imageviewer.cpp
+++ b/src/plugins/imageviewer/imageviewer.cpp
@@ -92,8 +92,6 @@ ImageViewer::ImageViewer(QWidget *parent)
d->ui_toolbar.toolButtonPlayPause->setCommandId(Constants::ACTION_TOGGLE_ANIMATION);
// connections
- connect(d->file, SIGNAL(changed()), this, SIGNAL(changed()));
-
connect(d->ui_toolbar.toolButtonZoomIn, SIGNAL(clicked()),
d->imageView, SLOT(zoomIn()));
connect(d->ui_toolbar.toolButtonZoomOut, SIGNAL(clicked()),
@@ -133,12 +131,10 @@ bool ImageViewer::open(QString *errorString, const QString &fileName, const QStr
*errorString = tr("Cannot open image file %1.").arg(QDir::toNativeSeparators(realFileName));
return false;
}
- setDisplayName(QFileInfo(fileName).fileName());
d->file->setFilePath(fileName);
d->ui_toolbar.toolButtonPlayPause->setVisible(d->imageView->isAnimated());
setPaused(!d->imageView->isAnimated());
// d_ptr->file->setMimeType
- emit changed();
return true;
}
@@ -152,17 +148,6 @@ Core::Id ImageViewer::id() const
return Core::Id(Constants::IMAGEVIEWER_ID);
}
-QString ImageViewer::displayName() const
-{
- return d->displayName;
-}
-
-void ImageViewer::setDisplayName(const QString &title)
-{
- d->displayName = title;
- emit changed();
-}
-
bool ImageViewer::isTemporary() const
{
return false;
diff --git a/src/plugins/imageviewer/imageviewer.h b/src/plugins/imageviewer/imageviewer.h
index 14a1774e0f..1ae2e4c4e6 100644
--- a/src/plugins/imageviewer/imageviewer.h
+++ b/src/plugins/imageviewer/imageviewer.h
@@ -58,8 +58,6 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
- QString displayName() const;
- void setDisplayName(const QString &title);
bool isTemporary() const;
QWidget *toolBar();
diff --git a/src/plugins/imageviewer/imageviewerfile.cpp b/src/plugins/imageviewer/imageviewerfile.cpp
index 4352b4a05d..e04539a59c 100644
--- a/src/plugins/imageviewer/imageviewerfile.cpp
+++ b/src/plugins/imageviewer/imageviewerfile.cpp
@@ -72,12 +72,6 @@ bool ImageViewerFile::save(QString *errorString, const QString &fileName, bool a
return false;
}
-void ImageViewerFile::setFilePath(const QString &newName)
-{
- m_editor->setDisplayName(QFileInfo(newName).fileName());
- IDocument::setFilePath(newName);
-}
-
QString ImageViewerFile::defaultPath() const
{
return QString();
diff --git a/src/plugins/imageviewer/imageviewerfile.h b/src/plugins/imageviewer/imageviewerfile.h
index 0381052931..448e9abdc4 100644
--- a/src/plugins/imageviewer/imageviewerfile.h
+++ b/src/plugins/imageviewer/imageviewerfile.h
@@ -46,7 +46,6 @@ public:
explicit ImageViewerFile(ImageViewer *parent = 0);
bool save(QString *errorString, const QString &fileName, bool autoSave);
- void setFilePath(const QString &newName);
QString defaultPath() const;
QString suggestedFileName() const;
diff --git a/src/plugins/mercurial/commiteditor.cpp b/src/plugins/mercurial/commiteditor.cpp
index 189afd4c43..175a8df224 100644
--- a/src/plugins/mercurial/commiteditor.cpp
+++ b/src/plugins/mercurial/commiteditor.cpp
@@ -30,6 +30,7 @@
#include "commiteditor.h"
#include "mercurialcommitwidget.h"
+#include <coreplugin/idocument.h>
#include <vcsbase/submitfilemodel.h>
#include <QDebug>
@@ -42,7 +43,7 @@ CommitEditor::CommitEditor(const VcsBaseSubmitEditorParameters *parameters, QWid
: VcsBaseSubmitEditor(parameters, new MercurialCommitWidget(parent)),
fileModel(0)
{
- setDisplayName(tr("Commit Editor"));
+ document()->setDisplayName(tr("Commit Editor"));
}
MercurialCommitWidget *CommitEditor::commitWidget()
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index f326a76ad4..0abe351cf3 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -578,7 +578,7 @@ void MercurialPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &s
const QString msg = tr("Commit changes for \"%1\".").
arg(QDir::toNativeSeparators(m_submitRepository));
- commitEditor->setDisplayName(msg);
+ commitEditor->document()->setDisplayName(msg);
QString branch = m_client->branchQuerySync(m_submitRepository);
commitEditor->setFields(m_submitRepository, branch,
diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp
index c72bac449c..3ae22eb738 100644
--- a/src/plugins/perforce/perforcesubmiteditor.cpp
+++ b/src/plugins/perforce/perforcesubmiteditor.cpp
@@ -32,6 +32,7 @@
#include "perforceplugin.h"
#include "perforceconstants.h"
+#include <coreplugin/idocument.h>
#include <vcsbase/submitfilemodel.h>
#include <utils/qtcassert.h>
@@ -46,7 +47,7 @@ PerforceSubmitEditor::PerforceSubmitEditor(const VcsBase::VcsBaseSubmitEditorPar
VcsBaseSubmitEditor(parameters, new PerforceSubmitEditorWidget(parent)),
m_fileModel(new VcsBase::SubmitFileModel(this))
{
- setDisplayName(tr("Perforce Submit"));
+ document()->setDisplayName(tr("Perforce Submit"));
setFileModel(m_fileModel);
}
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index bd6c58ed82..3719651508 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1754,11 +1754,8 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success)
void ProjectExplorerPlugin::updateExternalFileWarning()
{
- Core::IEditor *editor = qobject_cast<Core::IEditor *>(sender());
- if (!editor || editor->isTemporary())
- return;
- Core::IDocument *document = editor->document();
- if (!document)
+ Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
+ if (!document || document->filePath().isEmpty())
return;
Core::InfoBar *infoBar = document->infoBar();
Core::Id externalFileId(EXTERNAL_FILE_WARNING);
@@ -1769,8 +1766,6 @@ void ProjectExplorerPlugin::updateExternalFileWarning()
if (!d->m_currentProject || !infoBar->canInfoBeAdded(externalFileId))
return;
Utils::FileName fileName = Utils::FileName::fromString(document->filePath());
- if (fileName.isEmpty())
- return;
Utils::FileName projectDir = Utils::FileName::fromString(d->m_currentProject->projectDirectory());
if (projectDir.isEmpty() || fileName.isChildOf(projectDir))
return;
@@ -1833,8 +1828,8 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node
d->m_currentProject = project;
if (!node && Core::EditorManager::currentEditor()) {
- connect(Core::EditorManager::currentEditor(), SIGNAL(changed()),
- this, SLOT(updateExternalFileWarning()));
+ connect(Core::EditorManager::currentEditor()->document(), SIGNAL(changed()),
+ this, SLOT(updateExternalFileWarning()), Qt::UniqueConnection);
}
if (projectChanged || d->m_currentNode != node) {
d->m_currentNode = node;
diff --git a/src/plugins/qmldesigner/shortcutmanager.cpp b/src/plugins/qmldesigner/shortcutmanager.cpp
index 9f200d5cc7..518f905259 100644
--- a/src/plugins/qmldesigner/shortcutmanager.cpp
+++ b/src/plugins/qmldesigner/shortcutmanager.cpp
@@ -174,16 +174,6 @@ void ShortCutManager::updateActions(Core::IEditor* currentEditor)
{
int openedCount = Core::ICore::editorManager()->openedEditorsModel()->openDocumentCount();
- QString fileName;
- if (currentEditor) {
- if (!currentEditor->document()->filePath().isEmpty()) {
- QFileInfo fileInfo(currentEditor->document()->filePath());
- fileName = fileInfo.fileName();
- } else {
- fileName = currentEditor->displayName();
- }
- }
-
m_saveAction.setEnabled(currentEditor != 0 && currentEditor->document()->isModified());
m_saveAsAction.setEnabled(currentEditor != 0 && currentEditor->document()->isSaveAsAllowed());
m_revertToSavedAction.setEnabled(currentEditor != 0
@@ -191,8 +181,8 @@ void ShortCutManager::updateActions(Core::IEditor* currentEditor)
&& currentEditor->document()->isModified());
QString quotedName;
- if (!fileName.isEmpty())
- quotedName = '"' + fileName + '"';
+ if (currentEditor)
+ quotedName = '"' + currentEditor->document()->displayName() + '"';
m_saveAsAction.setText(tr("Save %1 As...").arg(quotedName));
m_saveAction.setText(tr("&Save %1").arg(quotedName));
diff --git a/src/plugins/qnx/bardescriptordocument.cpp b/src/plugins/qnx/bardescriptordocument.cpp
index 96fbee73c1..200f5e7ce5 100644
--- a/src/plugins/qnx/bardescriptordocument.cpp
+++ b/src/plugins/qnx/bardescriptordocument.cpp
@@ -169,12 +169,6 @@ bool BarDescriptorDocument::reload(QString *errorString, Core::IDocument::Reload
return open(errorString, filePath());
}
-void BarDescriptorDocument::setFilePath(const QString &newName)
-{
- m_editorWidget->editor()->setDisplayName(QFileInfo(newName).fileName());
- IDocument::setFilePath(newName);
-}
-
QString BarDescriptorDocument::xmlSource() const
{
BarDescriptorEditor *editor = qobject_cast<BarDescriptorEditor*>(m_editorWidget->editor());
diff --git a/src/plugins/qnx/bardescriptordocument.h b/src/plugins/qnx/bardescriptordocument.h
index f34512fdb2..88e5929a7d 100644
--- a/src/plugins/qnx/bardescriptordocument.h
+++ b/src/plugins/qnx/bardescriptordocument.h
@@ -69,7 +69,6 @@ public:
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
- void setFilePath(const QString &newName);
QString xmlSource() const;
bool loadContent(const QString &xmlSource, QString *errorMessage = 0, int *errorLine = 0);
diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp
index ab1779a58a..524ebd051a 100644
--- a/src/plugins/qnx/bardescriptoreditor.cpp
+++ b/src/plugins/qnx/bardescriptoreditor.cpp
@@ -104,20 +104,6 @@ Core::Id BarDescriptorEditor::id() const
return Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID;
}
-QString BarDescriptorEditor::displayName() const
-{
- return m_displayName;
-}
-
-void BarDescriptorEditor::setDisplayName(const QString &title)
-{
- if (title == m_displayName)
- return;
-
- m_displayName = title;
- emit changed();
-}
-
bool BarDescriptorEditor::isTemporary() const
{
return false;
diff --git a/src/plugins/qnx/bardescriptoreditor.h b/src/plugins/qnx/bardescriptoreditor.h
index b8bd6bfd9f..6da0419c5f 100644
--- a/src/plugins/qnx/bardescriptoreditor.h
+++ b/src/plugins/qnx/bardescriptoreditor.h
@@ -67,8 +67,6 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
Core::Id id() const;
- QString displayName() const;
- void setDisplayName(const QString &title);
bool isTemporary() const;
QWidget *toolBar();
@@ -84,8 +82,6 @@ private:
BarDescriptorDocument *m_file;
- QString m_displayName;
-
QToolBar *m_toolBar;
QActionGroup *m_actionGroup;
};
diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp
index 9b1bcae156..98fcaf925c 100644
--- a/src/plugins/qnx/bardescriptoreditorwidget.cpp
+++ b/src/plugins/qnx/bardescriptoreditorwidget.cpp
@@ -163,7 +163,7 @@ Core::IEditor *BarDescriptorEditorWidget::editor() const
{
if (!m_editor) {
m_editor = const_cast<BarDescriptorEditorWidget *>(this)->createEditor();
- connect(this, SIGNAL(changed()), m_editor, SIGNAL(changed()));
+ connect(this, SIGNAL(changed()), m_editor->document(), SIGNAL(changed()));
}
return m_editor;
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp
index a4d2d89c54..012db055df 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp
+++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp
@@ -71,9 +71,9 @@ static const char *qt4FileTypes[] = {
};
// Test for form editor (loosely coupled)
-static inline bool isFormWindowEditor(const QObject *o)
+static inline bool isFormWindowDocument(const QObject *o)
{
- return o && !qstrcmp(o->metaObject()->className(), "Designer::FormWindowEditor");
+ return o && !qstrcmp(o->metaObject()->className(), "Designer::Internal::FormWindowFile");
}
// Return contents of form editor (loosely coupled)
@@ -126,8 +126,8 @@ void Qt4Manager::init()
void Qt4Manager::editorChanged(Core::IEditor *editor)
{
// Handle old editor
- if (isFormWindowEditor(m_lastEditor)) {
- disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (m_lastEditor && isFormWindowDocument(m_lastEditor->document())) {
+ disconnect(m_lastEditor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
if (m_dirty) {
const QString contents = formWindowEditorContents(m_lastEditor);
@@ -140,8 +140,8 @@ void Qt4Manager::editorChanged(Core::IEditor *editor)
m_lastEditor = editor;
// Handle new editor
- if (isFormWindowEditor(m_lastEditor))
- connect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (m_lastEditor && isFormWindowDocument(m_lastEditor->document()))
+ connect(m_lastEditor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
}
void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
@@ -149,8 +149,8 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
if (m_lastEditor == editor) {
// Oh no our editor is going to be closed
// get the content first
- if (isFormWindowEditor(m_lastEditor)) {
- disconnect(m_lastEditor, SIGNAL(changed()), this, SLOT(uiEditorContentsChanged()));
+ if (isFormWindowDocument(m_lastEditor->document())) {
+ disconnect(m_lastEditor->document(), SIGNAL(changed()), this, SLOT(uiDocumentContentsChanged()));
if (m_dirty) {
const QString contents = formWindowEditorContents(m_lastEditor);
foreach (Qt4Project *project, m_projects)
@@ -162,10 +162,10 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
}
}
-void Qt4Manager::uiEditorContentsChanged()
+void Qt4Manager::uiDocumentContentsChanged()
{
// cast sender, get filename
- if (!m_dirty && isFormWindowEditor(sender()))
+ if (!m_dirty && isFormWindowDocument(sender()))
m_dirty = true;
}
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.h b/src/plugins/qt4projectmanager/qt4projectmanager.h
index 14f309a4c0..80432106b9 100644
--- a/src/plugins/qt4projectmanager/qt4projectmanager.h
+++ b/src/plugins/qt4projectmanager/qt4projectmanager.h
@@ -105,7 +105,7 @@ public slots:
private slots:
void editorAboutToClose(Core::IEditor *editor);
- void uiEditorContentsChanged();
+ void uiDocumentContentsChanged();
void editorChanged(Core::IEditor*);
private:
diff --git a/src/plugins/resourceeditor/resourceeditorw.cpp b/src/plugins/resourceeditor/resourceeditorw.cpp
index e1180d24ec..d6b343aae1 100644
--- a/src/plugins/resourceeditor/resourceeditorw.cpp
+++ b/src/plugins/resourceeditor/resourceeditorw.cpp
@@ -63,6 +63,7 @@ enum { debugResourceEditorW = 0 };
ResourceEditorDocument::ResourceEditorDocument(ResourceEditorW *parent) :
IDocument(parent),
m_mimeType(QLatin1String(ResourceEditor::Constants::C_RESOURCE_MIMETYPE)),
+ m_blockDirtyChanged(false),
m_parent(parent)
{
setFilePath(parent->m_resourceEditor->fileName());
@@ -83,7 +84,6 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
m_resourceDocument(new ResourceEditorDocument(this)),
m_plugin(plugin),
m_shouldAutoSave(false),
- m_diskIo(false),
m_contextMenu(new QMenu),
m_toolBar(new QToolBar)
{
@@ -113,7 +113,7 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
Core::DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)),
Qt::QueuedConnection);
- connect(m_resourceEditor, SIGNAL(dirtyChanged(bool)), this, SLOT(dirtyChanged(bool)));
+ connect(m_resourceEditor, SIGNAL(dirtyChanged(bool)), m_resourceDocument, SLOT(dirtyChanged(bool)));
connect(m_resourceEditor, SIGNAL(undoStackChanged(bool,bool)),
this, SLOT(onUndoStackChanged(bool,bool)));
connect(m_resourceEditor, SIGNAL(showContextMenu(QPoint,QString)),
@@ -122,7 +122,6 @@ ResourceEditorW::ResourceEditorW(const Core::Context &context,
this, SLOT(openFile(QString)));
connect(m_resourceEditor->commandHistory(), SIGNAL(indexChanged(int)),
this, SLOT(setShouldAutoSave()));
- connect(m_resourceDocument, SIGNAL(changed()), this, SIGNAL(changed()));
if (debugResourceEditorW)
qDebug() << "ResourceEditorW::ResourceEditorW()";
}
@@ -155,26 +154,21 @@ bool ResourceEditorW::open(QString *errorString, const QString &fileName, const
if (debugResourceEditorW)
qDebug() << "ResourceEditorW::open: " << fileName;
- if (fileName.isEmpty()) {
- setDisplayName(tr("untitled"));
+ if (fileName.isEmpty())
return true;
- }
-
- const QFileInfo fi(fileName);
- m_diskIo = true;
+ m_resourceDocument->setBlockDirtyChanged(true);
if (!m_resourceEditor->load(realFileName)) {
*errorString = m_resourceEditor->errorMessage();
- m_diskIo = false;
+ m_resourceDocument->setBlockDirtyChanged(false);
return false;
}
m_resourceDocument->setFilePath(fileName);
+ m_resourceDocument->setBlockDirtyChanged(false);
m_resourceEditor->setDirty(fileName != realFileName);
m_shouldAutoSave = false;
- m_diskIo = false;
- emit changed();
return true;
}
@@ -188,12 +182,12 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo
if (actualName.isEmpty())
return false;
- m_parent->m_diskIo = true;
+ m_blockDirtyChanged = true;
m_parent->m_resourceEditor->setFileName(actualName);
if (!m_parent->m_resourceEditor->save()) {
*errorString = m_parent->m_resourceEditor->errorMessage();
m_parent->m_resourceEditor->setFileName(oldFileName);
- m_parent->m_diskIo = false;
+ m_blockDirtyChanged = false;
return false;
}
@@ -201,12 +195,12 @@ bool ResourceEditorDocument::save(QString *errorString, const QString &name, boo
if (autoSave) {
m_parent->m_resourceEditor->setFileName(oldFileName);
m_parent->m_resourceEditor->setDirty(true);
- m_parent->m_diskIo = false;
+ m_blockDirtyChanged = false;
return true;
}
setFilePath(actualName);
- m_parent->m_diskIo = false;
+ m_blockDirtyChanged = false;
emit changed();
return true;
@@ -216,13 +210,14 @@ void ResourceEditorDocument::setFilePath(const QString &newName)
{
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::setFilePath(newName);
}
+void ResourceEditorDocument::setBlockDirtyChanged(bool value)
+{
+ m_blockDirtyChanged = value;
+}
+
Core::Id ResourceEditorW::id() const
{
return Core::Id(ResourceEditor::Constants::RESOURCEEDITOR_ID);
@@ -279,9 +274,9 @@ QString ResourceEditorDocument::suggestedFileName() const
return m_parent->m_suggestedName;
}
-void ResourceEditorW::dirtyChanged(bool dirty)
+void ResourceEditorDocument::dirtyChanged(bool dirty)
{
- if (m_diskIo)
+ if (m_blockDirtyChanged)
return; // We emit changed() afterwards, unless it was an autosave
if (debugResourceEditorW)
diff --git a/src/plugins/resourceeditor/resourceeditorw.h b/src/plugins/resourceeditor/resourceeditorw.h
index 90aa3b9240..e76f1d938a 100644
--- a/src/plugins/resourceeditor/resourceeditorw.h
+++ b/src/plugins/resourceeditor/resourceeditorw.h
@@ -63,9 +63,14 @@ public:
QString suggestedFileName() const;
QString mimeType() const;
void setFilePath(const QString &newName);
+ void setBlockDirtyChanged(bool value);
+
+public slots:
+ void dirtyChanged(bool);
private:
const QString m_mimeType;
+ bool m_blockDirtyChanged;
ResourceEditorW *m_parent;
};
@@ -84,15 +89,12 @@ public:
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document() { return m_resourceDocument; }
Core::Id id() const;
- QString displayName() const { return m_displayName; }
- void setDisplayName(const QString &title) { m_displayName = title; emit changed(); }
QWidget *toolBar();
void setSuggestedFileName(const QString &fileName);
bool isTemporary() const { return false; }
private slots:
- void dirtyChanged(bool);
void onUndoStackChanged(bool canUndo, bool canRedo);
void setShouldAutoSave(bool sad = true) { m_shouldAutoSave = sad; }
void showContextMenu(const QPoint &globalPoint, const QString &fileName);
@@ -110,7 +112,6 @@ private:
ResourceEditorDocument *m_resourceDocument;
ResourceEditorPlugin *m_plugin;
bool m_shouldAutoSave;
- bool m_diskIo;
QMenu *m_contextMenu;
QMenu *m_openWithMenu;
QString m_currentFileName;
diff --git a/src/plugins/subversion/subversionsubmiteditor.cpp b/src/plugins/subversion/subversionsubmiteditor.cpp
index 14c2961021..a7c6c12485 100644
--- a/src/plugins/subversion/subversionsubmiteditor.cpp
+++ b/src/plugins/subversion/subversionsubmiteditor.cpp
@@ -30,6 +30,7 @@
#include "subversionsubmiteditor.h"
+#include <coreplugin/idocument.h>
#include <vcsbase/submiteditorwidget.h>
#include <vcsbase/submitfilemodel.h>
@@ -39,7 +40,7 @@ SubversionSubmitEditor::SubversionSubmitEditor(const VcsBase::VcsBaseSubmitEdito
QWidget *parentWidget) :
VcsBase::VcsBaseSubmitEditor(parameters, new VcsBase::SubmitEditorWidget(parentWidget))
{
- setDisplayName(tr("Subversion Submit"));
+ document()->setDisplayName(tr("Subversion Submit"));
setDescriptionMandatory(false);
}
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index f4bae7752e..46cee5a027 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -335,7 +335,7 @@ void BaseTextEditorWidgetPrivate::print(QPrinter *printer)
{
QTextDocument *doc = q->document();
- QString title = q->displayName();
+ QString title = m_document->displayName();
if (title.isEmpty())
printer->setDocName(title);
@@ -499,7 +499,7 @@ BaseTextEditor *BaseTextEditorWidget::editor() const
connect(this, SIGNAL(textChanged()),
d->m_editor, SIGNAL(contentsChanged()));
connect(this, SIGNAL(changed()),
- d->m_editor, SIGNAL(changed()));
+ d->m_editor->document(), SIGNAL(changed()));
}
return d->m_editor;
}
@@ -557,7 +557,7 @@ void BaseTextEditorWidget::updateCannotDecodeInfo()
if (d->m_document->hasDecodingError()) {
Core::InfoBarEntry info(Core::Id(Constants::SELECT_ENCODING),
tr("<b>Error:</b> Could not decode \"%1\" with \"%2\"-encoding. Editing not possible.")
- .arg(displayName()).arg(QString::fromLatin1(d->m_document->codec()->name())));
+ .arg(d->m_document->displayName()).arg(QString::fromLatin1(d->m_document->codec()->name())));
info.setCustomButtonInfo(tr("Select Encoding"), this, SLOT(selectEncoding()));
d->m_document->infoBar()->addInfo(info);
} else {
@@ -2153,7 +2153,6 @@ void BaseTextEditorWidget::duplicateFrom(BaseTextEditorWidget *widget)
{
if (this == widget)
return;
- setDisplayName(widget->displayName());
d->m_revisionsVisible = widget->d->m_revisionsVisible;
if (d->m_document == widget->d->m_document)
return;
@@ -2161,17 +2160,6 @@ void BaseTextEditorWidget::duplicateFrom(BaseTextEditorWidget *widget)
d->m_document = widget->d->m_document;
}
-QString BaseTextEditorWidget::displayName() const
-{
- return d->m_displayName;
-}
-
-void BaseTextEditorWidget::setDisplayName(const QString &title)
-{
- d->m_displayName = title;
- emit changed();
-}
-
QSharedPointer<BaseTextDocument> BaseTextEditorWidget::baseTextDocument() const
{
return d->m_document;
@@ -2584,8 +2572,6 @@ void BaseTextEditorWidgetPrivate::setupDocumentSignals(const QSharedPointer<Base
QObject::connect(doc, SIGNAL(modificationChanged(bool)), q, SIGNAL(changed()));
QObject::connect(doc, SIGNAL(contentsChange(int,int,int)), q,
SLOT(editorContentsChange(int,int,int)), Qt::DirectConnection);
- QObject::connect(document.data(), SIGNAL(changed()), q, SIGNAL(changed()));
- QObject::connect(document.data(), SIGNAL(titleChanged(QString)), q, SLOT(setDisplayName(QString)));
QObject::connect(document.data(), SIGNAL(aboutToReload()), q, SLOT(documentAboutToBeReloaded()));
QObject::connect(document.data(), SIGNAL(reloadFinished(bool)), q, SLOT(documentReloadFinished(bool)));
q->slotUpdateExtraAreaWidth();
diff --git a/src/plugins/texteditor/basetexteditor.h b/src/plugins/texteditor/basetexteditor.h
index ce99441e20..ce8af7725b 100644
--- a/src/plugins/texteditor/basetexteditor.h
+++ b/src/plugins/texteditor/basetexteditor.h
@@ -140,7 +140,6 @@ public:
virtual bool open(QString *errorString, const QString &fileName, const QString &realFileName);
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
- QString displayName() const;
void gotoLine(int line, int column = 0);
@@ -245,8 +244,6 @@ public:
QMimeData *duplicateMimeData(const QMimeData *source) const;
public slots:
- void setDisplayName(const QString &title);
-
virtual void copy();
virtual void paste();
virtual void cut();
@@ -617,8 +614,6 @@ public:
Core::IDocument *document() { return m_editorWidget->editorDocument(); }
bool createNew(const QString &contents) { return m_editorWidget->createNew(contents); }
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
- QString displayName() const { return m_editorWidget->displayName(); }
- void setDisplayName(const QString &title) { m_editorWidget->setDisplayName(title); emit changed(); }
QByteArray saveState() const { return m_editorWidget->saveState(); }
bool restoreState(const QByteArray &state) { return m_editorWidget->restoreState(state); }
diff --git a/src/plugins/texteditor/basetexteditor_p.h b/src/plugins/texteditor/basetexteditor_p.h
index 7771a5e68c..e21677de32 100644
--- a/src/plugins/texteditor/basetexteditor_p.h
+++ b/src/plugins/texteditor/basetexteditor_p.h
@@ -123,7 +123,6 @@ public:
QByteArray m_tempState;
QByteArray m_tempNavigationState;
- QString m_displayName;
bool m_parenthesesMatchingEnabled;
QTimer *m_updateTimer;
diff --git a/src/plugins/texteditor/plaintexteditor.cpp b/src/plugins/texteditor/plaintexteditor.cpp
index f8bec37bdc..8bd4d46239 100644
--- a/src/plugins/texteditor/plaintexteditor.cpp
+++ b/src/plugins/texteditor/plaintexteditor.cpp
@@ -69,7 +69,6 @@ PlainTextEditorWidget::PlainTextEditorWidget(QWidget *parent)
setIndenter(new NormalIndenter); // Currently only "normal" indentation is supported.
setMimeType(QLatin1String(TextEditor::Constants::C_TEXTEDITOR_MIMETYPE_TEXT));
- setDisplayName(tr(Core::Constants::K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME));
m_commentDefinition.clearCommentStyles();
diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp
index 4620deabbf..82148083c0 100644
--- a/src/plugins/vcsbase/vcsbaseplugin.cpp
+++ b/src/plugins/vcsbase/vcsbaseplugin.cpp
@@ -207,7 +207,7 @@ StateListener::StateListener(QObject *parent) :
{
connect(Core::ICore::editorManager(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(slotStateChanged()));
- connect(Core::ICore::editorManager(), SIGNAL(currentEditorStateChanged(Core::IEditor*)),
+ connect(Core::ICore::editorManager(), SIGNAL(currentDocumentStateChanged()),
this, SLOT(slotStateChanged()));
connect(Core::ICore::vcsManager(), SIGNAL(repositoryChanged(QString)),
this, SLOT(slotStateChanged()));
@@ -221,7 +221,7 @@ static inline QString displayNameOfEditor(const QString &fileName)
{
const QList<Core::IEditor*> editors = Core::EditorManager::instance()->editorsForFileName(fileName);
if (!editors.isEmpty())
- return editors.front()->displayName();
+ return editors.front()->document()->displayName();
return QString();
}
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
index 7d32ca2f79..8b4be858e5 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
@@ -183,6 +183,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
{
setContext(Core::Context(parameters->context));
setWidget(d->m_widget);
+ document()->setDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName));
// Message font according to settings
const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::instance()->fontSettings();
@@ -379,19 +380,6 @@ Core::IDocument *VcsBaseSubmitEditor::document()
return d->m_file;
}
-QString VcsBaseSubmitEditor::displayName() const
-{
- if (d->m_displayName.isEmpty())
- d->m_displayName = QCoreApplication::translate("VCS", d->m_parameters->displayName);
- return d->m_displayName;
-}
-
-void VcsBaseSubmitEditor::setDisplayName(const QString &title)
-{
- d->m_displayName = title;
- emit changed();
-}
-
QString VcsBaseSubmitEditor::checkScriptWorkingDirectory() const
{
return d->m_checkScriptWorkingDirectory;
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h
index adf27dd39b..0752bc0cbc 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.h
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h
@@ -114,8 +114,6 @@ public:
bool createNew(const QString &contents);
bool open(QString *errorString, const QString &fileName, const QString &realFileName);
Core::IDocument *document();
- QString displayName() const;
- void setDisplayName(const QString &title);
Core::Id id() const;
bool isTemporary() const { return true; }