forked from qt-creator/qt-creator
Python: Use new ListModel convenience functions for interpreter model
Change-Id: I98cbfd255fe35a9a9dd23f6c09c472c505ed271e Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -123,9 +123,7 @@ InterpreterOptionsWidget::InterpreterOptionsWidget(const QList<Interpreter> &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())
|
||||
|
Reference in New Issue
Block a user