QML:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
property var rows_array: [{ str_hwnd: "", hwnd: QtObject, lv_row_index: 0, arrf_file_path: "", arrf_3dview_name: "", arrf_site_name: "", arrf_output_file_name: "", arrf_json_path: "", arrf_should_be_exported: true }]; ListView { id: lvMain; enabled: items_enabled; objectName: "o_lvMain"; anchors.top: borderRect.top; anchors.margins: 10; anchors.left: parent.left; height: 500; width: 780; clip: true; /* Чтобы динамически создаваемые контролы не вылезали за пределы ListView */ ScrollBar.vertical: vBar; delegate: Column { id: horizontalColumn; objectName: "summaryDelegate"; Row { id: horizontalRow; objectName: "horizontalRow"; property bool shouldExport: true; /* Значение меняется ф-циями add_row_from_cpp и add_row_w_subrows_from_cpp */ CheckBox { id: cbShouldBeExported; objectName: "cbShouldBeExported_" + index; ToolTip.text: "Выгружать файл - да/нет"; ToolTip.visible: hovered; height: 17; width: 17; checked: shouldExport; onClicked: { if (cbShouldBeExported.checked){ var checkedFilePath = listModel.get(index).path; for(var i = 0; i < rows_array.length; i++) { if(rows_array[i].arrf_file_path === checkedFilePath) { rows_array[i].arrf_should_be_exported = true; } } listModel.get(index).shouldExport = true; } else { var uncheckedFilePath = listModel.get(index).path; for(var i = 0; i < rows_array.length; i++) { if(rows_array[i].arrf_file_path === uncheckedFilePath) { rows_array[i].arrf_should_be_exported = false; } } listModel.get(index).shouldExport = false; } } } /* Uses black magic to hunt for the delegate instance with the given * index. Returns undefined if there's no currently instantiated * delegate with that index. */ function add_subrow(index: int, _3dview_Text: string, site_Text: string, fNameText: string, JSON_text: string){ var i = 0; for(var x = 0; x < contentItem.children.length; ++x) { var item = contentItem.children[x]; // We have to check for the specific objectName we gave our // delegates above, since we also get some items that are not // our delegates here. if (item.objectName === "summaryDelegate"){ if(i === index){ var cbExtract3D_0 = item.children[0].children[3]; cbExtract3D_0.cbProp_3DViewText = _3dview_Text; cbExtract3D_0.cbProp_siteText = site_Text; cbExtract3D_0.cbProp_filenameText = fNameText; cbExtract3D_0.cbProp_jsonPathText = JSON_text; cbExtract3D_0.trashcanVisible = 1; cbExtract3D_0.clicked(); /* Чистим, т.к. иначе текст запоминается в properties контрола и потом дублируется */ cbExtract3D_0.trashcanVisible = 0; cbExtract3D_0.cbProp_3DViewText = ""; cbExtract3D_0.cbProp_siteText = ""; cbExtract3D_0.cbProp_filenameText = ""; cbExtract3D_0.cbProp_jsonPathText = ""; } ++i; } } return undefined; } |
->stackoverflow.com/9039497
