From 7fb445a5cbfb24a7846270ef8da63362c6b6f84d Mon Sep 17 00:00:00 2001 From: Marek Wieckowski Date: Wed, 9 Jun 2010 09:11:30 +0200 Subject: designer: add sorting in signal-slot editor window Reviewed-by: Friedemann Kleint --- .../src/components/signalsloteditor/signalsloteditorwindow.cpp | 10 +++++++--- .../src/components/signalsloteditor/signalsloteditorwindow.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp index a25bd5d..5547761 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -712,9 +713,12 @@ SignalSlotEditorWindow::SignalSlotEditorWindow(QDesignerFormEditorInterface *cor m_remove_button(new QToolButton), m_core(core), m_model(new ConnectionModel(this)), + m_proxy_model(new QSortFilterProxyModel(this)), m_handling_selection_change(false) { - m_view->setModel(m_model); + m_proxy_model->setSourceModel(m_model); + m_view->setModel(m_proxy_model); + m_view->setSortingEnabled(true); m_view->setItemDelegate(new ConnectionDelegate(this)); m_view->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed); @@ -790,7 +794,7 @@ void SignalSlotEditorWindow::updateDialogSelection(Connection *con) if (m_handling_selection_change || m_editor == 0) return; - QModelIndex index = m_model->connectionToIndex(con); + QModelIndex index = m_proxy_model->mapFromSource(m_model->connectionToIndex(con)); if (index == m_view->currentIndex()) return; m_handling_selection_change = true; @@ -808,7 +812,7 @@ void SignalSlotEditorWindow::updateEditorSelection(const QModelIndex &index) if (m_editor == 0) return; - Connection *con = m_model->indexToConnection(index); + Connection *con = m_model->indexToConnection(m_proxy_model->mapToSource(index)); if (m_editor->selected(con)) return; m_handling_selection_change = true; diff --git a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.h b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.h index 9315955..665f0b7 100644 --- a/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.h +++ b/tools/designer/src/components/signalsloteditor/signalsloteditorwindow.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QDesignerFormWindowInterface; class QDesignerFormEditorInterface; class QModelIndex; +class QSortFilterProxyModel; class QTreeView; class QToolButton; @@ -84,6 +85,7 @@ private: QToolButton *m_add_button, *m_remove_button; QDesignerFormEditorInterface *m_core; ConnectionModel *m_model; + QSortFilterProxyModel *m_proxy_model; bool m_handling_selection_change; }; -- cgit v0.12