From be9dfc8c913525e5b636d1693e8a14a45d021f17 Mon Sep 17 00:00:00 2001 From: con Date: Mon, 8 Dec 2008 17:47:54 +0100 Subject: [PATCH] Fixes: - Show or "); + else + return tr(""); + default: + return QVariant(); + } //switch + } + switch (role) { case Qt::DisplayRole: { Symbol *symbol = static_cast(index.internalPointer()); diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 8567f81d751..ff68bd0bac2 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -203,9 +203,7 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable) m_methodCombo->setMaxVisibleItems(20); m_overviewModel = new OverviewModel(this); - m_noSymbolsModel = new QStringListModel(this); - m_noSymbolsModel->setStringList(QStringList() << tr("")); - m_methodCombo->setModel(m_noSymbolsModel); + m_methodCombo->setModel(m_overviewModel); connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex())); @@ -318,16 +316,9 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc) return; m_overviewModel->rebuild(doc); - if (m_overviewModel->rowCount() > 0) { - if (m_methodCombo->model() != m_overviewModel) - m_methodCombo->setModel(m_overviewModel); - OverviewTreeView *treeView = static_cast(m_methodCombo->view()); - treeView->sync(); - updateMethodBoxIndex(); - } else { - if (m_methodCombo->model() != m_noSymbolsModel) - m_methodCombo->setModel(m_noSymbolsModel); - } + OverviewTreeView *treeView = static_cast(m_methodCombo->view()); + treeView->sync(); + updateMethodBoxIndex(); } void CPPEditor::updateFileName() @@ -335,8 +326,6 @@ void CPPEditor::updateFileName() void CPPEditor::jumpToMethod(int) { - if (m_methodCombo->model() != m_overviewModel) - return; QModelIndex index = m_methodCombo->view()->currentIndex(); Symbol *symbol = m_overviewModel->symbolFromIndex(index); if (! symbol) @@ -351,8 +340,6 @@ void CPPEditor::jumpToMethod(int) void CPPEditor::updateMethodBoxIndex() { - if (m_methodCombo->model() != m_overviewModel) - return; int line = 0, column = 0; convertPosition(position(), &line, &column); @@ -362,7 +349,7 @@ void CPPEditor::updateMethodBoxIndex() for (int row = 0; row < rc; ++row) { const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex()); Symbol *symbol = m_overviewModel->symbolFromIndex(index); - if (symbol->line() > unsigned(line)) + if (symbol && symbol->line() > unsigned(line)) break; lastIndex = index; } diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h index 33745eddef2..05f2c5d9c74 100644 --- a/src/plugins/cppeditor/cppeditor.h +++ b/src/plugins/cppeditor/cppeditor.h @@ -139,7 +139,6 @@ private: QList m_contexts; QComboBox *m_methodCombo; CPlusPlus::OverviewModel *m_overviewModel; - QStringListModel *m_noSymbolsModel; }; } // namespace Internal