From 3c552e13a13e2ca2d4aee8c2c6b307ec2b573fcd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 12 May 2011 19:59:09 +0200 Subject: [PATCH] de-duplicate code a bit --- src/plugins/coreplugin/editormanager/openeditorsmodel.cpp | 14 ++++++-------- src/plugins/coreplugin/editormanager/openeditorsmodel.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp index dbffb71d46..d205e3d8b3 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp @@ -196,18 +196,16 @@ int OpenEditorsModel::findFileName(const QString &filename) const void OpenEditorsModel::removeEditor(IEditor *editor) { d->m_duplicateEditors.removeAll(editor); - int idx = findEditor(editor); - if (idx < 0) - return; - beginRemoveRows(QModelIndex(), idx, idx); - d->m_editors.removeAt(idx); - endRemoveRows(); - disconnect(editor, SIGNAL(changed()), this, SLOT(itemChanged())); + removeEditor(findEditor(editor)); } void OpenEditorsModel::removeEditor(const QModelIndex &index) { - int idx = index.row(); + removeEditor(index.row()); +} + +void OpenEditorsModel::removeEditor(int idx) +{ if (idx < 0) return; IEditor *editor= d->m_editors.at(idx).editor; diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.h b/src/plugins/coreplugin/editormanager/openeditorsmodel.h index 62e0928ae9..ab9b14b5ea 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsmodel.h +++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.h @@ -103,6 +103,7 @@ private: void addEntry(const Entry &entry); int findEditor(IEditor *editor) const; int findFileName(const QString &filename) const; + void removeEditor(int idx); QScopedPointer d; }; -- 2.11.0