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 {};
|
return {};
|
||||||
});
|
});
|
||||||
|
m_model.setAllData(interpreters);
|
||||||
for (const Interpreter &interpreter : interpreters)
|
|
||||||
m_model.appendItem(interpreter);
|
|
||||||
|
|
||||||
auto mainLayout = new QVBoxLayout();
|
auto mainLayout = new QVBoxLayout();
|
||||||
auto layout = new QHBoxLayout();
|
auto layout = new QHBoxLayout();
|
||||||
@@ -308,11 +306,9 @@ void InterpreterOptionsWidget::makeDefault()
|
|||||||
{
|
{
|
||||||
const QModelIndex &index = m_view.currentIndex();
|
const QModelIndex &index = m_view.currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
QModelIndex defaultIndex;
|
QModelIndex defaultIndex = m_model.findIndex([this](const Interpreter &interpreter) {
|
||||||
if (auto *defaultItem = m_model.findItemByData(
|
return interpreter.id == m_defaultId;
|
||||||
[this](const Interpreter &interpreter) { return interpreter.id == m_defaultId; })) {
|
});
|
||||||
defaultIndex = m_model.indexForItem(defaultItem);
|
|
||||||
}
|
|
||||||
m_defaultId = m_model.itemAt(index.row())->itemData.id;
|
m_defaultId = m_model.itemAt(index.row())->itemData.id;
|
||||||
emit m_model.dataChanged(index, index, {Qt::FontRole});
|
emit m_model.dataChanged(index, index, {Qt::FontRole});
|
||||||
if (defaultIndex.isValid())
|
if (defaultIndex.isValid())
|
||||||
|
Reference in New Issue
Block a user