Commit ff2afcab authored by con's avatar con

Sort method combo box alphabetically.

Patch received by Kris Wong.
parent 5c9778e7
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
#include <QtGui/QTextEdit> #include <QtGui/QTextEdit>
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QSortFilterProxyModel>
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor::Internal; using namespace CppEditor::Internal;
...@@ -239,11 +240,17 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable) ...@@ -239,11 +240,17 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
QTreeView *methodView = new OverviewTreeView; QTreeView *methodView = new OverviewTreeView;
methodView->header()->hide(); methodView->header()->hide();
methodView->setItemsExpandable(false); methodView->setItemsExpandable(false);
methodView->setSortingEnabled(true);
methodView->sortByColumn(0, Qt::AscendingOrder);
m_methodCombo->setView(methodView); m_methodCombo->setView(methodView);
m_methodCombo->setMaxVisibleItems(20); m_methodCombo->setMaxVisibleItems(20);
m_overviewModel = new OverviewModel(this); m_overviewModel = new OverviewModel(this);
m_methodCombo->setModel(m_overviewModel); m_proxyModel = new QSortFilterProxyModel(this);
m_proxyModel->setSourceModel(m_overviewModel);
m_proxyModel->setDynamicSortFilter(true);
m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
m_methodCombo->setModel(m_proxyModel);
connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int))); connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex()));
...@@ -366,7 +373,7 @@ void CPPEditor::updateFileName() ...@@ -366,7 +373,7 @@ void CPPEditor::updateFileName()
void CPPEditor::jumpToMethod(int) void CPPEditor::jumpToMethod(int)
{ {
QModelIndex index = m_methodCombo->view()->currentIndex(); QModelIndex index = m_proxyModel->mapToSource(m_methodCombo->view()->currentIndex());
Symbol *symbol = m_overviewModel->symbolFromIndex(index); Symbol *symbol = m_overviewModel->symbolFromIndex(index);
if (! symbol) if (! symbol)
return; return;
...@@ -394,7 +401,7 @@ void CPPEditor::updateMethodBoxIndex() ...@@ -394,7 +401,7 @@ void CPPEditor::updateMethodBoxIndex()
if (lastIndex.isValid()) { if (lastIndex.isValid()) {
bool blocked = m_methodCombo->blockSignals(true); bool blocked = m_methodCombo->blockSignals(true);
m_methodCombo->setCurrentIndex(lastIndex.row()); m_methodCombo->setCurrentIndex(m_proxyModel->mapFromSource(lastIndex).row());
updateMethodBoxToolTip(); updateMethodBoxToolTip();
(void) m_methodCombo->blockSignals(blocked); (void) m_methodCombo->blockSignals(blocked);
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QComboBox; class QComboBox;
class QSortFilterProxyModel;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace CPlusPlus { namespace CPlusPlus {
...@@ -161,6 +162,7 @@ private: ...@@ -161,6 +162,7 @@ private:
QList<int> m_contexts; QList<int> m_contexts;
QComboBox *m_methodCombo; QComboBox *m_methodCombo;
CPlusPlus::OverviewModel *m_overviewModel; CPlusPlus::OverviewModel *m_overviewModel;
QSortFilterProxyModel *m_proxyModel;
}; };
} // namespace Internal } // namespace Internal
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment