mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-26 12:21:26 -07:00
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:
parent
db05d7853a
commit
f3af5a72ad
14 changed files with 49 additions and 36 deletions
|
|
@ -21,8 +21,10 @@ UM.ManagementPage
|
|||
|
||||
function activeMachineIndex()
|
||||
{
|
||||
for(var i = 0; i < model.rowCount(); i++) {
|
||||
if (model.getItem(i).id == Cura.MachineManager.activeMachineId) {
|
||||
for(var i = 0; i < model.count; i++)
|
||||
{
|
||||
if (model.getItem(i).id == Cura.MachineManager.activeMachineId)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +49,7 @@ UM.ManagementPage
|
|||
{
|
||||
text: catalog.i18nc("@action:button", "Remove");
|
||||
iconName: "list-remove";
|
||||
enabled: base.currentItem != null && model.rowCount() > 1
|
||||
enabled: base.currentItem != null && model.count > 1
|
||||
onClicked: confirmDialog.open();
|
||||
},
|
||||
Button
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Item
|
|||
var currentItemId = base.currentItem == null ? "" : base.currentItem.root_material_id
|
||||
search_root_id = currentItemId
|
||||
}
|
||||
for (var material_idx = 0; material_idx < genericMaterialsModel.rowCount(); material_idx++)
|
||||
for (var material_idx = 0; material_idx < genericMaterialsModel.count; material_idx++)
|
||||
{
|
||||
var material = genericMaterialsModel.getItem(material_idx)
|
||||
if (material.root_material_id == search_root_id)
|
||||
|
|
@ -72,15 +72,15 @@ Item
|
|||
return true
|
||||
}
|
||||
}
|
||||
for (var brand_idx = 0; brand_idx < materialsModel.rowCount(); brand_idx++)
|
||||
for (var brand_idx = 0; brand_idx < materialsModel.count; brand_idx++)
|
||||
{
|
||||
var brand = materialsModel.getItem(brand_idx)
|
||||
var types_model = brand.material_types
|
||||
for (var type_idx = 0; type_idx < types_model.rowCount(); type_idx++)
|
||||
for (var type_idx = 0; type_idx < types_model.count; type_idx++)
|
||||
{
|
||||
var type = types_model.getItem(type_idx)
|
||||
var colors_model = type.colors
|
||||
for (var material_idx = 0; material_idx < colors_model.rowCount(); material_idx++)
|
||||
for (var material_idx = 0; material_idx < colors_model.count; material_idx++)
|
||||
{
|
||||
var material = colors_model.getItem(material_idx)
|
||||
if (material.root_material_id == search_root_id)
|
||||
|
|
|
|||
|
|
@ -188,21 +188,27 @@ Item
|
|||
Connections
|
||||
{
|
||||
target: qualitiesModel
|
||||
onItemsChanged: {
|
||||
onItemsChanged:
|
||||
{
|
||||
var toSelectItemName = base.currentItem == null ? "" : base.currentItem.name;
|
||||
if (newQualityNameToSelect != "") {
|
||||
if (newQualityNameToSelect != "")
|
||||
{
|
||||
toSelectItemName = newQualityNameToSelect;
|
||||
}
|
||||
|
||||
var newIdx = -1; // Default to nothing if nothing can be found
|
||||
if (toSelectItemName != "") {
|
||||
if (toSelectItemName != "")
|
||||
{
|
||||
// Select the required quality name if given
|
||||
for (var idx = 0; idx < qualitiesModel.rowCount(); ++idx) {
|
||||
for (var idx = 0; idx < qualitiesModel.count; ++idx)
|
||||
{
|
||||
var item = qualitiesModel.getItem(idx);
|
||||
if (item.name == toSelectItemName) {
|
||||
if (item.name == toSelectItemName)
|
||||
{
|
||||
// Switch to the newly created profile if needed
|
||||
newIdx = idx;
|
||||
if (base.toActivateNewQuality) {
|
||||
if (base.toActivateNewQuality)
|
||||
{
|
||||
// Activate this custom quality if required
|
||||
Cura.MachineManager.setQualityChangesGroup(item.quality_changes_group);
|
||||
}
|
||||
|
|
@ -382,9 +388,11 @@ Item
|
|||
var selectedItemName = Cura.MachineManager.activeQualityOrQualityChangesName;
|
||||
|
||||
// Select the required quality name if given
|
||||
for (var idx = 0; idx < qualitiesModel.rowCount(); idx++) {
|
||||
for (var idx = 0; idx < qualitiesModel.count; idx++)
|
||||
{
|
||||
var item = qualitiesModel.getItem(idx);
|
||||
if (item.name == selectedItemName) {
|
||||
if (item.name == selectedItemName)
|
||||
{
|
||||
currentIndex = idx;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ UM.PreferencesPage
|
|||
{
|
||||
return Qt.Unchecked
|
||||
}
|
||||
else if(definitionsModel.visibleCount == definitionsModel.rowCount(null))
|
||||
else if(definitionsModel.visibleCount == definitionsModel.count)
|
||||
{
|
||||
return Qt.Checked
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue