From e8b95f63497fe1f86da836990f08b6dc230f83e7 Mon Sep 17 00:00:00 2001 From: mae <qt-info@nokia.com> Date: Tue, 9 Jun 2009 19:33:33 +0200 Subject: [PATCH] more editor manager cleanup --- .../coreplugin/editormanager/editorview.cpp | 49 +++---------------- .../coreplugin/editormanager/editorview.h | 4 -- .../editormanager/openeditorsview.cpp | 2 +- 3 files changed, 7 insertions(+), 48 deletions(-) diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 592cddb776e..4b84abe8dac 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -321,42 +321,6 @@ void EditorModel::itemChanged() } -class EditorProxyModel : public QSortFilterProxyModel -{ - EditorView *m_view; - EditorModel *m_model; -public: - EditorProxyModel(EditorModel *source, EditorView *view) - : QSortFilterProxyModel(view), m_view(view), m_model(source) { - setSourceModel(source); - - } - - QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const - { - QVariant variant = QSortFilterProxyModel::data(proxyIndex, role); - if (role == Qt::FontRole) { - if (IEditor *editor = m_model->editorAt(proxyIndex.row()) ) { - if (m_view->hasEditor(editor)) { - QFont font = m_view->font(); - font.setBold(true); - return font; - } - foreach (IEditor *duplicate, m_model->duplicatesFor(editor)) { - if (duplicate&& m_view->hasEditor(duplicate)) { - QFont font = m_view->font(); - font.setBold(true); - return font; - } - } - } - } - return QSortFilterProxyModel::data(proxyIndex, role); - } - -}; - - //================EditorView==================== @@ -378,15 +342,13 @@ EditorView::EditorView(EditorModel *model, QWidget *parent) : tl->setSpacing(0); tl->setMargin(0); { - QAbstractItemModel *itemModel = m_model; - if (!itemModel) { + if (!m_model) { m_model = CoreImpl::instance()->editorManager()->openedEditorsModel(); - itemModel = new EditorProxyModel(m_model, this); } m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_editorList->setMinimumContentsLength(20); - m_editorList->setModel(itemModel); + m_editorList->setModel(m_model); m_editorList->setMaxVisibleItems(40); QToolBar *editorListToolBar = new QToolBar; @@ -601,8 +563,8 @@ void EditorView::removeEditor(IEditor *editor) toolBar->setVisible(false); toolBar->setParent(0); } - if (wasCurrent && m_editors.count()) - setCurrentEditor(m_editors.last()); + if (wasCurrent) + setCurrentEditor(m_editors.count() ? m_editors.last() : 0); } IEditor *EditorView::currentEditor() const @@ -615,9 +577,10 @@ IEditor *EditorView::currentEditor() const void EditorView::setCurrentEditor(IEditor *editor) { if (!editor || m_container->count() <= 0 - || m_container->indexOf(editor->widget()) == -1) + || m_container->indexOf(editor->widget()) == -1) { // ### TODO the combo box m_editorList should show an empty item return; + } m_editors.removeAll(editor); m_editors.append(editor); diff --git a/src/plugins/coreplugin/editormanager/editorview.h b/src/plugins/coreplugin/editormanager/editorview.h index 06773cf535d..32026d0f413 100644 --- a/src/plugins/coreplugin/editormanager/editorview.h +++ b/src/plugins/coreplugin/editormanager/editorview.h @@ -114,7 +114,6 @@ private: }; - class EditorView : public QWidget { Q_OBJECT @@ -175,7 +174,6 @@ private: QFrame *m_statusWidget; QLabel *m_statusWidgetLabel; QToolButton *m_statusWidgetButton; - QSortFilterProxyModel m_proxyModel; QList<IEditor *> m_editors; QMap<QWidget *, IEditor *> m_widgetEditorMap; }; @@ -233,8 +231,6 @@ private: QSplitter *m_splitter; }; - - } } #endif // EDITORVIEW_H diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp index 4ef00b59341..e63a3d28a12 100644 --- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp +++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp @@ -62,7 +62,6 @@ OpenEditorsDelegate::OpenEditorsDelegate(QObject *parent) void OpenEditorsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - if (option.state & QStyle::State_MouseOver) { if ((QApplication::mouseButtons() & Qt::LeftButton) == 0) pressedIndex = QModelIndex(); @@ -72,6 +71,7 @@ void OpenEditorsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o painter->fillRect(option.rect, brush); } + QStyledItemDelegate::paint(painter, option, index); if (index.column() == 1 && option.state & QStyle::State_MouseOver) { -- GitLab