From b2f06b7695bfefd87989719fbfbe7269c0ff723f Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 20 May 2020 08:16:19 +0200 Subject: [PATCH] Python: Use new ListModel convenience functions for interpreter model Change-Id: I98cbfd255fe35a9a9dd23f6c09c472c505ed271e Reviewed-by: David Schulz --- src/plugins/python/pythonsettings.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index cc497e9e145..e45ff9d5e5f 100644 --- a/src/plugins/python/pythonsettings.cpp +++ b/src/plugins/python/pythonsettings.cpp @@ -123,9 +123,7 @@ InterpreterOptionsWidget::InterpreterOptionsWidget(const QList &int } return {}; }); - - for (const Interpreter &interpreter : interpreters) - m_model.appendItem(interpreter); + m_model.setAllData(interpreters); auto mainLayout = new QVBoxLayout(); auto layout = new QHBoxLayout(); @@ -308,11 +306,9 @@ void InterpreterOptionsWidget::makeDefault() { const QModelIndex &index = m_view.currentIndex(); if (index.isValid()) { - QModelIndex defaultIndex; - if (auto *defaultItem = m_model.findItemByData( - [this](const Interpreter &interpreter) { return interpreter.id == m_defaultId; })) { - defaultIndex = m_model.indexForItem(defaultItem); - } + QModelIndex defaultIndex = m_model.findIndex([this](const Interpreter &interpreter) { + return interpreter.id == m_defaultId; + }); m_defaultId = m_model.itemAt(index.row())->itemData.id; emit m_model.dataChanged(index, index, {Qt::FontRole}); if (defaultIndex.isValid())