OSDN Git Service

de-duplicate code a bit
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Thu, 12 May 2011 17:59:09 +0000 (19:59 +0200)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Thu, 12 May 2011 18:39:42 +0000 (20:39 +0200)
src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
src/plugins/coreplugin/editormanager/openeditorsmodel.h

index dbffb71..d205e3d 100644 (file)
@@ -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;
index 62e0928..ab9b14b 100644 (file)
@@ -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<OpenEditorsModelPrivate> d;
 };