Use ListModel.count instead of rowCount

The .count property properly updates when the model is changed.

Contributes to issue CURA-5876.
This commit is contained in:
Ghostkeeper 2018-12-03 11:13:26 +01:00
parent db05d7853a
commit f3af5a72ad
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
14 changed files with 49 additions and 36 deletions

View file

@ -1,5 +1,5 @@
// Copyright (c) 2016 Ultimaker B.V.
// Uranium is released under the terms of the LGPLv3 or higher.
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.0
@ -31,12 +31,15 @@ SettingItem
{
forceActiveFocus();
propertyProvider.setPropertyValue("value", model.getItem(index).index);
} else
}
else
{
if (propertyProvider.properties.value == -1)
{
control.currentIndex = model.rowCount() - 1; // we know the last item is "Not overriden"
} else {
control.currentIndex = model.count - 1; // we know the last item is "Not overriden"
}
else
{
control.currentIndex = propertyProvider.properties.value; // revert to the old value
}
}